{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "not-found",
  "type": "registry:block",
  "title": "Not Found",
  "description": "A 404 with a compass that dithers between headings until you move your mouse or start searching, plus a did-you-mean fix for the typo, inline search and popular links.",
  "categories": [
    "block",
    "Content"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/input-group.json"
  ],
  "files": [
    {
      "path": "registry/devl/not-found.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { ArrowRightIcon, CheckIcon, CornerDownLeftIcon, FlagIcon, HouseIcon, type LucideIcon, SearchIcon } from \"lucide-react\";\nimport { AnimatePresence, type MotionValue, motion, useReducedMotion, useSpring, useTransform } from \"motion/react\";\nimport { type KeyboardEvent, type PointerEvent, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { InputGroup, InputGroupAddon, InputGroupInput } from \"@/components/ui/input-group\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface NotFoundPage {\n  title: string;\n  href: string;\n  section?: string;\n}\n\nexport interface NotFoundLink {\n  title: string;\n  description: string;\n  href: string;\n  icon: LucideIcon;\n}\n\nexport interface NotFoundProps {\n  path?: string;\n  pages?: NotFoundPage[];\n  popular?: NotFoundLink[];\n  homeHref?: string;\n  onNavigate?: (href: string) => void;\n  onReport?: (path: string) => void;\n  className?: string;\n}\n\nconst ease = [0.23, 1, 0.32, 1] as const;\nconst press = \"transition-[box-shadow,scale,background-color] duration-150 active:scale-[0.97]\";\n\nfunction distance(a: string, b: string) {\n  const dp = Array.from({ length: b.length + 1 }, (_, i) => i);\n  for (let i = 1; i <= a.length; i++) {\n    let prev = dp[0];\n    dp[0] = i;\n    for (let j = 1; j <= b.length; j++) {\n      const tmp = dp[j];\n      dp[j] = Math.min(dp[j] + 1, dp[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));\n      prev = tmp;\n    }\n  }\n  return dp[b.length];\n}\n\nfunction Highlight({ text, query }: { text: string; query: string }) {\n  const i = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;\n  if (i < 0) return <>{text}</>;\n  return (\n    <>\n      {text.slice(0, i)}\n      <mark className=\"rounded-[calc(var(--radius)*0.3)] bg-warning/25 text-foreground\">{text.slice(i, i + query.length)}</mark>\n      {text.slice(i + query.length)}\n    </>\n  );\n}\n\nfunction Compass({ angle }: { angle: MotionValue<number> }) {\n  const rotate = useTransform(angle, (a) => `rotate(${a}deg)`);\n  const ticks = Array.from({ length: 36 }, (_, i) => i * 10);\n  return (\n    <svg aria-hidden className=\"size-full overflow-visible\" viewBox=\"0 0 200 200\">\n      <circle className=\"fill-card stroke-border\" cx=\"100\" cy=\"100\" r=\"92\" strokeWidth=\"1.5\" />\n      <circle className=\"fill-muted stroke-border\" cx=\"100\" cy=\"100\" r=\"74\" strokeWidth=\"1\" />\n      {ticks.map((t) => (\n        <line\n          className={t % 90 === 0 ? \"stroke-foreground/50\" : \"stroke-foreground/15\"}\n          key={t}\n          strokeLinecap=\"round\"\n          strokeWidth={t % 90 === 0 ? 2 : 1.25}\n          transform={`rotate(${t} 100 100)`}\n          x1=\"100\"\n          x2=\"100\"\n          y1=\"12\"\n          y2={t % 90 === 0 ? 22 : 18}\n        />\n      ))}\n      {[\n        [\"N\", 100, 42],\n        [\"E\", 158, 104],\n        [\"S\", 100, 166],\n        [\"W\", 42, 104],\n      ].map(([l, x, y]) => (\n        <text\n          className={cn(\"font-medium font-mono text-[11px]\", l === \"N\" ? \"fill-rose-600 dark:fill-rose-400\" : \"fill-muted-foreground\")}\n          key={l as string}\n          textAnchor=\"middle\"\n          x={x}\n          y={y}\n        >\n          {l}\n        </text>\n      ))}\n      <motion.g style={{ transform: rotate, transformOrigin: \"100px 100px\" }}>\n        <path className=\"fill-rose-500\" d=\"M100 48 L109 100 L91 100 Z\" />\n        <path className=\"fill-foreground/25\" d=\"M100 152 L109 100 L91 100 Z\" />\n      </motion.g>\n      <circle className=\"fill-card stroke-foreground/30\" cx=\"100\" cy=\"100\" r=\"6\" strokeWidth=\"1.5\" />\n      <circle className=\"fill-foreground/50\" cx=\"100\" cy=\"100\" r=\"2\" />\n    </svg>\n  );\n}\n\nexport function NotFound({\n  path = \"/docs/webhooks/retires\",\n  pages = [],\n  popular = [],\n  homeHref = \"/\",\n  onNavigate,\n  onReport,\n  className,\n}: NotFoundProps) {\n  const reduce = useReducedMotion();\n  const uid = useId();\n  const dialRef = useRef<HTMLDivElement>(null);\n  const inputRef = useRef<HTMLInputElement>(null);\n  const [query, setQuery] = useState(\"\");\n  const [active, setActive] = useState(0);\n  const [reported, setReported] = useState(false);\n  const [aim, setAim] = useState<\"wander\" | \"pointer\" | \"search\">(\"wander\");\n  const angle = useSpring(38, { stiffness: 90, damping: 9, mass: 0.8 });\n\n  const suggestion = useMemo(() => {\n    let best: NotFoundPage | undefined;\n    let score = Number.POSITIVE_INFINITY;\n    for (const p of pages) {\n      const d = distance(path.toLowerCase(), p.href.toLowerCase());\n      if (d < score) {\n        score = d;\n        best = p;\n      }\n    }\n    return best && score <= Math.max(3, Math.round(path.length * 0.2)) ? best : undefined;\n  }, [pages, path]);\n\n  const results = useMemo(() => {\n    const q = query.trim().toLowerCase();\n    if (!q) return [];\n    return pages\n      .filter((p) => `${p.title} ${p.section ?? \"\"} ${p.href}`.toLowerCase().includes(q))\n      .slice(0, 5);\n  }, [pages, query]);\n\n  useEffect(() => {\n    if (reduce || aim !== \"wander\") return;\n    const headings = [38, -24, 112, 64, 196, 10, -70];\n    let i = 0;\n    const t = setInterval(() => {\n      i = (i + 1) % headings.length;\n      angle.set(headings[i]);\n    }, 2200);\n    return () => clearInterval(t);\n  }, [aim, angle, reduce]);\n\n  const pointTo = (x: number, y: number) => {\n    const dial = dialRef.current?.getBoundingClientRect();\n    if (!dial) return;\n    const deg = (Math.atan2(y - (dial.top + dial.height / 2), x - (dial.left + dial.width / 2)) * 180) / Math.PI + 90;\n    const current = angle.get();\n    const delta = ((((deg - current) % 360) + 540) % 360) - 180;\n    angle.set(current + delta);\n  };\n\n  useEffect(() => {\n    if (reduce || aim !== \"search\") return;\n    const box = inputRef.current?.getBoundingClientRect();\n    if (box) pointTo(box.left + 24, box.top + box.height / 2);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [aim, reduce]);\n\n  const onPointerMove = (e: PointerEvent) => {\n    if (reduce || e.pointerType !== \"mouse\" || aim === \"search\") return;\n    setAim(\"pointer\");\n    pointTo(e.clientX, e.clientY);\n  };\n\n  const go = (href: string) => onNavigate?.(href);\n\n  const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n    if (!results.length) return;\n    if (e.key === \"ArrowDown\") {\n      e.preventDefault();\n      setActive((a) => (a + 1) % results.length);\n    } else if (e.key === \"ArrowUp\") {\n      e.preventDefault();\n      setActive((a) => (a - 1 + results.length) % results.length);\n    } else if (e.key === \"Enter\") {\n      e.preventDefault();\n      go(results[active].href);\n    }\n  };\n\n  return (\n    <section\n      className={cn(\"mx-auto w-full max-w-[1000px] overflow-hidden rounded-2xl border bg-card text-card-foreground shadow-xs/5\", className)}\n      onPointerLeave={() => aim === \"pointer\" && setAim(\"wander\")}\n      onPointerMove={onPointerMove}\n    >\n      <div className=\"grid items-center gap-8 px-5 pt-8 pb-8 sm:px-10 sm:pt-12 md:grid-cols-[260px_1fr] md:gap-12\">\n        <div className=\"relative mx-auto w-44 sm:w-52 md:w-full\" ref={dialRef}>\n          <div aria-hidden className=\"absolute inset-6 -z-0 rounded-full bg-rose-500/10 blur-2xl\" />\n          <div className=\"relative\">\n            <Compass angle={angle} />\n          </div>\n        </div>\n\n        <div className=\"min-w-0\">\n          <p className=\"font-medium font-mono text-muted-foreground text-xs tracking-wide\">ERROR 404</p>\n          <h2 className=\"mt-2 text-balance font-semibold text-3xl tracking-tight sm:text-4xl\">This page wandered off</h2>\n          <p className=\"mt-3 max-w-[52ch] text-pretty text-muted-foreground text-sm sm:text-base\">\n            We couldn’t find{\" \"}\n            <code className=\"break-all rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.8125rem] text-foreground\">{path}</code>. It may\n            have moved, or the link has a typo.\n          </p>\n          {suggestion && (\n            <button\n              className=\"group mt-4 inline-flex max-w-full cursor-pointer items-center gap-2 rounded-lg border border-dashed px-3 py-2 text-left text-sm outline-none transition-[background-color,scale] duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\"\n              onClick={() => go(suggestion.href)}\n              type=\"button\"\n            >\n              <span className=\"shrink-0 text-muted-foreground\">Did you mean</span>\n              <span className=\"min-w-0 font-medium font-mono text-[0.8125rem] [overflow-wrap:anywhere]\">\n                {suggestion.href.split(\"/\").map((part, i) => (\n                  <span key={i}>\n                    {i > 0 && \"/\"}\n                    {i > 0 && <wbr />}\n                    {part}\n                  </span>\n                ))}\n              </span>\n              <ArrowRightIcon className=\"size-3.5 shrink-0 text-muted-foreground transition-transform duration-200 group-hover:translate-x-0.5\" />\n            </button>\n          )}\n\n          <div className=\"relative mt-6\">\n            <label className=\"sr-only\" htmlFor={`${uid}-q`}>\n              Search the site\n            </label>\n            <InputGroup className=\"h-10 sm:h-10\">\n              <InputGroupAddon>\n                <SearchIcon />\n              </InputGroupAddon>\n              <InputGroupInput\n                aria-activedescendant={results.length ? `${uid}-r${active}` : undefined}\n                aria-autocomplete=\"list\"\n                aria-controls={`${uid}-list`}\n                aria-expanded={results.length > 0}\n                autoComplete=\"off\"\n                id={`${uid}-q`}\n                onBlur={() => setAim(\"wander\")}\n                onChange={(e) => {\n                  setQuery(e.target.value);\n                  setActive(0);\n                }}\n                onFocus={() => setAim(\"search\")}\n                onKeyDown={onKeyDown}\n                placeholder=\"Search the docs\"\n                ref={inputRef}\n                role=\"combobox\"\n                size=\"lg\"\n                value={query}\n              />\n              {results.length > 0 && (\n                <InputGroupAddon align=\"inline-end\">\n                  <span className=\"hidden items-center gap-1 whitespace-nowrap text-muted-foreground text-xs sm:flex\">\n                    <CornerDownLeftIcon className=\"size-3\" />\n                    to open\n                  </span>\n                </InputGroupAddon>\n              )}\n            </InputGroup>\n            <AnimatePresence initial={false}>\n              {query.trim() && (\n                <motion.div\n                  animate={{ height: \"auto\", opacity: 1 }}\n                  className=\"overflow-hidden\"\n                  exit={{ height: 0, opacity: 0 }}\n                  initial={{ height: 0, opacity: 0 }}\n                  transition={{ duration: 0.2, ease }}\n                >\n                  <ul className=\"mt-2 rounded-xl border bg-popover p-1 shadow-xs/5\" id={`${uid}-list`} role=\"listbox\">\n                    {results.map((r, i) => (\n                      <li\n                        aria-selected={i === active}\n                        className={cn(\n                          \"flex cursor-pointer items-center gap-3 rounded-lg px-2.5 py-2 text-sm\",\n                          i === active ? \"bg-accent\" : \"hover:bg-accent/60\",\n                        )}\n                        id={`${uid}-r${i}`}\n                        key={r.href}\n                        onClick={() => go(r.href)}\n                        onMouseEnter={() => setActive(i)}\n                        role=\"option\"\n                      >\n                        <span className=\"min-w-0 flex-1\">\n                          <span className=\"block truncate font-medium\">\n                            <Highlight query={query.trim()} text={r.title} />\n                          </span>\n                          <span className=\"block truncate font-mono text-muted-foreground text-xs\">{r.href}</span>\n                        </span>\n                        {r.section && <span className=\"shrink-0 text-muted-foreground text-xs\">{r.section}</span>}\n                      </li>\n                    ))}\n                    {!results.length && (\n                      <li className=\"px-2.5 py-3 text-muted-foreground text-sm\" role=\"presentation\">\n                        Nothing matches “{query.trim()}”. Try “billing” or “webhooks”.\n                      </li>\n                    )}\n                  </ul>\n                </motion.div>\n              )}\n            </AnimatePresence>\n          </div>\n\n          <div className=\"mt-5 flex flex-wrap items-center gap-2\">\n            <Button className={press} onClick={() => go(homeHref)}>\n              <HouseIcon />\n              Back to home\n            </Button>\n            <Button\n              className={cn(\"text-muted-foreground\", press)}\n              disabled={reported}\n              onClick={() => {\n                setReported(true);\n                onReport?.(path);\n              }}\n              variant=\"ghost\"\n            >\n              <AnimatePresence initial={false} mode=\"popLayout\">\n                <motion.span\n                  animate={{ opacity: 1, y: 0 }}\n                  className=\"flex items-center gap-2\"\n                  exit={{ opacity: 0, y: -6 }}\n                  initial={{ opacity: 0, y: 6 }}\n                  key={reported ? \"done\" : \"idle\"}\n                  transition={{ duration: 0.16, ease }}\n                >\n                  {reported ? <CheckIcon className=\"text-success-foreground\" /> : <FlagIcon />}\n                  {reported ? \"Thanks, we’ll fix it\" : \"Report broken link\"}\n                </motion.span>\n              </AnimatePresence>\n            </Button>\n          </div>\n        </div>\n      </div>\n\n      {popular.length > 0 && (\n        <div className=\"border-t bg-muted/40 px-5 py-6 sm:px-10\">\n          <h3 className=\"font-medium text-muted-foreground text-xs\">Popular right now</h3>\n          <ul className=\"mt-3 grid gap-2 sm:grid-cols-2 lg:grid-cols-4\">\n            {popular.map((l) => (\n              <li key={l.href}>\n                <button\n                  className=\"group flex h-full w-full cursor-pointer items-start gap-3 rounded-xl border bg-card p-3 text-left shadow-xs/5 outline-none transition-[border-color,scale,box-shadow] duration-150 hover:border-foreground/15 focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\"\n                  onClick={() => go(l.href)}\n                  type=\"button\"\n                >\n                  <span className=\"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground\">\n                    <l.icon className=\"size-4\" />\n                  </span>\n                  <span className=\"min-w-0 flex-1\">\n                    <span className=\"flex items-center gap-1 font-medium text-sm\">\n                      {l.title}\n                      <ArrowRightIcon className=\"size-3.5 -translate-x-1 text-muted-foreground opacity-0 transition-[opacity,translate] duration-200 group-hover:translate-x-0 group-hover:opacity-100 group-focus-visible:translate-x-0 group-focus-visible:opacity-100\" />\n                    </span>\n                    <span className=\"mt-0.5 block text-pretty text-muted-foreground text-xs\">{l.description}</span>\n                  </span>\n                </button>\n              </li>\n            ))}\n          </ul>\n        </div>\n      )}\n    </section>\n  );\n}\n"
    }
  ]
}