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