@levo-so/studio 0.1.81 → 0.1.82

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 (47) hide show
  1. package/dist/{BillingStep-BbQdIZN7.js → BillingStep-DcZbhRY9.js} +1 -1
  2. package/dist/{MessageCard-BIF1Gvn5.js → MessageCard-B-uaKUq5.js} +1 -1
  3. package/dist/components/LoginForm/AuthMethodRenderer.d.ts +1 -0
  4. package/dist/components/LoginForm/AuthMethodRenderer.d.ts.map +1 -1
  5. package/dist/components/LoginForm/MagicLinkAuthForm.d.ts +1 -0
  6. package/dist/components/LoginForm/MagicLinkAuthForm.d.ts.map +1 -1
  7. package/dist/components/LoginForm/OtpAuthForm.d.ts +5 -1
  8. package/dist/components/LoginForm/OtpAuthForm.d.ts.map +1 -1
  9. package/dist/components/LoginForm/WhatsAppAuthForm.d.ts +5 -1
  10. package/dist/components/LoginForm/WhatsAppAuthForm.d.ts.map +1 -1
  11. package/dist/components/LoginForm/index.d.ts +1 -0
  12. package/dist/components/LoginForm/index.d.ts.map +1 -1
  13. package/dist/components/accessCard/LoginCard/index.d.ts.map +1 -1
  14. package/dist/components/accessCard/PendingApprovalCard/index.d.ts +11 -0
  15. package/dist/components/accessCard/PendingApprovalCard/index.d.ts.map +1 -0
  16. package/dist/components/withBlockProps.d.ts.map +1 -1
  17. package/dist/constants/authentication.d.ts +4 -0
  18. package/dist/constants/authentication.d.ts.map +1 -1
  19. package/dist/contentEngine/head_code.d.ts.map +1 -1
  20. package/dist/core/LevoBlock.d.ts +2 -2
  21. package/dist/core/LevoBlock.d.ts.map +1 -1
  22. package/dist/core/LevoPage.d.ts +2 -0
  23. package/dist/core/LevoPage.d.ts.map +1 -1
  24. package/dist/elements/forum/ForumPost.d.ts +3 -2
  25. package/dist/elements/forum/ForumPost.d.ts.map +1 -1
  26. package/dist/elements/forum/comments/Comments.d.ts.map +1 -1
  27. package/dist/elements/forum/utility/index.d.ts +2 -2
  28. package/dist/elements/forum/utility/index.d.ts.map +1 -1
  29. package/dist/{index-DCDaZb-C.js → index-BM9B_-Oa.js} +2 -2
  30. package/dist/{index-BMInQJyD.js → index-Btn2IEPB.js} +1 -1
  31. package/dist/{index-Cch5jWlo.js → index-CjQJ_4Xf.js} +2 -2
  32. package/dist/{index-BHRWOQZs.js → index-D6LjzTKx.js} +2 -2
  33. package/dist/{index-Ch9QPTz1.js → index-DvqlCYn2.js} +345 -321
  34. package/dist/index-ekxl-RSq.js +43 -0
  35. package/dist/index-qvImrx6Q.js +83 -0
  36. package/dist/index-vtvLeTPv.js +793 -0
  37. package/dist/index.js +111 -109
  38. package/dist/interfaces/block.d.ts +1 -1
  39. package/dist/interfaces/block.d.ts.map +1 -1
  40. package/dist/interfaces/sites.d.ts +1 -0
  41. package/dist/interfaces/sites.d.ts.map +1 -1
  42. package/dist/pixel/propertyMap.d.ts +1 -1
  43. package/dist/pixel/propertyMap.d.ts.map +1 -1
  44. package/dist/studio.css +1 -1
  45. package/package.json +10 -8
  46. package/dist/index-BJBZFS85.js +0 -35
  47. package/dist/index-BuNQ7dUE.js +0 -765
@@ -1,765 +0,0 @@
1
- "use client";
2
- import { jsx as e, jsxs as l, Fragment as q } from "react/jsx-runtime";
3
- import { useLevo as Q, LevoOAuth as I, successToast as X, errorHandler as Z } from "@levo-so/react";
4
- import { useState as _, useEffect as G, useRef as R, useMemo as F } from "react";
5
- import { g as $, A as ee } from "./index-Ch9QPTz1.js";
6
- import { getLevoError as B } from "@levo-so/core";
7
- import { useFormik as A } from "formik";
8
- import { parsePhoneNumberWithError as te } from "libphonenumber-js";
9
- import * as k from "yup";
10
- import ne from "react-otp-input";
11
- import { ChevronDown as re } from "lucide-react";
12
- import { Popover as L } from "radix-ui";
13
- import { usePhoneInput as oe, defaultCountries as P, parseCountry as M, FlagImage as j } from "react-international-phone";
14
- const z = k.string().required("Email is required").email("Please enter a valid email address").trim(), H = k.string().required("Please enter the verification code").length(4, "Verification code must be 4 digits").matches(/^\d+$/, "Verification code must contain only numbers"), U = k.string().required("Phone number is required").test("phone", "The phone number has incorrect format", (o) => {
15
- if (!o) return !1;
16
- try {
17
- return te(o)?.isValid() ?? !1;
18
- } catch {
19
- return !1;
20
- }
21
- }), K = k.object({
22
- email: z
23
- }), ie = k.object({
24
- email: z,
25
- otp: H
26
- }), se = k.object({
27
- phone: U
28
- }), ae = k.object({
29
- phone: U,
30
- otp: H
31
- }), le = K, ce = "_button_1je4h_2", de = "_content_1je4h_70", ue = "_icon_1je4h_77", me = "_spinner_1je4h_89", pe = "_iconEnter_1je4h_103", he = "_text_1je4h_119", N = {
32
- button: ce,
33
- content: de,
34
- icon: ue,
35
- spinner: me,
36
- iconEnter: pe,
37
- text: he
38
- }, E = ({
39
- className: o,
40
- children: c,
41
- isLoading: t = !1,
42
- isError: a = !1,
43
- loadingText: u = "Loading...",
44
- successText: s = "Success!",
45
- errorText: r = "Error!",
46
- variant: h = "default",
47
- size: p = "default",
48
- disabled: n,
49
- ...y
50
- }) => {
51
- const [v, i] = _(!1), [g, C] = _(!1), [S, m] = _(t);
52
- G(() => {
53
- if (S && !t)
54
- if (a) {
55
- C(!0);
56
- const T = setTimeout(() => {
57
- C(!1);
58
- }, 2e3);
59
- return () => clearTimeout(T);
60
- } else {
61
- i(!0);
62
- const T = setTimeout(() => {
63
- i(!1);
64
- }, 2e3);
65
- return () => clearTimeout(T);
66
- }
67
- m(t);
68
- }, [t, S, a]);
69
- const f = () => t ? u : v ? s : g ? r : c, V = () => g ? "destructive" : v ? "success" : h, w = () => t ? /* @__PURE__ */ e("div", { className: `${N.icon} ${N.iconEnter}`, children: /* @__PURE__ */ e("svg", { className: N.spinner, viewBox: "0 0 24 24", children: /* @__PURE__ */ e(
70
- "circle",
71
- {
72
- cx: "12",
73
- cy: "12",
74
- r: "10",
75
- stroke: "currentColor",
76
- strokeWidth: "4",
77
- fill: "none",
78
- strokeDasharray: "32",
79
- strokeDashoffset: "32"
80
- }
81
- ) }) }) : v && !t ? /* @__PURE__ */ e("div", { className: `${N.icon} ${N.iconEnter}`, children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
82
- /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", fill: "currentColor" }),
83
- /* @__PURE__ */ e(
84
- "path",
85
- {
86
- d: "m9 12 2 2 4-4",
87
- stroke: "white",
88
- strokeWidth: "2",
89
- fill: "none",
90
- strokeLinecap: "round",
91
- strokeLinejoin: "round"
92
- }
93
- )
94
- ] }) }) : g && !t ? /* @__PURE__ */ e("div", { className: `${N.icon} ${N.iconEnter}`, children: /* @__PURE__ */ l(
95
- "svg",
96
- {
97
- xmlns: "http://www.w3.org/2000/svg",
98
- width: "24",
99
- height: "24",
100
- viewBox: "0 0 24 24",
101
- fill: "none",
102
- stroke: "currentColor",
103
- strokeWidth: "2",
104
- strokeLinecap: "round",
105
- strokeLinejoin: "round",
106
- children: [
107
- /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
108
- /* @__PURE__ */ e("path", { d: "m15 9-6 6" }),
109
- /* @__PURE__ */ e("path", { d: "m9 9 6 6" })
110
- ]
111
- }
112
- ) }) : null;
113
- return /* @__PURE__ */ e(
114
- "button",
115
- {
116
- className: `${N.button} ${o || ""}`,
117
- "data-variant": V(),
118
- "data-size": p,
119
- disabled: n || t,
120
- ...y,
121
- children: /* @__PURE__ */ l("div", { className: N.content, children: [
122
- w(),
123
- /* @__PURE__ */ e("span", { className: N.text, children: f() })
124
- ] })
125
- }
126
- );
127
- }, fe = "_container_wx5fd_1", ge = "_label_wx5fd_5", _e = "_inputWrapper_wx5fd_13", ve = "_input_wx5fd_13", be = "_editButton_wx5fd_38", W = {
128
- container: fe,
129
- label: ge,
130
- inputWrapper: _e,
131
- input: ve,
132
- editButton: be
133
- }, Y = ({ email: o, setEmail: c, otpSent: t, handleReset: a }) => /* @__PURE__ */ l("div", { className: W.container, children: [
134
- /* @__PURE__ */ e("label", { className: W.label, children: "Email" }),
135
- /* @__PURE__ */ l("div", { className: W.inputWrapper, children: [
136
- /* @__PURE__ */ e(
137
- "input",
138
- {
139
- type: "email",
140
- value: o,
141
- onChange: (u) => c(u.target.value),
142
- className: W.input,
143
- placeholder: "Enter your email",
144
- disabled: t
145
- }
146
- ),
147
- t && /* @__PURE__ */ e(
148
- E,
149
- {
150
- variant: "outline",
151
- onClick: () => a(),
152
- className: W.editButton,
153
- children: "Edit"
154
- }
155
- )
156
- ] })
157
- ] }), ye = "_container_x1dec_1", Ne = "_iconWrapper_x1dec_9", Se = "_icon_x1dec_9", xe = "_content_x1dec_26", Ce = "_title_x1dec_30", we = "_message_x1dec_37", Ee = "_submessage_x1dec_49", Te = "_actions_x1dec_55", ke = "_resetButton_x1dec_59", x = {
158
- container: ye,
159
- iconWrapper: Ne,
160
- icon: Se,
161
- content: xe,
162
- title: Ce,
163
- message: we,
164
- submessage: Ee,
165
- actions: Te,
166
- resetButton: ke
167
- }, Be = ({ email: o, onReset: c }) => /* @__PURE__ */ l("div", { className: x.container, children: [
168
- /* @__PURE__ */ e("div", { className: x.iconWrapper, children: /* @__PURE__ */ e("svg", { className: x.icon, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e(
169
- "path",
170
- {
171
- strokeLinecap: "round",
172
- strokeLinejoin: "round",
173
- strokeWidth: 2,
174
- d: "M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
175
- }
176
- ) }) }),
177
- /* @__PURE__ */ l("div", { className: x.content, children: [
178
- /* @__PURE__ */ e("h3", { className: x.title, children: "Check your email" }),
179
- /* @__PURE__ */ l("p", { className: x.message, children: [
180
- "We've sent a magic link to ",
181
- /* @__PURE__ */ e("strong", { children: o })
182
- ] }),
183
- /* @__PURE__ */ e("p", { className: x.submessage, children: "Click the link in your email to sign in. The link will expire in 15 minutes." })
184
- ] }),
185
- /* @__PURE__ */ e("div", { className: x.actions, children: /* @__PURE__ */ e(E, { variant: "outline", onClick: c, className: x.resetButton, children: "Use a different email" }) })
186
- ] }), We = "_container_1mfd3_1", Oe = "_errorContainer_1mfd3_5", Le = "_divider_1mfd3_9", Ie = "_dividerLine_1mfd3_15", $e = "_dividerText_1mfd3_21", Ve = "_formSection_1mfd3_27", Ae = "_buttonWrapper_1mfd3_33", De = "_fullWidthButton_1mfd3_36", Re = "_oauthContainer_1mfd3_41", Fe = "_googleButton_1mfd3_54", Pe = "_googleIcon_1mfd3_78", Me = "_errorContent_1mfd3_90", je = "_errorText_1mfd3_107", qe = "_errorTitle_1mfd3_112", Ge = "_errorMessage_1mfd3_119", ze = "_errorDismiss_1mfd3_125", d = {
187
- container: We,
188
- errorContainer: Oe,
189
- divider: Le,
190
- dividerLine: Ie,
191
- dividerText: $e,
192
- formSection: Ve,
193
- buttonWrapper: Ae,
194
- fullWidthButton: De,
195
- oauthContainer: Re,
196
- googleButton: Fe,
197
- googleIcon: Pe,
198
- errorContent: Me,
199
- errorText: je,
200
- errorTitle: qe,
201
- errorMessage: Ge,
202
- errorDismiss: ze
203
- }, D = ({ error: o, onDismiss: c }) => /* @__PURE__ */ e("div", { className: d.errorContainer, children: /* @__PURE__ */ l("div", { className: d.errorContent, children: [
204
- /* @__PURE__ */ l("div", { className: d.errorText, children: [
205
- o.title && /* @__PURE__ */ e("div", { className: d.errorTitle, children: o.title }),
206
- /* @__PURE__ */ e("div", { className: d.errorMessage, children: o.message || "An unexpected error occurred" })
207
- ] }),
208
- c && /* @__PURE__ */ e("button", { onClick: c, className: d.errorDismiss, "aria-label": "Dismiss error", children: "×" })
209
- ] }) }), He = ({ onMagicLinkSent: o }) => {
210
- const { sendMagicLink: c } = $(), [t, a] = _(!1), [u, s] = _(null);
211
- G(() => {
212
- o?.(t);
213
- }, [t, o]);
214
- const r = A({
215
- initialValues: {
216
- email: ""
217
- },
218
- validationSchema: le,
219
- validateOnChange: !1,
220
- validateOnBlur: !1,
221
- onSubmit: async (p, { setSubmitting: n, setFieldError: y }) => {
222
- try {
223
- s(null), await c(p.email), a(!0);
224
- } catch (v) {
225
- const i = B(v);
226
- i.hasFieldErrors ? i.fieldErrors.forEach((g) => {
227
- y(g.param, g.message);
228
- }) : s(i);
229
- } finally {
230
- n(!1);
231
- }
232
- }
233
- }), h = () => {
234
- a(!1), r.resetForm(), s(null);
235
- };
236
- return t ? /* @__PURE__ */ e(Be, { email: r.values.email, onReset: h }) : /* @__PURE__ */ l(
237
- "form",
238
- {
239
- onSubmit: r.handleSubmit,
240
- style: {
241
- display: "flex",
242
- flexDirection: "column",
243
- gap: "1rem"
244
- },
245
- children: [
246
- /* @__PURE__ */ e(
247
- Y,
248
- {
249
- email: r.values.email,
250
- setEmail: (p) => r.setFieldValue("email", p),
251
- otpSent: !1,
252
- handleReset: h
253
- }
254
- ),
255
- /* @__PURE__ */ e("div", { className: d.buttonWrapper, children: /* @__PURE__ */ e(
256
- E,
257
- {
258
- type: "submit",
259
- isLoading: r.isSubmitting,
260
- isError: !!u,
261
- disabled: r.isSubmitting,
262
- className: d.fullWidthButton,
263
- loadingText: "Sending Magic Link...",
264
- errorText: "Failed to Send",
265
- children: "Send Magic Link"
266
- }
267
- ) }),
268
- u && /* @__PURE__ */ e(D, { error: u, onDismiss: () => s(null) })
269
- ]
270
- }
271
- );
272
- }, Ue = "_container_1c9qn_1", Ke = "_label_1c9qn_5", Ye = "_inputGroup_1c9qn_13", Je = "_input_1c9qn_13", Qe = "_resendButton_1c9qn_36", O = {
273
- container: Ue,
274
- label: Ke,
275
- inputGroup: Ye,
276
- input: Je,
277
- resendButton: Qe
278
- }, J = ({
279
- otpSent: o,
280
- isResendingOtp: c,
281
- otp: t,
282
- resendOTP: a,
283
- setOtp: u
284
- }) => {
285
- const [s, r] = _(0), h = () => {
286
- a(() => {
287
- r(30);
288
- const p = setInterval(() => {
289
- r((n) => n <= 1 ? (clearInterval(p), 0) : n - 1);
290
- }, 1e3);
291
- });
292
- };
293
- return o ? /* @__PURE__ */ l("div", { className: O.container, children: [
294
- /* @__PURE__ */ e("label", { className: O.label, children: "Verification Code" }),
295
- /* @__PURE__ */ e("div", { className: O.inputGroup, children: /* @__PURE__ */ e(
296
- ne,
297
- {
298
- value: t,
299
- onChange: u,
300
- numInputs: 4,
301
- inputStyle: {
302
- marginRight: "12px"
303
- },
304
- inputType: "tel",
305
- skipDefaultStyles: !0,
306
- renderInput: ({ className: p, ...n }) => /* @__PURE__ */ e("input", { className: `${O.input} ${p}`, ...n })
307
- }
308
- ) }),
309
- /* @__PURE__ */ e(
310
- "button",
311
- {
312
- onClick: h,
313
- disabled: c || s > 0,
314
- className: O.resendButton,
315
- children: c ? "Resending..." : s > 0 ? `Resend in ${s}s` : "Resend Code"
316
- }
317
- )
318
- ] }) : null;
319
- }, Xe = () => {
320
- const { sendOTP: o, verifyOTP: c, resendOTP: t } = $(), [a, u] = _(!1), [s, r] = _(null), [h, p] = _(!1), n = A({
321
- initialValues: {
322
- email: "",
323
- otp: ""
324
- },
325
- validationSchema: a ? ie : K,
326
- validateOnChange: !1,
327
- validateOnBlur: !1,
328
- onSubmit: async (i, { setSubmitting: g, setFieldError: C }) => {
329
- try {
330
- r(null), a ? await c(i.email, i.otp) : (await o({ email: i.email }), u(!0));
331
- } catch (S) {
332
- const m = B(S);
333
- m.hasFieldErrors ? m.fieldErrors.forEach((f) => {
334
- C(f.param, f.message);
335
- }) : r(m);
336
- } finally {
337
- g(!1);
338
- }
339
- }
340
- }), y = () => {
341
- u(!1), n.resetForm(), r(null);
342
- }, v = async () => {
343
- try {
344
- p(!0), r(null), await t({ email: n.values.email });
345
- } catch (i) {
346
- const g = B(i);
347
- r(g);
348
- } finally {
349
- p(!1);
350
- }
351
- };
352
- return /* @__PURE__ */ l(
353
- "form",
354
- {
355
- onSubmit: n.handleSubmit,
356
- style: {
357
- display: "flex",
358
- flexDirection: "column",
359
- gap: "1rem"
360
- },
361
- children: [
362
- /* @__PURE__ */ e(
363
- Y,
364
- {
365
- email: n.values.email,
366
- setEmail: (i) => n.setFieldValue("email", i),
367
- otpSent: a,
368
- handleReset: y
369
- }
370
- ),
371
- /* @__PURE__ */ e(
372
- J,
373
- {
374
- otpSent: a,
375
- otp: n.values.otp,
376
- setOtp: (i) => n.setFieldValue("otp", i),
377
- isResendingOtp: h,
378
- resendOTP: v
379
- }
380
- ),
381
- /* @__PURE__ */ e("div", { className: d.buttonWrapper, children: a ? /* @__PURE__ */ e(
382
- E,
383
- {
384
- type: "submit",
385
- isLoading: n.isSubmitting,
386
- isError: !!s,
387
- disabled: n.isSubmitting || !n.values.otp,
388
- className: d.fullWidthButton,
389
- loadingText: "Verifying...",
390
- errorText: "Verification Failed",
391
- children: "Verify & Sign In"
392
- }
393
- ) : /* @__PURE__ */ e(
394
- E,
395
- {
396
- type: "submit",
397
- isLoading: n.isSubmitting,
398
- isError: !!s,
399
- disabled: n.isSubmitting,
400
- className: d.fullWidthButton,
401
- loadingText: "Sending Code...",
402
- errorText: "Failed to Send",
403
- children: "Send Code"
404
- }
405
- ) }),
406
- s && /* @__PURE__ */ e(D, { error: s, onDismiss: () => r(null) })
407
- ]
408
- }
409
- );
410
- }, Ze = "_label_1fvbo_1", et = "_inputWrapper_1fvbo_9", tt = "_phoneInputWrapper_1fvbo_14", nt = "_input_1fvbo_9", rt = "_selector_1fvbo_41", ot = "_editButton_1fvbo_69", it = "_dropdownContent_1fvbo_73", st = "_countryItem_1fvbo_89", at = "_flag_1fvbo_111", lt = "_countryName_1fvbo_118", ct = "_dialCode_1fvbo_125", b = {
411
- label: Ze,
412
- inputWrapper: et,
413
- phoneInputWrapper: tt,
414
- input: nt,
415
- selector: rt,
416
- editButton: ot,
417
- dropdownContent: it,
418
- countryItem: st,
419
- flag: at,
420
- countryName: lt,
421
- dialCode: ct
422
- }, dt = ({ phone: o, setPhone: c, otpSent: t, handleReset: a }) => {
423
- const [u, s] = _(!1), [r, h] = _(""), p = R(null), n = R(null), { inputValue: y, handlePhoneValueChange: v, inputRef: i, country: g, setCountry: C } = oe({
424
- defaultCountry: "in",
425
- value: o,
426
- countries: P,
427
- onChange: (m) => {
428
- c(m.phone);
429
- },
430
- disableDialCodePrefill: !0,
431
- forceDialCode: !0
432
- }), S = P.filter((m) => {
433
- const f = M(m);
434
- return f.name.toLowerCase().includes(r.toLowerCase()) || f.dialCode.includes(r);
435
- });
436
- return /* @__PURE__ */ l("div", { children: [
437
- /* @__PURE__ */ e("label", { className: b.label, children: "Phone Number" }),
438
- /* @__PURE__ */ l("div", { className: b.inputWrapper, children: [
439
- /* @__PURE__ */ l("div", { className: b.phoneInputWrapper, children: [
440
- /* @__PURE__ */ l(L.Root, { open: u, onOpenChange: s, children: [
441
- /* @__PURE__ */ e(L.Trigger, { asChild: !0, disabled: t, children: /* @__PURE__ */ l("button", { type: "button", className: b.selector, disabled: t, children: [
442
- /* @__PURE__ */ e(j, { iso2: g.iso2, style: { width: "24px", height: "16px" } }),
443
- /* @__PURE__ */ e(re, { size: 16, style: { marginLeft: "4px", opacity: 0.5 } })
444
- ] }) }),
445
- /* @__PURE__ */ e(L.Portal, { children: /* @__PURE__ */ l(
446
- L.Content,
447
- {
448
- className: b.dropdownContent,
449
- align: "start",
450
- side: "bottom",
451
- sideOffset: 4,
452
- onOpenAutoFocus: (m) => {
453
- m.preventDefault(), n.current?.focus();
454
- },
455
- children: [
456
- /* @__PURE__ */ e("div", { style: { padding: "0.5rem" }, children: /* @__PURE__ */ e(
457
- "input",
458
- {
459
- ref: n,
460
- type: "text",
461
- placeholder: "Search country...",
462
- value: r,
463
- onChange: (m) => h(m.target.value),
464
- onKeyDown: (m) => {
465
- m.key === "ArrowDown" && (m.preventDefault(), p.current?.firstElementChild?.focus());
466
- },
467
- className: b.input,
468
- style: {
469
- borderRadius: "0.375rem",
470
- borderLeft: "1px solid #d1d5db"
471
- }
472
- }
473
- ) }),
474
- /* @__PURE__ */ l("div", { ref: p, style: { overflowY: "auto", flex: 1 }, children: [
475
- S.map((m) => {
476
- const f = M(m), V = f.iso2 === g.iso2;
477
- return /* @__PURE__ */ l(
478
- "button",
479
- {
480
- type: "button",
481
- className: b.countryItem,
482
- "data-selected": V,
483
- onClick: () => {
484
- C(f.iso2), s(!1), h("");
485
- },
486
- onKeyDown: (w) => {
487
- if (w.key === "ArrowDown")
488
- w.preventDefault(), w.currentTarget.nextElementSibling?.focus();
489
- else if (w.key === "ArrowUp") {
490
- w.preventDefault();
491
- const T = w.currentTarget.previousElementSibling;
492
- T ? T.focus() : n.current?.focus();
493
- }
494
- },
495
- children: [
496
- /* @__PURE__ */ e(j, { iso2: f.iso2, className: b.flag }),
497
- /* @__PURE__ */ e("span", { className: b.countryName, children: f.name }),
498
- /* @__PURE__ */ l("span", { className: b.dialCode, children: [
499
- "+",
500
- f.dialCode
501
- ] })
502
- ]
503
- },
504
- f.iso2
505
- );
506
- }),
507
- S.length === 0 && /* @__PURE__ */ e(
508
- "div",
509
- {
510
- style: {
511
- padding: "1rem",
512
- textAlign: "center",
513
- color: "#6b7280",
514
- fontSize: "0.875rem"
515
- },
516
- children: "No countries found"
517
- }
518
- )
519
- ] })
520
- ]
521
- }
522
- ) })
523
- ] }),
524
- /* @__PURE__ */ e(
525
- "input",
526
- {
527
- ref: i,
528
- type: "tel",
529
- value: y,
530
- onChange: v,
531
- className: b.input,
532
- disabled: t
533
- }
534
- )
535
- ] }),
536
- t && /* @__PURE__ */ e(
537
- E,
538
- {
539
- variant: "outline",
540
- onClick: () => a(),
541
- className: b.editButton,
542
- children: "Edit"
543
- }
544
- )
545
- ] })
546
- ] });
547
- }, ut = () => {
548
- const { sendOTP: o, verifyOTP: c, resendOTP: t } = $(), [a, u] = _(!1), [s, r] = _(null), [h, p] = _(!1), n = A({
549
- initialValues: {
550
- phone: "",
551
- otp: ""
552
- },
553
- validationSchema: a ? ae : se,
554
- validateOnChange: !1,
555
- validateOnBlur: !1,
556
- onSubmit: async (i, { setSubmitting: g, setFieldError: C }) => {
557
- try {
558
- r(null), a ? await c(i.phone, i.otp) : (await o({ phone: i.phone, medium: "whatsapp" }), u(!0));
559
- } catch (S) {
560
- const m = B(S);
561
- m.hasFieldErrors ? m.fieldErrors.forEach((f) => {
562
- C(f.param, f.message);
563
- }) : r(m);
564
- } finally {
565
- g(!1);
566
- }
567
- }
568
- }), y = () => {
569
- u(!1), n.resetForm(), r(null);
570
- }, v = async () => {
571
- try {
572
- p(!0), r(null), await t({ phone: n.values.phone, medium: "whatsapp" });
573
- } catch (i) {
574
- const g = B(i);
575
- r(g);
576
- } finally {
577
- p(!1);
578
- }
579
- };
580
- return /* @__PURE__ */ l(
581
- "form",
582
- {
583
- onSubmit: n.handleSubmit,
584
- style: {
585
- display: "flex",
586
- flexDirection: "column",
587
- gap: "1rem"
588
- },
589
- children: [
590
- /* @__PURE__ */ e(
591
- dt,
592
- {
593
- phone: n.values.phone,
594
- setPhone: (i) => n.setFieldValue("phone", i),
595
- otpSent: a,
596
- handleReset: y
597
- }
598
- ),
599
- /* @__PURE__ */ e(
600
- J,
601
- {
602
- otpSent: a,
603
- otp: n.values.otp,
604
- setOtp: (i) => n.setFieldValue("otp", i),
605
- isResendingOtp: h,
606
- resendOTP: v
607
- }
608
- ),
609
- /* @__PURE__ */ e("div", { className: d.buttonWrapper, children: a ? /* @__PURE__ */ e(
610
- E,
611
- {
612
- type: "submit",
613
- isLoading: n.isSubmitting,
614
- isError: !!s,
615
- disabled: n.isSubmitting,
616
- className: d.fullWidthButton,
617
- loadingText: "Verifying...",
618
- errorText: "Verification Failed",
619
- children: "Verify & Sign In"
620
- }
621
- ) : /* @__PURE__ */ e(
622
- E,
623
- {
624
- type: "submit",
625
- isLoading: n.isSubmitting,
626
- isError: !!s,
627
- disabled: n.isSubmitting,
628
- className: d.fullWidthButton,
629
- loadingText: "Sending Code...",
630
- errorText: "Failed to Send",
631
- children: "Send Code"
632
- }
633
- ) }),
634
- s && /* @__PURE__ */ e(D, { error: s })
635
- ]
636
- }
637
- );
638
- }, mt = ({
639
- method: o,
640
- onMagicLinkSent: c
641
- }) => {
642
- switch (o) {
643
- case "otp":
644
- return /* @__PURE__ */ e(Xe, {});
645
- case "whatsapp":
646
- return /* @__PURE__ */ e(ut, {});
647
- case "magiclink":
648
- return /* @__PURE__ */ e(He, { onMagicLinkSent: c });
649
- default:
650
- return null;
651
- }
652
- }, pt = ({ method: o }) => {
653
- switch (o) {
654
- case "google":
655
- return /* @__PURE__ */ e(I.Button, { provider: "google", children: /* @__PURE__ */ l("button", { type: "button", className: d.googleButton, children: [
656
- /* @__PURE__ */ e("img", { className: d.googleIcon, src: "https://static.levocdn.com/png/google.png" }),
657
- "Continue with Google"
658
- ] }) });
659
- case "microsoft":
660
- return /* @__PURE__ */ e(I.Button, { provider: "microsoft", children: /* @__PURE__ */ l("button", { type: "button", className: d.googleButton, children: [
661
- /* @__PURE__ */ e("img", { className: d.googleIcon, src: "https://static.levocdn.com/png/microsoft.png" }),
662
- "Continue with Microsoft"
663
- ] }) });
664
- case "linkedin":
665
- return /* @__PURE__ */ e(I.Button, { provider: "linkedin", children: /* @__PURE__ */ l("button", { type: "button", className: d.googleButton, children: [
666
- /* @__PURE__ */ e("img", { className: d.googleIcon, src: "https://static.levocdn.com/png/linkedin.png" }),
667
- "Continue with LinkedIn"
668
- ] }) });
669
- case "oauth":
670
- default:
671
- return /* @__PURE__ */ e(q, {});
672
- }
673
- }, ht = ({
674
- otpSent: o,
675
- oAuthTitle: c,
676
- onOAuthSuccess: t,
677
- onOAuthError: a,
678
- oAuthMethods: u
679
- }) => {
680
- const { logger: s } = Q();
681
- return /* @__PURE__ */ e("div", { className: d.oauthContainer, children: !o && /* @__PURE__ */ e(
682
- I.Container,
683
- {
684
- title: c,
685
- onSuccess: () => {
686
- X("You are logged in successfully", "Login Successful", {
687
- position: "top-right"
688
- }), t && t();
689
- },
690
- onError: (r) => {
691
- const h = B(r);
692
- s?.error("OAuth login failed", h.message), a && a(h);
693
- },
694
- children: u?.map((r) => /* @__PURE__ */ e(pt, { method: r }, r))
695
- }
696
- ) });
697
- }, ft = ({
698
- oAuthMethods: o,
699
- oAuthTitle: c = "Studio",
700
- showDivider: t,
701
- dividerText: a,
702
- onOAuthSuccess: u,
703
- onOAuthError: s
704
- }) => /* @__PURE__ */ l(q, { children: [
705
- /* @__PURE__ */ e(
706
- ht,
707
- {
708
- otpSent: !t,
709
- oAuthTitle: c,
710
- onOAuthSuccess: u,
711
- onOAuthError: s,
712
- oAuthMethods: o
713
- }
714
- ),
715
- t && /* @__PURE__ */ l("div", { className: d.divider, children: [
716
- /* @__PURE__ */ e("div", { className: d.dividerLine }),
717
- /* @__PURE__ */ e("div", { className: d.dividerText, children: a }),
718
- /* @__PURE__ */ e("div", { className: d.dividerLine })
719
- ] })
720
- ] }), Tt = ({
721
- className: o,
722
- oAuthTitle: c = "Studio",
723
- page: t,
724
- magicLinkSent: a,
725
- setMagicLinkSent: u,
726
- oAuthMethods: s
727
- }) => {
728
- const { refetchLoginStatus: r } = $(), h = F(() => t?.access?.[0]?.kind === "authentication" && t?.access?.[0]?.options?.primary_method || "otp", [t?.access]), p = F(() => s || (t?.access?.[0]?.kind === "authentication" ? t?.access?.[0]?.options?.methods?.filter((i) => ee.includes(i)) || [] : []), [t?.access, s]), n = () => {
729
- r();
730
- }, y = (i) => {
731
- Z(i);
732
- }, v = () => {
733
- switch (h) {
734
- case "whatsapp":
735
- return "or sign in with WhatsApp";
736
- case "magiclink":
737
- case "otp":
738
- default:
739
- return "or sign in with email";
740
- }
741
- };
742
- return /* @__PURE__ */ l("div", { className: `${d.container} ${o || ""}`, children: [
743
- p.length > 0 && !a && /* @__PURE__ */ e(
744
- ft,
745
- {
746
- oAuthMethods: p,
747
- oAuthTitle: c,
748
- showDivider: !0,
749
- dividerText: v(),
750
- onOAuthSuccess: n,
751
- onOAuthError: y
752
- }
753
- ),
754
- /* @__PURE__ */ e("div", { className: d.formSection, children: /* @__PURE__ */ e(
755
- mt,
756
- {
757
- method: h,
758
- onMagicLinkSent: u
759
- }
760
- ) })
761
- ] });
762
- };
763
- export {
764
- Tt as L
765
- };