{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "usage-meter-08",
  "description": "What is left as a round wave that drains as usage grows, with used, free and days until reset below.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/animated-number.json",
    "https://www.dashboardblocks.com/r/radix/animated-wave.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/usage-meter.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/usage-meter/usage-meter-08.tsx",
      "content": "'use client'\n\nimport { AnimatedNumber } from '@/registry/components/dashboardblocks/animated-number'\nimport { AnimatedWave } from '@/registry/components/dashboardblocks/animated-wave'\nimport {\n  BlockStateProvider,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  type UsageStatus,\n  formatUsage,\n  getUsageShare,\n  getUsageStatus,\n  UsageMeterValue,\n  UsageStatusLabel,\n  usageStatusConfig,\n} from '@/registry/components/dashboardblocks/usage-meter'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatPercent } from '@/registry/lib/dashboardblocks/format'\nimport type { ReactNode } from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface UsageMeter8Props extends BlockStateProps {\n  daysLeft?: number\n  icon: ReactNode\n  limit: number\n  onUpgrade?: () => void\n  title: string\n  unit: string\n  /** Leave out to show the empty state. */\n  used?: number\n}\n\nconst exampleProps: UsageMeter8Props = {\n  daysLeft: 27,\n  icon: (\n    <IconPlaceholder\n      lucide='DatabaseIcon'\n      tabler='IconDatabase'\n      hugeicons='Database01Icon'\n      phosphor='DatabaseIcon'\n      remixicon='RiDatabase2Line'\n    />\n  ),\n  limit: 1_500,\n  onUpgrade: () => {},\n  title: 'Storage',\n  unit: 'MB',\n  used: 430,\n}\n\nconst waveColors: Record<UsageStatus, string> = {\n  critical: 'text-red-300 dark:text-red-900',\n  ok: 'text-[color-mix(in_oklab,var(--color-chart-2)_25%,var(--color-background))]',\n  over: 'text-red-300 dark:text-red-900',\n  warning: 'text-orange-200 dark:text-orange-900',\n}\n\nconst UsageMeter8 = (props: UsageMeter8Props) => {\n  const {\n    daysLeft,\n    icon,\n    limit,\n    onUpgrade,\n    errorMessage,\n    status: blockStatus,\n    title,\n    unit,\n    used = 0,\n  } = props\n  const state = getBlockState(blockStatus, props.used)\n  const remaining = Math.max(0, limit - used)\n  const share = getUsageShare(used, limit)\n  const status = getUsageStatus(used, limit)\n  const stats = [\n    { label: 'Used', value: formatUsage(used, unit) },\n    {\n      label: 'Free',\n      value: formatPercent(remaining / (limit || 1), { maximumFractionDigits: 0 }),\n    },\n    ...(daysLeft !== undefined\n      ? [{ label: 'Resets in', value: `${daysLeft} ${daysLeft === 1 ? 'day' : 'days'}` }]\n      : []),\n  ]\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4 border-t pt-3 in-data-[slot=card]:first:border-t-0 in-data-[slot=card]:first:pt-0'>\n            <header className='flex min-h-8 items-center justify-between gap-3'>\n              <p className='text-muted-foreground flex min-w-0 items-center gap-2 text-sm [&_svg]:size-4 [&_svg]:shrink-0'>\n                {icon}\n                <span className='truncate'>{title}</span>\n              </p>\n              {onUpgrade && (\n                <Button variant='outline' size='sm' onClick={onUpgrade}>\n                  Upgrade\n                </Button>\n              )}\n            </header>\n            <div\n              {...(state\n                ? {}\n                : {\n                    role: 'meter',\n                    'aria-label': title,\n                    'aria-valuemax': limit,\n                    'aria-valuemin': 0,\n                    'aria-valuenow': Math.min(used, limit),\n                    'aria-valuetext': `${formatUsage(used, unit)} of ${formatUsage(limit, unit)} used, ${usageStatusConfig[status].label.toLowerCase()}`,\n                  })}\n              className={cn(\n                'bg-muted/50 relative size-48 self-center overflow-hidden rounded-full',\n                state === 'loading' && 'animate-pulse motion-reduce:animate-none',\n              )}\n            >\n              {!state && (\n                <AnimatedWave\n                  percentage={100 - Math.min(100, share)}\n                  className={waveColors[status]}\n                />\n              )}\n              {state ? (\n                <div className='absolute inset-0 flex items-center justify-center'>\n                  <UsageMeterValue className='px-4 text-center text-2xl leading-tight' />\n                </div>\n              ) : (\n                <div\n                  aria-hidden\n                  className='text-foreground absolute inset-0 flex flex-col items-center justify-center gap-1 text-center'\n                >\n                  <span className='text-4xl leading-none font-light tracking-tight tabular-nums'>\n                    <AnimatedNumber\n                      value={remaining}\n                      formatter={(value) => formatUsage(Math.round(value))}\n                    />\n                    <span className='text-muted-foreground ml-1 text-base font-normal tracking-normal'>\n                      {unit}\n                    </span>\n                  </span>\n                  <span className='text-muted-foreground text-xs tabular-nums'>\n                    left of {formatUsage(limit, unit)}\n                  </span>\n                  {status !== 'ok' && (\n                    <UsageStatusLabel className='text-xs' status={status} />\n                  )}\n                </div>\n              )}\n            </div>\n            {state !== 'empty' && state !== 'error' && (\n              <dl\n                className={cn(\n                  'grid w-full gap-4 border-t pt-3',\n                  stats.length === 3 ? 'grid-cols-3' : 'grid-cols-2',\n                )}\n              >\n                {stats.map((stat) => (\n                  <div key={stat.label} className='flex min-w-0 flex-col gap-0.5'>\n                    <dt className='text-muted-foreground text-xs'>{stat.label}</dt>\n                    <dd className='text-xl font-light tracking-tight whitespace-nowrap tabular-nums'>\n                      {state === 'loading' ? (\n                        <SkeletonText className='w-[3em]' />\n                      ) : (\n                        stat.value\n                      )}\n                    </dd>\n                  </div>\n                ))}\n              </dl>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { UsageMeter8, exampleProps as usageMeter8ExampleProps, type UsageMeter8Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/usage-meter/usage-meter-08.tsx"
    }
  ],
  "meta": {
    "shows": "What is left as a round wave that drains as usage grows, with used, free and days until reset below.",
    "size": "compact",
    "usedWith": [
      "usage-meter-07",
      "billing-01",
      "usage-meter-06"
    ],
    "component": "UsageMeter8",
    "props": "{ daysLeft?: number; icon: ReactNode; limit: number; onUpgrade?: () => void; title: string; unit: string; used?: number; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
