{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "feature-bento",
  "type": "registry:block",
  "title": "Feature Bento",
  "description": "A bento grid of feature tiles, each with a tiny working demo (search, shortcuts, version history, a flow, a chart) that wakes up on hover and rests when you leave.",
  "categories": [
    "block",
    "Marketing"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/devl/feature-bento.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { ArrowRightIcon, FileTextIcon, MessageSquareIcon, SearchIcon, SparklesIcon, ZapIcon } from \"lucide-react\";\nimport { AnimatePresence, motion, MotionConfig, useInView, useReducedMotion } from \"motion/react\";\nimport { type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nfunction useReducedMotionSafe() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && Boolean(prefers);\n}\n\nexport type FeatureDemo = \"search\" | \"shortcuts\" | \"history\" | \"automation\" | \"insights\";\n\nexport interface BentoFeature {\n  title: string;\n  description: string;\n  demo: FeatureDemo;\n  span?: 2 | 3 | 4 | 6;\n}\n\nexport interface FeatureBentoProps {\n  eyebrow?: string;\n  title: ReactNode;\n  description?: ReactNode;\n  features: BentoFeature[];\n  className?: string;\n}\n\nconst ease = [0.23, 1, 0.32, 1] as const;\nconst spring = { type: \"spring\", stiffness: 380, damping: 34 } as const;\nconst accent = \"text-violet-600 dark:text-violet-400\";\n\nconst docs = [\n  { title: \"Q3 roadmap\", meta: \"Product · edited 2h ago\" },\n  { title: \"Onboarding checklist\", meta: \"People · edited yesterday\" },\n  { title: \"Pricing page rewrite\", meta: \"Marketing · edited Mon\" },\n  { title: \"Roadmap review notes\", meta: \"Product · edited Sep 30\" },\n  { title: \"Launch plan: Atlas\", meta: \"Marketing · edited Sep 28\" },\n  { title: \"Mobile app roadmap\", meta: \"Engineering · edited Sep 24\" },\n  { title: \"Launch retro, spring\", meta: \"Marketing · edited Jun 3\" },\n  { title: \"Onboarding emails v2\", meta: \"Lifecycle · edited Aug 14\" },\n];\nconst queries = [\"roadmap\", \"launch\", \"onboarding\"];\n\nfunction Highlight({ text, query }: { text: string; query: string }) {\n  const at = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;\n  if (at < 0) return <>{text}</>;\n  return (\n    <>\n      {text.slice(0, at)}\n      <span className={cn(\"rounded-sm bg-violet-500/12 font-semibold\", accent)}>{text.slice(at, at + query.length)}</span>\n      {text.slice(at + query.length)}\n    </>\n  );\n}\n\nfunction SearchDemo({ active }: { active: boolean }) {\n  const [q, setQ] = useState(0);\n  const [typed, setTyped] = useState(queries[0].length);\n  useEffect(() => {\n    if (!active) return;\n    let cancelled = false;\n    let timer: number | undefined;\n    const run = (index: number, count: number) => {\n      if (cancelled) return;\n      const word = queries[index];\n      if (count <= word.length) {\n        setQ(index);\n        setTyped(count);\n        timer = window.setTimeout(() => run(index, count + 1), count === 0 ? 260 : 55);\n      } else {\n        timer = window.setTimeout(() => run((index + 1) % queries.length, 0), 1500);\n      }\n    };\n    timer = window.setTimeout(() => run((q + 1) % queries.length, 0), 350);\n    return () => {\n      cancelled = true;\n      window.clearTimeout(timer);\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [active]);\n\n  const query = queries[q].slice(0, typed);\n  const results = docs.filter((d) => d.title.toLowerCase().includes(query.toLowerCase())).slice(0, 3);\n\n  return (\n    <div className=\"flex h-full flex-col p-4 sm:p-5\">\n      <div className=\"flex h-9 items-center gap-2 rounded-lg border bg-background px-3 shadow-xs/5\">\n        <SearchIcon className=\"size-3.5 text-muted-foreground\" />\n        <span className=\"font-mono text-xs\">\n          {query}\n          <span\n            className={cn(\n              \"ms-px inline-block h-3.5 w-px translate-y-0.5 bg-foreground\",\n              active ? \"animate-caret-blink\" : \"opacity-0\",\n            )}\n          />\n        </span>\n        <span className=\"ms-auto font-mono text-[0.625rem] text-muted-foreground tabular-nums\">\n          {results.length} {results.length === 1 ? \"doc\" : \"docs\"}\n        </span>\n      </div>\n      <ul className=\"relative mt-2 flex-1 space-y-1\">\n        <AnimatePresence initial={false} mode=\"popLayout\">\n          {results.map((doc) => (\n            <motion.li\n              animate={{ opacity: 1, y: 0 }}\n              className=\"flex items-center gap-2.5 rounded-lg bg-background/60 px-2.5 py-2\"\n              exit={{ opacity: 0, y: -4 }}\n              initial={{ opacity: 0, y: 6 }}\n              key={doc.title}\n              layout\n              transition={{ duration: 0.22, ease }}\n            >\n              <FileTextIcon className=\"size-3.5 shrink-0 text-muted-foreground\" />\n              <span className=\"truncate text-xs\">\n                <Highlight query={query} text={doc.title} />\n              </span>\n              <span className=\"ms-auto hidden shrink-0 text-[0.625rem] text-muted-foreground sm:block\">{doc.meta}</span>\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ul>\n    </div>\n  );\n}\n\nconst combos = [\n  { keys: [\"⌘\", \"K\"], label: \"Open anything\" },\n  { keys: [\"⌘\", \"⇧\", \"P\"], label: \"Publish page\" },\n  { keys: [\"G\", \"I\"], label: \"Go to inbox\" },\n];\n\nfunction Key({ children, down }: { children: ReactNode; down: boolean }) {\n  return (\n    <motion.span\n      animate={{ y: down ? 2 : 0 }}\n      className={cn(\n        \"flex size-11 items-center justify-center rounded-xl border bg-background font-medium text-base shadow-xs/5 transition-[box-shadow,border-color] duration-100\",\n        down ? \"border-violet-500/40 shadow-none\" : \"border-b-[3px]\",\n      )}\n      transition={{ duration: 0.08 }}\n    >\n      {children}\n    </motion.span>\n  );\n}\n\nfunction ShortcutDemo({ active }: { active: boolean }) {\n  const [combo, setCombo] = useState(0);\n  const [pressed, setPressed] = useState(0);\n  useEffect(() => {\n    if (!active) {\n      setPressed(0);\n      return;\n    }\n    let cancelled = false;\n    const timers: number[] = [];\n    const later = (fn: () => void, ms: number) => timers.push(window.setTimeout(() => !cancelled && fn(), ms));\n    const play = (index: number) => {\n      setCombo(index);\n      setPressed(0);\n      const n = combos[index].keys.length;\n      for (let k = 1; k <= n; k++) later(() => setPressed(k), 200 + k * 170);\n      later(() => setPressed(0), 200 + n * 170 + 900);\n      later(() => play((index + 1) % combos.length), 200 + n * 170 + 1400);\n    };\n    play((combo + 1) % combos.length);\n    return () => {\n      cancelled = true;\n      timers.forEach(window.clearTimeout);\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [active]);\n\n  const current = combos[combo];\n  const fired = pressed === current.keys.length;\n  return (\n    <div className=\"flex h-full flex-col items-center justify-center gap-4 p-5\">\n      <div className=\"flex items-center gap-1.5\">\n        {current.keys.map((key, i) => (\n          <Key down={pressed > i} key={`${combo}-${key}`}>\n            {key}\n          </Key>\n        ))}\n      </div>\n      <div className=\"h-6\">\n        <AnimatePresence mode=\"wait\">\n          <motion.span\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            className={cn(\n              \"inline-flex h-6 items-center rounded-full border px-2.5 text-[0.6875rem] transition-colors duration-150\",\n              fired ? \"border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300\" : \"bg-background text-muted-foreground\",\n            )}\n            exit={{ opacity: 0, y: -4 }}\n            initial={{ opacity: 0, y: 4, scale: 0.97 }}\n            key={combo}\n            transition={{ duration: 0.18, ease }}\n          >\n            {current.label}\n          </motion.span>\n        </AnimatePresence>\n      </div>\n    </div>\n  );\n}\n\nconst versions = [\n  { label: \"v9\", who: \"Iris\", when: \"Sep 12\", lines: [0.9, 0.6, 0.75, 0.3] },\n  { label: \"v10\", who: \"Marc\", when: \"Sep 19\", lines: [0.9, 0.82, 0.5, 0.64] },\n  { label: \"v11\", who: \"Maya\", when: \"Oct 2\", lines: [0.7, 0.88, 0.62, 0.8] },\n  { label: \"v12\", who: \"Iris\", when: \"Oct 9\", lines: [0.96, 0.7, 0.86, 0.45] },\n  { label: \"v13\", who: \"You\", when: \"Today\", lines: [0.8, 0.94, 0.58, 0.72] },\n];\n\nfunction HistoryDemo({ active }: { active: boolean }) {\n  const [v, setV] = useState(versions.length - 1);\n  useEffect(() => {\n    if (!active) {\n      setV(versions.length - 1);\n      return;\n    }\n    let i = 0;\n    setV(0);\n    const id = window.setInterval(() => {\n      i = (i + 1) % versions.length;\n      setV(i);\n    }, 900);\n    return () => window.clearInterval(id);\n  }, [active]);\n  const version = versions[v];\n  return (\n    <div className=\"flex h-full flex-col justify-center gap-6 p-4 sm:p-5\">\n      <div className=\"rounded-lg border bg-background p-3 shadow-xs/5\">\n        <div className=\"mb-2.5 flex items-center justify-between text-[0.625rem] text-muted-foreground\">\n          <span className=\"font-medium font-mono text-foreground\">{version.label}</span>\n          <span className=\"tabular-nums\">\n            {version.who} · {version.when}\n          </span>\n        </div>\n        <div className=\"space-y-1.5\">\n          {version.lines.map((w, i) => (\n            <motion.div\n              animate={{ scaleX: w }}\n              className={cn(\"h-1.5 origin-left rounded-full\", i === 0 ? \"bg-foreground/70\" : \"bg-foreground/15\")}\n              initial={false}\n              // biome-ignore lint/suspicious/noArrayIndexKey: fixed rows\n              key={i}\n              transition={spring}\n            />\n          ))}\n        </div>\n      </div>\n      <div className=\"relative flex items-center justify-between px-1\">\n        <span className=\"absolute inset-x-1 top-1/2 h-px -translate-y-1/2 bg-border\" />\n        {versions.map((item, i) => (\n          <span\n            className={cn(\"relative size-2 rounded-full transition-colors duration-200\", i <= v ? \"bg-foreground/60\" : \"bg-border\")}\n            key={item.label}\n          />\n        ))}\n        <motion.span\n          animate={{ x: `${(v / (versions.length - 1)) * 100}%` }}\n          className=\"pointer-events-none absolute inset-y-0 right-2 left-2\"\n          initial={false}\n          transition={spring}\n        >\n          <span className=\"absolute top-1/2 left-0 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-background bg-violet-500 shadow-sm\" />\n        </motion.span>\n      </div>\n    </div>\n  );\n}\n\nconst steps = [\n  { icon: MessageSquareIcon, label: \"Form reply\" },\n  { icon: SparklesIcon, label: \"Summarise\" },\n  { icon: ZapIcon, label: \"Post to #sales\" },\n];\n\nfunction AutomationDemo({ active }: { active: boolean }) {\n  const reduce = useReducedMotionSafe();\n  const [lit, setLit] = useState(-1);\n  useEffect(() => {\n    if (!active) {\n      setLit(-1);\n      return;\n    }\n    let i = 0;\n    setLit(0);\n    const id = window.setInterval(() => {\n      i = (i + 1) % (steps.length + 1);\n      setLit(i === steps.length ? -1 : i);\n    }, 650);\n    return () => window.clearInterval(id);\n  }, [active]);\n  return (\n    <div className=\"flex h-full flex-col justify-center gap-2 p-4 sm:p-5\">\n      {steps.map((step, i) => (\n        <div className=\"flex flex-col items-start\" key={step.label}>\n          <motion.div\n            animate={{ scale: lit === i && !reduce ? 1.02 : 1 }}\n            className={cn(\n              \"flex h-9 w-full items-center gap-2.5 rounded-lg border bg-background px-3 text-xs shadow-xs/5 transition-colors duration-200\",\n              lit === i && \"border-violet-500/40\",\n              lit > i && \"text-muted-foreground\",\n            )}\n            transition={{ duration: 0.18, ease }}\n          >\n            <span\n              className={cn(\n                \"flex size-5 items-center justify-center rounded-md transition-colors duration-200\",\n                lit === i ? \"bg-violet-500 text-white\" : \"bg-muted text-muted-foreground\",\n              )}\n            >\n              <step.icon className=\"size-3\" />\n            </span>\n            {step.label}\n            <span\n              className={cn(\n                \"ms-auto size-1.5 rounded-full transition-colors duration-200\",\n                lit >= i ? \"bg-emerald-500\" : \"bg-border\",\n              )}\n            />\n          </motion.div>\n          {i < steps.length - 1 && (\n            <span className=\"relative ms-[1.375rem] h-2.5 w-px overflow-hidden bg-border\">\n              <motion.span\n                animate={{ y: lit > i ? \"0%\" : \"-100%\" }}\n                className=\"absolute inset-0 bg-violet-500\"\n                initial={false}\n                transition={{ duration: 0.2, ease }}\n              />\n            </span>\n          )}\n        </div>\n      ))}\n    </div>\n  );\n}\n\nconst rest = [38, 52, 44, 66, 58, 74, 88];\nconst days = [\"M\", \"T\", \"W\", \"T\", \"F\", \"S\", \"S\"];\n\nfunction InsightsDemo({ active }: { active: boolean }) {\n  const [bars, setBars] = useState(rest);\n  useEffect(() => {\n    if (!active) {\n      setBars(rest);\n      return;\n    }\n    const shuffle = () => setBars(rest.map((b) => Math.max(18, Math.min(100, b + Math.round((Math.random() - 0.4) * 40)))));\n    shuffle();\n    const id = window.setInterval(shuffle, 1100);\n    return () => window.clearInterval(id);\n  }, [active]);\n  const total = Math.round(bars.reduce((a, b) => a + b, 0) * 3.1);\n  return (\n    <div className=\"flex h-full flex-col p-4 sm:p-5\">\n      <div className=\"flex items-baseline justify-between\">\n        <span className=\"text-[0.625rem] text-muted-foreground\">Readers this week</span>\n        <span className=\"font-semibold text-sm tabular-nums\">{total.toLocaleString(\"en-US\")}</span>\n      </div>\n      <div className=\"mt-3 flex flex-1 items-end gap-1.5\">\n        {bars.map((h, i) => (\n          // biome-ignore lint/suspicious/noArrayIndexKey: fixed days\n          <div className=\"flex h-full flex-1 flex-col items-center justify-end gap-1.5\" key={i}>\n            <motion.div\n              animate={{ clipPath: `inset(${100 - h}% 0% 0% 0% round 6px)` }}\n              className={cn(\n                \"h-full w-full\",\n                i === 6 ? \"bg-violet-500\" : \"bg-[color-mix(in_srgb,var(--foreground)_12%,var(--card))]\",\n              )}\n              initial={false}\n              transition={spring}\n            />\n            <span className=\"text-[0.5625rem] text-muted-foreground\">{days[i]}</span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nconst demos: Record<FeatureDemo, (props: { active: boolean }) => ReactNode> = {\n  search: SearchDemo,\n  shortcuts: ShortcutDemo,\n  history: HistoryDemo,\n  automation: AutomationDemo,\n  insights: InsightsDemo,\n};\n\nconst spans: Record<number, string> = {\n  2: \"md:col-span-2\",\n  3: \"md:col-span-3\",\n  4: \"sm:col-span-2 md:col-span-4\",\n  6: \"sm:col-span-2 md:col-span-6\",\n};\n\nfunction Tile({ feature, index }: { feature: BentoFeature; index: number }) {\n  const reduce = useReducedMotionSafe();\n  const ref = useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { amount: 0.7 });\n  const [hovered, setHovered] = useState(false);\n  const [touch, setTouch] = useState(false);\n  useEffect(() => {\n    setTouch(window.matchMedia(\"(hover: none)\").matches);\n  }, []);\n  const active = !reduce && (hovered || (touch && inView));\n  const Demo = demos[feature.demo];\n\n  return (\n    <motion.article\n      className={cn(\n        \"group relative flex flex-col overflow-hidden rounded-2xl border bg-card shadow-xs/5 transition-[border-color,box-shadow] duration-200\",\n        \"hover:border-foreground/12 hover:shadow-md/5\",\n        spans[feature.span ?? 2],\n      )}\n      initial={{ opacity: 0, y: 12 }}\n      onPointerEnter={(e) => e.pointerType === \"mouse\" && setHovered(true)}\n      onPointerLeave={() => setHovered(false)}\n      ref={ref}\n      transition={{ duration: 0.5, ease, delay: Math.min(index, 5) * 0.04 }}\n      viewport={{ once: true, amount: 0.3 }}\n      whileInView={{ opacity: 1, y: 0 }}\n    >\n      <div className=\"relative m-2 mb-0 h-48 overflow-hidden rounded-lg bg-muted/60 bg-[radial-gradient(var(--color-border)_1px,transparent_1px)] [background-size:14px_14px]\">\n        <Demo active={active} />\n      </div>\n      <div className=\"flex flex-1 flex-col p-5 pt-4\">\n        <h3 className=\"font-medium text-[0.9375rem]\">{feature.title}</h3>\n        <p className=\"mt-1 text-pretty text-muted-foreground text-sm leading-relaxed\">{feature.description}</p>\n      </div>\n    </motion.article>\n  );\n}\n\nexport function FeatureBento({ eyebrow, title, description, features, className }: FeatureBentoProps) {\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <section className={cn(\"mx-auto w-full max-w-[1100px]\", className)}>\n        <header className=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\">\n          <div className=\"max-w-xl\">\n            {eyebrow && <p className=\"font-medium text-muted-foreground text-xs uppercase tracking-widest\">{eyebrow}</p>}\n            <h2 className=\"mt-2 text-balance font-heading font-semibold text-3xl tracking-tight sm:text-4xl\">{title}</h2>\n          </div>\n          {description && (\n            <p className=\"max-w-sm text-pretty text-muted-foreground text-sm leading-relaxed md:text-end\">\n              {description}\n              <span className=\"mt-1 hidden items-center gap-1 text-foreground/70 text-xs md:flex md:justify-end [@media(hover:none)]:hidden\">\n                Hover a tile to see it work <ArrowRightIcon className=\"size-3\" />\n              </span>\n            </p>\n          )}\n        </header>\n        <div className=\"mt-10 grid gap-3 sm:grid-cols-2 md:grid-cols-6 md:gap-4\">\n          {features.map((feature, i) => (\n            <Tile feature={feature} index={i} key={feature.title} />\n          ))}\n        </div>\n      </section>\n    </MotionConfig>\n  );\n}\n"
    }
  ]
}