{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hero-flow-field",
  "title": "Hero, flow field",
  "description": "A hero beside a print: a round flow field of several hundred strokes, plotted top to bottom on arrival, with a live stroke count.",
  "dependencies": [
    "svg-scroll-draw@^2.29.0"
  ],
  "registryDependencies": [
    "https://scrollfx-ui.vercel.app/r/plotter.json"
  ],
  "files": [
    {
      "path": "registry/blocks/hero-flow-field.tsx",
      "content": "'use client';\n\n/**\n * hero-flow-field — a hero beside a print: a round flow field of several\n * hundred strokes that a pen plots on arrival, top to bottom, in ink and one\n * accent colour. The caption counts the strokes as they land.\n *\n * Built on svg-scroll-draw (MIT): https://github.com/DhruvilChauahan0210/scrollfx\n * Needs: react, svg-scroll-draw, and lib/plotter (installed with it).\n * Styling: Tailwind CSS with shadcn/ui tokens. The print is a `bg-card` sheet.\n *\n * The drawing is generated in the browser from `seed`, so it is the same on\n * every visit (browsers may differ by a stroke or two: engines round Math.sin\n * differently), and the server HTML stays small. Reduced motion shows it whole.\n */\n\nimport { Fragment, useEffect, useRef, useState } from 'react';\nimport { scrollDraw } from 'svg-scroll-draw';\nimport 'svg-scroll-draw/no-flash.css';\nimport { flowField, type Stroke } from '@/lib/plotter';\n\nexport interface HeroFlowFieldProps {\n  eyebrow?: string;\n  /** One emphasised word between asterisks. */\n  heading?: string;\n  description?: string;\n  primary?: { label: string; href: string };\n  /** A command or note shown beside the button. */\n  aside?: string;\n  caption?: string;\n  seed?: number;\n  /** The second pen's colour. The first is the text colour. */\n  accent?: string;\n  /** How long the whole plot takes, in milliseconds. */\n  duration?: number;\n  className?: string;\n}\n\nfunction Heading({ text }: { text: string }) {\n  return (\n    <>\n      {text.split(/(\\*[^*]+\\*)/).map((p, i) => (p.startsWith('*') ? <em key={i} className=\"italic\">{p.slice(1, -1)}</em> : <span key={i}>{p}</span>))}\n    </>\n  );\n}\n\nconst STROKE_MS = 320;\n\nexport function HeroFlowField({\n  eyebrow = 'Generative sections for React',\n  heading = 'Pages, *plotted* as you read.',\n  description = 'Sections whose drawings ink themselves in, stroke by stroke, as the reader arrives and scrolls.',\n  primary = { label: 'Get started', href: '#' },\n  aside,\n  caption = 'Pl. I — Flow field',\n  seed = 417,\n  accent = '#e0482a',\n  duration = 5200,\n  className = '',\n}: HeroFlowFieldProps) {\n  const [strokes, setStrokes] = useState<Stroke[]>([]);\n  const svgRef = useRef<SVGSVGElement>(null);\n  const countRef = useRef<HTMLSpanElement>(null);\n\n  useEffect(() => setStrokes(flowField({ seed })), [seed]);\n\n  useEffect(() => {\n    const svg = svgRef.current;\n    if (!svg || !strokes.length) return;\n    const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;\n    // Each stroke draws in STROKE_MS; the offsets spread them over `duration`.\n    const stagger = (duration / STROKE_MS - 1) / Math.max(1, strokes.length - 1);\n    const draw = scrollDraw(svg, { selector: 'path', autoplay: true, duration: STROKE_MS, stagger, easing: 'ease-out', native: false });\n    if (reduce) draw.seek(1);\n    const start = performance.now();\n    let raf = 0;\n    const tick = () => {\n      const t = reduce ? 1 : Math.min(1, (performance.now() - start) / duration);\n      if (countRef.current) countRef.current.textContent = String(Math.round(t * strokes.length)).padStart(3, '0');\n      if (t < 1) raf = requestAnimationFrame(tick);\n    };\n    raf = requestAnimationFrame(tick);\n    return () => { cancelAnimationFrame(raf); draw.destroy(); };\n  }, [strokes, duration]);\n\n  return (\n    <section className={`relative mx-auto grid max-w-7xl items-center gap-12 px-6 pb-24 pt-10 sm:px-10 lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] lg:gap-20 lg:pt-20 ${className}`}>\n      <div className=\"max-w-xl\">\n        <p className=\"font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground\">{eyebrow}</p>\n        <h1 className=\"mt-8 font-serif text-[clamp(3rem,6.4vw,6.2rem)] leading-[0.94] tracking-[-0.035em]\">\n          <Heading text={heading} />\n        </h1>\n        <p className=\"mt-8 max-w-md text-pretty text-[17px] leading-relaxed text-muted-foreground\">{description}</p>\n        <div className=\"mt-10 flex flex-wrap items-center gap-4\">\n          <a href={primary.href} className=\"inline-flex h-12 items-center rounded-full bg-foreground px-7 text-[15px] font-medium text-background transition-transform hover:-translate-y-px\">\n            {primary.label}\n          </a>\n          {/* Each word is one unit, so a long command wraps at a space, never\n              at a hyphen inside a URL; a word wider than the box still wraps. */}\n          {aside && (\n            <code className=\"max-w-full rounded-2xl border px-5 py-3 font-mono text-[12px] leading-relaxed text-muted-foreground\">\n              {aside.split(' ').map((word, i) => (\n                // A plain space between words: dropped at a line break, so a\n                // wrapped line starts flush.\n                <Fragment key={i}>{i > 0 && ' '}<span className=\"inline-block max-w-full [overflow-wrap:anywhere]\">{word}</span></Fragment>\n              ))}\n            </code>\n          )}\n        </div>\n      </div>\n\n      {/* The print: a sheet, the drawing, and its plate caption. On a phone it comes first. */}\n      <figure className=\"order-first lg:order-none\">\n        <div className=\"aspect-square w-full rounded-[3px] bg-card p-[6%] shadow-[0_1px_0_rgba(0,0,0,.04),0_18px_40px_-18px_rgba(40,30,10,.3),0_2px_6px_-2px_rgba(40,30,10,.12)] dark:shadow-[0_0_0_1px_rgba(255,255,255,.05),0_24px_60px_-20px_rgba(0,0,0,.8)]\">\n          <svg ref={svgRef} data-scroll-draw-pending=\"\" viewBox=\"0 0 1000 1000\" className=\"size-full\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.15\" strokeLinecap=\"round\" strokeLinejoin=\"round\" role=\"img\" aria-label=\"A flow field plotted in ink\">\n            {strokes.map((s, i) => (s.pen ? <path key={i} d={s.d} stroke={accent} strokeWidth=\"1.9\" /> : <path key={i} d={s.d} />))}\n          </svg>\n        </div>\n        <figcaption className=\"mt-4 flex items-baseline justify-between gap-4 whitespace-nowrap font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground\">\n          <span>{caption}</span>\n          <span>\n            <span ref={countRef}>000</span> / {String(strokes.length).padStart(3, '0')} strokes<span className=\"hidden sm:inline\"> · seed {seed}</span>\n          </span>\n        </figcaption>\n      </figure>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "motion": "Watch it arrive: the pen plots the print, top to bottom.",
    "tall": false
  },
  "type": "registry:block"
}