{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "status-05",
  "description": "One service's uptime, incident count and downtime, with its daily history and recent incidents.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/status.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/status/status-05.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport {\n  StatusIndicator,\n  type StatusLevel,\n  UptimeBar,\n  type UptimeDay,\n  formatUptime,\n  getUptime,\n} from '@/registry/components/dashboardblocks/status'\nimport { formatDate } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Incident {\n  date: string\n  duration: string\n  severity: StatusLevel\n  title: string\n}\n\ninterface Status5Props extends BlockStateProps {\n  /** Oldest first. Leave out, or pass none, to show the empty state. */\n  days?: UptimeDay[]\n  description: string\n  downtime?: string\n  /** Newest first. */\n  incidents?: Incident[]\n  title: string\n}\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: Status5Props = {\n  days: exampleDays({\n    3: {\n      note: 'Elevated 5xx errors for 42 min',\n      status: 'partial',\n      uptime: 97.1,\n    },\n    31: { note: 'Full outage for 1 h 6 min', status: 'major', uptime: 95.4 },\n    66: {\n      note: 'Increased latency for 3 min',\n      status: 'degraded',\n      uptime: 99.8,\n    },\n  }),\n  description:\n    'api.example.com over the last 90 days. The last incident was resolved on Sep 22.',\n  downtime: '1 h 51 min',\n  incidents: [\n    {\n      date: 'Sep 22',\n      duration: '42 min',\n      severity: 'partial',\n      title: 'Elevated API error rates',\n    },\n    {\n      date: 'Aug 25',\n      duration: '1 h 6 min',\n      severity: 'major',\n      title: 'API unavailable',\n    },\n    {\n      date: 'Jul 21',\n      duration: '3 min',\n      severity: 'degraded',\n      title: 'Increased latency',\n    },\n  ],\n  title: 'API uptime',\n}\n\nconst Status5 = (props: Status5Props) => {\n  const {\n    days = [],\n    description,\n    downtime,\n    incidents = [],\n    errorMessage,\n    status,\n    title,\n  } = props\n  const state = getBlockState(status, days)\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 flex-col gap-0.5'>\n              <h2 className='font-semibold tracking-tight'>{title}</h2>\n              <p className='text-muted-foreground text-sm'>{description}</p>\n            </header>\n            <dl className='grid grid-cols-2 gap-x-6 gap-y-4 border-t pt-4 @md:grid-cols-[1fr_auto_auto]'>\n              <div className='col-span-2 flex flex-col gap-1 @md:col-span-1'>\n                <dt className='text-muted-foreground text-sm'>Uptime</dt>\n                {state ? (\n                  <dd>\n                    <KPIValue />\n                  </dd>\n                ) : (\n                  <dd className='text-4xl font-light tracking-tight tabular-nums'>\n                    {formatUptime(getUptime(days))}\n                  </dd>\n                )}\n              </div>\n              {state !== 'error' && state !== 'empty' && (\n                <>\n                  <div className='flex flex-col gap-1'>\n                    <dt className='text-muted-foreground text-sm'>Incidents</dt>\n                    <dd>\n                      <KPIValue className='text-2xl' value={incidents.length} />\n                    </dd>\n                  </div>\n                  <div className='flex flex-col gap-1'>\n                    <dt className='text-muted-foreground text-sm'>Downtime</dt>\n                    {state ? (\n                      <dd>\n                        <KPIValue className='text-2xl' />\n                      </dd>\n                    ) : (\n                      <dd className='text-2xl font-light tracking-tight whitespace-nowrap tabular-nums'>\n                        {downtime}\n                      </dd>\n                    )}\n                  </div>\n                </>\n              )}\n            </dl>\n            <div className='flex flex-col gap-2'>\n              <UptimeBar days={days} label={title} />\n              {!state && (\n                <div className='text-muted-foreground flex justify-between text-xs'>\n                  <span>{days.length} days ago</span>\n                  <span>Today</span>\n                </div>\n              )}\n            </div>\n            {state !== 'error' && state !== 'empty' && (\n              <div className='flex flex-col gap-1'>\n                <h3 className='text-sm font-medium'>Recent incidents</h3>\n                {state === 'loading' && (\n                  <div className='border-t'>\n                    <BlockStateRows rows={3} />\n                  </div>\n                )}\n                {!state && (\n                  <ul className='flex flex-col border-t'>\n                    {incidents.map((incident) => (\n                      <li\n                        key={`${incident.date}-${incident.title}`}\n                        className='flex flex-col items-start gap-x-4 gap-y-1 border-b py-2.5 last:border-b-0 @md:flex-row @md:items-center @md:justify-between'\n                      >\n                        <div className='flex min-w-0 flex-col'>\n                          <span className='text-sm font-medium'>{incident.title}</span>\n                          <span className='text-muted-foreground text-xs tabular-nums'>\n                            {incident.date}\n                          </span>\n                        </div>\n                        <div className='flex shrink-0 items-center gap-4'>\n                          <StatusIndicator status={incident.severity} />\n                          <span className='text-muted-foreground w-16 text-right text-sm tabular-nums'>\n                            <span className='sr-only'>Lasted </span>\n                            {incident.duration}\n                          </span>\n                        </div>\n                      </li>\n                    ))}\n                  </ul>\n                )}\n              </div>\n            )}\n          </section>\n        </BlockStateProvider>\n      </CardContent>\n    </Card>\n  )\n}\n\nexport { Status5, exampleProps as status5ExampleProps, type Status5Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/status/status-05.tsx"
    }
  ],
  "meta": {
    "shows": "One service's uptime, incident count and downtime, with its daily history and recent incidents.",
    "size": "full",
    "usedWith": [
      "status-02",
      "status-03",
      "alerts-01"
    ],
    "component": "Status5",
    "props": "{ days?: { label: string; note?: string; status: \"operational\" | \"degraded\" | \"partial\" | \"major\" | \"maintenance\" | \"unknown\"; uptime?: number }[]; description: string; downtime?: string; incidents?: { date: string; duration: string; severity: \"operational\" | \"degraded\" | \"partial\" | \"major\" | \"maintenance\" | \"unknown\"; title: string }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
