@cannyminds/dms-file-viewers 0.14.0 → 0.16.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 (97) hide show
  1. package/dist/chunk-5VXNBCB7.mjs +268 -0
  2. package/dist/chunk-5VXNBCB7.mjs.map +1 -0
  3. package/dist/chunk-7S4B534E.js +742 -0
  4. package/dist/chunk-7S4B534E.js.map +1 -0
  5. package/dist/chunk-AUNFO5WZ.js +268 -0
  6. package/dist/chunk-AUNFO5WZ.js.map +1 -0
  7. package/dist/chunk-BL4HRFCJ.mjs +487 -0
  8. package/dist/chunk-BL4HRFCJ.mjs.map +1 -0
  9. package/dist/chunk-CIAMJ46F.js +309 -0
  10. package/dist/chunk-CIAMJ46F.js.map +1 -0
  11. package/dist/chunk-DLSRPPBM.mjs +1863 -0
  12. package/dist/chunk-DLSRPPBM.mjs.map +1 -0
  13. package/dist/{chunk-J3JKVSAM.js → chunk-EEIQAW55.js} +5 -2
  14. package/dist/chunk-EEIQAW55.js.map +1 -0
  15. package/dist/chunk-FUNU3LUV.js +487 -0
  16. package/dist/chunk-FUNU3LUV.js.map +1 -0
  17. package/dist/chunk-HX5KWJCV.mjs +742 -0
  18. package/dist/chunk-HX5KWJCV.mjs.map +1 -0
  19. package/dist/chunk-LOXGEZRZ.js +329 -0
  20. package/dist/chunk-LOXGEZRZ.js.map +1 -0
  21. package/dist/chunk-NZLZUCP2.mjs +329 -0
  22. package/dist/chunk-NZLZUCP2.mjs.map +1 -0
  23. package/dist/chunk-PFX2NN3C.js +1863 -0
  24. package/dist/chunk-PFX2NN3C.js.map +1 -0
  25. package/dist/{chunk-DFBVN4MO.mjs → chunk-Q4OU6YDO.mjs} +5 -2
  26. package/dist/chunk-Q4OU6YDO.mjs.map +1 -0
  27. package/dist/chunk-VM5I5IEA.mjs +309 -0
  28. package/dist/chunk-VM5I5IEA.mjs.map +1 -0
  29. package/dist/chunk-YGQ6UYNQ.js +299 -0
  30. package/dist/chunk-YGQ6UYNQ.js.map +1 -0
  31. package/dist/chunk-ZRASAXL6.mjs +299 -0
  32. package/dist/chunk-ZRASAXL6.mjs.map +1 -0
  33. package/dist/components/viewers/AudioViewer.d.mts +1 -1
  34. package/dist/components/viewers/AudioViewer.d.ts +1 -1
  35. package/dist/components/viewers/AudioViewer.js +3 -3
  36. package/dist/components/viewers/AudioViewer.mjs +2 -2
  37. package/dist/components/viewers/DefaultViewer.d.mts +1 -1
  38. package/dist/components/viewers/DefaultViewer.d.ts +1 -1
  39. package/dist/components/viewers/DefaultViewer.js +3 -3
  40. package/dist/components/viewers/DefaultViewer.mjs +2 -2
  41. package/dist/components/viewers/ImageViewer.d.mts +1 -1
  42. package/dist/components/viewers/ImageViewer.d.ts +1 -1
  43. package/dist/components/viewers/ImageViewer.js +3 -3
  44. package/dist/components/viewers/ImageViewer.mjs +2 -2
  45. package/dist/components/viewers/PDFViewer.d.mts +1 -1
  46. package/dist/components/viewers/PDFViewer.d.ts +1 -1
  47. package/dist/components/viewers/PDFViewer.js +3 -3
  48. package/dist/components/viewers/PDFViewer.mjs +2 -2
  49. package/dist/components/viewers/TIFFViewer.d.mts +1 -1
  50. package/dist/components/viewers/TIFFViewer.d.ts +1 -1
  51. package/dist/components/viewers/TIFFViewer.js +3 -3
  52. package/dist/components/viewers/TIFFViewer.mjs +2 -2
  53. package/dist/components/viewers/TextViewer.d.mts +1 -1
  54. package/dist/components/viewers/TextViewer.d.ts +1 -1
  55. package/dist/components/viewers/TextViewer.js +3 -3
  56. package/dist/components/viewers/TextViewer.mjs +2 -2
  57. package/dist/components/viewers/VideoViewer.d.mts +1 -1
  58. package/dist/components/viewers/VideoViewer.d.ts +1 -1
  59. package/dist/components/viewers/VideoViewer.js +3 -3
  60. package/dist/components/viewers/VideoViewer.mjs +2 -2
  61. package/dist/index.d.mts +2 -2
  62. package/dist/index.d.ts +2 -2
  63. package/dist/index.js +9 -9
  64. package/dist/index.mjs +8 -8
  65. package/dist/{types-DNrkDJdK.d.mts → types-DM0RG-Yu.d.mts} +6 -2
  66. package/dist/{types-DNrkDJdK.d.ts → types-DM0RG-Yu.d.ts} +6 -2
  67. package/package.json +1 -1
  68. package/dist/chunk-7QRYWFCO.js +0 -639
  69. package/dist/chunk-7QRYWFCO.js.map +0 -1
  70. package/dist/chunk-7R2KG3PE.mjs +0 -210
  71. package/dist/chunk-7R2KG3PE.mjs.map +0 -1
  72. package/dist/chunk-CFYOPDCG.mjs +0 -235
  73. package/dist/chunk-CFYOPDCG.mjs.map +0 -1
  74. package/dist/chunk-D74R4IKW.mjs +0 -341
  75. package/dist/chunk-D74R4IKW.mjs.map +0 -1
  76. package/dist/chunk-DFBVN4MO.mjs.map +0 -1
  77. package/dist/chunk-EXZCEYLI.js +0 -247
  78. package/dist/chunk-EXZCEYLI.js.map +0 -1
  79. package/dist/chunk-J3JKVSAM.js.map +0 -1
  80. package/dist/chunk-NXVIRFGL.mjs +0 -247
  81. package/dist/chunk-NXVIRFGL.mjs.map +0 -1
  82. package/dist/chunk-P2VNW6OE.mjs +0 -180
  83. package/dist/chunk-P2VNW6OE.mjs.map +0 -1
  84. package/dist/chunk-P5FH7LK7.mjs +0 -639
  85. package/dist/chunk-P5FH7LK7.mjs.map +0 -1
  86. package/dist/chunk-PZJSY6OF.mjs +0 -1736
  87. package/dist/chunk-PZJSY6OF.mjs.map +0 -1
  88. package/dist/chunk-RVHIXSUP.js +0 -235
  89. package/dist/chunk-RVHIXSUP.js.map +0 -1
  90. package/dist/chunk-TGVFAAIP.js +0 -341
  91. package/dist/chunk-TGVFAAIP.js.map +0 -1
  92. package/dist/chunk-VOLQW3NF.js +0 -1736
  93. package/dist/chunk-VOLQW3NF.js.map +0 -1
  94. package/dist/chunk-VSGX22FQ.js +0 -180
  95. package/dist/chunk-VSGX22FQ.js.map +0 -1
  96. package/dist/chunk-WCAXWJE7.js +0 -210
  97. package/dist/chunk-WCAXWJE7.js.map +0 -1
@@ -1,1736 +0,0 @@
1
- "use client";
2
- import {
3
- toolbarStyles
4
- } from "./chunk-GMDRDOWP.mjs";
5
- import {
6
- getFileExtension
7
- } from "./chunk-M57PSU4O.mjs";
8
- import {
9
- FileIcon_default,
10
- mergeToolbarConfig
11
- } from "./chunk-DFBVN4MO.mjs";
12
-
13
- // src/components/viewers/PDFViewer.tsx
14
- import { useCallback, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3, forwardRef, useImperativeHandle } from "react";
15
-
16
- // src/components/viewers/pdf/StablePDFViewer.tsx
17
- import React from "react";
18
- import { PDFViewer as HeadlessPDFViewerImport } from "@cannyminds/pdf-viewer";
19
- import { jsx } from "react/jsx-runtime";
20
- var HeadlessPDFViewer = HeadlessPDFViewerImport;
21
- var StablePDFViewer = React.memo(({
22
- pdfBuffer,
23
- onPasswordRequest,
24
- pdfViewerRef
25
- }) => {
26
- return /* @__PURE__ */ jsx(
27
- HeadlessPDFViewer,
28
- {
29
- ref: pdfViewerRef,
30
- pdfBuffer,
31
- onPasswordRequest
32
- }
33
- );
34
- });
35
- StablePDFViewer.displayName = "StablePDFViewer";
36
-
37
- // src/components/viewers/pdf/PDFToolbar.tsx
38
- import React2 from "react";
39
- import FirstPageIcon from "@mui/icons-material/FirstPage";
40
- import LastPageIcon from "@mui/icons-material/LastPage";
41
- import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
42
- import ChevronRightIcon from "@mui/icons-material/ChevronRight";
43
- import ZoomInIcon from "@mui/icons-material/ZoomIn";
44
- import ZoomOutIcon from "@mui/icons-material/ZoomOut";
45
- import FitScreenIcon from "@mui/icons-material/FitScreen";
46
- import AspectRatioIcon from "@mui/icons-material/AspectRatio";
47
- import SearchIcon from "@mui/icons-material/Search";
48
- import FullscreenIcon from "@mui/icons-material/Fullscreen";
49
- import DownloadIcon from "@mui/icons-material/Download";
50
- import PrintIcon from "@mui/icons-material/Print";
51
- import InfoIcon from "@mui/icons-material/Info";
52
- import DescriptionIcon from "@mui/icons-material/Description";
53
- import RotateLeftIcon from "@mui/icons-material/RotateLeft";
54
- import RotateRightIcon from "@mui/icons-material/RotateRight";
55
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
56
- var PDFToolbar = React2.memo(({
57
- currentPage,
58
- totalPages,
59
- zoom,
60
- isSidebarOpen,
61
- showPageNavigation,
62
- showPageCount,
63
- showZoomControls,
64
- showSearch,
65
- showMetadata,
66
- showProperties,
67
- showDownload,
68
- showPrint,
69
- showRotation,
70
- disabledRotateLeft,
71
- disabledRotateRight,
72
- disabledMetadata,
73
- disabledProperties,
74
- disabledDownload,
75
- disabledPrint,
76
- onFirstPage,
77
- onPreviousPage,
78
- onNextPage,
79
- onLastPage,
80
- onPageInput,
81
- onPageInputKeyPress,
82
- onZoomIn,
83
- onZoomOut,
84
- onFitToWidth,
85
- onFitToPage,
86
- onToggleSidebar,
87
- onToggleFullScreen,
88
- onRotateLeft,
89
- onRotateRight,
90
- onDownloadClick,
91
- onPrintClick,
92
- onMetadataClick,
93
- onPropertiesClick
94
- }) => {
95
- return /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar", children: [
96
- showPageNavigation && /* @__PURE__ */ jsxs(Fragment, { children: [
97
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
98
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
99
- /* @__PURE__ */ jsx2(
100
- "button",
101
- {
102
- className: "toolbar-button",
103
- onClick: onFirstPage,
104
- disabled: currentPage <= 1,
105
- title: "First Page",
106
- children: /* @__PURE__ */ jsx2(FirstPageIcon, { fontSize: "small" })
107
- }
108
- ),
109
- /* @__PURE__ */ jsx2(
110
- "button",
111
- {
112
- className: "toolbar-button",
113
- onClick: onPreviousPage,
114
- disabled: currentPage <= 1,
115
- title: "Previous Page",
116
- children: /* @__PURE__ */ jsx2(ChevronLeftIcon, { fontSize: "small" })
117
- }
118
- ),
119
- /* @__PURE__ */ jsx2(
120
- "input",
121
- {
122
- type: "number",
123
- className: "page-input",
124
- value: currentPage,
125
- onChange: onPageInput,
126
- onKeyPress: onPageInputKeyPress,
127
- min: 1,
128
- max: totalPages || void 0
129
- }
130
- ),
131
- showPageCount && /* @__PURE__ */ jsxs("span", { className: "page-info", children: [
132
- "of ",
133
- totalPages || "..."
134
- ] }),
135
- /* @__PURE__ */ jsx2(
136
- "button",
137
- {
138
- className: "toolbar-button",
139
- onClick: onNextPage,
140
- disabled: currentPage >= totalPages,
141
- title: "Next Page",
142
- children: /* @__PURE__ */ jsx2(ChevronRightIcon, { fontSize: "small" })
143
- }
144
- ),
145
- /* @__PURE__ */ jsx2(
146
- "button",
147
- {
148
- className: "toolbar-button",
149
- onClick: onLastPage,
150
- disabled: currentPage >= totalPages,
151
- title: "Last Page",
152
- children: /* @__PURE__ */ jsx2(LastPageIcon, { fontSize: "small" })
153
- }
154
- )
155
- ] })
156
- ] }),
157
- showZoomControls && /* @__PURE__ */ jsxs(Fragment, { children: [
158
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
159
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
160
- /* @__PURE__ */ jsx2(
161
- "button",
162
- {
163
- className: "toolbar-button",
164
- onClick: onZoomOut,
165
- title: "Zoom Out",
166
- children: /* @__PURE__ */ jsx2(ZoomOutIcon, { fontSize: "small" })
167
- }
168
- ),
169
- /* @__PURE__ */ jsxs("span", { className: "zoom-display", children: [
170
- zoom,
171
- "%"
172
- ] }),
173
- /* @__PURE__ */ jsx2(
174
- "button",
175
- {
176
- className: "toolbar-button",
177
- onClick: onZoomIn,
178
- title: "Zoom In",
179
- children: /* @__PURE__ */ jsx2(ZoomInIcon, { fontSize: "small" })
180
- }
181
- ),
182
- /* @__PURE__ */ jsx2(
183
- "button",
184
- {
185
- className: "toolbar-button",
186
- onClick: onFitToWidth,
187
- title: "Fit to Width",
188
- children: /* @__PURE__ */ jsx2(AspectRatioIcon, { fontSize: "small" })
189
- }
190
- ),
191
- /* @__PURE__ */ jsx2(
192
- "button",
193
- {
194
- className: "toolbar-button",
195
- onClick: onFitToPage,
196
- title: "Fit to Page",
197
- children: /* @__PURE__ */ jsx2(FitScreenIcon, { fontSize: "small" })
198
- }
199
- )
200
- ] })
201
- ] }),
202
- showRotation && /* @__PURE__ */ jsxs(Fragment, { children: [
203
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
204
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
205
- /* @__PURE__ */ jsx2(
206
- "button",
207
- {
208
- className: "toolbar-button",
209
- onClick: onRotateLeft,
210
- disabled: disabledRotateLeft,
211
- title: "Rotate Counterclockwise",
212
- children: /* @__PURE__ */ jsx2(RotateLeftIcon, { fontSize: "small" })
213
- }
214
- ),
215
- /* @__PURE__ */ jsx2(
216
- "button",
217
- {
218
- className: "toolbar-button",
219
- onClick: onRotateRight,
220
- disabled: disabledRotateRight,
221
- title: "Rotate Clockwise",
222
- children: /* @__PURE__ */ jsx2(RotateRightIcon, { fontSize: "small" })
223
- }
224
- )
225
- ] })
226
- ] }),
227
- showSearch && /* @__PURE__ */ jsxs(Fragment, { children: [
228
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
229
- /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(
230
- "button",
231
- {
232
- className: "toolbar-button",
233
- onClick: onToggleSidebar,
234
- title: "Search in PDF",
235
- style: {
236
- backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
237
- color: isSidebarOpen ? "#1976d2" : "inherit"
238
- },
239
- children: /* @__PURE__ */ jsx2(SearchIcon, { fontSize: "small" })
240
- }
241
- ) })
242
- ] }),
243
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
244
- /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(
245
- "button",
246
- {
247
- className: "toolbar-button",
248
- onClick: onToggleFullScreen,
249
- title: "Fullscreen",
250
- children: /* @__PURE__ */ jsx2(FullscreenIcon, { fontSize: "small" })
251
- }
252
- ) }),
253
- (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ jsxs(Fragment, { children: [
254
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
255
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
256
- showDownload && /* @__PURE__ */ jsx2(
257
- "button",
258
- {
259
- className: "toolbar-button",
260
- onClick: onDownloadClick,
261
- disabled: disabledDownload,
262
- title: "Download PDF",
263
- children: /* @__PURE__ */ jsx2(DownloadIcon, { fontSize: "small" })
264
- }
265
- ),
266
- showPrint && /* @__PURE__ */ jsx2(
267
- "button",
268
- {
269
- className: "toolbar-button",
270
- onClick: onPrintClick,
271
- disabled: disabledPrint,
272
- title: "Print PDF",
273
- children: /* @__PURE__ */ jsx2(PrintIcon, { fontSize: "small" })
274
- }
275
- ),
276
- showMetadata && /* @__PURE__ */ jsx2(
277
- "button",
278
- {
279
- className: "toolbar-button",
280
- onClick: onMetadataClick,
281
- disabled: disabledMetadata,
282
- title: "Document Metadata",
283
- children: /* @__PURE__ */ jsx2(DescriptionIcon, { fontSize: "small" })
284
- }
285
- ),
286
- showProperties && /* @__PURE__ */ jsx2(
287
- "button",
288
- {
289
- className: "toolbar-button",
290
- onClick: onPropertiesClick,
291
- disabled: disabledProperties,
292
- title: "Document Properties",
293
- children: /* @__PURE__ */ jsx2(InfoIcon, { fontSize: "small" })
294
- }
295
- )
296
- ] })
297
- ] })
298
- ] });
299
- });
300
- PDFToolbar.displayName = "PDFToolbar";
301
-
302
- // src/components/viewers/pdf/PDFHeader.tsx
303
- import React3 from "react";
304
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
305
- var PDFHeader = React3.memo(({ fileName, fileExtension }) => {
306
- return /* @__PURE__ */ jsxs2("div", { className: "pdf-viewer-header", children: [
307
- /* @__PURE__ */ jsx3(FileIcon_default, { ext: fileExtension, size: 26 }),
308
- /* @__PURE__ */ jsx3("div", { className: "header-file-name", title: fileName, children: fileName })
309
- ] });
310
- });
311
- PDFHeader.displayName = "PDFHeader";
312
-
313
- // src/components/viewers/pdf/SearchSidebar.tsx
314
- import { useState, useLayoutEffect, useEffect, useRef } from "react";
315
- import {
316
- Box,
317
- Typography,
318
- TextField,
319
- IconButton,
320
- InputAdornment,
321
- Divider,
322
- CircularProgress
323
- } from "@mui/material";
324
- import SearchIcon2 from "@mui/icons-material/Search";
325
- import CloseIcon from "@mui/icons-material/Close";
326
- import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
327
- import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
328
- import ClearIcon from "@mui/icons-material/Clear";
329
- import FindInPageIcon from "@mui/icons-material/FindInPage";
330
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
331
- var SearchSidebar = ({
332
- isOpen,
333
- onClose,
334
- onSearch,
335
- onSearchResultClick,
336
- onNextResult,
337
- onPreviousResult,
338
- currentResultIndex,
339
- totalResults,
340
- searchKeyword,
341
- searchResults = [],
342
- isSearching = false,
343
- isSyntheticResults = false
344
- }) => {
345
- const [searchTerm, setSearchTerm] = useState(searchKeyword || "");
346
- const [hasSearched, setHasSearched] = useState(false);
347
- const contentRef = useRef(null);
348
- useEffect(() => {
349
- if (searchKeyword && searchKeyword !== searchTerm) {
350
- setSearchTerm(searchKeyword);
351
- }
352
- }, [searchKeyword]);
353
- useLayoutEffect(() => {
354
- const element = contentRef.current;
355
- if (!element) return;
356
- const handleMouseMove = (e) => {
357
- const rect = element.getBoundingClientRect();
358
- const distanceFromRight = rect.right - e.clientX;
359
- const distanceFromBottom = rect.bottom - e.clientY;
360
- if (distanceFromRight <= 15 || distanceFromBottom <= 15) {
361
- element.classList.add("scrollbar-hover");
362
- } else {
363
- element.classList.remove("scrollbar-hover");
364
- }
365
- };
366
- const handleMouseLeave = () => element.classList.remove("scrollbar-hover");
367
- element.addEventListener("mousemove", handleMouseMove);
368
- element.addEventListener("mouseleave", handleMouseLeave);
369
- return () => {
370
- element.removeEventListener("mousemove", handleMouseMove);
371
- element.removeEventListener("mouseleave", handleMouseLeave);
372
- };
373
- }, []);
374
- useLayoutEffect(() => {
375
- const style = document.createElement("style");
376
- style.id = "search-sidebar-scrollbar";
377
- style.textContent = `
378
- @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;600&family=Noto+Sans+Devanagari:wght@400;600&display=swap');
379
-
380
- .search-sidebar-content::-webkit-scrollbar {
381
- width: 12px;
382
- height: 12px;
383
- }
384
- .search-sidebar-content::-webkit-scrollbar-track {
385
- background-color: transparent;
386
- }
387
- .search-sidebar-content::-webkit-scrollbar-thumb {
388
- background-color: rgba(128, 128, 128, 0.3);
389
- border-radius: 8px;
390
- border: 4px solid transparent;
391
- background-clip: padding-box;
392
- transition: all 0.15s ease;
393
- }
394
- .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
395
- background-color: rgba(128, 128, 128, 0.5);
396
- border: 2px solid transparent;
397
- }
398
- .search-sidebar-content::-webkit-scrollbar-thumb:active {
399
- background-color: rgba(25, 118, 210, 0.8);
400
- border: 1px solid transparent;
401
- }
402
-
403
- @media (prefers-color-scheme: dark) {
404
- .search-sidebar-content::-webkit-scrollbar-thumb {
405
- background-color: rgba(255, 255, 255, 0.2);
406
- }
407
- .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
408
- background-color: rgba(255, 255, 255, 0.35);
409
- }
410
- }
411
-
412
- /* Tamil font support for search results */
413
- .search-result-text {
414
- font-family: 'Noto Sans Tamil', 'Noto Sans Devanagari', Arial, sans-serif !important;
415
- }
416
- `;
417
- document.head.appendChild(style);
418
- return () => {
419
- const el = document.getElementById("search-sidebar-scrollbar");
420
- if (el) el.remove();
421
- };
422
- }, []);
423
- useLayoutEffect(() => {
424
- setSearchTerm(searchKeyword || "");
425
- if (searchKeyword || searchResults.length > 0) {
426
- setHasSearched(true);
427
- }
428
- }, [searchKeyword, searchResults]);
429
- const handleSearchSubmit = (e) => {
430
- if (e) e.preventDefault();
431
- if (searchTerm.trim()) {
432
- setHasSearched(true);
433
- onSearch(searchTerm.trim());
434
- }
435
- };
436
- const handleSearchChange = (e) => {
437
- const value = e.target.value;
438
- setSearchTerm(value);
439
- if (!value.trim()) {
440
- setHasSearched(false);
441
- onSearch("");
442
- }
443
- };
444
- const handleClearSearch = () => {
445
- setSearchTerm("");
446
- setHasSearched(false);
447
- onSearch("");
448
- };
449
- const resultsByPage = searchResults.reduce((acc, result) => {
450
- if (!acc[result.pageNumber]) {
451
- acc[result.pageNumber] = [];
452
- }
453
- acc[result.pageNumber].push(result);
454
- return acc;
455
- }, {});
456
- const highlightText = (text, keyword) => {
457
- if (!keyword) return text;
458
- const textString = typeof text === "string" ? text : String(text || "");
459
- if (!textString) return text;
460
- try {
461
- const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
462
- const regex = new RegExp(`(${escapedKeyword})`, "gi");
463
- const parts = textString.split(regex);
464
- return parts.map(
465
- (part, index) => regex.test(part) ? /* @__PURE__ */ jsx4(
466
- Box,
467
- {
468
- component: "span",
469
- sx: {
470
- color: "primary.main",
471
- fontWeight: 600,
472
- fontSize: "inherit"
473
- },
474
- children: part
475
- },
476
- index
477
- ) : part
478
- );
479
- } catch (error) {
480
- return textString;
481
- }
482
- };
483
- if (!isOpen) return null;
484
- return /* @__PURE__ */ jsxs3(
485
- Box,
486
- {
487
- sx: {
488
- display: "flex",
489
- flexDirection: "column",
490
- height: "100%",
491
- width: "320px",
492
- backgroundColor: "background.paper",
493
- borderLeft: "1px solid",
494
- borderColor: "divider",
495
- overflow: "hidden"
496
- },
497
- children: [
498
- /* @__PURE__ */ jsxs3(Box, { sx: { px: 3, py: 2.5, backgroundColor: "background.default" }, children: [
499
- /* @__PURE__ */ jsxs3(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [
500
- /* @__PURE__ */ jsx4(Typography, { variant: "h6", sx: { fontSize: "1.125rem", fontWeight: 600, color: "text.primary" }, children: "Search" }),
501
- /* @__PURE__ */ jsx4(
502
- IconButton,
503
- {
504
- size: "small",
505
- onClick: onClose,
506
- sx: {
507
- color: "text.secondary",
508
- padding: "6px"
509
- },
510
- children: /* @__PURE__ */ jsx4(CloseIcon, { fontSize: "small" })
511
- }
512
- )
513
- ] }),
514
- /* @__PURE__ */ jsx4("form", { onSubmit: handleSearchSubmit, children: /* @__PURE__ */ jsx4(
515
- TextField,
516
- {
517
- fullWidth: true,
518
- size: "medium",
519
- placeholder: "Search in document...",
520
- value: searchTerm,
521
- onChange: handleSearchChange,
522
- autoComplete: "off",
523
- InputProps: {
524
- startAdornment: /* @__PURE__ */ jsx4(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { color: "text.disabled", fontSize: 20 } }) }),
525
- endAdornment: searchTerm && /* @__PURE__ */ jsx4(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx4(
526
- IconButton,
527
- {
528
- size: "small",
529
- onClick: handleClearSearch,
530
- sx: {
531
- color: "text.secondary",
532
- padding: "4px",
533
- "&:hover": {
534
- backgroundColor: "action.hover"
535
- }
536
- },
537
- children: /* @__PURE__ */ jsx4(ClearIcon, { sx: { fontSize: 18 } })
538
- }
539
- ) })
540
- },
541
- sx: {
542
- "& .MuiOutlinedInput-root": {
543
- fontSize: "0.9375rem",
544
- backgroundColor: "background.paper",
545
- borderRadius: "8px",
546
- "& fieldset": {
547
- borderColor: "divider"
548
- },
549
- "&.Mui-focused fieldset": {
550
- borderColor: "primary.main",
551
- borderWidth: "2px"
552
- }
553
- },
554
- "& .MuiInputBase-input": {
555
- padding: "10px 14px"
556
- }
557
- }
558
- }
559
- ) }),
560
- totalResults > 0 && /* @__PURE__ */ jsxs3(
561
- Box,
562
- {
563
- sx: {
564
- display: "flex",
565
- alignItems: "center",
566
- justifyContent: "space-between",
567
- mt: 2,
568
- pt: 2,
569
- borderTop: "1px solid",
570
- borderColor: "divider"
571
- },
572
- children: [
573
- /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", fontSize: "0.875rem", fontWeight: 500 }, children: [
574
- currentResultIndex + 1,
575
- " of ",
576
- totalResults,
577
- " results"
578
- ] }),
579
- /* @__PURE__ */ jsxs3(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
580
- /* @__PURE__ */ jsx4(
581
- IconButton,
582
- {
583
- size: "small",
584
- onClick: onPreviousResult,
585
- disabled: currentResultIndex <= 0,
586
- sx: {
587
- color: currentResultIndex <= 0 ? "text.disabled" : "primary.main",
588
- padding: "6px",
589
- borderRadius: "6px",
590
- border: "1px solid",
591
- borderColor: currentResultIndex <= 0 ? "divider" : "primary.main"
592
- },
593
- children: /* @__PURE__ */ jsx4(KeyboardArrowUpIcon, { sx: { fontSize: 20 } })
594
- }
595
- ),
596
- /* @__PURE__ */ jsx4(
597
- IconButton,
598
- {
599
- size: "small",
600
- onClick: onNextResult,
601
- disabled: currentResultIndex >= totalResults - 1,
602
- sx: {
603
- color: currentResultIndex >= totalResults - 1 ? "text.disabled" : "primary.main",
604
- padding: "6px",
605
- borderRadius: "6px",
606
- border: "1px solid",
607
- borderColor: currentResultIndex >= totalResults - 1 ? "divider" : "primary.main"
608
- },
609
- children: /* @__PURE__ */ jsx4(KeyboardArrowDownIcon, { sx: { fontSize: 20 } })
610
- }
611
- )
612
- ] })
613
- ]
614
- }
615
- )
616
- ] }),
617
- /* @__PURE__ */ jsx4(Divider, {}),
618
- /* @__PURE__ */ jsxs3(Box, { ref: contentRef, className: "search-sidebar-content", sx: {
619
- flex: 1,
620
- overflow: "auto",
621
- backgroundColor: "background.default"
622
- }, children: [
623
- !searchTerm && !hasSearched && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
624
- /* @__PURE__ */ jsx4(
625
- Box,
626
- {
627
- sx: {
628
- width: 80,
629
- height: 80,
630
- borderRadius: "50%",
631
- backgroundColor: "action.hover",
632
- display: "flex",
633
- alignItems: "center",
634
- justifyContent: "center",
635
- margin: "0 auto",
636
- mb: 3
637
- },
638
- children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { fontSize: 40, color: "text.disabled" } })
639
- }
640
- ),
641
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
642
- /* @__PURE__ */ jsx4(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: "Enter keywords to find text within the PDF document" })
643
- ] }),
644
- searchTerm && !hasSearched && !isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
645
- /* @__PURE__ */ jsx4(
646
- Box,
647
- {
648
- sx: {
649
- width: 80,
650
- height: 80,
651
- borderRadius: "50%",
652
- backgroundColor: "primary.light",
653
- display: "flex",
654
- alignItems: "center",
655
- justifyContent: "center",
656
- margin: "0 auto",
657
- mb: 3,
658
- opacity: 0.2
659
- },
660
- children: /* @__PURE__ */ jsx4(FindInPageIcon, { sx: { fontSize: 40, color: "primary.main" } })
661
- }
662
- ),
663
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Ready to Search" }),
664
- /* @__PURE__ */ jsx4(Typography, { variant: "body2", sx: { color: "text.secondary", mb: 2, lineHeight: 1.6 }, children: "Press Enter to find" }),
665
- /* @__PURE__ */ jsxs3(
666
- Typography,
667
- {
668
- variant: "body2",
669
- sx: {
670
- color: "white",
671
- fontWeight: 600,
672
- backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(144, 202, 249, 0.16)" : "primary.light",
673
- padding: "6px 16px",
674
- borderRadius: "16px",
675
- display: "inline-block",
676
- opacity: 0.9
677
- },
678
- children: [
679
- '"',
680
- searchTerm,
681
- '"'
682
- ]
683
- }
684
- )
685
- ] }),
686
- isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
687
- /* @__PURE__ */ jsx4(
688
- Box,
689
- {
690
- sx: {
691
- display: "flex",
692
- alignItems: "center",
693
- justifyContent: "center",
694
- margin: "0 auto",
695
- mb: 3
696
- },
697
- children: /* @__PURE__ */ jsx4(CircularProgress, { size: 60, thickness: 4 })
698
- }
699
- ),
700
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Searching..." }),
701
- /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
702
- 'Finding matches for "',
703
- searchTerm,
704
- '"'
705
- ] })
706
- ] }),
707
- hasSearched && totalResults === 0 && !isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
708
- /* @__PURE__ */ jsx4(
709
- Box,
710
- {
711
- sx: {
712
- width: 80,
713
- height: 80,
714
- borderRadius: "50%",
715
- backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(255, 152, 0, 0.12)" : "warning.light",
716
- display: "flex",
717
- alignItems: "center",
718
- justifyContent: "center",
719
- margin: "0 auto",
720
- mb: 3,
721
- opacity: 0.6
722
- },
723
- children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { fontSize: 40, color: "warning.main" } })
724
- }
725
- ),
726
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
727
- /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
728
- "No matches found for ",
729
- /* @__PURE__ */ jsxs3("strong", { children: [
730
- '"',
731
- searchTerm,
732
- '"'
733
- ] })
734
- ] })
735
- ] }),
736
- totalResults > 0 && /* @__PURE__ */ jsx4(Box, { sx: { p: 2 }, children: Object.keys(resultsByPage).sort((a, b) => parseInt(a) - parseInt(b)).map((pageNum) => {
737
- const pageNumber = parseInt(pageNum);
738
- const pageResults = resultsByPage[pageNumber];
739
- return /* @__PURE__ */ jsxs3(Box, { sx: { mb: 3 }, children: [
740
- /* @__PURE__ */ jsxs3(
741
- Typography,
742
- {
743
- variant: "subtitle2",
744
- sx: {
745
- color: "text.secondary",
746
- mb: 1.5,
747
- px: 1,
748
- fontSize: "0.8125rem",
749
- fontWeight: 600,
750
- textTransform: "uppercase",
751
- letterSpacing: "0.5px"
752
- },
753
- children: [
754
- "Page ",
755
- pageNumber
756
- ]
757
- }
758
- ),
759
- pageResults.map((result, index) => /* @__PURE__ */ jsx4(
760
- Box,
761
- {
762
- onClick: () => onSearchResultClick(result.pageNumber, result.index),
763
- sx: {
764
- p: 2,
765
- mx: 1,
766
- mb: 1.5,
767
- borderRadius: "8px",
768
- border: "2px solid",
769
- borderColor: result.index === currentResultIndex ? "primary.main" : "divider",
770
- backgroundColor: "background.paper",
771
- cursor: "pointer",
772
- transition: "all 0.2s ease",
773
- boxShadow: (theme) => theme.palette.mode === "dark" ? "0 1px 3px rgba(0, 0, 0, 0.3)" : "0 1px 3px rgba(0, 0, 0, 0.05)",
774
- "&:hover": {
775
- borderColor: "primary.main",
776
- boxShadow: (theme) => theme.palette.mode === "dark" ? "0 2px 8px rgba(255, 255, 255, 0.15)" : "0 2px 8px rgba(0, 0, 0, 0.1)",
777
- transform: "translateY(-1px)"
778
- }
779
- },
780
- children: /* @__PURE__ */ jsx4(
781
- Typography,
782
- {
783
- variant: "body2",
784
- className: "search-result-text",
785
- sx: {
786
- fontSize: "0.875rem",
787
- lineHeight: 1.6,
788
- color: result.index === currentResultIndex ? "text.primary" : "text.secondary"
789
- },
790
- children: highlightText(result.context, searchTerm)
791
- }
792
- )
793
- },
794
- index
795
- ))
796
- ] }, pageNumber);
797
- }) })
798
- ] })
799
- ]
800
- }
801
- );
802
- };
803
-
804
- // src/components/viewers/pdf/PasswordDialog.tsx
805
- import { useState as useState2, useEffect as useEffect2 } from "react";
806
- import {
807
- Dialog,
808
- DialogTitle,
809
- DialogContent,
810
- DialogActions,
811
- TextField as TextField2,
812
- Button,
813
- Typography as Typography2,
814
- IconButton as IconButton2,
815
- InputAdornment as InputAdornment2,
816
- Box as Box2,
817
- Alert
818
- } from "@mui/material";
819
- import CloseIcon2 from "@mui/icons-material/Close";
820
- import LockIcon from "@mui/icons-material/Lock";
821
- import VisibilityIcon from "@mui/icons-material/Visibility";
822
- import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
823
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
824
- var PasswordDialog = ({
825
- open,
826
- fileName,
827
- onSubmit,
828
- onCancel,
829
- error
830
- }) => {
831
- const [password, setPassword] = useState2("");
832
- const [showPassword, setShowPassword] = useState2(false);
833
- useEffect2(() => {
834
- if (open) {
835
- setPassword("");
836
- setShowPassword(false);
837
- }
838
- }, [open]);
839
- const handleSubmit = (e) => {
840
- e.preventDefault();
841
- if (password.trim()) {
842
- onSubmit(password);
843
- }
844
- };
845
- const handleTogglePasswordVisibility = () => {
846
- setShowPassword(!showPassword);
847
- };
848
- const handleKeyPress = (e) => {
849
- if (e.key === "Enter" && password.trim()) {
850
- handleSubmit(e);
851
- }
852
- };
853
- return /* @__PURE__ */ jsxs4(
854
- Dialog,
855
- {
856
- open,
857
- onClose: onCancel,
858
- maxWidth: "sm",
859
- fullWidth: true,
860
- PaperProps: {
861
- sx: {
862
- borderRadius: 2
863
- }
864
- },
865
- children: [
866
- /* @__PURE__ */ jsx5(DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
867
- /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
868
- /* @__PURE__ */ jsx5(
869
- Box2,
870
- {
871
- sx: {
872
- width: 40,
873
- height: 40,
874
- borderRadius: "50%",
875
- backgroundColor: "primary.light",
876
- display: "flex",
877
- alignItems: "center",
878
- justifyContent: "center",
879
- opacity: 0.9
880
- },
881
- children: /* @__PURE__ */ jsx5(LockIcon, { sx: { color: "white", fontSize: 20 } })
882
- }
883
- ),
884
- /* @__PURE__ */ jsx5(Typography2, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
885
- ] }),
886
- /* @__PURE__ */ jsx5(
887
- IconButton2,
888
- {
889
- size: "small",
890
- onClick: onCancel,
891
- sx: { color: "text.secondary" },
892
- "aria-label": "Close dialog",
893
- children: /* @__PURE__ */ jsx5(CloseIcon2, { fontSize: "small" })
894
- }
895
- )
896
- ] }) }),
897
- /* @__PURE__ */ jsxs4(DialogContent, { sx: { pt: 2 }, children: [
898
- /* @__PURE__ */ jsxs4(Typography2, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
899
- "This PDF is password protected. Please enter the password to view",
900
- " ",
901
- fileName && /* @__PURE__ */ jsxs4("strong", { children: [
902
- '"',
903
- fileName,
904
- '"'
905
- ] })
906
- ] }),
907
- error && /* @__PURE__ */ jsx5(Alert, { severity: "error", sx: { mb: 2 }, children: error }),
908
- /* @__PURE__ */ jsx5("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsx5(
909
- TextField2,
910
- {
911
- fullWidth: true,
912
- autoFocus: true,
913
- type: showPassword ? "text" : "password",
914
- label: "Password",
915
- placeholder: "Enter password",
916
- value: password,
917
- onChange: (e) => setPassword(e.target.value),
918
- onKeyPress: handleKeyPress,
919
- error: Boolean(error),
920
- InputProps: {
921
- endAdornment: /* @__PURE__ */ jsx5(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx5(
922
- IconButton2,
923
- {
924
- onClick: handleTogglePasswordVisibility,
925
- edge: "end",
926
- size: "small",
927
- "aria-label": showPassword ? "Hide password" : "Show password",
928
- children: showPassword ? /* @__PURE__ */ jsx5(VisibilityOffIcon, {}) : /* @__PURE__ */ jsx5(VisibilityIcon, {})
929
- }
930
- ) })
931
- },
932
- sx: {
933
- "& .MuiOutlinedInput-root": {
934
- borderRadius: 2
935
- }
936
- }
937
- }
938
- ) })
939
- ] }),
940
- /* @__PURE__ */ jsxs4(DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
941
- /* @__PURE__ */ jsx5(
942
- Button,
943
- {
944
- onClick: onCancel,
945
- variant: "outlined",
946
- sx: {
947
- borderRadius: 2,
948
- textTransform: "none",
949
- px: 3
950
- },
951
- children: "Cancel"
952
- }
953
- ),
954
- /* @__PURE__ */ jsx5(
955
- Button,
956
- {
957
- onClick: handleSubmit,
958
- variant: "contained",
959
- disabled: !password.trim(),
960
- sx: {
961
- borderRadius: 2,
962
- textTransform: "none",
963
- px: 3,
964
- boxShadow: 2
965
- },
966
- children: "Unlock PDF"
967
- }
968
- )
969
- ] })
970
- ]
971
- }
972
- );
973
- };
974
-
975
- // src/components/viewers/PDFViewer.tsx
976
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
977
- var PDFViewerContent = forwardRef((props, ref) => {
978
- const {
979
- file,
980
- onLoad,
981
- onError,
982
- fileName,
983
- showPageCount = true,
984
- showPageNavigation = true,
985
- showZoomControls = true,
986
- showRotation = true,
987
- showDownload = true,
988
- showPrint = true,
989
- showSearch = true,
990
- showMetadata = true,
991
- showProperties = true,
992
- onMetadataClick,
993
- onPropertiesClick,
994
- onDownloadClick,
995
- onPrintClick,
996
- initialSearchText,
997
- initialSearchPages
998
- } = props;
999
- const [pdfBuffer, setPdfBuffer] = useState3(null);
1000
- const [state, setState] = useState3("idle");
1001
- const [error, setError] = useState3(null);
1002
- const pdfViewerRef = useRef2(null);
1003
- const resolvedFileName = useMemo(() => {
1004
- if (fileName) return fileName;
1005
- if (file instanceof File) return file.name;
1006
- if (typeof file === "string") {
1007
- const urlParts = file.split("/");
1008
- return urlParts[urlParts.length - 1] || "document.pdf";
1009
- }
1010
- return "document.pdf";
1011
- }, [file, fileName]);
1012
- const fileExtension = useMemo(
1013
- () => getFileExtension(resolvedFileName),
1014
- [resolvedFileName]
1015
- );
1016
- const [currentPage, setCurrentPage] = useState3(1);
1017
- const [totalPages, setTotalPages] = useState3(0);
1018
- const [zoom, setZoom] = useState3(100);
1019
- const [searchQuery, setSearchQuery] = useState3("");
1020
- const [isSearching, setIsSearching] = useState3(false);
1021
- const [pdfContainer, setPdfContainer] = useState3(null);
1022
- const [isSidebarOpen, setIsSidebarOpen] = useState3(false);
1023
- const [searchResults, setSearchResults] = useState3([]);
1024
- const [currentSearchResultIndex, setCurrentSearchResultIndex] = useState3(0);
1025
- const [totalSearchResults, setTotalSearchResults] = useState3(0);
1026
- const [autoExecuteSearch, setAutoExecuteSearch] = useState3(!!initialSearchText);
1027
- const [isFullScreen, setIsFullScreen] = useState3(false);
1028
- const containerRef = useRef2(null);
1029
- const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState3(false);
1030
- const [passwordError, setPasswordError] = useState3("");
1031
- const [passwordResolve, setPasswordResolve] = useState3(null);
1032
- const hasExecutedInitialSearch = useRef2(false);
1033
- const handleToggleFullScreen = useCallback(() => {
1034
- if (!isFullScreen && containerRef.current?.requestFullscreen) {
1035
- containerRef.current.requestFullscreen();
1036
- setIsFullScreen(true);
1037
- } else if (isFullScreen && document.exitFullscreen) {
1038
- document.exitFullscreen();
1039
- setIsFullScreen(false);
1040
- }
1041
- }, [isFullScreen]);
1042
- const handleSidebarClose = useCallback(() => {
1043
- setIsSidebarOpen(false);
1044
- setSearchQuery("");
1045
- setSearchResults([]);
1046
- setTotalSearchResults(0);
1047
- setCurrentSearchResultIndex(0);
1048
- pdfViewerRef.current?.search.stopSearch();
1049
- }, []);
1050
- const toolbar = mergeToolbarConfig({
1051
- showDownload,
1052
- showPrint,
1053
- showMetadata,
1054
- showProperties,
1055
- showRotation,
1056
- onDownloadClick,
1057
- onPrintClick,
1058
- onMetadataClick,
1059
- onPropertiesClick,
1060
- toolbarActions: props.toolbarActions
1061
- });
1062
- const toolbarHandlers = useMemo(() => ({
1063
- handleZoomIn: () => {
1064
- pdfViewerRef.current?.zoom.zoomIn();
1065
- requestAnimationFrame(() => {
1066
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1067
- if (typeof zoomValue === "number") {
1068
- setZoom(Math.round(zoomValue * 100));
1069
- }
1070
- });
1071
- },
1072
- handleZoomOut: () => {
1073
- pdfViewerRef.current?.zoom.zoomOut();
1074
- requestAnimationFrame(() => {
1075
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1076
- if (typeof zoomValue === "number") {
1077
- setZoom(Math.round(zoomValue * 100));
1078
- }
1079
- });
1080
- },
1081
- handleFitToWidth: () => {
1082
- pdfViewerRef.current?.zoom.fitToWidth();
1083
- requestAnimationFrame(() => {
1084
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1085
- if (typeof zoomValue === "number") {
1086
- setZoom(Math.round(zoomValue * 100));
1087
- }
1088
- });
1089
- },
1090
- handleFitToPage: () => {
1091
- pdfViewerRef.current?.zoom.fitToPage();
1092
- requestAnimationFrame(() => {
1093
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1094
- if (typeof zoomValue === "number") {
1095
- setZoom(Math.round(zoomValue * 100));
1096
- }
1097
- });
1098
- },
1099
- handlePreviousPage: () => {
1100
- pdfViewerRef.current?.navigation.previousPage();
1101
- requestAnimationFrame(() => {
1102
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1103
- setCurrentPage(current);
1104
- });
1105
- },
1106
- handleNextPage: () => {
1107
- pdfViewerRef.current?.navigation.nextPage();
1108
- requestAnimationFrame(() => {
1109
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1110
- setCurrentPage(current);
1111
- });
1112
- },
1113
- handleFirstPage: () => {
1114
- pdfViewerRef.current?.navigation.goToFirstPage();
1115
- requestAnimationFrame(() => {
1116
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1117
- setCurrentPage(current);
1118
- });
1119
- },
1120
- handleLastPage: () => {
1121
- pdfViewerRef.current?.navigation.goToLastPage();
1122
- requestAnimationFrame(() => {
1123
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1124
- setCurrentPage(current);
1125
- });
1126
- },
1127
- toggleSidebar: () => {
1128
- if (isSidebarOpen) {
1129
- handleSidebarClose();
1130
- } else {
1131
- setIsSidebarOpen(true);
1132
- }
1133
- },
1134
- handlePageInput: (e) => {
1135
- const value = e.target.value;
1136
- if (/^\d*$/.test(value)) {
1137
- return;
1138
- }
1139
- const page = parseInt(value, 10);
1140
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1141
- pdfViewerRef.current?.navigation.goToPage(page);
1142
- setCurrentPage(page);
1143
- }
1144
- },
1145
- handlePageInputKeyPress: (e) => {
1146
- if (e.key === "Enter") {
1147
- const value = e.target.value;
1148
- const page = parseInt(value, 10);
1149
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1150
- pdfViewerRef.current?.navigation.goToPage(page);
1151
- setCurrentPage(page);
1152
- }
1153
- }
1154
- },
1155
- handleRotateLeft: () => {
1156
- pdfViewerRef.current?.rotate?.rotateBackward();
1157
- },
1158
- handleRotateRight: () => {
1159
- pdfViewerRef.current?.rotate?.rotateForward();
1160
- },
1161
- handleToggleFullScreen
1162
- }), [isSidebarOpen, totalPages, handleToggleFullScreen]);
1163
- useEffect3(() => {
1164
- console.log("came", initialSearchText, pdfViewerRef.current, hasExecutedInitialSearch.current, "state:", state, "totalPages:", totalPages);
1165
- if (!initialSearchText || hasExecutedInitialSearch.current) return;
1166
- const isPDFReady = state === "ready";
1167
- const isPagesInitialized = totalPages > 0;
1168
- const isViewerAvailable = !!pdfViewerRef.current;
1169
- const isSearchAPIReady = !!pdfViewerRef.current?.search?.searchText;
1170
- const canExecuteSearch = isPDFReady && isPagesInitialized && isViewerAvailable && isSearchAPIReady;
1171
- if (!canExecuteSearch) return;
1172
- hasExecutedInitialSearch.current = true;
1173
- const SEARCH_INITIALIZATION_DELAY = 100;
1174
- setTimeout(() => {
1175
- if (!pdfViewerRef.current?.search?.searchText) {
1176
- console.warn("Search API became unavailable, skipping initial search");
1177
- hasExecutedInitialSearch.current = false;
1178
- return;
1179
- }
1180
- requestAnimationFrame(() => {
1181
- requestAnimationFrame(() => {
1182
- setIsSidebarOpen(true);
1183
- handleSidebarSearch(initialSearchText, initialSearchPages);
1184
- setAutoExecuteSearch(false);
1185
- });
1186
- });
1187
- }, SEARCH_INITIALIZATION_DELAY);
1188
- }, [state, totalPages, pdfViewerRef.current, initialSearchText, initialSearchPages]);
1189
- useEffect3(() => {
1190
- setSearchQuery("");
1191
- setSearchResults([]);
1192
- setCurrentSearchResultIndex(0);
1193
- setTotalSearchResults(0);
1194
- setIsSearching(false);
1195
- setIsSidebarOpen(false);
1196
- hasExecutedInitialSearch.current = false;
1197
- setCurrentPage(1);
1198
- setTotalPages(0);
1199
- setZoom(100);
1200
- setState("idle");
1201
- setError(null);
1202
- setPdfBuffer(null);
1203
- }, [file]);
1204
- useEffect3(() => {
1205
- if (state !== "ready") return;
1206
- const container = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
1207
- if (container) {
1208
- setPdfContainer(container);
1209
- return;
1210
- }
1211
- const observer = new MutationObserver(() => {
1212
- const foundContainer = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
1213
- if (foundContainer) {
1214
- setPdfContainer(foundContainer);
1215
- observer.disconnect();
1216
- }
1217
- });
1218
- observer.observe(document.body, { childList: true, subtree: true });
1219
- return () => observer.disconnect();
1220
- }, [state]);
1221
- useEffect3(() => {
1222
- if (state !== "ready" || totalPages > 0) return;
1223
- const initializePageCount = async () => {
1224
- const waitForViewer = async (maxAttempts = 10) => {
1225
- for (let i = 0; i < maxAttempts; i++) {
1226
- if (pdfViewerRef.current) return pdfViewerRef.current;
1227
- await new Promise((resolve) => requestAnimationFrame(
1228
- () => setTimeout(resolve, Math.min(100 * Math.pow(2, i), 1e3))
1229
- ));
1230
- }
1231
- return null;
1232
- };
1233
- const viewer = await waitForViewer();
1234
- if (!viewer) return;
1235
- await new Promise((resolve) => requestAnimationFrame(resolve));
1236
- try {
1237
- const count = viewer.navigation?.getTotalPages?.();
1238
- if (count && count > 1) {
1239
- setTotalPages(count);
1240
- return;
1241
- }
1242
- } catch (e) {
1243
- }
1244
- try {
1245
- const results = await viewer.search?.searchText?.("e");
1246
- if (results?.results && results.results.length > 0) {
1247
- const pageIndices = results.results.map((m) => m.pageIndex).filter((idx) => typeof idx === "number");
1248
- const count = Math.max(...pageIndices) + 1;
1249
- viewer.search?.stopSearch?.();
1250
- setTotalPages(count);
1251
- return;
1252
- }
1253
- } catch (error2) {
1254
- }
1255
- await new Promise((resolve) => setTimeout(resolve, 200));
1256
- try {
1257
- const selectors = [
1258
- "[data-page-index]",
1259
- "[data-page-number]",
1260
- ".embedpdf-page",
1261
- '[role="article"]',
1262
- "canvas[data-page]",
1263
- ".react-pdf__Page"
1264
- ];
1265
- for (const selector of selectors) {
1266
- const pages = document.querySelectorAll(selector);
1267
- if (pages.length > 0) {
1268
- setTotalPages(pages.length);
1269
- return;
1270
- }
1271
- }
1272
- } catch (error2) {
1273
- }
1274
- try {
1275
- const count = viewer.navigation?.getTotalPages?.();
1276
- if (count && count > 0) {
1277
- setTotalPages(count);
1278
- return;
1279
- }
1280
- } catch (e) {
1281
- }
1282
- console.warn("Could not determine total pages, using fallback value of 1");
1283
- setTotalPages(1);
1284
- };
1285
- initializePageCount();
1286
- }, [state, totalPages]);
1287
- useEffect3(() => {
1288
- if (state === "ready" && pdfViewerRef.current) {
1289
- const updateInfo = () => {
1290
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1291
- const total = pdfViewerRef.current?.navigation.getTotalPages() || 0;
1292
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1293
- const currentSearchState = pdfViewerRef.current?.search.getSearchState();
1294
- setCurrentPage(current);
1295
- if (total > 0 && total !== totalPages) {
1296
- setTotalPages(total);
1297
- }
1298
- if (typeof zoomValue === "number") {
1299
- setZoom(Math.round(zoomValue * 100));
1300
- }
1301
- };
1302
- updateInfo();
1303
- const interval = setInterval(updateInfo, 300);
1304
- return () => clearInterval(interval);
1305
- }
1306
- }, [state, totalPages]);
1307
- useImperativeHandle(ref, () => ({
1308
- zoomIn: () => {
1309
- pdfViewerRef.current?.zoom.zoomIn();
1310
- updateZoomDisplay();
1311
- },
1312
- zoomOut: () => {
1313
- pdfViewerRef.current?.zoom.zoomOut();
1314
- updateZoomDisplay();
1315
- },
1316
- setZoom: (level) => {
1317
- pdfViewerRef.current?.zoom.setZoom(level);
1318
- updateZoomDisplay();
1319
- },
1320
- resetZoom: () => {
1321
- pdfViewerRef.current?.zoom.resetZoom();
1322
- updateZoomDisplay();
1323
- },
1324
- getZoom: () => {
1325
- const zoom2 = pdfViewerRef.current?.zoom.getZoom();
1326
- return typeof zoom2 === "number" ? zoom2 : 1;
1327
- },
1328
- goToPage: (page) => {
1329
- pdfViewerRef.current?.navigation.goToPage(page);
1330
- setCurrentPage(page);
1331
- },
1332
- getCurrentPage: () => pdfViewerRef.current?.navigation.getCurrentPage() || 1,
1333
- getTotalPages: () => pdfViewerRef.current?.navigation.getTotalPages() || 0,
1334
- nextPage: () => {
1335
- pdfViewerRef.current?.navigation.nextPage();
1336
- updatePageDisplay();
1337
- },
1338
- previousPage: () => {
1339
- pdfViewerRef.current?.navigation.previousPage();
1340
- updatePageDisplay();
1341
- },
1342
- goToFirstPage: () => {
1343
- pdfViewerRef.current?.navigation.goToFirstPage();
1344
- updatePageDisplay();
1345
- },
1346
- goToLastPage: () => {
1347
- pdfViewerRef.current?.navigation.goToLastPage();
1348
- updatePageDisplay();
1349
- },
1350
- searchText: async (keyword) => {
1351
- setIsSearching(true);
1352
- const results = await pdfViewerRef.current?.search.searchText(keyword);
1353
- setIsSearching(false);
1354
- setSearchQuery(keyword);
1355
- return results;
1356
- },
1357
- nextResult: () => {
1358
- const index = pdfViewerRef.current?.search.nextResult() || -1;
1359
- return index;
1360
- },
1361
- previousResult: () => {
1362
- const index = pdfViewerRef.current?.search.previousResult() || -1;
1363
- return index;
1364
- },
1365
- goToResult: (index) => pdfViewerRef.current?.search.goToResult(index) || -1,
1366
- stopSearch: () => {
1367
- pdfViewerRef.current?.search.stopSearch();
1368
- setSearchQuery("");
1369
- },
1370
- getSearchState: () => pdfViewerRef.current?.search.getSearchState() || null,
1371
- getSelectedText: () => pdfViewerRef.current?.selection.getSelectedText() || "",
1372
- clearSelection: () => pdfViewerRef.current?.selection.clearSelection(),
1373
- rotateForward: () => pdfViewerRef.current?.rotate?.rotateForward(),
1374
- rotateBackward: () => pdfViewerRef.current?.rotate?.rotateBackward(),
1375
- getRotation: () => pdfViewerRef.current?.rotate?.getRotation() || 0
1376
- }), []);
1377
- const updatePageDisplay = () => {
1378
- requestAnimationFrame(() => {
1379
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1380
- setCurrentPage(current);
1381
- });
1382
- };
1383
- const updateZoomDisplay = () => {
1384
- requestAnimationFrame(() => {
1385
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1386
- if (typeof zoomValue === "number") {
1387
- setZoom(Math.round(zoomValue * 100));
1388
- }
1389
- });
1390
- };
1391
- const handleSearch = async () => {
1392
- if (!searchQuery.trim()) return;
1393
- setIsSearching(true);
1394
- const results = await pdfViewerRef.current?.search.searchText(searchQuery);
1395
- setIsSearching(false);
1396
- if (results?.results && Array.isArray(results.results) && results.results.length > 0) {
1397
- const formattedResults = formatSearchResults(results.results);
1398
- updateSearchState(formattedResults);
1399
- } else {
1400
- clearSearchResults();
1401
- }
1402
- };
1403
- const handleSearchKeyPress = (e) => {
1404
- if (e.key === "Enter") {
1405
- handleSearch();
1406
- }
1407
- };
1408
- const handleSidebarSearch = async (keyword, pageNumbers) => {
1409
- setSearchQuery(keyword);
1410
- if (!keyword.trim()) {
1411
- setSearchResults([]);
1412
- setTotalSearchResults(0);
1413
- setCurrentSearchResultIndex(0);
1414
- pdfViewerRef.current?.search.stopSearch();
1415
- return;
1416
- }
1417
- if (!pdfViewerRef.current?.search?.searchText) {
1418
- console.warn("Search functionality not yet available");
1419
- return;
1420
- }
1421
- setIsSearching(true);
1422
- try {
1423
- const results = await pdfViewerRef.current.search.searchText(keyword);
1424
- console.log("Search completed:", results);
1425
- setIsSearching(false);
1426
- const hasValidResults = results?.results && Array.isArray(results.results) && results.results.length > 0;
1427
- if (hasValidResults) {
1428
- const formattedResults = formatSearchResults(results.results);
1429
- updateSearchState(formattedResults);
1430
- navigateToFirstResult(formattedResults);
1431
- } else if (pageNumbers && pageNumbers.length > 0) {
1432
- const fallbackResults = createFallbackResults(pageNumbers, keyword);
1433
- updateSearchState(fallbackResults);
1434
- navigateToPage(pageNumbers[0]);
1435
- } else {
1436
- clearSearchResults();
1437
- }
1438
- } catch (error2) {
1439
- console.error("Search failed:", error2);
1440
- setIsSearching(false);
1441
- clearSearchResults();
1442
- }
1443
- };
1444
- const formatSearchResults = (results) => {
1445
- return results.map((result, index) => {
1446
- let textContent = "";
1447
- let contextContent = "";
1448
- if (result.context && typeof result.context === "object") {
1449
- const { before = "", match = "", after = "" } = result.context;
1450
- textContent = match;
1451
- contextContent = `${before}${match}${after}`;
1452
- } else if (typeof result === "string") {
1453
- textContent = result;
1454
- contextContent = result;
1455
- } else {
1456
- textContent = String(result.match || result.text || "");
1457
- contextContent = textContent;
1458
- }
1459
- return {
1460
- pageNumber: (result.pageIndex ?? result.pageNumber ?? 0) + 1,
1461
- text: textContent,
1462
- context: contextContent,
1463
- index
1464
- };
1465
- });
1466
- };
1467
- const createFallbackResults = (pageNumbers, keyword) => {
1468
- return pageNumbers.map((pageNum, index) => ({
1469
- pageNumber: pageNum,
1470
- text: keyword,
1471
- context: `"${keyword}" found on this page ${pageNum}`,
1472
- index
1473
- }));
1474
- };
1475
- const updateSearchState = (results) => {
1476
- setSearchResults(results);
1477
- setTotalSearchResults(results.length);
1478
- setCurrentSearchResultIndex(0);
1479
- };
1480
- const clearSearchResults = () => {
1481
- setSearchResults([]);
1482
- setTotalSearchResults(0);
1483
- setCurrentSearchResultIndex(0);
1484
- };
1485
- const navigateToFirstResult = (results) => {
1486
- if (results.length > 0) {
1487
- navigateToPage(results[0].pageNumber);
1488
- }
1489
- };
1490
- const navigateToPage = (pageNumber) => {
1491
- requestAnimationFrame(() => {
1492
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
1493
- setCurrentPage(pageNumber);
1494
- });
1495
- };
1496
- const handleSearchResultClick = (pageNumber, resultIndex) => {
1497
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
1498
- setCurrentSearchResultIndex(resultIndex);
1499
- setCurrentPage(pageNumber);
1500
- pdfViewerRef.current?.search.goToResult(resultIndex);
1501
- };
1502
- const handleNextSearchResult = () => {
1503
- if (currentSearchResultIndex < totalSearchResults - 1) {
1504
- const nextIndex = currentSearchResultIndex + 1;
1505
- setCurrentSearchResultIndex(nextIndex);
1506
- pdfViewerRef.current?.search.nextResult();
1507
- if (searchResults[nextIndex]) {
1508
- const pageNumber = searchResults[nextIndex].pageNumber;
1509
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
1510
- setCurrentPage(pageNumber);
1511
- }
1512
- }
1513
- };
1514
- const handlePreviousSearchResult = () => {
1515
- if (currentSearchResultIndex > 0) {
1516
- const prevIndex = currentSearchResultIndex - 1;
1517
- setCurrentSearchResultIndex(prevIndex);
1518
- pdfViewerRef.current?.search.previousResult();
1519
- if (searchResults[prevIndex]) {
1520
- const pageNumber = searchResults[prevIndex].pageNumber;
1521
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
1522
- setCurrentPage(pageNumber);
1523
- }
1524
- }
1525
- };
1526
- useEffect3(() => {
1527
- if (!file) {
1528
- setState("error");
1529
- setError("No file provided");
1530
- return;
1531
- }
1532
- const loadPDF = async () => {
1533
- try {
1534
- setState("loading");
1535
- setError(null);
1536
- let arrayBuffer;
1537
- if (file instanceof File) {
1538
- arrayBuffer = await file.arrayBuffer();
1539
- } else if (typeof file === "string") {
1540
- const response = await fetch(file);
1541
- if (!response.ok) {
1542
- throw new Error(`Failed to load PDF: ${response.statusText}`);
1543
- }
1544
- arrayBuffer = await response.arrayBuffer();
1545
- } else if (file instanceof ArrayBuffer) {
1546
- arrayBuffer = file;
1547
- } else {
1548
- throw new Error("Unsupported file type");
1549
- }
1550
- setPdfBuffer(arrayBuffer);
1551
- setState("ready");
1552
- onLoad?.();
1553
- } catch (err) {
1554
- const errorMessage = err.message || "Failed to load PDF";
1555
- setState("error");
1556
- setError(errorMessage);
1557
- onError?.(err);
1558
- }
1559
- };
1560
- loadPDF();
1561
- }, [file, onLoad, onError]);
1562
- const handlePasswordRequest = useCallback(async (fileName2) => {
1563
- return new Promise((resolve) => {
1564
- setPasswordResolve(() => resolve);
1565
- setPasswordError("");
1566
- setIsPasswordDialogOpen(true);
1567
- });
1568
- }, []);
1569
- const handlePasswordSubmit = useCallback((password) => {
1570
- if (passwordResolve) {
1571
- passwordResolve(password);
1572
- setPasswordResolve(null);
1573
- setIsPasswordDialogOpen(false);
1574
- setPasswordError("");
1575
- }
1576
- }, [passwordResolve]);
1577
- const handlePasswordCancel = useCallback(() => {
1578
- if (passwordResolve) {
1579
- passwordResolve(null);
1580
- setPasswordResolve(null);
1581
- setIsPasswordDialogOpen(false);
1582
- setPasswordError("");
1583
- }
1584
- }, [passwordResolve]);
1585
- if (state === "loading") {
1586
- return /* @__PURE__ */ jsxs5("div", { style: {
1587
- display: "flex",
1588
- flexDirection: "column",
1589
- alignItems: "center",
1590
- justifyContent: "center",
1591
- height: "100%",
1592
- gap: "16px"
1593
- }, children: [
1594
- /* @__PURE__ */ jsx6("div", { className: "spinner", style: {
1595
- width: "48px",
1596
- height: "48px",
1597
- border: "4px solid #f3f3f3",
1598
- borderTop: "4px solid #3498db",
1599
- borderRadius: "50%",
1600
- animation: "spin 1s linear infinite"
1601
- } }),
1602
- /* @__PURE__ */ jsx6("p", { children: "Loading PDF..." }),
1603
- /* @__PURE__ */ jsx6("style", { children: `
1604
- @keyframes spin {
1605
- 0% { transform: rotate(0deg); }
1606
- 100% { transform: rotate(360deg); }
1607
- }
1608
- ` })
1609
- ] });
1610
- }
1611
- if (state === "error" || error) {
1612
- return /* @__PURE__ */ jsx6("div", { style: {
1613
- display: "flex",
1614
- flexDirection: "column",
1615
- alignItems: "center",
1616
- justifyContent: "center",
1617
- height: "100%",
1618
- padding: "24px"
1619
- }, children: /* @__PURE__ */ jsxs5("div", { style: {
1620
- maxWidth: "400px",
1621
- padding: "16px",
1622
- backgroundColor: "#fee",
1623
- border: "1px solid #fcc",
1624
- borderRadius: "4px"
1625
- }, children: [
1626
- /* @__PURE__ */ jsx6("h3", { style: { marginTop: 0 }, children: "Failed to Load PDF" }),
1627
- /* @__PURE__ */ jsx6("p", { children: error || "Unknown error occurred" })
1628
- ] }) });
1629
- }
1630
- if (!pdfBuffer || state !== "ready") {
1631
- return /* @__PURE__ */ jsx6("div", { style: {
1632
- display: "flex",
1633
- alignItems: "center",
1634
- justifyContent: "center",
1635
- height: "100%"
1636
- }, children: /* @__PURE__ */ jsx6("p", { children: "Preparing PDF..." }) });
1637
- }
1638
- return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: "pdf-viewer-container", children: [
1639
- /* @__PURE__ */ jsx6("style", { children: toolbarStyles }),
1640
- /* @__PURE__ */ jsx6(
1641
- PDFHeader,
1642
- {
1643
- fileName: resolvedFileName,
1644
- fileExtension
1645
- }
1646
- ),
1647
- /* @__PURE__ */ jsx6(
1648
- PDFToolbar,
1649
- {
1650
- currentPage,
1651
- totalPages,
1652
- zoom,
1653
- isSidebarOpen,
1654
- showPageNavigation,
1655
- showPageCount,
1656
- showZoomControls,
1657
- showSearch,
1658
- showRotation: !toolbar.isHidden("rotation"),
1659
- showMetadata: !toolbar.isHidden("metadata"),
1660
- showProperties: !toolbar.isHidden("properties"),
1661
- showDownload: !toolbar.isHidden("download"),
1662
- showPrint: !toolbar.isHidden("print"),
1663
- disabledRotateLeft: toolbar.isDisabled("rotateLeft"),
1664
- disabledRotateRight: toolbar.isDisabled("rotateRight"),
1665
- disabledMetadata: toolbar.isDisabled("metadata"),
1666
- disabledProperties: toolbar.isDisabled("properties"),
1667
- disabledDownload: toolbar.isDisabled("download"),
1668
- disabledPrint: toolbar.isDisabled("print"),
1669
- onFirstPage: toolbarHandlers.handleFirstPage,
1670
- onPreviousPage: toolbarHandlers.handlePreviousPage,
1671
- onNextPage: toolbarHandlers.handleNextPage,
1672
- onLastPage: toolbarHandlers.handleLastPage,
1673
- onPageInput: toolbarHandlers.handlePageInput,
1674
- onPageInputKeyPress: toolbarHandlers.handlePageInputKeyPress,
1675
- onZoomIn: toolbarHandlers.handleZoomIn,
1676
- onZoomOut: toolbarHandlers.handleZoomOut,
1677
- onFitToWidth: toolbarHandlers.handleFitToWidth,
1678
- onFitToPage: toolbarHandlers.handleFitToPage,
1679
- onToggleSidebar: toolbarHandlers.toggleSidebar,
1680
- onToggleFullScreen: toolbarHandlers.handleToggleFullScreen,
1681
- onRotateLeft: toolbarHandlers.handleRotateLeft,
1682
- onRotateRight: toolbarHandlers.handleRotateRight,
1683
- onDownloadClick: toolbar.getHandler("download", onDownloadClick),
1684
- onPrintClick: toolbar.getHandler("print", onPrintClick),
1685
- onMetadataClick: toolbar.getHandler("metadata", onMetadataClick),
1686
- onPropertiesClick: toolbar.getHandler("properties", onPropertiesClick)
1687
- }
1688
- ),
1689
- /* @__PURE__ */ jsxs5("div", { className: "pdf-viewer-main", children: [
1690
- /* @__PURE__ */ jsx6("div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ jsx6(
1691
- StablePDFViewer,
1692
- {
1693
- pdfBuffer,
1694
- onPasswordRequest: handlePasswordRequest,
1695
- pdfViewerRef
1696
- }
1697
- ) }),
1698
- /* @__PURE__ */ jsx6(
1699
- SearchSidebar,
1700
- {
1701
- isOpen: isSidebarOpen,
1702
- onClose: handleSidebarClose,
1703
- onSearch: handleSidebarSearch,
1704
- onSearchResultClick: handleSearchResultClick,
1705
- onNextResult: handleNextSearchResult,
1706
- onPreviousResult: handlePreviousSearchResult,
1707
- currentResultIndex: currentSearchResultIndex,
1708
- totalResults: totalSearchResults,
1709
- searchKeyword: searchQuery,
1710
- searchResults,
1711
- isSearching
1712
- }
1713
- )
1714
- ] }),
1715
- /* @__PURE__ */ jsx6(
1716
- PasswordDialog,
1717
- {
1718
- open: isPasswordDialogOpen,
1719
- fileName: resolvedFileName,
1720
- onSubmit: handlePasswordSubmit,
1721
- onCancel: handlePasswordCancel,
1722
- error: passwordError
1723
- }
1724
- )
1725
- ] });
1726
- });
1727
- PDFViewerContent.displayName = "PDFViewerContent";
1728
- var PDFViewer = forwardRef((props, ref) => {
1729
- return /* @__PURE__ */ jsx6(PDFViewerContent, { ...props, sourceDescription: "doc.pdf", ref });
1730
- });
1731
- PDFViewer.displayName = "PDFViewer";
1732
-
1733
- export {
1734
- PDFViewer
1735
- };
1736
- //# sourceMappingURL=chunk-PZJSY6OF.mjs.map