{
  "schemaVersion": 1,
  "target": "react",
  "name": "notification-center",
  "version": "0.1.0",
  "category": "overlays",
  "title": "Notification Center",
  "description": "A bell with an unread badge that opens a panel of notifications grouped by day, with filter tabs and counts, unread dots, inline actions, and mark one or all as read.",
  "tags": [
    "notifications",
    "inbox",
    "bell",
    "badge",
    "popover",
    "unread",
    "activity",
    "base-ui"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0",
    "motion": "^14.14.0"
  },
  "registryDependencies": [],
  "docsPath": "/components/notification-center",
  "props": [
    {
      "name": "items / defaultItems",
      "type": "NotificationItem[]",
      "description": "NotificationCenter, NotificationPanel: the notifications. Each has id, title, time, and optional body, read, category, avatar, tone, actions, and resolved."
    },
    {
      "name": "onItemsChange",
      "type": "(items) => void",
      "description": "Called when items are marked read or resolved."
    },
    {
      "name": "onAction",
      "type": "(item, action) => void",
      "description": "Called after an inline action runs. Pressing an action also marks its item read."
    },
    {
      "name": "filters",
      "type": "{ value, label, match?, empty? }[]",
      "default": "[{ value: \"all\", label: \"All\" }]",
      "description": "Tabs above the list with unread counts. A filter matches items whose category equals its value unless match is given; all shows everything. empty sets the tab's empty state."
    },
    {
      "name": "NotificationItem actions",
      "type": "{ label, primary?, resolvedLabel?, onSelect? }[]",
      "description": "Inline buttons. resolvedLabel replaces the buttons with a result line, such as Approved."
    },
    {
      "name": "now",
      "type": "Date",
      "default": "new Date()",
      "description": "Reference time for day groups (Today, Yesterday, This week, Earlier) and relative times. Pass a fixed date when rendering on the server."
    },
    {
      "name": "title / footer",
      "type": "ReactNode",
      "default": "\"Notifications\"",
      "description": "NotificationPanel: the heading and optional content under the list."
    },
    {
      "name": "open / defaultOpen / onOpenChange",
      "type": "boolean / Popover onOpenChange",
      "description": "NotificationCenter: the popover's open state."
    },
    {
      "name": "side / align",
      "type": "\"top\" | \"bottom\" | \"left\" | \"right\" / \"start\" | \"center\" | \"end\"",
      "default": "\"bottom\" / \"end\"",
      "description": "NotificationCenter: where the panel opens."
    },
    {
      "name": "container / initialFocus",
      "type": "Popover Portal container / Popup initialFocus",
      "description": "NotificationCenter: where the panel portals to, and where focus goes when it opens."
    },
    {
      "name": "NotificationBell count / max",
      "type": "number",
      "default": "max 99",
      "description": "The badge count; zero hides the badge and counts above max show as max+."
    }
  ],
  "accessibility": [
    "The bell is a button labeled \"Notifications, 3 unread\"; the badge is decorative.",
    "The panel is a Base UI Popover: focus moves into it on open, Escape closes it, and focus returns to the bell.",
    "Filter tabs are a Base UI tablist; arrow keys move between them and each tab's name includes its unread count.",
    "Each unread dot is a 24px button labeled \"Mark as read\" and described by the item's title; inline action buttons are described by the title too.",
    "Marking read, mark all, and resolved actions are announced in a polite live region; read state also shows as a lighter title, not only the dot.",
    "Under reduced motion the badge, bell swing, row entrances, tab pill, and dot cascade are instant."
  ],
  "states": [
    "closed",
    "open",
    "unread",
    "all read",
    "filtered",
    "empty",
    "resolved action"
  ],
  "files": [
    {
      "path": "ui/notification-center.tsx",
      "content": "\"use client\";\n\nimport { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { Tabs as BaseTabs } from \"@base-ui/react/tabs\";\nimport { AnimatePresence, MotionConfig, motion, useAnimate, useReducedMotion } from \"motion/react\";\nimport { useEffect, useId, useRef, useState, type ReactNode } from \"react\";\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nconst ease = [0.23, 1, 0.32, 1] as const;\n\nexport type NotificationTone = \"neutral\" | \"info\" | \"success\" | \"danger\" | \"warning\";\n\nexport interface NotificationAction {\n  label: string;\n  /** Renders as the primary button. */\n  primary?: boolean;\n  /** Replaces the buttons with this result once pressed, such as \"Approved\". */\n  resolvedLabel?: string;\n  onSelect?: (item: NotificationItem) => void;\n}\n\nexport interface NotificationItem {\n  id: string;\n  title: ReactNode;\n  body?: ReactNode;\n  /** When it happened. Groups the list and shows as a relative time. */\n  time: Date | string | number;\n  read?: boolean;\n  /** Matched by a filter's `value`, such as \"mentions\". */\n  category?: string;\n  /** A 32px avatar or icon. Defaults to a glyph for `tone`. */\n  avatar?: ReactNode;\n  tone?: NotificationTone;\n  /** Inline buttons, such as Approve and View. Pressing one marks the item read. */\n  actions?: NotificationAction[];\n  /** The result of an action that set `resolvedLabel`. */\n  resolved?: string;\n}\n\nexport interface NotificationFilter {\n  value: string;\n  label: string;\n  /** Which items the tab shows. Defaults to items whose `category` equals `value`; `all` shows everything. */\n  match?: (item: NotificationItem) => boolean;\n  /** Empty state for this tab. */\n  empty?: { title: string; description?: string };\n}\n\nexport interface NotificationPanelProps {\n  /** Controlled items. */\n  items?: NotificationItem[];\n  defaultItems?: NotificationItem[];\n  onItemsChange?: (items: NotificationItem[]) => void;\n  /** Called after an inline action runs. */\n  onAction?: (item: NotificationItem, action: NotificationAction) => void;\n  /** Tabs above the list. Defaults to a single All tab, which hides the tab row. */\n  filters?: NotificationFilter[];\n  /** The reference time for grouping and relative times. Defaults to now. */\n  now?: Date;\n  title?: ReactNode;\n  /** Content under the list, such as a link to settings. */\n  footer?: ReactNode;\n  className?: string;\n}\n\nconst allFilter: NotificationFilter = { value: \"all\", label: \"All\" };\n\nfunction useItems(itemsProp: NotificationItem[] | undefined, defaultItems: NotificationItem[], onItemsChange?: (items: NotificationItem[]) => void) {\n  const [state, setState] = useState(defaultItems);\n  const items = itemsProp ?? state;\n  const set = (next: NotificationItem[]) => {\n    if (itemsProp === undefined) setState(next);\n    onItemsChange?.(next);\n  };\n  return [items, set] as const;\n}\n\n/**\n * The notification list on its own: a header with the unread count and Mark all as read, filter\n * tabs with counts, items grouped by day with unread dots and inline actions, and an empty state\n * per tab. Use it inside NotificationCenter, a sheet, or a page.\n */\nexport function NotificationPanel(props: NotificationPanelProps) {\n  const [items, setItems] = useItems(props.items, props.defaultItems ?? [], props.onItemsChange);\n  return <PanelView {...props} items={items} setItems={setItems} />;\n}\n\ninterface PanelViewProps extends NotificationPanelProps {\n  items: NotificationItem[];\n  setItems: (items: NotificationItem[]) => void;\n}\n\nfunction PanelView({ items, setItems, onAction, filters = [allFilter], now: nowProp, title = \"Notifications\", footer, className }: PanelViewProps) {\n  const reduce = useReducedMotion();\n  const [active, setActive] = useState(filters[0]?.value ?? \"all\");\n  const [message, setMessage] = useState(\"\");\n  // Set for one pass after Mark all as read, so the dots leave top to bottom.\n  const [cascade, setCascade] = useState(false);\n  const titleId = useId();\n  const pillId = `notification-tab-${useId()}`;\n  const now = nowProp ?? new Date();\n\n  const matches = (filter: NotificationFilter, item: NotificationItem) =>\n    filter.match ? filter.match(item) : filter.value === \"all\" || item.category === filter.value;\n  const filter = filters.find((f) => f.value === active) ?? filters[0] ?? allFilter;\n  const visible = items.filter((item) => matches(filter, item));\n  const unread = items.filter((item) => !item.read).length;\n\n  useEffect(() => {\n    if (!cascade) return;\n    const id = window.setTimeout(() => setCascade(false), 600);\n    return () => window.clearTimeout(id);\n  }, [cascade]);\n\n  const markRead = (id: string) => {\n    setItems(items.map((item) => (item.id === id ? { ...item, read: true } : item)));\n    setMessage(\"Marked as read.\");\n  };\n\n  const markAll = () => {\n    setCascade(true);\n    setItems(items.map((item) => (item.read ? item : { ...item, read: true })));\n    setMessage(\"All notifications marked as read.\");\n  };\n\n  const runAction = (item: NotificationItem, action: NotificationAction) => {\n    action.onSelect?.(item);\n    onAction?.(item, action);\n    setItems(items.map((i) => (i.id === item.id ? { ...i, read: true, resolved: action.resolvedLabel ?? i.resolved } : i)));\n    if (action.resolvedLabel) setMessage(`${action.resolvedLabel}.`);\n  };\n\n  const groups = groupByDay(visible, now);\n  let dotIndex = 0;\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <section aria-labelledby={titleId} className={cx(\"flex min-h-0 flex-col text-sm\", className)}>\n        <header className=\"flex items-center justify-between gap-3 px-4 pt-3.5 pb-2.5\">\n          <h2 id={titleId} className=\"flex items-baseline gap-2 text-sm font-semibold text-zinc-950 dark:text-white\">\n            {title}\n            <span className=\"text-xs font-normal text-zinc-500 tabular-nums\">{unread > 0 ? `${unread} unread` : \"All read\"}</span>\n          </h2>\n          <button\n            type=\"button\"\n            onClick={markAll}\n            disabled={unread === 0}\n            className={cx(\n              \"-mr-1.5 h-7 shrink-0 rounded-md px-1.5 text-xs font-medium text-zinc-600 select-none dark:text-zinc-400\",\n              \"transition-[background-color,color,opacity] duration-150 ease-out motion-reduce:transition-none\",\n              \"enabled:hover:bg-zinc-950/[0.04] enabled:hover:text-zinc-950 dark:enabled:hover:bg-white/[0.06] dark:enabled:hover:text-white\",\n              \"disabled:opacity-40\",\n              \"outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n            )}\n          >\n            Mark all as read\n          </button>\n        </header>\n        <BaseTabs.Root value={active} onValueChange={(value) => setActive(value as string)} className=\"flex min-h-0 flex-col\">\n          {filters.length > 1 ? (\n            <BaseTabs.List className=\"mx-3 mb-1 flex gap-0.5 rounded-lg bg-zinc-950/[0.035] p-0.5 dark:bg-white/[0.06]\">\n              {filters.map((f) => {\n                const count = items.filter((item) => !item.read && matches(f, item)).length;\n                return (\n                  <BaseTabs.Tab\n                    key={f.value}\n                    value={f.value}\n                    aria-label={count > 0 ? `${f.label}, ${count} unread` : f.label}\n                    className={cx(\n                      \"relative flex h-7 flex-1 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium whitespace-nowrap select-none\",\n                      \"text-zinc-600 hover:text-zinc-950 data-[active]:text-zinc-950 dark:text-zinc-400 dark:hover:text-white dark:data-[active]:text-white\",\n                      \"transition-colors duration-150 ease-out motion-reduce:transition-none\",\n                      \"outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-0 focus-visible:outline-sky-500\",\n                    )}\n                  >\n                    {f.value === active ? (\n                      <motion.span\n                        aria-hidden=\"true\"\n                        layoutId={pillId}\n                        transition={{ type: \"spring\", bounce: 0, duration: 0.35 }}\n                        className=\"absolute inset-0 rounded-md bg-white shadow-[0_1px_2px_rgb(0_0_0/0.08),0_0_0_1px_rgb(0_0_0/0.05)] dark:bg-black dark:shadow-[0_0_0_1px_rgb(255_255_255/0.12)]\"\n                      />\n                    ) : null}\n                    <span className=\"relative\">{f.label}</span>\n                    {count > 0 ? <span className=\"relative font-mono text-[11px] text-zinc-500 tabular-nums\">{count}</span> : null}\n                  </BaseTabs.Tab>\n                );\n              })}\n            </BaseTabs.List>\n          ) : null}\n          {/* One panel whose value follows the active tab, so switching cross-fades instead of remounting. */}\n          <BaseTabs.Panel value={active} className=\"min-h-0 overflow-y-auto overscroll-contain outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-sky-500\">\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              <motion.div\n                key={active}\n                initial={{ opacity: 0, y: reduce ? 0 : 4 }}\n                animate={{ opacity: 1, y: 0 }}\n                exit={{ opacity: 0, transition: { duration: reduce ? 0 : 0.08 } }}\n                transition={{ duration: reduce ? 0 : 0.2, ease }}\n                className=\"pb-1.5\"\n              >\n                {visible.length === 0 ? (\n                  <EmptyState title={filter.empty?.title ?? \"You are all caught up\"} description={filter.empty?.description ?? \"New notifications will show up here.\"} />\n                ) : (\n                  groups.map((group) => (\n                    <section key={group.label} aria-label={group.label}>\n                      <h3 className=\"px-4 pt-2.5 pb-1 text-xs font-medium text-zinc-500\">{group.label}</h3>\n                      <ul>\n                        <AnimatePresence initial={false}>\n                          {group.items.map((item) => {\n                            const index = item.read ? 0 : dotIndex++;\n                            return (\n                              <Row\n                                key={item.id}\n                                item={item}\n                                now={now}\n                                cascadeDelay={cascade ? Math.min(index, 10) * 0.035 : 0}\n                                onRead={() => markRead(item.id)}\n                                onAction={(action) => runAction(item, action)}\n                              />\n                            );\n                          })}\n                        </AnimatePresence>\n                      </ul>\n                    </section>\n                  ))\n                )}\n              </motion.div>\n            </AnimatePresence>\n          </BaseTabs.Panel>\n        </BaseTabs.Root>\n        {footer ? <footer className=\"border-t border-zinc-950/[0.07] px-4 py-2.5 dark:border-white/[0.08]\">{footer}</footer> : null}\n        <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n          {message}\n        </span>\n      </section>\n    </MotionConfig>\n  );\n}\n\nfunction Row({\n  item,\n  now,\n  cascadeDelay,\n  onRead,\n  onAction,\n}: {\n  item: NotificationItem;\n  now: Date;\n  cascadeDelay: number;\n  onRead: () => void;\n  onAction: (action: NotificationAction) => void;\n}) {\n  const reduce = useReducedMotion();\n  const titleId = useId();\n  const date = toDate(item.time);\n\n  return (\n    // New arrivals open their space and fade in; rows below shift down rather than jump.\n    <motion.li\n      layout={reduce ? false : \"position\"}\n      initial={{ opacity: 0, height: 0 }}\n      animate={{ opacity: 1, height: \"auto\" }}\n      exit={{ opacity: 0, height: 0, transition: { duration: reduce ? 0 : 0.16 } }}\n      transition={reduce ? { duration: 0 } : { height: { duration: 0.28, ease }, opacity: { duration: 0.22, delay: 0.08 }, layout: { duration: 0.28, ease } }}\n      className=\"relative overflow-hidden\"\n    >\n      <div className=\"relative grid grid-cols-[2rem_1fr] gap-x-3 px-4 py-2.5\">\n      <span aria-hidden=\"true\" className=\"flex size-8 items-center justify-center\">\n        {item.avatar ?? <ToneGlyph tone={item.tone ?? \"neutral\"} />}\n      </span>\n      <div className=\"grid min-w-0 gap-0.5 pr-5\">\n        <div className=\"flex items-baseline justify-between gap-3\">\n          <p\n            id={titleId}\n            className={cx(\n              \"min-w-0 leading-5 transition-colors duration-200 motion-reduce:transition-none\",\n              item.read ? \"text-zinc-600 dark:text-zinc-400\" : \"font-medium text-zinc-950 dark:text-white\",\n            )}\n          >\n            {item.title}\n          </p>\n          <time dateTime={date.toISOString()} title={date.toLocaleString()} className=\"shrink-0 font-mono text-[11px] text-zinc-500 tabular-nums\">\n            {relativeTime(date, now)}\n          </time>\n        </div>\n        {item.body ? <p className=\"line-clamp-2 leading-5 text-zinc-600 dark:text-zinc-400\">{item.body}</p> : null}\n        {item.actions?.length || item.resolved ? (\n          <div className=\"relative mt-1.5 h-7\">\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              {item.resolved ? (\n                <motion.p\n                  key=\"resolved\"\n                  initial={{ opacity: 0, y: reduce ? 0 : 4 }}\n                  animate={{ opacity: 1, y: 0 }}\n                  transition={{ duration: reduce ? 0 : 0.22, ease }}\n                  className=\"flex h-7 items-center gap-1.5 text-xs text-zinc-600 dark:text-zinc-400\"\n                >\n                  <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4 text-emerald-600 dark:text-emerald-400\">\n                    <circle cx=\"8\" cy=\"8\" r=\"6.25\" />\n                    <path d=\"m5.5 8.25 1.75 1.75 3.25-3.5\" />\n                  </svg>\n                  {item.resolved}\n                </motion.p>\n              ) : (\n                <motion.div\n                  key=\"actions\"\n                  exit={{ opacity: 0, y: reduce ? 0 : -4, transition: { duration: reduce ? 0 : 0.12 } }}\n                  className=\"flex gap-1.5\"\n                >\n                  {item.actions!.map((action) => (\n                    <button\n                      key={action.label}\n                      type=\"button\"\n                      aria-describedby={titleId}\n                      onClick={() => onAction(action)}\n                      className={cx(\n                        \"inline-flex h-7 items-center rounded-md px-2.5 text-xs font-medium whitespace-nowrap select-none\",\n                        \"transition-[background-color,border-color,color,scale] duration-150 ease-out active:duration-100 motion-safe:active:scale-[0.97] motion-reduce:transition-none\",\n                        \"outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n                        action.primary\n                          ? \"bg-zinc-950 text-white shadow-[inset_0_1px_0_rgb(255_255_255/0.12)] hover:bg-zinc-800 dark:bg-white dark:text-black dark:hover:bg-zinc-200\"\n                          : \"border border-zinc-950/12 bg-white text-zinc-950 hover:border-zinc-950/20 hover:bg-zinc-950/[0.03] dark:border-white/15 dark:bg-black dark:text-white dark:hover:border-white/25 dark:hover:bg-white/[0.06]\",\n                      )}\n                    >\n                      {action.label}\n                    </button>\n                  ))}\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n        ) : null}\n      </div>\n      <AnimatePresence initial={false}>\n        {item.read ? null : (\n          <motion.button\n            key=\"dot\"\n            type=\"button\"\n            aria-label=\"Mark as read\"\n            aria-describedby={titleId}\n            onClick={onRead}\n            exit={{ opacity: 0, scale: 0.3, transition: { duration: reduce ? 0 : 0.18, ease: \"easeOut\", delay: reduce ? 0 : cascadeDelay } }}\n            className={cx(\n              \"group/dot absolute top-3 right-2.5 flex size-6 items-center justify-center rounded-full\",\n              \"outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-0 focus-visible:outline-sky-500\",\n            )}\n          >\n            <span\n              className={cx(\n                \"size-2 rounded-full bg-sky-500\",\n                \"transition-[scale,box-shadow] duration-150 ease-out motion-reduce:transition-none\",\n                \"group-hover/dot:scale-125 group-hover/dot:shadow-[0_0_0_3px_rgb(14_165_233/0.18)]\",\n              )}\n            />\n          </motion.button>\n        )}\n      </AnimatePresence>\n      </div>\n    </motion.li>\n  );\n}\n\nfunction EmptyState({ title, description }: { title: string; description?: string }) {\n  return (\n    <div className=\"flex flex-col items-center px-6 pt-8 pb-9 text-center\">\n      <span aria-hidden=\"true\" className=\"mb-3 flex size-10 items-center justify-center rounded-full border border-zinc-950/10 text-zinc-500 dark:border-white/15\">\n        <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4\">\n          <path d=\"M4.25 6.5a3.75 3.75 0 0 1 7.5 0c0 2.5.75 3.75 1.5 4.5H2.75c.75-.75 1.5-2 1.5-4.5Z\" />\n          <path d=\"M6.5 13.25a1.6 1.6 0 0 0 3 0\" />\n        </svg>\n      </span>\n      <p className=\"font-medium text-zinc-950 dark:text-white\">{title}</p>\n      {description ? <p className=\"mt-1 max-w-56 text-xs leading-5 text-zinc-500\">{description}</p> : null}\n    </div>\n  );\n}\n\nfunction ToneGlyph({ tone }: { tone: NotificationTone }) {\n  const color = {\n    neutral: \"text-zinc-500\",\n    info: \"text-sky-600 dark:text-sky-400\",\n    success: \"text-emerald-600 dark:text-emerald-400\",\n    danger: \"text-red-600 dark:text-red-400\",\n    warning: \"text-amber-600 dark:text-amber-400\",\n  }[tone];\n  return (\n    <span className={cx(\"flex size-8 items-center justify-center rounded-full border border-zinc-950/10 dark:border-white/12\", color)}>\n      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4\">\n        <circle cx=\"8\" cy=\"8\" r=\"6.25\" />\n        {tone === \"success\" ? <path d=\"m5.5 8.25 1.75 1.75 3.25-3.5\" /> : null}\n        {tone === \"danger\" ? <path d=\"m6 6 4 4m0-4-4 4\" /> : null}\n        {tone === \"warning\" ? <path d=\"M6.75 6v4M9.25 6v4\" /> : null}\n        {tone === \"info\" ? <path d=\"M8 7.5v3M8 5.25v.01\" /> : null}\n        {tone === \"neutral\" ? <path d=\"M8 5.5v2.75l1.75 1\" /> : null}\n      </svg>\n    </span>\n  );\n}\n\nexport interface NotificationBellProps extends Omit<BasePopover.Trigger.Props, \"className\" | \"children\"> {\n  /** Unread count. Zero hides the badge. */\n  count: number;\n  /** Counts above this show as `max+`. */\n  max?: number;\n  className?: string;\n}\n\n/**\n * The bell trigger. Its badge slides out from behind the bell's corner and pops in, its digits pop\n * when the count changes, the bell swings once when the count grows, and the badge shrinks away\n * when everything is read.\n */\nexport function NotificationBell({ count, max = 99, className, ...props }: NotificationBellProps) {\n  const reduce = useReducedMotion();\n  const [scope, animateBell] = useAnimate<HTMLSpanElement>();\n  const previous = useRef(count);\n\n  useEffect(() => {\n    if (count > previous.current && !reduce && scope.current) {\n      void animateBell(scope.current, { rotate: [0, 14, -10, 6, -3, 0] }, { duration: 0.6, ease: \"easeOut\" });\n    }\n    previous.current = count;\n  }, [count, reduce, animateBell, scope]);\n\n  const shown = count > max ? `${max}+` : String(count);\n\n  return (\n    <BasePopover.Trigger\n      aria-label={count > 0 ? `Notifications, ${count} unread` : \"Notifications\"}\n      className={cx(\n        \"relative inline-flex size-9 items-center justify-center rounded-lg select-none\",\n        \"text-zinc-600 hover:bg-zinc-950/[0.04] hover:text-zinc-950 dark:text-zinc-400 dark:hover:bg-white/[0.06] dark:hover:text-white\",\n        \"data-[popup-open]:bg-zinc-950/[0.06] data-[popup-open]:text-zinc-950 dark:data-[popup-open]:bg-white/[0.09] dark:data-[popup-open]:text-white\",\n        \"transition-[background-color,color,scale] duration-150 ease-out motion-safe:active:scale-[0.95] motion-reduce:transition-none\",\n        \"outline-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n        className,\n      )}\n      {...props}\n    >\n      <span ref={scope} className=\"flex origin-[50%_2px]\">\n        <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-[18px]\">\n          <path d=\"M4.25 6.5a3.75 3.75 0 0 1 7.5 0c0 2.5.75 3.75 1.5 4.5H2.75c.75-.75 1.5-2 1.5-4.5Z\" />\n          <path d=\"M6.5 13.25a1.6 1.6 0 0 0 3 0\" />\n        </svg>\n      </span>\n      <AnimatePresence initial={false}>\n        {count > 0 ? (\n          // Outer: slides out from behind the bell. Inner: pops. On exit only the inner shrinks away.\n          <motion.span\n            key=\"badge\"\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute top-1 left-[55%]\"\n            initial={reduce ? false : { x: -7, y: 7 }}\n            animate={{ x: 0, y: 0 }}\n            exit={{ x: 0, y: 0 }}\n            transition={{ duration: reduce ? 0 : 0.26, ease }}\n          >\n            <motion.span\n              className={cx(\n                \"flex h-4 min-w-4 items-center justify-center overflow-hidden rounded-full px-1\",\n                \"bg-zinc-950 font-mono text-[10px] leading-none font-medium text-white tabular-nums ring-2 ring-white\",\n                \"dark:bg-white dark:text-black dark:ring-black\",\n              )}\n              initial={reduce ? false : { scale: 0.4, opacity: 0, filter: \"blur(2px)\" }}\n              animate={{ scale: 1, opacity: 1, filter: \"blur(0px)\" }}\n              exit={reduce ? { opacity: 0, transition: { duration: 0 } } : { scale: 0.4, opacity: 0, filter: \"blur(2px)\", transition: { duration: 0.16, ease: \"easeIn\" } }}\n              transition={reduce ? { duration: 0 } : { type: \"spring\", bounce: 0.4, duration: 0.42 }}\n            >\n              <AnimatePresence mode=\"popLayout\" initial={false}>\n                <motion.span\n                  key={shown}\n                  initial={reduce ? false : { y: \"70%\", scale: 0.7, opacity: 0, filter: \"blur(1.5px)\" }}\n                  animate={{ y: 0, scale: 1, opacity: 1, filter: \"blur(0px)\" }}\n                  exit={reduce ? { opacity: 0, transition: { duration: 0 } } : { y: \"-70%\", scale: 0.7, opacity: 0, filter: \"blur(1.5px)\", transition: { duration: 0.14, ease: \"easeOut\" } }}\n                  transition={{ type: \"spring\", bounce: 0.35, duration: 0.45, delay: reduce ? 0 : 0.04 }}\n                  className=\"block\"\n                >\n                  {shown}\n                </motion.span>\n              </AnimatePresence>\n            </motion.span>\n          </motion.span>\n        ) : null}\n      </AnimatePresence>\n    </BasePopover.Trigger>\n  );\n}\n\nexport interface NotificationCenterProps extends NotificationPanelProps {\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: BasePopover.Root.Props[\"onOpenChange\"];\n  /** Where focus goes when the panel opens. Defaults to the first control in the panel. */\n  initialFocus?: BasePopover.Popup.Props[\"initialFocus\"];\n  side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n  align?: \"start\" | \"center\" | \"end\";\n  /** Element to portal the panel into. Defaults to `document.body`. */\n  container?: BasePopover.Portal.Props[\"container\"];\n  /** Classes for the bell. */\n  triggerClassName?: string;\n}\n\n/** A bell with an unread badge that opens the notification panel in a popover. */\nexport function NotificationCenter({\n  open,\n  defaultOpen,\n  onOpenChange,\n  side = \"bottom\",\n  align = \"end\",\n  container,\n  initialFocus,\n  triggerClassName,\n  items: itemsProp,\n  defaultItems = [],\n  onItemsChange,\n  className,\n  ...panelProps\n}: NotificationCenterProps) {\n  const [items, setItems] = useItems(itemsProp, defaultItems, onItemsChange);\n  const unread = items.filter((item) => !item.read).length;\n\n  return (\n    <BasePopover.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n      <NotificationBell count={unread} className={triggerClassName} />\n      <BasePopover.Portal container={container}>\n        <BasePopover.Positioner\n          side={side}\n          align={align}\n          sideOffset={8}\n          collisionPadding={12}\n          // Flip between below and above, but never to the side, where the panel would cover its own bar.\n          collisionAvoidance={{ side: \"flip\", align: \"shift\", fallbackAxisSide: \"none\" }}\n          className=\"z-50\"\n        >\n          <BasePopover.Popup\n            initialFocus={initialFocus}\n            className={cx(\n              \"flex max-h-[min(34rem,var(--available-height))] w-[min(23rem,calc(100vw-1.5rem))] origin-(--transform-origin) flex-col overflow-hidden rounded-xl\",\n              \"border border-zinc-950/10 bg-white text-zinc-950 shadow-[0_12px_32px_-8px_rgb(0_0_0/0.18)]\",\n              \"dark:border-white/15 dark:bg-black dark:text-white dark:shadow-[0_16px_48px_-12px_rgb(0_0_0/1),inset_0_1px_0_rgb(255_255_255/0.08)]\",\n              \"transition-[opacity,scale] duration-160 ease-[cubic-bezier(0.23,1,0.32,1)] motion-reduce:transition-none\",\n              \"data-[starting-style]:opacity-0 motion-safe:data-[starting-style]:scale-96\",\n              \"data-[ending-style]:opacity-0 data-[ending-style]:duration-110 data-[ending-style]:ease-out motion-safe:data-[ending-style]:scale-98\",\n              \"outline-none\",\n              className,\n            )}\n          >\n            <PanelView {...panelProps} items={items} setItems={setItems} />\n          </BasePopover.Popup>\n        </BasePopover.Positioner>\n      </BasePopover.Portal>\n    </BasePopover.Root>\n  );\n}\n\nfunction toDate(value: Date | string | number) {\n  return value instanceof Date ? value : new Date(value);\n}\n\nfunction dayDiff(date: Date, now: Date) {\n  const a = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();\n  const b = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n  return Math.round((b - a) / 86_400_000);\n}\n\nfunction groupByDay(items: NotificationItem[], now: Date) {\n  const order = [\"Today\", \"Yesterday\", \"This week\", \"Earlier\"];\n  const buckets = new Map<string, NotificationItem[]>();\n  const sorted = items.slice().sort((a, b) => toDate(b.time).getTime() - toDate(a.time).getTime());\n  for (const item of sorted) {\n    const diff = dayDiff(toDate(item.time), now);\n    const label = diff <= 0 ? \"Today\" : diff === 1 ? \"Yesterday\" : diff < 7 ? \"This week\" : \"Earlier\";\n    const list = buckets.get(label) ?? [];\n    list.push(item);\n    buckets.set(label, list);\n  }\n  return order.filter((label) => buckets.has(label)).map((label) => ({ label, items: buckets.get(label)! }));\n}\n\nfunction relativeTime(date: Date, now: Date) {\n  const minutes = Math.round((now.getTime() - date.getTime()) / 60_000);\n  const diff = dayDiff(date, now);\n  if (diff <= 0) {\n    if (minutes < 1) return \"now\";\n    if (minutes < 60) return `${minutes}m`;\n    return `${Math.floor(minutes / 60)}h`;\n  }\n  if (diff === 1) return new Intl.DateTimeFormat(undefined, { hour: \"numeric\", minute: \"2-digit\" }).format(date);\n  if (diff < 7) return new Intl.DateTimeFormat(undefined, { weekday: \"short\" }).format(date);\n  return new Intl.DateTimeFormat(undefined, { month: \"short\", day: \"numeric\" }).format(date);\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { NotificationCenter, type NotificationItem } from \"@/components/shaken/ui/notification-center\";\n\nconst now = new Date(\"2026-11-16T15:30:00\");\nconst ago = (minutes: number) => new Date(now.getTime() - minutes * 60_000);\n\nfunction Initials({ children }: { children: string }) {\n  return (\n    <span className=\"flex size-8 items-center justify-center rounded-full bg-zinc-950/[0.06] text-[11px] font-medium text-zinc-700 dark:bg-white/[0.1] dark:text-zinc-300\">\n      {children}\n    </span>\n  );\n}\n\nconst items: NotificationItem[] = [\n  {\n    id: \"deploy\",\n    category: \"approvals\",\n    tone: \"warning\",\n    title: \"Deploy to production needs approval\",\n    body: \"release-2.4 from Theo Brandt, 14 files changed, all checks passed.\",\n    time: ago(6),\n    actions: [\n      { label: \"Approve\", primary: true, resolvedLabel: \"Approved\" },\n      { label: \"View diff\" },\n    ],\n  },\n  {\n    id: \"mention\",\n    category: \"mentions\",\n    avatar: <Initials>IA</Initials>,\n    title: \"Ines Alvarez mentioned you\",\n    body: \"Can you check whether the 88% holds on the long-context set before we flip the flag?\",\n    time: ago(24),\n    actions: [{ label: \"Reply\" }],\n  },\n  { id: \"eval\", category: \"system\", tone: \"success\", title: \"Nightly evaluation finished\", body: \"320 of 320 cases passed in 11m 42s.\", time: ago(130) },\n  {\n    id: \"billing\",\n    category: \"system\",\n    tone: \"danger\",\n    title: \"Billing worker failed 3 times\",\n    body: \"The payments webhook timed out after 30s. Retries are paused.\",\n    time: ago(60 * 22),\n    read: true,\n  },\n  {\n    id: \"invite\",\n    avatar: <Initials>MO</Initials>,\n    title: \"Mara Okafor invited you to Northwind Labs\",\n    time: ago(60 * 24 * 3),\n    read: true,\n    resolved: \"Accepted\",\n  },\n  { id: \"key\", category: \"system\", tone: \"warning\", title: \"Key sk_test_0d77 expires in 7 days\", time: ago(60 * 24 * 9), read: true },\n];\n\nexport default function NotificationCenterExample() {\n  return (\n    <div className=\"flex w-full max-w-md items-center justify-between rounded-xl border border-zinc-950/10 bg-white py-1.5 pr-1.5 pl-4 dark:border-white/10 dark:bg-black\">\n      <span className=\"text-sm font-medium text-zinc-950 dark:text-white\">Northwind Labs</span>\n      <NotificationCenter\n        defaultItems={items}\n        now={now}\n        filters={[\n          { value: \"all\", label: \"All\" },\n          { value: \"mentions\", label: \"Mentions\", empty: { title: \"No mentions\", description: \"When someone mentions you in a run or thread, it shows up here.\" } },\n          { value: \"approvals\", label: \"Approvals\", empty: { title: \"Nothing to approve\", description: \"Deploys and tool calls that wait for you land here.\" } },\n          { value: \"system\", label: \"System\" },\n        ]}\n      />\n    </div>\n  );\n}\n"
  }
}
