{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "heroes-07",
  "title": "Hero with a chat box",
  "description": "A hero for an AI product whose prompt box types its own questions into the empty field, one after another, while app tiles orbit it on two dashed circles and stay upright as they turn.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/chat-prompt-input.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json",
    "https://ui.ndekocode.dev/r/wash.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/heroes/heroes-07/index.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\nimport { Wash } from '@/registry/ndeko/ui/wash';\n\nimport { APPS, HERO } from './data';\nimport { Orbit } from './orbit';\nimport { PromptBox } from './prompt-box';\n\nconst STAGE_FADE =\n  '[mask-image:linear-gradient(to_bottom,transparent,black_16%,black_84%,transparent)]';\n\nfunction spokenAppsOf(names: string[]) {\n  const last = names[names.length - 1];\n  const others = names.slice(0, -1);\n  return `${others.join(', ')} and ${last}`;\n}\n\nexport default function Heroes07() {\n  const appNames = APPS.map((app) => app.name);\n  const spokenApps = spokenAppsOf(appNames);\n\n  return (\n    <section className='@container'>\n      <div className='relative isolate overflow-x-clip'>\n        <Wash className='h-[28rem]' />\n        <div className='mx-auto flex max-w-6xl flex-col items-center px-4 py-16 @2xl:px-6 @2xl:py-24'>\n          <div className='flex max-w-3xl flex-col items-center gap-5 text-center'>\n            <p className='text-primary-ink text-sm font-medium'>\n              {HERO.eyebrow}\n            </p>\n            <h1 className='text-4xl font-semibold text-balance @2xl:text-5xl'>\n              {HERO.title}\n            </h1>\n            <p className='text-muted-foreground max-w-xl text-base text-pretty'>\n              {HERO.description}\n            </p>\n            <p className='sr-only'>Works with {spokenApps}</p>\n          </div>\n          <div\n            className={cn(\n              '@container relative mt-10 h-[22rem] w-full max-w-3xl overflow-hidden @2xl:h-[28rem]',\n              STAGE_FADE\n            )}\n          >\n            <Orbit />\n            <div className='relative z-10 flex h-full items-center justify-center px-4'>\n              <PromptBox />\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-07/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-07/prompt-box.tsx",
      "content": "'use client';\n\nimport { useMemo, useState } from 'react';\n\nimport {\n  type AutoplayStep,\n  typingSteps,\n  useAutoplay,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { keyDelayOf, prefixesOf } from '@/registry/ndeko/lib/demonstration';\nimport { PlugIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport {\n  PromptInput,\n  PromptInputSubmit,\n  PromptInputTextarea,\n} from '@/registry/ndeko/ui/chat-prompt-input';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { APPS, HERO, QUESTIONS } from './data';\n\nconst BEFORE_TYPING_MS = 350;\nconst TYPE_MS = 38;\nconst HOLD_MS = 1600;\nconst ERASE_MS = 14;\nconst LOOP_AFTER_MS = 500;\n\nconst BOX =\n  'dark:bg-card cursor-text rounded-2xl p-2.5 shadow-[0_1px_2px_rgb(0_0_0/0.04),0_16px_40px_-20px_rgb(0_0_0/0.16)]';\n\nfunction erasingSteps(\n  text: string,\n  write: (typed: string) => void\n): AutoplayStep[] {\n  const prefixes = prefixesOf(text);\n  const shorter = prefixes.slice(0, -1);\n  const remaining = [...shorter.reverse(), ''];\n  return remaining.map((typed, index) => {\n    const after = keyDelayOf(index, HOLD_MS, ERASE_MS);\n    return { after, run: () => write(typed) };\n  });\n}\n\nfunction questionSteps(write: (typed: string) => void): AutoplayStep[] {\n  const rounds = QUESTIONS.map((question) => [\n    ...typingSteps(question, write, {\n      startAfter: BEFORE_TYPING_MS,\n      characterMs: TYPE_MS,\n    }),\n    ...erasingSteps(question, write),\n  ]);\n  return rounds.flat();\n}\n\nfunction placeholderOf(isAutoplaying: boolean) {\n  if (isAutoplaying) {\n    return '';\n  }\n  return QUESTIONS[0];\n}\n\nfunction hintKeyOf(isSent: boolean) {\n  if (isSent) {\n    return 'sent';\n  }\n  return 'idle';\n}\n\nfunction announcementOf(isSent: boolean) {\n  if (isSent) {\n    return HERO.sentAnnouncement;\n  }\n  return '';\n}\n\nfunction caretClassOf(isLive: boolean) {\n  if (isLive) {\n    return 'animate-pulse';\n  }\n  return undefined;\n}\n\n/** Sits over the empty field and uses its metrics, so the typed question lands where a person's would. */\nfunction TypedQuestion({ text, isLive }: { text: string; isLive: boolean }) {\n  return (\n    <span\n      aria-hidden='true'\n      className='text-muted-foreground/75 pointer-events-none absolute inset-0 px-2 py-1.5 text-base leading-normal select-none'\n    >\n      {text}\n      <span\n        className={cn(\n          'bg-foreground/60 ms-px inline-block h-[1.15em] w-0.5 translate-y-[0.2em] rounded-full',\n          caretClassOf(isLive)\n        )}\n      />\n    </span>\n  );\n}\n\nfunction Hint({ isSent }: { isSent: boolean }) {\n  const key = hintKeyOf(isSent);\n\n  return (\n    <Swap swapKey={key} className='text-muted-foreground min-w-0 text-xs'>\n      {!isSent && (\n        <span className='flex items-center gap-1.5'>\n          <PlugIcon className='size-3.5 shrink-0' />\n          <span>Reads from {APPS.length} connected apps</span>\n        </span>\n      )}\n      {isSent && (\n        <a\n          href='#'\n          className='text-primary-ink focus-visible:ring-ring/25 rounded-sm outline-none hover:underline focus-visible:ring-[3px]'\n        >\n          {HERO.sentHint}\n        </a>\n      )}\n    </Swap>\n  );\n}\n\nexport function PromptBox() {\n  const [question, setQuestion] = useState('');\n  const [typed, setTyped] = useState('');\n  const [isSent, setIsSent] = useState(false);\n  const steps = useMemo(() => questionSteps(setTyped), []);\n\n  function clearTyped() {\n    setTyped('');\n  }\n\n  const { ref, isInView, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: LOOP_AFTER_MS,\n    onReset: clearTyped,\n  });\n  const placeholder = placeholderOf(isAutoplaying);\n  const announcement = announcementOf(isSent);\n\n  function changeQuestion(value: string) {\n    setQuestion(value);\n    setIsSent(false);\n  }\n\n  function send() {\n    const hasText = question.trim().length > 0;\n    if (!hasText) {\n      return;\n    }\n    setIsSent(true);\n  }\n\n  return (\n    <div ref={ref} className='w-full max-w-[30rem]'>\n      <PromptInput\n        value={question}\n        onValueChange={changeQuestion}\n        onSubmit={send}\n        className={BOX}\n      >\n        <div className='relative'>\n          <PromptInputTextarea\n            aria-label={HERO.boxLabel}\n            placeholder={placeholder}\n            className='min-h-[4.5rem] text-base md:text-base'\n          />\n          {isAutoplaying && <TypedQuestion text={typed} isLive={isInView} />}\n        </div>\n        <div className='flex min-h-8 items-center justify-between gap-3 ps-2'>\n          <Hint isSent={isSent} />\n          <PromptInputSubmit sendLabel={HERO.sendLabel} />\n        </div>\n      </PromptInput>\n      <LiveRegion message={announcement} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-07/prompt-box.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-07/orbit.tsx",
      "content": "'use client';\n\nimport { useInView } from 'motion/react';\nimport { type CSSProperties, useRef } from 'react';\n\nimport { useDocumentVisible } from '@/registry/ndeko/hooks/use-agent-run';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\n\nimport { INNER_RING, OUTER_RING, type Ring } from './data';\n\nconst FULL_TURN = 360;\n\nconst RING_SIZE: Record<Ring['id'], string> = {\n  outer: 'w-[min(35rem,calc(100cqw_-_2.5rem))]',\n  inner: 'w-[min(24rem,calc(68.5cqw_-_1.7rem))]',\n};\n\nfunction placeOf(index: number, count: number, startDegrees: number) {\n  const degrees = startDegrees + (FULL_TURN / count) * index;\n  const radians = (degrees * Math.PI) / 180;\n  const left = 50 + 50 * Math.cos(radians);\n  const top = 50 + 50 * Math.sin(radians);\n  const place: CSSProperties = {\n    left: `${left.toFixed(1)}%`,\n    top: `${top.toFixed(1)}%`,\n  };\n  return place;\n}\n\nfunction directionOf(isReversed: boolean) {\n  if (isReversed) {\n    return 'reverse';\n  }\n  return 'normal';\n}\n\nfunction playStateOf(isPlaying: boolean) {\n  if (isPlaying) {\n    return 'running';\n  }\n  return 'paused';\n}\n\nfunction spinClassOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return undefined;\n  }\n  return 'animate-spin';\n}\n\ntype SpinOptions = {\n  seconds: number;\n  isReversed: boolean;\n  isPlaying: boolean;\n};\n\nfunction spinStyleOf({ seconds, isReversed, isPlaying }: SpinOptions) {\n  const style: CSSProperties = {\n    animationDuration: `${seconds}s`,\n    animationDirection: directionOf(isReversed),\n    animationPlayState: playStateOf(isPlaying),\n  };\n  return style;\n}\n\ntype RingViewProps = {\n  ring: Ring;\n  isPlaying: boolean;\n  shouldReduceMotion: boolean;\n};\n\n/** The circle turns one way and each tile turns back the other way at the same speed, so the marks stay upright. */\nfunction RingView({ ring, isPlaying, shouldReduceMotion }: RingViewProps) {\n  const spinClass = spinClassOf(shouldReduceMotion);\n  const ringStyle = spinStyleOf({\n    seconds: ring.turnSeconds,\n    isReversed: ring.isReversed,\n    isPlaying,\n  });\n  const tileStyle = spinStyleOf({\n    seconds: ring.turnSeconds,\n    isReversed: !ring.isReversed,\n    isPlaying,\n  });\n  const count = ring.apps.length;\n\n  return (\n    <div\n      style={ringStyle}\n      className={cn(\n        'border-foreground/15 absolute top-1/2 left-1/2 aspect-square -translate-1/2 rounded-full border border-dashed',\n        RING_SIZE[ring.id],\n        spinClass\n      )}\n    >\n      {ring.apps.map((app, index) => (\n        <span\n          key={app.id}\n          style={placeOf(index, count, ring.startDegrees)}\n          className='absolute -translate-x-1/2 -translate-y-1/2'\n        >\n          <span style={tileStyle} className={cn('block', spinClass)}>\n            <BrandTile brand={app.brand} size='2xl' />\n          </span>\n        </span>\n      ))}\n    </div>\n  );\n}\n\nexport function Orbit() {\n  const ref = useRef<HTMLDivElement>(null);\n  const isInView = useInView(ref, { amount: 0.1 });\n  const isVisible = useDocumentVisible();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const isPlaying = isInView && isVisible;\n\n  return (\n    <div ref={ref} aria-hidden='true' className='absolute inset-0'>\n      <RingView\n        ring={OUTER_RING}\n        isPlaying={isPlaying}\n        shouldReduceMotion={shouldReduceMotion}\n      />\n      <RingView\n        ring={INNER_RING}\n        isPlaying={isPlaying}\n        shouldReduceMotion={shouldReduceMotion}\n      />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-07/orbit.tsx"
    },
    {
      "path": "registry/ndeko/blocks/heroes/heroes-07/data.ts",
      "content": "import type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type App = {\n  id: string;\n  name: string;\n  brand: BrandSlug;\n};\n\nexport type Ring = {\n  id: 'inner' | 'outer';\n  apps: App[];\n  startDegrees: number;\n  turnSeconds: number;\n  isReversed: boolean;\n};\n\nexport const HERO = {\n  eyebrow: 'An assistant for teams of two to twenty',\n  title: 'Ask one question and get the answer from every app you use',\n  description:\n    'Type it the way you would say it. The assistant reads your calendar, inbox, tracker and files, then answers with a link to where it found each part.',\n  boxLabel: 'Ask a question',\n  sendLabel: 'Ask',\n  sentHint: 'Sign up to see the answer',\n  sentAnnouncement: 'Sign up to see the answer to your question',\n};\n\nexport const QUESTIONS = [\n  'Which invoices are still unpaid this month?',\n  'What did I promise to send before Friday?',\n  'Move my 3 pm with Amara to tomorrow morning',\n  'Summarize the design review thread',\n];\n\nexport const INNER_RING: Ring = {\n  id: 'inner',\n  apps: [\n    { id: 'calendar', name: 'Google Calendar', brand: 'googlecalendar' },\n    { id: 'gmail', name: 'Gmail', brand: 'gmail' },\n    { id: 'notion', name: 'Notion', brand: 'notion' },\n    { id: 'drive', name: 'Google Drive', brand: 'googledrive' },\n  ],\n  startDegrees: 45,\n  turnSeconds: 90,\n  isReversed: false,\n};\n\nexport const OUTER_RING: Ring = {\n  id: 'outer',\n  apps: [\n    { id: 'linear', name: 'Linear', brand: 'linear' },\n    { id: 'github', name: 'GitHub', brand: 'github' },\n    { id: 'figma', name: 'Figma', brand: 'figma' },\n    { id: 'stripe', name: 'Stripe', brand: 'stripe' },\n    { id: 'jira', name: 'Jira', brand: 'jira' },\n  ],\n  startDegrees: -36,\n  turnSeconds: 140,\n  isReversed: true,\n};\n\nexport const APPS: App[] = [...INNER_RING.apps, ...OUTER_RING.apps];\n",
      "type": "registry:component",
      "target": "components/blocks/heroes-07/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "heroes"
  ],
  "type": "registry:block"
}