extends ../layout-marketing
include ../_mixins/recaptcha
include ../_mixins/material_symbol

block vars
	- bootstrap5PageStatus = 'disabled'

block content
	- var showCaptcha = settings.recaptcha && settings.recaptcha.siteKey && !(settings.recaptcha.disabled && settings.recaptcha.disabled.passwordReset)

	if showCaptcha
		script(
			type='text/javascript'
			nonce=scriptNonce
			src='https://www.recaptcha.net/recaptcha/api.js?render=explicit'
		)
		div(
			id='recaptcha'
			class='g-recaptcha'
			data-sitekey=settings.recaptcha.siteKey
			data-size='invisible'
			data-badge='inline'
		)

	main#main-content.content.content-alt(data-ol-captcha-retry-trigger-area='')
		.container-custom-sm.mx-auto
			.card
				form(
					name='passwordResetForm'
					captcha-action-name=showCaptcha ? 'passwordReset' : false
					data-ol-async-form
					action='/user/password/reset'
					method='POST'
					captcha=showCaptcha ? '' : false
				)
					if error === 'password_reset_token_expired'
						h3.mt-0.mb-2 #{translate("sorry_your_token_expired")}
						p #{translate('please_request_a_new_password_reset_email_and_follow_the_link')}.
					else
						h3.mt-0.mb-2(data-ol-not-sent) #{translate("password_reset")}
						h3.mt-0.mb-2(hidden data-ol-sent) #{translate("check_your_email")}
						p(data-ol-not-sent) #{translate("enter_your_email_address_below_and_we_will_send_you_a_link_to_reset_your_password")}.

					div(data-ol-not-sent)
						+formMessages
						if error && error !== 'password_reset_token_expired'
							.alert.alert-danger.mb-2(role='alert' aria-live='assertive')
								| #{translate(error)}

						div(data-ol-custom-form-message='no-password-allowed-due-to-sso' hidden)
							.notification.notification-type-error(
								aria-live='polite'
								style='margin-bottom: 10px'
							)
								.notification-icon
									+material-symbol-rounded('error')
								.notification-content-and-cta
									.notification-content
										p
											| !{translate("you_cant_reset_password_due_to_sso", {}, [{name: 'a', attrs: {href: '/sso-login'}}])}

						input(name='_csrf' type='hidden' value=csrfToken)
						.form-group.mb-3
							label(for='email') #{translate("email")}
							input#email.form-control(
								name='email'
								aria-label='email'
								type='email'
								placeholder=translate('enter_your_email_address')
								required
								autocomplete='username'
								autofocus
							)
						.actions
							button.btn.btn-primary.w-100(
								type='submit'
								data-ol-disabled-inflight
								aria-label=translate('request_password_reset_to_reconfirm')
							)
								span(data-ol-inflight='idle')
									| #{translate("request_password_reset")}
								span(hidden data-ol-inflight='pending')
									| #{translate("requesting_password_reset")}…
					div(hidden data-ol-sent)
						p.mb-4 #{translate('password_reset_email_sent')}
						a(href='/login') #{translate('back_to_log_in')}

			if showCaptcha
				+recaptchaConditions
