@yackey-labs/yauth-ui-solidjs 0.9.6 → 0.12.1

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.js CHANGED
@@ -1,987 +1,919 @@
1
- import { createComponent as g, delegateEvents as K, insert as e, Show as y, effect as C, template as i, memo as fe, addEventListener as ie } from "solid-js/web";
2
- import { createContext as we, createSignal as a, createResource as oe, createEffect as ae, Show as $e, useContext as _e, For as te } from "solid-js";
3
- import { startAuthentication as Se, startRegistration as ke } from "@simplewebauthn/browser";
4
- const pe = we(), jt = (r) => {
5
- if (!r.client && !r.baseUrl)
6
- throw new Error("YAuthProvider requires either a `client` or `baseUrl` prop");
7
- const [k, b] = a(r.client ?? null);
8
- if (!r.client && r.baseUrl) {
9
- const f = r.baseUrl;
10
- import("@yackey-labs/yauth-client").then((x) => {
11
- b(() => x.createYAuthClient({
12
- baseUrl: f
13
- }));
14
- });
15
- }
16
- let p = null;
17
- const [v, {
18
- refetch: h
19
- }] = oe(async () => {
20
- const f = k();
21
- if (!f) return null;
22
- try {
23
- return await f.getSession();
24
- } catch {
25
- return null;
26
- }
27
- });
28
- ae(() => {
29
- k() && h();
30
- }), ae(() => {
31
- if (!v.loading && p) {
32
- const x = p;
33
- p = null, x(v() ?? null);
34
- }
35
- });
36
- const $ = () => new Promise((f) => {
37
- p = f, h();
38
- });
39
- return g($e, {
40
- get when() {
41
- return k();
42
- },
43
- fallback: null,
44
- children: (f) => g(pe.Provider, {
45
- get value() {
46
- return {
47
- client: f(),
48
- user: () => v(),
49
- loading: () => v.loading,
50
- refetch: $
51
- };
52
- },
53
- get children() {
54
- return r.children;
55
- }
56
- })
57
- });
1
+ import { Show as e, addEventListener as t, createComponent as n, delegateEvents as r, effect as i, insert as a, memo as o, template as s } from "solid-js/web";
2
+ import { For as c, Show as l, createContext as u, createEffect as d, createResource as f, createSignal as p, useContext as m } from "solid-js";
3
+ import { startAuthentication as h, startRegistration as g } from "@simplewebauthn/browser";
4
+ //#region src/provider.tsx
5
+ var _ = u(), v = (e) => {
6
+ if (!e.client && !e.baseUrl) throw Error("YAuthProvider requires either a `client` or `baseUrl` prop");
7
+ let [t, r] = p(e.client ?? null);
8
+ if (!e.client && e.baseUrl) {
9
+ let t = e.baseUrl;
10
+ import("@yackey-labs/yauth-client").then((e) => {
11
+ r(() => e.createYAuthClient({ baseUrl: t }));
12
+ });
13
+ }
14
+ let i = null, [a, { refetch: o }] = f(async () => {
15
+ let e = t();
16
+ if (!e) return null;
17
+ try {
18
+ return (await e.getSession()).user;
19
+ } catch {
20
+ return null;
21
+ }
22
+ });
23
+ d(() => {
24
+ t() && o();
25
+ }), d(() => {
26
+ if (!a.loading && i) {
27
+ let e = i;
28
+ i = null, e(a() ?? null);
29
+ }
30
+ });
31
+ let s = () => new Promise((e) => {
32
+ i = e, o();
33
+ });
34
+ return n(l, {
35
+ get when() {
36
+ return t();
37
+ },
38
+ fallback: null,
39
+ children: (t) => n(_.Provider, {
40
+ get value() {
41
+ return {
42
+ client: t(),
43
+ user: () => a(),
44
+ loading: () => a.loading,
45
+ refetch: s
46
+ };
47
+ },
48
+ get children() {
49
+ return e.children;
50
+ }
51
+ })
52
+ });
58
53
  };
59
- function Y() {
60
- const r = _e(pe);
61
- if (!r)
62
- throw new Error("useYAuth must be used within a <YAuthProvider>");
63
- return r;
54
+ function y() {
55
+ let e = m(_);
56
+ if (!e) throw Error("useYAuth must be used within a <YAuthProvider>");
57
+ return e;
64
58
  }
65
- var Ce = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Ee = /* @__PURE__ */ i('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">Password changed successfully.'), Pe = /* @__PURE__ */ i('<form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-current-password>Current password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-current-password name=current_password type=password required autocomplete=current-password></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-new-password>New password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-new-password name=new_password type=password required autocomplete=new-password></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-confirm-password>Confirm new password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-confirm-password name=confirm_password type=password required autocomplete=new-password></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
66
- const Ft = (r) => {
67
- const {
68
- client: k
69
- } = Y(), b = k?.emailPassword;
70
- if (!b) return null;
71
- const [p, v] = a(""), [h, $] = a(""), [f, x] = a(""), [d, l] = a(null), [m, s] = a(!1), [t, c] = a(!1), n = async (u) => {
72
- u.preventDefault(), l(null), s(!1);
73
- const o = u.currentTarget, P = new FormData(o), w = P.get("current_password") || p(), _ = P.get("new_password") || h(), S = P.get("confirm_password") || f();
74
- if (_ !== S) {
75
- l("Passwords do not match");
76
- return;
77
- }
78
- c(!0);
79
- try {
80
- await b.changePassword({
81
- current_password: w,
82
- new_password: _
83
- }), s(!0), v(""), $(""), x(""), r.onSuccess?.();
84
- } catch (L) {
85
- const R = L instanceof Error ? L : new Error(String(L));
86
- l(R.message), r.onError?.(R);
87
- } finally {
88
- c(!1);
89
- }
90
- };
91
- return (() => {
92
- var u = Pe(), o = u.firstChild, P = o.firstChild, w = P.nextSibling, _ = o.nextSibling, S = _.firstChild, L = S.nextSibling, R = _.nextSibling, O = R.firstChild, D = O.nextSibling, G = R.nextSibling;
93
- return u.addEventListener("submit", n), e(u, g(y, {
94
- get when() {
95
- return d();
96
- },
97
- get children() {
98
- var A = Ce();
99
- return e(A, d), A;
100
- }
101
- }), o), e(u, g(y, {
102
- get when() {
103
- return m();
104
- },
105
- get children() {
106
- return Ee();
107
- }
108
- }), o), w.$$input = (A) => v(A.currentTarget.value), L.$$input = (A) => $(A.currentTarget.value), D.$$input = (A) => x(A.currentTarget.value), e(G, () => t() ? "Changing password..." : "Change password"), C((A) => {
109
- var I = t(), z = t(), Z = t(), H = t();
110
- return I !== A.e && (w.disabled = A.e = I), z !== A.t && (L.disabled = A.t = z), Z !== A.a && (D.disabled = A.a = Z), H !== A.o && (G.disabled = A.o = H), A;
111
- }, {
112
- e: void 0,
113
- t: void 0,
114
- a: void 0,
115
- o: void 0
116
- }), C(() => w.value = p()), C(() => L.value = h()), C(() => D.value = f()), u;
117
- })();
59
+ //#endregion
60
+ //#region src/components/change-password-form.tsx
61
+ var b = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), x = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Password changed successfully."), S = /* @__PURE__ */ s("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-current-password>Current password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-current-password name=current_password type=password required autocomplete=current-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-new-password>New password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-new-password name=new_password type=password required autocomplete=new-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-confirm-password>Confirm new password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-confirm-password name=confirm_password type=password required autocomplete=new-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), C = (t) => {
62
+ let { client: r } = y(), o = r?.emailPassword;
63
+ if (!o) return null;
64
+ let [s, c] = p(""), [l, u] = p(""), [d, f] = p(""), [m, h] = p(null), [g, _] = p(!1), [v, C] = p(!1), w = async (e) => {
65
+ e.preventDefault(), h(null), _(!1);
66
+ let n = e.currentTarget, r = new FormData(n), i = r.get("current_password") || s(), a = r.get("new_password") || l();
67
+ if (a !== (r.get("confirm_password") || d())) {
68
+ h("Passwords do not match");
69
+ return;
70
+ }
71
+ C(!0);
72
+ try {
73
+ await o.changePassword({
74
+ current_password: i,
75
+ new_password: a
76
+ }), _(!0), c(""), u(""), f(""), t.onSuccess?.();
77
+ } catch (e) {
78
+ let n = e instanceof Error ? e : Error(String(e));
79
+ h(n.message), t.onError?.(n);
80
+ } finally {
81
+ C(!1);
82
+ }
83
+ };
84
+ return (() => {
85
+ var t = S(), r = t.firstChild, o = r.firstChild.nextSibling, p = r.nextSibling, h = p.firstChild.nextSibling, _ = p.nextSibling, y = _.firstChild.nextSibling, C = _.nextSibling;
86
+ return t.addEventListener("submit", w), a(t, n(e, {
87
+ get when() {
88
+ return m();
89
+ },
90
+ get children() {
91
+ var e = b();
92
+ return a(e, m), e;
93
+ }
94
+ }), r), a(t, n(e, {
95
+ get when() {
96
+ return g();
97
+ },
98
+ get children() {
99
+ return x();
100
+ }
101
+ }), r), o.$$input = (e) => c(e.currentTarget.value), h.$$input = (e) => u(e.currentTarget.value), y.$$input = (e) => f(e.currentTarget.value), a(C, () => v() ? "Changing password..." : "Change password"), i((e) => {
102
+ var t = v(), n = v(), r = v(), i = v();
103
+ return t !== e.e && (o.disabled = e.e = t), n !== e.t && (h.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), i !== e.o && (C.disabled = e.o = i), e;
104
+ }, {
105
+ e: void 0,
106
+ t: void 0,
107
+ a: void 0,
108
+ o: void 0
109
+ }), i(() => o.value = s()), i(() => h.value = l()), i(() => y.value = d()), t;
110
+ })();
118
111
  };
119
- K(["input"]);
120
- var De = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Ae = /* @__PURE__ */ i('<div class="rounded-md border p-4 space-y-3"><p class="text-sm font-medium">This application is requesting the following permissions:</p><ul class=space-y-2>'), Te = /* @__PURE__ */ i('<div class="mx-auto max-w-md space-y-6 p-6"><div class="space-y-2 text-center"><h2 class="text-2xl font-semibold tracking-tight">Authorize </h2><p class="text-sm text-muted-foreground"><strong></strong> is requesting access to your account.</p></div><div class="flex gap-3"><button class="inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>Deny</button><button class="inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button></button></div><p class="text-center text-xs text-muted-foreground">By authorizing, you allow this application to access your account with the permissions listed above.'), Le = /* @__PURE__ */ i('<li class="flex items-center gap-2 text-sm"><svg class="h-4 w-4 text-primary"fill=none stroke=currentColor viewBox="0 0 24 24"aria-label=Checkmark role=img><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg><span>');
121
- const Mt = (r) => {
122
- const [k, b] = a(!1), [p, v] = a(null), h = async (f) => {
123
- v(null), b(!0);
124
- try {
125
- const x = r.authBaseUrl ?? "/api/auth", d = await fetch(`${x}/authorize`, {
126
- method: "POST",
127
- headers: {
128
- "Content-Type": "application/json"
129
- },
130
- credentials: "include",
131
- body: JSON.stringify({
132
- client_id: r.clientId,
133
- redirect_uri: r.redirectUri,
134
- response_type: r.responseType,
135
- code_challenge: r.codeChallenge,
136
- code_challenge_method: r.codeChallengeMethod,
137
- scope: r.scopes?.join(" "),
138
- state: r.state,
139
- approved: f
140
- })
141
- });
142
- if (d.redirected) {
143
- window.location.href = d.url;
144
- return;
145
- }
146
- if (!d.ok) {
147
- const m = await d.json().catch(() => null);
148
- throw new Error(m?.error_description ?? m?.error ?? "Authorization failed");
149
- }
150
- const l = d.headers.get("Location");
151
- if (l) {
152
- window.location.href = l;
153
- return;
154
- }
155
- r.onSubmit?.(f);
156
- } catch (x) {
157
- const d = x instanceof Error ? x : new Error(String(x));
158
- v(d.message), r.onError?.(d);
159
- } finally {
160
- b(!1);
161
- }
162
- }, $ = () => r.clientName ?? r.clientId;
163
- return (() => {
164
- var f = Te(), x = f.firstChild, d = x.firstChild;
165
- d.firstChild;
166
- var l = d.nextSibling, m = l.firstChild, s = x.nextSibling, t = s.firstChild, c = t.nextSibling;
167
- return e(d, $, null), e(m, $), e(f, g(y, {
168
- get when() {
169
- return p();
170
- },
171
- get children() {
172
- var n = De();
173
- return e(n, p), n;
174
- }
175
- }), s), e(f, g(y, {
176
- get when() {
177
- return fe(() => !!r.scopes)() && r.scopes.length > 0;
178
- },
179
- get children() {
180
- var n = Ae(), u = n.firstChild, o = u.nextSibling;
181
- return e(o, g(te, {
182
- get each() {
183
- return r.scopes;
184
- },
185
- children: (P) => (() => {
186
- var w = Le(), _ = w.firstChild, S = _.nextSibling;
187
- return e(S, P), w;
188
- })()
189
- })), n;
190
- }
191
- }), s), t.$$click = () => h(!1), c.$$click = () => h(!0), e(c, () => k() ? "Authorizing..." : "Authorize"), C((n) => {
192
- var u = k(), o = k();
193
- return u !== n.e && (t.disabled = n.e = u), o !== n.t && (c.disabled = n.t = o), n;
194
- }, {
195
- e: void 0,
196
- t: void 0
197
- }), f;
198
- })();
112
+ r(["input"]);
113
+ //#endregion
114
+ //#region src/components/consent-screen.tsx
115
+ var w = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), T = /* @__PURE__ */ s("<div class=\"rounded-md border p-4 space-y-3\"><p class=\"text-sm font-medium\">This application is requesting the following permissions:</p><ul class=space-y-2>"), E = /* @__PURE__ */ s("<div class=\"mx-auto max-w-md space-y-6 p-6\"><div class=\"space-y-2 text-center\"><h2 class=\"text-2xl font-semibold tracking-tight\">Authorize </h2><p class=\"text-sm text-muted-foreground\"><strong></strong> is requesting access to your account.</p></div><div class=\"flex gap-3\"><button class=\"inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>Deny</button><button class=\"inline-flex h-9 flex-1 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button></button></div><p class=\"text-center text-xs text-muted-foreground\">By authorizing, you allow this application to access your account with the permissions listed above."), D = /* @__PURE__ */ s("<li class=\"flex items-center gap-2 text-sm\"><svg class=\"h-4 w-4 text-primary\"fill=none stroke=currentColor viewBox=\"0 0 24 24\"aria-label=Checkmark role=img><path stroke-linecap=round stroke-linejoin=round stroke-width=2 d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"></path></svg><span>"), O = (t) => {
116
+ let [r, s] = p(!1), [l, u] = p(null), d = async (e) => {
117
+ u(null), s(!0);
118
+ try {
119
+ let n = t.authBaseUrl ?? "/api/auth", r = await fetch(`${n}/authorize`, {
120
+ method: "POST",
121
+ headers: { "Content-Type": "application/json" },
122
+ credentials: "include",
123
+ body: JSON.stringify({
124
+ client_id: t.clientId,
125
+ redirect_uri: t.redirectUri,
126
+ response_type: t.responseType,
127
+ code_challenge: t.codeChallenge,
128
+ code_challenge_method: t.codeChallengeMethod,
129
+ scope: t.scopes?.join(" "),
130
+ state: t.state,
131
+ approved: e
132
+ })
133
+ });
134
+ if (r.redirected) {
135
+ window.location.href = r.url;
136
+ return;
137
+ }
138
+ if (!r.ok) {
139
+ let e = await r.json().catch(() => null);
140
+ throw Error(e?.error_description ?? e?.error ?? "Authorization failed");
141
+ }
142
+ let i = r.headers.get("Location");
143
+ if (i) {
144
+ window.location.href = i;
145
+ return;
146
+ }
147
+ t.onSubmit?.(e);
148
+ } catch (e) {
149
+ let n = e instanceof Error ? e : Error(String(e));
150
+ u(n.message), t.onError?.(n);
151
+ } finally {
152
+ s(!1);
153
+ }
154
+ }, f = () => t.clientName ?? t.clientId;
155
+ return (() => {
156
+ var s = E(), u = s.firstChild, p = u.firstChild;
157
+ p.firstChild;
158
+ var m = p.nextSibling.firstChild, h = u.nextSibling, g = h.firstChild, _ = g.nextSibling;
159
+ return a(p, f, null), a(m, f), a(s, n(e, {
160
+ get when() {
161
+ return l();
162
+ },
163
+ get children() {
164
+ var e = w();
165
+ return a(e, l), e;
166
+ }
167
+ }), h), a(s, n(e, {
168
+ get when() {
169
+ return o(() => !!t.scopes)() && t.scopes.length > 0;
170
+ },
171
+ get children() {
172
+ var e = T(), r = e.firstChild.nextSibling;
173
+ return a(r, n(c, {
174
+ get each() {
175
+ return t.scopes;
176
+ },
177
+ children: (e) => (() => {
178
+ var t = D(), n = t.firstChild.nextSibling;
179
+ return a(n, e), t;
180
+ })()
181
+ })), e;
182
+ }
183
+ }), h), g.$$click = () => d(!1), _.$$click = () => d(!0), a(_, () => r() ? "Authorizing..." : "Authorize"), i((e) => {
184
+ var t = r(), n = r();
185
+ return t !== e.e && (g.disabled = e.e = t), n !== e.t && (_.disabled = e.t = n), e;
186
+ }, {
187
+ e: void 0,
188
+ t: void 0
189
+ }), s;
190
+ })();
199
191
  };
200
- K(["click"]);
201
- var je = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Fe = /* @__PURE__ */ i('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), Me = /* @__PURE__ */ i('<form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-forgot-password-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-forgot-password-email name=email type=email required autocomplete=email></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
202
- const Rt = (r) => {
203
- const {
204
- client: k
205
- } = Y(), b = k?.emailPassword;
206
- if (!b) return null;
207
- const [p, v] = a(""), [h, $] = a(null), [f, x] = a(null), [d, l] = a(!1), m = async (s) => {
208
- s.preventDefault(), $(null), x(null), l(!0);
209
- try {
210
- const t = s.currentTarget, c = new FormData(t), n = await b.forgotPassword({
211
- email: c.get("email") || p()
212
- });
213
- x(n.message), r.onSuccess?.(n.message);
214
- } catch (t) {
215
- const c = t instanceof Error ? t : new Error(String(t));
216
- $(c.message);
217
- } finally {
218
- l(!1);
219
- }
220
- };
221
- return (() => {
222
- var s = Me(), t = s.firstChild, c = t.firstChild, n = c.nextSibling, u = t.nextSibling;
223
- return s.addEventListener("submit", m), e(s, g(y, {
224
- get when() {
225
- return h();
226
- },
227
- get children() {
228
- var o = je();
229
- return e(o, h), o;
230
- }
231
- }), t), e(s, g(y, {
232
- get when() {
233
- return f();
234
- },
235
- get children() {
236
- var o = Fe();
237
- return e(o, f), o;
238
- }
239
- }), t), n.$$input = (o) => v(o.currentTarget.value), e(u, () => d() ? "Sending..." : "Send reset link"), C((o) => {
240
- var P = d(), w = d();
241
- return P !== o.e && (n.disabled = o.e = P), w !== o.t && (u.disabled = o.t = w), o;
242
- }, {
243
- e: void 0,
244
- t: void 0
245
- }), C(() => n.value = p()), s;
246
- })();
192
+ r(["click"]);
193
+ //#endregion
194
+ //#region src/components/forgot-password-form.tsx
195
+ var k = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), A = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), j = /* @__PURE__ */ s("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-forgot-password-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-forgot-password-email name=email type=email required autocomplete=email></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), M = (t) => {
196
+ let { client: r } = y(), o = r?.emailPassword;
197
+ if (!o) return null;
198
+ let [s, c] = p(""), [l, u] = p(null), [d, f] = p(null), [m, h] = p(!1), g = async (e) => {
199
+ e.preventDefault(), u(null), f(null), h(!0);
200
+ try {
201
+ let n = e.currentTarget, r = new FormData(n), i = await o.forgotPassword({ email: r.get("email") || s() });
202
+ f(i.message), t.onSuccess?.(i.message);
203
+ } catch (e) {
204
+ u((e instanceof Error ? e : Error(String(e))).message);
205
+ } finally {
206
+ h(!1);
207
+ }
208
+ };
209
+ return (() => {
210
+ var t = j(), r = t.firstChild, o = r.firstChild.nextSibling, u = r.nextSibling;
211
+ return t.addEventListener("submit", g), a(t, n(e, {
212
+ get when() {
213
+ return l();
214
+ },
215
+ get children() {
216
+ var e = k();
217
+ return a(e, l), e;
218
+ }
219
+ }), r), a(t, n(e, {
220
+ get when() {
221
+ return d();
222
+ },
223
+ get children() {
224
+ var e = A();
225
+ return a(e, d), e;
226
+ }
227
+ }), r), o.$$input = (e) => c(e.currentTarget.value), a(u, () => m() ? "Sending..." : "Send reset link"), i((e) => {
228
+ var t = m(), n = m();
229
+ return t !== e.e && (o.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
230
+ }, {
231
+ e: void 0,
232
+ t: void 0
233
+ }), i(() => o.value = s()), t;
234
+ })();
247
235
  };
248
- K(["input"]);
249
- var Re = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Ue = /* @__PURE__ */ i('<div class=space-y-2><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>');
250
- const qe = (r) => {
251
- const {
252
- client: k
253
- } = Y(), b = k?.passkey;
254
- if (!b) return null;
255
- const [p, v] = a(null), [h, $] = a(!1), f = async () => {
256
- const m = await b.loginBegin({
257
- email: r.email ?? void 0
258
- }), s = await Se({
259
- optionsJSON: m.options.publicKey
260
- });
261
- await b.loginFinish({
262
- challenge_id: m.challenge_id,
263
- credential: s
264
- });
265
- const t = await k.getSession();
266
- r.onSuccess?.(t);
267
- }, x = async () => {
268
- const l = await b.registerBegin(), m = await ke({
269
- optionsJSON: l.publicKey
270
- });
271
- await b.registerFinish({
272
- credential: m,
273
- name: "Passkey"
274
- }), r.onSuccess?.(void 0);
275
- }, d = async () => {
276
- v(null), $(!0);
277
- try {
278
- r.mode === "login" ? await f() : await x();
279
- } catch (l) {
280
- const m = l instanceof Error ? l : new Error(String(l));
281
- console.error("[yauth] Passkey error:", m);
282
- const s = m.name === "NotAllowedError" ? "Passkey authentication was cancelled or not available on this device." : m.message;
283
- v(s), r.onError?.(m);
284
- } finally {
285
- $(!1);
286
- }
287
- };
288
- return (() => {
289
- var l = Ue(), m = l.firstChild;
290
- return e(l, g(y, {
291
- get when() {
292
- return p();
293
- },
294
- get children() {
295
- var s = Re();
296
- return e(s, p), s;
297
- }
298
- }), m), m.$$click = d, e(m, (() => {
299
- var s = fe(() => !!h());
300
- return () => s() ? r.mode === "login" ? "Authenticating..." : "Registering..." : r.mode === "login" ? "Sign in with passkey" : "Register passkey";
301
- })()), C(() => m.disabled = h()), l;
302
- })();
236
+ r(["input"]);
237
+ //#endregion
238
+ //#region src/components/passkey-button.tsx
239
+ var N = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), P = /* @__PURE__ */ s("<div class=space-y-2><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), F = (t) => {
240
+ let { client: r } = y(), s = r?.passkey;
241
+ if (!s) return null;
242
+ let [c, l] = p(null), [u, d] = p(!1), f = async () => {
243
+ let e = await s.loginBegin({ email: t.email ?? void 0 }), n = await h({ optionsJSON: e.options.publicKey });
244
+ await s.loginFinish({
245
+ challenge_id: e.challenge_id,
246
+ credential: n
247
+ });
248
+ let i = await r.getSession();
249
+ t.onSuccess?.(i.user);
250
+ }, m = async () => {
251
+ let e = await g({ optionsJSON: (await s.registerBegin()).publicKey });
252
+ await s.registerFinish({
253
+ credential: e,
254
+ name: "Passkey"
255
+ }), t.onSuccess?.(void 0);
256
+ }, _ = async () => {
257
+ l(null), d(!0);
258
+ try {
259
+ t.mode === "login" ? await f() : await m();
260
+ } catch (e) {
261
+ let n = e instanceof Error ? e : Error(String(e));
262
+ console.error("[yauth] Passkey error:", n), l(n.name === "NotAllowedError" ? "Passkey authentication was cancelled or not available on this device." : n.message), t.onError?.(n);
263
+ } finally {
264
+ d(!1);
265
+ }
266
+ };
267
+ return (() => {
268
+ var r = P(), s = r.firstChild;
269
+ return a(r, n(e, {
270
+ get when() {
271
+ return c();
272
+ },
273
+ get children() {
274
+ var e = N();
275
+ return a(e, c), e;
276
+ }
277
+ }), s), s.$$click = _, a(s, (() => {
278
+ var e = o(() => !!u());
279
+ return () => e() ? t.mode === "login" ? "Authenticating..." : "Registering..." : t.mode === "login" ? "Sign in with passkey" : "Register passkey";
280
+ })()), i(() => s.disabled = u()), r;
281
+ })();
303
282
  };
304
- K(["click"]);
305
- var Ne = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Oe = /* @__PURE__ */ i('<div class=relative><div class="absolute inset-0 flex items-center"style=pointer-events:none><span class="w-full border-t"></span></div><div class="relative flex justify-center text-xs uppercase"><span class="bg-background px-2 text-muted-foreground">or'), Be = /* @__PURE__ */ i('<form class=space-y-6><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-login-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-login-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-login-password>Password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-login-password name=password type=password required autocomplete=current-password></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
306
- const Ut = (r) => {
307
- const {
308
- client: k,
309
- refetch: b
310
- } = Y(), p = k?.emailPassword;
311
- if (!p) return null;
312
- const [v, h] = a(""), [$, f] = a(""), [x, d] = a(null), [l, m] = a(!1), s = async (t) => {
313
- t.preventDefault(), d(null), m(!0);
314
- try {
315
- const c = t.currentTarget, n = new FormData(c);
316
- await p.login({
317
- email: n.get("email") || v(),
318
- password: n.get("password") || $()
319
- });
320
- const u = await b();
321
- r.onSuccess?.(u);
322
- } catch (c) {
323
- const n = c instanceof Error ? c : new Error(String(c));
324
- d(n.message), r.onError?.(n);
325
- } finally {
326
- m(!1);
327
- }
328
- };
329
- return (() => {
330
- var t = Be(), c = t.firstChild, n = c.firstChild, u = n.nextSibling, o = c.nextSibling, P = o.firstChild, w = P.nextSibling, _ = o.nextSibling;
331
- return ie(t, "submit", s), e(t, g(y, {
332
- get when() {
333
- return x();
334
- },
335
- get children() {
336
- var S = Ne();
337
- return e(S, x), S;
338
- }
339
- }), c), ie(u, "input", (S) => h(S.currentTarget.value)), ie(w, "input", (S) => f(S.currentTarget.value)), e(_, () => l() ? "Signing in..." : "Sign in"), e(t, g(y, {
340
- get when() {
341
- return r.showPasskey;
342
- },
343
- get children() {
344
- return [Oe(), g(qe, {
345
- mode: "login",
346
- get email() {
347
- return v();
348
- },
349
- onSuccess: (S) => {
350
- b(), r.onSuccess?.(S);
351
- },
352
- get onError() {
353
- return r.onError;
354
- }
355
- })];
356
- }
357
- }), null), C((S) => {
358
- var L = l(), R = l(), O = l();
359
- return L !== S.e && (u.disabled = S.e = L), R !== S.t && (w.disabled = S.t = R), O !== S.a && (_.disabled = S.a = O), S;
360
- }, {
361
- e: void 0,
362
- t: void 0,
363
- a: void 0
364
- }), C(() => u.value = v()), C(() => w.value = $()), t;
365
- })();
283
+ r(["click"]);
284
+ //#endregion
285
+ //#region src/components/login-form.tsx
286
+ var I = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), L = /* @__PURE__ */ s("<div class=relative><div class=\"absolute inset-0 flex items-center\"style=pointer-events:none><span class=\"w-full border-t\"></span></div><div class=\"relative flex justify-center text-xs uppercase\"><span class=\"bg-background px-2 text-muted-foreground\">or"), R = /* @__PURE__ */ s("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-login-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-login-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-login-password>Password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-login-password name=password type=password required autocomplete=current-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), z = (r) => {
287
+ let { client: o, refetch: s } = y(), c = o?.emailPassword;
288
+ if (!c) return null;
289
+ let [l, u] = p(""), [d, f] = p(""), [m, h] = p(null), [g, _] = p(!1), v = async (e) => {
290
+ e.preventDefault(), h(null), _(!0);
291
+ try {
292
+ let t = e.currentTarget, n = new FormData(t);
293
+ await c.login({
294
+ email: n.get("email") || l(),
295
+ password: n.get("password") || d()
296
+ });
297
+ let i = await s();
298
+ r.onSuccess?.(i);
299
+ } catch (e) {
300
+ let t = e instanceof Error ? e : Error(String(e));
301
+ h(t.message), r.onError?.(t);
302
+ } finally {
303
+ _(!1);
304
+ }
305
+ };
306
+ return (() => {
307
+ var o = R(), c = o.firstChild, p = c.firstChild.nextSibling, h = c.nextSibling, _ = h.firstChild.nextSibling, y = h.nextSibling;
308
+ return t(o, "submit", v), a(o, n(e, {
309
+ get when() {
310
+ return m();
311
+ },
312
+ get children() {
313
+ var e = I();
314
+ return a(e, m), e;
315
+ }
316
+ }), c), t(p, "input", (e) => u(e.currentTarget.value)), t(_, "input", (e) => f(e.currentTarget.value)), a(y, () => g() ? "Signing in..." : "Sign in"), a(o, n(e, {
317
+ get when() {
318
+ return r.showPasskey;
319
+ },
320
+ get children() {
321
+ return [L(), n(F, {
322
+ mode: "login",
323
+ get email() {
324
+ return l();
325
+ },
326
+ onSuccess: (e) => {
327
+ s(), r.onSuccess?.(e);
328
+ },
329
+ get onError() {
330
+ return r.onError;
331
+ }
332
+ })];
333
+ }
334
+ }), null), i((e) => {
335
+ var t = g(), n = g(), r = g();
336
+ return t !== e.e && (p.disabled = e.e = t), n !== e.t && (_.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), e;
337
+ }, {
338
+ e: void 0,
339
+ t: void 0,
340
+ a: void 0
341
+ }), i(() => p.value = l()), i(() => _.value = d()), o;
342
+ })();
343
+ }, B = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), V = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), H = /* @__PURE__ */ s("<div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-magic-link-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-magic-link-email name=email type=email required autocomplete=email placeholder=you@example.com>"), U = /* @__PURE__ */ s("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), W = /* @__PURE__ */ s("<form class=space-y-4>"), G = (t) => {
344
+ let { client: r } = y(), o = r?.magicLink;
345
+ if (!o) return null;
346
+ let [s, c] = p(""), [l, u] = p(null), [d, f] = p(null), [m, h] = p(!1), g = async (e) => {
347
+ e.preventDefault(), u(null), f(null), h(!0);
348
+ try {
349
+ let n = e.currentTarget, r = new FormData(n), i = await o.send({ email: r.get("email") || s() });
350
+ f(i.message), t.onSuccess?.(i.message);
351
+ } catch (e) {
352
+ u((e instanceof Error ? e : Error(String(e))).message);
353
+ } finally {
354
+ h(!1);
355
+ }
356
+ };
357
+ return (() => {
358
+ var t = W();
359
+ return t.addEventListener("submit", g), a(t, n(e, {
360
+ get when() {
361
+ return l();
362
+ },
363
+ get children() {
364
+ var e = B();
365
+ return a(e, l), e;
366
+ }
367
+ }), null), a(t, n(e, {
368
+ get when() {
369
+ return d();
370
+ },
371
+ get children() {
372
+ var e = V();
373
+ return a(e, d), e;
374
+ }
375
+ }), null), a(t, n(e, {
376
+ get when() {
377
+ return !d();
378
+ },
379
+ get children() {
380
+ return [(() => {
381
+ var e = H(), t = e.firstChild.nextSibling;
382
+ return t.$$input = (e) => c(e.currentTarget.value), i(() => t.disabled = m()), i(() => t.value = s()), e;
383
+ })(), (() => {
384
+ var e = U();
385
+ return a(e, () => m() ? "Sending..." : "Send magic link"), i(() => e.disabled = m()), e;
386
+ })()];
387
+ }
388
+ }), null), t;
389
+ })();
366
390
  };
367
- var Ve = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), ze = /* @__PURE__ */ i('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), Ye = /* @__PURE__ */ i('<div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-magic-link-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-magic-link-email name=email type=email required autocomplete=email placeholder=you@example.com>'), Ie = /* @__PURE__ */ i('<button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>'), Je = /* @__PURE__ */ i("<form class=space-y-4>");
368
- const qt = (r) => {
369
- const {
370
- client: k
371
- } = Y(), b = k?.magicLink;
372
- if (!b) return null;
373
- const [p, v] = a(""), [h, $] = a(null), [f, x] = a(null), [d, l] = a(!1), m = async (s) => {
374
- s.preventDefault(), $(null), x(null), l(!0);
375
- try {
376
- const t = s.currentTarget, c = new FormData(t), n = await b.send({
377
- email: c.get("email") || p()
378
- });
379
- x(n.message), r.onSuccess?.(n.message);
380
- } catch (t) {
381
- const c = t instanceof Error ? t : new Error(String(t));
382
- $(c.message);
383
- } finally {
384
- l(!1);
385
- }
386
- };
387
- return (() => {
388
- var s = Je();
389
- return s.addEventListener("submit", m), e(s, g(y, {
390
- get when() {
391
- return h();
392
- },
393
- get children() {
394
- var t = Ve();
395
- return e(t, h), t;
396
- }
397
- }), null), e(s, g(y, {
398
- get when() {
399
- return f();
400
- },
401
- get children() {
402
- var t = ze();
403
- return e(t, f), t;
404
- }
405
- }), null), e(s, g(y, {
406
- get when() {
407
- return !f();
408
- },
409
- get children() {
410
- return [(() => {
411
- var t = Ye(), c = t.firstChild, n = c.nextSibling;
412
- return n.$$input = (u) => v(u.currentTarget.value), C(() => n.disabled = d()), C(() => n.value = p()), t;
413
- })(), (() => {
414
- var t = Ie();
415
- return e(t, () => d() ? "Sending..." : "Send magic link"), C(() => t.disabled = d()), t;
416
- })()];
417
- }
418
- }), null), s;
419
- })();
391
+ r(["input"]);
392
+ //#endregion
393
+ //#region src/components/mfa-challenge.tsx
394
+ var K = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), q = /* @__PURE__ */ s("<form class=space-y-4><p class=\"text-sm text-muted-foreground\">Enter the code from your authenticator app, or use a backup code.</p><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-mfa-challenge-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-mfa-challenge-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), ee = (t) => {
395
+ let { client: r } = y(), o = r?.mfa;
396
+ if (!o) return null;
397
+ let [s, c] = p(""), [l, u] = p(null), [d, f] = p(!1), m = async (e) => {
398
+ e.preventDefault(), u(null), f(!0);
399
+ try {
400
+ let n = e.currentTarget, i = new FormData(n);
401
+ await o.verify({
402
+ pending_session_id: t.pendingSessionId,
403
+ code: i.get("code") || s()
404
+ });
405
+ let a = await r.getSession();
406
+ t.onSuccess?.(a.user);
407
+ } catch (e) {
408
+ let n = e instanceof Error ? e : Error(String(e));
409
+ u(n.message), t.onError?.(n);
410
+ } finally {
411
+ f(!1);
412
+ }
413
+ };
414
+ return (() => {
415
+ var t = q(), r = t.firstChild, o = r.nextSibling, u = o.firstChild.nextSibling, f = o.nextSibling;
416
+ return t.addEventListener("submit", m), a(t, n(e, {
417
+ get when() {
418
+ return l();
419
+ },
420
+ get children() {
421
+ var e = K();
422
+ return a(e, l), e;
423
+ }
424
+ }), r), u.$$input = (e) => c(e.currentTarget.value), a(f, () => d() ? "Verifying..." : "Verify"), i((e) => {
425
+ var t = d(), n = d();
426
+ return t !== e.e && (u.disabled = e.e = t), n !== e.t && (f.disabled = e.t = n), e;
427
+ }, {
428
+ e: void 0,
429
+ t: void 0
430
+ }), i(() => u.value = s()), t;
431
+ })();
420
432
  };
421
- K(["input"]);
422
- var Ke = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Ge = /* @__PURE__ */ i('<form class=space-y-4><p class="text-sm text-muted-foreground">Enter the code from your authenticator app, or use a backup code.</p><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-mfa-challenge-code>Verification code</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-mfa-challenge-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
423
- const Nt = (r) => {
424
- const {
425
- client: k
426
- } = Y(), b = k?.mfa;
427
- if (!b) return null;
428
- const [p, v] = a(""), [h, $] = a(null), [f, x] = a(!1), d = async (l) => {
429
- l.preventDefault(), $(null), x(!0);
430
- try {
431
- const m = l.currentTarget, s = new FormData(m);
432
- await b.verify({
433
- pending_session_id: r.pendingSessionId,
434
- code: s.get("code") || p()
435
- });
436
- const t = await k.getSession();
437
- r.onSuccess?.(t);
438
- } catch (m) {
439
- const s = m instanceof Error ? m : new Error(String(m));
440
- $(s.message), r.onError?.(s);
441
- } finally {
442
- x(!1);
443
- }
444
- };
445
- return (() => {
446
- var l = Ge(), m = l.firstChild, s = m.nextSibling, t = s.firstChild, c = t.nextSibling, n = s.nextSibling;
447
- return l.addEventListener("submit", d), e(l, g(y, {
448
- get when() {
449
- return h();
450
- },
451
- get children() {
452
- var u = Ke();
453
- return e(u, h), u;
454
- }
455
- }), m), c.$$input = (u) => v(u.currentTarget.value), e(n, () => f() ? "Verifying..." : "Verify"), C((u) => {
456
- var o = f(), P = f();
457
- return o !== u.e && (c.disabled = u.e = o), P !== u.t && (n.disabled = u.t = P), u;
458
- }, {
459
- e: void 0,
460
- t: void 0
461
- }), C(() => c.value = p()), l;
462
- })();
433
+ r(["input"]);
434
+ //#endregion
435
+ //#region src/components/mfa-setup.tsx
436
+ var te = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), ne = /* @__PURE__ */ s("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Set up two-factor authentication to secure your account.</p><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), re = /* @__PURE__ */ s("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Add this account to your authenticator app using the URI below, then enter the verification code.</p><div class=space-y-1><span class=\"text-sm font-medium leading-none\">OTP Auth URI</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs\"></code></div><div class=space-y-1><span class=\"text-sm font-medium leading-none\">Manual entry key</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider\"></code></div><form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-mfa-setup-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-mfa-setup-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), J = /* @__PURE__ */ s("<div class=space-y-4><div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Two-factor authentication has been enabled. Save these backup codes in a safe place. Each code can only be used once.</div><ul class=space-y-1>"), Y = /* @__PURE__ */ s("<div class=space-y-4>"), X = /* @__PURE__ */ s("<li class=\"rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider\">"), ie = (t) => {
437
+ let { client: r } = y(), o = r?.mfa;
438
+ if (!o) return null;
439
+ let [s, l] = p("begin"), [u, d] = p(""), [f, m] = p(""), [h, g] = p(""), [_, v] = p([]), [b, x] = p(null), [S, C] = p(!1), w = async () => {
440
+ x(null), C(!0);
441
+ try {
442
+ let e = await o.setup();
443
+ d(e.otpauth_url), m(e.secret), v(e.backup_codes), l("confirm");
444
+ } catch (e) {
445
+ x((e instanceof Error ? e : Error(String(e))).message);
446
+ } finally {
447
+ C(!1);
448
+ }
449
+ }, T = async (e) => {
450
+ e.preventDefault(), x(null), C(!0);
451
+ try {
452
+ let n = e.currentTarget, r = new FormData(n);
453
+ await o.confirm({ code: r.get("code") || h() }), l("done"), t.onComplete?.(_());
454
+ } catch (e) {
455
+ x((e instanceof Error ? e : Error(String(e))).message);
456
+ } finally {
457
+ C(!1);
458
+ }
459
+ };
460
+ return (() => {
461
+ var t = Y();
462
+ return a(t, n(e, {
463
+ get when() {
464
+ return b();
465
+ },
466
+ get children() {
467
+ var e = te();
468
+ return a(e, b), e;
469
+ }
470
+ }), null), a(t, n(e, {
471
+ get when() {
472
+ return s() === "begin";
473
+ },
474
+ get children() {
475
+ var e = ne(), t = e.firstChild.nextSibling;
476
+ return t.$$click = w, a(t, () => S() ? "Setting up..." : "Set up 2FA"), i(() => t.disabled = S()), e;
477
+ }
478
+ }), null), a(t, n(e, {
479
+ get when() {
480
+ return s() === "confirm";
481
+ },
482
+ get children() {
483
+ var e = re(), t = e.firstChild.nextSibling, n = t.firstChild.nextSibling, r = t.nextSibling, o = r.firstChild.nextSibling, s = r.nextSibling, c = s.firstChild, l = c.firstChild.nextSibling, d = c.nextSibling;
484
+ return a(n, u), a(o, f), s.addEventListener("submit", T), l.$$input = (e) => g(e.currentTarget.value), a(d, () => S() ? "Verifying..." : "Verify and enable"), i((e) => {
485
+ var t = S(), n = S();
486
+ return t !== e.e && (l.disabled = e.e = t), n !== e.t && (d.disabled = e.t = n), e;
487
+ }, {
488
+ e: void 0,
489
+ t: void 0
490
+ }), i(() => l.value = h()), e;
491
+ }
492
+ }), null), a(t, n(e, {
493
+ get when() {
494
+ return s() === "done";
495
+ },
496
+ get children() {
497
+ var e = J(), t = e.firstChild.nextSibling;
498
+ return a(t, n(c, {
499
+ get each() {
500
+ return _();
501
+ },
502
+ children: (e) => (() => {
503
+ var t = X();
504
+ return a(t, e), t;
505
+ })()
506
+ })), e;
507
+ }
508
+ }), null), t;
509
+ })();
463
510
  };
464
- K(["input"]);
465
- var He = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Qe = /* @__PURE__ */ i('<div class=space-y-4><p class="text-sm text-muted-foreground">Set up two-factor authentication to secure your account.</p><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), We = /* @__PURE__ */ i('<div class=space-y-4><p class="text-sm text-muted-foreground">Add this account to your authenticator app using the URI below, then enter the verification code.</p><div class=space-y-1><span class="text-sm font-medium leading-none">OTP Auth URI</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs"></code></div><div class=space-y-1><span class="text-sm font-medium leading-none">Manual entry key</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider"></code></div><form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-mfa-setup-code>Verification code</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-mfa-setup-code name=code type=text inputmode=numeric autocomplete=one-time-code required></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>'), Xe = /* @__PURE__ */ i('<div class=space-y-4><div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">Two-factor authentication has been enabled. Save these backup codes in a safe place. Each code can only be used once.</div><ul class=space-y-1>'), Ze = /* @__PURE__ */ i("<div class=space-y-4>"), et = /* @__PURE__ */ i('<li class="rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider">');
466
- const Ot = (r) => {
467
- const {
468
- client: k
469
- } = Y(), b = k?.mfa;
470
- if (!b) return null;
471
- const [p, v] = a("begin"), [h, $] = a(""), [f, x] = a(""), [d, l] = a(""), [m, s] = a([]), [t, c] = a(null), [n, u] = a(!1), o = async () => {
472
- c(null), u(!0);
473
- try {
474
- const w = await b.setup();
475
- $(w.otpauth_url), x(w.secret), s(w.backup_codes), v("confirm");
476
- } catch (w) {
477
- const _ = w instanceof Error ? w : new Error(String(w));
478
- c(_.message);
479
- } finally {
480
- u(!1);
481
- }
482
- }, P = async (w) => {
483
- w.preventDefault(), c(null), u(!0);
484
- try {
485
- const _ = w.currentTarget, S = new FormData(_);
486
- await b.confirm({
487
- code: S.get("code") || d()
488
- }), v("done"), r.onComplete?.(m());
489
- } catch (_) {
490
- const S = _ instanceof Error ? _ : new Error(String(_));
491
- c(S.message);
492
- } finally {
493
- u(!1);
494
- }
495
- };
496
- return (() => {
497
- var w = Ze();
498
- return e(w, g(y, {
499
- get when() {
500
- return t();
501
- },
502
- get children() {
503
- var _ = He();
504
- return e(_, t), _;
505
- }
506
- }), null), e(w, g(y, {
507
- get when() {
508
- return p() === "begin";
509
- },
510
- get children() {
511
- var _ = Qe(), S = _.firstChild, L = S.nextSibling;
512
- return L.$$click = o, e(L, () => n() ? "Setting up..." : "Set up 2FA"), C(() => L.disabled = n()), _;
513
- }
514
- }), null), e(w, g(y, {
515
- get when() {
516
- return p() === "confirm";
517
- },
518
- get children() {
519
- var _ = We(), S = _.firstChild, L = S.nextSibling, R = L.firstChild, O = R.nextSibling, D = L.nextSibling, G = D.firstChild, A = G.nextSibling, I = D.nextSibling, z = I.firstChild, Z = z.firstChild, H = Z.nextSibling, Q = z.nextSibling;
520
- return e(O, h), e(A, f), I.addEventListener("submit", P), H.$$input = (B) => l(B.currentTarget.value), e(Q, () => n() ? "Verifying..." : "Verify and enable"), C((B) => {
521
- var W = n(), ne = n();
522
- return W !== B.e && (H.disabled = B.e = W), ne !== B.t && (Q.disabled = B.t = ne), B;
523
- }, {
524
- e: void 0,
525
- t: void 0
526
- }), C(() => H.value = d()), _;
527
- }
528
- }), null), e(w, g(y, {
529
- get when() {
530
- return p() === "done";
531
- },
532
- get children() {
533
- var _ = Xe(), S = _.firstChild, L = S.nextSibling;
534
- return e(L, g(te, {
535
- get each() {
536
- return m();
537
- },
538
- children: (R) => (() => {
539
- var O = et();
540
- return e(O, R), O;
541
- })()
542
- })), _;
543
- }
544
- }), null), w;
545
- })();
511
+ r(["click", "input"]);
512
+ //#endregion
513
+ //#region src/components/oauth-buttons.tsx
514
+ var ae = /* @__PURE__ */ s("<div class=space-y-2>"), oe = /* @__PURE__ */ s("<button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>Sign in with "), se = (e) => {
515
+ let { client: t } = y(), r = t?.oauth;
516
+ if (!r) return null;
517
+ let i = (e) => {
518
+ window.location.href = r.authorize(e);
519
+ };
520
+ return (() => {
521
+ var t = ae();
522
+ return a(t, n(c, {
523
+ get each() {
524
+ return e.providers;
525
+ },
526
+ children: (e) => (() => {
527
+ var t = oe();
528
+ return t.firstChild, t.$$click = () => i(e), a(t, () => e.charAt(0).toUpperCase() + e.slice(1), null), t;
529
+ })()
530
+ })), t;
531
+ })();
546
532
  };
547
- K(["click", "input"]);
548
- var tt = /* @__PURE__ */ i("<div class=space-y-2>"), rt = /* @__PURE__ */ i('<button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>Sign in with ');
549
- const Bt = (r) => {
550
- const {
551
- client: k
552
- } = Y(), b = k?.oauth;
553
- if (!b) return null;
554
- const p = (v) => {
555
- window.location.href = b.authorize(v);
556
- };
557
- return (() => {
558
- var v = tt();
559
- return e(v, g(te, {
560
- get each() {
561
- return r.providers;
562
- },
563
- children: (h) => (() => {
564
- var $ = rt();
565
- return $.firstChild, $.$$click = () => p(h), e($, () => h.charAt(0).toUpperCase() + h.slice(1), null), $;
566
- })()
567
- })), v;
568
- })();
533
+ r(["click"]);
534
+ //#endregion
535
+ //#region src/components/profile-settings.tsx
536
+ var ce = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading profile..."), le = /* @__PURE__ */ s("<div class=space-y-8>"), ue = /* @__PURE__ */ s("<dt class=\"font-medium text-muted-foreground\">Display name"), de = /* @__PURE__ */ s("<dd>"), fe = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Profile</h2><dl class=\"grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm\"><dt class=\"font-medium text-muted-foreground\">Email</dt><dd></dd><dt class=\"font-medium text-muted-foreground\">Email verified</dt><dd></dd><dt class=\"font-medium text-muted-foreground\">Role</dt><dd>"), Z = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), pe = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading passkeys..."), me = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Passkeys"), he = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Loading accounts..."), ge = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Connected accounts"), _e = /* @__PURE__ */ s("<div class=\"flex gap-2\"><button class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button></button><button class=\"inline-flex h-9 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), ve = /* @__PURE__ */ s("<div class=space-y-4><p class=\"text-sm text-muted-foreground\">Add this account to your authenticator app, then enter the verification code.</p><div class=space-y-1><span class=\"text-sm font-medium leading-none\">OTP Auth URI</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs\"></code></div><div class=space-y-1><span class=\"text-sm font-medium leading-none\">Manual entry key</span><code class=\"block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider\"></code></div><form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-profile-mfa-code>Verification code</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-profile-mfa-code name=mfa_code type=text inputmode=numeric autocomplete=one-time-code required></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), ye = /* @__PURE__ */ s("<div class=space-y-4><div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">Two-factor authentication is enabled. Save these backup codes in a safe place.</div><ul class=space-y-1>"), be = /* @__PURE__ */ s("<section class=space-y-4><h2 class=\"text-lg font-semibold tracking-tight\">Two-factor authentication"), Q = /* @__PURE__ */ s("<ul class=space-y-2>"), xe = /* @__PURE__ */ s("<p class=\"text-sm text-muted-foreground\">No passkeys registered."), Se = /* @__PURE__ */ s("<li class=\"flex items-center justify-between rounded-md border border-input px-3 py-2\"><div class=space-y-0.5><span class=\"text-sm font-medium\"></span><span class=\"block text-xs text-muted-foreground\">Added </span></div><button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Ce = /* @__PURE__ */ s("<p class=\"text-sm text-muted-foreground\">No connected accounts."), we = /* @__PURE__ */ s("<li class=\"flex items-center justify-between rounded-md border border-input px-3 py-2\"><div class=space-y-0.5><span class=\"text-sm font-medium\"></span><span class=\"block text-xs text-muted-foreground\">Connected </span></div><button class=\"inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=button>"), Te = /* @__PURE__ */ s("<li class=\"rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider\">"), Ee = () => {
537
+ let { client: t, user: r, loading: o } = y(), s = t?.passkey, l = t?.oauth, u = t?.mfa, d = !!s, m = !!l, h = !!u, [g, { refetch: _ }] = f(async () => {
538
+ if (!s) return [];
539
+ try {
540
+ return (await s.list()).items;
541
+ } catch {
542
+ return [];
543
+ }
544
+ }), [v, b] = p(null), [x, S] = p(null), [C, { refetch: w }] = f(async () => {
545
+ if (!l) return [];
546
+ try {
547
+ return (await l.accounts()).items;
548
+ } catch {
549
+ return [];
550
+ }
551
+ }), [T, E] = p(null), [D, O] = p(null), [k, A] = p(""), [j, M] = p(""), [N, P] = p(""), [F, I] = p([]), [L, R] = p("idle"), [z, B] = p(null), [V, H] = p(!1), U = async (e) => {
552
+ b(null), S(e);
553
+ try {
554
+ await s.delete(e), _();
555
+ } catch (e) {
556
+ b((e instanceof Error ? e : Error(String(e))).message);
557
+ } finally {
558
+ S(null);
559
+ }
560
+ }, W = async (e) => {
561
+ E(null), O(e);
562
+ try {
563
+ await l.unlink(e), w();
564
+ } catch (e) {
565
+ E((e instanceof Error ? e : Error(String(e))).message);
566
+ } finally {
567
+ O(null);
568
+ }
569
+ }, G = async () => {
570
+ B(null), H(!0);
571
+ try {
572
+ let e = await u.setup();
573
+ A(e.otpauth_url), M(e.secret), I(e.backup_codes), R("confirm");
574
+ } catch (e) {
575
+ B((e instanceof Error ? e : Error(String(e))).message);
576
+ } finally {
577
+ H(!1);
578
+ }
579
+ }, K = async (e) => {
580
+ e.preventDefault(), B(null), H(!0);
581
+ try {
582
+ let t = e.currentTarget, n = new FormData(t);
583
+ await u.confirm({ code: n.get("mfa_code") || N() }), R("done");
584
+ } catch (e) {
585
+ B((e instanceof Error ? e : Error(String(e))).message);
586
+ } finally {
587
+ H(!1);
588
+ }
589
+ }, q = async () => {
590
+ B(null), H(!0);
591
+ try {
592
+ await u.disable(), R("idle"), A(""), M(""), P(""), I([]);
593
+ } catch (e) {
594
+ B((e instanceof Error ? e : Error(String(e))).message);
595
+ } finally {
596
+ H(!1);
597
+ }
598
+ };
599
+ return (() => {
600
+ var t = le();
601
+ return a(t, n(e, {
602
+ get when() {
603
+ return o();
604
+ },
605
+ get children() {
606
+ return ce();
607
+ }
608
+ }), null), a(t, n(e, {
609
+ get when() {
610
+ return r();
611
+ },
612
+ children: (t) => [
613
+ (() => {
614
+ var r = fe(), i = r.firstChild.nextSibling, o = i.firstChild.nextSibling, s = o.nextSibling, c = s.nextSibling, l = c.nextSibling.nextSibling;
615
+ return a(o, () => t().email), a(i, n(e, {
616
+ get when() {
617
+ return t().display_name;
618
+ },
619
+ get children() {
620
+ return [ue(), (() => {
621
+ var e = de();
622
+ return a(e, () => t().display_name), e;
623
+ })()];
624
+ }
625
+ }), s), a(c, () => t().email_verified ? "Yes" : "No"), a(l, () => t().role), r;
626
+ })(),
627
+ n(e, {
628
+ when: d,
629
+ get children() {
630
+ var t = me();
631
+ return t.firstChild, a(t, n(e, {
632
+ get when() {
633
+ return v();
634
+ },
635
+ get children() {
636
+ var e = Z();
637
+ return a(e, v), e;
638
+ }
639
+ }), null), a(t, n(e, {
640
+ get when() {
641
+ return g.loading;
642
+ },
643
+ get children() {
644
+ return pe();
645
+ }
646
+ }), null), a(t, n(e, {
647
+ get when() {
648
+ return g();
649
+ },
650
+ children: (t) => n(e, {
651
+ get when() {
652
+ return t().length > 0;
653
+ },
654
+ get fallback() {
655
+ return xe();
656
+ },
657
+ get children() {
658
+ var e = Q();
659
+ return a(e, n(c, {
660
+ get each() {
661
+ return t();
662
+ },
663
+ children: (e) => (() => {
664
+ var t = Se(), n = t.firstChild, r = n.firstChild, o = r.nextSibling;
665
+ o.firstChild;
666
+ var s = n.nextSibling;
667
+ return a(r, () => e.name ?? "Unnamed passkey"), a(o, () => new Date(e.created_at).toLocaleDateString(), null), s.$$click = () => U(e.id), a(s, () => x() === e.id ? "Deleting..." : "Delete"), i(() => s.disabled = x() === e.id), t;
668
+ })()
669
+ })), e;
670
+ }
671
+ })
672
+ }), null), t;
673
+ }
674
+ }),
675
+ n(e, {
676
+ when: m,
677
+ get children() {
678
+ var t = ge();
679
+ return t.firstChild, a(t, n(e, {
680
+ get when() {
681
+ return T();
682
+ },
683
+ get children() {
684
+ var e = Z();
685
+ return a(e, T), e;
686
+ }
687
+ }), null), a(t, n(e, {
688
+ get when() {
689
+ return C.loading;
690
+ },
691
+ get children() {
692
+ return he();
693
+ }
694
+ }), null), a(t, n(e, {
695
+ get when() {
696
+ return C();
697
+ },
698
+ children: (t) => n(e, {
699
+ get when() {
700
+ return t().length > 0;
701
+ },
702
+ get fallback() {
703
+ return Ce();
704
+ },
705
+ get children() {
706
+ var e = Q();
707
+ return a(e, n(c, {
708
+ get each() {
709
+ return t();
710
+ },
711
+ children: (e) => (() => {
712
+ var t = we(), n = t.firstChild, r = n.firstChild, o = r.nextSibling;
713
+ o.firstChild;
714
+ var s = n.nextSibling;
715
+ return a(r, () => e.provider.charAt(0).toUpperCase() + e.provider.slice(1)), a(o, () => new Date(e.created_at).toLocaleDateString(), null), s.$$click = () => W(e.provider), a(s, () => D() === e.provider ? "Unlinking..." : "Unlink"), i(() => s.disabled = D() === e.provider), t;
716
+ })()
717
+ })), e;
718
+ }
719
+ })
720
+ }), null), t;
721
+ }
722
+ }),
723
+ n(e, {
724
+ when: h,
725
+ get children() {
726
+ var t = be();
727
+ return t.firstChild, a(t, n(e, {
728
+ get when() {
729
+ return z();
730
+ },
731
+ get children() {
732
+ var e = Z();
733
+ return a(e, z), e;
734
+ }
735
+ }), null), a(t, n(e, {
736
+ get when() {
737
+ return L() === "idle";
738
+ },
739
+ get children() {
740
+ var e = _e(), t = e.firstChild, n = t.nextSibling;
741
+ return t.$$click = G, a(t, () => V() ? "Setting up..." : "Set up 2FA"), n.$$click = q, a(n, () => V() ? "Disabling..." : "Disable 2FA"), i((e) => {
742
+ var r = V(), i = V();
743
+ return r !== e.e && (t.disabled = e.e = r), i !== e.t && (n.disabled = e.t = i), e;
744
+ }, {
745
+ e: void 0,
746
+ t: void 0
747
+ }), e;
748
+ }
749
+ }), null), a(t, n(e, {
750
+ get when() {
751
+ return L() === "confirm";
752
+ },
753
+ get children() {
754
+ var e = ve(), t = e.firstChild.nextSibling, n = t.firstChild.nextSibling, r = t.nextSibling, o = r.firstChild.nextSibling, s = r.nextSibling, c = s.firstChild, l = c.firstChild.nextSibling, u = c.nextSibling;
755
+ return a(n, k), a(o, j), s.addEventListener("submit", K), l.$$input = (e) => P(e.currentTarget.value), a(u, () => V() ? "Verifying..." : "Verify and enable"), i((e) => {
756
+ var t = V(), n = V();
757
+ return t !== e.e && (l.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
758
+ }, {
759
+ e: void 0,
760
+ t: void 0
761
+ }), i(() => l.value = N()), e;
762
+ }
763
+ }), null), a(t, n(e, {
764
+ get when() {
765
+ return L() === "done";
766
+ },
767
+ get children() {
768
+ var e = ye(), t = e.firstChild.nextSibling;
769
+ return a(t, n(c, {
770
+ get each() {
771
+ return F();
772
+ },
773
+ children: (e) => (() => {
774
+ var t = Te();
775
+ return a(t, e), t;
776
+ })()
777
+ })), e;
778
+ }
779
+ }), null), t;
780
+ }
781
+ })
782
+ ]
783
+ }), null), t;
784
+ })();
569
785
  };
570
- K(["click"]);
571
- var nt = /* @__PURE__ */ i('<div class="text-sm text-muted-foreground">Loading profile...'), st = /* @__PURE__ */ i("<div class=space-y-8>"), it = /* @__PURE__ */ i('<dt class="font-medium text-muted-foreground">Display name'), lt = /* @__PURE__ */ i("<dd>"), ot = /* @__PURE__ */ i('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Profile</h2><dl class="grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm"><dt class="font-medium text-muted-foreground">Email</dt><dd></dd><dt class="font-medium text-muted-foreground">Email verified</dt><dd></dd><dt class="font-medium text-muted-foreground">Role</dt><dd>'), le = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), at = /* @__PURE__ */ i('<div class="text-sm text-muted-foreground">Loading passkeys...'), dt = /* @__PURE__ */ i('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Passkeys'), ct = /* @__PURE__ */ i('<div class="text-sm text-muted-foreground">Loading accounts...'), ut = /* @__PURE__ */ i('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Connected accounts'), mt = /* @__PURE__ */ i('<div class="flex gap-2"><button class="inline-flex h-9 cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button></button><button class="inline-flex h-9 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), gt = /* @__PURE__ */ i('<div class=space-y-4><p class="text-sm text-muted-foreground">Add this account to your authenticator app, then enter the verification code.</p><div class=space-y-1><span class="text-sm font-medium leading-none">OTP Auth URI</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs"></code></div><div class=space-y-1><span class="text-sm font-medium leading-none">Manual entry key</span><code class="block w-full break-all rounded-md border border-input bg-muted px-3 py-2 text-xs font-mono tracking-wider"></code></div><form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-profile-mfa-code>Verification code</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-profile-mfa-code name=mfa_code type=text inputmode=numeric autocomplete=one-time-code required></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>'), ft = /* @__PURE__ */ i('<div class=space-y-4><div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">Two-factor authentication is enabled. Save these backup codes in a safe place.</div><ul class=space-y-1>'), pt = /* @__PURE__ */ i('<section class=space-y-4><h2 class="text-lg font-semibold tracking-tight">Two-factor authentication'), ge = /* @__PURE__ */ i("<ul class=space-y-2>"), bt = /* @__PURE__ */ i('<p class="text-sm text-muted-foreground">No passkeys registered.'), vt = /* @__PURE__ */ i('<li class="flex items-center justify-between rounded-md border border-input px-3 py-2"><div class=space-y-0.5><span class="text-sm font-medium"></span><span class="block text-xs text-muted-foreground">Added </span></div><button class="inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), ht = /* @__PURE__ */ i('<p class="text-sm text-muted-foreground">No connected accounts.'), yt = /* @__PURE__ */ i('<li class="flex items-center justify-between rounded-md border border-input px-3 py-2"><div class=space-y-0.5><span class="text-sm font-medium"></span><span class="block text-xs text-muted-foreground">Connected </span></div><button class="inline-flex h-8 cursor-pointer items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-destructive hover:text-destructive-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=button>'), xt = /* @__PURE__ */ i('<li class="rounded-md border border-input bg-muted px-3 py-1.5 text-center font-mono text-sm tracking-wider">');
572
- const Vt = () => {
573
- const {
574
- client: r,
575
- user: k,
576
- loading: b
577
- } = Y(), p = r?.passkey, v = r?.oauth, h = r?.mfa, $ = !!p, f = !!v, x = !!h, [d, {
578
- refetch: l
579
- }] = oe(async () => {
580
- if (!p) return [];
581
- try {
582
- return await p.list();
583
- } catch {
584
- return [];
585
- }
586
- }), [m, s] = a(null), [t, c] = a(null), [n, {
587
- refetch: u
588
- }] = oe(async () => {
589
- if (!v) return [];
590
- try {
591
- return await v.accounts();
592
- } catch {
593
- return [];
594
- }
595
- }), [o, P] = a(null), [w, _] = a(null), [S, L] = a(""), [R, O] = a(""), [D, G] = a(""), [A, I] = a([]), [z, Z] = a("idle"), [H, Q] = a(null), [B, W] = a(!1), ne = async (j) => {
596
- s(null), c(j);
597
- try {
598
- await p.delete(j), l();
599
- } catch (F) {
600
- const E = F instanceof Error ? F : new Error(String(F));
601
- s(E.message);
602
- } finally {
603
- c(null);
604
- }
605
- }, be = async (j) => {
606
- P(null), _(j);
607
- try {
608
- await v.unlink(j), u();
609
- } catch (F) {
610
- const E = F instanceof Error ? F : new Error(String(F));
611
- P(E.message);
612
- } finally {
613
- _(null);
614
- }
615
- }, ve = async () => {
616
- Q(null), W(!0);
617
- try {
618
- const j = await h.setup();
619
- L(j.otpauth_url), O(j.secret), I(j.backup_codes), Z("confirm");
620
- } catch (j) {
621
- const F = j instanceof Error ? j : new Error(String(j));
622
- Q(F.message);
623
- } finally {
624
- W(!1);
625
- }
626
- }, he = async (j) => {
627
- j.preventDefault(), Q(null), W(!0);
628
- try {
629
- const F = j.currentTarget, E = new FormData(F);
630
- await h.confirm({
631
- code: E.get("mfa_code") || D()
632
- }), Z("done");
633
- } catch (F) {
634
- const E = F instanceof Error ? F : new Error(String(F));
635
- Q(E.message);
636
- } finally {
637
- W(!1);
638
- }
639
- }, ye = async () => {
640
- Q(null), W(!0);
641
- try {
642
- await h.disable(), Z("idle"), L(""), O(""), G(""), I([]);
643
- } catch (j) {
644
- const F = j instanceof Error ? j : new Error(String(j));
645
- Q(F.message);
646
- } finally {
647
- W(!1);
648
- }
649
- };
650
- return (() => {
651
- var j = st();
652
- return e(j, g(y, {
653
- get when() {
654
- return b();
655
- },
656
- get children() {
657
- return nt();
658
- }
659
- }), null), e(j, g(y, {
660
- get when() {
661
- return k();
662
- },
663
- children: (F) => [(() => {
664
- var E = ot(), T = E.firstChild, q = T.nextSibling, M = q.firstChild, U = M.nextSibling, N = U.nextSibling, V = N.nextSibling, X = V.nextSibling, J = X.nextSibling;
665
- return e(U, () => F().email), e(q, g(y, {
666
- get when() {
667
- return F().display_name;
668
- },
669
- get children() {
670
- return [it(), (() => {
671
- var re = lt();
672
- return e(re, () => F().display_name), re;
673
- })()];
674
- }
675
- }), N), e(V, () => F().email_verified ? "Yes" : "No"), e(J, () => F().role), E;
676
- })(), g(y, {
677
- when: $,
678
- get children() {
679
- var E = dt();
680
- return E.firstChild, e(E, g(y, {
681
- get when() {
682
- return m();
683
- },
684
- get children() {
685
- var T = le();
686
- return e(T, m), T;
687
- }
688
- }), null), e(E, g(y, {
689
- get when() {
690
- return d.loading;
691
- },
692
- get children() {
693
- return at();
694
- }
695
- }), null), e(E, g(y, {
696
- get when() {
697
- return d();
698
- },
699
- children: (T) => g(y, {
700
- get when() {
701
- return T().length > 0;
702
- },
703
- get fallback() {
704
- return bt();
705
- },
706
- get children() {
707
- var q = ge();
708
- return e(q, g(te, {
709
- get each() {
710
- return T();
711
- },
712
- children: (M) => (() => {
713
- var U = vt(), N = U.firstChild, V = N.firstChild, X = V.nextSibling;
714
- X.firstChild;
715
- var J = N.nextSibling;
716
- return e(V, () => M.name ?? "Unnamed passkey"), e(X, () => new Date(M.created_at).toLocaleDateString(), null), J.$$click = () => ne(M.id), e(J, () => t() === M.id ? "Deleting..." : "Delete"), C(() => J.disabled = t() === M.id), U;
717
- })()
718
- })), q;
719
- }
720
- })
721
- }), null), E;
722
- }
723
- }), g(y, {
724
- when: f,
725
- get children() {
726
- var E = ut();
727
- return E.firstChild, e(E, g(y, {
728
- get when() {
729
- return o();
730
- },
731
- get children() {
732
- var T = le();
733
- return e(T, o), T;
734
- }
735
- }), null), e(E, g(y, {
736
- get when() {
737
- return n.loading;
738
- },
739
- get children() {
740
- return ct();
741
- }
742
- }), null), e(E, g(y, {
743
- get when() {
744
- return n();
745
- },
746
- children: (T) => g(y, {
747
- get when() {
748
- return T().length > 0;
749
- },
750
- get fallback() {
751
- return ht();
752
- },
753
- get children() {
754
- var q = ge();
755
- return e(q, g(te, {
756
- get each() {
757
- return T();
758
- },
759
- children: (M) => (() => {
760
- var U = yt(), N = U.firstChild, V = N.firstChild, X = V.nextSibling;
761
- X.firstChild;
762
- var J = N.nextSibling;
763
- return e(V, () => M.provider.charAt(0).toUpperCase() + M.provider.slice(1)), e(X, () => new Date(M.created_at).toLocaleDateString(), null), J.$$click = () => be(M.provider), e(J, () => w() === M.provider ? "Unlinking..." : "Unlink"), C(() => J.disabled = w() === M.provider), U;
764
- })()
765
- })), q;
766
- }
767
- })
768
- }), null), E;
769
- }
770
- }), g(y, {
771
- when: x,
772
- get children() {
773
- var E = pt();
774
- return E.firstChild, e(E, g(y, {
775
- get when() {
776
- return H();
777
- },
778
- get children() {
779
- var T = le();
780
- return e(T, H), T;
781
- }
782
- }), null), e(E, g(y, {
783
- get when() {
784
- return z() === "idle";
785
- },
786
- get children() {
787
- var T = mt(), q = T.firstChild, M = q.nextSibling;
788
- return q.$$click = ve, e(q, () => B() ? "Setting up..." : "Set up 2FA"), M.$$click = ye, e(M, () => B() ? "Disabling..." : "Disable 2FA"), C((U) => {
789
- var N = B(), V = B();
790
- return N !== U.e && (q.disabled = U.e = N), V !== U.t && (M.disabled = U.t = V), U;
791
- }, {
792
- e: void 0,
793
- t: void 0
794
- }), T;
795
- }
796
- }), null), e(E, g(y, {
797
- get when() {
798
- return z() === "confirm";
799
- },
800
- get children() {
801
- var T = gt(), q = T.firstChild, M = q.nextSibling, U = M.firstChild, N = U.nextSibling, V = M.nextSibling, X = V.firstChild, J = X.nextSibling, re = V.nextSibling, de = re.firstChild, xe = de.firstChild, se = xe.nextSibling, ce = de.nextSibling;
802
- return e(N, S), e(J, R), re.addEventListener("submit", he), se.$$input = (ee) => G(ee.currentTarget.value), e(ce, () => B() ? "Verifying..." : "Verify and enable"), C((ee) => {
803
- var ue = B(), me = B();
804
- return ue !== ee.e && (se.disabled = ee.e = ue), me !== ee.t && (ce.disabled = ee.t = me), ee;
805
- }, {
806
- e: void 0,
807
- t: void 0
808
- }), C(() => se.value = D()), T;
809
- }
810
- }), null), e(E, g(y, {
811
- get when() {
812
- return z() === "done";
813
- },
814
- get children() {
815
- var T = ft(), q = T.firstChild, M = q.nextSibling;
816
- return e(M, g(te, {
817
- get each() {
818
- return A();
819
- },
820
- children: (U) => (() => {
821
- var N = xt();
822
- return e(N, U), N;
823
- })()
824
- })), T;
825
- }
826
- }), null), E;
827
- }
828
- })]
829
- }), null), j;
830
- })();
786
+ r(["click", "input"]);
787
+ //#endregion
788
+ //#region src/components/register-form.tsx
789
+ var De = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), $ = /* @__PURE__ */ s("<form class=space-y-6><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-email>Email</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-password>Password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-password name=password type=password required autocomplete=new-password></div><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-register-display-name>Display name (optional)</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-register-display-name name=display_name type=text autocomplete=name></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Oe = (t) => {
790
+ let { client: r } = y(), o = r?.emailPassword;
791
+ if (!o) return null;
792
+ let [s, c] = p(""), [l, u] = p(""), [d, f] = p(""), [m, h] = p(null), [g, _] = p(!1), v = async (e) => {
793
+ e.preventDefault(), h(null), _(!0);
794
+ try {
795
+ let n = e.currentTarget, r = new FormData(n), i = r.get("display_name") || d(), a = await o.register({
796
+ email: r.get("email") || s(),
797
+ password: r.get("password") || l(),
798
+ display_name: i || void 0
799
+ });
800
+ t.onSuccess?.(a.message ?? "");
801
+ } catch (e) {
802
+ let n = e instanceof Error ? e : Error(String(e));
803
+ h(n.message), t.onError?.(n);
804
+ } finally {
805
+ _(!1);
806
+ }
807
+ };
808
+ return (() => {
809
+ var t = $(), r = t.firstChild, o = r.firstChild.nextSibling, p = r.nextSibling, h = p.firstChild.nextSibling, _ = p.nextSibling, y = _.firstChild.nextSibling, b = _.nextSibling;
810
+ return t.addEventListener("submit", v), a(t, n(e, {
811
+ get when() {
812
+ return m();
813
+ },
814
+ get children() {
815
+ var e = De();
816
+ return a(e, m), e;
817
+ }
818
+ }), r), o.$$input = (e) => c(e.currentTarget.value), h.$$input = (e) => u(e.currentTarget.value), y.$$input = (e) => f(e.currentTarget.value), a(b, () => g() ? "Creating account..." : "Create account"), i((e) => {
819
+ var t = g(), n = g(), r = g(), i = g();
820
+ return t !== e.e && (o.disabled = e.e = t), n !== e.t && (h.disabled = e.t = n), r !== e.a && (y.disabled = e.a = r), i !== e.o && (b.disabled = e.o = i), e;
821
+ }, {
822
+ e: void 0,
823
+ t: void 0,
824
+ a: void 0,
825
+ o: void 0
826
+ }), i(() => o.value = s()), i(() => h.value = l()), i(() => y.value = d()), t;
827
+ })();
831
828
  };
832
- K(["click", "input"]);
833
- var wt = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), $t = /* @__PURE__ */ i('<form class=space-y-6><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-register-email>Email</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-register-email name=email type=email required autocomplete=email></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-register-password>Password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-register-password name=password type=password required autocomplete=new-password></div><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-register-display-name>Display name (optional)</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-register-display-name name=display_name type=text autocomplete=name></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
834
- const zt = (r) => {
835
- const {
836
- client: k
837
- } = Y(), b = k?.emailPassword;
838
- if (!b) return null;
839
- const [p, v] = a(""), [h, $] = a(""), [f, x] = a(""), [d, l] = a(null), [m, s] = a(!1), t = async (c) => {
840
- c.preventDefault(), l(null), s(!0);
841
- try {
842
- const n = c.currentTarget, u = new FormData(n), o = u.get("display_name") || f(), P = await b.register({
843
- email: u.get("email") || p(),
844
- password: u.get("password") || h(),
845
- display_name: o || void 0
846
- });
847
- r.onSuccess?.(P.message);
848
- } catch (n) {
849
- const u = n instanceof Error ? n : new Error(String(n));
850
- l(u.message), r.onError?.(u);
851
- } finally {
852
- s(!1);
853
- }
854
- };
855
- return (() => {
856
- var c = $t(), n = c.firstChild, u = n.firstChild, o = u.nextSibling, P = n.nextSibling, w = P.firstChild, _ = w.nextSibling, S = P.nextSibling, L = S.firstChild, R = L.nextSibling, O = S.nextSibling;
857
- return c.addEventListener("submit", t), e(c, g(y, {
858
- get when() {
859
- return d();
860
- },
861
- get children() {
862
- var D = wt();
863
- return e(D, d), D;
864
- }
865
- }), n), o.$$input = (D) => v(D.currentTarget.value), _.$$input = (D) => $(D.currentTarget.value), R.$$input = (D) => x(D.currentTarget.value), e(O, () => m() ? "Creating account..." : "Create account"), C((D) => {
866
- var G = m(), A = m(), I = m(), z = m();
867
- return G !== D.e && (o.disabled = D.e = G), A !== D.t && (_.disabled = D.t = A), I !== D.a && (R.disabled = D.a = I), z !== D.o && (O.disabled = D.o = z), D;
868
- }, {
869
- e: void 0,
870
- t: void 0,
871
- a: void 0,
872
- o: void 0
873
- }), C(() => o.value = p()), C(() => _.value = h()), C(() => R.value = f()), c;
874
- })();
829
+ r(["input"]);
830
+ //#endregion
831
+ //#region src/components/reset-password-form.tsx
832
+ var ke = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Ae = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), je = /* @__PURE__ */ s("<form class=space-y-4><div class=space-y-2><label class=\"text-sm font-medium leading-none\"for=yauth-reset-password-input>New password</label><input class=\"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\"id=yauth-reset-password-input name=password type=password required autocomplete=new-password></div><button class=\"inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"type=submit>"), Me = (t) => {
833
+ let { client: r } = y(), o = r?.emailPassword;
834
+ if (!o) return null;
835
+ let [s, c] = p(""), [l, u] = p(null), [d, f] = p(null), [m, h] = p(!1), g = async (e) => {
836
+ e.preventDefault(), u(null), f(null), h(!0);
837
+ try {
838
+ let n = e.currentTarget, r = new FormData(n), i = await o.resetPassword({
839
+ token: t.token,
840
+ password: r.get("password") || s()
841
+ });
842
+ f(i.message), t.onSuccess?.(i.message);
843
+ } catch (e) {
844
+ u((e instanceof Error ? e : Error(String(e))).message);
845
+ } finally {
846
+ h(!1);
847
+ }
848
+ };
849
+ return (() => {
850
+ var t = je(), r = t.firstChild, o = r.firstChild.nextSibling, u = r.nextSibling;
851
+ return t.addEventListener("submit", g), a(t, n(e, {
852
+ get when() {
853
+ return l();
854
+ },
855
+ get children() {
856
+ var e = ke();
857
+ return a(e, l), e;
858
+ }
859
+ }), r), a(t, n(e, {
860
+ get when() {
861
+ return d();
862
+ },
863
+ get children() {
864
+ var e = Ae();
865
+ return a(e, d), e;
866
+ }
867
+ }), r), o.$$input = (e) => c(e.currentTarget.value), a(u, () => m() ? "Resetting..." : "Reset password"), i((e) => {
868
+ var t = m(), n = m();
869
+ return t !== e.e && (o.disabled = e.e = t), n !== e.t && (u.disabled = e.t = n), e;
870
+ }, {
871
+ e: void 0,
872
+ t: void 0
873
+ }), i(() => o.value = s()), t;
874
+ })();
875
875
  };
876
- K(["input"]);
877
- var _t = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), St = /* @__PURE__ */ i('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), kt = /* @__PURE__ */ i('<form class=space-y-4><div class=space-y-2><label class="text-sm font-medium leading-none"for=yauth-reset-password-input>New password</label><input class="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm"id=yauth-reset-password-input name=password type=password required autocomplete=new-password></div><button class="inline-flex h-9 w-full cursor-pointer items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"type=submit>');
878
- const Yt = (r) => {
879
- const {
880
- client: k
881
- } = Y(), b = k?.emailPassword;
882
- if (!b) return null;
883
- const [p, v] = a(""), [h, $] = a(null), [f, x] = a(null), [d, l] = a(!1), m = async (s) => {
884
- s.preventDefault(), $(null), x(null), l(!0);
885
- try {
886
- const t = s.currentTarget, c = new FormData(t), n = await b.resetPassword({
887
- token: r.token,
888
- password: c.get("password") || p()
889
- });
890
- x(n.message), r.onSuccess?.(n.message);
891
- } catch (t) {
892
- const c = t instanceof Error ? t : new Error(String(t));
893
- $(c.message);
894
- } finally {
895
- l(!1);
896
- }
897
- };
898
- return (() => {
899
- var s = kt(), t = s.firstChild, c = t.firstChild, n = c.nextSibling, u = t.nextSibling;
900
- return s.addEventListener("submit", m), e(s, g(y, {
901
- get when() {
902
- return h();
903
- },
904
- get children() {
905
- var o = _t();
906
- return e(o, h), o;
907
- }
908
- }), t), e(s, g(y, {
909
- get when() {
910
- return f();
911
- },
912
- get children() {
913
- var o = St();
914
- return e(o, f), o;
915
- }
916
- }), t), n.$$input = (o) => v(o.currentTarget.value), e(u, () => d() ? "Resetting..." : "Reset password"), C((o) => {
917
- var P = d(), w = d();
918
- return P !== o.e && (n.disabled = o.e = P), w !== o.t && (u.disabled = o.t = w), o;
919
- }, {
920
- e: void 0,
921
- t: void 0
922
- }), C(() => n.value = p()), s;
923
- })();
924
- };
925
- K(["input"]);
926
- var Ct = /* @__PURE__ */ i('<div class="text-sm text-muted-foreground">Verifying your email address...'), Et = /* @__PURE__ */ i('<div class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400">'), Pt = /* @__PURE__ */ i('<div class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">'), Dt = /* @__PURE__ */ i("<div class=space-y-4>");
927
- const It = (r) => {
928
- const {
929
- client: k
930
- } = Y(), b = k?.emailPassword;
931
- if (!b) return null;
932
- const [p, v] = a("loading"), [h, $] = a(""), [f, x] = a("");
933
- return ae(async () => {
934
- try {
935
- const d = await b.verify({
936
- token: r.token
937
- });
938
- $(d.message), v("success"), r.onSuccess?.();
939
- } catch (d) {
940
- const l = d instanceof Error ? d : new Error(String(d));
941
- x(l.message), v("error"), r.onError?.(l);
942
- }
943
- }), (() => {
944
- var d = Dt();
945
- return e(d, g(y, {
946
- get when() {
947
- return p() === "loading";
948
- },
949
- get children() {
950
- return Ct();
951
- }
952
- }), null), e(d, g(y, {
953
- get when() {
954
- return p() === "success";
955
- },
956
- get children() {
957
- var l = Et();
958
- return e(l, h), l;
959
- }
960
- }), null), e(d, g(y, {
961
- get when() {
962
- return p() === "error";
963
- },
964
- get children() {
965
- var l = Pt();
966
- return e(l, f), l;
967
- }
968
- }), null), d;
969
- })();
970
- };
971
- export {
972
- Ft as ChangePasswordForm,
973
- Mt as ConsentScreen,
974
- Rt as ForgotPasswordForm,
975
- Ut as LoginForm,
976
- qt as MagicLinkForm,
977
- Nt as MfaChallenge,
978
- Ot as MfaSetup,
979
- Bt as OAuthButtons,
980
- qe as PasskeyButton,
981
- Vt as ProfileSettings,
982
- zt as RegisterForm,
983
- Yt as ResetPasswordForm,
984
- It as VerifyEmail,
985
- jt as YAuthProvider,
986
- Y as useYAuth
876
+ r(["input"]);
877
+ //#endregion
878
+ //#region src/components/verify-email.tsx
879
+ var Ne = /* @__PURE__ */ s("<div class=\"text-sm text-muted-foreground\">Verifying your email address..."), Pe = /* @__PURE__ */ s("<div class=\"rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-600 dark:text-emerald-400\">"), Fe = /* @__PURE__ */ s("<div class=\"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive\">"), Ie = /* @__PURE__ */ s("<div class=space-y-4>"), Le = (t) => {
880
+ let { client: r } = y(), i = r?.emailPassword;
881
+ if (!i) return null;
882
+ let [o, s] = p("loading"), [c, l] = p(""), [u, f] = p("");
883
+ return d(async () => {
884
+ try {
885
+ l((await i.verify({ token: t.token })).message), s("success"), t.onSuccess?.();
886
+ } catch (e) {
887
+ let n = e instanceof Error ? e : Error(String(e));
888
+ f(n.message), s("error"), t.onError?.(n);
889
+ }
890
+ }), (() => {
891
+ var t = Ie();
892
+ return a(t, n(e, {
893
+ get when() {
894
+ return o() === "loading";
895
+ },
896
+ get children() {
897
+ return Ne();
898
+ }
899
+ }), null), a(t, n(e, {
900
+ get when() {
901
+ return o() === "success";
902
+ },
903
+ get children() {
904
+ var e = Pe();
905
+ return a(e, c), e;
906
+ }
907
+ }), null), a(t, n(e, {
908
+ get when() {
909
+ return o() === "error";
910
+ },
911
+ get children() {
912
+ var e = Fe();
913
+ return a(e, u), e;
914
+ }
915
+ }), null), t;
916
+ })();
987
917
  };
918
+ //#endregion
919
+ export { C as ChangePasswordForm, O as ConsentScreen, M as ForgotPasswordForm, z as LoginForm, G as MagicLinkForm, ee as MfaChallenge, ie as MfaSetup, se as OAuthButtons, F as PasskeyButton, Ee as ProfileSettings, Oe as RegisterForm, Me as ResetPasswordForm, Le as VerifyEmail, v as YAuthProvider, y as useYAuth };