@levo-so/react 0.1.36 → 0.1.37

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 (42) hide show
  1. package/dist/{CheckboxWidget-3qTjxIlp.js → CheckboxWidget-BR6g2qCr.js} +1 -1
  2. package/dist/{CollectionFormBuilder-CUzpwIva.js → CollectionFormBuilder-KNHR7ngy.js} +18 -18
  3. package/dist/{CurrencyWidget-DgH4uCpg.js → CurrencyWidget-XHAkyPjV.js} +1 -1
  4. package/dist/{DateTimeWidget-C2hLHKU6.js → DateTimeWidget-UaUunQAK.js} +1 -1
  5. package/dist/{DefaultFormVariant-Cm9i2BBn.js → DefaultFormVariant-C8hqkuxx.js} +3 -3
  6. package/dist/{DropdownWidget-B6mRXcTa.js → DropdownWidget-DvObQQMp.js} +1 -1
  7. package/dist/{EmailWidget-CBFnvo9z.js → EmailWidget-7L0S6tat.js} +2 -2
  8. package/dist/{FormCaptcha-btA0HfMx.js → FormCaptcha-CgYoGiya.js} +1 -1
  9. package/dist/{GeocoderWidget-DZGXm9Ji.js → GeocoderWidget-DfghAiuD.js} +2 -2
  10. package/dist/{MultiGeocoderWidget-D7ogTcWu.js → MultiGeocoderWidget-CqwjH855.js} +3 -3
  11. package/dist/{MultiTextWidget-DYxi8PHm.js → MultiTextWidget-BMp9xdSv.js} +1 -1
  12. package/dist/{PhoneWidget-BxaGCfLs.js → PhoneWidget-DFP4giY9.js} +1 -1
  13. package/dist/{RadioWidget-Bkq1Oudi.js → RadioWidget-DMWMo2Mj.js} +2 -2
  14. package/dist/{RichTextWidget-Caqhw4GK.js → RichTextWidget-DOCSDDib.js} +2 -2
  15. package/dist/{Spinner-BcBoT-J5.js → Spinner-B4CjY8aw.js} +20 -19
  16. package/dist/{StepsFormVariant-D-m93LMv.js → StepsFormVariant-CUFLCpGE.js} +3 -3
  17. package/dist/{SwitchWidget-BpAzgVui.js → SwitchWidget-BjpxXOcZ.js} +1 -1
  18. package/dist/{TextWidget-CHkFlxmT.js → TextWidget-Cgk_TFqD.js} +1 -1
  19. package/dist/{TextareaWidget-B0htlijX.js → TextareaWidget-DGU_Xhrx.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-DLrS6ax4.js → ToggleCheckboxWidget-bhmeasG_.js} +1 -1
  21. package/dist/{URLWidget-CnWKNlOF.js → URLWidget-B20QysNc.js} +2 -2
  22. package/dist/{UploadWidget-DSvWOBuR.js → UploadWidget-SQ1MLpbO.js} +2 -2
  23. package/dist/audience/components/block.d.ts.map +1 -1
  24. package/dist/audience/components/component.d.ts +2 -2
  25. package/dist/audience/components/component.d.ts.map +1 -1
  26. package/dist/audience/components/page.d.ts.map +1 -1
  27. package/dist/audience/hooks/useBounce.d.ts +4 -0
  28. package/dist/audience/hooks/useBounce.d.ts.map +1 -0
  29. package/dist/audience/hooks/useCurrentTab.d.ts.map +1 -1
  30. package/dist/audience/hooks/useIdentifyAudience.d.ts +7 -0
  31. package/dist/audience/hooks/useIdentifyAudience.d.ts.map +1 -0
  32. package/dist/audience/hooks/useOpenTabs.d.ts.map +1 -1
  33. package/dist/audience/index.js +1 -1
  34. package/dist/collection/index.js +1 -1
  35. package/dist/components/button/buttonVariants.d.ts +1 -1
  36. package/dist/components/button/buttonVariants.d.ts.map +1 -1
  37. package/dist/components/index.js +1 -1
  38. package/dist/index.css +1 -1
  39. package/dist/index.js +3 -3
  40. package/dist/page-BVVduzWl.js +626 -0
  41. package/package.json +4 -4
  42. package/dist/page-C1-z2EsC.js +0 -574
@@ -0,0 +1,626 @@
1
+ "use client";
2
+ var te = Object.defineProperty;
3
+ var ne = (e, t, o) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
4
+ var U = (e, t, o) => ne(e, typeof t != "symbol" ? t + "" : t, o);
5
+ import { j as oe } from "./jsx-runtime-B6kdoens.js";
6
+ import { useEffect as f, useState as h } from "react";
7
+ import { useInView as re } from "react-intersection-observer";
8
+ import { useLevo as b } from "./providers/index.js";
9
+ import { LocalStorageLock as se } from "@levo-so/core";
10
+ import { usePageLifecycle as ie, LifecycleState as j } from "use-page-lifecycle";
11
+ const bt = ({ id: e, properties: t = {} }) => {
12
+ const { audience: o } = b(), { ref: n, inView: r } = re({
13
+ triggerOnce: !0
14
+ });
15
+ return f(() => {
16
+ o != null && o.instance && r && (o == null || o.track("block.view", {
17
+ ...t,
18
+ resource: "block",
19
+ identifier: e
20
+ }));
21
+ }, [r]), /* @__PURE__ */ oe.jsx("div", { ref: n, style: { height: "0px" } });
22
+ }, wt = ({ event: e, properties: t }) => {
23
+ const { audience: o } = b();
24
+ return f(() => {
25
+ o != null && o.instance && (o == null || o.track(e, t));
26
+ }, [o == null ? void 0 : o.instance, e, t]), null;
27
+ };
28
+ function A(e) {
29
+ var t = typeof e;
30
+ return e != null && (t == "object" || t == "function");
31
+ }
32
+ var ce = typeof global == "object" && global && global.Object === Object && global, ae = typeof self == "object" && self && self.Object === Object && self, V = ce || ae || Function("return this")(), D = function() {
33
+ return V.Date.now();
34
+ }, ue = /\s/;
35
+ function de(e) {
36
+ for (var t = e.length; t-- && ue.test(e.charAt(t)); )
37
+ ;
38
+ return t;
39
+ }
40
+ var le = /^\s+/;
41
+ function fe(e) {
42
+ return e && e.slice(0, de(e) + 1).replace(le, "");
43
+ }
44
+ var _ = V.Symbol, K = Object.prototype, me = K.hasOwnProperty, ge = K.toString, E = _ ? _.toStringTag : void 0;
45
+ function pe(e) {
46
+ var t = me.call(e, E), o = e[E];
47
+ try {
48
+ e[E] = void 0;
49
+ var n = !0;
50
+ } catch {
51
+ }
52
+ var r = ge.call(e);
53
+ return n && (t ? e[E] = o : delete e[E]), r;
54
+ }
55
+ var he = Object.prototype, be = he.toString;
56
+ function we(e) {
57
+ return be.call(e);
58
+ }
59
+ var ve = "[object Null]", ye = "[object Undefined]", B = _ ? _.toStringTag : void 0;
60
+ function Se(e) {
61
+ return e == null ? e === void 0 ? ye : ve : B && B in Object(e) ? pe(e) : we(e);
62
+ }
63
+ function ke(e) {
64
+ return e != null && typeof e == "object";
65
+ }
66
+ var Te = "[object Symbol]";
67
+ function Ee(e) {
68
+ return typeof e == "symbol" || ke(e) && Se(e) == Te;
69
+ }
70
+ var H = NaN, Le = /^[-+]0x[0-9a-f]+$/i, _e = /^0b[01]+$/i, Ce = /^0o[0-7]+$/i, xe = parseInt;
71
+ function W(e) {
72
+ if (typeof e == "number")
73
+ return e;
74
+ if (Ee(e))
75
+ return H;
76
+ if (A(e)) {
77
+ var t = typeof e.valueOf == "function" ? e.valueOf() : e;
78
+ e = A(t) ? t + "" : t;
79
+ }
80
+ if (typeof e != "string")
81
+ return e === 0 ? e : +e;
82
+ e = fe(e);
83
+ var o = _e.test(e);
84
+ return o || Ce.test(e) ? xe(e.slice(2), o ? 2 : 8) : Le.test(e) ? H : +e;
85
+ }
86
+ var Ne = "Expected a function", Ie = Math.max, Oe = Math.min;
87
+ function Re(e, t, o) {
88
+ var n, r, s, i, c, a, u = 0, l = !1, d = !1, m = !0;
89
+ if (typeof e != "function")
90
+ throw new TypeError(Ne);
91
+ t = W(t) || 0, A(o) && (l = !!o.leading, d = "maxWait" in o, s = d ? Ie(W(o.maxWait) || 0, t) : s, m = "trailing" in o ? !!o.trailing : m);
92
+ function p(g) {
93
+ var w = n, T = r;
94
+ return n = r = void 0, u = g, i = e.apply(T, w), i;
95
+ }
96
+ function N(g) {
97
+ return u = g, c = setTimeout(y, t), l ? p(g) : i;
98
+ }
99
+ function S(g) {
100
+ var w = g - a, T = g - u, F = t - w;
101
+ return d ? Oe(F, s - T) : F;
102
+ }
103
+ function k(g) {
104
+ var w = g - a, T = g - u;
105
+ return a === void 0 || w >= t || w < 0 || d && T >= s;
106
+ }
107
+ function y() {
108
+ var g = D();
109
+ if (k(g))
110
+ return I(g);
111
+ c = setTimeout(y, S(g));
112
+ }
113
+ function I(g) {
114
+ return c = void 0, m && n ? p(g) : (n = r = void 0, i);
115
+ }
116
+ function O() {
117
+ c !== void 0 && clearTimeout(c), u = 0, n = a = r = c = void 0;
118
+ }
119
+ function ee() {
120
+ return c === void 0 ? i : I(D());
121
+ }
122
+ function R() {
123
+ var g = D(), w = k(g);
124
+ if (n = arguments, r = this, a = g, w) {
125
+ if (c === void 0)
126
+ return N(a);
127
+ if (d)
128
+ return clearTimeout(c), c = setTimeout(y, t), p(a);
129
+ }
130
+ return c === void 0 && (c = setTimeout(y, t)), i;
131
+ }
132
+ return R.cancel = O, R.flush = ee, R;
133
+ }
134
+ const je = () => {
135
+ const [e, t] = h(0), [o, n] = h(0), [r, s] = h(0), [i, c] = h(Date.now()), [a, u] = h("read"), l = Re(() => {
136
+ const d = window.scrollY, m = document.documentElement.scrollHeight, p = window.innerHeight, N = Math.round(
137
+ d / (m - p) * 100
138
+ ), S = Math.floor(N / 5) * 5;
139
+ if (S <= o)
140
+ return;
141
+ const k = Date.now(), y = (k - i) / 1e3, O = Math.abs(d - r) / y;
142
+ u(O > 300 ? "scan" : "read"), s(d), c(k), n(S), t(S);
143
+ }, 250);
144
+ return f(() => (window.addEventListener("scroll", l), () => window.removeEventListener("scroll", l)), []), { depth: e, speedCategory: a };
145
+ }, De = () => {
146
+ const e = b(), [t, o] = h(0);
147
+ return f(() => {
148
+ const n = Number(localStorage.getItem(e.audience.storage_keys.open_tabs)) || 0;
149
+ o(n), localStorage.setItem(
150
+ e.audience.storage_keys.open_tabs,
151
+ (n + 1).toString()
152
+ );
153
+ const r = (i) => {
154
+ i.key === e.audience.storage_keys.open_tabs && o(Number(i.newValue) || 0);
155
+ };
156
+ window.addEventListener("storage", r);
157
+ const s = () => {
158
+ const i = Number(localStorage.getItem(e.audience.storage_keys.open_tabs)) || 0;
159
+ i > 0 && localStorage.setItem(
160
+ e.audience.storage_keys.open_tabs,
161
+ (i - 1).toString()
162
+ );
163
+ };
164
+ return window.addEventListener("beforeunload", s), () => {
165
+ window.removeEventListener("storage", r), window.removeEventListener("beforeunload", s);
166
+ };
167
+ }, []), t;
168
+ }, Me = () => {
169
+ const e = b(), [t, o] = h(null);
170
+ return f(() => {
171
+ let n = sessionStorage.getItem(
172
+ e.audience.storage_keys.current_tab
173
+ );
174
+ const r = JSON.parse(
175
+ localStorage.getItem(e.audience.storage_keys.all_tabs) || "[]"
176
+ );
177
+ n && r.includes(n) && (n = null), n || (n = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(
178
+ e.audience.storage_keys.current_tab,
179
+ n
180
+ )), r.includes(n) || (r.push(n), localStorage.setItem(
181
+ e.audience.storage_keys.all_tabs,
182
+ JSON.stringify(r)
183
+ )), o(n);
184
+ const s = () => {
185
+ const i = r.filter(
186
+ (c) => c !== n
187
+ );
188
+ localStorage.setItem(
189
+ e.audience.storage_keys.all_tabs,
190
+ JSON.stringify(i)
191
+ );
192
+ };
193
+ return window.addEventListener("beforeunload", s), () => {
194
+ window.removeEventListener("beforeunload", s);
195
+ };
196
+ }, []), t;
197
+ }, C = (e) => Object.prototype.toString.call(e) == "[object String]", Ae = (e, t) => e.indexOf(t) !== -1, x = (e) => e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), G = (e) => e === void 0, $e = (e) => e === null, J = (e) => G(e) || $e(e), z = (e) => !!e && (e == null ? void 0 : e.nodeType) === 3;
198
+ function Pe(e) {
199
+ return !!e && (e == null ? void 0 : e.nodeType) === 1;
200
+ }
201
+ function Fe(e, t) {
202
+ return !!e && !!(e != null && e.tagName) && (e == null ? void 0 : e.tagName.toLowerCase()) === t.toLowerCase();
203
+ }
204
+ function Ue(e) {
205
+ return e ? x(e).split(/\s+/) : [];
206
+ }
207
+ function Be(e) {
208
+ let t = "";
209
+ switch (typeof (e == null ? void 0 : e.className)) {
210
+ case "string":
211
+ t = e == null ? void 0 : e.className;
212
+ break;
213
+ case "object":
214
+ t = (e != null && e.className && "baseVal" in (e == null ? void 0 : e.className) ? (e == null ? void 0 : e.className).baseVal : null) || (e == null ? void 0 : e.getAttribute("class")) || "";
215
+ break;
216
+ default:
217
+ t = "";
218
+ }
219
+ return Ue(t);
220
+ }
221
+ const v = (e, t = 255) => J(e) ? "" : x(e).split(/(\s+)/).filter((o) => P(o)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, t), $ = (e) => {
222
+ let t = "";
223
+ if (Ye(e) && // !isSensitiveElement(el) &&
224
+ (e != null && e.childNodes) && (e != null && e.childNodes.length))
225
+ for (const o of e == null ? void 0 : e.childNodes)
226
+ z(o) && o.textContent && (t += v(o.textContent) ?? "");
227
+ return x(t);
228
+ }, He = (e) => {
229
+ var t, o;
230
+ return G(e.target) ? (e == null ? void 0 : e.srcElement) || null : (t = e == null ? void 0 : e.target) != null && t.shadowRoot ? ((o = e == null ? void 0 : e.composedPath()) == null ? void 0 : o[0]) || null : (e == null ? void 0 : e.target) || null;
231
+ }, We = (e, t) => {
232
+ if (!window || !e || Fe(e, "html") || !Pe(e))
233
+ return !1;
234
+ const o = window.getComputedStyle(e);
235
+ if (o && o.getPropertyValue("cursor") === "pointer" && t.type === "click")
236
+ return !0;
237
+ switch (e == null ? void 0 : e.tagName.toLowerCase()) {
238
+ case "html":
239
+ return !1;
240
+ case "form":
241
+ return t.type === "submit";
242
+ case "input":
243
+ case "select":
244
+ case "textarea":
245
+ return ["change", "click"].includes(t.type);
246
+ default:
247
+ return t.type === "click";
248
+ }
249
+ };
250
+ function Ye(e) {
251
+ if (Ae(Be(e), "ph-include"))
252
+ return !0;
253
+ const t = e.type || "";
254
+ if (C(t))
255
+ switch (t.toLowerCase()) {
256
+ case "hidden":
257
+ return !1;
258
+ case "password":
259
+ return !1;
260
+ }
261
+ const o = e.name || (e == null ? void 0 : e.id) || "";
262
+ return !(C(o) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g, "")));
263
+ }
264
+ const X = "(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})", Ve = new RegExp(`^(?:${X})$`), Ke = new RegExp(X), q = "\\d{3}-?\\d{2}-?\\d{4}", Ge = new RegExp(`^(${q})$`), Je = new RegExp(`(${q})`), P = (e, t = !0) => !(J(e) || C(e) && (e = x(e), (t ? Ve : Ke).test((e || "").replace(/[- ]/g, "")) || (t ? Ge : Je).test(e))), ze = (e) => C(e) ? e.substring(0, 10) === "_ngcontent" || e.substring(0, 7) === "_nghost" : !1, Xe = (e) => {
265
+ let t = $(e);
266
+ return t = `${t} ${Z(e)}`.trim(), P(t) ? t : "";
267
+ };
268
+ function Z(e) {
269
+ var o;
270
+ let t = "";
271
+ if (e != null && e.childNodes.length) {
272
+ for (const n of e.childNodes)
273
+ if (n && ((o = n.tagName) == null ? void 0 : o.toLowerCase()) === "span")
274
+ try {
275
+ const r = $(n);
276
+ t = `${t} ${r}`.trim(), n != null && n.childNodes.length && (t = `${t} ${Z(n)}`.trim());
277
+ } catch {
278
+ }
279
+ }
280
+ return t;
281
+ }
282
+ const qe = ["input", "textarea", "select"], Q = (e) => {
283
+ var r, s, i, c;
284
+ const t = (r = e == null ? void 0 : e.tagName) == null ? void 0 : r.toLowerCase(), o = {
285
+ element: t
286
+ };
287
+ (t == null ? void 0 : t.toLowerCase()) === "a" || (t == null ? void 0 : t.toLowerCase()) === "button" ? o.text = Xe(e) : o.text = $(e);
288
+ const n = Array.from(e.attributes).reduce(
289
+ (a, u) => {
290
+ if (P(u.value) && !ze(u.name)) {
291
+ if (u.name === "class")
292
+ return a;
293
+ a[u.name] = typeof (u == null ? void 0 : u.value) == "string" ? v(u.value) : u.value;
294
+ }
295
+ return a;
296
+ },
297
+ {}
298
+ );
299
+ if (o.attributes = n, qe.includes(t) || (e == null ? void 0 : e.getAttribute("contenteditable")) === "true") {
300
+ let a;
301
+ e.matches('input[type="checkbox"], input[type="radio"]') ? a = e.checked : e.matches("input, select, textarea") && !e.matches('input[type="password"]') && (a = e.value), a !== void 0 && (o.value = typeof a == "string" || a === null ? v(a, 1024) : a);
302
+ let u = "";
303
+ o != null && o.attributes.id && (u = v(
304
+ ((i = (s = document.querySelector(`label[for="${o == null ? void 0 : o.attributes.id}"]`)) == null ? void 0 : s.textContent) == null ? void 0 : i.trim()) || ""
305
+ ));
306
+ const l = e.closest("label");
307
+ u || (u = v(((c = l == null ? void 0 : l.textContent) == null ? void 0 : c.trim()) || "")), u && (o.label = u);
308
+ }
309
+ return o;
310
+ }, Ze = (e, t) => {
311
+ var r;
312
+ let o = He(e);
313
+ z(o) && (o = o.parentNode || null);
314
+ const n = ["copy", "cut"].includes(t);
315
+ if (o && (n || We(o, e))) {
316
+ const s = Q(o);
317
+ if (n) {
318
+ const i = v((r = window == null ? void 0 : window.getSelection()) == null ? void 0 : r.toString()), c = (e == null ? void 0 : e.type) || "clipboard";
319
+ s.copy_text = i ?? "", s.copy_type = c ?? "";
320
+ }
321
+ return s;
322
+ }
323
+ return null;
324
+ }, Qe = 30, et = 1e3, tt = 3;
325
+ class nt {
326
+ constructor() {
327
+ U(this, "clicks");
328
+ this.clicks = [];
329
+ }
330
+ isRageClick(t, o, n) {
331
+ const r = this.clicks[this.clicks.length - 1];
332
+ if (r && Math.abs(t - r.x) + Math.abs(o - r.y) < Qe && n - r.timestamp < et) {
333
+ if (this.clicks.push({ x: t, y: o, timestamp: n }), this.clicks.length === tt)
334
+ return !0;
335
+ } else
336
+ this.clicks = [{ x: t, y: o, timestamp: n }];
337
+ return !1;
338
+ }
339
+ }
340
+ const M = new nt(), ot = () => {
341
+ const { audience: e } = b();
342
+ f(() => {
343
+ let t = null;
344
+ const o = (s) => {
345
+ if (t) {
346
+ clearTimeout(t), t = null;
347
+ return;
348
+ }
349
+ t = setTimeout(() => {
350
+ r(s, !1), t = null;
351
+ }, 250);
352
+ }, n = (s) => {
353
+ t && (clearTimeout(t), t = null), r(s, !0);
354
+ }, r = (s, i = !1) => {
355
+ var c;
356
+ try {
357
+ let a = {
358
+ hostname: window.location.hostname,
359
+ pathname: window.location.pathname,
360
+ page_title: document.title,
361
+ url: window.location.href,
362
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
363
+ event_type: i ? "dblclick" : "click",
364
+ button_type: s.button
365
+ };
366
+ if (s.target instanceof HTMLElement) {
367
+ const u = s.target;
368
+ a.rage_click = M == null ? void 0 : M.isRageClick(
369
+ s.clientX,
370
+ s.clientY,
371
+ (/* @__PURE__ */ new Date()).getTime()
372
+ ), a = {
373
+ ...a,
374
+ ...Q(u)
375
+ };
376
+ let l = u == null ? void 0 : u.getAttribute("href");
377
+ if (!l) {
378
+ let d = u.parentNode, m = 0;
379
+ for (; d && m < 8; ) {
380
+ const p = (c = d == null ? void 0 : d.parentElement) == null ? void 0 : c.getAttribute("href");
381
+ if (p) {
382
+ l = p;
383
+ break;
384
+ }
385
+ d = d.parentNode, m++;
386
+ }
387
+ }
388
+ e == null || e.track("page.click", {
389
+ ...a,
390
+ href: l || void 0
391
+ });
392
+ }
393
+ } catch {
394
+ }
395
+ };
396
+ return document.addEventListener("click", o), document.addEventListener("dblclick", n), () => {
397
+ document.removeEventListener("click", o), document.removeEventListener("dblclick", n);
398
+ };
399
+ }, [e]);
400
+ }, L = (e) => Number(e.toFixed(0)), rt = (e) => {
401
+ const { audience: t } = b(), [o] = h({
402
+ value: L(performance.now()),
403
+ timestamp: L(Date.now())
404
+ }), [n, r] = h({
405
+ value: null,
406
+ timestamp: null
407
+ }), [s, i] = h({
408
+ value: null,
409
+ timestamp: null
410
+ });
411
+ return f(() => {
412
+ let c = !0;
413
+ const a = (d, m) => {
414
+ c && d({ value: L(m), timestamp: L(Date.now()) });
415
+ }, u = new PerformanceObserver((d) => {
416
+ for (const m of d.getEntries())
417
+ m.name === "first-contentful-paint" && a(r, m.startTime);
418
+ });
419
+ u.observe({ type: "paint", buffered: !0 });
420
+ const l = () => a(i, performance.now());
421
+ return document.readyState === "complete" ? a(i, performance.now()) : window.addEventListener("load", l), () => {
422
+ c = !1, u.disconnect(), window.removeEventListener("load", l);
423
+ };
424
+ }, []), f(() => {
425
+ o && t && (t == null || t.track("page.metrics", {
426
+ script_load: o.value,
427
+ script_load_at: o.timestamp,
428
+ version: 2
429
+ }));
430
+ }, [o, t]), f(() => {
431
+ n.value !== null && t && (t == null || t.track("page.metrics", {
432
+ first_contentful_paint: n.value,
433
+ first_contentful_paint_at: n.timestamp,
434
+ version: 2
435
+ }));
436
+ }, [n, t]), f(() => {
437
+ s.value !== null && t && (t == null || t.track("page.metrics", {
438
+ window_onload: s.value,
439
+ window_onload_at: s.timestamp,
440
+ version: 2
441
+ }));
442
+ }, [s, t]), { script: o, fcp: n, window_onload: s };
443
+ }, st = () => {
444
+ const { audience: e } = b();
445
+ f(() => {
446
+ let t;
447
+ const o = () => {
448
+ clearTimeout(t), t = setTimeout(() => {
449
+ const n = window.getSelection();
450
+ if (n && (n == null ? void 0 : n.rangeCount) > 0) {
451
+ const r = n == null ? void 0 : n.toString();
452
+ r && (e == null || e.track("page.selection", {
453
+ text: v(r)
454
+ }));
455
+ }
456
+ }, 1e3);
457
+ };
458
+ return document.addEventListener("selectionchange", o), () => {
459
+ clearTimeout(t), document.removeEventListener("selectionchange", o);
460
+ };
461
+ }, []);
462
+ }, Y = "lv_insights_st", it = 15 * 60 * 1e3, ct = (e = "https://cachefly.cachefly.net/1mb.test") => {
463
+ const [t, o] = h(null);
464
+ return f(() => {
465
+ const n = localStorage.getItem(Y);
466
+ if (n) {
467
+ const { speed: c, timestamp: a } = JSON.parse(n);
468
+ if (Date.now() - a < it) {
469
+ o(c);
470
+ return;
471
+ }
472
+ }
473
+ let r = null;
474
+ const s = async () => {
475
+ const c = new se("download_speed");
476
+ if (c.acquireLock())
477
+ try {
478
+ const u = performance.now();
479
+ await fetch(e, { cache: "no-store" });
480
+ const d = (performance.now() - u) / 1e3, m = Math.round(8 / d);
481
+ o(m), localStorage.setItem(
482
+ Y,
483
+ JSON.stringify({ speed: m, timestamp: Date.now() })
484
+ );
485
+ } catch {
486
+ } finally {
487
+ c.releaseLock();
488
+ }
489
+ }, i = () => {
490
+ document.removeEventListener("mousemove", i), document.removeEventListener("keydown", i), document.removeEventListener("scroll", i), r = setTimeout(s, 5e3);
491
+ };
492
+ return document.addEventListener("mousemove", i, { once: !0 }), document.addEventListener("keydown", i, { once: !0 }), document.addEventListener("scroll", i, { once: !0 }), () => {
493
+ r && clearTimeout(r), document.removeEventListener("mousemove", i), document.removeEventListener("keydown", i), document.removeEventListener("scroll", i);
494
+ };
495
+ }, [e]), t;
496
+ }, at = ({
497
+ id: e,
498
+ properties: t = {},
499
+ href: o
500
+ }) => {
501
+ const n = b();
502
+ f(() => {
503
+ (() => {
504
+ var s, i;
505
+ n != null && n.insightsUrl && n.workspace && o && ((s = n == null ? void 0 : n.audience) != null && s.instance ? n == null || n.audience.instance.page({
506
+ resource: "page",
507
+ identifier: e
508
+ }) : (i = n == null ? void 0 : n.audience) == null || i.initiate({
509
+ ...t,
510
+ id: e,
511
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
512
+ }));
513
+ })();
514
+ }, [n == null ? void 0 : n.insightsUrl, n == null ? void 0 : n.workspace, o]), f(() => {
515
+ const r = (s) => {
516
+ var c;
517
+ const i = localStorage.getItem(
518
+ n.audience.storage_keys.identify
519
+ );
520
+ s.key === n.audience.storage_keys.identify && !(n != null && n.audience.is_identified) && !i && ((c = n == null ? void 0 : n.audience) == null || c.identify({
521
+ withLock: !1
522
+ }));
523
+ };
524
+ return window.addEventListener("storage", r), () => {
525
+ window.removeEventListener("storage", r);
526
+ };
527
+ }, []);
528
+ }, ut = ({ id: e }) => {
529
+ const t = b();
530
+ f(() => {
531
+ const n = () => {
532
+ var i, c;
533
+ const r = (i = performance.getEntriesByType(
534
+ "navigation"
535
+ )) == null ? void 0 : i[0];
536
+ let s = !1;
537
+ if (r)
538
+ r.type === "navigate" && (s = !0);
539
+ else
540
+ try {
541
+ const a = document.activeElement;
542
+ (a == null ? void 0 : a.tagName) === "A" && a.href && (new URL(a.href).origin !== window.location.origin ? s = !0 : s = !1);
543
+ } catch {
544
+ }
545
+ (c = t == null ? void 0 : t.audience) == null || c.bounce({
546
+ resource: "page",
547
+ identifier: e,
548
+ is_navigating_away: s,
549
+ navigation_type: r == null ? void 0 : r.type
550
+ });
551
+ };
552
+ return window.addEventListener("beforeunload", n), () => {
553
+ window.removeEventListener("beforeunload", n);
554
+ };
555
+ }, [t == null ? void 0 : t.audience, e]);
556
+ const [o] = ie();
557
+ f(() => {
558
+ var n;
559
+ (o === j.HIDDEN || o === j.UNKNOWN || o === j.FROZEN) && ((n = t == null ? void 0 : t.audience) == null || n.bounce({
560
+ resource: "page",
561
+ identifier: e,
562
+ state: o
563
+ }));
564
+ }, [o, t == null ? void 0 : t.audience, e]);
565
+ }, vt = ({ id: e, properties: t = {} }) => {
566
+ var i;
567
+ const o = typeof window < "u" ? window.location.href : "", n = b();
568
+ f(() => {
569
+ n && typeof window < "u" && (window.levo_client = n);
570
+ }, [n]), f(() => {
571
+ n != null && n.audience && typeof window < "u" && (window.levo_audience = n == null ? void 0 : n.audience);
572
+ }, []), De(), Me(), ot();
573
+ const r = ct();
574
+ f(() => {
575
+ var c;
576
+ (c = n == null ? void 0 : n.audience) != null && c.instance && r && (n == null || n.audience.track("user.speedtest", {
577
+ speed: r,
578
+ unit: "Mbps"
579
+ }));
580
+ }, [r]);
581
+ const s = je();
582
+ return f(() => {
583
+ var c;
584
+ (c = n == null ? void 0 : n.audience) != null && c.instance && (n == null || n.audience.track("page.scroll", {
585
+ resource: "page",
586
+ identifier: e,
587
+ percent: s.depth,
588
+ speed_category: s.speedCategory
589
+ }));
590
+ }, [
591
+ (i = n == null ? void 0 : n.audience) == null ? void 0 : i.instance,
592
+ s.depth,
593
+ s.speedCategory,
594
+ e
595
+ ]), rt(), st(), at({
596
+ href: o,
597
+ id: e,
598
+ properties: t
599
+ }), ut({ id: e }), f(() => {
600
+ const c = {
601
+ change: "form.change",
602
+ submit: "form.submit",
603
+ copy: "page.copy",
604
+ cut: "page.copy"
605
+ }, a = (l) => (d) => {
606
+ var p;
607
+ const m = Ze(d, l);
608
+ m && c[l] && ((p = n == null ? void 0 : n.audience) == null || p.track(c[l], m));
609
+ }, u = {
610
+ change: a("change"),
611
+ copy: a("copy"),
612
+ cut: a("cut"),
613
+ submit: a("submit")
614
+ };
615
+ return document.addEventListener("change", u.change), document.addEventListener("copy", u.copy), document.addEventListener("cut", u.cut), document.addEventListener("submit", u.submit), () => {
616
+ document.removeEventListener("change", u.change), document.removeEventListener("copy", u.copy), document.removeEventListener("cut", u.cut), document.removeEventListener("submit", u.submit);
617
+ };
618
+ }, []), (!(n != null && n.insightsUrl) || !n.workspace || !n.workspace.startsWith("W")) && console.error(
619
+ "[@levo-so/react] The utility could not be initialized, due to missing workspace, or endpoint for insights."
620
+ ), null;
621
+ };
622
+ export {
623
+ bt as L,
624
+ wt as a,
625
+ vt as b
626
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/react",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo suite for React based applications",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "peerDependencies": {
17
17
  "react": ">=18",
18
18
  "react-dom": ">=18",
19
- "@levo-so/core": "0.1.36"
19
+ "@levo-so/core": "0.1.37"
20
20
  },
21
21
  "dependencies": {
22
22
  "@radix-ui/react-checkbox": "1.1.1",
@@ -90,9 +90,9 @@
90
90
  "typescript": "5.5.4",
91
91
  "vite": "5.4.3",
92
92
  "vite-plugin-dts": "4.1.0",
93
- "@levo/eslint-config": "0.0.0",
93
+ "@levo/ts-config": "0.0.0",
94
94
  "@levo/tw-config": "0.0.0",
95
- "@levo/ts-config": "0.0.0"
95
+ "@levo/eslint-config": "0.0.0"
96
96
  },
97
97
  "main": "./dist/index.js",
98
98
  "module": "./dist/index.js",