{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "status-02",
  "description": "Ninety days of daily status for each service as a row of bars, with its icon, its status now and a tooltip for any day.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/brand-logos.json",
    "https://www.dashboardblocks.com/r/radix/details.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/status.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/status/status-02.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { LogoTile } from '@/registry/components/dashboardblocks/brand-logos'\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport {\n  type StatusLevel,\n  StatusLegend,\n  UptimeBar,\n  type UptimeDay,\n  formatUptime,\n  getUptime,\n  statusConfig,\n} from '@/registry/components/dashboardblocks/status'\nimport { StatusLabel } from '@/registry/components/dashboardblocks/status-label'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport {\n  formatDate,\n  formatList,\n  formatNumber,\n} from '@/registry/lib/dashboardblocks/format'\nimport type { ReactNode } from 'react'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface ServiceUptime {\n  /** Oldest first, today last. */\n  days: UptimeDay[]\n  /** A short line under the name, such as its regions or how many models it serves. */\n  detail?: string\n  /** The service's logo or icon, drawn in a tile beside its name. */\n  icon?: ReactNode\n  name: string\n  /** Its status now, written under its name after `detail`. */\n  status?: StatusLevel\n}\n\ninterface Status2Props extends BlockStateProps {\n  /** Sits right of the title, such as a link to every service. */\n  action?: ReactNode\n  /** Defaults to a sentence naming the services not running normally, or the one with the lowest uptime. */\n  description?: ReactNode\n  /** Leave out, or pass none, to show the empty state. */\n  services?: ServiceUptime[]\n  title: string\n}\n\nconst PLACEHOLDER_SERVICES = 3\n\nconst END_DATE = Date.UTC(2026, 8, 25)\nconst DAY = 86_400_000\n\nconst exampleDays = (\n  events: Record<number, Partial<Omit<UptimeDay, 'label'>>>,\n): UptimeDay[] =>\n  Array.from({ length: 90 }, (_, index) => {\n    const daysAgo = 89 - index\n    return {\n      label: formatDate(new Date(END_DATE - daysAgo * DAY), 'date'),\n      status: 'operational',\n      uptime: 100,\n      ...events[daysAgo],\n    }\n  })\n\nconst exampleProps: Status2Props = {\n  services: [\n    {\n      days: exampleDays({\n        12: {\n          note: 'Slow page loads in EU for 25 min',\n          status: 'degraded',\n          uptime: 99.4,\n        },\n        47: {\n          note: 'Scheduled database upgrade',\n          status: 'maintenance',\n          uptime: 100,\n        },\n      }),\n      detail: '3 regions',\n      icon: (\n        <IconPlaceholder\n          lucide='MonitorIcon'\n          tabler='IconDeviceDesktop'\n          hugeicons='ComputerIcon'\n          phosphor='MonitorIcon'\n          remixicon='RiComputerLine'\n        />\n      ),\n      name: 'Web app',\n      status: 'operational',\n    },\n    {\n      days: exampleDays({\n        0: {\n          note: 'Slow responses in eu-west-1 for the last 40 min',\n          status: 'degraded',\n          uptime: 99.7,\n        },\n        3: {\n          note: 'Elevated 5xx errors for 42 min',\n          status: 'partial',\n          uptime: 97.1,\n        },\n        4: { note: 'Increased latency', status: 'degraded', uptime: 99.6 },\n        31: {\n          note: 'Full outage for 1 h 6 min',\n          status: 'major',\n          uptime: 95.4,\n        },\n        66: { note: 'Increased latency', status: 'degraded', uptime: 99.8 },\n      }),\n      detail: '3 regions',\n      icon: (\n        <IconPlaceholder\n          lucide='ServerIcon'\n          tabler='IconServer'\n          hugeicons='ServerStack01Icon'\n          phosphor='HardDrivesIcon'\n          remixicon='RiServerLine'\n        />\n      ),\n      name: 'API',\n      status: 'degraded',\n    },\n    {\n      days: exampleDays({\n        ...Object.fromEntries(\n          Array.from({ length: 14 }, (_, index) => [\n            76 + index,\n            { status: 'unknown' as const },\n          ]),\n        ),\n        20: {\n          note: 'Delayed deliveries for 18 min',\n          status: 'degraded',\n          uptime: 99.7,\n        },\n      }),\n      detail: '2 regions',\n      icon: (\n        <IconPlaceholder\n          lucide='ZapIcon'\n          tabler='IconBolt'\n          hugeicons='FlashIcon'\n          phosphor='LightningIcon'\n          remixicon='RiFlashlightLine'\n        />\n      ),\n      name: 'Webhooks',\n      status: 'operational',\n    },\n  ],\n  title: 'Uptime',\n}\n\nconst summarize = (services: ServiceUptime[]) => {\n  if (services.length === 0) return 'No services yet.'\n  const troubled = services.flatMap(({ name, status }) =>\n    status && status !== 'operational' && status !== 'unknown'\n      ? [`${name} ${statusConfig[status].phrase}`]\n      : [],\n  )\n  if (troubled.length > 0) {\n    const running = services.length - troubled.length\n    return `${formatNumber(running)} of ${formatNumber(services.length)} running normally. ${formatList(troubled)}.`\n  }\n  const rated = services.map((service) => ({\n    days: service.days.length,\n    name: service.name,\n    uptime: getUptime(service.days),\n  }))\n  const lowest = rated.reduce((low, service) =>\n    service.uptime < low.uptime ? service : low,\n  )\n  const period = `over the last ${lowest.days} days`\n  if (lowest.uptime >= 100) return `Every service was up the whole time ${period}.`\n  return `${lowest.name} had the lowest uptime ${period}, at ${formatUptime(lowest.uptime)}.`\n}\n\nconst ROWS =\n  'grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 @lg:grid-cols-[minmax(0,12rem)_minmax(0,1fr)_3.75rem] @lg:gap-x-5'\nconst ROW = 'col-span-full grid grid-cols-subgrid items-center gap-y-2.5'\nconst BAR = 'col-span-full row-start-2 @lg:col-span-1 @lg:row-start-auto'\n\nfunction ServiceName({ service }: { service: ServiceUptime }) {\n  const status = service.status && statusConfig[service.status]\n  return (\n    <span className='flex min-w-0 items-center gap-3'>\n      {service.icon && <LogoTile logo={service.icon} />}\n      <span className='flex min-w-0 flex-col'>\n        <span className='truncate text-sm font-medium'>{service.name}</span>\n        {(service.detail || status) && (\n          <Details className='text-muted-foreground truncate text-xs'>\n            {service.detail}\n            {status && (\n              <StatusLabel className='text-xs' tone={status.tone} variant='text'>\n                {status.shortLabel}\n              </StatusLabel>\n            )}\n          </Details>\n        )}\n      </span>\n    </span>\n  )\n}\n\nconst Status2 = (props: Status2Props) => {\n  const { action, services = [], errorMessage, status, title } = props\n  const { description = summarize(services) } = props\n  const state = getBlockState(status, services)\n\n  return (\n    <Card>\n      <CardContent>\n        <BlockStateProvider errorMessage={errorMessage} state={state}>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                <BlockReady className='text-sm'>\n                  <p className='text-muted-foreground text-sm text-pretty'>\n                    {description}\n                  </p>\n                </BlockReady>\n              </div>\n              {action && <div className='shrink-0'>{action}</div>}\n            </header>\n            {state === 'loading' && (\n              <ul aria-hidden className={ROWS}>\n                {Array.from({ length: PLACEHOLDER_SERVICES }, (_, index) => (\n                  <li key={index} className={cn(ROW, 'border-t py-3')}>\n                    <SkeletonText className='w-28 text-sm' />\n                    <UptimeBar className={BAR} days={[]} label='' />\n                    <SkeletonText className='w-12 justify-self-end text-sm' />\n                  </li>\n                ))}\n              </ul>\n            )}\n            {(state === 'error' || state === 'empty') && (\n              <div className='border-t'>\n                <BlockStateRows />\n              </div>\n            )}\n            {!state && (\n              <ul className={ROWS}>\n                {services.map((service) => (\n                  <li key={service.name} className={cn(ROW, 'border-t py-3')}>\n                    <ServiceName service={service} />\n                    <UptimeBar className={BAR} days={service.days} label={service.name} />\n                    <span className='text-right text-sm font-medium tabular-nums'>\n                      {formatUptime(getUptime(service.days))}\n                      <span className='sr-only'> uptime</span>\n                    </span>\n                  </li>\n                ))}\n                <li aria-hidden className={cn(ROW, 'text-muted-foreground pt-1 text-xs')}>\n                  <span className='col-span-full flex justify-between @lg:col-span-1 @lg:col-start-2'>\n                    <span>{services[0]?.days.length ?? 0} days ago</span>\n                    <span>Today</span>\n                  </span>\n                </li>\n              </ul>\n            )}\n            {state !== 'error' && state !== 'empty' && (\n              <StatusLegend\n                statuses={['operational', 'degraded', 'partial', 'major', 'maintenance']}\n              />\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport {\n  Status2,\n  exampleProps as status2ExampleProps,\n  type ServiceUptime,\n  type Status2Props,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/status/status-02.tsx"
    }
  ],
  "meta": {
    "shows": "Ninety days of daily status for each service as a row of bars, with its icon, its status now and a tooltip for any day.",
    "size": "full",
    "usedWith": [
      "status-01",
      "status-03",
      "alerts-01"
    ],
    "component": "Status2",
    "props": "{ action?: ReactNode; description?: ReactNode; services?: { days: { label: string; note?: string; status: \"operational\" | \"degraded\" | \"partial\" | \"major\" | \"maintenance\" | \"unknown\"; uptime?: number }[]; detail?: string; icon?: ReactNode; name: string; status?: \"operational\" | \"degraded\" | \"partial\" | \"major\" | \"maintenance\" | \"unknown\" }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
