{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-product-01",
  "title": "Usage and limits",
  "description": "Where a workspace stands against its plan: switch the period and the stacked bar by model empties and refills to the limit mark while the daily bars grow from the baseline, with a meter for each other limit and an upgrade line that unfolds near the limit.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "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/chat-motion.json",
    "https://ui.ndekocode.dev/r/company-mark.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/motion-number.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/tabs.json",
    "https://ui.ndekocode.dev/r/theme.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-session.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-01/index.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport {\n  pressedQuietOf,\n  spokenUnless,\n} from '@/registry/ndeko/lib/demonstration';\nimport { GaugeIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Fold, Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { CompanyMark } from '@/registry/ndeko/ui/company-mark';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\nimport { Tabs, TabsList, TabsTab } from '@/registry/ndeko/ui/tabs';\n\nimport { DayChart } from './day-chart';\nimport {\n  isNearLimit,\n  PERIODS,\n  percentOf,\n  periodOf,\n  shareOf,\n  USAGE,\n  usedOf,\n  WORKSPACE,\n} from './data';\nimport { LimitRows } from './limit-rows';\nimport { INITIAL, LOOP_AFTER_MS, reducer, RESTING, SCRIPT } from './session';\nimport { ModelLegend, UsageBar } from './usage-bar';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nconst SURFACE =\n  'bg-card hairline-ring ring-border dark:bg-foreground/[0.03] rounded-xl shadow-[0_1px_2px_rgb(0_0_0/0.04)]';\n\ntype Standing = {\n  variant: 'warning' | 'success';\n  label: string;\n};\n\nconst NEAR_LIMIT: Standing = { variant: 'warning', label: 'Near the limit' };\n\nconst WITHIN_PLAN: Standing = { variant: 'success', label: 'Within the plan' };\n\nfunction standingOf(isNear: boolean) {\n  if (isNear) {\n    return NEAR_LIMIT;\n  }\n  return WITHIN_PLAN;\n}\n\nexport default function AiProduct01() {\n  const { ref, isAutoplaying, state, act, pressed, isFinished, restart } =\n    useSession(SESSION);\n  useKeptHeight(ref);\n  const { period, hasChanged } = state;\n  const usage = USAGE[period];\n  const used = usedOf(usage);\n  const share = shareOf(used, usage.limit);\n  const isNear = isNearLimit(share);\n  const standing = standingOf(isNear);\n  const shown = periodOf(period);\n  const hasUpgrade = usage.upgrade !== null;\n  const upgradeLine = usage.upgrade ?? USAGE.month.upgrade ?? '';\n  const message = spokenUnless(isAutoplaying, state.spoken);\n  const canReplay = isFinished && !isAutoplaying;\n\n  function pickPeriod(value: unknown) {\n    const picked = PERIODS.find((candidate) => candidate.id === value);\n    if (picked) {\n      act({ type: 'periodPicked', period: picked.id });\n    }\n  }\n\n  return (\n    <div\n      ref={ref}\n      className='bg-background text-foreground @container min-h-[46rem] w-full @3xl:min-h-[40rem]'\n    >\n      <div className='mx-auto flex max-w-4xl flex-col gap-5 px-4 py-8 @2xl:px-6 @2xl:py-12'>\n        <header className='flex flex-wrap items-center justify-between gap-x-4 gap-y-3'>\n          <div className='flex min-w-0 items-center gap-2.5'>\n            <CompanyMark seed={WORKSPACE.name} size='lg' />\n            <div className='flex min-w-0 flex-col'>\n              <h2 className='truncate text-sm font-medium'>Usage and limits</h2>\n              <p className='text-muted-foreground flex items-center gap-1.5 text-xs'>\n                {WORKSPACE.name}, {WORKSPACE.plan}\n                <Badge variant='secondary'>Illustrative</Badge>\n              </p>\n            </div>\n          </div>\n          <div className='flex items-center gap-2'>\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={restart}\n              label='Replay'\n            />\n            <Tabs value={period} onValueChange={pickPeriod}>\n              <TabsList variant='segmented' aria-label='Period'>\n                {PERIODS.map((candidate) => (\n                  <TabsTab\n                    key={candidate.id}\n                    value={candidate.id}\n                    className={cn(\n                      'text-xs transition-[color,background-color,scale]',\n                      pressedQuietOf(pressed === `period-${candidate.id}`)\n                    )}\n                  >\n                    {candidate.label}\n                  </TabsTab>\n                ))}\n              </TabsList>\n            </Tabs>\n          </div>\n        </header>\n\n        <section\n          aria-label='Credits used'\n          className={cn(SURFACE, 'flex flex-col gap-5 p-5 @2xl:p-6')}\n        >\n          <div className='flex flex-wrap items-end justify-between gap-x-4 gap-y-2'>\n            <div className='flex flex-col gap-1'>\n              <p className='text-muted-foreground flex items-center gap-1.5 text-[13px] font-medium'>\n                <GaugeIcon className='size-4' />\n                Credits used {shown.spoken}\n              </p>\n              <p className='flex items-baseline gap-2'>\n                <MotionNumber\n                  value={used}\n                  className='text-3xl font-semibold @2xl:text-4xl'\n                />\n                <span className='text-muted-foreground flex items-baseline gap-1 text-[13px]'>\n                  of\n                  <MotionNumber value={usage.limit} />\n                </span>\n              </p>\n            </div>\n            <div className='flex items-center gap-2'>\n              <span className='flex items-baseline text-[13px] tabular-nums'>\n                <MotionNumber value={percentOf(share)} suffix='%' />\n              </span>\n              <Swap swapKey={standing.label}>\n                <Badge variant={standing.variant}>{standing.label}</Badge>\n              </Swap>\n            </div>\n          </div>\n          <UsageBar\n            periodId={period}\n            limit={usage.limit}\n            used={used}\n            byModel={usage.byModel}\n            hasChanged={hasChanged}\n          />\n          <ModelLegend byModel={usage.byModel} />\n          <Fold open={hasUpgrade}>\n            <div className='bg-foreground/[0.04] flex flex-wrap items-center justify-between gap-x-4 gap-y-2 rounded-lg p-3'>\n              <p className='min-w-0 flex-1 text-[13px] text-pretty'>\n                {upgradeLine}\n              </p>\n              <Button type='button' size='sm' variant='outline'>\n                Compare plans\n              </Button>\n            </div>\n          </Fold>\n        </section>\n\n        <div className='grid gap-5 @3xl:grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)]'>\n          <section\n            aria-label={shown.chartTitle}\n            className={cn(SURFACE, 'flex flex-col gap-4 p-5 @2xl:p-6')}\n          >\n            <h3 className='text-sm font-medium'>\n              <Swap swapKey={shown.chartTitle}>{shown.chartTitle}</Swap>\n            </h3>\n            <DayChart\n              periodId={period}\n              values={usage.chart}\n              labels={shown.chartLabels}\n              caption={`${shown.chartTitle}, illustrative`}\n              hasChanged={hasChanged}\n            />\n          </section>\n          <section\n            aria-label='Plan limits'\n            className={cn(SURFACE, 'flex flex-col gap-4 p-5 @2xl:p-6')}\n          >\n            <h3 className='text-sm font-medium'>Plan limits</h3>\n            <LimitRows />\n          </section>\n        </div>\n      </div>\n      <LiveRegion message={message} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-01/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-01/usage-bar.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { EASE_OUT_STRONG, INSTANT } from '@/registry/ndeko/lib/motion-presets';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\n\nimport { MODELS, shareOf, type ModelId, type PeriodId } from './data';\n\nconst STAGGER_S = 0.07;\n\nconst FILL_S = 0.7;\n\ntype Layer = {\n  id: ModelId;\n  color: string;\n  share: number;\n  delay: number;\n};\n\n/** The segments overlap, longest at the bottom: each layer reaches the end of its model, so the one on top is the first segment. */\nfunction layersOf(byModel: Record<ModelId, number>, limit: number) {\n  const layers: Layer[] = [];\n  let running = 0;\n  for (const [index, model] of MODELS.entries()) {\n    running += byModel[model.id];\n    layers.push({\n      id: model.id,\n      color: seriesColorOf(model.series),\n      share: shareOf(running, limit),\n      delay: index * STAGGER_S,\n    });\n  }\n  return [...layers].reverse();\n}\n\nfunction fillOf(shouldReduceMotion: boolean, delay: number): Transition {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return { duration: FILL_S, ease: EASE_OUT_STRONG, delay };\n}\n\nfunction startOf(hasChanged: boolean, shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return false;\n  }\n  if (hasChanged) {\n    return { scaleX: 0 };\n  }\n  return false;\n}\n\nexport function creditsText(value: number) {\n  return value.toLocaleString('en-US');\n}\n\ntype UsageBarProps = {\n  periodId: PeriodId;\n  limit: number;\n  used: number;\n  byModel: Record<ModelId, number>;\n  hasChanged: boolean;\n};\n\nexport function UsageBar({\n  periodId,\n  limit,\n  used,\n  byModel,\n  hasChanged,\n}: UsageBarProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const layers = layersOf(byModel, limit);\n  const initial = startOf(hasChanged, shouldReduceMotion);\n  const usedText = creditsText(used);\n  const limitText = creditsText(limit);\n  const label = `${usedText} of ${limitText} credits used`;\n\n  return (\n    <div className='relative flex flex-col gap-1.5'>\n      <p className='text-muted-foreground flex items-baseline justify-end gap-1 text-xs'>\n        Limit\n        <MotionNumber value={limit} className='text-foreground' />\n      </p>\n      <div className='relative'>\n        <div\n          role='img'\n          aria-label={label}\n          className='bg-foreground/[0.06] relative h-3 overflow-hidden rounded-full'\n        >\n          {layers.map((layer) => (\n            <motion.span\n              key={`${periodId}-${layer.id}`}\n              initial={initial}\n              animate={{ scaleX: layer.share }}\n              transition={fillOf(shouldReduceMotion, layer.delay)}\n              style={{ backgroundColor: layer.color }}\n              className='absolute inset-0 origin-left'\n            />\n          ))}\n        </div>\n        <span\n          aria-hidden='true'\n          className='bg-foreground/40 absolute end-0 -top-1 -bottom-1 w-px'\n        />\n      </div>\n    </div>\n  );\n}\n\ntype ModelLegendProps = {\n  byModel: Record<ModelId, number>;\n};\n\nexport function ModelLegend({ byModel }: ModelLegendProps) {\n  return (\n    <ul className='grid grid-cols-2 gap-x-4 gap-y-2 @xl:grid-cols-4'>\n      {MODELS.map((model) => (\n        <li key={model.id} className='flex min-w-0 items-center gap-2'>\n          <span\n            aria-hidden='true'\n            style={{ backgroundColor: seriesColorOf(model.series) }}\n            className='size-2 shrink-0 rounded-full'\n          />\n          <BrandTile brand={model.brand} size='sm' />\n          <span className='min-w-0 flex-1 truncate text-[13px]'>\n            {model.name}\n          </span>\n          <MotionNumber\n            value={byModel[model.id]}\n            className='text-muted-foreground text-xs'\n          />\n        </li>\n      ))}\n    </ul>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-01/usage-bar.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-01/day-chart.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { EASE_OUT_STRONG, INSTANT } from '@/registry/ndeko/lib/motion-presets';\nimport { cn } from '@/registry/ndeko/lib/utils';\n\nimport type { PeriodId } from './data';\n\nconst RISE_S = 0.6;\n\nconst STAGGER_S = 0.02;\n\nfunction riseOf(shouldReduceMotion: boolean, index: number): Transition {\n  if (shouldReduceMotion) {\n    return INSTANT;\n  }\n  return { duration: RISE_S, ease: EASE_OUT_STRONG, delay: index * STAGGER_S };\n}\n\nfunction startOf(hasChanged: boolean, shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return false;\n  }\n  if (hasChanged) {\n    return { scaleY: 0 };\n  }\n  return false;\n}\n\nfunction toneOf(isLatest: boolean) {\n  if (isLatest) {\n    return 'bg-primary';\n  }\n  return 'bg-primary/35';\n}\n\nfunction heightShareOf(value: number, tallest: number) {\n  if (tallest <= 0) {\n    return 0;\n  }\n  return value / tallest;\n}\n\nfunction tallestOf(values: readonly number[]) {\n  return Math.max(1, ...values);\n}\n\ntype DayChartProps = {\n  periodId: PeriodId;\n  values: readonly number[];\n  labels: readonly string[];\n  caption: string;\n  hasChanged: boolean;\n};\n\nexport function DayChart({\n  periodId,\n  values,\n  labels,\n  caption,\n  hasChanged,\n}: DayChartProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const initialOf = startOf(hasChanged, shouldReduceMotion);\n  const tallest = tallestOf(values);\n  const lastIndex = values.length - 1;\n\n  return (\n    <div className='relative flex flex-col gap-2'>\n      <div aria-hidden='true' className='flex h-28 items-stretch gap-0.5'>\n        {values.map((value, index) => (\n          <span\n            key={`${periodId}-${index}`}\n            className='bg-foreground/[0.04] relative flex-1 overflow-hidden rounded-[3px]'\n          >\n            <motion.span\n              initial={initialOf}\n              animate={{ scaleY: heightShareOf(value, tallest) }}\n              transition={riseOf(shouldReduceMotion, index)}\n              className={cn(\n                'absolute inset-0 origin-bottom',\n                toneOf(index === lastIndex)\n              )}\n            />\n          </span>\n        ))}\n      </div>\n      <p\n        aria-hidden='true'\n        className='text-muted-foreground flex justify-between text-[11px] tabular-nums'\n      >\n        {labels.map((label) => (\n          <span key={label}>{label}</span>\n        ))}\n      </p>\n      <div className='sr-only'>\n        <table>\n          <caption>{caption}</caption>\n          <tbody>\n            {values.map((value, index) => (\n              <tr key={index}>\n                <th scope='row'>{index + 1}</th>\n                <td>{value}</td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-01/day-chart.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-01/limit-rows.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\n\nimport { isNearLimit, LIMITS, shareOf, type Limit } from './data';\n\nfunction meterToneOf(isNear: boolean) {\n  if (isNear) {\n    return 'bg-warning';\n  }\n  return 'bg-primary';\n}\n\nfunction figureToneOf(isNear: boolean) {\n  if (isNear) {\n    return 'text-warning-foreground';\n  }\n  return 'text-muted-foreground';\n}\n\nfunction figureTextOf(limit: Limit) {\n  return `${limit.used} of ${limit.max}${limit.unit}`;\n}\n\nfunction LimitRow({ limit }: { limit: Limit }) {\n  const share = shareOf(limit.used, limit.max);\n  const isNear = isNearLimit(share);\n  const open = 1 - share;\n  const remaining = open * 100;\n  const fillStyle = { transform: `translateX(-${remaining}%)` };\n\n  return (\n    <li className='flex flex-col gap-1.5'>\n      <div className='flex items-baseline justify-between gap-3 text-[13px]'>\n        <span className='min-w-0 truncate'>{limit.label}</span>\n        <span className={cn('text-xs tabular-nums', figureToneOf(isNear))}>\n          {figureTextOf(limit)}\n          {isNear && <span className='sr-only'>, near the limit</span>}\n        </span>\n      </div>\n      <div\n        role='meter'\n        aria-label={limit.label}\n        aria-valuemin={0}\n        aria-valuemax={limit.max}\n        aria-valuenow={limit.used}\n        className='bg-foreground/[0.06] h-1.5 overflow-hidden rounded-full'\n      >\n        <span\n          style={fillStyle}\n          className={cn('block h-full rounded-full', meterToneOf(isNear))}\n        />\n      </div>\n    </li>\n  );\n}\n\nexport function LimitRows() {\n  return (\n    <ul className='flex flex-col gap-4'>\n      {LIMITS.map((limit) => (\n        <LimitRow key={limit.id} limit={limit} />\n      ))}\n    </ul>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-01/limit-rows.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-01/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\n\nimport {\n  periodOf,\n  shareOf,\n  USAGE,\n  usedOf,\n  percentOf,\n  type PeriodId,\n} from './data';\n\nexport type UsageState = {\n  period: PeriodId;\n  /** False until the first change: the bars are drawn full when the page loads and refill only after a change. */\n  hasChanged: boolean;\n  spoken: string;\n};\n\nexport type UsageAction = { type: 'periodPicked'; period: PeriodId };\n\ntype Step = SessionStep<UsageState, UsageAction>;\n\nexport const INITIAL: UsageState = {\n  period: 'month',\n  hasChanged: false,\n  spoken: '',\n};\n\nfunction spokenPeriodOf(id: PeriodId) {\n  const usage = USAGE[id];\n  const used = usedOf(usage);\n  const share = shareOf(used, usage.limit);\n  const percent = percentOf(share);\n  const name = periodOf(id).spoken;\n  return `Showing ${name}: ${used} of ${usage.limit} credits used, ${percent}%`;\n}\n\nfunction periodPicked(state: UsageState, period: PeriodId): UsageState {\n  if (state.period === period) {\n    return state;\n  }\n  return { period, hasChanged: true, spoken: spokenPeriodOf(period) };\n}\n\nexport function reducer(state: UsageState, action: UsageAction): UsageState {\n  switch (action.type) {\n    case 'periodPicked':\n      return periodPicked(state, action.period);\n  }\n}\n\nfunction picks(after: number, period: PeriodId): Step {\n  return {\n    after,\n    by: 'demo',\n    press: `period-${period}`,\n    action: { type: 'periodPicked', period },\n  };\n}\n\n/** The month is where the block rests, so a round ends on it and the next one starts from it. */\nexport const SCRIPT: Step[] = [\n  picks(2800, 'today'),\n  picks(3000, 'week'),\n  picks(3000, 'month'),\n];\n\nexport const RESTING: UsageState = INITIAL;\n\nexport const LOOP_AFTER_MS = 3200;\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-01/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-01/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\nimport type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type PeriodId = 'today' | 'week' | 'month';\n\nexport type Period = {\n  id: PeriodId;\n  label: string;\n  spoken: string;\n  chartTitle: string;\n  chartLabels: [string, string, string];\n};\n\nexport const PERIODS: Period[] = [\n  {\n    id: 'today',\n    label: 'Today',\n    spoken: 'today',\n    chartTitle: 'Credits by hour',\n    chartLabels: ['00:00', '09:00', '17:00'],\n  },\n  {\n    id: 'week',\n    label: 'This week',\n    spoken: 'this week',\n    chartTitle: 'Credits by day',\n    chartLabels: ['Mon', 'Wed', 'Fri'],\n  },\n  {\n    id: 'month',\n    label: 'This month',\n    spoken: 'this month',\n    chartTitle: 'Credits by day',\n    chartLabels: ['Day 1', 'Day 7', 'Day 13'],\n  },\n];\n\nexport const WORKSPACE = { name: 'Kasai Freight', plan: 'Team plan' };\n\nexport type ModelId = 'claude' | 'gemini' | 'chatgpt' | 'mistral';\n\nexport type Model = {\n  id: ModelId;\n  name: string;\n  brand: BrandSlug;\n  series: SeriesSlot;\n};\n\nexport const MODELS: Model[] = [\n  { id: 'claude', name: 'Claude', brand: 'claude', series: 1 },\n  { id: 'gemini', name: 'Gemini', brand: 'gemini', series: 2 },\n  { id: 'chatgpt', name: 'ChatGPT', brand: 'openai', series: 3 },\n  { id: 'mistral', name: 'Mistral', brand: 'mistral', series: 4 },\n];\n\nexport type Usage = {\n  limit: number;\n  byModel: Record<ModelId, number>;\n  chart: number[];\n  upgrade: string | null;\n};\n\n/** Every figure is invented. For each period the credits by model and the bars add up to the same total. */\nexport const USAGE: Record<PeriodId, Usage> = {\n  today: {\n    limit: 250,\n    byModel: { claude: 84, gemini: 46, chatgpt: 38, mistral: 12 },\n    chart: [0, 0, 0, 0, 0, 0, 2, 6, 14, 22, 26, 20, 12, 18, 24, 20, 10, 6],\n    upgrade: null,\n  },\n  week: {\n    limit: 1400,\n    byModel: { claude: 520, gemini: 290, chatgpt: 250, mistral: 90 },\n    chart: [230, 260, 240, 240, 180],\n    upgrade:\n      'Four fifths of this week is used. Scale adds 10,000 credits a month',\n  },\n  month: {\n    limit: 5000,\n    byModel: { claude: 1980, gemini: 1150, chatgpt: 900, mistral: 320 },\n    chart: [150, 470, 500, 480, 460, 420, 330, 390, 230, 260, 240, 240, 180],\n    upgrade:\n      'At this pace the credits run out in two days. Scale adds 10,000 credits a month',\n  },\n};\n\nexport const NEAR_LIMIT_SHARE = 0.8;\n\nexport type Limit = {\n  id: string;\n  label: string;\n  used: number;\n  max: number;\n  unit: string;\n};\n\nexport const LIMITS: Limit[] = [\n  { id: 'agents', label: 'Agents', used: 4, max: 5, unit: '' },\n  { id: 'seats', label: 'Seats', used: 9, max: 10, unit: '' },\n  { id: 'apps', label: 'Connected apps', used: 7, max: 12, unit: '' },\n  { id: 'files', label: 'Stored files', used: 3.2, max: 5, unit: ' GB' },\n];\n\nconst FALLBACK_PERIOD = PERIODS[0];\n\nexport function periodOf(id: PeriodId) {\n  const period = PERIODS.find((candidate) => candidate.id === id);\n  return period ?? FALLBACK_PERIOD;\n}\n\nexport function usedOf(usage: Usage) {\n  let total = 0;\n  for (const model of MODELS) {\n    total += usage.byModel[model.id];\n  }\n  return total;\n}\n\nexport function shareOf(used: number, limit: number) {\n  if (limit <= 0) {\n    return 0;\n  }\n  const share = used / limit;\n  return Math.min(1, share);\n}\n\nexport function isNearLimit(share: number) {\n  return share >= NEAR_LIMIT_SHARE;\n}\n\nexport function percentOf(share: number) {\n  return Math.round(share * 100);\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-01/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "ai-product"
  ],
  "type": "registry:block"
}