@edgespark/web 0.0.1-beta.5 → 0.0.1-beta.7

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,75 +1,106 @@
1
- import { createAuthClient as be } from "better-auth/client";
2
- class j extends Error {
1
+ import { createAuthClient as Ue } from "better-auth/client";
2
+ class ee extends Error {
3
3
  constructor(e, s) {
4
4
  super(s), this.name = "EdgeSparkError", this.code = e;
5
5
  }
6
6
  }
7
- class u extends j {
7
+ class f extends ee {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class de extends j {
12
+ class ye extends ee {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
16
16
  }
17
- class w extends j {
17
+ class v extends ee {
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
  }
21
21
  }
22
- function ce() {
22
+ function Se(t, e = "Authentication failed.", s) {
23
+ if (t instanceof v)
24
+ return t;
25
+ if (typeof t == "object" && t !== null) {
26
+ const i = t;
27
+ return new v(i.message || e, {
28
+ code: i.code ?? s,
29
+ status: i.status,
30
+ cause: t
31
+ });
32
+ }
33
+ return typeof t == "string" ? new v(t, { code: s }) : new v(e, { code: s, cause: t });
34
+ }
35
+ function Pe() {
23
36
  if (typeof window > "u" || typeof document > "u")
24
- throw new de(
37
+ throw new ye(
25
38
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
26
39
  );
27
40
  }
28
- function W() {
29
- return ce(), window.location.origin;
41
+ function Q() {
42
+ return Pe(), window.location.origin;
30
43
  }
31
- function ge(t) {
44
+ function Be(t) {
32
45
  return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
33
46
  }
34
- function ve(t) {
35
- if (t.origin !== W())
36
- throw new u(
37
- `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${W()}.`
47
+ function ke(t) {
48
+ if (t.origin !== Q())
49
+ throw new f(
50
+ `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
38
51
  );
39
52
  }
40
- function ye() {
53
+ function Me() {
41
54
  return {
42
55
  async fetch(t, e) {
43
- const s = ge(t);
44
- return ve(s), fetch(t, {
56
+ const s = Be(t);
57
+ return ke(s), fetch(t, {
45
58
  ...e,
46
59
  credentials: "include"
47
60
  });
48
61
  }
49
62
  };
50
63
  }
51
- const ue = "/api/_es/auth", Pe = "edgespark-auth-session", K = "__edgespark_auth_sync__", he = Symbol("edgespark.notifyAuthTabs");
52
- function me(t) {
53
- return be({
54
- baseURL: W(),
55
- basePath: ue,
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([
65
+ "signOut",
66
+ "revokeSession",
67
+ "revokeSessions",
68
+ "revokeOtherSessions"
69
+ ]);
70
+ class Fe {
71
+ constructor(e) {
72
+ this.value = e;
73
+ }
74
+ deref() {
75
+ return this.value;
76
+ }
77
+ }
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);
82
+ }) : null;
83
+ function Ie(t) {
84
+ return Ue({
85
+ baseURL: Q(),
86
+ basePath: Ee,
56
87
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
57
88
  fetchOptions: {
58
89
  credentials: "include"
59
90
  }
60
91
  });
61
92
  }
62
- function _(t) {
93
+ function R(t) {
63
94
  var e, s;
64
95
  return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
65
96
  }
66
- function Le(t) {
97
+ function ze(t) {
67
98
  return JSON.stringify({
68
99
  source: t,
69
100
  timestamp: Date.now()
70
101
  });
71
102
  }
72
- function Ee(t) {
103
+ function De(t) {
73
104
  if (typeof t != "string")
74
105
  return null;
75
106
  try {
@@ -79,182 +110,314 @@ function Ee(t) {
79
110
  return null;
80
111
  }
81
112
  }
82
- function Se(t) {
83
- if (!(t && typeof t == "object") || "error" in t && t.error)
113
+ async function X(t) {
114
+ var e;
115
+ try {
116
+ return await ((e = R(t)) == null ? void 0 : e.get().refetch()), !0;
117
+ } catch {
84
118
  return !1;
85
- const e = "data" in t ? t.data : t;
86
- 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;
119
+ }
87
120
  }
88
- function M(t) {
89
- if (t instanceof w)
90
- return t;
91
- const e = t;
92
- return new w(
93
- (e == null ? void 0 : e.message) || "Failed to load the current session.",
94
- {
95
- code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
96
- cause: t,
97
- status: e == null ? void 0 : e.status
121
+ function Re() {
122
+ return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(Oe) : null), F;
123
+ }
124
+ function oe(t) {
125
+ const e = De(t);
126
+ if (e)
127
+ for (const [s, i] of C) {
128
+ if (s === e.source)
129
+ continue;
130
+ const n = i.deref();
131
+ if (!n) {
132
+ C.delete(s);
133
+ continue;
134
+ }
135
+ X(n);
98
136
  }
99
- );
100
137
  }
101
- async function _e(t) {
102
- var e, s;
103
- await ((e = _(t)) == null ? void 0 : e.get().refetch()), (s = t[he]) == null || s.call(t);
138
+ function qe() {
139
+ var t;
140
+ re || (re = !0, (t = Re()) == null || t.addEventListener("message", (e) => {
141
+ oe(e.data);
142
+ }), typeof window < "u" && window.addEventListener("storage", (e) => {
143
+ e.key !== Le || e.newValue === null || oe(e.newValue);
144
+ }));
104
145
  }
105
- function Te() {
106
- const t = me(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`, s = typeof BroadcastChannel < "u" ? new BroadcastChannel(Pe) : null, i = 2, r = 500;
107
- let a = null, c = !1;
108
- const p = () => {
109
- var l;
110
- return c ? Promise.resolve(((l = _(t)) == null ? void 0 : l.get().data) ?? null) : (a || (a = (async () => {
111
- var m, f, g, v;
112
- let o = !1, d = null;
113
- try {
114
- for (let L = 0; L <= i; L++) {
115
- const E = await t.getSession(), y = ((m = _(t)) == null ? void 0 : m.get().data) ?? null;
116
- if ((f = E.data) != null && f.session && ((g = E.data) != null && g.user))
117
- return c = !0, E.data;
118
- if (y != null && y.session && (y != null && y.user))
119
- return c = !0, y;
120
- if (E.error ? d = E.error : o = !0, !E.error && L < i) {
121
- await new Promise((k) => setTimeout(k, r));
122
- continue;
123
- }
124
- L < i && await new Promise((k) => setTimeout(k, r));
125
- }
126
- if (!o)
127
- throw a = null, new w("Failed to load the current session.", {
128
- code: "SESSION_LOOKUP_FAILED",
129
- cause: d
130
- });
131
- const h = ((v = _(t)) == null ? void 0 : v.get().data) ?? null;
132
- return c = !0, h;
133
- } catch (h) {
134
- throw a = null, M(h);
135
- }
136
- })()), a);
137
- };
138
- p().catch(() => {
139
- });
140
- const T = async () => {
141
- var l, o;
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();
148
+ }
149
+ function I(t) {
150
+ const e = ze(t), s = Re();
151
+ let i = !1;
152
+ if (s)
142
153
  try {
143
- const d = await t.getSession();
144
- if ((l = d.data) != null && l.session && ((o = d.data) != null && o.user))
145
- return d.data;
146
- throw d.error ? M(d.error) : new w("No authenticated session is available.", {
147
- code: "UNAUTHENTICATED"
148
- });
149
- } catch (d) {
150
- throw M(d);
154
+ s.postMessage(e), i = !0;
155
+ } catch {
151
156
  }
152
- }, P = async () => {
153
- var l;
157
+ if (!i)
154
158
  try {
155
- await ((l = _(t)) == null ? void 0 : l.get().refetch());
159
+ window.localStorage.setItem(Le, e);
156
160
  } catch {
157
161
  }
158
- }, b = () => {
159
- const l = Le(e);
162
+ }
163
+ function D(t) {
164
+ if (!(typeof window > "u"))
160
165
  try {
161
- s == null || s.postMessage(l);
166
+ window.sessionStorage.setItem(
167
+ N,
168
+ JSON.stringify({
169
+ path: t,
170
+ createdAt: Date.now()
171
+ })
172
+ );
162
173
  } catch {
163
174
  }
175
+ }
176
+ function $() {
177
+ if (!(typeof window > "u"))
164
178
  try {
165
- window.localStorage.setItem(K, l);
179
+ window.sessionStorage.removeItem(N);
166
180
  } catch {
167
181
  }
168
- }, G = (l) => {
169
- const o = Ee(l);
170
- !o || o.source === e || P();
171
- };
172
- s == null || s.addEventListener("message", (l) => {
173
- G(l.data);
174
- }), typeof window < "u" && window.addEventListener("storage", (l) => {
175
- l.key !== K || l.newValue === null || G(l.newValue);
182
+ }
183
+ function He(t) {
184
+ return !!(t != null && t.session && (t != null && t.user));
185
+ }
186
+ function Te() {
187
+ if (typeof window > "u")
188
+ return null;
189
+ try {
190
+ const t = window.sessionStorage.getItem(N);
191
+ if (!t)
192
+ return null;
193
+ const e = JSON.parse(t);
194
+ return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ve ? null : { createdAt: e.createdAt };
195
+ } catch {
196
+ return null;
197
+ }
198
+ }
199
+ function ae() {
200
+ if (!Te())
201
+ return !1;
202
+ try {
203
+ window.sessionStorage.removeItem(N);
204
+ } catch {
205
+ }
206
+ return !0;
207
+ }
208
+ function xe() {
209
+ return Te() !== null;
210
+ }
211
+ function We(t) {
212
+ if (!(t && typeof t == "object") || "error" in t && t.error)
213
+ return !1;
214
+ const e = "data" in t ? t.data : t;
215
+ 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
+ }
217
+ function Ge(t) {
218
+ if (!(t && typeof t == "object") || "error" in t && t.error)
219
+ return !1;
220
+ const e = "data" in t ? t.data : t;
221
+ return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
222
+ }
223
+ function Ye(t) {
224
+ if (T(t) || !(t && typeof t == "object"))
225
+ return !1;
226
+ const e = "data" in t ? t.data : t;
227
+ return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
228
+ }
229
+ function Ke(t, e) {
230
+ if (t.length !== 1 || t[0] !== "changePassword")
231
+ return !1;
232
+ const [s] = e;
233
+ return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
234
+ }
235
+ function T(t) {
236
+ return !!(t && typeof t == "object" && "error" in t && t.error);
237
+ }
238
+ function Je(t) {
239
+ if (T(t) || !(t && typeof t == "object"))
240
+ return !1;
241
+ const e = "data" in t ? t.data : t;
242
+ return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
243
+ }
244
+ function Ze(t) {
245
+ return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
246
+ }
247
+ function q(t) {
248
+ return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
249
+ }
250
+ async function Qe(t) {
251
+ var s, i;
252
+ let e = null;
253
+ try {
254
+ await ((s = R(t)) == null ? void 0 : s.get().refetch());
255
+ } catch (n) {
256
+ e = n;
257
+ } finally {
258
+ (i = t[_e]) == null || i.call(t);
259
+ }
260
+ if (e)
261
+ throw e;
262
+ }
263
+ function Xe() {
264
+ const t = Ie(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
265
+ je(e, t);
266
+ const s = 2, i = 500;
267
+ let n = null, a = !1, h;
268
+ const w = (o) => (h = o, o), E = () => {
269
+ 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;
274
+ let o = !1, c = null;
275
+ try {
276
+ for (let p = 0; p <= s; p++) {
277
+ let d = null;
278
+ try {
279
+ d = await t.getSession();
280
+ } catch (y) {
281
+ c = y;
282
+ }
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) {
289
+ await new Promise(
290
+ (y) => setTimeout(y, i)
291
+ );
292
+ continue;
293
+ }
294
+ if (d && !d.error) {
295
+ const y = E();
296
+ return a = !0, w(y);
297
+ }
298
+ p < s && await new Promise(
299
+ (y) => setTimeout(y, i)
300
+ );
301
+ }
302
+ if (!o)
303
+ throw n = null, new v("Failed to load the current session.", {
304
+ code: "SESSION_LOOKUP_FAILED",
305
+ cause: c
306
+ });
307
+ const m = E();
308
+ return a = !0, w(m);
309
+ } catch (m) {
310
+ throw n = null, q(m);
311
+ }
312
+ })()), n);
313
+ L().catch(() => {
176
314
  });
177
- const Y = async () => {
178
- await P(), b();
179
- }, we = (l) => {
180
- let o = !1, d = !1, m;
181
- const f = (h) => {
182
- h !== m && (m = h, l(h));
315
+ const _ = async () => {
316
+ var o, c;
317
+ try {
318
+ const l = await t.getSession();
319
+ if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
320
+ return l.data;
321
+ throw l.error ? q(l.error) : new v("No authenticated session is available.", {
322
+ code: "UNAUTHENTICATED"
323
+ });
324
+ } catch (l) {
325
+ throw q(l);
326
+ }
327
+ }, A = async () => {
328
+ await X(t), I(e);
329
+ }, Ce = async () => {
330
+ 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));
183
337
  };
184
- p().then((h) => {
185
- o || (d = !0, f(h));
338
+ L().then((d) => {
339
+ c || (l = !0, g(w(d)));
186
340
  }).catch(() => {
187
- o || (d = !0);
341
+ c || (l = !0);
188
342
  });
189
- const g = _(t);
190
- if (!g)
343
+ const m = R(t);
344
+ if (!m)
191
345
  return () => {
192
- o = !0;
346
+ c = !0;
193
347
  };
194
- const v = g.subscribe((h) => {
195
- if (o || !d || h.error && !h.data)
348
+ const p = m.subscribe((d) => {
349
+ if (c || !l || d.error && !d.data)
196
350
  return;
197
- const L = h.data ?? null;
198
- f(L);
351
+ const b = d.data ?? null;
352
+ g(w(b));
199
353
  });
200
354
  return () => {
201
- o = !0, v();
355
+ c = !0, p();
202
356
  };
203
- }, fe = async (...l) => {
204
- const o = await t.signOut(...l);
205
- return o && typeof o == "object" && "error" in o && o.error || await Y(), o;
206
- }, pe = (l) => new Proxy(l, {
207
- get(o, d, m) {
208
- const f = Reflect.get(o, d, m);
209
- return typeof f != "function" ? f : async (...g) => {
210
- const v = await f.apply(o, g);
211
- return Se(v) && await Y(), v;
212
- };
213
- }
214
- });
215
- return new Proxy(t, {
216
- get(l, o, d) {
217
- if (o === "requireSession")
218
- return T;
219
- if (o === "onSessionChange")
220
- return we;
221
- if (o === "signOut")
222
- return fe;
223
- if (o === he)
224
- return b;
225
- if (o === "signIn" || o === "signUp") {
226
- const m = Reflect.get(l, o, d);
227
- return m && typeof m == "object" ? pe(m) : m;
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) => {
361
+ if (!o || typeof o != "object" && typeof o != "function")
362
+ return o;
363
+ const l = te.get(o);
364
+ if (l)
365
+ return l;
366
+ const u = new Proxy(o, {
367
+ get(g, m, p) {
368
+ if (c.length === 0) {
369
+ if (m === "requireSession")
370
+ return _;
371
+ if (m === "onSessionChange")
372
+ return Ae;
373
+ if (m === _e)
374
+ return () => {
375
+ I(e);
376
+ };
377
+ }
378
+ const d = Reflect.get(g, m, p);
379
+ return typeof m != "string" ? d : se(d, [...c, m]);
380
+ },
381
+ apply(g, m, p) {
382
+ const d = Reflect.apply(
383
+ g,
384
+ m,
385
+ p
386
+ );
387
+ return Ze(d) ? Promise.resolve(d).then(
388
+ (b) => $e(c, p, b)
389
+ ) : d;
228
390
  }
229
- return Reflect.get(l, o, d);
230
- }
231
- });
391
+ });
392
+ return te.set(o, u), u;
393
+ };
394
+ return se(t, []);
232
395
  }
233
- function Ce() {
234
- return me({ disableDefaultRedirectPlugin: !0 });
396
+ function et() {
397
+ return Ie({ disableDefaultRedirectPlugin: !0 });
235
398
  }
236
- function O(t) {
399
+ function tt(t) {
237
400
  const e = (() => {
238
401
  if (t instanceof URL)
239
402
  return t;
240
403
  const s = t.trim();
241
404
  if (!s)
242
- throw new u("redirectTo must not be an empty string.");
405
+ throw new f("redirectTo must not be an empty string.");
243
406
  try {
244
407
  return new URL(s, window.location.href);
245
408
  } catch {
246
- throw new u(
409
+ throw new f(
247
410
  `redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
248
411
  );
249
412
  }
250
413
  })();
251
414
  if (e.protocol !== "http:" && e.protocol !== "https:")
252
- throw new u(
415
+ throw new f(
253
416
  `redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
254
417
  );
255
418
  return e;
256
419
  }
257
- function Ie(t, e) {
420
+ function st(t, e) {
258
421
  return e ? {
259
422
  common: { ...t.common, ...e.common },
260
423
  signIn: { ...t.signIn, ...e.signIn },
@@ -266,7 +429,7 @@ function Ie(t, e) {
266
429
  errors: { ...t.errors, ...e.errors }
267
430
  } : t;
268
431
  }
269
- const B = {
432
+ const V = {
270
433
  common: {
271
434
  loading: "Loading sign-in…",
272
435
  redirecting: "Redirecting…",
@@ -329,7 +492,7 @@ const B = {
329
492
  invalidCode: "Enter the 6-digit verification code.",
330
493
  generic: "Something went wrong. Please try again."
331
494
  }
332
- }, V = {
495
+ }, j = {
333
496
  common: {
334
497
  loading: "加载中…",
335
498
  redirecting: "跳转中…",
@@ -392,7 +555,7 @@ const B = {
392
555
  invalidCode: "请输入 6 位验证码",
393
556
  generic: "出现错误,请稍后重试"
394
557
  }
395
- }, J = {
558
+ }, le = {
396
559
  common: {
397
560
  loading: "サインインを読み込み中…",
398
561
  redirecting: "リダイレクト中…",
@@ -455,7 +618,7 @@ const B = {
455
618
  invalidCode: "6桁の認証コードを入力してください",
456
619
  generic: "エラーが発生しました。もう一度お試しください"
457
620
  }
458
- }, Z = {
621
+ }, de = {
459
622
  common: {
460
623
  loading: "로그인 로딩 중…",
461
624
  redirecting: "리디렉션 중…",
@@ -518,7 +681,7 @@ const B = {
518
681
  invalidCode: "6자리 인증 코드를 입력해 주세요",
519
682
  generic: "문제가 발생했습니다. 다시 시도해 주세요"
520
683
  }
521
- }, F = {
684
+ }, H = {
522
685
  common: {
523
686
  loading: "Cargando inicio de sesión…",
524
687
  redirecting: "Redirigiendo…",
@@ -581,7 +744,7 @@ const B = {
581
744
  invalidCode: "Ingresa el código de verificación de 6 dígitos.",
582
745
  generic: "Algo salió mal. Por favor, inténtalo de nuevo."
583
746
  }
584
- }, Q = {
747
+ }, ce = {
585
748
  common: {
586
749
  loading: "Carregando login…",
587
750
  redirecting: "Redirecionando…",
@@ -644,7 +807,7 @@ const B = {
644
807
  invalidCode: "Insira o código de verificação de 6 dígitos.",
645
808
  generic: "Algo deu errado. Por favor, tente novamente."
646
809
  }
647
- }, X = {
810
+ }, ue = {
648
811
  common: {
649
812
  loading: "Chargement de la connexion…",
650
813
  redirecting: "Redirection…",
@@ -707,7 +870,7 @@ const B = {
707
870
  invalidCode: "Saisissez le code de vérification à 6 chiffres.",
708
871
  generic: "Une erreur est survenue. Veuillez réessayer."
709
872
  }
710
- }, ee = {
873
+ }, he = {
711
874
  common: {
712
875
  loading: "Anmeldung wird geladen…",
713
876
  redirecting: "Weiterleitung…",
@@ -770,7 +933,7 @@ const B = {
770
933
  invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
771
934
  generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
772
935
  }
773
- }, te = {
936
+ }, me = {
774
937
  common: {
775
938
  loading: "Caricamento accesso…",
776
939
  redirecting: "Reindirizzamento…",
@@ -833,7 +996,7 @@ const B = {
833
996
  invalidCode: "Inserisci il codice di verifica a 6 cifre.",
834
997
  generic: "Qualcosa è andato storto. Riprova."
835
998
  }
836
- }, se = {
999
+ }, fe = {
837
1000
  common: {
838
1001
  loading: "Загрузка входа…",
839
1002
  redirecting: "Перенаправление…",
@@ -896,7 +1059,7 @@ const B = {
896
1059
  invalidCode: "Введите 6-значный код подтверждения.",
897
1060
  generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
898
1061
  }
899
- }, ie = {
1062
+ }, we = {
900
1063
  common: {
901
1064
  loading: "جارٍ تحميل تسجيل الدخول…",
902
1065
  redirecting: "جارٍ إعادة التوجيه…",
@@ -959,7 +1122,7 @@ const B = {
959
1122
  invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
960
1123
  generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
961
1124
  }
962
- }, ne = {
1125
+ }, ge = {
963
1126
  common: {
964
1127
  loading: "सधाइन की जुलातीअ लोड हो रही है…",
965
1128
  redirecting: "रीडायरेक्ट हो रहا है…",
@@ -1022,62 +1185,52 @@ const B = {
1022
1185
  invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
1023
1186
  generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
1024
1187
  }
1025
- }, re = {
1026
- en: B,
1027
- "en-US": B,
1028
- zh: V,
1029
- "zh-CN": V,
1030
- "zh-TW": V,
1031
- ja: J,
1032
- "ja-JP": J,
1033
- ko: Z,
1034
- "ko-KR": Z,
1035
- es: F,
1036
- "es-ES": F,
1037
- "es-MX": F,
1038
- pt: Q,
1039
- "pt-BR": Q,
1040
- fr: X,
1041
- "fr-FR": X,
1042
- de: ee,
1043
- "de-DE": ee,
1044
- it: te,
1045
- "it-IT": te,
1046
- ru: se,
1047
- "ru-RU": se,
1048
- ar: ie,
1049
- "ar-SA": ie,
1050
- hi: ne,
1051
- "hi-IN": ne
1188
+ }, pe = {
1189
+ en: V,
1190
+ "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,
1213
+ hi: ge,
1214
+ "hi-IN": ge
1052
1215
  };
1053
- function Re() {
1216
+ function it() {
1054
1217
  if (typeof navigator > "u")
1055
- return B;
1218
+ return V;
1056
1219
  const t = navigator.languages ?? [navigator.language];
1057
1220
  for (const e of t) {
1058
- const s = re[e] ?? re[e.split("-")[0]];
1221
+ const s = pe[e] ?? pe[e.split("-")[0]];
1059
1222
  if (s) return s;
1060
1223
  }
1061
- return B;
1224
+ return V;
1062
1225
  }
1063
- function N(t, e = "Authentication failed.") {
1064
- if (t instanceof w)
1065
- return t;
1066
- if (typeof t == "object" && t !== null) {
1067
- const s = t;
1068
- return new w(s.message || e, {
1069
- code: s.code,
1070
- status: s.status,
1071
- cause: t
1072
- });
1073
- }
1074
- return typeof t == "string" ? new w(t) : new w(e, { cause: t });
1226
+ function x(t, e = "Authentication failed.") {
1227
+ return Se(t, e);
1075
1228
  }
1076
- async function C(t) {
1229
+ async function B(t) {
1077
1230
  var s, i;
1078
1231
  const e = await t.getSession();
1079
1232
  if (e.error)
1080
- throw new w(
1233
+ throw new v(
1081
1234
  e.error.message || "Failed to load the current session.",
1082
1235
  {
1083
1236
  code: e.error.code ?? "SESSION_LOOKUP_FAILED",
@@ -1093,7 +1246,13 @@ async function C(t) {
1093
1246
  session: null
1094
1247
  };
1095
1248
  }
1096
- const $e = "data-edgespark-auth", n = "edgespark-auth", z = "es_auth_completion", I = "es_auth_email", oe = "oauth", R = "verify-sign-in", S = "verify-sign-up", ae = 200, q = 2, D = {
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 = {
1250
+ "&": "&amp;",
1251
+ "<": "&lt;",
1252
+ ">": "&gt;",
1253
+ '"': "&quot;",
1254
+ "'": "&#39;"
1255
+ }, K = {
1097
1256
  google: "Google",
1098
1257
  apple: "Apple",
1099
1258
  microsoft: "Microsoft",
@@ -1101,24 +1260,27 @@ const $e = "data-edgespark-auth", n = "edgespark-auth", z = "es_auth_completion"
1101
1260
  gitlab: "GitLab",
1102
1261
  discord: "Discord"
1103
1262
  };
1104
- function $(t) {
1263
+ function P(t) {
1105
1264
  return "redirectTo" in t;
1106
1265
  }
1107
- function H(t) {
1266
+ function J(t) {
1108
1267
  return "onSuccess" in t && !("redirectTo" in t);
1109
1268
  }
1110
- function x(t) {
1269
+ function Z(t) {
1111
1270
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1112
1271
  }
1113
- function Ue(t) {
1272
+ function ot(t) {
1114
1273
  return /^\d{6}$/.test(t.trim());
1115
1274
  }
1116
- function Ae(t) {
1275
+ function at(t) {
1117
1276
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1118
1277
  }
1119
- class Be {
1120
- constructor(e, s, i, r, a) {
1121
- if (this.container = e, this.auth = s, this.options = i, this.loadConfig = r, this.runtimeOptions = a, this.state = {
1278
+ function lt(t) {
1279
+ return !!(t.error || t.errorDescription);
1280
+ }
1281
+ class dt {
1282
+ constructor(e, s, i, n, a) {
1283
+ this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
1122
1284
  view: "loading",
1123
1285
  busy: !0,
1124
1286
  busyLabel: void 0,
@@ -1130,56 +1292,74 @@ class Be {
1130
1292
  confirmPassword: "",
1131
1293
  code: "",
1132
1294
  newPassword: ""
1133
- }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, !(e instanceof HTMLElement))
1134
- throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
1135
- this.labels = Ie(Re(), i.labels), this.root = document.createElement("div"), this.root.setAttribute($e, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
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();
1136
1296
  }
1137
1297
  destroy() {
1138
1298
  this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
1139
1299
  }
1140
1300
  async initialize() {
1301
+ const e = this.consumeManagedReturnContext();
1141
1302
  try {
1142
- const e = this.consumeManagedReturnContext(), [s, i] = await Promise.all([
1303
+ const [s, i] = await Promise.allSettled([
1143
1304
  this.loadConfig(),
1144
1305
  this.readMountSession(e)
1145
1306
  ]);
1146
1307
  if (this.destroyed)
1147
1308
  return;
1148
- if (this.config = s, i.user && i.session) {
1149
- switch (e.marker) {
1150
- case oe:
1151
- case R:
1152
- await this.completeAuth("sign-in", i);
1153
- return;
1154
- case S:
1155
- await this.completeAuth("sign-up", i);
1156
- return;
1157
- default:
1158
- break;
1309
+ if (i.status === "rejected") {
1310
+ if (e.marker && !lt(e) && P(this.options)) {
1311
+ this.redirectAfterManagedReturnLookupFailure();
1312
+ return;
1313
+ }
1314
+ } else {
1315
+ const a = i.value;
1316
+ if (a.user && a.session) {
1317
+ switch (e.marker) {
1318
+ case G:
1319
+ case U:
1320
+ await this.completeAuth("sign-in", a);
1321
+ return;
1322
+ case S:
1323
+ await this.completeAuth("sign-up", a);
1324
+ return;
1325
+ default:
1326
+ break;
1327
+ }
1328
+ this.handleExistingSessionOnMount();
1329
+ return;
1159
1330
  }
1160
- this.handleExistingSessionOnMount(i);
1161
- return;
1162
1331
  }
1163
- if (this.handleSessionlessManagedReturn(e))
1332
+ if (s.status === "rejected")
1333
+ throw i.status === "rejected" ? i.reason : s.reason;
1334
+ if (this.config = s.value, this.handleSessionlessManagedReturn(e))
1164
1335
  return;
1336
+ if (i.status === "rejected")
1337
+ throw i.reason;
1338
+ const n = i.value;
1165
1339
  this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.render();
1166
- } catch (e) {
1167
- this.handleError(e, "Failed to load the authentication UI.");
1340
+ } catch (s) {
1341
+ this.handleError(s, "Failed to load the authentication UI.");
1168
1342
  }
1169
1343
  }
1344
+ redirectAfterManagedReturnLookupFailure() {
1345
+ P(this.options) && this.navigateToRedirect();
1346
+ }
1347
+ 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()));
1349
+ }
1170
1350
  async readMountSession(e) {
1171
1351
  if (!e.marker)
1172
- return C(this.auth);
1352
+ return B(this.auth);
1173
1353
  let s = null;
1174
- for (let i = 0; i <= q; i++) {
1354
+ for (let i = 0; i <= Y; i++) {
1175
1355
  try {
1176
- const r = await C(this.auth);
1177
- if (r.user && r.session)
1178
- return r;
1179
- } catch (r) {
1180
- s = r;
1356
+ const n = await B(this.auth);
1357
+ if (n.user && n.session)
1358
+ return n;
1359
+ } catch (n) {
1360
+ s = n;
1181
1361
  }
1182
- i < q && await new Promise((r) => setTimeout(r, ae));
1362
+ i < Y && await new Promise((n) => setTimeout(n, be));
1183
1363
  }
1184
1364
  if (s)
1185
1365
  throw s;
@@ -1197,8 +1377,8 @@ class Be {
1197
1377
  return;
1198
1378
  }
1199
1379
  this.root.innerHTML = `
1200
- <div class="${n}__shell">
1201
- <div class="${n}__card">
1380
+ <div class="${r}__shell">
1381
+ <div class="${r}__card">
1202
1382
  ${this.renderStatus()}
1203
1383
  ${this.renderCurrentView()}
1204
1384
  </div>
@@ -1208,9 +1388,9 @@ class Be {
1208
1388
  renderLoading() {
1209
1389
  const e = this.renderStatus();
1210
1390
  return `
1211
- <div class="${n}__shell">
1212
- <div class="${n}__card">
1213
- ${e || `<div class="${n}__status ${n}__status--info">${this.escape(this.labels.common.loading)}</div>`}
1391
+ <div class="${r}__shell">
1392
+ <div class="${r}__card">
1393
+ ${e || `<div class="${r}__status ${r}__status--info">${this.escape(this.labels.common.loading)}</div>`}
1214
1394
  </div>
1215
1395
  </div>
1216
1396
  `;
@@ -1218,11 +1398,11 @@ class Be {
1218
1398
  renderStatus() {
1219
1399
  const e = [];
1220
1400
  return this.state.error && e.push(
1221
- `<div class="${n}__status ${n}__status--error">${this.escape(this.state.error)}</div>`
1401
+ `<div class="${r}__status ${r}__status--error">${this.escape(this.state.error)}</div>`
1222
1402
  ), this.state.notice && e.push(
1223
- `<div class="${n}__status ${n}__status--info">${this.escape(this.state.notice)}</div>`
1403
+ `<div class="${r}__status ${r}__status--info">${this.escape(this.state.notice)}</div>`
1224
1404
  ), this.state.busy && this.state.busyLabel && e.push(
1225
- `<div class="${n}__status ${n}__status--muted">${this.escape(this.state.busyLabel)}</div>`
1405
+ `<div class="${r}__status ${r}__status--muted">${this.escape(this.state.busyLabel)}</div>`
1226
1406
  ), e.join("");
1227
1407
  }
1228
1408
  renderCurrentView() {
@@ -1239,38 +1419,38 @@ class Be {
1239
1419
  return this.renderResetPasswordView();
1240
1420
  case "loading":
1241
1421
  default:
1242
- return `<p class="${n}__copy">${this.escape(this.labels.common.loading)}</p>`;
1422
+ return `<p class="${r}__copy">${this.escape(this.labels.common.loading)}</p>`;
1243
1423
  }
1244
1424
  }
1245
1425
  renderSignInView() {
1246
- var i, r;
1426
+ var i, n;
1247
1427
  const e = this.renderOAuthProviders(), s = ((i = this.config) == null ? void 0 : i.emailPasswordEnabled) ?? !0;
1248
1428
  return `
1249
- <section class="${n}__section">
1250
- <header class="${n}__header">
1251
- <h1 class="${n}__title">${this.escape(this.labels.signIn.title)}</h1>
1252
- <p class="${n}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
1429
+ <section class="${r}__section">
1430
+ <header class="${r}__header">
1431
+ <h1 class="${r}__title">${this.escape(this.labels.signIn.title)}</h1>
1432
+ <p class="${r}__copy">${this.escape(this.labels.signIn.subtitle)}</p>
1253
1433
  </header>
1254
1434
  ${e}
1255
- ${e && s ? `<div class="${n}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
1435
+ ${e && s ? `<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
1256
1436
  ${s ? `
1257
- <form class="${n}__form" data-view="sign-in" novalidate>
1437
+ <form class="${r}__form" data-view="sign-in" novalidate>
1258
1438
  ${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email")}
1259
1439
  ${this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
1260
- <button class="${n}__button ${n}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1440
+ <button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1261
1441
  ${this.escape(this.labels.signIn.submitButton)}
1262
1442
  </button>
1263
1443
  </form>
1264
- <div class="${n}__actions">
1444
+ <div class="${r}__actions">
1265
1445
  ${this.canUsePasswordResetEmailOtp() ? `
1266
- <button class="${n}__link" type="button" data-action="forgot-password" ${this.state.busy ? "disabled" : ""}>
1446
+ <button class="${r}__link" type="button" data-action="forgot-password" ${this.state.busy ? "disabled" : ""}>
1267
1447
  ${this.escape(this.labels.signIn.forgotPassword)}
1268
1448
  </button>
1269
1449
  ` : ""}
1270
- ${(r = this.config) != null && r.disableSignUp ? "" : `
1271
- <p class="${n}__meta">
1450
+ ${(n = this.config) != null && n.disableSignUp ? "" : `
1451
+ <p class="${r}__meta">
1272
1452
  ${this.escape(this.labels.signIn.signUpPrompt)}
1273
- <button class="${n}__link" type="button" data-action="switch-sign-up" ${this.state.busy ? "disabled" : ""}>
1453
+ <button class="${r}__link" type="button" data-action="switch-sign-up" ${this.state.busy ? "disabled" : ""}>
1274
1454
  ${this.escape(this.labels.signIn.switchToSignUp)}
1275
1455
  </button>
1276
1456
  </p>
@@ -1283,25 +1463,25 @@ class Be {
1283
1463
  renderSignUpView() {
1284
1464
  const e = this.renderOAuthProviders();
1285
1465
  return `
1286
- <section class="${n}__section">
1287
- <header class="${n}__header">
1288
- <h1 class="${n}__title">${this.escape(this.labels.signUp.title)}</h1>
1289
- <p class="${n}__copy">${this.escape(this.labels.signUp.subtitle)}</p>
1466
+ <section class="${r}__section">
1467
+ <header class="${r}__header">
1468
+ <h1 class="${r}__title">${this.escape(this.labels.signUp.title)}</h1>
1469
+ <p class="${r}__copy">${this.escape(this.labels.signUp.subtitle)}</p>
1290
1470
  </header>
1291
1471
  ${e}
1292
- ${e ? `<div class="${n}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
1293
- <form class="${n}__form" data-view="sign-up" novalidate>
1472
+ ${e ? `<div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>` : ""}
1473
+ <form class="${r}__form" data-view="sign-up" novalidate>
1294
1474
  ${this.renderInput("name", this.labels.signUp.nameLabel, "text", this.state.name, "name")}
1295
1475
  ${this.renderInput("email", this.labels.signUp.emailLabel, "email", this.state.email, "email")}
1296
1476
  ${this.renderInput("password", this.labels.signUp.passwordLabel, "password", this.state.password, "new-password")}
1297
1477
  ${this.renderInput("confirmPassword", this.labels.signUp.confirmPasswordLabel, "password", this.state.confirmPassword, "new-password")}
1298
- <button class="${n}__button ${n}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1478
+ <button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1299
1479
  ${this.escape(this.labels.signUp.submitButton)}
1300
1480
  </button>
1301
1481
  </form>
1302
- <p class="${n}__meta">
1482
+ <p class="${r}__meta">
1303
1483
  ${this.escape(this.labels.signUp.signInPrompt)}
1304
- <button class="${n}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
1484
+ <button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
1305
1485
  ${this.escape(this.labels.signUp.switchToSignIn)}
1306
1486
  </button>
1307
1487
  </p>
@@ -1314,20 +1494,20 @@ class Be {
1314
1494
  this.labels.verifyEmail.resendCountdown
1315
1495
  );
1316
1496
  return `
1317
- <section class="${n}__section">
1318
- <header class="${n}__header">
1319
- <h1 class="${n}__title">${this.escape(this.labels.verifyEmail.title)}</h1>
1320
- <p class="${n}__copy">${this.escape(this.labels.verifyEmail.subtitle)}</p>
1497
+ <section class="${r}__section">
1498
+ <header class="${r}__header">
1499
+ <h1 class="${r}__title">${this.escape(this.labels.verifyEmail.title)}</h1>
1500
+ <p class="${r}__copy">${this.escape(this.labels.verifyEmail.subtitle)}</p>
1321
1501
  </header>
1322
- <p class="${n}__copy">
1502
+ <p class="${r}__copy">
1323
1503
  <strong>${this.escape(this.labels.verifyEmail.sentToLabel)}:</strong>
1324
1504
  ${this.escape(this.state.email)}
1325
1505
  </p>
1326
- <div class="${n}__stack">
1327
- <button class="${n}__button ${n}__button--secondary" type="button" data-action="resend-verification" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
1506
+ <div class="${r}__stack">
1507
+ <button class="${r}__button ${r}__button--secondary" type="button" data-action="resend-verification" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
1328
1508
  ${this.escape(e)}
1329
1509
  </button>
1330
- <button class="${n}__link" type="button" data-action="use-different-email" ${this.state.busy ? "disabled" : ""}>
1510
+ <button class="${r}__link" type="button" data-action="use-different-email" ${this.state.busy ? "disabled" : ""}>
1331
1511
  ${this.escape(this.labels.verifyEmail.changeEmailButton)}
1332
1512
  </button>
1333
1513
  </div>
@@ -1336,18 +1516,18 @@ class Be {
1336
1516
  }
1337
1517
  renderForgotPasswordView() {
1338
1518
  return `
1339
- <section class="${n}__section">
1340
- <header class="${n}__header">
1341
- <h1 class="${n}__title">${this.escape(this.labels.forgotPassword.title)}</h1>
1342
- <p class="${n}__copy">${this.escape(this.labels.forgotPassword.subtitle)}</p>
1519
+ <section class="${r}__section">
1520
+ <header class="${r}__header">
1521
+ <h1 class="${r}__title">${this.escape(this.labels.forgotPassword.title)}</h1>
1522
+ <p class="${r}__copy">${this.escape(this.labels.forgotPassword.subtitle)}</p>
1343
1523
  </header>
1344
- <form class="${n}__form" data-view="forgot-password" novalidate>
1524
+ <form class="${r}__form" data-view="forgot-password" novalidate>
1345
1525
  ${this.renderInput("email", this.labels.forgotPassword.emailLabel, "email", this.state.email, "email")}
1346
- <button class="${n}__button ${n}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1526
+ <button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1347
1527
  ${this.escape(this.labels.forgotPassword.submitButton)}
1348
1528
  </button>
1349
1529
  </form>
1350
- <button class="${n}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
1530
+ <button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
1351
1531
  ${this.escape(this.labels.common.backToSignIn)}
1352
1532
  </button>
1353
1533
  </section>
@@ -1359,23 +1539,23 @@ class Be {
1359
1539
  this.labels.resetPassword.resendCountdown
1360
1540
  );
1361
1541
  return `
1362
- <section class="${n}__section">
1363
- <header class="${n}__header">
1364
- <h1 class="${n}__title">${this.escape(this.labels.resetPassword.title)}</h1>
1365
- <p class="${n}__copy">${this.escape(this.labels.resetPassword.subtitle)}</p>
1542
+ <section class="${r}__section">
1543
+ <header class="${r}__header">
1544
+ <h1 class="${r}__title">${this.escape(this.labels.resetPassword.title)}</h1>
1545
+ <p class="${r}__copy">${this.escape(this.labels.resetPassword.subtitle)}</p>
1366
1546
  </header>
1367
- <form class="${n}__form" data-view="reset-password" novalidate>
1547
+ <form class="${r}__form" data-view="reset-password" novalidate>
1368
1548
  ${this.renderInput("code", this.labels.resetPassword.codeLabel, "text", this.state.code, "one-time-code")}
1369
1549
  ${this.renderInput("newPassword", this.labels.resetPassword.newPasswordLabel, "password", this.state.newPassword, "new-password")}
1370
1550
  ${this.renderInput("confirmPassword", this.labels.resetPassword.confirmPasswordLabel, "password", this.state.confirmPassword, "new-password")}
1371
- <button class="${n}__button ${n}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1551
+ <button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1372
1552
  ${this.escape(this.labels.resetPassword.submitButton)}
1373
1553
  </button>
1374
1554
  </form>
1375
- <button class="${n}__button ${n}__button--secondary" type="button" data-action="resend-reset-code" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
1555
+ <button class="${r}__button ${r}__button--secondary" type="button" data-action="resend-reset-code" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
1376
1556
  ${this.escape(e)}
1377
1557
  </button>
1378
- <button class="${n}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
1558
+ <button class="${r}__link" type="button" data-action="switch-sign-in" ${this.state.busy ? "disabled" : ""}>
1379
1559
  ${this.escape(this.labels.common.backToSignIn)}
1380
1560
  </button>
1381
1561
  </section>
@@ -1385,24 +1565,24 @@ class Be {
1385
1565
  var s;
1386
1566
  const e = ((s = this.config) == null ? void 0 : s.oauthProviders) ?? [];
1387
1567
  return e.length === 0 ? "" : `
1388
- <div class="${n}__stack">
1568
+ <div class="${r}__stack">
1389
1569
  ${e.map((i) => `
1390
- <button class="${n}__button ${n}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
1391
- ${this.escape(`${this.labels.oauth.continueWith} ${D[i]}`)}
1570
+ <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]}`)}
1392
1572
  </button>
1393
1573
  `).join("")}
1394
1574
  </div>
1395
1575
  `;
1396
1576
  }
1397
- renderInput(e, s, i, r, a) {
1577
+ renderInput(e, s, i, n, a) {
1398
1578
  return `
1399
- <label class="${n}__field">
1400
- <span class="${n}__label">${this.escape(s)}</span>
1579
+ <label class="${r}__field">
1580
+ <span class="${r}__label">${this.escape(s)}</span>
1401
1581
  <input
1402
- class="${n}__input"
1582
+ class="${r}__input"
1403
1583
  name="${this.escape(e)}"
1404
1584
  type="${this.escape(i)}"
1405
- value="${this.escape(r)}"
1585
+ value="${this.escape(n)}"
1406
1586
  autocomplete="${this.escape(a)}"
1407
1587
  ${this.state.busy ? "disabled" : ""}
1408
1588
  />
@@ -1410,20 +1590,20 @@ class Be {
1410
1590
  `;
1411
1591
  }
1412
1592
  bindDOM() {
1413
- this.root.querySelectorAll("form[data-view]").forEach((r) => {
1414
- r.addEventListener("submit", (a) => {
1593
+ this.root.querySelectorAll("form[data-view]").forEach((n) => {
1594
+ n.addEventListener("submit", (a) => {
1415
1595
  a.preventDefault();
1416
- const c = r.dataset.view;
1417
- c === "sign-in" && this.handleSignIn(), c === "sign-up" && this.handleSignUp(), c === "forgot-password" && this.handleForgotPassword(), c === "reset-password" && this.handleResetPassword();
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();
1418
1598
  });
1419
- }), this.root.querySelectorAll("input[name]").forEach((r) => {
1420
- r.addEventListener("input", () => {
1421
- Ae(r.name) && (this.state[r.name] = r.value);
1599
+ }), this.root.querySelectorAll("input[name]").forEach((n) => {
1600
+ n.addEventListener("input", () => {
1601
+ at(n.name) && (this.state[n.name] = n.value);
1422
1602
  });
1423
- }), this.root.querySelectorAll("[data-action]").forEach((r) => {
1424
- r.addEventListener("click", () => {
1425
- const a = r.dataset.action;
1426
- a === "switch-sign-up" && this.switchView("sign-up"), a === "switch-sign-in" && this.switchView("sign-in"), a === "forgot-password" && this.switchView("forgot-password"), a === "resend-verification" && this.resendVerificationEmail(), a === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), a === "resend-reset-code" && this.resendResetCode(), a === "oauth" && this.handleOAuthSignIn(r.dataset.provider);
1603
+ }), this.root.querySelectorAll("[data-action]").forEach((n) => {
1604
+ n.addEventListener("click", () => {
1605
+ const a = n.dataset.action;
1606
+ a === "switch-sign-up" && this.switchView("sign-up"), a === "switch-sign-in" && this.switchView("sign-in"), a === "forgot-password" && this.switchView("forgot-password"), a === "resend-verification" && this.resendVerificationEmail(), a === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), a === "resend-reset-code" && this.resendResetCode(), a === "oauth" && this.handleOAuthSignIn(n.dataset.provider);
1427
1607
  });
1428
1608
  });
1429
1609
  }
@@ -1431,7 +1611,7 @@ class Be {
1431
1611
  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();
1432
1612
  }
1433
1613
  async handleSignIn() {
1434
- if (!x(this.state.email)) {
1614
+ if (!Z(this.state.email)) {
1435
1615
  this.failValidation(this.labels.errors.invalidEmail);
1436
1616
  return;
1437
1617
  }
@@ -1443,7 +1623,7 @@ class Be {
1443
1623
  const e = await this.auth.signIn.email({
1444
1624
  email: this.state.email.trim(),
1445
1625
  password: this.state.password,
1446
- callbackURL: this.getManagedReturnURL(R, this.state.email.trim())
1626
+ callbackURL: this.getManagedReturnURL(U, this.state.email.trim())
1447
1627
  });
1448
1628
  if (e.error)
1449
1629
  throw e.error;
@@ -1456,7 +1636,7 @@ class Be {
1456
1636
  this.failValidation(this.labels.errors.requiredField);
1457
1637
  return;
1458
1638
  }
1459
- if (!x(this.state.email)) {
1639
+ if (!Z(this.state.email)) {
1460
1640
  this.failValidation(this.labels.errors.invalidEmail);
1461
1641
  return;
1462
1642
  }
@@ -1475,7 +1655,7 @@ class Be {
1475
1655
  return;
1476
1656
  }
1477
1657
  await this.runAction("Creating account…", async () => {
1478
- var r;
1658
+ var n;
1479
1659
  const i = await this.auth.signUp.email({
1480
1660
  name: this.state.name.trim(),
1481
1661
  email: this.state.email.trim(),
@@ -1484,7 +1664,7 @@ class Be {
1484
1664
  });
1485
1665
  if (i.error)
1486
1666
  throw i.error;
1487
- if ((r = this.config) != null && r.requireEmailVerification) {
1667
+ if ((n = this.config) != null && n.requireEmailVerification) {
1488
1668
  this.verificationCompletionAction = "sign-up", this.state.view = "verify-email", this.state.notice = "Check your inbox to verify your email address.", this.startCountdown();
1489
1669
  return;
1490
1670
  }
@@ -1492,7 +1672,7 @@ class Be {
1492
1672
  });
1493
1673
  }
1494
1674
  async handleOAuthSignIn(e) {
1495
- await this.runAction(`Redirecting to ${D[e]}…`, async () => {
1675
+ await this.runAction(`Redirecting to ${K[e]}…`, async () => {
1496
1676
  const s = await this.auth.signIn.social({
1497
1677
  provider: e,
1498
1678
  callbackURL: this.getManagedReturnURL("oauth"),
@@ -1502,18 +1682,18 @@ class Be {
1502
1682
  throw s.error;
1503
1683
  const i = this.extractRedirectURL(s.data);
1504
1684
  if (!i)
1505
- throw new u(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1506
- this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${D[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1685
+ 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);
1507
1687
  });
1508
1688
  }
1509
1689
  async handleForgotPassword() {
1510
1690
  if (!this.canUsePasswordResetEmailOtp()) {
1511
1691
  this.handleError(
1512
- new u("Password reset via email OTP is not enabled for this project.")
1692
+ new f("Password reset via email OTP is not enabled for this project.")
1513
1693
  );
1514
1694
  return;
1515
1695
  }
1516
- if (!x(this.state.email)) {
1696
+ if (!Z(this.state.email)) {
1517
1697
  this.failValidation(this.labels.errors.invalidEmail);
1518
1698
  return;
1519
1699
  }
@@ -1533,11 +1713,11 @@ class Be {
1533
1713
  var e, s;
1534
1714
  if (!this.canUsePasswordResetEmailOtp()) {
1535
1715
  this.handleError(
1536
- new u("Password reset via email OTP is not enabled for this project.")
1716
+ new f("Password reset via email OTP is not enabled for this project.")
1537
1717
  );
1538
1718
  return;
1539
1719
  }
1540
- if (!Ue(this.state.code)) {
1720
+ if (!ot(this.state.code)) {
1541
1721
  this.failValidation(this.labels.errors.invalidCode);
1542
1722
  return;
1543
1723
  }
@@ -1574,7 +1754,7 @@ class Be {
1574
1754
  const s = await this.auth.sendVerificationEmail({
1575
1755
  email: this.state.email.trim(),
1576
1756
  callbackURL: this.getManagedReturnURL(
1577
- this.verificationCompletionAction === "sign-up" ? S : R,
1757
+ this.verificationCompletionAction === "sign-up" ? S : U,
1578
1758
  this.state.email.trim()
1579
1759
  )
1580
1760
  });
@@ -1587,47 +1767,53 @@ class Be {
1587
1767
  const i = await this.retryAuthCompletionDataIfNeeded(
1588
1768
  s ?? await this.resolveAuthCompletionData()
1589
1769
  );
1770
+ if (this.destroyed)
1771
+ return;
1590
1772
  if (!i.user || !i.session) {
1591
- if (i.lookupError && $(this.options)) {
1592
- 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(O(this.options.redirectTo).toString());
1773
+ if (this.destroyed)
1774
+ return;
1775
+ if (i.lookupError && P(this.options)) {
1776
+ this.navigateToRedirect();
1593
1777
  return;
1594
1778
  }
1595
1779
  if (e === "sign-in")
1596
- throw i.lookupError ?? new de(
1780
+ throw i.lookupError ?? new ye(
1597
1781
  "Managed sign-in completed without an authenticated session."
1598
1782
  );
1599
1783
  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();
1600
1784
  return;
1601
1785
  }
1602
- const r = {
1786
+ const n = {
1603
1787
  action: e,
1604
1788
  user: i.user,
1605
1789
  session: i.session
1606
1790
  };
1607
- if (await this.syncPublicSessionBestEffort(), $(this.options)) {
1608
- this.terminalActionInProgress = !0, this.invokeRedirectModeSuccessHook(r), this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(O(this.options.redirectTo).toString());
1609
- return;
1610
- }
1611
- if (H(this.options)) {
1612
- this.destroy(), this.options.onSuccess(r);
1613
- return;
1791
+ if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1792
+ if (P(this.options)) {
1793
+ this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
1794
+ return;
1795
+ }
1796
+ if (J(this.options)) {
1797
+ this.options.onSuccess(n), this.terminalActionInProgress = !0;
1798
+ return;
1799
+ }
1614
1800
  }
1615
1801
  }
1616
1802
  async retryAuthCompletionDataIfNeeded(e) {
1617
1803
  if (e.session)
1618
1804
  return e;
1619
1805
  let s = e.lookupError;
1620
- for (let i = 0; i < q; i++) {
1621
- await new Promise((r) => setTimeout(r, ae));
1806
+ for (let i = 0; i < Y; i++) {
1807
+ await new Promise((n) => setTimeout(n, be));
1622
1808
  try {
1623
- const r = await C(this.auth);
1624
- if (r.user && r.session)
1809
+ const n = await B(this.auth);
1810
+ if (n.user && n.session)
1625
1811
  return {
1626
- user: r.user,
1627
- session: r.session
1812
+ user: n.user,
1813
+ session: n.session
1628
1814
  };
1629
- } catch (r) {
1630
- s = r;
1815
+ } catch (n) {
1816
+ s = n;
1631
1817
  }
1632
1818
  }
1633
1819
  return {
@@ -1644,7 +1830,7 @@ class Be {
1644
1830
  }
1645
1831
  async resolveAuthCompletionData(e) {
1646
1832
  try {
1647
- const s = await C(this.auth), i = this.extractUser(e);
1833
+ const s = await B(this.auth), i = this.extractUser(e);
1648
1834
  return {
1649
1835
  user: s.user ?? i,
1650
1836
  session: s.session
@@ -1663,19 +1849,21 @@ class Be {
1663
1849
  user: null,
1664
1850
  session: null
1665
1851
  };
1666
- if (H(this.options)) {
1667
- this.destroy(), this.options.onSuccess(e);
1668
- return;
1852
+ if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1853
+ if (J(this.options)) {
1854
+ this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
1855
+ return;
1856
+ }
1857
+ 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();
1669
1858
  }
1670
- 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();
1671
1859
  }
1672
- handleExistingSessionOnMount(e) {
1673
- if ($(this.options)) {
1674
- 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(O(this.options.redirectTo).toString());
1860
+ handleExistingSessionOnMount() {
1861
+ if (P(this.options)) {
1862
+ this.navigateToRedirect();
1675
1863
  return;
1676
1864
  }
1677
- if (H(this.options))
1678
- throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new u(
1865
+ if (J(this.options))
1866
+ throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new f(
1679
1867
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
1680
1868
  );
1681
1869
  }
@@ -1692,18 +1880,18 @@ class Be {
1692
1880
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
1693
1881
  }
1694
1882
  maybeHandleVerificationRequired(e) {
1695
- return N(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);
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);
1696
1884
  }
1697
1885
  handleVerificationEmailSent(e, s) {
1698
1886
  this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
1699
1887
  }
1700
1888
  invokeRedirectModeSuccessHook(e) {
1701
1889
  var s, i;
1702
- if (!(!$(this.options) || !this.options.onSuccess))
1890
+ if (!(!P(this.options) || !this.options.onSuccess))
1703
1891
  try {
1704
1892
  this.options.onSuccess(e);
1705
- } catch (r) {
1706
- const a = N(r, "Post-auth callback failed.");
1893
+ } catch (n) {
1894
+ const a = x(n, "Post-auth callback failed.");
1707
1895
  try {
1708
1896
  (i = (s = this.options).onError) == null || i.call(s, a);
1709
1897
  } catch {
@@ -1711,9 +1899,9 @@ class Be {
1711
1899
  }
1712
1900
  }
1713
1901
  handleError(e, s) {
1714
- var r, a;
1715
- const i = N(e, s);
1716
- this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (r = this.options).onError) == null || a.call(r, i);
1902
+ var n, a;
1903
+ const i = x(e, s);
1904
+ 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);
1717
1905
  }
1718
1906
  failValidation(e) {
1719
1907
  this.state.error = e, this.state.notice = null, this.render();
@@ -1722,15 +1910,15 @@ class Be {
1722
1910
  if (!e)
1723
1911
  return window.location.href;
1724
1912
  const i = new URL(window.location.href);
1725
- return i.searchParams.set(z, e), s ? i.searchParams.set(I, s) : i.searchParams.delete(I), i.toString();
1913
+ return i.searchParams.set(W, e), s ? i.searchParams.set(k, s) : i.searchParams.delete(k), i.toString();
1726
1914
  }
1727
1915
  consumeManagedReturnContext() {
1728
- const e = new URL(window.location.href), s = e.searchParams.get(z), i = e.searchParams.get(I), r = s ? e.searchParams.get("error") : null, a = s ? e.searchParams.get("error_description") : null;
1729
- return (s || i) && (e.searchParams.delete(z), e.searchParams.delete(I), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1730
- marker: s,
1731
- email: i,
1732
- error: r,
1733
- errorDescription: a
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())), {
1918
+ marker: i,
1919
+ email: n,
1920
+ error: a,
1921
+ errorDescription: h
1734
1922
  };
1735
1923
  }
1736
1924
  startCountdown(e = 60) {
@@ -1764,8 +1952,8 @@ class Be {
1764
1952
  try {
1765
1953
  i.setSelectionRange(e.selectionStart, e.selectionEnd);
1766
1954
  } catch {
1767
- const r = i.value.length;
1768
- i.setSelectionRange(r, r);
1955
+ const n = i.value.length;
1956
+ i.setSelectionRange(n, n);
1769
1957
  }
1770
1958
  this.pendingFocusSnapshot = null;
1771
1959
  }
@@ -1794,10 +1982,10 @@ class Be {
1794
1982
  return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
1795
1983
  }
1796
1984
  handleSessionlessManagedReturn(e) {
1797
- 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 === R || 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 w(
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(
1798
1986
  e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
1799
1987
  { code: e.error ?? "VERIFY_EMAIL_ERROR" }
1800
- )) : this.render(), !0) : e.marker === oe && (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 w(
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(
1801
1989
  e.errorDescription ?? "OAuth sign-in failed.",
1802
1990
  { code: e.error ?? "OAUTH_ERROR" }
1803
1991
  )), !0) : !1;
@@ -1813,106 +2001,106 @@ class Be {
1813
2001
  return i <= 0 ? e : s.replace("{seconds}", String(i));
1814
2002
  }
1815
2003
  escape(e) {
1816
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2004
+ return e.replace(/[&<>"']/g, (s) => rt[s]);
1817
2005
  }
1818
2006
  }
1819
- function ke(t) {
2007
+ function ct(t) {
1820
2008
  return "data" in t && t.data ? t.data : t;
1821
2009
  }
1822
- const Me = [
2010
+ const ut = [
1823
2011
  { id: "google", key: "providerGoogle" },
1824
2012
  { id: "apple", key: "providerApple" },
1825
2013
  { id: "microsoft", key: "providerMicrosoft" },
1826
2014
  { id: "github", key: "providerGithub" },
1827
2015
  { id: "gitlab", key: "providerGitlab" },
1828
2016
  { id: "discord", key: "providerDiscord" }
1829
- ], le = 2, Oe = 500;
1830
- async function Ve() {
1831
- const t = `${window.location.origin}${ue}/config`;
2017
+ ], ve = 2, ht = 500;
2018
+ async function mt() {
2019
+ const t = `${window.location.origin}${Ee}/config`;
1832
2020
  let e;
1833
- for (let s = 0; s <= le; s++)
2021
+ for (let s = 0; s <= ve; s++)
1834
2022
  try {
1835
2023
  const i = await fetch(t, { method: "GET", credentials: "include" });
1836
2024
  if (!i.ok)
1837
- throw new u(`Failed to load auth config: HTTP ${i.status}`);
1838
- const r = await i.json();
1839
- return Ne(ke(r));
2025
+ throw new f(`Failed to load auth config: HTTP ${i.status}`);
2026
+ const n = await i.json();
2027
+ return wt(ct(n));
1840
2028
  } catch (i) {
1841
- e = i, s < le && await new Promise((r) => setTimeout(r, Oe));
2029
+ e = i, s < ve && await new Promise((n) => setTimeout(n, ht));
1842
2030
  }
1843
2031
  throw e;
1844
2032
  }
1845
- let U = null;
1846
- async function Fe() {
1847
- return U || (U = Ve().catch((t) => {
1848
- throw U = null, t;
1849
- })), U;
2033
+ let M = null;
2034
+ async function ft() {
2035
+ return M || (M = mt().catch((t) => {
2036
+ throw M = null, t;
2037
+ })), M;
1850
2038
  }
1851
- function Ne(t) {
1852
- var s, i, r, a, c, p, T;
1853
- const e = Me.filter(({ key: P }) => {
1854
- const b = t[P];
1855
- return typeof b == "object" && b !== null && "enabled" in b && !!b.enabled;
1856
- }).map(({ id: P }) => P);
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);
1857
2045
  return {
1858
2046
  disableSignUp: !!t.disableSignUp,
1859
2047
  emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
1860
- minPasswordLength: ((r = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : r.minPasswordLength) ?? 8,
1861
- requireEmailVerification: !!((c = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && c.requireEmailVerification),
1862
- passwordResetEmailOtpEnabled: !!((T = (p = t.providerEmailPassword) == null ? void 0 : p.config) != null && T.requirePasswordResetEmailVerification),
2048
+ 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),
1863
2051
  oauthProviders: e
1864
2052
  };
1865
2053
  }
1866
- const A = /* @__PURE__ */ new WeakMap();
1867
- function ze(t) {
2054
+ const O = /* @__PURE__ */ new WeakMap();
2055
+ function gt(t) {
1868
2056
  if (!t)
1869
- throw new u(
2057
+ throw new f(
1870
2058
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
1871
2059
  );
1872
2060
  const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
1873
2061
  if (!e && !s)
1874
- throw new u(
2062
+ throw new f(
1875
2063
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
1876
2064
  );
1877
2065
  if ("redirectTo" in t) {
1878
2066
  const i = t.redirectTo;
1879
2067
  if (!(typeof i == "string" || i instanceof URL))
1880
- throw new u(
2068
+ throw new f(
1881
2069
  "authUI.mount(container, options) expected redirectTo to be a string or URL."
1882
2070
  );
1883
2071
  }
1884
2072
  if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
1885
- throw new u(
2073
+ throw new f(
1886
2074
  "authUI.mount(container, options) expected onSuccess to be a function."
1887
2075
  );
1888
2076
  if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
1889
- throw new u(
2077
+ throw new f(
1890
2078
  "authUI.mount(container, options) expected onError to be a function."
1891
2079
  );
1892
2080
  }
1893
- function qe(t) {
2081
+ function pt(t) {
1894
2082
  if (!(t instanceof HTMLElement))
1895
- throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
2083
+ throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
1896
2084
  }
1897
- function De(t, e) {
2085
+ function bt(t, e) {
1898
2086
  return {
1899
2087
  mount(s, i) {
1900
- var p;
1901
- ze(i), qe(s), (p = A.get(s)) == null || p.destroy();
1902
- const r = new Be(s, t, i, Fe, e), a = r.destroy.bind(r), c = {
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 = {
1903
2091
  destroy() {
1904
- a(), A.get(s) === c && A.delete(s);
2092
+ a(), O.get(s) === h && O.delete(s);
1905
2093
  }
1906
2094
  };
1907
- return A.set(s, c), c;
2095
+ return O.set(s, h), h;
1908
2096
  }
1909
2097
  };
1910
2098
  }
1911
- function xe() {
1912
- ce();
1913
- const t = Te(), e = Ce(), s = ye(), i = De(e, {
2099
+ function yt() {
2100
+ Pe();
2101
+ const t = Xe(), e = et(), s = Me(), i = bt(e, {
1914
2102
  syncPublicSession: async () => {
1915
- await _e(t);
2103
+ await Qe(t);
1916
2104
  }
1917
2105
  });
1918
2106
  return {
@@ -1922,22 +2110,22 @@ function xe() {
1922
2110
  };
1923
2111
  }
1924
2112
  export {
1925
- w as EdgeSparkAuthError,
1926
- u as EdgeSparkConfigError,
1927
- j as EdgeSparkError,
1928
- de as EdgeSparkRuntimeError,
1929
- ie as ar,
1930
- xe as createEdgeSpark,
1931
- ee as de,
1932
- Re as detectLocale,
1933
- B as enUS,
1934
- F as es,
1935
- X as fr,
1936
- ne as hi,
1937
- te as it,
1938
- J as ja,
1939
- Z as ko,
1940
- Q as ptBR,
1941
- se as ru,
1942
- V as zhCN
2113
+ v as EdgeSparkAuthError,
2114
+ 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,
2121
+ V as enUS,
2122
+ H as es,
2123
+ ue as fr,
2124
+ 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
1943
2131
  };