@using Microsoft.AspNetCore.Identity
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Options
@inject IViewLocalizer Localizer
@model LiteCharmsSecurity.STS.Identity.ViewModels.Account.ForgotPasswordViewModel
@inject IOptions<IdentityOptions> IdentityOptions
@{
    ViewData["Title"] = Localizer["Title"];
}

<div class="py-8">
    <h1 class="text-4xl font-bold mb-2">@ViewData["Title"]</h1>

    @await Html.PartialAsync("_ValidationSummary")

    <div class="card mt-6">
        <div class="card-header">
            <h2 class="card-title">@Localizer["ChoosePolicy"]</h2>
        </div>
        <div class="card-content">
            <form asp-controller="Account" asp-action="ForgotPassword" method="post" class="space-y-6">
                <div class="form-item">
                    <div class="flex space-x-6">
                        @if (IdentityOptions.Value.User.RequireUniqueEmail)
                        {
                            <div class="flex items-center space-x-2">
                                <input type="radio" name="Policy" asp-for="Policy" value="Email" id="policy-email" class="radio" checked />
                                <label for="policy-email" class="label cursor-pointer">Email</label>
                            </div>
                        }

                        @if (IdentityOptions.Value.User.RequireUniqueEmail)
                        {
                            <div class="flex items-center space-x-2">
                                <input type="radio" name="Policy" asp-for="Policy" value="Username" id="policy-username" class="radio" />
                                <label for="policy-username" class="label cursor-pointer">Username</label>
                            </div>
                        }
                        else
                        {
                            <div class="flex items-center space-x-2">
                                <input type="radio" name="Policy" asp-for="Policy" value="Username" id="policy-username" class="radio" checked />
                                <label for="policy-username" class="label cursor-pointer">Username</label>
                            </div>
                        }
                    </div>
                </div>

                <div id="resetPasswordByEmail" class="resetPasswordBy @(IdentityOptions.Value.User.RequireUniqueEmail ? "" : "hidden")">
                    <div class="form-item">
                        <label asp-for="Email" class="form-label">
                            <lucideicon name="mail" class="inline-block h-4 w-4 mr-1" />
                            @Localizer["Email"]
                        </label>
                        <input asp-for="Email" type="email" class="input" tw-validation required />
                        <span asp-validation-for="Email" class="form-message"></span>
                    </div>
                    <button type="submit" class="btn-default mt-3">
                        <lucideicon name="send" class="inline-block h-4 w-4 mr-2" />
                        @Localizer["Submit"]
                    </button>
                </div>

                <div id="resetPasswordByUsername" class="resetPasswordBy @(!IdentityOptions.Value.User.RequireUniqueEmail ? "" : "hidden")">
                    <div class="form-item">
                        <label asp-for="Username" class="form-label">
                            <lucideicon name="user" class="inline-block h-4 w-4 mr-1" />
                            @Localizer["Username"]
                        </label>
                        <input asp-for="Username" class="input" tw-validation required />
                        <span asp-validation-for="Username" class="form-message"></span>
                    </div>
                    <button type="submit" class="btn-default mt-3">
                        <lucideicon name="send" class="inline-block h-4 w-4 mr-2" />
                        @Localizer["Submit"]
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>

@section scripts {
    <script src="~/js/forgot-password.js"></script>
}
