@edgespark/web 0.0.1-beta.7 → 0.0.2

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/dist/index.es.js CHANGED
@@ -1,20 +1,20 @@
1
- import { createAuthClient as Ue } from "better-auth/client";
2
- class ee extends Error {
1
+ import { createAuthClient as Oe } from "better-auth/client";
2
+ class te extends Error {
3
3
  constructor(e, s) {
4
4
  super(s), this.name = "EdgeSparkError", this.code = e;
5
5
  }
6
6
  }
7
- class f extends ee {
7
+ class f extends te {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class ye extends ee {
12
+ class Ee extends te {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
16
16
  }
17
- class v extends ee {
17
+ class v extends te {
18
18
  constructor(e, s) {
19
19
  super((s == null ? void 0 : s.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = s == null ? void 0 : s.cause, this.status = s == null ? void 0 : s.status;
20
20
  }
@@ -34,40 +34,53 @@ function Se(t, e = "Authentication failed.", s) {
34
34
  }
35
35
  function Pe() {
36
36
  if (typeof window > "u" || typeof document > "u")
37
- throw new ye(
37
+ throw new Ee(
38
38
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
39
39
  );
40
40
  }
41
41
  function Q() {
42
42
  return Pe(), window.location.origin;
43
43
  }
44
- function Be(t) {
44
+ function Ne(t) {
45
45
  return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
46
46
  }
47
- function ke(t) {
47
+ function Ve(t) {
48
48
  if (t.origin !== Q())
49
49
  throw new f(
50
50
  `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
51
51
  );
52
52
  }
53
- function Me() {
53
+ function De() {
54
54
  return {
55
55
  async fetch(t, e) {
56
- const s = Be(t);
57
- return ke(s), fetch(t, {
56
+ const s = Ne(t);
57
+ return Ve(s), fetch(t, {
58
58
  ...e,
59
59
  credentials: "include"
60
60
  });
61
61
  }
62
62
  };
63
63
  }
64
- const Ee = "/api/_es/auth", Oe = "edgespark-auth-session", Le = "__edgespark_auth_sync__", N = "__edgespark_auth_pending_sign_in__", _e = Symbol("edgespark.notifyAuthTabs"), Ve = 10 * 60 * 1e3, Ne = /* @__PURE__ */ new Set([
64
+ const _e = "/api/_es/auth", Fe = "edgespark-auth-session", Le = "__edgespark_auth_sync__", D = "__edgespark_auth_pending_sign_in__", Ae = Symbol("edgespark.notifyAuthTabs"), He = 10 * 60 * 1e3, ze = /* @__PURE__ */ new Set([
65
65
  "signOut",
66
66
  "revokeSession",
67
67
  "revokeSessions",
68
68
  "revokeOtherSessions"
69
+ ]), je = /* @__PURE__ */ new Map([
70
+ [
71
+ "changeEmail",
72
+ "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."
73
+ ],
74
+ [
75
+ "deleteUser",
76
+ "deleteUser() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."
77
+ ],
78
+ [
79
+ "deleteUserCallback",
80
+ "deleteUserCallback() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."
81
+ ]
69
82
  ]);
70
- class Fe {
83
+ class xe {
71
84
  constructor(e) {
72
85
  this.value = e;
73
86
  }
@@ -75,32 +88,32 @@ class Fe {
75
88
  return this.value;
76
89
  }
77
90
  }
78
- const ie = globalThis.WeakRef, ne = globalThis.FinalizationRegistry;
79
- let F, re = !1;
80
- const C = /* @__PURE__ */ new Map(), z = ne ? new ne((t) => {
81
- C.delete(t);
91
+ const ne = globalThis.WeakRef, re = globalThis.FinalizationRegistry;
92
+ let F, oe = !1;
93
+ const $ = /* @__PURE__ */ new Map(), H = re ? new re((t) => {
94
+ $.delete(t);
82
95
  }) : null;
83
- function Ie(t) {
84
- return Ue({
96
+ function Re(t) {
97
+ return Oe({
85
98
  baseURL: Q(),
86
- basePath: Ee,
99
+ basePath: _e,
87
100
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
88
101
  fetchOptions: {
89
102
  credentials: "include"
90
103
  }
91
104
  });
92
105
  }
93
- function R(t) {
106
+ function U(t) {
94
107
  var e, s;
95
108
  return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
96
109
  }
97
- function ze(t) {
110
+ function qe(t) {
98
111
  return JSON.stringify({
99
112
  source: t,
100
113
  timestamp: Date.now()
101
114
  });
102
115
  }
103
- function De(t) {
116
+ function Ge(t) {
104
117
  if (typeof t != "string")
105
118
  return null;
106
119
  try {
@@ -110,44 +123,53 @@ function De(t) {
110
123
  return null;
111
124
  }
112
125
  }
113
- async function X(t) {
126
+ function Ke(t) {
127
+ return t.join(".");
128
+ }
129
+ function We(t) {
130
+ const e = Ke(t), s = je.get(e);
131
+ return s ? new v(s, {
132
+ code: "UNSUPPORTED_AUTH_METHOD"
133
+ }) : null;
134
+ }
135
+ async function ee(t) {
114
136
  var e;
115
137
  try {
116
- return await ((e = R(t)) == null ? void 0 : e.get().refetch()), !0;
138
+ return await ((e = U(t)) == null ? void 0 : e.get().refetch()), !0;
117
139
  } catch {
118
140
  return !1;
119
141
  }
120
142
  }
121
- function Re() {
122
- return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(Oe) : null), F;
143
+ function Te() {
144
+ return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(Fe) : null), F;
123
145
  }
124
- function oe(t) {
125
- const e = De(t);
146
+ function ae(t) {
147
+ const e = Ge(t);
126
148
  if (e)
127
- for (const [s, i] of C) {
149
+ for (const [s, i] of $) {
128
150
  if (s === e.source)
129
151
  continue;
130
152
  const n = i.deref();
131
153
  if (!n) {
132
- C.delete(s);
154
+ $.delete(s);
133
155
  continue;
134
156
  }
135
- X(n);
157
+ ee(n);
136
158
  }
137
159
  }
138
- function qe() {
160
+ function Ye() {
139
161
  var t;
140
- re || (re = !0, (t = Re()) == null || t.addEventListener("message", (e) => {
141
- oe(e.data);
162
+ oe || (oe = !0, (t = Te()) == null || t.addEventListener("message", (e) => {
163
+ ae(e.data);
142
164
  }), typeof window < "u" && window.addEventListener("storage", (e) => {
143
- e.key !== Le || e.newValue === null || oe(e.newValue);
165
+ e.key !== Le || e.newValue === null || ae(e.newValue);
144
166
  }));
145
167
  }
146
- function je(t, e) {
147
- ie ? C.set(t, new ie(e)) : (C.clear(), C.set(t, new Fe(e))), z == null || z.register(e, t), qe();
168
+ function Je(t, e) {
169
+ ne ? $.set(t, new ne(e)) : ($.clear(), $.set(t, new xe(e))), H == null || H.register(e, t), Ye();
148
170
  }
149
171
  function I(t) {
150
- const e = ze(t), s = Re();
172
+ const e = qe(t), s = Te();
151
173
  let i = !1;
152
174
  if (s)
153
175
  try {
@@ -160,11 +182,11 @@ function I(t) {
160
182
  } catch {
161
183
  }
162
184
  }
163
- function D(t) {
185
+ function z(t) {
164
186
  if (!(typeof window > "u"))
165
187
  try {
166
188
  window.sessionStorage.setItem(
167
- N,
189
+ D,
168
190
  JSON.stringify({
169
191
  path: t,
170
192
  createdAt: Date.now()
@@ -173,130 +195,162 @@ function D(t) {
173
195
  } catch {
174
196
  }
175
197
  }
176
- function $() {
198
+ function C() {
177
199
  if (!(typeof window > "u"))
178
200
  try {
179
- window.sessionStorage.removeItem(N);
201
+ window.sessionStorage.removeItem(D);
180
202
  } catch {
181
203
  }
182
204
  }
183
- function He(t) {
205
+ function Xe(t) {
184
206
  return !!(t != null && t.session && (t != null && t.user));
185
207
  }
186
- function Te() {
208
+ function m(t) {
209
+ return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
210
+ }
211
+ function Ze(t) {
212
+ return t ? JSON.stringify({
213
+ session: {
214
+ createdAt: m(t.session.createdAt),
215
+ expiresAt: m(t.session.expiresAt),
216
+ id: m(t.session.id),
217
+ impersonatedBy: m(t.session.impersonatedBy),
218
+ ipAddress: m(t.session.ipAddress),
219
+ token: m(t.session.token),
220
+ updatedAt: m(t.session.updatedAt),
221
+ userAgent: m(t.session.userAgent),
222
+ userId: m(t.session.userId)
223
+ },
224
+ user: {
225
+ banExpires: m(t.user.banExpires),
226
+ banReason: m(t.user.banReason),
227
+ banned: m(t.user.banned),
228
+ createdAt: m(t.user.createdAt),
229
+ email: m(t.user.email),
230
+ emailVerified: m(t.user.emailVerified),
231
+ id: m(t.user.id),
232
+ image: m(t.user.image),
233
+ lastLoginAt: m(t.user.lastLoginAt),
234
+ name: m(t.user.name),
235
+ role: m(t.user.role),
236
+ updatedAt: m(t.user.updatedAt)
237
+ }
238
+ }) : "__null__";
239
+ }
240
+ function Ie() {
187
241
  if (typeof window > "u")
188
242
  return null;
189
243
  try {
190
- const t = window.sessionStorage.getItem(N);
244
+ const t = window.sessionStorage.getItem(D);
191
245
  if (!t)
192
246
  return null;
193
247
  const e = JSON.parse(t);
194
- return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ve ? null : { createdAt: e.createdAt };
248
+ return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > He ? null : { createdAt: e.createdAt };
195
249
  } catch {
196
250
  return null;
197
251
  }
198
252
  }
199
- function ae() {
200
- if (!Te())
253
+ function le() {
254
+ if (!Ie())
201
255
  return !1;
202
256
  try {
203
- window.sessionStorage.removeItem(N);
257
+ window.sessionStorage.removeItem(D);
204
258
  } catch {
205
259
  }
206
260
  return !0;
207
261
  }
208
- function xe() {
209
- return Te() !== null;
262
+ function Qe() {
263
+ return Ie() !== null;
210
264
  }
211
- function We(t) {
265
+ function et(t) {
212
266
  if (!(t && typeof t == "object") || "error" in t && t.error)
213
267
  return !1;
214
268
  const e = "data" in t ? t.data : t;
215
269
  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;
216
270
  }
217
- function Ge(t) {
271
+ function tt(t) {
218
272
  if (!(t && typeof t == "object") || "error" in t && t.error)
219
273
  return !1;
220
274
  const e = "data" in t ? t.data : t;
221
275
  return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
222
276
  }
223
- function Ye(t) {
224
- if (T(t) || !(t && typeof t == "object"))
277
+ function st(t) {
278
+ if (L(t) || !(t && typeof t == "object"))
225
279
  return !1;
226
280
  const e = "data" in t ? t.data : t;
227
281
  return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
228
282
  }
229
- function Ke(t, e) {
283
+ function it(t, e) {
230
284
  if (t.length !== 1 || t[0] !== "changePassword")
231
285
  return !1;
232
286
  const [s] = e;
233
287
  return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
234
288
  }
235
- function T(t) {
289
+ function L(t) {
236
290
  return !!(t && typeof t == "object" && "error" in t && t.error);
237
291
  }
238
- function Je(t) {
239
- if (T(t) || !(t && typeof t == "object"))
292
+ function nt(t) {
293
+ if (L(t) || !(t && typeof t == "object"))
240
294
  return !1;
241
295
  const e = "data" in t ? t.data : t;
242
296
  return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
243
297
  }
244
- function Ze(t) {
298
+ function rt(t) {
245
299
  return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
246
300
  }
247
- function q(t) {
301
+ function j(t) {
248
302
  return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
249
303
  }
250
- async function Qe(t) {
304
+ async function ot(t) {
251
305
  var s, i;
252
306
  let e = null;
253
307
  try {
254
- await ((s = R(t)) == null ? void 0 : s.get().refetch());
308
+ await ((s = U(t)) == null ? void 0 : s.get().refetch());
255
309
  } catch (n) {
256
310
  e = n;
257
311
  } finally {
258
- (i = t[_e]) == null || i.call(t);
312
+ (i = t[Ae]) == null || i.call(t);
259
313
  }
260
314
  if (e)
261
315
  throw e;
262
316
  }
263
- function Xe() {
264
- const t = Ie(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
265
- je(e, t);
317
+ function at() {
318
+ const t = Re(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
319
+ Je(e, t);
266
320
  const s = 2, i = 500;
267
- let n = null, a = !1, h;
268
- const w = (o) => (h = o, o), E = () => {
321
+ let n = null, a = !1, u;
322
+ const g = (o) => (u = o, o), E = () => {
269
323
  var c;
270
- const o = (c = R(t)) == null ? void 0 : c.get();
271
- return o != null && o.error && !o.data && h !== void 0 ? h : (o == null ? void 0 : o.data) ?? h ?? null;
272
- }, L = () => a ? Promise.resolve(E()) : (n || (n = (async () => {
273
- var l, u, g;
324
+ const o = (c = U(t)) == null ? void 0 : c.get();
325
+ return o != null && o.error && !o.data && u !== void 0 ? u : (o == null ? void 0 : o.data) ?? u ?? null;
326
+ }, A = () => a ? Promise.resolve(E()) : (n || (n = (async () => {
327
+ var l, h, y;
274
328
  let o = !1, c = null;
275
329
  try {
276
- for (let p = 0; p <= s; p++) {
330
+ for (let b = 0; b <= s; b++) {
277
331
  let d = null;
278
332
  try {
279
333
  d = await t.getSession();
280
- } catch (y) {
281
- c = y;
334
+ } catch (S) {
335
+ c = S;
282
336
  }
283
- const b = ((l = R(t)) == null ? void 0 : l.get().data) ?? null;
284
- if ((u = d == null ? void 0 : d.data) != null && u.session && ((g = d.data) != null && g.user))
285
- return a = !0, ae() && I(e), w(d.data);
286
- if (b != null && b.session && (b != null && b.user))
287
- return a = !0, ae() && I(e), w(b);
288
- if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && xe() && p < s) {
337
+ const p = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
338
+ if ((h = d == null ? void 0 : d.data) != null && h.session && ((y = d.data) != null && y.user))
339
+ return a = !0, le() && I(e), g(d.data);
340
+ if (p != null && p.session && (p != null && p.user))
341
+ return a = !0, le() && I(e), g(p);
342
+ if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && Qe() && b < s) {
289
343
  await new Promise(
290
- (y) => setTimeout(y, i)
344
+ (S) => setTimeout(S, i)
291
345
  );
292
346
  continue;
293
347
  }
294
348
  if (d && !d.error) {
295
- const y = E();
296
- return a = !0, w(y);
349
+ const S = E();
350
+ return a = !0, g(S);
297
351
  }
298
- p < s && await new Promise(
299
- (y) => setTimeout(y, i)
352
+ b < s && await new Promise(
353
+ (S) => setTimeout(S, i)
300
354
  );
301
355
  }
302
356
  if (!o)
@@ -304,99 +358,103 @@ function Xe() {
304
358
  code: "SESSION_LOOKUP_FAILED",
305
359
  cause: c
306
360
  });
307
- const m = E();
308
- return a = !0, w(m);
309
- } catch (m) {
310
- throw n = null, q(m);
361
+ const w = E();
362
+ return a = !0, g(w);
363
+ } catch (w) {
364
+ throw n = null, j(w);
311
365
  }
312
366
  })()), n);
313
- L().catch(() => {
367
+ A().catch(() => {
314
368
  });
315
- const _ = async () => {
369
+ const R = async () => {
316
370
  var o, c;
317
371
  try {
318
372
  const l = await t.getSession();
319
373
  if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
320
374
  return l.data;
321
- throw l.error ? q(l.error) : new v("No authenticated session is available.", {
375
+ throw l.error ? j(l.error) : new v("No authenticated session is available.", {
322
376
  code: "UNAUTHENTICATED"
323
377
  });
324
378
  } catch (l) {
325
- throw q(l);
379
+ throw j(l);
326
380
  }
327
- }, A = async () => {
328
- await X(t), I(e);
329
- }, Ce = async () => {
381
+ }, T = async () => {
382
+ await ee(t), I(e);
383
+ }, Be = async () => {
330
384
  var l;
331
- const o = await X(t), c = ((l = R(t)) == null ? void 0 : l.get().data) ?? null;
332
- He(c) ? ($(), I(e)) : o || I(e);
333
- }, Ae = (o) => {
334
- let c = !1, l = !1, u;
335
- const g = (d) => {
336
- d !== u && (u = d, o(d));
385
+ const o = await ee(t), c = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
386
+ Xe(c) ? (C(), I(e)) : o || I(e);
387
+ }, ke = (o) => {
388
+ let c = !1, l = !1, h;
389
+ const y = (d) => {
390
+ const p = Ze(d);
391
+ p !== h && (h = p, o(d));
337
392
  };
338
- L().then((d) => {
339
- c || (l = !0, g(w(d)));
393
+ A().then((d) => {
394
+ c || (l = !0, y(g(d)));
340
395
  }).catch(() => {
341
396
  c || (l = !0);
342
397
  });
343
- const m = R(t);
344
- if (!m)
398
+ const w = U(t);
399
+ if (!w)
345
400
  return () => {
346
401
  c = !0;
347
402
  };
348
- const p = m.subscribe((d) => {
403
+ const b = w.subscribe((d) => {
349
404
  if (c || !l || d.error && !d.data)
350
405
  return;
351
- const b = d.data ?? null;
352
- g(w(b));
406
+ const p = d.data ?? null;
407
+ y(g(p));
353
408
  });
354
409
  return () => {
355
- c = !0, p();
410
+ c = !0, b();
356
411
  };
357
- }, $e = async (o, c, l) => {
358
- const u = o[0], g = o.length >= 2 && u === "emailOtp" && o[1] === "verifyEmail";
359
- return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? ($(), Je(l) && await A(), l) : o.length === 1 && u && Ne.has(u) ? ($(), T(l) || await A(), l) : Ke(o, c) && !T(l) ? ($(), await A(), l) : o.length === 1 && u === "changeEmail" && !T(l) ? (await A(), l) : ((u === "signIn" || u === "signUp" || g) && We(l) ? ($(), await A()) : (u === "signIn" || u === "signUp") && Ge(l) || u === "signUp" && Ye(l) ? D(o) : u === "verifyEmail" && !T(l) && (D(o), await Ce()), l);
360
- }, te = /* @__PURE__ */ new WeakMap(), se = (o, c) => {
412
+ }, Me = async (o, c, l) => {
413
+ const h = o[0], y = o.length >= 2 && h === "emailOtp" && o[1] === "verifyEmail", w = o.length >= 2 && h === "emailOtp" && o[1] === "resetPassword", b = o.length >= 2 && h === "resetPassword" && o[1] === "emailOtp";
414
+ return o.length === 1 && (h === "deleteUser" || h === "deleteUserCallback") ? (C(), nt(l) && await T(), l) : o.length === 1 && h && ze.has(h) ? (C(), L(l) || await T(), l) : it(o, c) && !L(l) ? (C(), await T(), l) : (w || b) && !L(l) ? (C(), await T(), l) : o.length === 1 && h === "changeEmail" && !L(l) ? (await T(), l) : ((h === "signIn" || h === "signUp" || y) && et(l) ? (C(), await T()) : (h === "signIn" || h === "signUp") && tt(l) || h === "signUp" && st(l) ? z(o) : h === "verifyEmail" && !L(l) && (z(o), await Be()), l);
415
+ }, se = /* @__PURE__ */ new WeakMap(), ie = (o, c) => {
361
416
  if (!o || typeof o != "object" && typeof o != "function")
362
417
  return o;
363
- const l = te.get(o);
418
+ const l = se.get(o);
364
419
  if (l)
365
420
  return l;
366
- const u = new Proxy(o, {
367
- get(g, m, p) {
421
+ const h = new Proxy(o, {
422
+ get(y, w, b) {
368
423
  if (c.length === 0) {
369
- if (m === "requireSession")
370
- return _;
371
- if (m === "onSessionChange")
372
- return Ae;
373
- if (m === _e)
424
+ if (w === "requireSession")
425
+ return R;
426
+ if (w === "onSessionChange")
427
+ return ke;
428
+ if (w === Ae)
374
429
  return () => {
375
430
  I(e);
376
431
  };
377
432
  }
378
- const d = Reflect.get(g, m, p);
379
- return typeof m != "string" ? d : se(d, [...c, m]);
433
+ const d = Reflect.get(y, w, b);
434
+ return typeof w != "string" ? d : ie(d, [...c, w]);
380
435
  },
381
- apply(g, m, p) {
382
- const d = Reflect.apply(
383
- g,
384
- m,
385
- p
436
+ apply(y, w, b) {
437
+ const d = We(c);
438
+ if (d)
439
+ throw d;
440
+ const p = Reflect.apply(
441
+ y,
442
+ w,
443
+ b
386
444
  );
387
- return Ze(d) ? Promise.resolve(d).then(
388
- (b) => $e(c, p, b)
389
- ) : d;
445
+ return rt(p) ? Promise.resolve(p).then(
446
+ (S) => Me(c, b, S)
447
+ ) : p;
390
448
  }
391
449
  });
392
- return te.set(o, u), u;
450
+ return se.set(o, h), h;
393
451
  };
394
- return se(t, []);
452
+ return ie(t, []);
395
453
  }
396
- function et() {
397
- return Ie({ disableDefaultRedirectPlugin: !0 });
454
+ function lt() {
455
+ return Re({ disableDefaultRedirectPlugin: !0 });
398
456
  }
399
- function tt(t) {
457
+ function dt(t) {
400
458
  const e = (() => {
401
459
  if (t instanceof URL)
402
460
  return t;
@@ -417,7 +475,7 @@ function tt(t) {
417
475
  );
418
476
  return e;
419
477
  }
420
- function st(t, e) {
478
+ function ct(t, e) {
421
479
  return e ? {
422
480
  common: { ...t.common, ...e.common },
423
481
  signIn: { ...t.signIn, ...e.signIn },
@@ -492,7 +550,7 @@ const V = {
492
550
  invalidCode: "Enter the 6-digit verification code.",
493
551
  generic: "Something went wrong. Please try again."
494
552
  }
495
- }, j = {
553
+ }, x = {
496
554
  common: {
497
555
  loading: "加载中…",
498
556
  redirecting: "跳转中…",
@@ -555,7 +613,7 @@ const V = {
555
613
  invalidCode: "请输入 6 位验证码",
556
614
  generic: "出现错误,请稍后重试"
557
615
  }
558
- }, le = {
616
+ }, de = {
559
617
  common: {
560
618
  loading: "サインインを読み込み中…",
561
619
  redirecting: "リダイレクト中…",
@@ -618,7 +676,7 @@ const V = {
618
676
  invalidCode: "6桁の認証コードを入力してください",
619
677
  generic: "エラーが発生しました。もう一度お試しください"
620
678
  }
621
- }, de = {
679
+ }, ce = {
622
680
  common: {
623
681
  loading: "로그인 로딩 중…",
624
682
  redirecting: "리디렉션 중…",
@@ -681,7 +739,7 @@ const V = {
681
739
  invalidCode: "6자리 인증 코드를 입력해 주세요",
682
740
  generic: "문제가 발생했습니다. 다시 시도해 주세요"
683
741
  }
684
- }, H = {
742
+ }, q = {
685
743
  common: {
686
744
  loading: "Cargando inicio de sesión…",
687
745
  redirecting: "Redirigiendo…",
@@ -744,7 +802,7 @@ const V = {
744
802
  invalidCode: "Ingresa el código de verificación de 6 dígitos.",
745
803
  generic: "Algo salió mal. Por favor, inténtalo de nuevo."
746
804
  }
747
- }, ce = {
805
+ }, ue = {
748
806
  common: {
749
807
  loading: "Carregando login…",
750
808
  redirecting: "Redirecionando…",
@@ -807,7 +865,7 @@ const V = {
807
865
  invalidCode: "Insira o código de verificação de 6 dígitos.",
808
866
  generic: "Algo deu errado. Por favor, tente novamente."
809
867
  }
810
- }, ue = {
868
+ }, he = {
811
869
  common: {
812
870
  loading: "Chargement de la connexion…",
813
871
  redirecting: "Redirection…",
@@ -870,7 +928,7 @@ const V = {
870
928
  invalidCode: "Saisissez le code de vérification à 6 chiffres.",
871
929
  generic: "Une erreur est survenue. Veuillez réessayer."
872
930
  }
873
- }, he = {
931
+ }, me = {
874
932
  common: {
875
933
  loading: "Anmeldung wird geladen…",
876
934
  redirecting: "Weiterleitung…",
@@ -933,7 +991,7 @@ const V = {
933
991
  invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
934
992
  generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
935
993
  }
936
- }, me = {
994
+ }, fe = {
937
995
  common: {
938
996
  loading: "Caricamento accesso…",
939
997
  redirecting: "Reindirizzamento…",
@@ -996,7 +1054,7 @@ const V = {
996
1054
  invalidCode: "Inserisci il codice di verifica a 6 cifre.",
997
1055
  generic: "Qualcosa è andato storto. Riprova."
998
1056
  }
999
- }, fe = {
1057
+ }, we = {
1000
1058
  common: {
1001
1059
  loading: "Загрузка входа…",
1002
1060
  redirecting: "Перенаправление…",
@@ -1059,7 +1117,7 @@ const V = {
1059
1117
  invalidCode: "Введите 6-значный код подтверждения.",
1060
1118
  generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
1061
1119
  }
1062
- }, we = {
1120
+ }, pe = {
1063
1121
  common: {
1064
1122
  loading: "جارٍ تحميل تسجيل الدخول…",
1065
1123
  redirecting: "جارٍ إعادة التوجيه…",
@@ -1185,48 +1243,88 @@ const V = {
1185
1243
  invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
1186
1244
  generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
1187
1245
  }
1188
- }, pe = {
1246
+ }, be = {
1189
1247
  en: V,
1190
1248
  "en-US": V,
1191
- zh: j,
1192
- "zh-CN": j,
1193
- "zh-TW": j,
1194
- ja: le,
1195
- "ja-JP": le,
1196
- ko: de,
1197
- "ko-KR": de,
1198
- es: H,
1199
- "es-ES": H,
1200
- "es-MX": H,
1201
- pt: ce,
1202
- "pt-BR": ce,
1203
- fr: ue,
1204
- "fr-FR": ue,
1205
- de: he,
1206
- "de-DE": he,
1207
- it: me,
1208
- "it-IT": me,
1209
- ru: fe,
1210
- "ru-RU": fe,
1211
- ar: we,
1212
- "ar-SA": we,
1249
+ zh: x,
1250
+ "zh-CN": x,
1251
+ "zh-TW": x,
1252
+ ja: de,
1253
+ "ja-JP": de,
1254
+ ko: ce,
1255
+ "ko-KR": ce,
1256
+ es: q,
1257
+ "es-ES": q,
1258
+ "es-MX": q,
1259
+ pt: ue,
1260
+ "pt-BR": ue,
1261
+ fr: he,
1262
+ "fr-FR": he,
1263
+ de: me,
1264
+ "de-DE": me,
1265
+ it: fe,
1266
+ "it-IT": fe,
1267
+ ru: we,
1268
+ "ru-RU": we,
1269
+ ar: pe,
1270
+ "ar-SA": pe,
1213
1271
  hi: ge,
1214
1272
  "hi-IN": ge
1215
1273
  };
1216
- function it() {
1274
+ function ut() {
1217
1275
  if (typeof navigator > "u")
1218
1276
  return V;
1219
1277
  const t = navigator.languages ?? [navigator.language];
1220
1278
  for (const e of t) {
1221
- const s = pe[e] ?? pe[e.split("-")[0]];
1279
+ const s = be[e] ?? be[e.split("-")[0]];
1222
1280
  if (s) return s;
1223
1281
  }
1224
1282
  return V;
1225
1283
  }
1226
- function x(t, e = "Authentication failed.") {
1284
+ const Ce = {
1285
+ LIGHT: "light",
1286
+ DARK: "dark"
1287
+ }, Ue = Ce.LIGHT, ht = Ce.DARK, $e = [Ue, ht], mt = Ue, ft = {
1288
+ BACKGROUND: "--edgespark-auth-bg",
1289
+ BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
1290
+ CARD_BACKGROUND: "--edgespark-auth-card-bg",
1291
+ BORDER: "--edgespark-auth-border",
1292
+ TEXT: "--edgespark-auth-text",
1293
+ TEXT_MUTED: "--edgespark-auth-text-muted",
1294
+ DIVIDER_BACKGROUND: "--edgespark-auth-divider-bg",
1295
+ PRIMARY: "--edgespark-auth-primary",
1296
+ PRIMARY_HOVER: "--edgespark-auth-primary-hover",
1297
+ PRIMARY_CONTRAST: "--edgespark-auth-primary-contrast",
1298
+ ERROR: "--edgespark-auth-error",
1299
+ INFO: "--edgespark-auth-info",
1300
+ CARD_RADIUS: "--edgespark-auth-radius-card",
1301
+ CONTROL_RADIUS: "--edgespark-auth-radius-control",
1302
+ SHADOW: "--edgespark-auth-shadow",
1303
+ FONT: "--edgespark-auth-font",
1304
+ MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
1305
+ MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
1306
+ MODAL_SHADOW: "--edgespark-auth-modal-shadow"
1307
+ }, wt = Object.values(
1308
+ ft
1309
+ );
1310
+ function pt(t) {
1311
+ return typeof t == "string" && $e.includes(t);
1312
+ }
1313
+ function gt(t) {
1314
+ return wt.includes(t);
1315
+ }
1316
+ function bt(t) {
1317
+ var e;
1318
+ return {
1319
+ theme: (t == null ? void 0 : t.theme) ?? mt,
1320
+ className: ((e = t == null ? void 0 : t.className) == null ? void 0 : e.trim()) ?? "",
1321
+ variables: { ...(t == null ? void 0 : t.variables) ?? {} }
1322
+ };
1323
+ }
1324
+ function G(t, e = "Authentication failed.") {
1227
1325
  return Se(t, e);
1228
1326
  }
1229
- async function B(t) {
1327
+ async function k(t) {
1230
1328
  var s, i;
1231
1329
  const e = await t.getSession();
1232
1330
  if (e.error)
@@ -1246,13 +1344,13 @@ async function B(t) {
1246
1344
  session: null
1247
1345
  };
1248
1346
  }
1249
- const nt = "data-edgespark-auth", r = "edgespark-auth", W = "es_auth_completion", k = "es_auth_email", G = "oauth", U = "verify-sign-in", S = "verify-sign-up", be = 200, Y = 2, rt = {
1347
+ const yt = "data-edgespark-auth", vt = "data-edgespark-auth-theme", r = "edgespark-auth", K = "es_auth_completion", M = "es_auth_email", W = "oauth", B = "verify-sign-in", P = "verify-sign-up", ye = 200, Y = 2, Et = {
1250
1348
  "&": "&amp;",
1251
1349
  "<": "&lt;",
1252
1350
  ">": "&gt;",
1253
1351
  '"': "&quot;",
1254
1352
  "'": "&#39;"
1255
- }, K = {
1353
+ }, J = {
1256
1354
  google: "Google",
1257
1355
  apple: "Apple",
1258
1356
  microsoft: "Microsoft",
@@ -1260,25 +1358,25 @@ const nt = "data-edgespark-auth", r = "edgespark-auth", W = "es_auth_completion"
1260
1358
  gitlab: "GitLab",
1261
1359
  discord: "Discord"
1262
1360
  };
1263
- function P(t) {
1361
+ function _(t) {
1264
1362
  return "redirectTo" in t;
1265
1363
  }
1266
- function J(t) {
1364
+ function X(t) {
1267
1365
  return "onSuccess" in t && !("redirectTo" in t);
1268
1366
  }
1269
1367
  function Z(t) {
1270
1368
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1271
1369
  }
1272
- function ot(t) {
1370
+ function St(t) {
1273
1371
  return /^\d{6}$/.test(t.trim());
1274
1372
  }
1275
- function at(t) {
1373
+ function Pt(t) {
1276
1374
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1277
1375
  }
1278
- function lt(t) {
1376
+ function _t(t) {
1279
1377
  return !!(t.error || t.errorDescription);
1280
1378
  }
1281
- class dt {
1379
+ class Lt {
1282
1380
  constructor(e, s, i, n, a) {
1283
1381
  this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
1284
1382
  view: "loading",
@@ -1292,7 +1390,12 @@ class dt {
1292
1390
  confirmPassword: "",
1293
1391
  code: "",
1294
1392
  newPassword: ""
1295
- }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, this.labels = st(it(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(nt, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1393
+ }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null;
1394
+ const u = bt(i.appearance);
1395
+ this.labels = ct(ut(), i.labels), this.root = document.createElement("div"), this.root.className = u.className ? `${r} ${u.className}` : r, this.root.setAttribute(yt, ""), this.root.setAttribute(vt, u.theme);
1396
+ for (const [g, E] of Object.entries(u.variables))
1397
+ E !== void 0 && this.root.style.setProperty(g, E);
1398
+ e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1296
1399
  }
1297
1400
  destroy() {
1298
1401
  this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
@@ -1307,7 +1410,7 @@ class dt {
1307
1410
  if (this.destroyed)
1308
1411
  return;
1309
1412
  if (i.status === "rejected") {
1310
- if (e.marker && !lt(e) && P(this.options)) {
1413
+ if (e.marker && !_t(e) && _(this.options)) {
1311
1414
  this.redirectAfterManagedReturnLookupFailure();
1312
1415
  return;
1313
1416
  }
@@ -1315,11 +1418,11 @@ class dt {
1315
1418
  const a = i.value;
1316
1419
  if (a.user && a.session) {
1317
1420
  switch (e.marker) {
1318
- case G:
1319
- case U:
1421
+ case W:
1422
+ case B:
1320
1423
  await this.completeAuth("sign-in", a);
1321
1424
  return;
1322
- case S:
1425
+ case P:
1323
1426
  await this.completeAuth("sign-up", a);
1324
1427
  return;
1325
1428
  default:
@@ -1342,24 +1445,24 @@ class dt {
1342
1445
  }
1343
1446
  }
1344
1447
  redirectAfterManagedReturnLookupFailure() {
1345
- P(this.options) && this.navigateToRedirect();
1448
+ _(this.options) && this.navigateToRedirect();
1346
1449
  }
1347
1450
  navigateToRedirect() {
1348
- P(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(tt(this.options.redirectTo).toString()));
1451
+ _(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(dt(this.options.redirectTo).toString()));
1349
1452
  }
1350
1453
  async readMountSession(e) {
1351
1454
  if (!e.marker)
1352
- return B(this.auth);
1455
+ return k(this.auth);
1353
1456
  let s = null;
1354
1457
  for (let i = 0; i <= Y; i++) {
1355
1458
  try {
1356
- const n = await B(this.auth);
1459
+ const n = await k(this.auth);
1357
1460
  if (n.user && n.session)
1358
1461
  return n;
1359
1462
  } catch (n) {
1360
1463
  s = n;
1361
1464
  }
1362
- i < Y && await new Promise((n) => setTimeout(n, be));
1465
+ i < Y && await new Promise((n) => setTimeout(n, ye));
1363
1466
  }
1364
1467
  if (s)
1365
1468
  throw s;
@@ -1568,7 +1671,7 @@ class dt {
1568
1671
  <div class="${r}__stack">
1569
1672
  ${e.map((i) => `
1570
1673
  <button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
1571
- ${this.escape(`${this.labels.oauth.continueWith} ${K[i]}`)}
1674
+ ${this.escape(`${this.labels.oauth.continueWith} ${J[i]}`)}
1572
1675
  </button>
1573
1676
  `).join("")}
1574
1677
  </div>
@@ -1593,12 +1696,12 @@ class dt {
1593
1696
  this.root.querySelectorAll("form[data-view]").forEach((n) => {
1594
1697
  n.addEventListener("submit", (a) => {
1595
1698
  a.preventDefault();
1596
- const h = n.dataset.view;
1597
- h === "sign-in" && this.handleSignIn(), h === "sign-up" && this.handleSignUp(), h === "forgot-password" && this.handleForgotPassword(), h === "reset-password" && this.handleResetPassword();
1699
+ const u = n.dataset.view;
1700
+ u === "sign-in" && this.handleSignIn(), u === "sign-up" && this.handleSignUp(), u === "forgot-password" && this.handleForgotPassword(), u === "reset-password" && this.handleResetPassword();
1598
1701
  });
1599
1702
  }), this.root.querySelectorAll("input[name]").forEach((n) => {
1600
1703
  n.addEventListener("input", () => {
1601
- at(n.name) && (this.state[n.name] = n.value);
1704
+ Pt(n.name) && (this.state[n.name] = n.value);
1602
1705
  });
1603
1706
  }), this.root.querySelectorAll("[data-action]").forEach((n) => {
1604
1707
  n.addEventListener("click", () => {
@@ -1623,7 +1726,7 @@ class dt {
1623
1726
  const e = await this.auth.signIn.email({
1624
1727
  email: this.state.email.trim(),
1625
1728
  password: this.state.password,
1626
- callbackURL: this.getManagedReturnURL(U, this.state.email.trim())
1729
+ callbackURL: this.getManagedReturnURL(B, this.state.email.trim())
1627
1730
  });
1628
1731
  if (e.error)
1629
1732
  throw e.error;
@@ -1660,7 +1763,7 @@ class dt {
1660
1763
  name: this.state.name.trim(),
1661
1764
  email: this.state.email.trim(),
1662
1765
  password: this.state.password,
1663
- callbackURL: this.getManagedReturnURL(S, this.state.email.trim())
1766
+ callbackURL: this.getManagedReturnURL(P, this.state.email.trim())
1664
1767
  });
1665
1768
  if (i.error)
1666
1769
  throw i.error;
@@ -1672,7 +1775,7 @@ class dt {
1672
1775
  });
1673
1776
  }
1674
1777
  async handleOAuthSignIn(e) {
1675
- await this.runAction(`Redirecting to ${K[e]}…`, async () => {
1778
+ await this.runAction(`Redirecting to ${J[e]}…`, async () => {
1676
1779
  const s = await this.auth.signIn.social({
1677
1780
  provider: e,
1678
1781
  callbackURL: this.getManagedReturnURL("oauth"),
@@ -1683,7 +1786,7 @@ class dt {
1683
1786
  const i = this.extractRedirectURL(s.data);
1684
1787
  if (!i)
1685
1788
  throw new f(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1686
- this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${K[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1789
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${J[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1687
1790
  });
1688
1791
  }
1689
1792
  async handleForgotPassword() {
@@ -1717,7 +1820,7 @@ class dt {
1717
1820
  );
1718
1821
  return;
1719
1822
  }
1720
- if (!ot(this.state.code)) {
1823
+ if (!St(this.state.code)) {
1721
1824
  this.failValidation(this.labels.errors.invalidCode);
1722
1825
  return;
1723
1826
  }
@@ -1754,7 +1857,7 @@ class dt {
1754
1857
  const s = await this.auth.sendVerificationEmail({
1755
1858
  email: this.state.email.trim(),
1756
1859
  callbackURL: this.getManagedReturnURL(
1757
- this.verificationCompletionAction === "sign-up" ? S : U,
1860
+ this.verificationCompletionAction === "sign-up" ? P : B,
1758
1861
  this.state.email.trim()
1759
1862
  )
1760
1863
  });
@@ -1772,12 +1875,12 @@ class dt {
1772
1875
  if (!i.user || !i.session) {
1773
1876
  if (this.destroyed)
1774
1877
  return;
1775
- if (i.lookupError && P(this.options)) {
1878
+ if (i.lookupError && _(this.options)) {
1776
1879
  this.navigateToRedirect();
1777
1880
  return;
1778
1881
  }
1779
1882
  if (e === "sign-in")
1780
- throw i.lookupError ?? new ye(
1883
+ throw i.lookupError ?? new Ee(
1781
1884
  "Managed sign-in completed without an authenticated session."
1782
1885
  );
1783
1886
  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();
@@ -1789,11 +1892,11 @@ class dt {
1789
1892
  session: i.session
1790
1893
  };
1791
1894
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1792
- if (P(this.options)) {
1895
+ if (_(this.options)) {
1793
1896
  this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
1794
1897
  return;
1795
1898
  }
1796
- if (J(this.options)) {
1899
+ if (X(this.options)) {
1797
1900
  this.options.onSuccess(n), this.terminalActionInProgress = !0;
1798
1901
  return;
1799
1902
  }
@@ -1804,9 +1907,9 @@ class dt {
1804
1907
  return e;
1805
1908
  let s = e.lookupError;
1806
1909
  for (let i = 0; i < Y; i++) {
1807
- await new Promise((n) => setTimeout(n, be));
1910
+ await new Promise((n) => setTimeout(n, ye));
1808
1911
  try {
1809
- const n = await B(this.auth);
1912
+ const n = await k(this.auth);
1810
1913
  if (n.user && n.session)
1811
1914
  return {
1812
1915
  user: n.user,
@@ -1830,7 +1933,7 @@ class dt {
1830
1933
  }
1831
1934
  async resolveAuthCompletionData(e) {
1832
1935
  try {
1833
- const s = await B(this.auth), i = this.extractUser(e);
1936
+ const s = await k(this.auth), i = this.extractUser(e);
1834
1937
  return {
1835
1938
  user: s.user ?? i,
1836
1939
  session: s.session
@@ -1850,7 +1953,7 @@ class dt {
1850
1953
  session: null
1851
1954
  };
1852
1955
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1853
- if (J(this.options)) {
1956
+ if (X(this.options)) {
1854
1957
  this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
1855
1958
  return;
1856
1959
  }
@@ -1858,11 +1961,11 @@ class dt {
1858
1961
  }
1859
1962
  }
1860
1963
  handleExistingSessionOnMount() {
1861
- if (P(this.options)) {
1964
+ if (_(this.options)) {
1862
1965
  this.navigateToRedirect();
1863
1966
  return;
1864
1967
  }
1865
- if (J(this.options))
1968
+ if (X(this.options))
1866
1969
  throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new f(
1867
1970
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
1868
1971
  );
@@ -1880,18 +1983,18 @@ class dt {
1880
1983
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
1881
1984
  }
1882
1985
  maybeHandleVerificationRequired(e) {
1883
- return x(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);
1986
+ return G(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);
1884
1987
  }
1885
1988
  handleVerificationEmailSent(e, s) {
1886
1989
  this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
1887
1990
  }
1888
1991
  invokeRedirectModeSuccessHook(e) {
1889
1992
  var s, i;
1890
- if (!(!P(this.options) || !this.options.onSuccess))
1993
+ if (!(!_(this.options) || !this.options.onSuccess))
1891
1994
  try {
1892
1995
  this.options.onSuccess(e);
1893
1996
  } catch (n) {
1894
- const a = x(n, "Post-auth callback failed.");
1997
+ const a = G(n, "Post-auth callback failed.");
1895
1998
  try {
1896
1999
  (i = (s = this.options).onError) == null || i.call(s, a);
1897
2000
  } catch {
@@ -1900,7 +2003,7 @@ class dt {
1900
2003
  }
1901
2004
  handleError(e, s) {
1902
2005
  var n, a;
1903
- const i = x(e, s);
2006
+ const i = G(e, s);
1904
2007
  this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (n = this.options).onError) == null || a.call(n, i);
1905
2008
  }
1906
2009
  failValidation(e) {
@@ -1910,15 +2013,15 @@ class dt {
1910
2013
  if (!e)
1911
2014
  return window.location.href;
1912
2015
  const i = new URL(window.location.href);
1913
- return i.searchParams.set(W, e), s ? i.searchParams.set(k, s) : i.searchParams.delete(k), i.toString();
2016
+ return i.searchParams.set(K, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
1914
2017
  }
1915
2018
  consumeManagedReturnContext() {
1916
- const e = new URL(window.location.href), s = e.searchParams.get(W), i = s === G || s === U || s === S ? s : null, n = e.searchParams.get(k), a = i ? e.searchParams.get("error") : null, h = i ? e.searchParams.get("error_description") : null;
1917
- return (i || n) && (e.searchParams.delete(W), e.searchParams.delete(k), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
2019
+ const e = new URL(window.location.href), s = e.searchParams.get(K), i = s === W || s === B || s === P ? s : null, n = e.searchParams.get(M), a = i ? e.searchParams.get("error") : null, u = i ? e.searchParams.get("error_description") : null;
2020
+ return (i || n) && (e.searchParams.delete(K), e.searchParams.delete(M), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1918
2021
  marker: i,
1919
2022
  email: n,
1920
2023
  error: a,
1921
- errorDescription: h
2024
+ errorDescription: u
1922
2025
  };
1923
2026
  }
1924
2027
  startCountdown(e = 60) {
@@ -1982,10 +2085,10 @@ class dt {
1982
2085
  return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
1983
2086
  }
1984
2087
  handleSessionlessManagedReturn(e) {
1985
- return e.email && (this.state.email = e.email), e.marker === S && !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 === U || e.marker === S ? (this.verificationCompletionAction = e.marker === S ? "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 v(
2088
+ return e.email && (this.state.email = e.email), e.marker === P && !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 === B || e.marker === P ? (this.verificationCompletionAction = e.marker === P ? "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 v(
1986
2089
  e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
1987
2090
  { code: e.error ?? "VERIFY_EMAIL_ERROR" }
1988
- )) : this.render(), !0) : e.marker === G && (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 v(
2091
+ )) : this.render(), !0) : e.marker === W && (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 v(
1989
2092
  e.errorDescription ?? "OAuth sign-in failed.",
1990
2093
  { code: e.error ?? "OAUTH_ERROR" }
1991
2094
  )), !0) : !1;
@@ -2001,22 +2104,22 @@ class dt {
2001
2104
  return i <= 0 ? e : s.replace("{seconds}", String(i));
2002
2105
  }
2003
2106
  escape(e) {
2004
- return e.replace(/[&<>"']/g, (s) => rt[s]);
2107
+ return e.replace(/[&<>"']/g, (s) => Et[s]);
2005
2108
  }
2006
2109
  }
2007
- function ct(t) {
2110
+ function At(t) {
2008
2111
  return "data" in t && t.data ? t.data : t;
2009
2112
  }
2010
- const ut = [
2113
+ const Rt = [
2011
2114
  { id: "google", key: "providerGoogle" },
2012
2115
  { id: "apple", key: "providerApple" },
2013
2116
  { id: "microsoft", key: "providerMicrosoft" },
2014
2117
  { id: "github", key: "providerGithub" },
2015
2118
  { id: "gitlab", key: "providerGitlab" },
2016
2119
  { id: "discord", key: "providerDiscord" }
2017
- ], ve = 2, ht = 500;
2018
- async function mt() {
2019
- const t = `${window.location.origin}${Ee}/config`;
2120
+ ], ve = 2, Tt = 500;
2121
+ async function It() {
2122
+ const t = `${window.location.origin}${_e}/config`;
2020
2123
  let e;
2021
2124
  for (let s = 0; s <= ve; s++)
2022
2125
  try {
@@ -2024,35 +2127,35 @@ async function mt() {
2024
2127
  if (!i.ok)
2025
2128
  throw new f(`Failed to load auth config: HTTP ${i.status}`);
2026
2129
  const n = await i.json();
2027
- return wt(ct(n));
2130
+ return Ut(At(n));
2028
2131
  } catch (i) {
2029
- e = i, s < ve && await new Promise((n) => setTimeout(n, ht));
2132
+ e = i, s < ve && await new Promise((n) => setTimeout(n, Tt));
2030
2133
  }
2031
2134
  throw e;
2032
2135
  }
2033
- let M = null;
2034
- async function ft() {
2035
- return M || (M = mt().catch((t) => {
2036
- throw M = null, t;
2037
- })), M;
2038
- }
2039
- function wt(t) {
2040
- var s, i, n, a, h, w, E;
2041
- const e = ut.filter(({ key: L }) => {
2042
- const _ = t[L];
2043
- return typeof _ == "object" && _ !== null && "enabled" in _ && !!_.enabled;
2044
- }).map(({ id: L }) => L);
2136
+ let O = null;
2137
+ async function Ct() {
2138
+ return O || (O = It().catch((t) => {
2139
+ throw O = null, t;
2140
+ })), O;
2141
+ }
2142
+ function Ut(t) {
2143
+ var s, i, n, a, u, g, E;
2144
+ const e = Rt.filter(({ key: A }) => {
2145
+ const R = t[A];
2146
+ return typeof R == "object" && R !== null && "enabled" in R && !!R.enabled;
2147
+ }).map(({ id: A }) => A);
2045
2148
  return {
2046
2149
  disableSignUp: !!t.disableSignUp,
2047
2150
  emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
2048
2151
  minPasswordLength: ((n = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : n.minPasswordLength) ?? 8,
2049
- requireEmailVerification: !!((h = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && h.requireEmailVerification),
2050
- passwordResetEmailOtpEnabled: !!((E = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && E.requirePasswordResetEmailVerification),
2152
+ requireEmailVerification: !!((u = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && u.requireEmailVerification),
2153
+ passwordResetEmailOtpEnabled: !!((E = (g = t.providerEmailPassword) == null ? void 0 : g.config) != null && E.requirePasswordResetEmailVerification),
2051
2154
  oauthProviders: e
2052
2155
  };
2053
2156
  }
2054
- const O = /* @__PURE__ */ new WeakMap();
2055
- function gt(t) {
2157
+ const N = /* @__PURE__ */ new WeakMap();
2158
+ function $t(t) {
2056
2159
  if (!t)
2057
2160
  throw new f(
2058
2161
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
@@ -2077,30 +2180,61 @@ function gt(t) {
2077
2180
  throw new f(
2078
2181
  "authUI.mount(container, options) expected onError to be a function."
2079
2182
  );
2183
+ if ("appearance" in t && t.appearance !== void 0) {
2184
+ const i = t.appearance;
2185
+ if (!i || typeof i != "object" || Array.isArray(i))
2186
+ throw new f(
2187
+ "authUI.mount(container, options) expected appearance to be an object."
2188
+ );
2189
+ if ("theme" in i && i.theme !== void 0 && !pt(i.theme))
2190
+ throw new f(
2191
+ `authUI.mount(container, options) expected appearance.theme to be one of: ${$e.join(", ")}.`
2192
+ );
2193
+ if ("className" in i && i.className !== void 0 && typeof i.className != "string")
2194
+ throw new f(
2195
+ "authUI.mount(container, options) expected appearance.className to be a string."
2196
+ );
2197
+ if ("variables" in i && i.variables !== void 0) {
2198
+ if (!i.variables || typeof i.variables != "object" || Array.isArray(i.variables))
2199
+ throw new f(
2200
+ "authUI.mount(container, options) expected appearance.variables to be an object."
2201
+ );
2202
+ for (const [n, a] of Object.entries(i.variables)) {
2203
+ if (!gt(n))
2204
+ throw new f(
2205
+ `authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
2206
+ );
2207
+ if (a !== void 0 && typeof a != "string")
2208
+ throw new f(
2209
+ `authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`
2210
+ );
2211
+ }
2212
+ }
2213
+ }
2080
2214
  }
2081
- function pt(t) {
2215
+ function Bt(t) {
2082
2216
  if (!(t instanceof HTMLElement))
2083
2217
  throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
2084
2218
  }
2085
- function bt(t, e) {
2219
+ function kt(t, e) {
2086
2220
  return {
2087
2221
  mount(s, i) {
2088
- var w;
2089
- gt(i), pt(s), (w = O.get(s)) == null || w.destroy();
2090
- const n = new dt(s, t, i, ft, e), a = n.destroy.bind(n), h = {
2222
+ var g;
2223
+ $t(i), Bt(s), (g = N.get(s)) == null || g.destroy();
2224
+ const n = new Lt(s, t, i, Ct, e), a = n.destroy.bind(n), u = {
2091
2225
  destroy() {
2092
- a(), O.get(s) === h && O.delete(s);
2226
+ a(), N.get(s) === u && N.delete(s);
2093
2227
  }
2094
2228
  };
2095
- return O.set(s, h), h;
2229
+ return N.set(s, u), u;
2096
2230
  }
2097
2231
  };
2098
2232
  }
2099
- function yt() {
2233
+ function Ot() {
2100
2234
  Pe();
2101
- const t = Xe(), e = et(), s = Me(), i = bt(e, {
2235
+ const t = at(), e = lt(), s = De(), i = kt(e, {
2102
2236
  syncPublicSession: async () => {
2103
- await Qe(t);
2237
+ await ot(t);
2104
2238
  }
2105
2239
  });
2106
2240
  return {
@@ -2110,22 +2244,29 @@ function yt() {
2110
2244
  };
2111
2245
  }
2112
2246
  export {
2247
+ ft as AUTH_UI_APPEARANCE_VARIABLE,
2248
+ wt as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
2249
+ mt as AUTH_UI_DEFAULT_THEME,
2250
+ Ce as AUTH_UI_THEME,
2251
+ $e as AUTH_UI_THEMES,
2252
+ ht as AUTH_UI_THEME_DARK,
2253
+ Ue as AUTH_UI_THEME_LIGHT,
2113
2254
  v as EdgeSparkAuthError,
2114
2255
  f as EdgeSparkConfigError,
2115
- ee as EdgeSparkError,
2116
- ye as EdgeSparkRuntimeError,
2117
- we as ar,
2118
- yt as createEdgeSpark,
2119
- he as de,
2120
- it as detectLocale,
2256
+ te as EdgeSparkError,
2257
+ Ee as EdgeSparkRuntimeError,
2258
+ pe as ar,
2259
+ Ot as createEdgeSpark,
2260
+ me as de,
2261
+ ut as detectLocale,
2121
2262
  V as enUS,
2122
- H as es,
2123
- ue as fr,
2263
+ q as es,
2264
+ he as fr,
2124
2265
  ge as hi,
2125
- me as it,
2126
- le as ja,
2127
- de as ko,
2128
- ce as ptBR,
2129
- fe as ru,
2130
- j as zhCN
2266
+ fe as it,
2267
+ de as ja,
2268
+ ce as ko,
2269
+ ue as ptBR,
2270
+ we as ru,
2271
+ x as zhCN
2131
2272
  };