pdf-tsx 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/LICENSE +78 -78
  2. package/README.md +678 -634
  3. package/dist/cjs/components/PDFViewer.cjs +1 -1
  4. package/dist/cjs/components/PDFViewer.module.cjs +1 -1
  5. package/dist/cjs/components/features/PDFViewModeToggle.cjs +1 -0
  6. package/dist/cjs/components/features/PDFViewModeToggle.module.cjs +1 -0
  7. package/dist/cjs/favicon.svg +9 -0
  8. package/dist/cjs/hooks/usePDFLoader.cjs +1 -1
  9. package/dist/cjs/index.cjs +1 -1
  10. package/dist/cjs/labels.cjs +1 -1
  11. package/dist/cjs/pdf-tsx.css +1 -1
  12. package/dist/cjs/vendor/pdfjs-wasm/jbig2.cjs +1 -0
  13. package/dist/cjs/vendor/pdfjs-wasm/openjpeg.cjs +1 -0
  14. package/dist/cjs/vendor/pdfjs-wasm/qcms_bg.cjs +1 -0
  15. package/dist/components/PDFSidebar.d.ts +1 -1
  16. package/dist/components/PDFViewer.d.ts +2 -2
  17. package/dist/components/features/PDFAnnotations.d.ts +2 -2
  18. package/dist/components/features/PDFAttachments.d.ts +2 -2
  19. package/dist/components/features/PDFChangeFile.d.ts +1 -1
  20. package/dist/components/features/PDFDownloadButton.d.ts +1 -1
  21. package/dist/components/features/PDFNavigation.d.ts +1 -1
  22. package/dist/components/features/PDFOutline.d.ts +1 -1
  23. package/dist/components/features/PDFPageFit.d.ts +1 -1
  24. package/dist/components/features/PDFPrintButton.d.ts +1 -1
  25. package/dist/components/features/PDFRotationControl.d.ts +1 -1
  26. package/dist/components/features/PDFSearch.d.ts +1 -1
  27. package/dist/components/features/PDFSidebarToggle.d.ts +1 -1
  28. package/dist/components/features/PDFSignatures.d.ts +2 -2
  29. package/dist/components/features/PDFThemeToggle.d.ts +1 -1
  30. package/dist/components/features/PDFThumbnails.d.ts +1 -1
  31. package/dist/components/features/PDFViewModeToggle.d.ts +11 -0
  32. package/dist/components/features/PDFZoomControls.d.ts +1 -1
  33. package/dist/components/ui/PDFToolbar.d.ts +1 -1
  34. package/dist/components/ui/PDFToolbarItem.d.ts +1 -1
  35. package/dist/components/ui/PDFToolbarSeparator.d.ts +1 -1
  36. package/dist/components/ui/ToolbarButton.d.ts +1 -1
  37. package/dist/components/ui/icons.d.ts +3 -2
  38. package/dist/context/LabelsContext.d.ts +1 -1
  39. package/dist/context/PDFViewerContext.d.ts +2 -0
  40. package/dist/context/ThemeContext.d.ts +1 -1
  41. package/dist/es/components/PDFViewer.js +247 -224
  42. package/dist/es/components/PDFViewer.module.js +26 -23
  43. package/dist/es/components/features/PDFViewModeToggle.js +70 -0
  44. package/dist/es/components/features/PDFViewModeToggle.module.js +12 -0
  45. package/dist/es/favicon.svg +9 -0
  46. package/dist/es/hooks/usePDFLoader.js +36 -16
  47. package/dist/es/index.js +13 -12
  48. package/dist/es/labels.js +8 -0
  49. package/dist/es/pdf-tsx.css +1 -1
  50. package/dist/es/vendor/pdfjs-wasm/jbig2.js +4 -0
  51. package/dist/es/vendor/pdfjs-wasm/openjpeg.js +4 -0
  52. package/dist/es/vendor/pdfjs-wasm/qcms_bg.js +4 -0
  53. package/dist/hooks/usePDFLoader.d.ts +1 -1
  54. package/dist/index.d.ts +1 -0
  55. package/dist/labels.d.ts +4 -0
  56. package/package.json +66 -65
  57. package/dist/cjs/vite.svg +0 -1
  58. package/dist/components/features/PDFSignButton.d.ts +0 -10
  59. package/dist/components/features/SignaturePad.d.ts +0 -10
  60. package/dist/es/vite.svg +0 -1
  61. package/dist/pdf-tsx.cjs.js +0 -5
  62. package/dist/pdf-tsx.css +0 -2
  63. package/dist/pdf-tsx.es.js +0 -2637
  64. package/dist/src/components/PDFSidebar.d.ts +0 -11
  65. package/dist/src/components/PDFViewer.d.ts +0 -22
  66. package/dist/src/components/features/PDFAnnotations.d.ts +0 -5
  67. package/dist/src/components/features/PDFAttachments.d.ts +0 -5
  68. package/dist/src/components/features/PDFChangeFile.d.ts +0 -9
  69. package/dist/src/components/features/PDFDownloadButton.d.ts +0 -9
  70. package/dist/src/components/features/PDFNavigation.d.ts +0 -10
  71. package/dist/src/components/features/PDFOutline.d.ts +0 -1
  72. package/dist/src/components/features/PDFPageFit.d.ts +0 -10
  73. package/dist/src/components/features/PDFPrintButton.d.ts +0 -9
  74. package/dist/src/components/features/PDFRotationControl.d.ts +0 -9
  75. package/dist/src/components/features/PDFSearch.d.ts +0 -13
  76. package/dist/src/components/features/PDFSidebarToggle.d.ts +0 -10
  77. package/dist/src/components/features/PDFSignatures.d.ts +0 -5
  78. package/dist/src/components/features/PDFThemeToggle.d.ts +0 -10
  79. package/dist/src/components/features/PDFThumbnails.d.ts +0 -1
  80. package/dist/src/components/features/PDFZoomControls.d.ts +0 -10
  81. package/dist/src/components/ui/PDFToolbar.d.ts +0 -8
  82. package/dist/src/components/ui/PDFToolbarDropdownContext.d.ts +0 -1
  83. package/dist/src/components/ui/PDFToolbarItem.d.ts +0 -7
  84. package/dist/src/components/ui/PDFToolbarSeparator.d.ts +0 -4
  85. package/dist/src/components/ui/ToolbarButton.d.ts +0 -6
  86. package/dist/src/components/ui/icons.d.ts +0 -7
  87. package/dist/src/context/LabelsContext.d.ts +0 -7
  88. package/dist/src/context/PDFViewerContext.d.ts +0 -30
  89. package/dist/src/context/ThemeContext.d.ts +0 -12
  90. package/dist/src/context/labelsContextValue.d.ts +0 -2
  91. package/dist/src/context/themeContextValue.d.ts +0 -7
  92. package/dist/src/hooks/useAnnotationLayer.d.ts +0 -34
  93. package/dist/src/hooks/useAnnotations.d.ts +0 -15
  94. package/dist/src/hooks/useAttachments.d.ts +0 -11
  95. package/dist/src/hooks/useKeyboardShortcuts.d.ts +0 -9
  96. package/dist/src/hooks/useLabels.d.ts +0 -2
  97. package/dist/src/hooks/useOutline.d.ts +0 -14
  98. package/dist/src/hooks/useOverlayRects.d.ts +0 -21
  99. package/dist/src/hooks/usePDFLoader.d.ts +0 -5
  100. package/dist/src/hooks/usePDFRenderer.d.ts +0 -16
  101. package/dist/src/hooks/useScrollTracking.d.ts +0 -10
  102. package/dist/src/hooks/useSignatures.d.ts +0 -17
  103. package/dist/src/hooks/useTextLayer.d.ts +0 -10
  104. package/dist/src/hooks/useTextSearch.d.ts +0 -12
  105. package/dist/src/hooks/useTheme.d.ts +0 -2
  106. package/dist/src/hooks/useThumbnails.d.ts +0 -10
  107. package/dist/src/index.d.ts +0 -24
  108. package/dist/src/labels.d.ts +0 -53
  109. package/dist/src/theme.d.ts +0 -27
  110. package/dist/src/utils/pdfFit.d.ts +0 -2
  111. package/dist/src/utils/url.d.ts +0 -1
  112. package/dist/utils/addSignatureToPdf.d.ts +0 -9
  113. package/dist/vite.svg +0 -1
  114. package/dist/wasm/LICENSE_JBIG2 +0 -196
  115. package/dist/wasm/LICENSE_OPENJPEG +0 -39
  116. package/dist/wasm/LICENSE_PDFJS_JBIG2 +0 -13
  117. package/dist/wasm/LICENSE_PDFJS_OPENJPEG +0 -22
  118. package/dist/wasm/LICENSE_PDFJS_QCMS +0 -22
  119. package/dist/wasm/LICENSE_QCMS +0 -21
  120. package/dist/wasm/jbig2.wasm +0 -0
  121. package/dist/wasm/jbig2_nowasm_fallback.js +0 -15
  122. package/dist/wasm/openjpeg.wasm +0 -0
  123. package/dist/wasm/openjpeg_nowasm_fallback.js +0 -17
  124. package/dist/wasm/qcms_bg.wasm +0 -0
  125. package/dist/wasm/quickjs-eval.js +0 -16
  126. package/dist/wasm/quickjs-eval.wasm +0 -0
  127. /package/dist/{src/hooks → hooks}/usePinchZoom.d.ts +0 -0
  128. /package/dist/{src/utils → utils}/pdfjsPolyfill.d.ts +0 -0
  129. /package/dist/{src/utils → utils}/zoom.d.ts +0 -0
@@ -3,266 +3,289 @@ import { useScrollTracking as t } from "../hooks/useScrollTracking.js";
3
3
  import { useKeyboardShortcuts as n } from "../hooks/useKeyboardShortcuts.js";
4
4
  import { useTextLayer as r } from "../hooks/useTextLayer.js";
5
5
  import { isSafeUrl as i } from "../utils/url.js";
6
- import { useAnnotationLayer as a } from "../hooks/useAnnotationLayer.js";
7
- import { usePDFLoader as ee } from "../hooks/usePDFLoader.js";
8
- import { usePDFRenderer as te } from "../hooks/usePDFRenderer.js";
9
- import { useOverlayRects as ne } from "../hooks/useOverlayRects.js";
10
- import { usePinchZoom as re } from "../hooks/usePinchZoom.js";
11
- import { PDFJS_POLYFILL as ie, applyPdfjsPolyfill as o } from "../utils/pdfjsPolyfill.js";
12
- import { computeFit as s } from "../utils/pdfFit.js";
13
- import { ThemeProvider as ae } from "../context/ThemeContext.js";
14
- import { LabelsProvider as oe } from "../context/LabelsContext.js";
15
- import { useLabels as c } from "../hooks/useLabels.js";
16
- import l from "./PDFViewer.module.js";
17
- import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
18
- import * as se from "pdfjs-dist";
19
- import { Fragment as ce, jsx as h, jsxs as g } from "react/jsx-runtime";
6
+ import { useAnnotationLayer as ee } from "../hooks/useAnnotationLayer.js";
7
+ import { usePDFLoader as te } from "../hooks/usePDFLoader.js";
8
+ import { usePDFRenderer as ne } from "../hooks/usePDFRenderer.js";
9
+ import { useOverlayRects as re } from "../hooks/useOverlayRects.js";
10
+ import { usePinchZoom as ie } from "../hooks/usePinchZoom.js";
11
+ import { PDFJS_POLYFILL as ae, applyPdfjsPolyfill as a } from "../utils/pdfjsPolyfill.js";
12
+ import { computeFit as oe } from "../utils/pdfFit.js";
13
+ import { ThemeProvider as se } from "../context/ThemeContext.js";
14
+ import { LabelsProvider as ce } from "../context/LabelsContext.js";
15
+ import { useLabels as o } from "../hooks/useLabels.js";
16
+ import s from "./PDFViewer.module.js";
17
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
18
+ import * as le from "pdfjs-dist";
19
+ import { Fragment as ue, jsx as p, jsxs as m } from "react/jsx-runtime";
20
20
  //#region src/components/PDFViewer.tsx
21
- o();
22
- var _ = 2;
23
- function le({ hasRead: e }) {
24
- let t = c();
25
- return /* @__PURE__ */ g("div", {
26
- className: `${l.requireReadBanner} ${e ? l.requireReadDone : ""}`,
27
- children: [e ? /* @__PURE__ */ h("svg", {
21
+ a();
22
+ var h = 2;
23
+ function de({ hasRead: e }) {
24
+ let t = o();
25
+ return /* @__PURE__ */ m("div", {
26
+ className: `${s.requireReadBanner} ${e ? s.requireReadDone : ""}`,
27
+ children: [e ? /* @__PURE__ */ p("svg", {
28
28
  width: "16",
29
29
  height: "16",
30
30
  viewBox: "0 0 16 16",
31
31
  fill: "none",
32
32
  "aria-hidden": "true",
33
- children: /* @__PURE__ */ h("path", {
33
+ children: /* @__PURE__ */ p("path", {
34
34
  d: "M3 8l3.5 3.5L13 4.5",
35
35
  stroke: "currentColor",
36
36
  strokeWidth: "2",
37
37
  strokeLinecap: "round",
38
38
  strokeLinejoin: "round"
39
39
  })
40
- }) : /* @__PURE__ */ h("svg", {
40
+ }) : /* @__PURE__ */ p("svg", {
41
41
  width: "16",
42
42
  height: "16",
43
43
  viewBox: "0 0 16 16",
44
44
  fill: "none",
45
45
  "aria-hidden": "true",
46
- children: /* @__PURE__ */ h("path", {
46
+ children: /* @__PURE__ */ p("path", {
47
47
  d: "M8 3v10M4 9l4 4 4-4",
48
48
  stroke: "currentColor",
49
49
  strokeWidth: "2",
50
50
  strokeLinecap: "round",
51
51
  strokeLinejoin: "round"
52
52
  })
53
- }), /* @__PURE__ */ h("span", { children: e ? t.requireReadDone : t.requireReadPending })]
53
+ }), /* @__PURE__ */ p("span", { children: e ? t.requireReadDone : t.requireReadPending })]
54
54
  });
55
55
  }
56
- var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, themeOverrides: ue, defaultTheme: de, defaultFit: x, language: fe, className: S, style: pe, requireRead: C, onDocumentRead: w }) => {
57
- d(() => {
58
- let e = new URL(c, location.href).href, t = new Blob([`${ie}\nimport(${JSON.stringify(e)});`], { type: "application/javascript" }), n = URL.createObjectURL(t);
59
- return se.GlobalWorkerOptions.workerSrc = n, () => URL.revokeObjectURL(n);
60
- }, [c]);
61
- let [T, E] = m(1), [D, me] = m(0), [O, k] = m(null), [A, he] = m([]), [j, ge] = m(!1), [M, N] = m(x ?? null), [P, F] = m(null), [I, L] = m(!1), R = p(!1), z = p(null), B = p([]), V = p([]), H = p(D);
62
- d(() => {
63
- H.current = D;
64
- }, [D]);
65
- let [_e, ve] = m(null);
66
- _e !== o && (ve(o), k(null), L(!1)), d(() => {
67
- R.current = !1;
56
+ var g = ({ file: a, workerSrc: o, sidebar: g, toolbar: _, onChangeFile: v, themeOverrides: fe, defaultTheme: pe, defaultFit: y, defaultLayout: me, language: he, className: b, style: ge, requireRead: x, onDocumentRead: _e }) => {
57
+ l(() => {
58
+ let e = new URL(o, location.href).href, t = new Blob([`${ae}\nimport(${JSON.stringify(e)});`], { type: "application/javascript" }), n = URL.createObjectURL(t);
59
+ return le.GlobalWorkerOptions.workerSrc = n, () => URL.revokeObjectURL(n);
68
60
  }, [o]);
69
- let { pdf: U, numPages: W, loading: ye } = ee(o);
70
- d(() => {
71
- U && (B.current = Array(U.numPages).fill(null), V.current = Array(U.numPages).fill(null));
72
- }, [U]), d(() => {
73
- !U || !x || !z.current || s(x, U, z.current, H.current).then(E);
74
- }, [U, x]);
75
- let G = p(M);
76
- d(() => {
77
- G.current = M;
78
- }, [M]), d(() => {
79
- if (!U || !z.current) return;
80
- let e = z.current, t = new ResizeObserver(() => {
81
- G.current && s(G.current, U, e, H.current).then(E);
61
+ let [S, C] = f(1), [w, ve] = f(0), [T, E] = f(null), [D, ye] = f([]), [O, be] = f(!1), [k, A] = f(y ?? null), [j, xe] = f(me ?? "continuous"), [M, N] = f(null), [P, F] = f(!1), I = d(!1), L = d(null), R = d([]), z = d([]), B = d(w);
62
+ l(() => {
63
+ B.current = w;
64
+ }, [w]);
65
+ let [Se, Ce] = f(null);
66
+ Se !== a && (Ce(a), E(null), F(!1)), l(() => {
67
+ I.current = !1;
68
+ }, [a]);
69
+ let { pdf: V, numPages: H, loading: we } = te(a);
70
+ l(() => {
71
+ V && (R.current = Array(V.numPages).fill(null), z.current = Array(V.numPages).fill(null));
72
+ }, [V]), l(() => {
73
+ !V || !y || !L.current || oe(y, V, L.current, B.current).then(C);
74
+ }, [V, y]);
75
+ let U = d(k);
76
+ l(() => {
77
+ U.current = k;
78
+ }, [k]), l(() => {
79
+ if (!V || !L.current) return;
80
+ let e = L.current, t = new ResizeObserver(() => {
81
+ U.current && oe(U.current, V, e, B.current).then(C);
82
82
  });
83
83
  return t.observe(e), () => t.disconnect();
84
- }, [U]);
85
- let { currentPage: K, goToPage: q } = t({
86
- numPages: W,
87
- containerRef: z,
88
- pageRefs: B
89
- });
90
- d(() => {
91
- W === 0 || K < W || (C && !I && L(!0), R.current || (R.current = !0, w?.()));
84
+ }, [V]);
85
+ let { currentPage: W, goToPage: G } = t({
86
+ numPages: H,
87
+ containerRef: L,
88
+ pageRefs: R
89
+ }), [K, Te] = f([]);
90
+ l(() => {
91
+ let e = L.current;
92
+ if (!e || H === 0) return;
93
+ let t = /* @__PURE__ */ new Set(), n = new IntersectionObserver((e) => {
94
+ let n = !1;
95
+ for (let r of e) {
96
+ let e = R.current.indexOf(r.target);
97
+ if (e === -1) continue;
98
+ let i = e + 1;
99
+ r.isIntersecting ? t.has(i) || (t.add(i), n = !0) : t.delete(i) && (n = !0);
100
+ }
101
+ n && Te(Array.from(t).sort((e, t) => e - t));
102
+ }, {
103
+ root: e,
104
+ rootMargin: "300px 0px",
105
+ threshold: 0
106
+ });
107
+ return R.current.forEach((e) => e && n.observe(e)), () => n.disconnect();
108
+ }, [H, j]), l(() => {
109
+ H === 0 || W < H || (x && !P && F(!0), I.current || (I.current = !0, _e?.()));
92
110
  }, [
93
- K,
94
111
  W,
95
- C,
96
- I,
97
- w
112
+ H,
113
+ x,
114
+ P,
115
+ _e
98
116
  ]);
99
- let J = f(() => {
100
- if (W === 0) return [];
101
- let e = /* @__PURE__ */ new Set(), t = Math.max(K - _, 1), n = Math.min(K + _, W);
117
+ let q = u(() => {
118
+ if (H === 0) return [];
119
+ let e = /* @__PURE__ */ new Set(), t = Math.max(W - h, 1), n = Math.min(W + h, H);
102
120
  for (let r = t; r <= n; r++) e.add(r);
103
- O && e.add(O.page);
104
- for (let t of A) e.add(t.page);
121
+ for (let t of K) e.add(t);
122
+ T && e.add(T.page);
123
+ for (let t of D) e.add(t.page);
105
124
  return Array.from(e).sort((e, t) => e - t);
106
125
  }, [
107
- K,
108
126
  W,
109
- O,
110
- A
111
- ]), { pageSizes: be, renderedPages: Y } = te({
112
- pdf: U,
113
- zoom: T,
114
- rotation: D,
115
- visiblePages: J,
116
- canvasRefs: V
117
- }), X = f(() => {
118
- let e = new Set(J);
119
- for (let t of Y) e.add(t);
127
+ H,
128
+ T,
129
+ D,
130
+ K
131
+ ]), { pageSizes: Ee, renderedPages: J } = ne({
132
+ pdf: V,
133
+ zoom: S,
134
+ rotation: w,
135
+ visiblePages: q,
136
+ canvasRefs: z
137
+ }), Y = u(() => {
138
+ let e = new Set(q);
139
+ for (let t of J) e.add(t);
120
140
  return Array.from(e).sort((e, t) => e - t);
121
- }, [J, Y]);
141
+ }, [q, J]);
122
142
  n({
123
- pdf: U,
124
- currentPage: K,
125
- goToPage: q,
126
- setRotation: me
127
- }), re(z, T, E, N);
128
- let xe = r({
129
- pdf: U,
130
- zoom: T,
131
- rotation: D,
132
- mountedPages: X,
133
- canvasRefs: V
134
- }), { linkOverlays: Se, noteOverlays: Ce } = a({
135
- pdf: U,
136
- zoom: T,
137
- rotation: D,
138
- mountedPages: X,
139
- goToPage: q
143
+ pdf: V,
144
+ currentPage: W,
145
+ goToPage: G,
146
+ setRotation: ve
147
+ }), ie(L, S, C, A);
148
+ let De = r({
149
+ pdf: V,
150
+ zoom: S,
151
+ rotation: w,
152
+ mountedPages: Y,
153
+ canvasRefs: z
154
+ }), { linkOverlays: Oe, noteOverlays: ke } = ee({
155
+ pdf: V,
156
+ zoom: S,
157
+ rotation: w,
158
+ mountedPages: Y,
159
+ goToPage: G
140
160
  });
141
- d(() => {
142
- if (!P) return;
143
- let e = () => F(null), t = (e) => {
144
- e.key === "Escape" && F(null);
161
+ l(() => {
162
+ if (!M) return;
163
+ let e = () => N(null), t = (e) => {
164
+ e.key === "Escape" && N(null);
145
165
  };
146
166
  return document.addEventListener("click", e), document.addEventListener("keydown", t), () => {
147
167
  document.removeEventListener("click", e), document.removeEventListener("keydown", t);
148
168
  };
149
- }, [P]);
150
- let { overlayRect: Z, searchOverlays: we } = ne({
151
- pdf: U,
152
- highlight: O,
153
- searchMatches: A,
154
- zoom: T,
155
- rotation: D
156
- }), Te = u((e, t) => {
169
+ }, [M]);
170
+ let { overlayRect: X, searchOverlays: Ae } = re({
171
+ pdf: V,
172
+ highlight: T,
173
+ searchMatches: D,
174
+ zoom: S,
175
+ rotation: w
176
+ }), je = c((e, t) => {
157
177
  (!e.url || !i(e.url)) && (t.preventDefault(), e.url || e._handleClick());
158
- }, []), Q = p(null), Ee = u((e, t) => {
159
- Q.current && clearTimeout(Q.current);
178
+ }, []), Z = d(null), Me = c((e, t) => {
179
+ Z.current && clearTimeout(Z.current);
160
180
  let n = t.clientY > window.innerHeight * .6;
161
- F({
181
+ N({
162
182
  x: Math.min(t.clientX, window.innerWidth - 304),
163
183
  y: n ? window.innerHeight - t.clientY + 8 : t.clientY + 12,
164
184
  above: n,
165
185
  contents: e.contents,
166
186
  title: e.title
167
187
  });
168
- }, []), $ = u(() => {
169
- Q.current = setTimeout(() => F(null), 200);
170
- }, []), De = u((e) => {
171
- k({
188
+ }, []), Q = c(() => {
189
+ Z.current = setTimeout(() => N(null), 200);
190
+ }, []), $ = c((e) => {
191
+ E({
172
192
  page: e.page,
173
193
  pdfRect: e.pdfRect
174
- }), q(e.page);
175
- }, [k, q]), Oe = f(() => ({
176
- pdf: U,
177
- numPages: W,
178
- zoom: T,
179
- setZoom: E,
180
- rotation: D,
181
- setRotation: me,
182
- currentPage: K,
183
- goToPage: q,
184
- containerRef: z,
185
- canvasRefs: V,
186
- file: o,
187
- highlight: O,
188
- setHighlight: k,
189
- searchMatches: A,
190
- setSearchMatches: he,
191
- onChangeFile: b,
192
- sidebarCollapsed: j,
193
- setSidebarCollapsed: ge,
194
- fitMode: M,
195
- setFitMode: N,
196
- navigationLocked: !!C && !I
194
+ }), G(e.page);
195
+ }, [E, G]), Ne = u(() => ({
196
+ pdf: V,
197
+ numPages: H,
198
+ zoom: S,
199
+ setZoom: C,
200
+ rotation: w,
201
+ setRotation: ve,
202
+ currentPage: W,
203
+ goToPage: G,
204
+ containerRef: L,
205
+ canvasRefs: z,
206
+ file: a,
207
+ highlight: T,
208
+ setHighlight: E,
209
+ searchMatches: D,
210
+ setSearchMatches: ye,
211
+ onChangeFile: v,
212
+ sidebarCollapsed: O,
213
+ setSidebarCollapsed: be,
214
+ fitMode: k,
215
+ setFitMode: A,
216
+ pageLayout: j,
217
+ setPageLayout: xe,
218
+ navigationLocked: !!x && !P
197
219
  }), [
198
- U,
220
+ V,
221
+ H,
222
+ S,
223
+ w,
199
224
  W,
225
+ G,
226
+ a,
200
227
  T,
201
228
  D,
202
- K,
203
- q,
204
- o,
229
+ v,
205
230
  O,
206
- A,
207
- b,
231
+ k,
208
232
  j,
209
- M,
210
- C,
211
- I
233
+ x,
234
+ P
212
235
  ]);
213
- return /* @__PURE__ */ h(ae, {
214
- themeOverrides: ue,
215
- defaultTheme: de,
216
- children: /* @__PURE__ */ h(oe, {
217
- language: fe,
218
- children: /* @__PURE__ */ g(e.Provider, {
219
- value: Oe,
220
- children: [/* @__PURE__ */ g("div", {
221
- className: `${l.appLayout}${S ? ` ${S}` : ""}`,
222
- style: pe,
223
- children: [y && /* @__PURE__ */ h("div", {
224
- className: l.toolbar,
225
- children: y
226
- }), /* @__PURE__ */ g("div", {
227
- className: l.body,
228
- children: [v, /* @__PURE__ */ g("div", {
229
- className: l.scrollContainer,
230
- ref: z,
236
+ return /* @__PURE__ */ p(se, {
237
+ themeOverrides: fe,
238
+ defaultTheme: pe,
239
+ children: /* @__PURE__ */ p(ce, {
240
+ language: he,
241
+ children: /* @__PURE__ */ m(e.Provider, {
242
+ value: Ne,
243
+ children: [/* @__PURE__ */ m("div", {
244
+ className: `${s.appLayout}${b ? ` ${b}` : ""}`,
245
+ style: ge,
246
+ children: [_ && /* @__PURE__ */ p("div", {
247
+ className: s.toolbar,
248
+ children: _
249
+ }), /* @__PURE__ */ m("div", {
250
+ className: s.body,
251
+ children: [g, /* @__PURE__ */ m("div", {
252
+ className: `${s.scrollContainer} ${j === "single" ? s.single : j === "spread" ? s.spread : ""}`,
253
+ ref: L,
231
254
  children: [
232
- ye && /* @__PURE__ */ h("div", { className: l.documentLoading }),
233
- Array.from({ length: W }, (e, t) => {
234
- let n = Y.has(t + 1), r = be[t], a = X.includes(t + 1);
235
- return /* @__PURE__ */ g("div", {
236
- className: l.pageWrapper,
255
+ we && /* @__PURE__ */ p("div", { className: s.documentLoading }),
256
+ Array.from({ length: H }, (e, t) => {
257
+ let n = J.has(t + 1), r = Ee[t], ee = Y.includes(t + 1);
258
+ return /* @__PURE__ */ m("div", {
259
+ className: `${s.pageWrapper}${t + 1 === W ? ` ${s.currentPage}` : ""}`,
237
260
  ref: (e) => {
238
- B.current[t] = e;
261
+ R.current[t] = e;
239
262
  },
240
263
  style: r ? {
241
264
  width: r.width,
242
265
  height: r.height
243
266
  } : void 0,
244
267
  children: [
245
- r && !n && /* @__PURE__ */ h("div", {
246
- className: l.pageSkeleton,
268
+ r && !n && /* @__PURE__ */ p("div", {
269
+ className: s.pageSkeleton,
247
270
  style: {
248
271
  width: r.width,
249
272
  height: r.height
250
273
  }
251
274
  }),
252
- a && /* @__PURE__ */ g(ce, { children: [/* @__PURE__ */ h("canvas", {
253
- className: l.pageCanvas,
275
+ ee && /* @__PURE__ */ m(ue, { children: [/* @__PURE__ */ p("canvas", {
276
+ className: s.pageCanvas,
254
277
  ref: (e) => {
255
- V.current[t] = e;
278
+ z.current[t] = e;
256
279
  },
257
280
  style: { display: n ? "block" : "none" }
258
- }), /* @__PURE__ */ h("div", {
259
- className: `textLayer ${l.textLayer}`,
281
+ }), /* @__PURE__ */ p("div", {
282
+ className: `textLayer ${s.textLayer}`,
260
283
  ref: (e) => {
261
- xe.current[t] = e;
284
+ De.current[t] = e;
262
285
  }
263
286
  })] }),
264
- Se.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ h("a", {
265
- className: l.linkOverlay,
287
+ Oe.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ p("a", {
288
+ className: s.linkOverlay,
266
289
  href: e.url && i(e.url) ? e.url : "#",
267
290
  target: "_blank",
268
291
  rel: "noopener noreferrer",
@@ -272,27 +295,27 @@ var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, theme
272
295
  width: e.width,
273
296
  height: e.height
274
297
  },
275
- onClick: (t) => Te(e, t)
298
+ onClick: (t) => je(e, t)
276
299
  }, t)),
277
- Ce.filter((e) => e.page === t + 1).map((e, t) => e.subtype === "Text" ? /* @__PURE__ */ h("div", {
278
- className: l.noteIconOverlay,
300
+ ke.filter((e) => e.page === t + 1).map((e, t) => e.subtype === "Text" ? /* @__PURE__ */ p("div", {
301
+ className: s.noteIconOverlay,
279
302
  style: {
280
303
  left: e.x,
281
304
  top: e.y,
282
305
  width: Math.max(e.width, 26),
283
306
  height: Math.max(e.height, 26)
284
307
  },
285
- onMouseEnter: (t) => Ee(e, t),
286
- onMouseLeave: $,
287
- onClick: () => De(e),
288
- children: /* @__PURE__ */ g("svg", {
308
+ onMouseEnter: (t) => Me(e, t),
309
+ onMouseLeave: Q,
310
+ onClick: () => $(e),
311
+ children: /* @__PURE__ */ m("svg", {
289
312
  width: "22",
290
313
  height: "22",
291
314
  viewBox: "0 0 12 12",
292
315
  fill: "none",
293
316
  "aria-hidden": "true",
294
317
  children: [
295
- /* @__PURE__ */ h("rect", {
318
+ /* @__PURE__ */ p("rect", {
296
319
  x: "0.5",
297
320
  y: "0.5",
298
321
  width: "9",
@@ -302,13 +325,13 @@ var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, theme
302
325
  stroke: "rgba(160,120,0,0.7)",
303
326
  strokeWidth: "1"
304
327
  }),
305
- /* @__PURE__ */ h("path", {
328
+ /* @__PURE__ */ p("path", {
306
329
  d: "M9.5 5.5v3l2.5-3z",
307
330
  fill: "rgba(255,210,0,0.9)",
308
331
  stroke: "rgba(160,120,0,0.7)",
309
332
  strokeWidth: "1"
310
333
  }),
311
- /* @__PURE__ */ h("line", {
334
+ /* @__PURE__ */ p("line", {
312
335
  x1: "2",
313
336
  y1: "3",
314
337
  x2: "8",
@@ -317,7 +340,7 @@ var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, theme
317
340
  strokeWidth: "1",
318
341
  strokeLinecap: "round"
319
342
  }),
320
- /* @__PURE__ */ h("line", {
343
+ /* @__PURE__ */ p("line", {
321
344
  x1: "2",
322
345
  y1: "5.5",
323
346
  x2: "7",
@@ -328,20 +351,20 @@ var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, theme
328
351
  })
329
352
  ]
330
353
  })
331
- }, t) : /* @__PURE__ */ h("div", {
332
- className: l.noteOverlay,
354
+ }, t) : /* @__PURE__ */ p("div", {
355
+ className: s.noteOverlay,
333
356
  style: {
334
357
  left: e.x,
335
358
  top: e.y,
336
359
  width: e.width,
337
360
  height: e.height
338
361
  },
339
- onMouseEnter: (t) => Ee(e, t),
340
- onMouseLeave: $,
341
- onClick: () => De(e)
362
+ onMouseEnter: (t) => Me(e, t),
363
+ onMouseLeave: Q,
364
+ onClick: () => $(e)
342
365
  }, t)),
343
- we.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ h("div", {
344
- className: l.searchMatchOverlay,
366
+ Ae.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ p("div", {
367
+ className: s.searchMatchOverlay,
345
368
  style: {
346
369
  left: e.x,
347
370
  top: e.y,
@@ -349,42 +372,42 @@ var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, theme
349
372
  height: e.height
350
373
  }
351
374
  }, t)),
352
- O && Z?.page === t + 1 && /* @__PURE__ */ h("div", {
353
- className: l.highlightOverlay,
375
+ T && X?.page === t + 1 && /* @__PURE__ */ p("div", {
376
+ className: s.highlightOverlay,
354
377
  style: {
355
- left: Z.x,
356
- top: Z.y,
357
- width: Z.width,
358
- height: Z.height
378
+ left: X.x,
379
+ top: X.y,
380
+ width: X.width,
381
+ height: X.height
359
382
  }
360
383
  })
361
384
  ]
362
- }, `${t}-${D}`);
385
+ }, `${t}-${w}`);
363
386
  }),
364
- C && /* @__PURE__ */ h(le, { hasRead: I })
387
+ x && /* @__PURE__ */ p(de, { hasRead: P })
365
388
  ]
366
389
  })]
367
390
  })]
368
- }), P && /* @__PURE__ */ g("div", {
369
- className: l.notePopover,
370
- style: P.above ? {
371
- left: P.x,
372
- bottom: P.y
391
+ }), M && /* @__PURE__ */ m("div", {
392
+ className: s.notePopover,
393
+ style: M.above ? {
394
+ left: M.x,
395
+ bottom: M.y
373
396
  } : {
374
- left: P.x,
375
- top: P.y
397
+ left: M.x,
398
+ top: M.y
376
399
  },
377
400
  onMouseEnter: () => {
378
- Q.current && clearTimeout(Q.current);
401
+ Z.current && clearTimeout(Z.current);
379
402
  },
380
- onMouseLeave: $,
403
+ onMouseLeave: Q,
381
404
  onClick: (e) => e.stopPropagation(),
382
- children: [P.title && /* @__PURE__ */ h("div", {
383
- className: l.notePopoverTitle,
384
- children: P.title
385
- }), /* @__PURE__ */ h("p", {
386
- className: l.notePopoverContent,
387
- children: P.contents
405
+ children: [M.title && /* @__PURE__ */ p("div", {
406
+ className: s.notePopoverTitle,
407
+ children: M.title
408
+ }), /* @__PURE__ */ p("p", {
409
+ className: s.notePopoverContent,
410
+ children: M.contents
388
411
  })]
389
412
  })]
390
413
  })
@@ -392,4 +415,4 @@ var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, theme
392
415
  });
393
416
  };
394
417
  //#endregion
395
- export { v as default };
418
+ export { g as default };