{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "quota-tile",
  "title": "Quota Tile",
  "description": "Tile for one plan quota: what it is, its status, the count against its allowance and a meter.",
  "dependencies": [
    "lucide-react@^1.27.0"
  ],
  "registryDependencies": [
    "@pestoui/badge",
    "@pestoui/card",
    "@pestoui/stat",
    "@pestoui/style",
    "@pestoui/usage-meter",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/components/quota-tile.tsx",
      "content": "import * as React from \"react\"\nimport { CircleCheck, TriangleAlert } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Stat } from \"@/components/stat\"\nimport { UsageMeter } from \"@/components/usage-meter\"\nimport { Badge } from \"@/components/ui/badge\"\nimport { Card, CardContent } from \"@/components/ui/card\"\n\n/* One plan quota — seats, storage, run credits — as a titled tile: what it is,\n   whether it is in trouble, the count against its allowance, and a meter.\n *\n * A composition, not a new primitive. The figure is a Stat, the state is a\n * Badge, the meter is a UsageMeter and the white face is a Card; this only\n * fixes how they sit together. The face sits in a tray one radius step out from\n * it (2xl tray, 6px inset, xl card), so the two corners stay concentric, and\n * the meter lives on the tray below the face.\n *\n * The state is derived from the numbers, never passed in: at `criticalAt` of\n * the allowance the badge turns destructive and says so in words, and the\n * meter goes destructive with it, so colour is never the only cue. The state\n * also rides on the root as data-state for anything a caller nests inside; the\n * tile does not read it to paint itself. */\n\n/* Thousands separators in one fixed locale, so the server and the browser\n   render the same string. */\nconst formatCount = (n: number) => n.toLocaleString(\"en-US\")\n\nconst HEADINGS = { 2: \"h2\", 3: \"h3\", 4: \"h4\" } as const\n\ntype QuotaTileProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n  /** A lucide-style icon component, drawn muted before the title. */\n  icon: React.ElementType\n  /** The quota's name — the tile's heading. */\n  label: React.ReactNode\n  used: number\n  limit: number\n  /** Trails the figure, after a space — \"GB\". */\n  unit?: string\n  /** Names the meter for assistive tech. */\n  srLabel: string\n  /** The share of the allowance, 0..1, at which the quota reads critical. */\n  criticalAt?: number\n  criticalLabel?: React.ReactNode\n  healthyLabel?: React.ReactNode\n  /** Formats `used` and `limit`. Keep it locale-fixed so server and client agree. */\n  formatValue?: (n: number) => string\n  /** The heading level the title renders at. */\n  headingLevel?: 2 | 3 | 4\n}\n\nfunction QuotaTile({\n  icon: Icon,\n  label,\n  used,\n  limit,\n  unit,\n  srLabel,\n  criticalAt = 0.8,\n  criticalLabel = \"Near limit\",\n  healthyLabel = \"Healthy\",\n  formatValue = formatCount,\n  headingLevel = 3,\n  className,\n  ...props\n}: QuotaTileProps) {\n  const share = limit > 0 ? used / limit : 0\n  const critical = share >= criticalAt\n  const headingId = React.useId()\n  const Heading = HEADINGS[headingLevel]\n\n  return (\n    <section\n      data-slot=\"quota-tile\"\n      data-state={critical ? \"critical\" : \"healthy\"}\n      aria-labelledby={headingId}\n      className={cn(\"rounded-2xl border border-border bg-muted/50 p-1.5\", className)}\n      {...props}\n    >\n      <Card size=\"sm\" className=\"gap-6\">\n        <CardContent className=\"flex flex-col gap-6\">\n          <div className=\"flex flex-wrap items-center gap-x-3 gap-y-2\">\n            <Icon\n              data-slot=\"quota-tile-icon\"\n              aria-hidden=\"true\"\n              className=\"size-5 shrink-0 text-muted-foreground\"\n            />\n            <Heading\n              id={headingId}\n              data-slot=\"quota-tile-title\"\n              className=\"text-body-md leading-6 font-medium text-foreground\"\n            >\n              {label}\n            </Heading>\n            {/* The badge names the state in words, so the colour is never the\n                only thing telling a reader the quota is in trouble. */}\n            {critical ? (\n              <Badge\n                data-slot=\"quota-tile-status\"\n                variant=\"destructive\"\n                className=\"ml-auto border-destructive/20\"\n              >\n                <TriangleAlert data-icon=\"inline-start\" aria-hidden=\"true\" />\n                {criticalLabel}\n              </Badge>\n            ) : (\n              <Badge\n                data-slot=\"quota-tile-status\"\n                variant=\"success\"\n                className=\"ml-auto border-success/20\"\n              >\n                <CircleCheck data-icon=\"inline-start\" aria-hidden=\"true\" />\n                {healthyLabel}\n              </Badge>\n            )}\n          </div>\n          {/* \"/ 20\" is the same size as the figure, only muted — not Stat's\n              half-size unit — so it is composed into the value. The unit slot\n              then carries the trailing unit. */}\n          <Stat\n            size=\"lg\"\n            className=\"font-normal\"\n            value={\n              <>\n                {formatValue(used)}\n                <span className=\"text-muted-foreground\"> / {formatValue(limit)}</span>\n              </>\n            }\n            unit={unit ? ` ${unit}` : undefined}\n          />\n        </CardContent>\n      </Card>\n      <div data-slot=\"quota-tile-meter\" className=\"px-3 pt-3 pb-2\">\n        <UsageMeter\n          variant=\"bar\"\n          tone={critical ? \"destructive\" : \"muted\"}\n          value={used}\n          max={limit}\n          srLabel={srLabel}\n        />\n      </div>\n    </section>\n  )\n}\n\nexport { QuotaTile }\nexport type { QuotaTileProps }\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}