{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toast-stack",
  "type": "registry:component",
  "title": "Toast Stack",
  "description": "Notifications that rest in a tidy stack: a new toast drops onto the pile squashed and springs into shape, and hover or focus fans the stack into a list. Fling a toast sideways and it tilts and skids off; with a duration set, the front toast counts down along its bottom edge and waits while the stack is open. Also includes Undo Toast, where an archived row shrinks into the toast, a ring counts down around Undo, and undo drops the row back in place. Also includes Promise Toast, a pill that follows a deploy step by step with progress filling behind the words and lands on a live link or an error with a way to the logs. Also includes Timed Toast Stack, toasts that stack like cards with each one's time left running round its edge, swipe-away with momentum, an upload that turns into done in place and a delete with Undo.",
  "dependencies": [
    "framer-motion",
    "react"
  ],
  "registryDependencies": [
    "https://www.nexus-ui.com/api/registry/nexus-font",
    "https://www.nexus-ui.com/api/registry/ui-sounds"
  ],
  "files": [
    {
      "path": "next-ui/toast-stack/index.ts",
      "type": "registry:lib",
      "target": "components/toast-stack/index.ts",
      "content": "export { ToastStack, useToastStack } from \"./toast-stack\";\nexport type { ToastItem, ToastStackProps, ToastType } from \"./toast-stack\";\nexport { UndoToast } from \"./undo-toast\";\nexport type { UndoToastMail, UndoToastProps } from \"./undo-toast\";\nexport { PromiseToast } from \"./promise-toast\";\nexport type { PromiseToastProps } from \"./promise-toast\";\nexport { default as TimedToastStack } from \"./timed-toast-stack\";\nexport type { TimedToastStackProps } from \"./timed-toast-stack\";\n"
    },
    {
      "path": "next-ui/toast-stack/promise-toast.tsx",
      "type": "registry:component",
      "target": "components/toast-stack/promise-toast.tsx",
      "content": "\"use client\";\nimport { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { useSound } from \"@/lib/ui-sounds\";\n\nexport interface PromiseToastProps {\n  /** Called when \"Visit\" is pressed on the success toast. Nothing navigates on its own. */\n  onVisit?: () => void;\n  /** Called when \"View logs\" is pressed on the failure toast. */\n  onViewLogs?: () => void;\n  /** Runs a good deploy, then one with a bug, on a loop until someone touches the component. Never runs under reduced motion. */\n  autoplay?: boolean;\n  /** Plays interface sounds on interaction. They follow the site-wide sound switch. Autoplay makes the same sounds once the visitor has used the page. */\n  enableSound?: boolean;\n  /** Extra classes for the wrapper. */\n  className?: string;\n}\n\ntype Step = { label: string; to: number; ms: number };\nconst STEPS: Step[] = [\n  { label: \"Installing dependencies\", to: 0.22, ms: 900 },\n  { label: \"Building 48 pages\", to: 0.64, ms: 1500 },\n  { label: \"Uploading to the edge\", to: 0.92, ms: 1000 },\n];\ntype Run = { id: number; fail: boolean; step: number; progress: number; state: \"running\" | \"ok\" | \"fail\" };\n\nconst FOCUS = \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#0071e3] dark:focus-visible:outline-[#0a84ff]\";\nconst FOCUS_ON_DARK = \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/70\";\n\n/** True while the element is on screen and the tab is visible. Only observes when `enabled`. */\nfunction useDemoActive(ref: RefObject<HTMLElement | null>, enabled: boolean) {\n  const [active, setActive] = useState(false);\n  useEffect(() => {\n    const el = ref.current;\n    if (!enabled || !el) return;\n    let shown = !document.hidden;\n    let inView = false;\n    const sync = () => setActive(shown && inView);\n    const io = new IntersectionObserver(([entry]) => {\n      inView = entry.isIntersecting;\n      sync();\n    });\n    io.observe(el);\n    const onVisibility = () => {\n      shown = !document.hidden;\n      sync();\n    };\n    document.addEventListener(\"visibilitychange\", onVisibility);\n    return () => {\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVisibility);\n      setActive(false);\n    };\n  }, [ref, enabled]);\n  return active;\n}\n\nfunction Icon({ state }: { state: Run[\"state\"] }) {\n  return (\n    <span className=\"relative flex h-6 w-6 flex-none items-center justify-center\" aria-hidden=\"true\">\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        {state === \"running\" && (\n          <motion.svg key=\"spin\" width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" initial={{ opacity: 0, scale: 0.6 }} animate={{ opacity: 1, scale: 1, rotate: 360 }} exit={{ opacity: 0, scale: 0.6 }} transition={{ rotate: { duration: 0.9, repeat: Infinity, ease: \"linear\" } }}>\n            <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"none\" stroke=\"rgba(255,255,255,.18)\" strokeWidth=\"2.5\" />\n            <path d=\"M12 3a9 9 0 019 9\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"2.5\" strokeLinecap=\"round\" />\n          </motion.svg>\n        )}\n        {state === \"ok\" && (\n          <motion.svg key=\"ok\" width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" initial={{ scale: 0.3, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} transition={{ type: \"spring\", stiffness: 500, damping: 18 }}>\n            <circle cx=\"12\" cy=\"12\" r=\"11\" fill=\"#30d158\" />\n            <motion.path d=\"M7 12.5l3.2 3.2L17 9\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"2.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={{ pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ delay: 0.12, duration: 0.3 }} />\n          </motion.svg>\n        )}\n        {state === \"fail\" && (\n          <motion.svg key=\"no\" width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" initial={{ scale: 0.3, opacity: 0 }} animate={{ scale: 1, opacity: 1 }} transition={{ type: \"spring\", stiffness: 500, damping: 18 }}>\n            <circle cx=\"12\" cy=\"12\" r=\"11\" fill=\"#ff453a\" />\n            <motion.path d=\"M8.5 8.5l7 7M15.5 8.5l-7 7\" fill=\"none\" stroke=\"#fff\" strokeWidth=\"2.6\" strokeLinecap=\"round\" initial={{ pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ delay: 0.12, duration: 0.3 }} />\n          </motion.svg>\n        )}\n      </AnimatePresence>\n    </span>\n  );\n}\n\n/**\n * A toast that follows a promise from start to finish instead of popping up\n * at the end. The pill shows each step as it happens with its own progress\n * filling behind the text, resizes smoothly as the wording changes, and lands\n * on success with the live link and actions, or on failure with the error\n * count and a way to the logs.\n */\nexport function PromiseToast({ onVisit, onViewLogs, autoplay = false, enableSound = true, className = \"\" }: PromiseToastProps) {\n  const play = useSound(enableSound);\n  const reduce = useReducedMotion() ?? false;\n  const [run, setRun] = useState<Run | null>(null);\n  const root = useRef<HTMLDivElement>(null);\n  const timers = useRef<number[]>([]);\n  const touched = useRef(false);\n  const nextFail = useRef(false);\n  const runId = useRef(0);\n  const active = useDemoActive(root, autoplay && !reduce);\n\n  const clear = () => {\n    timers.current.forEach((t) => window.clearTimeout(t));\n    timers.current = [];\n  };\n  useEffect(() => clear, []);\n\n  // `audible` is true for runs the user started; the autoplay loop answers through `play.auto`.\n  const start = (fail: boolean, audible = false) => {\n    clear();\n    runId.current += 1;\n    const id = runId.current;\n    setRun({ id, fail, step: 0, progress: 0.04, state: \"running\" });\n    let t = 120;\n    STEPS.forEach((s, i) => {\n      if (fail && i === 2) return;\n      timers.current.push(window.setTimeout(() => setRun((r) => (r && r.id === id ? { ...r, step: i, progress: s.to } : r)), t));\n      t += s.ms;\n    });\n    timers.current.push(\n      window.setTimeout(() => {\n        setRun((r) => (r && r.id === id ? { ...r, progress: fail ? r.progress : 1, state: fail ? \"fail\" : \"ok\" } : r));\n        if (audible) play(fail ? \"error\" : \"success\");\n        else play.auto(fail ? \"error\" : \"success\");\n      }, t),\n    );\n    timers.current.push(window.setTimeout(() => setRun((r) => (r && r.id === id ? null : r)), t + 4200));\n  };\n\n  const startRef = useRef(start);\n  useEffect(() => {\n    startRef.current = start;\n  });\n\n  useEffect(() => {\n    if (!autoplay || reduce || !active) return;\n    const go = () => {\n      if (touched.current) return;\n      play.auto(\"ping\");\n      startRef.current(nextFail.current);\n      nextFail.current = !nextFail.current;\n    };\n    const first = window.setTimeout(go, 700);\n    const id = window.setInterval(go, 8200);\n    return () => {\n      window.clearTimeout(first);\n      window.clearInterval(id);\n    };\n  }, [autoplay, reduce, active, play]);\n\n  const label = !run ? \"\" : run.state === \"ok\" ? \"Deployed to production\" : run.state === \"fail\" ? \"Build failed with 2 errors\" : STEPS[run.step].label;\n  const fill = run?.state === \"fail\" ? \"rgba(255,69,58,.28)\" : run?.state === \"ok\" ? \"rgba(48,209,88,.24)\" : \"rgba(255,255,255,.12)\";\n  const settle = reduce ? { duration: 0.15 } : { type: \"spring\" as const, stiffness: 380, damping: 30, x: { duration: 0.4 } };\n\n  return (\n    <div\n      ref={root}\n      className={`flex w-[420px] max-w-full flex-col items-center gap-6 ${className}`}\n      onPointerDown={() => {\n        touched.current = true;\n      }}\n    >\n      <div className=\"relative flex h-[200px] w-full items-end justify-center overflow-hidden rounded-[28px] bg-white p-5 shadow-[0_0_0_1px_rgba(0,0,0,.05),0_24px_50px_-30px_rgba(0,0,0,.3)] dark:bg-[#1c1c1e] dark:shadow-[0_0_0_1px_rgba(255,255,255,.08),0_24px_50px_-30px_rgba(0,0,0,.9)]\">\n        <span className=\"absolute left-5 top-4 text-[12px] font-medium text-[#6e6e73] dark:text-[#a1a1a6]\">nexus-ui / marketing-site</span>\n        <span className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n          {label}\n        </span>\n        <AnimatePresence>\n          {run && (\n            <motion.div\n              key={run.id}\n              layout={!reduce}\n              role=\"group\"\n              aria-label=\"Deploy progress\"\n              className=\"relative max-w-full overflow-hidden bg-[#1d1d1f] text-white shadow-[0_20px_40px_-16px_rgba(0,0,0,.55)] dark:bg-[#2c2c2e] dark:shadow-[0_0_0_1px_rgba(255,255,255,.1),0_20px_40px_-16px_rgba(0,0,0,.9)]\"\n              style={{ borderRadius: 26 }}\n              initial={reduce ? { opacity: 0 } : { y: 40, opacity: 0, scale: 0.9 }}\n              animate={{ y: 0, opacity: 1, scale: 1, x: run.state === \"fail\" && !reduce ? [0, -8, 7, -4, 0] : 0 }}\n              exit={reduce ? { opacity: 0, transition: { duration: 0.12 } } : { y: 24, opacity: 0, scale: 0.95, filter: \"blur(4px)\", transition: { duration: 0.25 } }}\n              transition={settle}\n            >\n              {/* progress lives behind the words */}\n              <motion.span\n                aria-hidden=\"true\"\n                className=\"absolute inset-y-0 left-0 w-full origin-left\"\n                style={{ background: fill }}\n                initial={{ scaleX: 0 }}\n                animate={{ scaleX: run.state === \"running\" ? run.progress : 1, opacity: run.state === \"running\" ? 1 : [1, 1, 0.5] }}\n                transition={{ scaleX: reduce ? { duration: 0.15 } : { type: \"spring\", stiffness: 60, damping: 20 }, opacity: { duration: 1.2 } }}\n              />\n              <motion.div layout={reduce ? false : \"position\"} className=\"relative flex items-center gap-3 py-3 pl-3.5 pr-5\">\n                <Icon state={run.state} />\n                <span className=\"relative block h-[20px] min-w-0 overflow-hidden\" aria-hidden=\"true\">\n                  <AnimatePresence mode=\"popLayout\" initial={false}>\n                    <motion.span\n                      key={label}\n                      className=\"block whitespace-nowrap text-[14.5px] font-medium leading-[20px]\"\n                      initial={reduce ? { opacity: 0 } : { y: 16, opacity: 0, filter: \"blur(4px)\" }}\n                      animate={{ y: 0, opacity: 1, filter: \"blur(0px)\" }}\n                      exit={reduce ? { opacity: 0 } : { y: -16, opacity: 0, filter: \"blur(4px)\" }}\n                      transition={{ type: \"spring\", stiffness: 420, damping: 34, filter: { duration: 0.2 } }}\n                    >\n                      {label}\n                    </motion.span>\n                  </AnimatePresence>\n                </span>\n                {run.state === \"running\" && (\n                  <motion.span layout={!reduce} aria-hidden=\"true\" className=\"ml-1 text-[13px] tabular-nums text-white/50\">\n                    {Math.round(run.progress * 100)}%\n                  </motion.span>\n                )}\n              </motion.div>\n              <AnimatePresence initial={false}>\n                {run.state !== \"running\" && (\n                  <motion.div layout={!reduce} className=\"relative flex items-center gap-2 px-3.5 pb-3\" initial={{ opacity: 0, y: -6 }} animate={{ opacity: 1, y: 0, transition: { delay: 0.15 } }} exit={{ opacity: 0 }}>\n                    {run.state === \"ok\" ? (\n                      <>\n                        <span className=\"mr-auto min-w-0 truncate rounded-full bg-white/10 px-3 py-1.5 font-mono text-[12px] text-white/80\">marketing.nexus.app</span>\n                        <button type=\"button\" onClick={() => onVisit?.()} className={`h-8 flex-none rounded-full bg-white px-3.5 text-[13px] font-semibold text-[#1d1d1f] ${FOCUS_ON_DARK}`}>\n                          Visit\n                        </button>\n                      </>\n                    ) : (\n                      <>\n                        <span className=\"mr-auto min-w-0 truncate font-mono text-[12px] text-[#ff9f9a]\">pricing.tsx:42 · Unexpected token</span>\n                        <button type=\"button\" onClick={() => onViewLogs?.()} className={`h-8 flex-none rounded-full bg-white/10 px-3.5 text-[13px] font-semibold hover:bg-white/15 ${FOCUS_ON_DARK}`}>\n                          View logs\n                        </button>\n                      </>\n                    )}\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n      <div className=\"flex flex-wrap justify-center gap-2\">\n        <motion.button\n          type=\"button\"\n          whileTap={reduce ? undefined : { scale: 0.95 }}\n          onClick={() => {\n            touched.current = true;\n            play(\"ping\");\n            start(false, true);\n          }}\n          className={`h-10 rounded-full bg-[#1d1d1f] px-5 text-[14px] font-medium text-white dark:bg-[#f5f5f7] dark:text-[#1d1d1f] ${FOCUS}`}\n        >\n          Deploy\n        </motion.button>\n        <motion.button\n          type=\"button\"\n          whileTap={reduce ? undefined : { scale: 0.95 }}\n          onClick={() => {\n            touched.current = true;\n            play(\"ping\");\n            start(true, true);\n          }}\n          className={`h-10 rounded-full bg-white px-5 text-[14px] font-medium text-[#1d1d1f] shadow-[0_0_0_1px_rgba(0,0,0,.08)] dark:bg-[#2c2c2e] dark:text-[#f5f5f7] dark:shadow-[0_0_0_1px_rgba(255,255,255,.1)] ${FOCUS}`}\n        >\n          Deploy with a bug\n        </motion.button>\n      </div>\n    </div>\n  );\n}\n"
    },
    {
      "path": "next-ui/toast-stack/timed-toast-stack.tsx",
      "type": "registry:component",
      "target": "components/toast-stack/timed-toast-stack.tsx",
      "content": "\"use client\";\n\n/* eslint-disable react-hooks/immutability, react-hooks/refs, react-hooks/purity -- these rules assume code runs while rendering; here refs, timers and setState are used in handlers, effects and animation frames, and the animation state lives in refs on purpose */\n\nimport {\n  AnimatePresence,\n  type PanInfo,\n  animate,\n  motion,\n  useInView,\n  useMotionValue,\n  useReducedMotion,\n} from \"framer-motion\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAutoplaySoundAllowed, useSoundsEnabled } from \"@/lib/ui-sounds\";\n\nexport type ToastKind = \"success\" | \"error\" | \"upload\" | \"undo\";\nexport type TimedToastStackProps = {\n  /** how long a toast stays, ms (paused while you hover the stack) */\n  duration?: number;\n  /** Soft sounds: a pop as each arrives. They also follow the site-wide sound switch. */\n  enableSound?: boolean;\n  /** 0 to 1 */\n  volume?: number;\n  autoplay?: boolean;\n  className?: string;\n};\n\n// ───────────── sound: small synthesised notes, no audio files. The browser keeps it silent until the visitor has\n// clicked or pressed a key somewhere on the page, so autoplay only makes sound once someone is using the page. ─────────────\n\ntype Engine = { ctx: AudioContext; noise: AudioBuffer };\nconst ENGINE_KEY = \"__uiSoundEngine\";\nconst engine = () => (globalThis as unknown as Record<string, Engine | undefined>)[ENGINE_KEY] ?? null;\nfunction unlockAudio() {\n  const g = globalThis as unknown as Record<string, Engine | undefined>;\n  const e = g[ENGINE_KEY];\n  if (e) {\n    if (e.ctx.state === \"suspended\") void e.ctx.resume();\n    return;\n  }\n  const AC =\n    window.AudioContext ?? (window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;\n  if (!AC) return;\n  const ctx = new AC();\n  const noise = ctx.createBuffer(1, ctx.sampleRate, ctx.sampleRate);\n  const d = noise.getChannelData(0);\n  for (let i = 0; i < d.length; i++) d[i] = Math.random() * 2 - 1;\n  g[ENGINE_KEY] = { ctx, noise };\n}\n\ntype NoteOpts = {\n  at?: number;\n  dur?: number;\n  gain?: number;\n  type?: OscillatorType;\n  glide?: number;\n  bell?: number;\n};\ntype Sound = {\n  /** a soft glassy note: a sine with a faint bell partial above it */\n  note: (freq: number, o?: NoteOpts) => void;\n  /** air moving: filtered noise swept from one pitch to another */\n  whoosh: (from: number, to: number, o?: { at?: number; dur?: number; gain?: number }) => void;\n  /** a tiny dry click */\n  tick: (o?: { at?: number; freq?: number; gain?: number }) => void;\n};\n\nfunction useSound(enabled: boolean, volume: number, allow: () => boolean = () => true): Sound {\n  useEffect(() => {\n    if (!enabled) return;\n    window.addEventListener(\"pointerdown\", unlockAudio, true);\n    window.addEventListener(\"keydown\", unlockAudio, true);\n    return () => {\n      window.removeEventListener(\"pointerdown\", unlockAudio, true);\n      window.removeEventListener(\"keydown\", unlockAudio, true);\n    };\n  }, [enabled]);\n  const on = useRef(enabled);\n  const vol = useRef(Math.max(0, Math.min(1, volume)));\n  const allowRef = useRef(allow);\n  useEffect(() => {\n    on.current = enabled;\n    vol.current = Math.max(0, Math.min(1, volume));\n    allowRef.current = allow;\n  });\n  return useMemo(() => {\n    const live = () => {\n      const e = engine();\n      return e && on.current && allowRef.current() && vol.current > 0 && e.ctx.state === \"running\" ? e : null;\n    };\n    const env = (ctx: AudioContext, t: number, peak: number, attack: number, dur: number) => {\n      const g = ctx.createGain();\n      g.gain.setValueAtTime(0.0001, t);\n      g.gain.exponentialRampToValueAtTime(Math.max(0.0002, peak), t + attack);\n      g.gain.exponentialRampToValueAtTime(0.0001, t + dur);\n      return g;\n    };\n    return {\n      note(freq, o = {}) {\n        const e = live();\n        if (!e) return;\n        const { ctx } = e;\n        const t = ctx.currentTime + 0.01 + (o.at ?? 0);\n        const dur = o.dur ?? 0.3;\n        const peak = (o.gain ?? 0.14) * vol.current;\n        const lp = ctx.createBiquadFilter();\n        lp.type = \"lowpass\";\n        lp.frequency.value = 7000;\n        lp.connect(ctx.destination);\n        const g = env(ctx, t, peak, 0.006, dur);\n        g.connect(lp);\n        const a = ctx.createOscillator();\n        a.type = o.type ?? \"sine\";\n        a.frequency.setValueAtTime(freq, t);\n        if (o.glide) a.frequency.exponentialRampToValueAtTime(o.glide, t + dur * 0.6);\n        a.connect(g);\n        a.start(t);\n        a.stop(t + dur + 0.05);\n        const bell = o.bell ?? 0.25;\n        if (bell > 0) {\n          const g2 = env(ctx, t, peak * bell, 0.003, dur * 0.4);\n          g2.connect(lp);\n          const b = ctx.createOscillator();\n          b.frequency.setValueAtTime(freq * 2.76, t);\n          if (o.glide) b.frequency.exponentialRampToValueAtTime(o.glide * 2.76, t + dur * 0.6);\n          b.connect(g2);\n          b.start(t);\n          b.stop(t + dur * 0.4 + 0.05);\n        }\n      },\n      whoosh(from, to, o = {}) {\n        const e = live();\n        if (!e) return;\n        const { ctx, noise } = e;\n        const t = ctx.currentTime + 0.01 + (o.at ?? 0);\n        const dur = Math.min(0.95, o.dur ?? 0.4);\n        const src = ctx.createBufferSource();\n        src.buffer = noise;\n        const bp = ctx.createBiquadFilter();\n        bp.type = \"bandpass\";\n        bp.Q.value = 1.1;\n        bp.frequency.setValueAtTime(from, t);\n        bp.frequency.exponentialRampToValueAtTime(to, t + dur);\n        const g = ctx.createGain();\n        const peak = (o.gain ?? 0.08) * vol.current;\n        g.gain.setValueAtTime(0.0001, t);\n        g.gain.exponentialRampToValueAtTime(Math.max(0.0002, peak), t + dur * 0.35);\n        g.gain.exponentialRampToValueAtTime(0.0001, t + dur);\n        src.connect(bp).connect(g).connect(ctx.destination);\n        src.start(t, Math.random() * 0.3);\n        src.stop(t + dur + 0.05);\n      },\n      tick(o = {}) {\n        const e = live();\n        if (!e) return;\n        const { ctx, noise } = e;\n        const t = ctx.currentTime + 0.005 + (o.at ?? 0);\n        const src = ctx.createBufferSource();\n        src.buffer = noise;\n        const bp = ctx.createBiquadFilter();\n        bp.type = \"bandpass\";\n        bp.frequency.value = o.freq ?? 3200;\n        bp.Q.value = 4;\n        const g = env(ctx, t, (o.gain ?? 0.09) * vol.current, 0.001, 0.03);\n        src.connect(bp).connect(g).connect(ctx.destination);\n        src.start(t, Math.random() * 0.5);\n        src.stop(t + 0.05);\n      },\n    } satisfies Sound;\n  }, []);\n}\n\nconst I = {\n  ok: \"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24m45.66 85.66l-56 56a8 8 0 0 1-11.32 0l-24-24a8 8 0 0 1 11.32-11.32L112 148.69l50.34-50.35a8 8 0 0 1 11.32 11.32\",\n  err: \"M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24m-8 56a8 8 0 0 1 16 0v56a8 8 0 0 1-16 0Zm8 104a12 12 0 1 1 12-12a12 12 0 0 1-12 12\",\n  trash:\n    \"M216 48h-40v-8a24 24 0 0 0-24-24h-48a24 24 0 0 0-24 24v8H40a8 8 0 0 0 0 16h8v144a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16V64h8a8 8 0 0 0 0-16M112 168a8 8 0 0 1-16 0v-64a8 8 0 0 1 16 0Zm48 0a8 8 0 0 1-16 0v-64a8 8 0 0 1 16 0Zm0-120H96v-8a8 8 0 0 1 8-8h48a8 8 0 0 1 8 8Z\",\n  up: \"M247.93 124.52C246.11 77.54 207.07 40 160.06 40a88.1 88.1 0 0 0-78.77 48.67A87.5 87.5 0 0 0 72 127.73a8.18 8.18 0 0 1-7.43 8.27a8 8 0 0 1-8.57-8a103.7 103.7 0 0 1 5.34-32.92a4 4 0 0 0-4.75-5.18A64.09 64.09 0 0 0 8 152c0 35.19 29.75 64 65 64h87a88.09 88.09 0 0 0 87.93-91.48m-50.27 9.14a8 8 0 0 1-11.32 0L168 115.31V176a8 8 0 0 1-16 0v-60.69l-18.34 18.35a8 8 0 0 1-11.32-11.32l32-32a8 8 0 0 1 11.32 0l32 32a8 8 0 0 1 0 11.32\",\n  x: \"M208.49 191.51a12 12 0 0 1-17 17L128 145l-63.51 63.49a12 12 0 0 1-17-17L111 128L47.51 64.49a12 12 0 0 1 17-17L128 111l63.51-63.52a12 12 0 0 1 17 17L145 128Z\",\n  undo: \"M228 128a100 100 0 0 1-98.66 100H128a99.4 99.4 0 0 1-68.62-27.29a12 12 0 0 1 16.48-17.45a76 76 0 1 0-1.57-109c-.13.13-.25.25-.39.37L54.89 92H72a12 12 0 0 1 0 24H24a12 12 0 0 1-12-12V56a12 12 0 0 1 24 0v20.72l21.48-19.66A100 100 0 0 1 228 128\",\n};\nconst Ico = ({ d, size }: { d: string; size: number }) => (\n  <svg viewBox=\"0 0 256 256\" width={size} height={size} style={{ display: \"block\" }} aria-hidden=\"true\">\n    <path fill=\"currentColor\" d={d} />\n  </svg>\n);\n\ntype T = {\n  id: number;\n  kind: ToastKind;\n  title: string;\n  body: string;\n  phase: \"busy\" | \"done\";\n  out?: number;\n};\nconst H = 64,\n  GAP = 10;\nconst PRESETS: Record<ToastKind, Omit<T, \"id\" | \"phase\">> = {\n  success: {\n    kind: \"success\",\n    title: \"Changes saved\",\n    body: \"Your profile is up to date.\",\n  },\n  error: {\n    kind: \"error\",\n    title: \"Couldn't reach the server\",\n    body: \"We'll try again in a moment.\",\n  },\n  upload: {\n    kind: \"upload\",\n    title: \"Uploading 3 photos\",\n    body: \"Keep this tab open.\",\n  },\n  undo: {\n    kind: \"undo\",\n    title: \"Message deleted\",\n    body: \"It's in the bin for 30 days.\",\n  },\n};\n\n/**\n * Toasts that stack like cards.\n *\n * New ones rise in at the front and push the others back into a neat stack, each one smaller and dimmer than the one\n * before. Point at the stack and it fans out so you can read them all, and their timers pause. Each toast's time left\n * runs round its edge as a thin line. Swipe one away (it flies off with your speed and a little spin) or let it run\n * out. An upload toast spins and then turns into a done toast in place; an error shakes as it arrives; a delete toast\n * has Undo, which takes it back.\n *   <TimedToastStack duration={5000} />\n */\nexport default function TimedToastStack({\n  duration = 5000,\n  enableSound = true,\n  volume = 0.8,\n  autoplay = false,\n  className = \"\",\n}: TimedToastStackProps) {\n  const reduce = !!useReducedMotion();\n  const [siteSound] = useSoundsEnabled();\n  // a demo playing by itself only makes sound where the page allows it (see AutoplaySound)\n  const autoplaySoundOk = useAutoplaySoundAllowed();\n  const autoplayOk = useRef(autoplaySoundOk);\n  useEffect(() => {\n    autoplayOk.current = autoplaySoundOk;\n  }, [autoplaySoundOk]);\n  const sfx = useSound(enableSound && siteSound, volume, () => touched.current || autoplayOk.current);\n  const rootRef = useRef<HTMLDivElement>(null);\n  const inView = useInView(rootRef, { margin: \"100px\" });\n  const touched = useRef(false);\n  const [list, setList] = useState<T[]>([]);\n  const [fan, setFan] = useState(false);\n  const nextId = useRef(1);\n\n  const push = (kind: ToastKind, extra?: Partial<T>) => {\n    const t: T = {\n      ...PRESETS[kind],\n      phase: kind === \"upload\" ? \"busy\" : \"done\",\n      id: nextId.current++,\n      ...extra,\n    };\n    setList((l) => [t, ...l].slice(0, 6));\n    sfx.note(kind === \"error\" ? 330 : 740, {\n      glide: kind === \"error\" ? 260 : 990,\n      dur: 0.12,\n      gain: 0.04,\n      bell: 0.2,\n    });\n    if (kind === \"upload\")\n      window.setTimeout(() => {\n        setList((l) =>\n          l.map((x) =>\n            x.id === t.id\n              ? {\n                  ...x,\n                  phase: \"done\",\n                  title: \"3 photos uploaded\",\n                  body: \"They're in your library now.\",\n                }\n              : x,\n          ),\n        );\n        sfx.note(988, { dur: 0.3, gain: 0.03, bell: 0.6 });\n      }, 2200);\n  };\n  // when one is thrown out, the rest wait a beat before closing the gap, so the leaving card isn't run over\n  const thrownAt = useRef(0);\n  const drop = (id: number, out = 0) => {\n    if (out) thrownAt.current = performance.now();\n    setList((l) => l.map((x) => (x.id === id ? { ...x, out } : x)));\n    // let the exit read its direction, then remove\n    window.setTimeout(() => setList((l) => l.filter((x) => x.id !== id)), 16);\n  };\n  const undo = (id: number) => {\n    drop(id);\n    window.setTimeout(\n      () =>\n        push(\"success\", {\n          title: \"Message restored\",\n          body: \"It's back in your inbox.\",\n        }),\n      120,\n    );\n  };\n\n  // autoplay: a little afternoon of notifications\n  useEffect(() => {\n    if (!autoplay || !inView) return;\n    const seq: ToastKind[] = [\"success\", \"upload\", \"undo\", \"error\", \"success\"];\n    let k = 0;\n    const id = window.setInterval(() => {\n      if (touched.current) return window.clearInterval(id);\n      push(seq[k++ % seq.length]);\n    }, 1700);\n    return () => window.clearInterval(id);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [autoplay, inView]);\n\n  return (\n    <div\n      ref={rootRef}\n      onPointerDown={() => {\n        touched.current = true;\n        unlockAudio();\n      }}\n      className={`relative w-full max-w-[460px] overflow-hidden rounded-[28px] text-[#1d1d1f] ${className}`}\n      style={{\n        height: 420,\n        background: \"linear-gradient(180deg, #ffffff 0%, #f2f2f6 100%)\",\n        boxShadow: \"0 0 0 1px rgba(0,0,0,.06), 0 30px 60px -40px rgba(0,0,0,.35)\",\n      }}\n    >\n      <div className=\"p-5\">\n        <div className=\"text-[17px] font-semibold tracking-[-0.01em]\">Notifications</div>\n        <div className=\"mt-1 text-[13px] text-[#86868b]\">\n          Make some toast. Point at the stack to fan it out; swipe one away.\n        </div>\n        <div className=\"mt-4 flex flex-wrap gap-2\">\n          {(\n            [\n              [\"success\", \"Save\", \"#30d158\"],\n              [\"upload\", \"Upload\", \"#0a84ff\"],\n              [\"undo\", \"Delete\", \"#8e8e93\"],\n              [\"error\", \"Fail\", \"#ff453a\"],\n            ] as const\n          ).map(([k, l, c]) => (\n            <button\n              key={k}\n              type=\"button\"\n              onClick={() => {\n                touched.current = true;\n                unlockAudio();\n                push(k);\n              }}\n              className=\"flex items-center gap-2 rounded-full bg-white px-3.5 py-2 text-[13px] font-medium outline-none shadow-[0_0_0_1px_rgba(0,0,0,.08),0_2px_6px_-3px_rgba(0,0,0,.2)] transition active:scale-95 focus-visible:shadow-[0_0_0_2px_#0071e3]\"\n            >\n              <span className=\"h-2 w-2 rounded-full\" style={{ background: c }} />\n              {l}\n            </button>\n          ))}\n        </div>\n      </div>\n\n      {/* the stack */}\n      <ol\n        aria-label=\"Notifications\"\n        className=\"absolute inset-x-4 bottom-4\"\n        style={{ height: fan ? Math.min(list.length, 4) * (H + GAP) : H + 24 }}\n        onPointerEnter={() => setFan(true)}\n        onPointerLeave={() => setFan(false)}\n        onFocusCapture={() => setFan(true)}\n        onBlurCapture={(e) => !e.currentTarget.contains(e.relatedTarget as Node) && setFan(false)}\n      >\n        <AnimatePresence initial={false}>\n          {list.map((t, i) => (\n            <Toast\n              key={t.id}\n              t={t}\n              i={i}\n              fan={fan}\n              count={list.length}\n              duration={duration}\n              reduce={reduce}\n              onDrop={drop}\n              onUndo={undo}\n              sfx={sfx}\n              late={performance.now() - thrownAt.current < 80}\n            />\n          ))}\n        </AnimatePresence>\n      </ol>\n      <div className=\"sr-only\" aria-live=\"polite\">\n        {list[0] ? `${list[0].title}. ${list[0].body}` : \"\"}\n      </div>\n    </div>\n  );\n}\n\nfunction Toast({\n  t,\n  i,\n  fan,\n  count,\n  duration,\n  reduce,\n  onDrop,\n  onUndo,\n  sfx,\n  late,\n}: {\n  late: boolean;\n  t: T;\n  i: number;\n  fan: boolean;\n  count: number;\n  duration: number;\n  reduce: boolean;\n  onDrop: (id: number, out?: number) => void;\n  onUndo: (id: number) => void;\n  sfx: Sound;\n}) {\n  // the time left runs round the edge; it waits while the stack is fanned out, and until an upload is done\n  const left = useMotionValue(1);\n  const paused = fan || t.phase === \"busy\";\n  useEffect(() => {\n    if (paused || reduce) return;\n    const a = animate(left, 0, {\n      duration: (left.get() * duration) / 1000,\n      ease: \"linear\",\n    });\n    a.then(() => left.get() <= 0.001 && onDrop(t.id, 0));\n    return () => a.stop();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [paused, reduce]);\n  const dash = useMotionValue(0);\n  useEffect(() => left.on(\"change\", (v) => dash.set(1 - v)), [left, dash]);\n\n  const tone =\n    t.kind === \"error\" ? \"#ff453a\" : t.kind === \"undo\" ? \"#8e8e93\" : t.phase === \"busy\" ? \"#0a84ff\" : \"#30d158\";\n  // stacked: smaller, dimmer and tucked behind; fanned: in a column\n  const target = fan\n    ? { y: -i * (H + GAP), scale: 1, opacity: 1 }\n    : { y: -i * 12, scale: 1 - i * 0.05, opacity: i > 2 ? 0 : 1 - i * 0.18 };\n  const onDragEnd = (_: unknown, info: PanInfo) => {\n    if (info.offset.x > 90 || info.velocity.x > 600) {\n      sfx.whoosh(900, 300, { dur: 0.25, gain: 0.03 });\n      onDrop(t.id, Math.max(info.velocity.x, 900));\n    }\n  };\n  return (\n    <motion.li\n      layout={false}\n      role=\"status\"\n      initial={reduce ? { opacity: 0 } : { y: 60, scale: 0.9, opacity: 0, x: t.kind === \"error\" ? 0 : 0 }}\n      animate={{\n        ...target,\n        x: 0,\n        zIndex: count - i,\n        ...(t.kind === \"error\" && i === 0 && !reduce ? { x: [0, -8, 7, -5, 3, 0] } : {}),\n      }}\n      exit={\n        reduce\n          ? { opacity: 0, transition: { duration: 0.2 } }\n          : t.out === -1\n            ? // the close button: a small pull back, then it glides off to the right, gathering speed, tilting a touch\n              // and fading as it goes, while the cards behind rise to take its place\n              {\n                x: [0, -8, 470],\n                rotate: [0, -0.6, 4],\n                scale: [1, 1.01, 0.96],\n                opacity: [1, 1, 0],\n                filter: [\"blur(0px)\", \"blur(0px)\", \"blur(1.5px)\"],\n                transition: {\n                  duration: 0.5,\n                  times: [0, 0.16, 1],\n                  ease: [\"easeOut\", [0.45, 0, 0.25, 1]],\n                },\n              }\n            : t.out\n              ? // swiped: it keeps the speed your finger gave it; only its travel is a spring, so nothing jumps\n                {\n                  x: 480,\n                  rotate: 7,\n                  opacity: 0,\n                  transition: {\n                    x: {\n                      type: \"spring\",\n                      stiffness: 170,\n                      damping: 26,\n                      velocity: t.out,\n                    },\n                    rotate: { duration: 0.5, ease: \"easeOut\" },\n                    opacity: { duration: 0.42, delay: 0.06, ease: \"easeIn\" },\n                  },\n                }\n              : // timed out: it sinks into the stack and fades\n                {\n                  y: target.y + 20,\n                  scale: 0.9,\n                  opacity: 0,\n                  transition: { duration: 0.3, ease: [0.4, 0, 0.2, 1] },\n                }\n      }\n      transition={{\n        type: \"spring\",\n        stiffness: 380,\n        damping: 32,\n        delay: late ? 0.17 : 0,\n        x: { duration: 0.45 },\n      }}\n      drag={i === 0 || fan ? \"x\" : false}\n      dragConstraints={{ left: 0, right: 0 }}\n      dragElastic={{ left: 0.08, right: 0.9 }}\n      onDragEnd={onDragEnd}\n      className=\"absolute inset-x-0 bottom-0 cursor-grab touch-pan-y active:cursor-grabbing\"\n      style={{ height: H, transformOrigin: \"50% 100%\" }}\n    >\n      <div\n        className=\"relative h-full overflow-hidden rounded-[18px] text-white\"\n        style={{\n          background: \"linear-gradient(180deg, rgba(44,44,48,.96), rgba(28,28,31,.96))\",\n          boxShadow:\n            \"0 0 0 1px rgba(255,255,255,.06) inset, 0 1px 0 rgba(255,255,255,.08) inset, 0 16px 32px -14px rgba(0,0,0,.55)\",\n        }}\n      >\n        {/* the time left, round the edge */}\n        <svg\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0 h-full w-full\"\n          preserveAspectRatio=\"none\"\n        >\n          <motion.rect\n            x=\"0.75\"\n            y=\"0.75\"\n            rx=\"17.25\"\n            ry=\"17.25\"\n            fill=\"none\"\n            stroke={tone}\n            strokeOpacity={0.75}\n            strokeWidth={1.5}\n            pathLength={1}\n            strokeDasharray=\"1 1\"\n            style={{\n              width: \"calc(100% - 1.5px)\",\n              height: \"calc(100% - 1.5px)\",\n              strokeDashoffset: dash,\n            }}\n          />\n        </svg>\n        {/* a card tucked behind shows only its edge; its words come back when the stack fans out */}\n        <motion.div\n          className=\"relative flex h-full items-center gap-3 pl-3.5 pr-2\"\n          initial={false}\n          animate={{ opacity: fan || i === 0 ? 1 : 0 }}\n          transition={{ duration: 0.2 }}\n        >\n          <span\n            className=\"relative grid h-8 w-8 shrink-0 place-items-center rounded-full\"\n            style={{ background: `${tone}26`, color: tone }}\n          >\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              {t.phase === \"busy\" ? (\n                <motion.span\n                  key=\"busy\"\n                  className=\"block h-[18px] w-[18px] rounded-full border-2 border-[#0a84ff]/30 border-t-[#0a84ff]\"\n                  animate={reduce ? undefined : { rotate: 360 }}\n                  exit={{ scale: 0.3, opacity: 0 }}\n                  transition={{\n                    repeat: Infinity,\n                    duration: 0.8,\n                    ease: \"linear\",\n                  }}\n                />\n              ) : (\n                <motion.span\n                  key=\"icon\"\n                  initial={{ scale: 0.3, rotate: -40 }}\n                  animate={{ scale: 1, rotate: 0 }}\n                  transition={{ type: \"spring\", stiffness: 520, damping: 18 }}\n                >\n                  <Ico\n                    d={t.kind === \"error\" ? I.err : t.kind === \"undo\" ? I.trash : t.kind === \"upload\" ? I.ok : I.ok}\n                    size={18}\n                  />\n                </motion.span>\n              )}\n            </AnimatePresence>\n          </span>\n          <div className=\"relative min-w-0 flex-1\">\n            <AnimatePresence mode=\"popLayout\" initial={false}>\n              <motion.div\n                key={t.title}\n                initial={{ opacity: 0, y: 8 }}\n                animate={{ opacity: 1, y: 0 }}\n                exit={{ opacity: 0, y: -8 }}\n                transition={{ duration: 0.22 }}\n              >\n                <div className=\"truncate text-[14px] font-semibold\">{t.title}</div>\n                <div className=\"truncate text-[12.5px] text-white/60\">{t.body}</div>\n              </motion.div>\n            </AnimatePresence>\n          </div>\n          {t.kind === \"undo\" && (\n            <button\n              type=\"button\"\n              onClick={() => onUndo(t.id)}\n              className=\"relative flex items-center gap-1 rounded-full bg-white/10 px-3 py-1.5 text-[13px] font-semibold outline-none transition hover:bg-white/15 focus-visible:shadow-[0_0_0_2px_#0a84ff]\"\n            >\n              <Ico d={I.undo} size={12} />\n              Undo\n            </button>\n          )}\n          <button\n            type=\"button\"\n            aria-label=\"Dismiss\"\n            onClick={() => {\n              sfx.whoosh(700, 260, { dur: 0.4, gain: 0.03 });\n              onDrop(t.id, -1);\n            }}\n            className=\"relative grid h-7 w-7 place-items-center rounded-full text-white/50 outline-none transition hover:bg-white/10 hover:text-white focus-visible:shadow-[0_0_0_2px_#0a84ff]\"\n          >\n            <Ico d={I.x} size={12} />\n          </button>\n        </motion.div>\n      </div>\n    </motion.li>\n  );\n}\n"
    },
    {
      "path": "next-ui/toast-stack/toast-stack.tsx",
      "type": "registry:component",
      "target": "components/toast-stack/toast-stack.tsx",
      "content": "\"use client\";\nimport { useCallback, useEffect, useRef, useState, type ReactNode } from \"react\";\nimport {\n  AnimatePresence,\n  animate,\n  motion,\n  useMotionValue,\n  useReducedMotion,\n  useTransform,\n  type AnimationPlaybackControls,\n  type PanInfo,\n} from \"framer-motion\";\nimport { useSound, type SoundName } from \"@/lib/ui-sounds\";\n\nexport type ToastType = \"success\" | \"error\" | \"info\" | \"warning\";\n\nexport type ToastItem = {\n  id: string;\n  title: string;\n  description?: string;\n  type?: ToastType;\n  /** Optional action button, e.g. \"Retry\" or \"Undo\". */\n  action?: { label: string };\n};\n\nexport type ToastStackProps = {\n  /** Toasts in the order they arrived; the last one sits at the front. */\n  toasts: ToastItem[];\n  /** Called when a toast is swiped away, closed, times out, or is dismissed with Escape. */\n  onDismiss: (id: string) => void;\n  /** Called when a toast's action button is pressed. */\n  onAction?: (toast: ToastItem) => void;\n  /** Which edge the stack grows from. */\n  position?: \"top\" | \"bottom\";\n  /** Fan the stack out on hover/focus, or keep it fanned out. */\n  expand?: \"hover\" | \"always\";\n  /** How many toasts are drawn at once. */\n  max?: number;\n  /** Width of each toast, in px. It shrinks to fit narrow containers. */\n  width?: number;\n  /** Dismiss the front toast after this many ms (paused while the stack is open). 0 keeps toasts until closed. */\n  duration?: number;\n  /** Fans the stack open and swipes the front toast away every few seconds until someone touches it. */\n  autoplay?: boolean;\n  /** Plays interface sounds on interaction. They follow the site-wide sound switch. Autoplay makes the same sounds once the visitor has used the page. */\n  enableSound?: boolean;\n  className?: string;\n};\n\nconst H = 64;\nconst GAP = 8;\nconst PEEK = 12;\nconst SWIPE_DISTANCE = 90;\nconst SWIPE_VELOCITY = 600;\nconst LAND = { type: \"spring\" as const, stiffness: 420, damping: 22, mass: 0.9 };\nconst FAN = { type: \"spring\" as const, stiffness: 360, damping: 30 };\n\nconst TONE: Record<ToastType, string> = {\n  success: \"#30d158\",\n  error: \"#ff3b30\",\n  info: \"#0a84ff\",\n  warning: \"#ff9f0a\",\n};\n\nfunction Icon({ type }: { type: ToastType }) {\n  const glyph: Record<ToastType, ReactNode> = {\n    success: <path d=\"M6.2 10.3 8.8 12.8 13.8 7.4\" />,\n    error: <path d=\"M7.5 7.5 12.5 12.5M12.5 7.5 7.5 12.5\" />,\n    info: <path d=\"M10 9.2V13.6M10 6.6V6.7\" />,\n    warning: <path d=\"M10 6.2V10.8M10 13.5V13.6\" />,\n  };\n  return (\n    <svg width=\"22\" height=\"22\" viewBox=\"0 0 20 20\" aria-hidden=\"true\" className=\"shrink-0\">\n      <circle cx=\"10\" cy=\"10\" r=\"9\" fill={TONE[type]} />\n      <g fill=\"none\" stroke=\"#fff\" strokeWidth=\"1.9\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n        {glyph[type]}\n      </g>\n    </svg>\n  );\n}\n\nconst ARRIVAL: Record<ToastType, SoundName> = { success: \"success\", error: \"error\", info: \"ping\", warning: \"ping\" };\n\n/**\n * Small state helper: `push` adds a toast at the front and returns its id. Pass `{ sound: true }` as the\n * second argument when the toast answers something the user did; it then plays a ping (a rising tone for\n * success, a bump for error). Toasts pushed without it stay silent.\n */\nexport function useToastStack(initial: ToastItem[] = [], options: { enableSound?: boolean } = {}) {\n  const [toasts, setToasts] = useState<ToastItem[]>(initial);\n  const counter = useRef(0);\n  const play = useSound(options.enableSound ?? true);\n  const push = useCallback(\n    (toast: Omit<ToastItem, \"id\"> & { id?: string }, opts?: { sound?: boolean }) => {\n      counter.current += 1;\n      const id = toast.id ?? `toast-${counter.current}-${Math.random().toString(36).slice(2, 7)}`;\n      setToasts((list) => [...list.filter((t) => t.id !== id), { ...toast, id }]);\n      if (opts?.sound) play(ARRIVAL[toast.type ?? \"info\"]);\n      return id;\n    },\n    [play],\n  );\n  const dismiss = useCallback((id: string) => setToasts((list) => list.filter((t) => t.id !== id)), []);\n  const clear = useCallback(() => setToasts([]), []);\n  return { toasts, push, dismiss, clear };\n}\n\nfunction Toast({\n  toast,\n  i,\n  expanded,\n  sign,\n  width,\n  max,\n  reduce,\n  bottom,\n  duration,\n  autoSwipe,\n  enableSound,\n  onDismiss,\n  onAction,\n}: {\n  toast: ToastItem;\n  i: number;\n  expanded: boolean;\n  sign: number;\n  width: number;\n  max: number;\n  reduce: boolean;\n  bottom: boolean;\n  duration: number;\n  autoSwipe: number;\n  enableSound: boolean;\n  onDismiss: (dir: number) => void;\n  onAction?: (toast: ToastItem) => void;\n}) {\n  const type = toast.type ?? \"info\";\n  const play = useSound(enableSound);\n  const front = i === 0;\n  const x = useMotionValue(0);\n  const tilt = useTransform(x, [-220, 0, 220], [-7, 0, 7]);\n  const fade = useTransform(x, [-260, -80, 0, 80, 260], [0.2, 1, 1, 1, 0.2]);\n  const life = useMotionValue(1);\n  const lifeRun = useRef<AnimationPlaybackControls | undefined>(undefined);\n  const y = sign * i * (expanded ? H + GAP : PEEK);\n  const scale = expanded ? 1 : 1 - i * 0.05;\n  const draggable = !reduce && (expanded || front);\n  const dismissRef = useRef(onDismiss);\n  useEffect(() => {\n    dismissRef.current = onDismiss;\n  });\n\n  // Auto-dismiss: only the front toast counts down, and it waits while the stack is open.\n  useEffect(() => {\n    if (!duration || !front || expanded) return;\n    const left = life.get() * duration;\n    lifeRun.current = animate(life, 0, {\n      duration: left / 1000,\n      ease: \"linear\",\n      onComplete: () => dismissRef.current(0),\n    });\n    return () => lifeRun.current?.stop();\n  }, [duration, front, expanded, life]);\n\n  // Autoplay swipe: fling the front toast off to the right.\n  const seen = useRef(autoSwipe);\n  useEffect(() => {\n    if (autoSwipe === seen.current) return;\n    seen.current = autoSwipe;\n    if (!front) return;\n    animate(x, [0, 26, 0], { duration: 0.35 });\n    const t = window.setTimeout(() => {\n      play.auto(\"swipe\");\n      dismissRef.current(1);\n    }, 380);\n    return () => window.clearTimeout(t);\n  }, [autoSwipe, front, x, play]);\n\n  const onDragEnd = (_: unknown, info: PanInfo) => {\n    if (Math.abs(info.offset.x) > SWIPE_DISTANCE || Math.abs(info.velocity.x) > SWIPE_VELOCITY) {\n      play(\"swipe\");\n      onDismiss(Math.sign(info.offset.x || info.velocity.x) || 1);\n    } else {\n      animate(x, 0, { type: \"spring\", stiffness: 500, damping: 30 });\n    }\n  };\n\n  return (\n    <motion.li\n      layout={false}\n      role={type === \"error\" ? \"alert\" : \"status\"}\n      tabIndex={0}\n      aria-label={`${toast.title}${toast.description ? `. ${toast.description}` : \"\"}`}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" || e.key === \"Delete\" || e.key === \"Backspace\") {\n          e.preventDefault();\n          play(\"swipe\", 0.6);\n          onDismiss(0);\n        }\n      }}\n      variants={{\n        exit: (dirs: Record<string, number>) => {\n          const dir = dirs?.[toast.id] ?? 0;\n          return reduce\n            ? { opacity: 0, transition: { duration: 0.15 } }\n            : dir\n              ? { x: dir * (width + 80), opacity: 0, rotate: dir * 9, transition: { type: \"spring\", stiffness: 260, damping: 30 } }\n              : { opacity: 0, scale: 0.9, y: y - sign * 10, transition: { duration: 0.18 } };\n        },\n      }}\n      // Arrives squashed, as if it dropped onto the stack, then springs into shape.\n      initial={reduce ? { opacity: 0 } : { opacity: 0, y: -sign * 34, scaleX: 1.05, scaleY: 0.86 }}\n      animate={{ opacity: !expanded && i > 2 ? 0 : 1, y, scaleX: scale, scaleY: scale }}\n      exit=\"exit\"\n      transition={reduce ? { duration: 0 } : front ? LAND : FAN}\n      className={`absolute inset-x-0 outline-none ${bottom ? \"bottom-0 origin-bottom\" : \"top-0 origin-top\"} rounded-[18px] focus-visible:ring-2 focus-visible:ring-[#0071e3] focus-visible:ring-offset-2 focus-visible:ring-offset-[#f5f5f7] dark:focus-visible:ring-[#0a84ff] dark:focus-visible:ring-offset-black`}\n      style={{ height: H, zIndex: max - i }}\n    >\n      <motion.div\n        drag={draggable ? \"x\" : false}\n        dragMomentum={false}\n        onDragEnd={onDragEnd}\n        style={{ x, rotate: tilt, opacity: fade, touchAction: \"pan-y\" }}\n        className={`relative flex h-full select-none items-center gap-3 overflow-hidden rounded-[18px] bg-white px-3.5 text-[#1d1d1f] shadow-[0_0_0_1px_rgba(0,0,0,.05),0_14px_32px_-20px_rgba(0,0,0,.4)] dark:bg-[#2c2c2e] dark:text-[#f5f5f7] dark:shadow-[0_0_0_1px_rgba(255,255,255,.08),0_14px_32px_-20px_rgba(0,0,0,.9)] ${\n          draggable ? \"cursor-grab active:cursor-grabbing\" : \"\"\n        }`}\n      >\n        <motion.div\n          className=\"flex min-w-0 flex-1 items-center gap-3\"\n          animate={{ opacity: expanded || front ? 1 : 0 }}\n          transition={{ duration: 0.18 }}\n        >\n          <Icon type={type} />\n          <div className=\"min-w-0 flex-1\">\n            <p className=\"m-0 truncate text-[14px] font-semibold leading-tight tracking-[-0.01em]\">{toast.title}</p>\n            {toast.description ? <p className=\"m-0 mt-0.5 truncate text-[13px] leading-tight text-[#6e6e73] dark:text-[#a1a1a6]\">{toast.description}</p> : null}\n          </div>\n          {toast.action ? (\n            <button\n              type=\"button\"\n              onPointerDown={(e) => e.stopPropagation()}\n              onClick={() => {\n                play(\"tap\");\n                onAction?.(toast);\n              }}\n              className=\"h-7 shrink-0 rounded-full bg-[#f0f0f3] px-3 text-[13px] font-medium text-[#1d1d1f] outline-none transition-colors hover:bg-[#e6e6ea] focus-visible:ring-2 focus-visible:ring-[#0071e3] dark:bg-[#3a3a3c] dark:text-[#f5f5f7] dark:hover:bg-[#48484a] dark:focus-visible:ring-[#0a84ff]\"\n            >\n              {toast.action.label}\n            </button>\n          ) : null}\n          <button\n            type=\"button\"\n            aria-label={`Dismiss ${toast.title}`}\n            onPointerDown={(e) => e.stopPropagation()}\n            onClick={() => {\n              play(\"swipe\", 0.6);\n              onDismiss(0);\n            }}\n            className=\"grid size-6 shrink-0 place-items-center rounded-full text-[#86868b] outline-none transition-colors hover:bg-[#f0f0f3] hover:text-[#1d1d1f] focus-visible:ring-2 focus-visible:ring-[#0071e3] dark:text-[#a1a1a6] dark:hover:bg-[#3a3a3c] dark:hover:text-[#f5f5f7] dark:focus-visible:ring-[#0a84ff]\"\n          >\n            <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\">\n              <path d=\"M1.5 1.5 8.5 8.5M8.5 1.5 1.5 8.5\" />\n            </svg>\n          </button>\n        </motion.div>\n        {duration > 0 && front ? (\n          <motion.span\n            aria-hidden=\"true\"\n            className=\"absolute inset-x-0 bottom-0 h-[2px] origin-left\"\n            style={{ scaleX: life, background: TONE[type], opacity: 0.7 }}\n          />\n        ) : null}\n      </motion.div>\n    </motion.li>\n  );\n}\n\n/**\n * Notifications that rest in a tidy stack. A new toast drops onto the pile\n * squashed and springs into shape; hover or focus fans the stack into a list;\n * fling a toast sideways and it tilts and skids off. Escape dismisses the\n * focused toast.\n */\nexport function ToastStack({\n  toasts,\n  onDismiss,\n  onAction,\n  position = \"bottom\",\n  expand = \"hover\",\n  max = 3,\n  width = 340,\n  duration = 0,\n  autoplay = false,\n  enableSound = true,\n  className = \"\",\n}: ToastStackProps) {\n  const reduce = useReducedMotion() === true;\n  const [hovered, setHovered] = useState(false);\n  const [focused, setFocused] = useState(false);\n  const [demoOpen, setDemoOpen] = useState(false);\n  const [swipe, setSwipe] = useState(0);\n  const [exitDirs, setExitDirs] = useState<Record<string, number>>({});\n  const touched = useRef(false);\n  const expanded = expand === \"always\" || hovered || focused || demoOpen;\n  const sign = position === \"bottom\" ? -1 : 1;\n\n  const visible = [...toasts].reverse().slice(0, Math.max(1, max));\n  const n = visible.length;\n  const height = n === 0 ? 0 : expanded ? n * H + (n - 1) * GAP : H + (n - 1) * PEEK;\n\n  const dismiss = (id: string, dir = 0) => {\n    setExitDirs((d) => ({ ...d, [id]: dir }));\n    onDismiss(id);\n  };\n\n  useEffect(() => {\n    if (!autoplay) return;\n    let k = 0;\n    const t = window.setInterval(() => {\n      if (touched.current) {\n        window.clearInterval(t);\n        setDemoOpen(false);\n        return;\n      }\n      const beat = k++ % 3;\n      if (beat === 0) setDemoOpen(true);\n      if (beat === 1) setDemoOpen(false);\n      if (beat === 2) setSwipe((s) => s + 1);\n    }, 1500);\n    return () => window.clearInterval(t);\n  }, [autoplay]);\n\n  const touch = () => {\n    if (touched.current) return;\n    touched.current = true;\n    setDemoOpen(false);\n  };\n\n  return (\n    <section\n      aria-label=\"Notifications\"\n      className={`relative max-w-full ${className}`}\n      style={{ width }}\n      onPointerEnter={() => setHovered(true)}\n      onPointerLeave={() => setHovered(false)}\n      onPointerDown={touch}\n      onFocus={() => {\n        touch();\n        setFocused(true);\n      }}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n      }}\n    >\n      <motion.ol\n        aria-live=\"polite\"\n        className=\"relative m-0 list-none p-0\"\n        initial={false}\n        animate={{ height }}\n        transition={reduce ? { duration: 0 } : FAN}\n      >\n        <AnimatePresence initial={false} custom={exitDirs}>\n          {visible.map((toast, i) => (\n            <Toast\n              key={toast.id}\n              toast={toast}\n              i={i}\n              expanded={expanded}\n              sign={sign}\n              width={width}\n              max={max}\n              reduce={reduce}\n              bottom={position === \"bottom\"}\n              duration={duration}\n              autoSwipe={swipe}\n              enableSound={enableSound}\n              onDismiss={(dir) => dismiss(toast.id, dir)}\n              onAction={onAction}\n            />\n          ))}\n        </AnimatePresence>\n      </motion.ol>\n    </section>\n  );\n}\n"
    },
    {
      "path": "next-ui/toast-stack/undo-toast.tsx",
      "type": "registry:component",
      "target": "components/toast-stack/undo-toast.tsx",
      "content": "\"use client\";\nimport { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { useSound } from \"@/lib/ui-sounds\";\n\nexport interface UndoToastMail {\n  id: number;\n  from: string;\n  subject: string;\n  time: string;\n  /** Avatar colour. */\n  hue: string;\n}\n\nexport interface UndoToastProps {\n  /** The rows in the list. Defaults to a small demo inbox of four messages. */\n  mails?: UndoToastMail[];\n  /** How long the toast waits for an Undo, in ms. Hovering or focusing the toast pauses the countdown. */\n  holdMs?: number;\n  /** Called when a row is archived. */\n  onArchive?: (mail: UndoToastMail) => void;\n  /** Called with the archived rows when Undo is pressed. */\n  onUndo?: (mails: UndoToastMail[]) => void;\n  /** Archives a row and undoes it on a loop until someone touches the component. Never runs under reduced motion. */\n  autoplay?: boolean;\n  /** Plays interface sounds on interaction. They follow the site-wide sound switch. Autoplay makes the same sounds once the visitor has used the page. */\n  enableSound?: boolean;\n  /** Extra classes for the card. */\n  className?: string;\n}\n\nconst INBOX: UndoToastMail[] = [\n  { id: 1, from: \"Maya Chen\", subject: \"Q3 roadmap, final draft\", time: \"9:41\", hue: \"#ff9f0a\" },\n  { id: 2, from: \"Stripe\", subject: \"Your payout is on the way\", time: \"9:12\", hue: \"#5e5ce6\" },\n  { id: 3, from: \"Leo Park\", subject: \"Pricing page feedback\", time: \"Yesterday\", hue: \"#0a84ff\" },\n  { id: 4, from: \"Linear\", subject: \"3 issues assigned to you\", time: \"Yesterday\", hue: \"#30d158\" },\n];\nconst HOLD = 5000;\nconst FOCUS = \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#0071e3] dark:focus-visible:outline-[#0a84ff]\";\n\ntype Ghost = { mail: UndoToastMail; x: number; y: number; w: number; h: number; tx: number; ty: number; tw: number };\n\n/** True while the element is on screen and the tab is visible. Only observes when `enabled`. */\nfunction useDemoActive(ref: RefObject<HTMLElement | null>, enabled: boolean) {\n  const [active, setActive] = useState(false);\n  useEffect(() => {\n    const el = ref.current;\n    if (!enabled || !el) return;\n    let shown = !document.hidden;\n    let inView = false;\n    const sync = () => setActive(shown && inView);\n    const io = new IntersectionObserver(([entry]) => {\n      inView = entry.isIntersecting;\n      sync();\n    });\n    io.observe(el);\n    const onVisibility = () => {\n      shown = !document.hidden;\n      sync();\n    };\n    document.addEventListener(\"visibilitychange\", onVisibility);\n    return () => {\n      io.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVisibility);\n      setActive(false);\n    };\n  }, [ref, enabled]);\n  return active;\n}\n\n/**\n * Archive with a real undo. The row you archive lifts out of the list and\n * shrinks down into the toast, so you can see where it went. A ring around\n * Undo counts down; press it and the row drops back into its old place with\n * a brief highlight. Archive several in a row and the toast counts them up.\n */\nexport function UndoToast({ mails = INBOX, holdMs = HOLD, onArchive, onUndo, autoplay = false, enableSound = true, className = \"\" }: UndoToastProps) {\n  const play = useSound(enableSound);\n  const reduce = useReducedMotion() ?? false;\n  const [list, setList] = useState(mails);\n  const [batch, setBatch] = useState<UndoToastMail[]>([]);\n  const [ghost, setGhost] = useState<Ghost | null>(null);\n  const [toastKey, setToastKey] = useState(0);\n  const [restored, setRestored] = useState<number[]>([]);\n  const [hover, setHover] = useState(false);\n  const [focusIn, setFocusIn] = useState(false);\n  const box = useRef<HTMLDivElement>(null);\n  const rows = useRef(new Map<number, HTMLLIElement>());\n  const timer = useRef<number | undefined>(undefined);\n  const restoreTimer = useRef<number | undefined>(undefined);\n  const touched = useRef(false);\n  const paused = hover || focusIn;\n  const active = useDemoActive(box, autoplay && !reduce);\n\n  const archive = (m: UndoToastMail) => {\n    const el = rows.current.get(m.id);\n    const b = box.current;\n    if (el && b && !reduce) {\n      const r = el.getBoundingClientRect();\n      const c = b.getBoundingClientRect();\n      const tw = Math.min(300, c.width - 24);\n      setGhost({ mail: m, x: r.left - c.left, y: r.top - c.top, w: r.width, h: r.height, tx: c.width / 2 - tw / 2, ty: c.height - 72, tw });\n    }\n    setBatch((bt) => [...bt, m]);\n    setList((l) => l.filter((x) => x.id !== m.id));\n    setToastKey((k) => k + 1);\n    onArchive?.(m);\n  };\n  const undo = () => {\n    if (!batch.length) return;\n    // Put them back in the order they were archived, at their old positions.\n    const back = new Set(batch.map((m) => m.id));\n    setList((l) => mails.filter((x) => back.has(x.id) || l.some((y) => y.id === x.id)));\n    setRestored(batch.map((m) => m.id));\n    onUndo?.(batch);\n    setBatch([]);\n    window.clearTimeout(restoreTimer.current);\n    restoreTimer.current = window.setTimeout(() => setRestored([]), 900);\n  };\n\n  useEffect(() => () => window.clearTimeout(restoreTimer.current), []);\n\n  // The toast times out unless you hover or focus it.\n  useEffect(() => {\n    if (!batch.length || paused) return;\n    timer.current = window.setTimeout(() => setBatch([]), holdMs);\n    return () => window.clearTimeout(timer.current);\n  }, [batch.length, toastKey, paused, holdMs]);\n\n  // The demo reads the latest list and handlers through a ref.\n  const latest = useRef({ archive, undo, list });\n  useEffect(() => {\n    latest.current = { archive, undo, list };\n  });\n\n  // Demo: archive a row, then undo it.\n  useEffect(() => {\n    if (!autoplay || reduce || !active) return;\n    const ids: number[] = [];\n    let alive = true;\n    let archived = false;\n    const run = () => {\n      if (!alive || touched.current) return;\n      ids.push(\n        window.setTimeout(() => {\n          if (touched.current) return;\n          const m = latest.current.list[1];\n          if (m) {\n            archived = true;\n            play.auto(\"ping\");\n            latest.current.archive(m);\n          }\n        }, 1400),\n      );\n      ids.push(\n        window.setTimeout(() => {\n          if (touched.current) return;\n          if (archived) play.auto(\"drop\");\n          archived = false;\n          latest.current.undo();\n        }, 3600),\n      );\n      ids.push(window.setTimeout(run, 6200));\n    };\n    run();\n    return () => {\n      alive = false;\n      ids.forEach((id) => window.clearTimeout(id));\n    };\n  }, [autoplay, reduce, active, play]);\n\n  const count = batch.length;\n  const last = batch[batch.length - 1];\n  const summary = count === 0 ? \"\" : count > 1 ? `${count} conversations archived` : `Archived ${last?.subject ?? \"\"}`;\n  const pop = reduce ? { duration: 0.15 } : { type: \"spring\" as const, stiffness: 420, damping: 30, delay: ghost ? 0.3 : 0 };\n\n  return (\n    <div\n      ref={box}\n      className={`relative w-[400px] max-w-full overflow-hidden rounded-[28px] bg-white shadow-[0_0_0_1px_rgba(0,0,0,.05),0_24px_50px_-30px_rgba(0,0,0,.35)] dark:bg-[#1c1c1e] dark:shadow-[0_0_0_1px_rgba(255,255,255,.08),0_24px_50px_-30px_rgba(0,0,0,.9)] ${className}`}\n      onPointerDown={() => {\n        touched.current = true;\n      }}\n    >\n      <div className=\"flex items-center justify-between px-5 pb-2 pt-5\">\n        <h3 className=\"m-0 text-[20px] font-semibold tracking-[-0.02em] text-[#1d1d1f] dark:text-[#f5f5f7]\">Inbox</h3>\n        <button\n          type=\"button\"\n          onClick={() => {\n            touched.current = true;\n            setList(mails);\n            setBatch([]);\n          }}\n          className={`rounded text-[13px] font-medium text-[#0071e3] hover:underline dark:text-[#0a84ff] ${FOCUS}`}\n        >\n          Reset\n        </button>\n      </div>\n      <ul className=\"m-0 min-h-[300px] list-none px-2 pb-24 pt-1\">\n        <AnimatePresence initial={false}>\n          {list.map((m) => (\n            <motion.li\n              key={m.id}\n              ref={(el) => {\n                if (el) rows.current.set(m.id, el);\n                else rows.current.delete(m.id);\n              }}\n              layout={!reduce}\n              initial={{ opacity: 0, height: 0 }}\n              animate={{ opacity: 1, height: \"auto\" }}\n              exit={{ opacity: 0, height: 0, transition: { duration: reduce ? 0.12 : 0.25, ease: [0.4, 0, 0.2, 1] } }}\n              transition={reduce ? { duration: 0.12 } : { type: \"spring\", stiffness: 380, damping: 34 }}\n              className=\"group relative overflow-hidden rounded-[14px]\"\n            >\n              {/* the highlight a restored row flashes */}\n              <motion.span\n                aria-hidden=\"true\"\n                className=\"pointer-events-none absolute inset-0 bg-[#0071e3]/[.08] dark:bg-[#0a84ff]/[.16]\"\n                initial={false}\n                animate={{ opacity: restored.includes(m.id) ? 1 : 0 }}\n                transition={{ duration: 0.6 }}\n              />\n              <div className=\"relative flex items-center gap-3 px-3 py-2.5\">\n                <span className=\"flex h-9 w-9 flex-none items-center justify-center rounded-full text-[14px] font-semibold text-white\" style={{ background: m.hue }}>\n                  {m.from[0]}\n                </span>\n                <span className=\"min-w-0 flex-1\">\n                  <span className=\"flex justify-between gap-2 text-[14px]\">\n                    <span className=\"truncate font-semibold text-[#1d1d1f] dark:text-[#f5f5f7]\">{m.from}</span>\n                    <span className=\"flex-none text-[12px] text-[#6e6e73] dark:text-[#a1a1a6]\">{m.time}</span>\n                  </span>\n                  <span className=\"block truncate text-[13px] text-[#6e6e73] dark:text-[#a1a1a6]\">{m.subject}</span>\n                </span>\n                <button\n                  type=\"button\"\n                  onClick={() => {\n                    touched.current = true;\n                    play(\"ping\");\n                    archive(m);\n                  }}\n                  aria-label={`Archive ${m.subject}`}\n                  className={`flex h-8 w-8 flex-none items-center justify-center rounded-full text-[#6e6e73] opacity-60 transition hover:bg-[#f5f5f7] hover:text-[#1d1d1f] focus-visible:opacity-100 group-hover:opacity-100 dark:text-[#a1a1a6] dark:hover:bg-[#3a3a3c] dark:hover:text-[#f5f5f7] ${FOCUS}`}\n                >\n                  <svg width=\"17\" height=\"17\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <rect x=\"3\" y=\"4\" width=\"18\" height=\"5\" rx=\"1.5\" />\n                    <path d=\"M5 9v9a2 2 0 002 2h10a2 2 0 002-2V9M10 13h4\" />\n                  </svg>\n                </button>\n              </div>\n            </motion.li>\n          ))}\n        </AnimatePresence>\n        {!list.length && <li className=\"py-16 text-center text-[14px] text-[#6e6e73] dark:text-[#a1a1a6]\">All caught up</li>}\n      </ul>\n\n      {/* the archived row, flying down into the toast */}\n      <AnimatePresence>\n        {ghost && (\n          <motion.div\n            key={`${ghost.mail.id}-${toastKey}`}\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute left-0 top-0 z-20 flex items-center gap-3 overflow-hidden bg-white px-3 shadow-[0_12px_30px_-10px_rgba(0,0,0,.35),0_0_0_1px_rgba(0,0,0,.06)] dark:bg-[#2c2c2e] dark:shadow-[0_12px_30px_-10px_rgba(0,0,0,.8),0_0_0_1px_rgba(255,255,255,.08)]\"\n            initial={{ x: ghost.x, y: ghost.y, width: ghost.w, height: ghost.h, borderRadius: 14, opacity: 1 }}\n            animate={{ x: ghost.tx, y: ghost.ty, width: ghost.tw, height: 52, borderRadius: 26, opacity: 0 }}\n            transition={{ duration: 0.5, ease: [0.3, 0, 0.2, 1], opacity: { duration: 0.2, delay: 0.32 } }}\n            onAnimationComplete={() => setGhost(null)}\n          >\n            <span className=\"flex h-9 w-9 flex-none items-center justify-center rounded-full text-[14px] font-semibold text-white\" style={{ background: ghost.mail.hue }}>\n              {ghost.mail.from[0]}\n            </span>\n            <span className=\"truncate text-[14px] font-semibold text-[#1d1d1f] dark:text-[#f5f5f7]\">{ghost.mail.from}</span>\n          </motion.div>\n        )}\n      </AnimatePresence>\n\n      <span className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n        {summary}\n      </span>\n\n      {/* the toast */}\n      <div className=\"pointer-events-none absolute inset-x-0 bottom-5 flex justify-center px-3\">\n        <AnimatePresence>\n          {count > 0 && (\n            <motion.div\n              key=\"toast\"\n              layout={!reduce}\n              role=\"group\"\n              aria-label=\"Archive undo\"\n              className=\"pointer-events-auto flex h-[52px] max-w-full items-center gap-3 rounded-full bg-[#1d1d1f] pl-5 pr-1.5 text-white shadow-[0_18px_40px_-14px_rgba(0,0,0,.6)] dark:bg-[#2c2c2e] dark:shadow-[0_0_0_1px_rgba(255,255,255,.1),0_18px_40px_-14px_rgba(0,0,0,.9)]\"\n              initial={reduce ? { opacity: 0 } : { y: 30, opacity: 0, scale: 0.9 }}\n              animate={{ y: 0, opacity: 1, scale: 1 }}\n              exit={reduce ? { opacity: 0, transition: { duration: 0.12 } } : { y: 30, opacity: 0, scale: 0.95, transition: { duration: 0.22 } }}\n              transition={pop}\n              onPointerEnter={() => setHover(true)}\n              onPointerLeave={() => setHover(false)}\n              onFocus={() => setFocusIn(true)}\n              onBlur={(e) => {\n                if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocusIn(false);\n              }}\n            >\n              <motion.span layout={!reduce} aria-hidden=\"true\" className=\"flex min-w-0 items-center gap-1.5 whitespace-nowrap text-[14px]\">\n                <span className=\"relative inline-flex h-[1.3em] overflow-hidden tabular-nums\">\n                  <AnimatePresence mode=\"popLayout\" initial={false}>\n                    <motion.span key={count} initial={reduce ? false : { y: \"100%\" }} animate={{ y: 0 }} exit={reduce ? { opacity: 0 } : { y: \"-100%\" }} transition={{ type: \"spring\", stiffness: 500, damping: 34 }}>\n                      {count > 1 ? count : \"\"}\n                    </motion.span>\n                  </AnimatePresence>\n                </span>\n                {count > 1 ? (\n                  \"conversations archived\"\n                ) : (\n                  <>\n                    Archived <span className=\"max-w-[84px] truncate text-white/60 min-[420px]:max-w-[120px]\">{last?.subject}</span>\n                  </>\n                )}\n              </motion.span>\n              <motion.button\n                layout={!reduce}\n                type=\"button\"\n                onClick={() => {\n                  touched.current = true;\n                  play(\"drop\");\n                  undo();\n                }}\n                className=\"relative flex h-10 flex-none items-center gap-2 rounded-full bg-white/10 pl-2 pr-4 text-[14px] font-semibold hover:bg-white/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#0071e3] dark:focus-visible:outline-[#0a84ff]\"\n              >\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" className=\"-rotate-90\" aria-hidden=\"true\">\n                  <circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"none\" stroke=\"rgba(255,255,255,.2)\" strokeWidth=\"2\" />\n                  <motion.circle\n                    key={`${toastKey}${paused ? \"h\" : \"\"}`}\n                    cx=\"12\"\n                    cy=\"12\"\n                    r=\"9\"\n                    fill=\"none\"\n                    stroke=\"#fff\"\n                    strokeWidth=\"2\"\n                    strokeLinecap=\"round\"\n                    initial={{ pathLength: 1 }}\n                    animate={{ pathLength: paused ? 1 : 0 }}\n                    transition={{ duration: paused ? 0.2 : holdMs / 1000, ease: \"linear\" }}\n                  />\n                </svg>\n                Undo\n              </motion.button>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}
