@pdf-viewer/react 1.12.0-rc.1 → 1.13.0-beta.0

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 (75) hide show
  1. package/dist/ToolbarLayout.module-126458d9.js +3539 -0
  2. package/dist/assets/style.css +1 -1
  3. package/dist/components/RPController.js +48 -48
  4. package/dist/components/RPPages.js +3 -4
  5. package/dist/components/RPProvider.js +4 -5
  6. package/dist/components/layout/LayoutContainer.js +3 -4
  7. package/dist/components/layout/RPDefaultLayout.js +3 -4
  8. package/dist/components/layout/RPLayout.js +13 -14
  9. package/dist/components/layout/sidebar/RPSidebar.js +2 -3
  10. package/dist/components/layout/sidebar/Thumbnail.js +3 -4
  11. package/dist/components/layout/sidebar/Thumbnails.js +3 -4
  12. package/dist/components/layout/toolbar/DocumentDialog.js +3 -4
  13. package/dist/components/layout/toolbar/FileDownloadTool.js +3 -4
  14. package/dist/components/layout/toolbar/MostPageTool.js +3 -4
  15. package/dist/components/layout/toolbar/OtherTool.js +3 -4
  16. package/dist/components/layout/toolbar/Paginate.js +3 -4
  17. package/dist/components/layout/toolbar/PrintTool.js +3 -4
  18. package/dist/components/layout/toolbar/RPMoreOptions.js +4 -5
  19. package/dist/components/layout/toolbar/RPToolbar.js +5 -6
  20. package/dist/components/layout/toolbar/RPToolbarEnd.js +3 -4
  21. package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -4
  22. package/dist/components/layout/toolbar/SearchTool.js +3 -4
  23. package/dist/components/layout/toolbar/ThumbnailTool.js +5 -6
  24. package/dist/components/layout/toolbar/ToolbarCustom.js +5 -6
  25. package/dist/components/layout/toolbar/ToolbarDefault.js +5 -6
  26. package/dist/components/layout/toolbar/ToolbarLayout.js +4 -5
  27. package/dist/components/layout/toolbar/ZoomTool.js +117 -130
  28. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -5
  29. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -5
  30. package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -5
  31. package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -5
  32. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -5
  33. package/dist/components/layout/toolbar/tools/PrintTool.js +4 -5
  34. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -5
  35. package/dist/components/layout/toolbar/tools/ZoomInTool.js +20 -19
  36. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +141 -0
  37. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +132 -27
  38. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +13 -12
  39. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +12 -13
  40. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -5
  41. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +4 -5
  42. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +4 -5
  43. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +4 -5
  44. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +4 -5
  45. package/dist/components/page/AnnotationLayer.js +3 -4
  46. package/dist/components/page/CanvasLayer.js +3 -4
  47. package/dist/components/page/DualPage.js +3 -4
  48. package/dist/components/page/RPPage.js +3 -4
  49. package/dist/components/page/SinglePage.js +3 -4
  50. package/dist/components/page/TextHighlightLayer.js +3 -4
  51. package/dist/components/page/TextLayer.js +3 -4
  52. package/dist/components/ui/LoadingIndicator.js +3 -4
  53. package/dist/contexts/PaginationContext.js +5 -6
  54. package/dist/contexts/PrintContext.js +5 -6
  55. package/dist/contexts/RenderQueueProvider.js +5 -6
  56. package/dist/contexts/SearchContext.js +5 -6
  57. package/dist/contexts/ThumbnailsContext.js +5 -6
  58. package/dist/main.js +81 -81
  59. package/dist/types/components/layout/toolbar/tools/ZoomLevelDisplay.d.ts +7 -0
  60. package/dist/types/main.d.ts +1 -1
  61. package/dist/types/utils/types.d.ts +1 -0
  62. package/dist/types/utils/zoom.d.ts +2 -0
  63. package/dist/utils/hooks/useFileDownload.js +3 -4
  64. package/dist/utils/hooks/useLicense.js +1 -1
  65. package/dist/utils/hooks/usePaginate.js +3 -4
  66. package/dist/utils/hooks/usePresentPage.js +3 -4
  67. package/dist/utils/hooks/usePrint.js +3 -4
  68. package/dist/utils/hooks/useScrollToPage.js +3 -4
  69. package/dist/utils/hooks/useSearch.js +3 -4
  70. package/dist/utils/hooks/useThumbnail.js +3 -4
  71. package/dist/utils/hooks/useVirtualReactWindow.js +3 -4
  72. package/dist/utils/zoom.js +6 -0
  73. package/package.json +1 -1
  74. package/dist/ToolbarLayout.module-1f1dd627.js +0 -3416
  75. package/dist/ZoomTool.module-7082af8c.js +0 -12
@@ -1,3416 +0,0 @@
1
- import { jsx as a, Fragment as fe, jsxs as $ } from "react/jsx-runtime";
2
- import * as X from "react";
3
- import { useRef as k, useEffect as z, useCallback as E, useState as q, useMemo as W, createContext as qe, useContext as Ge, useImperativeHandle as rn, createElement as Be, PureComponent as or, Component as ir, memo as on, forwardRef as ar } from "react";
4
- import { ChevronUpIcon as Xe } from "./components/icons/ChevronUpIcon.js";
5
- import { UIButton as we } from "./components/ui/Button.js";
6
- import { UIInput as an } from "./components/ui/Input.js";
7
- import { ViewMode as Re, ScrollMode as ne, AnnotationSubType as Dt, SelectionMode as sr, ErrorType as cr } from "./utils/types.js";
8
- import { useScrollModeContext as Ee } from "./contexts/ScrollModeContext.js";
9
- import { useDocumentContext as re } from "./contexts/RPDocumentContext.js";
10
- import { useDocumentPasswordContext as lr } from "./contexts/DocumentPasswordContext.js";
11
- import { useDarkModeContext as dr } from "./contexts/DarkModeContext.js";
12
- import "./contexts/RotationContext.js";
13
- import { useLayerContext as ur } from "./contexts/LayerContext.js";
14
- import { useZoomContext as _t } from "./contexts/ZoomContext.js";
15
- import { useViewModeContext as Me } from "./contexts/ViewModeContext.js";
16
- import { useVirtualScrollContext as Je } from "./contexts/VirtualScrollContext.js";
17
- import { useVirtualGridContext as sn } from "./contexts/VirtualGridContext.js";
18
- import { useSelectionModeContext as pr } from "./contexts/SelectionModeContext.js";
19
- import { useInitialStateContext as hr } from "./contexts/InitialStateContext.js";
20
- import { useFullScreenContext as fr } from "./contexts/FullScreenContext.js";
21
- import "./contexts/FileInputContext.js";
22
- import "./contexts/DropFileZoneContext.js";
23
- import { findMatches as mr, resetDivs as gr, highlightMatches as vr, isMatchEntireWord as wr } from "./utils/highlight.js";
24
- import { useLayoutContainer as be } from "./contexts/LayoutContainerContext.js";
25
- import { useDimensionPagesContext as Ue } from "./contexts/DimensionPagesContext.js";
26
- import { useLocalizationContext as me } from "./contexts/LocalizationContext.js";
27
- import { useHighlightContext as _r } from "./contexts/HighlightContext.js";
28
- import "./contexts/LicenseContext.js";
29
- import { useDownloadContext as br } from "./contexts/DownloadContext.js";
30
- import { useSmoothScrollContext as cn } from "./contexts/SmoothScrollContext.js";
31
- import "./contexts/ElementPageContext.js";
32
- import { usePagesRotateContext as et } from "./contexts/PagesRotateContext.js";
33
- import { Queue as Tr } from "./utils/Queue.js";
34
- import { renderPage as Cr } from "./utils/renderPage.js";
35
- import { useGlobalCurrentPage as Pr } from "./contexts/GlobalCurrentPage.js";
36
- import { useLoaderContext as bt } from "./contexts/LoaderContext.js";
37
- import { useToolComponentContext as Ne } from "./contexts/ToolComponentContext.js";
38
- import { useIconToolContext as Te } from "./contexts/IconToolContext.js";
39
- import { useOtherToolContext as yr } from "./contexts/OtherToolContext.js";
40
- import { useEventCallbackContext as Sr } from "./contexts/EventCallbackContext.js";
41
- import "./components/RPConfig.js";
42
- import { ThumbnailIcon as Ir } from "./components/icons/Thumbnail.js";
43
- import { c as de } from "./clsx-0c6e471a.js";
44
- import { LoaderIcon as ln } from "./components/icons/LoaderIcon.js";
45
- import { Container as xr } from "./components/layout/Container.js";
46
- import { useViewportContext as Oe, ViewportProvider as Rr } from "./contexts/ViewportContext.js";
47
- import { useToolbarComponentContext as Ce, ToolbarComponentProvider as Lr } from "./contexts/ToolbarComponentContext.js";
48
- import { RPSplitter as Er } from "./components/layout/sidebar/RPSplitter.js";
49
- import { WrapperLayout as Nr } from "./components/layout/WrapperLayout.js";
50
- import { c as _e, L as Or } from "./LayoutWrapper-6224491f.js";
51
- import { useThemeContext as Dr } from "./contexts/ThemeContext.js";
52
- import { RPDropFileZone as Ar } from "./components/RPDropFileZone.js";
53
- import { c as te, S as At } from "./SearchCloseButton-08d57275.js";
54
- import { UICheckbox as zt } from "./components/ui/Checkbox.js";
55
- import { useIconContext as Pe, IconProvider as zr } from "./contexts/IconContext.js";
56
- import Q from "./components/ui/RPTooltip.js";
57
- import { UIDropDown as dn } from "./components/ui/DropDown.js";
58
- import "./ZoomTool.module-7082af8c.js";
59
- import { MenuItem as Qe } from "./components/layout/toolbar/MenuItem.js";
60
- import { MenuSeparator as un } from "./components/layout/toolbar/MenuSeparator.js";
61
- import { dateFormatter as Mt } from "./utils/dateFormatter.js";
62
- import { PropertyItem as Mr } from "./components/layout/toolbar/PropertyItem.js";
63
- import "./RotateTool.module-67946714.js";
64
- import { withRef as tt } from "./utils/withRef.js";
65
- import { useInfiniteScroll as Fr } from "./utils/hooks/useInfiniteScroll.js";
66
- import { THUMBNAIL_MIN_WIDTH as kr } from "./utils/constants.js";
67
- import * as Wr from "pdfjs-dist";
68
- import { PixelsPerInch as Hr, AnnotationMode as $r, RenderingCancelledException as qr, AnnotationLayer as Gr } from "pdfjs-dist";
69
- import { SimpleLinkService as Ur } from "./utils/link_service.js";
70
- import { annotationsEvents as Vr, annotationEventsHandler as Br, handleClick as Ft, handleAnnotationWidget as jr, handleAnnotationLink as Kr, bindLayerEvents as Zr, unbindLayerEvents as kt } from "./utils/annotations.js";
71
- import { normalizeSingleKeyword as Xr, sortHighlightPosition as Qr, unwrap as Yr } from "./components/page/searchHighlight.js";
72
- import { CustomElement as Jr } from "./components/page/CustomElement.js";
73
- import { getGridDimension as Tt, getPositionFromPage as eo, getPageFromPosition as to } from "./utils/calculatePage.js";
74
- import { useMousePressed as no } from "./utils/hooks/useMousePressed.js";
75
- import { useGrabScroll as ro } from "./utils/hooks/useGrabScroll.js";
76
- import { usePinch as oo } from "./utils/hooks/usePinch.js";
77
- import { useDebounce as Ct } from "./utils/hooks/useDebounce.js";
78
- import io from "./components/ui/PasswordModal.js";
79
- import { getScrollDistance as ze } from "./utils/getScrollDistance.js";
80
- import { getWordPositionInPage as ao } from "./utils/getWordPositionInPage.js";
81
- import { getThumbnailViewport as so } from "./utils/getThumbnailViewport.js";
82
- import { smoothScrollTo as at } from "./utils/smoothScrollTo.js";
83
- import { appConsole as co } from "./utils/appConsole.js";
84
- import { FileUploadTool as pn } from "./components/layout/toolbar/FileUploadTool.js";
85
- import { DarkModeTool as lo } from "./components/layout/toolbar/DarkModeTool.js";
86
- import { ThreeDotIcon as uo } from "./components/icons/ThreeDotIcon.js";
87
- import { c as po, u as Pt, P as Ve, a as $e, b as yt, k as ho, e as fo, i as mo } from "./index-c9a2990a.js";
88
- import { D as go, d as st } from "./floating-ui.react-dom-d22a10b4.js";
89
- import { a as vo, h as wo, u as _o, F as bo, b as To, G as hn } from "./index-3bf64864.js";
90
- import { CloseIcon as Co } from "./components/icons/CloseIcon.js";
91
- import { DocumentProperties as Po } from "./components/layout/toolbar/DocumentProperties.js";
92
- import { RotateTool as yo } from "./components/layout/toolbar/RotateTool.js";
93
- import { ViewModeTool as So } from "./components/layout/toolbar/ViewModeTool.js";
94
- import { ScrollModeTool as Io } from "./components/layout/toolbar/ScrollModeTool.js";
95
- import { FileDownloadDefaultIcon as xo } from "./components/icons/FileDownloadDefaultIcon.js";
96
- import { PrintDefaultTool as Ro } from "./components/icons/PrintDefaultIcon.js";
97
- import { FullScreenTool as fn } from "./components/layout/toolbar/FullScreenTool.js";
98
- import { GoToDownIcon as mn } from "./components/icons/GoToDownIcon.js";
99
- import { SelectionModeTool as Lo } from "./components/layout/toolbar/SelectionModeTool.js";
100
- import { ZoomTool as Eo } from "./components/layout/toolbar/ZoomTool.js";
101
- import { SearchIcon as gn } from "./components/icons/SearchIcon.js";
102
- import { ClearIcon as No } from "./components/icons/ClearIcon.js";
103
- import { InfoIcon as Wt } from "./components/icons/InfoIcon.js";
104
- const vn = () => {
105
- const { viewMode: t } = Me(), { scrollMode: e } = Ee(), { virtualScrollRef: n, virtualScrollableElementRef: o, pageScrollElementRef: r } = Je(), { setFocusedPage: i } = pe(), c = k(), { columnCount: l } = sn(), { widths: d, heights: f } = Ue(), m = k(e), P = k(t), u = k(l), { targetScrollPage: T } = cn();
106
- z(() => {
107
- n != null && n.scrollToItem && (c.current = n);
108
- }, [n]), z(() => {
109
- m.current = e, P.current = t;
110
- }, [e, t]);
111
- const C = E(
112
- (g, S) => {
113
- if (!r)
114
- return;
115
- const v = Math.ceil(g / 2) * 2 - 1;
116
- if (g === v + 1) {
117
- const p = {
118
- left: d[v],
119
- top: 0
120
- };
121
- return new Promise(
122
- (s) => at(r, p, s)
123
- );
124
- }
125
- const h = {
126
- left: 0,
127
- top: 0
128
- };
129
- return r == null ? void 0 : r.scrollTo({
130
- ...h,
131
- behavior: S
132
- });
133
- },
134
- [r, d, at]
135
- );
136
- return z(() => {
137
- m.current = e, P.current = t;
138
- }, [e, t]), z(() => {
139
- u.current = l;
140
- }, [l]), { scrollToPage: E(
141
- (g, S = "smooth") => {
142
- i(g);
143
- const v = g - 1;
144
- let h = v, p = 0;
145
- if (P.current === Re.DUAL_PAGE && m.current === ne.PAGE_SCROLLING) {
146
- C(g, S);
147
- return;
148
- }
149
- if (m.current === ne.PAGE_SCROLLING) {
150
- i(g);
151
- return;
152
- }
153
- if (!c.current || !o)
154
- return;
155
- const s = o;
156
- S === "smooth" && (T.current = g);
157
- const { columnsWidth: w, rowsHeight: _ } = Tt(
158
- { widths: d, heights: f },
159
- l
160
- );
161
- if (m.current === ne.HORIZONTAL_SCROLLING) {
162
- p = v;
163
- const I = ze(w, p), R = {
164
- left: Math.floor(I),
165
- top: 0
166
- };
167
- return s.scrollTo({
168
- ...R,
169
- behavior: S
170
- });
171
- }
172
- if (P.current === Re.DUAL_PAGE) {
173
- p = v % 2, h = Math.floor(v / 2);
174
- const R = ze(w, p), L = ze(_, h), N = {
175
- left: Math.floor(R),
176
- top: Math.floor(L)
177
- };
178
- return s.scrollTo({
179
- ...N,
180
- behavior: S
181
- });
182
- }
183
- const y = ze(_, h), x = {
184
- left: 0,
185
- top: Math.floor(y)
186
- };
187
- return s.scrollTo({
188
- ...x,
189
- behavior: S
190
- });
191
- },
192
- [
193
- o,
194
- l,
195
- C,
196
- i,
197
- at,
198
- f,
199
- d
200
- ]
201
- ) };
202
- }, Oo = (t = 1) => {
203
- const [e, n] = q(t), [o, r] = q(0), { scrollToPage: i } = vn(), c = k(1), { viewMode: l } = Me(), { scrollMode: d } = Ee(), { widths: f } = Ue(), { pagesRef: m } = be(), P = Ct(e, 100), u = E(
204
- (h) => {
205
- if (!/^[0-9]*$/g.test(h.toString()) || !h)
206
- return { success: !1, currentPage: c.current };
207
- const s = +h;
208
- return s < 0 || s > o ? { success: !1, currentPage: c.current } : (n(s), c.current = s, { success: !0, currentPage: +h });
209
- },
210
- [o]
211
- ), T = E(u, [u]), C = E(
212
- (h) => {
213
- const p = u(h);
214
- return p.success && i(p.currentPage), p;
215
- },
216
- [u, i]
217
- ), b = E((h) => {
218
- const p = h % 2 === 1;
219
- if (!m || p)
220
- return !1;
221
- const s = p ? f[h] : f[h - 1], w = p ? f[h + 1] : f[h];
222
- return l === Re.DUAL_PAGE && s + w < m.clientWidth;
223
- }, [l, f, m, o]), g = E(() => {
224
- let h = e - 1;
225
- b(h) && (h = e - 2), C(h);
226
- }, [C, e, l, d, b]), S = W(() => l === Re.DUAL_PAGE && d === ne.PAGE_SCROLLING ? e === o - 1 : e === o, [e, o, l, d]), v = E(() => {
227
- if (S)
228
- return;
229
- let h = e + 1;
230
- b(h) && (h = e + 2), C(h);
231
- }, [C, e, b, l, d, S]);
232
- return {
233
- focusedPage: P,
234
- totalPages: o,
235
- setFocusedPage: T,
236
- setTotalPages: r,
237
- nextPage: v,
238
- prevPage: g,
239
- goToPage: C
240
- };
241
- }, wn = qe({
242
- focusedPage: 0,
243
- setFocusedPage: (t) => {
244
- },
245
- goToPage: (t) => ({ success: !!t, currentPage: +t }),
246
- totalPages: 0,
247
- setTotalPages: (t) => {
248
- },
249
- prevPage: () => {
250
- },
251
- nextPage: () => {
252
- }
253
- }), pe = () => {
254
- const t = Ge(wn);
255
- return typeof (t == null ? void 0 : t.focusedPage) > "u" && co.error("Please use this hooks inside children component of RPProvider"), t;
256
- }, Ys = ({ children: t }) => {
257
- const { pdf: e } = re(), { setCurrentPage: n } = Pr(), { focusedPage: o, totalPages: r, setFocusedPage: i, setTotalPages: c, goToPage: l, nextPage: d, prevPage: f } = Oo();
258
- return z(() => {
259
- e != null && e.numPages && (c(e.numPages), i(1));
260
- }, [e, c, i]), z(() => {
261
- n(o);
262
- }, [o, n]), /* @__PURE__ */ a(
263
- wn.Provider,
264
- {
265
- value: {
266
- focusedPage: o,
267
- totalPages: r,
268
- setFocusedPage: i,
269
- setTotalPages: c,
270
- nextPage: d,
271
- prevPage: f,
272
- goToPage: l
273
- },
274
- children: t
275
- }
276
- );
277
- }, Do = () => {
278
- const { pdf: t, pages: e } = re(), [n, o] = q({
279
- loadedPages: 0,
280
- totalPages: 0,
281
- percentage: 0
282
- }), [r, i] = q(!1), [c, l] = q(!1), [d, f] = q(null), m = k(!1);
283
- z(() => {
284
- m.current;
285
- }, [m]);
286
- const P = E(() => {
287
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
288
- const h = document.querySelector(".rp-print-zone");
289
- h && h.remove();
290
- }, []), u = E(() => {
291
- m.current = !1, i(!1), l(!1), f(null), o({
292
- loadedPages: 0,
293
- totalPages: 0,
294
- percentage: 0
295
- });
296
- }, []), T = () => {
297
- m.current = !0;
298
- }, C = async ({
299
- scratchCanvas: h,
300
- pdfDocument: p,
301
- pageNumber: s,
302
- viewerPdfPage: w,
303
- printResolution: _,
304
- optionalContentConfigPromise: y,
305
- printAnnotationStoragePromise: x
306
- }) => {
307
- if (m.current) {
308
- u();
309
- return;
310
- }
311
- const I = _ / Hr.PDF;
312
- h.width = Math.floor(w.width * I), h.height = Math.floor(w.height * I);
313
- const R = h.getContext("2d");
314
- R.save(), R.fillStyle = "rgb(255, 255, 255)", R.fillRect(0, 0, h.width, h.height), R.restore();
315
- const [L, N] = await Promise.all([
316
- p.getPage(s),
317
- x
318
- ]);
319
- if (m.current) {
320
- u();
321
- return;
322
- }
323
- const F = {
324
- canvasContext: R,
325
- transform: [I, 0, 0, I, 0, 0],
326
- viewport: L.getViewport({ scale: 1, rotation: w.rotation }),
327
- intent: "print",
328
- annotationMode: $r.ENABLE_STORAGE,
329
- optionalContentConfigPromise: y,
330
- printAnnotationStorage: N
331
- };
332
- try {
333
- return L.render(F).promise;
334
- } catch (M) {
335
- throw M instanceof qr || console.error(M), M;
336
- }
337
- }, b = E(() => {
338
- const h = window.print;
339
- return new Promise((p) => {
340
- const s = (y) => {
341
- setTimeout(() => {
342
- h.call(window), setTimeout(() => y(), 20);
343
- }, 0);
344
- };
345
- if (document.querySelector(".rp-print-zone")) {
346
- s(p);
347
- return;
348
- }
349
- const _ = new MutationObserver(() => {
350
- document.querySelector(".rp-print-zone") && (s(p), _.disconnect());
351
- });
352
- _.observe(document.body, { childList: !0, subtree: !0 });
353
- });
354
- }, []), g = async (h) => {
355
- const p = document.createElement("img"), s = document.createElement("div");
356
- return s.classList.add("rp-print-page"), await new Promise((w, _) => {
357
- h.toBlob((y) => {
358
- y ? (p.src = URL.createObjectURL(y), p.onload = () => {
359
- URL.revokeObjectURL(p.src), w();
360
- }, p.onerror = _) : _(new Error("Failed to create blob"));
361
- });
362
- }).catch(() => {
363
- }), s.appendChild(p), s;
364
- }, S = (h, p) => {
365
- const s = document.createElement("div");
366
- s.classList.add("rp-print-zone");
367
- const w = document.createElement("style"), _ = p.get(1);
368
- if (_) {
369
- const { width: y, height: x } = _ == null ? void 0 : _.page.getViewport({ scale: 1 });
370
- w.innerHTML = `@page { size: ${y}px ${x}px }`;
371
- }
372
- return s.appendChild(w), s.append(...h), s;
373
- }, v = E(async () => {
374
- if (!t)
375
- return;
376
- u();
377
- const h = document.createElement("canvas"), p = [];
378
- try {
379
- t.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
380
- const w = t.getOptionalContentConfig({ intent: "print" }), _ = Promise.resolve(
381
- t.annotationStorage.print ?? void 0
382
- ), y = e.size;
383
- for (const [I, R] of e) {
384
- if (m.current) {
385
- u();
386
- return;
387
- }
388
- const L = R.page.getViewport({ scale: 1 });
389
- if (await C({
390
- scratchCanvas: h,
391
- pdfDocument: t,
392
- pageNumber: I,
393
- viewerPdfPage: L,
394
- printResolution: 150,
395
- optionalContentConfigPromise: w,
396
- printAnnotationStoragePromise: _
397
- }), m.current) {
398
- u();
399
- return;
400
- }
401
- const N = await g(h);
402
- p.push(N);
403
- const F = parseFloat((p.length / y * 100).toFixed(2));
404
- o({
405
- loadedPages: I,
406
- totalPages: y,
407
- percentage: F
408
- });
409
- }
410
- if (m.current) {
411
- u();
412
- return;
413
- }
414
- const x = S(p, e);
415
- document.body.appendChild(x), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), i(!0), await b();
416
- } catch (s) {
417
- l(!0), s instanceof Error && f(s);
418
- } finally {
419
- h.height = 0, h.width = 0;
420
- }
421
- }, [t, e, m]);
422
- return z(() => {
423
- const h = () => {
424
- u(), P();
425
- };
426
- return window.addEventListener("afterprint", h, !0), () => {
427
- window.removeEventListener("afterprint", h, !0);
428
- };
429
- }, [P, u]), {
430
- print: v,
431
- cancel: T,
432
- progress: n,
433
- isComplete: r,
434
- isError: c,
435
- error: d
436
- };
437
- }, _n = qe({
438
- print: () => {
439
- },
440
- cancel: () => {
441
- },
442
- setOnProgress: (t) => {
443
- },
444
- progress: {},
445
- setOnComplete: (t) => t(),
446
- setOnError: (t) => {
447
- try {
448
- const e = new Error("Print error occurred");
449
- t(e);
450
- } catch (e) {
451
- console.error("Error in setOnError callback:", e);
452
- }
453
- }
454
- }), Js = ({ children: t }) => {
455
- const [e, n] = q(null), [o, r] = q(null), { print: i, cancel: c, progress: l, isComplete: d, isError: f, error: m } = Do(), P = E((g) => {
456
- g && typeof g == "function" && r(() => g);
457
- }, []), u = (g) => {
458
- m && g(m);
459
- }, T = E(
460
- (g) => {
461
- n(() => g);
462
- },
463
- [l, e]
464
- );
465
- z(() => {
466
- d && o && C();
467
- }, [d, o]), z(() => {
468
- f && u((g) => {
469
- console.error(g);
470
- });
471
- }, [f]), z(() => {
472
- l && e && e(l);
473
- }, [l, e]);
474
- const C = () => {
475
- o && (o(), r(null));
476
- }, b = {
477
- print: i,
478
- cancel: c,
479
- setOnProgress: T,
480
- setOnComplete: P,
481
- setOnError: u,
482
- progress: l
483
- };
484
- return /* @__PURE__ */ a(_n.Provider, { value: b, children: t });
485
- }, nt = () => {
486
- const t = Ge(_n);
487
- if (!t)
488
- throw new Error("usePrintContext must be used within a PrintProvider");
489
- return t;
490
- }, Ao = () => {
491
- const [t, e] = q({}), { pages: n } = re(), o = W(() => Object.keys(t).length, [t]), r = E(
492
- (c) => {
493
- if (!n.size)
494
- return;
495
- const l = c > n.size ? n.size : c, f = Array.from(n.values()).slice(0, l).map((m) => {
496
- const { thumbnailViewport: P, scale: u } = so(m.page, m.defaultRotation);
497
- return {
498
- scale: u,
499
- page: m.page,
500
- loading: !0,
501
- viewport: P,
502
- defaultRotation: m.defaultRotation
503
- };
504
- }).reduce((m, P) => (m[P.page.pageNumber] = P, m), {});
505
- e(f);
506
- },
507
- [n]
508
- );
509
- z(() => {
510
- r(10);
511
- }, [r]);
512
- const i = E(
513
- (c) => {
514
- if (!n)
515
- return;
516
- const l = n.get(c);
517
- l && e((d) => ({
518
- ...d,
519
- [c]: {
520
- loading: !0,
521
- page: l.page,
522
- viewport: l.thumbnailViewport,
523
- scale: l.thumbnailScale,
524
- defaultRotation: l.defaultRotation
525
- }
526
- }));
527
- },
528
- [n]
529
- );
530
- return { thumbnailPages: t, addPage: i, addToPage: r, thumbnailLength: o };
531
- }, bn = qe({
532
- thumbnailPages: {},
533
- addPage: (t) => {
534
- },
535
- addToPage: (t) => {
536
- },
537
- thumbnailLength: 0,
538
- setActive: (t) => {
539
- },
540
- active: !1
541
- }), Tn = () => Ge(bn), ec = ({
542
- children: t,
543
- initialThumbnailsVisible: e
544
- }) => {
545
- const { thumbnailPages: n, addPage: o, addToPage: r, thumbnailLength: i } = Ao(), [c, l] = q(e);
546
- return /* @__PURE__ */ a(
547
- bn.Provider,
548
- {
549
- value: { thumbnailPages: n, addPage: o, addToPage: r, thumbnailLength: i, active: c, setActive: l },
550
- children: t
551
- }
552
- );
553
- }, zo = (t = {}, e = "") => {
554
- const [n, o] = q(e), [r, i] = q(!1), { pdf: c, pages: l } = re(), { widths: d, heights: f } = Ue(), m = k(!n), { currentZoom: P } = _t(), [u, T] = q([]), { setFocusedPage: C } = pe(), { columnCount: b } = Me(), { pageRotate: g } = et(), [S, v] = q(0), { pageScrollElementRef: h, virtualScrollableElementRef: p } = Je(), { scrollMode: s } = Ee(), { pagesRef: w } = be(), [_, y] = q(null), x = k({}), I = k(0), R = W(() => S === 0 ? null : u[S - 1], [S, u]), L = W(() => u.length, [u]), N = E(
555
- (O) => {
556
- if (O === 0)
557
- return;
558
- const A = u[O - 1];
559
- if (!A || !l)
560
- return;
561
- const H = p || h;
562
- if (!H || !w)
563
- return;
564
- const U = l.get(A.page);
565
- if (s === ne.PAGE_SCROLLING && C(A.page), !U)
566
- return;
567
- let B = 0, V = 0;
568
- if (s === ne.VERTICAL_SCROLLING) {
569
- const se = A.page - 1, ce = b, ae = se % ce, Fe = Math.floor(se / ce);
570
- B = ze(f, Fe), V = ze(d, ae);
571
- }
572
- s === ne.HORIZONTAL_SCROLLING && (V = d.slice(0, A.page - 1).reduce((se, ce) => se + ce, 0));
573
- const J = {
574
- height: f[A.page - 1],
575
- width: d[A.page - 1]
576
- }, G = g[A.page], { leftInPage: K, topInPage: Y } = ao(
577
- J,
578
- w,
579
- A.rect,
580
- P,
581
- G
582
- ), ee = V + K, oe = B + Y, ie = {
583
- left: Math.max(ee, 0),
584
- top: Math.max(oe, 0)
585
- };
586
- H.scrollTo({
587
- ...ie,
588
- behavior: "smooth"
589
- });
590
- },
591
- [
592
- l,
593
- C,
594
- d,
595
- f,
596
- s,
597
- p,
598
- h,
599
- w,
600
- u
601
- ]
602
- );
603
- z(() => {
604
- S && N(S);
605
- }, [S]);
606
- const F = E(() => {
607
- v((O) => {
608
- let A;
609
- return L ? O + 1 > L ? A = 1 : A = O + 1 : A = 0, I.current = A, A;
610
- }), I.current === 1 && N(I.current);
611
- }, [L, N]), M = E(() => {
612
- v((O) => {
613
- let A;
614
- return L ? O - 1 <= 0 ? A = L : A = O - 1 : A = 0, I.current = A, A;
615
- }), I.current === 1 && N(I.current);
616
- }, [L, N]), D = E(async (O) => {
617
- if (!O)
618
- return {};
619
- const A = O.numPages, H = {};
620
- for (let U = 1; U <= A; U++) {
621
- if (m.current)
622
- throw "close pop over";
623
- const B = await O.getPage(U);
624
- H[U.toString()] = await B.getTextContent();
625
- }
626
- return H;
627
- }, []);
628
- return z(() => {
629
- if (!n) {
630
- m.current = !0, T([]), v(0);
631
- return;
632
- }
633
- m.current = !1, i(!0), T([]), v(0), D(c).then((O) => {
634
- x.current = O;
635
- const H = Object.keys(O).reduce((U, B) => {
636
- const V = mr(
637
- [n],
638
- O[B],
639
- Number(B) - 1,
640
- t
641
- ).map((J, G) => ({ ...J, page: Number(B), pageMatchIdx: G }));
642
- return [...U, ...V];
643
- }, []);
644
- T(H), v(H.length ? 1 : 0);
645
- }).catch(() => {
646
- T([]), v(0);
647
- }).finally(() => i(!1));
648
- }, [n, D, c, t]), {
649
- search: n,
650
- setSearch: o,
651
- loading: r,
652
- matches: u,
653
- totalMatches: L,
654
- currentMatchPosition: S,
655
- currentMatch: R,
656
- nextMatch: F,
657
- prevMatch: M,
658
- currentMatchElement: _,
659
- setCurrentMatchElement: y
660
- };
661
- }, Cn = qe({
662
- search: "",
663
- setSearch: (t) => {
664
- },
665
- loading: !1,
666
- matches: [],
667
- totalMatches: 0,
668
- currentMatchPosition: 0,
669
- currentMatch: null,
670
- nextMatch: () => {
671
- },
672
- prevMatch: () => {
673
- },
674
- searchOptions: {},
675
- setSearchOptions: (t) => t,
676
- currentMatchElement: null,
677
- setCurrentMatchElement: (t) => {
678
- }
679
- }), tc = ({
680
- children: t,
681
- initialSearch: e
682
- }) => {
683
- const [n, o] = q({}), {
684
- loading: r,
685
- setSearch: i,
686
- totalMatches: c,
687
- currentMatchPosition: l,
688
- currentMatch: d,
689
- search: f,
690
- matches: m,
691
- nextMatch: P,
692
- prevMatch: u,
693
- currentMatchElement: T,
694
- setCurrentMatchElement: C
695
- } = zo(n, e);
696
- return /* @__PURE__ */ a(
697
- Cn.Provider,
698
- {
699
- value: {
700
- searchOptions: n,
701
- setSearchOptions: o,
702
- loading: r,
703
- setSearch: i,
704
- totalMatches: c,
705
- currentMatchPosition: l,
706
- currentMatch: d,
707
- nextMatch: P,
708
- prevMatch: u,
709
- search: f,
710
- matches: m,
711
- currentMatchElement: T,
712
- setCurrentMatchElement: C
713
- },
714
- children: t
715
- }
716
- );
717
- }, St = () => Ge(Cn), Pn = qe(null), nc = ({ children: t }) => {
718
- const e = k(!1), [n, o] = q([]), r = E((d) => {
719
- o((f) => [...f, { id: d.page.pageNumber.toString(), data: d, priority: 0 }]);
720
- }, []), i = W(() => new Tr(r), [r]), { focusedPage: c } = pe(), l = E((d) => (e.current = !0, Cr(
721
- d.data.page,
722
- d.data.canvasElem,
723
- d.data.options
724
- ).promise.then(() => {
725
- d.data.canvasElem.hidden = !1;
726
- }).finally(() => {
727
- d.data.onLoaded && d.data.onLoaded();
728
- })), []);
729
- return z(() => {
730
- c && (i.changePagePriority(`^page-${c}`, 0), i.changePagePriority(`^thumbnail-${c}`, 1));
731
- }, [c]), z(() => {
732
- if (i.isEmpty() || e.current)
733
- return;
734
- const d = () => {
735
- const f = i.dequeue();
736
- f ? l(f).finally(() => {
737
- d();
738
- }) : (e.current = !1, o(i.peekAll()));
739
- };
740
- d();
741
- }, [i, l, n]), /* @__PURE__ */ a(Pn.Provider, { value: i, children: t });
742
- }, yn = () => {
743
- const t = Ge(Pn);
744
- if (!t)
745
- throw new Error("RenderQueue not found");
746
- return t;
747
- }, le = {
748
- "rp-pages": "_rp-pages_u7m2r_1",
749
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_u7m2r_6",
750
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_u7m2r_11",
751
- "rp-pages-container": "_rp-pages-container_u7m2r_15",
752
- "rp-viewer": "_rp-viewer_u7m2r_57",
753
- "rp-cursor-grab": "_rp-cursor-grab_u7m2r_62",
754
- "rp-cursor-grabbing": "_rp-cursor-grabbing_u7m2r_70",
755
- "rp-loader": "_rp-loader_u7m2r_78",
756
- "rp-not-supported": "_rp-not-supported_u7m2r_86",
757
- "rp-not-supported-content": "_rp-not-supported-content_u7m2r_102"
758
- }, ct = {
759
- "rp-page-wrapper": "_rp-page-wrapper_ii91u_1",
760
- "rp-page": "_rp-page_ii91u_1",
761
- "rp-loader-wrapper": "_rp-loader-wrapper_ii91u_15"
762
- }, Mo = (t) => {
763
- const { pageNumber: e, onLoaded: n, onLoading: o } = t, r = k(null), { pages: i } = re(), { pageRotate: c } = et(), l = k(), { currentZoom: d } = _t(), f = yn(), m = k(`page-${e}`);
764
- return z(() => {
765
- if (!i || d === 0)
766
- return;
767
- const P = i.get(e);
768
- if (r.current && P) {
769
- const u = r.current;
770
- u.hidden = !0;
771
- const T = l.current;
772
- T && T.cancel(), o && o(), f.enqueue(
773
- m.current,
774
- {
775
- page: P.page,
776
- canvasElem: u,
777
- options: {
778
- scale: d,
779
- rotate: c[e],
780
- renderForms: !0
781
- },
782
- onLoaded: n
783
- },
784
- 3
785
- );
786
- }
787
- return () => {
788
- f.removeQueue(m.current);
789
- };
790
- }, [i, e, c, d, o, n, f]), /* @__PURE__ */ a("canvas", { "data-rp": `page-${e}-canvas`, ref: r });
791
- }, Fo = "_selecting_ppr5g_10", ko = "_markedContent_ppr5g_33", ge = {
792
- "rp-text-layer": "_rp-text-layer_ppr5g_1",
793
- selecting: Fo,
794
- markedContent: ko,
795
- "rp-text-layer-text": "_rp-text-layer-text_ppr5g_52"
796
- }, Wo = (t) => {
797
- const { pageNumber: e } = t, { pages: n } = re(), o = k(null), { matches: r, currentMatch: i, setCurrentMatchElement: c } = St(), [l, d] = q(
798
- []
799
- ), f = k(), m = k(), P = k([]), u = W(() => r.filter((h) => h.pageIndex === e - 1), [r, e]), T = E(
800
- (h, p, s = !1) => {
801
- if (s && gr(h, p), !u.length) {
802
- P.current = [], d([]);
803
- return;
804
- }
805
- const w = vr(u, h, p);
806
- d(w);
807
- },
808
- [u]
809
- ), C = k(), b = k(!1), g = E(() => Array.from(document.querySelectorAll('[data-rp$="-textLayer"]')), []);
810
- z(() => ((() => {
811
- if (C.current)
812
- return;
813
- C.current = new AbortController();
814
- const { signal: p } = C.current, s = () => {
815
- g().forEach((_) => {
816
- const y = _.querySelector(".endOfContent");
817
- y && (_.appendChild(y), y.style.width = "", y.style.height = "", _.classList.remove(ge.selecting));
818
- });
819
- };
820
- document.addEventListener(
821
- "pointerdown",
822
- () => {
823
- b.current = !0;
824
- },
825
- { signal: p }
826
- ), document.addEventListener(
827
- "pointerup",
828
- () => {
829
- b.current = !1, s();
830
- },
831
- { signal: p }
832
- ), window.addEventListener(
833
- "blur",
834
- () => {
835
- b.current = !1, s();
836
- },
837
- { signal: p }
838
- ), document.addEventListener(
839
- "keyup",
840
- () => {
841
- b.current || s();
842
- },
843
- { signal: p }
844
- );
845
- let w = null;
846
- document.addEventListener(
847
- "selectionchange",
848
- () => {
849
- var F, M;
850
- const _ = document.getSelection();
851
- if (!_)
852
- return;
853
- if (_.rangeCount === 0) {
854
- s();
855
- return;
856
- }
857
- const y = /* @__PURE__ */ new Set();
858
- for (let D = 0; D < _.rangeCount; D++) {
859
- const O = _.getRangeAt(D);
860
- g().forEach((A) => {
861
- O.intersectsNode(A) && !y.has(A) && y.add(A);
862
- });
863
- }
864
- g().forEach((D) => {
865
- if (y.has(D))
866
- D.classList.add(ge.selecting);
867
- else {
868
- const O = D.querySelector(".endOfContent");
869
- O && (D.appendChild(O), O.style.width = "", O.style.height = "", D.classList.remove(ge.selecting));
870
- }
871
- });
872
- const x = _.getRangeAt(0);
873
- let R = w && (x.compareBoundaryPoints(Range.END_TO_END, w) === 0 || x.compareBoundaryPoints(Range.START_TO_END, w) === 0) ? x.startContainer : x.endContainer;
874
- R.nodeType === Node.TEXT_NODE && (R = R.parentNode);
875
- const L = (F = R.parentElement) == null ? void 0 : F.closest(
876
- ge["rp-text-layer"]
877
- ), N = L == null ? void 0 : L.querySelector(".endOfContent");
878
- N && L && (N.style.width = L.style.width, N.style.height = L.style.height, (M = R.parentElement) == null || M.insertBefore(N, R.nextSibling)), w = x.cloneRange();
879
- },
880
- { signal: p }
881
- );
882
- })(), () => {
883
- var p;
884
- (p = C.current) == null || p.abort(), C.current = void 0;
885
- }), [g]);
886
- const S = E(() => {
887
- o.current && o.current.classList.add(ge.selecting);
888
- }, []), v = E(() => {
889
- o.current && o.current.classList.remove(ge.selecting);
890
- }, []);
891
- return z(() => {
892
- if (P.current.forEach((s) => {
893
- s.classList.remove("selected");
894
- }), !l.length || !i || i.pageIndex !== e - 1)
895
- return;
896
- const h = u.findIndex(
897
- (s) => JSON.stringify(s) === JSON.stringify(i)
898
- );
899
- if (h === -1)
900
- return;
901
- const p = l.filter((s) => s.index === h);
902
- p.length && (P.current = p.map((s) => s.element), c(p[0].element), p.forEach((s) => {
903
- s.element.classList.add("selected");
904
- }));
905
- }, [i, l, u]), z(() => {
906
- const h = n.get(e);
907
- if (!h || !o.current)
908
- return;
909
- const p = o.current;
910
- return f.current && f.current.cancel(), h.page.getTextContent().then((s) => {
911
- const w = h.page.getViewport({ scale: 1 });
912
- return f.current = new Wr.TextLayer({
913
- viewport: w,
914
- textContentSource: s,
915
- container: p
916
- }), m.current = s, p && (p.innerText = ""), f.current.render();
917
- }).then(() => {
918
- var y, x;
919
- [].slice.call(p.children).forEach((I) => {
920
- I.classList.add(ge["rp-text-layer-text"]), I.setAttribute("data-rp", "rp-text-layer-text");
921
- });
922
- const w = (y = f.current) == null ? void 0 : y.textDivs;
923
- w && m.current && T(m.current, w);
924
- const _ = document.createElement("div");
925
- _.className = "endOfContent", (x = o.current) == null || x.appendChild(_);
926
- }).catch(() => {
927
- }), () => {
928
- var s;
929
- (s = f.current) == null || s.cancel();
930
- };
931
- }, [n, e]), z(() => {
932
- var s;
933
- [].slice.call(o.current.children).forEach((w) => {
934
- w.classList.add(ge["rp-text-layer-text"]);
935
- });
936
- const p = (s = f.current) == null ? void 0 : s.textDivs;
937
- p && m.current && T(m.current, p, !0);
938
- }, [T]), /* @__PURE__ */ a(
939
- "div",
940
- {
941
- "data-rp-text-layer": !0,
942
- "data-rp": `page-${e}-textLayer`,
943
- className: ge["rp-text-layer"],
944
- ref: o,
945
- onMouseDown: S,
946
- onMouseUp: v
947
- }
948
- );
949
- }, Ho = {
950
- "rp-annotation-layer": "_rp-annotation-layer_1udza_1"
951
- };
952
- let $o = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
953
- const qo = (t) => {
954
- const { pageNumber: e } = t, n = k(null), { pages: o, pdf: r } = re(), i = k(), [c, l] = q(), { setFocusedPage: d, goToPage: f } = pe(), { scrollMode: m } = Ee(), { print: P } = nt(), { download: u } = Gn(), T = W(() => o.get(e), [o, e]), C = W(() => T == null ? void 0 : T.page.getViewport(), [T]);
955
- z(() => {
956
- i.current && (i.current.div.replaceChildren(), i.current = void 0);
957
- }, [r]), z(() => {
958
- T && T.page.getAnnotations().then((g) => {
959
- i.current = void 0, l(g), n.current && (n.current.innerText = "");
960
- });
961
- }, [T]);
962
- const b = E(
963
- (g) => {
964
- !c || !r || (Vr(g), Br(g, r, c).then((S) => {
965
- var v, h;
966
- ((v = S == null ? void 0 : S.data) == null ? void 0 : v.action) === "Print" ? P() : ((h = S == null ? void 0 : S.data) == null ? void 0 : h.action) === "SaveAs" && u();
967
- }), m === ne.PAGE_SCROLLING ? Ft(g, c, r, (S) => d(S.pageIndex + 1)) : Ft(g, c, r, (S) => f(S.pageIndex + 1)));
968
- },
969
- [r, c, f, d, m, P, u]
970
- );
971
- return z(() => {
972
- if (!T || !c)
973
- return;
974
- const g = T.page.getViewport();
975
- if (i.current) {
976
- i.current.update({
977
- viewport: g.clone({ dontFlip: !0 })
978
- });
979
- return;
980
- }
981
- const S = /* @__PURE__ */ new Map([]);
982
- for (const p of c) {
983
- const { annotationType: s } = p;
984
- switch (s) {
985
- case Dt.Link:
986
- Kr(p);
987
- break;
988
- case Dt.Widget:
989
- jr(p, g, S);
990
- break;
991
- }
992
- }
993
- const v = new AbortController();
994
- return (async () => {
995
- var w;
996
- i.current && (i.current.div.replaceChildren(), i.current = void 0), n.current && (n.current.innerText = ""), i.current = new Gr({
997
- div: n.current,
998
- accessibilityManager: void 0,
999
- annotationCanvasMap: void 0,
1000
- annotationEditorUIManager: void 0,
1001
- structTreeLayer: null,
1002
- page: T.page,
1003
- viewport: g.clone({ dontFlip: !0 })
1004
- }), n.current && kt(n.current, b);
1005
- const p = await (r == null ? void 0 : r.hasJSActions()), s = await (r == null ? void 0 : r.getFieldObjects());
1006
- if (v.signal.aborted)
1007
- throw "abort";
1008
- return (w = i.current) == null ? void 0 : w.render({
1009
- annotations: c,
1010
- annotationStorage: r == null ? void 0 : r.annotationStorage,
1011
- hasJSActions: p,
1012
- fieldObjects: s,
1013
- div: n.current,
1014
- viewport: g.clone({ dontFlip: !0 }),
1015
- page: T.page,
1016
- imageResourcesPath: $o,
1017
- renderForms: !0,
1018
- linkService: new Ur(),
1019
- downloadManager: null,
1020
- enableScripting: !1
1021
- });
1022
- })().then(() => {
1023
- n.current && Zr(n.current, b);
1024
- }).catch((p) => {
1025
- if (p !== "abort")
1026
- throw p;
1027
- }), () => {
1028
- v.abort("clear"), n.current && kt(n.current, b);
1029
- };
1030
- }, [r, c, b]), /* @__PURE__ */ a(
1031
- "div",
1032
- {
1033
- "data-rp": `page-${e}-annotationLayer`,
1034
- style: { width: `${C == null ? void 0 : C.width}px`, height: `${C == null ? void 0 : C.height}px` },
1035
- className: Ho["rp-annotation-layer"],
1036
- ref: n
1037
- }
1038
- );
1039
- }, Go = {
1040
- "rp-text-highlight": "_rp-text-highlight_jdkf8_1"
1041
- }, Uo = ({ pageNumber: t, viewport: e }) => {
1042
- const [n, o] = q(), { pages: r } = re(), { highlightKeywords: i } = _r(), c = !0, l = k(null), [d, f] = q(null), [m, P] = q([]);
1043
- z(() => {
1044
- l.current && f(l.current.parentElement);
1045
- }, [l]), z(() => {
1046
- (async () => {
1047
- const h = r.get(t);
1048
- if (!h || !l.current)
1049
- return;
1050
- const p = await h.page.getTextContent();
1051
- o(p);
1052
- })();
1053
- }, [r, t]);
1054
- const u = W(() => i ? i.map((v) => {
1055
- var h, p;
1056
- return {
1057
- ...Xr(v.keyword, (h = v.options) == null ? void 0 : h.matchCase, (p = v.options) == null ? void 0 : p.wholeWords),
1058
- color: v.highlightColor
1059
- };
1060
- }) : [], [i]);
1061
- function T(v, h) {
1062
- if (!v)
1063
- return;
1064
- const p = `[data-rp="page-${h}-textLayer"]`;
1065
- return new Promise((s) => {
1066
- const w = v.querySelector(p);
1067
- if (w) {
1068
- s(w);
1069
- return;
1070
- }
1071
- new MutationObserver((y, x) => {
1072
- const I = v.querySelector(p);
1073
- I && (s(I), x.disconnect());
1074
- }).observe(v, { childList: !0, subtree: !0 });
1075
- });
1076
- }
1077
- function C(v) {
1078
- return new Promise((h) => {
1079
- const p = v.querySelectorAll(
1080
- '[data-rp="rp-text-layer-text"]'
1081
- );
1082
- if (p.length) {
1083
- h(Array.from(p));
1084
- return;
1085
- }
1086
- new MutationObserver((w, _) => {
1087
- const y = v.querySelectorAll(
1088
- ".rp-text-layer-text"
1089
- );
1090
- y.length && (h(Array.from(y)), _.disconnect());
1091
- }).observe(v, { childList: !0, subtree: !0 });
1092
- });
1093
- }
1094
- const b = (v, h, p, s) => {
1095
- var U;
1096
- const w = document.createRange(), _ = p.firstChild;
1097
- if (!_ || _.nodeType !== Node.TEXT_NODE)
1098
- return null;
1099
- const y = ((U = _.textContent) == null ? void 0 : U.length) ?? 0, x = s[0].charIdxInSpan, I = s.length === 1 ? x : s[s.length - 1].charIdxInSpan;
1100
- if (x > y || I + 1 > y)
1101
- return null;
1102
- w.setStart(_, x), w.setEnd(_, I + 1);
1103
- const R = document.createElement("span");
1104
- R.style.width = "auto", w.surroundContents(R);
1105
- const L = R.getBoundingClientRect(), N = v.getBoundingClientRect(), F = N.height, M = N.width, D = 100 * (L.left - N.left) / M, O = 100 * (L.top - N.top) / F, A = 100 * L.height / F, H = 100 * L.width / M;
1106
- return Yr(R), {
1107
- keywordStr: h,
1108
- left: D,
1109
- top: O,
1110
- height: A,
1111
- width: H,
1112
- pageHeight: F,
1113
- pageWidth: M
1114
- };
1115
- };
1116
- async function g(v, h) {
1117
- const p = await T(d, v);
1118
- if (!p)
1119
- return;
1120
- const s = await C(p);
1121
- if (s.length) {
1122
- const w = s.map((y) => y.tagName === "BR" ? " " : y.textContent).reduce(
1123
- (y, x, I) => y.concat(
1124
- x.split("").map((R, L) => ({
1125
- char: R,
1126
- charIdxInSpan: L,
1127
- spanIdx: I
1128
- }))
1129
- ),
1130
- [
1131
- {
1132
- char: "",
1133
- charIdxInSpan: 0,
1134
- spanIdx: 0
1135
- }
1136
- ]
1137
- ).slice(1), _ = S(p, h, s, w);
1138
- P(_);
1139
- }
1140
- }
1141
- const S = (v, h, p, s) => {
1142
- const w = h.length;
1143
- if (!s.length || !w)
1144
- return [];
1145
- const _ = [], y = s.map((x) => x.char).join("");
1146
- return u.forEach((x) => {
1147
- const { keyword: I, regExp: R, wholeWords: L, color: N } = x, F = I;
1148
- if (!F.trim())
1149
- return;
1150
- const M = R.flags.indexOf("g") === -1 ? new RegExp(R, `${R.flags}g`) : R;
1151
- let D;
1152
- const O = [];
1153
- for (; (D = M.exec(y)) !== null; )
1154
- L && !wr(y, D.index, D[0].length) || O.push({
1155
- keyword: M,
1156
- startIndex: D.index,
1157
- endIndex: M.lastIndex
1158
- });
1159
- const A = O.map((H) => ({
1160
- keyword: H.keyword,
1161
- indexes: s.slice(H.startIndex, H.endIndex),
1162
- color: N
1163
- }));
1164
- for (const H of A) {
1165
- const U = H.indexes.reduce(
1166
- (B, V) => (B[V.spanIdx] = (B[V.spanIdx] || []).concat([V]), B),
1167
- {}
1168
- );
1169
- for (const B of Object.values(U))
1170
- if (B.length !== 1 || B[0].char.trim() !== "") {
1171
- const V = B, J = p[V[0].spanIdx], G = b(
1172
- v,
1173
- F,
1174
- J,
1175
- V
1176
- );
1177
- if (G) {
1178
- const { left: K, top: Y } = G;
1179
- if (_.find((oe) => oe.left === K && oe.top === Y))
1180
- continue;
1181
- _.push({ ...G, highlightColor: H.color });
1182
- }
1183
- }
1184
- }
1185
- }), _.sort(Qr), _;
1186
- };
1187
- return z(() => {
1188
- (async () => {
1189
- if (!i || i.length === 0) {
1190
- P([]);
1191
- return;
1192
- }
1193
- try {
1194
- await g(t, i);
1195
- } catch (h) {
1196
- console.error(h);
1197
- }
1198
- })();
1199
- }, [c, i, t, n, e]), /* @__PURE__ */ a(fe, { children: /* @__PURE__ */ a("div", { ref: l, "data-rp": `page-${t}-textHighlightLayer`, children: m.map((v, h) => /* @__PURE__ */ a(
1200
- "div",
1201
- {
1202
- className: Go["rp-text-highlight"],
1203
- style: {
1204
- top: `${v.top}%`,
1205
- left: `${v.left}%`,
1206
- width: `${v.width}%`,
1207
- height: `${v.height}%`,
1208
- backgroundColor: v.highlightColor
1209
- }
1210
- },
1211
- h
1212
- )) }) });
1213
- }, It = tt((t, e) => {
1214
- const { pageNumber: n, style: o, ...r } = t, { pages: i } = re(), { pageRotate: c } = et(), { textLayer: l } = ur(), { currentZoom: d } = _t(), { LoaderImageComponent: f } = bt(), m = k(i.get(n)), [P, u] = q(!1), T = k(null), [C, b] = q({
1215
- width: 0,
1216
- height: 0
1217
- });
1218
- rn(e, () => T.current);
1219
- const g = W(() => m.current ? c[n] : 0, [n, c]);
1220
- z(() => {
1221
- if (i && (m.current = i.get(n), m.current)) {
1222
- const p = m.current.page.getViewport({
1223
- scale: d,
1224
- rotation: g
1225
- });
1226
- b(p);
1227
- }
1228
- }, [i, n, g, d]);
1229
- const S = W(() => {
1230
- switch (g) {
1231
- case 90:
1232
- return `${C.width / 2}px ${C.width / 2}px`;
1233
- case -90:
1234
- case 270:
1235
- return `${C.height / 2}px ${C.height / 2}px`;
1236
- default:
1237
- return "center";
1238
- }
1239
- }, [g, C]), v = E(() => {
1240
- u(!0);
1241
- }, []), h = E(() => {
1242
- u(!1);
1243
- }, []);
1244
- return /* @__PURE__ */ a(
1245
- "div",
1246
- {
1247
- ref: T,
1248
- id: `page-${n}`,
1249
- "data-rp": `page-${n}`,
1250
- ...r,
1251
- style: {
1252
- ...o,
1253
- "--rp-rotate": `${g}deg`,
1254
- "--rp-page-rotate-translate": `${S}`,
1255
- "--scale-factor": d
1256
- },
1257
- className: ct["rp-page-wrapper"],
1258
- children: /* @__PURE__ */ $(
1259
- "div",
1260
- {
1261
- style: {
1262
- width: `${C.width}px`,
1263
- height: `${C.height}px`
1264
- },
1265
- className: ct["rp-page"],
1266
- children: [
1267
- /* @__PURE__ */ a(Mo, { onLoading: v, onLoaded: h, pageNumber: n }),
1268
- P && f && /* @__PURE__ */ a("div", { className: ct["rp-loader-wrapper"], children: /* @__PURE__ */ a(f, {}) }),
1269
- /* @__PURE__ */ a(Jr, { pageNumber: n }),
1270
- l && /* @__PURE__ */ a(Wo, { pageNumber: n }),
1271
- /* @__PURE__ */ a(Uo, { pageNumber: n, viewport: C }),
1272
- /* @__PURE__ */ a(qo, { pageNumber: n })
1273
- ]
1274
- }
1275
- )
1276
- }
1277
- );
1278
- });
1279
- function mt() {
1280
- return mt = Object.assign ? Object.assign.bind() : function(t) {
1281
- for (var e = 1; e < arguments.length; e++) {
1282
- var n = arguments[e];
1283
- for (var o in n)
1284
- ({}).hasOwnProperty.call(n, o) && (t[o] = n[o]);
1285
- }
1286
- return t;
1287
- }, mt.apply(null, arguments);
1288
- }
1289
- function Ht(t) {
1290
- if (t === void 0)
1291
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1292
- return t;
1293
- }
1294
- function gt(t, e) {
1295
- return gt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, o) {
1296
- return n.__proto__ = o, n;
1297
- }, gt(t, e);
1298
- }
1299
- function Vo(t, e) {
1300
- t.prototype = Object.create(e.prototype), t.prototype.constructor = t, gt(t, e);
1301
- }
1302
- var $t = Number.isNaN || function(e) {
1303
- return typeof e == "number" && e !== e;
1304
- };
1305
- function Bo(t, e) {
1306
- return !!(t === e || $t(t) && $t(e));
1307
- }
1308
- function jo(t, e) {
1309
- if (t.length !== e.length)
1310
- return !1;
1311
- for (var n = 0; n < t.length; n++)
1312
- if (!Bo(t[n], e[n]))
1313
- return !1;
1314
- return !0;
1315
- }
1316
- function lt(t, e) {
1317
- e === void 0 && (e = jo);
1318
- var n, o = [], r, i = !1;
1319
- function c() {
1320
- for (var l = [], d = 0; d < arguments.length; d++)
1321
- l[d] = arguments[d];
1322
- return i && n === this && e(l, o) || (r = t.apply(this, l), i = !0, n = this, o = l), r;
1323
- }
1324
- return c;
1325
- }
1326
- function qt(t, e) {
1327
- if (t == null)
1328
- return {};
1329
- var n = {};
1330
- for (var o in t)
1331
- if ({}.hasOwnProperty.call(t, o)) {
1332
- if (e.indexOf(o) !== -1)
1333
- continue;
1334
- n[o] = t[o];
1335
- }
1336
- return n;
1337
- }
1338
- var Ko = typeof performance == "object" && typeof performance.now == "function", Gt = Ko ? function() {
1339
- return performance.now();
1340
- } : function() {
1341
- return Date.now();
1342
- };
1343
- function Ut(t) {
1344
- cancelAnimationFrame(t.id);
1345
- }
1346
- function Zo(t, e) {
1347
- var n = Gt();
1348
- function o() {
1349
- Gt() - n >= e ? t.call(null) : r.id = requestAnimationFrame(o);
1350
- }
1351
- var r = {
1352
- id: requestAnimationFrame(o)
1353
- };
1354
- return r;
1355
- }
1356
- var dt = -1;
1357
- function Xo(t) {
1358
- if (t === void 0 && (t = !1), dt === -1 || t) {
1359
- var e = document.createElement("div"), n = e.style;
1360
- n.width = "50px", n.height = "50px", n.overflow = "scroll", document.body.appendChild(e), dt = e.offsetWidth - e.clientWidth, document.body.removeChild(e);
1361
- }
1362
- return dt;
1363
- }
1364
- var De = null;
1365
- function Vt(t) {
1366
- if (t === void 0 && (t = !1), De === null || t) {
1367
- var e = document.createElement("div"), n = e.style;
1368
- n.width = "50px", n.height = "50px", n.overflow = "scroll", n.direction = "rtl";
1369
- var o = document.createElement("div"), r = o.style;
1370
- return r.width = "100px", r.height = "100px", e.appendChild(o), document.body.appendChild(e), e.scrollLeft > 0 ? De = "positive-descending" : (e.scrollLeft = 1, e.scrollLeft === 0 ? De = "negative" : De = "positive-ascending"), document.body.removeChild(e), De;
1371
- }
1372
- return De;
1373
- }
1374
- var Qo = 150, Yo = function(e) {
1375
- var n = e.columnIndex;
1376
- e.data;
1377
- var o = e.rowIndex;
1378
- return o + ":" + n;
1379
- }, je = null, Ke = null, Ze = null;
1380
- process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (je = /* @__PURE__ */ new WeakSet(), Ke = /* @__PURE__ */ new WeakSet(), Ze = /* @__PURE__ */ new WeakSet());
1381
- function Jo(t) {
1382
- var e, n = t.getColumnOffset, o = t.getColumnStartIndexForOffset, r = t.getColumnStopIndexForStartIndex, i = t.getColumnWidth, c = t.getEstimatedTotalHeight, l = t.getEstimatedTotalWidth, d = t.getOffsetForColumnAndAlignment, f = t.getOffsetForRowAndAlignment, m = t.getRowHeight, P = t.getRowOffset, u = t.getRowStartIndexForOffset, T = t.getRowStopIndexForStartIndex, C = t.initInstanceProps, b = t.shouldResetStyleCacheOnItemSizeChange, g = t.validateProps;
1383
- return e = /* @__PURE__ */ function(S) {
1384
- Vo(v, S);
1385
- function v(p) {
1386
- var s;
1387
- return s = S.call(this, p) || this, s._instanceProps = C(s.props, Ht(s)), s._resetIsScrollingTimeoutId = null, s._outerRef = void 0, s.state = {
1388
- instance: Ht(s),
1389
- isScrolling: !1,
1390
- horizontalScrollDirection: "forward",
1391
- scrollLeft: typeof s.props.initialScrollLeft == "number" ? s.props.initialScrollLeft : 0,
1392
- scrollTop: typeof s.props.initialScrollTop == "number" ? s.props.initialScrollTop : 0,
1393
- scrollUpdateWasRequested: !1,
1394
- verticalScrollDirection: "forward"
1395
- }, s._callOnItemsRendered = void 0, s._callOnItemsRendered = lt(function(w, _, y, x, I, R, L, N) {
1396
- return s.props.onItemsRendered({
1397
- overscanColumnStartIndex: w,
1398
- overscanColumnStopIndex: _,
1399
- overscanRowStartIndex: y,
1400
- overscanRowStopIndex: x,
1401
- visibleColumnStartIndex: I,
1402
- visibleColumnStopIndex: R,
1403
- visibleRowStartIndex: L,
1404
- visibleRowStopIndex: N
1405
- });
1406
- }), s._callOnScroll = void 0, s._callOnScroll = lt(function(w, _, y, x, I) {
1407
- return s.props.onScroll({
1408
- horizontalScrollDirection: y,
1409
- scrollLeft: w,
1410
- scrollTop: _,
1411
- verticalScrollDirection: x,
1412
- scrollUpdateWasRequested: I
1413
- });
1414
- }), s._getItemStyle = void 0, s._getItemStyle = function(w, _) {
1415
- var y = s.props, x = y.columnWidth, I = y.direction, R = y.rowHeight, L = s._getItemStyleCache(b && x, b && I, b && R), N = w + ":" + _, F;
1416
- if (L.hasOwnProperty(N))
1417
- F = L[N];
1418
- else {
1419
- var M = n(s.props, _, s._instanceProps), D = I === "rtl";
1420
- L[N] = F = {
1421
- position: "absolute",
1422
- left: D ? void 0 : M,
1423
- right: D ? M : void 0,
1424
- top: P(s.props, w, s._instanceProps),
1425
- height: m(s.props, w, s._instanceProps),
1426
- width: i(s.props, _, s._instanceProps)
1427
- };
1428
- }
1429
- return F;
1430
- }, s._getItemStyleCache = void 0, s._getItemStyleCache = lt(function(w, _, y) {
1431
- return {};
1432
- }), s._onScroll = function(w) {
1433
- var _ = w.currentTarget, y = _.clientHeight, x = _.clientWidth, I = _.scrollLeft, R = _.scrollTop, L = _.scrollHeight, N = _.scrollWidth;
1434
- s.setState(function(F) {
1435
- if (F.scrollLeft === I && F.scrollTop === R)
1436
- return null;
1437
- var M = s.props.direction, D = I;
1438
- if (M === "rtl")
1439
- switch (Vt()) {
1440
- case "negative":
1441
- D = -I;
1442
- break;
1443
- case "positive-descending":
1444
- D = N - x - I;
1445
- break;
1446
- }
1447
- D = Math.max(0, Math.min(D, N - x));
1448
- var O = Math.max(0, Math.min(R, L - y));
1449
- return {
1450
- isScrolling: !0,
1451
- horizontalScrollDirection: F.scrollLeft < I ? "forward" : "backward",
1452
- scrollLeft: D,
1453
- scrollTop: O,
1454
- verticalScrollDirection: F.scrollTop < R ? "forward" : "backward",
1455
- scrollUpdateWasRequested: !1
1456
- };
1457
- }, s._resetIsScrollingDebounced);
1458
- }, s._outerRefSetter = function(w) {
1459
- var _ = s.props.outerRef;
1460
- s._outerRef = w, typeof _ == "function" ? _(w) : _ != null && typeof _ == "object" && _.hasOwnProperty("current") && (_.current = w);
1461
- }, s._resetIsScrollingDebounced = function() {
1462
- s._resetIsScrollingTimeoutId !== null && Ut(s._resetIsScrollingTimeoutId), s._resetIsScrollingTimeoutId = Zo(s._resetIsScrolling, Qo);
1463
- }, s._resetIsScrolling = function() {
1464
- s._resetIsScrollingTimeoutId = null, s.setState({
1465
- isScrolling: !1
1466
- }, function() {
1467
- s._getItemStyleCache(-1);
1468
- });
1469
- }, s;
1470
- }
1471
- v.getDerivedStateFromProps = function(s, w) {
1472
- return ei(s, w), g(s), null;
1473
- };
1474
- var h = v.prototype;
1475
- return h.scrollTo = function(s) {
1476
- var w = s.scrollLeft, _ = s.scrollTop;
1477
- w !== void 0 && (w = Math.max(0, w)), _ !== void 0 && (_ = Math.max(0, _)), this.setState(function(y) {
1478
- return w === void 0 && (w = y.scrollLeft), _ === void 0 && (_ = y.scrollTop), y.scrollLeft === w && y.scrollTop === _ ? null : {
1479
- horizontalScrollDirection: y.scrollLeft < w ? "forward" : "backward",
1480
- scrollLeft: w,
1481
- scrollTop: _,
1482
- scrollUpdateWasRequested: !0,
1483
- verticalScrollDirection: y.scrollTop < _ ? "forward" : "backward"
1484
- };
1485
- }, this._resetIsScrollingDebounced);
1486
- }, h.scrollToItem = function(s) {
1487
- var w = s.align, _ = w === void 0 ? "auto" : w, y = s.columnIndex, x = s.rowIndex, I = this.props, R = I.columnCount, L = I.height, N = I.rowCount, F = I.width, M = this.state, D = M.scrollLeft, O = M.scrollTop, A = Xo();
1488
- y !== void 0 && (y = Math.max(0, Math.min(y, R - 1))), x !== void 0 && (x = Math.max(0, Math.min(x, N - 1)));
1489
- var H = c(this.props, this._instanceProps), U = l(this.props, this._instanceProps), B = U > F ? A : 0, V = H > L ? A : 0;
1490
- this.scrollTo({
1491
- scrollLeft: y !== void 0 ? d(this.props, y, _, D, this._instanceProps, V) : D,
1492
- scrollTop: x !== void 0 ? f(this.props, x, _, O, this._instanceProps, B) : O
1493
- });
1494
- }, h.componentDidMount = function() {
1495
- var s = this.props, w = s.initialScrollLeft, _ = s.initialScrollTop;
1496
- if (this._outerRef != null) {
1497
- var y = this._outerRef;
1498
- typeof w == "number" && (y.scrollLeft = w), typeof _ == "number" && (y.scrollTop = _);
1499
- }
1500
- this._callPropsCallbacks();
1501
- }, h.componentDidUpdate = function() {
1502
- var s = this.props.direction, w = this.state, _ = w.scrollLeft, y = w.scrollTop, x = w.scrollUpdateWasRequested;
1503
- if (x && this._outerRef != null) {
1504
- var I = this._outerRef;
1505
- if (s === "rtl")
1506
- switch (Vt()) {
1507
- case "negative":
1508
- I.scrollLeft = -_;
1509
- break;
1510
- case "positive-ascending":
1511
- I.scrollLeft = _;
1512
- break;
1513
- default:
1514
- var R = I.clientWidth, L = I.scrollWidth;
1515
- I.scrollLeft = L - R - _;
1516
- break;
1517
- }
1518
- else
1519
- I.scrollLeft = Math.max(0, _);
1520
- I.scrollTop = Math.max(0, y);
1521
- }
1522
- this._callPropsCallbacks();
1523
- }, h.componentWillUnmount = function() {
1524
- this._resetIsScrollingTimeoutId !== null && Ut(this._resetIsScrollingTimeoutId);
1525
- }, h.render = function() {
1526
- var s = this.props, w = s.children, _ = s.className, y = s.columnCount, x = s.direction, I = s.height, R = s.innerRef, L = s.innerElementType, N = s.innerTagName, F = s.itemData, M = s.itemKey, D = M === void 0 ? Yo : M, O = s.outerElementType, A = s.outerTagName, H = s.rowCount, U = s.style, B = s.useIsScrolling, V = s.width, J = this.state.isScrolling, G = this._getHorizontalRangeToRender(), K = G[0], Y = G[1], ee = this._getVerticalRangeToRender(), oe = ee[0], ie = ee[1], se = [];
1527
- if (y > 0 && H)
1528
- for (var ce = oe; ce <= ie; ce++)
1529
- for (var ae = K; ae <= Y; ae++)
1530
- se.push(Be(w, {
1531
- columnIndex: ae,
1532
- data: F,
1533
- isScrolling: B ? J : void 0,
1534
- key: D({
1535
- columnIndex: ae,
1536
- data: F,
1537
- rowIndex: ce
1538
- }),
1539
- rowIndex: ce,
1540
- style: this._getItemStyle(ce, ae)
1541
- }));
1542
- var Fe = c(this.props, this._instanceProps), ke = l(this.props, this._instanceProps);
1543
- return Be(O || A || "div", {
1544
- className: _,
1545
- onScroll: this._onScroll,
1546
- ref: this._outerRefSetter,
1547
- style: mt({
1548
- position: "relative",
1549
- height: I,
1550
- width: V,
1551
- overflow: "auto",
1552
- WebkitOverflowScrolling: "touch",
1553
- willChange: "transform",
1554
- direction: x
1555
- }, U)
1556
- }, Be(L || N || "div", {
1557
- children: se,
1558
- ref: R,
1559
- style: {
1560
- height: Fe,
1561
- pointerEvents: J ? "none" : void 0,
1562
- width: ke
1563
- }
1564
- }));
1565
- }, h._callPropsCallbacks = function() {
1566
- var s = this.props, w = s.columnCount, _ = s.onItemsRendered, y = s.onScroll, x = s.rowCount;
1567
- if (typeof _ == "function" && w > 0 && x > 0) {
1568
- var I = this._getHorizontalRangeToRender(), R = I[0], L = I[1], N = I[2], F = I[3], M = this._getVerticalRangeToRender(), D = M[0], O = M[1], A = M[2], H = M[3];
1569
- this._callOnItemsRendered(R, L, D, O, N, F, A, H);
1570
- }
1571
- if (typeof y == "function") {
1572
- var U = this.state, B = U.horizontalScrollDirection, V = U.scrollLeft, J = U.scrollTop, G = U.scrollUpdateWasRequested, K = U.verticalScrollDirection;
1573
- this._callOnScroll(V, J, B, K, G);
1574
- }
1575
- }, h._getHorizontalRangeToRender = function() {
1576
- var s = this.props, w = s.columnCount, _ = s.overscanColumnCount, y = s.overscanColumnsCount, x = s.overscanCount, I = s.rowCount, R = this.state, L = R.horizontalScrollDirection, N = R.isScrolling, F = R.scrollLeft, M = _ || y || x || 1;
1577
- if (w === 0 || I === 0)
1578
- return [0, 0, 0, 0];
1579
- var D = o(this.props, F, this._instanceProps), O = r(this.props, D, F, this._instanceProps), A = !N || L === "backward" ? Math.max(1, M) : 1, H = !N || L === "forward" ? Math.max(1, M) : 1;
1580
- return [Math.max(0, D - A), Math.max(0, Math.min(w - 1, O + H)), D, O];
1581
- }, h._getVerticalRangeToRender = function() {
1582
- var s = this.props, w = s.columnCount, _ = s.overscanCount, y = s.overscanRowCount, x = s.overscanRowsCount, I = s.rowCount, R = this.state, L = R.isScrolling, N = R.verticalScrollDirection, F = R.scrollTop, M = y || x || _ || 1;
1583
- if (w === 0 || I === 0)
1584
- return [0, 0, 0, 0];
1585
- var D = u(this.props, F, this._instanceProps), O = T(this.props, D, F, this._instanceProps), A = !L || N === "backward" ? Math.max(1, M) : 1, H = !L || N === "forward" ? Math.max(1, M) : 1;
1586
- return [Math.max(0, D - A), Math.max(0, Math.min(I - 1, O + H)), D, O];
1587
- }, v;
1588
- }(or), e.defaultProps = {
1589
- direction: "ltr",
1590
- itemData: void 0,
1591
- useIsScrolling: !1
1592
- }, e;
1593
- }
1594
- var ei = function(e, n) {
1595
- var o = e.children, r = e.direction, i = e.height, c = e.innerTagName, l = e.outerTagName, d = e.overscanColumnsCount, f = e.overscanCount, m = e.overscanRowsCount, P = e.width, u = n.instance;
1596
- if (process.env.NODE_ENV !== "production") {
1597
- if (typeof f == "number" && je && !je.has(u) && (je.add(u), console.warn("The overscanCount prop has been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (typeof d == "number" || typeof m == "number") && Ke && !Ke.has(u) && (Ke.add(u), console.warn("The overscanColumnsCount and overscanRowsCount props have been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (c != null || l != null) && Ze && !Ze.has(u) && (Ze.add(u), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")), o == null)
1598
- throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1599
- switch (r) {
1600
- case "ltr":
1601
- case "rtl":
1602
- break;
1603
- default:
1604
- throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + r + '" was specified.'));
1605
- }
1606
- if (typeof P != "number")
1607
- throw Error('An invalid "width" prop has been specified. Grids must specify a number for width. ' + ('"' + (P === null ? "null" : typeof P) + '" was specified.'));
1608
- if (typeof i != "number")
1609
- throw Error('An invalid "height" prop has been specified. Grids must specify a number for height. ' + ('"' + (i === null ? "null" : typeof i) + '" was specified.'));
1610
- }
1611
- }, Bt = 50, Sn = function(e, n) {
1612
- var o = e.rowCount, r = n.rowMetadataMap, i = n.estimatedRowHeight, c = n.lastMeasuredRowIndex, l = 0;
1613
- if (c >= o && (c = o - 1), c >= 0) {
1614
- var d = r[c];
1615
- l = d.offset + d.size;
1616
- }
1617
- var f = o - c - 1, m = f * i;
1618
- return l + m;
1619
- }, In = function(e, n) {
1620
- var o = e.columnCount, r = n.columnMetadataMap, i = n.estimatedColumnWidth, c = n.lastMeasuredColumnIndex, l = 0;
1621
- if (c >= o && (c = o - 1), c >= 0) {
1622
- var d = r[c];
1623
- l = d.offset + d.size;
1624
- }
1625
- var f = o - c - 1, m = f * i;
1626
- return l + m;
1627
- }, ve = function(e, n, o, r) {
1628
- var i, c, l;
1629
- if (e === "column" ? (i = r.columnMetadataMap, c = n.columnWidth, l = r.lastMeasuredColumnIndex) : (i = r.rowMetadataMap, c = n.rowHeight, l = r.lastMeasuredRowIndex), o > l) {
1630
- var d = 0;
1631
- if (l >= 0) {
1632
- var f = i[l];
1633
- d = f.offset + f.size;
1634
- }
1635
- for (var m = l + 1; m <= o; m++) {
1636
- var P = c(m);
1637
- i[m] = {
1638
- offset: d,
1639
- size: P
1640
- }, d += P;
1641
- }
1642
- e === "column" ? r.lastMeasuredColumnIndex = o : r.lastMeasuredRowIndex = o;
1643
- }
1644
- return i[o];
1645
- }, jt = function(e, n, o, r) {
1646
- var i, c;
1647
- e === "column" ? (i = o.columnMetadataMap, c = o.lastMeasuredColumnIndex) : (i = o.rowMetadataMap, c = o.lastMeasuredRowIndex);
1648
- var l = c > 0 ? i[c].offset : 0;
1649
- return l >= r ? xn(e, n, o, c, 0, r) : ti(e, n, o, Math.max(0, c), r);
1650
- }, xn = function(e, n, o, r, i, c) {
1651
- for (; i <= r; ) {
1652
- var l = i + Math.floor((r - i) / 2), d = ve(e, n, l, o).offset;
1653
- if (d === c)
1654
- return l;
1655
- d < c ? i = l + 1 : d > c && (r = l - 1);
1656
- }
1657
- return i > 0 ? i - 1 : 0;
1658
- }, ti = function(e, n, o, r, i) {
1659
- for (var c = e === "column" ? n.columnCount : n.rowCount, l = 1; r < c && ve(e, n, r, o).offset < i; )
1660
- r += l, l *= 2;
1661
- return xn(e, n, o, Math.min(r, c - 1), Math.floor(r / 2), i);
1662
- }, Kt = function(e, n, o, r, i, c, l) {
1663
- var d = e === "column" ? n.width : n.height, f = ve(e, n, o, c), m = e === "column" ? In(n, c) : Sn(n, c), P = Math.max(0, Math.min(m - d, f.offset)), u = Math.max(0, f.offset - d + l + f.size);
1664
- switch (r === "smart" && (i >= u - d && i <= P + d ? r = "auto" : r = "center"), r) {
1665
- case "start":
1666
- return P;
1667
- case "end":
1668
- return u;
1669
- case "center":
1670
- return Math.round(u + (P - u) / 2);
1671
- case "auto":
1672
- default:
1673
- return i >= u && i <= P ? i : u > P || i < u ? u : P;
1674
- }
1675
- }, ni = /* @__PURE__ */ Jo({
1676
- getColumnOffset: function(e, n, o) {
1677
- return ve("column", e, n, o).offset;
1678
- },
1679
- getColumnStartIndexForOffset: function(e, n, o) {
1680
- return jt("column", e, o, n);
1681
- },
1682
- getColumnStopIndexForStartIndex: function(e, n, o, r) {
1683
- for (var i = e.columnCount, c = e.width, l = ve("column", e, n, r), d = o + c, f = l.offset + l.size, m = n; m < i - 1 && f < d; )
1684
- m++, f += ve("column", e, m, r).size;
1685
- return m;
1686
- },
1687
- getColumnWidth: function(e, n, o) {
1688
- return o.columnMetadataMap[n].size;
1689
- },
1690
- getEstimatedTotalHeight: Sn,
1691
- getEstimatedTotalWidth: In,
1692
- getOffsetForColumnAndAlignment: function(e, n, o, r, i, c) {
1693
- return Kt("column", e, n, o, r, i, c);
1694
- },
1695
- getOffsetForRowAndAlignment: function(e, n, o, r, i, c) {
1696
- return Kt("row", e, n, o, r, i, c);
1697
- },
1698
- getRowOffset: function(e, n, o) {
1699
- return ve("row", e, n, o).offset;
1700
- },
1701
- getRowHeight: function(e, n, o) {
1702
- return o.rowMetadataMap[n].size;
1703
- },
1704
- getRowStartIndexForOffset: function(e, n, o) {
1705
- return jt("row", e, o, n);
1706
- },
1707
- getRowStopIndexForStartIndex: function(e, n, o, r) {
1708
- for (var i = e.rowCount, c = e.height, l = ve("row", e, n, r), d = o + c, f = l.offset + l.size, m = n; m < i - 1 && f < d; )
1709
- m++, f += ve("row", e, m, r).size;
1710
- return m;
1711
- },
1712
- initInstanceProps: function(e, n) {
1713
- var o = e, r = o.estimatedColumnWidth, i = o.estimatedRowHeight, c = {
1714
- columnMetadataMap: {},
1715
- estimatedColumnWidth: r || Bt,
1716
- estimatedRowHeight: i || Bt,
1717
- lastMeasuredColumnIndex: -1,
1718
- lastMeasuredRowIndex: -1,
1719
- rowMetadataMap: {}
1720
- };
1721
- return n.resetAfterColumnIndex = function(l, d) {
1722
- d === void 0 && (d = !0), n.resetAfterIndices({
1723
- columnIndex: l,
1724
- shouldForceUpdate: d
1725
- });
1726
- }, n.resetAfterRowIndex = function(l, d) {
1727
- d === void 0 && (d = !0), n.resetAfterIndices({
1728
- rowIndex: l,
1729
- shouldForceUpdate: d
1730
- });
1731
- }, n.resetAfterIndices = function(l) {
1732
- var d = l.columnIndex, f = l.rowIndex, m = l.shouldForceUpdate, P = m === void 0 ? !0 : m;
1733
- typeof d == "number" && (c.lastMeasuredColumnIndex = Math.min(c.lastMeasuredColumnIndex, d - 1)), typeof f == "number" && (c.lastMeasuredRowIndex = Math.min(c.lastMeasuredRowIndex, f - 1)), n._getItemStyleCache(-1), P && n.forceUpdate();
1734
- }, c;
1735
- },
1736
- shouldResetStyleCacheOnItemSizeChange: !1,
1737
- validateProps: function(e) {
1738
- var n = e.columnWidth, o = e.rowHeight;
1739
- if (process.env.NODE_ENV !== "production") {
1740
- if (typeof n != "function")
1741
- throw Error('An invalid "columnWidth" prop has been specified. Value should be a function. ' + ('"' + (n === null ? "null" : typeof n) + '" was specified.'));
1742
- if (typeof o != "function")
1743
- throw Error('An invalid "rowHeight" prop has been specified. Value should be a function. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1744
- }
1745
- }
1746
- });
1747
- process.env.NODE_ENV;
1748
- function Zt(t, e) {
1749
- for (var n in t)
1750
- if (!(n in e))
1751
- return !0;
1752
- for (var o in e)
1753
- if (t[o] !== e[o])
1754
- return !0;
1755
- return !1;
1756
- }
1757
- var ri = ["style"], oi = ["style"];
1758
- function ii(t, e) {
1759
- var n = t.style, o = qt(t, ri), r = e.style, i = qt(e, oi);
1760
- return !Zt(n, r) && !Zt(o, i);
1761
- }
1762
- const ai = () => {
1763
- const { viewMode: t } = Me(), { scrollMode: e } = Ee(), { setColumnCount: n } = sn(), { virtualScrollableElementRef: o } = Je(), r = Ue(), i = W(() => r.heights.length, [r.heights]), c = W(() => e === ne.HORIZONTAL_SCROLLING ? i : t === Re.DUAL_PAGE ? 2 : 1, [t, e, e, i, o]), l = W(() => r.widths.reduce((g, S, v) => {
1764
- const h = v % c;
1765
- return (!g[h] || S > g[h]) && (g[h] = S), g;
1766
- }, []), [r.widths, c]), d = E(
1767
- (b) => {
1768
- const g = b % l.length;
1769
- return l[g] || 0;
1770
- },
1771
- [l]
1772
- ), f = E(
1773
- (b) => {
1774
- const g = Array.from({ length: c }, (S, v) => {
1775
- const h = b * c + v;
1776
- return r.heights[h] || 0;
1777
- });
1778
- return Math.max(...g);
1779
- },
1780
- [r.heights, c]
1781
- );
1782
- z(() => {
1783
- n(c);
1784
- }, [c, n]);
1785
- const m = W(() => e === ne.HORIZONTAL_SCROLLING || e === ne.PAGE_SCROLLING ? 1 : Math.round(i / c), [c, i, e]), P = W(() => r.heights.reduce((b, g) => b + g, 0) / r.heights.length || 0, [r]), u = W(() => r.widths.reduce((b, g) => b + g, 0) / r.widths.length || 0, [r]), T = W(() => {
1786
- const { rowsHeight: b, columnsWidth: g } = Tt(r, c);
1787
- return {
1788
- rowsHeight: b,
1789
- columnsWidth: g
1790
- };
1791
- }, [r, c]), C = W(() => ({
1792
- width: T.columnsWidth.reduce((b, g) => b + g, 0),
1793
- height: T.rowsHeight.reduce((b, g) => b + g, 0)
1794
- }), [T]);
1795
- return {
1796
- rowCount: m,
1797
- rowHeight: f,
1798
- columnCount: c,
1799
- columnWidth: d,
1800
- pageDimension: r,
1801
- estimatedRowHeight: P,
1802
- estimatedColumnWidth: u,
1803
- gridDimension: T,
1804
- totalDimension: C
1805
- };
1806
- };
1807
- let ue;
1808
- typeof window < "u" ? ue = window : typeof self < "u" ? ue = self : ue = global;
1809
- let vt = null, wt = null;
1810
- const Xt = 20, ut = ue.clearTimeout, Qt = ue.setTimeout, pt = ue.cancelAnimationFrame || ue.mozCancelAnimationFrame || ue.webkitCancelAnimationFrame, Yt = ue.requestAnimationFrame || ue.mozRequestAnimationFrame || ue.webkitRequestAnimationFrame;
1811
- pt == null || Yt == null ? (vt = ut, wt = function(e) {
1812
- return Qt(e, Xt);
1813
- }) : (vt = function([e, n]) {
1814
- pt(e), ut(n);
1815
- }, wt = function(e) {
1816
- const n = Yt(function() {
1817
- ut(o), e();
1818
- }), o = Qt(function() {
1819
- pt(n), e();
1820
- }, Xt);
1821
- return [n, o];
1822
- });
1823
- function si(t) {
1824
- let e, n, o, r, i, c, l;
1825
- const d = typeof document < "u" && document.attachEvent;
1826
- if (!d) {
1827
- c = function(S) {
1828
- const v = S.__resizeTriggers__, h = v.firstElementChild, p = v.lastElementChild, s = h.firstElementChild;
1829
- p.scrollLeft = p.scrollWidth, p.scrollTop = p.scrollHeight, s.style.width = h.offsetWidth + 1 + "px", s.style.height = h.offsetHeight + 1 + "px", h.scrollLeft = h.scrollWidth, h.scrollTop = h.scrollHeight;
1830
- }, i = function(S) {
1831
- return S.offsetWidth !== S.__resizeLast__.width || S.offsetHeight !== S.__resizeLast__.height;
1832
- }, l = function(S) {
1833
- if (S.target.className && typeof S.target.className.indexOf == "function" && S.target.className.indexOf("contract-trigger") < 0 && S.target.className.indexOf("expand-trigger") < 0)
1834
- return;
1835
- const v = this;
1836
- c(this), this.__resizeRAF__ && vt(this.__resizeRAF__), this.__resizeRAF__ = wt(function() {
1837
- i(v) && (v.__resizeLast__.width = v.offsetWidth, v.__resizeLast__.height = v.offsetHeight, v.__resizeListeners__.forEach(function(s) {
1838
- s.call(v, S);
1839
- }));
1840
- });
1841
- };
1842
- let u = !1, T = "";
1843
- o = "animationstart";
1844
- const C = "Webkit Moz O ms".split(" ");
1845
- let b = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), g = "";
1846
- {
1847
- const S = document.createElement("fakeelement");
1848
- if (S.style.animationName !== void 0 && (u = !0), u === !1) {
1849
- for (let v = 0; v < C.length; v++)
1850
- if (S.style[C[v] + "AnimationName"] !== void 0) {
1851
- g = C[v], T = "-" + g.toLowerCase() + "-", o = b[v], u = !0;
1852
- break;
1853
- }
1854
- }
1855
- }
1856
- n = "resizeanim", e = "@" + T + "keyframes " + n + " { from { opacity: 0; } to { opacity: 0; } } ", r = T + "animation: 1ms " + n + "; ";
1857
- }
1858
- const f = function(u) {
1859
- if (!u.getElementById("detectElementResize")) {
1860
- const T = (e || "") + ".resize-triggers { " + (r || "") + 'visibility: hidden; opacity: 0; } .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', C = u.head || u.getElementsByTagName("head")[0], b = u.createElement("style");
1861
- b.id = "detectElementResize", b.type = "text/css", t != null && b.setAttribute("nonce", t), b.styleSheet ? b.styleSheet.cssText = T : b.appendChild(u.createTextNode(T)), C.appendChild(b);
1862
- }
1863
- };
1864
- return {
1865
- addResizeListener: function(u, T) {
1866
- if (d)
1867
- u.attachEvent("onresize", T);
1868
- else {
1869
- if (!u.__resizeTriggers__) {
1870
- const C = u.ownerDocument, b = ue.getComputedStyle(u);
1871
- b && b.position === "static" && (u.style.position = "relative"), f(C), u.__resizeLast__ = {}, u.__resizeListeners__ = [], (u.__resizeTriggers__ = C.createElement("div")).className = "resize-triggers";
1872
- const g = C.createElement("div");
1873
- g.className = "expand-trigger", g.appendChild(C.createElement("div"));
1874
- const S = C.createElement("div");
1875
- S.className = "contract-trigger", u.__resizeTriggers__.appendChild(g), u.__resizeTriggers__.appendChild(S), u.appendChild(u.__resizeTriggers__), c(u), u.addEventListener("scroll", l, !0), o && (u.__resizeTriggers__.__animationListener__ = function(h) {
1876
- h.animationName === n && c(u);
1877
- }, u.__resizeTriggers__.addEventListener(o, u.__resizeTriggers__.__animationListener__));
1878
- }
1879
- u.__resizeListeners__.push(T);
1880
- }
1881
- },
1882
- removeResizeListener: function(u, T) {
1883
- if (d)
1884
- u.detachEvent("onresize", T);
1885
- else if (u.__resizeListeners__.splice(u.__resizeListeners__.indexOf(T), 1), !u.__resizeListeners__.length) {
1886
- u.removeEventListener("scroll", l, !0), u.__resizeTriggers__.__animationListener__ && (u.__resizeTriggers__.removeEventListener(o, u.__resizeTriggers__.__animationListener__), u.__resizeTriggers__.__animationListener__ = null);
1887
- try {
1888
- u.__resizeTriggers__ = !u.removeChild(u.__resizeTriggers__);
1889
- } catch {
1890
- }
1891
- }
1892
- }
1893
- };
1894
- }
1895
- class ci extends ir {
1896
- constructor(...e) {
1897
- super(...e), this.state = {
1898
- height: this.props.defaultHeight || 0,
1899
- width: this.props.defaultWidth || 0
1900
- }, this._autoSizer = null, this._detectElementResize = null, this._didLogDeprecationWarning = !1, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
1901
- this._timeoutId = null;
1902
- const {
1903
- disableHeight: n,
1904
- disableWidth: o,
1905
- onResize: r
1906
- } = this.props;
1907
- if (this._parentNode) {
1908
- const i = window.getComputedStyle(this._parentNode) || {}, c = parseFloat(i.paddingLeft || "0"), l = parseFloat(i.paddingRight || "0"), d = parseFloat(i.paddingTop || "0"), f = parseFloat(i.paddingBottom || "0"), m = this._parentNode.getBoundingClientRect(), P = m.height - d - f, u = m.width - c - l;
1909
- if (!n && this.state.height !== P || !o && this.state.width !== u) {
1910
- this.setState({
1911
- height: P,
1912
- width: u
1913
- });
1914
- const T = () => {
1915
- this._didLogDeprecationWarning || (this._didLogDeprecationWarning = !0, console.warn("scaledWidth and scaledHeight parameters have been deprecated; use width and height instead"));
1916
- };
1917
- typeof r == "function" && r({
1918
- height: P,
1919
- width: u,
1920
- // TODO Remove these params in the next major release
1921
- get scaledHeight() {
1922
- return T(), P;
1923
- },
1924
- get scaledWidth() {
1925
- return T(), u;
1926
- }
1927
- });
1928
- }
1929
- }
1930
- }, this._setRef = (n) => {
1931
- this._autoSizer = n;
1932
- };
1933
- }
1934
- componentDidMount() {
1935
- const {
1936
- nonce: e
1937
- } = this.props, n = this._autoSizer ? this._autoSizer.parentNode : null;
1938
- if (n != null && n.ownerDocument && n.ownerDocument.defaultView && n instanceof n.ownerDocument.defaultView.HTMLElement) {
1939
- this._parentNode = n;
1940
- const o = n.ownerDocument.defaultView.ResizeObserver;
1941
- o != null ? (this._resizeObserver = new o(() => {
1942
- this._timeoutId = setTimeout(this._onResize, 0);
1943
- }), this._resizeObserver.observe(n)) : (this._detectElementResize = si(e), this._detectElementResize.addResizeListener(n, this._onResize)), this._onResize();
1944
- }
1945
- }
1946
- componentWillUnmount() {
1947
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
1948
- }
1949
- render() {
1950
- const {
1951
- children: e,
1952
- defaultHeight: n,
1953
- defaultWidth: o,
1954
- disableHeight: r = !1,
1955
- disableWidth: i = !1,
1956
- doNotBailOutOnEmptyChildren: c = !1,
1957
- nonce: l,
1958
- onResize: d,
1959
- style: f = {},
1960
- tagName: m = "div",
1961
- ...P
1962
- } = this.props, {
1963
- height: u,
1964
- width: T
1965
- } = this.state, C = {
1966
- overflow: "visible"
1967
- }, b = {};
1968
- let g = !1;
1969
- return r || (u === 0 && (g = !0), C.height = 0, b.height = u, b.scaledHeight = u), i || (T === 0 && (g = !0), C.width = 0, b.width = T, b.scaledWidth = T), c && (g = !1), Be(m, {
1970
- ref: this._setRef,
1971
- style: {
1972
- ...C,
1973
- ...f
1974
- },
1975
- ...P
1976
- }, !g && e(b));
1977
- }
1978
- }
1979
- const li = on(({ widths: t, heights: e }) => {
1980
- const { focusedPage: n, totalPages: o } = pe(), r = W(() => {
1981
- const l = [], d = Math.ceil(n / 2) * 2 - 1;
1982
- if (l.push(d), d + 1 <= o) {
1983
- const f = d + 1;
1984
- l.push(f);
1985
- }
1986
- return l;
1987
- }, [n, o]), i = W(() => {
1988
- const l = n % 2 === 1 ? n - 1 : n - 2, d = Math.floor(l / 2), f = e(d), m = t(l), P = t(l + 1);
1989
- return [
1990
- {
1991
- position: "absolute",
1992
- left: 0,
1993
- width: m,
1994
- height: f
1995
- },
1996
- {
1997
- position: "absolute",
1998
- left: m,
1999
- width: P,
2000
- height: f
2001
- }
2002
- ];
2003
- }, [t, e, r]), c = W(() => i.reduce((l, d) => l + Number(d.width || 0), 0), [i]);
2004
- return /* @__PURE__ */ a("div", { style: { width: c, position: "relative" }, children: r.map((l, d) => /* @__PURE__ */ a(It, { style: i[d], pageNumber: l }, l)) });
2005
- }), di = ({ widths: t, heights: e }) => {
2006
- const { focusedPage: n } = pe(), o = W(() => ({
2007
- position: "absolute",
2008
- width: t(n - 1),
2009
- height: e(n - 1)
2010
- }), [t, e, n]), r = W(() => t(n - 1), [t]);
2011
- return /* @__PURE__ */ a(
2012
- "div",
2013
- {
2014
- style: {
2015
- width: r,
2016
- position: "relative"
2017
- },
2018
- children: /* @__PURE__ */ a(It, { style: o, pageNumber: n }, n)
2019
- }
2020
- );
2021
- }, ui = (t, e, n) => {
2022
- const o = k(), { contentRef: r } = be(), { heights: i, widths: c } = Ue(), { setFocusedPage: l } = pe(), [d, f] = q([]), { targetScrollPage: m } = cn(), P = Ct(d, 0, 500), u = W(() => {
2023
- const { rowsHeight: C, columnsWidth: b } = Tt({ heights: i, widths: c }, t);
2024
- return i.map((g, S) => {
2025
- const v = c[S], h = eo(S + 1, t), p = b.slice(0, h.columnIndex).reduce((y, x) => y + x, 0), s = C.slice(0, h.rowIndex).reduce((y, x) => y + x, 0), w = p + v, _ = s + g;
2026
- return {
2027
- pageNumber: S + 1,
2028
- ...h,
2029
- width: v,
2030
- height: g,
2031
- startX: p,
2032
- startY: s,
2033
- endX: w,
2034
- endY: _
2035
- };
2036
- });
2037
- }, [i, c, t, e]);
2038
- z(() => {
2039
- var b;
2040
- P.length > 0 && !m.current && l(P[0].pageNumber), ((b = P[0]) == null ? void 0 : b.ratio) && P.some((g) => g.pageNumber === m.current) && setTimeout(() => {
2041
- m.current = void 0;
2042
- }, 500);
2043
- }, [P, l]);
2044
- const T = E(
2045
- (C) => {
2046
- o.current && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
2047
- const b = C.target, g = {
2048
- startTop: b.scrollTop,
2049
- startLeft: b.scrollLeft,
2050
- endTop: b.scrollTop + b.clientHeight,
2051
- endLeft: b.scrollLeft + b.clientWidth
2052
- }, S = u.filter((v) => {
2053
- const h = v.endX >= g.startLeft && v.endY >= g.startTop, p = v.startX <= g.endLeft && v.startY <= g.endTop;
2054
- return h && p;
2055
- }).map((v) => {
2056
- const h = g.startLeft > v.startX ? g.startLeft : v.startX, p = g.startTop > v.startY ? g.startTop : v.startY, s = g.endLeft < v.endX ? g.endLeft : v.endX, w = g.endTop < v.endY ? g.endTop : v.endY, _ = s - h, y = w - p, I = +(_ * y / (v.width * v.height) * 100).toFixed(2);
2057
- return {
2058
- pageNumber: v.pageNumber,
2059
- ratio: I
2060
- };
2061
- }).sort((v, h) => h.ratio - v.ratio);
2062
- f(S);
2063
- });
2064
- },
2065
- [r, u]
2066
- );
2067
- z(() => {
2068
- if (n)
2069
- return n == null || n.addEventListener("scroll", T), () => {
2070
- n == null || n.removeEventListener("scroll", T);
2071
- };
2072
- }, [n, T]);
2073
- }, Rn = tt((t, e) => {
2074
- const { children: n, toolbarRef: o, style: r, className: i, ...c } = t, { customVariables: l, customDarkVariables: d } = Dr(), { darkMode: f } = dr();
2075
- return /* @__PURE__ */ a(
2076
- "div",
2077
- {
2078
- ref: e,
2079
- ...c,
2080
- className: de(
2081
- _e["rp-theme-variables"],
2082
- _e["rp-container"],
2083
- f ? _e["rp-dark-mode"] : "",
2084
- i
2085
- ),
2086
- style: {
2087
- "--rp-toolbar-height": `${(o == null ? void 0 : o.clientHeight) || 48}px`,
2088
- ...l,
2089
- ...f ? d : {},
2090
- ...r
2091
- },
2092
- children: n
2093
- }
2094
- );
2095
- }), pi = on(({ columnIndex: t, rowIndex: e, data: n, style: o }) => {
2096
- const r = to(e, t, n.columnCount);
2097
- return /* @__PURE__ */ a(It, { style: o, pageNumber: r }, r);
2098
- }, ii), rc = () => {
2099
- const { initialPage: t = 1, initialScrollMode: e, instanceId: n } = hr(), { pagesRef: o, setPagesRef: r, setContentRef: i } = be(), { scrollToPage: c } = vn(), {
2100
- virtualScrollRef: l,
2101
- getVirtualScrollRef: d,
2102
- getPageScrollElementRef: f,
2103
- getVirtualScrollableElementRef: m,
2104
- setTotalInnerDimensions: P,
2105
- virtualScrollableElementRef: u,
2106
- totalInnerDimensions: T,
2107
- pageScrollElementRef: C
2108
- } = Je(), b = k(!0), { nextPage: g, prevPage: S, setFocusedPage: v, focusedPage: h } = pe(), { scrollMode: p } = Ee(), { viewMode: s } = Me(), w = k(null), { loading: _, error: y } = re(), { passwordRequired: x } = lr(), { LoaderImageComponent: I } = bt(), R = k(
2109
- T
2110
- ), L = k({
2111
- viewMode: s,
2112
- scrollMode: p
2113
- }), N = k(!1), F = k(), { isFullScreen: M } = fr(), {
2114
- pageDimension: D,
2115
- rowCount: O,
2116
- rowHeight: A,
2117
- columnCount: H,
2118
- columnWidth: U,
2119
- estimatedColumnWidth: B,
2120
- estimatedRowHeight: V,
2121
- totalDimension: J
2122
- } = ai(), G = Ct(T, 100), { onScroll: K } = Sr(), Y = k();
2123
- ui(H, O, u);
2124
- const ee = k({
2125
- scrollTop: 0,
2126
- scrollLeft: 0
2127
- });
2128
- oo(o);
2129
- const { isPressed: oe } = no(), { selectionMode: ie } = pr(), { initializeGrabScroll: se, resetGrabState: ce } = ro({
2130
- isPressed: oe
2131
- }), ae = W(() => ie === sr.HAND, [ie]), Fe = W(() => ({
2132
- columnCount: H
2133
- }), [H]), ke = E(
2134
- (j) => {
2135
- const Z = document.activeElement !== o;
2136
- !M && Z || (["ArrowUp", "ArrowLeft"].includes(j.key) ? (j.preventDefault(), S()) : ["ArrowDown", "ArrowRight"].includes(j.key) && (j.preventDefault(), g()));
2137
- },
2138
- [g, S, M, p]
2139
- );
2140
- z(() => (window.addEventListener("keydown", ke), () => {
2141
- window.removeEventListener("keydown", ke);
2142
- }), [ke]), z(() => {
2143
- if (w.current && (w.current.style.position = "relative"), !!l)
2144
- for (let j = 0; j < O; j++)
2145
- for (let Z = 0; Z < H; Z++)
2146
- l.resetAfterIndices({
2147
- columnIndex: Z,
2148
- rowIndex: j,
2149
- shouldForceUpdate: !0
2150
- });
2151
- }, [O, H, D, l]);
2152
- const Xn = E(
2153
- (j, Z) => {
2154
- if (!u)
2155
- return { scrollTop: 0, scrollLeft: 0 };
2156
- const ye = ee.current.scrollTop > Z, Se = ee.current.scrollLeft > j;
2157
- return ye || Se ? ee.current : {
2158
- scrollTop: u.scrollTop,
2159
- scrollLeft: u.scrollLeft
2160
- };
2161
- },
2162
- [u]
2163
- ), Et = E(
2164
- (j, Z) => {
2165
- if (L.current.viewMode !== s || L.current.scrollMode !== p) {
2166
- Y.current && clearTimeout(Y.current), N.current = !0, c(h, "auto"), Y.current = setTimeout(() => {
2167
- requestAnimationFrame(() => {
2168
- L.current = { viewMode: s, scrollMode: p };
2169
- });
2170
- }, 100);
2171
- return;
2172
- }
2173
- const Se = j.scrollTop, ot = j.scrollLeft;
2174
- if (!Z.height || !Z.width)
2175
- return;
2176
- N.current = !0;
2177
- const { height: Ie, width: it } = Z, { height: Nt, width: Ot } = R.current;
2178
- if (Nt === Ie && Ot === it)
2179
- return;
2180
- const er = Se / Nt * Ie, tr = ot / Ot * it, nr = Math.round(Math.min(er, Ie)) || 0, rr = Math.round(Math.min(tr, it)) || 0;
2181
- F.current = setTimeout(() => {
2182
- requestAnimationFrame(() => {
2183
- u == null || u.scrollTo({
2184
- top: nr,
2185
- left: rr,
2186
- behavior: "auto"
2187
- });
2188
- });
2189
- }, 0), R.current = {
2190
- height: Z.height,
2191
- width: Z.width
2192
- };
2193
- },
2194
- [u, s, p, c]
2195
- );
2196
- z(() => {
2197
- clearTimeout(F.current);
2198
- const j = Array.from({ length: O }).reduce(
2199
- (Se, ot, Ie) => Se + A(Ie),
2200
- 0
2201
- ), Z = Array.from({ length: H }).reduce(
2202
- (Se, ot, Ie) => Se + U(Ie),
2203
- 0
2204
- ), ye = Xn(Z, j);
2205
- ee.current = ye, Et(ye, { height: j, width: Z }), P({
2206
- height: j,
2207
- width: Z
2208
- });
2209
- }, [D, O, H, Et]);
2210
- const Qn = E(
2211
- (j) => {
2212
- ee.current = {
2213
- scrollTop: j.scrollTop,
2214
- scrollLeft: j.scrollLeft
2215
- };
2216
- },
2217
- [u]
2218
- );
2219
- z(() => {
2220
- if (K)
2221
- return C && C.addEventListener("scroll", K), u && u.addEventListener("scroll", K), () => {
2222
- C == null || C.removeEventListener("scroll", K), u == null || u.removeEventListener("scroll", K);
2223
- };
2224
- }, [u, C, K]), z(() => () => {
2225
- Y.current && clearTimeout(Y.current);
2226
- }, []);
2227
- const Yn = W(() => de(le["rp-pages-container"], {
2228
- [le["rp-cursor-grab"]]: ae && !oe,
2229
- [le["rp-cursor-grabbing"]]: ae && oe
2230
- }), [ae, oe]), Jn = E(
2231
- (j) => {
2232
- if (ae && j) {
2233
- const Z = de(le["rp-pages"]), ye = document.querySelector(`.${Z}`);
2234
- se(ye);
2235
- }
2236
- },
2237
- [ae, se, le]
2238
- );
2239
- return z(() => {
2240
- _ && ce();
2241
- }, [_]), z(() => {
2242
- if (!(G.height === 0 || !b.current)) {
2243
- if (e === ne.PAGE_SCROLLING) {
2244
- t !== h && C && v(t), b.current = !1;
2245
- return;
2246
- }
2247
- c(t, "auto"), v(t), b.current = !1;
2248
- }
2249
- }, [
2250
- c,
2251
- e,
2252
- C,
2253
- v,
2254
- G
2255
- ]), /* @__PURE__ */ $(fe, { children: [
2256
- /* @__PURE__ */ a(Or, { ref: i, children: /* @__PURE__ */ a(
2257
- Rn,
2258
- {
2259
- id: n,
2260
- ref: r,
2261
- tabIndex: -1,
2262
- className: Yn,
2263
- children: /* @__PURE__ */ a(ci, { style: { minHeight: "50px" }, children: ({ width: j, height: Z }) => /* @__PURE__ */ a("div", { "data-rp": "pages", ref: Jn, style: { width: j, height: Z }, children: p === ne.PAGE_SCROLLING ? /* @__PURE__ */ a(
2264
- "div",
2265
- {
2266
- ref: f,
2267
- style: { width: j, height: Z },
2268
- className: de(le["rp-pages"], le["rp-page-scrolling-wrapper"]),
2269
- children: s === Re.DUAL_PAGE ? /* @__PURE__ */ a(li, { widths: U, heights: A }) : /* @__PURE__ */ a(di, { widths: U, heights: A })
2270
- }
2271
- ) : V ? /* @__PURE__ */ a(
2272
- ni,
2273
- {
2274
- ref: d,
2275
- itemData: Fe,
2276
- outerRef: m,
2277
- innerRef: w,
2278
- onScroll: Qn,
2279
- columnCount: H,
2280
- columnWidth: U,
2281
- rowHeight: A,
2282
- height: Z,
2283
- width: j,
2284
- estimatedColumnWidth: B,
2285
- estimatedRowHeight: V,
2286
- rowCount: O,
2287
- className: de(
2288
- le["rp-pages"],
2289
- p === ne.HORIZONTAL_SCROLLING ? le["rp-pages-horizontal-scroll"] : ""
2290
- ),
2291
- style: {
2292
- "--rp-pages-height": `${J.height}px`,
2293
- "--rp-pages-width": `${J.width}px`,
2294
- "--rp-row-count": `${O}`,
2295
- "--rp-column-count": `${H}`
2296
- },
2297
- children: pi
2298
- }
2299
- ) : !_ && !y ? /* @__PURE__ */ a(
2300
- "div",
2301
- {
2302
- className: le["rp-loader"],
2303
- style: {
2304
- display: "flex",
2305
- justifyContent: "center",
2306
- alignItems: "center",
2307
- height: "100%",
2308
- width: "100%"
2309
- },
2310
- children: I && /* @__PURE__ */ a(I, {})
2311
- }
2312
- ) : y === cr.NOT_SUPPORTED ? /* @__PURE__ */ a("div", { className: le["rp-not-supported"], children: /* @__PURE__ */ $("div", { className: le["rp-not-supported-content"], children: [
2313
- "React PDF is unable to render on this browser. Please use the supported browsers from the list below:",
2314
- /* @__PURE__ */ a("div", { children: /* @__PURE__ */ $("ul", { children: [
2315
- /* @__PURE__ */ a("li", { children: "Chrome 110+" }),
2316
- /* @__PURE__ */ a("li", { children: "Edge 115+" }),
2317
- /* @__PURE__ */ a("li", { children: "Firefox 115+" }),
2318
- /* @__PURE__ */ a("li", { children: "Safari 16.5+" }),
2319
- /* @__PURE__ */ a("li", { children: "Safari iOS 16.5+" }),
2320
- /* @__PURE__ */ a("li", { children: "Chrome Android 126+" })
2321
- ] }) })
2322
- ] }) }) : null }) })
2323
- }
2324
- ) }),
2325
- x && /* @__PURE__ */ a(io, {})
2326
- ] });
2327
- }, We = {
2328
- "rp-toolbar-content": "_rp-toolbar-content_sz31z_1",
2329
- "rp-toolbar-wrapper": "_rp-toolbar-wrapper_sz31z_10",
2330
- "rp-toolbar-start": "_rp-toolbar-start_sz31z_33",
2331
- "rp-toolbar-middle": "_rp-toolbar-middle_sz31z_39",
2332
- "rp-toolbar-end": "_rp-toolbar-end_sz31z_46"
2333
- }, ht = {
2334
- "rp-paginate": "_rp-paginate_1gck0_1",
2335
- "rp-page-input": "_rp-page-input_1gck0_6",
2336
- "rp-total-page": "_rp-total-page_1gck0_18"
2337
- }, hi = () => {
2338
- const { prevIcon: t } = Pe(), { prevIcon: e } = Te();
2339
- return t || e || /* @__PURE__ */ a(Xe, {});
2340
- }, fi = () => {
2341
- const { nextIcon: t } = Pe(), { nextIcon: e } = Te();
2342
- return t || e || /* @__PURE__ */ a(Xe, { style: { transform: "rotate(180deg" } });
2343
- }, mi = () => {
2344
- const { focusedPage: t, totalPages: e, setFocusedPage: n, nextPage: o, prevPage: r, goToPage: i } = pe(), [c, l] = q(t.toString()), { pageNavigationTool: d = !0 } = Ce(), { pageNavigationTool: f = !0 } = Ne(), { isSmallScreen: m } = Oe(), { viewMode: P } = Me(), { scrollMode: u } = Ee(), { localeMessages: T } = me();
2345
- z(() => {
2346
- l(t.toString());
2347
- }, [t]);
2348
- const C = E((h) => {
2349
- const p = h.target.value;
2350
- l(p);
2351
- }, []), b = E(async () => {
2352
- const h = i(c);
2353
- h.success || l(h.currentPage.toString());
2354
- }, [i, c, e]), g = E(() => {
2355
- l(t.toString());
2356
- }, [t]), S = E(
2357
- (h) => {
2358
- h.key === "Enter" && b();
2359
- },
2360
- [b]
2361
- ), v = W(() => P === Re.DUAL_PAGE && u === ne.PAGE_SCROLLING && t === e - 1 || t === e, [t, e, P, u]);
2362
- return !d || !f ? null : typeof d != "boolean" ? /* @__PURE__ */ a(
2363
- d,
2364
- {
2365
- total: e,
2366
- current: t,
2367
- nextPage: o,
2368
- prevPage: r,
2369
- goToPage: i,
2370
- changePage: n
2371
- }
2372
- ) : typeof f != "boolean" ? /* @__PURE__ */ a(
2373
- f,
2374
- {
2375
- total: e,
2376
- current: t,
2377
- nextPage: o,
2378
- prevPage: r,
2379
- goToPage: i,
2380
- changePage: n
2381
- }
2382
- ) : /* @__PURE__ */ $("div", { className: ht["rp-paginate"], children: [
2383
- !m && /* @__PURE__ */ a(Q, { content: T == null ? void 0 : T.previousPageTooltip, children: /* @__PURE__ */ a(
2384
- we,
2385
- {
2386
- onClick: r,
2387
- "aria-label": T == null ? void 0 : T.previousPageTooltip,
2388
- "aria-disabled": t === 1,
2389
- children: /* @__PURE__ */ a(hi, {})
2390
- }
2391
- ) }),
2392
- /* @__PURE__ */ a(Q, { content: T == null ? void 0 : T.currentPageTooltip, children: /* @__PURE__ */ a(
2393
- an,
2394
- {
2395
- onKeyDown: S,
2396
- onBlur: g,
2397
- onChange: C,
2398
- value: c,
2399
- className: ht["rp-page-input"],
2400
- id: "page-input",
2401
- name: "page-input"
2402
- }
2403
- ) }),
2404
- /* @__PURE__ */ $("span", { className: ht["rp-total-page"], children: [
2405
- "/",
2406
- e
2407
- ] }),
2408
- !m && /* @__PURE__ */ a(Q, { content: T == null ? void 0 : T.nextPageTooltip, children: /* @__PURE__ */ a(
2409
- we,
2410
- {
2411
- onClick: o,
2412
- "aria-label": T == null ? void 0 : T.nextPageTooltip,
2413
- "aria-disabled": v,
2414
- children: /* @__PURE__ */ a(fi, {})
2415
- }
2416
- ) })
2417
- ] });
2418
- };
2419
- var rt = "Dialog", [Ln, oc] = po(rt), [gi, he] = Ln(rt), En = (t) => {
2420
- const {
2421
- __scopeDialog: e,
2422
- children: n,
2423
- open: o,
2424
- defaultOpen: r,
2425
- onOpenChange: i,
2426
- modal: c = !0
2427
- } = t, l = X.useRef(null), d = X.useRef(null), [f, m] = fo({
2428
- prop: o,
2429
- defaultProp: r ?? !1,
2430
- onChange: i,
2431
- caller: rt
2432
- });
2433
- return /* @__PURE__ */ a(
2434
- gi,
2435
- {
2436
- scope: e,
2437
- triggerRef: l,
2438
- contentRef: d,
2439
- contentId: st(),
2440
- titleId: st(),
2441
- descriptionId: st(),
2442
- open: f,
2443
- onOpenChange: m,
2444
- onOpenToggle: X.useCallback(() => m((P) => !P), [m]),
2445
- modal: c,
2446
- children: n
2447
- }
2448
- );
2449
- };
2450
- En.displayName = rt;
2451
- var Nn = "DialogTrigger", vi = X.forwardRef(
2452
- (t, e) => {
2453
- const { __scopeDialog: n, ...o } = t, r = he(Nn, n), i = Pt(e, r.triggerRef);
2454
- return /* @__PURE__ */ a(
2455
- Ve.button,
2456
- {
2457
- type: "button",
2458
- "aria-haspopup": "dialog",
2459
- "aria-expanded": r.open,
2460
- "aria-controls": r.contentId,
2461
- "data-state": Lt(r.open),
2462
- ...o,
2463
- ref: i,
2464
- onClick: $e(t.onClick, r.onOpenToggle)
2465
- }
2466
- );
2467
- }
2468
- );
2469
- vi.displayName = Nn;
2470
- var xt = "DialogPortal", [wi, On] = Ln(xt, {
2471
- forceMount: void 0
2472
- }), Dn = (t) => {
2473
- const { __scopeDialog: e, forceMount: n, children: o, container: r } = t, i = he(xt, e);
2474
- return /* @__PURE__ */ a(wi, { scope: e, forceMount: n, children: X.Children.map(o, (c) => /* @__PURE__ */ a(yt, { present: n || i.open, children: /* @__PURE__ */ a(To, { asChild: !0, container: r, children: c }) })) });
2475
- };
2476
- Dn.displayName = xt;
2477
- var Ye = "DialogOverlay", An = X.forwardRef(
2478
- (t, e) => {
2479
- const n = On(Ye, t.__scopeDialog), { forceMount: o = n.forceMount, ...r } = t, i = he(Ye, t.__scopeDialog);
2480
- return i.modal ? /* @__PURE__ */ a(yt, { present: o || i.open, children: /* @__PURE__ */ a(bi, { ...r, ref: e }) }) : null;
2481
- }
2482
- );
2483
- An.displayName = Ye;
2484
- var _i = mo("DialogOverlay.RemoveScroll"), bi = X.forwardRef(
2485
- (t, e) => {
2486
- const { __scopeDialog: n, ...o } = t, r = he(Ye, n);
2487
- return (
2488
- // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
2489
- // ie. when `Overlay` and `Content` are siblings
2490
- /* @__PURE__ */ a(vo, { as: _i, allowPinchZoom: !0, shards: [r.contentRef], children: /* @__PURE__ */ a(
2491
- Ve.div,
2492
- {
2493
- "data-state": Lt(r.open),
2494
- ...o,
2495
- ref: e,
2496
- style: { pointerEvents: "auto", ...o.style }
2497
- }
2498
- ) })
2499
- );
2500
- }
2501
- ), Le = "DialogContent", zn = X.forwardRef(
2502
- (t, e) => {
2503
- const n = On(Le, t.__scopeDialog), { forceMount: o = n.forceMount, ...r } = t, i = he(Le, t.__scopeDialog);
2504
- return /* @__PURE__ */ a(yt, { present: o || i.open, children: i.modal ? /* @__PURE__ */ a(Ti, { ...r, ref: e }) : /* @__PURE__ */ a(Ci, { ...r, ref: e }) });
2505
- }
2506
- );
2507
- zn.displayName = Le;
2508
- var Ti = X.forwardRef(
2509
- (t, e) => {
2510
- const n = he(Le, t.__scopeDialog), o = X.useRef(null), r = Pt(e, n.contentRef, o);
2511
- return X.useEffect(() => {
2512
- const i = o.current;
2513
- if (i)
2514
- return wo(i);
2515
- }, []), /* @__PURE__ */ a(
2516
- Mn,
2517
- {
2518
- ...t,
2519
- ref: r,
2520
- trapFocus: n.open,
2521
- disableOutsidePointerEvents: !0,
2522
- onCloseAutoFocus: $e(t.onCloseAutoFocus, (i) => {
2523
- var c;
2524
- i.preventDefault(), (c = n.triggerRef.current) == null || c.focus();
2525
- }),
2526
- onPointerDownOutside: $e(t.onPointerDownOutside, (i) => {
2527
- const c = i.detail.originalEvent, l = c.button === 0 && c.ctrlKey === !0;
2528
- (c.button === 2 || l) && i.preventDefault();
2529
- }),
2530
- onFocusOutside: $e(
2531
- t.onFocusOutside,
2532
- (i) => i.preventDefault()
2533
- )
2534
- }
2535
- );
2536
- }
2537
- ), Ci = X.forwardRef(
2538
- (t, e) => {
2539
- const n = he(Le, t.__scopeDialog), o = X.useRef(!1), r = X.useRef(!1);
2540
- return /* @__PURE__ */ a(
2541
- Mn,
2542
- {
2543
- ...t,
2544
- ref: e,
2545
- trapFocus: !1,
2546
- disableOutsidePointerEvents: !1,
2547
- onCloseAutoFocus: (i) => {
2548
- var c, l;
2549
- (c = t.onCloseAutoFocus) == null || c.call(t, i), i.defaultPrevented || (o.current || (l = n.triggerRef.current) == null || l.focus(), i.preventDefault()), o.current = !1, r.current = !1;
2550
- },
2551
- onInteractOutside: (i) => {
2552
- var d, f;
2553
- (d = t.onInteractOutside) == null || d.call(t, i), i.defaultPrevented || (o.current = !0, i.detail.originalEvent.type === "pointerdown" && (r.current = !0));
2554
- const c = i.target;
2555
- ((f = n.triggerRef.current) == null ? void 0 : f.contains(c)) && i.preventDefault(), i.detail.originalEvent.type === "focusin" && r.current && i.preventDefault();
2556
- }
2557
- }
2558
- );
2559
- }
2560
- ), Mn = X.forwardRef(
2561
- (t, e) => {
2562
- const { __scopeDialog: n, trapFocus: o, onOpenAutoFocus: r, onCloseAutoFocus: i, ...c } = t, l = he(Le, n), d = X.useRef(null), f = Pt(e, d);
2563
- return _o(), /* @__PURE__ */ $(fe, { children: [
2564
- /* @__PURE__ */ a(
2565
- bo,
2566
- {
2567
- asChild: !0,
2568
- loop: !0,
2569
- trapped: o,
2570
- onMountAutoFocus: r,
2571
- onUnmountAutoFocus: i,
2572
- children: /* @__PURE__ */ a(
2573
- go,
2574
- {
2575
- role: "dialog",
2576
- id: l.contentId,
2577
- "aria-describedby": l.descriptionId,
2578
- "aria-labelledby": l.titleId,
2579
- "data-state": Lt(l.open),
2580
- ...c,
2581
- ref: f,
2582
- onDismiss: () => l.onOpenChange(!1)
2583
- }
2584
- )
2585
- }
2586
- ),
2587
- /* @__PURE__ */ $(fe, { children: [
2588
- /* @__PURE__ */ a(yi, { titleId: l.titleId }),
2589
- /* @__PURE__ */ a(Ii, { contentRef: d, descriptionId: l.descriptionId })
2590
- ] })
2591
- ] });
2592
- }
2593
- ), Rt = "DialogTitle", Fn = X.forwardRef(
2594
- (t, e) => {
2595
- const { __scopeDialog: n, ...o } = t, r = he(Rt, n);
2596
- return /* @__PURE__ */ a(Ve.h2, { id: r.titleId, ...o, ref: e });
2597
- }
2598
- );
2599
- Fn.displayName = Rt;
2600
- var kn = "DialogDescription", Pi = X.forwardRef(
2601
- (t, e) => {
2602
- const { __scopeDialog: n, ...o } = t, r = he(kn, n);
2603
- return /* @__PURE__ */ a(Ve.p, { id: r.descriptionId, ...o, ref: e });
2604
- }
2605
- );
2606
- Pi.displayName = kn;
2607
- var Wn = "DialogClose", Hn = X.forwardRef(
2608
- (t, e) => {
2609
- const { __scopeDialog: n, ...o } = t, r = he(Wn, n);
2610
- return /* @__PURE__ */ a(
2611
- Ve.button,
2612
- {
2613
- type: "button",
2614
- ...o,
2615
- ref: e,
2616
- onClick: $e(t.onClick, () => r.onOpenChange(!1))
2617
- }
2618
- );
2619
- }
2620
- );
2621
- Hn.displayName = Wn;
2622
- function Lt(t) {
2623
- return t ? "open" : "closed";
2624
- }
2625
- var $n = "DialogTitleWarning", [ic, qn] = ho($n, {
2626
- contentName: Le,
2627
- titleName: Rt,
2628
- docsSlug: "dialog"
2629
- }), yi = ({ titleId: t }) => {
2630
- const e = qn($n), n = `\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
2631
-
2632
- If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
2633
-
2634
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;
2635
- return X.useEffect(() => {
2636
- t && (document.getElementById(t) || console.error(n));
2637
- }, [n, t]), null;
2638
- }, Si = "DialogDescriptionWarning", Ii = ({ contentRef: t, descriptionId: e }) => {
2639
- const o = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${qn(Si).contentName}}.`;
2640
- return X.useEffect(() => {
2641
- var i;
2642
- const r = (i = t.current) == null ? void 0 : i.getAttribute("aria-describedby");
2643
- e && r && (document.getElementById(e) || console.warn(o));
2644
- }, [o, t, e]), null;
2645
- }, xi = En, Ri = Dn, Li = An, Ei = zn, Ni = Fn, Oi = Hn;
2646
- const xe = {
2647
- "rp-dialog-wrapper": "_rp-dialog-wrapper_slqo7_1",
2648
- "rp-dialog-overlay": "_rp-dialog-overlay_slqo7_7",
2649
- "rp-document-dialog": "_rp-document-dialog_slqo7_13",
2650
- "rp-document-properties": "_rp-document-properties_slqo7_35",
2651
- "rp-dialog-title": "_rp-dialog-title_slqo7_39",
2652
- "rp-dialog-close": "_rp-dialog-close_slqo7_47",
2653
- "rp-properties-divider": "_rp-properties-divider_slqo7_55"
2654
- }, Di = () => {
2655
- const { pdfProperties: t } = re(), { container: e } = be(), { activeDocumentProperties: n, setActiveDocumentProperties: o } = yr(), { localeMessages: r } = me(), i = W(() => {
2656
- if (!t)
2657
- return [];
2658
- const {
2659
- fileSize: c,
2660
- filename: l,
2661
- title: d,
2662
- author: f,
2663
- subject: m,
2664
- createdOn: P,
2665
- creator: u,
2666
- keywords: T,
2667
- modifiedOn: C,
2668
- pdfProducer: b,
2669
- pdfVersion: g,
2670
- pageCount: S
2671
- } = t;
2672
- return [
2673
- { label: r == null ? void 0 : r.propertiesFilenameLabel, value: l },
2674
- { label: r == null ? void 0 : r.propertiesFileSizeLabel, value: c },
2675
- { separate: !0 },
2676
- { label: r == null ? void 0 : r.propertiesTitleLabel, value: d },
2677
- { label: r == null ? void 0 : r.propertiesAuthorLabel, value: f },
2678
- { label: r == null ? void 0 : r.propertiesSubjectLabel, value: m },
2679
- { label: r == null ? void 0 : r.propertiesKeywordLabel, value: T },
2680
- { label: r == null ? void 0 : r.propertiesCreatorLabel, value: u },
2681
- {
2682
- label: r == null ? void 0 : r.propertiesCreateOnLabel,
2683
- value: P ? Mt(P) : ""
2684
- },
2685
- {
2686
- label: r == null ? void 0 : r.propertiesModifiedOnLabel,
2687
- value: C ? Mt(C) : ""
2688
- },
2689
- { separate: !0 },
2690
- { label: r == null ? void 0 : r.propertiesPDFProducerLabel, value: b },
2691
- { label: r == null ? void 0 : r.propertiesPDFVersionLabel, value: g },
2692
- { label: r == null ? void 0 : r.propertiesPageCountLabel, value: S }
2693
- ];
2694
- }, [t, r]);
2695
- return /* @__PURE__ */ a(xi, { open: n, onOpenChange: o, children: /* @__PURE__ */ a(Ri, { container: e, children: /* @__PURE__ */ $("div", { className: xe["rp-dialog-wrapper"], children: [
2696
- /* @__PURE__ */ a(Li, { className: xe["rp-dialog-overlay"] }),
2697
- /* @__PURE__ */ $(Ei, { className: xe["rp-document-dialog"], children: [
2698
- /* @__PURE__ */ a(Ni, { className: xe["rp-dialog-title"], children: r == null ? void 0 : r.documentPropertiesLabel }),
2699
- /* @__PURE__ */ a("div", { className: xe["rp-document-properties"], children: i.map((c, l) => /* @__PURE__ */ a("div", { children: c.separate ? /* @__PURE__ */ a("div", { className: xe["rp-properties-divider"] }) : /* @__PURE__ */ a(Mr, { label: c.label, value: c.value }) }, l)) }),
2700
- /* @__PURE__ */ a(Oi, { asChild: !0, className: xe["rp-dialog-close"], children: /* @__PURE__ */ a(Co, {}) })
2701
- ] })
2702
- ] }) }) });
2703
- }, Ai = {
2704
- "rp-other-tool-content": "_rp-other-tool-content_su718_1"
2705
- }, Jt = ".pdf", zi = (t) => URL.createObjectURL(t), Mi = async (t) => {
2706
- const n = await (await fetch(t)).blob();
2707
- return zi(n);
2708
- }, Gn = () => {
2709
- const { filename: t, pdfSrc: e } = re(), { downloadFilename: n } = br(), o = (i) => {
2710
- const c = n || i;
2711
- return c.endsWith(Jt) ? c : `${c}${Jt}`;
2712
- };
2713
- return { download: E(async () => {
2714
- if (!t || !e)
2715
- throw new Error("There is no PDF source to download");
2716
- const i = document.createElement("a");
2717
- i.href = await Mi(e), i.download = o(t), document.body.appendChild(i), i.click(), document.body.removeChild(i);
2718
- }, [t, e]) };
2719
- }, Un = () => {
2720
- const { downloadIcon: t } = Pe(), { downloadIcon: e } = Te();
2721
- return t || e || /* @__PURE__ */ a(xo, {});
2722
- }, Vn = ({ children: t, className: e, localeMessages: n }) => /* @__PURE__ */ a(Q, { className: e, content: n == null ? void 0 : n.downloadFileTooltip, children: t }), Fi = ({ download: t, localeMessages: e }) => /* @__PURE__ */ a(Vn, { localeMessages: e, children: /* @__PURE__ */ a(we, { onClick: t, "aria-label": e == null ? void 0 : e.downloadFileTooltip, children: /* @__PURE__ */ a(Un, {}) }) }), ki = ({ download: t, localeMessages: e }) => /* @__PURE__ */ a(Qe, { onClick: t, children: /* @__PURE__ */ $(Vn, { className: "rp-menu-item", localeMessages: e, children: [
2723
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(Un, {}) }),
2724
- e == null ? void 0 : e.downloadFileLabel
2725
- ] }) }), Bn = () => {
2726
- const { download: t } = Gn(), { downloadTool: e = !0 } = Ce(), { downloadTool: n = !0 } = Ne(), { isSmallScreen: o } = Oe(), { localeMessages: r } = me(), i = r == null ? void 0 : r.downloadFileTooltip;
2727
- return !e || !n ? null : o ? /* @__PURE__ */ a(ki, { download: t, localeMessages: r }) : typeof e == "function" ? /* @__PURE__ */ a(Q, { content: i, children: /* @__PURE__ */ a(e, { download: t }) }) : typeof n == "function" ? /* @__PURE__ */ a(Q, { content: i, children: /* @__PURE__ */ a(n, { download: t }) }) : /* @__PURE__ */ a(Fi, { download: t, localeMessages: r });
2728
- }, jn = () => {
2729
- const { printIcon: t } = Pe(), { printIcon: e } = Te();
2730
- return t || e || /* @__PURE__ */ a(Ro, {});
2731
- }, Kn = ({ children: t, className: e, localeMessages: n }) => /* @__PURE__ */ a(Q, { className: e, content: n == null ? void 0 : n.printTooltip, children: t }), Wi = ({ print: t, localeMessages: e }) => /* @__PURE__ */ a(Kn, { localeMessages: e, children: /* @__PURE__ */ a(we, { onClick: t, "aria-label": e == null ? void 0 : e.printTooltip, children: /* @__PURE__ */ a(jn, {}) }) }), Hi = ({ print: t, localeMessages: e }) => /* @__PURE__ */ a(Qe, { onClick: t, children: /* @__PURE__ */ $(Kn, { className: "rp-menu-item", localeMessages: e, children: [
2732
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(jn, {}) }),
2733
- e == null ? void 0 : e.printLabel
2734
- ] }) }), Zn = () => {
2735
- const { print: t, cancel: e, setOnProgress: n, setOnComplete: o, setOnError: r, progress: i } = nt(), { printTool: c = !0 } = Ce(), { printTool: l = !0 } = Ne(), { isSmallScreen: d } = Oe(), { localeMessages: f } = me(), m = f == null ? void 0 : f.printTooltip;
2736
- return !c || !l ? null : d ? /* @__PURE__ */ a(Hi, { print: t, localeMessages: f }) : typeof c == "function" ? /* @__PURE__ */ a(Q, { content: m, children: /* @__PURE__ */ a(
2737
- c,
2738
- {
2739
- print: t,
2740
- cancel: e,
2741
- setOnProgress: n,
2742
- setOnError: r,
2743
- setOnComplete: o,
2744
- progress: i
2745
- }
2746
- ) }) : typeof l == "function" ? /* @__PURE__ */ a(Q, { content: m, children: /* @__PURE__ */ a(
2747
- l,
2748
- {
2749
- print: t,
2750
- cancel: e,
2751
- setOnProgress: n,
2752
- setOnError: r,
2753
- setOnComplete: o,
2754
- progress: i
2755
- }
2756
- ) }) : /* @__PURE__ */ a(Wi, { print: t, localeMessages: f });
2757
- }, $i = {
2758
- "rp-go-to-Top": "_rp-go-to-Top_4e0yd_1"
2759
- }, qi = () => {
2760
- const { goToFirstPageIcon: t } = Pe(), { goToFirstPageIcon: e } = Te();
2761
- return t || e || /* @__PURE__ */ a(mn, { className: $i["rp-go-to-Top"] });
2762
- }, Gi = () => {
2763
- const { goToLastPageIcon: t } = Pe(), { goToLastPageIcon: e } = Te();
2764
- return t || e || /* @__PURE__ */ a(mn, {});
2765
- }, en = { width: "100%" }, Ui = () => {
2766
- const { goToPage: t, totalPages: e, focusedPage: n } = pe(), { jumpNavigationTool: o = !0 } = Ce(), { jumpNavigationTool: r = !0 } = Ne(), { localeMessages: i } = me(), c = W(() => n === 1, [n]), l = W(() => n === e, [n, e]), d = E(() => {
2767
- t(1);
2768
- }, [t]), f = E(() => {
2769
- t(e);
2770
- }, [t, e]);
2771
- return !o || !r ? null : /* @__PURE__ */ $(hn, { children: [
2772
- /* @__PURE__ */ a(Qe, { onClick: d, children: /* @__PURE__ */ a(Q, { content: i == null ? void 0 : i.firstPageTooltip, style: en, children: /* @__PURE__ */ $("div", { className: "rp-menu-item", "aria-disabled": c, children: [
2773
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(qi, {}) }),
2774
- /* @__PURE__ */ a("span", { children: i == null ? void 0 : i.firstPageLabel })
2775
- ] }) }) }),
2776
- /* @__PURE__ */ a(Qe, { onClick: f, children: /* @__PURE__ */ a(Q, { content: i == null ? void 0 : i.lastPageTooltip, style: en, children: /* @__PURE__ */ $("div", { className: "rp-menu-item", "aria-disabled": l, children: [
2777
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(Gi, {}) }),
2778
- /* @__PURE__ */ a("span", { children: i == null ? void 0 : i.lastPageLabel })
2779
- ] }) }) }),
2780
- /* @__PURE__ */ a(un, {})
2781
- ] });
2782
- }, Vi = () => {
2783
- const [t, e] = q(!1), { container: n, pagesRef: o } = be(), { isSmallScreen: r } = Oe(), {
2784
- openFileTool: i,
2785
- downloadTool: c,
2786
- documentProperties: l,
2787
- scrollModeTool: d,
2788
- rotateTool: f,
2789
- selectionModeTool: m,
2790
- jumpNavigationTool: P,
2791
- printTool: u,
2792
- fullscreenTool: T,
2793
- viewModeTool: C
2794
- } = Ce(), {
2795
- openFileTool: b,
2796
- downloadTool: g,
2797
- documentProperties: S,
2798
- scrollModeTool: v,
2799
- rotateTool: h,
2800
- selectionModeTool: p,
2801
- jumpNavigationTool: s,
2802
- printTool: w,
2803
- fullscreenTool: _,
2804
- viewModeTool: y
2805
- } = Ne(), { localeMessages: x } = me(), [I, R] = q(0), L = k(
2806
- new ResizeObserver((M) => {
2807
- R(M[0].contentRect.height);
2808
- })
2809
- ), N = W(() => P || f || m || d || l || C || r && (i || c || u || T), [
2810
- i,
2811
- c,
2812
- u,
2813
- T,
2814
- l,
2815
- d,
2816
- f,
2817
- m,
2818
- P,
2819
- r
2820
- ]), F = W(() => s || h || p || v || S || y || r && (b || g || w || _), [
2821
- b,
2822
- g,
2823
- w,
2824
- _,
2825
- S,
2826
- v,
2827
- h,
2828
- p,
2829
- s,
2830
- r
2831
- ]);
2832
- return z(() => (o && L.current.observe(o), () => {
2833
- L.current.disconnect();
2834
- }), [o]), !N || !F ? null : /* @__PURE__ */ $(fe, { children: [
2835
- /* @__PURE__ */ a(
2836
- dn,
2837
- {
2838
- container: n,
2839
- onOpenChange: e,
2840
- triggerComponent: /* @__PURE__ */ a("div", { role: "button", children: /* @__PURE__ */ a(Q, { content: x == null ? void 0 : x.moreOptionTooltip, children: /* @__PURE__ */ a(we, { active: t, "aria-label": x == null ? void 0 : x.moreOptionTooltip, children: /* @__PURE__ */ a(uo, {}) }) }) }),
2841
- side: "bottom",
2842
- avoidCollisions: !1,
2843
- children: /* @__PURE__ */ $(
2844
- "div",
2845
- {
2846
- style: { maxHeight: `${I}px`, overflow: "auto" },
2847
- className: Ai["rp-other-tool-content"],
2848
- "data-rp": "moreOptionsDropdown",
2849
- children: [
2850
- r && /* @__PURE__ */ $(hn, { children: [
2851
- /* @__PURE__ */ a(pn, {}),
2852
- /* @__PURE__ */ a(Bn, {}),
2853
- /* @__PURE__ */ a(Zn, {}),
2854
- /* @__PURE__ */ a(fn, {}),
2855
- /* @__PURE__ */ a(un, {})
2856
- ] }),
2857
- /* @__PURE__ */ a(Ui, {}),
2858
- /* @__PURE__ */ a(yo, {}),
2859
- /* @__PURE__ */ a(Lo, {}),
2860
- /* @__PURE__ */ a(So, {}),
2861
- /* @__PURE__ */ a(Io, {}),
2862
- /* @__PURE__ */ a(Po, {})
2863
- ]
2864
- }
2865
- )
2866
- }
2867
- ),
2868
- /* @__PURE__ */ a(Di, {})
2869
- ] });
2870
- }, Bi = () => {
2871
- const { isSmallScreen: t } = Oe();
2872
- return /* @__PURE__ */ $(fe, { children: [
2873
- /* @__PURE__ */ a(lo, {}),
2874
- !t && /* @__PURE__ */ $(fe, { children: [
2875
- /* @__PURE__ */ a(pn, {}),
2876
- /* @__PURE__ */ a(Bn, {}),
2877
- /* @__PURE__ */ a(Zn, {}),
2878
- /* @__PURE__ */ a(fn, {})
2879
- ] }),
2880
- /* @__PURE__ */ a(Vi, {})
2881
- ] });
2882
- }, tn = () => {
2883
- const { totalMatches: t, nextMatch: e, prevMatch: n } = St(), { localeMessages: o } = me();
2884
- return /* @__PURE__ */ $(fe, { children: [
2885
- /* @__PURE__ */ a(
2886
- Q,
2887
- {
2888
- content: o == null ? void 0 : o.searchPrevTooltip,
2889
- className: te["rp-search-tool-result-navigator"],
2890
- children: /* @__PURE__ */ a(we, { tabIndex: 0, onClick: n, "aria-label": o == null ? void 0 : o.searchPrevTooltip, children: /* @__PURE__ */ a(
2891
- Xe,
2892
- {
2893
- className: te["rp-search-tool-input-icon"],
2894
- "aria-disabled": !t
2895
- }
2896
- ) })
2897
- }
2898
- ),
2899
- /* @__PURE__ */ a(
2900
- Q,
2901
- {
2902
- content: o == null ? void 0 : o.searchNextTooltip,
2903
- className: te["rp-search-tool-result-navigator"],
2904
- children: /* @__PURE__ */ a(we, { tabIndex: 0, onClick: e, "aria-label": o == null ? void 0 : o.searchNextTooltip, children: /* @__PURE__ */ a(
2905
- Xe,
2906
- {
2907
- style: { transform: "rotate(180deg" },
2908
- className: te["rp-search-tool-input-icon"],
2909
- "aria-disabled": !t
2910
- }
2911
- ) })
2912
- }
2913
- )
2914
- ] });
2915
- }, ji = () => {
2916
- const { searchIcon: t } = Pe(), { searchIcon: e } = Te();
2917
- return t || e || /* @__PURE__ */ a(gn, {});
2918
- }, Ki = ({ icon: t }) => {
2919
- const { container: e } = be(), [n, o] = q(!1), { pdf: r } = re(), [i, c] = q(null), {
2920
- searchOptions: l,
2921
- setSearchOptions: d,
2922
- loading: f,
2923
- setSearch: m,
2924
- totalMatches: P,
2925
- currentMatchPosition: u,
2926
- nextMatch: T,
2927
- prevMatch: C,
2928
- search: b
2929
- } = St(), { searchTool: g = !0 } = Ce(), { searchTool: S = !0 } = Ne(), [v, h] = q(b), { localeMessages: p } = me(), { isSmallScreen: s } = Oe(), [w, _] = q(null), [y, x] = q(!1), I = E(() => {
2930
- o(!0);
2931
- }, []), R = E(() => {
2932
- m(""), h(""), o(!1);
2933
- }, [m]), L = (G) => {
2934
- const K = G.key === "Enter", Y = G.key === " ";
2935
- (K || Y) && R();
2936
- }, N = E(
2937
- (G) => {
2938
- G.key === "Escape" && n && R();
2939
- },
2940
- [n]
2941
- ), F = E(
2942
- (G) => {
2943
- G.shiftKey && G.key === "Enter" ? C() : G.key === "Enter" && b !== v ? m(v) : G.key === "Enter" && T();
2944
- },
2945
- [v, C, T, m, b]
2946
- );
2947
- z(() => {
2948
- h(b);
2949
- }, [b]), z(() => {
2950
- b && r && x(!0);
2951
- }, [b, r]), z(() => {
2952
- b && b.trim() !== "" && (h(b), m(b));
2953
- }, []), z(() => (window.addEventListener("keydown", N), () => {
2954
- window.removeEventListener("keydown", N);
2955
- }), [N]), z(() => {
2956
- i && setTimeout(() => {
2957
- i.focus();
2958
- }, 0);
2959
- }, [i]);
2960
- const M = E((G) => {
2961
- h(G.target.value);
2962
- }, []), D = E(() => {
2963
- h(""), m("");
2964
- }, [m]), O = W(() => `${u} / ${P}`, [u, P]), { wholeWords: A, matchCase: H } = W(() => l, [l]), U = E(
2965
- (G) => {
2966
- d((K) => ({ ...K, matchCase: G }));
2967
- },
2968
- [d]
2969
- ), B = E(
2970
- (G) => {
2971
- d((K) => ({ ...K, wholeWords: G }));
2972
- },
2973
- [d]
2974
- );
2975
- z(() => {
2976
- r && y && R();
2977
- }, [r, R]);
2978
- const V = W(() => (w == null ? void 0 : w.querySelectorAll('[tabindex]:not([tabindex="-1"])')) || [], [w]), J = E(
2979
- (G) => {
2980
- if (G.key === "Tab") {
2981
- const K = document.activeElement;
2982
- let Y = 0;
2983
- V.forEach((ie, se) => {
2984
- ie === K && (Y = se);
2985
- });
2986
- let ee = Y + 1;
2987
- G.shiftKey && (ee = Y - 1);
2988
- const oe = V[ee];
2989
- if (oe)
2990
- oe.focus();
2991
- else if (ee > V.length - 1) {
2992
- const ie = V[0];
2993
- ie && ie.focus();
2994
- } else {
2995
- const ie = V[V.length - 1];
2996
- ie && ie.focus();
2997
- }
2998
- }
2999
- },
3000
- [V]
3001
- );
3002
- return !g || !S ? null : /* @__PURE__ */ a(fe, { children: /* @__PURE__ */ a(
3003
- dn,
3004
- {
3005
- open: n,
3006
- container: e,
3007
- side: "bottom",
3008
- align: "start",
3009
- tabIndex: 0,
3010
- avoidCollisions: !1,
3011
- triggerComponent: /* @__PURE__ */ a(Q, { content: p == null ? void 0 : p.searchButtonTooltip, children: /* @__PURE__ */ a(
3012
- we,
3013
- {
3014
- active: n,
3015
- onClick: I,
3016
- "aria-label": p == null ? void 0 : p.searchButtonTooltip,
3017
- children: t || /* @__PURE__ */ a(ji, {})
3018
- }
3019
- ) }),
3020
- children: /* @__PURE__ */ $(
3021
- "div",
3022
- {
3023
- ref: _,
3024
- className: te["rp-search-tool-content"],
3025
- tabIndex: 0,
3026
- onKeyDown: J,
3027
- children: [
3028
- /* @__PURE__ */ $("div", { className: te["rp-search-tool-input-wrapper"], children: [
3029
- /* @__PURE__ */ $("div", { className: te["rp-search-tool-input"], children: [
3030
- /* @__PURE__ */ a(Q, { content: p == null ? void 0 : p.searchInputTooltip, children: /* @__PURE__ */ a(
3031
- an,
3032
- {
3033
- value: v,
3034
- onKeyDown: F,
3035
- onChange: M,
3036
- icon: /* @__PURE__ */ a(gn, {}),
3037
- placeholder: p == null ? void 0 : p.searchInputPlaceholder,
3038
- className: te["rp-search-input"],
3039
- ref: c,
3040
- id: "search-input",
3041
- name: "search-input",
3042
- tabIndex: 0,
3043
- children: !!v && /* @__PURE__ */ a("span", { className: te["rp-search-tool-input-clear"], onClick: D, children: /* @__PURE__ */ a(No, {}) })
3044
- }
3045
- ) }),
3046
- f ? /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(ln, { className: te["rp-search-loader-icon"] }) }) : /* @__PURE__ */ a("span", { children: O }),
3047
- s && /* @__PURE__ */ a("div", { className: te["rp-search-tool-controls"], children: /* @__PURE__ */ a(At, { onKeyPress: L, handleClose: R }) })
3048
- ] }),
3049
- /* @__PURE__ */ $("div", { className: te["rp-search-tool-input-checkboxes"], children: [
3050
- s && /* @__PURE__ */ a(tn, {}),
3051
- /* @__PURE__ */ a(
3052
- zt,
3053
- {
3054
- tabIndex: 0,
3055
- name: "matchCase",
3056
- value: H,
3057
- onChange: U,
3058
- children: p == null ? void 0 : p.searchMatchCaseLabel
3059
- }
3060
- ),
3061
- !s && /* @__PURE__ */ a(Q, { content: p == null ? void 0 : p.searchMatchCaseTooltip, children: /* @__PURE__ */ a("div", { className: te["rp-search-icon-info"], tabIndex: 0, children: /* @__PURE__ */ a(Wt, {}) }) }),
3062
- /* @__PURE__ */ a(
3063
- zt,
3064
- {
3065
- tabIndex: 0,
3066
- name: "wholeWord",
3067
- value: A,
3068
- onChange: B,
3069
- children: p == null ? void 0 : p.searchWholeWordsLabel
3070
- }
3071
- ),
3072
- !s && /* @__PURE__ */ a(Q, { content: p == null ? void 0 : p.searchWholeWordsTooltip, children: /* @__PURE__ */ a("div", { tabIndex: 0, className: te["rp-search-icon-info"], children: /* @__PURE__ */ a(Wt, {}) }) })
3073
- ] })
3074
- ] }),
3075
- !s && /* @__PURE__ */ $("div", { className: te["rp-search-tool-controls"], children: [
3076
- /* @__PURE__ */ a(tn, {}),
3077
- /* @__PURE__ */ a(At, { onKeyPress: L, handleClose: R })
3078
- ] })
3079
- ]
3080
- }
3081
- )
3082
- }
3083
- ) });
3084
- }, Zi = "_loading_wazy2_1", Ae = {
3085
- "rp-loading-overlay": "_rp-loading-overlay_wazy2_1",
3086
- "rp-loading-modal": "_rp-loading-modal_wazy2_14",
3087
- "rp-loading-title": "_rp-loading-title_wazy2_27",
3088
- "rp-loading-progress-bar": "_rp-loading-progress-bar_wazy2_35",
3089
- "rp-loading-progress": "_rp-loading-progress_wazy2_35",
3090
- "rp-loading-cancel-button": "_rp-loading-cancel-button_wazy2_55",
3091
- loading: Zi
3092
- }, Xi = ({ percentage: t }) => {
3093
- const { cancel: e } = nt(), { localeMessages: n } = me();
3094
- return t < 1 ? null : /* @__PURE__ */ a("div", { className: de(Ae["rp-loading-overlay"]), children: /* @__PURE__ */ $("div", { className: de(Ae["rp-loading-modal"]), children: [
3095
- /* @__PURE__ */ $("div", { className: de(Ae["rp-loading-title"]), children: [
3096
- n == null ? void 0 : n.printLoadingMessage,
3097
- "..."
3098
- ] }),
3099
- /* @__PURE__ */ a("div", { className: de(Ae["rp-loading-progress-bar"]), children: /* @__PURE__ */ a(
3100
- "div",
3101
- {
3102
- className: de(Ae["rp-loading-progress"]),
3103
- style: { width: `${t}%` }
3104
- }
3105
- ) }),
3106
- /* @__PURE__ */ a("button", { className: de(Ae["rp-loading-cancel-button"]), onClick: e, children: n == null ? void 0 : n.printCancelLabel })
3107
- ] }) });
3108
- }, Qi = tt((t, e) => {
3109
- const { showPrintProgress: n = !0 } = Ce(), { showPrintProgress: o = !0 } = Ne(), { progress: r } = nt(), { isSmallScreen: i } = Oe(), { percentage: c } = r || {}, l = () => i ? { gridTemplateColumns: "25% 60% 15%" } : void 0, d = () => {
3110
- if (!(!n || !o || !c))
3111
- return /* @__PURE__ */ a(Xi, { percentage: c });
3112
- };
3113
- return /* @__PURE__ */ $("div", { children: [
3114
- /* @__PURE__ */ a("div", { "data-rp": "topBar", ref: e, className: We["rp-toolbar-content"], children: /* @__PURE__ */ $("div", { className: We["rp-toolbar-wrapper"], style: l(), children: [
3115
- /* @__PURE__ */ $("div", { "data-rp": "topBarLeft", className: We["rp-toolbar-start"], children: [
3116
- /* @__PURE__ */ a(Ki, {}),
3117
- /* @__PURE__ */ a(mi, {})
3118
- ] }),
3119
- /* @__PURE__ */ a("div", { "data-rp": "topBarCenter", className: We["rp-toolbar-middle"], children: /* @__PURE__ */ a(Eo, {}) }),
3120
- /* @__PURE__ */ a("div", { "data-rp": "topBarRight", className: We["rp-toolbar-end"], children: /* @__PURE__ */ a(Bi, {}) })
3121
- ] }) }),
3122
- /* @__PURE__ */ a(d, {})
3123
- ] });
3124
- }), ft = {
3125
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_1bqgz_1",
3126
- "rp-sidebar-content": "_rp-sidebar-content_1bqgz_1",
3127
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_1bqgz_16"
3128
- }, He = {
3129
- "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
3130
- "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
3131
- "rp-thumbnail": "_rp-thumbnail_3fenb_1",
3132
- "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
3133
- "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
3134
- }, Yi = (t) => {
3135
- const { pageNumber: e, isFocused: n, viewport: o } = t, { goToPage: r } = pe(), { pageRotate: i } = et(), c = k(null), l = yn(), { pages: d } = re(), [f, m] = q(null), P = k(!1), u = k(), T = W(() => n ? He["rp-thumbnail-active"] : "", [n]), C = W(() => ({
3136
- width: Math.round(o.width),
3137
- height: Math.round(o.height)
3138
- }), [o]), b = E(() => {
3139
- e && r(e);
3140
- }, [r, e]);
3141
- return z(() => {
3142
- const g = d.get(e);
3143
- u.current === g || (m(null), u.current = g);
3144
- }, [d, e]), z(() => {
3145
- const g = d.get(e);
3146
- if (!c.current || !e || !g || f)
3147
- return;
3148
- const S = new IntersectionObserver((v) => {
3149
- v.forEach((h) => {
3150
- if (P.current) {
3151
- P.current = !1, l.removeQueue(`thumbnail-${e}`);
3152
- return;
3153
- }
3154
- if (h.isIntersecting) {
3155
- const p = document.createElement("canvas");
3156
- P.current = !0, l.enqueue(
3157
- `thumbnail-${e}`,
3158
- {
3159
- page: g.page,
3160
- canvasElem: p,
3161
- options: {
3162
- scale: 1
3163
- },
3164
- onLoaded: () => {
3165
- p.toBlob((s) => {
3166
- if (!s)
3167
- return;
3168
- const w = URL.createObjectURL(s);
3169
- m(w);
3170
- });
3171
- }
3172
- },
3173
- 2
3174
- );
3175
- }
3176
- });
3177
- });
3178
- return c.current && S.observe(c.current), () => {
3179
- S.disconnect(), l.removeQueue(`thumbnail-${e}`);
3180
- };
3181
- }, [l, e, d, f]), /* @__PURE__ */ $(
3182
- "div",
3183
- {
3184
- onClick: b,
3185
- id: `page-${e}`,
3186
- className: He["rp-thumbnail-wrapper"],
3187
- ref: c,
3188
- children: [
3189
- /* @__PURE__ */ a(
3190
- "div",
3191
- {
3192
- style: {
3193
- transform: `rotate(${i[e || 0]}deg)`
3194
- },
3195
- className: de(T, He["rp-thumbnail"]),
3196
- children: f ? /* @__PURE__ */ a(
3197
- "img",
3198
- {
3199
- src: f,
3200
- width: C.width,
3201
- height: C.height,
3202
- alt: "thumbnail"
3203
- }
3204
- ) : /* @__PURE__ */ a(
3205
- "div",
3206
- {
3207
- className: He["rp-thumbnail-loader"],
3208
- style: {
3209
- width: `${C.width}px`,
3210
- height: `${C.height}px`
3211
- },
3212
- children: /* @__PURE__ */ a(ln, {})
3213
- }
3214
- )
3215
- }
3216
- ),
3217
- /* @__PURE__ */ a("div", { className: He["rp-thumbnail-text"], children: e })
3218
- ]
3219
- }
3220
- );
3221
- }, nn = {
3222
- "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
3223
- "rp-thumbnails": "_rp-thumbnails_16vqr_1"
3224
- }, Ji = 16, ea = (t, e) => {
3225
- const n = t == null ? void 0 : t.querySelector(`#page-${e}`);
3226
- t && (n != null && n.offsetTop) && (t.scrollTop = (n == null ? void 0 : n.offsetTop) - Ji);
3227
- }, ta = tt((t, e) => {
3228
- const { show: n, width: o } = t, { focusedPage: r, totalPages: i } = pe(), { thumbnailPages: c, addPage: l, thumbnailLength: d, addToPage: f } = Tn(), m = k(null), P = k(1);
3229
- rn(e, () => m.current);
3230
- const u = W(() => Object.values(c), [c]), T = E(() => {
3231
- const C = d + 1;
3232
- C <= i && l(C);
3233
- }, [l, i, d]);
3234
- return z(() => {
3235
- r > d && i > d ? f(r) : n && P.current !== r && (ea(m.current, r), P.current = r);
3236
- }, [r, d, f, n, u]), Fr(m.current, T), /* @__PURE__ */ a("div", { ref: m, className: nn["rp-thumbnails-container"], style: { width: o }, children: /* @__PURE__ */ a("div", { className: nn["rp-thumbnails"], children: n ? u.map((C, b) => {
3237
- var g, S;
3238
- return /* @__PURE__ */ a(
3239
- Yi,
3240
- {
3241
- isFocused: r === ((g = C.page) == null ? void 0 : g.pageNumber),
3242
- pageNumber: (S = C.page) == null ? void 0 : S.pageNumber,
3243
- loading: C.loading,
3244
- viewport: C.viewport,
3245
- defaultRotation: C.defaultRotation
3246
- },
3247
- b
3248
- );
3249
- }) : null }) });
3250
- }), na = () => {
3251
- const { thumbnailIcon: t } = Pe(), { thumbnailIcon: e } = Te();
3252
- return t || e || /* @__PURE__ */ a(Ir, {});
3253
- }, ra = () => {
3254
- const { active: t, setActive: e } = Tn(), [n, o] = q(kr), r = k(null), i = k(null), { thumbnailTool: c, sidebarEnable: l } = Ce(), { localeMessages: d } = me(), f = E(() => {
3255
- e((P) => !P);
3256
- }, []), m = W(() => typeof c != "boolean" && c ? /* @__PURE__ */ a(c, { onClick: f, active: t }) : c ? /* @__PURE__ */ a(Q, { content: d == null ? void 0 : d.thumbnailTooltip, children: /* @__PURE__ */ a(
3257
- we,
3258
- {
3259
- onClick: f,
3260
- active: t,
3261
- "aria-label": d == null ? void 0 : d.thumbnailTooltip,
3262
- children: /* @__PURE__ */ a(na, {})
3263
- }
3264
- ) }) : null, [c, t, f, d]);
3265
- return /* @__PURE__ */ a(fe, { children: l && /* @__PURE__ */ $(
3266
- "div",
3267
- {
3268
- style: { "--rp-thumbnail-width": `${n}px` },
3269
- className: ft["rp-sidebar-content-wrapper"],
3270
- "data-rp": "sidebar",
3271
- children: [
3272
- /* @__PURE__ */ a("div", { ref: i, className: ft["rp-sidebar-content"], children: m }),
3273
- /* @__PURE__ */ $(
3274
- "div",
3275
- {
3276
- "data-rp": "thumbnailSidebar",
3277
- hidden: !t,
3278
- className: ft["rp-thumbnails-wrapper"],
3279
- children: [
3280
- /* @__PURE__ */ a(ta, { show: t, ref: r }),
3281
- /* @__PURE__ */ a(
3282
- Er,
3283
- {
3284
- onWidthChange: o,
3285
- thumbnailRef: r,
3286
- leftSidebarRef: i
3287
- }
3288
- )
3289
- ]
3290
- }
3291
- )
3292
- ]
3293
- }
3294
- ) });
3295
- }, ac = ar((t, e) => {
3296
- const {
3297
- children: n,
3298
- slots: o,
3299
- icons: r,
3300
- style: i,
3301
- className: c,
3302
- mobileWidth: l,
3303
- onLoaded: d,
3304
- cleanupOnLoaded: f,
3305
- onLayoutWidthChange: m
3306
- } = t, [P, u] = q(null), { setContainer: T, setContentRef: C } = be(), { loading: b } = re(), { LoaderImageComponent: g } = bt();
3307
- return z(() => (d && d(), () => {
3308
- f && f();
3309
- }), [d, f]), // TODO: deprecated in v2.0.0, remove later ~
3310
- /* @__PURE__ */ a(Rn, { toolbarRef: P, ref: e, children: /* @__PURE__ */ a(Rr, { mobileWidth: l, onLayoutWidthChange: m, children: /* @__PURE__ */ a(Lr, { slots: o, children: /* @__PURE__ */ a(zr, { icons: r, children: /* @__PURE__ */ $(xr, { getContainerRef: T, style: i, className: c, children: [
3311
- /* @__PURE__ */ $(Nr, { children: [
3312
- /* @__PURE__ */ $("div", { className: _e["rp-layout"], children: [
3313
- /* @__PURE__ */ a(
3314
- Qi,
3315
- {
3316
- ref: u
3317
- }
3318
- ),
3319
- /* @__PURE__ */ $("div", { className: _e["rp-content"], children: [
3320
- /* @__PURE__ */ a("div", { className: _e["rp-sidebar"], children: /* @__PURE__ */ a(ra, {}) }),
3321
- /* @__PURE__ */ a("div", { ref: C, className: _e["rp-pages"], children: n })
3322
- ] })
3323
- ] }),
3324
- /* @__PURE__ */ a(Ar, {})
3325
- ] }),
3326
- b ? /* @__PURE__ */ a(
3327
- "div",
3328
- {
3329
- className: _e["rp-loader"],
3330
- style: {
3331
- position: "absolute",
3332
- top: 0,
3333
- left: 0,
3334
- right: 0,
3335
- bottom: 0,
3336
- width: "100%",
3337
- height: "100%"
3338
- },
3339
- children: /* @__PURE__ */ a(
3340
- "div",
3341
- {
3342
- style: {
3343
- display: "flex",
3344
- justifyContent: "center",
3345
- alignItems: "center",
3346
- height: "100%",
3347
- width: "100%"
3348
- },
3349
- children: g && /* @__PURE__ */ a(g, {})
3350
- }
3351
- )
3352
- }
3353
- ) : null
3354
- ] }) }) }) }) });
3355
- }), sc = {
3356
- "rp-toolbar-layout": "_rp-toolbar-layout_vwobs_1",
3357
- "rp-content": "_rp-content_vwobs_7",
3358
- "rp-topbar-content": "_rp-topbar-content_vwobs_13",
3359
- "rp-sidebar-content": "_rp-sidebar-content_vwobs_22",
3360
- "rp-pages": "_rp-pages_vwobs_32",
3361
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_vwobs_37"
3362
- };
3363
- export {
3364
- Cn as A,
3365
- Pn as B,
3366
- yn as C,
3367
- Di as D,
3368
- Mo as E,
3369
- Wo as F,
3370
- qo as G,
3371
- Uo as H,
3372
- It as I,
3373
- ai as J,
3374
- li as K,
3375
- Rn as L,
3376
- di as M,
3377
- ui as N,
3378
- Bn as O,
3379
- Ys as P,
3380
- Zn as Q,
3381
- rc as R,
3382
- Ki as S,
3383
- ec as T,
3384
- Ui as U,
3385
- Vi as V,
3386
- tn as W,
3387
- Qi as X,
3388
- Yi as Y,
3389
- ra as Z,
3390
- ac as a,
3391
- Gn as b,
3392
- nt as c,
3393
- St as d,
3394
- tc as e,
3395
- nc as f,
3396
- Js as g,
3397
- Tn as h,
3398
- ht as i,
3399
- We as j,
3400
- mi as k,
3401
- Bi as l,
3402
- sc as m,
3403
- ta as n,
3404
- Xi as o,
3405
- Ai as p,
3406
- $i as q,
3407
- vn as r,
3408
- Oo as s,
3409
- wn as t,
3410
- pe as u,
3411
- Do as v,
3412
- _n as w,
3413
- Ao as x,
3414
- bn as y,
3415
- zo as z
3416
- };