@pdf-viewer/react 1.9.0-beta.5 → 1.9.0-beta.7

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 (104) hide show
  1. package/dist/SearchCloseButton-cbf182aa.js +33 -0
  2. package/dist/ToolbarLayout.module-201969d2.js +3453 -0
  3. package/dist/assets/ToolbarLayout.css +1 -1
  4. package/dist/components/RPController.js +36 -36
  5. package/dist/components/RPDropFileZone.js +23 -21
  6. package/dist/components/RPPages.js +17 -18
  7. package/dist/components/RPProvider.js +14 -15
  8. package/dist/components/layout/Container.js +11 -10
  9. package/dist/components/layout/LayoutContainer.js +15 -16
  10. package/dist/components/layout/RPDefaultLayout.js +14 -76
  11. package/dist/components/layout/RPLayout.js +22 -22
  12. package/dist/components/layout/WrapperLayout.js +8 -7
  13. package/dist/components/layout/sidebar/RPSidebar.js +12 -51
  14. package/dist/components/layout/sidebar/RPSplitter.js +9 -7
  15. package/dist/components/layout/sidebar/Thumbnail.js +48 -2
  16. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  17. package/dist/components/layout/toolbar/DocumentDialog.js +24 -305
  18. package/dist/components/layout/toolbar/FileDownloadTool.js +13 -23
  19. package/dist/components/layout/toolbar/MenuItem.js +7 -6
  20. package/dist/components/layout/toolbar/MenuSeparator.js +5 -4
  21. package/dist/components/layout/toolbar/MostPageTool.js +25 -50
  22. package/dist/components/layout/toolbar/OtherTool.js +22 -115
  23. package/dist/components/layout/toolbar/Paginate.js +17 -99
  24. package/dist/components/layout/toolbar/PrintTool.js +13 -43
  25. package/dist/components/layout/toolbar/PropertyItem.js +8 -5
  26. package/dist/components/layout/toolbar/RPToolbar.js +7 -28
  27. package/dist/components/layout/toolbar/RPToolbarEnd.js +7 -22
  28. package/dist/components/layout/toolbar/RotateTool.js +21 -20
  29. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  30. package/dist/components/layout/toolbar/SearchCloseButton.js +7 -19
  31. package/dist/components/layout/toolbar/SearchResultNavigator.js +8 -42
  32. package/dist/components/layout/toolbar/SearchTool.js +30 -197
  33. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  34. package/dist/components/layout/toolbar/ThumbnailTool.js +4 -4
  35. package/dist/components/layout/toolbar/ToolbarCustom.js +22 -24
  36. package/dist/components/layout/toolbar/ToolbarDefault.js +20 -25
  37. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  38. package/dist/components/layout/toolbar/ZoomTool.js +28 -140
  39. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
  40. package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
  41. package/dist/components/layout/toolbar/tools/NextPageTool.js +17 -18
  42. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  43. package/dist/components/layout/toolbar/tools/PrintTool.js +3 -3
  44. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  45. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +11 -11
  46. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +20 -26
  47. package/dist/components/page/AnnotationLayer.js +16 -17
  48. package/dist/components/page/CanvasLayer.js +16 -18
  49. package/dist/components/page/DualPage.js +1 -1
  50. package/dist/components/page/RPPage.js +16 -17
  51. package/dist/components/page/SinglePage.js +1 -1
  52. package/dist/components/page/TextHighlightLayer.js +16 -17
  53. package/dist/components/page/TextLayer.js +16 -17
  54. package/dist/components/ui/Checkbox.js +51 -49
  55. package/dist/components/ui/DropDown.js +19 -13
  56. package/dist/components/ui/LoadingIndicator.js +5 -22
  57. package/dist/components/ui/RPTooltip.js +192 -405
  58. package/dist/contexts/ElementPageContext.js +37 -37
  59. package/dist/contexts/FileInputContext.js +18 -20
  60. package/dist/contexts/PaginationContext.js +1 -1
  61. package/dist/contexts/PrintContext.js +2 -2
  62. package/dist/contexts/RenderQueueProvider.js +10 -0
  63. package/dist/contexts/SearchContext.js +3 -3
  64. package/dist/contexts/ThumbnailsContext.js +1 -1
  65. package/dist/index-18b0454c.js +1657 -0
  66. package/dist/{index-8547fbc6.js → index-5908484b.js} +9 -9
  67. package/dist/index-f4a9ae4d.js +1664 -0
  68. package/dist/main.js +48 -50
  69. package/dist/types/components/layout/RPDefaultLayout.d.ts +1 -2
  70. package/dist/types/components/layout/sidebar/Thumbnail.d.ts +0 -1
  71. package/dist/types/components/layout/toolbar/RPToolbar.d.ts +3 -2
  72. package/dist/types/contexts/RenderQueueProvider.d.ts +16 -0
  73. package/dist/types/utils/Queue.d.ts +18 -0
  74. package/dist/types/utils/renderPage.d.ts +1 -6
  75. package/dist/types/utils/types.d.ts +5 -0
  76. package/dist/utils/Queue.js +47 -0
  77. package/dist/utils/hooks/useFileDownload.js +16 -17
  78. package/dist/utils/hooks/useLicense.js +1 -1
  79. package/dist/utils/hooks/usePageRotateContext.js +14 -14
  80. package/dist/utils/hooks/usePaginate.js +16 -17
  81. package/dist/utils/hooks/usePresentPage.js +16 -17
  82. package/dist/utils/hooks/usePrint.js +16 -17
  83. package/dist/utils/hooks/useScrollToPage.js +16 -17
  84. package/dist/utils/hooks/useSearch.js +16 -17
  85. package/dist/utils/hooks/useThumbnail.js +16 -18
  86. package/dist/utils/hooks/useVirtualReactWindow.js +16 -17
  87. package/package.json +1 -1
  88. package/dist/Checkbox.module-3edaacbb.js +0 -7
  89. package/dist/Combination-da8647d4.js +0 -693
  90. package/dist/Container.module-f8b5c306.js +0 -6
  91. package/dist/DropDown.module-a78567cb.js +0 -11
  92. package/dist/MenuItem.module-bc11d0d3.js +0 -6
  93. package/dist/MenuSeparator.module-89b2ff7f.js +0 -6
  94. package/dist/PropertyItem.module-db0150cc.js +0 -8
  95. package/dist/RPSplitter.module-13d612c4.js +0 -7
  96. package/dist/RPTheme.module-bd9038da.js +0 -8
  97. package/dist/RotateTool.module-03987eba.js +0 -6
  98. package/dist/SearchTool.module-016f3a8d.js +0 -16
  99. package/dist/ToolbarLayout.module-60c3d6e8.js +0 -2434
  100. package/dist/WrapperLayout.module-147bc943.js +0 -6
  101. package/dist/floating-ui.react-dom-f3f380e0.js +0 -1447
  102. package/dist/index-473557b1.js +0 -1191
  103. /package/dist/assets/{RPTheme.css → RPDropFileZone.css} +0 -0
  104. /package/dist/assets/{SearchTool.css → SearchCloseButton.css} +0 -0
@@ -1,2434 +0,0 @@
1
- import { jsx as z, Fragment as vt, jsxs as je } from "react/jsx-runtime";
2
- import { useRef as D, useEffect as F, useCallback as A, useState as q, useMemo as H, createContext as Pe, useContext as Te, useImperativeHandle as wt, createElement as Ce, PureComponent as Wt, Component as Dt, memo as bt } from "react";
3
- import { c as he } from "./clsx-0c6e471a.js";
4
- import { LoaderIcon as Ct } from "./components/icons/LoaderIcon.js";
5
- import { ViewMode as ge, ScrollMode as K, AnnotationSubType as Qe, SelectionMode as kt } from "./utils/types.js";
6
- import { useScrollModeContext as me } from "./contexts/ScrollModeContext.js";
7
- import { useDocumentContext as J } from "./contexts/RPDocumentContext.js";
8
- import { useDocumentPasswordContext as Ht } from "./contexts/DocumentPasswordContext.js";
9
- import { useDarkModeContext as $t } from "./contexts/DarkModeContext.js";
10
- import "./contexts/RotationContext.js";
11
- import { useLayerContext as qt } from "./contexts/LayerContext.js";
12
- import { useZoomContext as Be } from "./contexts/ZoomContext.js";
13
- import { useViewModeContext as we } from "./contexts/ViewModeContext.js";
14
- import { useVirtualScrollContext as Re } from "./contexts/VirtualScrollContext.js";
15
- import { useVirtualGridContext as St } from "./contexts/VirtualGridContext.js";
16
- import { useSelectionModeContext as Gt } from "./contexts/SelectionModeContext.js";
17
- import { useInitialStateContext as Vt } from "./contexts/InitialStateContext.js";
18
- import { useFullScreenContext as Ut } from "./contexts/FullScreenContext.js";
19
- import "./contexts/FileInputContext.js";
20
- import "./contexts/DropFileZoneContext.js";
21
- import { renderPage as $e } from "./utils/renderPage.js";
22
- import { findMatches as jt, resetDivs as Bt, highlightMatches as Zt, isMatchEntireWord as Xt } from "./utils/highlight.js";
23
- import { useLayoutContainer as Ie } from "./contexts/LayoutContainerContext.js";
24
- import { useDimensionPagesContext as be } from "./contexts/DimensionPagesContext.js";
25
- import "./contexts/LocalizationContext.js";
26
- import { useHighlightContext as Kt } from "./contexts/HighlightContext.js";
27
- import "./contexts/LicenseContext.js";
28
- import { useDownloadContext as Yt } from "./contexts/DownloadContext.js";
29
- import { useSmoothScrollContext as xt } from "./contexts/SmoothScrollContext.js";
30
- import "./contexts/ElementPageContext.js";
31
- import { usePagesRotateContext as Le } from "./contexts/PagesRotateContext.js";
32
- import { useLoaderContext as Jt } from "./contexts/LoaderContext.js";
33
- import "./contexts/ToolComponentContext.js";
34
- import "./contexts/IconToolContext.js";
35
- import "./contexts/OtherToolContext.js";
36
- import { useThemeContext as Qt } from "./contexts/ThemeContext.js";
37
- import "./components/RPConfig.js";
38
- import "./components/ui/Button.js";
39
- import "./components/ui/Input.js";
40
- import "./contexts/IconContext.js";
41
- import "./contexts/ToolbarComponentContext.js";
42
- import "./contexts/ViewportContext.js";
43
- import "./components/ui/RPTooltip.js";
44
- import "./MenuItem.module-bc11d0d3.js";
45
- import "./DropDown.module-a78567cb.js";
46
- import "./utils/dateFormatter.js";
47
- import "./PropertyItem.module-db0150cc.js";
48
- import "./MenuSeparator.module-89b2ff7f.js";
49
- import "./RotateTool.module-03987eba.js";
50
- import "./SearchTool.module-016f3a8d.js";
51
- import "./Checkbox.module-3edaacbb.js";
52
- import { useInfiniteScroll as en } from "./utils/hooks/useInfiniteScroll.js";
53
- import { withRef as Ze } from "./utils/withRef.js";
54
- import "./RPSplitter.module-13d612c4.js";
55
- import "./Container.module-f8b5c306.js";
56
- import "./WrapperLayout.module-147bc943.js";
57
- import "./RPTheme.module-bd9038da.js";
58
- import * as tn from "pdfjs-dist";
59
- import { PixelsPerInch as nn, AnnotationMode as rn, RenderingCancelledException as on, AnnotationLayer as sn } from "pdfjs-dist";
60
- import { SimpleLinkService as an } from "./utils/link_service.js";
61
- import { annotationsEvents as cn, annotationEventsHandler as ln, handleClick as et, handleAnnotationWidget as un, handleAnnotationLink as dn, bindLayerEvents as pn, unbindLayerEvents as tt } from "./utils/annotations.js";
62
- import { normalizeSingleKeyword as hn, sortHighlightPosition as fn, unwrap as gn } from "./components/page/searchHighlight.js";
63
- import { CustomElement as mn } from "./components/page/CustomElement.js";
64
- import { useMousePressed as _n } from "./utils/hooks/useMousePressed.js";
65
- import { useGrabScroll as vn } from "./utils/hooks/useGrabScroll.js";
66
- import { usePinch as wn } from "./utils/hooks/usePinch.js";
67
- import { useDebounce as Xe } from "./utils/hooks/useDebounce.js";
68
- import bn from "./components/ui/PasswordModal.js";
69
- import { getPositionFromPage as Cn, getPageFromPosition as Sn } from "./utils/calculatePage.js";
70
- import { getScrollDistance as fe } from "./utils/getScrollDistance.js";
71
- import { getWordPositionInPage as xn } from "./utils/getWordPositionInPage.js";
72
- import { getThumbnailViewport as nt } from "./utils/getThumbnailViewport.js";
73
- import { smoothScrollTo as Ne } from "./utils/smoothScrollTo.js";
74
- import { appConsole as yn } from "./utils/appConsole.js";
75
- import './assets/ToolbarLayout.css';const yt = () => {
76
- const { viewMode: n } = we(), { scrollMode: t } = me(), { virtualScrollRef: e, virtualScrollableElementRef: o, pageScrollElementRef: s } = Re(), { setFocusedPage: i } = oe(), c = D(), { columnCount: a } = St(), { widths: d, heights: f } = be(), g = D(t), w = D(n), l = D(a), { targetScrollPage: _ } = xt();
77
- F(() => {
78
- e != null && e.scrollToItem && (c.current = e);
79
- }, [e]), F(() => {
80
- g.current = t, w.current = n;
81
- }, [t, n]);
82
- const b = A(
83
- (C, x) => {
84
- if (!s)
85
- return;
86
- const h = Math.ceil(C / 2) * 2 - 1;
87
- if (C === h + 1) {
88
- const p = {
89
- left: d[h],
90
- top: 0
91
- };
92
- return new Promise(
93
- (r) => Ne(s, p, r)
94
- );
95
- }
96
- const u = {
97
- left: 0,
98
- top: 0
99
- };
100
- return s == null ? void 0 : s.scrollTo({
101
- ...u,
102
- behavior: x
103
- });
104
- },
105
- [s, d, Ne]
106
- );
107
- return F(() => {
108
- g.current = t, w.current = n;
109
- }, [t, n]), F(() => {
110
- l.current = a;
111
- }, [a]), { scrollToPage: A(
112
- (C, x = "smooth") => {
113
- i(C);
114
- const h = C - 1;
115
- let u = h, p = 0;
116
- if (w.current === ge.DUAL_PAGE && g.current === K.PAGE_SCROLLING) {
117
- b(C, x);
118
- return;
119
- }
120
- if (g.current === K.PAGE_SCROLLING) {
121
- i(C);
122
- return;
123
- }
124
- if (!c.current || !o)
125
- return;
126
- const r = o;
127
- if (_.current = C, g.current === K.HORIZONTAL_SCROLLING) {
128
- p = h;
129
- const S = {
130
- left: fe(d, p),
131
- top: 0
132
- };
133
- return r.scrollTo({
134
- ...S,
135
- behavior: x
136
- });
137
- }
138
- if (w.current === ge.DUAL_PAGE) {
139
- p = h % 2, u = Math.floor(h / 2);
140
- const S = {
141
- left: fe(d, p),
142
- top: fe(f, u)
143
- };
144
- return r.scrollTo({
145
- ...S,
146
- behavior: x
147
- });
148
- }
149
- const v = {
150
- left: 0,
151
- top: fe(f, u)
152
- };
153
- return r.scrollTo({
154
- ...v,
155
- behavior: x
156
- });
157
- },
158
- [
159
- o,
160
- a,
161
- b,
162
- i,
163
- Ne,
164
- f,
165
- d
166
- ]
167
- ) };
168
- }, Pn = (n = 1) => {
169
- const [t, e] = q(n), [o, s] = q(0), { scrollToPage: i } = yt(), c = D(1), { viewMode: a } = we(), { scrollMode: d } = me(), { widths: f } = be(), { pagesRef: g } = Ie(), w = Xe(t, 100), l = A(
170
- (u) => {
171
- if (!/^[0-9]*$/g.test(u.toString()) || !u)
172
- return { success: !1, currentPage: c.current };
173
- const r = +u;
174
- return r < 0 || r > o ? { success: !1, currentPage: c.current } : (e(r), c.current = r, { success: !0, currentPage: +u });
175
- },
176
- [o]
177
- ), _ = A(l, [l]), b = A(
178
- (u) => {
179
- const p = l(u);
180
- return p.success && i(p.currentPage), p;
181
- },
182
- [l, i]
183
- ), P = A((u) => {
184
- const p = u % 2 === 1;
185
- if (!g || p)
186
- return !1;
187
- const r = p ? f[u] : f[u - 1], v = p ? f[u + 1] : f[u];
188
- return a === ge.DUAL_PAGE && r + v < g.clientWidth;
189
- }, [a, f, g, o]), C = A(() => {
190
- let u = t - 1;
191
- P(u) && (u = t - 2), b(u);
192
- }, [b, t, a, d, P]), x = H(() => a === ge.DUAL_PAGE && d === K.PAGE_SCROLLING ? t === o - 1 : t === o, [t, o, a, d]), h = A(() => {
193
- if (x)
194
- return;
195
- let u = t + 1;
196
- P(u) && (u = t + 2), b(u);
197
- }, [b, t, P, a, d, x]);
198
- return {
199
- focusedPage: w,
200
- totalPages: o,
201
- setFocusedPage: _,
202
- setTotalPages: s,
203
- nextPage: h,
204
- prevPage: C,
205
- goToPage: b
206
- };
207
- }, Pt = Pe({
208
- focusedPage: 0,
209
- setFocusedPage: (n) => {
210
- },
211
- goToPage: (n) => ({ success: !!n, currentPage: +n }),
212
- totalPages: 0,
213
- setTotalPages: (n) => {
214
- },
215
- prevPage: () => {
216
- },
217
- nextPage: () => {
218
- }
219
- }), oe = () => {
220
- const n = Te(Pt);
221
- return typeof (n == null ? void 0 : n.focusedPage) > "u" && yn.error("Please use this hooks inside children component of RPProvider"), n;
222
- }, Do = ({ children: n }) => {
223
- const { pdf: t } = J(), { focusedPage: e, totalPages: o, setFocusedPage: s, setTotalPages: i, goToPage: c, nextPage: a, prevPage: d } = Pn();
224
- return F(() => {
225
- t != null && t.numPages && (i(t.numPages), s(1));
226
- }, [t, i, s]), /* @__PURE__ */ z(
227
- Pt.Provider,
228
- {
229
- value: {
230
- focusedPage: e,
231
- totalPages: o,
232
- setFocusedPage: s,
233
- setTotalPages: i,
234
- nextPage: a,
235
- prevPage: d,
236
- goToPage: c
237
- },
238
- children: n
239
- }
240
- );
241
- };
242
- const Tn = () => {
243
- const { pdf: n, pages: t } = J(), [e, o] = q({
244
- loadedPages: 0,
245
- totalPages: 0,
246
- percentage: 0
247
- }), [s, i] = q(!1), [c, a] = q(!1), [d, f] = q(null), g = D(!1);
248
- F(() => {
249
- g.current;
250
- }, [g]);
251
- const w = A(() => {
252
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
253
- const u = document.querySelector(".rp-print-zone");
254
- u && u.remove();
255
- }, []), l = A(() => {
256
- g.current = !1, i(!1), a(!1), f(null), o({
257
- loadedPages: 0,
258
- totalPages: 0,
259
- percentage: 0
260
- });
261
- }, []), _ = () => {
262
- g.current = !0;
263
- }, b = async ({
264
- scratchCanvas: u,
265
- pdfDocument: p,
266
- pageNumber: r,
267
- viewerPdfPage: v,
268
- printResolution: m,
269
- optionalContentConfigPromise: S,
270
- printAnnotationStoragePromise: I
271
- }) => {
272
- if (g.current) {
273
- l();
274
- return;
275
- }
276
- const y = m / nn.PDF;
277
- u.width = Math.floor(v.width * y), u.height = Math.floor(v.height * y);
278
- const T = u.getContext("2d");
279
- T.save(), T.fillStyle = "rgb(255, 255, 255)", T.fillRect(0, 0, u.width, u.height), T.restore();
280
- const [E, O] = await Promise.all([
281
- p.getPage(r),
282
- I
283
- ]);
284
- if (g.current) {
285
- l();
286
- return;
287
- }
288
- const N = {
289
- canvasContext: T,
290
- transform: [y, 0, 0, y, 0, 0],
291
- viewport: E.getViewport({ scale: 1, rotation: v.rotation }),
292
- intent: "print",
293
- annotationMode: rn.ENABLE_STORAGE,
294
- optionalContentConfigPromise: S,
295
- printAnnotationStorage: O
296
- };
297
- try {
298
- return E.render(N).promise;
299
- } catch (R) {
300
- throw R instanceof on || console.error(R), R;
301
- }
302
- }, P = A(() => {
303
- const u = window.print;
304
- return new Promise((p) => {
305
- const r = (S) => {
306
- setTimeout(() => {
307
- u.call(window), setTimeout(() => S(), 20);
308
- }, 0);
309
- };
310
- if (document.querySelector(".rp-print-zone")) {
311
- r(p);
312
- return;
313
- }
314
- const m = new MutationObserver(() => {
315
- document.querySelector(".rp-print-zone") && (r(p), m.disconnect());
316
- });
317
- m.observe(document.body, { childList: !0, subtree: !0 });
318
- });
319
- }, []), C = async (u) => {
320
- const p = document.createElement("img"), r = document.createElement("div");
321
- return r.classList.add("rp-print-page"), await new Promise((v, m) => {
322
- u.toBlob((S) => {
323
- S ? (p.src = URL.createObjectURL(S), p.onload = () => {
324
- URL.revokeObjectURL(p.src), v();
325
- }, p.onerror = m) : m(new Error("Failed to create blob"));
326
- });
327
- }).catch(() => {
328
- }), r.appendChild(p), r;
329
- }, x = (u, p) => {
330
- const r = document.createElement("div");
331
- r.classList.add("rp-print-zone");
332
- const v = document.createElement("style"), m = p.get(1);
333
- if (m) {
334
- const { width: S, height: I } = m == null ? void 0 : m.page.getViewport({ scale: 1 });
335
- v.innerHTML = `@page { size: ${S}px ${I}px }`;
336
- }
337
- return r.appendChild(v), r.append(...u), r;
338
- }, h = A(async () => {
339
- if (!n)
340
- return;
341
- l();
342
- const u = document.createElement("canvas"), p = [];
343
- try {
344
- n.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
345
- const v = n.getOptionalContentConfig({ intent: "print" }), m = Promise.resolve(
346
- n.annotationStorage.print ?? void 0
347
- ), S = t.size;
348
- for (const [y, T] of t) {
349
- if (g.current) {
350
- l();
351
- return;
352
- }
353
- const E = T.page.getViewport({ scale: 1 });
354
- if (await b({
355
- scratchCanvas: u,
356
- pdfDocument: n,
357
- pageNumber: y,
358
- viewerPdfPage: E,
359
- printResolution: 150,
360
- optionalContentConfigPromise: v,
361
- printAnnotationStoragePromise: m
362
- }), g.current) {
363
- l();
364
- return;
365
- }
366
- const O = await C(u);
367
- p.push(O);
368
- const N = parseFloat((p.length / S * 100).toFixed(2));
369
- o({
370
- loadedPages: y,
371
- totalPages: S,
372
- percentage: N
373
- });
374
- }
375
- if (g.current) {
376
- l();
377
- return;
378
- }
379
- const I = x(p, t);
380
- document.body.appendChild(I), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), i(!0), await P();
381
- } catch (r) {
382
- a(!0), r instanceof Error && f(r);
383
- } finally {
384
- u.height = 0, u.width = 0;
385
- }
386
- }, [n, t, g]);
387
- return F(() => {
388
- const u = () => {
389
- l(), w();
390
- };
391
- return window.addEventListener("afterprint", u, !0), () => {
392
- window.removeEventListener("afterprint", u, !0);
393
- };
394
- }, [w, l]), {
395
- print: h,
396
- cancel: _,
397
- progress: e,
398
- isComplete: s,
399
- isError: c,
400
- error: d
401
- };
402
- }, Tt = Pe({
403
- print: () => {
404
- },
405
- cancel: () => {
406
- },
407
- setOnProgress: (n) => {
408
- },
409
- progress: {},
410
- setOnComplete: (n) => n(),
411
- setOnError: (n) => {
412
- try {
413
- const t = new Error("Print error occurred");
414
- n(t);
415
- } catch (t) {
416
- console.error("Error in setOnError callback:", t);
417
- }
418
- }
419
- }), ko = ({ children: n }) => {
420
- const [t, e] = q(null), [o, s] = q(null), { print: i, cancel: c, progress: a, isComplete: d, isError: f, error: g } = Tn(), w = A((C) => {
421
- C && typeof C == "function" && s(() => C);
422
- }, []), l = (C) => {
423
- g && C(g);
424
- }, _ = A(
425
- (C) => {
426
- e(() => C);
427
- },
428
- [a, t]
429
- );
430
- F(() => {
431
- d && o && b();
432
- }, [d, o]), F(() => {
433
- f && l((C) => {
434
- console.error(C);
435
- });
436
- }, [f]), F(() => {
437
- a && t && t(a);
438
- }, [a, t]);
439
- const b = () => {
440
- o && (o(), s(null));
441
- }, P = {
442
- print: i,
443
- cancel: c,
444
- setOnProgress: _,
445
- setOnComplete: w,
446
- setOnError: l,
447
- progress: a
448
- };
449
- return /* @__PURE__ */ z(Tt.Provider, { value: P, children: n });
450
- }, Rn = () => {
451
- const n = Te(Tt);
452
- if (!n)
453
- throw new Error("usePrintContext must be used within a PrintProvider");
454
- return n;
455
- }, In = () => {
456
- const [n, t] = q({}), { pages: e } = J(), o = H(() => Object.keys(n).length, [n]), s = A(
457
- (c) => {
458
- if (!e.size)
459
- return;
460
- const a = c > e.size ? e.size : c, d = Array.from(e.values()).slice(0, a).map((w) => {
461
- const { thumbnailViewport: l, scale: _ } = nt(w.page, w.defaultRotation);
462
- return {
463
- scale: _,
464
- page: w.page,
465
- loading: !0,
466
- viewport: l,
467
- defaultRotation: w.defaultRotation
468
- };
469
- }), f = d.reduce((w, l) => (w[l.page.pageNumber] = l, w), {});
470
- t(f);
471
- const g = [];
472
- for (const w of d) {
473
- const l = document.createElement("canvas"), _ = $e(w.page, l, {
474
- scale: w.scale,
475
- rotate: w.defaultRotation
476
- }).promise.then(() => {
477
- const b = l.toDataURL();
478
- return {
479
- ...w,
480
- thumbnailSrc: b,
481
- loading: !1,
482
- defaultRotation: w.defaultRotation
483
- };
484
- });
485
- g.push(_);
486
- }
487
- Promise.all(g).then((w) => {
488
- const l = w.reduce(
489
- (_, b) => (_[b.page.pageNumber] = b, _),
490
- {}
491
- );
492
- t((_) => ({ ..._, ...l }));
493
- }).catch(() => {
494
- });
495
- },
496
- [e]
497
- );
498
- F(() => {
499
- s(10);
500
- }, [s]);
501
- const i = A(
502
- (c) => {
503
- if (!e)
504
- return;
505
- const a = e.get(c);
506
- if (!a)
507
- return;
508
- t((f) => ({
509
- ...f,
510
- [c]: {
511
- loading: !0,
512
- page: a.page,
513
- viewport: a.thumbnailViewport,
514
- scale: a.thumbnailScale,
515
- defaultRotation: a.defaultRotation
516
- }
517
- }));
518
- const d = document.createElement("canvas");
519
- $e(a.page, d, {
520
- scale: a.thumbnailScale,
521
- rotate: a.defaultRotation
522
- }).promise.then(() => {
523
- const f = d.toDataURL(), { thumbnailViewport: g, scale: w } = nt(a.page);
524
- return {
525
- scale: w,
526
- thumbnailSrc: f,
527
- page: a.page,
528
- loading: !1,
529
- viewport: g,
530
- defaultRotation: a.defaultRotation
531
- };
532
- }).then((f) => {
533
- t((g) => ({ ...g, [c]: f }));
534
- });
535
- },
536
- [e]
537
- );
538
- return { thumbnailPages: n, addPage: i, addToPage: s, thumbnailLength: o };
539
- }, Rt = Pe({
540
- thumbnailPages: {},
541
- addPage: (n) => {
542
- },
543
- addToPage: (n) => {
544
- },
545
- thumbnailLength: 0,
546
- setActive: (n) => {
547
- },
548
- active: !1
549
- }), Ln = () => Te(Rt), Ho = ({
550
- children: n,
551
- initialThumbnailsVisible: t
552
- }) => {
553
- const { thumbnailPages: e, addPage: o, addToPage: s, thumbnailLength: i } = In(), [c, a] = q(t);
554
- return /* @__PURE__ */ z(
555
- Rt.Provider,
556
- {
557
- value: { thumbnailPages: e, addPage: o, addToPage: s, thumbnailLength: i, active: c, setActive: a },
558
- children: n
559
- }
560
- );
561
- }, En = (n = {}, t = "") => {
562
- const [e, o] = q(t), [s, i] = q(!1), { pdf: c, pages: a } = J(), { widths: d, heights: f } = be(), g = D(!e), { currentZoom: w } = Be(), [l, _] = q([]), { setFocusedPage: b } = oe(), { columnCount: P } = we(), { pageRotate: C } = Le(), [x, h] = q(0), { pageScrollElementRef: u, virtualScrollableElementRef: p } = Re(), { scrollMode: r } = me(), { pagesRef: v } = Ie(), [m, S] = q(null), I = D({}), y = H(() => x === 0 ? null : l[x - 1], [x, l]), T = H(() => l.length, [l]);
563
- F(() => {
564
- if (!y || !a)
565
- return;
566
- const R = p || u;
567
- if (!R || !v)
568
- return;
569
- const L = a.get(y.page);
570
- if (r === K.PAGE_SCROLLING && b(y.page), !L)
571
- return;
572
- let M = 0, W = 0;
573
- if (r === K.VERTICAL_SCROLLING) {
574
- const ee = y.page - 1, Z = P, _e = ee % Z, ie = Math.floor(ee / Z);
575
- M = fe(f, ie), W = fe(d, _e);
576
- }
577
- r === K.HORIZONTAL_SCROLLING && (W = d.slice(0, y.page - 1).reduce((ee, Z) => ee + Z, 0));
578
- const k = {
579
- height: f[y.page - 1],
580
- width: d[y.page - 1]
581
- }, U = {
582
- top: k.height / 2,
583
- left: k.width / 2
584
- }, j = C[y.page], { leftInPage: V, topInPage: X } = xn(
585
- k,
586
- U,
587
- y.rect,
588
- w,
589
- j
590
- ), B = W + V, Q = M + X, se = {
591
- left: Math.max(B, 0),
592
- top: Math.max(Q, 0)
593
- };
594
- R.scrollTo({
595
- ...se,
596
- behavior: "smooth"
597
- });
598
- }, [
599
- a,
600
- b,
601
- d,
602
- f,
603
- y,
604
- r,
605
- p,
606
- u,
607
- v
608
- ]);
609
- const E = A(() => {
610
- h((R) => T ? R + 1 > T ? 1 : R + 1 : 0);
611
- }, [T]), O = A(() => {
612
- h((R) => T ? R - 1 <= 0 ? T : R - 1 : 0);
613
- }, [T]), N = A(async (R) => {
614
- if (!R)
615
- return {};
616
- const L = R.numPages, M = {};
617
- for (let W = 1; W <= L; W++) {
618
- if (g.current)
619
- throw "close pop over";
620
- const k = await R.getPage(W);
621
- M[W.toString()] = await k.getTextContent();
622
- }
623
- return M;
624
- }, []);
625
- return F(() => {
626
- if (!e) {
627
- g.current = !0, _([]), h(0);
628
- return;
629
- }
630
- g.current = !1, i(!0), _([]), h(0), N(c).then((R) => {
631
- I.current = R;
632
- const M = Object.keys(R).reduce((W, k) => {
633
- const U = jt(
634
- [e],
635
- R[k],
636
- Number(k) - 1,
637
- n
638
- ).map((j, V) => ({ ...j, page: Number(k), pageMatchIdx: V }));
639
- return [...W, ...U];
640
- }, []);
641
- _(M), h(M.length ? 1 : 0);
642
- }).catch(() => {
643
- _([]), h(0);
644
- }).finally(() => i(!1));
645
- }, [e, N, c, n]), {
646
- search: e,
647
- setSearch: o,
648
- loading: s,
649
- matches: l,
650
- totalMatches: T,
651
- currentMatchPosition: x,
652
- currentMatch: y,
653
- nextMatch: E,
654
- prevMatch: O,
655
- currentMatchElement: m,
656
- setCurrentMatchElement: S
657
- };
658
- }, It = Pe({
659
- search: "",
660
- setSearch: (n) => {
661
- },
662
- loading: !1,
663
- matches: [],
664
- totalMatches: 0,
665
- currentMatchPosition: 0,
666
- currentMatch: null,
667
- nextMatch: () => {
668
- },
669
- prevMatch: () => {
670
- },
671
- searchOptions: {},
672
- setSearchOptions: (n) => n,
673
- currentMatchElement: null,
674
- setCurrentMatchElement: (n) => {
675
- }
676
- }), $o = ({
677
- children: n,
678
- initialSearch: t
679
- }) => {
680
- const [e, o] = q({}), {
681
- loading: s,
682
- setSearch: i,
683
- totalMatches: c,
684
- currentMatchPosition: a,
685
- currentMatch: d,
686
- search: f,
687
- matches: g,
688
- nextMatch: w,
689
- prevMatch: l,
690
- currentMatchElement: _,
691
- setCurrentMatchElement: b
692
- } = En(e, t);
693
- return /* @__PURE__ */ z(
694
- It.Provider,
695
- {
696
- value: {
697
- searchOptions: e,
698
- setSearchOptions: o,
699
- loading: s,
700
- setSearch: i,
701
- totalMatches: c,
702
- currentMatchPosition: a,
703
- currentMatch: d,
704
- nextMatch: w,
705
- prevMatch: l,
706
- search: f,
707
- matches: g,
708
- currentMatchElement: _,
709
- setCurrentMatchElement: b
710
- },
711
- children: n
712
- }
713
- );
714
- }, Mn = () => Te(It), Ae = {
715
- "rp-layout": "_rp-layout_1q08v_1",
716
- "rp-content": "_rp-content_1q08v_5",
717
- "rp-pages": "_rp-pages_1q08v_11",
718
- "rp-container": "_rp-container_1q08v_16",
719
- "rp-loader": "_rp-loader_1q08v_20",
720
- "rp-theme-variables": "_rp-theme-variables_1q08v_24",
721
- "rp-dark-mode": "_rp-dark-mode_1q08v_135"
722
- }, zn = Ze((n, t) => {
723
- const { children: e, toolbarRef: o, style: s, className: i, ...c } = n, { customVariables: a, customDarkVariables: d } = Qt(), { darkMode: f } = $t();
724
- return /* @__PURE__ */ z(
725
- "div",
726
- {
727
- ref: t,
728
- ...c,
729
- className: he(
730
- Ae["rp-theme-variables"],
731
- Ae["rp-container"],
732
- f ? Ae["rp-dark-mode"] : "",
733
- i
734
- ),
735
- style: {
736
- "--rp-toolbar-height": `${(o == null ? void 0 : o.clientHeight) || 48}px`,
737
- ...a,
738
- ...f ? d : {},
739
- ...s
740
- },
741
- children: e
742
- }
743
- );
744
- }), te = {
745
- "rp-pages": "_rp-pages_6vux6_1",
746
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_6vux6_6",
747
- "rp-pages-container": "_rp-pages-container_6vux6_10",
748
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_6vux6_47",
749
- "rp-viewer": "_rp-viewer_6vux6_52",
750
- "rp-cursor-grab": "_rp-cursor-grab_6vux6_57",
751
- "rp-cursor-grabbing": "_rp-cursor-grabbing_6vux6_65",
752
- "rp-loader": "_rp-loader_6vux6_73"
753
- }, Fe = {
754
- "rp-page-wrapper": "_rp-page-wrapper_14ohm_1",
755
- "rp-page": "_rp-page_14ohm_1",
756
- "rp-loader-wrapper": "_rp-loader-wrapper_14ohm_15"
757
- }, On = (n) => {
758
- const { pageNumber: t, onLoaded: e, onLoading: o } = n, s = D(null), { pages: i } = J(), { pageRotate: c } = Le(), a = D(), { currentZoom: d } = Be();
759
- return F(() => {
760
- if (!i || d === 0)
761
- return;
762
- const f = i.get(t);
763
- if (s.current && f) {
764
- const g = s.current;
765
- g.hidden = !0;
766
- const w = a.current;
767
- w && w.cancel(), o && o(), a.current = $e(f.page, g, {
768
- scale: d,
769
- rotate: c[t],
770
- renderForms: !0
771
- }), a.current.promise.then(() => {
772
- g.hidden = !1;
773
- }).catch(() => {
774
- }).finally(() => {
775
- e && e();
776
- });
777
- }
778
- return () => {
779
- var g;
780
- (g = a.current) == null || g.cancel();
781
- };
782
- }, [i, t, c, d, o, e]), /* @__PURE__ */ z("canvas", { "data-rp": `page-${t}-canvas`, ref: s });
783
- }, Nn = "_selecting_usdup_9", ne = {
784
- "rp-text-layer": "_rp-text-layer_usdup_1",
785
- selecting: Nn,
786
- "rp-text-layer-text": "_rp-text-layer-text_usdup_39"
787
- }, An = (n) => {
788
- const { pageNumber: t } = n, { pages: e } = J(), o = D(null), { matches: s, currentMatch: i, setCurrentMatchElement: c } = Mn(), [a, d] = q(
789
- []
790
- ), f = D(), g = D(), w = D([]), l = H(() => s.filter((u) => u.pageIndex === t - 1), [s, t]), _ = A(
791
- (u, p, r = !1) => {
792
- if (r && Bt(u, p), !l.length) {
793
- w.current = [], d([]);
794
- return;
795
- }
796
- const v = Zt(l, u, p);
797
- d(v);
798
- },
799
- [l]
800
- ), b = D(), P = D(!1), C = A(() => Array.from(document.querySelectorAll('[data-rp$="-textLayer"]')), []);
801
- F(() => ((() => {
802
- if (b.current)
803
- return;
804
- b.current = new AbortController();
805
- const { signal: p } = b.current, r = () => {
806
- C().forEach((m) => {
807
- const S = m.querySelector(".endOfContent");
808
- S && (m.appendChild(S), S.style.width = "", S.style.height = "", m.classList.remove(ne.selecting));
809
- });
810
- };
811
- document.addEventListener(
812
- "pointerdown",
813
- () => {
814
- P.current = !0;
815
- },
816
- { signal: p }
817
- ), document.addEventListener(
818
- "pointerup",
819
- () => {
820
- P.current = !1, r();
821
- },
822
- { signal: p }
823
- ), window.addEventListener(
824
- "blur",
825
- () => {
826
- P.current = !1, r();
827
- },
828
- { signal: p }
829
- ), document.addEventListener(
830
- "keyup",
831
- () => {
832
- P.current || r();
833
- },
834
- { signal: p }
835
- );
836
- let v = null;
837
- document.addEventListener(
838
- "selectionchange",
839
- () => {
840
- var N, R;
841
- const m = document.getSelection();
842
- if (!m)
843
- return;
844
- if (m.rangeCount === 0) {
845
- r();
846
- return;
847
- }
848
- const S = /* @__PURE__ */ new Set();
849
- for (let L = 0; L < m.rangeCount; L++) {
850
- const M = m.getRangeAt(L);
851
- C().forEach((W) => {
852
- M.intersectsNode(W) && !S.has(W) && S.add(W);
853
- });
854
- }
855
- C().forEach((L) => {
856
- if (S.has(L))
857
- L.classList.add(ne.selecting);
858
- else {
859
- const M = L.querySelector(".endOfContent");
860
- M && (L.appendChild(M), M.style.width = "", M.style.height = "", L.classList.remove(ne.selecting));
861
- }
862
- });
863
- const I = m.getRangeAt(0);
864
- let T = v && (I.compareBoundaryPoints(Range.END_TO_END, v) === 0 || I.compareBoundaryPoints(Range.START_TO_END, v) === 0) ? I.startContainer : I.endContainer;
865
- T.nodeType === Node.TEXT_NODE && (T = T.parentNode);
866
- const E = (N = T.parentElement) == null ? void 0 : N.closest(
867
- ne["rp-text-layer"]
868
- ), O = E == null ? void 0 : E.querySelector(".endOfContent");
869
- O && E && (O.style.width = E.style.width, O.style.height = E.style.height, (R = T.parentElement) == null || R.insertBefore(O, T.nextSibling)), v = I.cloneRange();
870
- },
871
- { signal: p }
872
- );
873
- })(), () => {
874
- var p;
875
- (p = b.current) == null || p.abort(), b.current = void 0;
876
- }), [C]);
877
- const x = A(() => {
878
- o.current && o.current.classList.add(ne.selecting);
879
- }, []), h = A(() => {
880
- o.current && o.current.classList.remove(ne.selecting);
881
- }, []);
882
- return F(() => {
883
- if (w.current.forEach((r) => {
884
- r.classList.remove("selected");
885
- }), !a.length || !i || i.pageIndex !== t - 1)
886
- return;
887
- const u = l.findIndex(
888
- (r) => JSON.stringify(r) === JSON.stringify(i)
889
- );
890
- if (u === -1)
891
- return;
892
- const p = a.filter((r) => r.index === u);
893
- p.length && (w.current = p.map((r) => r.element), c(p[0].element), p.forEach((r) => {
894
- r.element.classList.add("selected");
895
- }));
896
- }, [i, a, l]), F(() => {
897
- const u = e.get(t);
898
- if (!u || !o.current)
899
- return;
900
- const p = o.current;
901
- return f.current && f.current.cancel(), u.page.getTextContent().then((r) => {
902
- const v = u.page.getViewport({ scale: 1 });
903
- return f.current = new tn.TextLayer({
904
- viewport: v,
905
- textContentSource: r,
906
- container: p
907
- }), g.current = r, p && (p.innerText = ""), f.current.render();
908
- }).then(() => {
909
- var S, I;
910
- [].slice.call(p.children).forEach((y) => {
911
- y.classList.add(ne["rp-text-layer-text"]), y.setAttribute("data-rp", "rp-text-layer-text");
912
- });
913
- const v = (S = f.current) == null ? void 0 : S.textDivs;
914
- v && g.current && _(g.current, v);
915
- const m = document.createElement("div");
916
- m.className = "endOfContent", (I = o.current) == null || I.appendChild(m);
917
- }).catch(() => {
918
- }), () => {
919
- var r;
920
- (r = f.current) == null || r.cancel();
921
- };
922
- }, [e, t]), F(() => {
923
- var r;
924
- [].slice.call(o.current.children).forEach((v) => {
925
- v.classList.add(ne["rp-text-layer-text"]);
926
- });
927
- const p = (r = f.current) == null ? void 0 : r.textDivs;
928
- p && g.current && _(g.current, p, !0);
929
- }, [_]), /* @__PURE__ */ z(
930
- "div",
931
- {
932
- "data-rp": `page-${t}-textLayer`,
933
- className: ne["rp-text-layer"],
934
- ref: o,
935
- onMouseDown: x,
936
- onMouseUp: h
937
- }
938
- );
939
- }, Fn = {
940
- "rp-annotation-layer": "_rp-annotation-layer_1udza_1"
941
- };
942
- let Wn = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
943
- const Dn = (n) => {
944
- const { pageNumber: t } = n, e = D(null), { pages: o, pdf: s } = J(), i = D(), [c, a] = q(), { setFocusedPage: d, goToPage: f } = oe(), { scrollMode: g } = me(), { print: w } = Rn(), { download: l } = dr(), _ = H(() => o.get(t), [o, t]), b = H(() => _ == null ? void 0 : _.page.getViewport(), [_]);
945
- F(() => {
946
- i.current && (i.current.div.replaceChildren(), i.current = void 0);
947
- }, [s]), F(() => {
948
- _ && _.page.getAnnotations().then((C) => {
949
- i.current = void 0, a(C), e.current && (e.current.innerText = "");
950
- });
951
- }, [_]);
952
- const P = A(
953
- (C) => {
954
- !c || !s || (cn(C), ln(C, s, c).then((x) => {
955
- var h, u;
956
- ((h = x == null ? void 0 : x.data) == null ? void 0 : h.action) === "Print" ? w() : ((u = x == null ? void 0 : x.data) == null ? void 0 : u.action) === "SaveAs" && l();
957
- }), g === K.PAGE_SCROLLING ? et(C, c, s, (x) => d(x.pageIndex + 1)) : et(C, c, s, (x) => f(x.pageIndex + 1)));
958
- },
959
- [s, c, f, d, g, w, l]
960
- );
961
- return F(() => {
962
- if (!_ || !c)
963
- return;
964
- const C = _.page.getViewport();
965
- if (i.current) {
966
- i.current.update({
967
- viewport: C.clone({ dontFlip: !0 })
968
- });
969
- return;
970
- }
971
- const x = /* @__PURE__ */ new Map([]);
972
- for (const p of c) {
973
- const { annotationType: r } = p;
974
- switch (r) {
975
- case Qe.Link:
976
- dn(p);
977
- break;
978
- case Qe.Widget:
979
- un(p, C, x);
980
- break;
981
- }
982
- }
983
- const h = new AbortController();
984
- return (async () => {
985
- var v;
986
- i.current && (i.current.div.replaceChildren(), i.current = void 0), e.current && (e.current.innerText = ""), i.current = new sn({
987
- div: e.current,
988
- accessibilityManager: void 0,
989
- annotationCanvasMap: void 0,
990
- annotationEditorUIManager: void 0,
991
- structTreeLayer: null,
992
- page: _.page,
993
- viewport: C.clone({ dontFlip: !0 })
994
- }), e.current && tt(e.current, P);
995
- const p = await (s == null ? void 0 : s.hasJSActions()), r = await (s == null ? void 0 : s.getFieldObjects());
996
- if (h.signal.aborted)
997
- throw "abort";
998
- return (v = i.current) == null ? void 0 : v.render({
999
- annotations: c,
1000
- annotationStorage: s == null ? void 0 : s.annotationStorage,
1001
- hasJSActions: p,
1002
- fieldObjects: r,
1003
- div: e.current,
1004
- viewport: C.clone({ dontFlip: !0 }),
1005
- page: _.page,
1006
- imageResourcesPath: Wn,
1007
- renderForms: !0,
1008
- linkService: new an(),
1009
- downloadManager: null,
1010
- enableScripting: !1
1011
- });
1012
- })().then(() => {
1013
- e.current && pn(e.current, P);
1014
- }).catch((p) => {
1015
- if (p !== "abort")
1016
- throw p;
1017
- }), () => {
1018
- h.abort("clear"), e.current && tt(e.current, P);
1019
- };
1020
- }, [s, c, P]), /* @__PURE__ */ z(
1021
- "div",
1022
- {
1023
- "data-rp": `page-${t}-annotationLayer`,
1024
- style: { width: `${b == null ? void 0 : b.width}px`, height: `${b == null ? void 0 : b.height}px` },
1025
- className: Fn["rp-annotation-layer"],
1026
- ref: e
1027
- }
1028
- );
1029
- }, kn = {
1030
- "rp-text-highlight": "_rp-text-highlight_jdkf8_1"
1031
- }, Hn = ({ pageNumber: n, viewport: t }) => {
1032
- const [e, o] = q(), { pages: s } = J(), { highlightKeywords: i } = Kt(), c = !0, a = D(null), [d, f] = q(null), [g, w] = q([]);
1033
- F(() => {
1034
- a.current && f(a.current.parentElement);
1035
- }, [a]), F(() => {
1036
- (async () => {
1037
- const u = s.get(n);
1038
- if (!u || !a.current)
1039
- return;
1040
- const p = await u.page.getTextContent();
1041
- o(p);
1042
- })();
1043
- }, [s, n]);
1044
- const l = H(() => i ? i.map((h) => {
1045
- var u, p;
1046
- return {
1047
- ...hn(h.keyword, (u = h.options) == null ? void 0 : u.matchCase, (p = h.options) == null ? void 0 : p.wholeWords),
1048
- color: h.highlightColor
1049
- };
1050
- }) : [], [i]);
1051
- function _(h, u) {
1052
- if (!h)
1053
- return;
1054
- const p = `[data-rp="page-${u}-textLayer"]`;
1055
- return new Promise((r) => {
1056
- const v = h.querySelector(p);
1057
- if (v) {
1058
- r(v);
1059
- return;
1060
- }
1061
- new MutationObserver((S, I) => {
1062
- const y = h.querySelector(p);
1063
- y && (r(y), I.disconnect());
1064
- }).observe(h, { childList: !0, subtree: !0 });
1065
- });
1066
- }
1067
- function b(h) {
1068
- return new Promise((u) => {
1069
- const p = h.querySelectorAll(
1070
- '[data-rp="rp-text-layer-text"]'
1071
- );
1072
- if (p.length) {
1073
- u(Array.from(p));
1074
- return;
1075
- }
1076
- new MutationObserver((v, m) => {
1077
- const S = h.querySelectorAll(
1078
- ".rp-text-layer-text"
1079
- );
1080
- S.length && (u(Array.from(S)), m.disconnect());
1081
- }).observe(h, { childList: !0, subtree: !0 });
1082
- });
1083
- }
1084
- const P = (h, u, p, r) => {
1085
- var U;
1086
- const v = document.createRange(), m = p.firstChild;
1087
- if (!m || m.nodeType !== Node.TEXT_NODE)
1088
- return null;
1089
- const S = ((U = m.textContent) == null ? void 0 : U.length) ?? 0, I = r[0].charIdxInSpan, y = r.length === 1 ? I : r[r.length - 1].charIdxInSpan;
1090
- if (I > S || y + 1 > S)
1091
- return null;
1092
- v.setStart(m, I), v.setEnd(m, y + 1);
1093
- const T = document.createElement("span");
1094
- T.style.width = "auto", v.surroundContents(T);
1095
- const E = T.getBoundingClientRect(), O = h.getBoundingClientRect(), N = O.height, R = O.width, L = 100 * (E.left - O.left) / R, M = 100 * (E.top - O.top) / N, W = 100 * E.height / N, k = 100 * E.width / R;
1096
- return gn(T), {
1097
- keywordStr: u,
1098
- left: L,
1099
- top: M,
1100
- height: W,
1101
- width: k,
1102
- pageHeight: N,
1103
- pageWidth: R
1104
- };
1105
- };
1106
- async function C(h, u) {
1107
- const p = await _(d, h);
1108
- if (!p)
1109
- return;
1110
- const r = await b(p);
1111
- if (r.length) {
1112
- const v = r.map((S) => S.tagName === "BR" ? " " : S.textContent).reduce(
1113
- (S, I, y) => S.concat(
1114
- I.split("").map((T, E) => ({
1115
- char: T,
1116
- charIdxInSpan: E,
1117
- spanIdx: y
1118
- }))
1119
- ),
1120
- [
1121
- {
1122
- char: "",
1123
- charIdxInSpan: 0,
1124
- spanIdx: 0
1125
- }
1126
- ]
1127
- ).slice(1), m = x(p, u, r, v);
1128
- w(m);
1129
- }
1130
- }
1131
- const x = (h, u, p, r) => {
1132
- const v = u.length;
1133
- if (!r.length || !v)
1134
- return [];
1135
- const m = [], S = r.map((I) => I.char).join("");
1136
- return l.forEach((I) => {
1137
- const { keyword: y, regExp: T, wholeWords: E, color: O } = I, N = y;
1138
- if (!N.trim())
1139
- return;
1140
- const R = T.flags.indexOf("g") === -1 ? new RegExp(T, `${T.flags}g`) : T;
1141
- let L;
1142
- const M = [];
1143
- for (; (L = R.exec(S)) !== null; )
1144
- E && !Xt(S, L.index, L[0].length) || M.push({
1145
- keyword: R,
1146
- startIndex: L.index,
1147
- endIndex: R.lastIndex
1148
- });
1149
- const W = M.map((k) => ({
1150
- keyword: k.keyword,
1151
- indexes: r.slice(k.startIndex, k.endIndex),
1152
- color: O
1153
- }));
1154
- for (const k of W) {
1155
- const U = k.indexes.reduce(
1156
- (j, V) => (j[V.spanIdx] = (j[V.spanIdx] || []).concat([V]), j),
1157
- {}
1158
- );
1159
- for (const j of Object.values(U))
1160
- if (j.length !== 1 || j[0].char.trim() !== "") {
1161
- const V = j, X = p[V[0].spanIdx], B = P(
1162
- h,
1163
- N,
1164
- X,
1165
- V
1166
- );
1167
- if (B) {
1168
- const { left: Q, top: se } = B;
1169
- if (m.find((Z) => Z.left === Q && Z.top === se))
1170
- continue;
1171
- m.push({ ...B, highlightColor: k.color });
1172
- }
1173
- }
1174
- }
1175
- }), m.sort(fn), m;
1176
- };
1177
- return F(() => {
1178
- (async () => {
1179
- if (!(!i || i.length === 0))
1180
- try {
1181
- await C(n, i);
1182
- } catch (u) {
1183
- console.error(u);
1184
- }
1185
- })();
1186
- }, [c, i, n, e, t]), /* @__PURE__ */ z(vt, { children: /* @__PURE__ */ z("div", { ref: a, "data-rp": `page-${n}-textHighlightLayer`, children: g.map((h, u) => /* @__PURE__ */ z(
1187
- "div",
1188
- {
1189
- className: kn["rp-text-highlight"],
1190
- style: {
1191
- top: `${h.top}%`,
1192
- left: `${h.left}%`,
1193
- width: `${h.width}%`,
1194
- height: `${h.height}%`,
1195
- backgroundColor: h.highlightColor
1196
- }
1197
- },
1198
- u
1199
- )) }) });
1200
- }, Ke = Ze((n, t) => {
1201
- const { pageNumber: e, style: o, ...s } = n, { pages: i } = J(), { pageRotate: c } = Le(), { textLayer: a } = qt(), { currentZoom: d } = Be(), f = D(i.get(e)), [g, w] = q(!1), l = D(null), [_, b] = q({
1202
- width: 0,
1203
- height: 0
1204
- });
1205
- wt(t, () => l.current);
1206
- const P = H(() => f.current ? c[e] : 0, [e, c]);
1207
- F(() => {
1208
- if (i && (f.current = i.get(e), f.current)) {
1209
- const u = f.current.page.getViewport({
1210
- scale: d,
1211
- rotation: P
1212
- });
1213
- b(u);
1214
- }
1215
- }, [i, e, P, d]);
1216
- const C = H(() => {
1217
- switch (P) {
1218
- case 90:
1219
- return `${_.width / 2}px ${_.width / 2}px`;
1220
- case -90:
1221
- case 270:
1222
- return `${_.height / 2}px ${_.height / 2}px`;
1223
- default:
1224
- return "center";
1225
- }
1226
- }, [P, _]), x = A(() => {
1227
- w(!0);
1228
- }, []), h = A(() => {
1229
- w(!1);
1230
- }, []);
1231
- return /* @__PURE__ */ z(
1232
- "div",
1233
- {
1234
- ref: l,
1235
- id: `page-${e}`,
1236
- "data-rp": `page-${e}`,
1237
- ...s,
1238
- style: {
1239
- ...o,
1240
- "--rp-rotate": `${P}deg`,
1241
- "--rp-page-rotate-translate": `${C}`,
1242
- "--scale-factor": d
1243
- },
1244
- className: Fe["rp-page-wrapper"],
1245
- children: /* @__PURE__ */ je(
1246
- "div",
1247
- {
1248
- style: {
1249
- width: `${_.width}px`,
1250
- height: `${_.height}px`
1251
- },
1252
- className: Fe["rp-page"],
1253
- children: [
1254
- /* @__PURE__ */ z(On, { onLoading: x, onLoaded: h, pageNumber: e }),
1255
- g && /* @__PURE__ */ z("div", { className: Fe["rp-loader-wrapper"], children: /* @__PURE__ */ z(Ct, {}) }),
1256
- /* @__PURE__ */ z(mn, { pageNumber: e }),
1257
- a && /* @__PURE__ */ z(An, { pageNumber: e }),
1258
- /* @__PURE__ */ z(Hn, { pageNumber: e, viewport: _ }),
1259
- /* @__PURE__ */ z(Dn, { pageNumber: e })
1260
- ]
1261
- }
1262
- )
1263
- }
1264
- );
1265
- });
1266
- function qe() {
1267
- return qe = Object.assign ? Object.assign.bind() : function(n) {
1268
- for (var t = 1; t < arguments.length; t++) {
1269
- var e = arguments[t];
1270
- for (var o in e)
1271
- ({}).hasOwnProperty.call(e, o) && (n[o] = e[o]);
1272
- }
1273
- return n;
1274
- }, qe.apply(null, arguments);
1275
- }
1276
- function rt(n) {
1277
- if (n === void 0)
1278
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1279
- return n;
1280
- }
1281
- function Ge(n, t) {
1282
- return Ge = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, o) {
1283
- return e.__proto__ = o, e;
1284
- }, Ge(n, t);
1285
- }
1286
- function $n(n, t) {
1287
- n.prototype = Object.create(t.prototype), n.prototype.constructor = n, Ge(n, t);
1288
- }
1289
- var ot = Number.isNaN || function(t) {
1290
- return typeof t == "number" && t !== t;
1291
- };
1292
- function qn(n, t) {
1293
- return !!(n === t || ot(n) && ot(t));
1294
- }
1295
- function Gn(n, t) {
1296
- if (n.length !== t.length)
1297
- return !1;
1298
- for (var e = 0; e < n.length; e++)
1299
- if (!qn(n[e], t[e]))
1300
- return !1;
1301
- return !0;
1302
- }
1303
- function We(n, t) {
1304
- t === void 0 && (t = Gn);
1305
- var e, o = [], s, i = !1;
1306
- function c() {
1307
- for (var a = [], d = 0; d < arguments.length; d++)
1308
- a[d] = arguments[d];
1309
- return i && e === this && t(a, o) || (s = n.apply(this, a), i = !0, e = this, o = a), s;
1310
- }
1311
- return c;
1312
- }
1313
- function st(n, t) {
1314
- if (n == null)
1315
- return {};
1316
- var e = {};
1317
- for (var o in n)
1318
- if ({}.hasOwnProperty.call(n, o)) {
1319
- if (t.indexOf(o) !== -1)
1320
- continue;
1321
- e[o] = n[o];
1322
- }
1323
- return e;
1324
- }
1325
- var Vn = typeof performance == "object" && typeof performance.now == "function", it = Vn ? function() {
1326
- return performance.now();
1327
- } : function() {
1328
- return Date.now();
1329
- };
1330
- function at(n) {
1331
- cancelAnimationFrame(n.id);
1332
- }
1333
- function Un(n, t) {
1334
- var e = it();
1335
- function o() {
1336
- it() - e >= t ? n.call(null) : s.id = requestAnimationFrame(o);
1337
- }
1338
- var s = {
1339
- id: requestAnimationFrame(o)
1340
- };
1341
- return s;
1342
- }
1343
- var De = -1;
1344
- function jn(n) {
1345
- if (n === void 0 && (n = !1), De === -1 || n) {
1346
- var t = document.createElement("div"), e = t.style;
1347
- e.width = "50px", e.height = "50px", e.overflow = "scroll", document.body.appendChild(t), De = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
1348
- }
1349
- return De;
1350
- }
1351
- var pe = null;
1352
- function ct(n) {
1353
- if (n === void 0 && (n = !1), pe === null || n) {
1354
- var t = document.createElement("div"), e = t.style;
1355
- e.width = "50px", e.height = "50px", e.overflow = "scroll", e.direction = "rtl";
1356
- var o = document.createElement("div"), s = o.style;
1357
- return s.width = "100px", s.height = "100px", t.appendChild(o), document.body.appendChild(t), t.scrollLeft > 0 ? pe = "positive-descending" : (t.scrollLeft = 1, t.scrollLeft === 0 ? pe = "negative" : pe = "positive-ascending"), document.body.removeChild(t), pe;
1358
- }
1359
- return pe;
1360
- }
1361
- var Bn = 150, Zn = function(t) {
1362
- var e = t.columnIndex;
1363
- t.data;
1364
- var o = t.rowIndex;
1365
- return o + ":" + e;
1366
- }, Se = null, xe = null, ye = null;
1367
- process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (Se = /* @__PURE__ */ new WeakSet(), xe = /* @__PURE__ */ new WeakSet(), ye = /* @__PURE__ */ new WeakSet());
1368
- function Xn(n) {
1369
- var t, e = n.getColumnOffset, o = n.getColumnStartIndexForOffset, s = n.getColumnStopIndexForStartIndex, i = n.getColumnWidth, c = n.getEstimatedTotalHeight, a = n.getEstimatedTotalWidth, d = n.getOffsetForColumnAndAlignment, f = n.getOffsetForRowAndAlignment, g = n.getRowHeight, w = n.getRowOffset, l = n.getRowStartIndexForOffset, _ = n.getRowStopIndexForStartIndex, b = n.initInstanceProps, P = n.shouldResetStyleCacheOnItemSizeChange, C = n.validateProps;
1370
- return t = /* @__PURE__ */ function(x) {
1371
- $n(h, x);
1372
- function h(p) {
1373
- var r;
1374
- return r = x.call(this, p) || this, r._instanceProps = b(r.props, rt(r)), r._resetIsScrollingTimeoutId = null, r._outerRef = void 0, r.state = {
1375
- instance: rt(r),
1376
- isScrolling: !1,
1377
- horizontalScrollDirection: "forward",
1378
- scrollLeft: typeof r.props.initialScrollLeft == "number" ? r.props.initialScrollLeft : 0,
1379
- scrollTop: typeof r.props.initialScrollTop == "number" ? r.props.initialScrollTop : 0,
1380
- scrollUpdateWasRequested: !1,
1381
- verticalScrollDirection: "forward"
1382
- }, r._callOnItemsRendered = void 0, r._callOnItemsRendered = We(function(v, m, S, I, y, T, E, O) {
1383
- return r.props.onItemsRendered({
1384
- overscanColumnStartIndex: v,
1385
- overscanColumnStopIndex: m,
1386
- overscanRowStartIndex: S,
1387
- overscanRowStopIndex: I,
1388
- visibleColumnStartIndex: y,
1389
- visibleColumnStopIndex: T,
1390
- visibleRowStartIndex: E,
1391
- visibleRowStopIndex: O
1392
- });
1393
- }), r._callOnScroll = void 0, r._callOnScroll = We(function(v, m, S, I, y) {
1394
- return r.props.onScroll({
1395
- horizontalScrollDirection: S,
1396
- scrollLeft: v,
1397
- scrollTop: m,
1398
- verticalScrollDirection: I,
1399
- scrollUpdateWasRequested: y
1400
- });
1401
- }), r._getItemStyle = void 0, r._getItemStyle = function(v, m) {
1402
- var S = r.props, I = S.columnWidth, y = S.direction, T = S.rowHeight, E = r._getItemStyleCache(P && I, P && y, P && T), O = v + ":" + m, N;
1403
- if (E.hasOwnProperty(O))
1404
- N = E[O];
1405
- else {
1406
- var R = e(r.props, m, r._instanceProps), L = y === "rtl";
1407
- E[O] = N = {
1408
- position: "absolute",
1409
- left: L ? void 0 : R,
1410
- right: L ? R : void 0,
1411
- top: w(r.props, v, r._instanceProps),
1412
- height: g(r.props, v, r._instanceProps),
1413
- width: i(r.props, m, r._instanceProps)
1414
- };
1415
- }
1416
- return N;
1417
- }, r._getItemStyleCache = void 0, r._getItemStyleCache = We(function(v, m, S) {
1418
- return {};
1419
- }), r._onScroll = function(v) {
1420
- var m = v.currentTarget, S = m.clientHeight, I = m.clientWidth, y = m.scrollLeft, T = m.scrollTop, E = m.scrollHeight, O = m.scrollWidth;
1421
- r.setState(function(N) {
1422
- if (N.scrollLeft === y && N.scrollTop === T)
1423
- return null;
1424
- var R = r.props.direction, L = y;
1425
- if (R === "rtl")
1426
- switch (ct()) {
1427
- case "negative":
1428
- L = -y;
1429
- break;
1430
- case "positive-descending":
1431
- L = O - I - y;
1432
- break;
1433
- }
1434
- L = Math.max(0, Math.min(L, O - I));
1435
- var M = Math.max(0, Math.min(T, E - S));
1436
- return {
1437
- isScrolling: !0,
1438
- horizontalScrollDirection: N.scrollLeft < y ? "forward" : "backward",
1439
- scrollLeft: L,
1440
- scrollTop: M,
1441
- verticalScrollDirection: N.scrollTop < T ? "forward" : "backward",
1442
- scrollUpdateWasRequested: !1
1443
- };
1444
- }, r._resetIsScrollingDebounced);
1445
- }, r._outerRefSetter = function(v) {
1446
- var m = r.props.outerRef;
1447
- r._outerRef = v, typeof m == "function" ? m(v) : m != null && typeof m == "object" && m.hasOwnProperty("current") && (m.current = v);
1448
- }, r._resetIsScrollingDebounced = function() {
1449
- r._resetIsScrollingTimeoutId !== null && at(r._resetIsScrollingTimeoutId), r._resetIsScrollingTimeoutId = Un(r._resetIsScrolling, Bn);
1450
- }, r._resetIsScrolling = function() {
1451
- r._resetIsScrollingTimeoutId = null, r.setState({
1452
- isScrolling: !1
1453
- }, function() {
1454
- r._getItemStyleCache(-1);
1455
- });
1456
- }, r;
1457
- }
1458
- h.getDerivedStateFromProps = function(r, v) {
1459
- return Kn(r, v), C(r), null;
1460
- };
1461
- var u = h.prototype;
1462
- return u.scrollTo = function(r) {
1463
- var v = r.scrollLeft, m = r.scrollTop;
1464
- v !== void 0 && (v = Math.max(0, v)), m !== void 0 && (m = Math.max(0, m)), this.setState(function(S) {
1465
- return v === void 0 && (v = S.scrollLeft), m === void 0 && (m = S.scrollTop), S.scrollLeft === v && S.scrollTop === m ? null : {
1466
- horizontalScrollDirection: S.scrollLeft < v ? "forward" : "backward",
1467
- scrollLeft: v,
1468
- scrollTop: m,
1469
- scrollUpdateWasRequested: !0,
1470
- verticalScrollDirection: S.scrollTop < m ? "forward" : "backward"
1471
- };
1472
- }, this._resetIsScrollingDebounced);
1473
- }, u.scrollToItem = function(r) {
1474
- var v = r.align, m = v === void 0 ? "auto" : v, S = r.columnIndex, I = r.rowIndex, y = this.props, T = y.columnCount, E = y.height, O = y.rowCount, N = y.width, R = this.state, L = R.scrollLeft, M = R.scrollTop, W = jn();
1475
- S !== void 0 && (S = Math.max(0, Math.min(S, T - 1))), I !== void 0 && (I = Math.max(0, Math.min(I, O - 1)));
1476
- var k = c(this.props, this._instanceProps), U = a(this.props, this._instanceProps), j = U > N ? W : 0, V = k > E ? W : 0;
1477
- this.scrollTo({
1478
- scrollLeft: S !== void 0 ? d(this.props, S, m, L, this._instanceProps, V) : L,
1479
- scrollTop: I !== void 0 ? f(this.props, I, m, M, this._instanceProps, j) : M
1480
- });
1481
- }, u.componentDidMount = function() {
1482
- var r = this.props, v = r.initialScrollLeft, m = r.initialScrollTop;
1483
- if (this._outerRef != null) {
1484
- var S = this._outerRef;
1485
- typeof v == "number" && (S.scrollLeft = v), typeof m == "number" && (S.scrollTop = m);
1486
- }
1487
- this._callPropsCallbacks();
1488
- }, u.componentDidUpdate = function() {
1489
- var r = this.props.direction, v = this.state, m = v.scrollLeft, S = v.scrollTop, I = v.scrollUpdateWasRequested;
1490
- if (I && this._outerRef != null) {
1491
- var y = this._outerRef;
1492
- if (r === "rtl")
1493
- switch (ct()) {
1494
- case "negative":
1495
- y.scrollLeft = -m;
1496
- break;
1497
- case "positive-ascending":
1498
- y.scrollLeft = m;
1499
- break;
1500
- default:
1501
- var T = y.clientWidth, E = y.scrollWidth;
1502
- y.scrollLeft = E - T - m;
1503
- break;
1504
- }
1505
- else
1506
- y.scrollLeft = Math.max(0, m);
1507
- y.scrollTop = Math.max(0, S);
1508
- }
1509
- this._callPropsCallbacks();
1510
- }, u.componentWillUnmount = function() {
1511
- this._resetIsScrollingTimeoutId !== null && at(this._resetIsScrollingTimeoutId);
1512
- }, u.render = function() {
1513
- var r = this.props, v = r.children, m = r.className, S = r.columnCount, I = r.direction, y = r.height, T = r.innerRef, E = r.innerElementType, O = r.innerTagName, N = r.itemData, R = r.itemKey, L = R === void 0 ? Zn : R, M = r.outerElementType, W = r.outerTagName, k = r.rowCount, U = r.style, j = r.useIsScrolling, V = r.width, X = this.state.isScrolling, B = this._getHorizontalRangeToRender(), Q = B[0], se = B[1], ee = this._getVerticalRangeToRender(), Z = ee[0], _e = ee[1], ie = [];
1514
- if (S > 0 && k)
1515
- for (var ce = Z; ce <= _e; ce++)
1516
- for (var ae = Q; ae <= se; ae++)
1517
- ie.push(Ce(v, {
1518
- columnIndex: ae,
1519
- data: N,
1520
- isScrolling: j ? X : void 0,
1521
- key: L({
1522
- columnIndex: ae,
1523
- data: N,
1524
- rowIndex: ce
1525
- }),
1526
- rowIndex: ce,
1527
- style: this._getItemStyle(ce, ae)
1528
- }));
1529
- var Ee = c(this.props, this._instanceProps), Me = a(this.props, this._instanceProps);
1530
- return Ce(M || W || "div", {
1531
- className: m,
1532
- onScroll: this._onScroll,
1533
- ref: this._outerRefSetter,
1534
- style: qe({
1535
- position: "relative",
1536
- height: y,
1537
- width: V,
1538
- overflow: "auto",
1539
- WebkitOverflowScrolling: "touch",
1540
- willChange: "transform",
1541
- direction: I
1542
- }, U)
1543
- }, Ce(E || O || "div", {
1544
- children: ie,
1545
- ref: T,
1546
- style: {
1547
- height: Ee,
1548
- pointerEvents: X ? "none" : void 0,
1549
- width: Me
1550
- }
1551
- }));
1552
- }, u._callPropsCallbacks = function() {
1553
- var r = this.props, v = r.columnCount, m = r.onItemsRendered, S = r.onScroll, I = r.rowCount;
1554
- if (typeof m == "function" && v > 0 && I > 0) {
1555
- var y = this._getHorizontalRangeToRender(), T = y[0], E = y[1], O = y[2], N = y[3], R = this._getVerticalRangeToRender(), L = R[0], M = R[1], W = R[2], k = R[3];
1556
- this._callOnItemsRendered(T, E, L, M, O, N, W, k);
1557
- }
1558
- if (typeof S == "function") {
1559
- var U = this.state, j = U.horizontalScrollDirection, V = U.scrollLeft, X = U.scrollTop, B = U.scrollUpdateWasRequested, Q = U.verticalScrollDirection;
1560
- this._callOnScroll(V, X, j, Q, B);
1561
- }
1562
- }, u._getHorizontalRangeToRender = function() {
1563
- var r = this.props, v = r.columnCount, m = r.overscanColumnCount, S = r.overscanColumnsCount, I = r.overscanCount, y = r.rowCount, T = this.state, E = T.horizontalScrollDirection, O = T.isScrolling, N = T.scrollLeft, R = m || S || I || 1;
1564
- if (v === 0 || y === 0)
1565
- return [0, 0, 0, 0];
1566
- var L = o(this.props, N, this._instanceProps), M = s(this.props, L, N, this._instanceProps), W = !O || E === "backward" ? Math.max(1, R) : 1, k = !O || E === "forward" ? Math.max(1, R) : 1;
1567
- return [Math.max(0, L - W), Math.max(0, Math.min(v - 1, M + k)), L, M];
1568
- }, u._getVerticalRangeToRender = function() {
1569
- var r = this.props, v = r.columnCount, m = r.overscanCount, S = r.overscanRowCount, I = r.overscanRowsCount, y = r.rowCount, T = this.state, E = T.isScrolling, O = T.verticalScrollDirection, N = T.scrollTop, R = S || I || m || 1;
1570
- if (v === 0 || y === 0)
1571
- return [0, 0, 0, 0];
1572
- var L = l(this.props, N, this._instanceProps), M = _(this.props, L, N, this._instanceProps), W = !E || O === "backward" ? Math.max(1, R) : 1, k = !E || O === "forward" ? Math.max(1, R) : 1;
1573
- return [Math.max(0, L - W), Math.max(0, Math.min(y - 1, M + k)), L, M];
1574
- }, h;
1575
- }(Wt), t.defaultProps = {
1576
- direction: "ltr",
1577
- itemData: void 0,
1578
- useIsScrolling: !1
1579
- }, t;
1580
- }
1581
- var Kn = function(t, e) {
1582
- var o = t.children, s = t.direction, i = t.height, c = t.innerTagName, a = t.outerTagName, d = t.overscanColumnsCount, f = t.overscanCount, g = t.overscanRowsCount, w = t.width, l = e.instance;
1583
- if (process.env.NODE_ENV !== "production") {
1584
- if (typeof f == "number" && Se && !Se.has(l) && (Se.add(l), console.warn("The overscanCount prop has been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (typeof d == "number" || typeof g == "number") && xe && !xe.has(l) && (xe.add(l), console.warn("The overscanColumnsCount and overscanRowsCount props have been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (c != null || a != null) && ye && !ye.has(l) && (ye.add(l), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")), o == null)
1585
- throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1586
- switch (s) {
1587
- case "ltr":
1588
- case "rtl":
1589
- break;
1590
- default:
1591
- throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + s + '" was specified.'));
1592
- }
1593
- if (typeof w != "number")
1594
- throw Error('An invalid "width" prop has been specified. Grids must specify a number for width. ' + ('"' + (w === null ? "null" : typeof w) + '" was specified.'));
1595
- if (typeof i != "number")
1596
- throw Error('An invalid "height" prop has been specified. Grids must specify a number for height. ' + ('"' + (i === null ? "null" : typeof i) + '" was specified.'));
1597
- }
1598
- }, lt = 50, Lt = function(t, e) {
1599
- var o = t.rowCount, s = e.rowMetadataMap, i = e.estimatedRowHeight, c = e.lastMeasuredRowIndex, a = 0;
1600
- if (c >= o && (c = o - 1), c >= 0) {
1601
- var d = s[c];
1602
- a = d.offset + d.size;
1603
- }
1604
- var f = o - c - 1, g = f * i;
1605
- return a + g;
1606
- }, Et = function(t, e) {
1607
- var o = t.columnCount, s = e.columnMetadataMap, i = e.estimatedColumnWidth, c = e.lastMeasuredColumnIndex, a = 0;
1608
- if (c >= o && (c = o - 1), c >= 0) {
1609
- var d = s[c];
1610
- a = d.offset + d.size;
1611
- }
1612
- var f = o - c - 1, g = f * i;
1613
- return a + g;
1614
- }, re = function(t, e, o, s) {
1615
- var i, c, a;
1616
- if (t === "column" ? (i = s.columnMetadataMap, c = e.columnWidth, a = s.lastMeasuredColumnIndex) : (i = s.rowMetadataMap, c = e.rowHeight, a = s.lastMeasuredRowIndex), o > a) {
1617
- var d = 0;
1618
- if (a >= 0) {
1619
- var f = i[a];
1620
- d = f.offset + f.size;
1621
- }
1622
- for (var g = a + 1; g <= o; g++) {
1623
- var w = c(g);
1624
- i[g] = {
1625
- offset: d,
1626
- size: w
1627
- }, d += w;
1628
- }
1629
- t === "column" ? s.lastMeasuredColumnIndex = o : s.lastMeasuredRowIndex = o;
1630
- }
1631
- return i[o];
1632
- }, ut = function(t, e, o, s) {
1633
- var i, c;
1634
- t === "column" ? (i = o.columnMetadataMap, c = o.lastMeasuredColumnIndex) : (i = o.rowMetadataMap, c = o.lastMeasuredRowIndex);
1635
- var a = c > 0 ? i[c].offset : 0;
1636
- return a >= s ? Mt(t, e, o, c, 0, s) : Yn(t, e, o, Math.max(0, c), s);
1637
- }, Mt = function(t, e, o, s, i, c) {
1638
- for (; i <= s; ) {
1639
- var a = i + Math.floor((s - i) / 2), d = re(t, e, a, o).offset;
1640
- if (d === c)
1641
- return a;
1642
- d < c ? i = a + 1 : d > c && (s = a - 1);
1643
- }
1644
- return i > 0 ? i - 1 : 0;
1645
- }, Yn = function(t, e, o, s, i) {
1646
- for (var c = t === "column" ? e.columnCount : e.rowCount, a = 1; s < c && re(t, e, s, o).offset < i; )
1647
- s += a, a *= 2;
1648
- return Mt(t, e, o, Math.min(s, c - 1), Math.floor(s / 2), i);
1649
- }, dt = function(t, e, o, s, i, c, a) {
1650
- var d = t === "column" ? e.width : e.height, f = re(t, e, o, c), g = t === "column" ? Et(e, c) : Lt(e, c), w = Math.max(0, Math.min(g - d, f.offset)), l = Math.max(0, f.offset - d + a + f.size);
1651
- switch (s === "smart" && (i >= l - d && i <= w + d ? s = "auto" : s = "center"), s) {
1652
- case "start":
1653
- return w;
1654
- case "end":
1655
- return l;
1656
- case "center":
1657
- return Math.round(l + (w - l) / 2);
1658
- case "auto":
1659
- default:
1660
- return i >= l && i <= w ? i : l > w || i < l ? l : w;
1661
- }
1662
- }, Jn = /* @__PURE__ */ Xn({
1663
- getColumnOffset: function(t, e, o) {
1664
- return re("column", t, e, o).offset;
1665
- },
1666
- getColumnStartIndexForOffset: function(t, e, o) {
1667
- return ut("column", t, o, e);
1668
- },
1669
- getColumnStopIndexForStartIndex: function(t, e, o, s) {
1670
- for (var i = t.columnCount, c = t.width, a = re("column", t, e, s), d = o + c, f = a.offset + a.size, g = e; g < i - 1 && f < d; )
1671
- g++, f += re("column", t, g, s).size;
1672
- return g;
1673
- },
1674
- getColumnWidth: function(t, e, o) {
1675
- return o.columnMetadataMap[e].size;
1676
- },
1677
- getEstimatedTotalHeight: Lt,
1678
- getEstimatedTotalWidth: Et,
1679
- getOffsetForColumnAndAlignment: function(t, e, o, s, i, c) {
1680
- return dt("column", t, e, o, s, i, c);
1681
- },
1682
- getOffsetForRowAndAlignment: function(t, e, o, s, i, c) {
1683
- return dt("row", t, e, o, s, i, c);
1684
- },
1685
- getRowOffset: function(t, e, o) {
1686
- return re("row", t, e, o).offset;
1687
- },
1688
- getRowHeight: function(t, e, o) {
1689
- return o.rowMetadataMap[e].size;
1690
- },
1691
- getRowStartIndexForOffset: function(t, e, o) {
1692
- return ut("row", t, o, e);
1693
- },
1694
- getRowStopIndexForStartIndex: function(t, e, o, s) {
1695
- for (var i = t.rowCount, c = t.height, a = re("row", t, e, s), d = o + c, f = a.offset + a.size, g = e; g < i - 1 && f < d; )
1696
- g++, f += re("row", t, g, s).size;
1697
- return g;
1698
- },
1699
- initInstanceProps: function(t, e) {
1700
- var o = t, s = o.estimatedColumnWidth, i = o.estimatedRowHeight, c = {
1701
- columnMetadataMap: {},
1702
- estimatedColumnWidth: s || lt,
1703
- estimatedRowHeight: i || lt,
1704
- lastMeasuredColumnIndex: -1,
1705
- lastMeasuredRowIndex: -1,
1706
- rowMetadataMap: {}
1707
- };
1708
- return e.resetAfterColumnIndex = function(a, d) {
1709
- d === void 0 && (d = !0), e.resetAfterIndices({
1710
- columnIndex: a,
1711
- shouldForceUpdate: d
1712
- });
1713
- }, e.resetAfterRowIndex = function(a, d) {
1714
- d === void 0 && (d = !0), e.resetAfterIndices({
1715
- rowIndex: a,
1716
- shouldForceUpdate: d
1717
- });
1718
- }, e.resetAfterIndices = function(a) {
1719
- var d = a.columnIndex, f = a.rowIndex, g = a.shouldForceUpdate, w = g === void 0 ? !0 : g;
1720
- typeof d == "number" && (c.lastMeasuredColumnIndex = Math.min(c.lastMeasuredColumnIndex, d - 1)), typeof f == "number" && (c.lastMeasuredRowIndex = Math.min(c.lastMeasuredRowIndex, f - 1)), e._getItemStyleCache(-1), w && e.forceUpdate();
1721
- }, c;
1722
- },
1723
- shouldResetStyleCacheOnItemSizeChange: !1,
1724
- validateProps: function(t) {
1725
- var e = t.columnWidth, o = t.rowHeight;
1726
- if (process.env.NODE_ENV !== "production") {
1727
- if (typeof e != "function")
1728
- throw Error('An invalid "columnWidth" prop has been specified. Value should be a function. ' + ('"' + (e === null ? "null" : typeof e) + '" was specified.'));
1729
- if (typeof o != "function")
1730
- throw Error('An invalid "rowHeight" prop has been specified. Value should be a function. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1731
- }
1732
- }
1733
- });
1734
- process.env.NODE_ENV;
1735
- function pt(n, t) {
1736
- for (var e in n)
1737
- if (!(e in t))
1738
- return !0;
1739
- for (var o in t)
1740
- if (n[o] !== t[o])
1741
- return !0;
1742
- return !1;
1743
- }
1744
- var Qn = ["style"], er = ["style"];
1745
- function tr(n, t) {
1746
- var e = n.style, o = st(n, Qn), s = t.style, i = st(t, er);
1747
- return !pt(e, s) && !pt(o, i);
1748
- }
1749
- const nr = () => {
1750
- const { viewMode: n } = we(), { scrollMode: t } = me(), { setColumnCount: e } = St(), { virtualScrollableElementRef: o } = Re(), s = be(), i = H(() => s.heights.length, [s.heights]), c = H(() => t === K.HORIZONTAL_SCROLLING ? i : n === ge.DUAL_PAGE ? 2 : 1, [n, t, t, i, o]), a = H(() => s.widths.reduce((b, P, C) => {
1751
- const x = C % c;
1752
- return (!b[x] || P > b[x]) && (b[x] = P), b;
1753
- }, []), [s.widths, c]), d = A(
1754
- (_) => {
1755
- const b = _ % a.length;
1756
- return a[b] || 0;
1757
- },
1758
- [a]
1759
- ), f = A(
1760
- (_) => {
1761
- const b = Array.from({ length: c }, (P, C) => {
1762
- const x = _ * c + C;
1763
- return s.heights[x] || 0;
1764
- });
1765
- return Math.max(...b);
1766
- },
1767
- [s.heights, c]
1768
- );
1769
- F(() => {
1770
- e(c);
1771
- }, [c, e]);
1772
- const g = H(() => t === K.HORIZONTAL_SCROLLING || t === K.PAGE_SCROLLING ? 1 : Math.round(i / c), [c, i, t]), w = H(() => s.heights.reduce((_, b) => _ + b, 0) / s.heights.length || 0, [s]), l = H(() => s.widths.reduce((_, b) => _ + b, 0) / s.heights.length || 0, [s]);
1773
- return {
1774
- rowCount: g,
1775
- rowHeight: f,
1776
- columnCount: c,
1777
- columnWidth: d,
1778
- pageDimension: s,
1779
- estimatedRowHeight: w,
1780
- estimatedColumnWidth: l
1781
- };
1782
- };
1783
- let Y;
1784
- typeof window < "u" ? Y = window : typeof self < "u" ? Y = self : Y = global;
1785
- let Ve = null, Ue = null;
1786
- const ht = 20, ke = Y.clearTimeout, ft = Y.setTimeout, He = Y.cancelAnimationFrame || Y.mozCancelAnimationFrame || Y.webkitCancelAnimationFrame, gt = Y.requestAnimationFrame || Y.mozRequestAnimationFrame || Y.webkitRequestAnimationFrame;
1787
- He == null || gt == null ? (Ve = ke, Ue = function(t) {
1788
- return ft(t, ht);
1789
- }) : (Ve = function([t, e]) {
1790
- He(t), ke(e);
1791
- }, Ue = function(t) {
1792
- const e = gt(function() {
1793
- ke(o), t();
1794
- }), o = ft(function() {
1795
- He(e), t();
1796
- }, ht);
1797
- return [e, o];
1798
- });
1799
- function rr(n) {
1800
- let t, e, o, s, i, c, a;
1801
- const d = typeof document < "u" && document.attachEvent;
1802
- if (!d) {
1803
- c = function(x) {
1804
- const h = x.__resizeTriggers__, u = h.firstElementChild, p = h.lastElementChild, r = u.firstElementChild;
1805
- p.scrollLeft = p.scrollWidth, p.scrollTop = p.scrollHeight, r.style.width = u.offsetWidth + 1 + "px", r.style.height = u.offsetHeight + 1 + "px", u.scrollLeft = u.scrollWidth, u.scrollTop = u.scrollHeight;
1806
- }, i = function(x) {
1807
- return x.offsetWidth !== x.__resizeLast__.width || x.offsetHeight !== x.__resizeLast__.height;
1808
- }, a = function(x) {
1809
- if (x.target.className && typeof x.target.className.indexOf == "function" && x.target.className.indexOf("contract-trigger") < 0 && x.target.className.indexOf("expand-trigger") < 0)
1810
- return;
1811
- const h = this;
1812
- c(this), this.__resizeRAF__ && Ve(this.__resizeRAF__), this.__resizeRAF__ = Ue(function() {
1813
- i(h) && (h.__resizeLast__.width = h.offsetWidth, h.__resizeLast__.height = h.offsetHeight, h.__resizeListeners__.forEach(function(r) {
1814
- r.call(h, x);
1815
- }));
1816
- });
1817
- };
1818
- let l = !1, _ = "";
1819
- o = "animationstart";
1820
- const b = "Webkit Moz O ms".split(" ");
1821
- let P = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), C = "";
1822
- {
1823
- const x = document.createElement("fakeelement");
1824
- if (x.style.animationName !== void 0 && (l = !0), l === !1) {
1825
- for (let h = 0; h < b.length; h++)
1826
- if (x.style[b[h] + "AnimationName"] !== void 0) {
1827
- C = b[h], _ = "-" + C.toLowerCase() + "-", o = P[h], l = !0;
1828
- break;
1829
- }
1830
- }
1831
- }
1832
- e = "resizeanim", t = "@" + _ + "keyframes " + e + " { from { opacity: 0; } to { opacity: 0; } } ", s = _ + "animation: 1ms " + e + "; ";
1833
- }
1834
- const f = function(l) {
1835
- if (!l.getElementById("detectElementResize")) {
1836
- const _ = (t || "") + ".resize-triggers { " + (s || "") + '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%; }', b = l.head || l.getElementsByTagName("head")[0], P = l.createElement("style");
1837
- P.id = "detectElementResize", P.type = "text/css", n != null && P.setAttribute("nonce", n), P.styleSheet ? P.styleSheet.cssText = _ : P.appendChild(l.createTextNode(_)), b.appendChild(P);
1838
- }
1839
- };
1840
- return {
1841
- addResizeListener: function(l, _) {
1842
- if (d)
1843
- l.attachEvent("onresize", _);
1844
- else {
1845
- if (!l.__resizeTriggers__) {
1846
- const b = l.ownerDocument, P = Y.getComputedStyle(l);
1847
- P && P.position === "static" && (l.style.position = "relative"), f(b), l.__resizeLast__ = {}, l.__resizeListeners__ = [], (l.__resizeTriggers__ = b.createElement("div")).className = "resize-triggers";
1848
- const C = b.createElement("div");
1849
- C.className = "expand-trigger", C.appendChild(b.createElement("div"));
1850
- const x = b.createElement("div");
1851
- x.className = "contract-trigger", l.__resizeTriggers__.appendChild(C), l.__resizeTriggers__.appendChild(x), l.appendChild(l.__resizeTriggers__), c(l), l.addEventListener("scroll", a, !0), o && (l.__resizeTriggers__.__animationListener__ = function(u) {
1852
- u.animationName === e && c(l);
1853
- }, l.__resizeTriggers__.addEventListener(o, l.__resizeTriggers__.__animationListener__));
1854
- }
1855
- l.__resizeListeners__.push(_);
1856
- }
1857
- },
1858
- removeResizeListener: function(l, _) {
1859
- if (d)
1860
- l.detachEvent("onresize", _);
1861
- else if (l.__resizeListeners__.splice(l.__resizeListeners__.indexOf(_), 1), !l.__resizeListeners__.length) {
1862
- l.removeEventListener("scroll", a, !0), l.__resizeTriggers__.__animationListener__ && (l.__resizeTriggers__.removeEventListener(o, l.__resizeTriggers__.__animationListener__), l.__resizeTriggers__.__animationListener__ = null);
1863
- try {
1864
- l.__resizeTriggers__ = !l.removeChild(l.__resizeTriggers__);
1865
- } catch {
1866
- }
1867
- }
1868
- }
1869
- };
1870
- }
1871
- class or extends Dt {
1872
- constructor(...t) {
1873
- super(...t), this.state = {
1874
- height: this.props.defaultHeight || 0,
1875
- scaledHeight: this.props.defaultHeight || 0,
1876
- scaledWidth: this.props.defaultWidth || 0,
1877
- width: this.props.defaultWidth || 0
1878
- }, this._autoSizer = null, this._detectElementResize = null, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
1879
- this._timeoutId = null;
1880
- const {
1881
- disableHeight: e,
1882
- disableWidth: o,
1883
- onResize: s
1884
- } = this.props;
1885
- if (this._parentNode) {
1886
- const i = window.getComputedStyle(this._parentNode) || {}, c = parseFloat(i.paddingLeft || "0"), a = parseFloat(i.paddingRight || "0"), d = parseFloat(i.paddingTop || "0"), f = parseFloat(i.paddingBottom || "0"), g = this._parentNode.getBoundingClientRect(), w = g.height - d - f, l = g.width - c - a, _ = this._parentNode.offsetHeight - d - f, b = this._parentNode.offsetWidth - c - a;
1887
- (!e && (this.state.height !== _ || this.state.scaledHeight !== w) || !o && (this.state.width !== b || this.state.scaledWidth !== l)) && (this.setState({
1888
- height: _,
1889
- width: b,
1890
- scaledHeight: w,
1891
- scaledWidth: l
1892
- }), typeof s == "function" && s({
1893
- height: _,
1894
- scaledHeight: w,
1895
- scaledWidth: l,
1896
- width: b
1897
- }));
1898
- }
1899
- }, this._setRef = (e) => {
1900
- this._autoSizer = e;
1901
- };
1902
- }
1903
- componentDidMount() {
1904
- const {
1905
- nonce: t
1906
- } = this.props, e = this._autoSizer ? this._autoSizer.parentNode : null;
1907
- if (e != null && e.ownerDocument && e.ownerDocument.defaultView && e instanceof e.ownerDocument.defaultView.HTMLElement) {
1908
- this._parentNode = e;
1909
- const o = e.ownerDocument.defaultView.ResizeObserver;
1910
- o != null ? (this._resizeObserver = new o(() => {
1911
- this._timeoutId = setTimeout(this._onResize, 0);
1912
- }), this._resizeObserver.observe(e)) : (this._detectElementResize = rr(t), this._detectElementResize.addResizeListener(e, this._onResize)), this._onResize();
1913
- }
1914
- }
1915
- componentWillUnmount() {
1916
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
1917
- }
1918
- render() {
1919
- const {
1920
- children: t,
1921
- defaultHeight: e,
1922
- defaultWidth: o,
1923
- disableHeight: s = !1,
1924
- disableWidth: i = !1,
1925
- doNotBailOutOnEmptyChildren: c = !1,
1926
- nonce: a,
1927
- onResize: d,
1928
- style: f = {},
1929
- tagName: g = "div",
1930
- ...w
1931
- } = this.props, {
1932
- height: l,
1933
- scaledHeight: _,
1934
- scaledWidth: b,
1935
- width: P
1936
- } = this.state, C = {
1937
- overflow: "visible"
1938
- }, x = {};
1939
- let h = !1;
1940
- return s || (l === 0 && (h = !0), C.height = 0, x.height = l, x.scaledHeight = _), i || (P === 0 && (h = !0), C.width = 0, x.width = P, x.scaledWidth = b), c && (h = !1), Ce(g, {
1941
- ref: this._setRef,
1942
- style: {
1943
- ...C,
1944
- ...f
1945
- },
1946
- ...w
1947
- }, !h && t(x));
1948
- }
1949
- }
1950
- const sr = bt(({ widths: n, heights: t }) => {
1951
- const { focusedPage: e, totalPages: o } = oe(), s = H(() => {
1952
- const a = [], d = Math.ceil(e / 2) * 2 - 1;
1953
- if (a.push(d), d + 1 <= o) {
1954
- const f = d + 1;
1955
- a.push(f);
1956
- }
1957
- return a;
1958
- }, [e, o]), i = H(() => {
1959
- const a = e % 2 === 1 ? e - 1 : e - 2, d = n(a), f = t(a), g = n(a + 1), w = t(a + 1), l = f > w ? f : w, _ = f < w ? f : w, b = l / 2 - _ / 2;
1960
- return [
1961
- {
1962
- position: "absolute",
1963
- left: 0,
1964
- top: l === f ? 0 : b,
1965
- width: d,
1966
- height: f
1967
- },
1968
- {
1969
- position: "absolute",
1970
- left: d,
1971
- top: l === w ? 0 : b,
1972
- width: g,
1973
- height: w
1974
- }
1975
- ];
1976
- }, [n, t, s]), c = H(() => i.reduce((a, d) => a + Number(d.width || 0), 0), [i]);
1977
- return /* @__PURE__ */ z("div", { style: { width: c, position: "relative" }, children: s.map((a, d) => /* @__PURE__ */ z(Ke, { style: i[d], pageNumber: a }, a)) });
1978
- }), ir = ({ widths: n, heights: t }) => {
1979
- const { focusedPage: e } = oe(), o = H(() => ({
1980
- position: "absolute",
1981
- width: n(e - 1),
1982
- height: t(e - 1)
1983
- }), [n, t, e]), s = H(() => n(e - 1), [n]);
1984
- return /* @__PURE__ */ z(
1985
- "div",
1986
- {
1987
- style: {
1988
- width: s,
1989
- position: "relative"
1990
- },
1991
- children: /* @__PURE__ */ z(Ke, { style: o, pageNumber: e }, e)
1992
- }
1993
- );
1994
- }, ar = (n, t, e) => {
1995
- const o = D(), { contentRef: s } = Ie(), { heights: i, widths: c } = be(), { setFocusedPage: a } = oe(), [d, f] = q([]), { targetScrollPage: g } = xt(), w = Xe(d, 0, 500), l = H(() => i.map((b, P) => {
1996
- const C = c[P], x = Cn(P + 1, n), h = C * x.columnIndex, u = b * x.rowIndex, p = h + C, r = u + b;
1997
- return {
1998
- pageNumber: P + 1,
1999
- ...x,
2000
- width: C,
2001
- height: b,
2002
- startX: h,
2003
- startY: u,
2004
- endX: p,
2005
- endY: r
2006
- };
2007
- }), [i, c, n, t]);
2008
- F(() => {
2009
- var P;
2010
- w.length > 0 && !g.current && a(w[0].pageNumber);
2011
- let b = (P = w[0]) == null ? void 0 : P.ratio;
2012
- b && w.filter((C) => Math.round(C.ratio) === Math.round(b)).some((C) => C.pageNumber === g.current) && setTimeout(() => {
2013
- g.current = void 0;
2014
- }, 500);
2015
- }, [w, a]);
2016
- const _ = A(
2017
- (b) => {
2018
- o.current && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
2019
- const P = b.target, C = {
2020
- startTop: P.scrollTop,
2021
- startLeft: P.scrollLeft,
2022
- endTop: P.scrollTop + P.clientHeight,
2023
- endLeft: P.scrollLeft + P.clientWidth
2024
- }, x = l.filter((h) => {
2025
- const u = h.endX >= C.startLeft && h.endY >= C.startTop, p = h.startX <= C.endLeft && h.startY <= C.endTop;
2026
- return u && p;
2027
- }).map((h) => {
2028
- const u = C.startLeft > h.startX ? C.startLeft : h.startX, p = C.startTop > h.startY ? C.startTop : h.startY, r = C.endLeft < h.endX ? C.endLeft : h.endX, v = C.endTop < h.endY ? C.endTop : h.endY, m = r - u, S = v - p, y = +(m * S / (h.width * h.height) * 100).toFixed(2);
2029
- return {
2030
- pageNumber: h.pageNumber,
2031
- ratio: y
2032
- };
2033
- }).sort((h, u) => u.ratio - h.ratio);
2034
- f(x);
2035
- });
2036
- },
2037
- [s, l]
2038
- );
2039
- F(() => {
2040
- if (e)
2041
- return e == null || e.addEventListener("scroll", _), () => {
2042
- e == null || e.removeEventListener("scroll", _);
2043
- };
2044
- }, [e, _]);
2045
- }, cr = bt(({ columnIndex: n, rowIndex: t, data: e, style: o }) => {
2046
- const s = Sn(t, n, e.columnCount);
2047
- return /* @__PURE__ */ z(Ke, { style: o, pageNumber: s }, s);
2048
- }, tr), qo = () => {
2049
- const { initialPage: n = 1, initialScrollMode: t, instanceId: e } = Vt(), { pagesRef: o, setPagesRef: s } = Ie(), { scrollToPage: i } = yt(), {
2050
- virtualScrollRef: c,
2051
- getVirtualScrollRef: a,
2052
- getPageScrollElementRef: d,
2053
- getVirtualScrollableElementRef: f,
2054
- setTotalInnerDimensions: g,
2055
- virtualScrollableElementRef: w,
2056
- totalInnerDimensions: l,
2057
- pageScrollElementRef: _
2058
- } = Re(), b = D(!0), { nextPage: P, prevPage: C, setFocusedPage: x, focusedPage: h } = oe(), { scrollMode: u } = me(), { viewMode: p } = we(), r = D(null), { loading: v } = J(), { passwordRequired: m } = Ht(), { LoaderImageComponent: S } = Jt(), I = D(
2059
- l
2060
- ), y = D({
2061
- viewMode: p,
2062
- scrollMode: u
2063
- }), T = D(!1), E = D(), { isFullScreen: O } = Ut(), {
2064
- pageDimension: N,
2065
- rowCount: R,
2066
- rowHeight: L,
2067
- columnCount: M,
2068
- columnWidth: W,
2069
- estimatedColumnWidth: k,
2070
- estimatedRowHeight: U
2071
- } = nr(), j = Xe(l, 100), V = D();
2072
- ar(M, R, w);
2073
- const X = D({
2074
- scrollTop: 0,
2075
- scrollLeft: 0
2076
- });
2077
- wn(o);
2078
- const { isPressed: B } = _n(), { selectionMode: Q } = Gt(), { initializeGrabScroll: se, resetGrabState: ee } = vn({
2079
- isPressed: B
2080
- }), Z = H(() => Q === kt.HAND, [Q]), _e = H(() => ({
2081
- columnCount: M
2082
- }), [M]), ie = A(
2083
- ($) => {
2084
- const G = document.activeElement !== o;
2085
- !O && G || (["ArrowUp", "ArrowLeft"].includes($.key) ? ($.preventDefault(), C()) : ["ArrowDown", "ArrowRight"].includes($.key) && ($.preventDefault(), P()));
2086
- },
2087
- [P, C, O, u]
2088
- );
2089
- F(() => (window.addEventListener("keydown", ie), () => {
2090
- window.removeEventListener("keydown", ie);
2091
- }), [ie]), F(() => {
2092
- if (r.current && (r.current.style.position = "relative"), !!c)
2093
- for (let $ = 0; $ < R; $++)
2094
- for (let G = 0; G < M; G++)
2095
- c.resetAfterIndices({
2096
- columnIndex: G,
2097
- rowIndex: $,
2098
- shouldForceUpdate: !0
2099
- });
2100
- }, [R, M, N, c]);
2101
- const ce = A(
2102
- ($, G) => {
2103
- if (!w)
2104
- return { scrollTop: 0, scrollLeft: 0 };
2105
- const le = X.current.scrollTop > G, ue = X.current.scrollLeft > $;
2106
- return le || ue ? X.current : {
2107
- scrollTop: w.scrollTop,
2108
- scrollLeft: w.scrollLeft
2109
- };
2110
- },
2111
- [w]
2112
- ), ae = A(
2113
- ($, G) => {
2114
- if (y.current.viewMode !== p || y.current.scrollMode !== u) {
2115
- V.current && clearTimeout(V.current), T.current = !0, i(h, "auto"), V.current = setTimeout(() => {
2116
- requestAnimationFrame(() => {
2117
- y.current = { viewMode: p, scrollMode: u };
2118
- });
2119
- }, 100);
2120
- return;
2121
- }
2122
- const ue = $.scrollTop, ze = $.scrollLeft;
2123
- if (!G.height || !G.width)
2124
- return;
2125
- T.current = !0;
2126
- const { height: de, width: Oe } = G, { height: Ye, width: Je } = I.current;
2127
- if (Ye === de && Je === Oe)
2128
- return;
2129
- const Ot = ue / Ye * de, Nt = ze / Je * Oe, At = Math.round(Math.min(Ot, de)) || 0, Ft = Math.round(Math.min(Nt, Oe)) || 0;
2130
- E.current = setTimeout(() => {
2131
- requestAnimationFrame(() => {
2132
- c == null || c.scrollTo({
2133
- scrollTop: At,
2134
- scrollLeft: Ft
2135
- });
2136
- });
2137
- }, 0), I.current = {
2138
- height: G.height,
2139
- width: G.width
2140
- };
2141
- },
2142
- [c, p, u, i]
2143
- );
2144
- F(() => {
2145
- clearTimeout(E.current);
2146
- const $ = Array.from({ length: R }).reduce(
2147
- (ue, ze, de) => ue + L(de),
2148
- 0
2149
- ), G = Array.from({ length: M }).reduce(
2150
- (ue, ze, de) => ue + W(de),
2151
- 0
2152
- ), le = ce(G, $);
2153
- X.current = le, ae(le, { height: $, width: G }), g({
2154
- height: $,
2155
- width: G
2156
- });
2157
- }, [N, R, M, ae]);
2158
- const Ee = A(
2159
- ($) => {
2160
- X.current = {
2161
- scrollTop: $.scrollTop,
2162
- scrollLeft: $.scrollLeft
2163
- };
2164
- },
2165
- [w]
2166
- );
2167
- F(() => () => {
2168
- V.current && clearTimeout(V.current);
2169
- }, []);
2170
- const Me = H(() => he(te["rp-pages-container"], {
2171
- [te["rp-cursor-grab"]]: Z && !B,
2172
- [te["rp-cursor-grabbing"]]: Z && B
2173
- }), [Z, B]), zt = A(
2174
- ($) => {
2175
- if (Z && $) {
2176
- const G = he(te["rp-pages"]), le = document.querySelector(`.${G}`);
2177
- se(le);
2178
- }
2179
- },
2180
- [Z, se, te]
2181
- );
2182
- return F(() => {
2183
- v && ee();
2184
- }, [v]), F(() => {
2185
- if (!(j.height === 0 || !b.current)) {
2186
- if (t === K.PAGE_SCROLLING) {
2187
- n !== h && _ && x(n), b.current = !1;
2188
- return;
2189
- }
2190
- i(n, "auto"), x(n), b.current = !1;
2191
- }
2192
- }, [
2193
- i,
2194
- t,
2195
- _,
2196
- x,
2197
- j
2198
- ]), /* @__PURE__ */ je(vt, { children: [
2199
- /* @__PURE__ */ z(zn, { id: e, ref: s, tabIndex: -1, className: Me, children: /* @__PURE__ */ z(or, { style: { minHeight: "50px" }, children: ({ width: $, height: G }) => /* @__PURE__ */ z("div", { "data-rp": "pages", ref: zt, style: { width: $, height: G }, children: u === K.PAGE_SCROLLING ? /* @__PURE__ */ z(
2200
- "div",
2201
- {
2202
- ref: d,
2203
- style: { width: $, height: G },
2204
- className: he(te["rp-pages"], te["rp-page-scrolling-wrapper"]),
2205
- children: p === ge.DUAL_PAGE ? /* @__PURE__ */ z(sr, { widths: W, heights: L }) : /* @__PURE__ */ z(ir, { widths: W, heights: L })
2206
- }
2207
- ) : k ? /* @__PURE__ */ z(
2208
- Jn,
2209
- {
2210
- ref: a,
2211
- itemData: _e,
2212
- outerRef: f,
2213
- innerRef: r,
2214
- onScroll: Ee,
2215
- columnCount: M,
2216
- columnWidth: W,
2217
- rowHeight: L,
2218
- height: G,
2219
- width: $,
2220
- estimatedColumnWidth: k,
2221
- estimatedRowHeight: U,
2222
- rowCount: R,
2223
- className: he(
2224
- te["rp-pages"],
2225
- u === K.HORIZONTAL_SCROLLING ? te["rp-pages-horizontal-scroll"] : ""
2226
- ),
2227
- children: cr
2228
- }
2229
- ) : v ? null : /* @__PURE__ */ z(
2230
- "div",
2231
- {
2232
- className: te["rp-loader"],
2233
- style: {
2234
- display: "flex",
2235
- justifyContent: "center",
2236
- alignItems: "center",
2237
- height: "100%",
2238
- width: "100%"
2239
- },
2240
- children: S && /* @__PURE__ */ z(S, {})
2241
- }
2242
- ) }) }) }),
2243
- m && /* @__PURE__ */ z(bn, {})
2244
- ] });
2245
- }, Go = {
2246
- "rp-toolbar-content": "_rp-toolbar-content_sz31z_1",
2247
- "rp-toolbar-wrapper": "_rp-toolbar-wrapper_sz31z_10",
2248
- "rp-toolbar-start": "_rp-toolbar-start_sz31z_33",
2249
- "rp-toolbar-middle": "_rp-toolbar-middle_sz31z_39",
2250
- "rp-toolbar-end": "_rp-toolbar-end_sz31z_46"
2251
- }, Vo = {
2252
- "rp-paginate": "_rp-paginate_1y9vo_1",
2253
- "rp-page-input": "_rp-page-input_1y9vo_6",
2254
- "rp-total-page": "_rp-total-page_1y9vo_11"
2255
- }, Uo = {
2256
- "rp-dialog-wrapper": "_rp-dialog-wrapper_slqo7_1",
2257
- "rp-dialog-overlay": "_rp-dialog-overlay_slqo7_7",
2258
- "rp-document-dialog": "_rp-document-dialog_slqo7_13",
2259
- "rp-document-properties": "_rp-document-properties_slqo7_35",
2260
- "rp-dialog-title": "_rp-dialog-title_slqo7_39",
2261
- "rp-dialog-close": "_rp-dialog-close_slqo7_47",
2262
- "rp-properties-divider": "_rp-properties-divider_slqo7_55"
2263
- }, jo = {
2264
- "rp-other-tool-content": "_rp-other-tool-content_su718_1"
2265
- }, mt = ".pdf", lr = (n) => URL.createObjectURL(n), ur = async (n) => {
2266
- const e = await (await fetch(n)).blob();
2267
- return lr(e);
2268
- }, dr = () => {
2269
- const { filename: n, pdfSrc: t } = J(), { downloadFilename: e } = Yt(), o = (i) => {
2270
- const c = e || i;
2271
- return c.endsWith(mt) ? c : `${c}${mt}`;
2272
- };
2273
- return { download: A(async () => {
2274
- if (!n || !t)
2275
- throw new Error("There is no PDF source to download");
2276
- const i = document.createElement("a");
2277
- i.href = await ur(t), i.download = o(n), document.body.appendChild(i), i.click(), document.body.removeChild(i);
2278
- }, [n, t]) };
2279
- }, Bo = {
2280
- "rp-go-to-Top": "_rp-go-to-Top_4e0yd_1"
2281
- }, pr = "_active_1yldl_11", Zo = {
2282
- "rp-zoom-wrapper": "_rp-zoom-wrapper_1yldl_1",
2283
- "rp-current-zoom-wrapper": "_rp-current-zoom-wrapper_1yldl_6",
2284
- active: pr,
2285
- "rp-current-zoom-icon": "_rp-current-zoom-icon_1yldl_15",
2286
- "rp-zoom-level-icon": "_rp-zoom-level-icon_1yldl_20",
2287
- "rp-current-zoom-text": "_rp-current-zoom-text_1yldl_24",
2288
- "rp-zoom-dropdown-content": "_rp-zoom-dropdown-content_1yldl_28"
2289
- }, hr = "_loading_wazy2_1", Xo = {
2290
- "rp-loading-overlay": "_rp-loading-overlay_wazy2_1",
2291
- "rp-loading-modal": "_rp-loading-modal_wazy2_14",
2292
- "rp-loading-title": "_rp-loading-title_wazy2_27",
2293
- "rp-loading-progress-bar": "_rp-loading-progress-bar_wazy2_35",
2294
- "rp-loading-progress": "_rp-loading-progress_wazy2_35",
2295
- "rp-loading-cancel-button": "_rp-loading-cancel-button_wazy2_55",
2296
- loading: hr
2297
- }, Ko = {
2298
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_1sdl6_1",
2299
- "rp-sidebar-content": "_rp-sidebar-content_1sdl6_1",
2300
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_1sdl6_16",
2301
- "rp-thumbnail-dragging": "_rp-thumbnail-dragging_1sdl6_21"
2302
- }, ve = {
2303
- "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
2304
- "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
2305
- "rp-thumbnail": "_rp-thumbnail_3fenb_1",
2306
- "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
2307
- "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
2308
- }, fr = (n) => {
2309
- const { thumbnailSrc: t, pageNumber: e, isFocused: o, viewport: s } = n, { goToPage: i } = oe(), { pageRotate: c } = Le(), a = H(() => o ? ve["rp-thumbnail-active"] : "", [o]), d = H(() => ({
2310
- width: Math.round(s.width),
2311
- height: Math.round(s.height)
2312
- }), [s]), f = A(() => {
2313
- e && i(e);
2314
- }, [i, e]);
2315
- return /* @__PURE__ */ je(
2316
- "div",
2317
- {
2318
- onClick: f,
2319
- id: `page-${e}`,
2320
- className: ve["rp-thumbnail-wrapper"],
2321
- children: [
2322
- /* @__PURE__ */ z(
2323
- "div",
2324
- {
2325
- style: {
2326
- transform: `rotate(${c[e || 0]}deg)`
2327
- },
2328
- className: he(a, ve["rp-thumbnail"]),
2329
- children: t ? /* @__PURE__ */ z(
2330
- "img",
2331
- {
2332
- src: t,
2333
- width: d.width,
2334
- height: d.height,
2335
- alt: "thumbnail"
2336
- }
2337
- ) : /* @__PURE__ */ z(
2338
- "div",
2339
- {
2340
- className: ve["rp-thumbnail-loader"],
2341
- style: {
2342
- width: `${d.width}px`,
2343
- height: `${d.height}px`
2344
- },
2345
- children: /* @__PURE__ */ z(Ct, {})
2346
- }
2347
- )
2348
- }
2349
- ),
2350
- /* @__PURE__ */ z("div", { className: ve["rp-thumbnail-text"], children: e })
2351
- ]
2352
- }
2353
- );
2354
- }, _t = {
2355
- "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
2356
- "rp-thumbnails": "_rp-thumbnails_16vqr_1"
2357
- }, gr = 16, mr = (n, t) => {
2358
- const e = n == null ? void 0 : n.querySelector(`#page-${t}`);
2359
- n && (e != null && e.offsetTop) && (n.scrollTop = (e == null ? void 0 : e.offsetTop) - gr);
2360
- }, Yo = Ze((n, t) => {
2361
- const { show: e } = n, { focusedPage: o, totalPages: s } = oe(), { thumbnailPages: i, addPage: c, thumbnailLength: a, addToPage: d } = Ln(), f = D(null), g = D(1);
2362
- wt(t, () => f.current);
2363
- const w = H(() => Object.values(i), [i]), l = A(() => {
2364
- const _ = a + 1;
2365
- _ <= s && c(_);
2366
- }, [c, s, a]);
2367
- return F(() => {
2368
- o > a ? d(o) : e && g.current !== o && (mr(f.current, o), g.current = o);
2369
- }, [o, a, d, e, w]), en(f.current, l), /* @__PURE__ */ z("div", { ref: f, className: _t["rp-thumbnails-container"], children: /* @__PURE__ */ z("div", { className: _t["rp-thumbnails"], children: e ? w.map((_, b) => {
2370
- var P, C;
2371
- return /* @__PURE__ */ z(
2372
- fr,
2373
- {
2374
- isFocused: o === ((P = _.page) == null ? void 0 : P.pageNumber),
2375
- pageNumber: (C = _.page) == null ? void 0 : C.pageNumber,
2376
- thumbnailSrc: _.thumbnailSrc,
2377
- loading: _.loading,
2378
- viewport: _.viewport,
2379
- defaultRotation: _.defaultRotation
2380
- },
2381
- b
2382
- );
2383
- }) : null }) });
2384
- }), Jo = {
2385
- "rp-toolbar-layout": "_rp-toolbar-layout_vwobs_1",
2386
- "rp-content": "_rp-content_vwobs_7",
2387
- "rp-topbar-content": "_rp-topbar-content_vwobs_13",
2388
- "rp-sidebar-content": "_rp-sidebar-content_vwobs_22",
2389
- "rp-pages": "_rp-pages_vwobs_32",
2390
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_vwobs_37"
2391
- };
2392
- export {
2393
- An as A,
2394
- Dn as B,
2395
- On as C,
2396
- Hn as D,
2397
- Ke as E,
2398
- nr as F,
2399
- sr as G,
2400
- ir as H,
2401
- ar as I,
2402
- fr as J,
2403
- zn as L,
2404
- Do as P,
2405
- qo as R,
2406
- $o as S,
2407
- Ho as T,
2408
- dr as a,
2409
- Rn as b,
2410
- Mn as c,
2411
- Ae as d,
2412
- ko as e,
2413
- Ln as f,
2414
- Vo as g,
2415
- Zo as h,
2416
- Go as i,
2417
- Ko as j,
2418
- Yo as k,
2419
- Xo as l,
2420
- Jo as m,
2421
- jo as n,
2422
- Bo as o,
2423
- Uo as p,
2424
- yt as q,
2425
- Pn as r,
2426
- Pt as s,
2427
- Tn as t,
2428
- oe as u,
2429
- Tt as v,
2430
- In as w,
2431
- Rt as x,
2432
- En as y,
2433
- It as z
2434
- };