@versini/ui-tooltip 2.0.0 → 2.0.2

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 CHANGED
@@ -1,1060 +1,19 @@
1
- import { jsxs as bt, jsx as $t } from "react/jsx-runtime";
2
- import { useRef as G, useEffect as pt, useState as ft, useCallback as ut } from "react";
3
- import H from "clsx";
1
+ import { TOOLTIP_ARROW_CLASSNAME as T, TOOLTIP_CLASSNAME as I, Tooltip as e } from "./components/Tooltip/Tooltip.js";
4
2
  /*!
5
- @versini/ui-tooltip v2.0.0
3
+ @versini/ui-tooltip v2.0.2
6
4
  © 2025 gizmette.com
7
5
  */
8
6
  try {
9
7
  window.__VERSINI_UI_TOOLTIP__ || (window.__VERSINI_UI_TOOLTIP__ = {
10
- version: "2.0.0",
11
- buildTime: "03/18/2025 07:53 PM EDT",
8
+ version: "2.0.2",
9
+ buildTime: "04/12/2025 09:18 AM EDT",
12
10
  homepage: "https://github.com/aversini/ui-components",
13
11
  license: "MIT"
14
12
  });
15
13
  } catch {
16
14
  }
17
- const Ht = "av-tooltip", jt = "av-tooltip-arrow", J = Math.min, z = Math.max, ot = Math.round, P = (t) => ({
18
- x: t,
19
- y: t
20
- }), Yt = {
21
- left: "right",
22
- right: "left",
23
- bottom: "top",
24
- top: "bottom"
25
- }, zt = {
26
- start: "end",
27
- end: "start"
28
- };
29
- function dt(t, e, o) {
30
- return z(t, J(e, o));
31
- }
32
- function Z(t, e) {
33
- return typeof t == "function" ? t(e) : t;
34
- }
35
- function j(t) {
36
- return t.split("-")[0];
37
- }
38
- function tt(t) {
39
- return t.split("-")[1];
40
- }
41
- function Lt(t) {
42
- return t === "x" ? "y" : "x";
43
- }
44
- function gt(t) {
45
- return t === "y" ? "height" : "width";
46
- }
47
- function X(t) {
48
- return ["top", "bottom"].includes(j(t)) ? "y" : "x";
49
- }
50
- function ht(t) {
51
- return Lt(X(t));
52
- }
53
- function Ut(t, e, o) {
54
- o === void 0 && (o = !1);
55
- const n = tt(t), i = ht(t), s = gt(i);
56
- let r = i === "x" ? n === (o ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
57
- return e.reference[s] > e.floating[s] && (r = it(r)), [r, it(r)];
58
- }
59
- function Xt(t) {
60
- const e = it(t);
61
- return [mt(t), e, mt(e)];
62
- }
63
- function mt(t) {
64
- return t.replace(/start|end/g, (e) => zt[e]);
65
- }
66
- function Kt(t, e, o) {
67
- const n = ["left", "right"], i = ["right", "left"], s = ["top", "bottom"], r = ["bottom", "top"];
68
- switch (t) {
69
- case "top":
70
- case "bottom":
71
- return o ? e ? i : n : e ? n : i;
72
- case "left":
73
- case "right":
74
- return e ? s : r;
75
- default:
76
- return [];
77
- }
78
- }
79
- function qt(t, e, o, n) {
80
- const i = tt(t);
81
- let s = Kt(j(t), o === "start", n);
82
- return i && (s = s.map((r) => r + "-" + i), e && (s = s.concat(s.map(mt)))), s;
83
- }
84
- function it(t) {
85
- return t.replace(/left|right|bottom|top/g, (e) => Yt[e]);
86
- }
87
- function Gt(t) {
88
- return {
89
- top: 0,
90
- right: 0,
91
- bottom: 0,
92
- left: 0,
93
- ...t
94
- };
95
- }
96
- function St(t) {
97
- return typeof t != "number" ? Gt(t) : {
98
- top: t,
99
- right: t,
100
- bottom: t,
101
- left: t
102
- };
103
- }
104
- function st(t) {
105
- const {
106
- x: e,
107
- y: o,
108
- width: n,
109
- height: i
110
- } = t;
111
- return {
112
- width: n,
113
- height: i,
114
- top: o,
115
- left: e,
116
- right: e + n,
117
- bottom: o + i,
118
- x: e,
119
- y: o
120
- };
121
- }
122
- function At(t, e, o) {
123
- let {
124
- reference: n,
125
- floating: i
126
- } = t;
127
- const s = X(e), r = ht(e), c = gt(r), l = j(e), a = s === "y", d = n.x + n.width / 2 - i.width / 2, f = n.y + n.height / 2 - i.height / 2, p = n[c] / 2 - i[c] / 2;
128
- let u;
129
- switch (l) {
130
- case "top":
131
- u = {
132
- x: d,
133
- y: n.y - i.height
134
- };
135
- break;
136
- case "bottom":
137
- u = {
138
- x: d,
139
- y: n.y + n.height
140
- };
141
- break;
142
- case "right":
143
- u = {
144
- x: n.x + n.width,
145
- y: f
146
- };
147
- break;
148
- case "left":
149
- u = {
150
- x: n.x - i.width,
151
- y: f
152
- };
153
- break;
154
- default:
155
- u = {
156
- x: n.x,
157
- y: n.y
158
- };
159
- }
160
- switch (tt(e)) {
161
- case "start":
162
- u[r] -= p * (o && a ? -1 : 1);
163
- break;
164
- case "end":
165
- u[r] += p * (o && a ? -1 : 1);
166
- break;
167
- }
168
- return u;
169
- }
170
- const Jt = async (t, e, o) => {
171
- const {
172
- placement: n = "bottom",
173
- strategy: i = "absolute",
174
- middleware: s = [],
175
- platform: r
176
- } = o, c = s.filter(Boolean), l = await (r.isRTL == null ? void 0 : r.isRTL(e));
177
- let a = await r.getElementRects({
178
- reference: t,
179
- floating: e,
180
- strategy: i
181
- }), {
182
- x: d,
183
- y: f
184
- } = At(a, n, l), p = n, u = {}, m = 0;
185
- for (let g = 0; g < c.length; g++) {
186
- const {
187
- name: h,
188
- fn: w
189
- } = c[g], {
190
- x,
191
- y,
192
- data: T,
193
- reset: b
194
- } = await w({
195
- x: d,
196
- y: f,
197
- initialPlacement: n,
198
- placement: p,
199
- strategy: i,
200
- middlewareData: u,
201
- rects: a,
202
- platform: r,
203
- elements: {
204
- reference: t,
205
- floating: e
206
- }
207
- });
208
- d = x ?? d, f = y ?? f, u = {
209
- ...u,
210
- [h]: {
211
- ...u[h],
212
- ...T
213
- }
214
- }, b && m <= 50 && (m++, typeof b == "object" && (b.placement && (p = b.placement), b.rects && (a = b.rects === !0 ? await r.getElementRects({
215
- reference: t,
216
- floating: e,
217
- strategy: i
218
- }) : b.rects), {
219
- x: d,
220
- y: f
221
- } = At(a, p, l)), g = -1);
222
- }
223
- return {
224
- x: d,
225
- y: f,
226
- placement: p,
227
- strategy: i,
228
- middlewareData: u
229
- };
230
- };
231
- async function kt(t, e) {
232
- var o;
233
- e === void 0 && (e = {});
234
- const {
235
- x: n,
236
- y: i,
237
- platform: s,
238
- rects: r,
239
- elements: c,
240
- strategy: l
241
- } = t, {
242
- boundary: a = "clippingAncestors",
243
- rootBoundary: d = "viewport",
244
- elementContext: f = "floating",
245
- altBoundary: p = !1,
246
- padding: u = 0
247
- } = Z(e, t), m = St(u), h = c[p ? f === "floating" ? "reference" : "floating" : f], w = st(await s.getClippingRect({
248
- element: (o = await (s.isElement == null ? void 0 : s.isElement(h))) == null || o ? h : h.contextElement || await (s.getDocumentElement == null ? void 0 : s.getDocumentElement(c.floating)),
249
- boundary: a,
250
- rootBoundary: d,
251
- strategy: l
252
- })), x = f === "floating" ? {
253
- x: n,
254
- y: i,
255
- width: r.floating.width,
256
- height: r.floating.height
257
- } : r.reference, y = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c.floating)), T = await (s.isElement == null ? void 0 : s.isElement(y)) ? await (s.getScale == null ? void 0 : s.getScale(y)) || {
258
- x: 1,
259
- y: 1
260
- } : {
261
- x: 1,
262
- y: 1
263
- }, b = st(s.convertOffsetParentRelativeRectToViewportRelativeRect ? await s.convertOffsetParentRelativeRectToViewportRelativeRect({
264
- elements: c,
265
- rect: x,
266
- offsetParent: y,
267
- strategy: l
268
- }) : x);
269
- return {
270
- top: (w.top - b.top + m.top) / T.y,
271
- bottom: (b.bottom - w.bottom + m.bottom) / T.y,
272
- left: (w.left - b.left + m.left) / T.x,
273
- right: (b.right - w.right + m.right) / T.x
274
- };
275
- }
276
- const Qt = (t) => ({
277
- name: "arrow",
278
- options: t,
279
- async fn(e) {
280
- const {
281
- x: o,
282
- y: n,
283
- placement: i,
284
- rects: s,
285
- platform: r,
286
- elements: c,
287
- middlewareData: l
288
- } = e, {
289
- element: a,
290
- padding: d = 0
291
- } = Z(t, e) || {};
292
- if (a == null)
293
- return {};
294
- const f = St(d), p = {
295
- x: o,
296
- y: n
297
- }, u = ht(i), m = gt(u), g = await r.getDimensions(a), h = u === "y", w = h ? "top" : "left", x = h ? "bottom" : "right", y = h ? "clientHeight" : "clientWidth", T = s.reference[m] + s.reference[u] - p[u] - s.floating[m], b = p[u] - s.reference[u], N = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(a));
298
- let E = N ? N[y] : 0;
299
- (!E || !await (r.isElement == null ? void 0 : r.isElement(N))) && (E = c.floating[y] || s.floating[m]);
300
- const I = T / 2 - b / 2, R = E / 2 - g[m] / 2 - 1, L = J(f[w], R), W = J(f[x], R), S = L, $ = E - g[m] - W, A = E / 2 - g[m] / 2 + I, Y = dt(S, A, $), M = !l.arrow && tt(i) != null && A !== Y && s.reference[m] / 2 - (A < S ? L : W) - g[m] / 2 < 0, k = M ? A < S ? A - S : A - $ : 0;
301
- return {
302
- [u]: p[u] + k,
303
- data: {
304
- [u]: Y,
305
- centerOffset: A - Y - k,
306
- ...M && {
307
- alignmentOffset: k
308
- }
309
- },
310
- reset: M
311
- };
312
- }
313
- }), Zt = function(t) {
314
- return t === void 0 && (t = {}), {
315
- name: "flip",
316
- options: t,
317
- async fn(e) {
318
- var o, n;
319
- const {
320
- placement: i,
321
- middlewareData: s,
322
- rects: r,
323
- initialPlacement: c,
324
- platform: l,
325
- elements: a
326
- } = e, {
327
- mainAxis: d = !0,
328
- crossAxis: f = !0,
329
- fallbackPlacements: p,
330
- fallbackStrategy: u = "bestFit",
331
- fallbackAxisSideDirection: m = "none",
332
- flipAlignment: g = !0,
333
- ...h
334
- } = Z(t, e);
335
- if ((o = s.arrow) != null && o.alignmentOffset)
336
- return {};
337
- const w = j(i), x = X(c), y = j(c) === c, T = await (l.isRTL == null ? void 0 : l.isRTL(a.floating)), b = p || (y || !g ? [it(c)] : Xt(c)), N = m !== "none";
338
- !p && N && b.push(...qt(c, g, m, T));
339
- const E = [c, ...b], I = await kt(e, h), R = [];
340
- let L = ((n = s.flip) == null ? void 0 : n.overflows) || [];
341
- if (d && R.push(I[w]), f) {
342
- const A = Ut(i, r, T);
343
- R.push(I[A[0]], I[A[1]]);
344
- }
345
- if (L = [...L, {
346
- placement: i,
347
- overflows: R
348
- }], !R.every((A) => A <= 0)) {
349
- var W, S;
350
- const A = (((W = s.flip) == null ? void 0 : W.index) || 0) + 1, Y = E[A];
351
- if (Y)
352
- return {
353
- data: {
354
- index: A,
355
- overflows: L
356
- },
357
- reset: {
358
- placement: Y
359
- }
360
- };
361
- let M = (S = L.filter((k) => k.overflows[0] <= 0).sort((k, V) => k.overflows[1] - V.overflows[1])[0]) == null ? void 0 : S.placement;
362
- if (!M)
363
- switch (u) {
364
- case "bestFit": {
365
- var $;
366
- const k = ($ = L.filter((V) => {
367
- if (N) {
368
- const B = X(V.placement);
369
- return B === x || // Create a bias to the `y` side axis due to horizontal
370
- // reading directions favoring greater width.
371
- B === "y";
372
- }
373
- return !0;
374
- }).map((V) => [V.placement, V.overflows.filter((B) => B > 0).reduce((B, Wt) => B + Wt, 0)]).sort((V, B) => V[1] - B[1])[0]) == null ? void 0 : $[0];
375
- k && (M = k);
376
- break;
377
- }
378
- case "initialPlacement":
379
- M = c;
380
- break;
381
- }
382
- if (i !== M)
383
- return {
384
- reset: {
385
- placement: M
386
- }
387
- };
388
- }
389
- return {};
390
- }
391
- };
392
- };
393
- async function te(t, e) {
394
- const {
395
- placement: o,
396
- platform: n,
397
- elements: i
398
- } = t, s = await (n.isRTL == null ? void 0 : n.isRTL(i.floating)), r = j(o), c = tt(o), l = X(o) === "y", a = ["left", "top"].includes(r) ? -1 : 1, d = s && l ? -1 : 1, f = Z(e, t);
399
- let {
400
- mainAxis: p,
401
- crossAxis: u,
402
- alignmentAxis: m
403
- } = typeof f == "number" ? {
404
- mainAxis: f,
405
- crossAxis: 0,
406
- alignmentAxis: null
407
- } : {
408
- mainAxis: f.mainAxis || 0,
409
- crossAxis: f.crossAxis || 0,
410
- alignmentAxis: f.alignmentAxis
411
- };
412
- return c && typeof m == "number" && (u = c === "end" ? m * -1 : m), l ? {
413
- x: u * d,
414
- y: p * a
415
- } : {
416
- x: p * a,
417
- y: u * d
418
- };
419
- }
420
- const ee = function(t) {
421
- return t === void 0 && (t = 0), {
422
- name: "offset",
423
- options: t,
424
- async fn(e) {
425
- var o, n;
426
- const {
427
- x: i,
428
- y: s,
429
- placement: r,
430
- middlewareData: c
431
- } = e, l = await te(e, t);
432
- return r === ((o = c.offset) == null ? void 0 : o.placement) && (n = c.arrow) != null && n.alignmentOffset ? {} : {
433
- x: i + l.x,
434
- y: s + l.y,
435
- data: {
436
- ...l,
437
- placement: r
438
- }
439
- };
440
- }
441
- };
442
- }, ne = function(t) {
443
- return t === void 0 && (t = {}), {
444
- name: "shift",
445
- options: t,
446
- async fn(e) {
447
- const {
448
- x: o,
449
- y: n,
450
- placement: i
451
- } = e, {
452
- mainAxis: s = !0,
453
- crossAxis: r = !1,
454
- limiter: c = {
455
- fn: (h) => {
456
- let {
457
- x: w,
458
- y: x
459
- } = h;
460
- return {
461
- x: w,
462
- y: x
463
- };
464
- }
465
- },
466
- ...l
467
- } = Z(t, e), a = {
468
- x: o,
469
- y: n
470
- }, d = await kt(e, l), f = X(j(i)), p = Lt(f);
471
- let u = a[p], m = a[f];
472
- if (s) {
473
- const h = p === "y" ? "top" : "left", w = p === "y" ? "bottom" : "right", x = u + d[h], y = u - d[w];
474
- u = dt(x, u, y);
475
- }
476
- if (r) {
477
- const h = f === "y" ? "top" : "left", w = f === "y" ? "bottom" : "right", x = m + d[h], y = m - d[w];
478
- m = dt(x, m, y);
479
- }
480
- const g = c.fn({
481
- ...e,
482
- [p]: u,
483
- [f]: m
484
- });
485
- return {
486
- ...g,
487
- data: {
488
- x: g.x - o,
489
- y: g.y - n,
490
- enabled: {
491
- [p]: s,
492
- [f]: r
493
- }
494
- }
495
- };
496
- }
497
- };
498
- };
499
- function rt() {
500
- return typeof window < "u";
501
- }
502
- function q(t) {
503
- return Pt(t) ? (t.nodeName || "").toLowerCase() : "#document";
504
- }
505
- function v(t) {
506
- var e;
507
- return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
508
- }
509
- function _(t) {
510
- var e;
511
- return (e = (Pt(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
512
- }
513
- function Pt(t) {
514
- return rt() ? t instanceof Node || t instanceof v(t).Node : !1;
515
- }
516
- function C(t) {
517
- return rt() ? t instanceof Element || t instanceof v(t).Element : !1;
518
- }
519
- function D(t) {
520
- return rt() ? t instanceof HTMLElement || t instanceof v(t).HTMLElement : !1;
521
- }
522
- function Tt(t) {
523
- return !rt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof v(t).ShadowRoot;
524
- }
525
- function et(t) {
526
- const {
527
- overflow: e,
528
- overflowX: o,
529
- overflowY: n,
530
- display: i
531
- } = O(t);
532
- return /auto|scroll|overlay|hidden|clip/.test(e + n + o) && !["inline", "contents"].includes(i);
533
- }
534
- function oe(t) {
535
- return ["table", "td", "th"].includes(q(t));
536
- }
537
- function ct(t) {
538
- return [":popover-open", ":modal"].some((e) => {
539
- try {
540
- return t.matches(e);
541
- } catch {
542
- return !1;
543
- }
544
- });
545
- }
546
- function wt(t) {
547
- const e = xt(), o = C(t) ? O(t) : t;
548
- return ["transform", "translate", "scale", "rotate", "perspective"].some((n) => o[n] ? o[n] !== "none" : !1) || (o.containerType ? o.containerType !== "normal" : !1) || !e && (o.backdropFilter ? o.backdropFilter !== "none" : !1) || !e && (o.filter ? o.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((n) => (o.willChange || "").includes(n)) || ["paint", "layout", "strict", "content"].some((n) => (o.contain || "").includes(n));
549
- }
550
- function ie(t) {
551
- let e = F(t);
552
- for (; D(e) && !K(e); ) {
553
- if (wt(e))
554
- return e;
555
- if (ct(e))
556
- return null;
557
- e = F(e);
558
- }
559
- return null;
560
- }
561
- function xt() {
562
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
563
- }
564
- function K(t) {
565
- return ["html", "body", "#document"].includes(q(t));
566
- }
567
- function O(t) {
568
- return v(t).getComputedStyle(t);
569
- }
570
- function lt(t) {
571
- return C(t) ? {
572
- scrollLeft: t.scrollLeft,
573
- scrollTop: t.scrollTop
574
- } : {
575
- scrollLeft: t.scrollX,
576
- scrollTop: t.scrollY
577
- };
578
- }
579
- function F(t) {
580
- if (q(t) === "html")
581
- return t;
582
- const e = (
583
- // Step into the shadow DOM of the parent of a slotted node.
584
- t.assignedSlot || // DOM Element detected.
585
- t.parentNode || // ShadowRoot detected.
586
- Tt(t) && t.host || // Fallback.
587
- _(t)
588
- );
589
- return Tt(e) ? e.host : e;
590
- }
591
- function Dt(t) {
592
- const e = F(t);
593
- return K(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : D(e) && et(e) ? e : Dt(e);
594
- }
595
- function Nt(t, e, o) {
596
- var n;
597
- e === void 0 && (e = []);
598
- const i = Dt(t), s = i === ((n = t.ownerDocument) == null ? void 0 : n.body), r = v(i);
599
- return s ? e.concat(r, r.visualViewport || [], et(i) ? i : [], []) : e.concat(i, Nt(i, []));
600
- }
601
- function vt(t) {
602
- return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
603
- }
604
- function Mt(t) {
605
- const e = O(t);
606
- let o = parseFloat(e.width) || 0, n = parseFloat(e.height) || 0;
607
- const i = D(t), s = i ? t.offsetWidth : o, r = i ? t.offsetHeight : n, c = ot(o) !== s || ot(n) !== r;
608
- return c && (o = s, n = r), {
609
- width: o,
610
- height: n,
611
- $: c
612
- };
613
- }
614
- function _t(t) {
615
- return C(t) ? t : t.contextElement;
616
- }
617
- function U(t) {
618
- const e = _t(t);
619
- if (!D(e))
620
- return P(1);
621
- const o = e.getBoundingClientRect(), {
622
- width: n,
623
- height: i,
624
- $: s
625
- } = Mt(e);
626
- let r = (s ? ot(o.width) : o.width) / n, c = (s ? ot(o.height) : o.height) / i;
627
- return (!r || !Number.isFinite(r)) && (r = 1), (!c || !Number.isFinite(c)) && (c = 1), {
628
- x: r,
629
- y: c
630
- };
631
- }
632
- const se = /* @__PURE__ */ P(0);
633
- function It(t) {
634
- const e = v(t);
635
- return !xt() || !e.visualViewport ? se : {
636
- x: e.visualViewport.offsetLeft,
637
- y: e.visualViewport.offsetTop
638
- };
639
- }
640
- function re(t, e, o) {
641
- return e === void 0 && (e = !1), !o || e && o !== v(t) ? !1 : e;
642
- }
643
- function Q(t, e, o, n) {
644
- e === void 0 && (e = !1), o === void 0 && (o = !1);
645
- const i = t.getBoundingClientRect(), s = _t(t);
646
- let r = P(1);
647
- e && (n ? C(n) && (r = U(n)) : r = U(t));
648
- const c = re(s, o, n) ? It(s) : P(0);
649
- let l = (i.left + c.x) / r.x, a = (i.top + c.y) / r.y, d = i.width / r.x, f = i.height / r.y;
650
- if (s) {
651
- const p = v(s), u = n && C(n) ? v(n) : n;
652
- let m = p, g = vt(m);
653
- for (; g && n && u !== m; ) {
654
- const h = U(g), w = g.getBoundingClientRect(), x = O(g), y = w.left + (g.clientLeft + parseFloat(x.paddingLeft)) * h.x, T = w.top + (g.clientTop + parseFloat(x.paddingTop)) * h.y;
655
- l *= h.x, a *= h.y, d *= h.x, f *= h.y, l += y, a += T, m = v(g), g = vt(m);
656
- }
657
- }
658
- return st({
659
- width: d,
660
- height: f,
661
- x: l,
662
- y: a
663
- });
664
- }
665
- function yt(t, e) {
666
- const o = lt(t).scrollLeft;
667
- return e ? e.left + o : Q(_(t)).left + o;
668
- }
669
- function Vt(t, e, o) {
670
- o === void 0 && (o = !1);
671
- const n = t.getBoundingClientRect(), i = n.left + e.scrollLeft - (o ? 0 : (
672
- // RTL <body> scrollbar.
673
- yt(t, n)
674
- )), s = n.top + e.scrollTop;
675
- return {
676
- x: i,
677
- y: s
678
- };
679
- }
680
- function ce(t) {
681
- let {
682
- elements: e,
683
- rect: o,
684
- offsetParent: n,
685
- strategy: i
686
- } = t;
687
- const s = i === "fixed", r = _(n), c = e ? ct(e.floating) : !1;
688
- if (n === r || c && s)
689
- return o;
690
- let l = {
691
- scrollLeft: 0,
692
- scrollTop: 0
693
- }, a = P(1);
694
- const d = P(0), f = D(n);
695
- if ((f || !f && !s) && ((q(n) !== "body" || et(r)) && (l = lt(n)), D(n))) {
696
- const u = Q(n);
697
- a = U(n), d.x = u.x + n.clientLeft, d.y = u.y + n.clientTop;
698
- }
699
- const p = r && !f && !s ? Vt(r, l, !0) : P(0);
700
- return {
701
- width: o.width * a.x,
702
- height: o.height * a.y,
703
- x: o.x * a.x - l.scrollLeft * a.x + d.x + p.x,
704
- y: o.y * a.y - l.scrollTop * a.y + d.y + p.y
705
- };
706
- }
707
- function le(t) {
708
- return Array.from(t.getClientRects());
709
- }
710
- function ae(t) {
711
- const e = _(t), o = lt(t), n = t.ownerDocument.body, i = z(e.scrollWidth, e.clientWidth, n.scrollWidth, n.clientWidth), s = z(e.scrollHeight, e.clientHeight, n.scrollHeight, n.clientHeight);
712
- let r = -o.scrollLeft + yt(t);
713
- const c = -o.scrollTop;
714
- return O(n).direction === "rtl" && (r += z(e.clientWidth, n.clientWidth) - i), {
715
- width: i,
716
- height: s,
717
- x: r,
718
- y: c
719
- };
720
- }
721
- function fe(t, e) {
722
- const o = v(t), n = _(t), i = o.visualViewport;
723
- let s = n.clientWidth, r = n.clientHeight, c = 0, l = 0;
724
- if (i) {
725
- s = i.width, r = i.height;
726
- const a = xt();
727
- (!a || a && e === "fixed") && (c = i.offsetLeft, l = i.offsetTop);
728
- }
729
- return {
730
- width: s,
731
- height: r,
732
- x: c,
733
- y: l
734
- };
735
- }
736
- function ue(t, e) {
737
- const o = Q(t, !0, e === "fixed"), n = o.top + t.clientTop, i = o.left + t.clientLeft, s = D(t) ? U(t) : P(1), r = t.clientWidth * s.x, c = t.clientHeight * s.y, l = i * s.x, a = n * s.y;
738
- return {
739
- width: r,
740
- height: c,
741
- x: l,
742
- y: a
743
- };
744
- }
745
- function Ct(t, e, o) {
746
- let n;
747
- if (e === "viewport")
748
- n = fe(t, o);
749
- else if (e === "document")
750
- n = ae(_(t));
751
- else if (C(e))
752
- n = ue(e, o);
753
- else {
754
- const i = It(t);
755
- n = {
756
- x: e.x - i.x,
757
- y: e.y - i.y,
758
- width: e.width,
759
- height: e.height
760
- };
761
- }
762
- return st(n);
763
- }
764
- function Bt(t, e) {
765
- const o = F(t);
766
- return o === e || !C(o) || K(o) ? !1 : O(o).position === "fixed" || Bt(o, e);
767
- }
768
- function de(t, e) {
769
- const o = e.get(t);
770
- if (o)
771
- return o;
772
- let n = Nt(t, []).filter((c) => C(c) && q(c) !== "body"), i = null;
773
- const s = O(t).position === "fixed";
774
- let r = s ? F(t) : t;
775
- for (; C(r) && !K(r); ) {
776
- const c = O(r), l = wt(r);
777
- !l && c.position === "fixed" && (i = null), (s ? !l && !i : !l && c.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || et(r) && !l && Bt(t, r)) ? n = n.filter((d) => d !== r) : i = c, r = F(r);
778
- }
779
- return e.set(t, n), n;
780
- }
781
- function me(t) {
782
- let {
783
- element: e,
784
- boundary: o,
785
- rootBoundary: n,
786
- strategy: i
787
- } = t;
788
- const r = [...o === "clippingAncestors" ? ct(e) ? [] : de(e, this._c) : [].concat(o), n], c = r[0], l = r.reduce((a, d) => {
789
- const f = Ct(e, d, i);
790
- return a.top = z(f.top, a.top), a.right = J(f.right, a.right), a.bottom = J(f.bottom, a.bottom), a.left = z(f.left, a.left), a;
791
- }, Ct(e, c, i));
792
- return {
793
- width: l.right - l.left,
794
- height: l.bottom - l.top,
795
- x: l.left,
796
- y: l.top
797
- };
798
- }
799
- function pe(t) {
800
- const {
801
- width: e,
802
- height: o
803
- } = Mt(t);
804
- return {
805
- width: e,
806
- height: o
807
- };
808
- }
809
- function ge(t, e, o) {
810
- const n = D(e), i = _(e), s = o === "fixed", r = Q(t, !0, s, e);
811
- let c = {
812
- scrollLeft: 0,
813
- scrollTop: 0
814
- };
815
- const l = P(0);
816
- if (n || !n && !s)
817
- if ((q(e) !== "body" || et(i)) && (c = lt(e)), n) {
818
- const p = Q(e, !0, s, e);
819
- l.x = p.x + e.clientLeft, l.y = p.y + e.clientTop;
820
- } else i && (l.x = yt(i));
821
- const a = i && !n && !s ? Vt(i, c) : P(0), d = r.left + c.scrollLeft - l.x - a.x, f = r.top + c.scrollTop - l.y - a.y;
822
- return {
823
- x: d,
824
- y: f,
825
- width: r.width,
826
- height: r.height
827
- };
828
- }
829
- function at(t) {
830
- return O(t).position === "static";
831
- }
832
- function Ot(t, e) {
833
- if (!D(t) || O(t).position === "fixed")
834
- return null;
835
- if (e)
836
- return e(t);
837
- let o = t.offsetParent;
838
- return _(t) === o && (o = o.ownerDocument.body), o;
839
- }
840
- function Ft(t, e) {
841
- const o = v(t);
842
- if (ct(t))
843
- return o;
844
- if (!D(t)) {
845
- let i = F(t);
846
- for (; i && !K(i); ) {
847
- if (C(i) && !at(i))
848
- return i;
849
- i = F(i);
850
- }
851
- return o;
852
- }
853
- let n = Ot(t, e);
854
- for (; n && oe(n) && at(n); )
855
- n = Ot(n, e);
856
- return n && K(n) && at(n) && !wt(n) ? o : n || ie(t) || o;
857
- }
858
- const he = async function(t) {
859
- const e = this.getOffsetParent || Ft, o = this.getDimensions, n = await o(t.floating);
860
- return {
861
- reference: ge(t.reference, await e(t.floating), t.strategy),
862
- floating: {
863
- x: 0,
864
- y: 0,
865
- width: n.width,
866
- height: n.height
867
- }
868
- };
869
- };
870
- function we(t) {
871
- return O(t).direction === "rtl";
872
- }
873
- const xe = {
874
- convertOffsetParentRelativeRectToViewportRelativeRect: ce,
875
- getDocumentElement: _,
876
- getClippingRect: me,
877
- getOffsetParent: Ft,
878
- getElementRects: he,
879
- getClientRects: le,
880
- getDimensions: pe,
881
- getScale: U,
882
- isElement: C,
883
- isRTL: we
884
- }, ye = ee, be = ne, Ae = Zt, Te = Qt, ve = (t, e, o) => {
885
- const n = /* @__PURE__ */ new Map(), i = {
886
- platform: xe,
887
- ...o
888
- }, s = {
889
- ...i.platform,
890
- _c: n
891
- };
892
- return Jt(t, e, {
893
- ...i,
894
- platform: s
895
- });
896
- }, Et = ["mousedown", "touchstart"];
897
- function Ce(t, e, o) {
898
- const n = G(null);
899
- return pt(() => {
900
- const i = (s) => {
901
- const r = s ? s.target : void 0;
902
- if (Array.isArray(o)) {
903
- const c = !document.body.contains(r) && r.tagName !== "HTML";
904
- o.every(
905
- (l) => !!l && !s.composedPath().includes(l)
906
- ) && !c && t();
907
- } else n.current && !n.current.contains(r) && t();
908
- };
909
- return Et.forEach(
910
- (s) => document.addEventListener(s, i)
911
- ), () => {
912
- Et.forEach(
913
- (s) => document.removeEventListener(s, i)
914
- );
915
- };
916
- }, [t, o, e]), n;
917
- }
918
- function Oe(t, e) {
919
- const [o, n] = ft(!1), i = G(null), s = G(null), r = ut(() => {
920
- n((l) => (!l && (!i.current || i.current === -1) && (i.current = window.setInterval(s.current, e)), !0));
921
- }, [e]), c = ut(() => {
922
- n(!1), window.clearInterval(i.current || -1), i.current = -1;
923
- }, []);
924
- return pt(() => (s.current = t, o && r(), c), [t, o, r, c]), { start: r, stop: c, active: o };
925
- }
926
- const nt = (t, e = "px") => typeof t > "u" ? "" : `${Math.round(t)}${e}`, Ee = () => H("absolute top-0 left-0 w-max py-1 px-2 rounded-sm text-sm z-50"), Rt = ({
927
- mode: t
928
- }) => H({
929
- "bg-surface-darker": t === "dark" || t === "system",
930
- "bg-surface-light": t === "light" || t === "alt-system",
931
- "dark:bg-surface-light": t === "system",
932
- "dark:bg-surface-darker": t === "alt-system"
933
- }), Re = ({
934
- mode: t
935
- }) => H({
936
- "text-copy-light": t === "dark" || t === "system",
937
- "text-copy-dark": t === "light" || t === "alt-system",
938
- "dark:text-copy-dark": t === "system",
939
- "dark:text-copy-light": t === "alt-system"
940
- }), Le = () => H("absolute", "size-2", "transform rotate-45"), Se = ({
941
- mode: t,
942
- className: e,
943
- tooltipClassName: o,
944
- arrowClassName: n
945
- }) => {
946
- const i = H("relative inline-block", e), s = H(
947
- Ht,
948
- Ee(),
949
- Rt({ mode: t }),
950
- Re({ mode: t }),
951
- o
952
- ), r = H(
953
- jt,
954
- Le(),
955
- Rt({ mode: t }),
956
- n
957
- );
958
- return { tooltip: s, arrow: r, wrapper: i };
959
- }, ke = ({ delay: t = 300 }) => ({
960
- animation: `av-tooltip-fade-in ${t}ms ease-in-out`
961
- }), Pe = 5e3, _e = ({
962
- trigger: t,
963
- label: e,
964
- placement: o = "top",
965
- mode: n = "system",
966
- delay: i = 300,
967
- className: s,
968
- tooltipClassName: r,
969
- arrowClassName: c
970
- }) => {
971
- const l = Ce(() => {
972
- g.stop(), m(!1);
973
- }), a = G(null), d = G(null), [f, p] = ft(!1), [u, m] = ft(!1), g = Oe(() => {
974
- m(!1);
975
- }, Pe), h = Se({
976
- mode: n,
977
- className: s,
978
- tooltipClassName: r,
979
- arrowClassName: c
980
- }), w = ke({ delay: i }), x = ut(async () => {
981
- var N, E, I, R;
982
- if (l.current && a.current && d.current) {
983
- const {
984
- x: L,
985
- y: W,
986
- middlewareData: S,
987
- placement: $
988
- } = await ve(l.current, a.current, {
989
- placement: o,
990
- middleware: [
991
- ye(10),
992
- Ae({
993
- crossAxis: o.includes("-"),
994
- fallbackAxisSideDirection: "start"
995
- }),
996
- be({ padding: 5 }),
997
- Te({ element: d.current })
998
- ]
999
- });
1000
- (N = a == null ? void 0 : a.current) != null && N.style && Object.assign(a.current.style, {
1001
- left: nt(L),
1002
- top: nt(W),
1003
- ...w
1004
- });
1005
- const A = {
1006
- top: "bottom",
1007
- right: "left",
1008
- bottom: "top",
1009
- left: "right"
1010
- }[$.split("-")[0]];
1011
- (E = d == null ? void 0 : d.current) != null && E.style && Object.assign(d.current.style, {
1012
- left: nt((I = S.arrow) == null ? void 0 : I.x),
1013
- top: nt((R = S.arrow) == null ? void 0 : R.y),
1014
- right: "",
1015
- bottom: "",
1016
- [A]: "-4px"
1017
- });
1018
- }
1019
- }, [o, w, l]);
1020
- pt(() => {
1021
- (async () => f && await x())();
1022
- }, [x, f]);
1023
- const y = () => {
1024
- p(!1), m(!0), g.start();
1025
- }, T = () => {
1026
- u || p(!0);
1027
- }, b = () => {
1028
- u || p(!1);
1029
- };
1030
- return /* @__PURE__ */ bt(
1031
- "div",
1032
- {
1033
- className: h.wrapper,
1034
- ref: l,
1035
- onMouseEnter: T,
1036
- onMouseLeave: b,
1037
- onClick: y,
1038
- children: [
1039
- t,
1040
- f && /* @__PURE__ */ bt(
1041
- "div",
1042
- {
1043
- role: "tooltip",
1044
- ref: a,
1045
- className: h.tooltip,
1046
- children: [
1047
- e,
1048
- /* @__PURE__ */ $t("div", { ref: d, className: h.arrow })
1049
- ]
1050
- }
1051
- )
1052
- ]
1053
- }
1054
- );
1055
- };
1056
15
  export {
1057
- jt as TOOLTIP_ARROW_CLASSNAME,
1058
- Ht as TOOLTIP_CLASSNAME,
1059
- _e as Tooltip
16
+ T as TOOLTIP_ARROW_CLASSNAME,
17
+ I as TOOLTIP_CLASSNAME,
18
+ e as Tooltip
1060
19
  };