@levo-so/react 0.1.78 → 0.1.80
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.
- package/dist/index.js +611 -80
- package/package.json +6 -6
- package/dist/audience/components/block.js +0 -32
- package/dist/audience/components/component.js +0 -13
- package/dist/audience/components/page.js +0 -19
- package/dist/components/Dialog.js +0 -84
- package/dist/components/DialogWrapper.js +0 -20
- package/dist/components/Sonner.js +0 -41
- package/dist/components/Spinner.js +0 -8
- package/dist/components/Tabs.js +0 -48
- package/dist/components/Tooltip.js +0 -30
- package/dist/components/button/Button.js +0 -41
- package/dist/components/button/buttonVariants.js +0 -40
- package/dist/constants/fileUploadPresets.js +0 -75
- package/dist/membership/components/Button.js +0 -13
- package/dist/membership/components/Container.js +0 -52
- package/dist/membership/components/Core.js +0 -33
- package/dist/membership/components/Popup.js +0 -56
- package/dist/membership/index.js +0 -9
- package/dist/membership/useLevoOAuth.js +0 -76
- package/dist/providers/LevoProvider.js +0 -19
- package/dist/utils/byteToSize.js +0 -9
- package/dist/utils/cn.js +0 -7
- package/dist/utils/errorHandler.js +0 -11
- package/dist/utils/isDateObject.js +0 -4
- package/dist/utils/isEmptyObject.js +0 -5
- package/dist/utils/isNullOrUndefined.js +0 -4
- package/dist/utils/isObject.js +0 -7
- /package/dist/{styles/index.css → index.css} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,82 +1,613 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { Toaster as
|
|
12
|
-
import { toast as
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as s, jsxs as L, Fragment as J } from "react/jsx-runtime";
|
|
3
|
+
import * as w from "react";
|
|
4
|
+
import Q, { createContext as Z, useContext as D, useState as y, useEffect as h, useMemo as S, useRef as W, useCallback as j } from "react";
|
|
5
|
+
import { BiLoaderAlt as U } from "react-icons/bi";
|
|
6
|
+
import { clsx as q } from "clsx";
|
|
7
|
+
import { twMerge as _ } from "tailwind-merge";
|
|
8
|
+
import { Slot as ee, Dialog as p, Tabs as N, Tooltip as C } from "radix-ui";
|
|
9
|
+
import { cva as te } from "class-variance-authority";
|
|
10
|
+
import { X as oe } from "lucide-react";
|
|
11
|
+
import { Toaster as ne, toast as B } from "sonner";
|
|
12
|
+
import { toast as pt } from "sonner";
|
|
13
|
+
import { getLevoError as z } from "@levo-so/core";
|
|
14
|
+
const I = Z({
|
|
15
|
+
client: null,
|
|
16
|
+
insights: null
|
|
17
|
+
}), Ke = ({ children: e, client: t, insights: o = null }) => /* @__PURE__ */ s(I.Provider, { value: { client: t, insights: o }, children: e }), $ = () => {
|
|
18
|
+
const e = D(I);
|
|
19
|
+
if (!e.client)
|
|
20
|
+
throw new Error(
|
|
21
|
+
"useLevo must be used within a LevoProvider. Please ensure you have wrapped your component tree with LevoProvider."
|
|
22
|
+
);
|
|
23
|
+
return e.client;
|
|
24
|
+
}, M = () => D(I).insights, Ve = ({ id: e, properties: t = {} }) => {
|
|
25
|
+
const o = M(), [n, a] = y(!1);
|
|
26
|
+
return h(() => {
|
|
27
|
+
if (n || typeof o?.track != "function") return;
|
|
28
|
+
const r = document.getElementById(e);
|
|
29
|
+
if (!r) return;
|
|
30
|
+
const c = () => {
|
|
31
|
+
n || (o?.track("block.view", {
|
|
32
|
+
...t,
|
|
33
|
+
resource: "block",
|
|
34
|
+
identifier: e
|
|
35
|
+
}), a(!0));
|
|
36
|
+
}, i = new IntersectionObserver(
|
|
37
|
+
(m) => {
|
|
38
|
+
m.forEach((d) => {
|
|
39
|
+
d.isIntersecting && (c(), i.disconnect());
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
{ threshold: 0 }
|
|
43
|
+
);
|
|
44
|
+
return i.observe(r), () => {
|
|
45
|
+
i.disconnect();
|
|
46
|
+
};
|
|
47
|
+
}, [o, e, t, n]), null;
|
|
48
|
+
}, Xe = ({ event: e, properties: t }) => {
|
|
49
|
+
const o = M();
|
|
50
|
+
return h(() => {
|
|
51
|
+
o?.track(e, t);
|
|
52
|
+
}, [o, e, t]), null;
|
|
53
|
+
}, Ye = ({ id: e }) => {
|
|
54
|
+
const t = $(), o = M();
|
|
55
|
+
return h(() => {
|
|
56
|
+
t && typeof window < "u" && (window.levo_client = t);
|
|
57
|
+
}, [t]), h(() => {
|
|
58
|
+
o && typeof window < "u" && (window.levo_insights = o);
|
|
59
|
+
}, [o]), h(() => {
|
|
60
|
+
o && e && o.init({
|
|
61
|
+
pageId: e
|
|
62
|
+
});
|
|
63
|
+
}, [o, e]), null;
|
|
64
|
+
}, g = (...e) => _(q(e)), se = te(
|
|
65
|
+
"inline-flex items-center justify-center font-medium text-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
66
|
+
{
|
|
67
|
+
variants: {
|
|
68
|
+
variant: {
|
|
69
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
70
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90",
|
|
71
|
+
destructiveOutline: "border border-red-500 bg-transparent text-destructive shadow-sm hover:bg-destructive hover:text-white",
|
|
72
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
73
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
74
|
+
secondaryOutline: "border border-white border-solid bg-transparent hover:border-input hover:bg-white",
|
|
75
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
76
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
77
|
+
},
|
|
78
|
+
size: {
|
|
79
|
+
default: "h-10 px-4 py-2",
|
|
80
|
+
xs: "h-8 px-3 text-xs",
|
|
81
|
+
sm: "h-9 px-3",
|
|
82
|
+
lg: "h-11 px-8",
|
|
83
|
+
icon: "h-10 w-10",
|
|
84
|
+
"icon-small": "h-8 w-8"
|
|
85
|
+
},
|
|
86
|
+
rounded: {
|
|
87
|
+
small: "rounded",
|
|
88
|
+
default: "rounded-md",
|
|
89
|
+
large: "rounded-lg",
|
|
90
|
+
full: "rounded-full"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
defaultVariants: {
|
|
94
|
+
variant: "default",
|
|
95
|
+
size: "default",
|
|
96
|
+
rounded: "default"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
), re = w.forwardRef(
|
|
100
|
+
({
|
|
101
|
+
className: e,
|
|
102
|
+
variant: t,
|
|
103
|
+
size: o,
|
|
104
|
+
rounded: n,
|
|
105
|
+
asChild: a = !1,
|
|
106
|
+
isLoading: r = !1,
|
|
107
|
+
loadingText: c,
|
|
108
|
+
disabled: i,
|
|
109
|
+
...m
|
|
110
|
+
}, d) => {
|
|
111
|
+
const v = a ? ee.Root : "button";
|
|
112
|
+
return /* @__PURE__ */ s(
|
|
113
|
+
v,
|
|
114
|
+
{
|
|
115
|
+
className: g(se({ variant: t, size: o, rounded: n, className: e })),
|
|
116
|
+
ref: d,
|
|
117
|
+
disabled: i || r,
|
|
118
|
+
type: "button",
|
|
119
|
+
...m,
|
|
120
|
+
children: r ? /* @__PURE__ */ L(J, { children: [
|
|
121
|
+
/* @__PURE__ */ s(U, { className: _("h-4 w-4 animate-spin", c ? "mr-2" : "") }),
|
|
122
|
+
c
|
|
123
|
+
] }) : m.children
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
re.displayName = "Button";
|
|
129
|
+
const ie = p.Root, Je = p.Trigger, ae = p.Portal, Qe = p.Close, F = w.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ s(
|
|
130
|
+
p.Overlay,
|
|
131
|
+
{
|
|
132
|
+
ref: o,
|
|
133
|
+
className: g(
|
|
134
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 grid max-h-screen place-items-center overflow-y-auto bg-background/80 py-10 backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
135
|
+
e
|
|
136
|
+
),
|
|
137
|
+
...t
|
|
138
|
+
}
|
|
139
|
+
));
|
|
140
|
+
F.displayName = p.Overlay.displayName;
|
|
141
|
+
const H = w.forwardRef(({ className: e, children: t, container: o, hideCloseButton: n, overlayStyles: a, ...r }, c) => /* @__PURE__ */ s(ae, { container: o, children: /* @__PURE__ */ s(F, { className: a, children: /* @__PURE__ */ L(
|
|
142
|
+
p.Content,
|
|
143
|
+
{
|
|
144
|
+
ref: c,
|
|
145
|
+
className: g(
|
|
146
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-50 grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:rounded-lg",
|
|
147
|
+
e
|
|
148
|
+
),
|
|
149
|
+
...r,
|
|
150
|
+
children: [
|
|
151
|
+
t,
|
|
152
|
+
!n && /* @__PURE__ */ L(
|
|
153
|
+
p.Close,
|
|
154
|
+
{
|
|
155
|
+
type: "button",
|
|
156
|
+
className: "absolute top-4 right-4 rounded-sm p-1 opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ s(oe, { className: "h-4 w-4" }),
|
|
159
|
+
/* @__PURE__ */ s("span", { className: "sr-only", children: "Close" })
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
) }) }));
|
|
166
|
+
H.displayName = p.Content.displayName;
|
|
167
|
+
const G = ({ className: e, ...t }) => /* @__PURE__ */ s("div", { className: g("flex flex-col space-y-1.5 text-center sm:text-left", e), ...t });
|
|
168
|
+
G.displayName = "DialogHeader";
|
|
169
|
+
const ce = ({ className: e, ...t }) => /* @__PURE__ */ s(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
className: g("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", e),
|
|
173
|
+
...t
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
ce.displayName = "DialogFooter";
|
|
177
|
+
const K = w.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ s(
|
|
178
|
+
p.Title,
|
|
179
|
+
{
|
|
180
|
+
ref: o,
|
|
181
|
+
className: g("font-semibold text-lg leading-none tracking-tight", e),
|
|
182
|
+
...t
|
|
183
|
+
}
|
|
184
|
+
));
|
|
185
|
+
K.displayName = p.Title.displayName;
|
|
186
|
+
const V = w.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ s(
|
|
187
|
+
p.Description,
|
|
188
|
+
{
|
|
189
|
+
ref: o,
|
|
190
|
+
className: g("text-muted-foreground text-sm", e),
|
|
191
|
+
...t
|
|
192
|
+
}
|
|
193
|
+
));
|
|
194
|
+
V.displayName = p.Description.displayName;
|
|
195
|
+
const Ze = ({
|
|
196
|
+
isOpen: e,
|
|
197
|
+
onClose: t,
|
|
198
|
+
children: o,
|
|
199
|
+
title: n,
|
|
200
|
+
description: a = "",
|
|
201
|
+
contentClassName: r,
|
|
202
|
+
modal: c = !0
|
|
203
|
+
}) => /* @__PURE__ */ s(ie, { open: e, onOpenChange: t, modal: c, children: /* @__PURE__ */ L(H, { className: r, children: [
|
|
204
|
+
n && /* @__PURE__ */ L(G, { className: "flex-1 font-medium", children: [
|
|
205
|
+
/* @__PURE__ */ s(K, { children: n }),
|
|
206
|
+
/* @__PURE__ */ s(V, { children: a })
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ s("div", { className: "w-full", children: o })
|
|
209
|
+
] }) }), qe = ({ ...e }) => /* @__PURE__ */ s(
|
|
210
|
+
ne,
|
|
211
|
+
{
|
|
212
|
+
closeButton: !0,
|
|
213
|
+
richColors: !0,
|
|
214
|
+
className: "toaster group",
|
|
215
|
+
toastOptions: {
|
|
216
|
+
classNames: {
|
|
217
|
+
toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
|
218
|
+
description: "group-[.toast]:text-muted-foreground",
|
|
219
|
+
actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
|
220
|
+
cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
...e
|
|
224
|
+
}
|
|
225
|
+
), le = (e, t = "Error", o = {}) => {
|
|
226
|
+
B.error(t, {
|
|
227
|
+
description: e,
|
|
228
|
+
duration: 4e3,
|
|
229
|
+
position: "bottom-right",
|
|
230
|
+
...o
|
|
231
|
+
});
|
|
232
|
+
}, et = (e, t = "Success", o = {}) => {
|
|
233
|
+
o?.id && B.dismiss(o?.id), B.success(t, {
|
|
234
|
+
description: e,
|
|
235
|
+
duration: 4e3,
|
|
236
|
+
position: "bottom-right",
|
|
237
|
+
...o
|
|
238
|
+
});
|
|
239
|
+
}, de = ({ className: e }) => /* @__PURE__ */ s(U, { className: g("h-8 w-8 animate-spin font-light", e) }), tt = N.Root, ue = w.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ s(
|
|
240
|
+
N.List,
|
|
241
|
+
{
|
|
242
|
+
ref: o,
|
|
243
|
+
className: g(
|
|
244
|
+
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
245
|
+
e
|
|
246
|
+
),
|
|
247
|
+
...t
|
|
248
|
+
}
|
|
249
|
+
));
|
|
250
|
+
ue.displayName = N.List.displayName;
|
|
251
|
+
const me = w.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ s(
|
|
252
|
+
N.Trigger,
|
|
253
|
+
{
|
|
254
|
+
ref: o,
|
|
255
|
+
className: g(
|
|
256
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 font-medium text-sm ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
257
|
+
e
|
|
258
|
+
),
|
|
259
|
+
"data-levo-studio-interactive": "true",
|
|
260
|
+
...t
|
|
261
|
+
}
|
|
262
|
+
));
|
|
263
|
+
me.displayName = N.Trigger.displayName;
|
|
264
|
+
const pe = w.forwardRef(({ className: e, ...t }, o) => /* @__PURE__ */ s(
|
|
265
|
+
N.Content,
|
|
266
|
+
{
|
|
267
|
+
ref: o,
|
|
268
|
+
className: g(
|
|
269
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
270
|
+
e
|
|
271
|
+
),
|
|
272
|
+
...t
|
|
273
|
+
}
|
|
274
|
+
));
|
|
275
|
+
pe.displayName = N.Content.displayName;
|
|
276
|
+
const ot = C.Provider, fe = C.Root, ge = C.Trigger, ve = C.Portal, X = w.forwardRef(({ className: e, sideOffset: t = 4, ...o }, n) => /* @__PURE__ */ s(
|
|
277
|
+
C.Content,
|
|
278
|
+
{
|
|
279
|
+
ref: n,
|
|
280
|
+
sideOffset: t,
|
|
281
|
+
className: g(
|
|
282
|
+
"fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 animate-in overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-popover-foreground text-xs shadow-md data-[state=closed]:animate-out",
|
|
283
|
+
e
|
|
284
|
+
),
|
|
285
|
+
...o
|
|
286
|
+
}
|
|
287
|
+
));
|
|
288
|
+
X.displayName = C.Content.displayName;
|
|
289
|
+
const nt = ({ children: e, label: t, labelClassName: o, asChild: n = !0, contentProps: a = {}, side: r }) => /* @__PURE__ */ L(fe, { children: [
|
|
290
|
+
t && /* @__PURE__ */ s(ve, { children: /* @__PURE__ */ s(X, { side: r, className: o, ...a, children: t }) }),
|
|
291
|
+
/* @__PURE__ */ s(ge, { asChild: n, children: e })
|
|
292
|
+
] }), he = [
|
|
293
|
+
"pdf",
|
|
294
|
+
"txt",
|
|
295
|
+
"xml",
|
|
296
|
+
"xls",
|
|
297
|
+
"xlsx",
|
|
298
|
+
"ods",
|
|
299
|
+
"odt",
|
|
300
|
+
"doc",
|
|
301
|
+
"docx",
|
|
302
|
+
"csv",
|
|
303
|
+
"odp",
|
|
304
|
+
"ppt",
|
|
305
|
+
"pptx"
|
|
306
|
+
], be = ["svg", "png", "jpg", "jpeg", "gif", "webp", "avif"], we = ["mp4", "ogv", "webm"], xe = ["mp3", "ogg", "opus"], ye = {
|
|
307
|
+
"application/xml": [".xml"],
|
|
308
|
+
"text/plain": [".txt"],
|
|
309
|
+
"application/pdf": [".pdf"],
|
|
310
|
+
"application/msword": [".doc"],
|
|
311
|
+
"application/vnd.ms-excel": [".xls"],
|
|
312
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
|
313
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
|
|
314
|
+
"text/csv": [".csv"]
|
|
315
|
+
}, Ne = {
|
|
316
|
+
"image/jpeg": [".jpeg", ".jpg"],
|
|
317
|
+
"image/jpg": [".jpg"],
|
|
318
|
+
"image/png": [".png"],
|
|
319
|
+
"image/gif": [".gif"],
|
|
320
|
+
"image/svg": [".svg"],
|
|
321
|
+
"image/svg+xml": [".svg"],
|
|
322
|
+
"image/webp": [".webp"],
|
|
323
|
+
"image/avif": [".avif"]
|
|
324
|
+
}, Te = {
|
|
325
|
+
"video/mp4": [".mp4"],
|
|
326
|
+
"video/mpeg": [".mpeg"],
|
|
327
|
+
"video/webm": [".webm"]
|
|
328
|
+
}, Le = {
|
|
329
|
+
"audio/mpeg": [".mp3"],
|
|
330
|
+
"audio/ogg": [".oga"],
|
|
331
|
+
"audio/opus": [".opus"]
|
|
332
|
+
}, k = {
|
|
333
|
+
audio: Le,
|
|
334
|
+
document: ye,
|
|
335
|
+
image: Ne,
|
|
336
|
+
video: Te
|
|
337
|
+
}, E = {
|
|
338
|
+
audio: xe,
|
|
339
|
+
document: he,
|
|
340
|
+
image: be,
|
|
341
|
+
video: we
|
|
342
|
+
}, st = [
|
|
343
|
+
...E.audio,
|
|
344
|
+
...E.document,
|
|
345
|
+
...E.image,
|
|
346
|
+
...E.video
|
|
347
|
+
], rt = {
|
|
348
|
+
...k.audio,
|
|
349
|
+
...k.document,
|
|
350
|
+
...k.image,
|
|
351
|
+
...k.video
|
|
352
|
+
}, Y = Q.createContext({
|
|
353
|
+
urls: null,
|
|
354
|
+
title: "",
|
|
355
|
+
isLoading: !1,
|
|
356
|
+
onSuccess: () => {
|
|
357
|
+
},
|
|
358
|
+
onError: () => {
|
|
359
|
+
}
|
|
360
|
+
}), Ce = ({ title: e, onSuccess: t, onError: o, children: n }) => {
|
|
361
|
+
const a = $(), r = typeof window < "u" ? window.location.href : "", [c, i] = y(null), [m, d] = y(!1);
|
|
362
|
+
h(() => {
|
|
363
|
+
a.membership && (d(!0), a.membership?.getOAuthURL().then((l) => {
|
|
364
|
+
i(l);
|
|
365
|
+
}).catch((l) => {
|
|
366
|
+
o({
|
|
367
|
+
code: l?.code || "SOMETHING_WENT_WRONG",
|
|
368
|
+
message: l?.message || "We could not connect with our service for your sign-in."
|
|
369
|
+
});
|
|
370
|
+
}).finally(() => {
|
|
371
|
+
d(!1);
|
|
372
|
+
}));
|
|
373
|
+
}, []);
|
|
374
|
+
const v = S(
|
|
375
|
+
() => ({ title: e, urls: c, isLoading: m, onSuccess: t, onError: o }),
|
|
376
|
+
[e, c, t, o, m]
|
|
377
|
+
);
|
|
378
|
+
return h(() => {
|
|
379
|
+
if (c && r) {
|
|
380
|
+
const l = {}, T = Object.keys(c);
|
|
381
|
+
for (const x of T)
|
|
382
|
+
try {
|
|
383
|
+
const b = c[x];
|
|
384
|
+
if (b) {
|
|
385
|
+
const O = new URL(b), R = O.searchParams;
|
|
386
|
+
R.set("redirect_uri", r);
|
|
387
|
+
const P = a.pageContext;
|
|
388
|
+
P && R.set("page_context", JSON.stringify(P)), l[x] = O.toString();
|
|
389
|
+
}
|
|
390
|
+
} catch {
|
|
391
|
+
}
|
|
392
|
+
i(l);
|
|
393
|
+
}
|
|
394
|
+
}, [r]), /* @__PURE__ */ s(Y.Provider, { value: v, children: n });
|
|
395
|
+
}, Oe = () => D(Y), Re = ({ url: e, title: t, height: o, width: n }) => {
|
|
396
|
+
const a = window.screenX + (window.outerWidth - n) / 2, r = window.screenY + (window.outerHeight - o) / 2.5;
|
|
397
|
+
return window.open(
|
|
398
|
+
e,
|
|
399
|
+
t,
|
|
400
|
+
`width=${n},height=${o},left=${a},top=${r}`
|
|
401
|
+
);
|
|
402
|
+
}, ke = ({
|
|
403
|
+
title: e = "",
|
|
404
|
+
width: t = 500,
|
|
405
|
+
height: o = 500,
|
|
406
|
+
url: n,
|
|
407
|
+
children: a,
|
|
408
|
+
onCode: r,
|
|
409
|
+
onClose: c
|
|
410
|
+
}) => {
|
|
411
|
+
const [i, m] = y(), d = W(void 0), v = () => {
|
|
412
|
+
window.clearInterval(d.current);
|
|
413
|
+
}, l = () => {
|
|
414
|
+
m(
|
|
415
|
+
Re({
|
|
416
|
+
url: n,
|
|
417
|
+
title: e,
|
|
418
|
+
width: t,
|
|
419
|
+
height: o
|
|
420
|
+
})
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
return h(() => (i && (d.current = window.setInterval(() => {
|
|
424
|
+
try {
|
|
425
|
+
const T = i.location.href, x = new URL(T).searchParams, b = x.get("code");
|
|
426
|
+
if (!b)
|
|
427
|
+
return;
|
|
428
|
+
r(b, x), v(), i.close();
|
|
429
|
+
} catch {
|
|
430
|
+
} finally {
|
|
431
|
+
(!i || i.closed) && (c(), v());
|
|
432
|
+
}
|
|
433
|
+
}, 700)), () => {
|
|
434
|
+
i && i.close(), c && c();
|
|
435
|
+
}), [i]), /* @__PURE__ */ s(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
onClick: () => {
|
|
439
|
+
l();
|
|
440
|
+
},
|
|
441
|
+
children: a
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
}, Ee = ({
|
|
445
|
+
title: e = "Levo",
|
|
446
|
+
url: t,
|
|
447
|
+
children: o,
|
|
448
|
+
onSuccess: n,
|
|
449
|
+
onError: a,
|
|
450
|
+
width: r = 500,
|
|
451
|
+
height: c = 700
|
|
452
|
+
}) => {
|
|
453
|
+
const i = j((m, d) => {
|
|
454
|
+
m.toLowerCase() === "success" ? n(d) : a(d);
|
|
455
|
+
}, []);
|
|
456
|
+
return /* @__PURE__ */ s(
|
|
457
|
+
ke,
|
|
458
|
+
{
|
|
459
|
+
title: e,
|
|
460
|
+
width: r,
|
|
461
|
+
height: c,
|
|
462
|
+
onClose: () => {
|
|
463
|
+
},
|
|
464
|
+
url: t,
|
|
465
|
+
onCode: i,
|
|
466
|
+
children: o
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
}, Pe = ({ children: e, provider: t }) => {
|
|
470
|
+
const { title: o, urls: n, isLoading: a, onSuccess: r, onError: c } = Oe(), i = n?.[t];
|
|
471
|
+
return i ? /* @__PURE__ */ s(Ee, { title: o, provider: t, url: i, onSuccess: r, onError: c, children: a ? /* @__PURE__ */ s("div", { className: "w-full items-center justify-center", children: /* @__PURE__ */ s(de, { className: "h-5 w-5 bg-brand" }) }) : e }) : null;
|
|
472
|
+
}, je = ({ url: e, title: t, height: o, width: n }) => {
|
|
473
|
+
const a = window.screenX + (window.outerWidth - n) / 2, r = window.screenY + (window.outerHeight - o) / 2.5;
|
|
474
|
+
return window.open(
|
|
475
|
+
e,
|
|
476
|
+
t,
|
|
477
|
+
`width=${n},height=${o},left=${a},top=${r}`
|
|
478
|
+
);
|
|
479
|
+
}, it = ({
|
|
480
|
+
title: e = "Levo",
|
|
481
|
+
width: t = 500,
|
|
482
|
+
height: o = 700,
|
|
483
|
+
onSuccess: n
|
|
484
|
+
}) => {
|
|
485
|
+
const a = $(), [r, c] = y(!1), [i, m] = y(null), [d, v] = y(null), [l, T] = y(), x = W(void 0), b = () => {
|
|
486
|
+
window.clearInterval(x.current);
|
|
487
|
+
}, O = j((u, f) => {
|
|
488
|
+
u.toLowerCase() === "success" ? (v(null), n(f)) : v(f);
|
|
489
|
+
}, []);
|
|
490
|
+
h(() => {
|
|
491
|
+
a.membership && (c(!0), a.membership?.getOAuthURL().then((u) => {
|
|
492
|
+
if (u)
|
|
493
|
+
return m(u), u;
|
|
494
|
+
throw new Error();
|
|
495
|
+
}).catch((u) => {
|
|
496
|
+
const f = z(u);
|
|
497
|
+
a.logger?.error("Failed to get OAuth URL", f.message), v({
|
|
498
|
+
code: f?.code || "SOMETHING_WENT_WRONG",
|
|
499
|
+
message: f?.message || "We could not connect with our service for your sign-in."
|
|
500
|
+
});
|
|
501
|
+
}).finally(() => {
|
|
502
|
+
c(!1);
|
|
503
|
+
}));
|
|
504
|
+
}, []), h(() => (l && (x.current = window.setInterval(() => {
|
|
505
|
+
try {
|
|
506
|
+
const u = l.location.href, f = new URL(u).searchParams, A = f.get("code");
|
|
507
|
+
if (!A)
|
|
508
|
+
return;
|
|
509
|
+
O(A, f), b(), l.close();
|
|
510
|
+
} catch {
|
|
511
|
+
} finally {
|
|
512
|
+
(!l || l.closed) && (b(), v(null));
|
|
513
|
+
}
|
|
514
|
+
}, 700)), () => {
|
|
515
|
+
l && l.close();
|
|
516
|
+
}), [l]);
|
|
517
|
+
const R = j(
|
|
518
|
+
(u) => {
|
|
519
|
+
if (u && i !== null) {
|
|
520
|
+
const f = i?.[u];
|
|
521
|
+
f && (l && l.close(), T(
|
|
522
|
+
je({
|
|
523
|
+
url: f,
|
|
524
|
+
title: e,
|
|
525
|
+
width: t,
|
|
526
|
+
height: o
|
|
527
|
+
})
|
|
528
|
+
));
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
[i, l]
|
|
532
|
+
);
|
|
533
|
+
return {
|
|
534
|
+
providers: S(() => i !== null ? Object.keys(i).filter(
|
|
535
|
+
(u) => !!i[u]
|
|
536
|
+
) : [], [i]),
|
|
537
|
+
isLoading: r,
|
|
538
|
+
error: d,
|
|
539
|
+
launchPopup: R
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
class at {
|
|
543
|
+
static Container = Ce;
|
|
544
|
+
static Button = Pe;
|
|
545
|
+
}
|
|
546
|
+
const ct = (e, t = 2) => {
|
|
547
|
+
if (e === 0) return "0 B";
|
|
548
|
+
const o = 1024, n = t < 0 ? 0 : t, a = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], r = Math.floor(Math.log(e) / Math.log(o));
|
|
549
|
+
return `${Number.parseFloat((e / o ** r).toFixed(n))} ${a[r]}`;
|
|
550
|
+
}, lt = (e) => {
|
|
551
|
+
const t = z(e);
|
|
552
|
+
return t?.code === "REQUEST_TIMEOUT" || t?.code === "NETWORK_ERROR" || t?.status === 408 || t?.status === 0 || le(t?.message || "", t?.title || "Error", {
|
|
553
|
+
id: `${t?.title || ""}-${t?.message || ""}`
|
|
554
|
+
}), t;
|
|
555
|
+
}, Be = (e) => e instanceof Date, De = (e) => e == null, Ie = (e) => typeof e == "object", $e = (e) => !De(e) && !Array.isArray(e) && Ie(e) && !Be(e), dt = (e) => $e(e) && !Object.keys(e).length;
|
|
25
556
|
export {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
557
|
+
re as Button,
|
|
558
|
+
ie as Dialog,
|
|
559
|
+
Qe as DialogClose,
|
|
560
|
+
H as DialogContent,
|
|
561
|
+
V as DialogDescription,
|
|
562
|
+
ce as DialogFooter,
|
|
563
|
+
G as DialogHeader,
|
|
564
|
+
F as DialogOverlay,
|
|
565
|
+
ae as DialogPortal,
|
|
566
|
+
K as DialogTitle,
|
|
567
|
+
Je as DialogTrigger,
|
|
568
|
+
Ze as DialogWrapper,
|
|
569
|
+
Ve as LevoInsightsBlock,
|
|
570
|
+
Xe as LevoInsightsComponent,
|
|
571
|
+
Ye as LevoInsightsPage,
|
|
572
|
+
at as LevoOAuth,
|
|
573
|
+
Ke as LevoProvider,
|
|
574
|
+
nt as SimpleTooltipWrapper,
|
|
575
|
+
de as Spinner,
|
|
576
|
+
tt as Tabs,
|
|
577
|
+
pe as TabsContent,
|
|
578
|
+
ue as TabsList,
|
|
579
|
+
me as TabsTrigger,
|
|
580
|
+
qe as Toaster,
|
|
581
|
+
fe as Tooltip,
|
|
582
|
+
X as TooltipContent,
|
|
583
|
+
ve as TooltipPortal,
|
|
584
|
+
ot as TooltipProvider,
|
|
585
|
+
ge as TooltipTrigger,
|
|
586
|
+
st as allMediaFileExtensions,
|
|
587
|
+
rt as allMediaMimetypes,
|
|
588
|
+
xe as audioFileExtensions,
|
|
589
|
+
Le as audioMimetype,
|
|
590
|
+
se as buttonVariants,
|
|
591
|
+
ct as byteToSize,
|
|
592
|
+
g as cn,
|
|
593
|
+
he as documentFileExtensions,
|
|
594
|
+
ye as documentMimetype,
|
|
595
|
+
lt as errorHandler,
|
|
596
|
+
le as errorToast,
|
|
597
|
+
be as imageFileExtensions,
|
|
598
|
+
Ne as imageMimetype,
|
|
599
|
+
Be as isDateObject,
|
|
600
|
+
dt as isEmptyObject,
|
|
601
|
+
De as isNullOrUndefined,
|
|
602
|
+
$e as isObject,
|
|
603
|
+
Ie as isObjectType,
|
|
604
|
+
E as mediaExtensionsByKind,
|
|
605
|
+
k as mediaMimetypeByKind,
|
|
606
|
+
et as successToast,
|
|
607
|
+
pt as toast,
|
|
608
|
+
$ as useLevo,
|
|
609
|
+
M as useLevoInsights,
|
|
610
|
+
it as useLevoOAuth,
|
|
611
|
+
we as videoFileExtensions,
|
|
612
|
+
Te as videoMimetype
|
|
82
613
|
};
|