{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "goal-meter",
  "title": "Goal Meter",
  "description": "Progress toward a fixed goal, drawn as a gradient fill with a knob and a percent flag.",
  "registryDependencies": [
    "@pestoui/progress",
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/components/goal-meter.tsx",
      "content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Progress } from \"@/components/ui/progress\"\n\n/* A count advancing toward a fixed goal — 18 of 27 agents live — drawn as a\n   gradient fill with a knob and a percent flag at the current value, the\n   unfilled remainder as a row of ticks, and a taller tick standing at the end.\n *\n * The bar itself is a Progress: it owns role=\"progressbar\" and the\n * aria-value trio, and the knob and its flag ride in Progress's own marker\n * slot so they follow the fill on the same spring. What Progress cannot draw\n * is the remainder as ticks and the end tick, so those sit behind it,\n * aria-hidden, and its track goes transparent to let them show through.\n *\n * Not a mode of Progress, and not UsageMeter. Progress has no ticked remainder\n * or end tick; UsageMeter reports a level spent out of an allowance\n * (role=\"meter\") and has neither a knob nor a flag. This is a task heading for\n * a finish line, so it reads \"how far along\", not \"how much is left\".\n *\n * Every class below is what the deployment-progress card rendered before this\n * was a component, so swapping the card over to it moves nothing. The two type\n * sizes are the size-only scale with the line-height the stock sizes used to\n * carry written out beside them. */\n\ntype GoalMeterProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n  /** How far along. Held inside 0..max, so a count past the goal reads as the goal reached. */\n  value: number\n  /** The goal. Greater than 0; anything else draws an empty bar. */\n  max: number\n  /** Ticks drawn across the unfilled remainder. Every other one hides below `sm`. */\n  ticks: number\n  /** The progressbar's accessible name. */\n  label: string\n  /** The spoken reading. Defaults to \"<percent>% complete\". */\n  valueText?: string\n  /** The caption over the end tick. Defaults to \"100%\". */\n  endLabel?: React.ReactNode\n}\n\nfunction GoalMeter({\n  value,\n  max,\n  ticks,\n  label,\n  valueText,\n  endLabel = \"100%\",\n  className,\n  ...props\n}: GoalMeterProps) {\n  /* Held inside 0..max before anything reads it. Progress treats a value\n     outside its range as indeterminate and drops the knob, while the ticks and\n     the spoken percent would go on reporting the raw number — a bar with no\n     reading that says \"150% complete\", or ticks hung off the left edge for a\n     negative one. An overshoot is the goal reached; a value in range passes\n     through untouched. */\n  /* A goal of zero or less has no \"how far along\". The bar is drawn empty\n     against a goal of 1, which keeps the progressbar's range valid instead of\n     handing the primitive a max it rejects. */\n  const goal = Number.isFinite(max) && max > 0 ? max : 1\n  const reached =\n    max > 0 && Number.isFinite(value) ? Math.min(Math.max(value, 0), goal) : 0\n  const share = (reached / goal) * 100\n  const percent = Math.round(share)\n  const tickCount = Number.isFinite(ticks) ? Math.max(0, Math.floor(ticks)) : 0\n\n  return (\n    <div data-slot=\"goal-meter\" className={cn(\"relative pt-7\", className)} {...props}>\n      <span\n        data-slot=\"goal-meter-end-label\"\n        aria-hidden=\"true\"\n        className=\"absolute top-0 right-3 text-body-sm leading-5 text-foreground tabular-nums\"\n      >\n        {endLabel}\n      </span>\n      <div className=\"relative h-7\">\n        <div\n          data-slot=\"goal-meter-ticks\"\n          aria-hidden=\"true\"\n          className=\"absolute inset-y-0 right-3 flex items-stretch justify-between gap-0.5 overflow-hidden\"\n          style={{ left: `calc(${share}% + 0.75rem)` }}\n        >\n          {Array.from({ length: tickCount }, (_, index) => (\n            <span\n              key={index}\n              className=\"w-1 shrink-0 rounded-full bg-muted-foreground/25 max-sm:even:hidden\"\n            />\n          ))}\n        </div>\n        <span\n          data-slot=\"goal-meter-end-tick\"\n          aria-hidden=\"true\"\n          className=\"absolute right-0 bottom-0 h-12 w-1 rounded-full bg-muted-foreground/40\"\n        />\n        <Progress\n          value={reached}\n          max={goal}\n          aria-label={label}\n          aria-valuetext={valueText ?? `${percent}% complete`}\n          className=\"absolute inset-0 h-full rounded-md bg-transparent [&_[data-slot=progress-indicator]]:rounded-md [&_[data-slot=progress-indicator]]:bg-linear-to-r [&_[data-slot=progress-indicator]]:from-chart-4 [&_[data-slot=progress-indicator]]:to-info\"\n          marker={\n            <span className=\"relative flex h-10 w-2.5 flex-col items-center self-end\">\n              <span className=\"size-2.5 shrink-0 rounded-full bg-info\" />\n              <span className=\"-mt-1 w-1 flex-1 rounded-full bg-info\" />\n              {/* White-on-blue would be 3.7:1; ink on an opaque card chip clears AA. */}\n              <span\n                data-slot=\"goal-meter-flag\"\n                className=\"absolute right-full bottom-1 mr-1.5 flex h-5 items-center rounded-sm bg-card px-1.5 text-caption-sm leading-4 font-medium text-info-ink tabular-nums\"\n              >\n                {percent}%\n              </span>\n            </span>\n          }\n        />\n      </div>\n    </div>\n  )\n}\n\nexport { GoalMeter }\nexport type { GoalMeterProps }\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}