@krak-stack/auth 0.1.52 → 0.1.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,37 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAtomSuspense } from "@effect/atom-react";
2
+ import { useAtomSet, useAtomSuspense, useAtomValue } from "@effect/atom-react";
3
+ import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
3
4
  import { Link, useNavigate, useRouterState } from "@tanstack/react-router";
4
- import { Schema } from "effect";
5
+ import { Effect, Option, Schema } from "effect";
5
6
  import { Atom, AsyncResult } from "effect/unstable/reactivity";
6
7
  import { REGEXP_ONLY_DIGITS } from "input-otp";
7
- import { KeyRound, Mail } from "lucide-react";
8
+ import { KeyRound, Loader2, Mail } from "lucide-react";
8
9
  import { useEffect, useState } from "react";
9
10
  import { Button, buttonVariants } from "@/components/ui/button";
10
11
  import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card";
12
+ import { CheckboxField, ErrorMessage, SubmitError, TextField, effectFormMessages, } from "@/components/ui/effect-form";
11
13
  import { Field, FieldLabel } from "@/components/ui/field";
12
- import { FieldError, useAppForm } from "@/components/ui/form";
13
14
  import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "@/components/ui/input-otp";
14
15
  import { authClientApi } from "./auth-client-api";
15
16
  import { useKrakstackAuth } from "./auth-provider";
16
17
  import { cn } from "./utils";
17
18
  import { ExtraProjectPublicConfig as ExtraProjectPublicConfigSchema, } from "../extra/schema";
18
19
  const EMAIL_OTP_RESEND_COOLDOWN_SECONDS = 60;
20
+ const signinFormBuilder = FormBuilder.empty
21
+ .addField("email", Schema.String)
22
+ .addField("password", Schema.String)
23
+ .addField("otp", Schema.String);
24
+ const signupFormBuilder = FormBuilder.empty
25
+ .addField("name", Schema.String)
26
+ .addField("email", Schema.String)
27
+ .addField("password", Schema.String);
28
+ const verifyEmailFormBuilder = FormBuilder.empty
29
+ .addField("email", Schema.String)
30
+ .addField("otp", Schema.String);
31
+ const resetPasswordFormBuilder = FormBuilder.empty.addField("password", Schema.String);
32
+ const twoFactorFormBuilder = FormBuilder.empty
33
+ .addField("code", Schema.String)
34
+ .addField("trustDevice", Schema.Boolean);
19
35
  const defaultMessages = {
20
36
  en: {
21
37
  auth_continue_with_google: "Continue with Google",
@@ -226,23 +242,56 @@ export function Signin(props) {
226
242
  const interval = window.setInterval(updateResendSeconds, 1000);
227
243
  return () => window.clearInterval(interval);
228
244
  }, [emailOtpResendAvailableAt]);
229
- const form = useAppForm({
230
- defaultValues: { email: "", password: "", otp: "" },
231
- onSubmit: async ({ value, formApi }) => {
232
- formApi.setErrorMap({ onSubmit: undefined });
233
- const email = value.email.trim();
234
- if (!emailSubmitted) {
235
- if (selectedAuthMethod === "emailOtp") {
236
- await sendEmailOtp(email, (message) => formApi.setErrorMap({ onSubmit: { form: message, fields: {} } }));
245
+ const [form] = useState(() => FormReact.make(signinFormBuilder, {
246
+ fields: { email: TextField, password: TextField, otp: OtpField },
247
+ mode: { validation: "onSubmit" },
248
+ onSubmit: (action, { decoded: value }) => Effect.tryPromise({
249
+ try: async () => {
250
+ const email = value.email.trim();
251
+ const sendEmailOtp = async () => {
252
+ const result = await authClient.emailOtp.sendVerificationOtp({
253
+ email,
254
+ type: "sign-in",
255
+ });
256
+ if (result.error) {
257
+ throw new Error(result.error.message ?? m.sign_in_email_otp_send_error);
258
+ }
259
+ setAuthMethod("emailOtp");
260
+ setEmailSubmitted(true);
261
+ setOtpSentTo(email);
262
+ setEmailOtpResendAvailableAt(Date.now() + EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000);
263
+ };
264
+ if (action.type === "social") {
265
+ const result = await authClient.signIn.social({
266
+ provider: "google",
267
+ callbackURL: socialRedirectTarget,
268
+ errorCallbackURL: "/sign-in",
269
+ ...(oauthQuery
270
+ ? { additionalData: { query: oauthQuery } }
271
+ : {}),
272
+ ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
273
+ });
274
+ if (result.error) {
275
+ throw new Error(result.error.message ?? m.sign_in_error);
276
+ }
277
+ if (result.data?.url)
278
+ onNavigate(result.data.url);
279
+ return;
280
+ }
281
+ if (action.type === "sendEmailOtp") {
282
+ await sendEmailOtp();
237
283
  return;
238
284
  }
239
- setEmailSubmitted(true);
240
- return;
241
- }
242
- try {
243
- if (selectedAuthMethod === "emailOtp") {
244
- if (!otpSentTo) {
245
- await sendEmailOtp(email, (message) => formApi.setErrorMap({ onSubmit: { form: message, fields: {} } }));
285
+ if (!action.emailSubmitted) {
286
+ if (action.method === "emailOtp")
287
+ await sendEmailOtp();
288
+ else
289
+ setEmailSubmitted(true);
290
+ return;
291
+ }
292
+ if (action.method === "emailOtp") {
293
+ if (!action.otpSent) {
294
+ await sendEmailOtp();
246
295
  return;
247
296
  }
248
297
  const result = await authClient.signIn.emailOtp({
@@ -250,13 +299,7 @@ export function Signin(props) {
250
299
  otp: value.otp.trim(),
251
300
  });
252
301
  if (result.error) {
253
- formApi.setErrorMap({
254
- onSubmit: {
255
- form: result.error.message ?? m.sign_in_email_otp_error,
256
- fields: {},
257
- },
258
- });
259
- return;
302
+ throw new Error(result.error.message ?? m.sign_in_email_otp_error);
260
303
  }
261
304
  onNavigate(redirectTarget);
262
305
  return;
@@ -268,119 +311,81 @@ export function Signin(props) {
268
311
  ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
269
312
  });
270
313
  if (result.error) {
271
- formApi.setErrorMap({
272
- onSubmit: {
273
- form: result.error.message ?? m.sign_in_error,
274
- fields: {},
275
- },
276
- });
277
- return;
314
+ throw new Error(result.error.message ?? m.sign_in_error);
278
315
  }
279
316
  if (hasTwoFactorRedirect(result.data)) {
280
317
  onTwoFactorRedirect(`/2fa${oauthQuery ? `?${oauthQuery}` : `?callbackURL=${encodeURIComponent(redirectTarget)}`}`);
281
318
  return;
282
319
  }
283
320
  onNavigate(result.data?.url ?? redirectTarget);
284
- }
285
- catch {
286
- formApi.setErrorMap({
287
- onSubmit: {
288
- form: selectedAuthMethod === "emailOtp"
289
- ? m.sign_in_email_otp_error
290
- : m.sign_in_error,
291
- fields: {},
292
- },
293
- });
294
- }
295
- },
296
- });
297
- const sendEmailOtp = async (email, setError) => {
298
- try {
299
- const result = await authClient.emailOtp.sendVerificationOtp({
300
- email,
301
- type: "sign-in",
302
- });
303
- if (result.error) {
304
- setError(result.error.message ?? m.sign_in_email_otp_send_error);
305
- return;
306
- }
307
- setAuthMethod("emailOtp");
308
- setEmailSubmitted(true);
309
- setOtpSentTo(email);
310
- setEmailOtpResendAvailableAt(Date.now() + EMAIL_OTP_RESEND_COOLDOWN_SECONDS * 1000);
311
- }
312
- catch {
313
- setError(m.sign_in_email_otp_send_error);
314
- }
315
- };
321
+ },
322
+ catch: (cause) => cause instanceof Error
323
+ ? cause
324
+ : new Error(action.type === "sendEmailOtp" ||
325
+ (action.type === "submit" &&
326
+ action.method === "emailOtp" &&
327
+ (!action.emailSubmitted || !action.otpSent))
328
+ ? m.sign_in_email_otp_send_error
329
+ : action.type === "submit" && action.method === "emailOtp"
330
+ ? m.sign_in_email_otp_error
331
+ : m.sign_in_error),
332
+ }),
333
+ }));
334
+ const submit = useAtomSet(form.submit);
335
+ const submitResult = useAtomValue(form.submit);
336
+ const formValues = Option.getOrElse(useAtomValue(form.values), () => ({
337
+ email: "",
338
+ password: "",
339
+ otp: "",
340
+ }));
341
+ const resetForm = useAtomSet(form.reset);
342
+ const setEmail = useAtomSet(form.getFieldAtoms(form.fields.email).setValue);
343
+ const setPassword = useAtomSet(form.getFieldAtoms(form.fields.password).setValue);
344
+ const setOtp = useAtomSet(form.getFieldAtoms(form.fields.otp).setValue);
316
345
  const resetEmailStep = () => {
346
+ const email = formValues.email;
347
+ resetForm();
348
+ setEmail(email);
317
349
  setEmailSubmitted(false);
318
350
  setOtpSentTo("");
319
351
  setEmailOtpResendAvailableAt(0);
320
- form.setFieldValue("password", "");
321
- form.setFieldValue("otp", "");
322
- form.setErrorMap({ onSubmit: undefined });
323
352
  };
324
- const switchAuthMethod = async () => {
325
- form.setErrorMap({ onSubmit: undefined });
326
- form.setFieldValue("password", "");
327
- form.setFieldValue("otp", "");
353
+ const switchAuthMethod = () => {
354
+ setPassword("");
355
+ setOtp("");
328
356
  if (selectedAuthMethod === "emailOtp") {
357
+ resetForm();
358
+ setEmail(formValues.email);
329
359
  setAuthMethod("password");
330
360
  setOtpSentTo("");
331
361
  setEmailOtpResendAvailableAt(0);
332
362
  return;
333
363
  }
334
- await sendEmailOtp(form.state.values.email.trim(), (message) => form.setErrorMap({ onSubmit: { form: message, fields: {} } }));
335
- };
336
- const resendEmailOtp = async () => {
337
- form.setErrorMap({ onSubmit: undefined });
338
- form.setFieldValue("otp", "");
339
- await sendEmailOtp(form.state.values.email.trim(), (message) => form.setErrorMap({ onSubmit: { form: message, fields: {} } }));
364
+ submit({ type: "sendEmailOtp" });
340
365
  };
341
- const signInWithGoogle = async () => {
342
- try {
343
- const result = await authClient.signIn.social({
344
- provider: "google",
345
- callbackURL: socialRedirectTarget,
346
- errorCallbackURL: "/sign-in",
347
- ...(oauthQuery ? { additionalData: { query: oauthQuery } } : {}),
348
- ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
349
- });
350
- if (result.error) {
351
- form.setErrorMap({
352
- onSubmit: {
353
- form: result.error.message ?? m.sign_in_error,
354
- fields: {},
355
- },
356
- });
357
- return;
358
- }
359
- if (result.data?.url)
360
- onNavigate(result.data.url);
361
- }
362
- catch {
363
- form.setErrorMap({ onSubmit: { form: m.sign_in_error, fields: {} } });
364
- }
366
+ const resendEmailOtp = () => {
367
+ setOtp("");
368
+ submit({ type: "sendEmailOtp" });
365
369
  };
366
- return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.auth_sign_in }), _jsx(CardDescription, { children: !emailSubmitted ? (m.sign_in_description) : (_jsxs(_Fragment, { children: [text(m.sign_in_email_as, { email: form.state.values.email }), " ", _jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: resetEmailStep, children: m.sign_in_change_email })] })) })] }), _jsxs(CardContent, { children: [hasPrimaryAuth ? (_jsx(form.AppForm, { children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
370
+ const signInWithGoogle = () => submit({ type: "social" });
371
+ return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.auth_sign_in }), _jsx(CardDescription, { children: !emailSubmitted ? (m.sign_in_description) : (_jsxs(_Fragment, { children: [text(m.sign_in_email_as, { email: formValues.email }), " ", _jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: resetEmailStep, children: m.sign_in_change_email })] })) })] }), _jsxs(CardContent, { children: [hasPrimaryAuth ? (_jsx(form.Initialize, { defaultValues: { email: "", password: "", otp: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
367
372
  event.preventDefault();
368
373
  event.stopPropagation();
369
- form.handleSubmit();
370
- }, children: [!emailSubmitted ? (_jsx(form.AppField, { name: "email", children: (field) => (_jsx(field.TextField, { label: m.field_email, type: "email", autoComplete: "email", onKeyDown: (event) => {
371
- if (event.key !== "Enter")
372
- return;
373
- event.preventDefault();
374
- form.handleSubmit();
375
- }, required: true })) })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.field_password, type: "password", autoComplete: "current-password", required: true })) }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [_jsx(Link, { className: authLinkClassName, to: "/forgot-password", search: searchObject(searchString), children: m.sign_in_forgot_password }), canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null] })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.AppField, { name: "otp", children: (field) => (_jsx(OtpInput, { field: field, label: m.sign_in_email_otp_code })) }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
374
+ submit({
375
+ type: "submit",
376
+ emailSubmitted,
377
+ method: selectedAuthMethod,
378
+ otpSent: Boolean(otpSentTo),
379
+ });
380
+ }, children: [!emailSubmitted ? (_jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.password, { label: m.field_password, type: "password", autoComplete: "current-password", required: true }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [_jsx(Link, { className: authLinkClassName, to: "/forgot-password", search: searchObject(searchString), children: m.sign_in_forgot_password }), canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null] })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.otp, { label: m.sign_in_email_otp_code }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
376
381
  ? text(m.sign_in_email_otp_resend_countdown, {
377
382
  seconds: String(emailOtpResendSeconds),
378
383
  })
379
- : m.sign_in_email_otp_resend })) : null, canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(KeyRound, {}), m.sign_in_use_password] })) : null] })] })) : null, _jsx(form.FormError, {}), _jsx("div", { children: _jsx(form.SubmitButton, { children: !emailSubmitted
380
- ? m.sign_in_continue
381
- : selectedAuthMethod === "emailOtp"
382
- ? m.sign_in_email_otp_verify
383
- : m.auth_sign_in }) })] }) })) : null, options.google && !emailSubmitted ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [hasPrimaryAuth ? (_jsx(Divider, { label: m.auth_or_continue_with })) : null, _jsxs(Button, { type: "button", variant: "outline", className: "w-full", onClick: signInWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, !hasPrimaryAuth && !options.google ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.oauth_client_no_auth_methods })) : null, options.signUp ? (_jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-up", search: searchObject(searchString), children: [m.sign_in_need_account, " ", m.auth_sign_up] }) })) : null] })] }));
384
+ : m.sign_in_email_otp_resend })) : null, canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(KeyRound, {}), m.sign_in_use_password] })) : null] })] })) : null, _jsx(SubmitError, { result: submitResult }), _jsx("div", { children: _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, !emailSubmitted
385
+ ? m.sign_in_continue
386
+ : selectedAuthMethod === "emailOtp"
387
+ ? m.sign_in_email_otp_verify
388
+ : m.auth_sign_in] }) })] }) })) : null, options.google && !emailSubmitted ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [hasPrimaryAuth ? (_jsx(Divider, { label: m.auth_or_continue_with })) : null, _jsxs(Button, { type: "button", variant: "outline", className: "w-full", disabled: submitResult.waiting, onClick: signInWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, !hasPrimaryAuth && !options.google ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.oauth_client_no_auth_methods })) : null, options.signUp ? (_jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-up", search: searchObject(searchString), children: [m.sign_in_need_account, " ", m.auth_sign_up] }) })) : null] })] }));
384
389
  }
385
390
  export function Signup(props) {
386
391
  const { authClient, baseUrl, labels: m, projectConfig: providedProjectConfig, } = useAuthFormOptions(props);
@@ -401,17 +406,27 @@ export function Signup(props) {
401
406
  signUp: authOptions?.signUp ?? true,
402
407
  signUpName: authOptions?.signUpName ?? true,
403
408
  };
404
- const form = useAppForm({
405
- defaultValues: { name: "", email: "", password: "" },
406
- onSubmit: async ({ value, formApi }) => {
407
- formApi.setErrorMap({ onSubmit: undefined });
408
- if (!options.signUp) {
409
- formApi.setErrorMap({
410
- onSubmit: { form: m.sign_up_disabled_description, fields: {} },
411
- });
412
- return;
413
- }
414
- try {
409
+ const [form] = useState(() => FormReact.make(signupFormBuilder, {
410
+ fields: { name: TextField, email: TextField, password: TextField },
411
+ mode: { validation: "onSubmit" },
412
+ onSubmit: (action, { decoded: value }) => Effect.tryPromise({
413
+ try: async () => {
414
+ if (action === "social") {
415
+ const result = await authClient.signIn.social({
416
+ provider: "google",
417
+ callbackURL: redirectTarget,
418
+ errorCallbackURL: "/sign-up",
419
+ });
420
+ if (result.error) {
421
+ throw new Error(result.error.message ?? m.sign_up_error);
422
+ }
423
+ if (result.data?.url)
424
+ onNavigate(result.data.url);
425
+ return;
426
+ }
427
+ if (!options.signUp) {
428
+ throw new Error(m.sign_up_disabled_description);
429
+ }
415
430
  const result = await authClient.signUp.email({
416
431
  name: options.signUpName
417
432
  ? value.name.trim()
@@ -420,54 +435,24 @@ export function Signup(props) {
420
435
  password: value.password,
421
436
  });
422
437
  if (result.error) {
423
- formApi.setErrorMap({
424
- onSubmit: {
425
- form: result.error.message ?? m.sign_up_error,
426
- fields: {},
427
- },
428
- });
429
- return;
438
+ throw new Error(result.error.message ?? m.sign_up_error);
430
439
  }
431
440
  onVerifyEmail(value.email.trim());
432
- }
433
- catch {
434
- formApi.setErrorMap({
435
- onSubmit: { form: m.sign_up_error, fields: {} },
436
- });
437
- }
438
- },
439
- });
440
- const signUpWithGoogle = async () => {
441
- try {
442
- const result = await authClient.signIn.social({
443
- provider: "google",
444
- callbackURL: redirectTarget,
445
- errorCallbackURL: "/sign-up",
446
- });
447
- if (result.error) {
448
- form.setErrorMap({
449
- onSubmit: {
450
- form: result.error.message ?? m.sign_up_error,
451
- fields: {},
452
- },
453
- });
454
- return;
455
- }
456
- if (result.data?.url)
457
- onNavigate(result.data.url);
458
- }
459
- catch {
460
- form.setErrorMap({ onSubmit: { form: m.sign_up_error, fields: {} } });
461
- }
462
- };
441
+ },
442
+ catch: (cause) => cause instanceof Error ? cause : new Error(m.sign_up_error),
443
+ }),
444
+ }));
445
+ const submit = useAtomSet(form.submit);
446
+ const submitResult = useAtomValue(form.submit);
447
+ const signUpWithGoogle = () => submit("social");
463
448
  if (!options.signUp) {
464
449
  return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_disabled_title }), _jsx(CardDescription, { children: m.sign_up_disabled_description })] }), _jsx(CardContent, { children: _jsx("p", { className: "text-muted-foreground text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-in", search: searchObject(searchString), children: [m.sign_up_have_account, " ", m.auth_sign_in] }) }) })] }));
465
450
  }
466
- return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_title }), _jsx(CardDescription, { children: m.sign_up_description })] }), _jsxs(CardContent, { children: [_jsx(form.AppForm, { children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
451
+ return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.sign_up_title }), _jsx(CardDescription, { children: m.sign_up_description })] }), _jsxs(CardContent, { children: [_jsx(form.Initialize, { defaultValues: { name: "", email: "", password: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
467
452
  event.preventDefault();
468
453
  event.stopPropagation();
469
- form.handleSubmit();
470
- }, children: [options.signUpName ? (_jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.field_name, autoComplete: "name", required: true })) })) : null, _jsx(form.AppField, { name: "email", children: (field) => (_jsx(field.TextField, { label: m.field_email, type: "email", autoComplete: "email", required: true })) }), _jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.field_password, type: "password", autoComplete: "new-password", minLength: 8, required: true })) }), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }), options.google ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [_jsx(Divider, { label: m.auth_or_continue_with }), _jsxs(Button, { type: "button", variant: "outline", className: "w-full", onClick: signUpWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-in", search: searchObject(searchString), children: [m.sign_up_have_account, " ", m.auth_sign_in] }) })] })] }));
454
+ submit("email");
455
+ }, children: [options.signUpName ? (_jsx(form.name, { label: m.field_name, autoComplete: "name", required: true })) : null, _jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true }), _jsx(form.password, { label: m.field_password, type: "password", autoComplete: "new-password", minLength: 8, required: true }), _jsx(SubmitError, { result: submitResult }), _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] })] }) }), options.google ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [_jsx(Divider, { label: m.auth_or_continue_with }), _jsxs(Button, { type: "button", variant: "outline", className: "w-full", disabled: submitResult.waiting, onClick: signUpWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsxs(Link, { className: authLinkClassName, to: "/sign-in", search: searchObject(searchString), children: [m.sign_up_have_account, " ", m.auth_sign_in] }) })] })] }));
471
456
  }
472
457
  export function VerifyEmail(props) {
473
458
  const { authClient, baseUrl, labels: m, projectConfig: providedProjectConfig, } = useAuthFormOptions(props);
@@ -479,54 +464,49 @@ export function VerifyEmail(props) {
479
464
  const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
480
465
  const onNavigate = (target) => navigateTarget(target, navigate);
481
466
  const [resent, setResent] = useState(false);
482
- const form = useAppForm({
483
- defaultValues: {
484
- email: getSearchParam(searchString, "email") ?? "",
485
- otp: "",
486
- },
487
- onSubmit: async ({ value, formApi }) => {
488
- formApi.setErrorMap({ onSubmit: undefined });
489
- const result = await authClient.emailOtp.verifyEmail({
490
- email: value.email.trim(),
491
- otp: value.otp.trim(),
492
- });
493
- if (result.error) {
494
- formApi.setErrorMap({
495
- onSubmit: {
496
- form: result.error.message ?? m.verify_email_error,
497
- fields: {},
498
- },
467
+ const [form] = useState(() => FormReact.make(verifyEmailFormBuilder, {
468
+ fields: { email: TextField, otp: OtpField },
469
+ mode: { validation: "onSubmit" },
470
+ onSubmit: (action, { decoded: value }) => Effect.tryPromise({
471
+ try: async () => {
472
+ if (action === "resend") {
473
+ const result = await authClient.emailOtp.sendVerificationOtp({
474
+ email: value.email.trim(),
475
+ type: "email-verification",
476
+ });
477
+ if (result.error) {
478
+ throw new Error(result.error.message ?? m.verify_email_resend_error);
479
+ }
480
+ setResent(true);
481
+ return;
482
+ }
483
+ const result = await authClient.emailOtp.verifyEmail({
484
+ email: value.email.trim(),
485
+ otp: value.otp.trim(),
499
486
  });
500
- return;
501
- }
502
- onNavigate(redirectTarget);
503
- },
504
- });
505
- const resendCode = async () => {
506
- form.setErrorMap({ onSubmit: undefined });
507
- const result = await authClient.emailOtp.sendVerificationOtp({
508
- email: form.state.values.email.trim(),
509
- type: "email-verification",
510
- });
511
- if (result.error) {
512
- form.setErrorMap({
513
- onSubmit: {
514
- form: result.error.message ?? m.verify_email_resend_error,
515
- fields: {},
516
- },
517
- });
518
- return;
519
- }
520
- setResent(true);
521
- };
522
- return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.verify_email_title }), _jsx(CardDescription, { children: m.verify_email_description })] }), _jsxs(CardContent, { children: [_jsx(form.AppForm, { children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
487
+ if (result.error) {
488
+ throw new Error(result.error.message ?? m.verify_email_error);
489
+ }
490
+ onNavigate(redirectTarget);
491
+ },
492
+ catch: (cause) => cause instanceof Error
493
+ ? cause
494
+ : new Error(action === "resend"
495
+ ? m.verify_email_resend_error
496
+ : m.verify_email_error),
497
+ }),
498
+ }));
499
+ const submit = useAtomSet(form.submit);
500
+ const submitResult = useAtomValue(form.submit);
501
+ const resendCode = () => submit("resend");
502
+ return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.verify_email_title }), _jsx(CardDescription, { children: m.verify_email_description })] }), _jsxs(CardContent, { children: [_jsx(form.Initialize, { defaultValues: {
503
+ email: getSearchParam(searchString, "email") ?? "",
504
+ otp: "",
505
+ }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
523
506
  event.preventDefault();
524
507
  event.stopPropagation();
525
- form.handleSubmit();
526
- }, children: [_jsx(form.AppField, { name: "email", children: (field) => (_jsx(field.TextField, { label: m.field_email, type: "email", autoComplete: "email", required: true })) }), _jsx(form.AppField, { name: "otp", children: (field) => {
527
- const invalid = !field.state.meta.isValid;
528
- return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.name, children: m.verify_email_code }), _jsxs(InputOTP, { id: field.name, name: field.name, maxLength: 6, value: field.state.value ?? "", onChange: (value) => field.handleChange(value), onBlur: field.handleBlur, autoComplete: "one-time-code", inputMode: "numeric", pattern: REGEXP_ONLY_DIGITS, required: true, children: [_jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 0, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 1, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 2, "aria-invalid": invalid })] }), _jsx(InputOTPSeparator, {}), _jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 3, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 4, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 5, "aria-invalid": invalid })] })] }), _jsx(FieldError, { errors: field.getMeta().errors })] }));
529
- } }), _jsx(form.FormError, {}), resent ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.verify_email_resent })) : null, _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsx(form.SubmitButton, {}), _jsx(Button, { type: "button", variant: "ghost", onClick: resendCode, children: m.verify_email_resend })] })] }) }), _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsx(Link, { className: authLinkClassName, to: "/sign-in", children: m.forgot_password_back_to_sign_in }) })] })] }));
508
+ submit("verify");
509
+ }, children: [_jsx(form.email, { label: m.field_email, type: "email", autoComplete: "email", required: true }), _jsx(form.otp, { label: m.verify_email_code }), _jsx(SubmitError, { result: submitResult }), resent ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.verify_email_resent })) : null, _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] }), _jsx(Button, { type: "button", variant: "ghost", disabled: submitResult.waiting, onClick: resendCode, children: m.verify_email_resend })] })] }) }), _jsx("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: _jsx(Link, { className: authLinkClassName, to: "/sign-in", children: m.forgot_password_back_to_sign_in }) })] })] }));
530
510
  }
531
511
  export function ResetPassword(props) {
532
512
  const { authClient, labels: m } = useAuthFormOptions(props);
@@ -536,37 +516,32 @@ export function ResetPassword(props) {
536
516
  });
537
517
  const token = getSearchParam(searchString, "token") ?? "";
538
518
  const onSuccess = () => navigate({ to: "/sign-in" });
539
- const form = useAppForm({
540
- defaultValues: { password: "" },
541
- onSubmit: async ({ value, formApi }) => {
542
- formApi.setErrorMap({ onSubmit: undefined });
543
- if (!token) {
544
- formApi.setErrorMap({
545
- onSubmit: { form: m.reset_password_missing_token, fields: {} },
519
+ const [form] = useState(() => FormReact.make(resetPasswordFormBuilder, {
520
+ fields: { password: TextField },
521
+ mode: { validation: "onSubmit" },
522
+ onSubmit: (_, { decoded: value }) => Effect.tryPromise({
523
+ try: async () => {
524
+ if (!token)
525
+ throw new Error(m.reset_password_missing_token);
526
+ const result = await authClient.resetPassword({
527
+ newPassword: value.password,
528
+ token,
546
529
  });
547
- return;
548
- }
549
- const result = await authClient.resetPassword({
550
- newPassword: value.password,
551
- token,
552
- });
553
- if (result.error) {
554
- formApi.setErrorMap({
555
- onSubmit: {
556
- form: result.error.message ?? m.reset_password_error,
557
- fields: {},
558
- },
559
- });
560
- return;
561
- }
562
- onSuccess();
563
- },
564
- });
565
- return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.reset_password_title }), _jsx(CardDescription, { children: m.reset_password_description })] }), _jsx(CardContent, { children: _jsx(form.AppForm, { children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
530
+ if (result.error) {
531
+ throw new Error(result.error.message ?? m.reset_password_error);
532
+ }
533
+ onSuccess();
534
+ },
535
+ catch: (cause) => cause instanceof Error ? cause : new Error(m.reset_password_error),
536
+ }),
537
+ }));
538
+ const submit = useAtomSet(form.submit);
539
+ const submitResult = useAtomValue(form.submit);
540
+ return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.reset_password_title }), _jsx(CardDescription, { children: m.reset_password_description })] }), _jsx(CardContent, { children: _jsx(form.Initialize, { defaultValues: { password: "" }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
566
541
  event.preventDefault();
567
542
  event.stopPropagation();
568
- form.handleSubmit();
569
- }, children: [_jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.reset_password_new_password, type: "password", autoComplete: "new-password", minLength: 8, required: true })) }), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }) })] }));
543
+ submit();
544
+ }, children: [_jsx(form.password, { label: m.reset_password_new_password, type: "password", autoComplete: "new-password", minLength: 8, required: true }), _jsx(SubmitError, { result: submitResult }), _jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] })] }) }) })] }));
570
545
  }
571
546
  export function TwoFactor(props) {
572
547
  const { authClient, baseUrl, labels: m, projectConfig: providedProjectConfig, } = useAuthFormOptions(props);
@@ -580,72 +555,79 @@ export function TwoFactor(props) {
580
555
  const onNavigate = (target) => navigateTarget(target, navigate);
581
556
  const [mode, setMode] = useState("totp");
582
557
  const [emailCodeSent, setEmailCodeSent] = useState(false);
583
- const form = useAppForm({
584
- defaultValues: { code: "", trustDevice: true },
585
- onSubmit: async ({ value, formApi }) => {
586
- formApi.setErrorMap({ onSubmit: undefined });
587
- const code = value.code.trim();
588
- const result = mode === "backup"
589
- ? await authClient.twoFactor.verifyBackupCode({
590
- code,
591
- trustDevice: value.trustDevice,
592
- ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
593
- })
594
- : mode === "email"
595
- ? await authClient.twoFactor.verifyOtp({
558
+ const [form] = useState(() => FormReact.make(twoFactorFormBuilder, {
559
+ fields: { code: AuthCodeField, trustDevice: CheckboxField },
560
+ mode: { validation: "onSubmit" },
561
+ onSubmit: (action, { decoded: value }) => Effect.tryPromise({
562
+ try: async () => {
563
+ if (action.type === "sendEmailCode") {
564
+ const result = await authClient.twoFactor.sendOtp();
565
+ if (result.error) {
566
+ throw new Error(result.error.message ?? m.two_factor_send_email_code_error);
567
+ }
568
+ setEmailCodeSent(true);
569
+ setMode("email");
570
+ return;
571
+ }
572
+ const code = value.code.trim();
573
+ const result = action.mode === "backup"
574
+ ? await authClient.twoFactor.verifyBackupCode({
596
575
  code,
597
576
  trustDevice: value.trustDevice,
598
577
  ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
599
578
  })
600
- : await authClient.twoFactor.verifyTotp({
601
- code,
602
- trustDevice: value.trustDevice,
603
- ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
604
- });
605
- if (result.error) {
606
- formApi.setErrorMap({
607
- onSubmit: {
608
- form: result.error.message ?? m.two_factor_verify_error,
609
- fields: {},
610
- },
611
- });
612
- return;
613
- }
614
- onNavigate(getResultRedirectUrl(result.data) ?? redirectTarget);
615
- },
616
- });
617
- const sendEmailCode = async () => {
618
- form.setErrorMap({ onSubmit: undefined });
619
- const result = await authClient.twoFactor.sendOtp();
620
- if (result.error) {
621
- form.setErrorMap({
622
- onSubmit: {
623
- form: result.error.message ?? m.two_factor_send_email_code_error,
624
- fields: {},
625
- },
626
- });
627
- return;
628
- }
629
- setEmailCodeSent(true);
630
- setMode("email");
631
- };
579
+ : action.mode === "email"
580
+ ? await authClient.twoFactor.verifyOtp({
581
+ code,
582
+ trustDevice: value.trustDevice,
583
+ ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
584
+ })
585
+ : await authClient.twoFactor.verifyTotp({
586
+ code,
587
+ trustDevice: value.trustDevice,
588
+ ...(oauthQuery ? { oauth_query: oauthQuery } : {}),
589
+ });
590
+ if (result.error) {
591
+ throw new Error(result.error.message ?? m.two_factor_verify_error);
592
+ }
593
+ onNavigate(getResultRedirectUrl(result.data) ?? redirectTarget);
594
+ },
595
+ catch: (cause) => cause instanceof Error
596
+ ? cause
597
+ : new Error(action.type === "sendEmailCode"
598
+ ? m.two_factor_send_email_code_error
599
+ : m.two_factor_verify_error),
600
+ }),
601
+ }));
602
+ const submit = useAtomSet(form.submit);
603
+ const submitResult = useAtomValue(form.submit);
604
+ const sendEmailCode = () => submit({ type: "sendEmailCode" });
632
605
  return (_jsxs(Card, { className: "w-full max-w-md", children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { className: "text-3xl", children: m.two_factor_title }), _jsx(CardDescription, { children: mode === "backup"
633
606
  ? m.two_factor_verify_backup_description
634
607
  : mode === "email"
635
608
  ? m.two_factor_verify_email_description
636
- : m.two_factor_verify_description })] }), _jsx(CardContent, { children: _jsx(form.AppForm, { children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
609
+ : m.two_factor_verify_description })] }), _jsx(CardContent, { children: _jsx(form.Initialize, { defaultValues: { code: "", trustDevice: true }, children: _jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
637
610
  event.preventDefault();
638
611
  event.stopPropagation();
639
- form.handleSubmit();
640
- }, children: [_jsx(form.AppField, { name: "code", children: (field) => mode === "backup" ? (_jsx(field.TextField, { label: m.two_factor_backup_code, autoComplete: "one-time-code", required: true })) : (_jsx(OtpInput, { field: field, label: mode === "email"
612
+ submit({ type: "verify", mode });
613
+ }, children: [_jsx(form.code, { autoComplete: "one-time-code", label: mode === "backup"
614
+ ? m.two_factor_backup_code
615
+ : mode === "email"
641
616
  ? m.two_factor_email_code
642
- : m.two_factor_code })) }), _jsx(form.AppField, { name: "trustDevice", children: (field) => (_jsx(field.CheckboxField, { label: m.two_factor_trust_device })) }), _jsx(form.FormError, {}), emailCodeSent && mode === "email" ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.two_factor_email_code_sent })) : null, _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsx(form.SubmitButton, {}), _jsx(Button, { type: "button", variant: "ghost", onClick: sendEmailCode, children: m.two_factor_send_email_code }), _jsx(Button, { type: "button", variant: "ghost", onClick: () => setMode(mode === "backup" ? "totp" : "backup"), children: mode === "backup"
617
+ : m.two_factor_code, otp: mode !== "backup", required: true }), _jsx(form.trustDevice, { label: m.two_factor_trust_device }), _jsx(SubmitError, { result: submitResult }), emailCodeSent && mode === "email" ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.two_factor_email_code_sent })) : null, _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsxs(Button, { type: "submit", disabled: submitResult.waiting, children: [submitResult.waiting ? (_jsx(Loader2, { className: "animate-spin", "data-icon": "inline-start" })) : null, effectFormMessages().submit] }), _jsx(Button, { type: "button", variant: "ghost", disabled: submitResult.waiting, onClick: sendEmailCode, children: m.two_factor_send_email_code }), _jsx(Button, { type: "button", variant: "ghost", onClick: () => setMode(mode === "backup" ? "totp" : "backup"), children: mode === "backup"
643
618
  ? m.two_factor_use_totp
644
619
  : m.two_factor_use_backup_code })] })] }) }) })] }));
645
620
  }
646
- const OtpInput = ({ field, label }) => {
647
- const invalid = !field.state.meta.isValid;
648
- return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.name, children: label }), _jsxs(InputOTP, { id: field.name, name: field.name, maxLength: 6, value: field.state.value ?? "", onChange: (value) => field.handleChange(value), onBlur: field.handleBlur, autoComplete: "one-time-code", inputMode: "numeric", pattern: REGEXP_ONLY_DIGITS, required: true, children: [_jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 0, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 1, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 2, "aria-invalid": invalid })] }), _jsx(InputOTPSeparator, {}), _jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 3, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 4, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 5, "aria-invalid": invalid })] })] }), _jsx(FieldError, { errors: field.getMeta().errors ?? [] })] }));
621
+ const OtpField = ({ field, props, }) => {
622
+ const invalid = Option.isSome(field.error);
623
+ return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.path, children: props.label }), _jsxs(InputOTP, { id: field.path, name: field.path, maxLength: 6, value: field.value, onChange: field.onChange, onBlur: field.onBlur, autoComplete: "one-time-code", inputMode: "numeric", pattern: REGEXP_ONLY_DIGITS, required: true, children: [_jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 0, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 1, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 2, "aria-invalid": invalid })] }), _jsx(InputOTPSeparator, {}), _jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 3, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 4, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 5, "aria-invalid": invalid })] })] }), Option.isSome(field.error) ? (_jsx(ErrorMessage, { text: field.error.value })) : null] }));
624
+ };
625
+ const AuthCodeField = ({ field, props }) => {
626
+ if (props.otp) {
627
+ return _jsx(OtpField, { field: field, props: { label: props.label } });
628
+ }
629
+ const { otp: _, ...textFieldProps } = props;
630
+ return _jsx(TextField, { field: field, props: textFieldProps });
649
631
  };
650
632
  const Divider = ({ label }) => (_jsxs("div", { className: "text-muted-foreground flex items-center gap-3 text-xs", children: [_jsx("span", { className: "bg-border h-px flex-1" }), label, _jsx("span", { className: "bg-border h-px flex-1" })] }));
651
633
  const GoogleLogo = () => (_jsxs("svg", { "aria-hidden": "true", className: "size-[18px]", viewBox: "0 0 18 18", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M17.64 9.204c0-.638-.057-1.252-.164-1.84H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.874 2.684-6.616Z", fill: "#4285F4" }), _jsx("path", { d: "M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.583-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18Z", fill: "#34A853" }), _jsx("path", { d: "M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332Z", fill: "#FBBC05" }), _jsx("path", { d: "M9 3.58c1.321 0 2.508.454 3.44 1.346l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.162 6.656 3.58 9 3.58Z", fill: "#EA4335" })] }));