@pdf-viewer/react 0.6.0-beta.4 → 0.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/RPDefaultLayout-4d897afb.js +2713 -0
  2. package/dist/assets/RPDefaultLayout.css +1 -0
  3. package/dist/components/RPController.js +66 -16
  4. package/dist/components/{RPViewer.js → RPPages.js} +18 -13
  5. package/dist/components/RPProvider.js +30 -0
  6. package/dist/components/layout/{RPLayout.js → RPDefaultLayout.js} +2 -5
  7. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  8. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  9. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  10. package/dist/components/layout/toolbar/DocumentDialog.js +17 -8
  11. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  12. package/dist/components/layout/toolbar/MostPageTool.js +19 -9
  13. package/dist/components/layout/toolbar/OtherTool.js +1 -1
  14. package/dist/components/layout/toolbar/Paginate.js +1 -1
  15. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  16. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  17. package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -2
  18. package/dist/components/layout/toolbar/SearchTool.js +17 -8
  19. package/dist/components/layout/toolbar/ZoomTool.js +17 -9
  20. package/dist/components/page/AnnotationLayer.js +19 -10
  21. package/dist/components/page/CanvasLayer.js +18 -8
  22. package/dist/components/page/DualPage.js +1 -1
  23. package/dist/components/page/RPPage.js +18 -9
  24. package/dist/components/page/SinglePage.js +1 -1
  25. package/dist/components/page/TextLayer.js +18 -8
  26. package/dist/components/ui/LoadingIndicator.js +1 -1
  27. package/dist/contexts/LayoutContainerContext.js +10 -7
  28. package/dist/contexts/{PaginateContext.js → PaginationContext.js} +4 -4
  29. package/dist/contexts/PrintContext.js +2 -2
  30. package/dist/contexts/{RotateContext.js → RotationContext.js} +5 -5
  31. package/dist/contexts/SearchContext.js +1 -1
  32. package/dist/contexts/ThumbnailsContext.js +2 -2
  33. package/dist/main.js +32 -32
  34. package/dist/types/components/RPPages.d.ts +2 -0
  35. package/dist/types/components/RPProvider.d.ts +3 -0
  36. package/dist/types/components/layout/RPDefaultLayout.d.ts +2 -0
  37. package/dist/types/contexts/LayoutContainerContext.d.ts +4 -2
  38. package/dist/types/contexts/{PaginateContext.d.ts → PaginationContext.d.ts} +1 -1
  39. package/dist/types/contexts/{RotateContext.d.ts → RotationContext.d.ts} +1 -1
  40. package/dist/types/main.d.ts +7 -7
  41. package/dist/types/utils/hooks/useFileDownload.d.ts +1 -1
  42. package/dist/types/utils/types.d.ts +5 -6
  43. package/dist/utils/hooks/useFileDownload.js +19 -9
  44. package/dist/utils/hooks/useLicense.js +1 -1
  45. package/dist/utils/hooks/useLoadPdf.js +27 -27
  46. package/dist/utils/hooks/useLoadWorker.js +1 -1
  47. package/dist/utils/hooks/usePageDimension.js +1 -1
  48. package/dist/utils/hooks/usePaginate.js +17 -9
  49. package/dist/utils/hooks/usePrint.js +18 -8
  50. package/dist/utils/hooks/useRotate.js +4 -4
  51. package/dist/utils/hooks/useScrollToPage.js +18 -11
  52. package/dist/utils/hooks/useSearch.js +23 -12
  53. package/dist/utils/hooks/useThumbnail.js +18 -8
  54. package/dist/utils/hooks/useVirtualReactWindow.js +17 -10
  55. package/package.json +1 -1
  56. package/dist/RPLayout-fab06e11.js +0 -2760
  57. package/dist/assets/RPLayout.css +0 -1
  58. package/dist/components/RPDocument.js +0 -18
  59. package/dist/types/components/RPDocument.d.ts +0 -3
  60. package/dist/types/components/RPViewer.d.ts +0 -2
  61. package/dist/types/components/layout/RPLayout.d.ts +0 -2
@@ -1,2760 +0,0 @@
1
- import { jsx as a, jsxs as O, Fragment as Ae } from "react/jsx-runtime";
2
- import * as V from "react";
3
- import { useRef as $, useEffect as A, useCallback as M, useState as F, useMemo as D, createContext as We, useContext as He, forwardRef as $e, useImperativeHandle as Zt, createElement as Le, PureComponent as Fn, Component as kn, memo as Wn } from "react";
4
- import { ChevronUpIcon as Me } from "./components/icons/ChevronUpIcon.js";
5
- import { UIButton as B } from "./components/ui/Button.js";
6
- import { UIInput as jt } from "./components/ui/Input.js";
7
- import { useScrollModeContext as Pe, ScrollModeProvider as Hn } from "./contexts/ScrollModeContext.js";
8
- import { useDocumentContext as Y } from "./contexts/RPDocumentContext.js";
9
- import "./components/RPConfig.js";
10
- import { ThumbnailIcon as $n } from "./components/icons/Thumbnail.js";
11
- import { c as j } from "./clsx-0c6e471a.js";
12
- import { LoaderIcon as pt } from "./components/icons/LoaderIcon.js";
13
- import { renderPage as ot } from "./utils/renderPage.js";
14
- import "./contexts/ThemeContext.js";
15
- import { RPDropFileZone as Vn } from "./components/RPDropFileZone.js";
16
- import { DropFileZoneProvider as Gn } from "./contexts/DropFileZoneContext.js";
17
- import { DarkModeProvider as Un } from "./contexts/DarkModeContext.js";
18
- import { useToolbarComponentContext as se, ToolbarComponentProvider as qn } from "./contexts/ToolbarComponentContext.js";
19
- import { useRotateContext as Ve, RotateProvider as Zn } from "./contexts/RotateContext.js";
20
- import { useViewModeContext as Ge, ViewModeProvider as jn } from "./contexts/ViewModeContext.js";
21
- import { FileInputProvider as Bn } from "./contexts/FileInputContext.js";
22
- import { useZoomContext as ht, ZoomProvider as Kn } from "./contexts/ZoomContext.js";
23
- import { findMatches as Xn, resetDivs as Jn, highlightMatches as Yn } from "./utils/highlight.js";
24
- import { useVirtualScrollContext as Ue, VirtualScrollProvider as Qn } from "./contexts/VirtualScrollContext.js";
25
- import * as er from "pdfjs-dist";
26
- import { AnnotationLayer as tr, PixelsPerInch as nr, AnnotationMode as rr, RenderingCancelledException as or } from "pdfjs-dist";
27
- import { getThumbnailViewport as It } from "./utils/getThumbnailViewport.js";
28
- import { useInfiniteScroll as ar } from "./utils/hooks/useInfiniteScroll.js";
29
- import { RPSplitter as ir } from "./components/layout/sidebar/RPSplitter.js";
30
- import { useIconContext as re, IconProvider as sr } from "./contexts/IconContext.js";
31
- import X from "./components/ui/RPTooltip.js";
32
- import { c as he, C as lr } from "./Container-83627c27.js";
33
- import { useLayoutContainer as qe, LayoutContainerProvider as cr } from "./contexts/LayoutContainerContext.js";
34
- import { ViewMode as ze, ScrollMode as Q, AnnotationSubType as at, SelectionMode as Bt, ZoomLevel as we } from "./utils/types.js";
35
- import { useLayerContext as ur, LayerProvider as dr } from "./contexts/LayerContext.js";
36
- import { useVirtualGridContext as Kt, VirtualGridProvider as pr } from "./contexts/VirtualGridContext.js";
37
- import { useScrollStateContext as Xt, ScrollStateProvider as hr } from "./contexts/ScrollStateContext.js";
38
- import { useViewportContext as ge, ViewportProvider as fr } from "./contexts/ViewportContext.js";
39
- import { useSelectionModeContext as mr, SelectionModeProvider as gr } from "./contexts/SelectionModeContext.js";
40
- import { useInitialStateContext as vr, InitialStateProvider as _r } from "./contexts/InitialStateContext.js";
41
- import { useFullScreenContext as wr, FullScreenProvider as br } from "./contexts/FullScreenContext.js";
42
- import { WrapperLayout as Cr } from "./components/layout/WrapperLayout.js";
43
- import { SimpleLinkService as Pr } from "./utils/link_service.js";
44
- import { dateFormatter as it } from "./utils/dateFormatter.js";
45
- import { sanitizeExternalUrl as Sr } from "./utils/sanitizeExternalUrl.js";
46
- import { useWatermark as Tr } from "./utils/hooks/useWatermark.js";
47
- import { usePageDimension as Jt } from "./utils/hooks/usePageDimension.js";
48
- import { useMousePressed as Ir } from "./utils/hooks/useMousePressed.js";
49
- import { useGrabScroll as yr } from "./utils/hooks/useGrabScroll.js";
50
- import { useDebounce as Rr } from "./utils/hooks/useDebounce.js";
51
- import { appConsole as xr } from "./utils/appConsole.js";
52
- import { FileUploadTool as Yt } from "./components/layout/toolbar/FileUploadTool.js";
53
- import { DarkModeTool as Mr } from "./components/layout/toolbar/DarkModeTool.js";
54
- import { ThreeDotIcon as Nr } from "./components/icons/ThreeDotIcon.js";
55
- import { UIDropDown as ft } from "./components/ui/DropDown.js";
56
- import { u as mt, a as Ne, c as xe, b as gt, d as Lr, e as Er, h as Or, f as Dr, F as Ar, D as zr, g as Be, i as Fr, G as Fe } from "./index-3459164c.js";
57
- import { c as kr, e as Wr, a as Hr } from "./index-743c36f0.js";
58
- import { CloseIcon as Qt } from "./components/icons/CloseIcon.js";
59
- import { PropertyItem as $r } from "./components/layout/toolbar/PropertyItem.js";
60
- import { useOtherToolContext as Vr, OtherToolProvider as Gr } from "./contexts/OtherToolContext.js";
61
- import { DocumentProperties as Ur } from "./components/layout/toolbar/DocumentProperties.js";
62
- import { RotateTool as qr } from "./components/layout/toolbar/RotateTool.js";
63
- import { ScrollModeTool as Zr } from "./components/layout/toolbar/ScrollModeTool.js";
64
- import { MenuSeparator as vt } from "./components/layout/toolbar/MenuSeparator.js";
65
- import { FileDownloadDefaultIcon as jr } from "./components/icons/FileDownloadDefaultIcon.js";
66
- import { MenuItem as ce } from "./components/layout/toolbar/MenuItem.js";
67
- import { PrintDefaultTool as Br } from "./components/icons/PrintDefaultIcon.js";
68
- import { FullScreenTool as en } from "./components/layout/toolbar/FullScreenTool.js";
69
- import { GoToDownIcon as tn } from "./components/icons/GoToDownIcon.js";
70
- import { SelectionModeTool as Kr } from "./components/layout/toolbar/SelectionModeTool.js";
71
- import { ZoomInIcon as Xr } from "./components/icons/ZoomInIcon.js";
72
- import { ZoomOutIcon as Jr } from "./components/icons/ZoomOutIcon.js";
73
- import { PAGE_PADDING as yt } from "./utils/constants.js";
74
- import { SearchIcon as Yr } from "./components/icons/SearchIcon.js";
75
- import { UICheckbox as Rt } from "./components/ui/Checkbox.js";
76
- import { ClearIcon as Qr } from "./components/icons/ClearIcon.js";
77
- import './assets/RPLayout.css';const ae = {
78
- "rp-pages": "_rp-pages_34orh_1",
79
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_34orh_7",
80
- "rp-pages-container": "_rp-pages-container_34orh_11",
81
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_34orh_17",
82
- "rp-viewer": "_rp-viewer_34orh_22",
83
- "rp-cursor-grab": "_rp-cursor-grab_34orh_27",
84
- "rp-cursor-grabbing": "_rp-cursor-grabbing_34orh_35"
85
- }, Ke = {
86
- "rp-page-wrapper": "_rp-page-wrapper_h7a2q_1",
87
- "rp-page": "_rp-page_h7a2q_1",
88
- "rp-loader-wrapper": "_rp-loader-wrapper_h7a2q_14"
89
- }, eo = (e) => {
90
- const { pageNumber: t, onLoaded: n, onLoading: r } = e, o = $(null), { pages: i } = Y(), { rotate: l } = Ve(), s = $(), { currentZoom: c } = ht();
91
- return A(() => {
92
- if (!i || c === 0)
93
- return;
94
- const p = i.get(t);
95
- if (o.current && p) {
96
- const h = o.current;
97
- h.hidden = !0;
98
- const m = s.current;
99
- m && m.cancel(), r && r(), s.current = ot(p.page, h, c, l), s.current.promise.then(() => {
100
- h.hidden = !1;
101
- }).catch((u) => {
102
- }).finally(() => {
103
- n && n();
104
- });
105
- }
106
- }, [i, t, l, c, r, n]), /* @__PURE__ */ a("canvas", { "data-rp": `page-${t}-canvas`, ref: o });
107
- }, Xe = {
108
- "rp-text-layer": "_rp-text-layer_1mgyz_1",
109
- "rp-text-layer-text": "_rp-text-layer-text_1mgyz_9"
110
- }, _t = () => {
111
- const { viewMode: e } = Ge(), { scrollMode: t } = Pe(), { virtualScrollRef: n, pageScrollElementRef: r } = Ue(), { setFocusedPage: o } = ee(), i = $(), { columnCount: l } = Kt(), s = Jt(), c = $(t), p = $(e);
112
- A(() => {
113
- n != null && n.scrollToItem && (i.current = n);
114
- }, [n]);
115
- const h = M(
116
- (u) => {
117
- if (!r)
118
- return;
119
- const f = Math.ceil(u / 2) * 2 - 1;
120
- u === f + 1 ? r.scrollTo({ left: s.widths[f], top: 0 }) : r.scrollTo({ left: 0, top: 0 });
121
- },
122
- [r, s]
123
- );
124
- return A(() => {
125
- c.current = t, p.current = e;
126
- }, [t, e]), { scrollToPage: M(
127
- (u, f = "start") => {
128
- const g = u - 1;
129
- let _ = g, v = 0;
130
- if (p.current === ze.DUAL_PAGE && c.current === Q.PAGE_SCROLLING) {
131
- h(u);
132
- return;
133
- }
134
- if (c.current === Q.PAGE_SCROLLING) {
135
- o(u);
136
- return;
137
- }
138
- i.current && (c.current === Q.HORIZONTAL_SCROLLING ? v = g : p.current === ze.DUAL_PAGE && (v = g % 2, _ = Math.floor(g / 2)), i.current.scrollToItem({ rowIndex: _, columnIndex: v, align: f }));
139
- },
140
- [l, h, o]
141
- ) };
142
- }, to = (e = {}, t = "") => {
143
- const [n, r] = F(t), [o, i] = F(!1), { pdf: l } = Y(), s = $(!n), [c, p] = F([]), [h, m] = F(0), { focusedPage: u } = ee(), { scrollToPage: f } = _t(), { virtualScrollRef: g, pageScrollElementRef: _, virtualScrollableElementRef: v } = Ue(), { scrollMode: b } = Pe(), [S, P] = F(null), T = D(() => h === 0 ? null : c[h - 1], [h, c]), d = D(() => c.length, [c]);
144
- A(() => {
145
- if (T && u !== T.page) {
146
- const y = u < T.page ? "start" : "end";
147
- f(T.page, y);
148
- }
149
- }, [T, f]), A(() => {
150
- if (!T || u !== T.page || !S || !S.classList.contains("selected"))
151
- return;
152
- const y = v || _;
153
- if (!y)
154
- return;
155
- const R = S.getBoundingClientRect(), N = y.clientHeight / 2, L = y.clientWidth / 2, x = y.scrollTop + R.top - N, E = y.scrollLeft + R.left - L;
156
- y.scrollTo({
157
- top: x,
158
- left: E,
159
- behavior: "smooth"
160
- });
161
- }, [
162
- u,
163
- g,
164
- S,
165
- b,
166
- v,
167
- _
168
- ]);
169
- const C = M(() => {
170
- m((y) => d ? y + 1 > d ? 1 : y + 1 : 0);
171
- }, [d]), w = M(() => {
172
- m((y) => d ? y - 1 <= 0 ? d : y - 1 : 0);
173
- }, [d]), I = M(async (y) => {
174
- if (!y)
175
- return {};
176
- const R = y.numPages, N = {};
177
- for (let L = 1; L <= R; L++) {
178
- if (s.current)
179
- throw "close pop over";
180
- const x = await y.getPage(L);
181
- N[L.toString()] = await x.getTextContent();
182
- }
183
- return N;
184
- }, []);
185
- return A(() => {
186
- if (!n) {
187
- s.current = !0, p([]), m(0);
188
- return;
189
- }
190
- s.current = !1, i(!0), p([]), m(0), I(l).then((y) => {
191
- const N = Object.keys(y).reduce((L, x) => {
192
- const E = Xn(
193
- [n],
194
- y[x],
195
- Number(x) - 1,
196
- e
197
- ).map((z, k) => ({ ...z, page: Number(x), pageMatchIdx: k }));
198
- return [...L, ...E];
199
- }, []);
200
- p(N), m(N.length ? 1 : 0);
201
- }).catch(() => {
202
- p([]), m(0);
203
- }).finally(() => i(!1));
204
- }, [n, I, l, e]), {
205
- search: n,
206
- setSearch: r,
207
- loading: o,
208
- matches: c,
209
- totalMatches: d,
210
- currentMatchPosition: h,
211
- currentMatch: T,
212
- nextMatch: C,
213
- prevMatch: w,
214
- currentMatchElement: S,
215
- setCurrentMatchElement: P
216
- };
217
- }, nn = We({
218
- search: "",
219
- setSearch: (e) => {
220
- },
221
- loading: !1,
222
- matches: [],
223
- totalMatches: 0,
224
- currentMatchPosition: 0,
225
- currentMatch: null,
226
- nextMatch: () => {
227
- },
228
- prevMatch: () => {
229
- },
230
- searchOptions: {},
231
- setSearchOptions: (e) => e,
232
- currentMatchElement: null,
233
- setCurrentMatchElement: (e) => {
234
- }
235
- }), no = ({
236
- children: e,
237
- initialSearch: t
238
- }) => {
239
- const [n, r] = F({}), {
240
- loading: o,
241
- setSearch: i,
242
- totalMatches: l,
243
- currentMatchPosition: s,
244
- currentMatch: c,
245
- search: p,
246
- matches: h,
247
- nextMatch: m,
248
- prevMatch: u,
249
- currentMatchElement: f,
250
- setCurrentMatchElement: g
251
- } = to(n, t);
252
- return /* @__PURE__ */ a(
253
- nn.Provider,
254
- {
255
- value: {
256
- searchOptions: n,
257
- setSearchOptions: r,
258
- loading: o,
259
- setSearch: i,
260
- totalMatches: l,
261
- currentMatchPosition: s,
262
- currentMatch: c,
263
- nextMatch: m,
264
- prevMatch: u,
265
- search: p,
266
- matches: h,
267
- currentMatchElement: f,
268
- setCurrentMatchElement: g
269
- },
270
- children: e
271
- }
272
- );
273
- }, rn = () => He(nn), ro = (e) => {
274
- const { pageNumber: t } = e, { pages: n } = Y(), r = $(null), { matches: o, currentMatch: i, setCurrentMatchElement: l } = rn(), [s, c] = F(
275
- []
276
- ), p = $(), h = $(), m = $(), u = D(() => o.filter((g) => g.pageIndex === t - 1), [o, t]), f = M(
277
- (g, _, v = !1) => {
278
- if (v && Jn(g, _), !u.length) {
279
- m.current = void 0, c([]);
280
- return;
281
- }
282
- const b = Yn(u, g, _);
283
- c(b);
284
- },
285
- [u]
286
- );
287
- return A(() => {
288
- var v;
289
- if ((v = m.current) == null || v.classList.remove("selected"), !s.length || !i || i.pageIndex !== t - 1)
290
- return;
291
- const g = u.findIndex(
292
- (b) => JSON.stringify(b) === JSON.stringify(i)
293
- );
294
- if (g === -1)
295
- return;
296
- const _ = s.find((b) => b.index === g);
297
- _ && (m.current = _.element, l(_.element), _.element.classList.add("selected"));
298
- }, [i, s, u]), A(() => {
299
- const g = n.get(t);
300
- if (!(!g || !r.current))
301
- return p.current && p.current.cancel(), g.page.getTextContent().then((_) => {
302
- const v = g.page.getViewport({ scale: 1 });
303
- return p.current = new er.TextLayer({
304
- viewport: v,
305
- textContentSource: _,
306
- container: r.current
307
- }), h.current = _, r.current && (r.current.innerText = ""), p.current.render();
308
- }).then(() => {
309
- var b;
310
- [].slice.call(r.current.children).forEach((S) => {
311
- S.classList.add(Xe["rp-text-layer-text"]);
312
- });
313
- const v = (b = p.current) == null ? void 0 : b.textDivs;
314
- v && h.current && f(h.current, v);
315
- }).catch(() => {
316
- }), () => {
317
- var _;
318
- (_ = p.current) == null || _.cancel();
319
- };
320
- }, [n, t]), A(() => {
321
- var v;
322
- [].slice.call(r.current.children).forEach((b) => {
323
- b.classList.add(Xe["rp-text-layer-text"]);
324
- });
325
- const _ = (v = p.current) == null ? void 0 : v.textDivs;
326
- _ && h.current && f(h.current, _, !0);
327
- }, [f]), /* @__PURE__ */ a(
328
- "div",
329
- {
330
- "data-rp": `page-${t}-textLayer`,
331
- className: Xe["rp-text-layer"],
332
- ref: r
333
- }
334
- );
335
- }, oo = {
336
- "rp-annotation-layer": "_rp-annotation-layer_o0ksd_1"
337
- }, on = ["click", "dblclick", "mouseover", "input", "change"];
338
- let ao = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
339
- const st = /* @__PURE__ */ new Map(), an = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
340
- function io(e, t) {
341
- const n = an(e, t);
342
- return st.has(n) ? st.get(n) ?? null : null;
343
- }
344
- const so = (e, t, n) => {
345
- st.set(an(e, t), n);
346
- }, xt = (e, t) => {
347
- switch (t[1].name) {
348
- case "XYZ":
349
- return {
350
- bottomOffset: (n, r) => t[3] === null ? r : t[3],
351
- leftOffset: (n, r) => t[2] === null ? 0 : t[2],
352
- pageIndex: e,
353
- scaleTo: t[4]
354
- };
355
- case "Fit":
356
- case "FitB":
357
- return {
358
- bottomOffset: 0,
359
- leftOffset: 0,
360
- pageIndex: e,
361
- scaleTo: 1
362
- };
363
- case "FitH":
364
- case "FitBH":
365
- return {
366
- bottomOffset: t[2],
367
- leftOffset: 0,
368
- pageIndex: e,
369
- scaleTo: 1
370
- };
371
- default:
372
- return {
373
- bottomOffset: 0,
374
- leftOffset: 0,
375
- pageIndex: e,
376
- scaleTo: 1
377
- };
378
- }
379
- };
380
- async function sn(e, t) {
381
- let n;
382
- if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
383
- const r = n[0], o = io(e, r);
384
- if (o === null) {
385
- const i = await e.getPageIndex(r);
386
- return so(e, r, i), await sn(e, n);
387
- } else
388
- return xt(o, n);
389
- } else
390
- return xt(n[0], n);
391
- }
392
- function lo(e) {
393
- const { id: t, url: n, unsafeUrl: r } = e;
394
- new MutationObserver((i, l) => {
395
- const s = document.querySelector(`[data-annotation-id="${t}"]`);
396
- if (s) {
397
- const c = s.querySelector("a"), p = Sr((n || r) ?? "", "");
398
- c && (c.setAttribute("target", "_blank"), c.setAttribute("href", p), c.setAttribute("rel", "noopener noreferrer")), l.disconnect();
399
- }
400
- }).observe(document.body, { childList: !0, subtree: !0 });
401
- }
402
- const co = (e) => {
403
- const n = e.target.parentNode;
404
- if (!n)
405
- return;
406
- const r = new MutationObserver((o) => {
407
- o.forEach(() => {
408
- n.querySelectorAll(
409
- '[data-l10n-id="pdfjs-annotation-date-time-string"]'
410
- ).forEach((l) => {
411
- const s = l.getAttribute("data-l10n-args");
412
- if (s)
413
- try {
414
- const { dateObj: c } = JSON.parse(s);
415
- l.textContent = it(c);
416
- } catch {
417
- }
418
- });
419
- });
420
- });
421
- return r.observe(n, {
422
- childList: !0,
423
- // Watch for changes to child elements
424
- subtree: !0,
425
- // Watch all descendants, not just direct children
426
- attributes: !0
427
- // Watch for changes to attributes
428
- }), () => r.disconnect();
429
- }, Mt = (e, t, n, r) => {
430
- if (e.type !== "click")
431
- return;
432
- const o = e.target, i = o.getAttribute("data-element-id"), l = o.getAttribute("href");
433
- if (l && l !== "#")
434
- return;
435
- const s = t.find((c) => c.id === i);
436
- !s || s.annotationType !== at.Link || s.dest && sn(n, s.dest).then((c) => {
437
- r(c);
438
- });
439
- };
440
- function uo(e, t) {
441
- for (const n of on)
442
- e.addEventListener(n, t);
443
- }
444
- function Nt(e, t) {
445
- for (const n of on)
446
- e.removeEventListener(n, t);
447
- }
448
- const po = (e) => {
449
- const { pageNumber: t } = e, n = $(null), { pages: r, pdf: o } = Y(), i = $(), [l, s] = F(), { setFocusedPage: c, goToPage: p } = ee(), { scrollMode: h } = Pe(), m = D(() => r.get(t), [r, t]), u = D(() => m == null ? void 0 : m.page.getViewport(), [m]);
450
- A(() => {
451
- i.current && (i.current.div.replaceChildren(), i.current = void 0);
452
- }, [o]);
453
- const f = D(() => o == null ? void 0 : o.annotationStorage, [o]);
454
- A(() => {
455
- m && m.page.getAnnotations().then((_) => {
456
- i.current = void 0, s(_), n.current && (n.current.innerText = "");
457
- });
458
- }, [m]);
459
- const g = M(
460
- (_) => {
461
- co(_), !(!l || !o) && (h === Q.PAGE_SCROLLING ? Mt(_, l, o, (v) => c(v.pageIndex + 1)) : Mt(_, l, o, (v) => p(v.pageIndex + 1)));
462
- },
463
- [o, l, p, c, h]
464
- );
465
- return A(() => {
466
- if (!m || !l)
467
- return;
468
- const _ = m.page.getViewport();
469
- if (i.current) {
470
- i.current.update({
471
- viewport: _.clone({ dontFlip: !0 })
472
- });
473
- return;
474
- }
475
- for (const b of l) {
476
- const { annotationType: S } = b;
477
- switch (S) {
478
- case at.Link:
479
- lo(b);
480
- break;
481
- case at.Widget:
482
- break;
483
- }
484
- }
485
- return (async () => {
486
- i.current = new tr({
487
- div: n.current,
488
- accessibilityManager: void 0,
489
- annotationCanvasMap: void 0,
490
- annotationEditorUIManager: void 0,
491
- structTreeLayer: void 0,
492
- page: m.page,
493
- viewport: _.clone({ dontFlip: !0 })
494
- }), n.current && Nt(n.current, g);
495
- const b = await (o == null ? void 0 : o.hasJSActions()), S = await (o == null ? void 0 : o.getFieldObjects());
496
- return i.current.render({
497
- annotations: l,
498
- annotationStorage: f,
499
- hasJSActions: b,
500
- fieldObjects: S,
501
- div: n.current,
502
- viewport: _.clone({ dontFlip: !0 }),
503
- page: m.page,
504
- imageResourcesPath: ao,
505
- renderForms: !1,
506
- linkService: new Pr(),
507
- downloadManager: null,
508
- enableScripting: !1
509
- });
510
- })().then(() => {
511
- n.current && uo(n.current, g);
512
- }), () => {
513
- n.current && Nt(n.current, g);
514
- };
515
- }, [o, l, g]), /* @__PURE__ */ a(
516
- "div",
517
- {
518
- "data-rp": `page-${t}-annotationLayer`,
519
- style: { width: `${u == null ? void 0 : u.width}px`, height: `${u == null ? void 0 : u.height}px` },
520
- className: oo["rp-annotation-layer"],
521
- ref: n
522
- }
523
- );
524
- }, ho = Array.from({ length: 21 }, (e, t) => Number((t * 0.05).toFixed(2))), wt = $e((e, t) => {
525
- const { pageNumber: n, style: r, onIntersectRatioChange: o, ...i } = e, { pages: l } = Y(), { rotate: s } = Ve(), { textLayer: c } = ur(), { currentZoom: p } = ht(), h = $(l.get(n)), [m, u] = F(!1), f = $(null), [g, _] = F({
526
- width: 0,
527
- height: 0
528
- });
529
- Zt(t, () => f.current), A(() => {
530
- if (l && (h.current = l.get(n), h.current)) {
531
- const P = h.current.page.getViewport({ scale: p, rotation: s });
532
- _(P);
533
- }
534
- }, [l, n, s, p]);
535
- const v = D(() => {
536
- switch (s) {
537
- case 90:
538
- return `${g.width / 2}px ${g.width / 2}px`;
539
- case -90:
540
- case 270:
541
- return `${g.height / 2}px ${g.height / 2}px`;
542
- default:
543
- return "center";
544
- }
545
- }, [s, g]), b = M(() => {
546
- u(!0);
547
- }, []), S = M(() => {
548
- u(!1);
549
- }, []);
550
- return A(() => {
551
- const P = new IntersectionObserver(
552
- (T) => {
553
- o && o(n, T[0].intersectionRatio);
554
- },
555
- { threshold: ho }
556
- );
557
- return f.current && P.observe(f.current), () => {
558
- P.disconnect(), o && o(n, -1);
559
- };
560
- }, [o, n, s]), /* @__PURE__ */ a(
561
- "div",
562
- {
563
- ref: f,
564
- id: `page-${n}`,
565
- "data-rp": `page-${n}`,
566
- ...i,
567
- style: {
568
- ...r,
569
- "--rp-rotate": `${s}deg`,
570
- "--rp-page-rotate-translate": `${v}`,
571
- "--scale-factor": p
572
- },
573
- className: Ke["rp-page-wrapper"],
574
- children: /* @__PURE__ */ O(
575
- "div",
576
- {
577
- style: {
578
- width: `${g.width}px`,
579
- height: `${g.height}px`
580
- },
581
- className: Ke["rp-page"],
582
- children: [
583
- /* @__PURE__ */ a(eo, { onLoading: b, onLoaded: S, pageNumber: n }),
584
- m && /* @__PURE__ */ a("div", { className: Ke["rp-loader-wrapper"], children: /* @__PURE__ */ a(pt, {}) }),
585
- c && /* @__PURE__ */ a(ro, { pageNumber: n }),
586
- /* @__PURE__ */ a(po, { pageNumber: n })
587
- ]
588
- }
589
- )
590
- }
591
- );
592
- });
593
- function lt() {
594
- return lt = Object.assign ? Object.assign.bind() : function(e) {
595
- for (var t = 1; t < arguments.length; t++) {
596
- var n = arguments[t];
597
- for (var r in n)
598
- ({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
599
- }
600
- return e;
601
- }, lt.apply(null, arguments);
602
- }
603
- function Lt(e) {
604
- if (e === void 0)
605
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
606
- return e;
607
- }
608
- function ct(e, t) {
609
- return ct = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, r) {
610
- return n.__proto__ = r, n;
611
- }, ct(e, t);
612
- }
613
- function fo(e, t) {
614
- e.prototype = Object.create(t.prototype), e.prototype.constructor = e, ct(e, t);
615
- }
616
- var Et = Number.isNaN || function(t) {
617
- return typeof t == "number" && t !== t;
618
- };
619
- function mo(e, t) {
620
- return !!(e === t || Et(e) && Et(t));
621
- }
622
- function go(e, t) {
623
- if (e.length !== t.length)
624
- return !1;
625
- for (var n = 0; n < e.length; n++)
626
- if (!mo(e[n], t[n]))
627
- return !1;
628
- return !0;
629
- }
630
- function Je(e, t) {
631
- t === void 0 && (t = go);
632
- var n, r = [], o, i = !1;
633
- function l() {
634
- for (var s = [], c = 0; c < arguments.length; c++)
635
- s[c] = arguments[c];
636
- return i && n === this && t(s, r) || (o = e.apply(this, s), i = !0, n = this, r = s), o;
637
- }
638
- return l;
639
- }
640
- function Ot(e, t) {
641
- if (e == null)
642
- return {};
643
- var n = {};
644
- for (var r in e)
645
- if ({}.hasOwnProperty.call(e, r)) {
646
- if (t.includes(r))
647
- continue;
648
- n[r] = e[r];
649
- }
650
- return n;
651
- }
652
- var vo = typeof performance == "object" && typeof performance.now == "function", Dt = vo ? function() {
653
- return performance.now();
654
- } : function() {
655
- return Date.now();
656
- };
657
- function At(e) {
658
- cancelAnimationFrame(e.id);
659
- }
660
- function _o(e, t) {
661
- var n = Dt();
662
- function r() {
663
- Dt() - n >= t ? e.call(null) : o.id = requestAnimationFrame(r);
664
- }
665
- var o = {
666
- id: requestAnimationFrame(r)
667
- };
668
- return o;
669
- }
670
- var Ye = -1;
671
- function wo(e) {
672
- if (e === void 0 && (e = !1), Ye === -1 || e) {
673
- var t = document.createElement("div"), n = t.style;
674
- n.width = "50px", n.height = "50px", n.overflow = "scroll", document.body.appendChild(t), Ye = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
675
- }
676
- return Ye;
677
- }
678
- var be = null;
679
- function zt(e) {
680
- if (e === void 0 && (e = !1), be === null || e) {
681
- var t = document.createElement("div"), n = t.style;
682
- n.width = "50px", n.height = "50px", n.overflow = "scroll", n.direction = "rtl";
683
- var r = document.createElement("div"), o = r.style;
684
- return o.width = "100px", o.height = "100px", t.appendChild(r), document.body.appendChild(t), t.scrollLeft > 0 ? be = "positive-descending" : (t.scrollLeft = 1, t.scrollLeft === 0 ? be = "negative" : be = "positive-ascending"), document.body.removeChild(t), be;
685
- }
686
- return be;
687
- }
688
- var bo = 150, Co = function(t) {
689
- var n = t.columnIndex;
690
- t.data;
691
- var r = t.rowIndex;
692
- return r + ":" + n;
693
- }, Ee = null, Oe = null, De = null;
694
- process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (Ee = /* @__PURE__ */ new WeakSet(), Oe = /* @__PURE__ */ new WeakSet(), De = /* @__PURE__ */ new WeakSet());
695
- function Po(e) {
696
- var t, n = e.getColumnOffset, r = e.getColumnStartIndexForOffset, o = e.getColumnStopIndexForStartIndex, i = e.getColumnWidth, l = e.getEstimatedTotalHeight, s = e.getEstimatedTotalWidth, c = e.getOffsetForColumnAndAlignment, p = e.getOffsetForRowAndAlignment, h = e.getRowHeight, m = e.getRowOffset, u = e.getRowStartIndexForOffset, f = e.getRowStopIndexForStartIndex, g = e.initInstanceProps, _ = e.shouldResetStyleCacheOnItemSizeChange, v = e.validateProps;
697
- return t = /* @__PURE__ */ function(b) {
698
- fo(S, b);
699
- function S(T) {
700
- var d;
701
- return d = b.call(this, T) || this, d._instanceProps = g(d.props, Lt(d)), d._resetIsScrollingTimeoutId = null, d._outerRef = void 0, d.state = {
702
- instance: Lt(d),
703
- isScrolling: !1,
704
- horizontalScrollDirection: "forward",
705
- scrollLeft: typeof d.props.initialScrollLeft == "number" ? d.props.initialScrollLeft : 0,
706
- scrollTop: typeof d.props.initialScrollTop == "number" ? d.props.initialScrollTop : 0,
707
- scrollUpdateWasRequested: !1,
708
- verticalScrollDirection: "forward"
709
- }, d._callOnItemsRendered = void 0, d._callOnItemsRendered = Je(function(C, w, I, y, R, N, L, x) {
710
- return d.props.onItemsRendered({
711
- overscanColumnStartIndex: C,
712
- overscanColumnStopIndex: w,
713
- overscanRowStartIndex: I,
714
- overscanRowStopIndex: y,
715
- visibleColumnStartIndex: R,
716
- visibleColumnStopIndex: N,
717
- visibleRowStartIndex: L,
718
- visibleRowStopIndex: x
719
- });
720
- }), d._callOnScroll = void 0, d._callOnScroll = Je(function(C, w, I, y, R) {
721
- return d.props.onScroll({
722
- horizontalScrollDirection: I,
723
- scrollLeft: C,
724
- scrollTop: w,
725
- verticalScrollDirection: y,
726
- scrollUpdateWasRequested: R
727
- });
728
- }), d._getItemStyle = void 0, d._getItemStyle = function(C, w) {
729
- var I = d.props, y = I.columnWidth, R = I.direction, N = I.rowHeight, L = d._getItemStyleCache(_ && y, _ && R, _ && N), x = C + ":" + w, E;
730
- if (L.hasOwnProperty(x))
731
- E = L[x];
732
- else {
733
- var z = n(d.props, w, d._instanceProps), k = R === "rtl";
734
- L[x] = E = {
735
- position: "absolute",
736
- left: k ? void 0 : z,
737
- right: k ? z : void 0,
738
- top: m(d.props, C, d._instanceProps),
739
- height: h(d.props, C, d._instanceProps),
740
- width: i(d.props, w, d._instanceProps)
741
- };
742
- }
743
- return E;
744
- }, d._getItemStyleCache = void 0, d._getItemStyleCache = Je(function(C, w, I) {
745
- return {};
746
- }), d._onScroll = function(C) {
747
- var w = C.currentTarget, I = w.clientHeight, y = w.clientWidth, R = w.scrollLeft, N = w.scrollTop, L = w.scrollHeight, x = w.scrollWidth;
748
- d.setState(function(E) {
749
- if (E.scrollLeft === R && E.scrollTop === N)
750
- return null;
751
- var z = d.props.direction, k = R;
752
- if (z === "rtl")
753
- switch (zt()) {
754
- case "negative":
755
- k = -R;
756
- break;
757
- case "positive-descending":
758
- k = x - y - R;
759
- break;
760
- }
761
- k = Math.max(0, Math.min(k, x - y));
762
- var G = Math.max(0, Math.min(N, L - I));
763
- return {
764
- isScrolling: !0,
765
- horizontalScrollDirection: E.scrollLeft < R ? "forward" : "backward",
766
- scrollLeft: k,
767
- scrollTop: G,
768
- verticalScrollDirection: E.scrollTop < N ? "forward" : "backward",
769
- scrollUpdateWasRequested: !1
770
- };
771
- }, d._resetIsScrollingDebounced);
772
- }, d._outerRefSetter = function(C) {
773
- var w = d.props.outerRef;
774
- d._outerRef = C, typeof w == "function" ? w(C) : w != null && typeof w == "object" && w.hasOwnProperty("current") && (w.current = C);
775
- }, d._resetIsScrollingDebounced = function() {
776
- d._resetIsScrollingTimeoutId !== null && At(d._resetIsScrollingTimeoutId), d._resetIsScrollingTimeoutId = _o(d._resetIsScrolling, bo);
777
- }, d._resetIsScrolling = function() {
778
- d._resetIsScrollingTimeoutId = null, d.setState({
779
- isScrolling: !1
780
- }, function() {
781
- d._getItemStyleCache(-1);
782
- });
783
- }, d;
784
- }
785
- S.getDerivedStateFromProps = function(d, C) {
786
- return So(d, C), v(d), null;
787
- };
788
- var P = S.prototype;
789
- return P.scrollTo = function(d) {
790
- var C = d.scrollLeft, w = d.scrollTop;
791
- C !== void 0 && (C = Math.max(0, C)), w !== void 0 && (w = Math.max(0, w)), this.setState(function(I) {
792
- return C === void 0 && (C = I.scrollLeft), w === void 0 && (w = I.scrollTop), I.scrollLeft === C && I.scrollTop === w ? null : {
793
- horizontalScrollDirection: I.scrollLeft < C ? "forward" : "backward",
794
- scrollLeft: C,
795
- scrollTop: w,
796
- scrollUpdateWasRequested: !0,
797
- verticalScrollDirection: I.scrollTop < w ? "forward" : "backward"
798
- };
799
- }, this._resetIsScrollingDebounced);
800
- }, P.scrollToItem = function(d) {
801
- var C = d.align, w = C === void 0 ? "auto" : C, I = d.columnIndex, y = d.rowIndex, R = this.props, N = R.columnCount, L = R.height, x = R.rowCount, E = R.width, z = this.state, k = z.scrollLeft, G = z.scrollTop, Z = wo();
802
- I !== void 0 && (I = Math.max(0, Math.min(I, N - 1))), y !== void 0 && (y = Math.max(0, Math.min(y, x - 1)));
803
- var U = l(this.props, this._instanceProps), K = s(this.props, this._instanceProps), ue = K > E ? Z : 0, oe = U > L ? Z : 0;
804
- this.scrollTo({
805
- scrollLeft: I !== void 0 ? c(this.props, I, w, k, this._instanceProps, oe) : k,
806
- scrollTop: y !== void 0 ? p(this.props, y, w, G, this._instanceProps, ue) : G
807
- });
808
- }, P.componentDidMount = function() {
809
- var d = this.props, C = d.initialScrollLeft, w = d.initialScrollTop;
810
- if (this._outerRef != null) {
811
- var I = this._outerRef;
812
- typeof C == "number" && (I.scrollLeft = C), typeof w == "number" && (I.scrollTop = w);
813
- }
814
- this._callPropsCallbacks();
815
- }, P.componentDidUpdate = function() {
816
- var d = this.props.direction, C = this.state, w = C.scrollLeft, I = C.scrollTop, y = C.scrollUpdateWasRequested;
817
- if (y && this._outerRef != null) {
818
- var R = this._outerRef;
819
- if (d === "rtl")
820
- switch (zt()) {
821
- case "negative":
822
- R.scrollLeft = -w;
823
- break;
824
- case "positive-ascending":
825
- R.scrollLeft = w;
826
- break;
827
- default:
828
- var N = R.clientWidth, L = R.scrollWidth;
829
- R.scrollLeft = L - N - w;
830
- break;
831
- }
832
- else
833
- R.scrollLeft = Math.max(0, w);
834
- R.scrollTop = Math.max(0, I);
835
- }
836
- this._callPropsCallbacks();
837
- }, P.componentWillUnmount = function() {
838
- this._resetIsScrollingTimeoutId !== null && At(this._resetIsScrollingTimeoutId);
839
- }, P.render = function() {
840
- var d = this.props, C = d.children, w = d.className, I = d.columnCount, y = d.direction, R = d.height, N = d.innerRef, L = d.innerElementType, x = d.innerTagName, E = d.itemData, z = d.itemKey, k = z === void 0 ? Co : z, G = d.outerElementType, Z = d.outerTagName, U = d.rowCount, K = d.style, ue = d.useIsScrolling, oe = d.width, ve = this.state.isScrolling, _e = this._getHorizontalRangeToRender(), Se = _e[0], W = _e[1], H = this._getVerticalRangeToRender(), q = H[0], le = H[1], Te = [];
841
- if (I > 0 && U)
842
- for (var de = q; de <= le; de++)
843
- for (var pe = Se; pe <= W; pe++)
844
- Te.push(Le(C, {
845
- columnIndex: pe,
846
- data: E,
847
- isScrolling: ue ? ve : void 0,
848
- key: k({
849
- columnIndex: pe,
850
- data: E,
851
- rowIndex: de
852
- }),
853
- rowIndex: de,
854
- style: this._getItemStyle(de, pe)
855
- }));
856
- var Ze = l(this.props, this._instanceProps), je = s(this.props, this._instanceProps);
857
- return Le(G || Z || "div", {
858
- className: w,
859
- onScroll: this._onScroll,
860
- ref: this._outerRefSetter,
861
- style: lt({
862
- position: "relative",
863
- height: R,
864
- width: oe,
865
- overflow: "auto",
866
- WebkitOverflowScrolling: "touch",
867
- willChange: "transform",
868
- direction: y
869
- }, K)
870
- }, Le(L || x || "div", {
871
- children: Te,
872
- ref: N,
873
- style: {
874
- height: Ze,
875
- pointerEvents: ve ? "none" : void 0,
876
- width: je
877
- }
878
- }));
879
- }, P._callPropsCallbacks = function() {
880
- var d = this.props, C = d.columnCount, w = d.onItemsRendered, I = d.onScroll, y = d.rowCount;
881
- if (typeof w == "function" && C > 0 && y > 0) {
882
- var R = this._getHorizontalRangeToRender(), N = R[0], L = R[1], x = R[2], E = R[3], z = this._getVerticalRangeToRender(), k = z[0], G = z[1], Z = z[2], U = z[3];
883
- this._callOnItemsRendered(N, L, k, G, x, E, Z, U);
884
- }
885
- if (typeof I == "function") {
886
- var K = this.state, ue = K.horizontalScrollDirection, oe = K.scrollLeft, ve = K.scrollTop, _e = K.scrollUpdateWasRequested, Se = K.verticalScrollDirection;
887
- this._callOnScroll(oe, ve, ue, Se, _e);
888
- }
889
- }, P._getHorizontalRangeToRender = function() {
890
- var d = this.props, C = d.columnCount, w = d.overscanColumnCount, I = d.overscanColumnsCount, y = d.overscanCount, R = d.rowCount, N = this.state, L = N.horizontalScrollDirection, x = N.isScrolling, E = N.scrollLeft, z = w || I || y || 1;
891
- if (C === 0 || R === 0)
892
- return [0, 0, 0, 0];
893
- var k = r(this.props, E, this._instanceProps), G = o(this.props, k, E, this._instanceProps), Z = !x || L === "backward" ? Math.max(1, z) : 1, U = !x || L === "forward" ? Math.max(1, z) : 1;
894
- return [Math.max(0, k - Z), Math.max(0, Math.min(C - 1, G + U)), k, G];
895
- }, P._getVerticalRangeToRender = function() {
896
- var d = this.props, C = d.columnCount, w = d.overscanCount, I = d.overscanRowCount, y = d.overscanRowsCount, R = d.rowCount, N = this.state, L = N.isScrolling, x = N.verticalScrollDirection, E = N.scrollTop, z = I || y || w || 1;
897
- if (C === 0 || R === 0)
898
- return [0, 0, 0, 0];
899
- var k = u(this.props, E, this._instanceProps), G = f(this.props, k, E, this._instanceProps), Z = !L || x === "backward" ? Math.max(1, z) : 1, U = !L || x === "forward" ? Math.max(1, z) : 1;
900
- return [Math.max(0, k - Z), Math.max(0, Math.min(R - 1, G + U)), k, G];
901
- }, S;
902
- }(Fn), t.defaultProps = {
903
- direction: "ltr",
904
- itemData: void 0,
905
- useIsScrolling: !1
906
- }, t;
907
- }
908
- var So = function(t, n) {
909
- var r = t.children, o = t.direction, i = t.height, l = t.innerTagName, s = t.outerTagName, c = t.overscanColumnsCount, p = t.overscanCount, h = t.overscanRowsCount, m = t.width, u = n.instance;
910
- if (process.env.NODE_ENV !== "production") {
911
- if (typeof p == "number" && Ee && !Ee.has(u) && (Ee.add(u), console.warn("The overscanCount prop has been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (typeof c == "number" || typeof h == "number") && Oe && !Oe.has(u) && (Oe.add(u), console.warn("The overscanColumnsCount and overscanRowsCount props have been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (l != null || s != null) && De && !De.has(u) && (De.add(u), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")), r == null)
912
- throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (r === null ? "null" : typeof r) + '" was specified.'));
913
- switch (o) {
914
- case "ltr":
915
- case "rtl":
916
- break;
917
- default:
918
- throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + o + '" was specified.'));
919
- }
920
- if (typeof m != "number")
921
- throw Error('An invalid "width" prop has been specified. Grids must specify a number for width. ' + ('"' + (m === null ? "null" : typeof m) + '" was specified.'));
922
- if (typeof i != "number")
923
- throw Error('An invalid "height" prop has been specified. Grids must specify a number for height. ' + ('"' + (i === null ? "null" : typeof i) + '" was specified.'));
924
- }
925
- }, Ft = 50, ln = function(t, n) {
926
- var r = t.rowCount, o = n.rowMetadataMap, i = n.estimatedRowHeight, l = n.lastMeasuredRowIndex, s = 0;
927
- if (l >= r && (l = r - 1), l >= 0) {
928
- var c = o[l];
929
- s = c.offset + c.size;
930
- }
931
- var p = r - l - 1, h = p * i;
932
- return s + h;
933
- }, cn = function(t, n) {
934
- var r = t.columnCount, o = n.columnMetadataMap, i = n.estimatedColumnWidth, l = n.lastMeasuredColumnIndex, s = 0;
935
- if (l >= r && (l = r - 1), l >= 0) {
936
- var c = o[l];
937
- s = c.offset + c.size;
938
- }
939
- var p = r - l - 1, h = p * i;
940
- return s + h;
941
- }, ie = function(t, n, r, o) {
942
- var i, l, s;
943
- if (t === "column" ? (i = o.columnMetadataMap, l = n.columnWidth, s = o.lastMeasuredColumnIndex) : (i = o.rowMetadataMap, l = n.rowHeight, s = o.lastMeasuredRowIndex), r > s) {
944
- var c = 0;
945
- if (s >= 0) {
946
- var p = i[s];
947
- c = p.offset + p.size;
948
- }
949
- for (var h = s + 1; h <= r; h++) {
950
- var m = l(h);
951
- i[h] = {
952
- offset: c,
953
- size: m
954
- }, c += m;
955
- }
956
- t === "column" ? o.lastMeasuredColumnIndex = r : o.lastMeasuredRowIndex = r;
957
- }
958
- return i[r];
959
- }, kt = function(t, n, r, o) {
960
- var i, l;
961
- t === "column" ? (i = r.columnMetadataMap, l = r.lastMeasuredColumnIndex) : (i = r.rowMetadataMap, l = r.lastMeasuredRowIndex);
962
- var s = l > 0 ? i[l].offset : 0;
963
- return s >= o ? un(t, n, r, l, 0, o) : To(t, n, r, Math.max(0, l), o);
964
- }, un = function(t, n, r, o, i, l) {
965
- for (; i <= o; ) {
966
- var s = i + Math.floor((o - i) / 2), c = ie(t, n, s, r).offset;
967
- if (c === l)
968
- return s;
969
- c < l ? i = s + 1 : c > l && (o = s - 1);
970
- }
971
- return i > 0 ? i - 1 : 0;
972
- }, To = function(t, n, r, o, i) {
973
- for (var l = t === "column" ? n.columnCount : n.rowCount, s = 1; o < l && ie(t, n, o, r).offset < i; )
974
- o += s, s *= 2;
975
- return un(t, n, r, Math.min(o, l - 1), Math.floor(o / 2), i);
976
- }, Wt = function(t, n, r, o, i, l, s) {
977
- var c = t === "column" ? n.width : n.height, p = ie(t, n, r, l), h = t === "column" ? cn(n, l) : ln(n, l), m = Math.max(0, Math.min(h - c, p.offset)), u = Math.max(0, p.offset - c + s + p.size);
978
- switch (o === "smart" && (i >= u - c && i <= m + c ? o = "auto" : o = "center"), o) {
979
- case "start":
980
- return m;
981
- case "end":
982
- return u;
983
- case "center":
984
- return Math.round(u + (m - u) / 2);
985
- case "auto":
986
- default:
987
- return i >= u && i <= m ? i : u > m || i < u ? u : m;
988
- }
989
- }, Io = /* @__PURE__ */ Po({
990
- getColumnOffset: function(t, n, r) {
991
- return ie("column", t, n, r).offset;
992
- },
993
- getColumnStartIndexForOffset: function(t, n, r) {
994
- return kt("column", t, r, n);
995
- },
996
- getColumnStopIndexForStartIndex: function(t, n, r, o) {
997
- for (var i = t.columnCount, l = t.width, s = ie("column", t, n, o), c = r + l, p = s.offset + s.size, h = n; h < i - 1 && p < c; )
998
- h++, p += ie("column", t, h, o).size;
999
- return h;
1000
- },
1001
- getColumnWidth: function(t, n, r) {
1002
- return r.columnMetadataMap[n].size;
1003
- },
1004
- getEstimatedTotalHeight: ln,
1005
- getEstimatedTotalWidth: cn,
1006
- getOffsetForColumnAndAlignment: function(t, n, r, o, i, l) {
1007
- return Wt("column", t, n, r, o, i, l);
1008
- },
1009
- getOffsetForRowAndAlignment: function(t, n, r, o, i, l) {
1010
- return Wt("row", t, n, r, o, i, l);
1011
- },
1012
- getRowOffset: function(t, n, r) {
1013
- return ie("row", t, n, r).offset;
1014
- },
1015
- getRowHeight: function(t, n, r) {
1016
- return r.rowMetadataMap[n].size;
1017
- },
1018
- getRowStartIndexForOffset: function(t, n, r) {
1019
- return kt("row", t, r, n);
1020
- },
1021
- getRowStopIndexForStartIndex: function(t, n, r, o) {
1022
- for (var i = t.rowCount, l = t.height, s = ie("row", t, n, o), c = r + l, p = s.offset + s.size, h = n; h < i - 1 && p < c; )
1023
- h++, p += ie("row", t, h, o).size;
1024
- return h;
1025
- },
1026
- initInstanceProps: function(t, n) {
1027
- var r = t, o = r.estimatedColumnWidth, i = r.estimatedRowHeight, l = {
1028
- columnMetadataMap: {},
1029
- estimatedColumnWidth: o || Ft,
1030
- estimatedRowHeight: i || Ft,
1031
- lastMeasuredColumnIndex: -1,
1032
- lastMeasuredRowIndex: -1,
1033
- rowMetadataMap: {}
1034
- };
1035
- return n.resetAfterColumnIndex = function(s, c) {
1036
- c === void 0 && (c = !0), n.resetAfterIndices({
1037
- columnIndex: s,
1038
- shouldForceUpdate: c
1039
- });
1040
- }, n.resetAfterRowIndex = function(s, c) {
1041
- c === void 0 && (c = !0), n.resetAfterIndices({
1042
- rowIndex: s,
1043
- shouldForceUpdate: c
1044
- });
1045
- }, n.resetAfterIndices = function(s) {
1046
- var c = s.columnIndex, p = s.rowIndex, h = s.shouldForceUpdate, m = h === void 0 ? !0 : h;
1047
- typeof c == "number" && (l.lastMeasuredColumnIndex = Math.min(l.lastMeasuredColumnIndex, c - 1)), typeof p == "number" && (l.lastMeasuredRowIndex = Math.min(l.lastMeasuredRowIndex, p - 1)), n._getItemStyleCache(-1), m && n.forceUpdate();
1048
- }, l;
1049
- },
1050
- shouldResetStyleCacheOnItemSizeChange: !1,
1051
- validateProps: function(t) {
1052
- var n = t.columnWidth, r = t.rowHeight;
1053
- if (process.env.NODE_ENV !== "production") {
1054
- if (typeof n != "function")
1055
- throw Error('An invalid "columnWidth" prop has been specified. Value should be a function. ' + ('"' + (n === null ? "null" : typeof n) + '" was specified.'));
1056
- if (typeof r != "function")
1057
- throw Error('An invalid "rowHeight" prop has been specified. Value should be a function. ' + ('"' + (r === null ? "null" : typeof r) + '" was specified.'));
1058
- }
1059
- }
1060
- });
1061
- process.env.NODE_ENV;
1062
- function Ht(e, t) {
1063
- for (var n in e)
1064
- if (!(n in t))
1065
- return !0;
1066
- for (var r in t)
1067
- if (e[r] !== t[r])
1068
- return !0;
1069
- return !1;
1070
- }
1071
- var yo = ["style"], Ro = ["style"];
1072
- function xo(e, t) {
1073
- var n = e.style, r = Ot(e, yo), o = t.style, i = Ot(t, Ro);
1074
- return !Ht(n, o) && !Ht(r, i);
1075
- }
1076
- const Mo = () => {
1077
- const { viewMode: e } = Ge(), { scrollMode: t } = Pe(), { setColumnCount: n } = Kt(), { virtualScrollableElementRef: r } = Ue(), o = Jt(), i = M(
1078
- (f) => o.widths[f] || 0,
1079
- [o]
1080
- ), l = M(
1081
- (f) => o.heights[f] || 0,
1082
- [o]
1083
- ), s = D(() => o.heights.length, [o]), c = D(() => Math.max(...o.widths), [o]), p = D(() => t === Q.HORIZONTAL_SCROLLING ? s : e === ze.DUAL_PAGE ? 2 : 1, [e, t, t, s, r, c]);
1084
- A(() => {
1085
- n(p);
1086
- }, [p, n]);
1087
- const h = D(() => t === Q.HORIZONTAL_SCROLLING || t === Q.PAGE_SCROLLING ? 1 : Math.round(s / p), [p, s, t]), m = D(() => o.heights.reduce((f, g) => f + g, 0) / o.heights.length || 0, [o]), u = D(() => o.widths.reduce((f, g) => f + g, 0) / o.heights.length || 0, [o]);
1088
- return {
1089
- rowCount: h,
1090
- rowHeight: l,
1091
- columnCount: p,
1092
- columnWidth: i,
1093
- pageDimension: o,
1094
- estimatedRowHeight: m,
1095
- estimatedColumnWidth: u
1096
- };
1097
- };
1098
- let J;
1099
- typeof window < "u" ? J = window : typeof self < "u" ? J = self : J = global;
1100
- let ut = null, dt = null;
1101
- const $t = 20, Qe = J.clearTimeout, Vt = J.setTimeout, et = J.cancelAnimationFrame || J.mozCancelAnimationFrame || J.webkitCancelAnimationFrame, Gt = J.requestAnimationFrame || J.mozRequestAnimationFrame || J.webkitRequestAnimationFrame;
1102
- et == null || Gt == null ? (ut = Qe, dt = function(t) {
1103
- return Vt(t, $t);
1104
- }) : (ut = function([t, n]) {
1105
- et(t), Qe(n);
1106
- }, dt = function(t) {
1107
- const n = Gt(function() {
1108
- Qe(r), t();
1109
- }), r = Vt(function() {
1110
- et(n), t();
1111
- }, $t);
1112
- return [n, r];
1113
- });
1114
- function No(e) {
1115
- let t, n, r, o, i, l, s;
1116
- const c = typeof document < "u" && document.attachEvent;
1117
- if (!c) {
1118
- l = function(b) {
1119
- const S = b.__resizeTriggers__, P = S.firstElementChild, T = S.lastElementChild, d = P.firstElementChild;
1120
- T.scrollLeft = T.scrollWidth, T.scrollTop = T.scrollHeight, d.style.width = P.offsetWidth + 1 + "px", d.style.height = P.offsetHeight + 1 + "px", P.scrollLeft = P.scrollWidth, P.scrollTop = P.scrollHeight;
1121
- }, i = function(b) {
1122
- return b.offsetWidth !== b.__resizeLast__.width || b.offsetHeight !== b.__resizeLast__.height;
1123
- }, s = function(b) {
1124
- if (b.target.className && typeof b.target.className.indexOf == "function" && b.target.className.indexOf("contract-trigger") < 0 && b.target.className.indexOf("expand-trigger") < 0)
1125
- return;
1126
- const S = this;
1127
- l(this), this.__resizeRAF__ && ut(this.__resizeRAF__), this.__resizeRAF__ = dt(function() {
1128
- i(S) && (S.__resizeLast__.width = S.offsetWidth, S.__resizeLast__.height = S.offsetHeight, S.__resizeListeners__.forEach(function(d) {
1129
- d.call(S, b);
1130
- }));
1131
- });
1132
- };
1133
- let u = !1, f = "";
1134
- r = "animationstart";
1135
- const g = "Webkit Moz O ms".split(" ");
1136
- let _ = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), v = "";
1137
- {
1138
- const b = document.createElement("fakeelement");
1139
- if (b.style.animationName !== void 0 && (u = !0), u === !1) {
1140
- for (let S = 0; S < g.length; S++)
1141
- if (b.style[g[S] + "AnimationName"] !== void 0) {
1142
- v = g[S], f = "-" + v.toLowerCase() + "-", r = _[S], u = !0;
1143
- break;
1144
- }
1145
- }
1146
- }
1147
- n = "resizeanim", t = "@" + f + "keyframes " + n + " { from { opacity: 0; } to { opacity: 0; } } ", o = f + "animation: 1ms " + n + "; ";
1148
- }
1149
- const p = function(u) {
1150
- if (!u.getElementById("detectElementResize")) {
1151
- const f = (t || "") + ".resize-triggers { " + (o || "") + '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%; }', g = u.head || u.getElementsByTagName("head")[0], _ = u.createElement("style");
1152
- _.id = "detectElementResize", _.type = "text/css", e != null && _.setAttribute("nonce", e), _.styleSheet ? _.styleSheet.cssText = f : _.appendChild(u.createTextNode(f)), g.appendChild(_);
1153
- }
1154
- };
1155
- return {
1156
- addResizeListener: function(u, f) {
1157
- if (c)
1158
- u.attachEvent("onresize", f);
1159
- else {
1160
- if (!u.__resizeTriggers__) {
1161
- const g = u.ownerDocument, _ = J.getComputedStyle(u);
1162
- _ && _.position === "static" && (u.style.position = "relative"), p(g), u.__resizeLast__ = {}, u.__resizeListeners__ = [], (u.__resizeTriggers__ = g.createElement("div")).className = "resize-triggers";
1163
- const v = g.createElement("div");
1164
- v.className = "expand-trigger", v.appendChild(g.createElement("div"));
1165
- const b = g.createElement("div");
1166
- b.className = "contract-trigger", u.__resizeTriggers__.appendChild(v), u.__resizeTriggers__.appendChild(b), u.appendChild(u.__resizeTriggers__), l(u), u.addEventListener("scroll", s, !0), r && (u.__resizeTriggers__.__animationListener__ = function(P) {
1167
- P.animationName === n && l(u);
1168
- }, u.__resizeTriggers__.addEventListener(r, u.__resizeTriggers__.__animationListener__));
1169
- }
1170
- u.__resizeListeners__.push(f);
1171
- }
1172
- },
1173
- removeResizeListener: function(u, f) {
1174
- if (c)
1175
- u.detachEvent("onresize", f);
1176
- else if (u.__resizeListeners__.splice(u.__resizeListeners__.indexOf(f), 1), !u.__resizeListeners__.length) {
1177
- u.removeEventListener("scroll", s, !0), u.__resizeTriggers__.__animationListener__ && (u.__resizeTriggers__.removeEventListener(r, u.__resizeTriggers__.__animationListener__), u.__resizeTriggers__.__animationListener__ = null);
1178
- try {
1179
- u.__resizeTriggers__ = !u.removeChild(u.__resizeTriggers__);
1180
- } catch {
1181
- }
1182
- }
1183
- }
1184
- };
1185
- }
1186
- class Lo extends kn {
1187
- constructor(...t) {
1188
- super(...t), this.state = {
1189
- height: this.props.defaultHeight || 0,
1190
- scaledHeight: this.props.defaultHeight || 0,
1191
- scaledWidth: this.props.defaultWidth || 0,
1192
- width: this.props.defaultWidth || 0
1193
- }, this._autoSizer = null, this._detectElementResize = null, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
1194
- this._timeoutId = null;
1195
- const {
1196
- disableHeight: n,
1197
- disableWidth: r,
1198
- onResize: o
1199
- } = this.props;
1200
- if (this._parentNode) {
1201
- const i = window.getComputedStyle(this._parentNode) || {}, l = parseFloat(i.paddingLeft || "0"), s = parseFloat(i.paddingRight || "0"), c = parseFloat(i.paddingTop || "0"), p = parseFloat(i.paddingBottom || "0"), h = this._parentNode.getBoundingClientRect(), m = h.height - c - p, u = h.width - l - s, f = this._parentNode.offsetHeight - c - p, g = this._parentNode.offsetWidth - l - s;
1202
- (!n && (this.state.height !== f || this.state.scaledHeight !== m) || !r && (this.state.width !== g || this.state.scaledWidth !== u)) && (this.setState({
1203
- height: f,
1204
- width: g,
1205
- scaledHeight: m,
1206
- scaledWidth: u
1207
- }), typeof o == "function" && o({
1208
- height: f,
1209
- scaledHeight: m,
1210
- scaledWidth: u,
1211
- width: g
1212
- }));
1213
- }
1214
- }, this._setRef = (n) => {
1215
- this._autoSizer = n;
1216
- };
1217
- }
1218
- componentDidMount() {
1219
- const {
1220
- nonce: t
1221
- } = this.props, n = this._autoSizer ? this._autoSizer.parentNode : null;
1222
- if (n != null && n.ownerDocument && n.ownerDocument.defaultView && n instanceof n.ownerDocument.defaultView.HTMLElement) {
1223
- this._parentNode = n;
1224
- const r = n.ownerDocument.defaultView.ResizeObserver;
1225
- r != null ? (this._resizeObserver = new r(() => {
1226
- this._timeoutId = setTimeout(this._onResize, 0);
1227
- }), this._resizeObserver.observe(n)) : (this._detectElementResize = No(t), this._detectElementResize.addResizeListener(n, this._onResize)), this._onResize();
1228
- }
1229
- }
1230
- componentWillUnmount() {
1231
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
1232
- }
1233
- render() {
1234
- const {
1235
- children: t,
1236
- defaultHeight: n,
1237
- defaultWidth: r,
1238
- disableHeight: o = !1,
1239
- disableWidth: i = !1,
1240
- doNotBailOutOnEmptyChildren: l = !1,
1241
- nonce: s,
1242
- onResize: c,
1243
- style: p = {},
1244
- tagName: h = "div",
1245
- ...m
1246
- } = this.props, {
1247
- height: u,
1248
- scaledHeight: f,
1249
- scaledWidth: g,
1250
- width: _
1251
- } = this.state, v = {
1252
- overflow: "visible"
1253
- }, b = {};
1254
- let S = !1;
1255
- return o || (u === 0 && (S = !0), v.height = 0, b.height = u, b.scaledHeight = f), i || (_ === 0 && (S = !0), v.width = 0, b.width = _, b.scaledWidth = g), l && (S = !1), Le(h, {
1256
- ref: this._setRef,
1257
- style: {
1258
- ...v,
1259
- ...p
1260
- },
1261
- ...m
1262
- }, !S && t(b));
1263
- }
1264
- }
1265
- const Eo = (e = 1) => {
1266
- const [t, n] = F(e), [r, o] = F(0), { scrollToPage: i } = _t(), l = $(1), { isScrolling: s } = Xt(), { viewMode: c } = Ge(), { scrollMode: p } = Pe(), h = Rr(t, 100), m = M(
1267
- (v) => {
1268
- if (!/^[0-9]*$/g.test(v.toString()) || !v)
1269
- return { success: !1, currentPage: l.current };
1270
- const S = +v;
1271
- return S < 0 || S > r ? { success: !1, currentPage: l.current } : (n(S), l.current = S, { success: !0, currentPage: +v });
1272
- },
1273
- [r]
1274
- ), u = M(m, [m]), f = M(
1275
- (v) => {
1276
- const b = m(v);
1277
- return b.success && (s.current = !0, i(b.currentPage)), b;
1278
- },
1279
- [m, i]
1280
- ), g = M(() => {
1281
- let v = t - 1;
1282
- f(v);
1283
- }, [f, t, c, p]), _ = M(() => {
1284
- let v = t + 1;
1285
- f(v);
1286
- }, [f, t, c, p]);
1287
- return {
1288
- focusedPage: h,
1289
- totalPages: r,
1290
- setFocusedPage: u,
1291
- setTotalPages: o,
1292
- nextPage: _,
1293
- prevPage: g,
1294
- goToPage: f
1295
- };
1296
- }, dn = We({
1297
- focusedPage: 0,
1298
- setFocusedPage: (e) => {
1299
- },
1300
- goToPage: (e) => ({ success: !!e, currentPage: +e }),
1301
- totalPages: 0,
1302
- setTotalPages: (e) => {
1303
- },
1304
- prevPage: () => {
1305
- },
1306
- nextPage: () => {
1307
- }
1308
- }), ee = () => {
1309
- const e = He(dn);
1310
- return typeof (e == null ? void 0 : e.focusedPage) > "u" && xr.error("Please use this hooks inside children component of RPController or RPLayout"), e;
1311
- }, Oo = ({ children: e }) => {
1312
- const { initialPage: t = 1 } = vr(), { pdf: n } = Y(), { focusedPage: r, totalPages: o, setFocusedPage: i, setTotalPages: l, goToPage: s, nextPage: c, prevPage: p } = Eo(t);
1313
- return A(() => {
1314
- n != null && n.numPages && l(n.numPages);
1315
- }, [n, l, o, t]), A(() => {
1316
- requestAnimationFrame(() => {
1317
- s(t);
1318
- });
1319
- }, [s, t]), /* @__PURE__ */ a(
1320
- dn.Provider,
1321
- {
1322
- value: {
1323
- focusedPage: r,
1324
- totalPages: o,
1325
- setFocusedPage: i,
1326
- setTotalPages: l,
1327
- nextPage: c,
1328
- prevPage: p,
1329
- goToPage: s
1330
- },
1331
- children: e
1332
- }
1333
- );
1334
- }, Do = ({ widths: e, heights: t }) => {
1335
- const { focusedPage: n, totalPages: r } = ee(), o = D(() => {
1336
- const s = [], c = Math.ceil(n / 2) * 2 - 1;
1337
- if (s.push(c), c + 1 < r) {
1338
- const p = c + 1;
1339
- s.push(p);
1340
- }
1341
- return s;
1342
- }, [n, r]), i = D(() => [
1343
- {
1344
- position: "absolute",
1345
- left: 0,
1346
- width: e(n - 1),
1347
- height: t(n - 1)
1348
- },
1349
- {
1350
- position: "absolute",
1351
- left: e(n),
1352
- top: 0,
1353
- width: e(n),
1354
- height: t(n)
1355
- }
1356
- ], [e, t, o]), l = D(() => i.reduce((s, c) => s + Number(c.width || 0), 0), [i]);
1357
- return /* @__PURE__ */ a("div", { style: { width: l, position: "relative" }, children: o.map((s, c) => /* @__PURE__ */ a(wt, { style: i[c], pageNumber: s }, s)) });
1358
- }, Ao = ({ widths: e, heights: t }) => {
1359
- const { focusedPage: n } = ee(), r = D(() => ({
1360
- position: "absolute",
1361
- width: e(n - 1),
1362
- height: t(n - 1)
1363
- }), [e, t, n]), o = D(() => e(n - 1), [e]);
1364
- return /* @__PURE__ */ a(
1365
- "div",
1366
- {
1367
- style: {
1368
- width: o,
1369
- position: "relative"
1370
- },
1371
- children: /* @__PURE__ */ a(wt, { style: r, pageNumber: n }, n)
1372
- }
1373
- );
1374
- }, zo = Wn(({ columnIndex: e, rowIndex: t, data: n, style: r }) => {
1375
- const o = D(() => e + 1 + t * n.columnCount, [e, t, n]);
1376
- return /* @__PURE__ */ a(
1377
- wt,
1378
- {
1379
- style: r,
1380
- onIntersectRatioChange: n.handleIntersectRatioChange,
1381
- pageNumber: o
1382
- },
1383
- o
1384
- );
1385
- }, xo), ts = () => {
1386
- const { getContainer: e, container: t } = Tr(), { scrollToPage: n } = _t(), {
1387
- virtualScrollRef: r,
1388
- getVirtualScrollRef: o,
1389
- getPageScrollElementRef: i,
1390
- getVirtualScrollableElementRef: l,
1391
- setTotalInnerDimensions: s,
1392
- totalInnerDimensions: c
1393
- } = Ue(), { nextPage: p, prevPage: h, setFocusedPage: m, focusedPage: u } = ee(), { scrollMode: f } = Pe(), { viewMode: g } = Ge(), _ = $(null), v = $({
1394
- height: 0,
1395
- width: 0
1396
- }), b = $({
1397
- viewMode: g,
1398
- scrollMode: f
1399
- }), { isFullScreen: S } = wr(), {
1400
- pageDimension: P,
1401
- rowCount: T,
1402
- rowHeight: d,
1403
- columnCount: C,
1404
- columnWidth: w,
1405
- estimatedColumnWidth: I,
1406
- estimatedRowHeight: y
1407
- } = Mo(), [R, N] = F({}), { isScrolling: L } = Xt(), x = $(), E = $({
1408
- scrollTop: 0,
1409
- scrollLeft: 0
1410
- }), { isPressed: z } = Ir(), { selectionMode: k } = mr(), { initializeGrabScroll: G, scrollBehavior: Z } = yr({
1411
- isPressed: z
1412
- }), U = D(() => k === Bt.HAND, [k]), K = M((W, H) => {
1413
- N((q) => ({ ...q, [W]: Math.round(H * 100) }));
1414
- }, []), ue = D(() => ({
1415
- columnCount: C,
1416
- handleIntersectRatioChange: K
1417
- }), [C, K]), oe = M(
1418
- (W) => {
1419
- const H = document.activeElement !== t;
1420
- !S && H || (["ArrowUp", "ArrowLeft"].includes(W.key) ? (W.preventDefault(), h()) : ["ArrowDown", "ArrowRight"].includes(W.key) && (W.preventDefault(), p()));
1421
- },
1422
- [p, h, S, f]
1423
- ), ve = M((W) => {
1424
- E.current = {
1425
- scrollTop: W.scrollTop,
1426
- scrollLeft: W.scrollLeft
1427
- };
1428
- }, []);
1429
- A(() => (window.addEventListener("keydown", oe), () => {
1430
- window.removeEventListener("keydown", oe);
1431
- }), [oe]), A(() => {
1432
- if (_.current && (_.current.style.position = "relative"), !!r) {
1433
- v.current = c, s({
1434
- height: Array.from({ length: T }).reduce(
1435
- (W, H, q) => W + d(q),
1436
- 0
1437
- ),
1438
- width: Array.from({ length: C }).reduce(
1439
- (W, H, q) => W + w(q),
1440
- 0
1441
- )
1442
- });
1443
- for (let W = 0; W < T; W++)
1444
- for (let H = 0; H < C; H++)
1445
- r.resetAfterIndices({
1446
- columnIndex: H,
1447
- rowIndex: W,
1448
- shouldForceUpdate: !0
1449
- });
1450
- }
1451
- }, [T, C, P, r, n]), A(() => {
1452
- if (L.current)
1453
- return;
1454
- if (b.current.viewMode !== g || b.current.scrollMode !== f) {
1455
- x.current && clearTimeout(x.current), N({}), n(u), f === Q.HORIZONTAL_SCROLLING && (r == null || r.scrollTo({
1456
- scrollTop: 0
1457
- })), x.current = setTimeout(() => {
1458
- requestAnimationFrame(() => {
1459
- b.current = { viewMode: g, scrollMode: f };
1460
- });
1461
- }, 100);
1462
- return;
1463
- }
1464
- const H = E.current.scrollTop, q = E.current.scrollLeft;
1465
- if (c.height !== 0 && c.width !== 0) {
1466
- const { height: le, width: Te } = c, { height: de, width: pe } = v.current, Ze = H / de * le, je = q / pe * Te, An = Math.min(Ze, le) || 0, zn = Math.min(je, Te) || 0;
1467
- r == null || r.scrollTo({
1468
- scrollTop: An,
1469
- scrollLeft: zn
1470
- });
1471
- }
1472
- }, [c, g, f]), A(() => {
1473
- const W = Object.entries(R);
1474
- if (L.current) {
1475
- L.current && (L.current = !1);
1476
- return;
1477
- }
1478
- let H = 0, q = -1;
1479
- W.forEach((le) => {
1480
- q < le[1] && (H = Number(le[0]), q = le[1]);
1481
- }), H && m(H);
1482
- }, [R, m]), A(() => () => {
1483
- x.current && clearTimeout(x.current);
1484
- }, []);
1485
- const _e = D(() => j(ae["rp-pages-container"], {
1486
- [ae["rp-cursor-grab"]]: U && !z,
1487
- [ae["rp-cursor-grabbing"]]: U && z
1488
- }), [U, z]), Se = M(
1489
- (W) => {
1490
- if (U && W) {
1491
- const H = j(ae["rp-pages"]), q = document.querySelector(`.${H}`);
1492
- G(q);
1493
- }
1494
- },
1495
- [U, G, ae]
1496
- );
1497
- return /* @__PURE__ */ a("div", { ref: e, tabIndex: -1, className: _e, children: /* @__PURE__ */ a(Lo, { children: ({ width: W, height: H }) => /* @__PURE__ */ a(
1498
- "div",
1499
- {
1500
- "data-rp": "pages",
1501
- ref: Se,
1502
- style: { width: W, height: H, scrollBehavior: Z },
1503
- children: f === Q.PAGE_SCROLLING ? /* @__PURE__ */ a(
1504
- "div",
1505
- {
1506
- ref: i,
1507
- style: { width: W, height: H },
1508
- className: j(ae["rp-pages"], ae["rp-page-scrolling-wrapper"]),
1509
- children: g === ze.DUAL_PAGE ? /* @__PURE__ */ a(Do, { widths: w, heights: d }) : /* @__PURE__ */ a(Ao, { widths: w, heights: d })
1510
- }
1511
- ) : I ? /* @__PURE__ */ a(
1512
- Io,
1513
- {
1514
- ref: o,
1515
- itemData: ue,
1516
- outerRef: l,
1517
- innerRef: _,
1518
- onScroll: ve,
1519
- columnCount: C,
1520
- columnWidth: w,
1521
- rowHeight: d,
1522
- height: H,
1523
- width: W,
1524
- estimatedColumnWidth: I,
1525
- estimatedRowHeight: y,
1526
- rowCount: T,
1527
- className: j(
1528
- ae["rp-pages"],
1529
- f === Q.HORIZONTAL_SCROLLING ? ae["rp-pages-horizontal-scroll"] : ""
1530
- ),
1531
- style: { scrollBehavior: Z },
1532
- children: zo
1533
- }
1534
- ) : null
1535
- }
1536
- ) }) });
1537
- }, Ie = {
1538
- "rp-toolbar-content": "_rp-toolbar-content_fw3uq_1",
1539
- "rp-toolbar-wrapper": "_rp-toolbar-wrapper_fw3uq_10",
1540
- "rp-toolbar-start": "_rp-toolbar-start_fw3uq_18",
1541
- "rp-toolbar-middle": "_rp-toolbar-middle_fw3uq_24",
1542
- "rp-toolbar-end": "_rp-toolbar-end_fw3uq_31"
1543
- }, tt = {
1544
- "rp-paginate": "_rp-paginate_1vu6o_1",
1545
- "rp-page-input": "_rp-page-input_1vu6o_6",
1546
- "rp-total-page": "_rp-total-page_1vu6o_12"
1547
- }, Fo = () => {
1548
- const { prevIcon: e } = re();
1549
- return e || /* @__PURE__ */ a(Me, {});
1550
- }, ko = () => {
1551
- const { nextIcon: e } = re();
1552
- return e || /* @__PURE__ */ a(Me, { style: { transform: "rotate(180deg" } });
1553
- }, Wo = () => {
1554
- const { focusedPage: e, totalPages: t, setFocusedPage: n, nextPage: r, prevPage: o, goToPage: i } = ee(), [l, s] = F(e.toString()), { pageNavigationTool: c = !0 } = se(), { isSmallScreen: p } = ge();
1555
- A(() => {
1556
- s(e.toString());
1557
- }, [e]);
1558
- const h = M((g) => {
1559
- const _ = g.target.value;
1560
- s(_);
1561
- }, []), m = M(() => {
1562
- const g = i(l);
1563
- g.success || s(g.currentPage.toString());
1564
- }, [i, l, t]), u = M(() => {
1565
- s(e.toString());
1566
- }, [e]), f = M(
1567
- (g) => {
1568
- g.key === "Enter" && m();
1569
- },
1570
- [m]
1571
- );
1572
- return typeof c != "boolean" ? /* @__PURE__ */ a(
1573
- c,
1574
- {
1575
- total: t,
1576
- current: e,
1577
- nextPage: r,
1578
- prevPage: o,
1579
- goToPage: i,
1580
- changePage: n
1581
- }
1582
- ) : c ? /* @__PURE__ */ O("div", { className: tt["rp-paginate"], children: [
1583
- !p && /* @__PURE__ */ a(X, { content: "Previous page", children: /* @__PURE__ */ a(B, { onClick: o, disabled: e === 1, children: /* @__PURE__ */ a(Fo, {}) }) }),
1584
- /* @__PURE__ */ a(
1585
- jt,
1586
- {
1587
- onKeyDown: f,
1588
- onBlur: u,
1589
- onChange: h,
1590
- value: l,
1591
- className: tt["rp-page-input"]
1592
- }
1593
- ),
1594
- /* @__PURE__ */ O("span", { className: tt["rp-total-page"], children: [
1595
- "/",
1596
- t
1597
- ] }),
1598
- !p && /* @__PURE__ */ a(X, { content: "Next page", children: /* @__PURE__ */ a(B, { onClick: r, disabled: e === t, children: /* @__PURE__ */ a(ko, {}) }) })
1599
- ] }) : null;
1600
- };
1601
- var bt = "Dialog", [pn, ns] = kr(bt), [Ho, te] = pn(bt), hn = (e) => {
1602
- const {
1603
- __scopeDialog: t,
1604
- children: n,
1605
- open: r,
1606
- defaultOpen: o,
1607
- onOpenChange: i,
1608
- modal: l = !0
1609
- } = e, s = V.useRef(null), c = V.useRef(null), [p = !1, h] = Hr({
1610
- prop: r,
1611
- defaultProp: o,
1612
- onChange: i
1613
- });
1614
- return /* @__PURE__ */ a(
1615
- Ho,
1616
- {
1617
- scope: t,
1618
- triggerRef: s,
1619
- contentRef: c,
1620
- contentId: Be(),
1621
- titleId: Be(),
1622
- descriptionId: Be(),
1623
- open: p,
1624
- onOpenChange: h,
1625
- onOpenToggle: V.useCallback(() => h((m) => !m), [h]),
1626
- modal: l,
1627
- children: n
1628
- }
1629
- );
1630
- };
1631
- hn.displayName = bt;
1632
- var fn = "DialogTrigger", $o = V.forwardRef(
1633
- (e, t) => {
1634
- const { __scopeDialog: n, ...r } = e, o = te(fn, n), i = mt(t, o.triggerRef);
1635
- return /* @__PURE__ */ a(
1636
- Ne.button,
1637
- {
1638
- type: "button",
1639
- "aria-haspopup": "dialog",
1640
- "aria-expanded": o.open,
1641
- "aria-controls": o.contentId,
1642
- "data-state": St(o.open),
1643
- ...r,
1644
- ref: i,
1645
- onClick: xe(e.onClick, o.onOpenToggle)
1646
- }
1647
- );
1648
- }
1649
- );
1650
- $o.displayName = fn;
1651
- var Ct = "DialogPortal", [Vo, mn] = pn(Ct, {
1652
- forceMount: void 0
1653
- }), gn = (e) => {
1654
- const { __scopeDialog: t, forceMount: n, children: r, container: o } = e, i = te(Ct, t);
1655
- return /* @__PURE__ */ a(Vo, { scope: t, forceMount: n, children: V.Children.map(r, (l) => /* @__PURE__ */ a(gt, { present: n || i.open, children: /* @__PURE__ */ a(Fr, { asChild: !0, container: o, children: l }) })) });
1656
- };
1657
- gn.displayName = Ct;
1658
- var ke = "DialogOverlay", vn = V.forwardRef(
1659
- (e, t) => {
1660
- const n = mn(ke, e.__scopeDialog), { forceMount: r = n.forceMount, ...o } = e, i = te(ke, e.__scopeDialog);
1661
- return i.modal ? /* @__PURE__ */ a(gt, { present: r || i.open, children: /* @__PURE__ */ a(Go, { ...o, ref: t }) }) : null;
1662
- }
1663
- );
1664
- vn.displayName = ke;
1665
- var Go = V.forwardRef(
1666
- (e, t) => {
1667
- const { __scopeDialog: n, ...r } = e, o = te(ke, n);
1668
- return (
1669
- // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
1670
- // ie. when `Overlay` and `Content` are siblings
1671
- /* @__PURE__ */ a(Lr, { as: Er, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ a(
1672
- Ne.div,
1673
- {
1674
- "data-state": St(o.open),
1675
- ...r,
1676
- ref: t,
1677
- style: { pointerEvents: "auto", ...r.style }
1678
- }
1679
- ) })
1680
- );
1681
- }
1682
- ), me = "DialogContent", _n = V.forwardRef(
1683
- (e, t) => {
1684
- const n = mn(me, e.__scopeDialog), { forceMount: r = n.forceMount, ...o } = e, i = te(me, e.__scopeDialog);
1685
- return /* @__PURE__ */ a(gt, { present: r || i.open, children: i.modal ? /* @__PURE__ */ a(Uo, { ...o, ref: t }) : /* @__PURE__ */ a(qo, { ...o, ref: t }) });
1686
- }
1687
- );
1688
- _n.displayName = me;
1689
- var Uo = V.forwardRef(
1690
- (e, t) => {
1691
- const n = te(me, e.__scopeDialog), r = V.useRef(null), o = mt(t, n.contentRef, r);
1692
- return V.useEffect(() => {
1693
- const i = r.current;
1694
- if (i)
1695
- return Or(i);
1696
- }, []), /* @__PURE__ */ a(
1697
- wn,
1698
- {
1699
- ...e,
1700
- ref: o,
1701
- trapFocus: n.open,
1702
- disableOutsidePointerEvents: !0,
1703
- onCloseAutoFocus: xe(e.onCloseAutoFocus, (i) => {
1704
- var l;
1705
- i.preventDefault(), (l = n.triggerRef.current) == null || l.focus();
1706
- }),
1707
- onPointerDownOutside: xe(e.onPointerDownOutside, (i) => {
1708
- const l = i.detail.originalEvent, s = l.button === 0 && l.ctrlKey === !0;
1709
- (l.button === 2 || s) && i.preventDefault();
1710
- }),
1711
- onFocusOutside: xe(
1712
- e.onFocusOutside,
1713
- (i) => i.preventDefault()
1714
- )
1715
- }
1716
- );
1717
- }
1718
- ), qo = V.forwardRef(
1719
- (e, t) => {
1720
- const n = te(me, e.__scopeDialog), r = V.useRef(!1), o = V.useRef(!1);
1721
- return /* @__PURE__ */ a(
1722
- wn,
1723
- {
1724
- ...e,
1725
- ref: t,
1726
- trapFocus: !1,
1727
- disableOutsidePointerEvents: !1,
1728
- onCloseAutoFocus: (i) => {
1729
- var l, s;
1730
- (l = e.onCloseAutoFocus) == null || l.call(e, i), i.defaultPrevented || (r.current || (s = n.triggerRef.current) == null || s.focus(), i.preventDefault()), r.current = !1, o.current = !1;
1731
- },
1732
- onInteractOutside: (i) => {
1733
- var c, p;
1734
- (c = e.onInteractOutside) == null || c.call(e, i), i.defaultPrevented || (r.current = !0, i.detail.originalEvent.type === "pointerdown" && (o.current = !0));
1735
- const l = i.target;
1736
- ((p = n.triggerRef.current) == null ? void 0 : p.contains(l)) && i.preventDefault(), i.detail.originalEvent.type === "focusin" && o.current && i.preventDefault();
1737
- }
1738
- }
1739
- );
1740
- }
1741
- ), wn = V.forwardRef(
1742
- (e, t) => {
1743
- const { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: o, onCloseAutoFocus: i, ...l } = e, s = te(me, n), c = V.useRef(null), p = mt(t, c);
1744
- return Dr(), /* @__PURE__ */ O(Ae, { children: [
1745
- /* @__PURE__ */ a(
1746
- Ar,
1747
- {
1748
- asChild: !0,
1749
- loop: !0,
1750
- trapped: r,
1751
- onMountAutoFocus: o,
1752
- onUnmountAutoFocus: i,
1753
- children: /* @__PURE__ */ a(
1754
- zr,
1755
- {
1756
- role: "dialog",
1757
- id: s.contentId,
1758
- "aria-describedby": s.descriptionId,
1759
- "aria-labelledby": s.titleId,
1760
- "data-state": St(s.open),
1761
- ...l,
1762
- ref: p,
1763
- onDismiss: () => s.onOpenChange(!1)
1764
- }
1765
- )
1766
- }
1767
- ),
1768
- /* @__PURE__ */ O(Ae, { children: [
1769
- /* @__PURE__ */ a(jo, { titleId: s.titleId }),
1770
- /* @__PURE__ */ a(Ko, { contentRef: c, descriptionId: s.descriptionId })
1771
- ] })
1772
- ] });
1773
- }
1774
- ), Pt = "DialogTitle", bn = V.forwardRef(
1775
- (e, t) => {
1776
- const { __scopeDialog: n, ...r } = e, o = te(Pt, n);
1777
- return /* @__PURE__ */ a(Ne.h2, { id: o.titleId, ...r, ref: t });
1778
- }
1779
- );
1780
- bn.displayName = Pt;
1781
- var Cn = "DialogDescription", Zo = V.forwardRef(
1782
- (e, t) => {
1783
- const { __scopeDialog: n, ...r } = e, o = te(Cn, n);
1784
- return /* @__PURE__ */ a(Ne.p, { id: o.descriptionId, ...r, ref: t });
1785
- }
1786
- );
1787
- Zo.displayName = Cn;
1788
- var Pn = "DialogClose", Sn = V.forwardRef(
1789
- (e, t) => {
1790
- const { __scopeDialog: n, ...r } = e, o = te(Pn, n);
1791
- return /* @__PURE__ */ a(
1792
- Ne.button,
1793
- {
1794
- type: "button",
1795
- ...r,
1796
- ref: t,
1797
- onClick: xe(e.onClick, () => o.onOpenChange(!1))
1798
- }
1799
- );
1800
- }
1801
- );
1802
- Sn.displayName = Pn;
1803
- function St(e) {
1804
- return e ? "open" : "closed";
1805
- }
1806
- var Tn = "DialogTitleWarning", [rs, In] = Wr(Tn, {
1807
- contentName: me,
1808
- titleName: Pt,
1809
- docsSlug: "dialog"
1810
- }), jo = ({ titleId: e }) => {
1811
- const t = In(Tn), n = `\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
1812
-
1813
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
1814
-
1815
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;
1816
- return V.useEffect(() => {
1817
- e && (document.getElementById(e) || console.error(n));
1818
- }, [n, e]), null;
1819
- }, Bo = "DialogDescriptionWarning", Ko = ({ contentRef: e, descriptionId: t }) => {
1820
- const r = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${In(Bo).contentName}}.`;
1821
- return V.useEffect(() => {
1822
- var i;
1823
- const o = (i = e.current) == null ? void 0 : i.getAttribute("aria-describedby");
1824
- t && o && (document.getElementById(t) || console.warn(r));
1825
- }, [r, e, t]), null;
1826
- }, Xo = hn, Jo = gn, Yo = vn, Qo = _n, ea = bn, ta = Sn;
1827
- const fe = {
1828
- "rp-dialog-wrapper": "_rp-dialog-wrapper_slqo7_1",
1829
- "rp-dialog-overlay": "_rp-dialog-overlay_slqo7_7",
1830
- "rp-document-dialog": "_rp-document-dialog_slqo7_13",
1831
- "rp-document-properties": "_rp-document-properties_slqo7_35",
1832
- "rp-dialog-title": "_rp-dialog-title_slqo7_39",
1833
- "rp-dialog-close": "_rp-dialog-close_slqo7_47",
1834
- "rp-properties-divider": "_rp-properties-divider_slqo7_55"
1835
- }, na = () => {
1836
- const { pdfProperties: e } = Y(), { container: t } = qe(), { activeDocumentProperties: n, setActiveDocumentProperties: r } = Vr(), o = D(() => {
1837
- if (!e)
1838
- return [];
1839
- const {
1840
- fileSize: i,
1841
- filename: l,
1842
- title: s,
1843
- author: c,
1844
- subject: p,
1845
- createdOn: h,
1846
- creator: m,
1847
- keywords: u,
1848
- modifierOn: f,
1849
- pdfProducer: g,
1850
- pdfVersion: _,
1851
- pageCount: v
1852
- } = e;
1853
- return [
1854
- { label: "File name", value: l },
1855
- { label: "File size", value: i },
1856
- { separate: !0 },
1857
- { label: "Title", value: s },
1858
- { label: "Author", value: c },
1859
- { label: "Subject", value: p },
1860
- { label: "Keywords", value: u },
1861
- { label: "Creator", value: m },
1862
- {
1863
- label: "Created on",
1864
- value: h ? it(h) : ""
1865
- },
1866
- {
1867
- label: "Modified on",
1868
- value: f ? it(f) : ""
1869
- },
1870
- { separate: !0 },
1871
- { label: "PDF producer", value: g },
1872
- { label: "PDF version", value: _ },
1873
- { label: "Page count", value: v }
1874
- ];
1875
- }, [e]);
1876
- return /* @__PURE__ */ a(Xo, { open: n, onOpenChange: r, children: /* @__PURE__ */ a(Jo, { container: t, children: /* @__PURE__ */ O("div", { className: fe["rp-dialog-wrapper"], children: [
1877
- /* @__PURE__ */ a(Yo, { className: fe["rp-dialog-overlay"] }),
1878
- /* @__PURE__ */ O(Qo, { className: fe["rp-document-dialog"], children: [
1879
- /* @__PURE__ */ a(ea, { className: fe["rp-dialog-title"], children: "Document Properties" }),
1880
- /* @__PURE__ */ a("div", { className: fe["rp-document-properties"], children: o.map((i, l) => /* @__PURE__ */ a("div", { children: i.separate ? /* @__PURE__ */ a("div", { className: fe["rp-properties-divider"] }) : /* @__PURE__ */ a($r, { label: i.label, value: i.value }) }, l)) }),
1881
- /* @__PURE__ */ a(ta, { asChild: !0, className: fe["rp-dialog-close"], children: /* @__PURE__ */ a(Qt, {}) })
1882
- ] })
1883
- ] }) }) });
1884
- }, ra = {
1885
- "rp-other-tool-content": "_rp-other-tool-content_su718_1"
1886
- }, oa = () => {
1887
- const { filename: e, pdfSrc: t } = Y();
1888
- return { downloadFile: () => {
1889
- if (!e)
1890
- return;
1891
- const r = document.createElement("a");
1892
- r.href = t, r.download = e, document.body.appendChild(r), r.click(), document.body.removeChild(r);
1893
- } };
1894
- }, yn = () => {
1895
- const { downloadIcon: e } = re();
1896
- return e || /* @__PURE__ */ a(jr, {});
1897
- }, Rn = ({ children: e, className: t }) => /* @__PURE__ */ a(X, { className: t, content: "Download file", children: e }), aa = ({ downloadFile: e }) => /* @__PURE__ */ a(Rn, { children: /* @__PURE__ */ a(B, { onClick: e, children: /* @__PURE__ */ a(yn, {}) }) }), ia = ({ downloadFile: e }) => /* @__PURE__ */ a(ce, { onClick: e, children: /* @__PURE__ */ O(Rn, { className: "rp-menu-item", children: [
1898
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(yn, {}) }),
1899
- "Download file"
1900
- ] }) }), xn = () => {
1901
- const { downloadFile: e } = oa(), { downloadTool: t = !0 } = se(), { isSmallScreen: n } = ge();
1902
- return t ? n ? /* @__PURE__ */ a(ia, { downloadFile: e }) : typeof t == "function" ? /* @__PURE__ */ a(t, { downloadFile: e }) : t ? /* @__PURE__ */ a(aa, { downloadFile: e }) : null : null;
1903
- };
1904
- const sa = () => {
1905
- const { pdf: e, pages: t } = Y(), [n, r] = F({
1906
- loadedPages: 0,
1907
- totalPages: 0,
1908
- percentage: 0
1909
- }), [o, i] = F(!1), [l, s] = F(!1), [c, p] = F(null), h = $(!1);
1910
- A(() => {
1911
- h.current;
1912
- }, [h]);
1913
- const m = M(() => {
1914
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
1915
- const P = document.querySelector(".rp-print-zone");
1916
- P && P.remove();
1917
- }, []), u = M(() => {
1918
- h.current = !1, i(!1), s(!1), p(null), r({
1919
- loadedPages: 0,
1920
- totalPages: 0,
1921
- percentage: 0
1922
- });
1923
- }, []), f = () => {
1924
- h.current = !0;
1925
- }, g = async ({
1926
- scratchCanvas: P,
1927
- pdfDocument: T,
1928
- pageNumber: d,
1929
- viewerPdfPage: C,
1930
- printResolution: w,
1931
- optionalContentConfigPromise: I,
1932
- printAnnotationStoragePromise: y
1933
- }) => {
1934
- if (h.current) {
1935
- u();
1936
- return;
1937
- }
1938
- const R = w / nr.PDF;
1939
- P.width = Math.floor(C.width * R), P.height = Math.floor(C.height * R);
1940
- const N = P.getContext("2d");
1941
- N.save(), N.fillStyle = "rgb(255, 255, 255)", N.fillRect(0, 0, P.width, P.height), N.restore();
1942
- const [L, x] = await Promise.all([
1943
- T.getPage(d),
1944
- y
1945
- ]);
1946
- if (h.current) {
1947
- u();
1948
- return;
1949
- }
1950
- const E = {
1951
- canvasContext: N,
1952
- transform: [R, 0, 0, R, 0, 0],
1953
- viewport: L.getViewport({ scale: 1, rotation: C.rotation }),
1954
- intent: "print",
1955
- annotationMode: rr.ENABLE_STORAGE,
1956
- optionalContentConfigPromise: I,
1957
- printAnnotationStorage: x
1958
- };
1959
- try {
1960
- return L.render(E).promise;
1961
- } catch (z) {
1962
- throw z instanceof or || console.error(z), z;
1963
- }
1964
- }, _ = M(() => {
1965
- const P = window.print;
1966
- return new Promise((T) => {
1967
- const d = (I) => {
1968
- setTimeout(() => {
1969
- P.call(window), setTimeout(() => I(), 20);
1970
- }, 0);
1971
- };
1972
- if (document.querySelector(".rp-print-zone")) {
1973
- d(T);
1974
- return;
1975
- }
1976
- const w = new MutationObserver(() => {
1977
- document.querySelector(".rp-print-zone") && (d(T), w.disconnect());
1978
- });
1979
- w.observe(document.body, { childList: !0, subtree: !0 });
1980
- });
1981
- }, []), v = async (P) => {
1982
- const T = document.createElement("img"), d = document.createElement("div");
1983
- return d.classList.add("rp-print-page"), await new Promise((C, w) => {
1984
- P.toBlob((I) => {
1985
- I ? (T.src = URL.createObjectURL(I), T.onload = () => {
1986
- URL.revokeObjectURL(T.src), C();
1987
- }, T.onerror = w) : w(new Error("Failed to create blob"));
1988
- });
1989
- }).catch(() => {
1990
- }), d.appendChild(T), d;
1991
- }, b = (P, T) => {
1992
- const d = document.createElement("div");
1993
- d.classList.add("rp-print-zone");
1994
- const C = document.createElement("style"), w = T.get(1);
1995
- if (w) {
1996
- const { width: I, height: y } = w == null ? void 0 : w.page.getViewport({ scale: 1 });
1997
- C.innerHTML = `@page { size: ${I}px ${y}px }`;
1998
- }
1999
- return d.appendChild(C), d.append(...P), d;
2000
- }, S = M(async () => {
2001
- if (!e)
2002
- return;
2003
- u();
2004
- const P = document.createElement("canvas"), T = [];
2005
- try {
2006
- e.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
2007
- const C = e.getOptionalContentConfig({ intent: "print" }), w = Promise.resolve(
2008
- e.annotationStorage.print ?? void 0
2009
- ), I = t.size;
2010
- for (const [R, N] of t) {
2011
- if (h.current) {
2012
- u();
2013
- return;
2014
- }
2015
- const L = N.page.getViewport({ scale: 1 });
2016
- if (await g({
2017
- scratchCanvas: P,
2018
- pdfDocument: e,
2019
- pageNumber: R,
2020
- viewerPdfPage: L,
2021
- printResolution: 150,
2022
- optionalContentConfigPromise: C,
2023
- printAnnotationStoragePromise: w
2024
- }), h.current) {
2025
- u();
2026
- return;
2027
- }
2028
- const x = await v(P);
2029
- T.push(x);
2030
- const E = parseFloat((T.length / I * 100).toFixed(2));
2031
- r({
2032
- loadedPages: R,
2033
- totalPages: I,
2034
- percentage: E
2035
- });
2036
- }
2037
- if (h.current) {
2038
- u();
2039
- return;
2040
- }
2041
- const y = b(T, t);
2042
- document.body.appendChild(y), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), i(!0), await _();
2043
- } catch (d) {
2044
- s(!0), d instanceof Error && p(d);
2045
- } finally {
2046
- P.height = 0, P.width = 0;
2047
- }
2048
- }, [e, t, h]);
2049
- return A(() => {
2050
- const P = () => {
2051
- u(), m();
2052
- };
2053
- return window.addEventListener("afterprint", P, !0), () => {
2054
- window.removeEventListener("afterprint", P, !0);
2055
- };
2056
- }, [m, u]), {
2057
- print: S,
2058
- cancel: f,
2059
- progress: n,
2060
- isComplete: o,
2061
- isError: l,
2062
- error: c
2063
- };
2064
- }, Mn = We({
2065
- print: () => {
2066
- },
2067
- cancel: () => {
2068
- },
2069
- setOnProgress: (e) => {
2070
- },
2071
- progress: {},
2072
- setOnComplete: (e) => e(),
2073
- setOnError: (e) => {
2074
- try {
2075
- const t = new Error("Print error occurred");
2076
- e(t);
2077
- } catch (t) {
2078
- console.error("Error in setOnError callback:", t);
2079
- }
2080
- }
2081
- }), la = ({ children: e }) => {
2082
- const [t, n] = F(null), [r, o] = F(null), { print: i, cancel: l, progress: s, isComplete: c, isError: p, error: h } = sa(), m = M((v) => {
2083
- v && typeof v == "function" && o(() => v);
2084
- }, []), u = (v) => {
2085
- h && v(h);
2086
- }, f = M(
2087
- (v) => {
2088
- n(() => v);
2089
- },
2090
- [s, t]
2091
- );
2092
- A(() => {
2093
- c && r && g();
2094
- }, [c, r]), A(() => {
2095
- p && u((v) => {
2096
- console.error(v);
2097
- });
2098
- }, [p]), A(() => {
2099
- s && t && t(s);
2100
- }, [s, t]);
2101
- const g = () => {
2102
- r && (r(), o(null));
2103
- }, _ = {
2104
- print: i,
2105
- cancel: l,
2106
- setOnProgress: f,
2107
- setOnComplete: m,
2108
- setOnError: u,
2109
- progress: s
2110
- };
2111
- return /* @__PURE__ */ a(Mn.Provider, { value: _, children: e });
2112
- }, Tt = () => {
2113
- const e = He(Mn);
2114
- if (!e)
2115
- throw new Error("usePrintContext must be used within a PrintProvider");
2116
- return e;
2117
- }, Nn = () => {
2118
- const { printIcon: e } = re();
2119
- return e || /* @__PURE__ */ a(Br, {});
2120
- }, Ln = ({ children: e, className: t }) => /* @__PURE__ */ a(X, { className: t, content: "Print", children: e }), ca = ({ print: e }) => /* @__PURE__ */ a(Ln, { children: /* @__PURE__ */ a(B, { onClick: e, children: /* @__PURE__ */ a(Nn, {}) }) }), ua = ({ print: e }) => /* @__PURE__ */ a(ce, { onClick: e, children: /* @__PURE__ */ O(Ln, { className: "rp-menu-item", children: [
2121
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(Nn, {}) }),
2122
- "Print"
2123
- ] }) }), En = () => {
2124
- const { print: e, cancel: t, setOnProgress: n, setOnComplete: r, setOnError: o, progress: i } = Tt(), { printTool: l = !0 } = se(), { isSmallScreen: s } = ge();
2125
- return l ? s ? /* @__PURE__ */ a(ua, { print: e }) : typeof l == "function" ? /* @__PURE__ */ a(
2126
- l,
2127
- {
2128
- print: e,
2129
- cancel: t,
2130
- setOnProgress: n,
2131
- setOnError: o,
2132
- setOnComplete: r,
2133
- progress: i
2134
- }
2135
- ) : l ? /* @__PURE__ */ a(ca, { print: e }) : null : null;
2136
- }, da = {
2137
- "rp-go-to-Top": "_rp-go-to-Top_4e0yd_1"
2138
- }, pa = () => {
2139
- const { goToFirstPageIcon: e } = re();
2140
- return e || /* @__PURE__ */ a(tn, { className: da["rp-go-to-Top"] });
2141
- }, ha = () => {
2142
- const { goToLastPageIcon: e } = re();
2143
- return e || /* @__PURE__ */ a(tn, {});
2144
- }, fa = () => {
2145
- const { goToPage: e, totalPages: t, focusedPage: n } = ee(), { jumpNavigationTool: r = !0 } = se(), o = D(() => n === 1, [n]), i = D(() => n === t, [n, t]), l = M(() => {
2146
- e(1);
2147
- }, [e]), s = M(() => {
2148
- e(t);
2149
- }, [e, t]);
2150
- return r ? /* @__PURE__ */ O(Fe, { children: [
2151
- /* @__PURE__ */ a(ce, { disabled: o, onClick: l, children: /* @__PURE__ */ O(X, { className: "rp-menu-item", content: "Go to first page", children: [
2152
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(pa, {}) }),
2153
- "First page"
2154
- ] }) }),
2155
- /* @__PURE__ */ a(ce, { disabled: i, onClick: s, children: /* @__PURE__ */ O(X, { className: "rp-menu-item", content: "Go to last page", children: [
2156
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(ha, {}) }),
2157
- "Last page"
2158
- ] }) }),
2159
- /* @__PURE__ */ a(vt, {})
2160
- ] }) : null;
2161
- }, ma = () => {
2162
- const { container: e } = qe(), { isSmallScreen: t } = ge(), {
2163
- openFileTool: n,
2164
- downloadTool: r,
2165
- documentProperties: o,
2166
- scrollModeTool: i,
2167
- rotateTool: l,
2168
- selectionModeTool: s,
2169
- jumpNavigationTool: c,
2170
- printTool: p,
2171
- fullscreenTool: h
2172
- } = se();
2173
- return D(() => {
2174
- const u = c || l || s || i || o;
2175
- let f = !1;
2176
- return t && (f = !(!n && !r && !p && !h)), u || f;
2177
- }, [
2178
- n,
2179
- r,
2180
- o,
2181
- i,
2182
- l,
2183
- s,
2184
- c,
2185
- t
2186
- ]) ? /* @__PURE__ */ O(Gr, { children: [
2187
- /* @__PURE__ */ a(
2188
- ft,
2189
- {
2190
- "data-rp": "moreOptionsDropdown",
2191
- container: e,
2192
- triggerComponent: /* @__PURE__ */ a("div", { role: "button", children: /* @__PURE__ */ a(X, { content: "More options", children: /* @__PURE__ */ a(B, { children: /* @__PURE__ */ a(Nr, {}) }) }) }),
2193
- children: /* @__PURE__ */ O("div", { className: ra["rp-other-tool-content"], children: [
2194
- t && /* @__PURE__ */ O(Fe, { children: [
2195
- /* @__PURE__ */ a(Yt, {}),
2196
- /* @__PURE__ */ a(xn, {}),
2197
- /* @__PURE__ */ a(En, {}),
2198
- /* @__PURE__ */ a(en, {}),
2199
- /* @__PURE__ */ a(vt, {})
2200
- ] }),
2201
- /* @__PURE__ */ a(fa, {}),
2202
- /* @__PURE__ */ a(qr, {}),
2203
- /* @__PURE__ */ a(Kr, {}),
2204
- /* @__PURE__ */ a(Zr, {}),
2205
- /* @__PURE__ */ a(Ur, {})
2206
- ] })
2207
- }
2208
- ),
2209
- /* @__PURE__ */ a(na, {})
2210
- ] }) : null;
2211
- }, ga = () => {
2212
- const { isSmallScreen: e } = ge();
2213
- return /* @__PURE__ */ O(Ae, { children: [
2214
- /* @__PURE__ */ a(Mr, {}),
2215
- !e && /* @__PURE__ */ O(Ae, { children: [
2216
- /* @__PURE__ */ a(Yt, {}),
2217
- /* @__PURE__ */ a(xn, {}),
2218
- /* @__PURE__ */ a(En, {}),
2219
- /* @__PURE__ */ a(en, {})
2220
- ] }),
2221
- /* @__PURE__ */ a(ma, {})
2222
- ] });
2223
- }, ye = {
2224
- "rp-zoom-wrapper": "_rp-zoom-wrapper_163s9_1",
2225
- "rp-current-zoom-wrapper": "_rp-current-zoom-wrapper_163s9_6",
2226
- "rp-current-zoom-icon": "_rp-current-zoom-icon_163s9_11",
2227
- "rp-current-zoom": "_rp-current-zoom_163s9_6",
2228
- "rp-zoom-dropdown-content": "_rp-zoom-dropdown-content_163s9_20"
2229
- }, va = 25, nt = 1e3, _a = [50, 75, 100, 125, 150, 200, 300, 400], wa = () => {
2230
- const { zoomInIcon: e } = re();
2231
- return e || /* @__PURE__ */ a(Xr, {});
2232
- }, ba = () => {
2233
- const { zoomOutIcon: e } = re();
2234
- return e || /* @__PURE__ */ a(Jr, {});
2235
- }, Ca = () => {
2236
- const { zoomLevel: e, setZoomLevel: t } = ht(), { container: n, contentRef: r } = qe(), { zoomTool: o = !0 } = se(), { focusedPage: i } = ee(), { rotate: l } = Ve(), { pages: s } = Y(), { isSmallScreen: c } = ge(), p = M(() => {
2237
- t((v) => {
2238
- const b = Math.floor(v / 25) * 25;
2239
- return Math.min(b + 25, nt);
2240
- });
2241
- }, [t]), h = M(() => {
2242
- t((v) => {
2243
- const b = Math.ceil(v / 25) * 25;
2244
- return Math.min(b - 25, nt);
2245
- });
2246
- }, [t]), m = D(() => e === va, [e]), u = D(() => e === nt, [e]), f = D(() => {
2247
- var v;
2248
- return (v = s.get(i)) == null ? void 0 : v.page.getViewport({ scale: 1, rotation: l });
2249
- }, [s, i, l]), g = M(
2250
- (v) => {
2251
- const b = ((f == null ? void 0 : f.width) || 0) + 2 * yt, S = ((f == null ? void 0 : f.height) || 0) + 2 * yt, P = (r == null ? void 0 : r.clientWidth) || 0, T = (r == null ? void 0 : r.clientHeight) || 0;
2252
- switch (v) {
2253
- case we.ACTUAL:
2254
- t(100);
2255
- break;
2256
- case we.PAGE_FIT:
2257
- let d = 0;
2258
- const C = P > T;
2259
- S > b && C ? d = T / S : d = P / b;
2260
- const w = Math.floor(d * 100);
2261
- t(w);
2262
- break;
2263
- case we.PAGE_WIDTH:
2264
- t(Math.floor(P / b * 100));
2265
- break;
2266
- }
2267
- },
2268
- [t, f]
2269
- ), _ = M(
2270
- (v) => {
2271
- typeof v == "number" ? t(v) : g(v);
2272
- },
2273
- [t, g]
2274
- );
2275
- return typeof o != "boolean" ? /* @__PURE__ */ a(o, { zoomLevel: e, setZoomLevel: t }) : o ? /* @__PURE__ */ O("div", { className: ye["rp-zoom-wrapper"], children: [
2276
- /* @__PURE__ */ a(X, { content: "Zoom out", children: /* @__PURE__ */ a(B, { disabled: m, onClick: h, children: /* @__PURE__ */ a(ba, {}) }) }),
2277
- !c && /* @__PURE__ */ a(
2278
- ft,
2279
- {
2280
- container: n,
2281
- triggerComponent: /* @__PURE__ */ a("div", { role: "button", children: /* @__PURE__ */ a(X, { content: "Select zoom level", children: /* @__PURE__ */ O(B, { className: ye["rp-current-zoom-wrapper"], children: [
2282
- /* @__PURE__ */ O("span", { className: ye["rp-current-zoom"], children: [
2283
- e,
2284
- " %"
2285
- ] }),
2286
- /* @__PURE__ */ a(Me, { className: ye["rp-current-zoom-icon"] })
2287
- ] }) }) }),
2288
- style: { minWidth: "200px" },
2289
- align: "center",
2290
- children: /* @__PURE__ */ O("div", { className: ye["rp-zoom-dropdown-content"], children: [
2291
- /* @__PURE__ */ O(Fe, { children: [
2292
- /* @__PURE__ */ a(ce, { onClick: () => _(we.ACTUAL), children: "Actual size" }),
2293
- /* @__PURE__ */ a(ce, { onClick: () => _(we.PAGE_FIT), children: "Page fit" }),
2294
- /* @__PURE__ */ a(ce, { onClick: () => _(we.PAGE_WIDTH), children: "Page width" })
2295
- ] }),
2296
- /* @__PURE__ */ a(vt, {}),
2297
- /* @__PURE__ */ a(Fe, { children: _a.map((v) => /* @__PURE__ */ O(ce, { onClick: () => _(v), children: [
2298
- v,
2299
- " %"
2300
- ] }, v)) })
2301
- ] })
2302
- }
2303
- ),
2304
- /* @__PURE__ */ a(X, { content: "Zoom in", children: /* @__PURE__ */ a(B, { disabled: u, onClick: p, children: /* @__PURE__ */ a(wa, {}) }) })
2305
- ] }) : null;
2306
- }, ne = {
2307
- "rp-search-tool-content": "_rp-search-tool-content_1vxow_1",
2308
- "rp-search-tool-input": "_rp-search-tool-input_1vxow_6",
2309
- "rp-search-tool-input-icon": "_rp-search-tool-input-icon_1vxow_12",
2310
- "rp-search-tool-controls": "_rp-search-tool-controls_1vxow_16",
2311
- "rp-search-tool-input-wrapper": "_rp-search-tool-input-wrapper_1vxow_24",
2312
- "rp-search-tool-input-checkboxes": "_rp-search-tool-input-checkboxes_1vxow_30",
2313
- "rp-search-tool-input-clear": "_rp-search-tool-input-clear_1vxow_35",
2314
- "rp-search-input": "_rp-search-input_1vxow_49"
2315
- }, Ut = () => {
2316
- const { searchIcon: e } = re();
2317
- return e || /* @__PURE__ */ a(Yr, {});
2318
- }, Pa = () => {
2319
- const { container: e } = qe(), [t, n] = F(!1), { pdf: r } = Y(), [o, i] = F(null), {
2320
- searchOptions: l,
2321
- setSearchOptions: s,
2322
- loading: c,
2323
- setSearch: p,
2324
- totalMatches: h,
2325
- currentMatchPosition: m,
2326
- nextMatch: u,
2327
- prevMatch: f,
2328
- search: g
2329
- } = rn(), { searchTool: _ = !0 } = se(), [v, b] = F(g), S = M(() => {
2330
- n(!0);
2331
- }, []), P = M(() => {
2332
- p(""), b(""), n(!1);
2333
- }, [p]), T = M(
2334
- (x) => {
2335
- x.key === "Escape" && t && P();
2336
- },
2337
- [t]
2338
- ), d = M(
2339
- (x) => {
2340
- x.shiftKey && x.key === "Enter" ? f() : x.key === "Enter" && g !== v ? p(v) : x.key === "Enter" && u();
2341
- },
2342
- [v, f, u, p, g]
2343
- );
2344
- A(() => (window.addEventListener("keydown", T), () => {
2345
- window.removeEventListener("keydown", T);
2346
- }), [T]), A(() => {
2347
- o && o.focus();
2348
- }, [o]);
2349
- const C = M((x) => {
2350
- b(x.target.value);
2351
- }, []), w = M(() => {
2352
- b(""), p("");
2353
- }, [p]), I = D(() => `${m} / ${h}`, [m, h]), { wholeWords: y, matchCase: R } = D(() => l, [l]), N = M(
2354
- (x) => {
2355
- s((E) => ({ ...E, matchCase: x }));
2356
- },
2357
- [s]
2358
- ), L = M(
2359
- (x) => {
2360
- s((E) => ({ ...E, wholeWords: x }));
2361
- },
2362
- [s]
2363
- );
2364
- return A(() => {
2365
- P();
2366
- }, [r, P]), _ ? /* @__PURE__ */ a(
2367
- ft,
2368
- {
2369
- open: t,
2370
- container: e,
2371
- align: "start",
2372
- triggerComponent: /* @__PURE__ */ a(X, { content: "Search in document", children: /* @__PURE__ */ a(B, { onClick: S, children: /* @__PURE__ */ a(Ut, {}) }) }),
2373
- children: /* @__PURE__ */ O("div", { className: ne["rp-search-tool-content"], children: [
2374
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-input-wrapper"], children: [
2375
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-input"], children: [
2376
- /* @__PURE__ */ a(
2377
- jt,
2378
- {
2379
- value: v,
2380
- onKeyDown: d,
2381
- onChange: C,
2382
- icon: /* @__PURE__ */ a(Ut, {}),
2383
- placeholder: "Enter to Search",
2384
- className: ne["rp-search-input"],
2385
- ref: i,
2386
- children: !!v && /* @__PURE__ */ a("span", { className: ne["rp-search-tool-input-clear"], onClick: w, children: /* @__PURE__ */ a(Qr, {}) })
2387
- }
2388
- ),
2389
- c ? /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(pt, {}) }) : /* @__PURE__ */ a("span", { children: I })
2390
- ] }),
2391
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-input-checkboxes"], children: [
2392
- /* @__PURE__ */ a(Rt, { name: "matchCase", value: R, onChange: N, children: "Match Case" }),
2393
- /* @__PURE__ */ a(Rt, { name: "wholeWord", value: y, onChange: L, children: "Whole Word" })
2394
- ] })
2395
- ] }),
2396
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-controls"], children: [
2397
- /* @__PURE__ */ a(B, { onClick: f, children: /* @__PURE__ */ a(Me, { className: ne["rp-search-tool-input-icon"] }) }),
2398
- /* @__PURE__ */ a(B, { onClick: u, children: /* @__PURE__ */ a(
2399
- Me,
2400
- {
2401
- style: { transform: "rotate(180deg" },
2402
- className: ne["rp-search-tool-input-icon"]
2403
- }
2404
- ) }),
2405
- /* @__PURE__ */ a(B, { children: /* @__PURE__ */ a(Qt, { onClick: P, className: ne["rp-search-tool-input-icon"] }) })
2406
- ] })
2407
- ] })
2408
- }
2409
- ) : null;
2410
- }, Sa = "_loading_1snj5_1", Ce = {
2411
- "rp-loading-overlay": "_rp-loading-overlay_1snj5_1",
2412
- "rp-loading-modal": "_rp-loading-modal_1snj5_14",
2413
- "rp-loading-title": "_rp-loading-title_1snj5_27",
2414
- "rp-loading-progress-bar": "_rp-loading-progress-bar_1snj5_35",
2415
- "rp-loading-progress": "_rp-loading-progress_1snj5_35",
2416
- "rp-loading-cancel-button": "_rp-loading-cancel-button_1snj5_52",
2417
- loading: Sa
2418
- }, Ta = ({ percentage: e }) => {
2419
- const { cancel: t } = Tt();
2420
- return e < 1 ? null : /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-overlay"]), children: /* @__PURE__ */ O("div", { className: j(Ce["rp-loading-modal"]), children: [
2421
- /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-title"]), children: "Preparing document..." }),
2422
- /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-progress-bar"]), children: /* @__PURE__ */ a(
2423
- "div",
2424
- {
2425
- className: j(Ce["rp-loading-progress"]),
2426
- style: { width: `${e}%` }
2427
- }
2428
- ) }),
2429
- /* @__PURE__ */ a("button", { className: j(Ce["rp-loading-cancel-button"]), onClick: t, children: "Cancel" })
2430
- ] }) });
2431
- }, Ia = $e((e, t) => {
2432
- const { showPrintProgress: n } = se(), { progress: r } = Tt(), { isSmallScreen: o } = ge(), { percentage: i } = r || {}, l = () => o ? { gridTemplateColumns: "25% 60% 15%" } : void 0;
2433
- return /* @__PURE__ */ O("div", { children: [
2434
- /* @__PURE__ */ a("div", { "data-rp": "topBar", ref: t, className: Ie["rp-toolbar-content"], children: /* @__PURE__ */ O("div", { className: Ie["rp-toolbar-wrapper"], style: l(), children: [
2435
- /* @__PURE__ */ O("div", { "data-rp": "topBarLeft", className: Ie["rp-toolbar-start"], children: [
2436
- /* @__PURE__ */ a(Pa, {}),
2437
- /* @__PURE__ */ a(Wo, {})
2438
- ] }),
2439
- /* @__PURE__ */ a("div", { "data-rp": "topBarCenter", className: Ie["rp-toolbar-middle"], children: /* @__PURE__ */ a(Ca, {}) }),
2440
- /* @__PURE__ */ a("div", { "data-rp": "topBarRight", className: Ie["rp-toolbar-end"], children: /* @__PURE__ */ a(ga, {}) })
2441
- ] }) }),
2442
- n && i ? /* @__PURE__ */ a(Ta, { percentage: i }) : null
2443
- ] });
2444
- }), rt = {
2445
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_4wlw3_1",
2446
- "rp-sidebar-content": "_rp-sidebar-content_4wlw3_1",
2447
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_4wlw3_16",
2448
- "rp-thumbnail-dragging": "_rp-thumbnail-dragging_4wlw3_21"
2449
- }, Re = {
2450
- "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
2451
- "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
2452
- "rp-thumbnail": "_rp-thumbnail_3fenb_1",
2453
- "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
2454
- "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
2455
- }, ya = (e) => {
2456
- const { thumbnailSrc: t, pageNumber: n, isFocused: r, viewport: o } = e, { goToPage: i } = ee(), l = D(() => r ? Re["rp-thumbnail-active"] : "", [r]), s = D(() => ({
2457
- width: Math.round(o.width),
2458
- height: Math.round(o.height)
2459
- }), [o]), c = M(() => {
2460
- n && i(n);
2461
- }, [i, n]);
2462
- return /* @__PURE__ */ O(
2463
- "div",
2464
- {
2465
- onClick: c,
2466
- id: `page-${n}`,
2467
- className: Re["rp-thumbnail-wrapper"],
2468
- children: [
2469
- /* @__PURE__ */ a("div", { className: j(l, Re["rp-thumbnail"]), children: t ? /* @__PURE__ */ a(
2470
- "img",
2471
- {
2472
- src: t,
2473
- width: s.width,
2474
- height: s.height,
2475
- alt: "thumbnail"
2476
- }
2477
- ) : /* @__PURE__ */ a(
2478
- "div",
2479
- {
2480
- className: Re["rp-thumbnail-loader"],
2481
- style: {
2482
- width: `${s.width}px`,
2483
- height: `${s.height}px`
2484
- },
2485
- children: /* @__PURE__ */ a(pt, {})
2486
- }
2487
- ) }),
2488
- /* @__PURE__ */ a("div", { className: Re["rp-thumbnail-text"], children: n })
2489
- ]
2490
- }
2491
- );
2492
- }, qt = {
2493
- "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
2494
- "rp-thumbnails": "_rp-thumbnails_16vqr_1"
2495
- }, Ra = () => {
2496
- const [e, t] = F({}), { pages: n } = Y(), { rotate: r } = Ve(), o = D(() => Object.keys(e).length, [e]), i = M(
2497
- (s) => {
2498
- if (!n.size)
2499
- return;
2500
- const c = Array.from(n.values()).slice(0, s).map((m) => {
2501
- const { thumbnailViewport: u, scale: f } = It(m.page, r);
2502
- return {
2503
- scale: f,
2504
- page: m.page,
2505
- loading: !0,
2506
- viewport: u
2507
- };
2508
- }), p = c.reduce((m, u) => (m[u.page.pageNumber] = u, m), {});
2509
- t(p);
2510
- const h = [];
2511
- for (const m of c) {
2512
- const u = document.createElement("canvas"), f = ot(
2513
- m.page,
2514
- u,
2515
- m.scale,
2516
- r
2517
- ).promise.then(() => {
2518
- const g = u.toDataURL();
2519
- return {
2520
- ...m,
2521
- thumbnailSrc: g,
2522
- loading: !1
2523
- };
2524
- });
2525
- h.push(f);
2526
- }
2527
- Promise.all(h).then((m) => {
2528
- const u = m.reduce(
2529
- (f, g) => (f[g.page.pageNumber] = g, f),
2530
- {}
2531
- );
2532
- t((f) => ({ ...f, ...u }));
2533
- });
2534
- },
2535
- [n, r]
2536
- );
2537
- A(() => {
2538
- i(10);
2539
- }, [i]);
2540
- const l = M(
2541
- (s) => {
2542
- if (!n)
2543
- return;
2544
- const c = n.get(s);
2545
- if (!c)
2546
- return;
2547
- t((h) => ({
2548
- ...h,
2549
- [s]: {
2550
- loading: !0,
2551
- page: c.page,
2552
- viewport: c.thumbnailViewport,
2553
- scale: c.thumbnailScale
2554
- }
2555
- }));
2556
- const p = document.createElement("canvas");
2557
- ot(c.page, p, c.thumbnailScale, r).promise.then(() => {
2558
- const h = p.toDataURL(), { thumbnailViewport: m, scale: u } = It(c.page, r);
2559
- return {
2560
- scale: u,
2561
- thumbnailSrc: h,
2562
- page: c.page,
2563
- loading: !1,
2564
- viewport: m
2565
- };
2566
- }).then((h) => {
2567
- t((m) => ({ ...m, [s]: h }));
2568
- });
2569
- },
2570
- [n, r]
2571
- );
2572
- return { thumbnailPages: e, addPage: l, addToPage: i, thumbnailLength: o };
2573
- }, On = We({
2574
- thumbnailPages: {},
2575
- addPage: (e) => {
2576
- },
2577
- addToPage: (e) => {
2578
- },
2579
- thumbnailLength: 0,
2580
- setActive: (e) => {
2581
- },
2582
- active: !1
2583
- }), Dn = () => He(On), xa = ({
2584
- children: e,
2585
- initialThumbnailsVisible: t
2586
- }) => {
2587
- const { thumbnailPages: n, addPage: r, addToPage: o, thumbnailLength: i } = Ra(), [l, s] = F(t);
2588
- return /* @__PURE__ */ a(
2589
- On.Provider,
2590
- {
2591
- value: { thumbnailPages: n, addPage: r, addToPage: o, thumbnailLength: i, active: l, setActive: s },
2592
- children: e
2593
- }
2594
- );
2595
- }, Ma = 16, Na = (e, t) => {
2596
- const n = e == null ? void 0 : e.querySelector(`#page-${t}`);
2597
- e && (n != null && n.offsetTop) && (e.scrollTop = (n == null ? void 0 : n.offsetTop) - Ma);
2598
- }, La = $e((e, t) => {
2599
- const { show: n } = e, { focusedPage: r, totalPages: o } = ee(), { thumbnailPages: i, addPage: l, thumbnailLength: s, addToPage: c } = Dn(), p = $(null), h = $(1);
2600
- Zt(t, () => p.current);
2601
- const m = D(() => Object.values(i), [i]), u = M(() => {
2602
- const f = s + 1;
2603
- f <= o && l(f);
2604
- }, [l, o, s]);
2605
- return A(() => {
2606
- r > s ? c(r) : n && h.current !== r && (Na(p.current, r), h.current = r);
2607
- }, [r, s, c, n, m]), ar(p.current, u), /* @__PURE__ */ a("div", { ref: p, className: qt["rp-thumbnails-container"], children: /* @__PURE__ */ a("div", { className: qt["rp-thumbnails"], children: n ? m.map((f, g) => {
2608
- var _, v;
2609
- return /* @__PURE__ */ a(
2610
- ya,
2611
- {
2612
- isFocused: r === ((_ = f.page) == null ? void 0 : _.pageNumber),
2613
- pageNumber: (v = f.page) == null ? void 0 : v.pageNumber,
2614
- thumbnailSrc: f.thumbnailSrc,
2615
- loading: f.loading,
2616
- viewport: f.viewport
2617
- },
2618
- g
2619
- );
2620
- }) : null }) });
2621
- }), Ea = () => {
2622
- const { thumbnailIcon: e } = re();
2623
- return e || /* @__PURE__ */ a($n, {});
2624
- }, Oa = () => {
2625
- const { active: e, setActive: t } = Dn(), [n, r] = F(200), o = $(null), { thumbnailTool: i } = se(), l = M(() => {
2626
- t((c) => !c);
2627
- }, []), s = D(() => typeof i != "boolean" && i ? /* @__PURE__ */ a(i, { onClick: l, active: e }) : i ? /* @__PURE__ */ a(X, { content: "Thumbnail", children: /* @__PURE__ */ a(B, { onClick: l, active: e, children: /* @__PURE__ */ a(Ea, {}) }) }) : null, [i, e, l]);
2628
- return /* @__PURE__ */ O(
2629
- "div",
2630
- {
2631
- style: { "--rp-thumbnail-width": `${n}px` },
2632
- className: rt["rp-sidebar-content-wrapper"],
2633
- "data-rp": "sidebar",
2634
- children: [
2635
- /* @__PURE__ */ a("div", { className: rt["rp-sidebar-content"], children: s }),
2636
- /* @__PURE__ */ O("div", { "data-rp": "thumbnailSidebar", hidden: !e, className: rt["rp-thumbnails-wrapper"], children: [
2637
- /* @__PURE__ */ a(La, { show: e, ref: o }),
2638
- /* @__PURE__ */ a(ir, { onWidthChange: r, thumbnailRef: o })
2639
- ] })
2640
- ]
2641
- }
2642
- );
2643
- }, Da = (e) => {
2644
- const {
2645
- children: t,
2646
- darkMode: n = !1,
2647
- onDarkModeChange: r,
2648
- initialRotate: o = 0,
2649
- textLayer: i = !0,
2650
- initialPage: l = 1,
2651
- // initialViewMode = ViewMode.SINGLE_PAGE,
2652
- initialScale: s,
2653
- initialScrollMode: c = Q.VERTICAL_SCROLLING,
2654
- mobileWidth: p
2655
- } = e;
2656
- return /* @__PURE__ */ a(
2657
- _r,
2658
- {
2659
- initialScale: s,
2660
- initialPage: l,
2661
- initialScrollMode: c,
2662
- initialRotate: o,
2663
- children: /* @__PURE__ */ a(fr, { mobileWidth: p, children: /* @__PURE__ */ a(pr, { children: /* @__PURE__ */ a(Qn, { children: /* @__PURE__ */ a(jn, { children: /* @__PURE__ */ a(Hn, { children: /* @__PURE__ */ a(gr, { initialSelectionMode: Bt.TEXT, children: /* @__PURE__ */ a(hr, { children: /* @__PURE__ */ a(Oo, { children: /* @__PURE__ */ a(Zn, { children: /* @__PURE__ */ a(dr, { textLayer: i, children: /* @__PURE__ */ a(Kn, { children: /* @__PURE__ */ a(
2664
- Un,
2665
- {
2666
- darkMode: n,
2667
- onDarkModeChange: r,
2668
- children: t
2669
- }
2670
- ) }) }) }) }) }) }) }) }) }) }) })
2671
- }
2672
- );
2673
- }, os = $e((e, t) => {
2674
- const {
2675
- children: n,
2676
- slots: r,
2677
- icons: o,
2678
- initialThumbnailsVisible: i = !1,
2679
- initialSearch: l,
2680
- showToolbar: s = !0,
2681
- style: c,
2682
- className: p,
2683
- onLoaded: h,
2684
- cleanupOnLoaded: m,
2685
- ...u
2686
- } = e, [f, g] = F(null), [_, v] = F(null), [b, S] = F(null);
2687
- return A(() => (h && h(), () => {
2688
- m && m();
2689
- }), [h, m]), /* @__PURE__ */ a("div", { ref: t, className: j(he["rp-theme-variables"], he["rp-container"]), children: /* @__PURE__ */ a(cr, { container: _, contentRef: b, children: /* @__PURE__ */ a(Da, { ...u, children: /* @__PURE__ */ a(no, { initialSearch: l, children: /* @__PURE__ */ a(xa, { initialThumbnailsVisible: i, children: /* @__PURE__ */ a(qn, { slots: r, children: /* @__PURE__ */ a(Gn, { children: /* @__PURE__ */ a(sr, { icons: o, children: /* @__PURE__ */ a(br, { elementRef: b, children: /* @__PURE__ */ a(la, { children: /* @__PURE__ */ a(Bn, { children: s ? /* @__PURE__ */ a(
2690
- lr,
2691
- {
2692
- getContainerRef: v,
2693
- toolbarRef: f,
2694
- style: c,
2695
- className: p,
2696
- children: /* @__PURE__ */ O(Cr, { children: [
2697
- /* @__PURE__ */ O("div", { className: he["rp-layout"], children: [
2698
- /* @__PURE__ */ a(Ia, { ref: g }),
2699
- /* @__PURE__ */ O("div", { className: he["rp-content"], children: [
2700
- /* @__PURE__ */ a("div", { className: he["rp-sidebar"], children: /* @__PURE__ */ a(Oa, {}) }),
2701
- /* @__PURE__ */ a("div", { ref: S, className: he["rp-pages"], children: n })
2702
- ] })
2703
- ] }),
2704
- /* @__PURE__ */ a(Vn, {})
2705
- ] })
2706
- }
2707
- ) : /* @__PURE__ */ a(
2708
- "div",
2709
- {
2710
- ref: S,
2711
- className: j(he["rp-pages"], p),
2712
- style: c,
2713
- children: n
2714
- }
2715
- ) }) }) }) }) }) }) }) }) }) }) });
2716
- });
2717
- export {
2718
- po as A,
2719
- xa as B,
2720
- eo as C,
2721
- Do as D,
2722
- La as E,
2723
- xn as F,
2724
- Oa as G,
2725
- Da as H,
2726
- Ta as L,
2727
- fa as M,
2728
- ma as O,
2729
- dn as P,
2730
- ts as R,
2731
- nn as S,
2732
- ro as T,
2733
- Ca as Z,
2734
- os as a,
2735
- oa as b,
2736
- Tt as c,
2737
- rn as d,
2738
- _t as e,
2739
- to as f,
2740
- no as g,
2741
- wt as h,
2742
- Mo as i,
2743
- Eo as j,
2744
- Oo as k,
2745
- Ao as l,
2746
- Wo as m,
2747
- na as n,
2748
- sa as o,
2749
- Mn as p,
2750
- la as q,
2751
- En as r,
2752
- ga as s,
2753
- Pa as t,
2754
- ee as u,
2755
- Ia as v,
2756
- ya as w,
2757
- Ra as x,
2758
- On as y,
2759
- Dn as z
2760
- };