{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cavemio-notification-inbox",
  "title": "Notification inbox",
  "description": "The bell, done properly: its own circle grows into the inbox, new notifications swing it and roll the count, and read ones fold out of Unread.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/components/notification-inbox.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Archive, Bell, X } from \"lucide-react\";\nimport { NumberRoll } from \"./number-roll\";\nimport { RelativeTime, toTime, type DateLike } from \"./relative-time\";\nimport { StatusButton, type ActionStatus } from \"./status-button\";\nimport { TextMorph } from \"./text-morph\";\nimport { useRowMotion } from \"./use-row-motion\";\n\n/* ─────────────────────────────────────────────────────────\n * NOTIFICATION INBOX: the bell, done properly\n *\n *   arrive    a new notification rings the bell (a short swing\n *             from its top) and the count rolls; if the inbox is\n *             open it fades in on top while the rest glide down\n *   open      the bell's own circle grows into the inbox: size\n *             and corners ease, the bell fades into the list,\n *             and it folds back the same way\n *   tabs      Unread / All, the highlight sliding between them;\n *             Unread counts as you go\n *   read      opening a notification reads it; the dot shrinks,\n *             the title settles to grey, and in Unread the row\n *             folds away a moment later. Mark all read does\n *             them together\n *   archive   the row folds away and the rest glide up\n *   empty     \"You're all caught up\", with a drawn check\n *\n * Items are plain records; subscribe() feeds new ones from\n * Knock, Novu, Supabase Realtime or your own stream.\n * ───────────────────────────────────────────────────────── */\n\nexport type { DateLike };\n\nexport interface InboxItem {\n  id: string;\n  title: string;\n  body?: string;\n  at: DateLike;\n  read?: boolean;\n  actor?: { name: string; image?: string };\n  /** Where opening it goes. */\n  href?: string;\n}\n\nexport interface NotificationInboxProps extends Omit<\n  React.HTMLAttributes<HTMLDivElement>,\n  \"defaultValue\" | \"onChange\"\n> {\n  value?: InboxItem[];\n  defaultValue?: InboxItem[];\n  onValueChange?: (items: InboxItem[]) => void;\n  /** Feeds new notifications: call push with one or many; return a function that stops it. */\n  subscribe?: (push: (items: InboxItem | InboxItem[]) => void) => () => void;\n  /** Saves read state. Throw to put it back. */\n  onRead?: (ids: string[], read: boolean) => Promise<unknown> | unknown;\n  onArchive?: (ids: string[]) => Promise<unknown> | unknown;\n  /** Called when a notification is opened (after it's marked read). */\n  onOpen?: (item: InboxItem) => void;\n  /** Older notifications, newest first; an empty list means there are no more. */\n  loadMore?: (before: InboxItem) => Promise<InboxItem[]>;\n  /** Which edge of the bell the inbox lines up with. */\n  align?: \"end\" | \"start\";\n  label?: string;\n  defaultOpen?: boolean;\n}\n\ntype Phase = \"closed\" | \"opening\" | \"open\" | \"closing\";\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst DURATION = 460;\nconst WIDTH = 384;\nconst FOCUS =\n  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40\";\nconst NONE: InboxItem[] = [];\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\nconst DAY = 86_400_000;\nconst groupOf = (at: DateLike) => {\n  const t = new Date(toTime(at));\n  const today = new Date();\n  today.setHours(0, 0, 0, 0);\n  const start = today.getTime();\n  return t.getTime() >= start\n    ? \"Today\"\n    : t.getTime() >= start - DAY\n      ? \"Yesterday\"\n      : \"Earlier\";\n};\n\nfunction Avatar({ item }: { item: InboxItem }) {\n  if (item.actor?.image)\n    return (\n      <img\n        src={item.actor.image}\n        alt=\"\"\n        className=\"size-7 shrink-0 rounded-full object-cover shadow-[0_0_0_1px_var(--border)]\"\n      />\n    );\n  const letters = (item.actor?.name ?? \"•\")\n    .split(/\\s+/)\n    .slice(0, 2)\n    .map((w) => w[0]?.toUpperCase())\n    .join(\"\");\n  return (\n    <span\n      aria-hidden=\"true\"\n      className=\"grid size-7 shrink-0 place-items-center rounded-full bg-muted text-[10.5px] font-medium text-muted-foreground shadow-[inset_0_0_0_1px_var(--border)]\"\n    >\n      {letters}\n    </span>\n  );\n}\n\ninterface RowProps {\n  item: InboxItem;\n  reduced: boolean;\n  canArchive: boolean;\n  act: React.RefObject<{\n    open: (i: InboxItem) => void;\n    read: (i: InboxItem, read: boolean) => void;\n    archive: (i: InboxItem) => void;\n  }>;\n}\n\nconst Row = React.memo(function Row({\n  item,\n  reduced,\n  canArchive,\n  act,\n}: RowProps) {\n  const unread = !item.read;\n  const Body = item.href ? \"a\" : \"button\";\n  return (\n    <li data-row-id={item.id} className=\"group relative\">\n      <Body\n        {...(item.href ? { href: item.href } : { type: \"button\" as const })}\n        onClick={() => act.current.open(item)}\n        className={`flex w-full cursor-pointer items-start gap-3 rounded-[12px] px-3 py-2.5 pr-16 text-left transition-colors hover:bg-accent/60 ${FOCUS}`}\n      >\n        <span className=\"relative mt-0.5\">\n          <Avatar item={item} />\n        </span>\n        <span className=\"min-w-0 flex-1\">\n          <span\n            className={`block text-[13px] leading-[1.4] transition-colors duration-500 ${unread ? \"font-medium text-foreground\" : \"text-muted-foreground\"}`}\n          >\n            {item.title}\n            <span className=\"sr-only\">{unread ? \", unread\" : \"\"}</span>\n          </span>\n          {item.body && (\n            <span className=\"mt-0.5 line-clamp-2 block text-[12px] leading-[1.45] text-muted-foreground\">\n              {item.body}\n            </span>\n          )}\n          <span className=\"mt-1 block text-[11px] text-muted-foreground\">\n            <RelativeTime date={item.at} />\n          </span>\n        </span>\n      </Body>\n      {/* The unread dot doubles as the read / unread toggle; archive sits beside it. */}\n      <span className=\"absolute top-2.5 right-2 flex items-center gap-0.5\">\n        {canArchive && (\n          <button\n            type=\"button\"\n            aria-label={`Archive “${item.title}”`}\n            onClick={() => act.current.archive(item)}\n            className={`grid size-7 cursor-pointer place-items-center rounded-full text-muted-foreground opacity-0 transition-[opacity,background-color,color] group-focus-within:opacity-100 group-hover:opacity-100 hover:bg-accent hover:text-foreground [@media(pointer:coarse)]:opacity-100 ${FOCUS}`}\n          >\n            <Archive\n              className=\"size-3.5\"\n              strokeWidth={1.75}\n              aria-hidden=\"true\"\n            />\n          </button>\n        )}\n        <button\n          type=\"button\"\n          aria-label={\n            unread ? `Mark “${item.title}” read` : `Mark “${item.title}” unread`\n          }\n          aria-pressed={!unread}\n          onClick={() => act.current.read(item, unread)}\n          className={`grid size-7 cursor-pointer place-items-center rounded-full transition-colors hover:bg-accent ${FOCUS}`}\n        >\n          <span\n            aria-hidden=\"true\"\n            className={`size-2 rounded-full transition-[transform,background-color,box-shadow] ${unread ? \"bg-primary\" : \"bg-transparent shadow-[inset_0_0_0_1px_var(--border)] group-hover:shadow-[inset_0_0_0_1px_var(--muted-foreground)]\"}`}\n            style={{\n              transform: unread ? \"scale(1)\" : \"scale(0.8)\",\n              transitionDuration: reduced ? \"0ms\" : \"420ms\",\n              transitionTimingFunction: EASE,\n            }}\n          />\n        </button>\n      </span>\n    </li>\n  );\n});\n\nexport function NotificationInbox({\n  value,\n  defaultValue = NONE,\n  onValueChange,\n  subscribe,\n  onRead,\n  onArchive,\n  onOpen,\n  loadMore,\n  align = \"end\",\n  label = \"Inbox\",\n  defaultOpen = false,\n  className = \"\",\n  ...props\n}: NotificationInboxProps) {\n  const reduced = useReducedMotion();\n  const id = React.useId();\n  const [inner, setInner] = React.useState(defaultValue);\n  const items = value ?? inner;\n  const [phase, setPhase] = React.useState<Phase>(\n    defaultOpen ? \"open\" : \"closed\",\n  );\n  const [tab, setTab] = React.useState<\"unread\" | \"all\">(\"unread\");\n  const [leaving, setLeaving] = React.useState<string[]>([]);\n  const [markAll, setMarkAll] = React.useState<ActionStatus>(\"idle\");\n  const [loading, setLoading] = React.useState(false);\n  const [noMore, setNoMore] = React.useState(!loadMore);\n  const [panelHeight, setPanelHeight] = React.useState(0);\n  const [fit, setFit] = React.useState({ width: WIDTH, shift: 0 });\n  const [announce, setAnnounce] = React.useState(\"\");\n  const [bar, setBar] = React.useState({ left: 0, width: 0, ready: false });\n  const wrapRef = React.useRef<HTMLDivElement>(null);\n  const bellRef = React.useRef<HTMLButtonElement>(null);\n  const iconRef = React.useRef<HTMLSpanElement>(null);\n  const panelRef = React.useRef<HTMLDivElement>(null);\n  const listRef = React.useRef<HTMLUListElement>(null);\n  const ghostRef = React.useRef<HTMLDivElement>(null);\n  const tabRefs = React.useRef<Record<string, HTMLButtonElement | null>>({});\n  const timer = React.useRef(0);\n  const latest = React.useRef(items);\n  React.useLayoutEffect(() => {\n    latest.current = items;\n  });\n  const expanded = phase === \"open\";\n  const mounted = phase !== \"closed\";\n\n  const commit = React.useCallback(\n    (next: InboxItem[]) => {\n      if (value === undefined) setInner(next);\n      onValueChange?.(next);\n    },\n    [value, onValueChange],\n  );\n\n  const unreadCount = items.filter((i) => !i.read).length;\n  const shown = items.filter(\n    (i) => tab === \"all\" || !i.read || leaving.includes(i.id),\n  );\n  const rows: (\n    { kind: \"head\"; key: string } | { kind: \"item\"; item: InboxItem }\n  )[] = [];\n  let lastGroup = \"\";\n  for (const item of shown) {\n    const g = groupOf(item.at);\n    if (g !== lastGroup) rows.push({ kind: \"head\", key: `head-${g}` });\n    lastGroup = g;\n    rows.push({ kind: \"item\", item });\n  }\n  const ranks = new Map(\n    rows.map((r, i) => [r.kind === \"head\" ? r.key : r.item.id, i]),\n  );\n  useRowMotion(listRef, { reduced, ranks, ghosts: ghostRef, resetKey: tab });\n\n  // New notifications: the bell swings, the count rolls.\n  const ring = React.useCallback(() => {\n    if (reduced) return;\n    iconRef.current?.animate(\n      [\n        { transform: \"rotate(0deg)\" },\n        { transform: \"rotate(-16deg)\" },\n        { transform: \"rotate(13deg)\" },\n        { transform: \"rotate(-8deg)\" },\n        { transform: \"rotate(4deg)\" },\n        { transform: \"rotate(0deg)\" },\n      ],\n      { duration: 720, easing: \"ease-out\" },\n    );\n  }, [reduced]);\n\n  React.useEffect(() => {\n    if (!subscribe) return;\n    return subscribe((incoming) => {\n      const list = Array.isArray(incoming) ? incoming : [incoming];\n      const fresh = list.filter(\n        (n) => !latest.current.some((i) => i.id === n.id),\n      );\n      if (!fresh.length) return;\n      commit([...fresh, ...latest.current]);\n      ring();\n      setAnnounce(\n        fresh.length === 1\n          ? `New: ${fresh[0].title}`\n          : `${fresh.length} new notifications`,\n      );\n    });\n  }, [subscribe, commit, ring]);\n\n  const measureFit = () => {\n    const wrap = wrapRef.current;\n    if (!wrap) return;\n    const r = wrap.getBoundingClientRect();\n    const vw = document.documentElement.clientWidth;\n    const width = Math.min(WIDTH, vw - 24);\n    // Lined up with the bell's edge, nudged back on screen.\n    const shift =\n      align === \"end\"\n        ? Math.max(0, 12 - (r.right - width))\n        : Math.min(0, vw - 12 - (r.left + width));\n    setFit((f) =>\n      f.width === width && f.shift === shift ? f : { width, shift },\n    );\n  };\n\n  // Opened from the start: fit it to the screen before the first paint.\n  React.useLayoutEffect(() => {\n    if (defaultOpen) measureFit();\n  }, []);\n\n  const open = () => {\n    if (phase === \"open\" || phase === \"opening\") return;\n    window.clearTimeout(timer.current);\n    measureFit();\n    setPhase(reduced ? \"open\" : \"opening\");\n  };\n  const close = React.useCallback(\n    (refocus = true) => {\n      window.clearTimeout(timer.current);\n      if (refocus) bellRef.current?.focus({ preventScroll: true });\n      if (reduced) return setPhase(\"closed\");\n      setPhase(\"closing\");\n      timer.current = window.setTimeout(() => setPhase(\"closed\"), DURATION);\n    },\n    [reduced],\n  );\n\n  React.useEffect(() => {\n    if (phase !== \"opening\") return;\n    let inner = 0;\n    const outer = requestAnimationFrame(\n      () => (inner = requestAnimationFrame(() => setPhase(\"open\"))),\n    );\n    return () => {\n      cancelAnimationFrame(outer);\n      cancelAnimationFrame(inner);\n    };\n  }, [phase]);\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  React.useLayoutEffect(() => {\n    const panel = panelRef.current;\n    if (!panel) return;\n    const measure = () => setPanelHeight(panel.offsetHeight);\n    measure();\n    const observer = new ResizeObserver(measure);\n    observer.observe(panel);\n    return () => observer.disconnect();\n  }, [mounted]);\n\n  React.useLayoutEffect(() => {\n    const b = tabRefs.current[tab];\n    if (!b) return;\n    setBar((p) =>\n      p.left === b.offsetLeft && p.width === b.offsetWidth\n        ? p\n        : { left: b.offsetLeft, width: b.offsetWidth, ready: p.width > 0 },\n    );\n  }, [tab, mounted, unreadCount]);\n\n  React.useEffect(() => {\n    if (expanded) tabRefs.current[tab]?.focus({ preventScroll: true });\n  }, [expanded]);\n\n  React.useEffect(() => {\n    if (!expanded) return;\n    const onDown = (e: PointerEvent) => {\n      if (!wrapRef.current?.contains(e.target as Node)) close(false);\n    };\n    document.addEventListener(\"pointerdown\", onDown);\n    return () => document.removeEventListener(\"pointerdown\", onDown);\n  }, [expanded, close]);\n\n  const setRead = async (ids: string[], read: boolean) => {\n    const before = latest.current;\n    commit(before.map((i) => (ids.includes(i.id) ? { ...i, read } : i)));\n    if (read && tab === \"unread\") {\n      // Read rows stay a moment in Unread, then fold away.\n      setLeaving((l) => [...l, ...ids]);\n      window.setTimeout(\n        () => setLeaving((l) => l.filter((x) => !ids.includes(x))),\n        900,\n      );\n    }\n    try {\n      await onRead?.(ids, read);\n    } catch {\n      commit(\n        latest.current.map((i) =>\n          ids.includes(i.id) ? { ...i, read: !read } : i,\n        ),\n      );\n      setAnnounce(\"That change couldn't be saved.\");\n    }\n  };\n\n  const act = React.useRef<RowProps[\"act\"][\"current\"]>(null!);\n  React.useLayoutEffect(() => {\n    act.current = {\n      open: (item) => {\n        if (!item.read) setRead([item.id], true);\n        onOpen?.(item);\n      },\n      read: (item, read) => {\n        setRead([item.id], read);\n        setAnnounce(read ? \"Marked read.\" : \"Marked unread.\");\n      },\n      archive: async (item) => {\n        const before = latest.current;\n        commit(before.filter((i) => i.id !== item.id));\n        setAnnounce(\"Archived.\");\n        try {\n          await onArchive?.([item.id]);\n        } catch {\n          commit(\n            [item, ...latest.current].sort(\n              (a, b) => toTime(b.at) - toTime(a.at),\n            ),\n          );\n          setAnnounce(\"That couldn't be archived.\");\n        }\n      },\n    };\n  });\n\n  const readAll = async () => {\n    const ids = latest.current.filter((i) => !i.read).map((i) => i.id);\n    if (!ids.length) return;\n    setMarkAll(\"pending\");\n    try {\n      await setRead(ids, true);\n      setMarkAll(\"success\");\n      setAnnounce(\"All marked read.\");\n    } catch {\n      setMarkAll(\"error\");\n    }\n  };\n\n  const more = async () => {\n    const last = latest.current[latest.current.length - 1];\n    if (!loadMore || !last || loading) return;\n    setLoading(true);\n    try {\n      const older = await loadMore(last);\n      if (!older.length) setNoMore(true);\n      else\n        commit([\n          ...latest.current,\n          ...older.filter((o) => !latest.current.some((i) => i.id === o.id)),\n        ]);\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  const width = expanded ? fit.width : 36;\n  const height = expanded ? panelHeight : 36;\n  const empty = !shown.length;\n\n  return (\n    <div\n      ref={wrapRef}\n      className={`relative inline-flex ${className}`}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" && expanded) {\n          e.preventDefault();\n          close();\n        }\n      }}\n      {...props}\n    >\n      <button\n        ref={bellRef}\n        type=\"button\"\n        aria-label={`${label}${unreadCount ? `, ${unreadCount} unread` : \"\"}`}\n        aria-haspopup=\"dialog\"\n        aria-expanded={expanded}\n        aria-controls={mounted ? `${id}-panel` : undefined}\n        onClick={() => (expanded ? close() : open())}\n        className={`relative grid size-9 cursor-pointer place-items-center rounded-full text-foreground shadow-[inset_0_0_0_1px_var(--border)] transition-colors hover:bg-accent ${FOCUS}`}\n      >\n        <span ref={iconRef} className=\"grid origin-top place-items-center\">\n          <Bell className=\"size-4\" strokeWidth={1.75} aria-hidden=\"true\" />\n        </span>\n        <span\n          aria-hidden=\"true\"\n          className=\"absolute -top-1 -right-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-medium text-primary-foreground tabular-nums shadow-[0_0_0_2px_var(--background)]\"\n          // Hidden while the inbox is open: the count is in the Unread tab then.\n          style={{\n            transform: unreadCount && !mounted ? \"scale(1)\" : \"scale(0)\",\n            transition: reduced\n              ? \"none\"\n              : `transform 380ms ${unreadCount && !mounted ? \"cubic-bezier(0.34,1.36,0.64,1)\" : EASE}`,\n          }}\n        >\n          <NumberRoll value={Math.min(99, unreadCount || 1)} />\n        </span>\n      </button>\n\n      {mounted && (\n        <div\n          id={`${id}-panel`}\n          role=\"dialog\"\n          aria-label={label}\n          className=\"absolute top-0 z-40 overflow-hidden bg-popover text-popover-foreground\"\n          style={{\n            [align === \"end\" ? \"right\" : \"left\"]: expanded\n              ? align === \"end\"\n                ? -fit.shift\n                : fit.shift\n              : 0,\n            width,\n            height,\n            borderRadius: expanded ? 20 : 18,\n            boxShadow: \"inset 0 0 0 1px var(--border)\",\n            transition: reduced\n              ? \"none\"\n              : `width ${DURATION}ms ${EASE}, height ${DURATION}ms ${EASE}, right ${DURATION}ms ${EASE}, left ${DURATION}ms ${EASE}, border-radius ${DURATION}ms ${EASE}`,\n          }}\n        >\n          {/* The bell, fading as its circle grows into the inbox. */}\n          <span\n            aria-hidden=\"true\"\n            className={`pointer-events-none absolute top-0 grid size-9 place-items-center ${align === \"end\" ? \"right-0\" : \"left-0\"}`}\n            style={{\n              opacity: expanded ? 0 : 1,\n              transition: reduced\n                ? \"none\"\n                : `opacity ${expanded ? 140 : 260}ms ${EASE} ${expanded ? 0 : 140}ms`,\n            }}\n          >\n            <Bell className=\"size-4\" strokeWidth={1.75} />\n          </span>\n\n          <div\n            ref={panelRef}\n            inert={!expanded}\n            className={`absolute top-0 ${align === \"end\" ? \"right-0\" : \"left-0\"}`}\n            style={{\n              width: fit.width,\n              opacity: expanded ? 1 : 0,\n              transition: reduced\n                ? \"none\"\n                : `opacity ${expanded ? 280 : 120}ms ${EASE} ${expanded ? 100 : 0}ms`,\n            }}\n          >\n            <div className=\"flex items-center gap-2 px-3 pt-3 pb-2\">\n              <div\n                role=\"tablist\"\n                aria-label={label}\n                className=\"relative flex items-center gap-0.5\"\n              >\n                <span\n                  aria-hidden=\"true\"\n                  className=\"absolute top-0 left-0 h-7 rounded-full bg-accent shadow-[inset_0_0_0_1px_var(--border)]\"\n                  style={{\n                    width: bar.width,\n                    transform: `translateX(${bar.left}px)`,\n                    transition:\n                      bar.ready && !reduced\n                        ? `transform 360ms ${EASE}, width 360ms ${EASE}`\n                        : \"none\",\n                  }}\n                />\n                {([\"unread\", \"all\"] as const).map((t) => (\n                  <button\n                    key={t}\n                    ref={(el) => {\n                      tabRefs.current[t] = el;\n                    }}\n                    role=\"tab\"\n                    aria-selected={tab === t}\n                    tabIndex={tab === t ? 0 : -1}\n                    onClick={() => setTab(t)}\n                    onKeyDown={(e) => {\n                      if (e.key !== \"ArrowLeft\" && e.key !== \"ArrowRight\")\n                        return;\n                      e.preventDefault();\n                      const next = t === \"unread\" ? \"all\" : \"unread\";\n                      setTab(next);\n                      tabRefs.current[next]?.focus();\n                    }}\n                    className={`relative inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-full px-3 text-[12.5px] font-medium transition-colors ${FOCUS} ${tab === t ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\"}`}\n                  >\n                    {t === \"unread\" ? \"Unread\" : \"All\"}\n                    {t === \"unread\" && (\n                      <span className=\"text-[11.5px] font-normal text-muted-foreground tabular-nums\">\n                        <NumberRoll value={unreadCount} />\n                      </span>\n                    )}\n                  </button>\n                ))}\n              </div>\n              <span className=\"ml-auto\" />\n              {onRead && (\n                <StatusButton\n                  size=\"sm\"\n                  variant=\"ghost\"\n                  status={markAll}\n                  labels={{\n                    idle: \"Mark all read\",\n                    pending: \"Marking\",\n                    success: \"All read\",\n                    error: \"Try again\",\n                  }}\n                  onClick={readAll}\n                  onReset={() => setMarkAll(\"idle\")}\n                  aria-disabled={\n                    (!unreadCount && markAll === \"idle\") || undefined\n                  }\n                  className={\n                    !unreadCount && markAll === \"idle\"\n                      ? \"pointer-events-none opacity-40\"\n                      : \"\"\n                  }\n                />\n              )}\n              <button\n                type=\"button\"\n                aria-label={`Close ${label.toLowerCase()}`}\n                onClick={() => close()}\n                className={`grid size-7 shrink-0 cursor-pointer place-items-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground ${FOCUS}`}\n              >\n                <X className=\"size-3.5\" strokeWidth={1.75} aria-hidden=\"true\" />\n              </button>\n            </div>\n\n            <div\n              className=\"max-h-[min(26rem,calc(100dvh_-_10rem))] overflow-y-auto overscroll-contain px-1.5 pb-1.5\"\n              role=\"tabpanel\"\n            >\n              <div className=\"relative\">\n                <ul\n                  ref={listRef}\n                  aria-label={\n                    tab === \"unread\"\n                      ? \"Unread notifications\"\n                      : \"All notifications\"\n                  }\n                  className=\"relative\"\n                >\n                  {rows.map((r) =>\n                    r.kind === \"head\" ? (\n                      <li\n                        key={r.key}\n                        data-row-id={r.key}\n                        aria-hidden=\"true\"\n                        className=\"px-3 pt-2 pb-1 text-[11px] font-medium text-muted-foreground\"\n                      >\n                        {r.key.slice(5)}\n                      </li>\n                    ) : (\n                      <Row\n                        key={r.item.id}\n                        item={r.item}\n                        reduced={reduced}\n                        canArchive={Boolean(onArchive)}\n                        act={act}\n                      />\n                    ),\n                  )}\n                </ul>\n                <div\n                  ref={ghostRef}\n                  aria-hidden=\"true\"\n                  className=\"pointer-events-none absolute inset-0\"\n                />\n              </div>\n\n              <div\n                className=\"grid\"\n                style={{\n                  gridTemplateRows: empty ? \"1fr\" : \"0fr\",\n                  opacity: empty ? 1 : 0,\n                  transition: reduced\n                    ? \"none\"\n                    : `grid-template-rows 420ms ${EASE}, opacity 300ms ${EASE} ${empty ? 120 : 0}ms`,\n                }}\n              >\n                <div className=\"min-h-0 min-w-0 overflow-clip\">\n                  <div className=\"flex flex-col items-center gap-2 py-9 text-center\">\n                    <span className=\"grid size-9 place-items-center rounded-full text-emerald-600 shadow-[inset_0_0_0_1px_var(--border)] dark:text-emerald-400\">\n                      <svg\n                        viewBox=\"0 0 16 16\"\n                        fill=\"none\"\n                        aria-hidden=\"true\"\n                        className=\"size-4\"\n                      >\n                        <path\n                          d=\"M3.5 8.5 6.5 11.5 12.5 4.5\"\n                          stroke=\"currentColor\"\n                          strokeWidth=\"1.8\"\n                          strokeLinecap=\"round\"\n                          strokeLinejoin=\"round\"\n                          pathLength={1}\n                          strokeDasharray={1}\n                          style={{\n                            strokeDashoffset: empty && expanded ? 0 : 1,\n                            transition: reduced\n                              ? \"none\"\n                              : `stroke-dashoffset 480ms ${EASE} 260ms`,\n                          }}\n                        />\n                      </svg>\n                    </span>\n                    <p className=\"text-[13px] font-medium\">\n                      {tab === \"unread\"\n                        ? \"You're all caught up\"\n                        : \"Nothing here yet\"}\n                    </p>\n                    <p className=\"text-[12px] text-muted-foreground\">\n                      {tab === \"unread\"\n                        ? \"New notifications will show up here.\"\n                        : \"When something happens, you'll hear about it here.\"}\n                    </p>\n                  </div>\n                </div>\n              </div>\n\n              {loadMore && !noMore && tab === \"all\" && !empty && (\n                <div className=\"flex justify-center py-1.5\">\n                  <button\n                    type=\"button\"\n                    onClick={more}\n                    aria-busy={loading || undefined}\n                    className={`h-7 cursor-pointer rounded-full px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground ${FOCUS}`}\n                  >\n                    <TextMorph>{loading ? \"Loading\" : \"Show older\"}</TextMorph>\n                  </button>\n                </div>\n              )}\n            </div>\n          </div>\n        </div>\n      )}\n\n      <span className=\"sr-only\" role=\"status\">\n        {announce}\n      </span>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/number-roll.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * NUMBER ROLL: numbers that change like an odometer\n *\n *   rolling   each digit is a column that rolls to its new\n *             value, in the direction the number moved: going\n *             up, a 9 rolls on to 0 instead of spinning back\n *   places    new places slide open from nothing; lost ones\n *             fold away\n *   format    anything Intl.NumberFormat does: currency,\n *             percent, compact (\"1.2K\"), decimals\n *\n * The real number is always there as text for screen readers\n * and copy and paste; the columns are only what you see.\n * ───────────────────────────────────────────────────────── */\n\nexport interface NumberRollProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  value: number;\n  /** Intl.NumberFormat options, e.g. { style: \"currency\", currency: \"USD\" }. */\n  format?: Intl.NumberFormatOptions;\n  locales?: string | string[];\n  prefix?: string;\n  suffix?: string;\n  /** Start from this value and roll to `value` once mounted, e.g. 0 for stats. */\n  from?: number;\n  /** Roll duration in ms. */\n  duration?: number;\n  /** Always roll this way, e.g. \"down\" for a countdown's seconds, which wrap from 00 to 59. Defaults to the way the number moved. */\n  direction?: \"up\" | \"down\";\n}\n\ntype Column = { key: string; char: string; digit: number | null };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst SETS = 5; // the strip repeats 0–9 five times so a roll never runs out of digits\nconst MIDDLE = 20;\n/** The strip as one text node, a digit a line: fifty lines, but one element to lay out instead of fifty. */\nconst STRIP = Array.from({ length: SETS * 10 }, (_, i) => i % 10).join(\"\\n\");\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Digits are keyed by their place counted from the right, so the units column stays the units column. */\nfunction columns(text: string): Column[] {\n  const chars = [...text];\n  const seen = new Map<string, number>();\n  let place = 0;\n  const out: Column[] = [];\n  for (let i = chars.length - 1; i >= 0; i--) {\n    const char = chars[i];\n    if (/\\d/.test(char))\n      out.push({ key: `d${place++}`, char, digit: Number(char) });\n    else {\n      // Symbols are keyed by how many of the same symbol sit to their right, so a comma that shifts is the same comma.\n      const n = seen.get(char) ?? 0;\n      seen.set(char, n + 1);\n      out.push({ key: `s${char}${n}`, char, digit: null });\n    }\n  }\n  return out.reverse();\n}\n\n// Memoised: a parent that re-renders with the same number doesn't rebuild the strips.\nconst Digit = React.memo(function Digit({\n  digit,\n  trend,\n  duration,\n  reduced,\n  rollIn,\n}: {\n  digit: number;\n  trend: number;\n  duration: number;\n  reduced: boolean;\n  rollIn: boolean;\n}) {\n  const [pos, setPos] = React.useState(MIDDLE + (rollIn ? 0 : digit));\n  const [moving, setMoving] = React.useState(false);\n  const posRef = React.useRef(pos);\n  const stripRef = React.useRef<HTMLSpanElement>(null);\n\n  React.useLayoutEffect(() => {\n    const current = posRef.current;\n    const showing = ((current % 10) + 10) % 10;\n    if (showing === digit) return;\n    if (reduced) {\n      posRef.current = MIDDLE + digit;\n      setMoving(false);\n      setPos(MIDDLE + digit);\n      return;\n    }\n    const up = trend > 0 || (trend === 0 && digit > showing);\n    let target = up\n      ? current + ((digit - showing + 10) % 10)\n      : current - ((showing - digit + 10) % 10);\n    // Values arriving faster than a roll (a progress percent) never let it re-centre, so before it runs off the strip,\n    // jump the strip back by whole sets mid-roll (it looks identical) and roll on from there.\n    if (target < 10 || target > SETS * 10 - 11) {\n      const shift = Math.round((target - MIDDLE) / 10) * 10;\n      const strip = stripRef.current;\n      if (strip?.offsetHeight) {\n        let visual = current;\n        try {\n          visual =\n            -new DOMMatrixReadOnly(getComputedStyle(strip).transform).m42 /\n            (strip.offsetHeight / (SETS * 10));\n        } catch {}\n        const transition = strip.style.transition;\n        strip.style.transition = \"none\";\n        strip.style.transform = `translateY(${(-(visual - shift) * 100) / (SETS * 10)}%)`;\n        void strip.offsetHeight;\n        strip.style.transition = transition;\n      }\n      target -= shift;\n    }\n    posRef.current = target;\n    setMoving(true);\n    setPos(target);\n  }, [digit, trend, reduced]);\n\n  // After a roll, quietly re-centre on the middle set so the next roll always has room.\n  const settle = () => {\n    const centred = MIDDLE + (((posRef.current % 10) + 10) % 10);\n    posRef.current = centred;\n    setMoving(false);\n    setPos(centred);\n  };\n\n  return (\n    <span className=\"relative inline-block [clip-path:inset(0)]\">\n      <span className=\"invisible\">{digit}</span>\n      <span\n        ref={stripRef}\n        aria-hidden=\"true\"\n        onTransitionEnd={settle}\n        className=\"absolute inset-x-0 top-0 block whitespace-pre text-center\"\n        style={{\n          transform: `translateY(${(-pos * 100) / (SETS * 10)}%)`,\n          transition: moving ? `transform ${duration}ms ${EASE}` : \"none\",\n        }}\n      >\n        {STRIP}\n      </span>\n    </span>\n  );\n});\n\n/** A place that appeared after the first paint slides open; places that were there from the start just sit. */\nfunction Place({\n  enter,\n  children,\n}: {\n  enter: boolean;\n  children: React.ReactNode;\n}) {\n  const [entering] = React.useState(enter);\n  return (\n    <span\n      className={`inline-block ${entering ? \"[clip-path:inset(0)] animate-[ui-col-in_500ms_cubic-bezier(0.16,1,0.3,1)_both]\" : \"\"}`}\n    >\n      {children}\n    </span>\n  );\n}\n\nexport function NumberRoll({\n  value,\n  format,\n  locales,\n  prefix = \"\",\n  suffix = \"\",\n  from,\n  duration = 900,\n  direction,\n  className = \"\",\n  ...props\n}: NumberRollProps) {\n  const reduced = useReducedMotion();\n  const [shown, setShown] = React.useState(from ?? value);\n  const previous = React.useRef(shown);\n  const mounted = React.useRef(false);\n\n  // Roll from `from` to the real value once on screen (a frame later, so the start is painted).\n  React.useEffect(() => {\n    const frame = requestAnimationFrame(() => setShown(value));\n    return () => cancelAnimationFrame(frame);\n  }, [value]);\n\n  React.useEffect(() => {\n    mounted.current = true;\n  }, []);\n\n  const formatter = React.useMemo(\n    () => new Intl.NumberFormat(locales, format),\n    [locales, format && JSON.stringify(format)],\n  );\n  const text = `${prefix}${formatter.format(shown)}${suffix}`;\n  const cols = React.useMemo(() => columns(text), [text]);\n  const trend =\n    direction === \"up\"\n      ? 1\n      : direction === \"down\"\n        ? -1\n        : Math.sign(shown - previous.current);\n\n  // Places that disappear fold away instead of vanishing.\n  const [leaving, setLeaving] = React.useState<Column[]>([]);\n  const lastCols = React.useRef(cols);\n  React.useLayoutEffect(() => {\n    const gone = lastCols.current.filter(\n      (c) => !cols.some((n) => n.key === c.key),\n    );\n    lastCols.current = cols;\n    previous.current = shown;\n    if (!gone.length || reduced) return;\n    setLeaving(gone);\n    const timer = window.setTimeout(() => setLeaving([]), 420);\n    return () => window.clearTimeout(timer);\n  }, [cols, shown, reduced]);\n\n  return (\n    <span className={`inline-flex tabular-nums ${className}`} {...props}>\n      <span className=\"sr-only\">{`${prefix}${formatter.format(value)}${suffix}`}</span>\n      <span\n        aria-hidden=\"true\"\n        className=\"inline-flex items-baseline whitespace-pre\"\n      >\n        {leaving.map((c) => (\n          <span\n            key={`out-${c.key}`}\n            className=\"inline-block [clip-path:inset(0)] animate-[ui-col-out_400ms_cubic-bezier(0.16,1,0.3,1)_forwards]\"\n          >\n            {c.char}\n          </span>\n        ))}\n        {cols.map((c) => (\n          <Place key={c.key} enter={mounted.current && !reduced}>\n            {c.digit === null ? (\n              c.char\n            ) : (\n              <Digit\n                digit={c.digit}\n                trend={trend}\n                duration={duration}\n                reduced={reduced}\n                rollIn={mounted.current}\n              />\n            )}\n          </Place>\n        ))}\n      </span>\n    </span>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/relative-time.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { NumberRoll } from \"./number-roll\";\nimport { TextMorph } from \"./text-morph\";\n\n/* ─────────────────────────────────────────────────────────\n * RELATIVE TIME: \"2 min ago\" that keeps itself true\n *\n *   tick      it re-renders only when the words would change:\n *             on the next minute under an hour, the next hour\n *             under a day; nothing runs between\n *   roll      the number rolls up (\"2 min\" → \"3 min\") and the\n *             unit morphs when it changes (\"59 min\" → \"1 h\")\n *   date      past a week it settles on the date (\"12 Sep\")\n *\n * Until it's mounted it renders the date, so the server and the\n * first paint agree; the hover title is always the full time.\n * ───────────────────────────────────────────────────────── */\n\nexport type DateLike = Date | string | number;\n\nexport interface RelativeTimeProps extends Omit<\n  React.HTMLAttributes<HTMLElement>,\n  \"children\"\n> {\n  date: DateLike;\n  /** Said before the time, e.g. \"Last used\". */\n  prefix?: string;\n  /** Under a minute. */\n  justNow?: string;\n  locales?: string | string[];\n}\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\n\nexport const toTime = (d: DateLike) =>\n  d instanceof Date\n    ? d.getTime()\n    : typeof d === \"number\"\n      ? d\n      : new Date(d).getTime();\n\nconst MONTHS = [\n  \"Jan\",\n  \"Feb\",\n  \"Mar\",\n  \"Apr\",\n  \"May\",\n  \"Jun\",\n  \"Jul\",\n  \"Aug\",\n  \"Sep\",\n  \"Oct\",\n  \"Nov\",\n  \"Dec\",\n];\n\n/** \"12 Sep\", with the year when it isn't this one; pass locales to use the browser's own format. */\nexport function formatDate(d: DateLike, locales?: string | string[]) {\n  const t = new Date(toTime(d));\n  const sameYear = t.getFullYear() === new Date().getFullYear();\n  if (locales)\n    return t.toLocaleDateString(\n      locales,\n      sameYear\n        ? { day: \"numeric\", month: \"short\" }\n        : { day: \"numeric\", month: \"short\", year: \"numeric\" },\n    );\n  return `${t.getDate()} ${MONTHS[t.getMonth()]}${sameYear ? \"\" : ` ${t.getFullYear()}`}`;\n}\n\ntype Parts = { n: number | null; unit: string; next: number };\n\nfunction parts(\n  at: number,\n  now: number,\n  justNow: string,\n  locales?: string | string[],\n): Parts {\n  const ago = Math.max(0, now - at);\n  if (ago < MINUTE) return { n: null, unit: justNow, next: MINUTE - ago };\n  if (ago < HOUR)\n    return {\n      n: Math.floor(ago / MINUTE),\n      unit: \"min ago\",\n      next: MINUTE - (ago % MINUTE),\n    };\n  if (ago < DAY) {\n    const h = Math.floor(ago / HOUR);\n    return {\n      n: h,\n      unit: h === 1 ? \"hour ago\" : \"hours ago\",\n      next: HOUR - (ago % HOUR),\n    };\n  }\n  if (ago < 7 * DAY) {\n    const d = Math.floor(ago / DAY);\n    return {\n      n: d,\n      unit: d === 1 ? \"day ago\" : \"days ago\",\n      next: DAY - (ago % DAY),\n    };\n  }\n  return { n: null, unit: formatDate(at, locales), next: 0 };\n}\n\nconst subscribeMounted = () => () => {};\n\nexport function RelativeTime({\n  date,\n  prefix,\n  justNow = \"just now\",\n  locales,\n  className = \"\",\n  ...props\n}: RelativeTimeProps) {\n  const at = toTime(date);\n  const mounted = React.useSyncExternalStore(\n    subscribeMounted,\n    () => true,\n    () => false,\n  );\n  const [now, setNow] = React.useState(() => Date.now());\n  const p = parts(at, mounted ? now : at + 8 * DAY, justNow, locales);\n\n  // One timer, set for the moment the words change.\n  React.useEffect(() => {\n    if (!mounted || !p.next) return;\n    const timer = window.setTimeout(() => setNow(Date.now()), p.next + 50);\n    return () => window.clearTimeout(timer);\n  }, [mounted, p.next, now]);\n\n  React.useEffect(() => {\n    const timer = window.setTimeout(() => setNow(Date.now()), 0);\n    return () => window.clearTimeout(timer);\n  }, [at]);\n\n  const iso = new Date(at).toISOString();\n  return (\n    <time\n      dateTime={iso}\n      title={new Date(at).toLocaleString(locales ?? \"en-GB\", {\n        dateStyle: \"medium\",\n        timeStyle: \"short\",\n      })}\n      className={`inline-flex items-baseline whitespace-nowrap tabular-nums ${className}`}\n      {...props}\n    >\n      {prefix && <span>{prefix}&nbsp;</span>}\n      {/* Remounted once on the client, so the first real words appear without a morph. */}\n      <Words key={mounted ? \"client\" : \"server\"} n={p.n} unit={p.unit} />\n    </time>\n  );\n}\n\nfunction Words({ n, unit }: { n: number | null; unit: string }) {\n  return (\n    <>\n      <span\n        aria-hidden={n === null || undefined}\n        className=\"inline-grid transition-[grid-template-columns] duration-[380ms] ease-[cubic-bezier(0.16,1,0.3,1)] motion-reduce:transition-none\"\n        style={{ gridTemplateColumns: n === null ? \"0fr\" : \"1fr\" }}\n      >\n        <span className=\"min-w-0 [clip-path:inset(-4px_0)]\">\n          <span className=\"inline-flex items-baseline pr-[0.25em]\">\n            <NumberRoll value={n ?? 1} direction=\"up\" />\n          </span>\n        </span>\n      </span>\n      <TextMorph>{unit}</TextMorph>\n    </>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/text-morph.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * TEXT MORPH: text that changes the way it should\n *\n *   shared   letters both texts share stay alive and slide to\n *            their new place (\"Save\" → \"Saving\" keeps \"Sav\")\n *   new      letters that weren't there rise in out of a blur,\n *            one after another\n *   gone     letters that leave lift away and blur out where\n *            they stood\n *   width    the box eases to its new width, so a button or\n *            pill holding it resizes with it\n *\n * Texts with little in common crossfade as a whole instead of\n * flinging single letters across. The real text is always\n * there for screen readers.\n * ───────────────────────────────────────────────────────── */\n\nexport interface TextMorphProps extends Omit<\n  React.HTMLAttributes<HTMLSpanElement>,\n  \"children\"\n> {\n  children: string;\n  /** Morph time in ms. */\n  duration?: number;\n  /** Where new letters come from: below (\"up\") or above (\"down\"). */\n  direction?: \"up\" | \"down\";\n  /** Ease the box's width too; turn off for text that wraps. */\n  animateWidth?: boolean;\n}\n\ntype Glyph = { key: number; char: string };\ntype Leaving = Glyph & { x: number; y: number };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\n/** Keep the letters two texts share (longest common subsequence); everything else is new. */\nfunction morph(\n  previous: Glyph[],\n  text: string,\n  nextKey: () => number,\n): Glyph[] {\n  const a = previous.map((g) => g.char);\n  const b = Array.from(text);\n  const fresh = () => b.map((char) => ({ key: nextKey(), char }));\n  if (!a.length || !b.length) return fresh();\n\n  const dp = Array.from(\n    { length: a.length + 1 },\n    () => new Uint16Array(b.length + 1),\n  );\n  for (let i = a.length - 1; i >= 0; i--)\n    for (let j = b.length - 1; j >= 0; j--)\n      dp[i][j] =\n        a[i] === b[j]\n          ? dp[i + 1][j + 1] + 1\n          : Math.max(dp[i + 1][j], dp[i][j + 1]);\n\n  // Too little in common reads as two different words: crossfade them instead.\n  if (dp[0][0] < Math.min(a.length, b.length) * 0.5) return fresh();\n\n  const out: Glyph[] = [];\n  let i = 0;\n  let j = 0;\n  while (j < b.length) {\n    if (i < a.length && a[i] === b[j]) {\n      out.push(previous[i++]);\n      j++;\n    } else if (i < a.length && dp[i + 1][j] >= dp[i][j + 1]) i++;\n    else out.push({ key: nextKey(), char: b[j++] });\n  }\n  return out;\n}\n\nfunction LeavingGlyph({\n  glyph,\n  lift,\n  duration,\n  onDone,\n}: {\n  glyph: Leaving;\n  lift: number;\n  duration: number;\n  onDone: (key: number) => void;\n}) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  React.useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const animation = el.animate(\n      [\n        { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n        { opacity: 0, filter: \"blur(4px)\", transform: `translateY(${lift}em)` },\n      ],\n      { duration: duration * 0.6, easing: EASE, fill: \"forwards\" },\n    );\n    animation.onfinish = () => onDone(glyph.key);\n    return () => animation.cancel();\n  }, [glyph.key, lift, duration, onDone]);\n  return (\n    <span\n      ref={ref}\n      aria-hidden=\"true\"\n      className=\"pointer-events-none absolute whitespace-pre\"\n      style={{ left: glyph.x, top: glyph.y }}\n    >\n      {glyph.char}\n    </span>\n  );\n}\n\nexport function TextMorph({\n  children: text,\n  duration = 460,\n  direction = \"up\",\n  animateWidth = true,\n  className = \"\",\n  ...props\n}: TextMorphProps) {\n  const reduced = useReducedMotion();\n  const counter = React.useRef(text.length);\n  const nextKey = React.useCallback(() => ++counter.current, []);\n  const [glyphs, setGlyphs] = React.useState<Glyph[]>(() =>\n    Array.from(text).map((char, i) => ({ key: i + 1, char })),\n  );\n  const [leaving, setLeaving] = React.useState<Leaving[]>([]);\n  const rootRef = React.useRef<HTMLSpanElement>(null);\n  const els = React.useRef(new Map<number, HTMLSpanElement>());\n  const before = React.useRef<{\n    at: Map<number, { x: number; y: number }>;\n    width: number;\n  } | null>(null);\n  const rise = direction === \"up\" ? 0.35 : -0.35;\n\n  // A preference change must also finish an in-flight morph whose target text\n  // already matches the glyphs (including the empty label in a folded receipt).\n  React.useLayoutEffect(() => {\n    if (!reduced) return;\n    before.current = null;\n    const root = rootRef.current;\n    root\n      ?.getAnimations({ subtree: true })\n      .forEach((animation) => animation.cancel());\n    if (root) root.style.whiteSpace = \"\";\n    setLeaving((previous) => (previous.length ? [] : previous));\n  }, [reduced]);\n\n  // 1. The text changed: note where every letter stands, then work out which letters stay.\n  React.useLayoutEffect(() => {\n    if (text === glyphs.map((g) => g.char).join(\"\")) return;\n    const root = rootRef.current;\n    if (!root || reduced) {\n      setLeaving([]);\n      setGlyphs(Array.from(text).map((char) => ({ key: nextKey(), char })));\n      return;\n    }\n    const box = root.getBoundingClientRect();\n    const at = new Map<number, { x: number; y: number }>();\n    els.current.forEach((el, key) => {\n      const r = el.getBoundingClientRect();\n      at.set(key, { x: r.left - box.left, y: r.top - box.top });\n    });\n    before.current = { at, width: box.width };\n    const next = morph(glyphs, text, nextKey);\n    const kept = new Set(next.map((g) => g.key));\n    setLeaving((l) => [\n      ...l,\n      ...glyphs\n        .filter((g) => !kept.has(g.key))\n        .map((g) => ({ ...g, ...(at.get(g.key) ?? { x: 0, y: 0 }) })),\n    ]);\n    setGlyphs(next);\n  }, [text, reduced]);\n\n  // 2. The new letters are in place: glide the ones that stayed, raise the new ones, ease the width.\n  React.useLayoutEffect(() => {\n    const prev = before.current;\n    const root = rootRef.current;\n    if (!prev || !root) return;\n    before.current = null;\n    const box = root.getBoundingClientRect();\n    let order = 0;\n    for (const g of glyphs) {\n      const el = els.current.get(g.key);\n      if (!el) continue;\n      const from = prev.at.get(g.key);\n      if (from) {\n        const r = el.getBoundingClientRect();\n        const dx = from.x - (r.left - box.left);\n        const dy = from.y - (r.top - box.top);\n        if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5)\n          el.animate(\n            [\n              { transform: `translate(${dx}px, ${dy}px)` },\n              { transform: \"none\" },\n            ],\n            { duration, easing: EASE },\n          );\n      } else {\n        el.animate(\n          [\n            {\n              opacity: 0,\n              filter: \"blur(4px)\",\n              transform: `translateY(${rise}em)`,\n            },\n            { opacity: 1, filter: \"blur(0px)\", transform: \"none\" },\n          ],\n          {\n            duration,\n            easing: EASE,\n            delay: Math.min(order++ * 16, 160),\n            fill: \"backwards\",\n          },\n        );\n      }\n    }\n    if (animateWidth && Math.abs(prev.width - box.width) > 0.5) {\n      // Hold the words on one line while the box is narrower than them, or \"No credits left\" would wrap mid-morph.\n      root.style.whiteSpace = \"nowrap\";\n      const resize = root.animate(\n        [{ width: `${prev.width}px` }, { width: `${box.width}px` }],\n        { duration, easing: EASE },\n      );\n      resize.onfinish = resize.oncancel = () => {\n        root.style.whiteSpace = \"\";\n      };\n    }\n  }, [glyphs, duration, rise, animateWidth]);\n\n  const done = React.useCallback(\n    (key: number) => setLeaving((l) => l.filter((g) => g.key !== key)),\n    [],\n  );\n\n  // Words stay unbroken; lines may only wrap at spaces.\n  const words: Glyph[][] = [];\n  for (const g of glyphs) {\n    if (\n      g.char === \" \" ||\n      !words.length ||\n      words[words.length - 1][0]?.char === \" \"\n    )\n      words.push([g]);\n    else words[words.length - 1].push(g);\n  }\n\n  return (\n    <span\n      ref={rootRef}\n      className={`relative inline-block ${className}`}\n      {...props}\n    >\n      <span className=\"sr-only\">{text}</span>\n      {words.map((word, w) => (\n        <span\n          key={w}\n          aria-hidden=\"true\"\n          className=\"inline-block whitespace-pre\"\n        >\n          {word.map((g) => (\n            <span\n              key={g.key}\n              ref={(el) => {\n                if (el) els.current.set(g.key, el);\n                else els.current.delete(g.key);\n              }}\n              className=\"inline-block\"\n            >\n              {g.char}\n            </span>\n          ))}\n        </span>\n      ))}\n      {leaving.map((g) => (\n        <LeavingGlyph\n          key={`out-${g.key}`}\n          glyph={g}\n          lift={-rise}\n          duration={duration}\n          onDone={done}\n        />\n      ))}\n    </span>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/status-button.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { TextMorph } from \"./text-morph\";\n\n/* ─────────────────────────────────────────────────────────\n * STATUS BUTTON: a button that tells you what happened\n *\n *   idle     \"Save\", with an optional icon\n *   pending  a spinner opens in; the label morphs to \"Saving\"\n *   success  a check draws itself; \"Saved\"\n *   error    the button gives a small shake; \"Try again\"\n *\n * Every change is one motion: the icon slot opens and closes,\n * icons swap through a blur, letters the labels share stay put\n * and the button's width eases to fit.\n * ───────────────────────────────────────────────────────── */\n\nexport type ActionStatus = \"idle\" | \"pending\" | \"success\" | \"error\";\n\nexport interface StatusButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n  status?: ActionStatus;\n  /** Labels per state; defaults to Save, Saving, Saved, Try again. */\n  labels?: Partial<Record<ActionStatus, string>>;\n  /** Shown before the label while idle. */\n  icon?: React.ReactNode;\n  variant?: \"primary\" | \"outline\" | \"ghost\";\n  /** \"sm\" is 28px tall, for toolbars and headers. */\n  size?: \"default\" | \"sm\";\n  /** Called this long after success (ms), e.g. to go back to idle. */\n  onReset?: () => void;\n  resetAfter?: number;\n}\n\nconst LABELS: Record<ActionStatus, string> = {\n  idle: \"Save\",\n  pending: \"Saving\",\n  success: \"Saved\",\n  error: \"Try again\",\n};\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst FOCUS =\n  \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 focus-visible:ring-offset-2 focus-visible:ring-offset-background\";\n\nconst reducedQuery = \"(prefers-reduced-motion: reduce)\";\nconst subscribeReduced = (onChange: () => void) => {\n  const query = window.matchMedia(reducedQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n};\nconst useReducedMotion = () =>\n  React.useSyncExternalStore(\n    subscribeReduced,\n    () => window.matchMedia(reducedQuery).matches,\n    () => false,\n  );\n\nfunction Check({ drawn, reduced }: { drawn: boolean; reduced: boolean }) {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\">\n      <path\n        d=\"M3.5 8.5 6.5 11.5 12.5 4.5\"\n        stroke=\"currentColor\"\n        strokeWidth=\"2\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        pathLength={1}\n        strokeDasharray={1}\n        style={{\n          strokeDashoffset: drawn ? 0 : 1,\n          transition:\n            drawn && !reduced\n              ? `stroke-dashoffset 420ms ${EASE} 120ms`\n              : \"none\",\n        }}\n      />\n    </svg>\n  );\n}\n\nfunction Alert() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\">\n      <circle cx=\"8\" cy=\"8\" r=\"6.25\" stroke=\"currentColor\" strokeWidth=\"1.5\" />\n      <path\n        d=\"M8 4.75v3.75\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.75\"\n        strokeLinecap=\"round\"\n      />\n      <circle cx=\"8\" cy=\"11\" r=\"1\" fill=\"currentColor\" />\n    </svg>\n  );\n}\n\nexport function StatusButton({\n  status = \"idle\",\n  labels,\n  icon,\n  variant = \"primary\",\n  size = \"default\",\n  onReset,\n  resetAfter = 1800,\n  className = \"\",\n  onClick,\n  ...props\n}: StatusButtonProps) {\n  const reduced = useReducedMotion();\n  const ref = React.useRef<HTMLButtonElement>(null);\n  const label = { ...LABELS, ...labels }[status];\n  const showIcon = status !== \"idle\" || Boolean(icon);\n  const busy = status === \"pending\";\n  const sm = size === \"sm\";\n  const iconSize = sm ? 14 : 16;\n\n  // A short shake when it fails: the eye catches it even if you looked away.\n  React.useEffect(() => {\n    if (status !== \"error\" || reduced) return;\n    ref.current?.animate(\n      [\n        { transform: \"none\" },\n        { transform: \"translateX(-4px)\" },\n        { transform: \"translateX(4px)\" },\n        { transform: \"translateX(-2px)\" },\n        { transform: \"none\" },\n      ],\n      { duration: 380, easing: \"ease-out\" },\n    );\n  }, [status, reduced]);\n\n  React.useEffect(() => {\n    if (status !== \"success\" || !onReset) return;\n    const timer = window.setTimeout(onReset, resetAfter);\n    return () => window.clearTimeout(timer);\n  }, [status, onReset, resetAfter]);\n\n  const tone =\n    status === \"error\"\n      ? \"bg-red-500/10 text-red-600 shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--color-red-500)_30%,transparent)] dark:text-red-400\"\n      : variant === \"primary\"\n        ? \"bg-primary text-primary-foreground hover:bg-primary/90\"\n        : variant === \"ghost\"\n          ? `hover:bg-accent hover:text-foreground ${status === \"idle\" ? \"text-muted-foreground\" : \"text-foreground\"}`\n          : \"text-foreground shadow-[inset_0_0_0_1px_var(--border)] hover:bg-accent\";\n\n  const icons: Record<ActionStatus, React.ReactNode> = {\n    idle: icon,\n    // Spins only while pending, so a hidden spinner never keeps the page busy.\n    pending: (\n      <span\n        className={`${sm ? \"size-3\" : \"size-3.5\"} rounded-full border-[1.5px] border-current border-t-transparent opacity-80 motion-reduce:animate-none ${status === \"pending\" ? \"animate-spin\" : \"\"}`}\n      />\n    ),\n    success: <Check drawn={status === \"success\"} reduced={reduced} />,\n    error: <Alert />,\n  };\n\n  return (\n    <>\n      <button\n        ref={ref}\n        type=\"button\"\n        aria-busy={busy || undefined}\n        aria-disabled={busy || undefined}\n        onClick={(e) => {\n          if (busy) return e.preventDefault();\n          onClick?.(e);\n        }}\n        className={`cursor-pointer disabled:cursor-default aria-disabled:cursor-default inline-flex items-center justify-center whitespace-nowrap rounded-full font-medium transition-[background-color,color,box-shadow,scale,padding] duration-300 active:scale-[0.97] motion-reduce:active:scale-100 ${\n          sm\n            ? `h-7 text-[12px] ${variant === \"ghost\" ? \"px-2.5\" : \"px-3\"}`\n            : \"h-9 px-4 text-[13px]\"\n        } ${FOCUS} ${tone} ${className}`}\n        {...props}\n      >\n        <span\n          aria-hidden=\"true\"\n          className={`relative flex shrink-0 items-center justify-center ${sm ? \"h-3.5 [&_svg]:size-3.5\" : \"h-4 [&_svg]:size-4\"}`}\n          style={{\n            width: showIcon ? iconSize : 0,\n            marginRight: showIcon ? (sm ? 5 : 6) : 0,\n            transition: reduced\n              ? \"none\"\n              : `width 380ms ${EASE}, margin 380ms ${EASE}`,\n          }}\n        >\n          {(Object.keys(icons) as ActionStatus[]).map((s) => (\n            <span\n              key={s}\n              className=\"absolute inset-0 flex items-center justify-center\"\n              style={{\n                opacity: s === status ? 1 : 0,\n                transform: s === status ? \"none\" : \"scale(0.6)\",\n                filter: s === status ? \"none\" : \"blur(3px)\",\n                transition: reduced\n                  ? \"none\"\n                  : `opacity 260ms ${EASE}, transform 380ms ${EASE}, filter 260ms ${EASE}`,\n              }}\n            >\n              {icons[s]}\n            </span>\n          ))}\n        </span>\n        <TextMorph>{label}</TextMorph>\n      </button>\n      {/* Outside the button, so the announcement isn't read as part of its name. */}\n      <span className=\"sr-only\" role=\"status\">\n        {status === \"idle\" ? \"\" : label}\n      </span>\n    </>\n  );\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/components/use-row-motion.ts",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\n/* ─────────────────────────────────────────────────────────\n * ROW MOTION: rows that keep their place on screen\n *\n *   glide     after any render (a sort, a filter, new data from\n *             the server) every row that moved glides from its\n *             old place to its new one. Glides are additive, so\n *             a change that lands mid-glide adds its own offset\n *             instead of restarting anything\n *   travel    a row that sorts onto the page slides in from the\n *             side where it ranked before; one that sorts off\n *             slides out toward its new rank\n *   enter     a row that's new to the list fades in where it\n *             lands while the rows below glide clear of it\n *   leave     a row that's gone folds away where it stood. Its\n *             copy is the row's own element, detached by React\n *             and moved into a layer React never renders into,\n *             so a leaving row costs no render at all\n *   stagger   a sort can ask for the rows to set off one after\n *             another, top first\n *\n * Positions are layout offsets (transforms ignored), kept after\n * every render and whenever the list changes size (a row\n * opening its detail), so they're never stale. Rows are found\n * by data-row-id; ranks are their places in the whole sorted\n * list, not just the page.\n * ───────────────────────────────────────────────────────── */\n\ntype Seen = { top: number; height: number; el: HTMLElement };\n\nconst EASE = \"cubic-bezier(0.16,1,0.3,1)\";\nconst GLIDE = 480;\n\nexport function useRowMotion(\n  container: React.RefObject<HTMLElement | null>,\n  {\n    reduced,\n    resetKey,\n    ranks,\n    ghosts,\n  }: {\n    reduced: boolean;\n    resetKey?: string | number;\n    ranks: ReadonlyMap<string, number>;\n    ghosts: React.RefObject<HTMLElement | null>;\n  },\n) {\n  const seen = React.useRef(new Map<string, Seen>());\n  const lastRanks = React.useRef(ranks);\n  const lastKey = React.useRef(resetKey);\n  const staggerNext = React.useRef(false);\n\n  const read = React.useCallback(() => {\n    const out = new Map<string, Seen>();\n    container.current\n      ?.querySelectorAll<HTMLElement>(\"[data-row-id]\")\n      .forEach((el) =>\n        out.set(el.dataset.rowId!, {\n          top: el.offsetTop,\n          height: el.offsetHeight,\n          el,\n        }),\n      );\n    return out;\n  }, [container]);\n\n  /** The row React just removed, back on screen where it stood, leaving: sliding toward where it went, or folding. */\n  const leave = (was: Seen, dy: number) => {\n    const layer = ghosts.current;\n    const el = was.el;\n    if (!layer || el.isConnected) return;\n    // No getAnimations() here (it flushes style for the whole page): the exit below is added last and replaces any\n    // glide still on the element.\n    el.removeAttribute(\"data-row-id\");\n    el.removeAttribute(\"tabindex\");\n    el.setAttribute(\"aria-hidden\", \"true\");\n    el.inert = true;\n    Object.assign(el.style, {\n      position: \"absolute\",\n      left: \"0\",\n      right: \"0\",\n      top: `${was.top}px`,\n      height: `${was.height}px`,\n      margin: \"0\",\n      overflow: \"hidden\",\n    });\n    layer.appendChild(el);\n    const a = el.animate(\n      dy\n        ? [\n            { transform: \"translateY(0px)\", opacity: 1, filter: \"blur(0px)\" },\n            {\n              transform: `translateY(${dy}px)`,\n              opacity: 0,\n              filter: \"blur(3px)\",\n            },\n          ]\n        : [\n            { opacity: 1, transform: \"none\", filter: \"blur(0px)\" },\n            { opacity: 0, transform: \"scale(0.985)\", filter: \"blur(4px)\" },\n          ],\n      { duration: dy ? 360 : 280, easing: EASE, fill: \"forwards\" },\n    );\n    a.onfinish = a.oncancel = () => el.remove();\n  };\n\n  React.useLayoutEffect(() => {\n    const el = container.current;\n    if (!el) return;\n    const before = seen.current;\n    const after = read();\n    const prevRanks = lastRanks.current;\n    seen.current = after;\n    lastRanks.current = ranks;\n    const stagger = staggerNext.current;\n    staggerNext.current = false;\n    if (lastKey.current !== resetKey) {\n      // A different page: the caller slides the whole body; nothing glides and nothing folds.\n      lastKey.current = resetKey;\n      return;\n    }\n    if (reduced || !before.size) return;\n\n    // A typical row's height. Rows that come onto or leave the page only hint at the way they went (a row and a\n    // quarter at most), so the list never shows holes while they travel.\n    const heights = [...after.values()]\n      .map((b) => b.height)\n      .sort((a, b) => a - b);\n    const rowH = heights[Math.floor(heights.length / 2)] ?? 48;\n    const clamp = (dy: number) =>\n      Math.max(-rowH * 1.25, Math.min(rowH * 1.25, dy));\n\n    let order = 0;\n    after.forEach((now, id) => {\n      const row = now.el;\n      const was = before.get(id);\n      const delay = stagger ? Math.min(order++ * 16, 200) : 0;\n      if (was) {\n        const dy = was.top - now.top;\n        if (Math.abs(dy) < 0.5) return;\n        row.animate(\n          [\n            { transform: `translateY(${dy}px)`, zIndex: 1 },\n            { transform: \"translateY(0px)\", zIndex: 1 },\n          ],\n          {\n            duration: GLIDE,\n            delay,\n            easing: EASE,\n            composite: \"add\",\n            fill: \"backwards\",\n          },\n        );\n        return;\n      }\n      const from = prevRanks.get(id);\n      const to = ranks.get(id);\n      if (from !== undefined && to !== undefined) {\n        // It ranked somewhere off the page: it comes in from that side.\n        row.animate(\n          [\n            {\n              transform: `translateY(${clamp((from - to) * rowH)}px)`,\n              opacity: 0,\n              filter: \"blur(3px)\",\n            },\n            { transform: \"translateY(0px)\", opacity: 1, filter: \"blur(0px)\" },\n          ],\n          {\n            duration: GLIDE,\n            delay: delay / 2,\n            easing: EASE,\n            fill: \"backwards\",\n          },\n        );\n        return;\n      }\n      row.animate(\n        [\n          { opacity: 0, filter: \"blur(4px)\" },\n          { opacity: 1, filter: \"blur(0px)\" },\n        ],\n        { duration: 420, delay: 90, easing: EASE, fill: \"backwards\" },\n      );\n    });\n\n    // Still in the list, just not on this page: its copy slides toward where it went. Gone for good: it folds.\n    before.forEach((was, id) => {\n      if (after.has(id)) return;\n      const from = prevRanks.get(id);\n      const to = ranks.get(id);\n      leave(\n        was,\n        from !== undefined && to !== undefined\n          ? clamp((to - from) * rowH) || rowH\n          : 0,\n      );\n    });\n  });\n\n  // The list changed size without a render of ours (a detail opening by transition): keep the positions true.\n  React.useEffect(() => {\n    const el = container.current;\n    if (!el) return;\n    const observer = new ResizeObserver(() => {\n      seen.current = read();\n    });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [container, read]);\n\n  return {\n    /** The next change (a sort) sets the rows off one after another. */\n    stagger: () => {\n      staggerNext.current = true;\n    },\n  };\n}\n",
      "type": "registry:component"
    }
  ],
  "css": {
    "@keyframes ui-col-in": {
      "from": {
        "max-width": "0",
        "opacity": "0"
      },
      "to": {
        "max-width": "1em",
        "opacity": "1"
      }
    },
    "@keyframes ui-col-out": {
      "from": {
        "max-width": "1em",
        "opacity": "1"
      },
      "to": {
        "max-width": "0",
        "opacity": "0"
      }
    }
  },
  "meta": {
    "cavemio": {
      "component": "notification-inbox",
      "exportName": "NotificationInbox",
      "categories": [
        "overlays"
      ],
      "isNew": false,
      "usage": "import { NotificationInbox } from \"@/components/notification-inbox\";\n\n<NotificationInbox\n  defaultValue={notifications}\n  subscribe={(push) => feed.on(\"notification\", push)}\n  onRead={(ids, read) => api.markRead(ids, read)}\n  onArchive={(ids) => api.archive(ids)}\n  onOpen={(n) => n.href && router.push(n.href)}\n/>",
      "accessibility": "- The bell is a button that says how many are unread (\"Inbox, 2 unread\") and opens a dialog; focus goes to the active tab and returns to the bell on close.\n- Unread and All are a tablist (arrows switch). Each row is a button or link with \", unread\" read out when it is; the dot is a toggle button named for what it will do.\n- New notifications, read changes and archives are announced in a status region outside the dialog.\n- The archive button appears on hover and focus with a mouse, and is always visible on touch screens.\n- Reduced motion opens the inbox in place, without the swing, glides or folds; the counts still change.",
      "previewNote": "Interactive local fixture. Data and async results are simulated in the preview; the caller supplies application services.",
      "documentation": {
        "props": [
          {
            "name": "value",
            "type": "InboxItem[]",
            "description": "– · Controlled notifications, newest first: { id, title, body?, at, read?, actor?, href? }."
          },
          {
            "name": "defaultValue",
            "type": "InboxItem[]",
            "description": "– · Starting notifications when uncontrolled."
          },
          {
            "name": "onValueChange",
            "type": "(items) => void",
            "description": "– · Every arrival, read change and archive."
          },
          {
            "name": "subscribe",
            "type": "(push) => () => void",
            "description": "– · Feeds new notifications; call push with one or many. Duplicates by id are ignored."
          },
          {
            "name": "onRead",
            "type": "(ids, read) => Promise<unknown>",
            "description": "– · Saves read state; the change shows at once and is undone if this throws. Without it there is no Mark all read."
          },
          {
            "name": "onArchive",
            "type": "(ids) => Promise<unknown>",
            "description": "– · Archives; the row leaves at once and comes back if this throws. Without it there is no archive button."
          },
          {
            "name": "onOpen",
            "type": "(item) => void",
            "description": "– · Runs when a notification is opened, after it's marked read. Items with href are links."
          },
          {
            "name": "loadMore",
            "type": "(before) => Promise<InboxItem[]>",
            "description": "– · Older notifications for the All tab; an empty list hides Show older."
          },
          {
            "name": "align",
            "type": "\"end\" | \"start\"",
            "description": "\"end\" · Which edge of the bell the inbox lines up with."
          },
          {
            "name": "label",
            "type": "string",
            "description": "\"Inbox\" · Names the bell and the dialog."
          },
          {
            "name": "defaultOpen",
            "type": "boolean",
            "description": "false · Starts open."
          }
        ],
        "useCases": [
          {
            "title": "SaaS app headers",
            "description": "The bell in the top bar, with an unread count."
          },
          {
            "title": "Collaboration tools",
            "description": "Mentions, comments and assignments for each person."
          },
          {
            "title": "Marketplace and shop dashboards",
            "description": "New orders, reviews and payouts as they happen."
          },
          {
            "title": "Admin consoles",
            "description": "Alerts and system events that need to be seen and cleared."
          }
        ],
        "features": [
          {
            "title": "The bell grows into the inbox",
            "description": "The bell’s circle eases into the inbox panel, and folds back the same way when it closes."
          },
          {
            "title": "New ones arrive visibly",
            "description": "subscribe() feeds new notifications. The bell swings, the count rolls, and an open inbox fades the new row in while the rest glide down."
          },
          {
            "title": "Unread and All",
            "description": "Opening a notification reads it. In Unread, the row lingers for a moment and then folds away."
          },
          {
            "title": "Read and archive save safely",
            "description": "A change shows at once, and is put back if your onRead or onArchive function throws."
          },
          {
            "title": "Mark all read",
            "description": "One button reads everything, with a drawn check, and the counts roll to zero."
          },
          {
            "title": "All caught up, and older ones",
            "description": "An empty inbox says so with a drawn check, and loadMore brings in older notifications for All."
          }
        ],
        "states": [
          {
            "title": "open",
            "description": "The bell's 36px circle grows into the inbox (460ms, size and corners together), lined up with the bell's edge and nudged back on screen; the bell fades as the list fades in 100ms behind. Escape, the cross or a click outside folds it back and returns focus to the bell."
          },
          {
            "title": "arrive",
            "description": "subscribe() pushes a notification: the bell swings from its top (720ms, ±16° settling), the badge springs in or its count rolls, and in an open inbox the row fades in on top while the rest glide down."
          },
          {
            "title": "read",
            "description": "Opening a notification (or its dot) marks it read: the dot shrinks to an outline, the title eases to grey; in Unread the row stays 900ms, then folds away. onRead failing puts it back."
          },
          {
            "title": "mark all",
            "description": "Mark all read → Marking → All read with a drawn check; every unread row reads and folds out of Unread together, and the counts roll to zero."
          },
          {
            "title": "archive",
            "description": "The archive button (shown on hover or focus, always on touch) removes the row: it folds away where it stood and the rest glide up. onArchive failing brings it back."
          },
          {
            "title": "empty",
            "description": "\"You're all caught up\" opens by height with a check that draws itself in a thin line circle."
          }
        ]
      }
    }
  },
  "type": "registry:component"
}