@zerodev/wallet-react-ui 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +54 -10
  2. package/dist/_types/auth/authStoreSlice.d.ts +3 -4
  3. package/dist/_types/auth/authStoreSlice.d.ts.map +1 -1
  4. package/dist/_types/auth/hooks/useAuth.d.ts +0 -2
  5. package/dist/_types/auth/hooks/useAuth.d.ts.map +1 -1
  6. package/dist/_types/auth/index.d.ts +9 -1
  7. package/dist/_types/auth/index.d.ts.map +1 -1
  8. package/dist/_types/auth/pages/OtpInput.d.ts.map +1 -1
  9. package/dist/_types/auth/pages/SignUp/Email.d.ts +4 -0
  10. package/dist/_types/auth/pages/SignUp/Email.d.ts.map +1 -0
  11. package/dist/_types/auth/pages/SignUp/Google.d.ts +3 -0
  12. package/dist/_types/auth/pages/SignUp/Google.d.ts.map +1 -0
  13. package/dist/_types/auth/pages/SignUp/Passkey.d.ts +3 -0
  14. package/dist/_types/auth/pages/SignUp/Passkey.d.ts.map +1 -0
  15. package/dist/_types/auth/pages/SignUp/context.d.ts +25 -0
  16. package/dist/_types/auth/pages/SignUp/context.d.ts.map +1 -0
  17. package/dist/_types/auth/pages/SignUp/index.d.ts +31 -0
  18. package/dist/_types/auth/pages/SignUp/index.d.ts.map +1 -0
  19. package/dist/_types/auth/pages/Verifying.d.ts.map +1 -1
  20. package/dist/_types/auth/types.d.ts +0 -8
  21. package/dist/_types/auth/types.d.ts.map +1 -1
  22. package/dist/_types/auth/utils/isCancellationError.d.ts +2 -0
  23. package/dist/_types/auth/utils/isCancellationError.d.ts.map +1 -0
  24. package/dist/_types/connector.d.ts +3 -13
  25. package/dist/_types/connector.d.ts.map +1 -1
  26. package/dist/_types/index.d.ts +4 -3
  27. package/dist/_types/index.d.ts.map +1 -1
  28. package/dist/_types/shared/utils/common.d.ts +0 -1
  29. package/dist/_types/shared/utils/common.d.ts.map +1 -1
  30. package/dist/_types/store.d.ts +1 -6
  31. package/dist/_types/store.d.ts.map +1 -1
  32. package/dist/index.cjs +3 -3
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.mjs +555 -562
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/styles.css +1 -1
  37. package/package.json +4 -4
  38. package/src/auth/authStoreSlice.ts +7 -13
  39. package/src/auth/hooks/useAuth.ts +0 -5
  40. package/src/auth/index.tsx +19 -7
  41. package/src/auth/pages/OtpInput.tsx +1 -4
  42. package/src/auth/pages/SignUp/Email.tsx +86 -0
  43. package/src/auth/pages/SignUp/Google.tsx +43 -0
  44. package/src/auth/pages/SignUp/Passkey.tsx +56 -0
  45. package/src/auth/pages/SignUp/context.tsx +41 -0
  46. package/src/auth/pages/SignUp/index.tsx +138 -0
  47. package/src/auth/pages/Verifying.tsx +3 -10
  48. package/src/auth/types.ts +0 -9
  49. package/src/auth/utils/isCancellationError.ts +8 -0
  50. package/src/connector.ts +12 -28
  51. package/src/index.ts +3 -3
  52. package/src/shared/utils/common.ts +0 -12
  53. package/src/store.ts +1 -8
  54. package/dist/_types/auth/pages/SignUp.d.ts +0 -2
  55. package/dist/_types/auth/pages/SignUp.d.ts.map +0 -1
  56. package/src/auth/pages/SignUp.tsx +0 -311
package/dist/index.mjs CHANGED
@@ -1,83 +1,81 @@
1
- import { jsxs as c, jsx as n, Fragment as A } from "react/jsx-runtime";
2
- import { Text as m, cn as G, PoweredBy as B, Button as E, Wrapper as ne, ListItem as $, ListItemChevron as re, ListItemIcon as D, Input as se, Icon as ie, Screen as ae, TopNav as oe } from "@zerodev/react-ui";
3
- import { useState as w, useEffect as O, useMemo as le, useRef as K } from "react";
4
- import { useStore as I, create as de } from "zustand";
5
- import { useConfig as ce, useConnect as ue } from "wagmi";
6
- import { useSendMagicLink as Y, useSendOTP as J, useVerifyOTP as he, useAuthenticateOAuth as pe, useRegisterPasskey as me, useLoginPasskey as ze, useVerifyMagicLink as fe, zeroDevWallet as ge, NotAuthenticatedError as ye } from "@zerodev/wallet-react";
7
- import { subscribeWithSelector as xe } from "zustand/middleware";
8
- const we = "" + new URL("error.webp", import.meta.url).href, Se = "" + new URL("loading.webp", import.meta.url).href, Ne = "" + new URL("send.webp", import.meta.url).href, ve = "" + new URL("success.webp", import.meta.url).href, be = {
9
- error: we,
10
- loading: Se,
11
- send: Ne,
12
- success: ve
1
+ import { jsxs as d, jsx as t, Fragment as N } from "react/jsx-runtime";
2
+ import { Text as m, cn as H, PoweredBy as T, Button as w, Wrapper as Q, Input as Z, Icon as ee, ListItem as _, ListItemChevron as te, ListItemIcon as q, Screen as ne, TopNav as re } from "@zerodev/react-ui";
3
+ import { useState as z, useEffect as k, useMemo as ie, useRef as D, createContext as se, useContext as oe } from "react";
4
+ import { useStore as C, create as ae } from "zustand";
5
+ import { useConfig as de, useConnect as ce } from "wagmi";
6
+ import { useSendMagicLink as W, useSendOTP as F, useVerifyOTP as le, useAuthenticateOAuth as ue, useRegisterPasskey as pe, useLoginPasskey as he, useVerifyMagicLink as me, zeroDevWallet as fe, NotAuthenticatedError as ge } from "@zerodev/wallet-react";
7
+ import { subscribeWithSelector as ze } from "zustand/middleware";
8
+ const ye = "" + new URL("error.webp", import.meta.url).href, xe = "" + new URL("loading.webp", import.meta.url).href, we = "" + new URL("send.webp", import.meta.url).href, Se = "" + new URL("success.webp", import.meta.url).href, Ne = {
9
+ error: ye,
10
+ loading: xe,
11
+ send: we,
12
+ success: Se
13
13
  };
14
- function P({
14
+ function E({
15
15
  imageName: e,
16
- title: s,
17
- children: a,
18
- className: t
16
+ title: r,
17
+ children: s,
18
+ className: i
19
19
  }) {
20
- return /* @__PURE__ */ c(
20
+ return /* @__PURE__ */ d(
21
21
  "div",
22
22
  {
23
- className: G("zd:flex zd:flex-col zd:gap-8 zd:items-center", t),
23
+ className: H("zd:flex zd:flex-col zd:gap-8 zd:items-center", i),
24
24
  children: [
25
- /* @__PURE__ */ n(
25
+ /* @__PURE__ */ t(
26
26
  "img",
27
27
  {
28
- src: be[e],
28
+ src: Ne[e],
29
29
  alt: e,
30
30
  className: "zd:w-[118px] zd:h-[118px] zd:bg-transparent"
31
31
  }
32
32
  ),
33
- /* @__PURE__ */ c("div", { className: "zd:flex zd:flex-col zd:gap-4 zd:items-center", children: [
34
- /* @__PURE__ */ n(m, { className: "zd:text-h2 zd:text-center zd:whitespace-pre-wrap", children: s }),
35
- /* @__PURE__ */ n(m, { className: "zd:text-center zd:whitespace-pre-wrap", children: a })
33
+ /* @__PURE__ */ d("div", { className: "zd:flex zd:flex-col zd:gap-4 zd:items-center", children: [
34
+ /* @__PURE__ */ t(m, { className: "zd:text-h2 zd:text-center zd:whitespace-pre-wrap", children: r }),
35
+ /* @__PURE__ */ t(m, { className: "zd:text-center zd:whitespace-pre-wrap", children: s })
36
36
  ] })
37
37
  ]
38
38
  }
39
39
  );
40
40
  }
41
- function X() {
42
- const s = ce().connectors.find((a) => a.id === "zerodev-wallet");
43
- if (!s || !("getKitStore" in s))
41
+ function ve() {
42
+ const r = de().connectors.find((s) => s.id === "zerodev-wallet");
43
+ if (!r || !("getKitStore" in r))
44
44
  throw new Error("useKitStore must be used with the zeroDevWallet connector");
45
- return s.getKitStore();
45
+ return r.getKitStore();
46
46
  }
47
- function R() {
48
- const e = X(), s = I(e, (l) => l.auth.step), a = I(e, (l) => l.auth.stepHistory), t = I(e, (l) => l.auth.email), r = I(e, (l) => l.auth.otpId), d = I(
47
+ function S() {
48
+ const e = ve(), r = C(e, (o) => o.auth.step), s = C(e, (o) => o.auth.stepHistory), i = C(e, (o) => o.auth.email), n = C(e, (o) => o.auth.otpId), a = C(
49
49
  e,
50
- (l) => l.auth.otpEncryptionTargetBundle
51
- ), i = I(e, (l) => l.auth.enabledMethods), u = I(e, (l) => l.auth.config);
50
+ (o) => o.auth.otpEncryptionTargetBundle
51
+ );
52
52
  return {
53
- step: s,
54
- email: t,
55
- otpId: r,
56
- otpEncryptionTargetBundle: d,
57
- enabledMethods: i,
58
- config: u,
53
+ step: r,
54
+ email: i,
55
+ otpId: n,
56
+ otpEncryptionTargetBundle: a,
59
57
  goToStep: e.getState().auth.goToStep,
60
- goBack: a.length > 0 ? e.getState().auth.goBack : null,
58
+ goBack: s.length > 0 ? e.getState().auth.goBack : null,
61
59
  reset: e.getState().auth.reset,
62
60
  setEmail: e.getState().auth.setEmail,
63
61
  setOtpSession: e.getState().auth.setOtpSession,
64
62
  clearOtpSession: e.getState().auth.clearOtpSession
65
63
  };
66
64
  }
67
- function Ee() {
68
- const { email: e, setOtpSession: s } = R(), { mutateAsync: a, isPending: t } = Y(), [r, d] = w(60), i = r <= 0 && !t;
69
- return O(() => {
70
- if (r <= 0) return;
65
+ function be() {
66
+ const { email: e, setOtpSession: r } = S(), { mutateAsync: s, isPending: i } = W(), [n, a] = z(60), o = n <= 0 && !i;
67
+ return k(() => {
68
+ if (n <= 0) return;
71
69
  const l = setInterval(() => {
72
- d((h) => Math.max(0, h - 1));
70
+ a((p) => Math.max(0, p - 1));
73
71
  }, 1e3);
74
72
  return () => {
75
73
  clearInterval(l);
76
74
  };
77
- }, [r]), /* @__PURE__ */ c(A, { children: [
78
- /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:justify-center", children: [
79
- /* @__PURE__ */ c(
80
- P,
75
+ }, [n]), /* @__PURE__ */ d(N, { children: [
76
+ /* @__PURE__ */ d("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:justify-center", children: [
77
+ /* @__PURE__ */ d(
78
+ E,
81
79
  {
82
80
  imageName: "send",
83
81
  title: `Check your email!
@@ -85,279 +83,277 @@ function Ee() {
85
83
  children: [
86
84
  "We've sent a magic link to",
87
85
  " ",
88
- /* @__PURE__ */ n(m, { as: "span", className: "zd:text-solarOrange", children: e }),
86
+ /* @__PURE__ */ t(m, { as: "span", className: "zd:text-solarOrange", children: e }),
89
87
  `
90
88
  `,
91
89
  "Please open the email and click the link to log in."
92
90
  ]
93
91
  }
94
92
  ),
95
- /* @__PURE__ */ n("div", { className: "zd:flex zd:flex-col zd:gap-1", children: /* @__PURE__ */ c(m, { className: "zd:text-center", children: [
93
+ /* @__PURE__ */ t("div", { className: "zd:flex zd:flex-col zd:gap-1", children: /* @__PURE__ */ d(m, { className: "zd:text-center", children: [
96
94
  "Did not get an email?",
97
95
  " ",
98
- /* @__PURE__ */ n(
96
+ /* @__PURE__ */ t(
99
97
  "button",
100
98
  {
101
99
  type: "button",
102
- disabled: !i,
100
+ disabled: !o,
103
101
  onClick: async () => {
104
- if (!(!e || !i))
102
+ if (!(!e || !o))
105
103
  try {
106
- const { otpId: l, otpEncryptionTargetBundle: h } = await a({
104
+ const { otpId: l, otpEncryptionTargetBundle: p } = await s({
107
105
  email: e
108
106
  });
109
- s({ otpId: l, otpEncryptionTargetBundle: h }), d(60);
107
+ r({ otpId: l, otpEncryptionTargetBundle: p }), a(60);
110
108
  } catch {
111
109
  }
112
110
  },
113
111
  className: "zd:cursor-pointer zd:underline zd:disabled:opacity-50 zd:disabled:cursor-not-allowed",
114
- children: i ? "Resend" : `Resend in ${r} ${r === 1 ? "second" : "seconds"}`
112
+ children: o ? "Resend" : `Resend in ${n} ${n === 1 ? "second" : "seconds"}`
115
113
  }
116
114
  )
117
115
  ] }) })
118
116
  ] }),
119
- /* @__PURE__ */ n(B, { className: "zd:self-center zd:pt-4 zd:pb-6" })
117
+ /* @__PURE__ */ t(T, { className: "zd:self-center zd:pt-4 zd:pb-6" })
120
118
  ] });
121
119
  }
122
- function ke() {
120
+ function Ee() {
123
121
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("code");
124
122
  }
125
- function M() {
123
+ function A() {
126
124
  if (typeof window > "u") return;
127
125
  const e = new URL(window.location.href);
128
126
  e.searchParams.has("code") && (e.searchParams.delete("code"), window.history.replaceState(null, "", e.toString()));
129
127
  }
130
- function Te({
128
+ function ke({
131
129
  title: e = "Oops, something went wrong",
132
- message: s = "We couldn't complete the sign-in process. This could be due to timeout, an expired link, or a cancelled request.",
133
- showRetry: a = !1,
134
- showChooseAnother: t = !0
130
+ message: r = "We couldn't complete the sign-in process. This could be due to timeout, an expired link, or a cancelled request.",
131
+ showRetry: s = !1,
132
+ showChooseAnother: i = !0
135
133
  }) {
136
- const { goToStep: r, goBack: d, reset: i } = R();
137
- return /* @__PURE__ */ c(A, { children: [
138
- /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:items-center zd:justify-center", children: [
139
- /* @__PURE__ */ n(P, { imageName: "error", title: e, children: s }),
140
- /* @__PURE__ */ c("div", { className: "zd:flex zd:flex-col zd:gap-1", children: [
141
- a && /* @__PURE__ */ n(E, { action: "primary", text: "Try again", onClick: d ?? (() => r("sign-up")) }),
142
- t && /* @__PURE__ */ n(
143
- E,
134
+ const { goToStep: n, goBack: a, reset: o } = S();
135
+ return /* @__PURE__ */ d(N, { children: [
136
+ /* @__PURE__ */ d("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:items-center zd:justify-center", children: [
137
+ /* @__PURE__ */ t(E, { imageName: "error", title: e, children: r }),
138
+ /* @__PURE__ */ d("div", { className: "zd:flex zd:flex-col zd:gap-1", children: [
139
+ s && /* @__PURE__ */ t(w, { action: "primary", text: "Try again", onClick: a ?? (() => n("sign-up")) }),
140
+ i && /* @__PURE__ */ t(
141
+ w,
144
142
  {
145
- action: a ? "secondary" : "primary",
143
+ action: s ? "secondary" : "primary",
146
144
  onClick: () => {
147
- M(), r("sign-up");
145
+ A(), n("sign-up");
148
146
  },
149
147
  text: "Choose another sign-in method"
150
148
  }
151
149
  ),
152
- !a && !t && /* @__PURE__ */ n(E, { action: "primary", text: "Start over", onClick: i })
150
+ !s && !i && /* @__PURE__ */ t(w, { action: "primary", text: "Start over", onClick: o })
153
151
  ] })
154
152
  ] }),
155
- /* @__PURE__ */ n(B, { className: "zd:self-center zd:pt-4 zd:pb-6" })
153
+ /* @__PURE__ */ t(T, { className: "zd:self-center zd:pt-4 zd:pb-6" })
156
154
  ] });
157
155
  }
158
- const Ie = 4, Ae = 8, Ce = 6;
159
- function Le(e) {
160
- return Math.max(Ie, Math.min(Ae, e));
156
+ const Te = 4, Ie = 8, Ce = 6;
157
+ function Ae(e) {
158
+ return Math.max(Te, Math.min(Ie, e));
161
159
  }
162
- function Pe({ char: e, isFocused: s }) {
163
- return /* @__PURE__ */ n(
164
- ne,
160
+ function Pe({ char: e, isFocused: r }) {
161
+ return /* @__PURE__ */ t(
162
+ Q,
165
163
  {
166
164
  "data-testid": "code-input-box",
167
- "data-active": s || void 0,
168
- className: G(
165
+ "data-active": r || void 0,
166
+ className: H(
169
167
  "zd:h-16 zd:w-14 zd:rounded-lg zd:flex zd:items-center zd:justify-center",
170
- s && "zd:border-[1.5px] zd:border-greyScale"
168
+ r && "zd:border-[1.5px] zd:border-greyScale"
171
169
  ),
172
- children: /* @__PURE__ */ n(m, { className: "zd:text-h2", children: e })
170
+ children: /* @__PURE__ */ t(m, { className: "zd:text-h2", children: e })
173
171
  }
174
172
  );
175
173
  }
176
174
  function Re({
177
175
  onChange: e,
178
- onComplete: s,
179
- disabled: a = !1,
180
- error: t = !1,
181
- autoFocus: r = !1,
182
- length: d = Ce,
183
- "data-testid": i
176
+ onComplete: r,
177
+ disabled: s = !1,
178
+ error: i = !1,
179
+ autoFocus: n = !1,
180
+ length: a = Ce,
181
+ "data-testid": o
184
182
  }) {
185
- const u = Le(d), l = le(
186
- () => Array.from({ length: u }, (p, g) => ({
187
- id: `char-${g}`,
188
- index: g
183
+ const c = Ae(a), l = ie(
184
+ () => Array.from({ length: c }, (u, x) => ({
185
+ id: `char-${x}`,
186
+ index: x
189
187
  })),
190
- [u]
191
- ), [h, x] = w(""), [f, N] = w(!1), k = K(null);
192
- O(() => {
193
- var p;
194
- r && !a && ((p = k.current) == null || p.focus());
195
- }, [r, a]), O(() => {
196
- x((p) => p.slice(0, u));
197
- }, [u]);
198
- const v = (p) => {
199
- const g = p.slice(0, u).toUpperCase();
200
- x(g), e == null || e(g), g.length === u && setTimeout(() => {
201
- var C;
202
- s == null || s(g), (C = k.current) == null || C.blur();
188
+ [c]
189
+ ), [p, h] = z(""), [v, b] = z(!1), f = D(null);
190
+ k(() => {
191
+ var u;
192
+ n && !s && ((u = f.current) == null || u.focus());
193
+ }, [n, s]), k(() => {
194
+ h((u) => u.slice(0, c));
195
+ }, [c]);
196
+ const y = (u) => {
197
+ const x = u.slice(0, c).toUpperCase();
198
+ h(x), e == null || e(x), x.length === c && setTimeout(() => {
199
+ var g;
200
+ r == null || r(x), (g = f.current) == null || g.blur();
203
201
  }, 0);
204
202
  };
205
- return /* @__PURE__ */ c(
203
+ return /* @__PURE__ */ d(
206
204
  "button",
207
205
  {
208
206
  type: "button",
209
207
  className: "zd:flex zd:flex-row zd:items-center zd:justify-between zd:gap-2 zd:w-full zd:cursor-text",
210
208
  onClick: () => {
211
- var p;
212
- return (p = k.current) == null ? void 0 : p.focus();
209
+ var u;
210
+ return (u = f.current) == null ? void 0 : u.focus();
213
211
  },
214
- disabled: a,
215
- "data-testid": i,
212
+ disabled: s,
213
+ "data-testid": o,
216
214
  children: [
217
- /* @__PURE__ */ n(
215
+ /* @__PURE__ */ t(
218
216
  "input",
219
217
  {
220
- ref: k,
221
- value: h,
222
- onChange: (p) => v(p.target.value),
223
- onFocus: () => N(!0),
224
- onBlur: () => N(!1),
225
- maxLength: u,
226
- disabled: a,
218
+ ref: f,
219
+ value: p,
220
+ onChange: (u) => y(u.target.value),
221
+ onFocus: () => b(!0),
222
+ onBlur: () => b(!1),
223
+ maxLength: c,
224
+ disabled: s,
227
225
  className: "zd:absolute zd:opacity-0 zd:pointer-events-none",
228
226
  style: { position: "absolute", opacity: 0 },
229
227
  "aria-label": "Verification code"
230
228
  }
231
229
  ),
232
- l.map((p) => /* @__PURE__ */ n(
230
+ l.map((u) => /* @__PURE__ */ t(
233
231
  Pe,
234
232
  {
235
- char: h[p.index] ?? "",
236
- isFocused: !t && f && p.index === h.length
233
+ char: p[u.index] ?? "",
234
+ isFocused: !i && v && u.index === p.length
237
235
  },
238
- p.id
236
+ u.id
239
237
  ))
240
238
  ]
241
239
  }
242
240
  );
243
241
  }
244
- function Oe() {
242
+ function Le() {
245
243
  const {
246
244
  email: e,
247
- otpId: s,
248
- otpEncryptionTargetBundle: a,
249
- setOtpSession: t,
250
- clearOtpSession: r,
251
- goToStep: d,
252
- config: i
253
- } = R(), { mutateAsync: u, isPending: l } = J(), { mutateAsync: h, isPending: x } = he(), [f, N] = w(""), [k, v] = w(!1), [p, g] = w(60);
254
- O(() => {
255
- if (p <= 0) return;
256
- const S = setInterval(() => {
257
- g((T) => Math.max(0, T - 1));
245
+ otpId: r,
246
+ otpEncryptionTargetBundle: s,
247
+ setOtpSession: i,
248
+ clearOtpSession: n,
249
+ goToStep: a
250
+ } = S(), { mutateAsync: o, isPending: c } = F(), { mutateAsync: l, isPending: p } = le(), [h, v] = z(""), [b, f] = z(!1), [y, u] = z(60);
251
+ k(() => {
252
+ if (y <= 0) return;
253
+ const I = setInterval(() => {
254
+ u((O) => Math.max(0, O - 1));
258
255
  }, 1e3);
259
- return () => clearInterval(S);
260
- }, [p]);
261
- const C = async () => {
262
- var S, T;
263
- if (!(!f.trim() || !s || !a)) {
264
- v(!1);
256
+ return () => clearInterval(I);
257
+ }, [y]);
258
+ const x = async () => {
259
+ if (!(!h.trim() || !r || !s)) {
260
+ f(!1);
265
261
  try {
266
- await h({
267
- otpId: s,
268
- code: f.trim(),
269
- otpEncryptionTargetBundle: a
270
- }), r(), d("authenticated"), (S = i == null ? void 0 : i.onSuccess) == null || S.call(i);
271
- } catch (F) {
272
- v(!0), (T = i == null ? void 0 : i.onError) == null || T.call(i, F);
262
+ await l({
263
+ otpId: r,
264
+ code: h.trim(),
265
+ otpEncryptionTargetBundle: s
266
+ }), n(), a("authenticated");
267
+ } catch {
268
+ f(!0);
273
269
  }
274
270
  }
275
- }, y = (S) => {
276
- N(S);
277
- }, H = async () => {
278
- if (!(!e || p > 0 || l))
271
+ }, g = (I) => {
272
+ v(I);
273
+ }, L = async () => {
274
+ if (!(!e || y > 0 || c))
279
275
  try {
280
- const { otpId: S, otpEncryptionTargetBundle: T } = await u({ email: e });
281
- t({
282
- otpId: S,
283
- otpEncryptionTargetBundle: T
284
- }), g(60), v(!1);
276
+ const { otpId: I, otpEncryptionTargetBundle: O } = await o({ email: e });
277
+ i({
278
+ otpId: I,
279
+ otpEncryptionTargetBundle: O
280
+ }), u(60), f(!1);
285
281
  } catch {
286
- v(!0);
282
+ f(!0);
287
283
  }
288
- }, U = p <= 0 && !l;
289
- return /* @__PURE__ */ c(A, { children: [
290
- /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:justify-center zd:items-center", children: [
291
- /* @__PURE__ */ c("div", { className: "zd:flex zd:flex-col zd:gap-4", children: [
292
- /* @__PURE__ */ n(m, { className: "zd:text-h2 zd:text-center", children: "Enter verification code" }),
293
- /* @__PURE__ */ c(m, { className: "zd:text-center", children: [
284
+ }, P = y <= 0 && !c;
285
+ return /* @__PURE__ */ d(N, { children: [
286
+ /* @__PURE__ */ d("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:justify-center zd:items-center", children: [
287
+ /* @__PURE__ */ d("div", { className: "zd:flex zd:flex-col zd:gap-4", children: [
288
+ /* @__PURE__ */ t(m, { className: "zd:text-h2 zd:text-center", children: "Enter verification code" }),
289
+ /* @__PURE__ */ d(m, { className: "zd:text-center", children: [
294
290
  "Enter the code from the email we sent to",
295
291
  " ",
296
- /* @__PURE__ */ n(m, { className: "zd:text-solarOrange", children: e })
292
+ /* @__PURE__ */ t(m, { className: "zd:text-solarOrange", children: e })
297
293
  ] })
298
294
  ] }),
299
- /* @__PURE__ */ n(
295
+ /* @__PURE__ */ t(
300
296
  Re,
301
297
  {
302
- onComplete: y,
303
- onChange: () => v(!1),
304
- disabled: x,
305
- error: k,
298
+ onComplete: g,
299
+ onChange: () => f(!1),
300
+ disabled: p,
301
+ error: b,
306
302
  autoFocus: !0
307
303
  }
308
304
  ),
309
- /* @__PURE__ */ n(
310
- E,
305
+ /* @__PURE__ */ t(
306
+ w,
311
307
  {
312
308
  text: "Confirm code",
313
- onClick: C,
314
- disabled: !f.trim() || x
309
+ onClick: x,
310
+ disabled: !h.trim() || p
315
311
  }
316
312
  ),
317
- /* @__PURE__ */ n("div", { className: "zd:flex zd:flex-col zd:gap-1", children: /* @__PURE__ */ c(m, { className: "zd:text-center", children: [
313
+ /* @__PURE__ */ t("div", { className: "zd:flex zd:flex-col zd:gap-1", children: /* @__PURE__ */ d(m, { className: "zd:text-center", children: [
318
314
  "Did not get an email?",
319
315
  " ",
320
- /* @__PURE__ */ n(
316
+ /* @__PURE__ */ t(
321
317
  "button",
322
318
  {
323
319
  type: "button",
324
- disabled: !U,
325
- onClick: H,
320
+ disabled: !P,
321
+ onClick: L,
326
322
  className: "zd:cursor-pointer zd:underline zd:disabled:opacity-50 zd:disabled:cursor-not-allowed",
327
- children: U ? "Resend" : `Resend in ${p} ${p === 1 ? "second" : "seconds"}`
323
+ children: P ? "Resend" : `Resend in ${y} ${y === 1 ? "second" : "seconds"}`
328
324
  }
329
325
  )
330
326
  ] }) })
331
327
  ] }),
332
- /* @__PURE__ */ n(B, { className: "zd:self-center zd:pt-4 zd:pb-6" })
328
+ /* @__PURE__ */ t(T, { className: "zd:self-center zd:pt-4 zd:pb-6" })
333
329
  ] });
334
330
  }
335
- function Be({
331
+ function Oe({
336
332
  termsAndConditionsUrl: e,
337
- privacyPolicyUrl: s,
338
- agreedToTerms: a,
339
- setAgreedToTerms: t,
340
- highlight: r = !1
333
+ privacyPolicyUrl: r,
334
+ agreedToTerms: s,
335
+ setAgreedToTerms: i,
336
+ highlight: n = !1
341
337
  }) {
342
- return /* @__PURE__ */ c("div", { className: "zd:flex zd:flex-col zd:items-center zd:gap-5", children: [
343
- !!(e || s) && /* @__PURE__ */ c(
338
+ return /* @__PURE__ */ d("div", { className: "zd:flex zd:flex-col zd:items-center zd:gap-5", children: [
339
+ !!(e || r) && /* @__PURE__ */ d(
344
340
  "div",
345
341
  {
346
- className: `zd:flex zd:flex-row zd:items-center zd:gap-2 zd:rounded-md zd:p-2 zd:transition-colors ${r ? "zd:border zd:border-negative" : "zd:border zd:border-transparent"}`,
342
+ className: `zd:flex zd:flex-row zd:items-center zd:gap-2 zd:rounded-md zd:p-2 zd:transition-colors ${n ? "zd:border zd:border-negative" : "zd:border zd:border-transparent"}`,
347
343
  children: [
348
- /* @__PURE__ */ n(
344
+ /* @__PURE__ */ t(
349
345
  "input",
350
346
  {
351
347
  type: "checkbox",
352
- checked: a,
353
- onChange: (i) => t(i.target.checked),
348
+ checked: s,
349
+ onChange: (o) => i(o.target.checked),
354
350
  className: "zd:cursor-pointer zd:[color-scheme:light]"
355
351
  }
356
352
  ),
357
- /* @__PURE__ */ c(m, { className: "zd:flex-1", children: [
353
+ /* @__PURE__ */ d(m, { className: "zd:flex-1", children: [
358
354
  "I agree to the",
359
355
  " ",
360
- e && /* @__PURE__ */ n(
356
+ e && /* @__PURE__ */ t(
361
357
  m,
362
358
  {
363
359
  as: "a",
@@ -368,12 +364,12 @@ function Be({
368
364
  children: "Terms & Conditions"
369
365
  }
370
366
  ),
371
- e && s && " and ",
372
- s && /* @__PURE__ */ n(
367
+ e && r && " and ",
368
+ r && /* @__PURE__ */ t(
373
369
  m,
374
370
  {
375
371
  as: "a",
376
- href: s,
372
+ href: r,
377
373
  target: "_blank",
378
374
  rel: "noopener noreferrer",
379
375
  className: "zd:underline",
@@ -384,21 +380,17 @@ function Be({
384
380
  ]
385
381
  }
386
382
  ),
387
- /* @__PURE__ */ n(B, {})
383
+ /* @__PURE__ */ t(T, {})
388
384
  ] });
389
385
  }
390
- const Me = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
391
- function j(e) {
392
- return Me.test(e.trim());
393
- }
394
- const Ue = "" + new URL("blob.webm", import.meta.url).href;
395
- function je({ className: e }) {
396
- return /* @__PURE__ */ n(
386
+ const Be = "" + new URL("blob.webm", import.meta.url).href;
387
+ function Ue({ className: e }) {
388
+ return /* @__PURE__ */ t(
397
389
  "video",
398
390
  {
399
391
  className: e,
400
392
  style: { aspectRatio: "1 / 1" },
401
- src: Ue,
393
+ src: Be,
402
394
  autoPlay: !0,
403
395
  loop: !0,
404
396
  muted: !0,
@@ -408,286 +400,292 @@ function je({ className: e }) {
408
400
  }
409
401
  );
410
402
  }
411
- function _(e) {
412
- return e instanceof Error ? e.name === "AbortError" || e.name === "NotAllowedError" ? !0 : e.message.toLowerCase().includes("oauth popup was closed") : !1;
403
+ const V = se(null);
404
+ function R() {
405
+ const e = oe(V);
406
+ if (!e)
407
+ throw new Error("SignUp.* components must be rendered inside <SignUp>");
408
+ return e;
413
409
  }
414
- function He() {
415
- const { goToStep: e, setEmail: s, setOtpSession: a, config: t, enabledMethods: r } = R(), [d, i] = w(!1), [u, l] = w(!1), [h, x] = w(""), f = (t == null ? void 0 : t.emailAuthMethod) === "otp", { mutateAsync: N, isPending: k } = J(), { mutateAsync: v, isPending: p } = Y(), g = k || p, [C, y] = w(null), { mutateAsync: H, isPending: U } = pe({
416
- mutation: {
417
- onSuccess: async () => {
418
- var o;
419
- e("authenticated"), (o = t == null ? void 0 : t.onSuccess) == null || o.call(t);
420
- },
421
- onError: (o) => {
422
- var z;
423
- (z = t == null ? void 0 : t.onError) == null || z.call(t, o);
410
+ function U(e) {
411
+ const { setAuthPending: r } = R();
412
+ k(() => (r(e), () => r(!1)), [e, r]);
413
+ }
414
+ const Me = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
415
+ function B(e) {
416
+ return Me.test(e.trim());
417
+ }
418
+ function $() {
419
+ const { goToStep: e, setEmail: r, setOtpSession: s } = S(), {
420
+ authPending: i,
421
+ emailAuthMethod: n,
422
+ needsAgreement: a,
423
+ guardAgreement: o,
424
+ setError: c
425
+ } = R(), [l, p] = z(""), h = n === "otp", { mutateAsync: v, isPending: b } = F(), { mutateAsync: f, isPending: y } = W(), u = b || y;
426
+ U(u);
427
+ const x = async () => {
428
+ if (!(!l || i) && B(l) && o()) {
429
+ c(null);
430
+ try {
431
+ const g = h ? v : f, { otpId: L, otpEncryptionTargetBundle: P } = await g({
432
+ email: l
433
+ });
434
+ r(l), s({ otpId: L, otpEncryptionTargetBundle: P }), e(h ? "otp-input" : "email-verification");
435
+ } catch (g) {
436
+ c(
437
+ g instanceof Error ? g.message : "Failed to send verification code"
438
+ );
424
439
  }
425
440
  }
426
- }), { mutate: S, isPending: T } = me({
427
- mutation: {
428
- onSuccess: () => {
429
- var o;
430
- e("authenticated"), (o = t == null ? void 0 : t.onSuccess) == null || o.call(t);
441
+ };
442
+ return /* @__PURE__ */ t(
443
+ Z,
444
+ {
445
+ iconName: "email",
446
+ placeholder: "Enter your email",
447
+ value: l,
448
+ onChange: (g) => p(g.target.value),
449
+ type: "email",
450
+ autoCapitalize: "none",
451
+ autoComplete: "email",
452
+ disabled: i,
453
+ variant: "listItemStyle",
454
+ onKeyDown: (g) => {
455
+ g.key === "Enter" && l && !i && x();
431
456
  },
432
- onError: (o) => {
433
- var z;
434
- _(o) || y(o instanceof Error ? o.message : String(o)), (z = t == null ? void 0 : t.onError) == null || z.call(t, o);
435
- }
457
+ children: u ? /* @__PURE__ */ t("div", { className: "zd:w-13 zd:h-13 zd:flex zd:items-center zd:justify-center", children: /* @__PURE__ */ t("div", { className: "zd:w-5 zd:h-5 zd:border-2 zd:border-solarOrange zd:border-t-transparent zd:rounded-full zd:animate-spin" }) }) : /* @__PURE__ */ t(
458
+ "button",
459
+ {
460
+ type: "button",
461
+ disabled: !B(l) || a,
462
+ className: `zd:w-13 zd:h-13 zd:rounded-2xl zd:flex zd:items-center zd:justify-center zd:transition-colors ${B(l) && !a ? "zd:cursor-pointer" : "zd:cursor-not-allowed zd:opacity-50"}`,
463
+ onClick: () => x(),
464
+ children: /* @__PURE__ */ t(ee, { name: "chevronRight", className: "zd:text-greyScale" })
465
+ }
466
+ )
436
467
  }
437
- }), { mutate: F, isPending: Q } = ze({
468
+ );
469
+ }
470
+ function G(e) {
471
+ return e instanceof Error ? e.name === "AbortError" || e.name === "NotAllowedError" ? !0 : e.message.toLowerCase().includes("oauth popup was closed") : !1;
472
+ }
473
+ function K() {
474
+ const { goToStep: e } = S(), { authPending: r, guardAgreement: s, setError: i } = R(), { mutateAsync: n, isPending: a } = ue({
438
475
  mutation: {
439
476
  onSuccess: () => {
440
- var o;
441
- e("authenticated"), (o = t == null ? void 0 : t.onSuccess) == null || o.call(t);
442
- },
443
- onError: (o) => {
444
- var z;
445
- _(o) || y(o instanceof Error ? o.message : String(o)), (z = t == null ? void 0 : t.onError) == null || z.call(t, o);
477
+ e("authenticated");
446
478
  }
447
479
  }
448
- }), b = U || g || T || Q, L = !!(t != null && t.termsAndConditionsUrl || t != null && t.privacyPolicyUrl) && !d, Z = () => {
449
- if (!b) {
450
- if (L) {
451
- l(!0);
452
- return;
453
- }
454
- y(null), S();
455
- }
456
- }, ee = () => {
457
- if (!b) {
458
- if (L) {
459
- l(!0);
460
- return;
461
- }
462
- y(null), F();
463
- }
464
- }, te = async () => {
465
- if (L) {
466
- l(!0);
467
- return;
468
- }
469
- y(null);
470
- try {
471
- await H({ provider: "google" });
472
- } catch (o) {
473
- const z = o instanceof Error ? o.message : String(o);
474
- _(o) || y(z);
475
- }
476
- }, W = f ? async () => {
477
- if (!(!h || b) && j(h)) {
478
- if (L) {
479
- l(!0);
480
- return;
481
- }
482
- y(null);
483
- try {
484
- const { otpId: o, otpEncryptionTargetBundle: z } = await N({
485
- email: h
486
- });
487
- s(h), a({ otpId: o, otpEncryptionTargetBundle: z }), e("otp-input");
488
- } catch (o) {
489
- y(
490
- o instanceof Error ? o.message : "Failed to send verification code"
491
- );
480
+ });
481
+ return U(a), /* @__PURE__ */ t(
482
+ _,
483
+ {
484
+ icon: /* @__PURE__ */ t(q, { name: "google" }),
485
+ title: "Google",
486
+ trailing: /* @__PURE__ */ t(te, {}),
487
+ disabled: r,
488
+ onClick: async () => {
489
+ if (!r && s()) {
490
+ i(null);
491
+ try {
492
+ await n({ provider: "google" });
493
+ } catch (c) {
494
+ G(c) || i(c instanceof Error ? c.message : String(c));
495
+ }
496
+ }
492
497
  }
493
498
  }
494
- } : async () => {
495
- if (!(!h || b) && j(h)) {
496
- if (L) {
497
- l(!0);
498
- return;
499
- }
500
- y(null);
501
- try {
502
- const { otpId: o, otpEncryptionTargetBundle: z } = await v({
503
- email: h
504
- });
505
- s(h), a({ otpId: o, otpEncryptionTargetBundle: z }), e("email-verification");
506
- } catch (o) {
507
- y(
508
- o instanceof Error ? o.message : "Failed to send verification code"
509
- );
510
- }
499
+ );
500
+ }
501
+ function Y() {
502
+ const { goToStep: e } = S(), { authPending: r, guardAgreement: s, setError: i } = R(), n = {
503
+ onSuccess: () => {
504
+ e("authenticated");
505
+ },
506
+ onError: (h) => {
507
+ G(h) || i(h instanceof Error ? h.message : String(h));
511
508
  }
509
+ }, { mutate: a, isPending: o } = pe({ mutation: n }), { mutate: c, isPending: l } = he({
510
+ mutation: n
511
+ });
512
+ U(o || l);
513
+ const p = (h) => () => {
514
+ r || s() && (i(null), h());
512
515
  };
513
- return C ? /* @__PURE__ */ n("div", { className: "zd:flex zd:items-center zd:justify-center zd:h-full", children: /* @__PURE__ */ c("div", { className: "zd:flex zd:flex-col zd:gap-4 zd:max-w-md", children: [
514
- /* @__PURE__ */ n(m, { className: "zd:text-h2 zd:text-center", children: "Error occurred" }),
515
- /* @__PURE__ */ n(m, { className: "zd:text-center zd:text-red-500", children: C }),
516
- /* @__PURE__ */ n(
517
- E,
516
+ return /* @__PURE__ */ d(N, { children: [
517
+ /* @__PURE__ */ t(
518
+ w,
518
519
  {
519
- action: "primary",
520
- text: "Try again",
521
- onClick: () => y(null)
520
+ action: "secondary",
521
+ text: "Create a passkey",
522
+ iconName: "key",
523
+ trailIcon: !0,
524
+ disabled: r,
525
+ onClick: p(() => a())
526
+ }
527
+ ),
528
+ /* @__PURE__ */ t(
529
+ w,
530
+ {
531
+ action: "secondary",
532
+ text: "Log in with passkey",
533
+ iconName: "key",
534
+ trailIcon: !0,
535
+ disabled: r,
536
+ onClick: p(() => c())
522
537
  }
523
538
  )
524
- ] }) }) : /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:justify-between zd:pb-4 zd:overflow-y-auto zd:overflow-x-hidden", children: [
525
- /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:justify-center", children: [
526
- /* @__PURE__ */ c("div", { className: "zd:px-4 zd:flex zd:flex-col zd:items-center", children: [
527
- /* @__PURE__ */ n("div", { className: "zd:w-full zd:px-16 zd:py-4", children: /* @__PURE__ */ n(je, { className: "zd:w-full zd:pointer-events-none zd:select-none" }) }),
528
- /* @__PURE__ */ n(m, { className: "zd:text-h2 zd:text-center", children: "Continue to your wallet" }),
529
- /* @__PURE__ */ n(m, { className: "zd:mt-2 zd:text-center zd:text-greyScale/50", children: "Choose a sign-in method to proceed" })
530
- ] }),
531
- /* @__PURE__ */ c("div", { className: "zd:mt-6 zd:flex zd:flex-col zd:gap-4 zd:mb-4", children: [
532
- r.includes("passkey") && /* @__PURE__ */ c(A, { children: [
533
- /* @__PURE__ */ c("div", { className: "zd:px-4 zd:flex zd:flex-col zd:gap-2", children: [
534
- /* @__PURE__ */ n(
535
- E,
536
- {
537
- action: "secondary",
538
- text: "Create a passkey",
539
- iconName: "key",
540
- trailIcon: !0,
541
- disabled: b,
542
- onClick: Z
543
- }
544
- ),
545
- /* @__PURE__ */ n(
546
- E,
547
- {
548
- action: "secondary",
549
- text: "Log in with passkey",
550
- iconName: "key",
551
- trailIcon: !0,
552
- disabled: b,
553
- onClick: ee
554
- }
555
- )
556
- ] }),
557
- /* @__PURE__ */ c("div", { className: "zd:flex zd:items-center zd:gap-3", children: [
558
- /* @__PURE__ */ n("div", { className: "zd:h-px zd:flex-1 zd:bg-greyScale/30" }),
559
- /* @__PURE__ */ n(m, { className: "zd:text-body3", children: "or" }),
560
- /* @__PURE__ */ n("div", { className: "zd:h-px zd:flex-1 zd:bg-greyScale/30" })
561
- ] })
562
- ] }),
563
- /* @__PURE__ */ c("div", { className: "zd:px-4 zd:flex zd:flex-col zd:gap-2", children: [
564
- r.includes("google") && /* @__PURE__ */ n(
565
- $,
539
+ ] });
540
+ }
541
+ function J({
542
+ children: e,
543
+ termsAndConditionsUrl: r,
544
+ privacyPolicyUrl: s,
545
+ emailAuthMethod: i = "magicLink"
546
+ }) {
547
+ const [n, a] = z(!1), [o, c] = z(!1), [l, p] = z(null), [h, v] = z(!1), f = !!(r || s) && !n, y = () => f ? (c(!0), !1) : !0;
548
+ return /* @__PURE__ */ d(
549
+ V.Provider,
550
+ {
551
+ value: {
552
+ authPending: h,
553
+ emailAuthMethod: i,
554
+ setAuthPending: v,
555
+ needsAgreement: f,
556
+ guardAgreement: y,
557
+ setError: p
558
+ },
559
+ children: [
560
+ l !== null && /* @__PURE__ */ t("div", { className: "zd:flex zd:items-center zd:justify-center zd:h-full", children: /* @__PURE__ */ d("div", { className: "zd:flex zd:flex-col zd:gap-4 zd:max-w-md", children: [
561
+ /* @__PURE__ */ t(m, { className: "zd:text-h2 zd:text-center", children: "Error occurred" }),
562
+ /* @__PURE__ */ t(m, { className: "zd:text-center zd:text-red-500", children: l }),
563
+ /* @__PURE__ */ t(
564
+ w,
566
565
  {
567
- icon: /* @__PURE__ */ n(D, { name: "google" }),
568
- title: "Google",
569
- trailing: /* @__PURE__ */ n(re, {}),
570
- className: "zd:rounded-3xl",
571
- disabled: b,
572
- onClick: te
566
+ action: "primary",
567
+ text: "Try again",
568
+ onClick: () => p(null)
573
569
  }
574
- ),
575
- r.includes("email") && /* @__PURE__ */ n(
576
- se,
577
- {
578
- iconName: "email",
579
- placeholder: "Enter your email",
580
- value: h,
581
- onChange: (o) => x(o.target.value),
582
- type: "email",
583
- autoCapitalize: "none",
584
- autoComplete: "email",
585
- disabled: b,
586
- variant: "listItemStyle",
587
- containerClassName: "zd:rounded-3xl",
588
- onKeyDown: (o) => {
589
- o.key === "Enter" && h && !b && W();
590
- },
591
- children: g ? /* @__PURE__ */ n("div", { className: "zd:w-13 zd:h-13 zd:flex zd:items-center zd:justify-center", children: /* @__PURE__ */ n("div", { className: "zd:w-5 zd:h-5 zd:border-2 zd:border-solarOrange zd:border-t-transparent zd:rounded-full zd:animate-spin" }) }) : /* @__PURE__ */ n(
592
- "button",
570
+ )
571
+ ] }) }),
572
+ /* @__PURE__ */ d(
573
+ "div",
574
+ {
575
+ className: `zd:flex-1 zd:flex zd:flex-col zd:justify-between zd:pb-4 zd:overflow-y-auto zd:overflow-x-hidden${l !== null ? " zd:hidden" : ""}`,
576
+ children: [
577
+ /* @__PURE__ */ d("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:justify-center", children: [
578
+ /* @__PURE__ */ d("div", { className: "zd:px-4 zd:flex zd:flex-col zd:items-center", children: [
579
+ /* @__PURE__ */ t("div", { className: "zd:w-full zd:px-16 zd:py-4", children: /* @__PURE__ */ t(Ue, { className: "zd:w-full zd:pointer-events-none zd:select-none" }) }),
580
+ /* @__PURE__ */ t(m, { className: "zd:text-h2 zd:text-center", children: "Continue to your wallet" }),
581
+ /* @__PURE__ */ t(m, { className: "zd:mt-2 zd:text-center zd:text-greyScale/50", children: "Choose a sign-in method to proceed" })
582
+ ] }),
583
+ /* @__PURE__ */ t("div", { className: "zd:mt-6 zd:mb-4 zd:px-4 zd:flex zd:flex-col zd:gap-2", children: e })
584
+ ] }),
585
+ /* @__PURE__ */ t("div", { className: "zd:px-4", children: /* @__PURE__ */ t(
586
+ Oe,
593
587
  {
594
- type: "button",
595
- disabled: !j(h) || L,
596
- className: `zd:w-13 zd:h-13 zd:rounded-2xl zd:flex zd:items-center zd:justify-center zd:transition-colors ${j(h) && !L ? "zd:cursor-pointer" : "zd:cursor-not-allowed zd:opacity-50"}`,
597
- onClick: () => W(),
598
- children: /* @__PURE__ */ n(ie, { name: "chevronRight", className: "zd:text-greyScale" })
588
+ termsAndConditionsUrl: r,
589
+ privacyPolicyUrl: s,
590
+ agreedToTerms: n,
591
+ setAgreedToTerms: (u) => {
592
+ a(u), u && c(!1);
593
+ },
594
+ highlight: o
599
595
  }
600
- )
601
- }
602
- )
603
- ] })
604
- ] })
605
- ] }),
606
- /* @__PURE__ */ n("div", { className: "zd:px-4", children: /* @__PURE__ */ n(
607
- Be,
608
- {
609
- termsAndConditionsUrl: t == null ? void 0 : t.termsAndConditionsUrl,
610
- privacyPolicyUrl: t == null ? void 0 : t.privacyPolicyUrl,
611
- agreedToTerms: d,
612
- setAgreedToTerms: (o) => {
613
- i(o), o && l(!1);
614
- },
615
- highlight: u
616
- }
617
- ) })
596
+ ) })
597
+ ]
598
+ }
599
+ )
600
+ ]
601
+ }
602
+ );
603
+ }
604
+ function X({ label: e = "or" }) {
605
+ return /* @__PURE__ */ d("div", { className: "zd:-mx-4 zd:my-2 zd:flex zd:items-center zd:gap-3", children: [
606
+ /* @__PURE__ */ t("div", { className: "zd:h-px zd:flex-1 zd:bg-greyScale/30" }),
607
+ /* @__PURE__ */ t(m, { className: "zd:text-body3", children: e }),
608
+ /* @__PURE__ */ t("div", { className: "zd:h-px zd:flex-1 zd:bg-greyScale/30" })
618
609
  ] });
619
610
  }
620
- function Fe() {
621
- return typeof window > "u" ? null : new URLSearchParams(window.location.search).get("code");
611
+ function je(e) {
612
+ return /* @__PURE__ */ d(J, { ...e, children: [
613
+ /* @__PURE__ */ t(Y, {}),
614
+ /* @__PURE__ */ t(X, {}),
615
+ /* @__PURE__ */ t(K, {}),
616
+ /* @__PURE__ */ t($, {})
617
+ ] });
622
618
  }
619
+ const He = Object.assign(J, {
620
+ Default: je,
621
+ Passkey: Y,
622
+ Google: K,
623
+ Email: $,
624
+ Divider: X
625
+ });
623
626
  function _e() {
624
- const {
625
- otpId: e,
626
- otpEncryptionTargetBundle: s,
627
- goToStep: a,
628
- clearOtpSession: t,
629
- config: r
630
- } = R(), [d] = w(Fe), [i, u] = w(null), l = K(!1), { mutate: h, isPending: x } = fe({
627
+ return typeof window > "u" ? null : new URLSearchParams(window.location.search).get("code");
628
+ }
629
+ function qe() {
630
+ const { otpId: e, otpEncryptionTargetBundle: r, goToStep: s, clearOtpSession: i } = S(), [n] = z(_e), [a, o] = z(null), c = D(!1), { mutate: l, isPending: p } = me({
631
631
  mutation: {
632
- onSuccess: async () => {
633
- var f;
634
- t(), a("authenticated"), (f = r == null ? void 0 : r.onSuccess) == null || f.call(r);
632
+ onSuccess: () => {
633
+ i(), s("authenticated");
635
634
  },
636
- onError: (f) => {
637
- var N;
638
- u(f), (N = r == null ? void 0 : r.onError) == null || N.call(r, f);
635
+ onError: (h) => {
636
+ o(h);
639
637
  }
640
638
  }
641
639
  });
642
- return O(() => {
643
- if (!(l.current || !d)) {
644
- if (l.current = !0, !e || !s) {
645
- M(), a(null);
640
+ return k(() => {
641
+ if (!(c.current || !n)) {
642
+ if (c.current = !0, !e || !r) {
643
+ A(), s(null);
646
644
  return;
647
645
  }
648
- h({ otpId: e, code: d, otpEncryptionTargetBundle: s });
646
+ l({ otpId: e, code: n, otpEncryptionTargetBundle: r });
649
647
  }
650
- }, [e, s, d, h, a]), /* @__PURE__ */ c(A, { children: [
651
- /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:items-center zd:justify-center", children: [
652
- !i && x && /* @__PURE__ */ n(P, { imageName: "loading", title: "Verifying Your Email", children: "Please wait while we securely connect your wallet." }),
653
- !i && !d && !x && /* @__PURE__ */ c(A, { children: [
654
- /* @__PURE__ */ c(P, { imageName: "error", title: "Invalid Link", children: [
648
+ }, [e, r, n, l, s]), /* @__PURE__ */ d(N, { children: [
649
+ /* @__PURE__ */ d("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:items-center zd:justify-center", children: [
650
+ !a && p && /* @__PURE__ */ t(E, { imageName: "loading", title: "Verifying Your Email", children: "Please wait while we securely connect your wallet." }),
651
+ !a && !n && !p && /* @__PURE__ */ d(N, { children: [
652
+ /* @__PURE__ */ d(E, { imageName: "error", title: "Invalid Link", children: [
655
653
  "This verification link is invalid or incomplete.",
656
- /* @__PURE__ */ n("br", {}),
654
+ /* @__PURE__ */ t("br", {}),
657
655
  "Please check your email and try again with the correct link."
658
656
  ] }),
659
- /* @__PURE__ */ n(
660
- E,
657
+ /* @__PURE__ */ t(
658
+ w,
661
659
  {
662
660
  action: "primary",
663
661
  onClick: () => {
664
- M(), a("sign-up");
662
+ A(), s("sign-up");
665
663
  },
666
664
  text: "Choose another sign-in method"
667
665
  }
668
666
  )
669
667
  ] }),
670
- i != null && /* @__PURE__ */ c(A, { children: [
671
- /* @__PURE__ */ n(P, { imageName: "error", title: "Oops, something went wrong", children: "We couldn't complete the sign-in process. This could be due to timeout, an expired link, or a cancelled request." }),
672
- /* @__PURE__ */ n(
673
- E,
668
+ a != null && /* @__PURE__ */ d(N, { children: [
669
+ /* @__PURE__ */ t(E, { imageName: "error", title: "Oops, something went wrong", children: "We couldn't complete the sign-in process. This could be due to timeout, an expired link, or a cancelled request." }),
670
+ /* @__PURE__ */ t(
671
+ w,
674
672
  {
675
673
  action: "primary",
676
674
  onClick: () => {
677
- M(), a("sign-up");
675
+ A(), s("sign-up");
678
676
  },
679
677
  text: "Choose another sign-in method"
680
678
  }
681
679
  )
682
680
  ] })
683
681
  ] }),
684
- /* @__PURE__ */ n(B, { className: "zd:self-center zd:pt-4 zd:pb-6" })
682
+ /* @__PURE__ */ t(T, { className: "zd:self-center zd:pt-4 zd:pb-6" })
685
683
  ] });
686
684
  }
687
- function qe() {
688
- const { goToStep: e } = R(), { connect: s, connectors: a, isPending: t } = ue(), r = a.filter((i) => i.id !== "zerodev-wallet"), d = (i) => {
689
- s(
690
- { connector: i },
685
+ function De() {
686
+ const { goToStep: e } = S(), { connect: r, connectors: s, isPending: i } = ce(), n = s.filter((o) => o.id !== "zerodev-wallet"), a = (o) => {
687
+ r(
688
+ { connector: o },
691
689
  {
692
690
  onSuccess: () => {
693
691
  e(null);
@@ -695,104 +693,107 @@ function qe() {
695
693
  }
696
694
  );
697
695
  };
698
- return /* @__PURE__ */ c(A, { children: [
699
- /* @__PURE__ */ c("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:justify-center", children: [
700
- /* @__PURE__ */ n(m, { className: "zd:text-h2 zd:text-center", children: "Select your wallet" }),
701
- /* @__PURE__ */ n("div", { className: "zd:flex zd:flex-col zd:gap-2", children: r.length === 0 ? /* @__PURE__ */ n(m, { className: "zd:text-center", children: "No wallets detected. Install a browser wallet extension to continue." }) : r.map((i) => /* @__PURE__ */ n(
702
- $,
696
+ return /* @__PURE__ */ d(N, { children: [
697
+ /* @__PURE__ */ d("div", { className: "zd:flex-1 zd:flex zd:flex-col zd:gap-8 zd:justify-center", children: [
698
+ /* @__PURE__ */ t(m, { className: "zd:text-h2 zd:text-center", children: "Select your wallet" }),
699
+ /* @__PURE__ */ t("div", { className: "zd:flex zd:flex-col zd:gap-2", children: n.length === 0 ? /* @__PURE__ */ t(m, { className: "zd:text-center", children: "No wallets detected. Install a browser wallet extension to continue." }) : n.map((o) => /* @__PURE__ */ t(
700
+ _,
703
701
  {
704
- title: i.name,
705
- icon: i.icon ? /* @__PURE__ */ n(
702
+ title: o.name,
703
+ icon: o.icon ? /* @__PURE__ */ t(
706
704
  "img",
707
705
  {
708
- src: i.icon,
706
+ src: o.icon,
709
707
  alt: "",
710
708
  className: "zd:w-6 zd:h-6"
711
709
  }
712
- ) : /* @__PURE__ */ n(D, { name: "walletOutline" }),
713
- disabled: t,
714
- onClick: () => d(i),
710
+ ) : /* @__PURE__ */ t(q, { name: "walletOutline" }),
711
+ disabled: i,
712
+ onClick: () => a(o),
715
713
  className: "zd:rounded-3xl"
716
714
  },
717
- i.uid
715
+ o.uid
718
716
  )) })
719
717
  ] }),
720
- /* @__PURE__ */ n(B, { className: "zd:self-center zd:pt-4 zd:pb-6" })
718
+ /* @__PURE__ */ t(T, { className: "zd:self-center zd:pt-4 zd:pb-6" })
721
719
  ] });
722
720
  }
723
721
  const We = {
724
722
  "wallet-selection": "Choose your wallet"
725
723
  };
726
- function Ve() {
727
- return /* @__PURE__ */ n("div", { className: "zd:flex zd:flex-1 zd:items-center zd:justify-center", children: /* @__PURE__ */ n(P, { imageName: "loading", title: "Authenticating...", children: "Please wait while we complete the OAuth authentication." }) });
724
+ function Fe() {
725
+ return /* @__PURE__ */ t("div", { className: "zd:flex zd:flex-1 zd:items-center zd:justify-center", children: /* @__PURE__ */ t(E, { imageName: "loading", title: "Authenticating...", children: "Please wait while we complete the OAuth authentication." }) });
728
726
  }
729
- function Ge() {
730
- return /* @__PURE__ */ n("div", { className: "zd:flex zd:flex-1 zd:items-center zd:justify-center", children: /* @__PURE__ */ n(P, { imageName: "loading", title: "Passkey authentication", children: "Please authenticate with your passkey." }) });
727
+ function Ve() {
728
+ return /* @__PURE__ */ t("div", { className: "zd:flex zd:flex-1 zd:items-center zd:justify-center", children: /* @__PURE__ */ t(E, { imageName: "loading", title: "Passkey authentication", children: "Please authenticate with your passkey." }) });
731
729
  }
732
- function $e(e) {
730
+ function $e(e, r) {
733
731
  switch (e) {
734
732
  case "sign-up":
735
- return /* @__PURE__ */ n(He, {});
733
+ return r ? r() : /* @__PURE__ */ t(He.Default, {});
736
734
  case "email-verification":
737
- return /* @__PURE__ */ n(Ee, {});
735
+ return /* @__PURE__ */ t(be, {});
738
736
  case "otp-input":
739
- return /* @__PURE__ */ n(Oe, {});
737
+ return /* @__PURE__ */ t(Le, {});
740
738
  case "verifying-otp":
741
- return /* @__PURE__ */ n(_e, {});
739
+ return /* @__PURE__ */ t(qe, {});
742
740
  case "oauth-in-progress":
743
- return /* @__PURE__ */ n(Ve, {});
741
+ return /* @__PURE__ */ t(Fe, {});
744
742
  case "passkey-prompt":
745
- return /* @__PURE__ */ n(Ge, {});
743
+ return /* @__PURE__ */ t(Ve, {});
746
744
  case "wallet-selection":
747
- return /* @__PURE__ */ n(qe, {});
745
+ return /* @__PURE__ */ t(De, {});
748
746
  case "error":
749
- return /* @__PURE__ */ n(Te, {});
747
+ return /* @__PURE__ */ t(ke, {});
750
748
  default:
751
749
  return null;
752
750
  }
753
751
  }
754
- function lt({
752
+ function st({
755
753
  onClose: e,
756
- size: s
754
+ size: r,
755
+ renderSignUp: s,
756
+ logo: i
757
757
  } = {}) {
758
- const { step: a, goToStep: t, goBack: r, reset: d } = R(), i = I(X(), (x) => x.logo);
759
- O(() => {
760
- a === null && ke() && t("verifying-otp");
761
- }, [a, t]);
762
- const u = $e(a);
763
- if (!u) return null;
764
- const l = () => {
765
- M(), d(), e == null || e();
766
- }, h = a ? We[a] : void 0;
767
- return /* @__PURE__ */ n(
768
- ae,
758
+ const { step: n, goToStep: a, goBack: o, reset: c } = S();
759
+ k(() => {
760
+ n === null && Ee() && a("verifying-otp");
761
+ }, [n, a]);
762
+ const l = $e(n, s);
763
+ if (!l) return null;
764
+ const p = () => {
765
+ A(), c(), e == null || e();
766
+ }, h = n ? We[n] : void 0;
767
+ return /* @__PURE__ */ t(
768
+ ne,
769
769
  {
770
- ...s && { size: s },
771
- contentClassName: a === "sign-up" ? "zd:px-0" : void 0,
772
- topNav: /* @__PURE__ */ n(
773
- oe,
770
+ ...r && { size: r },
771
+ className: n === "sign-up" ? "zd:h-auto zd:max-h-202.5" : void 0,
772
+ contentClassName: n === "sign-up" ? "zd:px-0" : void 0,
773
+ topNav: /* @__PURE__ */ t(
774
+ re,
774
775
  {
775
- ...r !== null && { onLeftButtonClick: r },
776
- onRightButtonClick: l,
776
+ ...o !== null && { onLeftButtonClick: o },
777
+ onRightButtonClick: p,
777
778
  ...h && { title: h },
778
- ...a === "sign-up" && {
779
+ ...n === "sign-up" && {
779
780
  ...i && { logo: i },
780
781
  className: "zd:px-4"
781
782
  }
782
783
  }
783
784
  ),
784
- children: u
785
+ children: l
785
786
  }
786
787
  );
787
788
  }
788
- const q = "zerodev:auth:otpSession";
789
- function De() {
789
+ const M = "zerodev:auth:otpSession";
790
+ function Ge() {
790
791
  if (typeof window > "u") return null;
791
792
  try {
792
- const e = window.localStorage.getItem(q);
793
+ const e = window.localStorage.getItem(M);
793
794
  if (!e) return null;
794
- const s = JSON.parse(e);
795
- return !(s != null && s.otpId) || !(s != null && s.otpEncryptionTargetBundle) ? null : s;
795
+ const r = JSON.parse(e);
796
+ return !(r != null && r.otpId) || !(r != null && r.otpEncryptionTargetBundle) ? null : r;
796
797
  } catch {
797
798
  return null;
798
799
  }
@@ -801,69 +802,63 @@ function Ke(e) {
801
802
  if (!(typeof window > "u"))
802
803
  try {
803
804
  window.localStorage.setItem(
804
- q,
805
+ M,
805
806
  JSON.stringify(e)
806
807
  );
807
808
  } catch {
808
809
  }
809
810
  }
810
- function V() {
811
+ function j() {
811
812
  if (!(typeof window > "u"))
812
813
  try {
813
- window.localStorage.removeItem(q);
814
+ window.localStorage.removeItem(M);
814
815
  } catch {
815
816
  }
816
817
  }
817
- const Ye = (e, s, a) => ({
818
+ const Ye = (e, r, s) => ({
818
819
  auth: {
819
820
  // Initial state
820
821
  step: null,
821
822
  stepHistory: [],
822
- enabledMethods: [],
823
823
  email: null,
824
824
  otpId: null,
825
825
  otpEncryptionTargetBundle: null,
826
- config: null,
827
826
  // Actions
828
- initialize: (t) => {
829
- const r = De();
830
- e((d) => ({
827
+ initialize: () => {
828
+ const i = Ge();
829
+ i && e((n) => ({
831
830
  auth: {
832
- ...d.auth,
833
- config: t,
834
- enabledMethods: t.enabledMethods,
835
- ...r && {
836
- otpId: r.otpId,
837
- otpEncryptionTargetBundle: r.otpEncryptionTargetBundle
838
- }
831
+ ...n.auth,
832
+ otpId: i.otpId,
833
+ otpEncryptionTargetBundle: i.otpEncryptionTargetBundle
839
834
  }
840
835
  }));
841
836
  },
842
- goToStep: (t) => {
843
- e((r) => ({
837
+ goToStep: (i) => {
838
+ e((n) => ({
844
839
  auth: {
845
- ...r.auth,
846
- step: t,
847
- stepHistory: r.auth.step === null ? r.auth.stepHistory : [...r.auth.stepHistory, r.auth.step]
840
+ ...n.auth,
841
+ step: i,
842
+ stepHistory: n.auth.step === null ? n.auth.stepHistory : [...n.auth.stepHistory, n.auth.step]
848
843
  }
849
844
  }));
850
845
  },
851
846
  goBack: () => {
852
- const { auth: t } = s();
853
- if (t.stepHistory.length === 0) return;
854
- const r = [...t.stepHistory], d = r.pop();
855
- e((i) => ({
847
+ const { auth: i } = r();
848
+ if (i.stepHistory.length === 0) return;
849
+ const n = [...i.stepHistory], a = n.pop();
850
+ e((o) => ({
856
851
  auth: {
857
- ...i.auth,
858
- step: d,
859
- stepHistory: r
852
+ ...o.auth,
853
+ step: a,
854
+ stepHistory: n
860
855
  }
861
856
  }));
862
857
  },
863
858
  reset: () => {
864
- V(), e((t) => ({
859
+ j(), e((i) => ({
865
860
  auth: {
866
- ...t.auth,
861
+ ...i.auth,
867
862
  step: null,
868
863
  stepHistory: [],
869
864
  email: null,
@@ -872,95 +867,93 @@ const Ye = (e, s, a) => ({
872
867
  }
873
868
  }));
874
869
  },
875
- setEmail: (t) => {
876
- e((r) => ({
870
+ setEmail: (i) => {
871
+ e((n) => ({
877
872
  auth: {
878
- ...r.auth,
879
- email: t
873
+ ...n.auth,
874
+ email: i
880
875
  }
881
876
  }));
882
877
  },
883
- setOtpSession: ({ otpId: t, otpEncryptionTargetBundle: r }) => {
884
- Ke({ otpId: t, otpEncryptionTargetBundle: r }), e((d) => ({
878
+ setOtpSession: ({ otpId: i, otpEncryptionTargetBundle: n }) => {
879
+ Ke({ otpId: i, otpEncryptionTargetBundle: n }), e((a) => ({
885
880
  auth: {
886
- ...d.auth,
887
- otpId: t,
888
- otpEncryptionTargetBundle: r
881
+ ...a.auth,
882
+ otpId: i,
883
+ otpEncryptionTargetBundle: n
889
884
  }
890
885
  }));
891
886
  },
892
887
  clearOtpSession: () => {
893
- V(), e((t) => ({
888
+ j(), e((i) => ({
894
889
  auth: {
895
- ...t.auth,
890
+ ...i.auth,
896
891
  otpId: null,
897
892
  otpEncryptionTargetBundle: null
898
893
  }
899
894
  }));
900
895
  }
901
896
  }
902
- }), Je = (e = {}) => de()(
903
- xe((s, a, t) => ({
897
+ }), Je = () => ae()(
898
+ ze((e, r, s) => ({
904
899
  pendingRequests: [],
905
900
  userConfirmationListenerActive: !1,
906
- logo: e.logo ?? null,
907
- addPendingRequest: (r) => s((d) => ({
908
- pendingRequests: [...d.pendingRequests, r]
901
+ addPendingRequest: (i) => e((n) => ({
902
+ pendingRequests: [...n.pendingRequests, i]
909
903
  })),
910
- removePendingRequest: (r) => s((d) => ({
911
- pendingRequests: d.pendingRequests.filter((i) => i.id !== r)
904
+ removePendingRequest: (i) => e((n) => ({
905
+ pendingRequests: n.pendingRequests.filter((a) => a.id !== i)
912
906
  })),
913
- clearPendingRequests: () => s({ pendingRequests: [] }),
914
- setUserConfirmationListenerActive: (r) => s({ userConfirmationListenerActive: r }),
915
- ...Ye(s, a)
907
+ clearPendingRequests: () => e({ pendingRequests: [] }),
908
+ setUserConfirmationListenerActive: (i) => e({ userConfirmationListenerActive: i }),
909
+ ...Ye(e, r)
916
910
  }))
917
911
  );
918
912
  function Xe(e) {
919
- return new Promise((s, a) => {
920
- const t = e.subscribe(
921
- (r) => r.auth.step,
922
- (r) => {
923
- r === "authenticated" ? (t(), s()) : r === null && (t(), a(new Error("Auth flow dismissed")));
913
+ return new Promise((r, s) => {
914
+ const i = e.subscribe(
915
+ (n) => n.auth.step,
916
+ (n) => {
917
+ n === "authenticated" ? (i(), r()) : n === null && (i(), s(new Error("Auth flow dismissed")));
924
918
  }
925
919
  );
926
920
  });
927
921
  }
928
- function dt(e) {
929
- var t, r;
930
- const s = ge(e), a = Je({ logo: (t = e.config) == null ? void 0 : t.logo });
931
- return (r = e.config) != null && r.auth && a.getState().auth.initialize(e.config.auth), (d) => {
932
- const i = s(d);
922
+ function ot(e) {
923
+ const r = fe(e), s = Je();
924
+ return (i) => {
925
+ const n = r(i);
933
926
  return {
934
- ...i,
935
- async connect(u) {
936
- var l;
927
+ ...n,
928
+ async connect(a) {
937
929
  try {
938
- return await i.connect(u);
939
- } catch (h) {
940
- if (u != null && u.isReconnecting || !((l = e.config) != null && l.auth) || !(h instanceof ye))
941
- throw h;
942
- if (a.getState().auth.step !== null)
930
+ return await n.connect(a);
931
+ } catch (o) {
932
+ if (a != null && a.isReconnecting || !(o instanceof ge))
933
+ throw o;
934
+ if (s.getState().auth.step !== null)
943
935
  throw new Error("Auth flow already in progress");
944
- return a.getState().auth.goToStep("sign-up"), await Xe(a), i.connect(u);
936
+ return s.getState().auth.goToStep("sign-up"), await Xe(s), n.connect(a);
945
937
  }
946
938
  },
947
939
  async disconnect() {
948
- var u, l;
949
- await ((u = i.disconnect) == null ? void 0 : u.call(i)), (l = e.config) != null && l.auth && a.getState().auth.reset();
940
+ var a;
941
+ await ((a = n.disconnect) == null ? void 0 : a.call(n)), s.getState().auth.reset();
950
942
  },
951
943
  async setup() {
952
- var u;
953
- await ((u = i.setup) == null ? void 0 : u.call(i)), typeof window > "u";
944
+ var a;
945
+ await ((a = n.setup) == null ? void 0 : a.call(n)), !(typeof window > "u") && s.getState().auth.initialize();
954
946
  },
955
947
  getKitStore() {
956
- return a;
948
+ return s;
957
949
  }
958
950
  };
959
951
  };
960
952
  }
961
953
  export {
962
- lt as AuthFlow,
963
- R as useAuth,
964
- dt as zeroDevWallet
954
+ st as ConnectWallet,
955
+ He as SignUp,
956
+ S as useAuth,
957
+ ot as zeroDevWallet
965
958
  };
966
959
  //# sourceMappingURL=index.mjs.map