{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "run-09",
  "title": "Usage by model",
  "description": "Spend against a plan stacked by model or by agent: the bar of the month fills to its limit with rolling figures, a limit tick that travels, daily bars and a notice above 80%.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/segments.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/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/run/run-09.tsx",
      "content": "'use client';\n\nimport { AnimatePresence, motion } from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\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 { seriesColorOf, type SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport {\n  hold,\n  PRESS_LEAD_MS,\n  pressedQuietOf,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport { CheckIcon, TriangleAlertIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Badge } from '@/registry/ndeko/ui/badge';\n\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { FADE, risePresenceOf } from '@/registry/ndeko/lib/motion-presets';\nimport { Segments, type Segment } from '@/registry/ndeko/ui/segments';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\n\nexport type UsageEntity = {\n  id: string;\n  name: string;\n  /** Fixed per entity, so a colour always means the same model or agent whatever its rank. */\n  series: SeriesSlot;\n  spendUsd: number;\n};\n\nexport type UsagePeriod = {\n  label: string;\n  limitUsd: number;\n  byModel: UsageEntity[];\n  byAgent: UsageEntity[];\n  /** One spend per day of the period; days not reached yet are left out. */\n  dailyUsd: number[];\n  daysInPeriod: number;\n  /** Index of today in `dailyUsd`, when the period is the current one. */\n  todayIndex?: number;\n  resetsOn: string;\n};\n\nexport type GroupBy = 'model' | 'agent';\n\ntype PeriodId = 'this-month' | 'last-month';\n\nconst PERIODS: Segment<PeriodId>[] = [\n  { value: 'this-month', label: 'This month' },\n  { value: 'last-month', label: 'Last month' },\n];\n\nconst GROUPINGS: Segment<GroupBy>[] = [\n  { value: 'model', label: 'Model' },\n  { value: 'agent', label: 'Agent' },\n];\n\nconst USD: Intl.NumberFormatOptions = { style: 'currency', currency: 'USD' };\n\nconst WHOLE_USD: Intl.NumberFormatOptions = {\n  style: 'currency',\n  currency: 'USD',\n  maximumFractionDigits: 0,\n};\n\nconst PERCENT: Intl.NumberFormatOptions = { maximumFractionDigits: 0 };\n\nconst WARNING_FROM = 0.8;\n\n/** The bar's scale rounds up in steps of $250, with room above the limit for its tick. */\nconst SCALE_STEP_USD = 250;\n\nconst SCALE_HEADROOM = 1.2;\n\nconst RAISE_LABELS: Record<MorphState, string> = {\n  idle: 'Raise limit',\n  busy: 'Raising',\n  done: 'Raised',\n};\n\nconst USD_TEXT = new Intl.NumberFormat('en-US', WHOLE_USD);\n\nfunction totalOf(entities: UsageEntity[]) {\n  let total = 0;\n  for (const entity of entities) {\n    total += entity.spendUsd;\n  }\n  return total;\n}\n\nfunction scaleOf(limit: number, total: number) {\n  const peak = Math.max(limit, total);\n  const withRoom = peak * SCALE_HEADROOM;\n  const steps = Math.ceil(withRoom / SCALE_STEP_USD);\n  return steps * SCALE_STEP_USD;\n}\n\nfunction percentOf(value: number, scale: number) {\n  const share = value / scale;\n  return share * 100;\n}\n\nfunction entitiesOf(period: UsagePeriod, groupBy: GroupBy) {\n  if (groupBy === 'agent') {\n    return period.byAgent;\n  }\n  return period.byModel;\n}\n\ntype StackSegment = {\n  entity: UsageEntity;\n  /** Where the segment starts on the bar and how much of it is its own, both from 0 to 1. */\n  start: number;\n  share: number;\n};\n\nconst BAR_TRAVEL =\n  'transition-transform duration-700 ease-(--ease-out-strong) motion-reduce:transition-none';\n\nfunction stackOf(entities: UsageEntity[], scale: number) {\n  const segments: StackSegment[] = [];\n  let start = 0;\n  for (const entity of entities) {\n    const share = entity.spendUsd / scale;\n    segments.push({ entity, start, share });\n    start += share;\n  }\n  return segments;\n}\n\n/** A segment is the whole bar, moved to its start and scaled to its share: no width to lay out. */\nfunction segmentStyleOf(segment: StackSegment): React.CSSProperties {\n  const offset = segment.start * 100;\n  return {\n    backgroundColor: seriesColorOf(segment.entity.series),\n    transform: `translateX(${offset}%) scaleX(${segment.share})`,\n  };\n}\n\n/** A gap after a segment: a mark of the surface behind the bar, moved to where the segment ends. */\nfunction gapStyleOf(segment: StackSegment): React.CSSProperties {\n  const end = segment.start + segment.share;\n  const offset = end * 100;\n  return { transform: `translateX(${offset}%)` };\n}\n\nfunction hasSpend(segment: StackSegment) {\n  return segment.share > 0;\n}\n\nfunction StackedBar({\n  entities,\n  limit,\n  scale,\n  label,\n}: {\n  entities: UsageEntity[];\n  limit: number;\n  scale: number;\n  label: string;\n}) {\n  const total = totalOf(entities);\n  const tickOffset = percentOf(limit, scale);\n  const totalText = USD_TEXT.format(total);\n  const limitText = USD_TEXT.format(limit);\n  const spoken = `${totalText} spent of a ${limitText} limit`;\n  const valueNow = Math.min(total, limit);\n  const segments = stackOf(entities, scale);\n  const spent = segments.filter(hasSpend);\n\n  return (\n    <div className='relative pt-1 pb-5'>\n      <div\n        role='meter'\n        aria-label={label}\n        aria-valuemin={0}\n        aria-valuemax={limit}\n        aria-valuenow={valueNow}\n        aria-valuetext={spoken}\n        className='bg-foreground/[0.05] relative h-3 overflow-hidden rounded-full'\n      >\n        <AnimatePresence initial={false}>\n          {segments.map((segment) => (\n            <motion.span\n              key={segment.entity.id}\n              initial={{ opacity: 0 }}\n              animate={{ opacity: 1 }}\n              exit={{ opacity: 0 }}\n              transition={FADE}\n              className={cn('absolute inset-0 origin-left', BAR_TRAVEL)}\n              style={segmentStyleOf(segment)}\n            />\n          ))}\n        </AnimatePresence>\n        {spent.map((segment) => (\n          <span\n            key={segment.entity.id}\n            className={cn('absolute inset-0', BAR_TRAVEL)}\n            style={gapStyleOf(segment)}\n          >\n            <span className='bg-card absolute inset-y-0 start-0 w-0.5' />\n          </span>\n        ))}\n      </div>\n      <div\n        className={cn('pointer-events-none absolute inset-0', BAR_TRAVEL)}\n        style={{ transform: `translateX(${tickOffset}%)` }}\n      >\n        <span\n          aria-hidden='true'\n          className='bg-foreground/60 absolute start-0 top-0 h-5 w-0.5 -translate-x-1/2 rounded-full'\n        />\n        <span className='text-muted-foreground absolute start-0 top-6 -translate-x-1/2 text-[11px] whitespace-nowrap'>\n          Limit <MotionNumber value={limit} format={WHOLE_USD} />\n        </span>\n      </div>\n    </div>\n  );\n}\n\nfunction Legend({ entities }: { entities: UsageEntity[] }) {\n  const total = totalOf(entities);\n  const base = Math.max(total, 1);\n\n  return (\n    <AnimatedSize>\n      <ul aria-label='Spend by entity' className='flex flex-col'>\n        <AnimatePresence initial={false} mode='popLayout'>\n          {entities.map((entity) => {\n            const share = percentOf(entity.spendUsd, base);\n            return (\n              <motion.li\n                key={entity.id}\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                exit={{ opacity: 0 }}\n                transition={FADE}\n                className='flex h-8 items-center gap-2.5 text-[13px]'\n              >\n                <span\n                  aria-hidden='true'\n                  className='size-2 shrink-0 rounded-full'\n                  style={{ backgroundColor: seriesColorOf(entity.series) }}\n                />\n                <span className='min-w-0 flex-1 truncate'>{entity.name}</span>\n                <MotionNumber\n                  value={share}\n                  format={PERCENT}\n                  suffix='%'\n                  className='text-muted-foreground w-10 justify-end text-xs'\n                />\n                <MotionNumber\n                  value={entity.spendUsd}\n                  format={USD}\n                  className='w-20 justify-end'\n                />\n              </motion.li>\n            );\n          })}\n        </AnimatePresence>\n      </ul>\n    </AnimatedSize>\n  );\n}\n\n/** Days rise one after the other when a period arrives, 18ms apart. */\nconst DAY_STAGGER_MS = 18;\n\nfunction dailyBarStyleOf(\n  spend: number,\n  maxSpend: number,\n  index: number\n): React.CSSProperties {\n  const share = spend / maxSpend;\n  const bounded = Math.max(0.04, share);\n  const delay = index * DAY_STAGGER_MS;\n  return { transform: `scaleY(${bounded})`, transitionDelay: `${delay}ms` };\n}\n\nfunction dayFillOf(index: number, todayIndex: number | undefined) {\n  if (index === todayIndex) {\n    return 'bg-primary';\n  }\n  return 'bg-foreground/25';\n}\n\nfunction maxOf(values: number[]) {\n  let max = 1;\n  for (const value of values) {\n    max = Math.max(max, value);\n  }\n  return max;\n}\n\nfunction dayCountLabelOf(period: UsagePeriod) {\n  if (period.todayIndex === undefined) {\n    return `${period.daysInPeriod} days`;\n  }\n  const day = period.todayIndex + 1;\n  return `Day ${day} of ${period.daysInPeriod}`;\n}\n\nfunction DailyBars({ period }: { period: UsagePeriod }) {\n  const maxSpend = maxOf(period.dailyUsd);\n  const aheadCount = period.daysInPeriod - period.dailyUsd.length;\n  const aheadDays = Array.from({ length: aheadCount }, (_, index) => index);\n\n  return (\n    <div className='flex flex-col gap-1.5'>\n      <div aria-hidden='true' className='flex h-12 items-end gap-[3px]'>\n        {period.dailyUsd.map((spend, index) => (\n          <span\n            key={index}\n            className={cn(\n              'h-full min-w-0 flex-1 origin-bottom rounded-t-[2px] transition-[transform,background-color] duration-300 ease-(--ease-out-strong) motion-reduce:transition-none',\n              dayFillOf(index, period.todayIndex)\n            )}\n            style={dailyBarStyleOf(spend, maxSpend, index)}\n          />\n        ))}\n        {aheadDays.map((day) => (\n          <span\n            key={`ahead-${day}`}\n            className='hairline-border border-foreground/15 h-2 min-w-0 flex-1 rounded-[2px] border-dashed'\n          />\n        ))}\n      </div>\n      <div className='text-muted-foreground flex items-center justify-between gap-3 text-xs'>\n        <span>{dayCountLabelOf(period)}</span>\n        <span>Resets on {period.resetsOn}</span>\n      </div>\n      <div className='sr-only'>\n        <table>\n          <caption>Spend per day, {period.label}</caption>\n          <tbody>\n            {period.dailyUsd.map((spend, index) => (\n              <tr key={index}>\n                <th scope='row'>Day {index + 1}</th>\n                <td>{USD_TEXT.format(spend)}</td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </div>\n    </div>\n  );\n}\n\nexport type UsageByModelProps = {\n  period: UsagePeriod;\n  groupBy: GroupBy;\n  onGroupByChange: (groupBy: GroupBy) => void;\n  periodSwitch?: React.ReactNode;\n  raiseState?: MorphState;\n  onRaiseLimit?: () => void;\n  raisedLine?: string | null;\n  /** Shows Raise limit held down, for a demonstration that presses it. */\n  isRaisePressed?: boolean;\n  className?: string;\n};\n\nexport function UsageByModel({\n  period,\n  groupBy,\n  onGroupByChange,\n  periodSwitch,\n  raiseState = 'idle',\n  onRaiseLimit,\n  raisedLine = null,\n  isRaisePressed = false,\n  className,\n}: UsageByModelProps) {\n  const titleId = useId();\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const risePresence = risePresenceOf(shouldReduceMotion);\n  const entities = entitiesOf(period, groupBy);\n  const total = totalOf(entities);\n  const limit = period.limitUsd;\n  const scale = scaleOf(limit, total);\n  const usedShare = total / limit;\n  const usedPercent = usedShare * 100;\n  const isNearLimit = usedShare >= WARNING_FROM;\n  const isRaising = raiseState !== 'idle';\n  const isNoticeShown = isNearLimit || isRaising;\n  const trace = traceOf(raisedLine, isNoticeShown);\n  const groupLabel = `Spend by ${groupBy}`;\n\n  return (\n    <section\n      aria-labelledby={titleId}\n      className={cn(\n        'bg-card hairline-ring ring-border flex flex-col gap-4 rounded-xl p-4 shadow-[0_1px_2px_rgb(0_0_0/0.04)]',\n        className\n      )}\n    >\n      <header className='flex flex-wrap items-center justify-between gap-2'>\n        <div className='flex items-center gap-2'>\n          <h3 id={titleId} className='text-sm font-medium'>\n            Usage\n          </h3>\n          <Badge variant='secondary'>Illustrative</Badge>\n        </div>\n        {periodSwitch}\n      </header>\n\n      <div className='flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1'>\n        <p className='flex items-baseline gap-1.5'>\n          <MotionNumber\n            value={total}\n            format={USD}\n            className='text-2xl font-semibold'\n          />\n          <span className='text-muted-foreground text-[13px]'>\n            of <MotionNumber value={limit} format={WHOLE_USD} />\n          </span>\n        </p>\n        <MotionNumber\n          value={usedPercent}\n          format={PERCENT}\n          suffix='% used'\n          className={cn(\n            'text-xs transition-colors duration-200',\n            usedToneOf(isNearLimit)\n          )}\n        />\n      </div>\n\n      <StackedBar\n        entities={entities}\n        limit={limit}\n        scale={scale}\n        label={groupLabel}\n      />\n\n      <div className='flex flex-col gap-1'>\n        <div className='flex items-center justify-between gap-2'>\n          <span className='text-muted-foreground text-xs'>Group by</span>\n          <Segments\n            value={groupBy}\n            segments={GROUPINGS}\n            onValueChange={onGroupByChange}\n            label='Group the spend by'\n          />\n        </div>\n        <Legend entities={entities} />\n      </div>\n\n      <DailyBars period={period} />\n\n      <AnimatePresence initial={false} mode='popLayout'>\n        {isNoticeShown && (\n          <motion.div key='notice' className='@container' {...risePresence}>\n            <div className='bg-warning/10 flex flex-col gap-2.5 rounded-lg p-3 @lg:flex-row @lg:items-center'>\n              <p className='text-warning-foreground flex min-w-0 flex-1 items-start gap-2 text-xs leading-5'>\n                <TriangleAlertIcon className='mt-0.5 size-3.5 shrink-0' />\n                Agents pause when the limit is reached. Raise it to keep them\n                running until the reset.\n              </p>\n              <MorphButton\n                type='button'\n                size='sm'\n                variant='outline'\n                state={raiseState}\n                labels={RAISE_LABELS}\n                onClick={onRaiseLimit}\n                className={pressedQuietOf(isRaisePressed)}\n              />\n            </div>\n          </motion.div>\n        )}\n        {trace && (\n          <motion.p\n            key='raised'\n            className='text-muted-foreground flex items-center gap-2 text-xs'\n            {...risePresence}\n          >\n            <CheckIcon className='text-success-foreground size-3.5' />\n            {trace}\n          </motion.p>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nfunction traceOf(raisedLine: string | null, isNoticeShown: boolean) {\n  if (isNoticeShown) {\n    return null;\n  }\n  return raisedLine;\n}\n\nfunction usedToneOf(isNearLimit: boolean) {\n  if (isNearLimit) {\n    return 'text-warning-foreground';\n  }\n  return 'text-muted-foreground';\n}\n\nconst THIS_MONTH: UsagePeriod = {\n  label: 'this month',\n  limitUsd: 500,\n  byModel: [\n    { id: 'claude-haiku', name: 'Claude Haiku', series: 1, spendUsd: 96.4 },\n    { id: 'claude-sonnet', name: 'Claude Sonnet', series: 2, spendUsd: 171.2 },\n    { id: 'claude-opus', name: 'Claude Opus', series: 3, spendUsd: 147.6 },\n  ],\n  byAgent: [\n    { id: 'planner', name: 'Planner', series: 1, spendUsd: 88.3 },\n    { id: 'researcher', name: 'Researcher', series: 2, spendUsd: 142.1 },\n    { id: 'writer', name: 'Writer', series: 3, spendUsd: 121.5 },\n    { id: 'reviewer', name: 'Reviewer', series: 4, spendUsd: 63.3 },\n  ],\n  dailyUsd: [\n    18.2, 21.4, 24.9, 19.6, 12.1, 9.8, 22.7, 26.3, 25.1, 28.4, 23, 11.2, 10.4,\n    27.9, 30.6, 31.8, 29.2, 42.6,\n  ],\n  daysInPeriod: 30,\n  todayIndex: 17,\n  resetsOn: 'the 1st',\n};\n\nconst LAST_MONTH: UsagePeriod = {\n  label: 'last month',\n  limitUsd: 500,\n  byModel: [\n    { id: 'claude-haiku', name: 'Claude Haiku', series: 1, spendUsd: 82.1 },\n    { id: 'claude-sonnet', name: 'Claude Sonnet', series: 2, spendUsd: 131.7 },\n    { id: 'claude-opus', name: 'Claude Opus', series: 3, spendUsd: 104.8 },\n  ],\n  byAgent: [\n    { id: 'planner', name: 'Planner', series: 1, spendUsd: 71.4 },\n    { id: 'researcher', name: 'Researcher', series: 2, spendUsd: 109.9 },\n    { id: 'writer', name: 'Writer', series: 3, spendUsd: 92.6 },\n    { id: 'reviewer', name: 'Reviewer', series: 4, spendUsd: 44.7 },\n  ],\n  dailyUsd: [\n    9.4, 11.2, 12.8, 10.1, 6.2, 5.4, 11.9, 12.6, 13.1, 12.2, 10.8, 5.9, 5.1,\n    12.4, 13.7, 12.9, 11.6, 10.2, 6, 5.6, 12.1, 13.4, 14.2, 12.7, 11.3, 6.4,\n    5.8, 12.9, 13.6, 17.1,\n  ],\n  daysInPeriod: 30,\n  resetsOn: 'the 1st',\n};\n\nconst RAISED_LIMIT_USD = 750;\n\nconst RAISED_LIMIT_TEXT = USD_TEXT.format(RAISED_LIMIT_USD);\n\nconst RAISE_BUSY_MS = 700;\n\nconst RAISE_DONE_MS = 700;\n\nfunction unspent(entity: UsageEntity): UsageEntity {\n  return { ...entity, spendUsd: 0 };\n}\n\n/** The first morning of the month: nothing spent yet, every day still to come. */\nconst MONTH_START: UsagePeriod = {\n  ...THIS_MONTH,\n  byModel: THIS_MONTH.byModel.map(unspent),\n  byAgent: THIS_MONTH.byAgent.map(unspent),\n  dailyUsd: THIS_MONTH.dailyUsd.map(() => 0),\n  todayIndex: 0,\n};\n\nfunction thisMonthOf(isStarting: boolean) {\n  if (isStarting) {\n    return MONTH_START;\n  }\n  return THIS_MONTH;\n}\n\nfunction periodOf(\n  periodId: PeriodId,\n  raisedLimit: number | null,\n  isStarting: boolean\n) {\n  if (periodId === 'last-month') {\n    return LAST_MONTH;\n  }\n  const month = thisMonthOf(isStarting);\n  if (raisedLimit === null) {\n    return month;\n  }\n  return { ...month, limitUsd: raisedLimit };\n}\n\nfunction raisedLineOf(periodId: PeriodId, raisedLimit: number | null) {\n  const isThisMonth = periodId === 'this-month';\n  if (!isThisMonth) {\n    return null;\n  }\n  if (raisedLimit === null) {\n    return null;\n  }\n  const limitText = USD_TEXT.format(raisedLimit);\n  return `Limit raised to ${limitText} until the reset`;\n}\n\n/** The notice waits on a person: the demonstration raises the limit after this long. */\nconst RAISE_AFTER_MS = 2500;\n\ntype PressKey = 'raise';\n\nexport default function Run09() {\n  const [periodId, setPeriodId] = useState<PeriodId>('this-month');\n  const [groupBy, setGroupBy] = useState<GroupBy>('model');\n  const [raisedLimit, setRaisedLimit] = useState<number | null>(null);\n  const [raiseState, setRaiseState] = useState<MorphState>('idle');\n  const [isMonthStarting, setIsMonthStarting] = useState(false);\n  const [message, setMessage] = useState('');\n  const { schedule, clearAll } = useTimeouts();\n  const { pressed, press } = usePress<PressKey>();\n\n  function changePeriod(next: PeriodId) {\n    setPeriodId(next);\n    const nextPeriod = periodOf(next, raisedLimit, false);\n    const total = totalOf(nextPeriod.byModel);\n    const totalText = USD_TEXT.format(total);\n    setMessage(`${totalText} spent ${nextPeriod.label}`);\n  }\n\n  function changeGroupBy(next: GroupBy) {\n    setGroupBy(next);\n    setMessage(`Spend grouped by ${next}`);\n  }\n\n  function raiseLimit() {\n    if (raiseState !== 'idle') {\n      return;\n    }\n    setRaiseState('busy');\n    schedule(() => setRaiseState('done'), RAISE_BUSY_MS);\n    const settleDelay = RAISE_BUSY_MS + RAISE_DONE_MS;\n    schedule(() => {\n      setRaisedLimit(RAISED_LIMIT_USD);\n      setRaiseState('idle');\n      setMessage(`Limit raised to ${RAISED_LIMIT_TEXT}`);\n    }, settleDelay);\n  }\n\n  function resetDemo() {\n    clearAll();\n    setPeriodId('this-month');\n    setGroupBy('model');\n    setRaisedLimit(null);\n    setRaiseState('idle');\n    setIsMonthStarting(false);\n  }\n\n  const raiseTime = RAISE_BUSY_MS + RAISE_DONE_MS;\n  const regroupAfter = raiseTime + 1400;\n  const steps: AutoplayStep[] = [\n    { after: 1600, run: () => setIsMonthStarting(true) },\n    { after: 1000, run: () => setIsMonthStarting(false) },\n    { after: RAISE_AFTER_MS, run: () => press('raise') },\n    { after: PRESS_LEAD_MS, run: raiseLimit },\n    { after: regroupAfter, run: () => changeGroupBy('agent') },\n    { after: 2200, run: () => changeGroupBy('model') },\n    { after: 1200, run: hold },\n  ];\n  const { ref, isInView, isAutoplaying } = useAutoplay(steps, {\n    loopAfter: 2600,\n    onReset: resetDemo,\n  });\n  // A person who takes over while the month is being rewound gets the month as it stands today.\n  const isStarting = isMonthStarting && isAutoplaying;\n  const period = periodOf(periodId, raisedLimit, isStarting);\n  const raisedLine = raisedLineOf(periodId, raisedLimit);\n\n  useKeptHeight(ref);\n\n  return (\n    <div\n      ref={ref}\n      className='flex min-h-[34rem] w-full max-w-[30rem] flex-col gap-2'\n    >\n      <ClockGate isActive={isInView}>\n        <UsageByModel\n          period={period}\n          groupBy={groupBy}\n          onGroupByChange={changeGroupBy}\n          periodSwitch={\n            <Segments\n              value={periodId}\n              segments={PERIODS}\n              onValueChange={changePeriod}\n              label='Period'\n            />\n          }\n          raiseState={raiseState}\n          onRaiseLimit={raiseLimit}\n          raisedLine={raisedLine}\n          isRaisePressed={pressed === 'raise'}\n        />\n      </ClockGate>\n      <LiveRegion message={spokenUnless(isAutoplaying, message)} />\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "run"
  ],
  "type": "registry:component"
}