{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "prompt-04",
  "title": "Model and effort",
  "description": "An effort slider with four stops you drag and flick, with every model’s time and cost rolling under your finger, also folded into a chip for a composer.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/drawn-check.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/motion-word-roll.json",
    "https://ui.ndekocode.dev/r/popover.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/prompt/prompt-04.tsx",
      "content": "'use client';\n\nimport {\n  animate,\n  AnimatePresence,\n  motion,\n  useMotionValue,\n  useMotionValueEvent,\n  useTransform,\n} from 'motion/react';\nimport { useEffect, useId, useImperativeHandle, useRef, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { WordRoll } from '@/components/core/word-roll';\nimport {\n  useAutoplay,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { hold, spokenUnless } from '@/registry/ndeko/lib/demonstration';\nimport { ChevronDownIcon } from '@/registry/ndeko/lib/icons';\nimport { springOf } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport {\n  Popover,\n  PopoverContent,\n  PopoverTitle,\n  PopoverTrigger,\n} from '@/registry/ndeko/ui/popover';\n\nimport { LabTile } from './_parts/lab-tile';\nimport type { LabId } from './_parts/labs';\n\nexport type Effort = 'low' | 'medium' | 'high' | 'max';\n\nexport type EffortModel = {\n  id: string;\n  name: string;\n  lab: LabId;\n  /** Seconds per answer at Low and at Max effort; the stops between grow geometrically. */\n  seconds: [number, number];\n  /** Dollars per answer at Low and at Max effort. */\n  cost: [number, number];\n};\n\nexport type EffortControlHandle = {\n  /** Glides the knob to a stop, held the way a finger holds it, and lets it catch there. */\n  moveTo: (effort: Effort) => void;\n};\n\nconst EFFORTS: Effort[] = ['low', 'medium', 'high', 'max'];\n\nconst EFFORT_LABEL: Record<Effort, string> = {\n  low: 'Low',\n  medium: 'Medium',\n  high: 'High',\n  max: 'Max',\n};\n\nconst EFFORT_LABELS = EFFORTS.map((effort) => EFFORT_LABEL[effort]);\n\nconst LAST_INDEX = EFFORTS.length - 1;\n\n/** Live figures move in twentieths of a stop, so digits roll with the finger without a render per frame. */\nconst LIVE_STEPS_PER_STOP = 20;\n\n/** How far a flick carries, in seconds of its release velocity. */\nconst PROJECTION_S = 0.16;\n\n/** Past either end the knob follows the finger at this fraction of the distance. */\nconst EDGE_RESISTANCE = 0.18;\n\nconst SETTLE = { type: 'spring', stiffness: 420, damping: 34 } as const;\n\nconst SECONDS_FORMAT: Intl.NumberFormatOptions = {\n  minimumFractionDigits: 1,\n  maximumFractionDigits: 1,\n};\n\nconst COST_FORMAT: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  minimumFractionDigits: 3,\n  maximumFractionDigits: 3,\n};\n\nconst SECONDS_TEXT = new Intl.NumberFormat('en-US', SECONDS_FORMAT);\n\nconst COST_TEXT = new Intl.NumberFormat('en-US', COST_FORMAT);\n\nfunction shareOfIndex(index: number) {\n  return index / LAST_INDEX;\n}\n\nfunction percentOf(share: number) {\n  const percent = share * 100;\n  return `${percent}%`;\n}\n\n/** The knob travels by transform: its share of the width of the track, which is a size container. */\nfunction knobOffsetOf(share: number) {\n  return `calc(${share} * 100cqw)`;\n}\n\nfunction stopDotStyleOf(index: number) {\n  const share = shareOfIndex(index);\n  return { left: percentOf(share) };\n}\n\nfunction boundedIndex(index: number) {\n  return Math.min(LAST_INDEX, Math.max(0, index));\n}\n\nfunction nearestIndexOf(position: number) {\n  const rounded = Math.round(position);\n  return boundedIndex(rounded);\n}\n\nfunction quantize(position: number) {\n  const steps = Math.round(position * LIVE_STEPS_PER_STOP);\n  const quantized = steps / LIVE_STEPS_PER_STOP;\n  return Math.min(LAST_INDEX, Math.max(0, quantized));\n}\n\nfunction rubberBand(share: number) {\n  if (share < 0) {\n    return share * EDGE_RESISTANCE;\n  }\n  if (share > 1) {\n    const overshoot = share - 1;\n    return 1 + overshoot * EDGE_RESISTANCE;\n  }\n  return share;\n}\n\nfunction clampedShare(share: number) {\n  return Math.min(1, Math.max(0, share));\n}\n\nfunction figureAt(range: [number, number], position: number) {\n  const [atLow, atMax] = range;\n  const ratio = atMax / atLow;\n  const progress = position / LAST_INDEX;\n  const growth = Math.pow(ratio, progress);\n  return atLow * growth;\n}\n\nfunction roundedSeconds(seconds: number) {\n  const tenths = Math.round(seconds * 10);\n  return tenths / 10;\n}\n\nfunction roundedCost(cost: number) {\n  const thousandths = Math.round(cost * 1000);\n  return thousandths / 1000;\n}\n\nexport function secondsOf(model: EffortModel, position: number) {\n  const seconds = figureAt(model.seconds, position);\n  return roundedSeconds(seconds);\n}\n\nexport function costOf(model: EffortModel, position: number) {\n  const cost = figureAt(model.cost, position);\n  return roundedCost(cost);\n}\n\nfunction stopToneOf(isCurrent: boolean) {\n  if (isCurrent) {\n    return 'text-foreground';\n  }\n  return 'text-muted-foreground hover:text-foreground';\n}\n\nfunction stopAlignOf(index: number) {\n  if (index === 0) {\n    return 'start-0 text-start';\n  }\n  if (index === LAST_INDEX) {\n    return 'end-0 text-end';\n  }\n  return '-translate-x-1/2 text-center';\n}\n\nfunction stopLeftOf(index: number) {\n  const isEdge = index === 0 || index === LAST_INDEX;\n  if (isEdge) {\n    return undefined;\n  }\n  const share = shareOfIndex(index);\n  return { left: percentOf(share) };\n}\n\nfunction keyStepOf(key: string) {\n  const isBack = key === 'ArrowLeft' || key === 'ArrowDown';\n  if (isBack) {\n    return -1;\n  }\n  const isForward = key === 'ArrowRight' || key === 'ArrowUp';\n  if (isForward) {\n    return 1;\n  }\n  return 0;\n}\n\ntype EffortTrackProps = {\n  value: Effort;\n  livePosition: number;\n  onValueChange: (effort: Effort) => void;\n  onLiveChange: (position: number | null) => void;\n  valueText: string;\n  handleRef?: React.Ref<EffortControlHandle>;\n};\n\nfunction EffortTrack({\n  value,\n  livePosition,\n  onValueChange,\n  onLiveChange,\n  valueText,\n  handleRef,\n}: EffortTrackProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const index = EFFORTS.indexOf(value);\n  const share = useMotionValue(shareOfIndex(index));\n  const knobX = useTransform(share, knobOffsetOf);\n  const fillScale = useTransform(share, clampedShare);\n  const [isGrabbing, setIsGrabbing] = useState(false);\n  const [isLifted, setIsLifted] = useState(false);\n  const trackRef = useRef<HTMLDivElement>(null);\n  const knobRef = useRef<HTMLSpanElement>(null);\n  const isDragging = useRef(false);\n  const isInteracting = useRef(false);\n  const interaction = useRef(0);\n  const settling = useRef<ReturnType<typeof animate> | null>(null);\n  const nearestStop = nearestIndexOf(livePosition);\n  const isHeld = isGrabbing || isLifted;\n  const press = pressOf(isHeld, shouldReduceMotion);\n\n  useMotionValueEvent(share, 'change', (latest) => {\n    if (!isInteracting.current) {\n      return;\n    }\n    const position = latest * LAST_INDEX;\n    onLiveChange(quantize(position));\n  });\n\n  useEffect(() => {\n    if (isInteracting.current) {\n      return;\n    }\n    const target = shareOfIndex(index);\n    settling.current?.stop();\n    if (shouldReduceMotion) {\n      share.set(target);\n      return;\n    }\n    settling.current = animate(share, target, SETTLE);\n  }, [index, share, shouldReduceMotion]);\n\n  function beginInteraction() {\n    settling.current?.stop();\n    isInteracting.current = true;\n    interaction.current += 1;\n  }\n\n  function finishInteraction(token: number) {\n    const isLatest = token === interaction.current;\n    if (!isLatest) {\n      return;\n    }\n    isInteracting.current = false;\n    setIsLifted(false);\n    onLiveChange(null);\n  }\n\n  function settleTo(targetIndex: number, velocity: number) {\n    const token = interaction.current;\n    const target = shareOfIndex(targetIndex);\n    onValueChange(EFFORTS[targetIndex]);\n    if (shouldReduceMotion) {\n      share.set(target);\n      finishInteraction(token);\n      return;\n    }\n    const controls = animate(share, target, { ...SETTLE, velocity });\n    settling.current = controls;\n    controls.then(() => finishInteraction(token));\n  }\n\n  function shareAt(clientX: number) {\n    const track = trackRef.current;\n    if (!track) {\n      return share.get();\n    }\n    const rect = track.getBoundingClientRect();\n    const offset = clientX - rect.left;\n    const raw = offset / rect.width;\n    return rubberBand(raw);\n  }\n\n  function startDrag(event: React.PointerEvent<HTMLDivElement>) {\n    if (event.button !== 0) {\n      return;\n    }\n    event.currentTarget.setPointerCapture(event.pointerId);\n    beginInteraction();\n    isDragging.current = true;\n    setIsGrabbing(true);\n    knobRef.current?.focus({ preventScroll: true });\n    share.set(shareAt(event.clientX));\n  }\n\n  function moveDrag(event: React.PointerEvent<HTMLDivElement>) {\n    if (!isDragging.current) {\n      return;\n    }\n    share.set(shareAt(event.clientX));\n  }\n\n  function endDrag() {\n    if (!isDragging.current) {\n      return;\n    }\n    isDragging.current = false;\n    setIsGrabbing(false);\n    const velocity = share.getVelocity();\n    const current = share.get();\n    const carried = velocity * PROJECTION_S;\n    const projected = current + carried;\n    const position = projected * LAST_INDEX;\n    settleTo(nearestIndexOf(position), velocity);\n  }\n\n  function moveFromKeys(event: React.KeyboardEvent<HTMLSpanElement>) {\n    const step = keyStepOf(event.key);\n    let targetIndex = index + step;\n    if (event.key === 'Home') {\n      targetIndex = 0;\n    }\n    if (event.key === 'End') {\n      targetIndex = LAST_INDEX;\n    }\n    const bounded = boundedIndex(targetIndex);\n    const isMove = bounded !== index;\n    if (!isMove) {\n      return;\n    }\n    event.preventDefault();\n    beginInteraction();\n    settleTo(bounded, 0);\n  }\n\n  function jumpTo(stopIndex: number) {\n    beginInteraction();\n    settleTo(stopIndex, 0);\n  }\n\n  function moveTo(effort: Effort) {\n    const stopIndex = EFFORTS.indexOf(effort);\n    beginInteraction();\n    setIsLifted(true);\n    settleTo(stopIndex, 0);\n  }\n\n  useImperativeHandle(handleRef, () => ({ moveTo }));\n\n  return (\n    <div className='flex flex-col gap-1.5'>\n      <div\n        onPointerDown={startDrag}\n        onPointerMove={moveDrag}\n        onPointerUp={endDrag}\n        onPointerCancel={endDrag}\n        className={cn(\n          'relative h-9 touch-none px-3 select-none',\n          cursorOf(isGrabbing)\n        )}\n      >\n        <div ref={trackRef} className='@container relative h-full'>\n          <span className='bg-foreground/[0.08] absolute inset-x-0 top-1/2 h-1.5 -translate-y-1/2 rounded-full' />\n          <motion.span\n            aria-hidden='true'\n            style={{ scaleX: fillScale }}\n            className='bg-primary/85 absolute inset-x-0 top-1/2 h-1.5 origin-left -translate-y-1/2 rounded-full'\n          />\n          {EFFORTS.map((effort, stopIndex) => (\n            <span\n              key={effort}\n              aria-hidden='true'\n              style={stopDotStyleOf(stopIndex)}\n              className='bg-card hairline-ring ring-foreground/20 absolute top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full'\n            />\n          ))}\n          <motion.span\n            ref={knobRef}\n            role='slider'\n            tabIndex={0}\n            aria-label='Effort'\n            aria-valuemin={0}\n            aria-valuemax={LAST_INDEX}\n            aria-valuenow={index}\n            aria-valuetext={valueText}\n            onKeyDown={moveFromKeys}\n            style={{ x: knobX }}\n            animate={press}\n            transition={{ duration: 0.12 }}\n            className='bg-card hairline-ring ring-foreground/15 dark:bg-foreground/90 focus-visible:ring-ring focus-visible:ring-offset-background absolute top-1/2 left-0 -mt-2.5 -ml-2.5 size-5 rounded-full shadow-[0_1px_3px_rgb(0_0_0/0.18)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2'\n          />\n        </div>\n      </div>\n      <div className='relative mx-3 h-4 text-xs'>\n        {EFFORTS.map((effort, stopIndex) => (\n          <button\n            key={effort}\n            type='button'\n            tabIndex={-1}\n            onClick={() => jumpTo(stopIndex)}\n            style={stopLeftOf(stopIndex)}\n            className={cn(\n              'absolute top-0 cursor-pointer whitespace-nowrap transition-[color,scale] duration-150 active:scale-[0.97]',\n              stopAlignOf(stopIndex),\n              stopToneOf(stopIndex === nearestStop)\n            )}\n          >\n            {EFFORT_LABEL[effort]}\n          </button>\n        ))}\n      </div>\n    </div>\n  );\n}\n\nfunction cursorOf(isGrabbing: boolean) {\n  if (isGrabbing) {\n    return 'cursor-grabbing';\n  }\n  return 'cursor-grab';\n}\n\nfunction pressOf(isHeld: boolean, shouldReduceMotion: boolean | null) {\n  const canScale = isHeld && !shouldReduceMotion;\n  if (canScale) {\n    return { scale: 1.15 };\n  }\n  return { scale: 1 };\n}\n\nfunction rowStepOf(key: string) {\n  const isPrevious = key === 'ArrowUp' || key === 'ArrowLeft';\n  if (isPrevious) {\n    return -1;\n  }\n  const isNext = key === 'ArrowDown' || key === 'ArrowRight';\n  if (isNext) {\n    return 1;\n  }\n  return 0;\n}\n\nfunction moveIndexOf(key: string, current: number, count: number) {\n  const step = rowStepOf(key);\n  if (key === 'Home') {\n    return 0;\n  }\n  if (key === 'End') {\n    return count - 1;\n  }\n  const moved = current + step;\n  const wrapped = moved + count;\n  return wrapped % count;\n}\n\ntype ModelRowsProps = {\n  models: EffortModel[];\n  modelId: string;\n  onModelChange: (modelId: string) => void;\n  position: number;\n};\n\nfunction ModelRows({\n  models,\n  modelId,\n  onModelChange,\n  position,\n}: ModelRowsProps) {\n  const highlightId = useId();\n  const groupRef = useRef<HTMLDivElement>(null);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const spring = springOf(shouldReduceMotion);\n  const pickedIndex = models.findIndex((model) => model.id === modelId);\n\n  function moveFromKeys(event: React.KeyboardEvent<HTMLButtonElement>) {\n    const isArrow = rowStepOf(event.key) !== 0;\n    const isEdge = event.key === 'Home' || event.key === 'End';\n    const isMove = isArrow || isEdge;\n    if (!isMove) {\n      return;\n    }\n    event.preventDefault();\n    const nextIndex = moveIndexOf(event.key, pickedIndex, models.length);\n    const next = models[nextIndex];\n    onModelChange(next.id);\n    requestAnimationFrame(() => {\n      const button = groupRef.current?.querySelector<HTMLElement>(\n        `[data-model=\"${next.id}\"]`\n      );\n      button?.focus();\n    });\n  }\n\n  return (\n    <div className='flex flex-col gap-1'>\n      <div\n        aria-hidden='true'\n        className='text-muted-foreground grid grid-cols-[1fr_3.5rem_4rem] gap-2 px-2.5 text-[11px]'\n      >\n        <span>Model</span>\n        <span className='text-end'>Time</span>\n        <span className='text-end'>Cost</span>\n      </div>\n      <div\n        ref={groupRef}\n        role='radiogroup'\n        aria-label='Model'\n        className='flex flex-col'\n      >\n        {models.map((model) => {\n          const isPicked = model.id === modelId;\n          const seconds = secondsOf(model, position);\n          const cost = costOf(model, position);\n          return (\n            <button\n              key={model.id}\n              type='button'\n              role='radio'\n              aria-checked={isPicked}\n              tabIndex={tabIndexOf(isPicked)}\n              data-model={model.id}\n              onClick={() => onModelChange(model.id)}\n              onKeyDown={moveFromKeys}\n              className='hover:bg-foreground/[0.03] focus-visible:ring-ring/25 relative grid h-10 cursor-pointer grid-cols-[1fr_3.5rem_4rem] items-center gap-2 rounded-lg px-2.5 text-start text-[13px] outline-none focus-visible:ring-[3px]'\n            >\n              {isPicked && (\n                <motion.span\n                  layoutId={highlightId}\n                  layoutDependency={modelId}\n                  transition={spring}\n                  aria-hidden='true'\n                  className='bg-foreground/[0.05] dark:bg-foreground/[0.07] absolute inset-0 rounded-lg'\n                />\n              )}\n              <span className='relative flex min-w-0 items-center gap-2'>\n                <LabTile lab={model.lab} size='sm' />\n                <span className='truncate font-medium'>{model.name}</span>\n                <AnimatePresence initial={false}>\n                  {isPicked && <DrawnCheck key='mark' className='size-4' />}\n                </AnimatePresence>\n              </span>\n              <span className='text-muted-foreground relative text-end text-xs'>\n                <MotionNumber\n                  value={seconds}\n                  format={SECONDS_FORMAT}\n                  suffix='s'\n                />\n              </span>\n              <span className='relative text-end text-xs'>\n                <MotionNumber value={cost} format={COST_FORMAT} />\n              </span>\n            </button>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n\nfunction tabIndexOf(isPicked: boolean) {\n  if (isPicked) {\n    return 0;\n  }\n  return -1;\n}\n\nfunction modelIn(models: EffortModel[], modelId: string) {\n  return models.find((model) => model.id === modelId) ?? models[0];\n}\n\nfunction valueTextOf(model: EffortModel, effort: Effort) {\n  const position = EFFORTS.indexOf(effort);\n  const seconds = secondsOf(model, position);\n  const cost = costOf(model, position);\n  const secondsText = SECONDS_TEXT.format(seconds);\n  const costText = COST_TEXT.format(cost);\n  const label = EFFORT_LABEL[effort];\n  return `${label}: about ${secondsText} seconds and ${costText} per answer with ${model.name}`;\n}\n\nexport type EffortControlProps = {\n  models: EffortModel[];\n  modelId: string;\n  onModelChange: (modelId: string) => void;\n  effort: Effort;\n  onEffortChange: (effort: Effort) => void;\n  /** Moves the knob from outside, for a demonstration or a control beside it. */\n  handleRef?: React.Ref<EffortControlHandle>;\n  className?: string;\n};\n\nexport function EffortControl({\n  models,\n  modelId,\n  onModelChange,\n  effort,\n  onEffortChange,\n  handleRef,\n  className,\n}: EffortControlProps) {\n  const [livePosition, setLivePosition] = useState<number | null>(null);\n  const restingPosition = EFFORTS.indexOf(effort);\n  const position = livePosition ?? restingPosition;\n  const nearest = nearestIndexOf(position);\n  const nearestLabel = EFFORT_LABEL[EFFORTS[nearest]];\n  const model = modelIn(models, modelId);\n  const valueText = valueTextOf(model, effort);\n\n  return (\n    <div className={cn('flex flex-col gap-4', className)}>\n      <div className='flex flex-col gap-2'>\n        <div className='flex items-baseline justify-between gap-3'>\n          <p className='text-sm font-medium'>Effort</p>\n          <p className='text-muted-foreground text-xs'>\n            <WordRoll\n              text={nearestLabel}\n              labels={EFFORT_LABELS}\n              value={nearest}\n            />\n          </p>\n        </div>\n        <EffortTrack\n          value={effort}\n          livePosition={position}\n          onValueChange={onEffortChange}\n          onLiveChange={setLivePosition}\n          valueText={valueText}\n          handleRef={handleRef}\n        />\n      </div>\n      <ModelRows\n        models={models}\n        modelId={modelId}\n        onModelChange={onModelChange}\n        position={position}\n      />\n      <p className='text-muted-foreground text-[11px]'>\n        Time and cost per answer are illustrative\n      </p>\n    </div>\n  );\n}\n\nfunction chipLabelOf(model: EffortModel, effort: Effort) {\n  return `${model.name}, ${EFFORT_LABEL[effort]}`;\n}\n\nexport function EffortChip(props: EffortControlProps) {\n  const model = modelIn(props.models, props.modelId);\n  const label = chipLabelOf(model, props.effort);\n\n  return (\n    <Popover>\n      <PopoverTrigger\n        render={\n          <Button\n            type='button'\n            variant='outline'\n            size='sm'\n            aria-label={`Model and effort: ${label}`}\n            className='gap-1.5 ps-1.5 pe-2'\n          />\n        }\n      >\n        <LabTile lab={model.lab} size='sm' />\n        <WordRoll text={label} />\n        <ChevronDownIcon className='text-muted-foreground size-3.5' />\n      </PopoverTrigger>\n      <PopoverContent\n        side='top'\n        align='end'\n        className='w-[22rem] max-w-[calc(100vw-2rem)] p-4'\n      >\n        <PopoverTitle className='sr-only'>Model and effort</PopoverTitle>\n        <EffortControl {...props} />\n      </PopoverContent>\n    </Popover>\n  );\n}\n\nconst MODELS: EffortModel[] = [\n  {\n    id: 'claude-haiku',\n    name: 'Claude Haiku',\n    lab: 'anthropic',\n    seconds: [1.2, 6.4],\n    cost: [0.001, 0.006],\n  },\n  {\n    id: 'claude-sonnet',\n    name: 'Claude Sonnet',\n    lab: 'anthropic',\n    seconds: [2.4, 18],\n    cost: [0.004, 0.038],\n  },\n  {\n    id: 'claude-opus',\n    name: 'Claude Opus',\n    lab: 'anthropic',\n    seconds: [5.5, 52],\n    cost: [0.019, 0.24],\n  },\n  {\n    id: 'gemini-pro',\n    name: 'Gemini Pro',\n    lab: 'google',\n    seconds: [4.1, 37],\n    cost: [0.011, 0.12],\n  },\n];\n\nconst START_MODEL = 'claude-sonnet';\n\nconst START_EFFORT: Effort = 'high';\n\nexport default function Prompt04() {\n  const [modelId, setModelId] = useState(START_MODEL);\n  const [effort, setEffort] = useState<Effort>(START_EFFORT);\n  const control = useRef<EffortControlHandle>(null);\n  const model = modelIn(MODELS, modelId);\n  const announcement = valueTextOf(model, effort);\n\n  function resetDemo() {\n    setModelId(START_MODEL);\n    setEffort(START_EFFORT);\n  }\n\n  const steps: AutoplayStep[] = [\n    { after: 1500, run: () => control.current?.moveTo('medium') },\n    { after: 620, run: () => control.current?.moveTo('low') },\n    { after: 1100, run: () => control.current?.moveTo('medium') },\n    { after: 620, run: () => control.current?.moveTo('high') },\n    { after: 620, run: () => control.current?.moveTo('max') },\n    { after: 1200, run: () => control.current?.moveTo('high') },\n    { after: 1200, run: () => setModelId('claude-opus') },\n    { after: 1500, run: () => setModelId(START_MODEL) },\n    { after: 500, run: hold },\n  ];\n  const { ref, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: 2400,\n    onReset: resetDemo,\n  });\n\n  useKeptHeight(ref);\n\n  return (\n    <div ref={ref} className='flex w-full max-w-[26rem] flex-col gap-3'>\n      <EffortControl\n        models={MODELS}\n        modelId={modelId}\n        onModelChange={setModelId}\n        effort={effort}\n        onEffortChange={setEffort}\n        handleRef={control}\n        className='bg-card hairline-ring ring-border rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n      />\n      <div className='flex flex-col gap-1.5'>\n        <p className='text-muted-foreground px-1 text-xs'>In a composer</p>\n        <div className='bg-card hairline-ring ring-border flex items-center gap-2 rounded-xl p-1.5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'>\n          <Input\n            aria-label='Prompt'\n            placeholder='Plan the Q4 data migration'\n            className='min-w-0 flex-1 bg-transparent shadow-none ring-0 dark:bg-transparent'\n          />\n          <EffortChip\n            models={MODELS}\n            modelId={modelId}\n            onModelChange={setModelId}\n            effort={effort}\n            onEffortChange={setEffort}\n          />\n        </div>\n      </div>\n      <LiveRegion message={spokenUnless(isAutoplaying, announcement)} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/prompt/prompt-04.tsx"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/lab-tile.tsx",
      "content": "import { BrandTile, type BrandTileSize } from '@/registry/ndeko/ui/brand-tile';\n\nimport { labOf, type LabId } from './labs';\n\ntype LabTileProps = {\n  lab: LabId;\n  size?: BrandTileSize;\n  className?: string;\n};\n\nexport function LabTile({ lab, size = 'md', className }: LabTileProps) {\n  const entry = labOf(lab);\n\n  return <BrandTile brand={entry.brand} size={size} className={className} />;\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/lab-tile.tsx"
    },
    {
      "path": "registry/ndeko/components/prompt/_parts/labs.ts",
      "content": "import type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type LabId = 'anthropic' | 'openai' | 'google' | 'deepseek';\n\nexport type Lab = {\n  id: LabId;\n  name: string;\n  brand: BrandSlug;\n};\n\nexport type Capability = 'vision' | 'tools' | 'reasoning' | 'long-context';\n\nexport type Tier = 1 | 2 | 3;\n\nexport type ModelOption = {\n  id: string;\n  name: string;\n  lab: LabId;\n  /** How many tokens the model reads at once. Illustrative in the demos. */\n  contextTokens: number;\n  /** 1 is the slowest, 3 the fastest. */\n  speed: Tier;\n  /** 1 is the cheapest, 3 the dearest. */\n  price: Tier;\n  capabilities: Capability[];\n  hint: string;\n};\n\nexport const LABS: Lab[] = [\n  { id: 'anthropic', name: 'Anthropic', brand: 'claude' },\n  { id: 'openai', name: 'OpenAI', brand: 'openai' },\n  { id: 'google', name: 'Google', brand: 'gemini' },\n  { id: 'deepseek', name: 'DeepSeek', brand: 'deepseek' },\n];\n\n/** Families without a version number; context, speed and price are coarse tiers for the demos, not facts about a model. */\nexport const MODELS: ModelOption[] = [\n  {\n    id: 'claude-haiku',\n    name: 'Claude Haiku',\n    lab: 'anthropic',\n    contextTokens: 200_000,\n    speed: 3,\n    price: 1,\n    capabilities: ['tools'],\n    hint: 'Quick replies and small edits',\n  },\n  {\n    id: 'claude-sonnet',\n    name: 'Claude Sonnet',\n    lab: 'anthropic',\n    contextTokens: 200_000,\n    speed: 2,\n    price: 2,\n    capabilities: ['vision', 'tools', 'long-context'],\n    hint: 'Everyday work across long files',\n  },\n  {\n    id: 'claude-opus',\n    name: 'Claude Opus',\n    lab: 'anthropic',\n    contextTokens: 200_000,\n    speed: 1,\n    price: 3,\n    capabilities: ['vision', 'tools', 'reasoning', 'long-context'],\n    hint: 'Hard problems that need a plan',\n  },\n  {\n    id: 'gpt-mini',\n    name: 'GPT mini',\n    lab: 'openai',\n    contextTokens: 128_000,\n    speed: 3,\n    price: 1,\n    capabilities: ['tools'],\n    hint: 'Cheap bulk tasks',\n  },\n  {\n    id: 'gemini-pro',\n    name: 'Gemini Pro',\n    lab: 'google',\n    contextTokens: 1_000_000,\n    speed: 1,\n    price: 3,\n    capabilities: ['vision', 'tools', 'reasoning', 'long-context'],\n    hint: 'Whole repositories at once',\n  },\n  {\n    id: 'deepseek',\n    name: 'DeepSeek',\n    lab: 'deepseek',\n    contextTokens: 64_000,\n    speed: 2,\n    price: 1,\n    capabilities: ['tools', 'reasoning'],\n    hint: 'Reasoning on a budget',\n  },\n];\n\nexport const CAPABILITIES: Capability[] = [\n  'vision',\n  'tools',\n  'reasoning',\n  'long-context',\n];\n\nexport const CAPABILITY_LABEL: Record<Capability, string> = {\n  vision: 'Vision',\n  tools: 'Tools',\n  reasoning: 'Reasoning',\n  'long-context': 'Long context',\n};\n\nexport const SPEED_WORD: Record<Tier, string> = {\n  1: 'Slow',\n  2: 'Medium speed',\n  3: 'Fast',\n};\n\nexport const PRICE_WORD: Record<Tier, string> = {\n  1: 'Low price',\n  2: 'Medium price',\n  3: 'High price',\n};\n\nconst FALLBACK_LAB = LABS[0];\n\nconst FALLBACK_MODEL = MODELS[0];\n\nexport function labOf(id: LabId) {\n  const lab = LABS.find((candidate) => candidate.id === id);\n  return lab ?? FALLBACK_LAB;\n}\n\nexport function modelOf(id: string) {\n  const model = MODELS.find((candidate) => candidate.id === id);\n  return model ?? FALLBACK_MODEL;\n}\n\n/** 32k, 200k, 1M. */\nexport function contextLabelOf(tokens: number) {\n  const isMillion = tokens >= 1_000_000;\n  if (isMillion) {\n    const millions = Math.round(tokens / 1_000_000);\n    return `${millions}M`;\n  }\n  const thousands = Math.round(tokens / 1000);\n  return `${thousands}k`;\n}\n",
      "type": "registry:component",
      "target": "components/prompt/_parts/labs.ts"
    }
  ],
  "categories": [
    "components",
    "prompt"
  ],
  "type": "registry:component"
}