@levo-so/studio 0.1.59 → 0.1.61

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 (121) hide show
  1. package/dist/{Beams-0Cg_3upg.js → Beams-sKsW_tr4.js} +46 -55
  2. package/dist/{Dots-turX9wMO.js → Dots-BEIutbKS.js} +44 -40
  3. package/dist/{Gradient-Be4Kqh_1.js → Gradient-DAR7R3Mz.js} +2 -2
  4. package/dist/Grid-BuKIXWMJ.js +174 -0
  5. package/dist/MessageCard-C8v6oHmf.js +45 -0
  6. package/dist/{Waves-DL4kuojY.js → Waves-C8qlIS1W.js} +29 -80
  7. package/dist/bridge/Highlighter.d.ts +3 -5
  8. package/dist/bridge/StudioBlockPreview.d.ts +1 -0
  9. package/dist/bridge/StudioPagePreview.d.ts +2 -2
  10. package/dist/bridge/StudioPreview.d.ts +1 -1
  11. package/dist/bridge/constants.d.ts +2 -0
  12. package/dist/bridge/hooks/useElementTracker.d.ts +9 -0
  13. package/dist/bridge/index.d.ts +3 -3
  14. package/dist/bridge/utils.d.ts +1 -4
  15. package/dist/components/AnimatedBlock.d.ts +50 -0
  16. package/dist/components/backgroundPresets/exports.d.ts +1 -1
  17. package/dist/components/backgroundPresets/presetSystem.d.ts +2 -2
  18. package/dist/components/bookingCard/BookingCard.d.ts +65 -0
  19. package/dist/components/bookingCard/index.d.ts +2 -0
  20. package/dist/components/bookingModal/BookingConfirmation.d.ts +48 -0
  21. package/dist/components/bookingModal/BookingModal.d.ts +19 -0
  22. package/dist/components/bookingModal/BookingSummary.d.ts +34 -0
  23. package/dist/components/bookingModal/index.d.ts +4 -0
  24. package/dist/components/index.d.ts +1 -0
  25. package/dist/components/integrationFilters/FieldRenderer.d.ts +3 -0
  26. package/dist/components/integrationFilters/IntegrationFilters.d.ts +1 -1
  27. package/dist/components/integrationFilters/fields/DropdownField.d.ts +1 -1
  28. package/dist/components/integrationFilters/fields/TextField.d.ts +1 -1
  29. package/dist/components/registerModal/AttendeeForm.d.ts +27 -0
  30. package/dist/components/registerModal/CouponView.d.ts +14 -0
  31. package/dist/components/registerModal/RegisterModal.d.ts +2 -1
  32. package/dist/components/registerModal/TicketSelectionStep.d.ts +15 -0
  33. package/dist/components/registerModal/utils.d.ts +85 -1
  34. package/dist/components/stripePaymentModal/StripePaymentModal.d.ts +22 -0
  35. package/dist/components/stripePaymentModal/index.d.ts +3 -0
  36. package/dist/components/ui/Calendar.d.ts +1 -1
  37. package/dist/components/ui/base/avatar.d.ts +13 -0
  38. package/dist/components/ui/base/index.d.ts +3 -0
  39. package/dist/components/ui/base/input.d.ts +1 -1
  40. package/dist/components/ui/base/skeleton.d.ts +3 -0
  41. package/dist/components/ui/base/textarea.d.ts +4 -0
  42. package/dist/components/ui/base/tooltip.d.ts +17 -0
  43. package/dist/components/ui/form/FormTextarea.d.ts +15 -0
  44. package/dist/components/ui/index.d.ts +3 -0
  45. package/dist/components/withBlockProps.d.ts +6 -14
  46. package/dist/constants/animation.d.ts +10 -0
  47. package/dist/contentEngine/content.d.ts +8 -3
  48. package/dist/contentEngine/index.d.ts +3 -3
  49. package/dist/contentEngine/sourceFetcher.d.ts +1 -1
  50. package/dist/contentEngine/themeUtils.d.ts +13 -0
  51. package/dist/contentEngine/types.d.ts +1 -0
  52. package/dist/contentEngine/useContextEngine.d.ts +11 -0
  53. package/dist/context/ForumContext.d.ts +48 -0
  54. package/dist/core/AccessManager/index.d.ts +1 -1
  55. package/dist/core/LevoBlock.d.ts +3 -2
  56. package/dist/core/LevoPage.d.ts +2 -2
  57. package/dist/core/index.d.ts +1 -1
  58. package/dist/elements/AlertDialog/index.d.ts +23 -0
  59. package/dist/elements/Carousel.d.ts +10 -2
  60. package/dist/elements/Tabs.d.ts +1 -1
  61. package/dist/elements/UserMenu.d.ts +1 -1
  62. package/dist/elements/accordion/index.d.ts +1 -1
  63. package/dist/elements/dialog/index.d.ts +1 -1
  64. package/dist/elements/forum/ForumPost.d.ts +18 -0
  65. package/dist/elements/forum/ForumPostContentRenderer.d.ts +8 -0
  66. package/dist/elements/forum/SearchInput.d.ts +5 -0
  67. package/dist/elements/forum/categoryFilter/CategoryFilter.d.ts +16 -0
  68. package/dist/elements/forum/categoryFilter/index.d.ts +2 -0
  69. package/dist/elements/forum/comments/Comment.d.ts +14 -0
  70. package/dist/elements/forum/comments/Comments.d.ts +9 -0
  71. package/dist/elements/forum/comments/ReplyBox.d.ts +11 -0
  72. package/dist/elements/forum/comments/commentUtility.d.ts +25 -0
  73. package/dist/elements/forum/comments/index.d.ts +2 -0
  74. package/dist/elements/forum/createForumPost/CreateForumPost.d.ts +9 -0
  75. package/dist/elements/forum/createForumPost/CreateForumPostModal.d.ts +87 -0
  76. package/dist/elements/forum/createForumPost/index.d.ts +2 -0
  77. package/dist/elements/forum/index.d.ts +8 -0
  78. package/dist/elements/forum/restrictionOverlays/CommentsRestrictionOverlay.d.ts +16 -0
  79. package/dist/elements/forum/restrictionOverlays/JoinRequestForm.d.ts +14 -0
  80. package/dist/elements/forum/restrictionOverlays/PendingRequestState.d.ts +11 -0
  81. package/dist/elements/forum/restrictionOverlays/PostsRestrictionOverlay.d.ts +16 -0
  82. package/dist/elements/forum/restrictionOverlays/index.d.ts +5 -0
  83. package/dist/elements/forum/utility/Video.d.ts +16 -0
  84. package/dist/elements/forum/utility/index.d.ts +49 -0
  85. package/dist/elements/index.d.ts +10 -9
  86. package/dist/elements-BxhlsyhI.js +9 -0
  87. package/dist/hooks/index.d.ts +3 -0
  88. package/dist/hooks/useLogin.d.ts +1 -1
  89. package/dist/hooks/useStripePayment.d.ts +49 -0
  90. package/dist/index-BJrh8CwF.js +16197 -0
  91. package/dist/{index-BdswdesP.js → index-BYXw6aHi.js} +3 -4
  92. package/dist/index-CV5mr-8e.js +365 -0
  93. package/dist/index-CXtfbmpx.js +23 -0
  94. package/dist/index-CgUU2EbC.js +765 -0
  95. package/dist/index-DsAqikcl.js +29 -0
  96. package/dist/index-DxsNKR4p.js +56 -0
  97. package/dist/{index-DHHPZcEh.js → index-IcG2wuuE.js} +1 -8
  98. package/dist/index.d.ts +16 -13
  99. package/dist/index.js +159 -107
  100. package/dist/interfaces/block.d.ts +2 -2
  101. package/dist/interfaces/levoBlock.d.ts +64 -10
  102. package/dist/interfaces/site.d.ts +1 -193
  103. package/dist/interfaces/sites.d.ts +201 -3
  104. package/dist/interfaces/theme.d.ts +2 -0
  105. package/dist/pixel/parserUtil.d.ts +1 -0
  106. package/dist/providers/AuthProvider.d.ts +1 -0
  107. package/dist/providers/BlockContext.d.ts +2 -1
  108. package/dist/providers/LazyMotionProvider.d.ts +15 -0
  109. package/dist/providers/index.d.ts +1 -0
  110. package/dist/studio.css +1 -1
  111. package/dist/utils/colorUtils.d.ts +7 -0
  112. package/dist/utils/getKeysWithValue.d.ts +1 -1
  113. package/dist/utils/string.d.ts +7 -0
  114. package/dist/utils/withBlockPropsUtils.d.ts +6 -55
  115. package/package.json +13 -16
  116. package/dist/Grid-B0vqOT42.js +0 -184
  117. package/dist/MessageCard-CCngWCHS.js +0 -53
  118. package/dist/components/withBlockProps copy.d.ts +0 -61
  119. package/dist/index-CPJI9a7D.js +0 -13503
  120. package/dist/index-CmNhuPZp.js +0 -34
  121. package/dist/index-kVKDoWCh.js +0 -57
@@ -0,0 +1,765 @@
1
+ "use client";
2
+ import { jsx as e, jsxs as l, Fragment as q } from "react/jsx-runtime";
3
+ import { useLevo as Q, useLevoInsights as X, LevoOAuth as I, successToast as Z, errorHandler as ee } from "@levo-so/react";
4
+ import { useState as _, useEffect as G, useRef as R, useMemo as F } from "react";
5
+ import { h as $, A as te } from "./index-BJrh8CwF.js";
6
+ import { getLevoError as B } from "@levo-so/core";
7
+ import { useFormik as A } from "formik";
8
+ import { parsePhoneNumberWithError as ne } from "libphonenumber-js";
9
+ import * as k from "yup";
10
+ import re from "react-otp-input";
11
+ import { ChevronDown as oe } from "lucide-react";
12
+ import { Popover as O } from "radix-ui";
13
+ import { usePhoneInput as ie, 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", (r) => {
15
+ if (!r) return !1;
16
+ try {
17
+ return ne(r)?.isValid() ?? !1;
18
+ } catch {
19
+ return !1;
20
+ }
21
+ }), K = k.object({
22
+ email: z
23
+ }), se = k.object({
24
+ email: z,
25
+ otp: H
26
+ }), ae = k.object({
27
+ phone: U
28
+ }), le = k.object({
29
+ phone: U,
30
+ otp: H
31
+ }), ce = K, de = "_button_1je4h_2", ue = "_content_1je4h_70", me = "_icon_1je4h_77", pe = "_spinner_1je4h_89", he = "_iconEnter_1je4h_103", fe = "_text_1je4h_119", N = {
32
+ button: de,
33
+ content: ue,
34
+ icon: me,
35
+ spinner: pe,
36
+ iconEnter: he,
37
+ text: fe
38
+ }, E = ({
39
+ className: r,
40
+ children: c,
41
+ isLoading: t = !1,
42
+ isError: a = !1,
43
+ loadingText: m = "Loading...",
44
+ successText: s = "Success!",
45
+ errorText: o = "Error!",
46
+ variant: h = "default",
47
+ size: u = "default",
48
+ disabled: n,
49
+ ...y
50
+ }) => {
51
+ const [v, i] = _(!1), [g, C] = _(!1), [S, p] = _(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
+ p(t);
68
+ }, [t, S, a]);
69
+ const f = () => t ? m : v ? s : g ? o : 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} ${r || ""}`,
117
+ "data-variant": V(),
118
+ "data-size": u,
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
+ }, ge = "_container_wx5fd_1", _e = "_label_wx5fd_5", ve = "_inputWrapper_wx5fd_13", be = "_input_wx5fd_13", ye = "_editButton_wx5fd_38", W = {
128
+ container: ge,
129
+ label: _e,
130
+ inputWrapper: ve,
131
+ input: be,
132
+ editButton: ye
133
+ }, Y = ({ email: r, 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: r,
141
+ onChange: (m) => c(m.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
+ ] }), 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", x = {
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: 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: r })
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
+ ] }), Le = "_container_1mfd3_1", Oe = "_errorContainer_1mfd3_5", Ie = "_divider_1mfd3_9", $e = "_dividerLine_1mfd3_15", Ve = "_dividerText_1mfd3_21", Ae = "_formSection_1mfd3_27", De = "_buttonWrapper_1mfd3_33", Re = "_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: Le,
188
+ errorContainer: Oe,
189
+ divider: Ie,
190
+ dividerLine: $e,
191
+ dividerText: Ve,
192
+ formSection: Ae,
193
+ buttonWrapper: De,
194
+ fullWidthButton: Re,
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
+ }, D = ({ error: r, 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
+ 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
+ c && /* @__PURE__ */ e("button", { onClick: c, className: d.errorDismiss, "aria-label": "Dismiss error", children: "×" })
209
+ ] }) }), Ue = ({ onMagicLinkSent: r }) => {
210
+ const { sendMagicLink: c } = $(), [t, a] = _(!1), [m, s] = _(null);
211
+ G(() => {
212
+ r?.(t);
213
+ }, [t, r]);
214
+ const o = A({
215
+ initialValues: {
216
+ email: ""
217
+ },
218
+ validationSchema: ce,
219
+ validateOnChange: !1,
220
+ validateOnBlur: !1,
221
+ onSubmit: async (u, { setSubmitting: n, setFieldError: y }) => {
222
+ try {
223
+ s(null), await c(u.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), o.resetForm(), s(null);
235
+ };
236
+ return t ? /* @__PURE__ */ e(We, { email: o.values.email, onReset: h }) : /* @__PURE__ */ l(
237
+ "form",
238
+ {
239
+ onSubmit: o.handleSubmit,
240
+ style: {
241
+ display: "flex",
242
+ flexDirection: "column",
243
+ gap: "1rem"
244
+ },
245
+ children: [
246
+ /* @__PURE__ */ e(
247
+ Y,
248
+ {
249
+ email: o.values.email,
250
+ setEmail: (u) => o.setFieldValue("email", u),
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: o.isSubmitting,
260
+ isError: !!m,
261
+ disabled: o.isSubmitting,
262
+ className: d.fullWidthButton,
263
+ loadingText: "Sending Magic Link...",
264
+ errorText: "Failed to Send",
265
+ children: "Send Magic Link"
266
+ }
267
+ ) }),
268
+ m && /* @__PURE__ */ e(D, { error: m, onDismiss: () => s(null) })
269
+ ]
270
+ }
271
+ );
272
+ }, Ke = "_container_1c9qn_1", Ye = "_label_1c9qn_5", Je = "_inputGroup_1c9qn_13", Qe = "_input_1c9qn_13", Xe = "_resendButton_1c9qn_36", L = {
273
+ container: Ke,
274
+ label: Ye,
275
+ inputGroup: Je,
276
+ input: Qe,
277
+ resendButton: Xe
278
+ }, J = ({
279
+ otpSent: r,
280
+ isResendingOtp: c,
281
+ otp: t,
282
+ resendOTP: a,
283
+ setOtp: m
284
+ }) => {
285
+ const [s, o] = _(0), h = () => {
286
+ a(() => {
287
+ o(30);
288
+ const u = setInterval(() => {
289
+ o((n) => n <= 1 ? (clearInterval(u), 0) : n - 1);
290
+ }, 1e3);
291
+ });
292
+ };
293
+ return r ? /* @__PURE__ */ l("div", { className: L.container, children: [
294
+ /* @__PURE__ */ e("label", { className: L.label, children: "Verification Code" }),
295
+ /* @__PURE__ */ e("div", { className: L.inputGroup, children: /* @__PURE__ */ e(
296
+ re,
297
+ {
298
+ value: t,
299
+ onChange: m,
300
+ numInputs: 4,
301
+ inputStyle: {
302
+ marginRight: "12px"
303
+ },
304
+ inputType: "tel",
305
+ skipDefaultStyles: !0,
306
+ renderInput: ({ className: u, ...n }) => /* @__PURE__ */ e("input", { className: `${L.input} ${u}`, ...n })
307
+ }
308
+ ) }),
309
+ /* @__PURE__ */ e(
310
+ "button",
311
+ {
312
+ onClick: h,
313
+ disabled: c || s > 0,
314
+ className: L.resendButton,
315
+ children: c ? "Resending..." : s > 0 ? `Resend in ${s}s` : "Resend Code"
316
+ }
317
+ )
318
+ ] }) : null;
319
+ }, Ze = () => {
320
+ const { sendOTP: r, verifyOTP: c, resendOTP: t } = $(), [a, m] = _(!1), [s, o] = _(null), [h, u] = _(!1), n = A({
321
+ initialValues: {
322
+ email: "",
323
+ otp: ""
324
+ },
325
+ validationSchema: a ? se : K,
326
+ validateOnChange: !1,
327
+ validateOnBlur: !1,
328
+ onSubmit: async (i, { setSubmitting: g, setFieldError: C }) => {
329
+ try {
330
+ o(null), a ? await c(i.email, i.otp) : (await r({ email: i.email }), m(!0));
331
+ } catch (S) {
332
+ const p = B(S);
333
+ p.hasFieldErrors ? p.fieldErrors.forEach((f) => {
334
+ C(f.param, f.message);
335
+ }) : o(p);
336
+ } finally {
337
+ g(!1);
338
+ }
339
+ }
340
+ }), y = () => {
341
+ m(!1), n.resetForm(), o(null);
342
+ }, v = async () => {
343
+ try {
344
+ u(!0), o(null), await t({ email: n.values.email });
345
+ } catch (i) {
346
+ const g = B(i);
347
+ o(g);
348
+ } finally {
349
+ u(!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,
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: () => o(null) })
407
+ ]
408
+ }
409
+ );
410
+ }, 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", b = {
411
+ label: et,
412
+ inputWrapper: tt,
413
+ phoneInputWrapper: nt,
414
+ input: rt,
415
+ selector: ot,
416
+ editButton: it,
417
+ dropdownContent: st,
418
+ countryItem: at,
419
+ flag: lt,
420
+ countryName: ct,
421
+ dialCode: dt
422
+ }, ut = ({ phone: r, setPhone: c, otpSent: t, handleReset: a }) => {
423
+ const [m, s] = _(!1), [o, h] = _(""), u = R(null), n = R(null), { inputValue: y, handlePhoneValueChange: v, inputRef: i, country: g, setCountry: C } = ie({
424
+ defaultCountry: "in",
425
+ value: r,
426
+ countries: P,
427
+ onChange: (p) => {
428
+ c(p.phone);
429
+ },
430
+ disableDialCodePrefill: !0,
431
+ forceDialCode: !0
432
+ }), S = P.filter((p) => {
433
+ const f = M(p);
434
+ return f.name.toLowerCase().includes(o.toLowerCase()) || f.dialCode.includes(o);
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(O.Root, { open: m, onOpenChange: s, children: [
441
+ /* @__PURE__ */ e(O.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(oe, { size: 16, style: { marginLeft: "4px", opacity: 0.5 } })
444
+ ] }) }),
445
+ /* @__PURE__ */ e(O.Portal, { children: /* @__PURE__ */ l(
446
+ O.Content,
447
+ {
448
+ className: b.dropdownContent,
449
+ align: "start",
450
+ side: "bottom",
451
+ sideOffset: 4,
452
+ onOpenAutoFocus: (p) => {
453
+ p.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: o,
463
+ onChange: (p) => h(p.target.value),
464
+ onKeyDown: (p) => {
465
+ p.key === "ArrowDown" && (p.preventDefault(), u.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: u, style: { overflowY: "auto", flex: 1 }, children: [
475
+ S.map((p) => {
476
+ const f = M(p), 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
+ }, mt = () => {
548
+ const { sendOTP: r, verifyOTP: c, resendOTP: t } = $(), [a, m] = _(!1), [s, o] = _(null), [h, u] = _(!1), n = A({
549
+ initialValues: {
550
+ phone: "",
551
+ otp: ""
552
+ },
553
+ validationSchema: a ? le : ae,
554
+ validateOnChange: !1,
555
+ validateOnBlur: !1,
556
+ onSubmit: async (i, { setSubmitting: g, setFieldError: C }) => {
557
+ try {
558
+ o(null), a ? await c(i.phone, i.otp) : (await r({ phone: i.phone, medium: "whatsapp" }), m(!0));
559
+ } catch (S) {
560
+ const p = B(S);
561
+ p.hasFieldErrors ? p.fieldErrors.forEach((f) => {
562
+ C(f.param, f.message);
563
+ }) : o(p);
564
+ } finally {
565
+ g(!1);
566
+ }
567
+ }
568
+ }), y = () => {
569
+ m(!1), n.resetForm(), o(null);
570
+ }, v = async () => {
571
+ try {
572
+ u(!0), o(null), await t({ phone: n.values.phone, medium: "whatsapp" });
573
+ } catch (i) {
574
+ const g = B(i);
575
+ o(g);
576
+ } finally {
577
+ u(!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
+ ut,
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
+ }, pt = ({
639
+ method: r,
640
+ onMagicLinkSent: c
641
+ }) => {
642
+ switch (r) {
643
+ case "otp":
644
+ return /* @__PURE__ */ e(Ze, {});
645
+ case "whatsapp":
646
+ return /* @__PURE__ */ e(mt, {});
647
+ case "magiclink":
648
+ return /* @__PURE__ */ e(Ue, { onMagicLinkSent: c });
649
+ default:
650
+ return null;
651
+ }
652
+ }, ht = ({ method: r }) => {
653
+ switch (r) {
654
+ case "google":
655
+ return /* @__PURE__ */ e(I.Button, { provider: "google", children: /* @__PURE__ */ l("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", { 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", { 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
+ }, ft = ({
674
+ otpSent: r,
675
+ oAuthTitle: c,
676
+ onOAuthSuccess: t,
677
+ onOAuthError: a,
678
+ oAuthMethods: m
679
+ }) => {
680
+ const { logger: s } = Q(), o = X();
681
+ return /* @__PURE__ */ e("div", { className: d.oauthContainer, children: !r && /* @__PURE__ */ e(
682
+ I.Container,
683
+ {
684
+ title: c,
685
+ onSuccess: () => {
686
+ Z("You are logged in successfully", "Login Successful", {
687
+ position: "top-right"
688
+ }), o?.identify(), t && t();
689
+ },
690
+ onError: (h) => {
691
+ const u = B(h);
692
+ s?.error("OAuth login failed", u.message), a && a(u);
693
+ },
694
+ children: m?.map((h) => /* @__PURE__ */ e(ht, { method: h }, h))
695
+ }
696
+ ) });
697
+ }, gt = ({
698
+ oAuthMethods: r,
699
+ oAuthTitle: c = "Studio",
700
+ showDivider: t,
701
+ dividerText: a,
702
+ onOAuthSuccess: m,
703
+ onOAuthError: s
704
+ }) => /* @__PURE__ */ l(q, { children: [
705
+ /* @__PURE__ */ e(
706
+ ft,
707
+ {
708
+ otpSent: !t,
709
+ oAuthTitle: c,
710
+ onOAuthSuccess: m,
711
+ onOAuthError: s,
712
+ oAuthMethods: r
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
+ ] }), kt = ({
721
+ className: r,
722
+ oAuthTitle: c = "Studio",
723
+ page: t,
724
+ magicLinkSent: a,
725
+ setMagicLinkSent: m,
726
+ oAuthMethods: s
727
+ }) => {
728
+ const { refetchLoginStatus: o } = $(), h = F(() => t?.access?.[0]?.kind === "authentication" && t?.access?.[0]?.options?.primary_method || "otp", [t?.access]), u = F(() => s || (t?.access?.[0]?.kind === "authentication" ? t?.access?.[0]?.options?.methods?.filter((i) => te.includes(i)) || [] : []), [t?.access, s]), n = () => {
729
+ o();
730
+ }, y = (i) => {
731
+ ee(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} ${r || ""}`, children: [
743
+ u.length > 0 && !a && /* @__PURE__ */ e(
744
+ gt,
745
+ {
746
+ oAuthMethods: u,
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
+ pt,
756
+ {
757
+ method: h,
758
+ onMagicLinkSent: m
759
+ }
760
+ ) })
761
+ ] });
762
+ };
763
+ export {
764
+ kt as L
765
+ };