{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pricing",
  "title": "Pricing",
  "description": "A pricing section with plan cards, a featured plan and an optional monthly or yearly billing switch.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/badge",
    "@corsair-ui/button",
    "@corsair-ui/card",
    "@corsair-ui/toggle-group"
  ],
  "files": [
    {
      "path": "registry/default/components/blocks/pricing.tsx",
      "content": "\"use client\";\n\nimport { CheckIcon } from \"lucide-react\";\nimport { isValidElement, useState, type ComponentProps, type ReactNode } from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\nimport { Badge } from \"@/registry/default/ui/badge\";\nimport { Button } from \"@/registry/default/ui/button\";\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardFooter,\n  CardHeader,\n} from \"@/registry/default/ui/card\";\nimport { ToggleGroup, ToggleGroupItem } from \"@/registry/default/ui/toggle-group\";\n\ntype PricingBilling = \"monthly\" | \"yearly\";\n\n/** A value that is either the same for both billing periods or differs per period. */\ntype PricingValue = ReactNode | { monthly: ReactNode; yearly: ReactNode };\n\ninterface PricingPlan {\n  /** Used as the React key; falls back to the index. */\n  id?: string;\n  name: ReactNode;\n  description?: ReactNode;\n  /** One price, or `{ monthly, yearly }` to show the billing switch. Pass formatted strings. */\n  price: PricingValue;\n  /** Shown after the price in muted text, e.g. \"/month\". */\n  period?: PricingValue;\n  features: ReactNode[];\n  action?: { label: ReactNode; href: string };\n  /** Highlights the plan with a ring and a solid action button. */\n  featured?: boolean;\n  /** Small label next to the plan name, e.g. \"Most popular\". */\n  badge?: ReactNode;\n}\n\ninterface PricingProps extends Omit<ComponentProps<\"section\">, \"title\"> {\n  eyebrow?: ReactNode;\n  title?: ReactNode;\n  description?: ReactNode;\n  plans?: PricingPlan[];\n  /** The billing period shown (controlled). */\n  billing?: PricingBilling;\n  /** The billing period shown first (uncontrolled). Defaults to \"monthly\". */\n  defaultBilling?: PricingBilling;\n  onBillingChange?: (billing: PricingBilling) => void;\n  monthlyLabel?: ReactNode;\n  yearlyLabel?: ReactNode;\n  /** Accessible name of the billing switch. */\n  billingLabel?: string;\n  /** Shown next to the yearly label, e.g. \"Save 20%\". Pass `null` to hide. */\n  yearlyNote?: ReactNode;\n}\n\nconst DEFAULT_PLANS: PricingPlan[] = [\n  {\n    id: \"starter\",\n    name: \"Starter\",\n    description: \"For individuals trying things out.\",\n    price: { monthly: \"$0\", yearly: \"$0\" },\n    period: { monthly: \"/month\", yearly: \"/year\" },\n    features: [\"Up to 3 projects\", \"Basic analytics\", \"Community support\"],\n    action: { label: \"Get started\", href: \"#get-started\" },\n  },\n  {\n    id: \"pro\",\n    name: \"Pro\",\n    description: \"For growing teams that need more room.\",\n    price: { monthly: \"$12\", yearly: \"$120\" },\n    period: { monthly: \"/month\", yearly: \"/year\" },\n    features: [\n      \"Unlimited projects\",\n      \"Advanced analytics\",\n      \"Shared workspaces\",\n      \"Priority email support\",\n    ],\n    action: { label: \"Start free trial\", href: \"#get-started\" },\n    featured: true,\n    badge: \"Most popular\",\n  },\n  {\n    id: \"enterprise\",\n    name: \"Enterprise\",\n    description: \"For organisations with custom needs.\",\n    price: \"Custom\",\n    features: [\"Everything in Pro\", \"Single sign-on\", \"Audit logs\", \"Dedicated account manager\"],\n    action: { label: \"Contact sales\", href: \"#contact\" },\n  },\n];\n\n// Full class names so Tailwind picks them up.\nconst GRID_COLUMNS: Record<number, string> = {\n  1: \"mx-auto max-w-md\",\n  2: \"mx-auto max-w-4xl md:grid-cols-2\",\n  3: \"lg:grid-cols-3\",\n  4: \"md:grid-cols-2 lg:grid-cols-4\",\n};\n\nfunction isPerBilling(value: PricingValue): value is { monthly: ReactNode; yearly: ReactNode } {\n  return (\n    typeof value === \"object\" &&\n    value !== null &&\n    !isValidElement(value) &&\n    \"monthly\" in value &&\n    \"yearly\" in value\n  );\n}\n\nfunction resolve(value: PricingValue, billing: PricingBilling): ReactNode {\n  return isPerBilling(value) ? value[billing] : value;\n}\n\n/**\n * A pricing section: a centred header, an optional monthly / yearly switch\n * and one card per plan. Give a plan `price: { monthly, yearly }` (and the\n * same shape for `period`) and the switch appears above the grid; plain\n * values stay the same for both periods. Prices are shown as passed, so\n * format them for your locale and currency. The featured plan gets a ring\n * and a solid button, and its `badge` sits next to the name.\n *\n * Every string is a prop: `monthlyLabel`, `yearlyLabel`, `yearlyNote` and\n * `billingLabel` (the switch's accessible name). The billing period works\n * controlled (`billing` + `onBillingChange`) or uncontrolled\n * (`defaultBilling`), and the current one is exposed as `data-billing`.\n *\n * Accessibility: the section title is an `<h2>` and plan names are `<h3>`;\n * plans and features are lists; the switch is a radio-style toggle group\n * that cannot be cleared, reachable with Tab and the arrow keys.\n *\n * @example\n * <Pricing\n *   title=\"Pricing\"\n *   plans={[\n *     { name: \"Free\", price: \"$0\", features: [\"1 project\"] },\n *     { name: \"Team\", price: { monthly: \"$20\", yearly: \"$200\" }, features: [\"10 projects\"], featured: true },\n *   ]}\n * />\n */\nfunction Pricing({\n  className,\n  eyebrow = \"Pricing\",\n  title = \"Plans that grow with you\",\n  description = \"Start for free and upgrade when your team needs more. Every plan includes a 14-day trial.\",\n  plans = DEFAULT_PLANS,\n  billing: billingProp,\n  defaultBilling = \"monthly\",\n  onBillingChange,\n  monthlyLabel = \"Monthly\",\n  yearlyLabel = \"Yearly\",\n  billingLabel = \"Billing period\",\n  yearlyNote = \"2 months free\",\n  ...props\n}: PricingProps) {\n  const [billingState, setBillingState] = useState<PricingBilling>(defaultBilling);\n  const billing = billingProp ?? billingState;\n  const hasBillingSwitch = plans.some(\n    (plan) => isPerBilling(plan.price) || (plan.period !== undefined && isPerBilling(plan.period))\n  );\n  const hasHeader = eyebrow != null || title != null || description != null;\n\n  function handleBillingChange(value: string) {\n    // A single toggle group can be cleared by pressing the active item; keep one selected.\n    if (value !== \"monthly\" && value !== \"yearly\") return;\n    if (billingProp === undefined) setBillingState(value);\n    onBillingChange?.(value);\n  }\n\n  return (\n    <section\n      data-slot=\"pricing\"\n      data-billing={billing}\n      className={cn(\"py-16 sm:py-24\", className)}\n      {...props}\n    >\n      <div data-slot=\"pricing-container\" className=\"mx-auto w-full max-w-6xl px-4 sm:px-6\">\n        {hasHeader ? (\n          <div data-slot=\"pricing-header\" className=\"mx-auto max-w-2xl text-center\">\n            {eyebrow != null ? (\n              <p data-slot=\"pricing-eyebrow\" className=\"text-muted-foreground text-sm font-medium\">\n                {eyebrow}\n              </p>\n            ) : null}\n            {title != null ? (\n              <h2\n                data-slot=\"pricing-title\"\n                className={cn(\n                  \"text-3xl font-semibold tracking-tight text-balance sm:text-4xl\",\n                  eyebrow != null && \"mt-2\"\n                )}\n              >\n                {title}\n              </h2>\n            ) : null}\n            {description != null ? (\n              <p\n                data-slot=\"pricing-description\"\n                className=\"text-muted-foreground mt-4 text-lg text-pretty\"\n              >\n                {description}\n              </p>\n            ) : null}\n          </div>\n        ) : null}\n        <div data-slot=\"pricing-content\" className={cn(hasHeader && \"mt-12\")}>\n          {hasBillingSwitch ? (\n            <div data-slot=\"pricing-billing\" className=\"mb-10 flex justify-center\">\n              <ToggleGroup\n                type=\"single\"\n                variant=\"outline\"\n                value={billing}\n                onValueChange={handleBillingChange}\n                aria-label={billingLabel}\n              >\n                <ToggleGroupItem value=\"monthly\" data-slot=\"pricing-billing-monthly\">\n                  {monthlyLabel}\n                </ToggleGroupItem>\n                <ToggleGroupItem value=\"yearly\" data-slot=\"pricing-billing-yearly\">\n                  {yearlyLabel}\n                  {yearlyNote != null ? (\n                    <span\n                      data-slot=\"pricing-yearly-note\"\n                      className=\"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs\"\n                    >\n                      {yearlyNote}\n                    </span>\n                  ) : null}\n                </ToggleGroupItem>\n              </ToggleGroup>\n            </div>\n          ) : null}\n          <ul\n            data-slot=\"pricing-plans\"\n            className={cn(\"grid gap-6\", GRID_COLUMNS[Math.min(Math.max(plans.length, 1), 4)])}\n          >\n            {plans.map((plan, index) => {\n              const period = plan.period === undefined ? null : resolve(plan.period, billing);\n              return (\n                <li key={plan.id ?? index} data-slot=\"pricing-plan-item\" className=\"flex\">\n                  <Card\n                    data-slot=\"pricing-plan\"\n                    data-featured={plan.featured ? \"\" : undefined}\n                    className={cn(\"w-full\", plan.featured && \"border-primary ring-primary ring-2\")}\n                  >\n                    <CardHeader>\n                      <div className=\"flex flex-wrap items-center gap-2\">\n                        <h3\n                          data-slot=\"pricing-plan-name\"\n                          className=\"text-lg leading-none font-semibold\"\n                        >\n                          {plan.name}\n                        </h3>\n                        {plan.badge != null ? (\n                          <Badge data-slot=\"pricing-plan-badge\">{plan.badge}</Badge>\n                        ) : null}\n                      </div>\n                      {plan.description != null ? (\n                        <CardDescription data-slot=\"pricing-plan-description\">\n                          {plan.description}\n                        </CardDescription>\n                      ) : null}\n                    </CardHeader>\n                    <CardContent className=\"flex flex-1 flex-col gap-6\">\n                      <p data-slot=\"pricing-price\" className=\"flex flex-wrap items-baseline gap-1\">\n                        <span className=\"text-4xl font-semibold tracking-tight\">\n                          {resolve(plan.price, billing)}\n                        </span>\n                        {period != null ? (\n                          <span\n                            data-slot=\"pricing-period\"\n                            className=\"text-muted-foreground text-sm\"\n                          >\n                            {period}\n                          </span>\n                        ) : null}\n                      </p>\n                      <ul data-slot=\"pricing-features\" className=\"flex flex-col gap-3 text-sm\">\n                        {plan.features.map((feature, featureIndex) => (\n                          <li\n                            key={featureIndex}\n                            data-slot=\"pricing-feature\"\n                            className=\"flex items-start gap-2\"\n                          >\n                            <CheckIcon\n                              aria-hidden=\"true\"\n                              className=\"text-primary mt-0.5 size-4 shrink-0\"\n                            />\n                            <span>{feature}</span>\n                          </li>\n                        ))}\n                      </ul>\n                    </CardContent>\n                    {plan.action ? (\n                      <CardFooter>\n                        <Button\n                          asChild\n                          // \"outline\" is the button variant name, not the Tailwind utility.\n                          // tailwind-compat-ignore-next-line\n                          variant={plan.featured ? \"default\" : \"outline\"}\n                          className=\"w-full\"\n                        >\n                          <a data-slot=\"pricing-plan-action\" href={plan.action.href}>\n                            {plan.action.label}\n                          </a>\n                        </Button>\n                      </CardFooter>\n                    ) : null}\n                  </Card>\n                </li>\n              );\n            })}\n          </ul>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport { Pricing, type PricingBilling, type PricingPlan, type PricingProps, type PricingValue };\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:block"
}