@levo-so/site-runtime 0.2.1 → 0.2.3

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.
@@ -0,0 +1,116 @@
1
+ import { createContext as e, useContext as t, useEffect as n, useMemo as r, useRef as i } from "react";
2
+ import { jsx as a } from "react/jsx-runtime";
3
+ import { c as o } from "react/compiler-runtime";
4
+ import s from "clsx";
5
+ import { createRuntimeFn as c } from "@vanilla-extract/recipes/createRuntimeFn";
6
+ //#region ../../libraries/levocn/dist/styles/reset.cssm.js
7
+ var l = "_1er5g5a0", u = c({
8
+ defaultClassName: "_1a7d0ek1 _1a7d0ek0",
9
+ variantClassNames: {
10
+ variant: {
11
+ default: "_1a7d0ek2",
12
+ outline: "_1a7d0ek3",
13
+ secondary: "_1a7d0ek4",
14
+ ghost: "_1a7d0ek5",
15
+ destructive: "_1a7d0ek6",
16
+ link: "_1a7d0ek7"
17
+ },
18
+ size: {
19
+ default: "_1a7d0ek8",
20
+ xs: "_1a7d0ek9",
21
+ sm: "_1a7d0eka",
22
+ lg: "_1a7d0ekb",
23
+ icon: "_1a7d0ekc",
24
+ "icon-xs": "_1a7d0ekd",
25
+ "icon-sm": "_1a7d0eke",
26
+ "icon-lg": "_1a7d0ekf"
27
+ }
28
+ },
29
+ defaultVariants: {
30
+ variant: "default",
31
+ size: "default"
32
+ },
33
+ compoundVariants: []
34
+ }), d = (e) => {
35
+ let t = o(14), n, r, i, c, l;
36
+ t[0] === e ? (n = t[1], r = t[2], i = t[3], c = t[4], l = t[5]) : ({className: n, variant: l, size: i, type: c, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i, t[4] = c, t[5] = l);
37
+ let d = c === void 0 ? "button" : c, f;
38
+ t[6] !== n || t[7] !== i || t[8] !== l ? (f = s(u({
39
+ variant: l,
40
+ size: i
41
+ }), n), t[6] = n, t[7] = i, t[8] = l, t[9] = f) : f = t[9];
42
+ let p;
43
+ return t[10] !== r || t[11] !== f || t[12] !== d ? (p = /* @__PURE__ */ a("button", {
44
+ "data-slot": "button",
45
+ type: d,
46
+ className: f,
47
+ ...r
48
+ }), t[10] = r, t[11] = f, t[12] = d, t[13] = p) : p = t[13], p;
49
+ }, f = /* @__PURE__ */ new Set(), p = {}, m = e(null), h = () => {
50
+ let e = o(1), n = t(m);
51
+ if (!n) {
52
+ let t;
53
+ return e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = {
54
+ portalRef: { current: null },
55
+ classes: f,
56
+ overrides: p
57
+ }, e[0] = t) : t = e[0], t;
58
+ }
59
+ return n;
60
+ }, g = ({ children: e, cssReset: o, className: c, style: u, portalToThemeRoot: d, ...h }) => {
61
+ let g = t(m), _ = i(null), v = !g && o !== !1 ? l : "", y = g?.classes ?? f, b = g?.overrides ?? p, x = r(() => {
62
+ let e = c ? c.split(/\s+/).filter(Boolean) : [], t = new Set(y);
63
+ for (let n of e) t.add(n);
64
+ return {
65
+ portalRef: _,
66
+ classes: t,
67
+ overrides: {
68
+ ...b,
69
+ ...u
70
+ }
71
+ };
72
+ }, [
73
+ y,
74
+ c,
75
+ b,
76
+ u
77
+ ]);
78
+ n(() => {
79
+ if (d) return;
80
+ let e = document.createElement("div");
81
+ return document.body.appendChild(e), _.current = e, () => {
82
+ document.body.removeChild(e), _.current = null;
83
+ };
84
+ }, [d]), n(() => {
85
+ if (d) return;
86
+ let e = _.current;
87
+ if (!e) return;
88
+ e.className = s(v, ...x.classes), e.style.cssText = "";
89
+ let t = {
90
+ display: "contents",
91
+ ...x.overrides
92
+ };
93
+ for (let [n, r] of Object.entries(t)) r != null && e.style.setProperty(n, String(r));
94
+ }, [
95
+ x.classes,
96
+ x.overrides,
97
+ v,
98
+ d
99
+ ]);
100
+ let S = s(v, ...c ? c.split(/\s+/).filter((e) => e && !y.has(e)) : []);
101
+ return /* @__PURE__ */ a(m.Provider, {
102
+ value: x,
103
+ children: /* @__PURE__ */ a("div", {
104
+ ...d ? { ref: _ } : {},
105
+ ...S ? { className: S } : {},
106
+ style: {
107
+ display: "contents",
108
+ ...u
109
+ },
110
+ ...h,
111
+ children: e
112
+ })
113
+ });
114
+ };
115
+ //#endregion
116
+ export { u as i, g as n, d as r, h as t };
@@ -0,0 +1,67 @@
1
+ import { i as e, t } from "./ThemeProvider-BQmIB5tr.js";
2
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
3
+ import { c as i } from "react/compiler-runtime";
4
+ import a from "clsx";
5
+ import { Tooltip as o } from "@base-ui/react/tooltip";
6
+ //#region ../../libraries/levocn/dist/ui/tooltip/Tooltip.cssm.js
7
+ var s = "_3zwjqd0", c = "_3zwjqd1", l = "_3zwjqd2", u = (e) => {
8
+ let t = i(6), r, a;
9
+ t[0] === e ? (r = t[1], a = t[2]) : ({delay: a, ...r} = e, t[0] = e, t[1] = r, t[2] = a);
10
+ let s = a === void 0 ? 0 : a, c;
11
+ return t[3] !== s || t[4] !== r ? (c = /* @__PURE__ */ n(o.Provider, {
12
+ "data-slot": "tooltip-provider",
13
+ delay: s,
14
+ ...r
15
+ }), t[3] = s, t[4] = r, t[5] = c) : c = t[5], c;
16
+ }, d = (e) => {
17
+ let t = i(4), r;
18
+ t[0] === e ? r = t[1] : ({...r} = e, t[0] = e, t[1] = r);
19
+ let a;
20
+ return t[2] === r ? a = t[3] : (a = /* @__PURE__ */ n(o.Root, {
21
+ "data-slot": "tooltip",
22
+ ...r
23
+ }), t[2] = r, t[3] = a), a;
24
+ }, f = (t) => {
25
+ let r = i(12), s, c, l, u;
26
+ r[0] === t ? (s = r[1], c = r[2], l = r[3], u = r[4]) : ({className: s, variant: u, size: l, ...c} = t, r[0] = t, r[1] = s, r[2] = c, r[3] = l, r[4] = u);
27
+ let d;
28
+ r[5] !== s || r[6] !== l || r[7] !== u ? (d = a(e({
29
+ variant: u,
30
+ size: l
31
+ }), s), r[5] = s, r[6] = l, r[7] = u, r[8] = d) : d = r[8];
32
+ let f;
33
+ return r[9] !== c || r[10] !== d ? (f = /* @__PURE__ */ n(o.Trigger, {
34
+ className: d,
35
+ ...c
36
+ }), r[9] = c, r[10] = d, r[11] = f) : f = r[11], f;
37
+ }, p = (e) => {
38
+ let u = i(24), d, f, p, m, h, g, _;
39
+ u[0] === e ? (d = u[1], f = u[2], p = u[3], m = u[4], h = u[5], g = u[6], _ = u[7]) : ({className: f, side: m, sideOffset: h, align: g, alignOffset: _, children: d, ...p} = e, u[0] = e, u[1] = d, u[2] = f, u[3] = p, u[4] = m, u[5] = h, u[6] = g, u[7] = _);
40
+ let v = m === void 0 ? "top" : m, y = h === void 0 ? 8 : h, b = g === void 0 ? "center" : g, x = _ === void 0 ? 0 : _, { portalRef: S } = t(), C;
41
+ u[8] === f ? C = u[9] : (C = a(s, f), u[8] = f, u[9] = C);
42
+ let w;
43
+ u[10] === Symbol.for("react.memo_cache_sentinel") ? (w = /* @__PURE__ */ n(o.Arrow, { className: c }), u[10] = w) : w = u[10];
44
+ let T;
45
+ u[11] !== d || u[12] !== p || u[13] !== C ? (T = /* @__PURE__ */ r(o.Popup, {
46
+ "data-slot": "tooltip-content",
47
+ className: C,
48
+ ...p,
49
+ children: [d, w]
50
+ }), u[11] = d, u[12] = p, u[13] = C, u[14] = T) : T = u[14];
51
+ let E;
52
+ u[15] !== b || u[16] !== x || u[17] !== v || u[18] !== y || u[19] !== T ? (E = /* @__PURE__ */ n(o.Positioner, {
53
+ align: b,
54
+ alignOffset: x,
55
+ side: v,
56
+ sideOffset: y,
57
+ className: l,
58
+ children: T
59
+ }), u[15] = b, u[16] = x, u[17] = v, u[18] = y, u[19] = T, u[20] = E) : E = u[20];
60
+ let D;
61
+ return u[21] !== S || u[22] !== E ? (D = /* @__PURE__ */ n(o.Portal, {
62
+ container: S,
63
+ children: E
64
+ }), u[21] = S, u[22] = E, u[23] = D) : D = u[23], D;
65
+ };
66
+ //#endregion
67
+ export { u as i, f as n, p as r, d as t };
@@ -0,0 +1,191 @@
1
+ "use client";
2
+ import { d as e, i as t, n, o as r, t as i } from "./Dialog-CzVhHLEY.js";
3
+ import { r as a } from "./ThemeProvider-BQmIB5tr.js";
4
+ import { t as o } from "./CollectionInput-B1qV4QEH.js";
5
+ import { useEffect as s, useState as c } from "react";
6
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
7
+ import { toast as f } from "sonner";
8
+ import { c as p } from "react/compiler-runtime";
9
+ import m from "clsx";
10
+ import { IconCircleCheck as h, IconLoader as g } from "@tabler/icons-react";
11
+ //#region ../react/dist/components/Sonner.js
12
+ var _ = (e, t = "Error", n = {}) => {
13
+ f.error(t, {
14
+ description: e,
15
+ duration: 4e3,
16
+ position: "bottom-right",
17
+ ...n
18
+ });
19
+ }, v = (e, t = "Success", n = {}) => {
20
+ n?.id && f.dismiss(n?.id), f.success(t, {
21
+ description: e,
22
+ duration: 4e3,
23
+ position: "bottom-right",
24
+ ...n
25
+ });
26
+ }, y = "_1k4xirc1", b = (e) => {
27
+ let t = p(8), n, r;
28
+ t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
29
+ let i;
30
+ t[3] === n ? i = t[4] : (i = m(y, n), t[3] = n, t[4] = i);
31
+ let a;
32
+ return t[5] !== r || t[6] !== i ? (a = /* @__PURE__ */ u(g, {
33
+ role: "status",
34
+ "aria-label": "Loading",
35
+ className: i,
36
+ ...r
37
+ }), t[5] = r, t[6] = i, t[7] = a) : a = t[7], a;
38
+ }, x = "_6o7s4x0", S = "qkytrb0", C = "qkytrb1", w = "qkytrb2", T = "qkytrb3", E = "qkytrb4", D = "qkytrb5", O = "qkytrb6", k = ({ isOpen: l, onClose: f, value: p, type: m = "email", onVerifySuccess: h }) => {
39
+ let { membership: g } = e(), [y, b] = c(""), [k, A] = c(!1), [j, M] = c(!1), [N, P] = c(30);
40
+ return s(() => {
41
+ let e;
42
+ return l && N > 0 && (e = setInterval(() => {
43
+ P((e) => e - 1);
44
+ }, 1e3)), () => clearInterval(e);
45
+ }, [l, N]), s(() => {
46
+ l && (b(""), P(30), A(!1), M(!1));
47
+ }, [l]), /* @__PURE__ */ u(r, {
48
+ open: l,
49
+ onOpenChange: (e) => {
50
+ e || f();
51
+ },
52
+ children: /* @__PURE__ */ d(n, {
53
+ className: x,
54
+ children: [/* @__PURE__ */ u(i, { children: /* @__PURE__ */ u(t, { children: `Verify ${m === "email" ? "Email" : "Phone"}` }) }), /* @__PURE__ */ d("div", {
55
+ className: S,
56
+ children: [
57
+ /* @__PURE__ */ d("div", {
58
+ className: C,
59
+ children: [
60
+ "Enter the 4-digit code sent to ",
61
+ /* @__PURE__ */ u("strong", { children: p }),
62
+ ".",
63
+ " ",
64
+ /* @__PURE__ */ u("button", {
65
+ onClick: () => f(),
66
+ className: w,
67
+ children: "Change?"
68
+ })
69
+ ]
70
+ }),
71
+ /* @__PURE__ */ u("div", {
72
+ className: T,
73
+ children: /* @__PURE__ */ u(o, {
74
+ value: y,
75
+ onChange: (e) => {
76
+ b(e.target.value.replace(/\D/g, "").slice(0, 4));
77
+ },
78
+ placeholder: "0000",
79
+ maxLength: 4,
80
+ className: D
81
+ })
82
+ }),
83
+ /* @__PURE__ */ d("div", {
84
+ className: E,
85
+ children: [/* @__PURE__ */ u(a, {
86
+ onClick: async () => {
87
+ if (!(!y || y.length !== 4)) {
88
+ A(!0);
89
+ try {
90
+ await g?.signInWithOtp({
91
+ content: p,
92
+ code: y
93
+ }), v("Verification successful"), h(p), f();
94
+ } catch (e) {
95
+ let t = e;
96
+ _(t?.message || "Invalid OTP", t?.title || "Verification Failed");
97
+ } finally {
98
+ A(!1);
99
+ }
100
+ }
101
+ },
102
+ disabled: y.length !== 4 || k,
103
+ className: "w-full",
104
+ children: k ? "Verifying..." : "Verify"
105
+ }), /* @__PURE__ */ u("div", {
106
+ className: O,
107
+ children: N > 0 ? /* @__PURE__ */ d("span", { children: [
108
+ "Resend code in ",
109
+ N,
110
+ "s"
111
+ ] }) : /* @__PURE__ */ u("button", {
112
+ onClick: async () => {
113
+ if (!(N > 0)) {
114
+ M(!0);
115
+ try {
116
+ await g?.requestOtp({
117
+ content: p,
118
+ medium: m === "phone" ? "whatsapp" : "email"
119
+ }), v("OTP resent successfully"), P(30);
120
+ } catch (e) {
121
+ let t = e;
122
+ _(t?.message || "Failed to resend OTP", t?.title || "Error");
123
+ } finally {
124
+ M(!1);
125
+ }
126
+ }
127
+ },
128
+ disabled: j,
129
+ className: w,
130
+ children: j ? "Resending..." : "Resend Code"
131
+ })
132
+ })]
133
+ })
134
+ ]
135
+ })]
136
+ })
137
+ });
138
+ }, A = "jfrbe10", j = "jfrbe11", M = "jfrbe12", N = ({ value: t, type: n, isVerified: r, onVerifySuccess: i, onStateChange: o }) => {
139
+ let { membership: s } = e(), [f, p] = c(!1), [m, g] = c(!1), v = (e) => {
140
+ o && o(e);
141
+ }, y = async () => {
142
+ let e = t?.trim()?.toLowerCase();
143
+ if (!e) {
144
+ _(`Please enter a ${n}`);
145
+ return;
146
+ }
147
+ if (n === "email" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)) {
148
+ _("Please enter a valid email address");
149
+ return;
150
+ }
151
+ g(!0), v(!0);
152
+ try {
153
+ await s?.requestOtp({
154
+ content: e,
155
+ medium: n === "phone" ? "whatsapp" : "email"
156
+ }), p(!0);
157
+ } catch (e) {
158
+ let t = e;
159
+ _(t?.message || "Failed to send OTP", t?.title || "Error"), v(!1);
160
+ } finally {
161
+ g(!1);
162
+ }
163
+ }, x = () => {
164
+ p(!1), v(!1);
165
+ };
166
+ return r ? /* @__PURE__ */ d("div", {
167
+ className: A,
168
+ children: [/* @__PURE__ */ u(h, { className: M }), /* @__PURE__ */ u("span", {
169
+ className: j,
170
+ children: "Verified"
171
+ })]
172
+ }) : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(a, {
173
+ size: "default",
174
+ variant: "ghost",
175
+ onClick: y,
176
+ onMouseDown: (e) => e.preventDefault(),
177
+ disabled: !t || m,
178
+ type: "button",
179
+ children: m ? /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(b, { size: 14 }), "Sending..."] }) : "Verify"
180
+ }), f && /* @__PURE__ */ u(k, {
181
+ isOpen: f,
182
+ onClose: x,
183
+ value: t?.trim()?.toLowerCase() || "",
184
+ type: n,
185
+ onVerifySuccess: (e) => {
186
+ i(e), x();
187
+ }
188
+ })] });
189
+ };
190
+ //#endregion
191
+ export { _ as a, v as i, x as n, b as r, N as t };
@@ -0,0 +1,80 @@
1
+ import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
2
+ import { d as t } from "./Dialog-CzVhHLEY.js";
3
+ import { a as n, c as r, g as i, h as a, l as o, n as s, r as c, t as l } from "./PopupRenderer-Bncp54gB-DuCULkBK.js";
4
+ import { Suspense as u, lazy as d, useEffect as f, useRef as p, useState as m } from "react";
5
+ import { jsx as h } from "react/jsx-runtime";
6
+ import { c as g } from "react/compiler-runtime";
7
+ import "clsx";
8
+ import "@tabler/icons-react";
9
+ import { $isIdentityContextReady as _ } from "@levo-so/insights/stores";
10
+ //#region ../../libraries/popups/dist/index.js
11
+ var v = /* @__PURE__ */ e({
12
+ PopupLoader: () => x,
13
+ fetchActivePopups: () => y,
14
+ usePopup: () => C
15
+ }), y = async (e, t) => {
16
+ let n = {};
17
+ return t?.site_id && (n.site_id = t.site_id), t?.locale && (n.locale = t.locale), t?.country && (n.country = t.country), (await e.url("/v1/studio/popup/list-active").query(n).get().json())?.content?.data ?? [];
18
+ }, b = d(() => import("./PopupRenderer-Bncp54gB-DuCULkBK.js").then((e) => e.o).then((e) => e.t).then((e) => ({ default: e.PopupRenderer }))), x = (e) => {
19
+ let n = g(9), { siteId: r, pageId: i } = e, { fetch: a, logger: o } = t(), [c, l] = m(null), d = p(!1), v, x;
20
+ if (n[0] !== a || n[1] !== o || n[2] !== r ? (v = () => {
21
+ if (d.current) return;
22
+ let e = () => {
23
+ d.current || (d.current = !0, y(a, r ? { site_id: r } : void 0).then((e) => {
24
+ s(e), l(e);
25
+ }).catch((e) => {
26
+ o?.error("Failed to fetch popups", { exception: e }), s([]), l([]);
27
+ }).finally(S));
28
+ };
29
+ if (_.get()) {
30
+ e();
31
+ return;
32
+ }
33
+ let t = _.listen((n) => {
34
+ n && (t(), e());
35
+ });
36
+ return () => t();
37
+ }, x = [
38
+ a,
39
+ o,
40
+ r
41
+ ], n[0] = a, n[1] = o, n[2] = r, n[3] = v, n[4] = x) : (v = n[3], x = n[4]), f(v, x), !c || c.length === 0) return null;
42
+ let C;
43
+ n[5] === Symbol.for("react.memo_cache_sentinel") ? (C = {
44
+ position: "relative",
45
+ zIndex: 99999
46
+ }, n[5] = C) : C = n[5];
47
+ let w;
48
+ return n[6] !== i || n[7] !== c ? (w = /* @__PURE__ */ h("div", {
49
+ style: C,
50
+ children: /* @__PURE__ */ h(u, { children: /* @__PURE__ */ h(b, {
51
+ popups: c,
52
+ pageId: i
53
+ }) })
54
+ }), n[6] = i, n[7] = c, n[8] = w) : w = n[8], w;
55
+ };
56
+ function S() {
57
+ return c(!1);
58
+ }
59
+ var C = () => {
60
+ let e = g(3), t = i(r), n = i(o), a = w, s = T, c;
61
+ return e[0] !== n || e[1] !== t ? (c = {
62
+ popups: t,
63
+ isLoading: n,
64
+ openPopup: a,
65
+ closePopup: s
66
+ }, e[0] = n, e[1] = t, e[2] = c) : c = e[2], c;
67
+ };
68
+ function w(e) {
69
+ let t = r.get().find((t) => t.id === e);
70
+ t && n(t, {
71
+ force: !0,
72
+ trigger_type: "manual"
73
+ });
74
+ }
75
+ function T() {
76
+ let e = a.get().active_popup_id;
77
+ e && l(e);
78
+ }
79
+ //#endregion
80
+ export { v as n, C as t };