@cannyminds/dms-file-viewers 0.13.0 → 0.15.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-42VHR3EK.mjs +714 -0
  2. package/dist/chunk-42VHR3EK.mjs.map +1 -0
  3. package/dist/{chunk-J3JKVSAM.js → chunk-AYVTSFZA.js} +2 -1
  4. package/dist/chunk-AYVTSFZA.js.map +1 -0
  5. package/dist/chunk-C4L2R2QY.mjs +277 -0
  6. package/dist/chunk-C4L2R2QY.mjs.map +1 -0
  7. package/dist/chunk-DBXSX2B6.js +277 -0
  8. package/dist/chunk-DBXSX2B6.js.map +1 -0
  9. package/dist/chunk-DPSRGULQ.mjs +247 -0
  10. package/dist/chunk-DPSRGULQ.mjs.map +1 -0
  11. package/dist/chunk-FK6RYOAZ.mjs +297 -0
  12. package/dist/chunk-FK6RYOAZ.mjs.map +1 -0
  13. package/dist/chunk-FZVXQGA7.mjs +466 -0
  14. package/dist/chunk-FZVXQGA7.mjs.map +1 -0
  15. package/dist/chunk-GSRAK2YV.js +266 -0
  16. package/dist/chunk-GSRAK2YV.js.map +1 -0
  17. package/dist/chunk-HYRQBGAX.js +466 -0
  18. package/dist/chunk-HYRQBGAX.js.map +1 -0
  19. package/dist/chunk-RKDOWWQD.js +247 -0
  20. package/dist/chunk-RKDOWWQD.js.map +1 -0
  21. package/dist/chunk-TMAHQICY.mjs +1842 -0
  22. package/dist/chunk-TMAHQICY.mjs.map +1 -0
  23. package/dist/chunk-VBJVOB45.mjs +266 -0
  24. package/dist/chunk-VBJVOB45.mjs.map +1 -0
  25. package/dist/{chunk-DFBVN4MO.mjs → chunk-WR5SJ3LM.mjs} +2 -1
  26. package/dist/chunk-WR5SJ3LM.mjs.map +1 -0
  27. package/dist/chunk-XSXOX4MV.js +297 -0
  28. package/dist/chunk-XSXOX4MV.js.map +1 -0
  29. package/dist/chunk-XWWMHRVU.js +1842 -0
  30. package/dist/chunk-XWWMHRVU.js.map +1 -0
  31. package/dist/chunk-YU535XRJ.js +714 -0
  32. package/dist/chunk-YU535XRJ.js.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-DxRCbIFP.d.mts} +4 -2
  66. package/dist/{types-DNrkDJdK.d.ts → types-DxRCbIFP.d.ts} +4 -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 strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
-
3
-
4
- var _chunkA2MSWOEMjs = require('./chunk-A2MSWOEM.js');
5
-
6
-
7
- var _chunkYEPEMLM3js = require('./chunk-YEPEMLM3.js');
8
-
9
-
10
-
11
- var _chunkJ3JKVSAMjs = require('./chunk-J3JKVSAM.js');
12
-
13
- // src/components/viewers/PDFViewer.tsx
14
- var _react = require('react'); var _react2 = _interopRequireDefault(_react);
15
-
16
- // src/components/viewers/pdf/StablePDFViewer.tsx
17
-
18
- var _pdfviewer = require('@cannyminds/pdf-viewer');
19
- var _jsxruntime = require('react/jsx-runtime');
20
- var HeadlessPDFViewer = _pdfviewer.PDFViewer;
21
- var StablePDFViewer = _react2.default.memo(({
22
- pdfBuffer,
23
- onPasswordRequest,
24
- pdfViewerRef
25
- }) => {
26
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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
-
39
- var _FirstPage = require('@mui/icons-material/FirstPage'); var _FirstPage2 = _interopRequireDefault(_FirstPage);
40
- var _LastPage = require('@mui/icons-material/LastPage'); var _LastPage2 = _interopRequireDefault(_LastPage);
41
- var _ChevronLeft = require('@mui/icons-material/ChevronLeft'); var _ChevronLeft2 = _interopRequireDefault(_ChevronLeft);
42
- var _ChevronRight = require('@mui/icons-material/ChevronRight'); var _ChevronRight2 = _interopRequireDefault(_ChevronRight);
43
- var _ZoomIn = require('@mui/icons-material/ZoomIn'); var _ZoomIn2 = _interopRequireDefault(_ZoomIn);
44
- var _ZoomOut = require('@mui/icons-material/ZoomOut'); var _ZoomOut2 = _interopRequireDefault(_ZoomOut);
45
- var _FitScreen = require('@mui/icons-material/FitScreen'); var _FitScreen2 = _interopRequireDefault(_FitScreen);
46
- var _AspectRatio = require('@mui/icons-material/AspectRatio'); var _AspectRatio2 = _interopRequireDefault(_AspectRatio);
47
- var _Search = require('@mui/icons-material/Search'); var _Search2 = _interopRequireDefault(_Search);
48
- var _Fullscreen = require('@mui/icons-material/Fullscreen'); var _Fullscreen2 = _interopRequireDefault(_Fullscreen);
49
- var _Download = require('@mui/icons-material/Download'); var _Download2 = _interopRequireDefault(_Download);
50
- var _Print = require('@mui/icons-material/Print'); var _Print2 = _interopRequireDefault(_Print);
51
- var _Info = require('@mui/icons-material/Info'); var _Info2 = _interopRequireDefault(_Info);
52
- var _Description = require('@mui/icons-material/Description'); var _Description2 = _interopRequireDefault(_Description);
53
- var _RotateLeft = require('@mui/icons-material/RotateLeft'); var _RotateLeft2 = _interopRequireDefault(_RotateLeft);
54
- var _RotateRight = require('@mui/icons-material/RotateRight'); var _RotateRight2 = _interopRequireDefault(_RotateRight);
55
-
56
- var PDFToolbar = _react2.default.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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar", children: [
96
- showPageNavigation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
97
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
98
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
99
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
100
- "button",
101
- {
102
- className: "toolbar-button",
103
- onClick: onFirstPage,
104
- disabled: currentPage <= 1,
105
- title: "First Page",
106
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
107
- }
108
- ),
109
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
110
- "button",
111
- {
112
- className: "toolbar-button",
113
- onClick: onPreviousPage,
114
- disabled: currentPage <= 1,
115
- title: "Previous Page",
116
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
117
- }
118
- ),
119
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "page-info", children: [
132
- "of ",
133
- totalPages || "..."
134
- ] }),
135
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
136
- "button",
137
- {
138
- className: "toolbar-button",
139
- onClick: onNextPage,
140
- disabled: currentPage >= totalPages,
141
- title: "Next Page",
142
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
143
- }
144
- ),
145
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
146
- "button",
147
- {
148
- className: "toolbar-button",
149
- onClick: onLastPage,
150
- disabled: currentPage >= totalPages,
151
- title: "Last Page",
152
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
153
- }
154
- )
155
- ] })
156
- ] }),
157
- showZoomControls && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
158
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
159
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
160
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
161
- "button",
162
- {
163
- className: "toolbar-button",
164
- onClick: onZoomOut,
165
- title: "Zoom Out",
166
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomOut2.default, { fontSize: "small" })
167
- }
168
- ),
169
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "zoom-display", children: [
170
- zoom,
171
- "%"
172
- ] }),
173
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
174
- "button",
175
- {
176
- className: "toolbar-button",
177
- onClick: onZoomIn,
178
- title: "Zoom In",
179
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomIn2.default, { fontSize: "small" })
180
- }
181
- ),
182
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
183
- "button",
184
- {
185
- className: "toolbar-button",
186
- onClick: onFitToWidth,
187
- title: "Fit to Width",
188
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" })
189
- }
190
- ),
191
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
192
- "button",
193
- {
194
- className: "toolbar-button",
195
- onClick: onFitToPage,
196
- title: "Fit to Page",
197
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" })
198
- }
199
- )
200
- ] })
201
- ] }),
202
- showRotation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
203
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
204
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
205
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
206
- "button",
207
- {
208
- className: "toolbar-button",
209
- onClick: onRotateLeft,
210
- disabled: disabledRotateLeft,
211
- title: "Rotate Counterclockwise",
212
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _RotateLeft2.default, { fontSize: "small" })
213
- }
214
- ),
215
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
216
- "button",
217
- {
218
- className: "toolbar-button",
219
- onClick: onRotateRight,
220
- disabled: disabledRotateRight,
221
- title: "Rotate Clockwise",
222
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _RotateRight2.default, { fontSize: "small" })
223
- }
224
- )
225
- ] })
226
- ] }),
227
- showSearch && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
228
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
229
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { fontSize: "small" })
240
- }
241
- ) })
242
- ] }),
243
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
244
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
245
- "button",
246
- {
247
- className: "toolbar-button",
248
- onClick: onToggleFullScreen,
249
- title: "Fullscreen",
250
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Fullscreen2.default, { fontSize: "small" })
251
- }
252
- ) }),
253
- (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
254
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
255
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
256
- showDownload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
257
- "button",
258
- {
259
- className: "toolbar-button",
260
- onClick: onDownloadClick,
261
- disabled: disabledDownload,
262
- title: "Download PDF",
263
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
264
- }
265
- ),
266
- showPrint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
267
- "button",
268
- {
269
- className: "toolbar-button",
270
- onClick: onPrintClick,
271
- disabled: disabledPrint,
272
- title: "Print PDF",
273
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
274
- }
275
- ),
276
- showMetadata && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
277
- "button",
278
- {
279
- className: "toolbar-button",
280
- onClick: onMetadataClick,
281
- disabled: disabledMetadata,
282
- title: "Document Metadata",
283
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
284
- }
285
- ),
286
- showProperties && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
287
- "button",
288
- {
289
- className: "toolbar-button",
290
- onClick: onPropertiesClick,
291
- disabled: disabledProperties,
292
- title: "Document Properties",
293
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
294
- }
295
- )
296
- ] })
297
- ] })
298
- ] });
299
- });
300
- PDFToolbar.displayName = "PDFToolbar";
301
-
302
- // src/components/viewers/pdf/PDFHeader.tsx
303
-
304
-
305
- var PDFHeader = _react2.default.memo(({ fileName, fileExtension }) => {
306
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-header", children: [
307
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkJ3JKVSAMjs.FileIcon_default, { ext: fileExtension, size: 26 }),
308
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "header-file-name", title: fileName, children: fileName })
309
- ] });
310
- });
311
- PDFHeader.displayName = "PDFHeader";
312
-
313
- // src/components/viewers/pdf/SearchSidebar.tsx
314
-
315
-
316
-
317
-
318
-
319
-
320
-
321
-
322
-
323
- var _material = require('@mui/material');
324
-
325
- var _Close = require('@mui/icons-material/Close'); var _Close2 = _interopRequireDefault(_Close);
326
- var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _KeyboardArrowUp2 = _interopRequireDefault(_KeyboardArrowUp);
327
- var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
328
- var _Clear = require('@mui/icons-material/Clear'); var _Clear2 = _interopRequireDefault(_Clear);
329
- var _FindInPage = require('@mui/icons-material/FindInPage'); var _FindInPage2 = _interopRequireDefault(_FindInPage);
330
-
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] = _react.useState.call(void 0, searchKeyword || "");
346
- const [hasSearched, setHasSearched] = _react.useState.call(void 0, false);
347
- const contentRef = _react.useRef.call(void 0, null);
348
- _react.useEffect.call(void 0, () => {
349
- if (searchKeyword && searchKeyword !== searchTerm) {
350
- setSearchTerm(searchKeyword);
351
- }
352
- }, [searchKeyword]);
353
- _react.useLayoutEffect.call(void 0, () => {
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
- _react.useLayoutEffect.call(void 0, () => {
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
- _react.useLayoutEffect.call(void 0, () => {
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__ */ _jsxruntime.jsx.call(void 0,
466
- _material.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__ */ _jsxruntime.jsxs.call(void 0,
485
- _material.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__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { px: 3, py: 2.5, backgroundColor: "background.default" }, children: [
499
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [
500
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", sx: { fontSize: "1.125rem", fontWeight: 600, color: "text.primary" }, children: "Search" }),
501
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
502
- _material.IconButton,
503
- {
504
- size: "small",
505
- onClick: onClose,
506
- sx: {
507
- color: "text.secondary",
508
- padding: "6px"
509
- },
510
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Close2.default, { fontSize: "small" })
511
- }
512
- )
513
- ] }),
514
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { onSubmit: handleSearchSubmit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
515
- _material.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__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "start", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { color: "text.disabled", fontSize: 20 } }) }),
525
- endAdornment: searchTerm && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
526
- _material.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__ */ _jsxruntime.jsx.call(void 0, _Clear2.default, { 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__ */ _jsxruntime.jsxs.call(void 0,
561
- _material.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__ */ _jsxruntime.jsxs.call(void 0, _material.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__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
580
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
581
- _material.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__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowUp2.default, { sx: { fontSize: 20 } })
594
- }
595
- ),
596
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
597
- _material.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__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { sx: { fontSize: 20 } })
610
- }
611
- )
612
- ] })
613
- ]
614
- }
615
- )
616
- ] }),
617
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Divider, {}),
618
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { ref: contentRef, className: "search-sidebar-content", sx: {
619
- flex: 1,
620
- overflow: "auto",
621
- backgroundColor: "background.default"
622
- }, children: [
623
- !searchTerm && !hasSearched && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
624
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
625
- _material.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__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "text.disabled" } })
639
- }
640
- ),
641
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
642
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.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__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
645
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
646
- _material.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__ */ _jsxruntime.jsx.call(void 0, _FindInPage2.default, { sx: { fontSize: 40, color: "primary.main" } })
661
- }
662
- ),
663
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Ready to Search" }),
664
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", mb: 2, lineHeight: 1.6 }, children: "Press Enter to find" }),
665
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
666
- _material.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__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
687
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
688
- _material.Box,
689
- {
690
- sx: {
691
- display: "flex",
692
- alignItems: "center",
693
- justifyContent: "center",
694
- margin: "0 auto",
695
- mb: 3
696
- },
697
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { size: 60, thickness: 4 })
698
- }
699
- ),
700
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Searching..." }),
701
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.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__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
708
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
709
- _material.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__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "warning.main" } })
724
- }
725
- ),
726
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
727
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
728
- "No matches found for ",
729
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
730
- '"',
731
- searchTerm,
732
- '"'
733
- ] })
734
- ] })
735
- ] }),
736
- 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) => {
737
- const pageNumber = parseInt(pageNum);
738
- const pageResults = resultsByPage[pageNumber];
739
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { mb: 3 }, children: [
740
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
741
- _material.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__ */ _jsxruntime.jsx.call(void 0,
760
- _material.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__ */ _jsxruntime.jsx.call(void 0,
781
- _material.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
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
-
814
-
815
-
816
-
817
-
818
-
819
-
820
- var _Lock = require('@mui/icons-material/Lock'); var _Lock2 = _interopRequireDefault(_Lock);
821
- var _Visibility = require('@mui/icons-material/Visibility'); var _Visibility2 = _interopRequireDefault(_Visibility);
822
- var _VisibilityOff = require('@mui/icons-material/VisibilityOff'); var _VisibilityOff2 = _interopRequireDefault(_VisibilityOff);
823
-
824
- var PasswordDialog = ({
825
- open,
826
- fileName,
827
- onSubmit,
828
- onCancel,
829
- error
830
- }) => {
831
- const [password, setPassword] = _react.useState.call(void 0, "");
832
- const [showPassword, setShowPassword] = _react.useState.call(void 0, false);
833
- _react.useEffect.call(void 0, () => {
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__ */ _jsxruntime.jsxs.call(void 0,
854
- _material.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__ */ _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: [
867
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
868
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
869
- _material.Box,
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__ */ _jsxruntime.jsx.call(void 0, _Lock2.default, { sx: { color: "white", fontSize: 20 } })
882
- }
883
- ),
884
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
885
- ] }),
886
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
887
- _material.IconButton,
888
- {
889
- size: "small",
890
- onClick: onCancel,
891
- sx: { color: "text.secondary" },
892
- "aria-label": "Close dialog",
893
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Close2.default, { fontSize: "small" })
894
- }
895
- )
896
- ] }) }),
897
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogContent, { sx: { pt: 2 }, children: [
898
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { 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__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
902
- '"',
903
- fileName,
904
- '"'
905
- ] })
906
- ] }),
907
- error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Alert, { severity: "error", sx: { mb: 2 }, children: error }),
908
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { onSubmit: handleSubmit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
909
- _material.TextField,
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__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
922
- _material.IconButton,
923
- {
924
- onClick: handleTogglePasswordVisibility,
925
- edge: "end",
926
- size: "small",
927
- "aria-label": showPassword ? "Hide password" : "Show password",
928
- children: showPassword ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VisibilityOff2.default, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Visibility2.default, {})
929
- }
930
- ) })
931
- },
932
- sx: {
933
- "& .MuiOutlinedInput-root": {
934
- borderRadius: 2
935
- }
936
- }
937
- }
938
- ) })
939
- ] }),
940
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
941
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
942
- _material.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__ */ _jsxruntime.jsx.call(void 0,
955
- _material.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
-
977
- var PDFViewerContent = _react.forwardRef.call(void 0, (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] = _react.useState.call(void 0, null);
1000
- const [state, setState] = _react.useState.call(void 0, "idle");
1001
- const [error, setError] = _react.useState.call(void 0, null);
1002
- const pdfViewerRef = _react.useRef.call(void 0, null);
1003
- const resolvedFileName = _react.useMemo.call(void 0, () => {
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 = _react.useMemo.call(void 0,
1013
- () => _chunkYEPEMLM3js.getFileExtension.call(void 0, resolvedFileName),
1014
- [resolvedFileName]
1015
- );
1016
- const [currentPage, setCurrentPage] = _react.useState.call(void 0, 1);
1017
- const [totalPages, setTotalPages] = _react.useState.call(void 0, 0);
1018
- const [zoom, setZoom] = _react.useState.call(void 0, 100);
1019
- const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
1020
- const [isSearching, setIsSearching] = _react.useState.call(void 0, false);
1021
- const [pdfContainer, setPdfContainer] = _react.useState.call(void 0, null);
1022
- const [isSidebarOpen, setIsSidebarOpen] = _react.useState.call(void 0, false);
1023
- const [searchResults, setSearchResults] = _react.useState.call(void 0, []);
1024
- const [currentSearchResultIndex, setCurrentSearchResultIndex] = _react.useState.call(void 0, 0);
1025
- const [totalSearchResults, setTotalSearchResults] = _react.useState.call(void 0, 0);
1026
- const [autoExecuteSearch, setAutoExecuteSearch] = _react.useState.call(void 0, !!initialSearchText);
1027
- const [isFullScreen, setIsFullScreen] = _react.useState.call(void 0, false);
1028
- const containerRef = _react.useRef.call(void 0, null);
1029
- const [isPasswordDialogOpen, setIsPasswordDialogOpen] = _react.useState.call(void 0, false);
1030
- const [passwordError, setPasswordError] = _react.useState.call(void 0, "");
1031
- const [passwordResolve, setPasswordResolve] = _react.useState.call(void 0, null);
1032
- const hasExecutedInitialSearch = _react.useRef.call(void 0, false);
1033
- const handleToggleFullScreen = _react.useCallback.call(void 0, () => {
1034
- if (!isFullScreen && _optionalChain([containerRef, 'access', _ => _.current, 'optionalAccess', _2 => _2.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 = _react.useCallback.call(void 0, () => {
1043
- setIsSidebarOpen(false);
1044
- setSearchQuery("");
1045
- setSearchResults([]);
1046
- setTotalSearchResults(0);
1047
- setCurrentSearchResultIndex(0);
1048
- _optionalChain([pdfViewerRef, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.search, 'access', _5 => _5.stopSearch, 'call', _6 => _6()]);
1049
- }, []);
1050
- const toolbar = _chunkJ3JKVSAMjs.mergeToolbarConfig.call(void 0, {
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 = _react.useMemo.call(void 0, () => ({
1063
- handleZoomIn: () => {
1064
- _optionalChain([pdfViewerRef, 'access', _7 => _7.current, 'optionalAccess', _8 => _8.zoom, 'access', _9 => _9.zoomIn, 'call', _10 => _10()]);
1065
- requestAnimationFrame(() => {
1066
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.zoom, 'access', _13 => _13.getZoom, 'call', _14 => _14()]);
1067
- if (typeof zoomValue === "number") {
1068
- setZoom(Math.round(zoomValue * 100));
1069
- }
1070
- });
1071
- },
1072
- handleZoomOut: () => {
1073
- _optionalChain([pdfViewerRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.zoom, 'access', _17 => _17.zoomOut, 'call', _18 => _18()]);
1074
- requestAnimationFrame(() => {
1075
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.zoom, 'access', _21 => _21.getZoom, 'call', _22 => _22()]);
1076
- if (typeof zoomValue === "number") {
1077
- setZoom(Math.round(zoomValue * 100));
1078
- }
1079
- });
1080
- },
1081
- handleFitToWidth: () => {
1082
- _optionalChain([pdfViewerRef, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.zoom, 'access', _25 => _25.fitToWidth, 'call', _26 => _26()]);
1083
- requestAnimationFrame(() => {
1084
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.zoom, 'access', _29 => _29.getZoom, 'call', _30 => _30()]);
1085
- if (typeof zoomValue === "number") {
1086
- setZoom(Math.round(zoomValue * 100));
1087
- }
1088
- });
1089
- },
1090
- handleFitToPage: () => {
1091
- _optionalChain([pdfViewerRef, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.zoom, 'access', _33 => _33.fitToPage, 'call', _34 => _34()]);
1092
- requestAnimationFrame(() => {
1093
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.zoom, 'access', _37 => _37.getZoom, 'call', _38 => _38()]);
1094
- if (typeof zoomValue === "number") {
1095
- setZoom(Math.round(zoomValue * 100));
1096
- }
1097
- });
1098
- },
1099
- handlePreviousPage: () => {
1100
- _optionalChain([pdfViewerRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.navigation, 'access', _41 => _41.previousPage, 'call', _42 => _42()]);
1101
- requestAnimationFrame(() => {
1102
- const current = _optionalChain([pdfViewerRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.navigation, 'access', _45 => _45.getCurrentPage, 'call', _46 => _46()]) || 1;
1103
- setCurrentPage(current);
1104
- });
1105
- },
1106
- handleNextPage: () => {
1107
- _optionalChain([pdfViewerRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.navigation, 'access', _49 => _49.nextPage, 'call', _50 => _50()]);
1108
- requestAnimationFrame(() => {
1109
- const current = _optionalChain([pdfViewerRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.navigation, 'access', _53 => _53.getCurrentPage, 'call', _54 => _54()]) || 1;
1110
- setCurrentPage(current);
1111
- });
1112
- },
1113
- handleFirstPage: () => {
1114
- _optionalChain([pdfViewerRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.navigation, 'access', _57 => _57.goToFirstPage, 'call', _58 => _58()]);
1115
- requestAnimationFrame(() => {
1116
- const current = _optionalChain([pdfViewerRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.navigation, 'access', _61 => _61.getCurrentPage, 'call', _62 => _62()]) || 1;
1117
- setCurrentPage(current);
1118
- });
1119
- },
1120
- handleLastPage: () => {
1121
- _optionalChain([pdfViewerRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.navigation, 'access', _65 => _65.goToLastPage, 'call', _66 => _66()]);
1122
- requestAnimationFrame(() => {
1123
- const current = _optionalChain([pdfViewerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.navigation, 'access', _69 => _69.getCurrentPage, 'call', _70 => _70()]) || 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
- _optionalChain([pdfViewerRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.navigation, 'access', _73 => _73.goToPage, 'call', _74 => _74(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
- _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.navigation, 'access', _77 => _77.goToPage, 'call', _78 => _78(page)]);
1151
- setCurrentPage(page);
1152
- }
1153
- }
1154
- },
1155
- handleRotateLeft: () => {
1156
- _optionalChain([pdfViewerRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.rotate, 'optionalAccess', _81 => _81.rotateBackward, 'call', _82 => _82()]);
1157
- },
1158
- handleRotateRight: () => {
1159
- _optionalChain([pdfViewerRef, 'access', _83 => _83.current, 'optionalAccess', _84 => _84.rotate, 'optionalAccess', _85 => _85.rotateForward, 'call', _86 => _86()]);
1160
- },
1161
- handleToggleFullScreen
1162
- }), [isSidebarOpen, totalPages, handleToggleFullScreen]);
1163
- _react.useEffect.call(void 0, () => {
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 = !!_optionalChain([pdfViewerRef, 'access', _87 => _87.current, 'optionalAccess', _88 => _88.search, 'optionalAccess', _89 => _89.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 (!_optionalChain([pdfViewerRef, 'access', _90 => _90.current, 'optionalAccess', _91 => _91.search, 'optionalAccess', _92 => _92.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
- _react.useEffect.call(void 0, () => {
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
- _react.useEffect.call(void 0, () => {
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
- _react.useEffect.call(void 0, () => {
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 = _optionalChain([viewer, 'access', _93 => _93.navigation, 'optionalAccess', _94 => _94.getTotalPages, 'optionalCall', _95 => _95()]);
1238
- if (count && count > 1) {
1239
- setTotalPages(count);
1240
- return;
1241
- }
1242
- } catch (e) {
1243
- }
1244
- try {
1245
- const results = await _optionalChain([viewer, 'access', _96 => _96.search, 'optionalAccess', _97 => _97.searchText, 'optionalCall', _98 => _98("e")]);
1246
- if (_optionalChain([results, 'optionalAccess', _99 => _99.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
- _optionalChain([viewer, 'access', _100 => _100.search, 'optionalAccess', _101 => _101.stopSearch, 'optionalCall', _102 => _102()]);
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 = _optionalChain([viewer, 'access', _103 => _103.navigation, 'optionalAccess', _104 => _104.getTotalPages, 'optionalCall', _105 => _105()]);
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
- _react.useEffect.call(void 0, () => {
1288
- if (state === "ready" && pdfViewerRef.current) {
1289
- const updateInfo = () => {
1290
- const current = _optionalChain([pdfViewerRef, 'access', _106 => _106.current, 'optionalAccess', _107 => _107.navigation, 'access', _108 => _108.getCurrentPage, 'call', _109 => _109()]) || 1;
1291
- const total = _optionalChain([pdfViewerRef, 'access', _110 => _110.current, 'optionalAccess', _111 => _111.navigation, 'access', _112 => _112.getTotalPages, 'call', _113 => _113()]) || 0;
1292
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _114 => _114.current, 'optionalAccess', _115 => _115.zoom, 'access', _116 => _116.getZoom, 'call', _117 => _117()]);
1293
- const currentSearchState = _optionalChain([pdfViewerRef, 'access', _118 => _118.current, 'optionalAccess', _119 => _119.search, 'access', _120 => _120.getSearchState, 'call', _121 => _121()]);
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
- _react.useImperativeHandle.call(void 0, ref, () => ({
1308
- zoomIn: () => {
1309
- _optionalChain([pdfViewerRef, 'access', _122 => _122.current, 'optionalAccess', _123 => _123.zoom, 'access', _124 => _124.zoomIn, 'call', _125 => _125()]);
1310
- updateZoomDisplay();
1311
- },
1312
- zoomOut: () => {
1313
- _optionalChain([pdfViewerRef, 'access', _126 => _126.current, 'optionalAccess', _127 => _127.zoom, 'access', _128 => _128.zoomOut, 'call', _129 => _129()]);
1314
- updateZoomDisplay();
1315
- },
1316
- setZoom: (level) => {
1317
- _optionalChain([pdfViewerRef, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.zoom, 'access', _132 => _132.setZoom, 'call', _133 => _133(level)]);
1318
- updateZoomDisplay();
1319
- },
1320
- resetZoom: () => {
1321
- _optionalChain([pdfViewerRef, 'access', _134 => _134.current, 'optionalAccess', _135 => _135.zoom, 'access', _136 => _136.resetZoom, 'call', _137 => _137()]);
1322
- updateZoomDisplay();
1323
- },
1324
- getZoom: () => {
1325
- const zoom2 = _optionalChain([pdfViewerRef, 'access', _138 => _138.current, 'optionalAccess', _139 => _139.zoom, 'access', _140 => _140.getZoom, 'call', _141 => _141()]);
1326
- return typeof zoom2 === "number" ? zoom2 : 1;
1327
- },
1328
- goToPage: (page) => {
1329
- _optionalChain([pdfViewerRef, 'access', _142 => _142.current, 'optionalAccess', _143 => _143.navigation, 'access', _144 => _144.goToPage, 'call', _145 => _145(page)]);
1330
- setCurrentPage(page);
1331
- },
1332
- getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _146 => _146.current, 'optionalAccess', _147 => _147.navigation, 'access', _148 => _148.getCurrentPage, 'call', _149 => _149()]) || 1,
1333
- getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _150 => _150.current, 'optionalAccess', _151 => _151.navigation, 'access', _152 => _152.getTotalPages, 'call', _153 => _153()]) || 0,
1334
- nextPage: () => {
1335
- _optionalChain([pdfViewerRef, 'access', _154 => _154.current, 'optionalAccess', _155 => _155.navigation, 'access', _156 => _156.nextPage, 'call', _157 => _157()]);
1336
- updatePageDisplay();
1337
- },
1338
- previousPage: () => {
1339
- _optionalChain([pdfViewerRef, 'access', _158 => _158.current, 'optionalAccess', _159 => _159.navigation, 'access', _160 => _160.previousPage, 'call', _161 => _161()]);
1340
- updatePageDisplay();
1341
- },
1342
- goToFirstPage: () => {
1343
- _optionalChain([pdfViewerRef, 'access', _162 => _162.current, 'optionalAccess', _163 => _163.navigation, 'access', _164 => _164.goToFirstPage, 'call', _165 => _165()]);
1344
- updatePageDisplay();
1345
- },
1346
- goToLastPage: () => {
1347
- _optionalChain([pdfViewerRef, 'access', _166 => _166.current, 'optionalAccess', _167 => _167.navigation, 'access', _168 => _168.goToLastPage, 'call', _169 => _169()]);
1348
- updatePageDisplay();
1349
- },
1350
- searchText: async (keyword) => {
1351
- setIsSearching(true);
1352
- const results = await _optionalChain([pdfViewerRef, 'access', _170 => _170.current, 'optionalAccess', _171 => _171.search, 'access', _172 => _172.searchText, 'call', _173 => _173(keyword)]);
1353
- setIsSearching(false);
1354
- setSearchQuery(keyword);
1355
- return results;
1356
- },
1357
- nextResult: () => {
1358
- const index = _optionalChain([pdfViewerRef, 'access', _174 => _174.current, 'optionalAccess', _175 => _175.search, 'access', _176 => _176.nextResult, 'call', _177 => _177()]) || -1;
1359
- return index;
1360
- },
1361
- previousResult: () => {
1362
- const index = _optionalChain([pdfViewerRef, 'access', _178 => _178.current, 'optionalAccess', _179 => _179.search, 'access', _180 => _180.previousResult, 'call', _181 => _181()]) || -1;
1363
- return index;
1364
- },
1365
- goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _182 => _182.current, 'optionalAccess', _183 => _183.search, 'access', _184 => _184.goToResult, 'call', _185 => _185(index)]) || -1,
1366
- stopSearch: () => {
1367
- _optionalChain([pdfViewerRef, 'access', _186 => _186.current, 'optionalAccess', _187 => _187.search, 'access', _188 => _188.stopSearch, 'call', _189 => _189()]);
1368
- setSearchQuery("");
1369
- },
1370
- getSearchState: () => _optionalChain([pdfViewerRef, 'access', _190 => _190.current, 'optionalAccess', _191 => _191.search, 'access', _192 => _192.getSearchState, 'call', _193 => _193()]) || null,
1371
- getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _194 => _194.current, 'optionalAccess', _195 => _195.selection, 'access', _196 => _196.getSelectedText, 'call', _197 => _197()]) || "",
1372
- clearSelection: () => _optionalChain([pdfViewerRef, 'access', _198 => _198.current, 'optionalAccess', _199 => _199.selection, 'access', _200 => _200.clearSelection, 'call', _201 => _201()]),
1373
- rotateForward: () => _optionalChain([pdfViewerRef, 'access', _202 => _202.current, 'optionalAccess', _203 => _203.rotate, 'optionalAccess', _204 => _204.rotateForward, 'call', _205 => _205()]),
1374
- rotateBackward: () => _optionalChain([pdfViewerRef, 'access', _206 => _206.current, 'optionalAccess', _207 => _207.rotate, 'optionalAccess', _208 => _208.rotateBackward, 'call', _209 => _209()]),
1375
- getRotation: () => _optionalChain([pdfViewerRef, 'access', _210 => _210.current, 'optionalAccess', _211 => _211.rotate, 'optionalAccess', _212 => _212.getRotation, 'call', _213 => _213()]) || 0
1376
- }), []);
1377
- const updatePageDisplay = () => {
1378
- requestAnimationFrame(() => {
1379
- const current = _optionalChain([pdfViewerRef, 'access', _214 => _214.current, 'optionalAccess', _215 => _215.navigation, 'access', _216 => _216.getCurrentPage, 'call', _217 => _217()]) || 1;
1380
- setCurrentPage(current);
1381
- });
1382
- };
1383
- const updateZoomDisplay = () => {
1384
- requestAnimationFrame(() => {
1385
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _218 => _218.current, 'optionalAccess', _219 => _219.zoom, 'access', _220 => _220.getZoom, 'call', _221 => _221()]);
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 _optionalChain([pdfViewerRef, 'access', _222 => _222.current, 'optionalAccess', _223 => _223.search, 'access', _224 => _224.searchText, 'call', _225 => _225(searchQuery)]);
1395
- setIsSearching(false);
1396
- if (_optionalChain([results, 'optionalAccess', _226 => _226.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
- _optionalChain([pdfViewerRef, 'access', _227 => _227.current, 'optionalAccess', _228 => _228.search, 'access', _229 => _229.stopSearch, 'call', _230 => _230()]);
1415
- return;
1416
- }
1417
- if (!_optionalChain([pdfViewerRef, 'access', _231 => _231.current, 'optionalAccess', _232 => _232.search, 'optionalAccess', _233 => _233.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 = _optionalChain([results, 'optionalAccess', _234 => _234.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: (_nullishCoalesce(_nullishCoalesce(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
- _optionalChain([pdfViewerRef, 'access', _235 => _235.current, 'optionalAccess', _236 => _236.navigation, 'access', _237 => _237.goToPage, 'call', _238 => _238(pageNumber)]);
1493
- setCurrentPage(pageNumber);
1494
- });
1495
- };
1496
- const handleSearchResultClick = (pageNumber, resultIndex) => {
1497
- _optionalChain([pdfViewerRef, 'access', _239 => _239.current, 'optionalAccess', _240 => _240.navigation, 'access', _241 => _241.goToPage, 'call', _242 => _242(pageNumber)]);
1498
- setCurrentSearchResultIndex(resultIndex);
1499
- setCurrentPage(pageNumber);
1500
- _optionalChain([pdfViewerRef, 'access', _243 => _243.current, 'optionalAccess', _244 => _244.search, 'access', _245 => _245.goToResult, 'call', _246 => _246(resultIndex)]);
1501
- };
1502
- const handleNextSearchResult = () => {
1503
- if (currentSearchResultIndex < totalSearchResults - 1) {
1504
- const nextIndex = currentSearchResultIndex + 1;
1505
- setCurrentSearchResultIndex(nextIndex);
1506
- _optionalChain([pdfViewerRef, 'access', _247 => _247.current, 'optionalAccess', _248 => _248.search, 'access', _249 => _249.nextResult, 'call', _250 => _250()]);
1507
- if (searchResults[nextIndex]) {
1508
- const pageNumber = searchResults[nextIndex].pageNumber;
1509
- _optionalChain([pdfViewerRef, 'access', _251 => _251.current, 'optionalAccess', _252 => _252.navigation, 'access', _253 => _253.goToPage, 'call', _254 => _254(pageNumber)]);
1510
- setCurrentPage(pageNumber);
1511
- }
1512
- }
1513
- };
1514
- const handlePreviousSearchResult = () => {
1515
- if (currentSearchResultIndex > 0) {
1516
- const prevIndex = currentSearchResultIndex - 1;
1517
- setCurrentSearchResultIndex(prevIndex);
1518
- _optionalChain([pdfViewerRef, 'access', _255 => _255.current, 'optionalAccess', _256 => _256.search, 'access', _257 => _257.previousResult, 'call', _258 => _258()]);
1519
- if (searchResults[prevIndex]) {
1520
- const pageNumber = searchResults[prevIndex].pageNumber;
1521
- _optionalChain([pdfViewerRef, 'access', _259 => _259.current, 'optionalAccess', _260 => _260.navigation, 'access', _261 => _261.goToPage, 'call', _262 => _262(pageNumber)]);
1522
- setCurrentPage(pageNumber);
1523
- }
1524
- }
1525
- };
1526
- _react.useEffect.call(void 0, () => {
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
- _optionalChain([onLoad, 'optionalCall', _263 => _263()]);
1553
- } catch (err) {
1554
- const errorMessage = err.message || "Failed to load PDF";
1555
- setState("error");
1556
- setError(errorMessage);
1557
- _optionalChain([onError, 'optionalCall', _264 => _264(err)]);
1558
- }
1559
- };
1560
- loadPDF();
1561
- }, [file, onLoad, onError]);
1562
- const handlePasswordRequest = _react.useCallback.call(void 0, async (fileName2) => {
1563
- return new Promise((resolve) => {
1564
- setPasswordResolve(() => resolve);
1565
- setPasswordError("");
1566
- setIsPasswordDialogOpen(true);
1567
- });
1568
- }, []);
1569
- const handlePasswordSubmit = _react.useCallback.call(void 0, (password) => {
1570
- if (passwordResolve) {
1571
- passwordResolve(password);
1572
- setPasswordResolve(null);
1573
- setIsPasswordDialogOpen(false);
1574
- setPasswordError("");
1575
- }
1576
- }, [passwordResolve]);
1577
- const handlePasswordCancel = _react.useCallback.call(void 0, () => {
1578
- if (passwordResolve) {
1579
- passwordResolve(null);
1580
- setPasswordResolve(null);
1581
- setIsPasswordDialogOpen(false);
1582
- setPasswordError("");
1583
- }
1584
- }, [passwordResolve]);
1585
- if (state === "loading") {
1586
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: {
1587
- display: "flex",
1588
- flexDirection: "column",
1589
- alignItems: "center",
1590
- justifyContent: "center",
1591
- height: "100%",
1592
- gap: "16px"
1593
- }, children: [
1594
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "p", { children: "Loading PDF..." }),
1603
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "div", { style: {
1613
- display: "flex",
1614
- flexDirection: "column",
1615
- alignItems: "center",
1616
- justifyContent: "center",
1617
- height: "100%",
1618
- padding: "24px"
1619
- }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: {
1620
- maxWidth: "400px",
1621
- padding: "16px",
1622
- backgroundColor: "#fee",
1623
- border: "1px solid #fcc",
1624
- borderRadius: "4px"
1625
- }, children: [
1626
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { style: { marginTop: 0 }, children: "Failed to Load PDF" }),
1627
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: error || "Unknown error occurred" })
1628
- ] }) });
1629
- }
1630
- if (!pdfBuffer || state !== "ready") {
1631
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: {
1632
- display: "flex",
1633
- alignItems: "center",
1634
- justifyContent: "center",
1635
- height: "100%"
1636
- }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: "Preparing PDF..." }) });
1637
- }
1638
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: containerRef, className: "pdf-viewer-container", children: [
1639
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: _chunkA2MSWOEMjs.toolbarStyles }),
1640
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1641
- PDFHeader,
1642
- {
1643
- fileName: resolvedFileName,
1644
- fileExtension
1645
- }
1646
- ),
1647
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-main", children: [
1690
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1691
- StablePDFViewer,
1692
- {
1693
- pdfBuffer,
1694
- onPasswordRequest: handlePasswordRequest,
1695
- pdfViewerRef
1696
- }
1697
- ) }),
1698
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
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__ */ _jsxruntime.jsx.call(void 0,
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 = _react.forwardRef.call(void 0, (props, ref) => {
1729
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PDFViewerContent, { ...props, sourceDescription: "doc.pdf", ref });
1730
- });
1731
- PDFViewer.displayName = "PDFViewer";
1732
-
1733
-
1734
-
1735
- exports.PDFViewer = PDFViewer;
1736
- //# sourceMappingURL=chunk-VOLQW3NF.js.map