@edgespark/web 0.0.0-beta.8b6c080
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.
- package/README.md +294 -0
- package/auth/styles/styles.css +384 -0
- package/dist/api/fetch.d.ts +8 -0
- package/dist/api/types.d.ts +13 -0
- package/dist/auth/create-auth.d.ts +18 -0
- package/dist/auth/local-dev.d.ts +36 -0
- package/dist/auth/types.d.ts +84 -0
- package/dist/auth-ui/ManagedAuthUI.d.ts +105 -0
- package/dist/auth-ui/appearance.d.ts +64 -0
- package/dist/auth-ui/config.d.ts +54 -0
- package/dist/auth-ui/default-labels.d.ts +2 -0
- package/dist/auth-ui/google-one-tap.d.ts +47 -0
- package/dist/auth-ui/index.d.ts +4 -0
- package/dist/auth-ui/mount.d.ts +22 -0
- package/dist/auth-ui/prompt-google-one-tap.d.ts +43 -0
- package/dist/auth-ui/runtime.d.ts +7 -0
- package/dist/auth-ui/types.d.ts +187 -0
- package/dist/browser.d.ts +2 -0
- package/dist/client.d.ts +43 -0
- package/dist/errors.d.ts +32 -0
- package/dist/index.cjs +177 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.es.js +2774 -0
- package/dist/locales/ar.d.ts +2 -0
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/en-US.d.ts +2 -0
- package/dist/locales/es.d.ts +2 -0
- package/dist/locales/fr.d.ts +2 -0
- package/dist/locales/hi.d.ts +2 -0
- package/dist/locales/index.d.ts +21 -0
- package/dist/locales/it.d.ts +2 -0
- package/dist/locales/ja.d.ts +2 -0
- package/dist/locales/ko.d.ts +2 -0
- package/dist/locales/pt-BR.d.ts +2 -0
- package/dist/locales/ru.d.ts +2 -0
- package/dist/locales/zh-CN.d.ts +2 -0
- package/dist/redirect.d.ts +5 -0
- package/dist/shared/types.d.ts +6 -0
- package/package.json +53 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EdgeSparkApi } from './api/types';
|
|
2
|
+
import { EdgeSparkAuth } from './auth/types';
|
|
3
|
+
import { EdgeSparkAuthUI } from './auth-ui';
|
|
4
|
+
export interface EdgeSparkClient {
|
|
5
|
+
/**
|
|
6
|
+
* Headless auth client with a better-auth-aligned API shape, plus a small
|
|
7
|
+
* set of EdgeSpark session helpers:
|
|
8
|
+
*
|
|
9
|
+
* - `requireSession()` — resolves or throws, for route guards
|
|
10
|
+
* - `onSessionChange()` — hydration-safe session observer
|
|
11
|
+
*
|
|
12
|
+
* Standard auth methods such as `signIn.email`, `signIn.social`,
|
|
13
|
+
* `signUp.email`, `signOut`, and `getSession` remain available on the same
|
|
14
|
+
* familiar shape.
|
|
15
|
+
*
|
|
16
|
+
* Some upstream better-auth methods may still be intentionally unsupported
|
|
17
|
+
* by the current EdgeSpark platform capability set. Those methods fail fast
|
|
18
|
+
* with `UNSUPPORTED_AUTH_METHOD` instead of deferring to a platform 400/404.
|
|
19
|
+
*/
|
|
20
|
+
auth: EdgeSparkAuth;
|
|
21
|
+
/**
|
|
22
|
+
* Same-origin fetch wrapper for app APIs.
|
|
23
|
+
*
|
|
24
|
+
* Always sends cookie credentials. Rejects cross-origin URLs.
|
|
25
|
+
*/
|
|
26
|
+
api: EdgeSparkApi;
|
|
27
|
+
/**
|
|
28
|
+
* Managed auth UI for login, sign-up, verification, and password reset flows.
|
|
29
|
+
*
|
|
30
|
+
* Mount with `{ redirectTo }` for login pages, or `{ onSuccess }` for
|
|
31
|
+
* modals and SPA routing.
|
|
32
|
+
*/
|
|
33
|
+
authUI: EdgeSparkAuthUI;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates the EdgeSpark browser client.
|
|
37
|
+
*
|
|
38
|
+
* The v2 SDK is intentionally zero-config:
|
|
39
|
+
* - current page origin is always used
|
|
40
|
+
* - cookie credentials are always enabled
|
|
41
|
+
* - auth routes stay internal
|
|
42
|
+
*/
|
|
43
|
+
export declare function createEdgeSpark(): EdgeSparkClient;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Base error class for all EdgeSpark SDK errors. Use `instanceof` to catch. */
|
|
2
|
+
export declare class EdgeSparkError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
constructor(code: string, message: string);
|
|
5
|
+
}
|
|
6
|
+
/** Programmer mistake: bad options, invalid container, cross-origin fetch, etc. */
|
|
7
|
+
export declare class EdgeSparkConfigError extends EdgeSparkError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** Called outside a browser (SSR, Node, tests without DOM). */
|
|
11
|
+
export declare class EdgeSparkRuntimeError extends EdgeSparkError {
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
/** Auth operation failed (sign-in rejected, session missing, etc.). */
|
|
15
|
+
export declare class EdgeSparkAuthError extends EdgeSparkError {
|
|
16
|
+
readonly cause?: unknown;
|
|
17
|
+
readonly status?: number;
|
|
18
|
+
constructor(message: string, options?: {
|
|
19
|
+
code?: string;
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
status?: number;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Normalize an unknown thrown value into an {@link EdgeSparkAuthError}.
|
|
26
|
+
*
|
|
27
|
+
* Already-normalized instances pass through unchanged. Objects with
|
|
28
|
+
* `message`/`code`/`status` fields are preserved. Plain strings become
|
|
29
|
+
* the error message. Everything else falls back to the caller-supplied
|
|
30
|
+
* defaults.
|
|
31
|
+
*/
|
|
32
|
+
export declare function normalizeToAuthError(error: unknown, fallbackMessage?: string, fallbackCode?: string): EdgeSparkAuthError;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ke=require("better-auth/client");class W extends Error{constructor(e,i){super(i),this.name="EdgeSparkError",this.code=e}}class w extends W{constructor(e){super("CONFIG_ERROR",e),this.name="EdgeSparkConfigError"}}class we extends W{constructor(e){super("RUNTIME_ERROR",e),this.name="EdgeSparkRuntimeError"}}class _ extends W{constructor(e,i){super((i==null?void 0:i.code)??"AUTH_ERROR",e),this.name="EdgeSparkAuthError",this.cause=i==null?void 0:i.cause,this.status=i==null?void 0:i.status}}function be(t,e="Authentication failed.",i){if(t instanceof _)return t;if(typeof t=="object"&&t!==null){const s=t;return new _(s.message||e,{code:s.code??i,status:s.status,cause:t})}return typeof t=="string"?new _(t,{code:i}):new _(e,{code:i,cause:t})}function Be(){if(typeof window>"u"||typeof document>"u")throw new we("@edgespark/web is browser-only. Create the client from a real browser runtime.")}function oe(){return Be(),window.location.origin}function We(t){return t instanceof URL?t:typeof t=="string"?new URL(t,window.location.href):new URL(t.url,window.location.href)}function Ye(t){if(t.origin!==oe())throw new w(`Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${oe()}.`)}function Je(){return{async fetch(t,e){const i=We(t);return Ye(i),fetch(t,{...e,credentials:"include"})}}}const Me="/api/_es/auth",Xe="edgespark-auth-session",De="__edgespark_auth_sync__",Y="__edgespark_auth_pending_sign_in__",Ne=Symbol("edgespark.notifyAuthTabs"),Ze=10*60*1e3,Qe=new Set(["signOut","revokeSession","revokeSessions","revokeOtherSessions"]),et=new Map([["changeEmail","changeEmail() is not currently supported by EdgeSpark platform auth. Use authUI.mount() or other supported client.auth flows instead of wiring raw /api/_es/auth/* routes manually."],["deleteUser","deleteUser() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."],["deleteUserCallback","deleteUserCallback() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."]]);class tt{constructor(e){this.value=e}deref(){return this.value}}const Pe=globalThis.WeakRef,_e=globalThis.FinalizationRegistry;let J,Ie=!1;const M=new Map,X=_e?new _e(t=>{M.delete(t)}):null;function Ve(t){return Ke.createAuthClient({baseURL:oe(),basePath:Me,...t!=null&&t.disableDefaultRedirectPlugin?{disableDefaultFetchPlugins:!0}:{},fetchOptions:{credentials:"include"}})}function B(t){var e,i;return(i=(e=t.$store)==null?void 0:e.atoms)==null?void 0:i.session}function it(t){return JSON.stringify({source:t,timestamp:Date.now()})}function st(t){if(typeof t!="string")return null;try{const e=JSON.parse(t);return e&&typeof e=="object"?e:null}catch{return null}}function nt(t){return t.join(".")}function rt(t){const e=nt(t),i=et.get(e);return i?new _(i,{code:"UNSUPPORTED_AUTH_METHOD"}):null}async function ae(t){var e;try{return await((e=B(t))==null?void 0:e.get().refetch()),!0}catch{return!1}}function He(){return J===void 0&&(J=typeof BroadcastChannel<"u"?new BroadcastChannel(Xe):null),J}function Ae(t){const e=st(t);if(e)for(const[i,s]of M){if(i===e.source)continue;const n=s.deref();if(!n){M.delete(i);continue}ae(n)}}function ot(){var t;Ie||(Ie=!0,(t=He())==null||t.addEventListener("message",e=>{Ae(e.data)}),typeof window<"u"&&window.addEventListener("storage",e=>{e.key!==De||e.newValue===null||Ae(e.newValue)}))}function at(t,e){Pe?M.set(t,new Pe(e)):(M.clear(),M.set(t,new tt(e))),X==null||X.register(e,t),ot()}function k(t){const e=it(t),i=He();let s=!1;if(i)try{i.postMessage(e),s=!0}catch{}if(!s)try{window.localStorage.setItem(De,e)}catch{}}function Z(t){if(!(typeof window>"u"))try{window.sessionStorage.setItem(Y,JSON.stringify({path:t,createdAt:Date.now()}))}catch{}}function O(){if(!(typeof window>"u"))try{window.sessionStorage.removeItem(Y)}catch{}}function dt(t){return!!(t!=null&&t.session&&(t!=null&&t.user))}function y(t){return t instanceof Date?t.toISOString():t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:t==null?null:String(t)}function lt(t){return t?JSON.stringify({session:{createdAt:y(t.session.createdAt),expiresAt:y(t.session.expiresAt),id:y(t.session.id),impersonatedBy:y(t.session.impersonatedBy),ipAddress:y(t.session.ipAddress),token:y(t.session.token),updatedAt:y(t.session.updatedAt),userAgent:y(t.session.userAgent),userId:y(t.session.userId)},user:{banExpires:y(t.user.banExpires),banReason:y(t.user.banReason),banned:y(t.user.banned),createdAt:y(t.user.createdAt),email:y(t.user.email),emailVerified:y(t.user.emailVerified),id:y(t.user.id),image:y(t.user.image),lastLoginAt:y(t.user.lastLoginAt),name:y(t.user.name),role:y(t.user.role),updatedAt:y(t.user.updatedAt)}}):"__null__"}function Fe(){if(typeof window>"u")return null;try{const t=window.sessionStorage.getItem(Y);if(!t)return null;const e=JSON.parse(t);return!e||typeof e!="object"||typeof e.createdAt!="number"||Date.now()-e.createdAt>Ze?null:{createdAt:e.createdAt}}catch{return null}}function Le(){if(!Fe())return!1;try{window.sessionStorage.removeItem(Y)}catch{}return!0}function ct(){return Fe()!==null}function ut(t){if(!(t&&typeof t=="object")||"error"in t&&t.error)return!1;const e="data"in t?t.data:t;return e&&typeof e=="object"?"token"in e&&typeof e.token=="string"&&e.token.length>0?!0:"session"in e&&"user"in e&&!!e.session&&!!e.user:!1}function ht(t){if(!(t&&typeof t=="object")||"error"in t&&t.error)return!1;const e="data"in t?t.data:t;return e&&typeof e=="object"?"url"in e&&typeof e.url=="string":!1}function mt(t){if($(t)||!(t&&typeof t=="object"))return!1;const e="data"in t?t.data:t;return e&&typeof e=="object"?"user"in e&&!!e.user&&"token"in e&&e.token===null&&!("url"in e):!1}function gt(t,e){if(t.length!==1||t[0]!=="changePassword")return!1;const[i]=e;return!!(i&&typeof i=="object"&&"revokeOtherSessions"in i&&i.revokeOtherSessions===!0)}function $(t){return!!(t&&typeof t=="object"&&"error"in t&&t.error)}function ft(t){if($(t)||!(t&&typeof t=="object"))return!1;const e="data"in t?t.data:t;return e&&typeof e=="object"?"message"in e&&e.message==="User deleted":!1}function pt(t){return!!(t&&(typeof t=="object"||typeof t=="function")&&"then"in t&&typeof t.then=="function")}function Q(t){return be(t,"Failed to load the current session.","SESSION_LOOKUP_FAILED")}async function wt(t){var i,s;let e=null;try{await((i=B(t))==null?void 0:i.get().refetch())}catch(n){e=n}finally{(s=t[Ne])==null||s.call(t)}if(e)throw e}function bt(){const t=Ve(),e=`${Date.now()}-${Math.random().toString(36).slice(2)}`;at(e,t);const i=2,s=500;let n=null,o=!1,d;const h=a=>(d=a,a),g=()=>{var m;const a=(m=B(t))==null?void 0:m.get();return a!=null&&a.error&&!a.data&&d!==void 0?d:(a==null?void 0:a.data)??d??null},P=()=>o?Promise.resolve(g()):(n||(n=(async()=>{var c,f,C;let a=!1,m=null;try{for(let A=0;A<=i;A++){let u=null;try{u=await t.getSession()}catch(T){m=T}const S=((c=B(t))==null?void 0:c.get().data)??null;if((f=u==null?void 0:u.data)!=null&&f.session&&((C=u.data)!=null&&C.user))return o=!0,Le()&&k(e),h(u.data);if(S!=null&&S.session&&(S!=null&&S.user))return o=!0,Le()&&k(e),h(S);if(u!=null&&u.error?m=u.error:u&&(a=!0),u&&!u.error&&ct()&&A<i){await new Promise(T=>setTimeout(T,s));continue}if(u&&!u.error){const T=g();return o=!0,h(T)}A<i&&await new Promise(T=>setTimeout(T,s))}if(!a)throw n=null,new _("Failed to load the current session.",{code:"SESSION_LOOKUP_FAILED",cause:m});const v=g();return o=!0,h(v)}catch(v){throw n=null,Q(v)}})()),n);P().catch(()=>{});const b=async()=>{var a,m;try{const c=await t.getSession();if((a=c.data)!=null&&a.session&&((m=c.data)!=null&&m.user))return c.data;throw c.error?Q(c.error):new _("No authenticated session is available.",{code:"UNAUTHENTICATED"})}catch(c){throw Q(c)}},p=async()=>{await ae(t),k(e)},E=async()=>{var c;const a=await ae(t),m=((c=B(t))==null?void 0:c.get().data)??null;dt(m)?(O(),k(e)):a||k(e)},l=a=>{let m=!1,c=!1,f;const C=u=>{const S=lt(u);S!==f&&(f=S,a(u))};P().then(u=>{m||(c=!0,C(h(u)))}).catch(()=>{m||(c=!0)});const v=B(t);if(!v)return()=>{m=!0};const A=v.subscribe(u=>{if(m||!c||u.error&&!u.data)return;const S=u.data??null;C(h(S))});return()=>{m=!0,A()}},I=async(a,m,c)=>{const f=a[0],C=a.length>=2&&f==="emailOtp"&&a[1]==="verifyEmail",v=a.length>=2&&f==="emailOtp"&&a[1]==="resetPassword",A=a.length>=2&&f==="resetPassword"&&a[1]==="emailOtp",u=a.length>=2&&f==="oneTap"&&a[1]==="callback";return a.length===1&&(f==="deleteUser"||f==="deleteUserCallback")?(O(),ft(c)&&await p(),c):a.length===1&&f&&Qe.has(f)?(O(),$(c)||await p(),c):gt(a,m)&&!$(c)?(O(),await p(),c):(v||A)&&!$(c)?(O(),await p(),c):a.length===1&&f==="changeEmail"&&!$(c)?(await p(),c):((f==="signIn"||f==="signUp"||C||u)&&ut(c)?(O(),await p()):(f==="signIn"||f==="signUp")&&ht(c)||f==="signUp"&&mt(c)?Z(a):f==="verifyEmail"&&!$(c)&&(Z(a),await E()),c)},L=new WeakMap,D=(a,m)=>{if(!a||typeof a!="object"&&typeof a!="function")return a;const c=L.get(a);if(c)return c;const f=new Proxy(a,{get(C,v,A){if(m.length===0){if(v==="requireSession")return b;if(v==="onSessionChange")return l;if(v===Ne)return()=>{k(e)}}const u=Reflect.get(C,v,A);return typeof v!="string"?u:D(u,[...m,v])},apply(C,v,A){const u=rt(m);if(u)throw u;const S=Reflect.apply(C,v,A);return pt(S)?Promise.resolve(S).then(T=>I(m,A,T)):S}});return L.set(a,f),f};return D(t,[])}function yt(){return Ve({disableDefaultRedirectPlugin:!0})}const ye="/api/_es/dev";function vt(){if(typeof document>"u")return!1;const t=document.querySelector('meta[name="edgespark-local-dev"]');return(t==null?void 0:t.getAttribute("content"))==="true"}async function Et(t){const e=typeof window<"u"?window.location.origin:"";if(!e)return!1;const i=await fetch(`${e}${ye}/auto-verify?email=${encodeURIComponent(t)}`,{credentials:"include"});return i.ok?(await i.json()).verified===!0:!1}async function St(t){const e=typeof window<"u"?window.location.origin:"";if(!e)return null;try{const i=await fetch(`${e}${ye}/pending-otp?email=${encodeURIComponent(t)}`,{credentials:"include"});return i.ok?(await i.json()).otp??null:null}catch{return null}}async function Pt(t){const e=typeof window<"u"?window.location.origin:"";if(!e)return null;try{const i=await fetch(`${e}${ye}/pending-sign-in-otp?email=${encodeURIComponent(t)}`,{credentials:"include"});return i.ok?(await i.json()).otp??null:null}catch{return null}}function _t(t){const e=(()=>{if(t instanceof URL)return t;const i=t.trim();if(!i)throw new w("redirectTo must not be an empty string.");try{return new URL(i,window.location.href)}catch{throw new w(`redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`)}})();if(e.protocol!=="http:"&&e.protocol!=="https:")throw new w(`redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`);return e}function It(t,e){return e?{common:{...t.common,...e.common},signIn:{...t.signIn,...e.signIn},signUp:{...t.signUp,...e.signUp},verifyEmail:{...t.verifyEmail,...e.verifyEmail},forgotPassword:{...t.forgotPassword,...e.forgotPassword},resetPassword:{...t.resetPassword,...e.resetPassword},oauth:{...t.oauth,...e.oauth},errors:{...t.errors,...e.errors}}:t}const H={common:{loading:"Loading sign-in…",redirecting:"Redirecting…",backToSignIn:"Back to sign in"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Sign-in code sent to your email",sendingCode:"Sending sign-in code…",signingIn:"Signing in…",title:"Welcome back",subtitle:"Sign in to continue",emailLabel:"Email",passwordLabel:"Password",submitButton:"Sign in",resendCodeButton:"Resend code",resendCountdown:"Resend in {seconds}s",forgotPassword:"Forgot password?",switchToSignUp:"Create an account",signUpPrompt:"Don’t have an account?"},signUp:{title:"Create your account",subtitle:"Start with your name, email, and password",nameLabel:"Name",emailLabel:"Email",passwordLabel:"Password",confirmPasswordLabel:"Confirm password",submitButton:"Create account",switchToSignIn:"Sign in",signInPrompt:"Already have an account?"},verifyEmail:{title:"Verify your email",subtitle:"Finish account setup from the verification email we sent.",sentToLabel:"Sent to",resendButton:"Resend verification email",resendCountdown:"Resend in {seconds}s",changeEmailButton:"Use a different email"},forgotPassword:{title:"Reset your password",subtitle:"Enter your email and we will send a reset code.",emailLabel:"Email",submitButton:"Send reset code"},resetPassword:{title:"Set a new password",subtitle:"Use the code from your email to finish resetting your password.",codeLabel:"Verification code",newPasswordLabel:"New password",confirmPasswordLabel:"Confirm password",submitButton:"Update password",resendCodeButton:"Resend code",resendCountdown:"Resend in {seconds}s"},oauth:{redirecting:"Redirecting to {provider}…",dividerText:"or",continueWith:"Continue with"},errors:{invalidEmail:"Enter a valid email address.",requiredField:"This field is required.",passwordTooShort:"Password must be at least {min} characters.",passwordMismatch:"Passwords do not match.",invalidCode:"Enter the 6-digit verification code.",generic:"Something went wrong. Please try again."}},q={common:{loading:"加载中…",redirecting:"跳转中…",backToSignIn:"返回登录"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"登录验证码已发送至你的邮箱",sendingCode:"正在发送登录验证码…",signingIn:"正在登录…",title:"欢迎回来",subtitle:"登录以继续",emailLabel:"邮箱",passwordLabel:"密码",submitButton:"登录",forgotPassword:"忘记密码?",switchToSignUp:"立即注册",signUpPrompt:"没有账号?"},signUp:{title:"创建账号",subtitle:"填写姓名、邮箱和密码开始使用",nameLabel:"姓名",emailLabel:"邮箱",passwordLabel:"密码",confirmPasswordLabel:"确认密码",submitButton:"注册",switchToSignIn:"去登录",signInPrompt:"已有账号?"},verifyEmail:{title:"验证邮箱",subtitle:"请查收邮件并点击验证链接",sentToLabel:"已发送至",resendButton:"重新发送验证邮件",resendCountdown:"{seconds}秒后可重发",changeEmailButton:"更换邮箱"},forgotPassword:{title:"重置密码",subtitle:"输入邮箱以接收重置验证码",emailLabel:"邮箱",submitButton:"发送重置码"},resetPassword:{title:"设置新密码",subtitle:"使用邮件中的验证码完成密码重置",codeLabel:"验证码",newPasswordLabel:"新密码",confirmPasswordLabel:"确认密码",submitButton:"更新密码",resendCodeButton:"重新发送",resendCountdown:"{seconds}秒后可重发"},oauth:{redirecting:"正在跳转至 {provider}…",dividerText:"或",continueWith:"使用"},errors:{invalidEmail:"请输入有效的邮箱地址",requiredField:"此项为必填",passwordTooShort:"密码至少需要 {min} 个字符",passwordMismatch:"两次密码输入不一致",invalidCode:"请输入 6 位验证码",generic:"出现错误,请稍后重试"}},de={common:{loading:"サインインを読み込み中…",redirecting:"リダイレクト中…",backToSignIn:"サインインに戻る"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"ログインコードをメールに送信しました",sendingCode:"ログインコードを送信中…",signingIn:"ログイン中…",title:"おかえりなさい",subtitle:"サインインして続行",emailLabel:"メールアドレス",passwordLabel:"パスワード",submitButton:"サインイン",forgotPassword:"パスワードをお忘れですか?",switchToSignUp:"アカウントを作成",signUpPrompt:"アカウントをお持ちでない方"},signUp:{title:"アカウントを作成",subtitle:"名前、メールアドレス、パスワードを入力してください",nameLabel:"名前",emailLabel:"メールアドレス",passwordLabel:"パスワード",confirmPasswordLabel:"パスワード(確認)",submitButton:"アカウント作成",switchToSignIn:"サインイン",signInPrompt:"既にアカウントをお持ちですか?"},verifyEmail:{title:"メールアドレスを確認",subtitle:"送信した確認メールからアカウント設定を完了してください",sentToLabel:"送信先",resendButton:"確認メールを再送信",resendCountdown:"{seconds}秒後に再送信可能",changeEmailButton:"別のメールアドレスを使用"},forgotPassword:{title:"パスワードをリセット",subtitle:"メールアドレスを入力するとリセットコードをお送りします",emailLabel:"メールアドレス",submitButton:"リセットコードを送信"},resetPassword:{title:"新しいパスワードを設定",subtitle:"メールで届いた認証コードを使ってパスワードをリセットしてください",codeLabel:"認証コード",newPasswordLabel:"新しいパスワード",confirmPasswordLabel:"パスワード(確認)",submitButton:"パスワードを更新",resendCodeButton:"コードを再送信",resendCountdown:"{seconds}秒後に再送信可能"},oauth:{redirecting:"{provider} に移動中…",dividerText:"または",continueWith:"で続行"},errors:{invalidEmail:"有効なメールアドレスを入力してください",requiredField:"この項目は必須です",passwordTooShort:"パスワードは {min} 文字以上で入力してください",passwordMismatch:"パスワードが一致しません",invalidCode:"6桁の認証コードを入力してください",generic:"エラーが発生しました。もう一度お試しください"}},le={common:{loading:"로그인 로딩 중…",redirecting:"리디렉션 중…",backToSignIn:"로그인으로 돌아가기"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"로그인 코드를 이메일로 보냈습니다",sendingCode:"로그인 코드 전송 중…",signingIn:"로그인 중…",title:"다시 오신 것을 환영합니다",subtitle:"로그인하여 계속하기",emailLabel:"이메일",passwordLabel:"비밀번호",submitButton:"로그인",forgotPassword:"비밀번호를 잊으셨나요?",switchToSignUp:"계정 만들기",signUpPrompt:"계정이 없으신가요?"},signUp:{title:"계정 만들기",subtitle:"이름, 이메일, 비밀번호를 입력해 주세요",nameLabel:"이름",emailLabel:"이메일",passwordLabel:"비밀번호",confirmPasswordLabel:"비밀번호 확인",submitButton:"계정 생성",switchToSignIn:"로그인",signInPrompt:"이미 계정이 있으신가요?"},verifyEmail:{title:"이메일 인증",subtitle:"발송된 인증 이메일에서 계정 설정을 완료해 주세요",sentToLabel:"발송 대상",resendButton:"인증 이메일 재발송",resendCountdown:"{seconds}초 후 재발송 가능",changeEmailButton:"다른 이메일 사용"},forgotPassword:{title:"비밀번호 재설정",subtitle:"이메일을 입력하시면 재설정 코드를 보내드립니다",emailLabel:"이메일",submitButton:"재설정 코드 발송"},resetPassword:{title:"새 비밀번호 설정",subtitle:"이메일로 받은 인증 코드를 사용하여 비밀번호를 재설정하세요",codeLabel:"인증 코드",newPasswordLabel:"새 비밀번호",confirmPasswordLabel:"비밀번호 확인",submitButton:"비밀번호 변경",resendCodeButton:"코드 재발송",resendCountdown:"{seconds}초 후 재발송 가능"},oauth:{redirecting:"{provider}(으)로 이동 중…",dividerText:"또는",continueWith:"으로 계속"},errors:{invalidEmail:"올바른 이메일 주소를 입력해 주세요",requiredField:"필수 입력 항목입니다",passwordTooShort:"비밀번호는 최소 {min}자 이상이어야 합니다",passwordMismatch:"비밀번호가 일치하지 않습니다",invalidCode:"6자리 인증 코드를 입력해 주세요",generic:"문제가 발생했습니다. 다시 시도해 주세요"}},K={common:{loading:"Cargando inicio de sesión…",redirecting:"Redirigiendo…",backToSignIn:"Volver a iniciar sesión"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Código de acceso enviado a tu correo",sendingCode:"Enviando código de acceso…",signingIn:"Iniciando sesión…",title:"Bienvenido de nuevo",subtitle:"Inicia sesión para continuar",emailLabel:"Correo electrónico",passwordLabel:"Contraseña",submitButton:"Iniciar sesión",forgotPassword:"¿Olvidaste tu contraseña?",switchToSignUp:"Crear una cuenta",signUpPrompt:"¿No tienes cuenta?"},signUp:{title:"Crea tu cuenta",subtitle:"Empieza con tu nombre, correo y contraseña",nameLabel:"Nombre",emailLabel:"Correo electrónico",passwordLabel:"Contraseña",confirmPasswordLabel:"Confirmar contraseña",submitButton:"Crear cuenta",switchToSignIn:"Iniciar sesión",signInPrompt:"¿Ya tienes una cuenta?"},verifyEmail:{title:"Verifica tu correo",subtitle:"Completa la configuración desde el correo de verificación que te enviamos.",sentToLabel:"Enviado a",resendButton:"Reenviar correo de verificación",resendCountdown:"Reenviar en {seconds}s",changeEmailButton:"Usar otro correo"},forgotPassword:{title:"Restablecer contraseña",subtitle:"Ingresa tu correo y te enviaremos un código de restablecimiento.",emailLabel:"Correo electrónico",submitButton:"Enviar código"},resetPassword:{title:"Establece una nueva contraseña",subtitle:"Usa el código de tu correo para completar el restablecimiento.",codeLabel:"Código de verificación",newPasswordLabel:"Nueva contraseña",confirmPasswordLabel:"Confirmar contraseña",submitButton:"Actualizar contraseña",resendCodeButton:"Reenviar código",resendCountdown:"Reenviar en {seconds}s"},oauth:{redirecting:"Redirigiendo a {provider}…",dividerText:"o",continueWith:"Continuar con"},errors:{invalidEmail:"Ingresa una dirección de correo válida.",requiredField:"Este campo es obligatorio.",passwordTooShort:"La contraseña debe tener al menos {min} caracteres.",passwordMismatch:"Las contraseñas no coinciden.",invalidCode:"Ingresa el código de verificación de 6 dígitos.",generic:"Algo salió mal. Por favor, inténtalo de nuevo."}},ce={common:{loading:"Carregando login…",redirecting:"Redirecionando…",backToSignIn:"Voltar para o login"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Código de acesso enviado por e-mail",sendingCode:"Enviando código de acesso…",signingIn:"Entrando…",title:"Bem-vindo de volta",subtitle:"Faça login para continuar",emailLabel:"E-mail",passwordLabel:"Senha",submitButton:"Entrar",forgotPassword:"Esqueceu a senha?",switchToSignUp:"Criar uma conta",signUpPrompt:"Não tem uma conta?"},signUp:{title:"Crie sua conta",subtitle:"Comece com seu nome, e-mail e senha",nameLabel:"Nome",emailLabel:"E-mail",passwordLabel:"Senha",confirmPasswordLabel:"Confirmar senha",submitButton:"Criar conta",switchToSignIn:"Entrar",signInPrompt:"Já tem uma conta?"},verifyEmail:{title:"Verifique seu e-mail",subtitle:"Conclua a configuração a partir do e-mail de verificação que enviamos.",sentToLabel:"Enviado para",resendButton:"Reenviar e-mail de verificação",resendCountdown:"Reenviar em {seconds}s",changeEmailButton:"Usar outro e-mail"},forgotPassword:{title:"Redefinir senha",subtitle:"Informe seu e-mail e enviaremos um código de redefinição.",emailLabel:"E-mail",submitButton:"Enviar código"},resetPassword:{title:"Defina uma nova senha",subtitle:"Use o código recebido por e-mail para concluir a redefinição.",codeLabel:"Código de verificação",newPasswordLabel:"Nova senha",confirmPasswordLabel:"Confirmar senha",submitButton:"Atualizar senha",resendCodeButton:"Reenviar código",resendCountdown:"Reenviar em {seconds}s"},oauth:{redirecting:"Redirecionando para {provider}…",dividerText:"ou",continueWith:"Continuar com"},errors:{invalidEmail:"Insira um endereço de e-mail válido.",requiredField:"Este campo é obrigatório.",passwordTooShort:"A senha deve ter pelo menos {min} caracteres.",passwordMismatch:"As senhas não coincidem.",invalidCode:"Insira o código de verificação de 6 dígitos.",generic:"Algo deu errado. Por favor, tente novamente."}},ue={common:{loading:"Chargement de la connexion…",redirecting:"Redirection…",backToSignIn:"Retour à la connexion"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Code de connexion envoyé par e-mail",sendingCode:"Envoi du code de connexion…",signingIn:"Connexion en cours…",title:"Bon retour",subtitle:"Connectez-vous pour continuer",emailLabel:"Adresse e-mail",passwordLabel:"Mot de passe",submitButton:"Se connecter",forgotPassword:"Mot de passe oublié ?",switchToSignUp:"Créer un compte",signUpPrompt:"Vous n’avez pas de compte ?"},signUp:{title:"Créez votre compte",subtitle:"Commencez par votre nom, e-mail et mot de passe",nameLabel:"Nom",emailLabel:"Adresse e-mail",passwordLabel:"Mot de passe",confirmPasswordLabel:"Confirmer le mot de passe",submitButton:"Créer le compte",switchToSignIn:"Se connecter",signInPrompt:"Vous avez déjà un compte ?"},verifyEmail:{title:"Vérifiez votre e-mail",subtitle:"Finalisez la création de votre compte depuis l’e-mail de vérification envoyé.",sentToLabel:"Envoyé à",resendButton:"Renvoyer l’e-mail de vérification",resendCountdown:"Renvoyer dans {seconds}s",changeEmailButton:"Utiliser un autre e-mail"},forgotPassword:{title:"Réinitialiser le mot de passe",subtitle:"Saisissez votre e-mail pour recevoir un code de réinitialisation.",emailLabel:"Adresse e-mail",submitButton:"Envoyer le code"},resetPassword:{title:"Définir un nouveau mot de passe",subtitle:"Utilisez le code reçu par e-mail pour réinitialiser votre mot de passe.",codeLabel:"Code de vérification",newPasswordLabel:"Nouveau mot de passe",confirmPasswordLabel:"Confirmer le mot de passe",submitButton:"Mettre à jour le mot de passe",resendCodeButton:"Renvoyer le code",resendCountdown:"Renvoyer dans {seconds}s"},oauth:{redirecting:"Redirection vers {provider}…",dividerText:"ou",continueWith:"Continuer avec"},errors:{invalidEmail:"Veuillez saisir une adresse e-mail valide.",requiredField:"Ce champ est requis.",passwordTooShort:"Le mot de passe doit contenir au moins {min} caractères.",passwordMismatch:"Les mots de passe ne correspondent pas.",invalidCode:"Saisissez le code de vérification à 6 chiffres.",generic:"Une erreur est survenue. Veuillez réessayer."}},he={common:{loading:"Anmeldung wird geladen…",redirecting:"Weiterleitung…",backToSignIn:"Zurück zur Anmeldung"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Anmeldecode wurde per E-Mail gesendet",sendingCode:"Anmeldecode wird gesendet…",signingIn:"Anmeldung läuft…",title:"Willkommen zurück",subtitle:"Melden Sie sich an, um fortzufahren",emailLabel:"E-Mail-Adresse",passwordLabel:"Passwort",submitButton:"Anmelden",forgotPassword:"Passwort vergessen?",switchToSignUp:"Konto erstellen",signUpPrompt:"Noch kein Konto?"},signUp:{title:"Konto erstellen",subtitle:"Geben Sie Ihren Namen, Ihre E-Mail und ein Passwort ein",nameLabel:"Name",emailLabel:"E-Mail-Adresse",passwordLabel:"Passwort",confirmPasswordLabel:"Passwort bestätigen",submitButton:"Konto erstellen",switchToSignIn:"Anmelden",signInPrompt:"Bereits ein Konto?"},verifyEmail:{title:"E-Mail bestätigen",subtitle:"Schließen Sie die Einrichtung über die Bestätigungs-E-Mail ab, die wir Ihnen gesendet haben.",sentToLabel:"Gesendet an",resendButton:"Bestätigungs-E-Mail erneut senden",resendCountdown:"Erneut senden in {seconds}s",changeEmailButton:"Andere E-Mail verwenden"},forgotPassword:{title:"Passwort zurücksetzen",subtitle:"Geben Sie Ihre E-Mail ein und wir senden Ihnen einen Zurücksetzungscode.",emailLabel:"E-Mail-Adresse",submitButton:"Code senden"},resetPassword:{title:"Neues Passwort festlegen",subtitle:"Verwenden Sie den Code aus der E-Mail, um Ihr Passwort zurückzusetzen.",codeLabel:"Bestätigungscode",newPasswordLabel:"Neues Passwort",confirmPasswordLabel:"Passwort bestätigen",submitButton:"Passwort aktualisieren",resendCodeButton:"Code erneut senden",resendCountdown:"Erneut senden in {seconds}s"},oauth:{redirecting:"Weiterleitung zu {provider}…",dividerText:"oder",continueWith:"Weiter mit"},errors:{invalidEmail:"Bitte geben Sie eine gültige E-Mail-Adresse ein.",requiredField:"Dieses Feld ist erforderlich.",passwordTooShort:"Das Passwort muss mindestens {min} Zeichen lang sein.",passwordMismatch:"Die Passwörter stimmen nicht überein.",invalidCode:"Geben Sie den 6-stelligen Bestätigungscode ein.",generic:"Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."}},me={common:{loading:"Caricamento accesso…",redirecting:"Reindirizzamento…",backToSignIn:"Torna all’accesso"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Codice di accesso inviato alla tua e-mail",sendingCode:"Invio del codice di accesso…",signingIn:"Accesso in corso…",title:"Bentornato",subtitle:"Accedi per continuare",emailLabel:"Indirizzo e-mail",passwordLabel:"Password",submitButton:"Accedi",forgotPassword:"Password dimenticata?",switchToSignUp:"Crea un account",signUpPrompt:"Non hai un account?"},signUp:{title:"Crea il tuo account",subtitle:"Inserisci nome, e-mail e password per iniziare",nameLabel:"Nome",emailLabel:"Indirizzo e-mail",passwordLabel:"Password",confirmPasswordLabel:"Conferma password",submitButton:"Crea account",switchToSignIn:"Accedi",signInPrompt:"Hai già un account?"},verifyEmail:{title:"Verifica la tua e-mail",subtitle:"Completa la configurazione dall’e-mail di verifica che ti abbiamo inviato.",sentToLabel:"Inviata a",resendButton:"Reinvia e-mail di verifica",resendCountdown:"Reinvia tra {seconds}s",changeEmailButton:"Usa un’altra e-mail"},forgotPassword:{title:"Reimposta la password",subtitle:"Inserisci la tua e-mail e ti invieremo un codice di reimpostazione.",emailLabel:"Indirizzo e-mail",submitButton:"Invia codice"},resetPassword:{title:"Imposta una nuova password",subtitle:"Usa il codice ricevuto via e-mail per reimpostare la password.",codeLabel:"Codice di verifica",newPasswordLabel:"Nuova password",confirmPasswordLabel:"Conferma password",submitButton:"Aggiorna password",resendCodeButton:"Reinvia codice",resendCountdown:"Reinvia tra {seconds}s"},oauth:{redirecting:"Reindirizzamento a {provider}…",dividerText:"oppure",continueWith:"Continua con"},errors:{invalidEmail:"Inserisci un indirizzo e-mail valido.",requiredField:"Questo campo è obbligatorio.",passwordTooShort:"La password deve contenere almeno {min} caratteri.",passwordMismatch:"Le password non corrispondono.",invalidCode:"Inserisci il codice di verifica a 6 cifre.",generic:"Qualcosa è andato storto. Riprova."}},ge={common:{loading:"Загрузка входа…",redirecting:"Перенаправление…",backToSignIn:"Вернуться ко входу"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"Код входа отправлен на вашу почту",sendingCode:"Отправка кода входа…",signingIn:"Вход…",title:"С возвращением",subtitle:"Войдите, чтобы продолжить",emailLabel:"Электронная почта",passwordLabel:"Пароль",submitButton:"Войти",forgotPassword:"Забыли пароль?",switchToSignUp:"Создать аккаунт",signUpPrompt:"Нет аккаунта?"},signUp:{title:"Создание аккаунта",subtitle:"Укажите имя, электронную почту и пароль",nameLabel:"Имя",emailLabel:"Электронная почта",passwordLabel:"Пароль",confirmPasswordLabel:"Подтвердите пароль",submitButton:"Создать аккаунт",switchToSignIn:"Войти",signInPrompt:"Уже есть аккаунт?"},verifyEmail:{title:"Подтвердите почту",subtitle:"Завершите настройку через письмо с подтверждением, которое мы отправили.",sentToLabel:"Отправлено на",resendButton:"Отправить повторно",resendCountdown:"Повторная отправка через {seconds}с",changeEmailButton:"Использовать другую почту"},forgotPassword:{title:"Сброс пароля",subtitle:"Введите электронную почту, и мы отправим код для сброса.",emailLabel:"Электронная почта",submitButton:"Отправить код"},resetPassword:{title:"Установите новый пароль",subtitle:"Используйте код из письма для завершения сброса пароля.",codeLabel:"Код подтверждения",newPasswordLabel:"Новый пароль",confirmPasswordLabel:"Подтвердите пароль",submitButton:"Обновить пароль",resendCodeButton:"Отправить код повторно",resendCountdown:"Повторная отправка через {seconds}с"},oauth:{redirecting:"Переход в {provider}…",dividerText:"или",continueWith:"Продолжить через"},errors:{invalidEmail:"Введите корректный адрес электронной почты.",requiredField:"Это поле обязательно.",passwordTooShort:"Пароль должен содержать не менее {min} символов.",passwordMismatch:"Пароли не совпадают.",invalidCode:"Введите 6-значный код подтверждения.",generic:"Произошла ошибка. Пожалуйста, попробуйте снова."}},fe={common:{loading:"جارٍ تحميل تسجيل الدخول…",redirecting:"جارٍ إعادة التوجيه…",backToSignIn:"العودة إلى تسجيل الدخول"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"تم إرسال رمز تسجيل الدخول إلى بريدك الإلكتروني",sendingCode:"جارٍ إرسال رمز تسجيل الدخول…",signingIn:"جارٍ تسجيل الدخول…",title:"مرحبًا بعودتك",subtitle:"سجّل الدخول للمتابعة",emailLabel:"البريد الإلكتروني",passwordLabel:"كلمة المرور",submitButton:"تسجيل الدخول",forgotPassword:"هل نسيت كلمة المرور؟",switchToSignUp:"إنشاء حساب",signUpPrompt:"ليس لديك حساب؟"},signUp:{title:"أنشئ حسابك",subtitle:"ابدأ بإدخال اسمك وبريدك الإلكتروني وكلمة المرور",nameLabel:"الاسم",emailLabel:"البريد الإلكتروني",passwordLabel:"كلمة المرور",confirmPasswordLabel:"تأكيد كلمة المرور",submitButton:"إنشاء الحساب",switchToSignIn:"تسجيل الدخول",signInPrompt:"لديك حساب بالفعل؟"},verifyEmail:{title:"تحقّق من بريدك الإلكتروني",subtitle:"أكمل إعداد حسابك من رسالة التحقّق التي أرسلناها.",sentToLabel:"أُرسل إلى",resendButton:"إعادة إرسال رسالة التحقّق",resendCountdown:"إعادة الإرسال خلال {seconds} ثانية",changeEmailButton:"استخدام بريد إلكتروني آخر"},forgotPassword:{title:"إعادة تعيين كلمة المرور",subtitle:"أدخل بريدك الإلكتروني وسنرسل لك رمز إعادة التعيين.",emailLabel:"البريد الإلكتروني",submitButton:"إرسال رمز إعادة التعيين"},resetPassword:{title:"تعيين كلمة مرور جديدة",subtitle:"استخدم الرمز المرسل إلى بريدك لإكمال إعادة تعيين كلمة المرور.",codeLabel:"رمز التحقّق",newPasswordLabel:"كلمة المرور الجديدة",confirmPasswordLabel:"تأكيد كلمة المرور",submitButton:"تحديث كلمة المرور",resendCodeButton:"إعادة إرسال الرمز",resendCountdown:"إعادة الإرسال خلال {seconds} ثانية"},oauth:{redirecting:"جارٍ الانتقال إلى {provider}…",dividerText:"أو",continueWith:"المتابعة باستخدام"},errors:{invalidEmail:"يرجى إدخال عنوان بريد إلكتروني صالح.",requiredField:"هذا الحقل مطلوب.",passwordTooShort:"يجب أن تتكوّن كلمة المرور من {min} حرفًا على الأقل.",passwordMismatch:"كلمتا المرور غير متطابقتين.",invalidCode:"يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",generic:"حدث خطأ. يرجى المحاولة مرة أخرى."}},pe={common:{loading:"सधाइन की जुलातीअ लोड हो रही है…",redirecting:"रीडायरेक्ट हो रहا है…",backToSignIn:"साइन इन पर वापस जाएँ"},signIn:{emailPlaceholder:"you@mail.com",codePlaceholder:"साइन-इन कोड आपके ईमेल पर भेज दिया गया है",sendingCode:"साइन-इन कोड भेजा जा रहा है…",signingIn:"साइन इन हो रहा है…",title:"वापसी आपका स्वागत है",subtitle:"जारी रखने के लिए साइन इन करें",emailLabel:"ईमेल",passwordLabel:"पासवर्ड",submitButton:"साइन इन",forgotPassword:"पासवर्ड भूल गए?",switchToSignUp:"खाता बनाएँ",signUpPrompt:"खाता नहीं है?"},signUp:{title:"अपना खाता बनाएँ",subtitle:"अपना नाम, ईमेल और पासवर्ड दर्ज करें",nameLabel:"नाम",emailLabel:"ईमेल",passwordLabel:"पासवर्ड",confirmPasswordLabel:"पासवर्ड की पुष्टि",submitButton:"खाता बनाएँ",switchToSignIn:"साइन इन",signInPrompt:"पहले से खाता है?"},verifyEmail:{title:"अपना ईमेल सत्यापित करें",subtitle:"हमने जो सत्यापन ईमेल भेजा है उससे सेटअप पूरा करें।",sentToLabel:"भेजा गया",resendButton:"सत्यापन ईमेल फिर से भेजें",resendCountdown:"{seconds} सेकंड में फिर से भेजें",changeEmailButton:"दूसरा ईमेल इस्तेमाल करें"},forgotPassword:{title:"पासवर्ड रीसेट करें",subtitle:"अपना ईमेल दर्ज करें और हम रीसेट कोड भेजेंगे।",emailLabel:"ईमेल",submitButton:"रीसेट कोड भेजें"},resetPassword:{title:"नया पासवर्ड सेट करें",subtitle:"पासवर्ड रीसेट पूरा करने के लिए ईमेल में प्राप्त कोड का उपयोग करें।",codeLabel:"सत्यापन कोड",newPasswordLabel:"नया पासवर्ड",confirmPasswordLabel:"पासवर्ड की पुष्टि",submitButton:"पासवर्ड अपडेट करें",resendCodeButton:"कोड फिर से भेजें",resendCountdown:"{seconds} सेकंड में फिर से भेजें"},oauth:{redirecting:"{provider} पर भेजा जा रहा है…",dividerText:"या",continueWith:"से जारी रखें"},errors:{invalidEmail:"कृपया एक वैध ईमेल पता दर्ज करें।",requiredField:"यह फ़ील्ड आवश्यक है।",passwordTooShort:"पासवर्ड कम से कम {min} अक्षरों का होना चाहिए।",passwordMismatch:"पासवर्ड मेल नहीं खाते।",invalidCode:"कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",generic:"कुछ गलत हो गई। कृपया फिर से प्रयास करें।"}},Ce={en:H,"en-US":H,zh:q,"zh-CN":q,"zh-TW":q,ja:de,"ja-JP":de,ko:le,"ko-KR":le,es:K,"es-ES":K,"es-MX":K,pt:ce,"pt-BR":ce,fr:ue,"fr-FR":ue,de:he,"de-DE":he,it:me,"it-IT":me,ru:ge,"ru-RU":ge,ar:fe,"ar-SA":fe,hi:pe,"hi-IN":pe};function ze(){if(typeof navigator>"u")return H;const t=navigator.languages??[navigator.language];for(const e of t){const i=Ce[e]??Ce[e.split("-")[0]];if(i)return i}return H}const ve={LIGHT:"light",DARK:"dark"},Ee=ve.LIGHT,xe=ve.DARK,Se=[Ee,xe],Ge=Ee,je={BACKGROUND:"--edgespark-auth-bg",BACKGROUND_MUTED:"--edgespark-auth-bg-muted",CARD_BACKGROUND:"--edgespark-auth-card-bg",BORDER:"--edgespark-auth-border",TEXT:"--edgespark-auth-text",TEXT_MUTED:"--edgespark-auth-text-muted",DIVIDER_BACKGROUND:"--edgespark-auth-divider-bg",PRIMARY:"--edgespark-auth-primary",PRIMARY_HOVER:"--edgespark-auth-primary-hover",PRIMARY_CONTRAST:"--edgespark-auth-primary-contrast",ERROR:"--edgespark-auth-error",INFO:"--edgespark-auth-info",CARD_RADIUS:"--edgespark-auth-radius-card",CONTROL_RADIUS:"--edgespark-auth-radius-control",SHADOW:"--edgespark-auth-shadow",FONT:"--edgespark-auth-font",MODAL_BACKDROP:"--edgespark-auth-modal-backdrop",MODAL_CARD_BACKGROUND:"--edgespark-auth-modal-card-bg",MODAL_SHADOW:"--edgespark-auth-modal-shadow"},qe=Object.values(je);function At(t){return typeof t=="string"&&Se.includes(t)}function Lt(t){return qe.includes(t)}function Ct(t){var e;return{theme:(t==null?void 0:t.theme)??Ge,className:((e=t==null?void 0:t.className)==null?void 0:e.trim())??"",variables:{...(t==null?void 0:t.variables)??{}}}}function ee(t,e="Authentication failed."){return be(t,e)}async function V(t){var i,s;const e=await t.getSession();if(e.error)throw new _(e.error.message||"Failed to load the current session.",{code:e.error.code??"SESSION_LOOKUP_FAILED",status:e.error.status,cause:e.error});return(i=e.data)!=null&&i.user&&((s=e.data)!=null&&s.session)?{user:e.data.user,session:e.data}:{user:null,session:null}}let Tt=0;const Rt="data-edgespark-auth",Ut="data-edgespark-auth-theme",r="edgespark-auth",te="es_auth_completion",F="es_auth_email",ie="oauth",N="verify-sign-in",R="verify-sign-up",Te=200,se=2,$t={"&":"&","<":"<",">":">",'"':""","'":"'"},Re={google:"Google",apple:"Apple",microsoft:"Microsoft",github:"GitHub",gitlab:"GitLab",discord:"Discord"};function U(t){return"redirectTo"in t}function ne(t){return"onSuccess"in t&&!("redirectTo"in t)}function z(t){return!t||typeof t!="string"?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim())}function Ue(t){return/^\d{6}$/.test(t.trim())}function kt(t){return t==="email"||t==="name"||t==="password"||t==="confirmPassword"||t==="code"||t==="newPassword"}function Ot(t){return!!(t.error||t.errorDescription)}class Bt{constructor(e,i,s,n,o){this.container=e,this.auth=i,this.options=s,this.loadConfig=n,this.runtimeOptions=o,this.fieldIdPrefix=`edgespark-auth-${++Tt}`,this.state={view:"loading",busy:!0,busyLabel:void 0,error:null,notice:null,email:"",name:"",password:"",confirmPassword:"",code:"",newPassword:"",signInMethod:"password",signInOtpSent:!1},this.destroyed=!1,this.terminalActionInProgress=!1,this.config=null,this.countdownUntil=null,this.countdownTimer=null,this.pendingFocusSnapshot=null,this.focusRestoreTimer=null,this.verificationCompletionAction=null;const d=Ct(s.appearance);this.labels=It(ze(),s.labels),this.root=document.createElement("div"),this.root.className=d.className?`${r} ${d.className}`:r,this.root.setAttribute(Rt,""),this.root.setAttribute(Ut,d.theme);for(const[h,g]of Object.entries(d.variables))g!==void 0&&this.root.style.setProperty(h,g);e.appendChild(this.root),this.render(),this.initialize()}destroy(){this.destroyed||(this.destroyed=!0,this.clearCountdown(),this.clearFocusRestoreTimer(),this.root.remove())}async initialize(){const e=this.consumeManagedReturnContext();try{const[i,s]=await Promise.allSettled([this.loadConfig(),this.readMountSession(e)]);if(this.destroyed)return;if(s.status==="rejected"){if(e.marker&&!Ot(e)&&U(this.options)){this.redirectAfterManagedReturnLookupFailure();return}}else{const o=s.value;if(o.user&&o.session){switch(e.marker){case ie:case N:await this.completeAuth("sign-in",o);return;case R:await this.completeAuth("sign-up",o);return;default:break}this.handleExistingSessionOnMount();return}}if(i.status==="rejected")throw s.status==="rejected"?s.reason:i.reason;if(this.config=i.value,this.state.signInMethod=this.resolveInitialSignInMethod(),this.handleSessionlessManagedReturn(e))return;if(s.status==="rejected")throw s.reason;const n=s.value;this.state.view="sign-in",this.state.busy=!1,this.state.busyLabel=void 0,this.render()}catch(i){this.handleError(i,"Failed to load the authentication UI.")}}redirectAfterManagedReturnLookupFailure(){U(this.options)&&this.navigateToRedirect()}navigateToRedirect(){U(this.options)&&(this.terminalActionInProgress=!0,this.state.busy=!0,this.state.busyLabel=this.labels.common.redirecting,this.state.error=null,this.state.notice=null,this.render(),window.location.assign(_t(this.options.redirectTo).toString()))}async readMountSession(e){if(!e.marker)return V(this.auth);let i=null;for(let s=0;s<=se;s++){try{const n=await V(this.auth);if(n.user&&n.session)return n}catch(n){i=n}s<se&&await new Promise(n=>setTimeout(n,Te))}if(i)throw i;return{user:null,session:null}}render(){if(this.destroyed)return;const e=this.captureFocusSnapshot();if(e&&(this.pendingFocusSnapshot=e),this.root.dataset.authAction=this.state.busy?this.state.busyAction??"loading":"idle",!this.config){this.root.innerHTML=this.renderLoading();return}this.root.innerHTML=`
|
|
2
|
+
<div class="${r}__shell">
|
|
3
|
+
${this.renderDevModeBanner()}
|
|
4
|
+
<div class="${r}__card">
|
|
5
|
+
${this.renderStatus()}
|
|
6
|
+
${this.renderCurrentView()}
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
`,this.bindDOM(),this.scheduleFocusRestore()}renderLoading(){return`
|
|
10
|
+
<div class="${r}__shell">
|
|
11
|
+
<div class="${r}__card" aria-busy="${!this.state.error}">
|
|
12
|
+
${this.renderStatus()}
|
|
13
|
+
${this.state.error?"":`
|
|
14
|
+
<p class="${r}__sr-only" role="status">${this.escape(this.labels.common.loading)}</p>
|
|
15
|
+
<div class="${r}__section ${r}__skeleton" aria-hidden="true">
|
|
16
|
+
<div class="${r}__skeleton-label"></div>
|
|
17
|
+
<div class="${r}__skeleton-input"></div>
|
|
18
|
+
<div class="${r}__skeleton-button"></div>
|
|
19
|
+
<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>
|
|
20
|
+
<div class="${r}__skeleton-button ${r}__skeleton-button--secondary"></div>
|
|
21
|
+
</div>
|
|
22
|
+
`}
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
`}renderDevModeBanner(){var e;return(e=this.config)!=null&&e.isLocalDev?`<div class="${r}__dev-banner">Local dev mode — emails are mocked, OAuth uses test identities</div>`:""}renderStatus(){var i;const e=[];return this.state.error&&e.push(`<div role="alert" class="${r}__status ${r}__status--error">${this.escape(this.state.error)}</div>`),this.state.notice&&e.push(`<div role="status" class="${this.state.view==="sign-in"&&this.state.signInOtpSent&&!((i=this.config)!=null&&i.isLocalDev)?`${r}__sr-only`:`${r}__status ${r}__status--info`}">${this.escape(this.state.notice)}</div>`),this.state.busy&&this.state.busyLabel&&!this.state.busyAction&&e.push(`<div class="${r}__status ${r}__status--muted">${this.escape(this.state.busyLabel)}</div>`),e.join("")}renderCurrentView(){switch(this.state.view){case"sign-in":return this.renderSignInView();case"sign-up":return this.renderSignUpView();case"verify-email":return this.renderVerifyEmailView();case"forgot-password":return this.renderForgotPasswordView();case"reset-password":return this.renderResetPasswordView();case"loading":default:return`<p class="${r}__copy">${this.escape(this.labels.common.loading)}</p>`}}renderSignInView(){var b,p,E,l;const e=this.renderOAuthProviders(),i=!!((b=this.config)!=null&&b.emailPasswordEnabled),s=!!((p=this.config)!=null&&p.emailOtpSignInEnabled),n=i||s,o=i&&s,d=s&&!i?"otp":this.state.signInMethod,h=d==="otp",g=h?this.state.signInOtpSent?this.labels.signIn.verifyCodeButton??"Verify code":this.labels.signIn.sendCodeButton??"Send code":this.labels.signIn.submitButton,P=this.countdownText(this.labels.signIn.resendCodeButton??"Resend code",this.labels.signIn.resendCountdown??"Resend in {seconds}s");return`
|
|
26
|
+
<section class="${r}__section">
|
|
27
|
+
<header class="${r}__header">
|
|
28
|
+
<h1 class="${r}__title">${this.escape(this.labels.signIn.title)}</h1>
|
|
29
|
+
<p class="${r}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
|
|
30
|
+
</header>
|
|
31
|
+
${e}
|
|
32
|
+
${e&&n?`<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>`:""}
|
|
33
|
+
${n?`
|
|
34
|
+
${o?`
|
|
35
|
+
<div class="${r}__tabs" role="tablist" aria-label="Sign-in method">
|
|
36
|
+
<button class="${r}__tab ${d==="password"?`${r}__tab--active`:""}" type="button" data-action="sign-in-method" data-method="password" ${this.state.busy?"disabled":""}>
|
|
37
|
+
${this.escape(this.labels.signIn.passwordTab??"Password")}
|
|
38
|
+
</button>
|
|
39
|
+
<button class="${r}__tab ${d==="otp"?`${r}__tab--active`:""}" type="button" data-action="sign-in-method" data-method="otp" ${this.state.busy?"disabled":""}>
|
|
40
|
+
${this.escape(this.labels.signIn.codeTab??"Code")}
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
`:""}
|
|
44
|
+
<form class="${r}__form" data-view="sign-in" novalidate>
|
|
45
|
+
${this.renderInput("email",this.labels.signIn.emailLabel,"email",this.state.email,"email",this.labels.signIn.emailPlaceholder)}
|
|
46
|
+
${h?this.state.signInOtpSent?this.renderInput("code",this.labels.signIn.codeLabel??"Code","text",this.state.code,"one-time-code",this.labels.signIn.codePlaceholder,`
|
|
47
|
+
<button class="${r}__text-action" type="button" data-action="resend-sign-in-code" aria-busy="${this.state.busy&&this.state.busyAction==="resend-code"}" ${this.state.busy||this.isCountdownActive()?"disabled":""}>
|
|
48
|
+
${this.escape(this.state.busy&&this.state.busyAction==="resend-code"?this.state.busyLabel??P:P)}
|
|
49
|
+
</button>
|
|
50
|
+
`):"":this.renderInput("password",this.labels.signIn.passwordLabel,"password",this.state.password,"current-password")}
|
|
51
|
+
<button class="${r}__button ${r}__button--primary" type="submit" aria-busy="${this.state.busy&&(this.state.busyAction==="sign-in"||this.state.busyAction==="send-code")}" ${this.state.busy?"disabled":""}>
|
|
52
|
+
${this.escape(this.state.busy&&(this.state.busyAction==="sign-in"||this.state.busyAction==="send-code")?this.state.busyLabel??g:g)}
|
|
53
|
+
</button>
|
|
54
|
+
</form>
|
|
55
|
+
<div class="${r}__actions">
|
|
56
|
+
${!h&&this.canUsePasswordResetEmailOtp()?`
|
|
57
|
+
<button class="${r}__link" type="button" data-action="forgot-password" ${this.state.busy?"disabled":""}>
|
|
58
|
+
${this.escape(this.labels.signIn.forgotPassword)}
|
|
59
|
+
</button>
|
|
60
|
+
`:""}
|
|
61
|
+
${!((E=this.config)!=null&&E.disableSignUp)&&((l=this.config)!=null&&l.emailPasswordEnabled)?`
|
|
62
|
+
<p class="${r}__meta">
|
|
63
|
+
${this.escape(this.labels.signIn.signUpPrompt)}
|
|
64
|
+
<button class="${r}__link" type="button" data-action="switch-sign-up" ${this.state.busy?"disabled":""}>
|
|
65
|
+
${this.escape(this.labels.signIn.switchToSignUp)}
|
|
66
|
+
</button>
|
|
67
|
+
</p>
|
|
68
|
+
`:""}
|
|
69
|
+
</div>
|
|
70
|
+
`:""}
|
|
71
|
+
</section>
|
|
72
|
+
`}renderSignUpView(){const e=this.renderOAuthProviders();return`
|
|
73
|
+
<section class="${r}__section">
|
|
74
|
+
<header class="${r}__header">
|
|
75
|
+
<h1 class="${r}__title">${this.escape(this.labels.signUp.title)}</h1>
|
|
76
|
+
<p class="${r}__copy">${this.escape(this.labels.signUp.subtitle)}</p>
|
|
77
|
+
</header>
|
|
78
|
+
${e}
|
|
79
|
+
${e?`<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>`:""}
|
|
80
|
+
<form class="${r}__form" data-view="sign-up" novalidate>
|
|
81
|
+
${this.renderInput("name",this.labels.signUp.nameLabel,"text",this.state.name,"name")}
|
|
82
|
+
${this.renderInput("email",this.labels.signUp.emailLabel,"email",this.state.email,"email")}
|
|
83
|
+
${this.renderInput("password",this.labels.signUp.passwordLabel,"password",this.state.password,"new-password")}
|
|
84
|
+
${this.renderInput("confirmPassword",this.labels.signUp.confirmPasswordLabel,"password",this.state.confirmPassword,"new-password")}
|
|
85
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy?"disabled":""}>
|
|
86
|
+
${this.escape(this.labels.signUp.submitButton)}
|
|
87
|
+
</button>
|
|
88
|
+
</form>
|
|
89
|
+
<p class="${r}__meta">
|
|
90
|
+
${this.escape(this.labels.signUp.signInPrompt)}
|
|
91
|
+
<button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy?"disabled":""}>
|
|
92
|
+
${this.escape(this.labels.signUp.switchToSignIn)}
|
|
93
|
+
</button>
|
|
94
|
+
</p>
|
|
95
|
+
</section>
|
|
96
|
+
`}renderVerifyEmailView(){const e=this.countdownText(this.labels.verifyEmail.resendButton,this.labels.verifyEmail.resendCountdown);return`
|
|
97
|
+
<section class="${r}__section">
|
|
98
|
+
<header class="${r}__header">
|
|
99
|
+
<h1 class="${r}__title">${this.escape(this.labels.verifyEmail.title)}</h1>
|
|
100
|
+
<p class="${r}__copy">${this.escape(this.labels.verifyEmail.subtitle)}</p>
|
|
101
|
+
</header>
|
|
102
|
+
<p class="${r}__copy">
|
|
103
|
+
<strong>${this.escape(this.labels.verifyEmail.sentToLabel)}:</strong>
|
|
104
|
+
${this.escape(this.state.email)}
|
|
105
|
+
</p>
|
|
106
|
+
<div class="${r}__stack">
|
|
107
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="resend-verification" ${this.state.busy||this.isCountdownActive()?"disabled":""}>
|
|
108
|
+
${this.escape(e)}
|
|
109
|
+
</button>
|
|
110
|
+
<button class="${r}__link" type="button" data-action="use-different-email" ${this.state.busy?"disabled":""}>
|
|
111
|
+
${this.escape(this.labels.verifyEmail.changeEmailButton)}
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
</section>
|
|
115
|
+
`}renderForgotPasswordView(){return`
|
|
116
|
+
<section class="${r}__section">
|
|
117
|
+
<header class="${r}__header">
|
|
118
|
+
<h1 class="${r}__title">${this.escape(this.labels.forgotPassword.title)}</h1>
|
|
119
|
+
<p class="${r}__copy">${this.escape(this.labels.forgotPassword.subtitle)}</p>
|
|
120
|
+
</header>
|
|
121
|
+
<form class="${r}__form" data-view="forgot-password" novalidate>
|
|
122
|
+
${this.renderInput("email",this.labels.forgotPassword.emailLabel,"email",this.state.email,"email")}
|
|
123
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy?"disabled":""}>
|
|
124
|
+
${this.escape(this.labels.forgotPassword.submitButton)}
|
|
125
|
+
</button>
|
|
126
|
+
</form>
|
|
127
|
+
<button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy?"disabled":""}>
|
|
128
|
+
${this.escape(this.labels.common.backToSignIn)}
|
|
129
|
+
</button>
|
|
130
|
+
</section>
|
|
131
|
+
`}renderResetPasswordView(){const e=this.countdownText(this.labels.resetPassword.resendCodeButton,this.labels.resetPassword.resendCountdown);return`
|
|
132
|
+
<section class="${r}__section">
|
|
133
|
+
<header class="${r}__header">
|
|
134
|
+
<h1 class="${r}__title">${this.escape(this.labels.resetPassword.title)}</h1>
|
|
135
|
+
<p class="${r}__copy">${this.escape(this.labels.resetPassword.subtitle)}</p>
|
|
136
|
+
</header>
|
|
137
|
+
<form class="${r}__form" data-view="reset-password" novalidate>
|
|
138
|
+
${this.renderInput("code",this.labels.resetPassword.codeLabel,"text",this.state.code,"one-time-code")}
|
|
139
|
+
${this.renderInput("newPassword",this.labels.resetPassword.newPasswordLabel,"password",this.state.newPassword,"new-password")}
|
|
140
|
+
${this.renderInput("confirmPassword",this.labels.resetPassword.confirmPasswordLabel,"password",this.state.confirmPassword,"new-password")}
|
|
141
|
+
<button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy?"disabled":""}>
|
|
142
|
+
${this.escape(this.labels.resetPassword.submitButton)}
|
|
143
|
+
</button>
|
|
144
|
+
</form>
|
|
145
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="resend-reset-code" ${this.state.busy||this.isCountdownActive()?"disabled":""}>
|
|
146
|
+
${this.escape(e)}
|
|
147
|
+
</button>
|
|
148
|
+
<button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy?"disabled":""}>
|
|
149
|
+
${this.escape(this.labels.common.backToSignIn)}
|
|
150
|
+
</button>
|
|
151
|
+
</section>
|
|
152
|
+
`}renderOAuthProviders(){var i;const e=((i=this.config)==null?void 0:i.oauthProviders)??[];return e.length===0?"":`
|
|
153
|
+
<div class="${r}__stack">
|
|
154
|
+
${e.map(s=>`
|
|
155
|
+
<button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${s}" aria-busy="${this.state.busy&&this.state.busyAction===`oauth:${s}`}" ${this.state.busy?"disabled":""}>
|
|
156
|
+
${this.escape(this.state.busy&&this.state.busyAction===`oauth:${s}`?this.state.busyLabel??this.labels.common.redirecting:`${this.labels.oauth.continueWith} ${Re[s]}`)}
|
|
157
|
+
</button>
|
|
158
|
+
`).join("")}
|
|
159
|
+
</div>
|
|
160
|
+
`}renderInput(e,i,s,n,o,d="",h=""){const g=`${this.fieldIdPrefix}-${e}`;return`
|
|
161
|
+
<div class="${r}__field">
|
|
162
|
+
<div class="${r}__field-heading">
|
|
163
|
+
<label class="${r}__label" for="${g}">${this.escape(i)}</label>
|
|
164
|
+
${h}
|
|
165
|
+
</div>
|
|
166
|
+
<input
|
|
167
|
+
id="${g}"
|
|
168
|
+
placeholder="${this.escape(d)}"
|
|
169
|
+
class="${r}__input"
|
|
170
|
+
name="${this.escape(e)}"
|
|
171
|
+
type="${this.escape(s)}"
|
|
172
|
+
value="${this.escape(n)}"
|
|
173
|
+
autocomplete="${this.escape(o)}"
|
|
174
|
+
${this.state.busy?"disabled":""}
|
|
175
|
+
/>
|
|
176
|
+
</div>
|
|
177
|
+
`}bindDOM(){this.root.querySelectorAll("form[data-view]").forEach(n=>{n.addEventListener("submit",o=>{o.preventDefault();const d=n.dataset.view;d==="sign-in"&&this.handleSignIn(),d==="sign-up"&&this.handleSignUp(),d==="forgot-password"&&this.handleForgotPassword(),d==="reset-password"&&this.handleResetPassword()})}),this.root.querySelectorAll("input[name]").forEach(n=>{n.addEventListener("input",()=>{kt(n.name)&&(this.state[n.name]=n.value,n.name==="email"&&this.state.signInOtpSent&&(this.state.signInOtpSent=!1,this.state.code="",this.clearCountdown(),this.state.notice=null,this.state.error=null,this.render()))})}),this.root.querySelectorAll("[data-action]").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.action;o==="switch-sign-up"&&this.switchView("sign-up"),o==="switch-sign-in"&&this.switchView("sign-in"),o==="forgot-password"&&this.switchView("forgot-password"),o==="resend-verification"&&this.resendVerificationEmail(),o==="use-different-email"&&this.switchView(this.verificationCompletionAction==="sign-in"?"sign-in":"sign-up"),o==="sign-in-method"&&this.setSignInMethod(n.dataset.method==="otp"?"otp":"password"),o==="resend-sign-in-code"&&this.resendSignInCode(),o==="resend-reset-code"&&this.resendResetCode(),o==="oauth"&&this.handleOAuthSignIn(n.dataset.provider)})})}switchView(e){this.clearCountdown(),e!=="verify-email"&&(this.verificationCompletionAction=null),this.state.view=e,this.state.error=null,this.state.notice=null,this.state.busy=!1,this.state.busyLabel=void 0,this.terminalActionInProgress=!1,this.render()}async handleSignIn(){var i,s;if(((i=this.config)!=null&&i.emailOtpSignInEnabled&&!((s=this.config)!=null&&s.emailPasswordEnabled)?"otp":this.state.signInMethod)==="otp"){await this.handleEmailOtpSignIn();return}if(!z(this.state.email)){this.failValidation(this.labels.errors.invalidEmail);return}if(!this.state.password){this.failValidation(this.labels.errors.requiredField);return}await this.runAction(this.labels.signIn.signingIn??this.labels.common.loading,async()=>{const n=await this.auth.signIn.email({email:this.state.email.trim(),password:this.state.password,callbackURL:this.getManagedReturnURL(N,this.state.email.trim())});if(n.error)throw n.error;await this.completeAuth("sign-in")},"sign-in")}async handleEmailOtpSignIn(){if(!this.canUseEmailOtpSignIn()){this.handleError(new w("Email OTP sign-in is not enabled for this project."));return}if(!z(this.state.email)){this.failValidation(this.labels.errors.invalidEmail);return}if(!this.state.signInOtpSent){await this.sendSignInOtp();return}if(!Ue(this.state.code)){this.failValidation(this.labels.errors.invalidCode);return}await this.runAction(this.labels.signIn.signingIn??this.labels.common.loading,async()=>{const e=await this.emailOtpSignInEndpoints().signIn.emailOtp({email:this.state.email.trim(),otp:this.state.code.trim()});if(e.error)throw e.error;await this.completeAuth("sign-in",await this.resolveAuthCompletionData(e.data))},"sign-in")}async sendSignInOtp(e=!1){await this.runAction(this.labels.signIn.sendingCode??this.labels.common.loading,async()=>{var s;const i=await this.emailOtpSignInEndpoints().emailOtp.sendVerificationOtp({email:this.state.email.trim(),type:"sign-in"});if(i.error)throw i.error;if(this.state.signInOtpSent=!0,this.state.code="",(s=this.config)!=null&&s.isLocalDev){this.state.busyLabel="Dev mode: fetching sign-in code...",this.render();const n=await Pt(this.state.email.trim());n?(this.state.code=n,this.state.notice=`Dev mode: sign-in code auto-filled (${n})`):this.state.notice="Dev mode: could not retrieve sign-in code — check server logs"}else this.state.notice=this.labels.signIn.codePlaceholder??this.labels.signIn.codeLabel??"Code";this.startCountdown()},e?"resend-code":"send-code")}async resendSignInCode(){this.isCountdownActive()||await this.sendSignInOtp(!0)}async handleSignUp(){var e,i;if(!this.state.name.trim()){this.failValidation(this.labels.errors.requiredField);return}if(!z(this.state.email)){this.failValidation(this.labels.errors.invalidEmail);return}if(!this.state.password){this.failValidation(this.labels.errors.requiredField);return}if(this.state.password.length<(((e=this.config)==null?void 0:e.minPasswordLength)??8)){this.failValidation(this.labels.errors.passwordTooShort.replace("{min}",String(((i=this.config)==null?void 0:i.minPasswordLength)??8)));return}if(this.state.password!==this.state.confirmPassword){this.failValidation(this.labels.errors.passwordMismatch);return}await this.runAction("Creating account…",async()=>{var n;const s=await this.auth.signUp.email({name:this.state.name.trim(),email:this.state.email.trim(),password:this.state.password,callbackURL:this.getManagedReturnURL(R,this.state.email.trim())});if(s.error)throw s.error;if((n=this.config)!=null&&n.requireEmailVerification){if(this.config.isLocalDev&&await this.tryDevAutoVerify("sign-up",s.data))return;this.verificationCompletionAction="sign-up",this.state.view="verify-email",this.state.notice=this.config.isLocalDev?"Dev mode: auto-verify didn’t complete. Click resend to retry.":"Check your inbox to verify your email address.",this.startCountdown();return}await this.completeAuth("sign-up",await this.resolveAuthCompletionData(s.data))})}async handleOAuthSignIn(e){const i=(this.labels.oauth.redirecting??this.labels.common.redirecting).replace("{provider}",Re[e]);await this.runAction(i,async()=>{const s=await this.auth.signIn.social({provider:e,callbackURL:this.getManagedReturnURL("oauth"),errorCallbackURL:this.getManagedReturnURL("oauth")});if(s.error)throw s.error;const n=this.extractRedirectURL(s.data);if(!n)throw new w(`OAuth sign-in did not return a redirect URL for provider "${e}".`);this.terminalActionInProgress=!0,this.state.busy=!0,this.state.busyLabel=i,this.state.error=null,this.state.notice=null,this.render(),window.location.assign(n)},`oauth:${e}`)}async handleForgotPassword(){if(!this.canUsePasswordResetEmailOtp()){this.handleError(new w("Password reset via email OTP is not enabled for this project."));return}if(!z(this.state.email)){this.failValidation(this.labels.errors.invalidEmail);return}await this.runAction("Sending reset code…",async()=>{var i;const e=await this.passwordResetEndpoints().forgetPassword.emailOtp({email:this.state.email.trim()});if(e.error)throw e.error;if(this.state.view="reset-password",(i=this.config)!=null&&i.isLocalDev){this.state.busyLabel="Dev mode: fetching reset code…",this.render();const s=await St(this.state.email.trim());s?(this.state.code=s,this.state.notice=`Dev mode: reset code auto-filled (${s})`):this.state.notice="Dev mode: could not retrieve reset code — check server logs"}else this.state.notice=`We sent a reset code to ${this.state.email.trim()}.`;this.startCountdown()})}async resendResetCode(){this.isCountdownActive()||await this.handleForgotPassword()}async handleResetPassword(){var e,i;if(!this.canUsePasswordResetEmailOtp()){this.handleError(new w("Password reset via email OTP is not enabled for this project."));return}if(!Ue(this.state.code)){this.failValidation(this.labels.errors.invalidCode);return}if(!this.state.newPassword){this.failValidation(this.labels.errors.requiredField);return}if(this.state.newPassword.length<(((e=this.config)==null?void 0:e.minPasswordLength)??8)){this.failValidation(this.labels.errors.passwordTooShort.replace("{min}",String(((i=this.config)==null?void 0:i.minPasswordLength)??8)));return}if(this.state.newPassword!==this.state.confirmPassword){this.failValidation(this.labels.errors.passwordMismatch);return}await this.runAction("Updating password…",async()=>{const s=await this.passwordResetEndpoints().emailOtp.resetPassword({email:this.state.email.trim(),otp:this.state.code.trim(),password:this.state.newPassword});if(s.error)throw s.error;await this.completePasswordReset()})}async resendVerificationEmail(){var e;if((e=this.config)!=null&&e.isLocalDev){if(this.isCountdownActive())return;await this.runAction("Dev mode: retrying auto-verify…",async()=>{const i=this.verificationCompletionAction??"sign-in";if(!await this.tryDevAutoVerify(i))throw new Error("Dev auto-verify did not complete. Check the edgespark dev logs and try again.")});return}await this.sendVerificationEmail(!1)}async tryDevAutoVerify(e,i){const s=this.state.email.trim();try{return this.state.busyLabel="Dev mode: auto-verifying email…",this.render(),await Et(s)?(this.state.notice="Dev mode: email verification auto-completed",await this.completeAuth(e,await this.resolveAuthCompletionData(i)),!0):(console.warn("[edgespark] Dev auto-verify returned false — falling through"),!1)}catch(n){return console.warn("[edgespark] Dev auto-verify failed:",n),!1}}async sendVerificationEmail(e){!e&&this.isCountdownActive()||await this.runAction("Sending verification email…",async()=>{const i=await this.auth.sendVerificationEmail({email:this.state.email.trim(),callbackURL:this.getManagedReturnURL(this.verificationCompletionAction==="sign-up"?R:N,this.state.email.trim())});if(i.error)throw i.error;this.handleVerificationEmailSent(this.state.email.trim(),!0)})}async completeAuth(e,i){const s=await this.retryAuthCompletionDataIfNeeded(i??await this.resolveAuthCompletionData());if(this.destroyed)return;if(!s.user||!s.session){if(this.destroyed)return;if(s.lookupError&&U(this.options)){this.navigateToRedirect();return}if(e==="sign-in")throw s.lookupError??new we("Managed sign-in completed without an authenticated session.");this.state.view="sign-in",this.state.password="",this.state.confirmPassword="",this.state.error=null,this.state.busy=!1,this.state.busyLabel=void 0,this.state.notice="Account created. Sign in to continue.",this.render();return}const n={action:e,user:s.user,session:s.session};if(await this.syncPublicSessionBestEffort(),!this.destroyed){if(U(this.options)){this.invokeRedirectModeSuccessHook(n),this.navigateToRedirect();return}if(ne(this.options)){this.options.onSuccess(n),this.terminalActionInProgress=!0;return}}}async retryAuthCompletionDataIfNeeded(e){if(e.session)return e;let i=e.lookupError;for(let s=0;s<se;s++){await new Promise(n=>setTimeout(n,Te));try{const n=await V(this.auth);if(n.user&&n.session)return{user:n.user,session:n.session}}catch(n){i=n}}return{...e,lookupError:i??e.lookupError}}async syncPublicSessionBestEffort(){var e,i;try{await((i=(e=this.runtimeOptions)==null?void 0:e.syncPublicSession)==null?void 0:i.call(e))}catch{}}async resolveAuthCompletionData(e){try{const i=await V(this.auth),s=this.extractUser(e);return{user:i.user??s,session:i.session}}catch(i){return{user:this.extractUser(e),session:null,lookupError:i}}}async completePasswordReset(){const e={action:"password-reset",user:null,session:null};if(await this.syncPublicSessionBestEffort(),!this.destroyed){if(ne(this.options)){this.clearCountdown(),this.options.onSuccess(e),this.terminalActionInProgress=!0;return}this.invokeRedirectModeSuccessHook(e),this.clearCountdown(),this.state.view="sign-in",this.state.password="",this.state.confirmPassword="",this.state.newPassword="",this.state.code="",this.state.busy=!1,this.state.busyLabel=void 0,this.state.error=null,this.state.notice="Password updated. Sign in with your new password.",this.render()}}handleExistingSessionOnMount(){if(U(this.options)){this.navigateToRedirect();return}if(ne(this.options))throw this.state.view="sign-in",this.state.busy=!1,this.state.busyLabel=void 0,this.state.notice=null,new w("authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI.")}async runAction(e,i,s){this.state.busyAction=s,this.state.busy=!0,this.state.busyLabel=e,this.state.error=null,this.state.notice=null,this.render();try{await i()}catch(n){if(this.maybeHandleVerificationRequired(n))return;this.handleError(n);return}!this.destroyed&&!this.terminalActionInProgress&&(this.state.busy=!1,this.state.busyLabel=void 0,this.render())}maybeHandleVerificationRequired(e){return ee(e).code!=="EMAIL_NOT_VERIFIED"?!1:(this.verificationCompletionAction="sign-in",this.state.view="verify-email",this.state.busy=!1,this.state.busyLabel=void 0,this.state.error=null,this.state.notice=`Verify your email to finish signing in as ${this.state.email.trim()}.`,this.render(),this.sendVerificationEmail(!0),!0)}handleVerificationEmailSent(e,i){this.state.notice=i?`We sent another verification email to ${e}.`:`We sent a verification email to ${e}.`,this.startCountdown()}invokeRedirectModeSuccessHook(e){var i,s;if(!(!U(this.options)||!this.options.onSuccess))try{this.options.onSuccess(e)}catch(n){const o=ee(n,"Post-auth callback failed.");try{(s=(i=this.options).onError)==null||s.call(i,o)}catch{}}}handleError(e,i){var n,o;const s=ee(e,i);this.state.busy=!1,this.state.busyLabel=void 0,this.state.error=s.message,this.render(),(o=(n=this.options).onError)==null||o.call(n,s)}failValidation(e){this.state.error=e,this.state.notice=null,this.render()}getManagedReturnURL(e,i){if(!e)return window.location.href;const s=new URL(window.location.href);return s.searchParams.set(te,e),i?s.searchParams.set(F,i):s.searchParams.delete(F),s.toString()}consumeManagedReturnContext(){const e=new URL(window.location.href),i=e.searchParams.get(te),s=i===ie||i===N||i===R?i:null,n=e.searchParams.get(F),o=s?e.searchParams.get("error"):null,d=s?e.searchParams.get("error_description"):null;return(s||n)&&(e.searchParams.delete(te),e.searchParams.delete(F),s&&(e.searchParams.delete("error"),e.searchParams.delete("error_description")),window.history.replaceState(null,"",e.toString())),{marker:s,email:n,error:o,errorDescription:d}}startCountdown(e=60){this.countdownUntil=Date.now()+e*1e3,this.countdownTimer&&window.clearInterval(this.countdownTimer),this.countdownTimer=window.setInterval(()=>{if(!this.isCountdownActive()){this.countdownTimer&&(window.clearInterval(this.countdownTimer),this.countdownTimer=null),this.updateCountdownControls();return}this.updateCountdownControls()},1e3)}updateCountdownControls(){const e=[{action:"resend-sign-in-code",base:this.labels.signIn.resendCodeButton??"Resend code",template:this.labels.signIn.resendCountdown??"Resend in {seconds}s"},{action:"resend-verification",base:this.labels.verifyEmail.resendButton,template:this.labels.verifyEmail.resendCountdown},{action:"resend-reset-code",base:this.labels.resetPassword.resendCodeButton,template:this.labels.resetPassword.resendCountdown}];for(const i of e){const s=this.root.querySelector(`[data-action="${i.action}"]`);s&&(i.action==="resend-sign-in-code"&&this.state.busy&&this.state.busyAction==="resend-code"||(s.textContent=this.countdownText(i.base,i.template),s.disabled=this.state.busy||this.isCountdownActive()))}}clearCountdown(){this.countdownUntil=null,this.countdownTimer&&(window.clearInterval(this.countdownTimer),this.countdownTimer=null)}captureFocusSnapshot(){const e=document.activeElement;return!(e instanceof HTMLInputElement)||!this.root.contains(e)||!e.name?null:{name:e.name,type:e.type,selectionStart:e.selectionStart,selectionEnd:e.selectionEnd}}scheduleFocusRestore(){this.pendingFocusSnapshot&&(this.clearFocusRestoreTimer(),this.focusRestoreTimer=window.setTimeout(()=>{if(this.focusRestoreTimer=null,this.destroyed||!this.pendingFocusSnapshot)return;const e=this.pendingFocusSnapshot,i=`input[name="${this.escape(e.name)}"][type="${this.escape(e.type)}"]`,s=this.root.querySelector(i);if(!(!s||s.disabled)){if(s.focus(),e.selectionStart!==null&&e.selectionEnd!==null)try{s.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{const n=s.value.length;s.setSelectionRange(n,n)}this.pendingFocusSnapshot=null}},0))}clearFocusRestoreTimer(){this.focusRestoreTimer!==null&&(window.clearTimeout(this.focusRestoreTimer),this.focusRestoreTimer=null)}passwordResetEndpoints(){return this.auth}emailOtpSignInEndpoints(){return this.auth}resolveInitialSignInMethod(){var e,i;return(e=this.config)!=null&&e.emailPasswordEnabled?"password":(i=this.config)!=null&&i.emailOtpSignInEnabled?"otp":"password"}setSignInMethod(e){this.state.signInMethod!==e&&(this.state.signInMethod=e,this.state.signInOtpSent=!1,this.state.code="",this.state.error=null,this.state.notice=null,this.render())}canUseEmailOtpSignIn(){var e;return!!((e=this.config)!=null&&e.emailOtpSignInEnabled)}extractRedirectURL(e){if(!e||typeof e!="object")return null;const i=e;return i.redirect&&typeof i.url=="string"&&i.url.length>0?i.url:null}extractUser(e){if(!e||typeof e!="object")return null;const i=e;return i.user&&typeof i.user=="object"?i.user:null}canUsePasswordResetEmailOtp(){var e;return!!((e=this.config)!=null&&e.passwordResetEmailOtpEnabled)}handleSessionlessManagedReturn(e){return e.email&&(this.state.email=e.email),e.marker===R&&!e.error?(this.verificationCompletionAction=null,this.clearCountdown(),this.state.view="sign-in",this.state.password="",this.state.confirmPassword="",this.state.error=null,this.state.busy=!1,this.state.busyLabel=void 0,this.state.notice="Account created. Sign in to continue.",this.render(),!0):e.marker===N||e.marker===R?(this.verificationCompletionAction=e.marker===R?"sign-up":"sign-in",this.state.view="verify-email",this.state.busy=!1,this.state.busyLabel=void 0,this.state.notice=null,e.error||e.errorDescription?this.handleError(new _(e.errorDescription??"Verification failed. Request a new verification email and try again.",{code:e.error??"VERIFY_EMAIL_ERROR"})):this.render(),!0):e.marker===ie&&(e.error||e.errorDescription)?(this.state.view="sign-in",this.state.busy=!1,this.state.busyLabel=void 0,this.state.notice=null,this.handleError(new _(e.errorDescription??"OAuth sign-in failed.",{code:e.error??"OAUTH_ERROR"})),!0):!1}isCountdownActive(){return this.getCountdownSecondsRemaining()>0}getCountdownSecondsRemaining(){return this.countdownUntil?Math.max(0,Math.ceil((this.countdownUntil-Date.now())/1e3)):0}countdownText(e,i){const s=this.getCountdownSecondsRemaining();return s<=0?e:i.replace("{seconds}",String(s))}escape(e){return e.replace(/[&<>"']/g,i=>$t[i])}}function Mt(t){return"data"in t&&t.data?t.data:t}const Dt=[{id:"google",key:"providerGoogle"},{id:"apple",key:"providerApple"},{id:"microsoft",key:"providerMicrosoft"},{id:"github",key:"providerGithub"},{id:"gitlab",key:"providerGitlab"},{id:"discord",key:"providerDiscord"}],$e=2,Nt=500;async function Vt(){const t=`${window.location.origin}${Me}/config`;let e;for(let i=0;i<=$e;i++)try{const s=await fetch(t,{method:"GET",credentials:"include"});if(!s.ok)throw new w(`Failed to load auth config: HTTP ${s.status}`);const n=await s.json(),o=Mt(n);return Ht(o,vt())}catch(s){e=s,i<$e&&await new Promise(n=>setTimeout(n,Nt))}throw e}let x=null;async function ke(){return x||(x=Vt().catch(t=>{throw x=null,t})),x}function Ht(t,e=!1){var o,d,h,g,P,b,p,E,l;const i=Dt.filter(({key:I})=>{const L=t[I];return typeof L=="object"&&L!==null&&"enabled"in L&&!!L.enabled}).map(({id:I})=>I),s=t.providerGoogle,n=s!=null&&s.enabled&&typeof((o=s.config)==null?void 0:o.clientId)=="string"?s.config.clientId:null;return{disableSignUp:!!t.disableSignUp,emailPasswordEnabled:!!((d=t.providerEmailPassword)!=null&&d.enabled),emailOtpSignInEnabled:!!((h=t.providerEmailOtp)!=null&&h.enabled),minPasswordLength:((P=(g=t.providerEmailPassword)==null?void 0:g.config)==null?void 0:P.minPasswordLength)??8,requireEmailVerification:!!((p=(b=t.providerEmailPassword)==null?void 0:b.config)!=null&&p.requireEmailVerification),passwordResetEmailOtpEnabled:!!((l=(E=t.providerEmailPassword)==null?void 0:E.config)!=null&&l.requirePasswordResetEmailVerification),oauthProviders:i,googleClientId:n,isLocalDev:e}}const Ft="https://accounts.google.com/gsi/client",Oe="data-edgespark-gsi";let G=null;function re(){var t,e;return(e=(t=window.google)==null?void 0:t.accounts)==null?void 0:e.id}function zt(){if(typeof window>"u")return Promise.reject(new Error("Google Identity Services is unavailable outside the browser."));const t=re();return t?Promise.resolve(t):(G||(G=new Promise((e,i)=>{const s=document.querySelector(`script[${Oe}]`);if(s){const o=re();if(o){e(o);return}s.remove()}const n=document.createElement("script");n.src=Ft,n.async=!0,n.defer=!0,n.setAttribute(Oe,""),n.addEventListener("load",()=>{const o=re();o?e(o):(n.remove(),i(new Error("Google Identity Services loaded but did not expose google.accounts.id.")))},{once:!0}),n.addEventListener("error",()=>{n.remove(),i(new Error("Failed to load Google Identity Services."))},{once:!0}),document.head.appendChild(n)}).catch(e=>{throw G=null,e})),G)}function xt(){return{cancel:()=>{}}}function Gt(t){let e=null;return function(s){if(typeof window>"u")return console.error("[edgespark] promptGoogleOneTap() requires a browser environment."),xt();if(e)return console.warn("[edgespark] promptGoogleOneTap() is already in flight; returning the existing handle. Call cancel() on the original before re-prompting."),e;let n=!1,o=null;const d=()=>{n||(n=!0,e===h&&(e=null))},h={cancel(){if(!n&&(d(),o))try{o.cancel()}catch{}}},g=()=>{var p;if(!n){d();try{(p=s==null?void 0:s.onUnavailable)==null||p.call(s)}catch(E){console.error("[edgespark] onUnavailable threw:",E)}}},P=(p,E)=>{var I;if(n)return;d();const l=be(p,E);try{(I=s==null?void 0:s.onError)==null||I.call(s,l)}catch(L){console.error("[edgespark] onError threw:",L)}},b=(p,E)=>{var l;if(!n){d();try{(l=s==null?void 0:s.onSuccess)==null||l.call(s,{action:"sign-in",user:p,session:E})}catch(I){console.error("[edgespark] onSuccess threw:",I)}}};return e=h,(async()=>{let p;try{p=await t.loadConfig()}catch(l){P(l,"Failed to load auth config for Google One Tap.");return}if(n)return;if(p.isLocalDev){console.error("[edgespark] promptGoogleOneTap() is disabled in local dev mode — Google Identity Services cannot run against mock OAuth."),d();return}const E=p.googleClientId;if(!E){console.error("[edgespark] promptGoogleOneTap() called but Google is not configured. Set `providerGoogle` in `auth-config.yaml` with resolvable credentials."),d();return}try{o=await zt()}catch(l){console.warn("[edgespark] Google Identity Services failed to load; treating as unavailable.",l),g();return}if(!n){o.initialize({client_id:E,callback:l=>{n||typeof(l==null?void 0:l.credential)!="string"||l.credential.length===0||jt(l.credential,t,{emitSuccess:b,emitError:P,isDone:()=>n})},cancel_on_tap_outside:!1,use_fedcm_for_prompt:!0,context:"signin"});try{o.prompt(l=>{var I,L,D,a;if(!n){if((I=l.isDismissedMoment)!=null&&I.call(l)){const m=(L=l.getDismissedReason)==null?void 0:L.call(l);if(m==="credential_returned"||m==="cancel_called")return;g();return}((D=l.isNotDisplayed)!=null&&D.call(l)||(a=l.isSkippedMoment)!=null&&a.call(l))&&g()}})}catch(l){P(l,"Failed to prompt Google One Tap.")}}})(),h}}async function jt(t,e,i){var P;const{emitSuccess:s,emitError:n,isDone:o}=i,d=e.authClient;if(!((P=d.oneTap)!=null&&P.callback)){n(new _("Google One Tap endpoint not registered. Update the EdgeSpark sidecar.",{code:"ONE_TAP_UNAVAILABLE"}),"Google One Tap endpoint not registered.");return}try{const b=await d.oneTap.callback({idToken:t});if(o())return;if(b.error){n(new _(b.error.message??"Google One Tap sign-in failed.",{code:b.error.code??"ONE_TAP_FAILED",status:b.error.status,cause:b.error}),"Google One Tap sign-in failed.");return}}catch(b){if(o())return;n(b,"Google One Tap sign-in failed.");return}let h=null,g=null;try{const b=await V(e.authClient);if(o())return;h=b.user,g=b.session}catch(b){if(o())return;n(b,"Sign-in succeeded but session lookup failed.");return}if(!h||!g){n(new _("Google One Tap completed without an authenticated session.",{code:"ONE_TAP_NO_SESSION"}),"Google One Tap completed without an authenticated session.");return}s(h,g)}const j=new WeakMap;function qt(t){if(!t)throw new w("authUI.mount(container, options) requires either { redirectTo } or { onSuccess }.");const e="redirectTo"in t,i="onSuccess"in t&&typeof t.onSuccess=="function";if(!e&&!i)throw new w("authUI.mount(container, options) requires either { redirectTo } or { onSuccess }.");if("redirectTo"in t){const s=t.redirectTo;if(!(typeof s=="string"||s instanceof URL))throw new w("authUI.mount(container, options) expected redirectTo to be a string or URL.")}if("onSuccess"in t&&t.onSuccess!==void 0&&typeof t.onSuccess!="function")throw new w("authUI.mount(container, options) expected onSuccess to be a function.");if("onError"in t&&t.onError!==void 0&&typeof t.onError!="function")throw new w("authUI.mount(container, options) expected onError to be a function.");if("appearance"in t&&t.appearance!==void 0){const s=t.appearance;if(!s||typeof s!="object"||Array.isArray(s))throw new w("authUI.mount(container, options) expected appearance to be an object.");if("theme"in s&&s.theme!==void 0&&!At(s.theme))throw new w(`authUI.mount(container, options) expected appearance.theme to be one of: ${Se.join(", ")}.`);if("className"in s&&s.className!==void 0&&typeof s.className!="string")throw new w("authUI.mount(container, options) expected appearance.className to be a string.");if("variables"in s&&s.variables!==void 0){if(!s.variables||typeof s.variables!="object"||Array.isArray(s.variables))throw new w("authUI.mount(container, options) expected appearance.variables to be an object.");for(const[n,o]of Object.entries(s.variables)){if(!Lt(n))throw new w(`authUI.mount(container, options) received unsupported appearance.variables key "${n}".`);if(o!==void 0&&typeof o!="string")throw new w(`authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`)}}}}function Kt(t){if(!(t instanceof HTMLElement))throw new w("authUI.mount(container, options) requires a real HTMLElement container.")}function Wt(t,e){const i=Gt({authClient:e.publicAuthClient,loadConfig:ke});return{mount(s,n){var g;qt(n),Kt(s),(g=j.get(s))==null||g.destroy();const o=new Bt(s,t,n,ke,e),d=o.destroy.bind(o),h={destroy(){d(),j.get(s)===h&&j.delete(s)}};return j.set(s,h),h},promptGoogleOneTap:i}}function Yt(){Be();const t=bt(),e=yt(),i=Je(),s=Wt(e,{syncPublicSession:async()=>{await wt(t)},publicAuthClient:t});return{auth:t,api:i,authUI:s}}exports.AUTH_UI_APPEARANCE_VARIABLE=je;exports.AUTH_UI_APPEARANCE_VARIABLE_NAMES=qe;exports.AUTH_UI_DEFAULT_THEME=Ge;exports.AUTH_UI_THEME=ve;exports.AUTH_UI_THEMES=Se;exports.AUTH_UI_THEME_DARK=xe;exports.AUTH_UI_THEME_LIGHT=Ee;exports.EdgeSparkAuthError=_;exports.EdgeSparkConfigError=w;exports.EdgeSparkError=W;exports.EdgeSparkRuntimeError=we;exports.ar=fe;exports.createEdgeSpark=Yt;exports.de=he;exports.detectLocale=ze;exports.enUS=H;exports.es=K;exports.fr=ue;exports.hi=pe;exports.it=me;exports.ja=de;exports.ko=le;exports.ptBR=ce;exports.ru=ge;exports.zhCN=q;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { createEdgeSpark } from './client';
|
|
2
|
+
export type { EdgeSparkClient } from './client';
|
|
3
|
+
export type { AuthSession, AuthUser, BetterAuthClientInstance, EdgeSparkAuth, SessionChangeCallback, SessionResult, } from './auth/types';
|
|
4
|
+
export type { EdgeSparkApi, EdgeSparkRequestInit } from './api/types';
|
|
5
|
+
export type { DeepPartial } from './shared/types';
|
|
6
|
+
export type { RedirectTarget } from './redirect';
|
|
7
|
+
export { AUTH_UI_APPEARANCE_VARIABLE, AUTH_UI_APPEARANCE_VARIABLE_NAMES, AUTH_UI_THEME, AUTH_UI_DEFAULT_THEME, AUTH_UI_THEME_DARK, AUTH_UI_THEME_LIGHT, AUTH_UI_THEMES, } from './auth-ui/appearance';
|
|
8
|
+
export type { AuthUIAppearance, AuthUIAppearanceVariableName, AuthUIAppearanceVariables, AuthUITheme, } from './auth-ui/appearance';
|
|
9
|
+
export type { AuthenticatedAuthSuccessEvent, AuthSuccessEvent, AuthUILabelOverrides, AuthUILabels, ControlledAuthUIOptions, EdgeSparkAuthUI, MountAuthUIOptions, MountedAuthUI, OneTapPromptHandle, PromptGoogleOneTapOptions, RedirectAuthUIOptions, } from './auth-ui/types';
|
|
10
|
+
export { EdgeSparkAuthError, EdgeSparkConfigError, EdgeSparkError, EdgeSparkRuntimeError, } from './errors';
|
|
11
|
+
/**
|
|
12
|
+
* Locale helpers for managed auth UI labels.
|
|
13
|
+
*
|
|
14
|
+
* Auto-detection already happens by default inside `authUI.mount(...)`.
|
|
15
|
+
* Import these only when the app wants to force a preset or build a custom
|
|
16
|
+
* label object:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* es.authUI.mount(container, {
|
|
20
|
+
* redirectTo: "/dashboard",
|
|
21
|
+
* labels: fr,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* `detectLocale()` is exported for advanced cases that need the same browser
|
|
26
|
+
* language matching outside the managed UI.
|
|
27
|
+
*/
|
|
28
|
+
export { detectLocale, enUS, zhCN, ja, ko, es, ptBR, fr, de, it, ru, ar, hi, } from './locales';
|