@react-pdf-kit/viewer 2.0.1-rc.6 → 2.1.0-beta.1

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 (94) hide show
  1. package/README.md +49 -84
  2. package/dist/{Combination-17ab8af1.js → Combination-136ff99c.js} +2 -2
  3. package/dist/assets/style.css +1 -1
  4. package/dist/assets/style.js +4 -4
  5. package/dist/components/RPController.js +73 -74
  6. package/dist/components/RPPages.js +544 -545
  7. package/dist/components/layout/RPDefaultLayout.js +6 -6
  8. package/dist/components/layout/RPLayout.js +6 -6
  9. package/dist/components/layout/sidebar/RPSidebar.js +4 -4
  10. package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
  11. package/dist/components/layout/toolbar/DocumentDialog.js +3 -3
  12. package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
  13. package/dist/components/layout/toolbar/FileDownloadTool.js +6 -6
  14. package/dist/components/layout/toolbar/FileUploadTool.js +6 -6
  15. package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
  16. package/dist/components/layout/toolbar/MenuItem.js +6 -6
  17. package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
  18. package/dist/components/layout/toolbar/MostPageTool.js +6 -6
  19. package/dist/components/layout/toolbar/OtherTool.js +6 -6
  20. package/dist/components/layout/toolbar/Paginate.js +4 -4
  21. package/dist/components/layout/toolbar/PrintTool.js +6 -6
  22. package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
  23. package/dist/components/layout/toolbar/RPMoreOptions.js +6 -6
  24. package/dist/components/layout/toolbar/RPToolbar.js +6 -6
  25. package/dist/components/layout/toolbar/RPToolbarEnd.js +6 -6
  26. package/dist/components/layout/toolbar/RotateTool.js +6 -6
  27. package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
  28. package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
  29. package/dist/components/layout/toolbar/SearchResultNavigator.js +21 -29
  30. package/dist/components/layout/toolbar/SearchTool.js +102 -99
  31. package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
  32. package/dist/components/layout/toolbar/ThumbnailTool.js +4 -4
  33. package/dist/components/layout/toolbar/ToolbarDefault.js +6 -6
  34. package/dist/components/layout/toolbar/ToolbarLayout.js +6 -6
  35. package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
  36. package/dist/components/layout/toolbar/ZoomTool.js +6 -6
  37. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +5 -5
  38. package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
  39. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +6 -6
  40. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -4
  41. package/dist/components/layout/toolbar/tools/FileUploadTool.js +4 -4
  42. package/dist/components/layout/toolbar/tools/FirstPageTool.js +6 -6
  43. package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
  44. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
  45. package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -4
  46. package/dist/components/layout/toolbar/tools/LastPageTool.js +6 -6
  47. package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -4
  48. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
  49. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -4
  50. package/dist/components/layout/toolbar/tools/PrintTool.js +4 -4
  51. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +4 -4
  52. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +4 -4
  53. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
  54. package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
  55. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
  56. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -4
  57. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
  58. package/dist/components/layout/toolbar/tools/ZoomInTool.js +4 -4
  59. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +6 -6
  60. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +4 -4
  61. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -6
  62. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -4
  63. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
  64. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +6 -6
  65. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +6 -6
  66. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
  67. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +6 -6
  68. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +6 -6
  69. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +6 -6
  70. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
  71. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
  72. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
  73. package/dist/components/ui/Checkbox.js +2 -2
  74. package/dist/components/ui/DropDown.js +6 -6
  75. package/dist/components/ui/Input.js +10 -10
  76. package/dist/components/ui/RPTooltip.js +411 -197
  77. package/dist/contexts/InitialStateContext.js +6 -8
  78. package/dist/floating-ui.react-dom-5ec29bd6.js +1327 -0
  79. package/dist/index-61f59539.js +1198 -0
  80. package/dist/{index-ada501c4.js → index-655864a7.js} +1 -1
  81. package/dist/{index-113053cf.js → index-c0faa594.js} +2 -2
  82. package/dist/{index-23911b43.js → index-e3ee9457.js} +6 -6
  83. package/dist/main.js +6 -6
  84. package/dist/types/utils/hooks/useWatermark.d.ts +1 -1
  85. package/dist/types/utils/types.d.ts +1 -1
  86. package/dist/utils/highlight.js +36 -36
  87. package/dist/utils/hooks/useHighlight.js +40 -78
  88. package/dist/utils/hooks/useLicense.js +1 -1
  89. package/dist/utils/hooks/usePrint.js +78 -71
  90. package/dist/utils/hooks/useWatermark.js +43 -61
  91. package/dist/utils/injectPrintCSS.js +9 -9
  92. package/package.json +1 -1
  93. package/dist/index-11f3cd64.js +0 -983
  94. package/dist/index-d0f0aa9a.js +0 -1542
@@ -1,12 +1,226 @@
1
- import { jsx as p, jsxs as L } from "react/jsx-runtime";
2
- import * as s from "react";
3
- import { P as M, c as K, f as J, a as j, b as g, d as Q, h as Z } from "../../index-113053cf.js";
4
- import { u as $, D as ee } from "../../index-23911b43.js";
5
- import { c as G, R as te, A as oe, C as re, a as ne } from "../../index-d0f0aa9a.js";
6
- import { withRef as se } from "../../utils/withRef.js";
1
+ import { jsx as p, jsxs as Y } from "react/jsx-runtime";
2
+ import * as a from "react";
3
+ import { P as S, c as ae, a as k, u as oe, f as Fe, b as E, d as We, i as Be } from "../../index-c0faa594.js";
4
+ import { a as Ge, u as Xe, D as Ve } from "../../index-e3ee9457.js";
5
+ import { u as Ue, a as ze, o as qe, s as Ze, f as Ke, b as Je, c as Qe, h as et, l as tt } from "../../floating-ui.react-dom-5ec29bd6.js";
6
+ import { u as rt } from "../../index-655864a7.js";
7
+ import { withRef as ot } from "../../utils/withRef.js";
7
8
  import "react-dom";
8
- import "../../index-ada501c4.js";
9
- var ae = Object.freeze({
9
+ var nt = "Arrow", se = a.forwardRef((e, r) => {
10
+ const { children: t, width: o = 10, height: n = 5, ...i } = e;
11
+ return /* @__PURE__ */ p(
12
+ S.svg,
13
+ {
14
+ ...i,
15
+ ref: r,
16
+ width: o,
17
+ height: n,
18
+ viewBox: "0 0 30 10",
19
+ preserveAspectRatio: "none",
20
+ children: e.asChild ? t : /* @__PURE__ */ p("polygon", { points: "0,0 30,0 15,10" })
21
+ }
22
+ );
23
+ });
24
+ se.displayName = nt;
25
+ var at = se, B = "Popper", [ie, le] = ae(B), [st, ce] = ie(B), pe = (e) => {
26
+ const { __scopePopper: r, children: t } = e, [o, n] = a.useState(null);
27
+ return /* @__PURE__ */ p(st, { scope: r, anchor: o, onAnchorChange: n, children: t });
28
+ };
29
+ pe.displayName = B;
30
+ var de = "PopperAnchor", ue = a.forwardRef(
31
+ (e, r) => {
32
+ const { __scopePopper: t, virtualRef: o, ...n } = e, i = ce(de, t), l = a.useRef(null), h = k(r, l), s = a.useRef(null);
33
+ return a.useEffect(() => {
34
+ const d = s.current;
35
+ s.current = (o == null ? void 0 : o.current) || l.current, d !== s.current && i.onAnchorChange(s.current);
36
+ }), o ? null : /* @__PURE__ */ p(S.div, { ...n, ref: h });
37
+ }
38
+ );
39
+ ue.displayName = de;
40
+ var G = "PopperContent", [it, lt] = ie(G), fe = a.forwardRef(
41
+ (e, r) => {
42
+ var Z, K, J, Q, ee, te;
43
+ const {
44
+ __scopePopper: t,
45
+ side: o = "bottom",
46
+ sideOffset: n = 0,
47
+ align: i = "center",
48
+ alignOffset: l = 0,
49
+ arrowPadding: h = 0,
50
+ avoidCollisions: s = !0,
51
+ collisionBoundary: d = [],
52
+ collisionPadding: c = 0,
53
+ sticky: f = "partial",
54
+ hideWhenDetached: g = !1,
55
+ updatePositionStrategy: u = "optimized",
56
+ onPlaced: v,
57
+ ...m
58
+ } = e, y = ce(G, t), [w, x] = a.useState(null), T = k(r, (_) => x(_)), [C, b] = a.useState(null), P = rt(C), N = (P == null ? void 0 : P.width) ?? 0, V = (P == null ? void 0 : P.height) ?? 0, Ee = o + (i !== "center" ? "-" + i : ""), Re = typeof c == "number" ? c : { top: 0, right: 0, bottom: 0, left: 0, ...c }, U = Array.isArray(d) ? d : [d], _e = U.length > 0, D = {
59
+ padding: Re,
60
+ boundary: U.filter(pt),
61
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
62
+ altBoundary: _e
63
+ }, { refs: Oe, floatingStyles: z, placement: Se, isPositioned: H, middlewareData: A } = Ue({
64
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
65
+ strategy: "fixed",
66
+ placement: Ee,
67
+ whileElementsMounted: (..._) => ze(..._, {
68
+ animationFrame: u === "always"
69
+ }),
70
+ elements: {
71
+ reference: y.anchor
72
+ },
73
+ middleware: [
74
+ qe({ mainAxis: n + V, alignmentAxis: l }),
75
+ s && Ze({
76
+ mainAxis: !0,
77
+ crossAxis: !1,
78
+ limiter: f === "partial" ? tt() : void 0,
79
+ ...D
80
+ }),
81
+ s && Ke({ ...D }),
82
+ Je({
83
+ ...D,
84
+ apply: ({ elements: _, rects: re, availableWidth: Me, availableHeight: $e }) => {
85
+ const { width: je, height: Ye } = re.reference, L = _.floating.style;
86
+ L.setProperty("--radix-popper-available-width", `${Me}px`), L.setProperty("--radix-popper-available-height", `${$e}px`), L.setProperty("--radix-popper-anchor-width", `${je}px`), L.setProperty("--radix-popper-anchor-height", `${Ye}px`);
87
+ }
88
+ }),
89
+ C && Qe({ element: C, padding: h }),
90
+ dt({ arrowWidth: N, arrowHeight: V }),
91
+ g && et({ strategy: "referenceHidden", ...D })
92
+ ]
93
+ }), [q, Ne] = ge(Se), I = Ge(v);
94
+ oe(() => {
95
+ H && (I == null || I());
96
+ }, [H, I]);
97
+ const De = (Z = A.arrow) == null ? void 0 : Z.x, He = (K = A.arrow) == null ? void 0 : K.y, Ie = ((J = A.arrow) == null ? void 0 : J.centerOffset) !== 0, [Le, ke] = a.useState();
98
+ return oe(() => {
99
+ w && ke(window.getComputedStyle(w).zIndex);
100
+ }, [w]), /* @__PURE__ */ p(
101
+ "div",
102
+ {
103
+ ref: Oe.setFloating,
104
+ "data-radix-popper-content-wrapper": "",
105
+ style: {
106
+ ...z,
107
+ transform: H ? z.transform : "translate(0, -200%)",
108
+ // keep off the page when measuring
109
+ minWidth: "max-content",
110
+ zIndex: Le,
111
+ "--radix-popper-transform-origin": [
112
+ (Q = A.transformOrigin) == null ? void 0 : Q.x,
113
+ (ee = A.transformOrigin) == null ? void 0 : ee.y
114
+ ].join(" "),
115
+ // hide the content if using the hide middleware and should be hidden
116
+ // set visibility to hidden and disable pointer events so the UI behaves
117
+ // as if the PopperContent isn't there at all
118
+ ...((te = A.hide) == null ? void 0 : te.referenceHidden) && {
119
+ visibility: "hidden",
120
+ pointerEvents: "none"
121
+ }
122
+ },
123
+ dir: e.dir,
124
+ children: /* @__PURE__ */ p(
125
+ it,
126
+ {
127
+ scope: t,
128
+ placedSide: q,
129
+ onArrowChange: b,
130
+ arrowX: De,
131
+ arrowY: He,
132
+ shouldHideArrow: Ie,
133
+ children: /* @__PURE__ */ p(
134
+ S.div,
135
+ {
136
+ "data-side": q,
137
+ "data-align": Ne,
138
+ ...m,
139
+ ref: T,
140
+ style: {
141
+ ...m.style,
142
+ // if the PopperContent hasn't been placed yet (not all measurements done)
143
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
144
+ animation: H ? void 0 : "none"
145
+ }
146
+ }
147
+ )
148
+ }
149
+ )
150
+ }
151
+ );
152
+ }
153
+ );
154
+ fe.displayName = G;
155
+ var he = "PopperArrow", ct = {
156
+ top: "bottom",
157
+ right: "left",
158
+ bottom: "top",
159
+ left: "right"
160
+ }, ve = a.forwardRef(function(r, t) {
161
+ const { __scopePopper: o, ...n } = r, i = lt(he, o), l = ct[i.placedSide];
162
+ return (
163
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
164
+ // doesn't report size as we'd expect on SVG elements.
165
+ // it reports their bounding box which is effectively the largest path inside the SVG.
166
+ /* @__PURE__ */ p(
167
+ "span",
168
+ {
169
+ ref: i.onArrowChange,
170
+ style: {
171
+ position: "absolute",
172
+ left: i.arrowX,
173
+ top: i.arrowY,
174
+ [l]: 0,
175
+ transformOrigin: {
176
+ top: "",
177
+ right: "0 0",
178
+ bottom: "center 0",
179
+ left: "100% 0"
180
+ }[i.placedSide],
181
+ transform: {
182
+ top: "translateY(100%)",
183
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
184
+ bottom: "rotate(180deg)",
185
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
186
+ }[i.placedSide],
187
+ visibility: i.shouldHideArrow ? "hidden" : void 0
188
+ },
189
+ children: /* @__PURE__ */ p(
190
+ at,
191
+ {
192
+ ...n,
193
+ ref: t,
194
+ style: {
195
+ ...n.style,
196
+ // ensures the element can be measured correctly (mostly for if SVG)
197
+ display: "block"
198
+ }
199
+ }
200
+ )
201
+ }
202
+ )
203
+ );
204
+ });
205
+ ve.displayName = he;
206
+ function pt(e) {
207
+ return e !== null;
208
+ }
209
+ var dt = (e) => ({
210
+ name: "transformOrigin",
211
+ options: e,
212
+ fn(r) {
213
+ var y, w, x;
214
+ const { placement: t, rects: o, middlewareData: n } = r, l = ((y = n.arrow) == null ? void 0 : y.centerOffset) !== 0, h = l ? 0 : e.arrowWidth, s = l ? 0 : e.arrowHeight, [d, c] = ge(t), f = { start: "0%", center: "50%", end: "100%" }[c], g = (((w = n.arrow) == null ? void 0 : w.x) ?? 0) + h / 2, u = (((x = n.arrow) == null ? void 0 : x.y) ?? 0) + s / 2;
215
+ let v = "", m = "";
216
+ return d === "bottom" ? (v = l ? f : `${g}px`, m = `${-s}px`) : d === "top" ? (v = l ? f : `${g}px`, m = `${o.floating.height + s}px`) : d === "right" ? (v = `${-s}px`, m = l ? f : `${u}px`) : d === "left" && (v = `${o.floating.width + s}px`, m = l ? f : `${u}px`), { data: { x: v, y: m } };
217
+ }
218
+ });
219
+ function ge(e) {
220
+ const [r, t = "center"] = e.split("-");
221
+ return [r, t];
222
+ }
223
+ var ut = pe, ft = ue, ht = fe, vt = ve, gt = Object.freeze({
10
224
  // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
11
225
  position: "absolute",
12
226
  border: 0,
@@ -18,203 +232,203 @@ var ae = Object.freeze({
18
232
  clip: "rect(0, 0, 0, 0)",
19
233
  whiteSpace: "nowrap",
20
234
  wordWrap: "normal"
21
- }), ie = "VisuallyHidden", F = s.forwardRef(
22
- (e, o) => /* @__PURE__ */ p(
23
- M.span,
235
+ }), mt = "VisuallyHidden", me = a.forwardRef(
236
+ (e, r) => /* @__PURE__ */ p(
237
+ S.span,
24
238
  {
25
239
  ...e,
26
- ref: o,
27
- style: { ...ae, ...e.style }
240
+ ref: r,
241
+ style: { ...gt, ...e.style }
28
242
  }
29
243
  )
30
244
  );
31
- F.displayName = ie;
32
- var le = F, [_, Ne] = K("Tooltip", [
33
- G
34
- ]), A = G(), V = "TooltipProvider", ce = 700, O = "tooltip.open", [ue, I] = _(V), Y = (e) => {
245
+ me.displayName = mt;
246
+ var yt = me, [M, Gt] = ae("Tooltip", [
247
+ le
248
+ ]), $ = le(), ye = "TooltipProvider", wt = 700, F = "tooltip.open", [xt, X] = M(ye), we = (e) => {
35
249
  const {
36
- __scopeTooltip: o,
37
- delayDuration: t = ce,
38
- skipDelayDuration: r = 300,
250
+ __scopeTooltip: r,
251
+ delayDuration: t = wt,
252
+ skipDelayDuration: o = 300,
39
253
  disableHoverableContent: n = !1,
40
- children: l
41
- } = e, i = s.useRef(!0), v = s.useRef(!1), a = s.useRef(0);
42
- return s.useEffect(() => {
43
- const d = a.current;
254
+ children: i
255
+ } = e, l = a.useRef(!0), h = a.useRef(!1), s = a.useRef(0);
256
+ return a.useEffect(() => {
257
+ const d = s.current;
44
258
  return () => window.clearTimeout(d);
45
259
  }, []), /* @__PURE__ */ p(
46
- ue,
260
+ xt,
47
261
  {
48
- scope: o,
49
- isOpenDelayedRef: i,
262
+ scope: r,
263
+ isOpenDelayedRef: l,
50
264
  delayDuration: t,
51
- onOpen: s.useCallback(() => {
52
- window.clearTimeout(a.current), i.current = !1;
265
+ onOpen: a.useCallback(() => {
266
+ window.clearTimeout(s.current), l.current = !1;
53
267
  }, []),
54
- onClose: s.useCallback(() => {
55
- window.clearTimeout(a.current), a.current = window.setTimeout(
56
- () => i.current = !0,
57
- r
268
+ onClose: a.useCallback(() => {
269
+ window.clearTimeout(s.current), s.current = window.setTimeout(
270
+ () => l.current = !0,
271
+ o
58
272
  );
59
- }, [r]),
60
- isPointerInTransitRef: v,
61
- onPointerInTransitChange: s.useCallback((d) => {
62
- v.current = d;
273
+ }, [o]),
274
+ isPointerInTransitRef: h,
275
+ onPointerInTransitChange: a.useCallback((d) => {
276
+ h.current = d;
63
277
  }, []),
64
278
  disableHoverableContent: n,
65
- children: l
279
+ children: i
66
280
  }
67
281
  );
68
282
  };
69
- Y.displayName = V;
70
- var P = "Tooltip", [pe, D] = _(P), B = (e) => {
283
+ we.displayName = ye;
284
+ var O = "Tooltip", [Ct, j] = M(O), xe = (e) => {
71
285
  const {
72
- __scopeTooltip: o,
286
+ __scopeTooltip: r,
73
287
  children: t,
74
- open: r,
288
+ open: o,
75
289
  defaultOpen: n,
76
- onOpenChange: l,
77
- disableHoverableContent: i,
78
- delayDuration: v
79
- } = e, a = I(P, e.__scopeTooltip), d = A(o), [c, f] = s.useState(null), h = $(), u = s.useRef(0), y = i ?? a.disableHoverableContent, m = v ?? a.delayDuration, T = s.useRef(!1), [x, C] = J({
80
- prop: r,
290
+ onOpenChange: i,
291
+ disableHoverableContent: l,
292
+ delayDuration: h
293
+ } = e, s = X(O, e.__scopeTooltip), d = $(r), [c, f] = a.useState(null), g = Xe(), u = a.useRef(0), v = l ?? s.disableHoverableContent, m = h ?? s.delayDuration, y = a.useRef(!1), [w, x] = Fe({
294
+ prop: o,
81
295
  defaultProp: n ?? !1,
82
- onChange: (S) => {
83
- S ? (a.onOpen(), document.dispatchEvent(new CustomEvent(O))) : a.onClose(), l == null || l(S);
296
+ onChange: (N) => {
297
+ N ? (s.onOpen(), document.dispatchEvent(new CustomEvent(F))) : s.onClose(), i == null || i(N);
84
298
  },
85
- caller: P
86
- }), b = s.useMemo(() => x ? T.current ? "delayed-open" : "instant-open" : "closed", [x]), E = s.useCallback(() => {
87
- window.clearTimeout(u.current), u.current = 0, T.current = !1, C(!0);
88
- }, [C]), R = s.useCallback(() => {
89
- window.clearTimeout(u.current), u.current = 0, C(!1);
90
- }, [C]), N = s.useCallback(() => {
299
+ caller: O
300
+ }), T = a.useMemo(() => w ? y.current ? "delayed-open" : "instant-open" : "closed", [w]), C = a.useCallback(() => {
301
+ window.clearTimeout(u.current), u.current = 0, y.current = !1, x(!0);
302
+ }, [x]), b = a.useCallback(() => {
303
+ window.clearTimeout(u.current), u.current = 0, x(!1);
304
+ }, [x]), P = a.useCallback(() => {
91
305
  window.clearTimeout(u.current), u.current = window.setTimeout(() => {
92
- T.current = !0, C(!0), u.current = 0;
306
+ y.current = !0, x(!0), u.current = 0;
93
307
  }, m);
94
- }, [m, C]);
95
- return s.useEffect(() => () => {
308
+ }, [m, x]);
309
+ return a.useEffect(() => () => {
96
310
  u.current && (window.clearTimeout(u.current), u.current = 0);
97
- }, []), /* @__PURE__ */ p(te, { ...d, children: /* @__PURE__ */ p(
98
- pe,
311
+ }, []), /* @__PURE__ */ p(ut, { ...d, children: /* @__PURE__ */ p(
312
+ Ct,
99
313
  {
100
- scope: o,
101
- contentId: h,
102
- open: x,
103
- stateAttribute: b,
314
+ scope: r,
315
+ contentId: g,
316
+ open: w,
317
+ stateAttribute: T,
104
318
  trigger: c,
105
319
  onTriggerChange: f,
106
- onTriggerEnter: s.useCallback(() => {
107
- a.isOpenDelayedRef.current ? N() : E();
108
- }, [a.isOpenDelayedRef, N, E]),
109
- onTriggerLeave: s.useCallback(() => {
110
- y ? R() : (window.clearTimeout(u.current), u.current = 0);
111
- }, [R, y]),
112
- onOpen: E,
113
- onClose: R,
114
- disableHoverableContent: y,
320
+ onTriggerEnter: a.useCallback(() => {
321
+ s.isOpenDelayedRef.current ? P() : C();
322
+ }, [s.isOpenDelayedRef, P, C]),
323
+ onTriggerLeave: a.useCallback(() => {
324
+ v ? b() : (window.clearTimeout(u.current), u.current = 0);
325
+ }, [b, v]),
326
+ onOpen: C,
327
+ onClose: b,
328
+ disableHoverableContent: v,
115
329
  children: t
116
330
  }
117
331
  ) });
118
332
  };
119
- B.displayName = P;
120
- var k = "TooltipTrigger", U = s.forwardRef(
121
- (e, o) => {
122
- const { __scopeTooltip: t, ...r } = e, n = D(k, t), l = I(k, t), i = A(t), v = s.useRef(null), a = j(o, v, n.onTriggerChange), d = s.useRef(!1), c = s.useRef(!1), f = s.useCallback(() => d.current = !1, []);
123
- return s.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ p(oe, { asChild: !0, ...i, children: /* @__PURE__ */ p(
124
- M.button,
333
+ xe.displayName = O;
334
+ var W = "TooltipTrigger", Ce = a.forwardRef(
335
+ (e, r) => {
336
+ const { __scopeTooltip: t, ...o } = e, n = j(W, t), i = X(W, t), l = $(t), h = a.useRef(null), s = k(r, h, n.onTriggerChange), d = a.useRef(!1), c = a.useRef(!1), f = a.useCallback(() => d.current = !1, []);
337
+ return a.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ p(ft, { asChild: !0, ...l, children: /* @__PURE__ */ p(
338
+ S.button,
125
339
  {
126
340
  "aria-describedby": n.open ? n.contentId : void 0,
127
341
  "data-state": n.stateAttribute,
128
- ...r,
129
- ref: a,
130
- onPointerMove: g(e.onPointerMove, (h) => {
131
- h.pointerType !== "touch" && !c.current && !l.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
342
+ ...o,
343
+ ref: s,
344
+ onPointerMove: E(e.onPointerMove, (g) => {
345
+ g.pointerType !== "touch" && !c.current && !i.isPointerInTransitRef.current && (n.onTriggerEnter(), c.current = !0);
132
346
  }),
133
- onPointerLeave: g(e.onPointerLeave, () => {
347
+ onPointerLeave: E(e.onPointerLeave, () => {
134
348
  n.onTriggerLeave(), c.current = !1;
135
349
  }),
136
- onPointerDown: g(e.onPointerDown, () => {
350
+ onPointerDown: E(e.onPointerDown, () => {
137
351
  n.open && n.onClose(), d.current = !0, document.addEventListener("pointerup", f, { once: !0 });
138
352
  }),
139
- onFocus: g(e.onFocus, () => {
353
+ onFocus: E(e.onFocus, () => {
140
354
  d.current || n.onOpen();
141
355
  }),
142
- onBlur: g(e.onBlur, n.onClose),
143
- onClick: g(e.onClick, n.onClose)
356
+ onBlur: E(e.onBlur, n.onClose),
357
+ onClick: E(e.onClick, n.onClose)
144
358
  }
145
359
  ) });
146
360
  }
147
361
  );
148
- U.displayName = k;
149
- var de = "TooltipPortal", [Se, fe] = _(de, {
362
+ Ce.displayName = W;
363
+ var Pt = "TooltipPortal", [Xt, Tt] = M(Pt, {
150
364
  forceMount: void 0
151
- }), w = "TooltipContent", q = s.forwardRef(
152
- (e, o) => {
153
- const t = fe(w, e.__scopeTooltip), { forceMount: r = t.forceMount, side: n = "top", ...l } = e, i = D(w, e.__scopeTooltip);
154
- return /* @__PURE__ */ p(Q, { present: r || i.open, children: i.disableHoverableContent ? /* @__PURE__ */ p(W, { side: n, ...l, ref: o }) : /* @__PURE__ */ p(ve, { side: n, ...l, ref: o }) });
365
+ }), R = "TooltipContent", Pe = a.forwardRef(
366
+ (e, r) => {
367
+ const t = Tt(R, e.__scopeTooltip), { forceMount: o = t.forceMount, side: n = "top", ...i } = e, l = j(R, e.__scopeTooltip);
368
+ return /* @__PURE__ */ p(We, { present: o || l.open, children: l.disableHoverableContent ? /* @__PURE__ */ p(Te, { side: n, ...i, ref: r }) : /* @__PURE__ */ p(bt, { side: n, ...i, ref: r }) });
155
369
  }
156
- ), ve = s.forwardRef((e, o) => {
157
- const t = D(w, e.__scopeTooltip), r = I(w, e.__scopeTooltip), n = s.useRef(null), l = j(o, n), [i, v] = s.useState(null), { trigger: a, onClose: d } = t, c = n.current, { onPointerInTransitChange: f } = r, h = s.useCallback(() => {
158
- v(null), f(!1);
159
- }, [f]), u = s.useCallback(
160
- (y, m) => {
161
- const T = y.currentTarget, x = { x: y.clientX, y: y.clientY }, C = me(x, T.getBoundingClientRect()), b = Ce(x, C), E = xe(m.getBoundingClientRect()), R = we([...b, ...E]);
162
- v(R), f(!0);
370
+ ), bt = a.forwardRef((e, r) => {
371
+ const t = j(R, e.__scopeTooltip), o = X(R, e.__scopeTooltip), n = a.useRef(null), i = k(r, n), [l, h] = a.useState(null), { trigger: s, onClose: d } = t, c = n.current, { onPointerInTransitChange: f } = o, g = a.useCallback(() => {
372
+ h(null), f(!1);
373
+ }, [f]), u = a.useCallback(
374
+ (v, m) => {
375
+ const y = v.currentTarget, w = { x: v.clientX, y: v.clientY }, x = _t(w, y.getBoundingClientRect()), T = Ot(w, x), C = St(m.getBoundingClientRect()), b = Dt([...T, ...C]);
376
+ h(b), f(!0);
163
377
  },
164
378
  [f]
165
379
  );
166
- return s.useEffect(() => () => h(), [h]), s.useEffect(() => {
167
- if (a && c) {
168
- const y = (T) => u(T, c), m = (T) => u(T, a);
169
- return a.addEventListener("pointerleave", y), c.addEventListener("pointerleave", m), () => {
170
- a.removeEventListener("pointerleave", y), c.removeEventListener("pointerleave", m);
380
+ return a.useEffect(() => () => g(), [g]), a.useEffect(() => {
381
+ if (s && c) {
382
+ const v = (y) => u(y, c), m = (y) => u(y, s);
383
+ return s.addEventListener("pointerleave", v), c.addEventListener("pointerleave", m), () => {
384
+ s.removeEventListener("pointerleave", v), c.removeEventListener("pointerleave", m);
171
385
  };
172
386
  }
173
- }, [a, c, u, h]), s.useEffect(() => {
174
- if (i) {
175
- const y = (m) => {
176
- const T = m.target, x = { x: m.clientX, y: m.clientY }, C = (a == null ? void 0 : a.contains(T)) || (c == null ? void 0 : c.contains(T)), b = !ge(x, i);
177
- C ? h() : b && (h(), d());
387
+ }, [s, c, u, g]), a.useEffect(() => {
388
+ if (l) {
389
+ const v = (m) => {
390
+ const y = m.target, w = { x: m.clientX, y: m.clientY }, x = (s == null ? void 0 : s.contains(y)) || (c == null ? void 0 : c.contains(y)), T = !Nt(w, l);
391
+ x ? g() : T && (g(), d());
178
392
  };
179
- return document.addEventListener("pointermove", y), () => document.removeEventListener("pointermove", y);
393
+ return document.addEventListener("pointermove", v), () => document.removeEventListener("pointermove", v);
180
394
  }
181
- }, [a, c, i, d, h]), /* @__PURE__ */ p(W, { ...e, ref: l });
182
- }), [he, ye] = _(P, { isInside: !1 }), Te = Z("TooltipContent"), W = s.forwardRef(
183
- (e, o) => {
395
+ }, [s, c, l, d, g]), /* @__PURE__ */ p(Te, { ...e, ref: i });
396
+ }), [At, Et] = M(O, { isInside: !1 }), Rt = Be("TooltipContent"), Te = a.forwardRef(
397
+ (e, r) => {
184
398
  const {
185
399
  __scopeTooltip: t,
186
- children: r,
400
+ children: o,
187
401
  "aria-label": n,
188
- onEscapeKeyDown: l,
189
- onPointerDownOutside: i,
190
- ...v
191
- } = e, a = D(w, t), d = A(t), { onClose: c } = a;
192
- return s.useEffect(() => (document.addEventListener(O, c), () => document.removeEventListener(O, c)), [c]), s.useEffect(() => {
193
- if (a.trigger) {
194
- const f = (h) => {
195
- const u = h.target;
196
- u != null && u.contains(a.trigger) && c();
402
+ onEscapeKeyDown: i,
403
+ onPointerDownOutside: l,
404
+ ...h
405
+ } = e, s = j(R, t), d = $(t), { onClose: c } = s;
406
+ return a.useEffect(() => (document.addEventListener(F, c), () => document.removeEventListener(F, c)), [c]), a.useEffect(() => {
407
+ if (s.trigger) {
408
+ const f = (g) => {
409
+ const u = g.target;
410
+ u != null && u.contains(s.trigger) && c();
197
411
  };
198
412
  return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
199
413
  }
200
- }, [a.trigger, c]), /* @__PURE__ */ p(
201
- ee,
414
+ }, [s.trigger, c]), /* @__PURE__ */ p(
415
+ Ve,
202
416
  {
203
417
  asChild: !0,
204
418
  disableOutsidePointerEvents: !1,
205
- onEscapeKeyDown: l,
206
- onPointerDownOutside: i,
419
+ onEscapeKeyDown: i,
420
+ onPointerDownOutside: l,
207
421
  onFocusOutside: (f) => f.preventDefault(),
208
422
  onDismiss: c,
209
- children: /* @__PURE__ */ L(
210
- re,
423
+ children: /* @__PURE__ */ Y(
424
+ ht,
211
425
  {
212
- "data-state": a.stateAttribute,
426
+ "data-state": s.stateAttribute,
213
427
  ...d,
214
- ...v,
215
- ref: o,
428
+ ...h,
429
+ ref: r,
216
430
  style: {
217
- ...v.style,
431
+ ...h.style,
218
432
  "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
219
433
  "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
220
434
  "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
@@ -222,8 +436,8 @@ var de = "TooltipPortal", [Se, fe] = _(de, {
222
436
  "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
223
437
  },
224
438
  children: [
225
- /* @__PURE__ */ p(Te, { children: r }),
226
- /* @__PURE__ */ p(he, { scope: t, isInside: !0, children: /* @__PURE__ */ p(le, { id: a.contentId, role: "tooltip", children: n || r }) })
439
+ /* @__PURE__ */ p(Rt, { children: o }),
440
+ /* @__PURE__ */ p(At, { scope: t, isInside: !0, children: /* @__PURE__ */ p(yt, { id: s.contentId, role: "tooltip", children: n || o }) })
227
441
  ]
228
442
  }
229
443
  )
@@ -231,127 +445,127 @@ var de = "TooltipPortal", [Se, fe] = _(de, {
231
445
  );
232
446
  }
233
447
  );
234
- q.displayName = w;
235
- var X = "TooltipArrow", z = s.forwardRef(
236
- (e, o) => {
237
- const { __scopeTooltip: t, ...r } = e, n = A(t);
238
- return ye(
239
- X,
448
+ Pe.displayName = R;
449
+ var be = "TooltipArrow", Ae = a.forwardRef(
450
+ (e, r) => {
451
+ const { __scopeTooltip: t, ...o } = e, n = $(t);
452
+ return Et(
453
+ be,
240
454
  t
241
- ).isInside ? null : /* @__PURE__ */ p(ne, { ...n, ...r, ref: o });
455
+ ).isInside ? null : /* @__PURE__ */ p(vt, { ...n, ...o, ref: r });
242
456
  }
243
457
  );
244
- z.displayName = X;
245
- function me(e, o) {
246
- const t = Math.abs(o.top - e.y), r = Math.abs(o.bottom - e.y), n = Math.abs(o.right - e.x), l = Math.abs(o.left - e.x);
247
- switch (Math.min(t, r, n, l)) {
248
- case l:
458
+ Ae.displayName = be;
459
+ function _t(e, r) {
460
+ const t = Math.abs(r.top - e.y), o = Math.abs(r.bottom - e.y), n = Math.abs(r.right - e.x), i = Math.abs(r.left - e.x);
461
+ switch (Math.min(t, o, n, i)) {
462
+ case i:
249
463
  return "left";
250
464
  case n:
251
465
  return "right";
252
466
  case t:
253
467
  return "top";
254
- case r:
468
+ case o:
255
469
  return "bottom";
256
470
  default:
257
471
  throw new Error("unreachable");
258
472
  }
259
473
  }
260
- function Ce(e, o, t = 5) {
261
- const r = [];
262
- switch (o) {
474
+ function Ot(e, r, t = 5) {
475
+ const o = [];
476
+ switch (r) {
263
477
  case "top":
264
- r.push(
478
+ o.push(
265
479
  { x: e.x - t, y: e.y + t },
266
480
  { x: e.x + t, y: e.y + t }
267
481
  );
268
482
  break;
269
483
  case "bottom":
270
- r.push(
484
+ o.push(
271
485
  { x: e.x - t, y: e.y - t },
272
486
  { x: e.x + t, y: e.y - t }
273
487
  );
274
488
  break;
275
489
  case "left":
276
- r.push(
490
+ o.push(
277
491
  { x: e.x + t, y: e.y - t },
278
492
  { x: e.x + t, y: e.y + t }
279
493
  );
280
494
  break;
281
495
  case "right":
282
- r.push(
496
+ o.push(
283
497
  { x: e.x - t, y: e.y - t },
284
498
  { x: e.x - t, y: e.y + t }
285
499
  );
286
500
  break;
287
501
  }
288
- return r;
502
+ return o;
289
503
  }
290
- function xe(e) {
291
- const { top: o, right: t, bottom: r, left: n } = e;
504
+ function St(e) {
505
+ const { top: r, right: t, bottom: o, left: n } = e;
292
506
  return [
293
- { x: n, y: o },
294
- { x: t, y: o },
507
+ { x: n, y: r },
295
508
  { x: t, y: r },
296
- { x: n, y: r }
509
+ { x: t, y: o },
510
+ { x: n, y: o }
297
511
  ];
298
512
  }
299
- function ge(e, o) {
300
- const { x: t, y: r } = e;
513
+ function Nt(e, r) {
514
+ const { x: t, y: o } = e;
301
515
  let n = !1;
302
- for (let l = 0, i = o.length - 1; l < o.length; i = l++) {
303
- const v = o[l], a = o[i], d = v.x, c = v.y, f = a.x, h = a.y;
304
- c > r != h > r && t < (f - d) * (r - c) / (h - c) + d && (n = !n);
516
+ for (let i = 0, l = r.length - 1; i < r.length; l = i++) {
517
+ const h = r[i], s = r[l], d = h.x, c = h.y, f = s.x, g = s.y;
518
+ c > o != g > o && t < (f - d) * (o - c) / (g - c) + d && (n = !n);
305
519
  }
306
520
  return n;
307
521
  }
308
- function we(e) {
309
- const o = e.slice();
310
- return o.sort((t, r) => t.x < r.x ? -1 : t.x > r.x ? 1 : t.y < r.y ? -1 : t.y > r.y ? 1 : 0), be(o);
522
+ function Dt(e) {
523
+ const r = e.slice();
524
+ return r.sort((t, o) => t.x < o.x ? -1 : t.x > o.x ? 1 : t.y < o.y ? -1 : t.y > o.y ? 1 : 0), Ht(r);
311
525
  }
312
- function be(e) {
526
+ function Ht(e) {
313
527
  if (e.length <= 1)
314
528
  return e.slice();
315
- const o = [];
316
- for (let r = 0; r < e.length; r++) {
317
- const n = e[r];
318
- for (; o.length >= 2; ) {
319
- const l = o[o.length - 1], i = o[o.length - 2];
320
- if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x))
321
- o.pop();
529
+ const r = [];
530
+ for (let o = 0; o < e.length; o++) {
531
+ const n = e[o];
532
+ for (; r.length >= 2; ) {
533
+ const i = r[r.length - 1], l = r[r.length - 2];
534
+ if ((i.x - l.x) * (n.y - l.y) >= (i.y - l.y) * (n.x - l.x))
535
+ r.pop();
322
536
  else
323
537
  break;
324
538
  }
325
- o.push(n);
539
+ r.push(n);
326
540
  }
327
- o.pop();
541
+ r.pop();
328
542
  const t = [];
329
- for (let r = e.length - 1; r >= 0; r--) {
330
- const n = e[r];
543
+ for (let o = e.length - 1; o >= 0; o--) {
544
+ const n = e[o];
331
545
  for (; t.length >= 2; ) {
332
- const l = t[t.length - 1], i = t[t.length - 2];
333
- if ((l.x - i.x) * (n.y - i.y) >= (l.y - i.y) * (n.x - i.x))
546
+ const i = t[t.length - 1], l = t[t.length - 2];
547
+ if ((i.x - l.x) * (n.y - l.y) >= (i.y - l.y) * (n.x - l.x))
334
548
  t.pop();
335
549
  else
336
550
  break;
337
551
  }
338
552
  t.push(n);
339
553
  }
340
- return t.pop(), o.length === 1 && t.length === 1 && o[0].x === t[0].x && o[0].y === t[0].y ? o : o.concat(t);
554
+ return t.pop(), r.length === 1 && t.length === 1 && r[0].x === t[0].x && r[0].y === t[0].y ? r : r.concat(t);
341
555
  }
342
- const Ee = "_tooltipContent_12gjy_1", Re = "_tooltipArrow_12gjy_8", Pe = "_fadeIn_12gjy_1", H = {
343
- tooltipContent: Ee,
344
- tooltipArrow: Re,
345
- fadeIn: Pe
346
- }, He = se(
347
- ({ children: e, content: o, className: t, style: r }, n) => /* @__PURE__ */ p(Y, { children: /* @__PURE__ */ L(B, { delayDuration: 1e3, children: [
348
- /* @__PURE__ */ p(U, { asChild: !0, children: /* @__PURE__ */ p("div", { ref: n, className: t, style: r, children: e }) }),
349
- /* @__PURE__ */ L(q, { className: H.tooltipContent, sideOffset: 5, children: [
350
- /* @__PURE__ */ p(z, { className: H.tooltipArrow }),
351
- /* @__PURE__ */ p("span", { children: o })
556
+ const It = "_tooltipContent_12gjy_1", Lt = "_tooltipArrow_12gjy_8", kt = "_fadeIn_12gjy_1", ne = {
557
+ tooltipContent: It,
558
+ tooltipArrow: Lt,
559
+ fadeIn: kt
560
+ }, Vt = ot(
561
+ ({ children: e, content: r, className: t, style: o }, n) => /* @__PURE__ */ p(we, { children: /* @__PURE__ */ Y(xe, { delayDuration: 1e3, children: [
562
+ /* @__PURE__ */ p(Ce, { asChild: !0, children: /* @__PURE__ */ p("div", { ref: n, className: t, style: o, children: e }) }),
563
+ /* @__PURE__ */ Y(Pe, { className: ne.tooltipContent, sideOffset: 5, children: [
564
+ /* @__PURE__ */ p(Ae, { className: ne.tooltipArrow }),
565
+ /* @__PURE__ */ p("span", { children: r })
352
566
  ] })
353
567
  ] }) })
354
568
  );
355
569
  export {
356
- He as default
570
+ Vt as default
357
571
  };