@tomny-dev/uzi 0.13.0-pr.108.367.1.13f0f3b → 0.13.0
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthPage.d.ts","sourceRoot":"","sources":["../../../src/components/auth-page/AuthPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAuC,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK3F,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mFAAmF;IACnF,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,kFAAkF;IAClF,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxC,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACxE,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACxE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACnD,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,Q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CHANGED
|
@@ -216,6 +216,11 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
216
216
|
role: "alert",
|
|
217
217
|
children: serverError
|
|
218
218
|
}),
|
|
219
|
+
!(signup ? onSignUp : onSignIn) && /* @__PURE__ */ jsx("p", {
|
|
220
|
+
className: auth_page_module_default.error,
|
|
221
|
+
role: "status",
|
|
222
|
+
children: signup ? "Sign-up is not available." : "Sign-in is not available."
|
|
223
|
+
}),
|
|
219
224
|
/* @__PURE__ */ jsx(Button, {
|
|
220
225
|
type: "submit",
|
|
221
226
|
variant: "primary",
|
package/dist/index68.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index68.js","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPassword, setConfirmPassword] = React.useState(\"\");\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(\"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = \"Email is required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && password !== confirmPassword) nextErrors.confirm = \"Passwords do not match\";\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials = { email: normalizedEmail, password };\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label=\"Email\" error={errors.email}>\n <Input\n id={emailId} type=\"email\" placeholder=\"you@example.com\" value={email}\n autoComplete=\"email\" required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPassword}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAmDA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;CACjD,MAAM,CAAC,iBAAiB,sBAAsB,MAAM,SAAS,EAAE;CAC/D,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAC5D,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,KAAK;CAClD,MAAM,aAAa,MAAM,OAAO,KAAK;CACrC,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAiC,CAAC,CAAC;CACrE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,EAAE;CACvD,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,UAAU,KAAK;CACrB,MAAM,aAAa,KAAK;CACxB,MAAM,YAAY,KAAK;CACvB,MAAM,UAAU,KAAK;CACrB,MAAM,SAAS,SAAS;CACxB,MAAM,gBAAgB,UAAU,CAAC,CAAC,eAAe;CACjD,MAAM,YAAY,CAAC,CAAC,gBAAiB,CAAC,CAAC,YAAY,CAAC,CAAC;CAErD,MAAM,gBAAgB;EAEpB,IAAI,cAAc,UAA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AQ,MAAK;KAAS,SAAQ;KAAU,MAAK;KAAK,UAAU,YAAY,YAAY,SAAS,CAAC,WAAW,CAAC;eACvG,UAAW,SAAS,wBAAwB,kBAAoB,SAAS,mBAAmB;IACvF,CAAA;GACA;IACF;;AAEd"}
|
|
1
|
+
{"version":3,"file":"index68.js","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPassword, setConfirmPassword] = React.useState(\"\");\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(\"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = \"Email is required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && password !== confirmPassword) nextErrors.confirm = \"Passwords do not match\";\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials = { email: normalizedEmail, password };\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label=\"Email\" error={errors.email}>\n <Input\n id={emailId} type=\"email\" placeholder=\"you@example.com\" value={email}\n autoComplete=\"email\" required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPassword}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n {!(signup ? onSignUp : onSignIn) && (\n <p className={styles.error} role=\"status\">\n {signup ? \"Sign-up is not available.\" : \"Sign-in is not available.\"}\n </p>\n )}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\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AAU,YAAY,YAAY,SAAS,CAAC,WAAW,CAAC;eACvG,UAAW,SAAS,wBAAwB,kBAAoB,SAAS,mBAAmB;IACvF,CAAA;GACA;IACF;;AAEd"}
|
package/dist/index69.cjs
CHANGED
|
@@ -218,6 +218,11 @@ function AuthPage({ brand, signInTitle = "Welcome back", signUpTitle = "Create y
|
|
|
218
218
|
role: "alert",
|
|
219
219
|
children: serverError
|
|
220
220
|
}),
|
|
221
|
+
!(signup ? onSignUp : onSignIn) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
222
|
+
className: require_auth_page_module.default.error,
|
|
223
|
+
role: "status",
|
|
224
|
+
children: signup ? "Sign-up is not available." : "Sign-in is not available."
|
|
225
|
+
}),
|
|
221
226
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
|
|
222
227
|
type: "submit",
|
|
223
228
|
variant: "primary",
|
package/dist/index69.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index69.cjs","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPassword, setConfirmPassword] = React.useState(\"\");\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(\"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = \"Email is required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && password !== confirmPassword) nextErrors.confirm = \"Passwords do not match\";\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials = { email: normalizedEmail, password };\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label=\"Email\" error={errors.email}>\n <Input\n id={emailId} type=\"email\" placeholder=\"you@example.com\" value={email}\n autoComplete=\"email\" required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPassword}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmDA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;CACjD,MAAM,CAAC,iBAAiB,sBAAsB,MAAM,SAAS,EAAE;CAC/D,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAS,KAAK;CAC5D,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,KAAK;CAClD,MAAM,aAAa,MAAM,OAAO,KAAK;CACrC,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAiC,CAAC,CAAC;CACrE,MAAM,CAAC,aAAa,kBAAkB,MAAM,SAAS,EAAE;CACvD,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,UAAU,KAAK;CACrB,MAAM,aAAa,KAAK;CACxB,MAAM,YAAY,KAAK;CACvB,MAAM,UAAU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OAAO;OAAO,oBAAkB,OAAO,QAAQ,UAAU,WAAW,KAAA;OACpF,WAAW,UAAU;QAAE,iBAAiB,MAAM,OAAO,OAAO;QAAG,WAAW,SAAS;SAAE,GAAG;SAAK,OAAO;QAAG,EAAE;OAAG;MAAI,CAAA,GAClH,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD,EAAA,UAAA,CAAO,eAAe,cAAc,mBACjC,eAAe,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;OAAG,MAAM,cAAc;iBAAW;MAAmB,CAAA,IAAI,kBACjF,EAAA,CAAA,CACD;SACN,OAAO,SAAS,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;MAAG,WAAW,yBAAA,QAAO;MAAO,IAAI,UAAU;MAAU,MAAK;gBAAS,OAAO;KAAS,CAAA,CAChG;;IAEN,CAAC,UAAU,sBAAsB,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAW,yBAAA,QAAO;KAAQ,MAAM;eAAoB;IAAmB,CAAA;IAC3G,eAAe,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;KAAG,WAAW,yBAAA,QAAO;KAAO,MAAK;eAAS;IAAe,CAAA;IACzE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,QAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,MAAK;KAAK,UAAU,YAAY,YAAY,SAAS,CAAC,WAAW,CAAC;eACvG,UAAW,SAAS,wBAAwB,kBAAoB,SAAS,mBAAmB;IACvF,CAAA;GACA;IACF;;AAEd"}
|
|
1
|
+
{"version":3,"file":"index69.cjs","names":[],"sources":["../src/components/auth-page/AuthPage.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { AuthCard } from \"../auth-card/AuthCard\";\nimport { AuthField, AuthForm, AuthModeSwitch, type AuthMode } from \"../auth-form/AuthForm\";\nimport { Input } from \"../input/Input\";\nimport { Button } from \"../button/Button\";\nimport styles from \"./auth-page.module.css\";\n\nexport interface AuthCredentials {\n email: string;\n password: string;\n}\n\nexport interface AuthPageProps {\n /** Brand/logo above the form. */\n brand?: React.ReactNode;\n /** Title for each mode. */\n signInTitle?: string;\n signUpTitle?: string;\n signInSubtitle?: string;\n signUpSubtitle?: string;\n /** Initial tab; changes to this prop after mount do not reset the selected tab. */\n defaultMode?: AuthMode;\n /** Optional controlled tab, e.g. when sign-in and sign-up use separate routes. */\n mode?: AuthMode;\n onModeChange?: (mode: AuthMode) => void;\n /** App-specific auth callbacks; throwing an Error displays an inline failure. */\n onSignIn?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onSignUp?: (credentials: AuthCredentials) => Promise<unknown> | unknown;\n onError?: (error: unknown, mode: AuthMode) => void;\n /** Prefill email without ever populating a password. */\n initialEmail?: string;\n /** Prevent submission until the app's authentication provider is ready. */\n disabled?: boolean;\n /** Minimum password length for account creation; default 8. */\n minPasswordLength?: number;\n /** Optional terms requirement for sign-up only. */\n signUpOptions?: {\n requireTerms?: boolean;\n termsHref?: string;\n termsLabel?: string;\n };\n /** Optional app-owned password recovery route. */\n forgotPasswordHref?: string;\n className?: string;\n layout?: \"fullscreen\" | \"embedded\";\n}\n\n/**\n * Complete app-neutral authentication UX. Uzi owns UI state and validation;\n * the consuming application owns credentials, sessions, API calls and redirects.\n */\nexport function AuthPage({\n brand,\n signInTitle = \"Welcome back\",\n signUpTitle = \"Create your account\",\n signInSubtitle,\n signUpSubtitle,\n defaultMode = \"signin\",\n mode: controlledMode,\n onModeChange,\n onSignIn,\n onSignUp,\n onError,\n initialEmail = \"\",\n disabled = false,\n minPasswordLength = 8,\n signUpOptions,\n forgotPasswordHref,\n className,\n layout = \"fullscreen\",\n}: AuthPageProps) {\n const [internalMode, setInternalMode] = React.useState<AuthMode>(defaultMode);\n const mode = controlledMode ?? internalMode;\n const [email, setEmail] = React.useState(initialEmail);\n const [password, setPassword] = React.useState(\"\");\n const [confirmPassword, setConfirmPassword] = React.useState(\"\");\n const [acceptedTerms, setAcceptedTerms] = React.useState(false);\n const [showPassword, setShowPassword] = React.useState(false);\n const [pending, setPending] = React.useState(false);\n const pendingRef = React.useRef(false);\n const [errors, setErrors] = React.useState<Record<string, string>>({});\n const [serverError, setServerError] = React.useState(\"\");\n const id = React.useId();\n const emailId = id + \"-email\";\n const passwordId = id + \"-password\";\n const confirmId = id + \"-confirm\";\n const termsId = id + \"-terms\";\n const signup = mode === \"signup\";\n const termsRequired = signup && !!signUpOptions?.requireTerms;\n const canSwitch = !!onModeChange || (!!onSignIn && !!onSignUp);\n\n React.useEffect(() => {\n // Changes from an authenticated account may prefill the email after hydration.\n if (initialEmail) setEmail((previous) => previous || initialEmail);\n }, [initialEmail]);\n\n const switchMode = (next: AuthMode) => {\n if (pendingRef.current || next === mode) return;\n setInternalMode(next);\n setPassword(\"\");\n setConfirmPassword(\"\");\n setShowPassword(false);\n setErrors({});\n setServerError(\"\");\n onModeChange?.(next);\n };\n\n const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (pendingRef.current || disabled) return;\n const nextErrors: Record<string, string> = {};\n const normalizedEmail = email.trim();\n if (!normalizedEmail) nextErrors.email = \"Email is required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(normalizedEmail)) nextErrors.email = \"Enter a valid email address\";\n if (!password) nextErrors.password = \"Password is required\";\n else if (signup && password.length < minPasswordLength) nextErrors.password = `Use at least ${minPasswordLength} characters`;\n if (signup && password !== confirmPassword) nextErrors.confirm = \"Passwords do not match\";\n if (termsRequired && !acceptedTerms) nextErrors.terms = \"Accept the terms to continue\";\n setErrors(nextErrors);\n setServerError(\"\");\n if (Object.keys(nextErrors).length) return;\n\n pendingRef.current = true;\n setPending(true);\n try {\n const credentials = { email: normalizedEmail, password };\n if (signup) {\n if (!onSignUp) return;\n await onSignUp(credentials);\n } else {\n if (!onSignIn) return;\n await onSignIn(credentials);\n }\n setPassword(\"\");\n setConfirmPassword(\"\");\n } catch (error) {\n setServerError(error instanceof Error && error.message ? error.message : \"Unable to complete the request. Try again.\");\n onError?.(error, mode);\n } finally {\n pendingRef.current = false;\n setPending(false);\n }\n };\n\n return (\n <AuthCard\n className={className}\n layout={layout}\n brand={brand}\n title={signup ? signUpTitle : signInTitle}\n subtitle={signup ? signUpSubtitle : signInSubtitle}\n >\n {canSwitch && <AuthModeSwitch mode={mode} onModeChange={switchMode} />}\n <AuthForm onSubmit={submit} noValidate aria-busy={pending}>\n <AuthField htmlFor={emailId} label=\"Email\" error={errors.email}>\n <Input\n id={emailId} type=\"email\" placeholder=\"you@example.com\" value={email}\n autoComplete=\"email\" required disabled={disabled || pending}\n aria-invalid={!!errors.email} aria-describedby={errors.email ? emailId + \"-error\" : undefined}\n onChange={(event) => { setEmail(event.target.value); setErrors((old) => ({ ...old, email: \"\" })); }}\n />\n </AuthField>\n <AuthField htmlFor={passwordId} label=\"Password\" error={errors.password}>\n <div className={styles.passwordRow}>\n <Input\n id={passwordId} type={showPassword ? \"text\" : \"password\"}\n placeholder={signup ? \"At least \" + minPasswordLength + \" characters\" : \"Enter your password\"}\n value={password} required disabled={disabled || pending}\n autoComplete={signup ? \"new-password\" : \"current-password\"}\n aria-invalid={!!errors.password} aria-describedby={errors.password ? passwordId + \"-error\" : undefined}\n onChange={(event) => { setPassword(event.target.value); setErrors((old) => ({ ...old, password: \"\" })); }}\n />\n <button type=\"button\" className={styles.visibility} disabled={disabled || pending}\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n aria-controls={passwordId} aria-pressed={showPassword}\n onClick={() => setShowPassword((old) => !old)}>\n {showPassword ? \"Hide\" : \"Show\"}\n </button>\n </div>\n </AuthField>\n {signup && (\n <AuthField htmlFor={confirmId} label=\"Confirm password\" error={errors.confirm}>\n <Input id={confirmId} type=\"password\" placeholder=\"Re-enter password\" value={confirmPassword}\n autoComplete=\"new-password\" required disabled={disabled || pending}\n aria-invalid={!!errors.confirm} aria-describedby={errors.confirm ? confirmId + \"-error\" : undefined}\n onChange={(event) => { setConfirmPassword(event.target.value); setErrors((old) => ({ ...old, confirm: \"\" })); }} />\n </AuthField>\n )}\n {termsRequired && (\n <div className={styles.terms}>\n <label htmlFor={termsId} className={styles.termsLabel}>\n <input id={termsId} type=\"checkbox\" checked={acceptedTerms} disabled={disabled || pending}\n aria-invalid={!!errors.terms} aria-describedby={errors.terms ? termsId + \"-error\" : undefined}\n onChange={(event) => { setAcceptedTerms(event.target.checked); setErrors((old) => ({ ...old, terms: \"\" })); }} />\n <span>{signUpOptions?.termsLabel ?? \"I agree to the \"}\n {signUpOptions?.termsHref ? <a href={signUpOptions.termsHref}>Terms of Service</a> : \"Terms of Service\"}\n </span>\n </label>\n {errors.terms && <p className={styles.error} id={termsId + \"-error\"} role=\"alert\">{errors.terms}</p>}\n </div>\n )}\n {!signup && forgotPasswordHref && <a className={styles.forgot} href={forgotPasswordHref}>Forgot password?</a>}\n {serverError && <p className={styles.error} role=\"alert\">{serverError}</p>}\n {!(signup ? onSignUp : onSignIn) && (\n <p className={styles.error} role=\"status\">\n {signup ? \"Sign-up is not available.\" : \"Sign-in is not available.\"}\n </p>\n )}\n <Button type=\"submit\" variant=\"primary\" size=\"lg\" disabled={disabled || pending || (signup ? !onSignUp : !onSignIn)}>\n {pending ? (signup ? \"Creating account...\" : \"Signing in...\") : (signup ? \"Create account\" : \"Sign in\")}\n </Button>\n </AuthForm>\n </AuthCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmDA,SAAgB,SAAS,EACvB,OACA,cAAc,gBACd,cAAc,uBACd,gBACA,gBACA,cAAc,UACd,MAAM,gBACN,cACA,UACA,UACA,SACA,eAAe,IACf,WAAW,OACX,oBAAoB,GACpB,eACA,oBACA,WACA,SAAS,gBACO;CAChB,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAAmB,WAAW;CAC5E,MAAM,OAAO,kBAAkB;CAC/B,MAAM,CAAC,OAAO,YAAY,MAAM,SAAS,YAAY;CACrD,MAAM,CAAC,UAAU,eAAe,MAAM,SAAS,EAAE;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