@cannyminds/dms-file-viewers 0.3.0 → 0.5.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 (81) hide show
  1. package/dist/{chunk-FZYMVHF6.mjs → chunk-4DJJINTB.mjs} +54 -55
  2. package/dist/chunk-4DJJINTB.mjs.map +1 -0
  3. package/dist/chunk-677DWENS.mjs +133 -0
  4. package/dist/chunk-677DWENS.mjs.map +1 -0
  5. package/dist/{chunk-GNWU6XHH.js → chunk-6ZBHO5SP.js} +15 -9
  6. package/dist/{chunk-GNWU6XHH.js.map → chunk-6ZBHO5SP.js.map} +1 -1
  7. package/dist/chunk-77UARJVQ.js +133 -0
  8. package/dist/chunk-77UARJVQ.js.map +1 -0
  9. package/dist/{chunk-LKBM4O47.mjs → chunk-7BLEPGZ4.mjs} +67 -61
  10. package/dist/chunk-7BLEPGZ4.mjs.map +1 -0
  11. package/dist/{chunk-QRYIHDRT.mjs → chunk-BHMFZTZ7.mjs} +54 -55
  12. package/dist/chunk-BHMFZTZ7.mjs.map +1 -0
  13. package/dist/{chunk-EMP7RZM2.js → chunk-DOOYIHGW.js} +52 -53
  14. package/dist/chunk-DOOYIHGW.js.map +1 -0
  15. package/dist/{chunk-73ZIFR3P.mjs → chunk-K5SKH4SD.mjs} +798 -466
  16. package/dist/chunk-K5SKH4SD.mjs.map +1 -0
  17. package/dist/{chunk-3STHCDAC.js → chunk-QELOFQEB.js} +757 -425
  18. package/dist/chunk-QELOFQEB.js.map +1 -0
  19. package/dist/{chunk-BNHQYEZ7.js → chunk-SBEFC7HP.js} +203 -158
  20. package/dist/chunk-SBEFC7HP.js.map +1 -0
  21. package/dist/{chunk-4RL77HKO.js → chunk-SNEIVT4R.js} +52 -53
  22. package/dist/chunk-SNEIVT4R.js.map +1 -0
  23. package/dist/{chunk-XQBXRMB7.mjs → chunk-UX6U3H7J.mjs} +14 -8
  24. package/dist/chunk-UX6U3H7J.mjs.map +1 -0
  25. package/dist/{chunk-7JTIG6OU.js → chunk-WP55NYFS.js} +67 -61
  26. package/dist/chunk-WP55NYFS.js.map +1 -0
  27. package/dist/{chunk-NOLXOOIP.mjs → chunk-YHMHDPLQ.mjs} +200 -155
  28. package/dist/chunk-YHMHDPLQ.mjs.map +1 -0
  29. package/dist/components/viewers/AudioViewer.d.mts +1 -1
  30. package/dist/components/viewers/AudioViewer.d.ts +1 -1
  31. package/dist/components/viewers/AudioViewer.js +2 -2
  32. package/dist/components/viewers/AudioViewer.mjs +1 -1
  33. package/dist/components/viewers/DefaultViewer.d.mts +1 -1
  34. package/dist/components/viewers/DefaultViewer.d.ts +1 -1
  35. package/dist/components/viewers/DefaultViewer.js +3 -2
  36. package/dist/components/viewers/DefaultViewer.js.map +1 -1
  37. package/dist/components/viewers/DefaultViewer.mjs +2 -1
  38. package/dist/components/viewers/ImageViewer.d.mts +1 -1
  39. package/dist/components/viewers/ImageViewer.d.ts +1 -1
  40. package/dist/components/viewers/ImageViewer.js +3 -3
  41. package/dist/components/viewers/ImageViewer.mjs +2 -2
  42. package/dist/components/viewers/PDFViewer.d.mts +1 -1
  43. package/dist/components/viewers/PDFViewer.d.ts +1 -1
  44. package/dist/components/viewers/PDFViewer.js +2 -2
  45. package/dist/components/viewers/PDFViewer.mjs +1 -1
  46. package/dist/components/viewers/TIFFViewer.d.mts +1 -1
  47. package/dist/components/viewers/TIFFViewer.d.ts +1 -1
  48. package/dist/components/viewers/TIFFViewer.js +2 -2
  49. package/dist/components/viewers/TIFFViewer.mjs +1 -1
  50. package/dist/components/viewers/TextViewer.d.mts +1 -1
  51. package/dist/components/viewers/TextViewer.d.ts +1 -1
  52. package/dist/components/viewers/TextViewer.js +2 -2
  53. package/dist/components/viewers/TextViewer.mjs +1 -1
  54. package/dist/components/viewers/VideoViewer.d.mts +1 -1
  55. package/dist/components/viewers/VideoViewer.d.ts +1 -1
  56. package/dist/components/viewers/VideoViewer.js +2 -2
  57. package/dist/components/viewers/VideoViewer.mjs +1 -1
  58. package/dist/index.d.mts +2 -2
  59. package/dist/index.d.ts +2 -2
  60. package/dist/index.js +30 -9
  61. package/dist/index.js.map +1 -1
  62. package/dist/index.mjs +29 -8
  63. package/dist/index.mjs.map +1 -1
  64. package/dist/{types-CquKzJLE.d.mts → types-C6IEfcTM.d.mts} +13 -1
  65. package/dist/{types-CquKzJLE.d.ts → types-C6IEfcTM.d.ts} +13 -1
  66. package/package.json +1 -1
  67. package/dist/chunk-3STHCDAC.js.map +0 -1
  68. package/dist/chunk-4RL77HKO.js.map +0 -1
  69. package/dist/chunk-73ZIFR3P.mjs.map +0 -1
  70. package/dist/chunk-7JTIG6OU.js.map +0 -1
  71. package/dist/chunk-BNHQYEZ7.js.map +0 -1
  72. package/dist/chunk-EMP7RZM2.js.map +0 -1
  73. package/dist/chunk-FZYMVHF6.mjs.map +0 -1
  74. package/dist/chunk-LKBM4O47.mjs.map +0 -1
  75. package/dist/chunk-NOLXOOIP.mjs.map +0 -1
  76. package/dist/chunk-QLJKOQTP.mjs +0 -78
  77. package/dist/chunk-QLJKOQTP.mjs.map +0 -1
  78. package/dist/chunk-QRYIHDRT.mjs.map +0 -1
  79. package/dist/chunk-XQBXRMB7.mjs.map +0 -1
  80. package/dist/chunk-Z7FUO5RX.js +0 -78
  81. package/dist/chunk-Z7FUO5RX.js.map +0 -1
@@ -6,7 +6,30 @@ var _chunkRE4XRGSVjs = require('./chunk-RE4XRGSV.js');
6
6
 
7
7
  // src/components/viewers/PDFViewer.tsx
8
8
  var _react = require('react'); var _react2 = _interopRequireDefault(_react);
9
+
10
+ // src/components/viewers/pdf/StablePDFViewer.tsx
11
+
9
12
  var _pdfviewer = require('@cannyminds/pdf-viewer');
13
+ var _jsxruntime = require('react/jsx-runtime');
14
+ var HeadlessPDFViewer = _pdfviewer.PDFViewer;
15
+ var StablePDFViewer = _react2.default.memo(({
16
+ pdfBuffer,
17
+ onPasswordRequest,
18
+ pdfViewerRef
19
+ }) => {
20
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
21
+ HeadlessPDFViewer,
22
+ {
23
+ ref: pdfViewerRef,
24
+ pdfBuffer,
25
+ onPasswordRequest
26
+ }
27
+ );
28
+ });
29
+ StablePDFViewer.displayName = "StablePDFViewer";
30
+
31
+ // src/components/viewers/pdf/PDFToolbar.tsx
32
+
10
33
  var _FirstPage = require('@mui/icons-material/FirstPage'); var _FirstPage2 = _interopRequireDefault(_FirstPage);
11
34
  var _LastPage = require('@mui/icons-material/LastPage'); var _LastPage2 = _interopRequireDefault(_LastPage);
12
35
  var _ChevronLeft = require('@mui/icons-material/ChevronLeft'); var _ChevronLeft2 = _interopRequireDefault(_ChevronLeft);
@@ -21,6 +44,214 @@ var _Print = require('@mui/icons-material/Print'); var _Print2 = _interopRequire
21
44
  var _Info = require('@mui/icons-material/Info'); var _Info2 = _interopRequireDefault(_Info);
22
45
  var _Description = require('@mui/icons-material/Description'); var _Description2 = _interopRequireDefault(_Description);
23
46
 
47
+ var PDFToolbar = _react2.default.memo(({
48
+ currentPage,
49
+ totalPages,
50
+ zoom,
51
+ isSidebarOpen,
52
+ showPageNavigation,
53
+ showPageCount,
54
+ showZoomControls,
55
+ showSearch,
56
+ showMetadata,
57
+ showProperties,
58
+ showDownload,
59
+ showPrint,
60
+ onFirstPage,
61
+ onPreviousPage,
62
+ onNextPage,
63
+ onLastPage,
64
+ onPageInput,
65
+ onPageInputKeyPress,
66
+ onZoomIn,
67
+ onZoomOut,
68
+ onFitToWidth,
69
+ onFitToPage,
70
+ onToggleSidebar,
71
+ onDownloadClick,
72
+ onPrintClick,
73
+ onMetadataClick,
74
+ onPropertiesClick
75
+ }) => {
76
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar", children: [
77
+ showPageNavigation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
78
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
79
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
80
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
81
+ "button",
82
+ {
83
+ className: "toolbar-button",
84
+ onClick: onFirstPage,
85
+ disabled: currentPage <= 1,
86
+ title: "First Page",
87
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
88
+ }
89
+ ),
90
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
91
+ "button",
92
+ {
93
+ className: "toolbar-button",
94
+ onClick: onPreviousPage,
95
+ disabled: currentPage <= 1,
96
+ title: "Previous Page",
97
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
98
+ }
99
+ ),
100
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
101
+ "input",
102
+ {
103
+ type: "number",
104
+ className: "page-input",
105
+ value: currentPage,
106
+ onChange: onPageInput,
107
+ onKeyPress: onPageInputKeyPress,
108
+ min: 1,
109
+ max: totalPages || void 0
110
+ }
111
+ ),
112
+ showPageCount && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "page-info", children: [
113
+ "of ",
114
+ totalPages || "..."
115
+ ] }),
116
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
117
+ "button",
118
+ {
119
+ className: "toolbar-button",
120
+ onClick: onNextPage,
121
+ disabled: currentPage >= totalPages,
122
+ title: "Next Page",
123
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
124
+ }
125
+ ),
126
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
127
+ "button",
128
+ {
129
+ className: "toolbar-button",
130
+ onClick: onLastPage,
131
+ disabled: currentPage >= totalPages,
132
+ title: "Last Page",
133
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
134
+ }
135
+ )
136
+ ] })
137
+ ] }),
138
+ showZoomControls && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
139
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
140
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
141
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
142
+ "button",
143
+ {
144
+ className: "toolbar-button",
145
+ onClick: onZoomOut,
146
+ title: "Zoom Out",
147
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomOut2.default, { fontSize: "small" })
148
+ }
149
+ ),
150
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "zoom-display", children: [
151
+ zoom,
152
+ "%"
153
+ ] }),
154
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
155
+ "button",
156
+ {
157
+ className: "toolbar-button",
158
+ onClick: onZoomIn,
159
+ title: "Zoom In",
160
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomIn2.default, { fontSize: "small" })
161
+ }
162
+ ),
163
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
164
+ "button",
165
+ {
166
+ className: "toolbar-button",
167
+ onClick: onFitToWidth,
168
+ title: "Fit to Width",
169
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" })
170
+ }
171
+ ),
172
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
173
+ "button",
174
+ {
175
+ className: "toolbar-button",
176
+ onClick: onFitToPage,
177
+ title: "Fit to Page",
178
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" })
179
+ }
180
+ )
181
+ ] })
182
+ ] }),
183
+ showSearch && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
184
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
185
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
186
+ "button",
187
+ {
188
+ className: "toolbar-button",
189
+ onClick: onToggleSidebar,
190
+ title: "Search in PDF",
191
+ style: {
192
+ backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
193
+ color: isSidebarOpen ? "#1976d2" : "inherit"
194
+ },
195
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { fontSize: "small" })
196
+ }
197
+ ) })
198
+ ] }),
199
+ (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
200
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
201
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
202
+ showDownload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
203
+ "button",
204
+ {
205
+ className: "toolbar-button",
206
+ onClick: onDownloadClick,
207
+ title: "Download PDF",
208
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
209
+ }
210
+ ),
211
+ showPrint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
212
+ "button",
213
+ {
214
+ className: "toolbar-button",
215
+ onClick: onPrintClick,
216
+ title: "Print PDF",
217
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
218
+ }
219
+ ),
220
+ showMetadata && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
221
+ "button",
222
+ {
223
+ className: "toolbar-button",
224
+ onClick: onMetadataClick,
225
+ title: "Document Metadata",
226
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
227
+ }
228
+ ),
229
+ showProperties && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
230
+ "button",
231
+ {
232
+ className: "toolbar-button",
233
+ onClick: onPropertiesClick,
234
+ title: "Document Properties",
235
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
236
+ }
237
+ )
238
+ ] })
239
+ ] })
240
+ ] });
241
+ });
242
+ PDFToolbar.displayName = "PDFToolbar";
243
+
244
+ // src/components/viewers/pdf/PDFHeader.tsx
245
+
246
+
247
+ var PDFHeader = _react2.default.memo(({ fileName, fileExtension }) => {
248
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-header", children: [
249
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRE4XRGSVjs.FileIcon_default, { ext: fileExtension, size: 26 }),
250
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "header-file-name", title: fileName, children: fileName })
251
+ ] });
252
+ });
253
+ PDFHeader.displayName = "PDFHeader";
254
+
24
255
  // src/components/viewers/pdf/SearchSidebar.tsx
25
256
 
26
257
 
@@ -37,7 +268,7 @@ var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _Keyb
37
268
  var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
38
269
  var _Clear = require('@mui/icons-material/Clear'); var _Clear2 = _interopRequireDefault(_Clear);
39
270
  var _FindInPage = require('@mui/icons-material/FindInPage'); var _FindInPage2 = _interopRequireDefault(_FindInPage);
40
- var _jsxruntime = require('react/jsx-runtime');
271
+
41
272
  var SearchSidebar = ({
42
273
  isOpen,
43
274
  onClose,
@@ -49,11 +280,17 @@ var SearchSidebar = ({
49
280
  totalResults,
50
281
  searchKeyword,
51
282
  searchResults = [],
52
- isSearching = false
283
+ isSearching = false,
284
+ isSyntheticResults = false
53
285
  }) => {
54
286
  const [searchTerm, setSearchTerm] = _react.useState.call(void 0, searchKeyword || "");
55
287
  const [hasSearched, setHasSearched] = _react.useState.call(void 0, false);
56
288
  const contentRef = _react.useRef.call(void 0, null);
289
+ _react.useEffect.call(void 0, () => {
290
+ if (searchKeyword && searchKeyword !== searchTerm) {
291
+ setSearchTerm(searchKeyword);
292
+ }
293
+ }, [searchKeyword]);
57
294
  _react.useLayoutEffect.call(void 0, () => {
58
295
  const element = contentRef.current;
59
296
  if (!element) return;
@@ -89,20 +326,29 @@ var SearchSidebar = ({
89
326
  background-color: transparent;
90
327
  }
91
328
  .search-sidebar-content::-webkit-scrollbar-thumb {
92
- background-color: rgba(0, 0, 0, 0.25);
329
+ background-color: rgba(128, 128, 128, 0.3);
93
330
  border-radius: 8px;
94
331
  border: 4px solid transparent;
95
332
  background-clip: padding-box;
96
333
  transition: all 0.15s ease;
97
334
  }
98
335
  .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
99
- background-color: rgba(0, 0, 0, 0.4);
336
+ background-color: rgba(128, 128, 128, 0.5);
100
337
  border: 2px solid transparent;
101
338
  }
102
339
  .search-sidebar-content::-webkit-scrollbar-thumb:active {
103
- background-color: rgba(25, 118, 210, 0.85);
340
+ background-color: rgba(25, 118, 210, 0.8);
104
341
  border: 1px solid transparent;
105
342
  }
343
+
344
+ @media (prefers-color-scheme: dark) {
345
+ .search-sidebar-content::-webkit-scrollbar-thumb {
346
+ background-color: rgba(255, 255, 255, 0.2);
347
+ }
348
+ .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
349
+ background-color: rgba(255, 255, 255, 0.35);
350
+ }
351
+ }
106
352
 
107
353
  /* Tamil font support for search results */
108
354
  .search-result-text {
@@ -344,12 +590,13 @@ var SearchSidebar = ({
344
590
  width: 80,
345
591
  height: 80,
346
592
  borderRadius: "50%",
347
- backgroundColor: "#e3f2fd",
593
+ backgroundColor: "primary.light",
348
594
  display: "flex",
349
595
  alignItems: "center",
350
596
  justifyContent: "center",
351
597
  margin: "0 auto",
352
- mb: 3
598
+ mb: 3,
599
+ opacity: 0.2
353
600
  },
354
601
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FindInPage2.default, { sx: { fontSize: 40, color: "primary.main" } })
355
602
  }
@@ -361,12 +608,13 @@ var SearchSidebar = ({
361
608
  {
362
609
  variant: "body2",
363
610
  sx: {
364
- color: "primary.main",
611
+ color: "white",
365
612
  fontWeight: 600,
366
- backgroundColor: "#e3f2fd",
613
+ backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(144, 202, 249, 0.16)" : "primary.light",
367
614
  padding: "6px 16px",
368
615
  borderRadius: "16px",
369
- display: "inline-block"
616
+ display: "inline-block",
617
+ opacity: 0.9
370
618
  },
371
619
  children: [
372
620
  '"',
@@ -384,14 +632,15 @@ var SearchSidebar = ({
384
632
  width: 80,
385
633
  height: 80,
386
634
  borderRadius: "50%",
387
- backgroundColor: "#fff3e0",
635
+ backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(255, 152, 0, 0.12)" : "warning.light",
388
636
  display: "flex",
389
637
  alignItems: "center",
390
638
  justifyContent: "center",
391
639
  margin: "0 auto",
392
- mb: 3
640
+ mb: 3,
641
+ opacity: 0.6
393
642
  },
394
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "#ff9800" } })
643
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "warning.main" } })
395
644
  }
396
645
  ),
397
646
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
@@ -404,8 +653,9 @@ var SearchSidebar = ({
404
653
  ] })
405
654
  ] })
406
655
  ] }),
407
- totalResults > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { p: 2 }, children: Object.entries(resultsByPage).sort(([a, _], [b, __]) => parseInt(a) - parseInt(b)).map(([pageNum, pageResults]) => {
656
+ totalResults > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { p: 2 }, children: Object.keys(resultsByPage).sort((a, b) => parseInt(a) - parseInt(b)).map((pageNum) => {
408
657
  const pageNumber = parseInt(pageNum);
658
+ const pageResults = resultsByPage[pageNumber];
409
659
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { mb: 3 }, children: [
410
660
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
411
661
  _material.Typography,
@@ -435,15 +685,15 @@ var SearchSidebar = ({
435
685
  mx: 1,
436
686
  mb: 1.5,
437
687
  borderRadius: "8px",
438
- border: "1px solid",
688
+ border: "2px solid",
439
689
  borderColor: result.index === currentResultIndex ? "primary.main" : "divider",
440
- backgroundColor: result.index === currentResultIndex ? "#e3f2fd" : "background.paper",
690
+ backgroundColor: "background.paper",
441
691
  cursor: "pointer",
442
692
  transition: "all 0.2s ease",
443
- boxShadow: result.index === currentResultIndex ? "0 2px 8px rgba(25, 118, 210, 0.15)" : "0 1px 3px rgba(0, 0, 0, 0.05)",
693
+ boxShadow: (theme) => theme.palette.mode === "dark" ? "0 1px 3px rgba(0, 0, 0, 0.3)" : "0 1px 3px rgba(0, 0, 0, 0.05)",
444
694
  "&:hover": {
445
695
  borderColor: "primary.main",
446
- boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
696
+ boxShadow: (theme) => theme.palette.mode === "dark" ? "0 2px 8px rgba(255, 255, 255, 0.15)" : "0 2px 8px rgba(0, 0, 0, 0.1)",
447
697
  transform: "translateY(-1px)"
448
698
  }
449
699
  },
@@ -471,18 +721,188 @@ var SearchSidebar = ({
471
721
  );
472
722
  };
473
723
 
474
- // src/components/viewers/PDFViewer.tsx
724
+ // src/components/viewers/pdf/PasswordDialog.tsx
725
+
726
+
727
+
728
+
729
+
475
730
 
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+ var _Lock = require('@mui/icons-material/Lock'); var _Lock2 = _interopRequireDefault(_Lock);
741
+ var _Visibility = require('@mui/icons-material/Visibility'); var _Visibility2 = _interopRequireDefault(_Visibility);
742
+ var _VisibilityOff = require('@mui/icons-material/VisibilityOff'); var _VisibilityOff2 = _interopRequireDefault(_VisibilityOff);
743
+
744
+ var PasswordDialog = ({
745
+ open,
746
+ fileName,
747
+ onSubmit,
748
+ onCancel,
749
+ error
750
+ }) => {
751
+ const [password, setPassword] = _react.useState.call(void 0, "");
752
+ const [showPassword, setShowPassword] = _react.useState.call(void 0, false);
753
+ _react.useEffect.call(void 0, () => {
754
+ if (open) {
755
+ setPassword("");
756
+ setShowPassword(false);
757
+ }
758
+ }, [open]);
759
+ const handleSubmit = (e) => {
760
+ e.preventDefault();
761
+ if (password.trim()) {
762
+ onSubmit(password);
763
+ }
764
+ };
765
+ const handleTogglePasswordVisibility = () => {
766
+ setShowPassword(!showPassword);
767
+ };
768
+ const handleKeyPress = (e) => {
769
+ if (e.key === "Enter" && password.trim()) {
770
+ handleSubmit(e);
771
+ }
772
+ };
773
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
774
+ _material.Dialog,
775
+ {
776
+ open,
777
+ onClose: onCancel,
778
+ maxWidth: "sm",
779
+ fullWidth: true,
780
+ PaperProps: {
781
+ sx: {
782
+ borderRadius: 2
783
+ }
784
+ },
785
+ children: [
786
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
787
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
788
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
789
+ _material.Box,
790
+ {
791
+ sx: {
792
+ width: 40,
793
+ height: 40,
794
+ borderRadius: "50%",
795
+ backgroundColor: "primary.light",
796
+ display: "flex",
797
+ alignItems: "center",
798
+ justifyContent: "center",
799
+ opacity: 0.9
800
+ },
801
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Lock2.default, { sx: { color: "white", fontSize: 20 } })
802
+ }
803
+ ),
804
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
805
+ ] }),
806
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
807
+ _material.IconButton,
808
+ {
809
+ size: "small",
810
+ onClick: onCancel,
811
+ sx: { color: "text.secondary" },
812
+ "aria-label": "Close dialog",
813
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Close2.default, { fontSize: "small" })
814
+ }
815
+ )
816
+ ] }) }),
817
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogContent, { sx: { pt: 2 }, children: [
818
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
819
+ "This PDF is password protected. Please enter the password to view",
820
+ " ",
821
+ fileName && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
822
+ '"',
823
+ fileName,
824
+ '"'
825
+ ] })
826
+ ] }),
827
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Alert, { severity: "error", sx: { mb: 2 }, children: error }),
828
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { onSubmit: handleSubmit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
829
+ _material.TextField,
830
+ {
831
+ fullWidth: true,
832
+ autoFocus: true,
833
+ type: showPassword ? "text" : "password",
834
+ label: "Password",
835
+ placeholder: "Enter password",
836
+ value: password,
837
+ onChange: (e) => setPassword(e.target.value),
838
+ onKeyPress: handleKeyPress,
839
+ error: Boolean(error),
840
+ InputProps: {
841
+ endAdornment: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
842
+ _material.IconButton,
843
+ {
844
+ onClick: handleTogglePasswordVisibility,
845
+ edge: "end",
846
+ size: "small",
847
+ "aria-label": showPassword ? "Hide password" : "Show password",
848
+ children: showPassword ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VisibilityOff2.default, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Visibility2.default, {})
849
+ }
850
+ ) })
851
+ },
852
+ sx: {
853
+ "& .MuiOutlinedInput-root": {
854
+ borderRadius: 2
855
+ }
856
+ }
857
+ }
858
+ ) })
859
+ ] }),
860
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
861
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
862
+ _material.Button,
863
+ {
864
+ onClick: onCancel,
865
+ variant: "outlined",
866
+ sx: {
867
+ borderRadius: 2,
868
+ textTransform: "none",
869
+ px: 3
870
+ },
871
+ children: "Cancel"
872
+ }
873
+ ),
874
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
875
+ _material.Button,
876
+ {
877
+ onClick: handleSubmit,
878
+ variant: "contained",
879
+ disabled: !password.trim(),
880
+ sx: {
881
+ borderRadius: 2,
882
+ textTransform: "none",
883
+ px: 3,
884
+ boxShadow: 2
885
+ },
886
+ children: "Unlock PDF"
887
+ }
888
+ )
889
+ ] })
890
+ ]
891
+ }
892
+ );
893
+ };
894
+
895
+ // src/components/viewers/pdf/PDFStyles.tsx
476
896
  var toolbarStyles = `
477
897
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');
478
-
898
+
479
899
  * {
480
900
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
481
901
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
482
- 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
902
+ 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
483
903
  'Arial Unicode MS', sans-serif !important;
484
904
  }
485
-
905
+
486
906
  /* Target PDF.js text layer */
487
907
  .textLayer,
488
908
  .textLayer span,
@@ -495,14 +915,14 @@ var toolbarStyles = `
495
915
  [role="document"] * {
496
916
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
497
917
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
498
- 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
918
+ 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
499
919
  'Arial Unicode MS', sans-serif !important;
500
920
  }
501
-
921
+
502
922
  .pdf-viewer-header {
503
923
  display: flex;
504
924
  align-items: center;
505
- justify-content: center;
925
+ justify-content: flex-start;
506
926
  gap: 8px;
507
927
  padding: 3px 16px 0 16px;
508
928
  background: #fff;
@@ -624,6 +1044,9 @@ var toolbarStyles = `
624
1044
  -ms-user-select: text !important;
625
1045
  }
626
1046
  `;
1047
+
1048
+ // src/components/viewers/PDFViewer.tsx
1049
+
627
1050
  var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
628
1051
  const {
629
1052
  file,
@@ -641,7 +1064,9 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
641
1064
  onMetadataClick,
642
1065
  onPropertiesClick,
643
1066
  onDownloadClick,
644
- onPrintClick
1067
+ onPrintClick,
1068
+ initialSearchText,
1069
+ initialSearchPages
645
1070
  } = props;
646
1071
  const [pdfBuffer, setPdfBuffer] = _react.useState.call(void 0, null);
647
1072
  const [state, setState] = _react.useState.call(void 0, "idle");
@@ -670,6 +1095,115 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
670
1095
  const [searchResults, setSearchResults] = _react.useState.call(void 0, []);
671
1096
  const [currentSearchResultIndex, setCurrentSearchResultIndex] = _react.useState.call(void 0, 0);
672
1097
  const [totalSearchResults, setTotalSearchResults] = _react.useState.call(void 0, 0);
1098
+ const [autoExecuteSearch, setAutoExecuteSearch] = _react.useState.call(void 0, !!initialSearchText);
1099
+ const [isPasswordDialogOpen, setIsPasswordDialogOpen] = _react.useState.call(void 0, false);
1100
+ const [passwordError, setPasswordError] = _react.useState.call(void 0, "");
1101
+ const [passwordResolve, setPasswordResolve] = _react.useState.call(void 0, null);
1102
+ const hasExecutedInitialSearch = _react.useRef.call(void 0, false);
1103
+ const toolbarHandlers = _react.useMemo.call(void 0, () => ({
1104
+ handleZoomIn: () => {
1105
+ _optionalChain([pdfViewerRef, 'access', _ => _.current, 'optionalAccess', _2 => _2.zoom, 'access', _3 => _3.zoomIn, 'call', _4 => _4()]);
1106
+ requestAnimationFrame(() => {
1107
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _5 => _5.current, 'optionalAccess', _6 => _6.zoom, 'access', _7 => _7.getZoom, 'call', _8 => _8()]);
1108
+ if (typeof zoomValue === "number") {
1109
+ setZoom(Math.round(zoomValue * 100));
1110
+ }
1111
+ });
1112
+ },
1113
+ handleZoomOut: () => {
1114
+ _optionalChain([pdfViewerRef, 'access', _9 => _9.current, 'optionalAccess', _10 => _10.zoom, 'access', _11 => _11.zoomOut, 'call', _12 => _12()]);
1115
+ requestAnimationFrame(() => {
1116
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _13 => _13.current, 'optionalAccess', _14 => _14.zoom, 'access', _15 => _15.getZoom, 'call', _16 => _16()]);
1117
+ if (typeof zoomValue === "number") {
1118
+ setZoom(Math.round(zoomValue * 100));
1119
+ }
1120
+ });
1121
+ },
1122
+ handleFitToWidth: () => {
1123
+ _optionalChain([pdfViewerRef, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.zoom, 'access', _19 => _19.fitToWidth, 'call', _20 => _20()]);
1124
+ requestAnimationFrame(() => {
1125
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _21 => _21.current, 'optionalAccess', _22 => _22.zoom, 'access', _23 => _23.getZoom, 'call', _24 => _24()]);
1126
+ if (typeof zoomValue === "number") {
1127
+ setZoom(Math.round(zoomValue * 100));
1128
+ }
1129
+ });
1130
+ },
1131
+ handleFitToPage: () => {
1132
+ _optionalChain([pdfViewerRef, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.zoom, 'access', _27 => _27.fitToPage, 'call', _28 => _28()]);
1133
+ requestAnimationFrame(() => {
1134
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _29 => _29.current, 'optionalAccess', _30 => _30.zoom, 'access', _31 => _31.getZoom, 'call', _32 => _32()]);
1135
+ if (typeof zoomValue === "number") {
1136
+ setZoom(Math.round(zoomValue * 100));
1137
+ }
1138
+ });
1139
+ },
1140
+ handlePreviousPage: () => {
1141
+ _optionalChain([pdfViewerRef, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.navigation, 'access', _35 => _35.previousPage, 'call', _36 => _36()]);
1142
+ requestAnimationFrame(() => {
1143
+ const current = _optionalChain([pdfViewerRef, 'access', _37 => _37.current, 'optionalAccess', _38 => _38.navigation, 'access', _39 => _39.getCurrentPage, 'call', _40 => _40()]) || 1;
1144
+ setCurrentPage(current);
1145
+ });
1146
+ },
1147
+ handleNextPage: () => {
1148
+ _optionalChain([pdfViewerRef, 'access', _41 => _41.current, 'optionalAccess', _42 => _42.navigation, 'access', _43 => _43.nextPage, 'call', _44 => _44()]);
1149
+ requestAnimationFrame(() => {
1150
+ const current = _optionalChain([pdfViewerRef, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.navigation, 'access', _47 => _47.getCurrentPage, 'call', _48 => _48()]) || 1;
1151
+ setCurrentPage(current);
1152
+ });
1153
+ },
1154
+ handleFirstPage: () => {
1155
+ _optionalChain([pdfViewerRef, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.navigation, 'access', _51 => _51.goToFirstPage, 'call', _52 => _52()]);
1156
+ requestAnimationFrame(() => {
1157
+ const current = _optionalChain([pdfViewerRef, 'access', _53 => _53.current, 'optionalAccess', _54 => _54.navigation, 'access', _55 => _55.getCurrentPage, 'call', _56 => _56()]) || 1;
1158
+ setCurrentPage(current);
1159
+ });
1160
+ },
1161
+ handleLastPage: () => {
1162
+ _optionalChain([pdfViewerRef, 'access', _57 => _57.current, 'optionalAccess', _58 => _58.navigation, 'access', _59 => _59.goToLastPage, 'call', _60 => _60()]);
1163
+ requestAnimationFrame(() => {
1164
+ const current = _optionalChain([pdfViewerRef, 'access', _61 => _61.current, 'optionalAccess', _62 => _62.navigation, 'access', _63 => _63.getCurrentPage, 'call', _64 => _64()]) || 1;
1165
+ setCurrentPage(current);
1166
+ });
1167
+ },
1168
+ toggleSidebar: () => setIsSidebarOpen(!isSidebarOpen),
1169
+ handlePageInput: (e) => {
1170
+ const value = e.target.value;
1171
+ if (/^\d*$/.test(value)) {
1172
+ return;
1173
+ }
1174
+ const page = parseInt(value, 10);
1175
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1176
+ _optionalChain([pdfViewerRef, 'access', _65 => _65.current, 'optionalAccess', _66 => _66.navigation, 'access', _67 => _67.goToPage, 'call', _68 => _68(page)]);
1177
+ setCurrentPage(page);
1178
+ }
1179
+ },
1180
+ handlePageInputKeyPress: (e) => {
1181
+ if (e.key === "Enter") {
1182
+ const value = e.target.value;
1183
+ const page = parseInt(value, 10);
1184
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1185
+ _optionalChain([pdfViewerRef, 'access', _69 => _69.current, 'optionalAccess', _70 => _70.navigation, 'access', _71 => _71.goToPage, 'call', _72 => _72(page)]);
1186
+ setCurrentPage(page);
1187
+ }
1188
+ }
1189
+ }
1190
+ }), [isSidebarOpen, totalPages]);
1191
+ _react.useEffect.call(void 0, () => {
1192
+ console.log("came", initialSearchText, pdfViewerRef.current, hasExecutedInitialSearch.current);
1193
+ if (pdfViewerRef.current && !hasExecutedInitialSearch.current && initialSearchText) {
1194
+ hasExecutedInitialSearch.current = true;
1195
+ setIsSidebarOpen(true);
1196
+ setSearchQuery(initialSearchText);
1197
+ handleSidebarSearch(initialSearchText, initialSearchPages);
1198
+ setAutoExecuteSearch(false);
1199
+ pdfViewerRef.current.search.searchText(initialSearchText).then((results) => {
1200
+ console.log("results", results);
1201
+ if (_optionalChain([results, 'optionalAccess', _73 => _73.results, 'optionalAccess', _74 => _74.length]) > 0) {
1202
+ _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.navigation, 'access', _77 => _77.goToPage, 'call', _78 => _78(results.results[0].pageIndex + 1)]);
1203
+ }
1204
+ });
1205
+ }
1206
+ }, [pdfViewerRef.current, initialSearchText]);
673
1207
  _react.useEffect.call(void 0, () => {
674
1208
  setSearchQuery("");
675
1209
  setSearchResults([]);
@@ -685,79 +1219,85 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
685
1219
  setPdfBuffer(null);
686
1220
  }, [file]);
687
1221
  _react.useEffect.call(void 0, () => {
688
- if (state === "ready") {
689
- setTimeout(() => {
690
- const container = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
691
- if (container) {
692
- setPdfContainer(container);
693
- }
694
- }, 500);
1222
+ if (state !== "ready") return;
1223
+ const container = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
1224
+ if (container) {
1225
+ setPdfContainer(container);
1226
+ return;
695
1227
  }
1228
+ const observer = new MutationObserver(() => {
1229
+ const foundContainer = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
1230
+ if (foundContainer) {
1231
+ setPdfContainer(foundContainer);
1232
+ observer.disconnect();
1233
+ }
1234
+ });
1235
+ observer.observe(document.body, { childList: true, subtree: true });
1236
+ return () => observer.disconnect();
696
1237
  }, [state]);
697
1238
  _react.useEffect.call(void 0, () => {
698
- if (state === "ready" && totalPages === 0) {
699
- const initializePageCount = async () => {
700
- let viewer = pdfViewerRef.current;
701
- let retries = 0;
702
- while (!viewer && retries < 10) {
703
- await new Promise((resolve) => setTimeout(resolve, 500));
704
- viewer = pdfViewerRef.current;
705
- retries++;
1239
+ if (state !== "ready" || totalPages > 0) return;
1240
+ const initializePageCount = async () => {
1241
+ const waitForViewer = async (maxAttempts = 10) => {
1242
+ for (let i = 0; i < maxAttempts; i++) {
1243
+ if (pdfViewerRef.current) return pdfViewerRef.current;
1244
+ await new Promise((resolve) => requestAnimationFrame(
1245
+ () => setTimeout(resolve, Math.min(100 * Math.pow(2, i), 1e3))
1246
+ ));
706
1247
  }
707
- if (!viewer) return;
708
- await new Promise((resolve) => setTimeout(resolve, 1500));
709
- try {
710
- let count = _optionalChain([viewer, 'access', _2 => _2.navigation, 'optionalAccess', _3 => _3.getTotalPages, 'optionalCall', _4 => _4()]);
711
- if (count && count > 1) {
712
- setTotalPages(count);
713
- return;
714
- }
715
- } catch (e) {
1248
+ return null;
1249
+ };
1250
+ const viewer = await waitForViewer();
1251
+ if (!viewer) return;
1252
+ await new Promise((resolve) => requestAnimationFrame(resolve));
1253
+ try {
1254
+ const count = _optionalChain([viewer, 'access', _79 => _79.navigation, 'optionalAccess', _80 => _80.getTotalPages, 'optionalCall', _81 => _81()]);
1255
+ if (count && count > 1) {
1256
+ setTotalPages(count);
1257
+ return;
716
1258
  }
717
- try {
718
- const results = await _optionalChain([viewer, 'access', _5 => _5.search, 'optionalAccess', _6 => _6.searchText, 'optionalCall', _7 => _7("e")]);
719
- if (_optionalChain([results, 'optionalAccess', _8 => _8.results]) && results.results.length > 0) {
720
- const pageIndices = results.results.map((m) => m.pageIndex).filter((idx) => typeof idx === "number");
721
- const count = Math.max(...pageIndices) + 1;
722
- _optionalChain([viewer, 'access', _9 => _9.search, 'optionalAccess', _10 => _10.stopSearch, 'optionalCall', _11 => _11()]);
723
- setTotalPages(count);
724
- return;
725
- }
726
- } catch (error2) {
1259
+ } catch (e) {
1260
+ }
1261
+ try {
1262
+ const results = await _optionalChain([viewer, 'access', _82 => _82.search, 'optionalAccess', _83 => _83.searchText, 'optionalCall', _84 => _84("e")]);
1263
+ if (_optionalChain([results, 'optionalAccess', _85 => _85.results]) && results.results.length > 0) {
1264
+ const pageIndices = results.results.map((m) => m.pageIndex).filter((idx) => typeof idx === "number");
1265
+ const count = Math.max(...pageIndices) + 1;
1266
+ _optionalChain([viewer, 'access', _86 => _86.search, 'optionalAccess', _87 => _87.stopSearch, 'optionalCall', _88 => _88()]);
1267
+ setTotalPages(count);
1268
+ return;
727
1269
  }
728
- try {
729
- await new Promise((resolve) => setTimeout(resolve, 1e3));
730
- const selectors = [
731
- "[data-page-index]",
732
- "[data-page-number]",
733
- ".embedpdf-page",
734
- '[role="article"]',
735
- "canvas[data-page]",
736
- ".react-pdf__Page"
737
- ];
738
- let pages = null;
739
- for (const selector of selectors) {
740
- pages = document.querySelectorAll(selector);
741
- if (pages.length > 0) break;
742
- }
743
- if (pages && pages.length > 0) {
1270
+ } catch (error2) {
1271
+ }
1272
+ try {
1273
+ const selectors = [
1274
+ "[data-page-index]",
1275
+ "[data-page-number]",
1276
+ ".embedpdf-page",
1277
+ '[role="article"]',
1278
+ "canvas[data-page]",
1279
+ ".react-pdf__Page"
1280
+ ];
1281
+ for (const selector of selectors) {
1282
+ const pages = document.querySelectorAll(selector);
1283
+ if (pages.length > 0) {
744
1284
  setTotalPages(pages.length);
745
1285
  return;
746
1286
  }
747
- } catch (error2) {
748
1287
  }
749
- setTotalPages(1);
750
- };
751
- initializePageCount();
752
- }
1288
+ } catch (error2) {
1289
+ }
1290
+ setTotalPages(1);
1291
+ };
1292
+ initializePageCount();
753
1293
  }, [state, totalPages]);
754
1294
  _react.useEffect.call(void 0, () => {
755
1295
  if (state === "ready" && pdfViewerRef.current) {
756
1296
  const updateInfo = () => {
757
- const current = _optionalChain([pdfViewerRef, 'access', _12 => _12.current, 'optionalAccess', _13 => _13.navigation, 'access', _14 => _14.getCurrentPage, 'call', _15 => _15()]) || 1;
758
- const total = _optionalChain([pdfViewerRef, 'access', _16 => _16.current, 'optionalAccess', _17 => _17.navigation, 'access', _18 => _18.getTotalPages, 'call', _19 => _19()]) || 0;
759
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _20 => _20.current, 'optionalAccess', _21 => _21.zoom, 'access', _22 => _22.getZoom, 'call', _23 => _23()]);
760
- const currentSearchState = _optionalChain([pdfViewerRef, 'access', _24 => _24.current, 'optionalAccess', _25 => _25.search, 'access', _26 => _26.getSearchState, 'call', _27 => _27()]);
1297
+ const current = _optionalChain([pdfViewerRef, 'access', _89 => _89.current, 'optionalAccess', _90 => _90.navigation, 'access', _91 => _91.getCurrentPage, 'call', _92 => _92()]) || 1;
1298
+ const total = _optionalChain([pdfViewerRef, 'access', _93 => _93.current, 'optionalAccess', _94 => _94.navigation, 'access', _95 => _95.getTotalPages, 'call', _96 => _96()]) || 0;
1299
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _97 => _97.current, 'optionalAccess', _98 => _98.zoom, 'access', _99 => _99.getZoom, 'call', _100 => _100()]);
1300
+ const currentSearchState = _optionalChain([pdfViewerRef, 'access', _101 => _101.current, 'optionalAccess', _102 => _102.search, 'access', _103 => _103.getSearchState, 'call', _104 => _104()]);
761
1301
  setCurrentPage(current);
762
1302
  if (total > 0 && total !== totalPages) {
763
1303
  setTotalPages(total);
@@ -773,142 +1313,89 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
773
1313
  }, [state, totalPages]);
774
1314
  _react.useImperativeHandle.call(void 0, ref, () => ({
775
1315
  zoomIn: () => {
776
- _optionalChain([pdfViewerRef, 'access', _28 => _28.current, 'optionalAccess', _29 => _29.zoom, 'access', _30 => _30.zoomIn, 'call', _31 => _31()]);
1316
+ _optionalChain([pdfViewerRef, 'access', _105 => _105.current, 'optionalAccess', _106 => _106.zoom, 'access', _107 => _107.zoomIn, 'call', _108 => _108()]);
777
1317
  updateZoomDisplay();
778
1318
  },
779
1319
  zoomOut: () => {
780
- _optionalChain([pdfViewerRef, 'access', _32 => _32.current, 'optionalAccess', _33 => _33.zoom, 'access', _34 => _34.zoomOut, 'call', _35 => _35()]);
1320
+ _optionalChain([pdfViewerRef, 'access', _109 => _109.current, 'optionalAccess', _110 => _110.zoom, 'access', _111 => _111.zoomOut, 'call', _112 => _112()]);
781
1321
  updateZoomDisplay();
782
1322
  },
783
1323
  setZoom: (level) => {
784
- _optionalChain([pdfViewerRef, 'access', _36 => _36.current, 'optionalAccess', _37 => _37.zoom, 'access', _38 => _38.setZoom, 'call', _39 => _39(level)]);
1324
+ _optionalChain([pdfViewerRef, 'access', _113 => _113.current, 'optionalAccess', _114 => _114.zoom, 'access', _115 => _115.setZoom, 'call', _116 => _116(level)]);
785
1325
  updateZoomDisplay();
786
1326
  },
787
1327
  resetZoom: () => {
788
- _optionalChain([pdfViewerRef, 'access', _40 => _40.current, 'optionalAccess', _41 => _41.zoom, 'access', _42 => _42.resetZoom, 'call', _43 => _43()]);
1328
+ _optionalChain([pdfViewerRef, 'access', _117 => _117.current, 'optionalAccess', _118 => _118.zoom, 'access', _119 => _119.resetZoom, 'call', _120 => _120()]);
789
1329
  updateZoomDisplay();
790
1330
  },
791
1331
  getZoom: () => {
792
- const zoom2 = _optionalChain([pdfViewerRef, 'access', _44 => _44.current, 'optionalAccess', _45 => _45.zoom, 'access', _46 => _46.getZoom, 'call', _47 => _47()]);
1332
+ const zoom2 = _optionalChain([pdfViewerRef, 'access', _121 => _121.current, 'optionalAccess', _122 => _122.zoom, 'access', _123 => _123.getZoom, 'call', _124 => _124()]);
793
1333
  return typeof zoom2 === "number" ? zoom2 : 1;
794
1334
  },
795
1335
  goToPage: (page) => {
796
- _optionalChain([pdfViewerRef, 'access', _48 => _48.current, 'optionalAccess', _49 => _49.navigation, 'access', _50 => _50.goToPage, 'call', _51 => _51(page)]);
1336
+ _optionalChain([pdfViewerRef, 'access', _125 => _125.current, 'optionalAccess', _126 => _126.navigation, 'access', _127 => _127.goToPage, 'call', _128 => _128(page)]);
797
1337
  setCurrentPage(page);
798
1338
  },
799
- getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _52 => _52.current, 'optionalAccess', _53 => _53.navigation, 'access', _54 => _54.getCurrentPage, 'call', _55 => _55()]) || 1,
800
- getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _56 => _56.current, 'optionalAccess', _57 => _57.navigation, 'access', _58 => _58.getTotalPages, 'call', _59 => _59()]) || 0,
1339
+ getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _129 => _129.current, 'optionalAccess', _130 => _130.navigation, 'access', _131 => _131.getCurrentPage, 'call', _132 => _132()]) || 1,
1340
+ getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.navigation, 'access', _135 => _135.getTotalPages, 'call', _136 => _136()]) || 0,
801
1341
  nextPage: () => {
802
- _optionalChain([pdfViewerRef, 'access', _60 => _60.current, 'optionalAccess', _61 => _61.navigation, 'access', _62 => _62.nextPage, 'call', _63 => _63()]);
1342
+ _optionalChain([pdfViewerRef, 'access', _137 => _137.current, 'optionalAccess', _138 => _138.navigation, 'access', _139 => _139.nextPage, 'call', _140 => _140()]);
803
1343
  updatePageDisplay();
804
1344
  },
805
1345
  previousPage: () => {
806
- _optionalChain([pdfViewerRef, 'access', _64 => _64.current, 'optionalAccess', _65 => _65.navigation, 'access', _66 => _66.previousPage, 'call', _67 => _67()]);
1346
+ _optionalChain([pdfViewerRef, 'access', _141 => _141.current, 'optionalAccess', _142 => _142.navigation, 'access', _143 => _143.previousPage, 'call', _144 => _144()]);
807
1347
  updatePageDisplay();
808
1348
  },
809
1349
  goToFirstPage: () => {
810
- _optionalChain([pdfViewerRef, 'access', _68 => _68.current, 'optionalAccess', _69 => _69.navigation, 'access', _70 => _70.goToFirstPage, 'call', _71 => _71()]);
1350
+ _optionalChain([pdfViewerRef, 'access', _145 => _145.current, 'optionalAccess', _146 => _146.navigation, 'access', _147 => _147.goToFirstPage, 'call', _148 => _148()]);
811
1351
  updatePageDisplay();
812
1352
  },
813
1353
  goToLastPage: () => {
814
- _optionalChain([pdfViewerRef, 'access', _72 => _72.current, 'optionalAccess', _73 => _73.navigation, 'access', _74 => _74.goToLastPage, 'call', _75 => _75()]);
1354
+ _optionalChain([pdfViewerRef, 'access', _149 => _149.current, 'optionalAccess', _150 => _150.navigation, 'access', _151 => _151.goToLastPage, 'call', _152 => _152()]);
815
1355
  updatePageDisplay();
816
1356
  },
817
1357
  searchText: async (keyword) => {
818
1358
  setIsSearching(true);
819
- const results = await _optionalChain([pdfViewerRef, 'access', _76 => _76.current, 'optionalAccess', _77 => _77.search, 'access', _78 => _78.searchText, 'call', _79 => _79(keyword)]);
1359
+ const results = await _optionalChain([pdfViewerRef, 'access', _153 => _153.current, 'optionalAccess', _154 => _154.search, 'access', _155 => _155.searchText, 'call', _156 => _156(keyword)]);
820
1360
  setIsSearching(false);
821
1361
  setSearchQuery(keyword);
822
1362
  return results;
823
1363
  },
824
1364
  nextResult: () => {
825
- const index = _optionalChain([pdfViewerRef, 'access', _80 => _80.current, 'optionalAccess', _81 => _81.search, 'access', _82 => _82.nextResult, 'call', _83 => _83()]) || -1;
1365
+ const index = _optionalChain([pdfViewerRef, 'access', _157 => _157.current, 'optionalAccess', _158 => _158.search, 'access', _159 => _159.nextResult, 'call', _160 => _160()]) || -1;
826
1366
  return index;
827
1367
  },
828
1368
  previousResult: () => {
829
- const index = _optionalChain([pdfViewerRef, 'access', _84 => _84.current, 'optionalAccess', _85 => _85.search, 'access', _86 => _86.previousResult, 'call', _87 => _87()]) || -1;
1369
+ const index = _optionalChain([pdfViewerRef, 'access', _161 => _161.current, 'optionalAccess', _162 => _162.search, 'access', _163 => _163.previousResult, 'call', _164 => _164()]) || -1;
830
1370
  return index;
831
1371
  },
832
- goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _88 => _88.current, 'optionalAccess', _89 => _89.search, 'access', _90 => _90.goToResult, 'call', _91 => _91(index)]) || -1,
1372
+ goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _165 => _165.current, 'optionalAccess', _166 => _166.search, 'access', _167 => _167.goToResult, 'call', _168 => _168(index)]) || -1,
833
1373
  stopSearch: () => {
834
- _optionalChain([pdfViewerRef, 'access', _92 => _92.current, 'optionalAccess', _93 => _93.search, 'access', _94 => _94.stopSearch, 'call', _95 => _95()]);
1374
+ _optionalChain([pdfViewerRef, 'access', _169 => _169.current, 'optionalAccess', _170 => _170.search, 'access', _171 => _171.stopSearch, 'call', _172 => _172()]);
835
1375
  setSearchQuery("");
836
1376
  },
837
- getSearchState: () => _optionalChain([pdfViewerRef, 'access', _96 => _96.current, 'optionalAccess', _97 => _97.search, 'access', _98 => _98.getSearchState, 'call', _99 => _99()]) || null,
838
- getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _100 => _100.current, 'optionalAccess', _101 => _101.selection, 'access', _102 => _102.getSelectedText, 'call', _103 => _103()]) || "",
839
- clearSelection: () => _optionalChain([pdfViewerRef, 'access', _104 => _104.current, 'optionalAccess', _105 => _105.selection, 'access', _106 => _106.clearSelection, 'call', _107 => _107()])
1377
+ getSearchState: () => _optionalChain([pdfViewerRef, 'access', _173 => _173.current, 'optionalAccess', _174 => _174.search, 'access', _175 => _175.getSearchState, 'call', _176 => _176()]) || null,
1378
+ getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _177 => _177.current, 'optionalAccess', _178 => _178.selection, 'access', _179 => _179.getSelectedText, 'call', _180 => _180()]) || "",
1379
+ clearSelection: () => _optionalChain([pdfViewerRef, 'access', _181 => _181.current, 'optionalAccess', _182 => _182.selection, 'access', _183 => _183.clearSelection, 'call', _184 => _184()])
840
1380
  }), []);
841
1381
  const updatePageDisplay = () => {
842
- setTimeout(() => {
843
- const current = _optionalChain([pdfViewerRef, 'access', _108 => _108.current, 'optionalAccess', _109 => _109.navigation, 'access', _110 => _110.getCurrentPage, 'call', _111 => _111()]) || 1;
1382
+ requestAnimationFrame(() => {
1383
+ const current = _optionalChain([pdfViewerRef, 'access', _185 => _185.current, 'optionalAccess', _186 => _186.navigation, 'access', _187 => _187.getCurrentPage, 'call', _188 => _188()]) || 1;
844
1384
  setCurrentPage(current);
845
- }, 100);
1385
+ });
846
1386
  };
847
1387
  const updateZoomDisplay = () => {
848
- setTimeout(() => {
849
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _112 => _112.current, 'optionalAccess', _113 => _113.zoom, 'access', _114 => _114.getZoom, 'call', _115 => _115()]);
1388
+ requestAnimationFrame(() => {
1389
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _189 => _189.current, 'optionalAccess', _190 => _190.zoom, 'access', _191 => _191.getZoom, 'call', _192 => _192()]);
850
1390
  if (typeof zoomValue === "number") {
851
1391
  setZoom(Math.round(zoomValue * 100));
852
1392
  }
853
- }, 100);
854
- };
855
- const handleZoomIn = () => {
856
- _optionalChain([pdfViewerRef, 'access', _116 => _116.current, 'optionalAccess', _117 => _117.zoom, 'access', _118 => _118.zoomIn, 'call', _119 => _119()]);
857
- updateZoomDisplay();
858
- };
859
- const handleZoomOut = () => {
860
- _optionalChain([pdfViewerRef, 'access', _120 => _120.current, 'optionalAccess', _121 => _121.zoom, 'access', _122 => _122.zoomOut, 'call', _123 => _123()]);
861
- updateZoomDisplay();
862
- };
863
- const handleFitToWidth = () => {
864
- _optionalChain([pdfViewerRef, 'access', _124 => _124.current, 'optionalAccess', _125 => _125.zoom, 'access', _126 => _126.fitToWidth, 'call', _127 => _127()]);
865
- updateZoomDisplay();
866
- };
867
- const handleFitToPage = () => {
868
- _optionalChain([pdfViewerRef, 'access', _128 => _128.current, 'optionalAccess', _129 => _129.zoom, 'access', _130 => _130.fitToPage, 'call', _131 => _131()]);
869
- updateZoomDisplay();
870
- };
871
- const handlePreviousPage = () => {
872
- _optionalChain([pdfViewerRef, 'access', _132 => _132.current, 'optionalAccess', _133 => _133.navigation, 'access', _134 => _134.previousPage, 'call', _135 => _135()]);
873
- updatePageDisplay();
874
- };
875
- const handleNextPage = () => {
876
- _optionalChain([pdfViewerRef, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.navigation, 'access', _138 => _138.nextPage, 'call', _139 => _139()]);
877
- updatePageDisplay();
878
- };
879
- const handleFirstPage = () => {
880
- _optionalChain([pdfViewerRef, 'access', _140 => _140.current, 'optionalAccess', _141 => _141.navigation, 'access', _142 => _142.goToFirstPage, 'call', _143 => _143()]);
881
- updatePageDisplay();
882
- };
883
- const handleLastPage = () => {
884
- _optionalChain([pdfViewerRef, 'access', _144 => _144.current, 'optionalAccess', _145 => _145.navigation, 'access', _146 => _146.goToLastPage, 'call', _147 => _147()]);
885
- updatePageDisplay();
886
- };
887
- const handlePageInput = (e) => {
888
- const value = e.target.value;
889
- const page = parseInt(value, 10);
890
- if (/^\d*$/.test(value)) {
891
- return;
892
- }
893
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
894
- _optionalChain([pdfViewerRef, 'access', _148 => _148.current, 'optionalAccess', _149 => _149.navigation, 'access', _150 => _150.goToPage, 'call', _151 => _151(page)]);
895
- setCurrentPage(page);
896
- }
897
- };
898
- const handlePageInputKeyPress = (e) => {
899
- if (e.key === "Enter") {
900
- const value = e.target.value;
901
- const page = parseInt(value, 10);
902
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
903
- _optionalChain([pdfViewerRef, 'access', _152 => _152.current, 'optionalAccess', _153 => _153.navigation, 'access', _154 => _154.goToPage, 'call', _155 => _155(page)]);
904
- setCurrentPage(page);
905
- }
906
- }
1393
+ });
907
1394
  };
908
1395
  const handleSearch = async () => {
909
1396
  if (searchQuery.trim()) {
910
1397
  setIsSearching(true);
911
- const results = await _optionalChain([pdfViewerRef, 'access', _156 => _156.current, 'optionalAccess', _157 => _157.search, 'access', _158 => _158.searchText, 'call', _159 => _159(searchQuery)]);
1398
+ const results = await _optionalChain([pdfViewerRef, 'access', _193 => _193.current, 'optionalAccess', _194 => _194.search, 'access', _195 => _195.searchText, 'call', _196 => _196(searchQuery)]);
912
1399
  setIsSearching(false);
913
1400
  if (results && results.results) {
914
1401
  const formattedResults = results.results.map((result, index) => {
@@ -952,13 +1439,13 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
952
1439
  handleSearch();
953
1440
  }
954
1441
  };
955
- const handleSidebarSearch = async (keyword) => {
1442
+ const handleSidebarSearch = async (keyword, pageNumbers) => {
956
1443
  setSearchQuery(keyword);
957
1444
  if (keyword.trim()) {
958
1445
  setIsSearching(true);
959
- const results = await _optionalChain([pdfViewerRef, 'access', _160 => _160.current, 'optionalAccess', _161 => _161.search, 'access', _162 => _162.searchText, 'call', _163 => _163(keyword)]);
1446
+ const results = await _optionalChain([pdfViewerRef, 'access', _197 => _197.current, 'optionalAccess', _198 => _198.search, 'access', _199 => _199.searchText, 'call', _200 => _200(keyword)]);
960
1447
  setIsSearching(false);
961
- if (results && results.results) {
1448
+ if (results && results.results && results.results.length > 0) {
962
1449
  const formattedResults = results.results.map((result, index) => {
963
1450
  let textContent = "";
964
1451
  let contextContent = "";
@@ -987,9 +1474,21 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
987
1474
  setCurrentSearchResultIndex(0);
988
1475
  if (formattedResults.length > 0) {
989
1476
  const firstPageNumber = formattedResults[0].pageNumber;
990
- _optionalChain([pdfViewerRef, 'access', _164 => _164.current, 'optionalAccess', _165 => _165.navigation, 'access', _166 => _166.goToPage, 'call', _167 => _167(firstPageNumber)]);
1477
+ _optionalChain([pdfViewerRef, 'access', _201 => _201.current, 'optionalAccess', _202 => _202.navigation, 'access', _203 => _203.goToPage, 'call', _204 => _204(firstPageNumber)]);
991
1478
  setCurrentPage(firstPageNumber);
992
1479
  }
1480
+ } else if (pageNumbers && pageNumbers.length > 0) {
1481
+ const fallbackResults = pageNumbers.map((pageNum, index) => ({
1482
+ pageNumber: pageNum,
1483
+ text: keyword,
1484
+ context: `"${keyword}" found on this page ${pageNum}`,
1485
+ index
1486
+ }));
1487
+ setSearchResults(fallbackResults);
1488
+ setTotalSearchResults(fallbackResults.length);
1489
+ setCurrentSearchResultIndex(0);
1490
+ _optionalChain([pdfViewerRef, 'access', _205 => _205.current, 'optionalAccess', _206 => _206.navigation, 'access', _207 => _207.goToPage, 'call', _208 => _208(pageNumbers[0])]);
1491
+ setCurrentPage(pageNumbers[0]);
993
1492
  } else {
994
1493
  setSearchResults([]);
995
1494
  setTotalSearchResults(0);
@@ -997,28 +1496,25 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
997
1496
  }
998
1497
  } else {
999
1498
  setSearchResults([]);
1000
- _optionalChain([pdfViewerRef, 'access', _168 => _168.current, 'optionalAccess', _169 => _169.search, 'access', _170 => _170.stopSearch, 'call', _171 => _171()]);
1499
+ _optionalChain([pdfViewerRef, 'access', _209 => _209.current, 'optionalAccess', _210 => _210.search, 'access', _211 => _211.stopSearch, 'call', _212 => _212()]);
1001
1500
  setTotalSearchResults(0);
1002
1501
  setCurrentSearchResultIndex(0);
1003
1502
  }
1004
1503
  };
1005
1504
  const handleSearchResultClick = (pageNumber, resultIndex) => {
1006
- _optionalChain([pdfViewerRef, 'access', _172 => _172.current, 'optionalAccess', _173 => _173.navigation, 'access', _174 => _174.goToPage, 'call', _175 => _175(pageNumber)]);
1505
+ _optionalChain([pdfViewerRef, 'access', _213 => _213.current, 'optionalAccess', _214 => _214.navigation, 'access', _215 => _215.goToPage, 'call', _216 => _216(pageNumber)]);
1007
1506
  setCurrentSearchResultIndex(resultIndex);
1008
1507
  setCurrentPage(pageNumber);
1009
- _optionalChain([pdfViewerRef, 'access', _176 => _176.current, 'optionalAccess', _177 => _177.search, 'access', _178 => _178.goToResult, 'call', _179 => _179(resultIndex)]);
1010
- };
1011
- const toggleSidebar = () => {
1012
- setIsSidebarOpen(!isSidebarOpen);
1508
+ _optionalChain([pdfViewerRef, 'access', _217 => _217.current, 'optionalAccess', _218 => _218.search, 'access', _219 => _219.goToResult, 'call', _220 => _220(resultIndex)]);
1013
1509
  };
1014
1510
  const handleNextSearchResult = () => {
1015
1511
  if (currentSearchResultIndex < totalSearchResults - 1) {
1016
1512
  const nextIndex = currentSearchResultIndex + 1;
1017
1513
  setCurrentSearchResultIndex(nextIndex);
1018
- _optionalChain([pdfViewerRef, 'access', _180 => _180.current, 'optionalAccess', _181 => _181.search, 'access', _182 => _182.nextResult, 'call', _183 => _183()]);
1514
+ _optionalChain([pdfViewerRef, 'access', _221 => _221.current, 'optionalAccess', _222 => _222.search, 'access', _223 => _223.nextResult, 'call', _224 => _224()]);
1019
1515
  if (searchResults[nextIndex]) {
1020
1516
  const pageNumber = searchResults[nextIndex].pageNumber;
1021
- _optionalChain([pdfViewerRef, 'access', _184 => _184.current, 'optionalAccess', _185 => _185.navigation, 'access', _186 => _186.goToPage, 'call', _187 => _187(pageNumber)]);
1517
+ _optionalChain([pdfViewerRef, 'access', _225 => _225.current, 'optionalAccess', _226 => _226.navigation, 'access', _227 => _227.goToPage, 'call', _228 => _228(pageNumber)]);
1022
1518
  setCurrentPage(pageNumber);
1023
1519
  }
1024
1520
  }
@@ -1027,79 +1523,14 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1027
1523
  if (currentSearchResultIndex > 0) {
1028
1524
  const prevIndex = currentSearchResultIndex - 1;
1029
1525
  setCurrentSearchResultIndex(prevIndex);
1030
- _optionalChain([pdfViewerRef, 'access', _188 => _188.current, 'optionalAccess', _189 => _189.search, 'access', _190 => _190.previousResult, 'call', _191 => _191()]);
1526
+ _optionalChain([pdfViewerRef, 'access', _229 => _229.current, 'optionalAccess', _230 => _230.search, 'access', _231 => _231.previousResult, 'call', _232 => _232()]);
1031
1527
  if (searchResults[prevIndex]) {
1032
1528
  const pageNumber = searchResults[prevIndex].pageNumber;
1033
- _optionalChain([pdfViewerRef, 'access', _192 => _192.current, 'optionalAccess', _193 => _193.navigation, 'access', _194 => _194.goToPage, 'call', _195 => _195(pageNumber)]);
1529
+ _optionalChain([pdfViewerRef, 'access', _233 => _233.current, 'optionalAccess', _234 => _234.navigation, 'access', _235 => _235.goToPage, 'call', _236 => _236(pageNumber)]);
1034
1530
  setCurrentPage(pageNumber);
1035
1531
  }
1036
1532
  }
1037
1533
  };
1038
- const handleDownload = () => {
1039
- if (onDownloadClick) {
1040
- onDownloadClick();
1041
- return;
1042
- }
1043
- if (!pdfBuffer) return;
1044
- const blob = new Blob([pdfBuffer], { type: "application/pdf" });
1045
- const url = URL.createObjectURL(blob);
1046
- const link = document.createElement("a");
1047
- link.href = url;
1048
- link.download = resolvedFileName;
1049
- document.body.appendChild(link);
1050
- link.click();
1051
- document.body.removeChild(link);
1052
- URL.revokeObjectURL(url);
1053
- };
1054
- const handlePrint = () => {
1055
- if (onPrintClick) {
1056
- onPrintClick();
1057
- return;
1058
- }
1059
- if (!pdfBuffer) return;
1060
- const blob = new Blob([pdfBuffer], { type: "application/pdf" });
1061
- const blobUrl = URL.createObjectURL(blob);
1062
- const iframe = document.createElement("iframe");
1063
- iframe.style.position = "fixed";
1064
- iframe.style.right = "0";
1065
- iframe.style.bottom = "0";
1066
- iframe.style.width = "0";
1067
- iframe.style.height = "0";
1068
- iframe.style.border = "0";
1069
- document.body.appendChild(iframe);
1070
- iframe.onload = () => {
1071
- try {
1072
- setTimeout(() => {
1073
- const iframeWindow = iframe.contentWindow;
1074
- if (!iframeWindow) return;
1075
- iframeWindow.focus();
1076
- iframeWindow.print();
1077
- const checkPrintComplete = () => {
1078
- setTimeout(() => {
1079
- try {
1080
- document.body.removeChild(iframe);
1081
- URL.revokeObjectURL(blobUrl);
1082
- } catch (e) {
1083
- }
1084
- }, 500);
1085
- };
1086
- if ("onafterprint" in iframeWindow) {
1087
- iframeWindow.onafterprint = checkPrintComplete;
1088
- } else {
1089
- setTimeout(checkPrintComplete, 3e3);
1090
- }
1091
- }, 500);
1092
- } catch (error2) {
1093
- document.body.removeChild(iframe);
1094
- URL.revokeObjectURL(blobUrl);
1095
- }
1096
- };
1097
- iframe.onerror = () => {
1098
- document.body.removeChild(iframe);
1099
- URL.revokeObjectURL(blobUrl);
1100
- };
1101
- iframe.src = blobUrl;
1102
- };
1103
1534
  _react.useEffect.call(void 0, () => {
1104
1535
  if (!file) {
1105
1536
  setState("error");
@@ -1126,21 +1557,39 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1126
1557
  }
1127
1558
  setPdfBuffer(arrayBuffer);
1128
1559
  setState("ready");
1129
- _optionalChain([onLoad, 'optionalCall', _196 => _196()]);
1560
+ _optionalChain([onLoad, 'optionalCall', _237 => _237()]);
1130
1561
  } catch (err) {
1131
1562
  const errorMessage = err.message || "Failed to load PDF";
1132
1563
  setState("error");
1133
1564
  setError(errorMessage);
1134
- _optionalChain([onError, 'optionalCall', _197 => _197(err)]);
1565
+ _optionalChain([onError, 'optionalCall', _238 => _238(err)]);
1135
1566
  }
1136
1567
  };
1137
1568
  loadPDF();
1138
1569
  }, [file, onLoad, onError]);
1139
1570
  const handlePasswordRequest = _react.useCallback.call(void 0, async (fileName2) => {
1140
- const password = prompt(`This PDF is password protected.
1141
- Enter password for ${fileName2 || "document"}:`);
1142
- return password;
1571
+ return new Promise((resolve) => {
1572
+ setPasswordResolve(() => resolve);
1573
+ setPasswordError("");
1574
+ setIsPasswordDialogOpen(true);
1575
+ });
1143
1576
  }, []);
1577
+ const handlePasswordSubmit = _react.useCallback.call(void 0, (password) => {
1578
+ if (passwordResolve) {
1579
+ passwordResolve(password);
1580
+ setPasswordResolve(null);
1581
+ setIsPasswordDialogOpen(false);
1582
+ setPasswordError("");
1583
+ }
1584
+ }, [passwordResolve]);
1585
+ const handlePasswordCancel = _react.useCallback.call(void 0, () => {
1586
+ if (passwordResolve) {
1587
+ passwordResolve(null);
1588
+ setPasswordResolve(null);
1589
+ setIsPasswordDialogOpen(false);
1590
+ setPasswordError("");
1591
+ }
1592
+ }, [passwordResolve]);
1144
1593
  if (state === "loading") {
1145
1594
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: {
1146
1595
  display: "flex",
@@ -1196,181 +1645,54 @@ Enter password for ${fileName2 || "document"}:`);
1196
1645
  }
1197
1646
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-container", children: [
1198
1647
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: toolbarStyles }),
1199
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-header", children: [
1200
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRE4XRGSVjs.FileIcon_default, { ext: fileExtension, size: 26 }),
1201
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "header-file-name", title: resolvedFileName, children: resolvedFileName })
1202
- ] }),
1203
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar", children: [
1204
- showPageNavigation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1205
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1206
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
1207
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1208
- "button",
1209
- {
1210
- className: "toolbar-button",
1211
- onClick: handleFirstPage,
1212
- disabled: currentPage <= 1,
1213
- title: "First Page",
1214
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
1215
- }
1216
- ),
1217
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1218
- "button",
1219
- {
1220
- className: "toolbar-button",
1221
- onClick: handlePreviousPage,
1222
- disabled: currentPage <= 1,
1223
- title: "Previous Page",
1224
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
1225
- }
1226
- ),
1227
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1228
- "input",
1229
- {
1230
- type: "number",
1231
- className: "page-input",
1232
- value: currentPage,
1233
- onChange: handlePageInput,
1234
- onKeyPress: handlePageInputKeyPress,
1235
- min: 1,
1236
- max: totalPages || void 0
1237
- }
1238
- ),
1239
- showPageCount && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "page-info", children: [
1240
- "of ",
1241
- totalPages || "..."
1242
- ] }),
1243
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1244
- "button",
1245
- {
1246
- className: "toolbar-button",
1247
- onClick: handleNextPage,
1248
- disabled: currentPage >= totalPages,
1249
- title: "Next Page",
1250
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
1251
- }
1252
- ),
1253
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1254
- "button",
1255
- {
1256
- className: "toolbar-button",
1257
- onClick: handleLastPage,
1258
- disabled: currentPage >= totalPages,
1259
- title: "Last Page",
1260
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
1261
- }
1262
- )
1263
- ] })
1264
- ] }),
1265
- showZoomControls && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1266
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1267
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
1268
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1269
- "button",
1270
- {
1271
- className: "toolbar-button",
1272
- onClick: handleZoomOut,
1273
- title: "Zoom Out",
1274
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomOut2.default, { fontSize: "small" })
1275
- }
1276
- ),
1277
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "zoom-display", children: [
1278
- zoom,
1279
- "%"
1280
- ] }),
1281
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1282
- "button",
1283
- {
1284
- className: "toolbar-button",
1285
- onClick: handleZoomIn,
1286
- title: "Zoom In",
1287
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomIn2.default, { fontSize: "small" })
1288
- }
1289
- ),
1290
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1291
- "button",
1292
- {
1293
- className: "toolbar-button",
1294
- onClick: handleFitToWidth,
1295
- title: "Fit to Width",
1296
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" })
1297
- }
1298
- ),
1299
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1300
- "button",
1301
- {
1302
- className: "toolbar-button",
1303
- onClick: handleFitToPage,
1304
- title: "Fit to Page",
1305
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" })
1306
- }
1307
- )
1308
- ] })
1309
- ] }),
1310
- showSearch && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1311
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1312
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1313
- "button",
1314
- {
1315
- className: "toolbar-button",
1316
- onClick: toggleSidebar,
1317
- title: "Search in PDF",
1318
- style: {
1319
- backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
1320
- color: isSidebarOpen ? "#1976d2" : "inherit"
1321
- },
1322
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { fontSize: "small" })
1323
- }
1324
- ) })
1325
- ] }),
1326
- (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1327
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1328
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
1329
- showDownload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1330
- "button",
1331
- {
1332
- className: "toolbar-button",
1333
- onClick: onDownloadClick,
1334
- title: "Download PDF",
1335
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
1336
- }
1337
- ),
1338
- showPrint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1339
- "button",
1340
- {
1341
- className: "toolbar-button",
1342
- onClick: onPrintClick,
1343
- title: "Print PDF",
1344
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
1345
- }
1346
- ),
1347
- showMetadata && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1348
- "button",
1349
- {
1350
- className: "toolbar-button",
1351
- onClick: onMetadataClick,
1352
- title: "Document Metadata",
1353
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
1354
- }
1355
- ),
1356
- showProperties && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1357
- "button",
1358
- {
1359
- className: "toolbar-button",
1360
- onClick: onPropertiesClick,
1361
- title: "Document Properties",
1362
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
1363
- }
1364
- )
1365
- ] })
1366
- ] })
1367
- ] }),
1648
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1649
+ PDFHeader,
1650
+ {
1651
+ fileName: resolvedFileName,
1652
+ fileExtension
1653
+ }
1654
+ ),
1655
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1656
+ PDFToolbar,
1657
+ {
1658
+ currentPage,
1659
+ totalPages,
1660
+ zoom,
1661
+ isSidebarOpen,
1662
+ showPageNavigation,
1663
+ showPageCount,
1664
+ showZoomControls,
1665
+ showSearch,
1666
+ showMetadata,
1667
+ showProperties,
1668
+ showDownload,
1669
+ showPrint,
1670
+ onFirstPage: toolbarHandlers.handleFirstPage,
1671
+ onPreviousPage: toolbarHandlers.handlePreviousPage,
1672
+ onNextPage: toolbarHandlers.handleNextPage,
1673
+ onLastPage: toolbarHandlers.handleLastPage,
1674
+ onPageInput: toolbarHandlers.handlePageInput,
1675
+ onPageInputKeyPress: toolbarHandlers.handlePageInputKeyPress,
1676
+ onZoomIn: toolbarHandlers.handleZoomIn,
1677
+ onZoomOut: toolbarHandlers.handleZoomOut,
1678
+ onFitToWidth: toolbarHandlers.handleFitToWidth,
1679
+ onFitToPage: toolbarHandlers.handleFitToPage,
1680
+ onToggleSidebar: toolbarHandlers.toggleSidebar,
1681
+ onDownloadClick,
1682
+ onPrintClick,
1683
+ onMetadataClick,
1684
+ onPropertiesClick
1685
+ }
1686
+ ),
1368
1687
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-main", children: [
1369
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children: _react2.default.createElement(_pdfviewer.PDFViewer, {
1370
- ref: pdfViewerRef,
1371
- pdfBuffer,
1372
- onPasswordRequest: handlePasswordRequest
1373
- }) }),
1688
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1689
+ StablePDFViewer,
1690
+ {
1691
+ pdfBuffer,
1692
+ onPasswordRequest: handlePasswordRequest,
1693
+ pdfViewerRef
1694
+ }
1695
+ ) }),
1374
1696
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1375
1697
  SearchSidebar,
1376
1698
  {
@@ -1387,7 +1709,17 @@ Enter password for ${fileName2 || "document"}:`);
1387
1709
  isSearching
1388
1710
  }
1389
1711
  )
1390
- ] })
1712
+ ] }),
1713
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1714
+ PasswordDialog,
1715
+ {
1716
+ open: isPasswordDialogOpen,
1717
+ fileName: resolvedFileName,
1718
+ onSubmit: handlePasswordSubmit,
1719
+ onCancel: handlePasswordCancel,
1720
+ error: passwordError
1721
+ }
1722
+ )
1391
1723
  ] });
1392
1724
  });
1393
1725
  PDFViewerContent.displayName = "PDFViewerContent";
@@ -1399,4 +1731,4 @@ PDFViewer.displayName = "PDFViewer";
1399
1731
 
1400
1732
 
1401
1733
  exports.PDFViewer = PDFViewer;
1402
- //# sourceMappingURL=chunk-3STHCDAC.js.map
1734
+ //# sourceMappingURL=chunk-QELOFQEB.js.map