import { Button, StrongPassword } from "@wrnexus/ui"

component ResetPassword {
  props {
    action = "/api/auth/password/reset"
    schema = "auth-password-reset"
    token = ""
    redirect = "/sign-in"
    title = "Set a new password"
    description = "Choose a strong password you have not used before."
    submitLabel = "Reset password"
    successMessage = "Your password has been reset."
    color = "primary"
    size = "md"
    class = ""
  }
  view {
    <section {...attrs} data-wrnexus-runtime="auth" class='w-full max-w-md rounded-[var(--wrn-radius-lg)] border border-[var(--wrn-color-border)] bg-[var(--wrn-color-surface)] p-6 text-[var(--wrn-color-text)] shadow-[var(--wrn-shadow-2)] {class}'>
      <h1 class="m-0 text-2xl font-semibold">{title}</h1>
      <p class="mt-2 text-sm text-[var(--wrn-color-muted)]">{description}</p>
      <form method="post" action='{action}' data-schema='{schema}' data-redirect='{redirect}' novalidate class="mt-6 space-y-4">
        <input type="hidden" name="token" value='{token}' />
        <StrongPassword label="New password" name="password" autocomplete="new-password" minLength="12" requireLowercase="true" requireUppercase="true" requireNumber="true" requireSpecialCharacter="true" color="{color}" size="{size}" />
        <p data-error="token" class="m-0 min-h-4 text-xs text-[var(--wrn-color-danger)]"></p>
        <p data-error="_form" role="alert" class="m-0 hidden rounded-[var(--wrn-radius-sm)] bg-[color-mix(in_srgb,var(--wrn-color-danger)_10%,transparent)] p-3 text-sm text-[var(--wrn-color-danger)]"></p>
        <p data-success='{successMessage}' role="status" hidden class="m-0 rounded-[var(--wrn-radius-sm)] bg-[color-mix(in_srgb,var(--wrn-color-success)_10%,transparent)] p-3 text-sm text-[var(--wrn-color-success)]">{successMessage}</p>
        <Button type="submit" label="{submitLabel}" variant="solid" color="{color}" size="{size}" fullWidth="true" />
      </form>
    </section>
  }
}
