{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "micro-notify-bell",
  "type": "registry:component",
  "title": "Notify Bell",
  "description": "A notification bell that swings on a damped pendulum with a lagging clapper every time the count goes up. Drag it sideways to swing it by hand. The badge digits roll like an odometer.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "notification",
    "bell",
    "badge",
    "physics",
    "counter",
    "micro"
  ],
  "docs": "https://hyperblur.dev/effects/micro-notify-bell",
  "files": [
    {
      "path": "registry/hyperblur/micro-notify-bell.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/micro-notify-bell.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MicroNotifyBellProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"children\"> {\n  count?: number;\n  defaultCount?: number;\n  max?: number;\n  size?: number;\n  accent?: string;\n  label?: string;\n  clearOnOpen?: boolean;\n  idle?: boolean;\n  onCountChange?: (count: number) => void;\n  onOpen?: () => void;\n}\n\nconst css = `\n.hb-wf9 {\n  --hb-wf9-c: #ff4d5e;\n  --hb-wf9-s: 46px;\n  position: relative;\n  display: inline-grid;\n  place-items: center;\n  width: var(--hb-wf9-s);\n  height: var(--hb-wf9-s);\n  margin: 0;\n  padding: 0;\n  box-sizing: border-box;\n  border: 1px solid #2a2a2a;\n  border-radius: 14px;\n  background: linear-gradient(180deg, #1b1b1b, #131313);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 8px 18px -10px rgba(0,0,0,0.9);\n  color: #d4d4d4;\n  cursor: grab;\n  touch-action: none;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;\n}\n.hb-wf9 *, .hb-wf9 *::before, .hb-wf9 *::after { box-sizing: border-box; }\n.hb-wf9:hover { border-color: #3a3a3a; color: #fff; }\n.hb-wf9:focus-visible { outline: 2px solid var(--hb-wf9-c); outline-offset: 3px; }\n.hb-wf9:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-wf9-svg { width: 56%; height: 56%; overflow: visible; }\n.hb-wf9-bell { transform-origin: 12px 3.2px; }\n.hb-wf9-clap { transform-origin: 12px 15px; }\n.hb-wf9-ring {\n  position: absolute;\n  inset: 0;\n  border-radius: inherit;\n  border: 1.5px solid var(--hb-wf9-c);\n  opacity: 0;\n  pointer-events: none;\n  animation: hb-wf9-ring 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) both;\n}\n.hb-wf9-ring + .hb-wf9-ring { animation-delay: 0.16s; }\n@keyframes hb-wf9-ring { 0% { opacity: 0.7; transform: scale(1); } 100% { opacity: 0; transform: scale(1.65); } }\n.hb-wf9-bd {\n  position: absolute;\n  top: -6px;\n  right: -7px;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  min-width: 20px;\n  height: 20px;\n  padding: 0 5px;\n  border-radius: 999px;\n  background: linear-gradient(180deg, color-mix(in srgb, var(--hb-wf9-c) 85%, #fff), var(--hb-wf9-c));\n  box-shadow: 0 0 0 2.5px #0a0a0a, 0 4px 10px -2px color-mix(in srgb, var(--hb-wf9-c) 60%, transparent);\n  color: #fff;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 11px;\n  font-weight: 700;\n  line-height: 1;\n  font-variant-numeric: tabular-nums;\n  overflow: hidden;\n  transform: scale(1);\n  transition: transform 0.35s cubic-bezier(0.3, 1.8, 0.4, 1), opacity 0.2s ease;\n}\n.hb-wf9-bd[data-zero=\"true\"] { transform: scale(0); opacity: 0; }\n.hb-wf9-dg { position: relative; display: block; height: 11px; overflow: hidden; }\n.hb-wf9-col { display: flex; flex-direction: column; transition: transform 0.5s cubic-bezier(0.25, 1.3, 0.4, 1); }\n.hb-wf9-col span { display: block; height: 11px; line-height: 11px; text-align: center; }\n.hb-wf9-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wf9, .hb-wf9-bd, .hb-wf9-col { transition: none; }\n  .hb-wf9-ring { animation: none; display: none; }\n}\n`;\n\nconst digits = Array.from({ length: 10 }, (_, i) => i);\n\nexport function MicroNotifyBell({\n  count,\n  defaultCount = 3,\n  max = 99,\n  size = 46,\n  accent = \"#ff4d5e\",\n  label = \"Notifications\",\n  clearOnOpen = true,\n  idle = false,\n  disabled,\n  onCountChange,\n  onOpen,\n  className = \"\",\n  style,\n  onClick,\n  ...rest\n}: MicroNotifyBellProps) {\n  const [inner, setInner] = React.useState(defaultCount);\n  const n = count ?? inner;\n  const [rings, setRings] = React.useState(0);\n  const [awake, setAwake] = React.useState(false);\n  const bellRef = React.useRef<SVGGElement>(null);\n  const clapRef = React.useRef<SVGGElement>(null);\n  const sim = React.useRef({ a: 0, v: 0, c: 0, cv: 0, raf: 0, last: 0, running: false, reduced: false });\n  const drag = React.useRef({ on: false, x: 0, lastX: 0, moved: false });\n  const prev = React.useRef(n);\n  const latest = React.useRef({ n, count, onCountChange });\n\n  React.useEffect(() => {\n    latest.current = { n, count, onCountChange };\n  });\n\n  const run = React.useCallback(() => {\n    const s = sim.current;\n    if (s.running || s.reduced) return;\n    s.running = true;\n    s.last = performance.now();\n    const step = (t: number) => {\n      const dt = Math.min(0.033, (t - s.last) / 1000);\n      s.last = t;\n      if (!drag.current.on) {\n        s.v += (-260 * s.a - 5.2 * s.v) * dt;\n        s.a += s.v * dt;\n      }\n      s.cv += (-420 * (s.c + s.a * 0.9) - 9 * s.cv) * dt;\n      s.c += s.cv * dt;\n      bellRef.current?.setAttribute(\"transform\", `rotate(${s.a.toFixed(2)} 12 3.2)`);\n      clapRef.current?.setAttribute(\"transform\", `rotate(${(s.c * 1.4).toFixed(2)} 12 15)`);\n      if (!drag.current.on && Math.abs(s.a) < 0.05 && Math.abs(s.v) < 0.05 && Math.abs(s.c) < 0.05 && Math.abs(s.cv) < 0.05) {\n        s.running = false;\n        bellRef.current?.setAttribute(\"transform\", \"rotate(0 12 3.2)\");\n        clapRef.current?.setAttribute(\"transform\", \"rotate(0 12 15)\");\n        return;\n      }\n      s.raf = requestAnimationFrame(step);\n    };\n    s.raf = requestAnimationFrame(step);\n  }, []);\n\n  const ring = React.useCallback(\n    (strength = 1) => {\n      const s = sim.current;\n      s.v += 210 * strength * (s.a >= 0 ? 1 : -1);\n      setRings((r) => r + 1);\n      run();\n    },\n    [run],\n  );\n\n  React.useEffect(() => {\n    const s = sim.current;\n    s.reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    return () => cancelAnimationFrame(s.raf);\n  }, []);\n\n  React.useEffect(() => {\n    if (n > prev.current) ring(1);\n    prev.current = n;\n  }, [n, ring]);\n\n  React.useEffect(() => {\n    if (!idle || awake) return;\n    const id = window.setInterval(() => {\n      const l = latest.current;\n      const next = l.n >= 12 ? 2 : l.n + 1;\n      if (l.count === undefined) setInner(next);\n      l.onCountChange?.(next);\n    }, 3200);\n    return () => window.clearInterval(id);\n  }, [idle, awake]);\n\n  const shown = Math.min(n, max);\n  const over = n > max;\n  const chars = String(shown).split(\"\");\n\n  return (\n    <button\n      type=\"button\"\n      aria-label={n > 0 ? `${label}, ${n} unread` : label}\n      disabled={disabled}\n      className={`hb-wf9 ${className}`}\n      style={{ ...style, [\"--hb-wf9-c\" as string]: accent, [\"--hb-wf9-s\" as string]: `${size}px` }}\n      onPointerEnter={() => setAwake(true)}\n      onPointerDown={(e) => {\n        if (disabled) return;\n        setAwake(true);\n        e.currentTarget.setPointerCapture(e.pointerId);\n        drag.current = { on: true, x: e.clientX, lastX: e.clientX, moved: false };\n        run();\n      }}\n      onPointerMove={(e) => {\n        const d = drag.current;\n        if (!d.on) return;\n        const dx = e.clientX - d.x;\n        if (Math.abs(dx) > 3) d.moved = true;\n        const s = sim.current;\n        const target = Math.max(-38, Math.min(38, dx * 1.1));\n        s.v = (target - s.a) * 30;\n        s.a = target;\n        d.lastX = e.clientX;\n      }}\n      onPointerUp={() => {\n        drag.current.on = false;\n        run();\n      }}\n      onPointerCancel={() => {\n        drag.current.on = false;\n        run();\n      }}\n      onClick={(e) => {\n        onClick?.(e);\n        if (drag.current.moved) {\n          drag.current.moved = false;\n          return;\n        }\n        ring(0.55);\n        onOpen?.();\n        if (clearOnOpen && n > 0) {\n          if (count === undefined) setInner(0);\n          onCountChange?.(0);\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-micro-notify-bell\" precedence=\"default\">\n        {css}\n      </style>\n      {rings > 0 ? (\n        <React.Fragment key={rings}>\n          <span className=\"hb-wf9-ring\" aria-hidden=\"true\" />\n          <span className=\"hb-wf9-ring\" aria-hidden=\"true\" />\n        </React.Fragment>\n      ) : null}\n      <svg className=\"hb-wf9-svg\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n        <g ref={bellRef}>\n          <g ref={clapRef}>\n            <path d=\"M10 18.6a2.1 2.1 0 0 0 4 0\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n          </g>\n          <path\n            d=\"M12 3.2c-3.5 0-5.8 2.6-5.8 6v3c0 1.4-.6 2.5-1.5 3.5-.5.6-.1 1.5.7 1.5h13.2c.8 0 1.2-.9.7-1.5-.9-1-1.5-2.1-1.5-3.5v-3c0-3.4-2.3-6-5.8-6z\"\n            fill=\"currentColor\"\n            fillOpacity=\"0.14\"\n            stroke=\"currentColor\"\n            strokeWidth=\"1.7\"\n            strokeLinejoin=\"round\"\n          />\n          <circle cx=\"12\" cy=\"2.6\" r=\"1.1\" fill=\"currentColor\" />\n        </g>\n      </svg>\n      <span className=\"hb-wf9-bd\" data-zero={n === 0} aria-hidden=\"true\">\n        {chars.map((c, i) => (\n          <span key={`${chars.length}-${i}`} className=\"hb-wf9-dg\">\n            <span className=\"hb-wf9-col\" style={{ transform: `translateY(${-Number(c) * 11}px)` }}>\n              {digits.map((d) => (\n                <span key={d}>{d}</span>\n              ))}\n            </span>\n          </span>\n        ))}\n        {over ? <span>+</span> : null}\n      </span>\n      <span className=\"hb-wf9-sr\" aria-live=\"polite\">\n        {n > 0 ? `${n} unread` : \"\"}\n      </span>\n    </button>\n  );\n}\n"
    }
  ]
}