@pdf-viewer/react 1.9.0-beta.1 → 1.9.0-beta.2

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