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