{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-forgot-password-form",
  "title": "ForgotPasswordForm",
  "description": "Bloco completo de recuperação de conta e redefinição de senha com instruções e confirmação.",
  "dependencies": [
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/input",
    "@lema-ds/button",
    "@lema-ds/label",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider"
  ],
  "files": [
    {
      "path": "components/ds/ds-forgot-password-form.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport {\n  KeyRoundIcon,\n  MailIcon,\n  MailCheckIcon,\n  Loader2Icon,\n  ArrowLeftIcon,\n} from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Input } from \"@/components/ui/input\"\nimport { Button } from \"@/components/ui/button\"\nimport { Label } from \"@/components/ui/label\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useUILocale } from \"@/components/ui/ds-locale-provider\"\n\n// ── Types ──\n\nexport interface ForgotPasswordFormProps\n  extends\n    Omit<React.HTMLAttributes<HTMLDivElement>, \"onSubmit\">,\n    VariantProps<typeof forgotPasswordFormVariants> {\n  onSubmit?: (email: string) => Promise<boolean | void> | void\n  onBackToLogin?: () => void\n  resendCooldown?: number\n  loading?: boolean\n  locale?: UILocale\n}\n\n// ── Variants ──\n\nexport const forgotPasswordFormVariants = cva(\n  \"flex w-full max-w-md flex-col gap-5 rounded-2xl border border-border/80 bg-card p-6 text-card-foreground shadow-lg sm:p-8\",\n  {\n    variants: {\n      variant: {\n        default: \"\",\n        flat: \"border-0 bg-transparent p-0 shadow-none sm:p-0\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  }\n)\n\n// ── Component ──\n\nexport const ForgotPasswordForm = React.forwardRef<\n  HTMLDivElement,\n  ForgotPasswordFormProps\n>(\n  (\n    {\n      className,\n      variant = \"default\",\n      onSubmit,\n      onBackToLogin,\n      resendCooldown = 60,\n      loading: controlledLoading = false,\n      locale: localeProp,\n      ...props\n    },\n    ref\n  ) => {\n    const locale = useUILocale(localeProp)\n    const [email, setEmail] = React.useState(\"\")\n    const [sent, setSent] = React.useState(false)\n    const [internalLoading, setInternalLoading] = React.useState(false)\n    const [countdown, setCountdown] = React.useState(resendCooldown)\n\n    const t = UI_I18N[locale]?.auth ?? UI_I18N[\"en-US\"].auth\n    const isLoading = controlledLoading || internalLoading\n\n    React.useEffect(() => {\n      if (!sent || countdown <= 0) return\n      const timer = setInterval(() => {\n        setCountdown((prev) => prev - 1)\n      }, 1000)\n      return () => clearInterval(timer)\n    }, [sent, countdown])\n\n    const handleSubmit = async (e: React.FormEvent) => {\n      e.preventDefault()\n      if (!email || isLoading || !onSubmit) return\n\n      try {\n        setInternalLoading(true)\n        await onSubmit(email)\n        setSent(true)\n        setCountdown(resendCooldown)\n      } finally {\n        setInternalLoading(false)\n      }\n    }\n\n    const handleResend = async () => {\n      if (countdown > 0 || isLoading || !onSubmit) return\n\n      try {\n        setInternalLoading(true)\n        await onSubmit(email)\n        setCountdown(resendCooldown)\n      } finally {\n        setInternalLoading(false)\n      }\n    }\n\n    return (\n      <div\n        ref={ref}\n        className={cn(forgotPasswordFormVariants({ variant }), className)}\n        {...props}\n      >\n        {sent ? (\n          <div\n            role=\"status\"\n            aria-live=\"polite\"\n            className=\"flex animate-in flex-col items-center gap-4 py-2 text-center duration-300 fade-in-0\"\n          >\n            <div className=\"flex size-14 items-center justify-center rounded-full bg-primary/15 text-primary\">\n              <MailCheckIcon className=\"size-7\" aria-hidden=\"true\" />\n            </div>\n\n            <div className=\"flex flex-col gap-1.5\">\n              <h3 className=\"text-xl font-bold tracking-tight text-foreground\">\n                {t.resetLinkSent}\n              </h3>\n              <p className=\"max-w-xs text-xs text-muted-foreground\">\n                {t.magicLinkSent}{\" \"}\n                <span className=\"font-semibold text-foreground\">{email}</span>.\n                Follow the instructions to create a new password.\n              </p>\n            </div>\n\n            <div className=\"flex w-full flex-col gap-2 pt-3\">\n              <div className=\"flex items-center justify-center gap-1.5 text-xs text-muted-foreground\">\n                {countdown > 0 ? (\n                  <span>\n                    {t.resendIn}{\" \"}\n                    <strong className=\"text-foreground\">{countdown}s</strong>\n                  </span>\n                ) : (\n                  <Button\n                    type=\"button\"\n                    variant=\"link\"\n                    size=\"sm\"\n                    onClick={handleResend}\n                    disabled={isLoading}\n                    className=\"h-auto p-0 text-xs font-semibold text-primary\"\n                  >\n                    {t.resendCode}\n                  </Button>\n                )}\n              </div>\n\n              {onBackToLogin && (\n                <Button\n                  type=\"button\"\n                  variant=\"outline\"\n                  onClick={onBackToLogin}\n                  className=\"mt-2 h-10 w-full gap-2\"\n                >\n                  <ArrowLeftIcon className=\"size-4\" aria-hidden=\"true\" />\n                  <span>{t.backToLogin}</span>\n                </Button>\n              )}\n            </div>\n          </div>\n        ) : (\n          <>\n            {/* Header */}\n            <div className=\"flex flex-col gap-2 text-center sm:text-left\">\n              <div className=\"flex size-11 items-center justify-center self-center rounded-xl bg-primary/10 text-primary sm:self-start\">\n                <KeyRoundIcon className=\"size-5\" aria-hidden=\"true\" />\n              </div>\n              <h2 className=\"text-2xl font-bold tracking-tight text-foreground\">\n                {t.resetPasswordTitle}\n              </h2>\n              <p className=\"text-xs leading-relaxed text-muted-foreground\">\n                {t.resetPasswordDescription}\n              </p>\n            </div>\n\n            {/* Form */}\n            <form onSubmit={handleSubmit} className=\"flex flex-col gap-4\">\n              <div className=\"flex flex-col gap-1.5\">\n                <Label htmlFor=\"forgot-email\" className=\"text-xs font-medium\">\n                  {t.email}\n                </Label>\n                <div className=\"relative\">\n                  <div className=\"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-muted-foreground\">\n                    <MailIcon className=\"size-4\" aria-hidden=\"true\" />\n                  </div>\n                  <Input\n                    id=\"forgot-email\"\n                    type=\"email\"\n                    required\n                    disabled={isLoading}\n                    value={email}\n                    onChange={(e) => setEmail(e.target.value)}\n                    placeholder={t.emailPlaceholder}\n                    className=\"h-10 pl-9 text-sm placeholder:text-muted-foreground\"\n                  />\n                </div>\n              </div>\n\n              <Button\n                type=\"submit\"\n                disabled={!email || isLoading}\n                className=\"mt-1 h-10 w-full\"\n              >\n                {isLoading && (\n                  <Loader2Icon\n                    className=\"mr-2 size-4 animate-spin\"\n                    aria-hidden=\"true\"\n                  />\n                )}\n                {t.sendResetLink}\n              </Button>\n            </form>\n\n            {/* Back to Login link */}\n            {onBackToLogin && (\n              <div className=\"flex items-center justify-center border-t border-border/50 pt-2\">\n                <Button\n                  type=\"button\"\n                  variant=\"ghost\"\n                  size=\"sm\"\n                  onClick={onBackToLogin}\n                  className=\"gap-1.5 text-xs text-muted-foreground hover:text-foreground\"\n                >\n                  <ArrowLeftIcon className=\"size-3.5\" aria-hidden=\"true\" />\n                  <span>{t.backToLogin}</span>\n                </Button>\n              </div>\n            )}\n          </>\n        )}\n      </div>\n    )\n  }\n)\nForgotPasswordForm.displayName = \"ForgotPasswordForm\"\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
