import { useRouter } from "../../router/RouteContext.js";
import { useEnvironment } from "../../contexts/EnvironmentContext.js";
import { useLoadingStatus } from "../../hooks/useLoadingStatus.js";
import { localizationKeys } from "../../localization/localizationKeys.js";
import { useTotalEnabledAuthMethods } from "../../hooks/useTotalEnabledAuthMethods.js";
import { useSignInContext } from "../../contexts/components/SignIn.js";
import { useCoreSignIn } from "../../contexts/CoreClientContext.js";
import { buildRequest, useFormControl } from "../../utils/useFormControl.js";
import { descriptors } from "../../customizables/elementDescriptors.js";
import { useCardState, withCardStateProvider } from "../../elements/contexts/index.js";
import { Flow } from "../../customizables/Flow.js";
import { Col } from "../../customizables/index.js";
import { getIdentifierControlDisplayValues, groupIdentifiers } from "../../common/constants.js";
import { Card } from "../../elements/Card/index.js";
import { Header } from "../../elements/Header.js";
import { handleError } from "../../utils/errorHandler.js";
import { Form } from "../../elements/Form.js";
import { CaptchaElement } from "../../elements/CaptchaElement.js";
import { LoadingCard } from "../../elements/LoadingCard.js";
import { withRedirectToAfterSignIn, withRedirectToSignInTask } from "../../common/withRedirect.js";
import { useSupportEmail } from "../../hooks/useSupportEmail.js";
import { getPreferredAlternativePhoneChannel, getPreferredAlternativePhoneChannelForCombinedFlow, getSignUpAttributeFromIdentifier } from "./utils.js";
import { SignInSocialButtons } from "./SignInSocialButtons.js";
import { hasMultipleEnterpriseConnections, useHandleAuthenticateWithPasskey } from "./shared.js";
import { SocialButtonsReversibleContainerWithDivider } from "../../elements/ReversibleContainer.js";
import { isMobileDevice } from "../../utils/isMobileDevice.js";
import { handleCombinedFlowTransfer } from "./handleCombinedFlowTransfer.js";
import { SignInAlternativePhoneCodePhoneNumberCard } from "./SignInAlternativePhoneCodePhoneNumberCard.js";
import { clerkInvalidFAPIResponse } from "@clerk/shared/internal/clerk-js/errors";
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { ERROR_CODES, SIGN_UP_MODES } from "@clerk/shared/internal/clerk-js/constants";
import { getClerkQueryParam, removeClerkQueryParam } from "@clerk/shared/internal/clerk-js/queryParams";
import { useClerk } from "@clerk/shared/react";
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
import { getAlternativePhoneCodeProviderData } from "@clerk/shared/alternativePhoneCode";
import { isWebAuthnAutofillSupported, isWebAuthnSupported } from "@clerk/shared/webauthn";

//#region src/components/SignIn/SignInStart.tsx
const useAutoFillPasskey = () => {
	const [isSupported, setIsSupported] = useState(false);
	const { navigate } = useRouter();
	const onSecondFactor = () => navigate("factor-two");
	const authenticateWithPasskey = useHandleAuthenticateWithPasskey(onSecondFactor);
	const { userSettings } = useEnvironment();
	const { passkeySettings, attributes } = userSettings;
	useEffect(() => {
		async function runAutofillPasskey() {
			const _isSupported = await isWebAuthnAutofillSupported();
			setIsSupported(_isSupported);
			if (!_isSupported) return;
			await authenticateWithPasskey({ flow: "autofill" });
		}
		if (passkeySettings.allow_autofill && attributes.passkey?.enabled) runAutofillPasskey();
	}, []);
	return { isWebAuthnAutofillSupported: isSupported };
};
function SignInStartInternal() {
	const card = useCardState();
	const clerk = useClerk();
	const status = useLoadingStatus();
	const { userSettings, authConfig } = useEnvironment();
	const signIn = useCoreSignIn();
	const { navigate } = useRouter();
	const ctx = useSignInContext();
	const { afterSignInUrl, signUpUrl, waitlistUrl, isCombinedFlow, navigateOnSetActive } = ctx;
	const supportEmail = useSupportEmail();
	const totalEnabledAuthMethods = useTotalEnabledAuthMethods();
	const identifierAttributes = useMemo(() => groupIdentifiers(userSettings.enabledFirstFactorIdentifiers), [userSettings.enabledFirstFactorIdentifiers]);
	const alternativePhoneCodeChannels = userSettings.alternativePhoneCodeChannels;
	/**
	* Passkeys
	*/
	const { isWebAuthnAutofillSupported: isWebAuthnAutofillSupported$1 } = useAutoFillPasskey();
	const onSecondFactor = () => navigate("factor-two");
	const authenticateWithPasskey = useHandleAuthenticateWithPasskey(onSecondFactor);
	const isWebSupported = isWebAuthnSupported();
	const [identifierAttribute, setIdentifierAttribute] = useState(!!ctx.initialValues?.phoneNumber && !(ctx.initialValues.emailAddress || ctx.initialValues.username) && identifierAttributes.includes("phone_number") ? "phone_number" : identifierAttributes[0] || "");
	const [hasSwitchedByAutofill, setHasSwitchedByAutofill] = useState(false);
	const organizationTicket = getClerkQueryParam("__clerk_ticket") || "";
	const clerkStatus = getClerkQueryParam("__clerk_status") || "";
	const standardFormAttributes = userSettings.enabledFirstFactorIdentifiers;
	const web3FirstFactors = userSettings.web3FirstFactors;
	const authenticatableSocialStrategies = userSettings.authenticatableSocialStrategies;
	const passwordBasedInstance = userSettings.instanceIsPasswordBased;
	const { currentIdentifier, nextIdentifier } = getIdentifierControlDisplayValues(identifierAttributes, identifierAttribute);
	const instantPasswordField = useFormControl("password", "", {
		type: "password",
		label: localizationKeys("formFieldLabel__password"),
		placeholder: localizationKeys("formFieldInputPlaceholder__password")
	});
	const [alternativePhoneCodeProvider, setAlternativePhoneCodeProvider] = useState(null);
	const showAlternativePhoneCodeProviders = userSettings.alternativePhoneCodeChannels.length > 0;
	const onAlternativePhoneCodeUseAnotherMethod = () => {
		setAlternativePhoneCodeProvider(null);
	};
	const onAlternativePhoneCodeProviderClick = (phoneCodeChannel) => {
		setAlternativePhoneCodeProvider(getAlternativePhoneCodeProviderData(phoneCodeChannel) || null);
	};
	const ctxInitialValues = ctx.initialValues || {};
	const initialValues = useMemo(() => ({
		email_address: ctxInitialValues.emailAddress,
		email_address_username: ctxInitialValues.emailAddress || ctxInitialValues.username,
		username: ctxInitialValues.username,
		phone_number: ctxInitialValues.phoneNumber
	}), [ctx.initialValues]);
	const hasSocialOrWeb3Buttons = !!authenticatableSocialStrategies.length || !!web3FirstFactors.length || !!alternativePhoneCodeChannels.length;
	const [shouldAutofocus, setShouldAutofocus] = useState(!isMobileDevice() && !hasSocialOrWeb3Buttons);
	const textIdentifierField = useFormControl("identifier", initialValues[identifierAttribute] || "", {
		...currentIdentifier,
		isRequired: true,
		transformer: (value) => value.trim()
	});
	const phoneIdentifierField = useFormControl("identifier", initialValues["phone_number"] || "", {
		...currentIdentifier,
		isRequired: true
	});
	const identifierField = identifierAttribute === "phone_number" ? phoneIdentifierField : textIdentifierField;
	const switchToNextIdentifier = () => {
		setIdentifierAttribute((i) => identifierAttributes[(identifierAttributes.indexOf(i) + 1) % identifierAttributes.length]);
		setShouldAutofocus(true);
		setHasSwitchedByAutofill(false);
	};
	const handlePhoneNumberPaste = (value) => {
		textIdentifierField.setValue(initialValues[identifierAttribute] || "");
		phoneIdentifierField.setValue(value);
		setIdentifierAttribute("phone_number");
		setShouldAutofocus(true);
	};
	useLayoutEffect(() => {
		if (identifierField.value.startsWith("+") && identifierAttributes.includes("phone_number") && identifierAttribute !== "phone_number" && !hasSwitchedByAutofill) {
			handlePhoneNumberPaste(identifierField.value);
			setHasSwitchedByAutofill(true);
		}
	}, [identifierField.value, identifierAttributes]);
	useEffect(() => {
		if (!organizationTicket) return;
		if (clerkStatus === "sign_up") {
			const paramsToForward = new URLSearchParams();
			if (organizationTicket) paramsToForward.set("__clerk_ticket", organizationTicket);
			navigate(isCombinedFlow ? `create` : signUpUrl, { searchParams: paramsToForward });
			return;
		}
		status.setLoading();
		card.setLoading();
		signIn.create({
			strategy: "ticket",
			ticket: organizationTicket
		}).then((res) => {
			switch (res.status) {
				case "needs_first_factor":
					if (!hasOnlyEnterpriseSSOFirstFactors(res) || hasMultipleEnterpriseConnections(res.supportedFirstFactors)) return navigate("factor-one");
					return authenticateWithEnterpriseSSO();
				case "needs_second_factor": return navigate("factor-two");
				case "needs_client_trust": return navigate("client-trust");
				case "complete":
					removeClerkQueryParam("__clerk_ticket");
					return clerk.setActive({
						session: res.createdSessionId,
						navigate: async ({ session, decorateUrl }) => {
							await navigateOnSetActive({
								session,
								redirectUrl: afterSignInUrl,
								decorateUrl
							});
						}
					});
				default:
					console.error(clerkInvalidFAPIResponse(res.status, supportEmail));
					return;
			}
		}).catch((err) => {
			return attemptToRecoverFromSignInError(err);
		}).finally(() => {
			if (!!hasOnlyEnterpriseSSOFirstFactors(signIn)) return;
			status.setIdle();
			card.setIdle();
		});
	}, []);
	useEffect(() => {
		async function handleOauthError() {
			const defaultErrorHandler = () => {
				card.setError("Unable to complete action at this time. If the problem persists please contact support.");
			};
			const error = signIn?.firstFactorVerification?.error;
			if (error) {
				switch (error.code) {
					case ERROR_CODES.NOT_ALLOWED_TO_SIGN_UP:
					case ERROR_CODES.OAUTH_ACCESS_DENIED:
					case ERROR_CODES.NOT_ALLOWED_ACCESS:
					case ERROR_CODES.SAML_USER_ATTRIBUTE_MISSING:
					case ERROR_CODES.OAUTH_EMAIL_DOMAIN_RESERVED_BY_SAML:
					case ERROR_CODES.USER_LOCKED:
					case ERROR_CODES.EXTERNAL_ACCOUNT_NOT_FOUND:
					case ERROR_CODES.SIGN_UP_MODE_RESTRICTED:
					case ERROR_CODES.SIGN_UP_MODE_RESTRICTED_WAITLIST:
					case ERROR_CODES.ENTERPRISE_SSO_USER_ATTRIBUTE_MISSING:
					case ERROR_CODES.ENTERPRISE_SSO_EMAIL_ADDRESS_DOMAIN_MISMATCH:
					case ERROR_CODES.ENTERPRISE_SSO_HOSTED_DOMAIN_MISMATCH:
					case ERROR_CODES.SAML_EMAIL_ADDRESS_DOMAIN_MISMATCH:
					case ERROR_CODES.ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO:
					case ERROR_CODES.CAPTCHA_INVALID:
					case ERROR_CODES.FRAUD_DEVICE_BLOCKED:
					case ERROR_CODES.FRAUD_ACTION_BLOCKED:
					case ERROR_CODES.SIGNUP_RATE_LIMIT_EXCEEDED:
					case ERROR_CODES.USER_BANNED:
					case ERROR_CODES.USER_DEACTIVATED:
						card.setError(error);
						break;
					default: defaultErrorHandler();
				}
				await signIn.create({});
			}
		}
		handleOauthError();
	}, []);
	const buildSignInParams = (fields) => {
		const hasPassword = fields.some((f) => f.name === "password" && !!f.value);
		/**
		* FAPI will return an error when password is submitted but the user's email matches requires enterprise sso authentication.
		* We need to strip password from the create request, and reconstruct it later.
		*/
		if (!hasPassword || userSettings.enterpriseSSO.enabled) fields = fields.filter((f) => f.name !== "password");
		return {
			...buildRequest(fields),
			...hasPassword && !userSettings.enterpriseSSO.enabled && { strategy: "password" }
		};
	};
	const safePasswordSignInForEnterpriseSSOInstance = (signInCreatePromise, fields) => {
		return signInCreatePromise.then((signInResource) => {
			if (!userSettings.enterpriseSSO.enabled) return signInResource;
			/**
			* For instances with Enterprise SSO enabled, perform sign in with password only when it is allowed for the identified user.
			*/
			const passwordField = fields.find((f) => f.name === "password")?.value;
			if (!passwordField || signInResource.supportedFirstFactors?.some((ff) => ff.strategy === "enterprise_sso")) return signInResource;
			return signInResource.attemptFirstFactor({
				strategy: "password",
				password: passwordField
			});
		});
	};
	const signInWithFields = async (...fields) => {
		const preferredAlternativePhoneChannel = alternativePhoneCodeProvider?.channel || getPreferredAlternativePhoneChannel(fields, authConfig.preferredChannels, "identifier");
		if (preferredAlternativePhoneChannel) {
			const noop = () => {};
			fields.push({
				id: "strategy",
				value: "phone_code",
				clearFeedback: noop,
				setValue: noop,
				onChange: noop,
				setError: noop
			});
			fields.push({
				id: "channel",
				value: preferredAlternativePhoneChannel,
				clearFeedback: noop,
				setValue: noop,
				onChange: noop,
				setError: noop
			});
		}
		try {
			const res = await safePasswordSignInForEnterpriseSSOInstance(signIn.create(buildSignInParams(fields)), fields);
			switch (res.status) {
				case "needs_identifier":
					if (res.supportedFirstFactors?.some((ff) => ff.strategy === "enterprise_sso")) await authenticateWithEnterpriseSSO();
					break;
				case "needs_first_factor":
					if (!hasOnlyEnterpriseSSOFirstFactors(res) || hasMultipleEnterpriseConnections(res.supportedFirstFactors)) return navigate("factor-one");
					return authenticateWithEnterpriseSSO();
				case "needs_second_factor": return navigate("factor-two");
				case "needs_client_trust": return navigate("client-trust");
				case "complete": return clerk.setActive({
					session: res.createdSessionId,
					navigate: async ({ session, decorateUrl }) => {
						await navigateOnSetActive({
							session,
							redirectUrl: afterSignInUrl,
							decorateUrl
						});
					}
				});
				default:
					console.error(clerkInvalidFAPIResponse(res.status, supportEmail));
					return;
			}
		} catch (e) {
			return attemptToRecoverFromSignInError(e);
		}
	};
	const authenticateWithEnterpriseSSO = async () => {
		const redirectUrl = ctx.ssoCallbackUrl;
		const redirectUrlComplete = ctx.afterSignInUrl || "/";
		return signIn.authenticateWithRedirect({
			strategy: "enterprise_sso",
			redirectUrl,
			redirectUrlComplete,
			oidcPrompt: ctx.oidcPrompt,
			continueSignIn: true
		});
	};
	const attemptToRecoverFromSignInError = async (e) => {
		if (!e.errors) return;
		const instantPasswordError = e.errors.find((e$1) => e$1.code === ERROR_CODES.INVALID_STRATEGY_FOR_USER || e$1.code === ERROR_CODES.FORM_PASSWORD_INCORRECT || e$1.code === ERROR_CODES.FORM_PASSWORD_PWNED);
		const sessionAlreadyExistsError = e.errors.find((e$1) => e$1.code === ERROR_CODES.SESSION_EXISTS);
		const alreadySignedInError = e.errors.find((e$1) => e$1.code === "identifier_already_signed_in");
		const accountDoesNotExistError = e.errors.find((e$1) => e$1.code === ERROR_CODES.INVITATION_ACCOUNT_NOT_EXISTS || e$1.code === ERROR_CODES.FORM_IDENTIFIER_NOT_FOUND);
		if (instantPasswordError) await signInWithFields(identifierField);
		else if (sessionAlreadyExistsError) await clerk.setActive({
			session: clerk.client.lastActiveSessionId,
			navigate: async ({ session, decorateUrl }) => {
				await navigateOnSetActive({
					session,
					redirectUrl: afterSignInUrl,
					decorateUrl
				});
			}
		});
		else if (alreadySignedInError) {
			const sid = alreadySignedInError.meta.sessionId;
			await clerk.setActive({
				session: sid,
				navigate: async ({ session, decorateUrl }) => {
					await navigateOnSetActive({
						session,
						redirectUrl: afterSignInUrl,
						decorateUrl
					});
				}
			});
		} else if (isCombinedFlow && accountDoesNotExistError) {
			const attribute = getSignUpAttributeFromIdentifier(identifierField);
			if (userSettings.signUp.mode === SIGN_UP_MODES.WAITLIST) return navigate(clerk.buildWaitlistUrl(attribute === "emailAddress" ? { initialValues: { [attribute]: identifierField.value } } : {}));
			clerk.client.signUp[attribute] = identifierField.value;
			const redirectUrl = ctx.ssoCallbackUrl;
			const redirectUrlComplete = ctx.afterSignUpUrl || "/";
			return handleCombinedFlowTransfer({
				afterSignUpUrl: ctx.afterSignUpUrl || "/",
				clerk,
				handleError: (e$1) => handleError(e$1, [identifierField, instantPasswordField], card.setError),
				identifierAttribute: attribute,
				identifierValue: identifierField.value,
				navigate,
				organizationTicket,
				signUpMode: userSettings.signUp.mode,
				redirectUrl,
				redirectUrlComplete,
				navigateOnSetActive,
				passwordEnabled: userSettings.attributes.password?.required ?? false,
				alternativePhoneCodeChannel: alternativePhoneCodeProvider?.channel || getPreferredAlternativePhoneChannelForCombinedFlow(authConfig.preferredChannels, attribute, identifierField.value),
				unsafeMetadata: ctx.unsafeMetadata
			});
		} else handleError(e, [identifierField, instantPasswordField], card.setError);
	};
	const handleFirstPartySubmit = async (e) => {
		e.preventDefault();
		return signInWithFields(identifierField, instantPasswordField);
	};
	const DynamicField = useMemo(() => {
		return {
			tel: Form.PhoneInput,
			password: Form.PasswordInput,
			text: Form.PlainInput,
			email: Form.PlainInput
		}[identifierField.type];
	}, [identifierField.type]);
	if (status.isLoading || clerkStatus === "sign_up") return /* @__PURE__ */ jsx(LoadingCard, {});
	const { action, validLastAuthenticationStrategies,...identifierFieldProps } = identifierField.props;
	const lastAuthenticationStrategy = clerk.client?.lastAuthenticationStrategy;
	const isIdentifierLastAuthenticationStrategy = lastAuthenticationStrategy && totalEnabledAuthMethods > 1 ? validLastAuthenticationStrategies?.has(lastAuthenticationStrategy) : false;
	return /* @__PURE__ */ jsx(Flow.Part, {
		part: "start",
		children: !alternativePhoneCodeProvider ? /* @__PURE__ */ jsxs(Card.Root, { children: [/* @__PURE__ */ jsxs(Card.Content, { children: [
			/* @__PURE__ */ jsxs(Header.Root, {
				showLogo: true,
				children: [/* @__PURE__ */ jsx(Header.Title, { localizationKey: isCombinedFlow ? localizationKeys("signIn.start.titleCombined") : localizationKeys("signIn.start.title") }), /* @__PURE__ */ jsx(Header.Subtitle, {
					localizationKey: isCombinedFlow ? localizationKeys("signIn.start.subtitleCombined") : localizationKeys("signIn.start.subtitle"),
					sx: { "&:empty": { display: "none" } }
				})]
			}),
			/* @__PURE__ */ jsx(Card.Alert, { children: card.error }),
			/* @__PURE__ */ jsxs(Col, {
				elementDescriptor: descriptors.main,
				gap: 6,
				children: [
					/* @__PURE__ */ jsxs(SocialButtonsReversibleContainerWithDivider, { children: [hasSocialOrWeb3Buttons && /* @__PURE__ */ jsx(SignInSocialButtons, {
						enableWeb3Providers: true,
						enableOAuthProviders: true,
						enableAlternativePhoneCodeProviders: showAlternativePhoneCodeProviders,
						onAlternativePhoneCodeProviderClick
					}), standardFormAttributes.length ? /* @__PURE__ */ jsxs(Form.Root, {
						onSubmit: handleFirstPartySubmit,
						gap: 8,
						children: [/* @__PURE__ */ jsxs(Col, {
							gap: 6,
							children: [/* @__PURE__ */ jsx(Form.ControlRow, {
								elementId: identifierField.id,
								children: /* @__PURE__ */ jsx(DynamicField, {
									actionLabel: nextIdentifier?.action,
									onActionClicked: switchToNextIdentifier,
									...identifierFieldProps,
									autoFocus: shouldAutofocus,
									autoComplete: isWebAuthnAutofillSupported$1 ? "webauthn" : void 0,
									isLastAuthenticationStrategy: isIdentifierLastAuthenticationStrategy
								})
							}), /* @__PURE__ */ jsx(InstantPasswordRow, { field: passwordBasedInstance ? instantPasswordField : void 0 })]
						}), /* @__PURE__ */ jsxs(Col, {
							center: true,
							children: [/* @__PURE__ */ jsx(CaptchaElement, {}), /* @__PURE__ */ jsx(Form.SubmitButton, { hasArrow: true })]
						})]
					}) : null] }),
					!standardFormAttributes.length && /* @__PURE__ */ jsx(CaptchaElement, {}),
					userSettings.attributes.passkey?.enabled && userSettings.passkeySettings.show_sign_in_button && isWebSupported && /* @__PURE__ */ jsx(Card.Action, {
						elementId: "usePasskey",
						children: /* @__PURE__ */ jsx(Card.ActionLink, {
							localizationKey: localizationKeys("signIn.start.actionLink__use_passkey"),
							onClick: () => authenticateWithPasskey({ flow: "discoverable" })
						})
					})
				]
			})
		] }), /* @__PURE__ */ jsxs(Card.Footer, { children: [userSettings.signUp.mode === SIGN_UP_MODES.PUBLIC && !isCombinedFlow && /* @__PURE__ */ jsxs(Card.Action, {
			elementId: "signIn",
			children: [/* @__PURE__ */ jsx(Card.ActionText, { localizationKey: localizationKeys("signIn.start.actionText") }), /* @__PURE__ */ jsx(Card.ActionLink, {
				localizationKey: localizationKeys("signIn.start.actionLink"),
				to: clerk.buildUrlWithAuth(signUpUrl)
			})]
		}), userSettings.signUp.mode === SIGN_UP_MODES.WAITLIST && /* @__PURE__ */ jsxs(Card.Action, {
			elementId: "signIn",
			children: [/* @__PURE__ */ jsx(Card.ActionText, { localizationKey: localizationKeys("signIn.start.actionText__join_waitlist") }), /* @__PURE__ */ jsx(Card.ActionLink, {
				localizationKey: localizationKeys("signIn.start.actionLink__join_waitlist"),
				to: clerk.buildUrlWithAuth(waitlistUrl)
			})]
		})] })] }) : /* @__PURE__ */ jsx(SignInAlternativePhoneCodePhoneNumberCard, {
			handleSubmit: handleFirstPartySubmit,
			phoneNumberFormState: phoneIdentifierField,
			onUseAnotherMethod: onAlternativePhoneCodeUseAnotherMethod,
			phoneCodeProvider: alternativePhoneCodeProvider
		})
	});
}
const hasOnlyEnterpriseSSOFirstFactors = (signIn) => {
	if (!signIn.supportedFirstFactors?.length) return false;
	return signIn.supportedFirstFactors.every((ff) => ff.strategy === "enterprise_sso");
};
const InstantPasswordRow = ({ field }) => {
	const [autofilled, setAutofilled] = useState(false);
	const ref = useRef(null);
	const show = !!(autofilled || field?.value);
	useLayoutEffect(() => {
		const intervalId = setInterval(() => {
			if (ref?.current) {
				const autofilled$1 = window.getComputedStyle(ref.current, ":autofill").animationName === "onAutoFillStart" || !!ref.current?.matches("*:-webkit-autofill");
				if (autofilled$1) {
					setAutofilled(autofilled$1);
					clearInterval(intervalId);
				}
			}
		}, 500);
		return () => {
			clearInterval(intervalId);
		};
	}, []);
	useEffect(() => {
		if (field?.value && field.value !== "") setAutofilled(false);
	}, [field?.value]);
	if (!field) return null;
	return /* @__PURE__ */ jsx(Form.ControlRow, {
		elementId: field.id,
		sx: show ? void 0 : {
			position: "absolute",
			opacity: 0,
			height: 0,
			pointerEvents: "none",
			marginTop: "-1rem"
		},
		children: /* @__PURE__ */ jsx(Form.PasswordInput, {
			...field.props,
			ref,
			tabIndex: show ? void 0 : -1
		})
	});
};
const SignInStart = withRedirectToSignInTask(withRedirectToAfterSignIn(withCardStateProvider(SignInStartInternal)));

//#endregion
export { SignInStart };
//# sourceMappingURL=SignInStart.js.map