@cannymindstech/file-viewers 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/chunk-2BLHLWNN.js +299 -0
  2. package/dist/chunk-2BLHLWNN.js.map +1 -0
  3. package/dist/chunk-6BRYDA3B.js +329 -0
  4. package/dist/chunk-6BRYDA3B.js.map +1 -0
  5. package/dist/chunk-6MV4VQQN.mjs +2269 -0
  6. package/dist/chunk-6MV4VQQN.mjs.map +1 -0
  7. package/dist/chunk-7JPF5AYR.mjs +488 -0
  8. package/dist/chunk-7JPF5AYR.mjs.map +1 -0
  9. package/dist/chunk-7LPCKPN2.js +2269 -0
  10. package/dist/chunk-7LPCKPN2.js.map +1 -0
  11. package/dist/chunk-7PMZ4GN5.mjs +290 -0
  12. package/dist/chunk-7PMZ4GN5.mjs.map +1 -0
  13. package/dist/chunk-B5NNB4KD.mjs +268 -0
  14. package/dist/chunk-B5NNB4KD.mjs.map +1 -0
  15. package/dist/chunk-CIWCHSAA.js +309 -0
  16. package/dist/chunk-CIWCHSAA.js.map +1 -0
  17. package/dist/chunk-D7SDEVDM.js +268 -0
  18. package/dist/chunk-D7SDEVDM.js.map +1 -0
  19. package/dist/chunk-ECZ6IBOS.js +424 -0
  20. package/dist/chunk-ECZ6IBOS.js.map +1 -0
  21. package/dist/chunk-EKNP342T.mjs +299 -0
  22. package/dist/chunk-EKNP342T.mjs.map +1 -0
  23. package/dist/chunk-EM63H4SA.js +290 -0
  24. package/dist/chunk-EM63H4SA.js.map +1 -0
  25. package/dist/chunk-IJMNPAXX.mjs +309 -0
  26. package/dist/chunk-IJMNPAXX.mjs.map +1 -0
  27. package/dist/chunk-KJNOBIUZ.mjs +36 -0
  28. package/dist/chunk-KJNOBIUZ.mjs.map +1 -0
  29. package/dist/chunk-KQCU7XW2.mjs +424 -0
  30. package/dist/chunk-KQCU7XW2.mjs.map +1 -0
  31. package/dist/chunk-MJYCPSD4.js +742 -0
  32. package/dist/chunk-MJYCPSD4.js.map +1 -0
  33. package/dist/chunk-OPJOCUSL.js +36 -0
  34. package/dist/chunk-OPJOCUSL.js.map +1 -0
  35. package/dist/chunk-QGL3ZOPD.mjs +742 -0
  36. package/dist/chunk-QGL3ZOPD.mjs.map +1 -0
  37. package/dist/chunk-QV63FULE.js +488 -0
  38. package/dist/chunk-QV63FULE.js.map +1 -0
  39. package/dist/chunk-XJQ5J2UF.mjs +329 -0
  40. package/dist/chunk-XJQ5J2UF.mjs.map +1 -0
  41. package/dist/components/viewers/AudioViewer.d.mts +6 -0
  42. package/dist/components/viewers/AudioViewer.d.ts +6 -0
  43. package/dist/components/viewers/AudioViewer.js +10 -0
  44. package/dist/components/viewers/AudioViewer.js.map +1 -0
  45. package/dist/components/viewers/AudioViewer.mjs +10 -0
  46. package/dist/components/viewers/AudioViewer.mjs.map +1 -0
  47. package/dist/components/viewers/DefaultViewer.d.mts +6 -0
  48. package/dist/components/viewers/DefaultViewer.d.ts +6 -0
  49. package/dist/components/viewers/DefaultViewer.js +10 -0
  50. package/dist/components/viewers/DefaultViewer.js.map +1 -0
  51. package/dist/components/viewers/DefaultViewer.mjs +10 -0
  52. package/dist/components/viewers/DefaultViewer.mjs.map +1 -0
  53. package/dist/components/viewers/ImageViewer.d.mts +6 -0
  54. package/dist/components/viewers/ImageViewer.d.ts +6 -0
  55. package/dist/components/viewers/ImageViewer.js +10 -0
  56. package/dist/components/viewers/ImageViewer.js.map +1 -0
  57. package/dist/components/viewers/ImageViewer.mjs +10 -0
  58. package/dist/components/viewers/ImageViewer.mjs.map +1 -0
  59. package/dist/components/viewers/PDFViewer.d.mts +51 -0
  60. package/dist/components/viewers/PDFViewer.d.ts +51 -0
  61. package/dist/components/viewers/PDFViewer.js +11 -0
  62. package/dist/components/viewers/PDFViewer.js.map +1 -0
  63. package/dist/components/viewers/PDFViewer.mjs +11 -0
  64. package/dist/components/viewers/PDFViewer.mjs.map +1 -0
  65. package/dist/components/viewers/TIFFViewer.d.mts +6 -0
  66. package/dist/components/viewers/TIFFViewer.d.ts +6 -0
  67. package/dist/components/viewers/TIFFViewer.js +10 -0
  68. package/dist/components/viewers/TIFFViewer.js.map +1 -0
  69. package/dist/components/viewers/TIFFViewer.mjs +10 -0
  70. package/dist/components/viewers/TIFFViewer.mjs.map +1 -0
  71. package/dist/components/viewers/TextViewer.d.mts +6 -0
  72. package/dist/components/viewers/TextViewer.d.ts +6 -0
  73. package/dist/components/viewers/TextViewer.js +10 -0
  74. package/dist/components/viewers/TextViewer.js.map +1 -0
  75. package/dist/components/viewers/TextViewer.mjs +10 -0
  76. package/dist/components/viewers/TextViewer.mjs.map +1 -0
  77. package/dist/components/viewers/VideoViewer.d.mts +6 -0
  78. package/dist/components/viewers/VideoViewer.d.ts +6 -0
  79. package/dist/components/viewers/VideoViewer.js +10 -0
  80. package/dist/components/viewers/VideoViewer.js.map +1 -0
  81. package/dist/components/viewers/VideoViewer.mjs +10 -0
  82. package/dist/components/viewers/VideoViewer.mjs.map +1 -0
  83. package/dist/index.d.mts +75 -0
  84. package/dist/index.d.ts +75 -0
  85. package/dist/index.js +305 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/index.mjs +305 -0
  88. package/dist/index.mjs.map +1 -0
  89. package/dist/types-AT684fjV.d.mts +96 -0
  90. package/dist/types-AT684fjV.d.ts +96 -0
  91. package/package.json +45 -0
@@ -0,0 +1,2269 @@
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 _chunkECZ6IBOSjs = require('./chunk-ECZ6IBOS.js');
5
+
6
+
7
+ var _chunkOPJOCUSLjs = require('./chunk-OPJOCUSL.js');
8
+
9
+
10
+
11
+ var _chunkEM63H4SAjs = require('./chunk-EM63H4SA.js');
12
+
13
+ // src/components/viewers/PDFViewer.tsx
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
23
+
24
+ // src/components/viewers/pdf/StablePDFViewer.tsx
25
+
26
+ var _pdfviewer = require('@cannymindstech/pdf-viewer');
27
+ var _jsxruntime = require('react/jsx-runtime');
28
+ var HeadlessPDFViewer = _pdfviewer.PDFViewer;
29
+ var StablePDFViewer = _react2.default.memo(({
30
+ pdfBuffer,
31
+ onPasswordRequest,
32
+ pdfViewerRef,
33
+ showAnnotations,
34
+ userDetails,
35
+ annotationSelectionMenu,
36
+ isHighlighterActive,
37
+ isStampActive,
38
+ onHighlighterClick,
39
+ onStampClick,
40
+ onSignatureClick,
41
+ permissions,
42
+ hideInternalLoading
43
+ }) => {
44
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
45
+ HeadlessPDFViewer,
46
+ {
47
+ ref: pdfViewerRef,
48
+ pdfBuffer,
49
+ onPasswordRequest,
50
+ showAnnotations,
51
+ userDetails,
52
+ annotationSelectionMenu,
53
+ isHighlighterActive,
54
+ isStampActive,
55
+ onHighlighterClick,
56
+ onStampClick,
57
+ onSignatureClick,
58
+ permissions,
59
+ hideInternalLoading
60
+ }
61
+ );
62
+ });
63
+ StablePDFViewer.displayName = "StablePDFViewer";
64
+
65
+ // src/components/viewers/pdf/PDFToolbar.tsx
66
+
67
+ var _material = require('@mui/material');
68
+ var _FirstPage = require('@mui/icons-material/FirstPage'); var _FirstPage2 = _interopRequireDefault(_FirstPage);
69
+ var _LastPage = require('@mui/icons-material/LastPage'); var _LastPage2 = _interopRequireDefault(_LastPage);
70
+ var _ChevronLeft = require('@mui/icons-material/ChevronLeft'); var _ChevronLeft2 = _interopRequireDefault(_ChevronLeft);
71
+ var _ChevronRight = require('@mui/icons-material/ChevronRight'); var _ChevronRight2 = _interopRequireDefault(_ChevronRight);
72
+ var _Remove = require('@mui/icons-material/Remove'); var _Remove2 = _interopRequireDefault(_Remove);
73
+ var _Add = require('@mui/icons-material/Add'); var _Add2 = _interopRequireDefault(_Add);
74
+ var _FitScreen = require('@mui/icons-material/FitScreen'); var _FitScreen2 = _interopRequireDefault(_FitScreen);
75
+ var _AspectRatio = require('@mui/icons-material/AspectRatio'); var _AspectRatio2 = _interopRequireDefault(_AspectRatio);
76
+ var _Tune = require('@mui/icons-material/Tune'); var _Tune2 = _interopRequireDefault(_Tune);
77
+ var _Search = require('@mui/icons-material/Search'); var _Search2 = _interopRequireDefault(_Search);
78
+ var _Fullscreen = require('@mui/icons-material/Fullscreen'); var _Fullscreen2 = _interopRequireDefault(_Fullscreen);
79
+ var _Download = require('@mui/icons-material/Download'); var _Download2 = _interopRequireDefault(_Download);
80
+ var _Print = require('@mui/icons-material/Print'); var _Print2 = _interopRequireDefault(_Print);
81
+ var _Info = require('@mui/icons-material/Info'); var _Info2 = _interopRequireDefault(_Info);
82
+ var _Description = require('@mui/icons-material/Description'); var _Description2 = _interopRequireDefault(_Description);
83
+ var _RotateLeft = require('@mui/icons-material/RotateLeft'); var _RotateLeft2 = _interopRequireDefault(_RotateLeft);
84
+ var _RotateRight = require('@mui/icons-material/RotateRight'); var _RotateRight2 = _interopRequireDefault(_RotateRight);
85
+ var _History = require('@mui/icons-material/History'); var _History2 = _interopRequireDefault(_History);
86
+ var _iconsmaterial = require('@mui/icons-material');
87
+ var _Highlight = require('@mui/icons-material/Highlight'); var _Highlight2 = _interopRequireDefault(_Highlight);
88
+ var _Draw = require('@mui/icons-material/Draw'); var _Draw2 = _interopRequireDefault(_Draw);
89
+ var _Approval = require('@mui/icons-material/Approval'); var _Approval2 = _interopRequireDefault(_Approval);
90
+ var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
91
+ var _Portrait = require('@mui/icons-material/Portrait'); var _Portrait2 = _interopRequireDefault(_Portrait);
92
+ var _SwapVert = require('@mui/icons-material/SwapVert'); var _SwapVert2 = _interopRequireDefault(_SwapVert);
93
+ var _AutoFixHigh = require('@mui/icons-material/AutoFixHigh'); var _AutoFixHigh2 = _interopRequireDefault(_AutoFixHigh);
94
+
95
+ var PDFToolbar = _react2.default.memo(
96
+ ({
97
+ currentPage,
98
+ totalPages,
99
+ zoom,
100
+ isSidebarOpen,
101
+ showPageNavigation,
102
+ showPageCount,
103
+ showZoomControls,
104
+ showSearch,
105
+ showMetadata,
106
+ showProperties,
107
+ showTags,
108
+ showHistory,
109
+ showDownload,
110
+ showPrint,
111
+ showRotation,
112
+ showAnnotations,
113
+ // Destructure new props with defaults
114
+ showAnnotate = true,
115
+ disabledAnnotate = false,
116
+ showPrintOriginal = true,
117
+ showPrintWithAnnotations = true,
118
+ showDownloadOriginal = true,
119
+ showDownloadWithAnnotations = true,
120
+ isHighlighterActive,
121
+ isStampActive,
122
+ disabledRotateLeft,
123
+ disabledRotateRight,
124
+ disabledMetadata,
125
+ disabledProperties,
126
+ disabledTags,
127
+ disabledHistory,
128
+ disabledDownload,
129
+ disabledPrint,
130
+ disabledCopy,
131
+ disabledHighlighter,
132
+ disabledStamp,
133
+ disabledSignature,
134
+ onFirstPage,
135
+ onPreviousPage,
136
+ onNextPage,
137
+ onLastPage,
138
+ onPageInput,
139
+ onPageInputKeyPress,
140
+ onZoomIn,
141
+ onZoomOut,
142
+ onFitToWidth,
143
+ onFitToPage,
144
+ onToggleSidebar,
145
+ onToggleFullScreen,
146
+ onRotateLeft,
147
+ onRotateRight,
148
+ onDownloadClick,
149
+ onDownloadWithAnnotations,
150
+ onDownloadWithoutAnnotations,
151
+ onPrintClick,
152
+ onPrintWithAnnotations,
153
+ onPrintWithoutAnnotations,
154
+ onCopyClick,
155
+ onMetadataClick,
156
+ onPropertiesClick,
157
+ onTagsClick,
158
+ onHistoryClick,
159
+ onHighlighterClick,
160
+ onStampClick,
161
+ onSignatureClick,
162
+ // Save functionality
163
+ hasUnsavedAnnotations,
164
+ isSavingAnnotations,
165
+ canSaveAnnotations,
166
+ onSaveAnnotations
167
+ }) => {
168
+ const [isPrintMenuOpen, setIsPrintMenuOpen] = _react.useState.call(void 0, false);
169
+ const [isDownloadMenuOpen, setIsDownloadMenuOpen] = _react.useState.call(void 0, false);
170
+ const [isAnnotationMenuOpen, setIsAnnotationMenuOpen] = _react.useState.call(void 0, false);
171
+ const [isViewMenuOpen, setIsViewMenuOpen] = _react.useState.call(void 0, false);
172
+ const printMenuRef = _react.useRef.call(void 0, null);
173
+ const downloadMenuRef = _react.useRef.call(void 0, null);
174
+ const annotationMenuRef = _react.useRef.call(void 0, null);
175
+ const viewMenuRef = _react.useRef.call(void 0, null);
176
+ _react.useEffect.call(void 0, () => {
177
+ const handleClickOutside = (event) => {
178
+ if (printMenuRef.current && !printMenuRef.current.contains(event.target)) {
179
+ setIsPrintMenuOpen(false);
180
+ }
181
+ if (downloadMenuRef.current && !downloadMenuRef.current.contains(event.target)) {
182
+ setIsDownloadMenuOpen(false);
183
+ }
184
+ if (annotationMenuRef.current && !annotationMenuRef.current.contains(event.target)) {
185
+ setIsAnnotationMenuOpen(false);
186
+ }
187
+ if (viewMenuRef.current && !viewMenuRef.current.contains(event.target)) {
188
+ setIsViewMenuOpen(false);
189
+ }
190
+ };
191
+ document.addEventListener("mousedown", handleClickOutside);
192
+ return () => document.removeEventListener("mousedown", handleClickOutside);
193
+ }, []);
194
+ const handlePrintWithAnnotations = () => {
195
+ setIsPrintMenuOpen(false);
196
+ _optionalChain([onPrintWithAnnotations, 'optionalCall', _ => _()]);
197
+ };
198
+ const handlePrintWithoutAnnotations = () => {
199
+ setIsPrintMenuOpen(false);
200
+ _optionalChain([onPrintWithoutAnnotations, 'optionalCall', _2 => _2()]);
201
+ };
202
+ const handleDownloadWithAnnotations = () => {
203
+ setIsDownloadMenuOpen(false);
204
+ _optionalChain([onDownloadWithAnnotations, 'optionalCall', _3 => _3()]);
205
+ };
206
+ const handleDownloadWithoutAnnotations = () => {
207
+ setIsDownloadMenuOpen(false);
208
+ _optionalChain([onDownloadWithoutAnnotations, 'optionalCall', _4 => _4()]);
209
+ };
210
+ const [activeMode, setActiveMode] = _react.useState.call(void 0, "view");
211
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar-container", children: [
212
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar", children: [
213
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-left", children: [
214
+ showPageNavigation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
215
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "First Page", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
216
+ "button",
217
+ {
218
+ className: "toolbar-button",
219
+ onClick: onFirstPage,
220
+ disabled: currentPage <= 1,
221
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
222
+ }
223
+ ) }) }),
224
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Previous Page", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
225
+ "button",
226
+ {
227
+ className: "toolbar-button",
228
+ onClick: onPreviousPage,
229
+ disabled: currentPage <= 1,
230
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
231
+ }
232
+ ) }) }),
233
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "page-info", style: { display: "flex", alignItems: "center", margin: "0 8px", fontSize: "14px", fontWeight: 500 }, children: [
234
+ currentPage,
235
+ " ",
236
+ showPageCount && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { style: { color: "#6b7280", marginLeft: "4px" }, children: [
237
+ "/ ",
238
+ totalPages || "..."
239
+ ] })
240
+ ] }),
241
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Next Page", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
242
+ "button",
243
+ {
244
+ className: "toolbar-button",
245
+ onClick: onNextPage,
246
+ disabled: currentPage >= totalPages,
247
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
248
+ }
249
+ ) }) }),
250
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Last Page", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
251
+ "button",
252
+ {
253
+ className: "toolbar-button",
254
+ onClick: onLastPage,
255
+ disabled: currentPage >= totalPages,
256
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
257
+ }
258
+ ) }) })
259
+ ] }),
260
+ showZoomControls && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
261
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
262
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
263
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Zoom Out", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
264
+ "button",
265
+ {
266
+ className: "toolbar-button",
267
+ onClick: onZoomOut,
268
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Remove2.default, { fontSize: "small" })
269
+ }
270
+ ) }),
271
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "zoom-display", children: [
272
+ zoom,
273
+ "%"
274
+ ] }),
275
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Zoom In", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
276
+ "button",
277
+ {
278
+ className: "toolbar-button",
279
+ onClick: onZoomIn,
280
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Add2.default, { fontSize: "small" })
281
+ }
282
+ ) })
283
+ ] })
284
+ ] }),
285
+ (showZoomControls || showRotation) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
286
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
287
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-dropdown-container", ref: viewMenuRef, children: [
288
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "View Options", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
289
+ "button",
290
+ {
291
+ className: `toolbar-button toolbar-dropdown-button ${isViewMenuOpen ? "toolbar-button-active" : ""}`,
292
+ onClick: () => setIsViewMenuOpen(!isViewMenuOpen),
293
+ children: [
294
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Tune2.default, { fontSize: "small" }),
295
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { fontSize: "small", style: { marginLeft: -4 } })
296
+ ]
297
+ }
298
+ ) }),
299
+ isViewMenuOpen && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-dropdown-menu", style: { width: "240px" }, children: [
300
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-header", children: "SPREAD MODE" }),
301
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { className: "toolbar-dropdown-item toolbar-dropdown-item-active", onClick: () => setIsViewMenuOpen(false), children: [
302
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Portrait2.default, { fontSize: "small" }),
303
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Single Page" })
304
+ ] }),
305
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-divider" }),
306
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-header", children: "SCROLL LAYOUT" }),
307
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { className: "toolbar-dropdown-item toolbar-dropdown-item-active", onClick: () => setIsViewMenuOpen(false), children: [
308
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _SwapVert2.default, { fontSize: "small" }),
309
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Vertical" })
310
+ ] }),
311
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-divider" }),
312
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { className: "toolbar-dropdown-item", onClick: () => {
313
+ setIsViewMenuOpen(false);
314
+ _optionalChain([onFitToWidth, 'optionalCall', _5 => _5()]);
315
+ }, children: [
316
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" }),
317
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Fit to Width" })
318
+ ] }),
319
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { className: "toolbar-dropdown-item", onClick: () => {
320
+ setIsViewMenuOpen(false);
321
+ _optionalChain([onFitToPage, 'optionalCall', _6 => _6()]);
322
+ }, children: [
323
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" }),
324
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Fit to Page" })
325
+ ] }),
326
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-divider" }),
327
+ showRotation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
328
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-header", children: "PAGE ROTATION" }),
329
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
330
+ "button",
331
+ {
332
+ className: "toolbar-dropdown-item",
333
+ onClick: () => {
334
+ setIsViewMenuOpen(false);
335
+ _optionalChain([onRotateRight, 'optionalCall', _7 => _7()]);
336
+ },
337
+ disabled: false,
338
+ children: [
339
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _RotateRight2.default, { fontSize: "small" }),
340
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Rotate Clockwise" })
341
+ ]
342
+ }
343
+ ),
344
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
345
+ "button",
346
+ {
347
+ className: "toolbar-dropdown-item",
348
+ onClick: () => {
349
+ setIsViewMenuOpen(false);
350
+ _optionalChain([onRotateLeft, 'optionalCall', _8 => _8()]);
351
+ },
352
+ disabled: disabledRotateLeft,
353
+ children: [
354
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _RotateLeft2.default, { fontSize: "small" }),
355
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Rotate Counter-Clockwise" })
356
+ ]
357
+ }
358
+ )
359
+ ] }),
360
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-divider" }),
361
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
362
+ "button",
363
+ {
364
+ className: "toolbar-dropdown-item",
365
+ onClick: () => {
366
+ setIsViewMenuOpen(false);
367
+ onToggleFullScreen();
368
+ },
369
+ children: [
370
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Fullscreen2.default, { fontSize: "small" }),
371
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Fullscreen" })
372
+ ]
373
+ }
374
+ )
375
+ ] })
376
+ ] }) })
377
+ ] }),
378
+ showSearch && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
379
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
380
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Search", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
381
+ "button",
382
+ {
383
+ className: `toolbar-button ${isSidebarOpen ? "toolbar-button-active" : ""}`,
384
+ onClick: onToggleSidebar,
385
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { fontSize: "small" })
386
+ }
387
+ ) }) })
388
+ ] })
389
+ ] }),
390
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-center", children: [
391
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
392
+ "button",
393
+ {
394
+ className: `toolbar-tab ${activeMode === "view" ? "toolbar-tab-active" : ""}`,
395
+ onClick: () => setActiveMode("view"),
396
+ children: "View"
397
+ }
398
+ ),
399
+ showAnnotate && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
400
+ "button",
401
+ {
402
+ className: `toolbar-tab ${activeMode === "annotate" ? "toolbar-tab-active" : ""}`,
403
+ onClick: () => !disabledAnnotate && setActiveMode("annotate"),
404
+ style: {
405
+ position: "relative",
406
+ opacity: disabledAnnotate ? 0.5 : 1,
407
+ cursor: disabledAnnotate ? "not-allowed" : "pointer"
408
+ },
409
+ children: [
410
+ "Annotate",
411
+ hasUnsavedAnnotations && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: {
412
+ position: "absolute",
413
+ top: "4px",
414
+ right: "4px",
415
+ width: "6px",
416
+ height: "6px",
417
+ backgroundColor: "#ef4444",
418
+ borderRadius: "50%"
419
+ } })
420
+ ]
421
+ }
422
+ )
423
+ ] }),
424
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-right", children: (hasUnsavedAnnotations || showDownload || showPrint || showMetadata || showProperties || showTags || showHistory) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
425
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
426
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
427
+ showDownload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-container", ref: downloadMenuRef, children: showDownloadOriginal && showDownloadWithAnnotations ? (
428
+ // RENDER DROPDOWN if BOTH are enabled
429
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
430
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Download", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
431
+ "button",
432
+ {
433
+ className: `toolbar-button toolbar-dropdown-button ${isDownloadMenuOpen ? "toolbar-button-active" : ""}`,
434
+ onClick: () => setIsDownloadMenuOpen(!isDownloadMenuOpen),
435
+ disabled: disabledDownload,
436
+ children: [
437
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" }),
438
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { fontSize: "small", style: { marginLeft: -4 } })
439
+ ]
440
+ }
441
+ ) }) }),
442
+ isDownloadMenuOpen && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-dropdown-menu toolbar-dropdown-menu-right", children: [
443
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
444
+ "button",
445
+ {
446
+ className: "toolbar-dropdown-item",
447
+ onClick: handleDownloadWithoutAnnotations,
448
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Download Document Only" })
449
+ }
450
+ ),
451
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
452
+ "button",
453
+ {
454
+ className: "toolbar-dropdown-item",
455
+ onClick: handleDownloadWithAnnotations,
456
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Download with Annotations" })
457
+ }
458
+ )
459
+ ] })
460
+ ] })
461
+ ) : (
462
+ // RENDER SINGLE BUTTON if ONLY ONE is enabled
463
+ (showDownloadOriginal || showDownloadWithAnnotations) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Download", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
464
+ "button",
465
+ {
466
+ className: "toolbar-button",
467
+ onClick: showDownloadOriginal ? handleDownloadWithoutAnnotations : handleDownloadWithAnnotations,
468
+ disabled: disabledDownload,
469
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
470
+ }
471
+ ) }) })
472
+ ) }),
473
+ showPrint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-dropdown-container", ref: printMenuRef, children: showPrintOriginal && showPrintWithAnnotations ? (
474
+ // RENDER DROPDOWN if BOTH are enabled
475
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
476
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Print", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
477
+ "button",
478
+ {
479
+ className: `toolbar-button toolbar-dropdown-button ${isPrintMenuOpen ? "toolbar-button-active" : ""}`,
480
+ onClick: () => setIsPrintMenuOpen(!isPrintMenuOpen),
481
+ disabled: disabledPrint,
482
+ children: [
483
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" }),
484
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { fontSize: "small", style: { marginLeft: -4 } })
485
+ ]
486
+ }
487
+ ) }) }),
488
+ isPrintMenuOpen && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-dropdown-menu toolbar-dropdown-menu-right", children: [
489
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
490
+ "button",
491
+ {
492
+ className: "toolbar-dropdown-item",
493
+ onClick: handlePrintWithoutAnnotations,
494
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Print Document Only" })
495
+ }
496
+ ),
497
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
498
+ "button",
499
+ {
500
+ className: "toolbar-dropdown-item",
501
+ onClick: handlePrintWithAnnotations,
502
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Print with Annotations" })
503
+ }
504
+ )
505
+ ] })
506
+ ] })
507
+ ) : (
508
+ // RENDER SINGLE BUTTON if ONLY ONE is enabled
509
+ (showPrintOriginal || showPrintWithAnnotations) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Print", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
510
+ "button",
511
+ {
512
+ className: "toolbar-button",
513
+ onClick: showPrintOriginal ? handlePrintWithoutAnnotations : handlePrintWithAnnotations,
514
+ disabled: disabledPrint,
515
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
516
+ }
517
+ ) }) })
518
+ ) }),
519
+ showMetadata && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Metadata", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
520
+ "button",
521
+ {
522
+ className: "toolbar-button",
523
+ onClick: onMetadataClick,
524
+ disabled: disabledMetadata,
525
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
526
+ }
527
+ ) }) }),
528
+ showProperties && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Properties", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
529
+ "button",
530
+ {
531
+ className: "toolbar-button",
532
+ onClick: onPropertiesClick,
533
+ disabled: disabledProperties,
534
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
535
+ }
536
+ ) }) }),
537
+ showTags && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Tags", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
538
+ "button",
539
+ {
540
+ className: "toolbar-button",
541
+ onClick: onTagsClick,
542
+ disabled: disabledTags,
543
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsmaterial.LocalOffer, { fontSize: "small" })
544
+ }
545
+ ) }) }),
546
+ showHistory && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Version History", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
547
+ "button",
548
+ {
549
+ className: "toolbar-button",
550
+ onClick: onHistoryClick,
551
+ disabled: disabledHistory,
552
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _History2.default, { fontSize: "small" })
553
+ }
554
+ ) }) })
555
+ ] })
556
+ ] }) })
557
+ ] }),
558
+ activeMode === "annotate" && showAnnotations && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-secondary-toolbar", children: [
559
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Highlight", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
560
+ "button",
561
+ {
562
+ className: `toolbar-button ${isHighlighterActive ? "toolbar-button-active" : ""}`,
563
+ onClick: onHighlighterClick,
564
+ disabled: disabledHighlighter,
565
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Highlight2.default, { fontSize: "small" })
566
+ }
567
+ ) }) }),
568
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Stamp", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
569
+ "button",
570
+ {
571
+ className: `toolbar-button ${isStampActive ? "toolbar-button-active" : ""}`,
572
+ onClick: onStampClick,
573
+ disabled: disabledStamp,
574
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Approval2.default, { fontSize: "small" })
575
+ }
576
+ ) }) }),
577
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Signature", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
578
+ "button",
579
+ {
580
+ className: "toolbar-button",
581
+ onClick: onSignatureClick,
582
+ disabled: disabledSignature,
583
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Draw2.default, { fontSize: "small" })
584
+ }
585
+ ) }) }),
586
+ hasUnsavedAnnotations && canSaveAnnotations !== false && onSaveAnnotations && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
587
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { width: 1, height: 24, backgroundColor: "#e5e7eb", margin: "0 8px" } }),
588
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Save Annotations", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
589
+ "button",
590
+ {
591
+ className: "toolbar-button",
592
+ onClick: onSaveAnnotations,
593
+ disabled: isSavingAnnotations,
594
+ style: {
595
+ color: hasUnsavedAnnotations ? "#2563eb" : "inherit",
596
+ padding: "6px 16px",
597
+ border: hasUnsavedAnnotations ? "1px solid #2563eb" : "1px solid transparent",
598
+ borderRadius: "6px",
599
+ display: "flex",
600
+ alignItems: "center",
601
+ gap: "6px",
602
+ backgroundColor: hasUnsavedAnnotations ? "#eff6ff" : "transparent",
603
+ fontSize: "14px",
604
+ fontWeight: 500,
605
+ width: "auto",
606
+ cursor: isSavingAnnotations ? "not-allowed" : "pointer"
607
+ },
608
+ children: [
609
+ isSavingAnnotations ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 24 24", style: { animation: "spin 1s linear infinite" }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "3", fill: "none", strokeDasharray: "31.4", strokeDashoffset: "10" }) }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
610
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" }),
611
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "polyline", { points: "17 21 17 13 7 13 7 21" }),
612
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "polyline", { points: "7 3 7 8 15 8" })
613
+ ] }),
614
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: isSavingAnnotations ? "Saving..." : "Save" })
615
+ ]
616
+ }
617
+ ) }) })
618
+ ] })
619
+ ] }),
620
+ activeMode === "redact" && showAnnotations && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-secondary-toolbar", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Tooltip, { title: "Redact Text", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { className: "toolbar-button", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AutoFixHigh2.default, { fontSize: "small" }) }) }) })
621
+ ] });
622
+ }
623
+ );
624
+ PDFToolbar.displayName = "PDFToolbar";
625
+
626
+ // src/components/viewers/pdf/PDFHeader.tsx
627
+
628
+
629
+ var PDFHeader = _react2.default.memo(({ fileName, fileExtension }) => {
630
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-header", children: [
631
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkEM63H4SAjs.FileIcon_default, { ext: fileExtension, size: 26 }),
632
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "header-file-name", title: fileName, children: fileName })
633
+ ] });
634
+ });
635
+ PDFHeader.displayName = "PDFHeader";
636
+
637
+ // src/components/viewers/pdf/SearchSidebar.tsx
638
+
639
+
640
+
641
+
642
+
643
+
644
+
645
+
646
+
647
+
648
+
649
+ var _Close = require('@mui/icons-material/Close'); var _Close2 = _interopRequireDefault(_Close);
650
+ var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _KeyboardArrowUp2 = _interopRequireDefault(_KeyboardArrowUp);
651
+
652
+ var _Clear = require('@mui/icons-material/Clear'); var _Clear2 = _interopRequireDefault(_Clear);
653
+ var _FindInPage = require('@mui/icons-material/FindInPage'); var _FindInPage2 = _interopRequireDefault(_FindInPage);
654
+
655
+ var SearchSidebar = ({
656
+ isOpen,
657
+ onClose,
658
+ onSearch,
659
+ onSearchResultClick,
660
+ onNextResult,
661
+ onPreviousResult,
662
+ currentResultIndex,
663
+ totalResults,
664
+ searchKeyword,
665
+ searchResults = [],
666
+ isSearching = false,
667
+ isSyntheticResults = false
668
+ }) => {
669
+ const [searchTerm, setSearchTerm] = _react.useState.call(void 0, searchKeyword || "");
670
+ const [hasSearched, setHasSearched] = _react.useState.call(void 0, false);
671
+ const contentRef = _react.useRef.call(void 0, null);
672
+ _react.useEffect.call(void 0, () => {
673
+ if (searchKeyword && searchKeyword !== searchTerm) {
674
+ setSearchTerm(searchKeyword);
675
+ }
676
+ }, [searchKeyword]);
677
+ _react.useLayoutEffect.call(void 0, () => {
678
+ const element = contentRef.current;
679
+ if (!element) return;
680
+ const handleMouseMove = (e) => {
681
+ const rect = element.getBoundingClientRect();
682
+ const distanceFromRight = rect.right - e.clientX;
683
+ const distanceFromBottom = rect.bottom - e.clientY;
684
+ if (distanceFromRight <= 15 || distanceFromBottom <= 15) {
685
+ element.classList.add("scrollbar-hover");
686
+ } else {
687
+ element.classList.remove("scrollbar-hover");
688
+ }
689
+ };
690
+ const handleMouseLeave = () => element.classList.remove("scrollbar-hover");
691
+ element.addEventListener("mousemove", handleMouseMove);
692
+ element.addEventListener("mouseleave", handleMouseLeave);
693
+ return () => {
694
+ element.removeEventListener("mousemove", handleMouseMove);
695
+ element.removeEventListener("mouseleave", handleMouseLeave);
696
+ };
697
+ }, []);
698
+ _react.useLayoutEffect.call(void 0, () => {
699
+ const style = document.createElement("style");
700
+ style.id = "search-sidebar-scrollbar";
701
+ style.textContent = `
702
+ @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;600&family=Noto+Sans+Devanagari:wght@400;600&display=swap');
703
+
704
+ .search-sidebar-content::-webkit-scrollbar {
705
+ width: 12px;
706
+ height: 12px;
707
+ }
708
+ .search-sidebar-content::-webkit-scrollbar-track {
709
+ background-color: transparent;
710
+ }
711
+ .search-sidebar-content::-webkit-scrollbar-thumb {
712
+ background-color: rgba(128, 128, 128, 0.3);
713
+ border-radius: 8px;
714
+ border: 4px solid transparent;
715
+ background-clip: padding-box;
716
+ transition: all 0.15s ease;
717
+ }
718
+ .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
719
+ background-color: rgba(128, 128, 128, 0.5);
720
+ border: 2px solid transparent;
721
+ }
722
+ .search-sidebar-content::-webkit-scrollbar-thumb:active {
723
+ background-color: rgba(25, 118, 210, 0.8);
724
+ border: 1px solid transparent;
725
+ }
726
+
727
+ @media (prefers-color-scheme: dark) {
728
+ .search-sidebar-content::-webkit-scrollbar-thumb {
729
+ background-color: rgba(255, 255, 255, 0.2);
730
+ }
731
+ .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
732
+ background-color: rgba(255, 255, 255, 0.35);
733
+ }
734
+ }
735
+
736
+ /* Tamil font support for search results */
737
+ .search-result-text {
738
+ font-family: 'Noto Sans Tamil', 'Noto Sans Devanagari', Arial, sans-serif !important;
739
+ }
740
+ `;
741
+ document.head.appendChild(style);
742
+ return () => {
743
+ const el = document.getElementById("search-sidebar-scrollbar");
744
+ if (el) el.remove();
745
+ };
746
+ }, []);
747
+ _react.useLayoutEffect.call(void 0, () => {
748
+ setSearchTerm(searchKeyword || "");
749
+ if (searchKeyword || searchResults.length > 0) {
750
+ setHasSearched(true);
751
+ }
752
+ }, [searchKeyword, searchResults]);
753
+ const handleSearchSubmit = (e) => {
754
+ if (e) e.preventDefault();
755
+ if (searchTerm.trim()) {
756
+ setHasSearched(true);
757
+ onSearch(searchTerm.trim());
758
+ }
759
+ };
760
+ const handleSearchChange = (e) => {
761
+ const value = e.target.value;
762
+ setSearchTerm(value);
763
+ if (!value.trim()) {
764
+ setHasSearched(false);
765
+ onSearch("");
766
+ }
767
+ };
768
+ const handleClearSearch = () => {
769
+ setSearchTerm("");
770
+ setHasSearched(false);
771
+ onSearch("");
772
+ };
773
+ const resultsByPage = searchResults.reduce((acc, result) => {
774
+ if (!acc[result.pageNumber]) {
775
+ acc[result.pageNumber] = [];
776
+ }
777
+ acc[result.pageNumber].push(result);
778
+ return acc;
779
+ }, {});
780
+ const highlightText = (text, keyword) => {
781
+ if (!keyword) return text;
782
+ const textString = typeof text === "string" ? text : String(text || "");
783
+ if (!textString) return text;
784
+ try {
785
+ const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
786
+ const regex = new RegExp(`(${escapedKeyword})`, "gi");
787
+ const parts = textString.split(regex);
788
+ return parts.map(
789
+ (part, index) => regex.test(part) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
790
+ _material.Box,
791
+ {
792
+ component: "span",
793
+ sx: {
794
+ color: "primary.main",
795
+ fontWeight: 600,
796
+ fontSize: "inherit"
797
+ },
798
+ children: part
799
+ },
800
+ index
801
+ ) : part
802
+ );
803
+ } catch (error) {
804
+ return textString;
805
+ }
806
+ };
807
+ if (!isOpen) return null;
808
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
809
+ _material.Box,
810
+ {
811
+ sx: {
812
+ display: "flex",
813
+ flexDirection: "column",
814
+ height: "100%",
815
+ width: "320px",
816
+ backgroundColor: "background.paper",
817
+ borderLeft: "1px solid",
818
+ borderColor: "divider",
819
+ overflow: "hidden"
820
+ },
821
+ children: [
822
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { px: 3, py: 2.5, backgroundColor: "background.default" }, children: [
823
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [
824
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", sx: { fontSize: "1.125rem", fontWeight: 600, color: "text.primary" }, children: "Search" }),
825
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
826
+ _material.IconButton,
827
+ {
828
+ size: "small",
829
+ onClick: onClose,
830
+ sx: {
831
+ color: "text.secondary",
832
+ padding: "6px"
833
+ },
834
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Close2.default, { fontSize: "small" })
835
+ }
836
+ )
837
+ ] }),
838
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { onSubmit: handleSearchSubmit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
839
+ _material.TextField,
840
+ {
841
+ fullWidth: true,
842
+ size: "medium",
843
+ placeholder: "Search in document...",
844
+ value: searchTerm,
845
+ onChange: handleSearchChange,
846
+ autoComplete: "off",
847
+ InputProps: {
848
+ 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 } }) }),
849
+ endAdornment: searchTerm && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
850
+ _material.IconButton,
851
+ {
852
+ size: "small",
853
+ onClick: handleClearSearch,
854
+ sx: {
855
+ color: "text.secondary",
856
+ padding: "4px",
857
+ "&:hover": {
858
+ backgroundColor: "action.hover"
859
+ }
860
+ },
861
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Clear2.default, { sx: { fontSize: 18 } })
862
+ }
863
+ ) })
864
+ },
865
+ sx: {
866
+ "& .MuiOutlinedInput-root": {
867
+ fontSize: "0.9375rem",
868
+ backgroundColor: "background.paper",
869
+ borderRadius: "8px",
870
+ "& fieldset": {
871
+ borderColor: "divider"
872
+ },
873
+ "&.Mui-focused fieldset": {
874
+ borderColor: "primary.main",
875
+ borderWidth: "2px"
876
+ }
877
+ },
878
+ "& .MuiInputBase-input": {
879
+ padding: "10px 14px"
880
+ }
881
+ }
882
+ }
883
+ ) }),
884
+ totalResults > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
885
+ _material.Box,
886
+ {
887
+ sx: {
888
+ display: "flex",
889
+ alignItems: "center",
890
+ justifyContent: "space-between",
891
+ mt: 2,
892
+ pt: 2,
893
+ borderTop: "1px solid",
894
+ borderColor: "divider"
895
+ },
896
+ children: [
897
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", fontSize: "0.875rem", fontWeight: 500 }, children: [
898
+ currentResultIndex + 1,
899
+ " of ",
900
+ totalResults,
901
+ " results"
902
+ ] }),
903
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
904
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
905
+ _material.IconButton,
906
+ {
907
+ size: "small",
908
+ onClick: onPreviousResult,
909
+ disabled: currentResultIndex <= 0,
910
+ sx: {
911
+ color: currentResultIndex <= 0 ? "text.disabled" : "primary.main",
912
+ padding: "6px",
913
+ borderRadius: "6px",
914
+ border: "1px solid",
915
+ borderColor: currentResultIndex <= 0 ? "divider" : "primary.main"
916
+ },
917
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowUp2.default, { sx: { fontSize: 20 } })
918
+ }
919
+ ),
920
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
921
+ _material.IconButton,
922
+ {
923
+ size: "small",
924
+ onClick: onNextResult,
925
+ disabled: currentResultIndex >= totalResults - 1,
926
+ sx: {
927
+ color: currentResultIndex >= totalResults - 1 ? "text.disabled" : "primary.main",
928
+ padding: "6px",
929
+ borderRadius: "6px",
930
+ border: "1px solid",
931
+ borderColor: currentResultIndex >= totalResults - 1 ? "divider" : "primary.main"
932
+ },
933
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _KeyboardArrowDown2.default, { sx: { fontSize: 20 } })
934
+ }
935
+ )
936
+ ] })
937
+ ]
938
+ }
939
+ )
940
+ ] }),
941
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Divider, {}),
942
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { ref: contentRef, className: "search-sidebar-content", sx: {
943
+ flex: 1,
944
+ overflow: "auto",
945
+ backgroundColor: "background.default"
946
+ }, children: [
947
+ !searchTerm && !hasSearched && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
948
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
949
+ _material.Box,
950
+ {
951
+ sx: {
952
+ width: 80,
953
+ height: 80,
954
+ borderRadius: "50%",
955
+ backgroundColor: "action.hover",
956
+ display: "flex",
957
+ alignItems: "center",
958
+ justifyContent: "center",
959
+ margin: "0 auto",
960
+ mb: 3
961
+ },
962
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "text.disabled" } })
963
+ }
964
+ ),
965
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
966
+ /* @__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" })
967
+ ] }),
968
+ searchTerm && !hasSearched && !isSearching && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
969
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
970
+ _material.Box,
971
+ {
972
+ sx: {
973
+ width: 80,
974
+ height: 80,
975
+ borderRadius: "50%",
976
+ backgroundColor: "primary.light",
977
+ display: "flex",
978
+ alignItems: "center",
979
+ justifyContent: "center",
980
+ margin: "0 auto",
981
+ mb: 3,
982
+ opacity: 0.2
983
+ },
984
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FindInPage2.default, { sx: { fontSize: 40, color: "primary.main" } })
985
+ }
986
+ ),
987
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Ready to Search" }),
988
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", mb: 2, lineHeight: 1.6 }, children: "Press Enter to find" }),
989
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
990
+ _material.Typography,
991
+ {
992
+ variant: "body2",
993
+ sx: {
994
+ color: "white",
995
+ fontWeight: 600,
996
+ backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(144, 202, 249, 0.16)" : "primary.light",
997
+ padding: "6px 16px",
998
+ borderRadius: "16px",
999
+ display: "inline-block",
1000
+ opacity: 0.9
1001
+ },
1002
+ children: [
1003
+ '"',
1004
+ searchTerm,
1005
+ '"'
1006
+ ]
1007
+ }
1008
+ )
1009
+ ] }),
1010
+ isSearching && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
1011
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1012
+ _material.Box,
1013
+ {
1014
+ sx: {
1015
+ display: "flex",
1016
+ alignItems: "center",
1017
+ justifyContent: "center",
1018
+ margin: "0 auto",
1019
+ mb: 3
1020
+ },
1021
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { size: 60, thickness: 4 })
1022
+ }
1023
+ ),
1024
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Searching..." }),
1025
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
1026
+ 'Finding matches for "',
1027
+ searchTerm,
1028
+ '"'
1029
+ ] })
1030
+ ] }),
1031
+ hasSearched && totalResults === 0 && !isSearching && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
1032
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1033
+ _material.Box,
1034
+ {
1035
+ sx: {
1036
+ width: 80,
1037
+ height: 80,
1038
+ borderRadius: "50%",
1039
+ backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(255, 152, 0, 0.12)" : "warning.light",
1040
+ display: "flex",
1041
+ alignItems: "center",
1042
+ justifyContent: "center",
1043
+ margin: "0 auto",
1044
+ mb: 3,
1045
+ opacity: 0.6
1046
+ },
1047
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "warning.main" } })
1048
+ }
1049
+ ),
1050
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
1051
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
1052
+ "No matches found for ",
1053
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
1054
+ '"',
1055
+ searchTerm,
1056
+ '"'
1057
+ ] })
1058
+ ] })
1059
+ ] }),
1060
+ 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) => {
1061
+ const pageNumber = parseInt(pageNum);
1062
+ const pageResults = resultsByPage[pageNumber];
1063
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { mb: 3 }, children: [
1064
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1065
+ _material.Typography,
1066
+ {
1067
+ variant: "subtitle2",
1068
+ sx: {
1069
+ color: "text.secondary",
1070
+ mb: 1.5,
1071
+ px: 1,
1072
+ fontSize: "0.8125rem",
1073
+ fontWeight: 600,
1074
+ textTransform: "uppercase",
1075
+ letterSpacing: "0.5px"
1076
+ },
1077
+ children: [
1078
+ "Page ",
1079
+ pageNumber
1080
+ ]
1081
+ }
1082
+ ),
1083
+ pageResults.map((result, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1084
+ _material.Box,
1085
+ {
1086
+ onClick: () => onSearchResultClick(result.pageNumber, result.index),
1087
+ sx: {
1088
+ p: 2,
1089
+ mx: 1,
1090
+ mb: 1.5,
1091
+ borderRadius: "8px",
1092
+ border: "2px solid",
1093
+ borderColor: result.index === currentResultIndex ? "primary.main" : "divider",
1094
+ backgroundColor: "background.paper",
1095
+ cursor: "pointer",
1096
+ transition: "all 0.2s ease",
1097
+ boxShadow: (theme) => theme.palette.mode === "dark" ? "0 1px 3px rgba(0, 0, 0, 0.3)" : "0 1px 3px rgba(0, 0, 0, 0.05)",
1098
+ "&:hover": {
1099
+ borderColor: "primary.main",
1100
+ boxShadow: (theme) => theme.palette.mode === "dark" ? "0 2px 8px rgba(255, 255, 255, 0.15)" : "0 2px 8px rgba(0, 0, 0, 0.1)",
1101
+ transform: "translateY(-1px)"
1102
+ }
1103
+ },
1104
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1105
+ _material.Typography,
1106
+ {
1107
+ variant: "body2",
1108
+ className: "search-result-text",
1109
+ sx: {
1110
+ fontSize: "0.875rem",
1111
+ lineHeight: 1.6,
1112
+ color: result.index === currentResultIndex ? "text.primary" : "text.secondary"
1113
+ },
1114
+ children: highlightText(result.context, searchTerm)
1115
+ }
1116
+ )
1117
+ },
1118
+ index
1119
+ ))
1120
+ ] }, pageNumber);
1121
+ }) })
1122
+ ] })
1123
+ ]
1124
+ }
1125
+ );
1126
+ };
1127
+
1128
+ // src/components/viewers/pdf/PasswordDialog.tsx
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+
1136
+
1137
+
1138
+
1139
+
1140
+
1141
+
1142
+
1143
+
1144
+ var _Lock = require('@mui/icons-material/Lock'); var _Lock2 = _interopRequireDefault(_Lock);
1145
+ var _Visibility = require('@mui/icons-material/Visibility'); var _Visibility2 = _interopRequireDefault(_Visibility);
1146
+ var _VisibilityOff = require('@mui/icons-material/VisibilityOff'); var _VisibilityOff2 = _interopRequireDefault(_VisibilityOff);
1147
+
1148
+ var PasswordDialog = ({
1149
+ open,
1150
+ fileName,
1151
+ onSubmit,
1152
+ onCancel,
1153
+ error,
1154
+ isLoading = false
1155
+ }) => {
1156
+ const [password, setPassword] = _react.useState.call(void 0, "");
1157
+ const [showPassword, setShowPassword] = _react.useState.call(void 0, false);
1158
+ _react.useEffect.call(void 0, () => {
1159
+ if (open && !isLoading) {
1160
+ if (error) {
1161
+ setPassword("");
1162
+ }
1163
+ }
1164
+ }, [open, error, isLoading]);
1165
+ _react.useEffect.call(void 0, () => {
1166
+ if (open) {
1167
+ setShowPassword(false);
1168
+ if (!error) {
1169
+ setPassword("");
1170
+ }
1171
+ }
1172
+ }, [open]);
1173
+ const handleSubmit = (e) => {
1174
+ e.preventDefault();
1175
+ if (password.trim() && !isLoading) {
1176
+ onSubmit(password);
1177
+ }
1178
+ };
1179
+ const handleTogglePasswordVisibility = () => {
1180
+ setShowPassword(!showPassword);
1181
+ };
1182
+ const handleKeyPress = (e) => {
1183
+ if (e.key === "Enter" && password.trim() && !isLoading) {
1184
+ handleSubmit(e);
1185
+ }
1186
+ };
1187
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1188
+ _material.Dialog,
1189
+ {
1190
+ open,
1191
+ disableEscapeKeyDown: true,
1192
+ onClose: (event, reason) => {
1193
+ if (reason === "backdropClick") return;
1194
+ },
1195
+ maxWidth: "sm",
1196
+ fullWidth: true,
1197
+ slotProps: {
1198
+ backdrop: {
1199
+ sx: {
1200
+ backdropFilter: "blur(8px)",
1201
+ backgroundColor: "rgba(0, 0, 0, 0.6)"
1202
+ }
1203
+ }
1204
+ },
1205
+ PaperProps: {
1206
+ sx: {
1207
+ borderRadius: 2
1208
+ }
1209
+ },
1210
+ children: [
1211
+ /* @__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", gap: 1.5 }, children: [
1212
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1213
+ _material.Box,
1214
+ {
1215
+ sx: {
1216
+ width: 40,
1217
+ height: 40,
1218
+ borderRadius: "50%",
1219
+ backgroundColor: "primary.light",
1220
+ display: "flex",
1221
+ alignItems: "center",
1222
+ justifyContent: "center",
1223
+ opacity: 0.9
1224
+ },
1225
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Lock2.default, { sx: { color: "white", fontSize: 20 } })
1226
+ }
1227
+ ),
1228
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
1229
+ ] }) }),
1230
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogContent, { sx: { pt: 2 }, children: [
1231
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
1232
+ "This PDF is password protected. Please enter the password to view",
1233
+ " ",
1234
+ fileName && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
1235
+ '"',
1236
+ fileName,
1237
+ '"'
1238
+ ] })
1239
+ ] }),
1240
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Alert, { severity: "error", sx: { mb: 2 }, children: error }),
1241
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { onSubmit: handleSubmit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1242
+ _material.TextField,
1243
+ {
1244
+ fullWidth: true,
1245
+ autoFocus: true,
1246
+ type: showPassword ? "text" : "password",
1247
+ label: "Password",
1248
+ placeholder: "Enter password",
1249
+ value: password,
1250
+ onChange: (e) => setPassword(e.target.value),
1251
+ onKeyPress: handleKeyPress,
1252
+ error: Boolean(error),
1253
+ disabled: isLoading,
1254
+ InputProps: {
1255
+ endAdornment: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1256
+ _material.IconButton,
1257
+ {
1258
+ onClick: handleTogglePasswordVisibility,
1259
+ edge: "end",
1260
+ size: "small",
1261
+ "aria-label": showPassword ? "Hide password" : "Show password",
1262
+ disabled: isLoading,
1263
+ children: showPassword ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VisibilityOff2.default, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Visibility2.default, {})
1264
+ }
1265
+ ) })
1266
+ },
1267
+ sx: {
1268
+ "& .MuiOutlinedInput-root": {
1269
+ borderRadius: 2
1270
+ }
1271
+ }
1272
+ }
1273
+ ) })
1274
+ ] }),
1275
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1276
+ _material.Button,
1277
+ {
1278
+ onClick: handleSubmit,
1279
+ variant: "contained",
1280
+ disabled: !password.trim() || isLoading,
1281
+ sx: {
1282
+ borderRadius: 2,
1283
+ textTransform: "none",
1284
+ px: 3,
1285
+ boxShadow: 2,
1286
+ minWidth: 120
1287
+ },
1288
+ children: isLoading ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1289
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { size: 16, color: "inherit", sx: { mr: 1 } }),
1290
+ "Verifying..."
1291
+ ] }) : "Unlock PDF"
1292
+ }
1293
+ ) })
1294
+ ]
1295
+ }
1296
+ );
1297
+ };
1298
+
1299
+ // src/components/viewers/PDFViewer.tsx
1300
+
1301
+ var PDFViewerContent = _react.forwardRef.call(void 0,
1302
+ (props, ref) => {
1303
+ const {
1304
+ file,
1305
+ onLoad,
1306
+ onError,
1307
+ fileName,
1308
+ showPageCount = true,
1309
+ showPageNavigation = true,
1310
+ showZoomControls = true,
1311
+ showRotation = true,
1312
+ showDownload = true,
1313
+ showPrint = true,
1314
+ showSearch = true,
1315
+ showMetadata = true,
1316
+ showProperties = true,
1317
+ showTags = true,
1318
+ showHistory = true,
1319
+ onMetadataClick,
1320
+ onPropertiesClick,
1321
+ onTagsClick,
1322
+ onHistoryClick,
1323
+ onDownloadClick,
1324
+ onDownloadWithAnnotations,
1325
+ onDownloadWithoutAnnotations,
1326
+ onPrintClick,
1327
+ onPrintWithAnnotations,
1328
+ onPrintWithoutAnnotations,
1329
+ initialSearchText,
1330
+ initialSearchPages,
1331
+ showAnnotations,
1332
+ userDetails,
1333
+ annotationSelectionMenu,
1334
+ isHighlighterActive,
1335
+ isStampActive,
1336
+ onHighlighterClick,
1337
+ onStampClick,
1338
+ onSignatureClick,
1339
+ // New granular toolbar props
1340
+ showAnnotate,
1341
+ disabledAnnotate,
1342
+ showPrintOriginal,
1343
+ showPrintWithAnnotations,
1344
+ showDownloadOriginal,
1345
+ showDownloadWithAnnotations,
1346
+ // Annotation save props
1347
+ hasUnsavedAnnotations,
1348
+ isSavingAnnotations,
1349
+ canSaveAnnotations,
1350
+ onSaveAnnotations,
1351
+ loading
1352
+ } = props;
1353
+ const [pdfBuffer, setPdfBuffer] = _react.useState.call(void 0, null);
1354
+ const [state, setState] = _react.useState.call(void 0, "idle");
1355
+ const [error, setError] = _react.useState.call(void 0, null);
1356
+ const pdfViewerRef = _react.useRef.call(void 0, null);
1357
+ const [isInternalReady, setIsInternalReady] = _react.useState.call(void 0, false);
1358
+ const [internalHighlighterActive, setInternalHighlighterActive] = _react.useState.call(void 0, false);
1359
+ const [internalStampActive, setInternalStampActive] = _react.useState.call(void 0, false);
1360
+ const highlighterActive = isHighlighterActive !== void 0 ? isHighlighterActive : internalHighlighterActive;
1361
+ const stampActive = isStampActive !== void 0 ? isStampActive : internalStampActive;
1362
+ const resolvedFileName = _react.useMemo.call(void 0, () => {
1363
+ if (fileName) return fileName;
1364
+ if (file instanceof File) return file.name;
1365
+ if (typeof file === "string") {
1366
+ const urlParts = file.split("/");
1367
+ return urlParts[urlParts.length - 1] || "document.pdf";
1368
+ }
1369
+ return "document.pdf";
1370
+ }, [file, fileName]);
1371
+ const fileExtension = _react.useMemo.call(void 0,
1372
+ () => _chunkOPJOCUSLjs.getFileExtension.call(void 0, resolvedFileName),
1373
+ [resolvedFileName]
1374
+ );
1375
+ const [currentPage, setCurrentPage] = _react.useState.call(void 0, 1);
1376
+ const [totalPages, setTotalPages] = _react.useState.call(void 0, 0);
1377
+ const [zoom, setZoom] = _react.useState.call(void 0, 100);
1378
+ const [searchQuery, setSearchQuery] = _react.useState.call(void 0, "");
1379
+ const [isSearching, setIsSearching] = _react.useState.call(void 0, false);
1380
+ const [pdfContainer, setPdfContainer] = _react.useState.call(void 0, null);
1381
+ const [isSidebarOpen, setIsSidebarOpen] = _react.useState.call(void 0, false);
1382
+ const [searchResults, setSearchResults] = _react.useState.call(void 0, []);
1383
+ const [currentSearchResultIndex, setCurrentSearchResultIndex] = _react.useState.call(void 0, 0);
1384
+ const [totalSearchResults, setTotalSearchResults] = _react.useState.call(void 0, 0);
1385
+ const [autoExecuteSearch, setAutoExecuteSearch] = _react.useState.call(void 0,
1386
+ !!initialSearchText
1387
+ );
1388
+ const [isFullScreen, setIsFullScreen] = _react.useState.call(void 0, false);
1389
+ const containerRef = _react.useRef.call(void 0, null);
1390
+ const [isPasswordDialogOpen, setIsPasswordDialogOpen] = _react.useState.call(void 0, false);
1391
+ const [passwordError, setPasswordError] = _react.useState.call(void 0, "");
1392
+ const [isVerifyingPassword, setIsVerifyingPassword] = _react.useState.call(void 0, false);
1393
+ const [passwordResolve, setPasswordResolve] = _react.useState.call(void 0, null);
1394
+ const passwordTimeoutRef = _react.useRef.call(void 0, null);
1395
+ const hasExecutedInitialSearch = _react.useRef.call(void 0, false);
1396
+ const handleToggleFullScreen = _react.useCallback.call(void 0, () => {
1397
+ if (!isFullScreen && _optionalChain([containerRef, 'access', _9 => _9.current, 'optionalAccess', _10 => _10.requestFullscreen])) {
1398
+ containerRef.current.requestFullscreen();
1399
+ setIsFullScreen(true);
1400
+ } else if (isFullScreen && document.exitFullscreen) {
1401
+ document.exitFullscreen();
1402
+ setIsFullScreen(false);
1403
+ }
1404
+ }, [isFullScreen]);
1405
+ _react.useEffect.call(void 0, () => {
1406
+ const handleFullscreenChange = () => {
1407
+ const isCurrentlyFullscreen = !!document.fullscreenElement;
1408
+ setIsFullScreen(isCurrentlyFullscreen);
1409
+ };
1410
+ document.addEventListener("fullscreenchange", handleFullscreenChange);
1411
+ return () => {
1412
+ document.removeEventListener("fullscreenchange", handleFullscreenChange);
1413
+ };
1414
+ }, []);
1415
+ const handleSidebarClose = _react.useCallback.call(void 0, () => {
1416
+ setIsSidebarOpen(false);
1417
+ setSearchQuery("");
1418
+ setSearchResults([]);
1419
+ setTotalSearchResults(0);
1420
+ setCurrentSearchResultIndex(0);
1421
+ _optionalChain([pdfViewerRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.search, 'access', _13 => _13.stopSearch, 'call', _14 => _14()]);
1422
+ }, []);
1423
+ const toolbar = _chunkEM63H4SAjs.mergeToolbarConfig.call(void 0, {
1424
+ showDownload,
1425
+ showPrint,
1426
+ showMetadata,
1427
+ showProperties,
1428
+ showTags,
1429
+ showHistory,
1430
+ showRotation,
1431
+ onDownloadClick,
1432
+ onPrintClick,
1433
+ onMetadataClick,
1434
+ onPropertiesClick,
1435
+ onTagsClick,
1436
+ onHistoryClick,
1437
+ toolbarActions: props.toolbarActions
1438
+ });
1439
+ const toolbarHandlers = _react.useMemo.call(void 0,
1440
+ () => ({
1441
+ handleZoomIn: () => {
1442
+ _optionalChain([pdfViewerRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.zoom, 'access', _17 => _17.zoomIn, 'call', _18 => _18()]);
1443
+ requestAnimationFrame(() => {
1444
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.zoom, 'access', _21 => _21.getZoom, 'call', _22 => _22()]);
1445
+ if (typeof zoomValue === "number") {
1446
+ setZoom(Math.round(zoomValue * 100));
1447
+ }
1448
+ });
1449
+ },
1450
+ handleZoomOut: () => {
1451
+ _optionalChain([pdfViewerRef, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.zoom, 'access', _25 => _25.zoomOut, 'call', _26 => _26()]);
1452
+ requestAnimationFrame(() => {
1453
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.zoom, 'access', _29 => _29.getZoom, 'call', _30 => _30()]);
1454
+ if (typeof zoomValue === "number") {
1455
+ setZoom(Math.round(zoomValue * 100));
1456
+ }
1457
+ });
1458
+ },
1459
+ handleFitToWidth: () => {
1460
+ _optionalChain([pdfViewerRef, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.zoom, 'access', _33 => _33.fitToWidth, 'call', _34 => _34()]);
1461
+ requestAnimationFrame(() => {
1462
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.zoom, 'access', _37 => _37.getZoom, 'call', _38 => _38()]);
1463
+ if (typeof zoomValue === "number") {
1464
+ setZoom(Math.round(zoomValue * 100));
1465
+ }
1466
+ });
1467
+ },
1468
+ handleFitToPage: () => {
1469
+ _optionalChain([pdfViewerRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.zoom, 'access', _41 => _41.fitToPage, 'call', _42 => _42()]);
1470
+ requestAnimationFrame(() => {
1471
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.zoom, 'access', _45 => _45.getZoom, 'call', _46 => _46()]);
1472
+ if (typeof zoomValue === "number") {
1473
+ setZoom(Math.round(zoomValue * 100));
1474
+ }
1475
+ });
1476
+ },
1477
+ handlePreviousPage: () => {
1478
+ _optionalChain([pdfViewerRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.navigation, 'access', _49 => _49.previousPage, 'call', _50 => _50()]);
1479
+ requestAnimationFrame(() => {
1480
+ const current = _optionalChain([pdfViewerRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.navigation, 'access', _53 => _53.getCurrentPage, 'call', _54 => _54()]) || 1;
1481
+ setCurrentPage(current);
1482
+ });
1483
+ },
1484
+ handleNextPage: () => {
1485
+ _optionalChain([pdfViewerRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.navigation, 'access', _57 => _57.nextPage, 'call', _58 => _58()]);
1486
+ requestAnimationFrame(() => {
1487
+ const current = _optionalChain([pdfViewerRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.navigation, 'access', _61 => _61.getCurrentPage, 'call', _62 => _62()]) || 1;
1488
+ setCurrentPage(current);
1489
+ });
1490
+ },
1491
+ handleFirstPage: () => {
1492
+ _optionalChain([pdfViewerRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.navigation, 'access', _65 => _65.goToFirstPage, 'call', _66 => _66()]);
1493
+ requestAnimationFrame(() => {
1494
+ const current = _optionalChain([pdfViewerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.navigation, 'access', _69 => _69.getCurrentPage, 'call', _70 => _70()]) || 1;
1495
+ setCurrentPage(current);
1496
+ });
1497
+ },
1498
+ handleLastPage: () => {
1499
+ _optionalChain([pdfViewerRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.navigation, 'access', _73 => _73.goToLastPage, 'call', _74 => _74()]);
1500
+ requestAnimationFrame(() => {
1501
+ const current = _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.navigation, 'access', _77 => _77.getCurrentPage, 'call', _78 => _78()]) || 1;
1502
+ setCurrentPage(current);
1503
+ });
1504
+ },
1505
+ toggleSidebar: () => {
1506
+ if (isSidebarOpen) {
1507
+ handleSidebarClose();
1508
+ } else {
1509
+ setIsSidebarOpen(true);
1510
+ }
1511
+ },
1512
+ handlePageInput: (e) => {
1513
+ const value = e.target.value;
1514
+ if (/^\d*$/.test(value)) {
1515
+ return;
1516
+ }
1517
+ const page = parseInt(value, 10);
1518
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1519
+ _optionalChain([pdfViewerRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.navigation, 'access', _81 => _81.goToPage, 'call', _82 => _82(page)]);
1520
+ setCurrentPage(page);
1521
+ }
1522
+ },
1523
+ handlePageInputKeyPress: (e) => {
1524
+ if (e.key === "Enter") {
1525
+ const value = e.target.value;
1526
+ const page = parseInt(value, 10);
1527
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1528
+ _optionalChain([pdfViewerRef, 'access', _83 => _83.current, 'optionalAccess', _84 => _84.navigation, 'access', _85 => _85.goToPage, 'call', _86 => _86(page)]);
1529
+ setCurrentPage(page);
1530
+ }
1531
+ }
1532
+ },
1533
+ handleRotateLeft: () => {
1534
+ _optionalChain([pdfViewerRef, 'access', _87 => _87.current, 'optionalAccess', _88 => _88.rotate, 'optionalAccess', _89 => _89.rotateBackward, 'call', _90 => _90()]);
1535
+ },
1536
+ handleRotateRight: () => {
1537
+ _optionalChain([pdfViewerRef, 'access', _91 => _91.current, 'optionalAccess', _92 => _92.rotate, 'optionalAccess', _93 => _93.rotateForward, 'call', _94 => _94()]);
1538
+ },
1539
+ handlePrint: () => {
1540
+ _optionalChain([pdfViewerRef, 'access', _95 => _95.current, 'optionalAccess', _96 => _96.print, 'optionalAccess', _97 => _97.print, 'call', _98 => _98()]);
1541
+ },
1542
+ handlePrintWithAnnotations: async () => {
1543
+ if (onPrintWithAnnotations) {
1544
+ await onPrintWithAnnotations();
1545
+ } else {
1546
+ await _optionalChain([pdfViewerRef, 'access', _99 => _99.current, 'optionalAccess', _100 => _100.print, 'optionalAccess', _101 => _101.printWithAnnotations, 'optionalCall', _102 => _102()]);
1547
+ }
1548
+ },
1549
+ handlePrintWithoutAnnotations: async () => {
1550
+ if (onPrintWithoutAnnotations) {
1551
+ await onPrintWithoutAnnotations();
1552
+ } else {
1553
+ await _optionalChain([pdfViewerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.print, 'optionalAccess', _105 => _105.printWithoutAnnotations, 'optionalCall', _106 => _106()]);
1554
+ }
1555
+ },
1556
+ handleDownloadWithAnnotations: async () => {
1557
+ if (onDownloadWithAnnotations) {
1558
+ onDownloadWithAnnotations();
1559
+ } else {
1560
+ await _optionalChain([pdfViewerRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.download, 'optionalAccess', _109 => _109.downloadWithAnnotations, 'optionalCall', _110 => _110(resolvedFileName)]);
1561
+ }
1562
+ },
1563
+ handleDownloadWithoutAnnotations: async () => {
1564
+ if (onDownloadWithoutAnnotations) {
1565
+ onDownloadWithoutAnnotations();
1566
+ } else {
1567
+ await _optionalChain([pdfViewerRef, 'access', _111 => _111.current, 'optionalAccess', _112 => _112.download, 'optionalAccess', _113 => _113.downloadWithoutAnnotations, 'optionalCall', _114 => _114(resolvedFileName)]);
1568
+ }
1569
+ },
1570
+ handleHighlighterClick: () => {
1571
+ if (highlighterActive) {
1572
+ _optionalChain([pdfViewerRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.annotation, 'optionalAccess', _117 => _117.deactivateHighlighter, 'call', _118 => _118()]);
1573
+ setInternalHighlighterActive(false);
1574
+ } else {
1575
+ if (stampActive) {
1576
+ _optionalChain([pdfViewerRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.annotation, 'optionalAccess', _121 => _121.deactivateStamp, 'call', _122 => _122()]);
1577
+ setInternalStampActive(false);
1578
+ }
1579
+ _optionalChain([pdfViewerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.annotation, 'optionalAccess', _125 => _125.activateHighlighter, 'call', _126 => _126()]);
1580
+ setInternalHighlighterActive(true);
1581
+ }
1582
+ },
1583
+ handleStampClick: () => {
1584
+ if (stampActive) {
1585
+ _optionalChain([pdfViewerRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.annotation, 'optionalAccess', _129 => _129.deactivateStamp, 'call', _130 => _130()]);
1586
+ setInternalStampActive(false);
1587
+ } else {
1588
+ if (highlighterActive) {
1589
+ _optionalChain([pdfViewerRef, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.annotation, 'optionalAccess', _133 => _133.deactivateHighlighter, 'call', _134 => _134()]);
1590
+ setInternalHighlighterActive(false);
1591
+ }
1592
+ _optionalChain([pdfViewerRef, 'access', _135 => _135.current, 'optionalAccess', _136 => _136.annotation, 'optionalAccess', _137 => _137.activateStamp, 'call', _138 => _138("")]);
1593
+ setInternalStampActive(true);
1594
+ }
1595
+ },
1596
+ handleSignatureClick: () => {
1597
+ },
1598
+ handleCopy: () => {
1599
+ _optionalChain([pdfViewerRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.selection, 'access', _141 => _141.copy, 'call', _142 => _142()]);
1600
+ },
1601
+ handleToggleFullScreen
1602
+ }),
1603
+ [isSidebarOpen, totalPages, handleToggleFullScreen, highlighterActive, stampActive, onDownloadWithAnnotations, onDownloadWithoutAnnotations, onPrintWithAnnotations, onPrintWithoutAnnotations]
1604
+ );
1605
+ _react.useEffect.call(void 0, () => {
1606
+ if (!initialSearchText || hasExecutedInitialSearch.current) return;
1607
+ const isPDFReady = state === "ready";
1608
+ const isPagesInitialized = totalPages > 0;
1609
+ const isViewerAvailable = !!pdfViewerRef.current;
1610
+ const isSearchAPIReady = !!_optionalChain([pdfViewerRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.search, 'optionalAccess', _145 => _145.searchText]);
1611
+ const canExecuteSearch = isPDFReady && isPagesInitialized && isViewerAvailable && isSearchAPIReady;
1612
+ if (!canExecuteSearch) return;
1613
+ hasExecutedInitialSearch.current = true;
1614
+ const SEARCH_INITIALIZATION_DELAY = 100;
1615
+ setTimeout(() => {
1616
+ if (!_optionalChain([pdfViewerRef, 'access', _146 => _146.current, 'optionalAccess', _147 => _147.search, 'optionalAccess', _148 => _148.searchText])) {
1617
+ hasExecutedInitialSearch.current = false;
1618
+ return;
1619
+ }
1620
+ requestAnimationFrame(() => {
1621
+ requestAnimationFrame(() => {
1622
+ setIsSidebarOpen(true);
1623
+ handleSidebarSearch(initialSearchText, initialSearchPages);
1624
+ setAutoExecuteSearch(false);
1625
+ });
1626
+ });
1627
+ }, SEARCH_INITIALIZATION_DELAY);
1628
+ }, [
1629
+ state,
1630
+ totalPages,
1631
+ pdfViewerRef.current,
1632
+ initialSearchText,
1633
+ initialSearchPages
1634
+ ]);
1635
+ _react.useEffect.call(void 0, () => {
1636
+ setSearchQuery("");
1637
+ setSearchResults([]);
1638
+ setCurrentSearchResultIndex(0);
1639
+ setTotalSearchResults(0);
1640
+ setIsSearching(false);
1641
+ setIsSidebarOpen(false);
1642
+ hasExecutedInitialSearch.current = false;
1643
+ setCurrentPage(1);
1644
+ setTotalPages(0);
1645
+ setZoom(100);
1646
+ setState("idle");
1647
+ setError(null);
1648
+ setPdfBuffer(null);
1649
+ }, [file]);
1650
+ _react.useEffect.call(void 0, () => {
1651
+ if (state !== "ready") return;
1652
+ const container = document.querySelector(
1653
+ '[data-pdf-viewer], .embedpdf-viewport, [role="document"]'
1654
+ );
1655
+ if (container) {
1656
+ setPdfContainer(container);
1657
+ return;
1658
+ }
1659
+ const observer = new MutationObserver(() => {
1660
+ const foundContainer = document.querySelector(
1661
+ '[data-pdf-viewer], .embedpdf-viewport, [role="document"]'
1662
+ );
1663
+ if (foundContainer) {
1664
+ setPdfContainer(foundContainer);
1665
+ observer.disconnect();
1666
+ }
1667
+ });
1668
+ observer.observe(document.body, { childList: true, subtree: true });
1669
+ return () => observer.disconnect();
1670
+ }, [state]);
1671
+ _react.useEffect.call(void 0, () => {
1672
+ if (state !== "ready") return;
1673
+ const checkInternalReadiness = async () => {
1674
+ if (!pdfViewerRef.current) return;
1675
+ try {
1676
+ const count = _optionalChain([pdfViewerRef, 'access', _149 => _149.current, 'access', _150 => _150.navigation, 'optionalAccess', _151 => _151.getTotalPages, 'optionalCall', _152 => _152()]);
1677
+ if (count && count > 0) {
1678
+ setTotalPages(count);
1679
+ setIsInternalReady(true);
1680
+ return;
1681
+ }
1682
+ const docInfo = _optionalChain([pdfViewerRef, 'access', _153 => _153.current, 'optionalAccess', _154 => _154.document, 'optionalAccess', _155 => _155.getDocumentInfo, 'optionalCall', _156 => _156()]);
1683
+ if (docInfo && docInfo.totalPages > 0) {
1684
+ setTotalPages(docInfo.totalPages);
1685
+ setIsInternalReady(true);
1686
+ return;
1687
+ }
1688
+ } catch (e) {
1689
+ }
1690
+ };
1691
+ const pollInterval = setInterval(checkInternalReadiness, 100);
1692
+ return () => clearInterval(pollInterval);
1693
+ }, [state]);
1694
+ _react.useEffect.call(void 0, () => {
1695
+ if (state !== "ready" || totalPages > 0) return;
1696
+ const initializePageCount = async () => {
1697
+ const waitForViewer = async (maxAttempts = 10) => {
1698
+ for (let i = 0; i < maxAttempts; i++) {
1699
+ if (pdfViewerRef.current) return pdfViewerRef.current;
1700
+ await new Promise(
1701
+ (resolve) => requestAnimationFrame(
1702
+ () => setTimeout(resolve, Math.min(100 * Math.pow(2, i), 1e3))
1703
+ )
1704
+ );
1705
+ }
1706
+ return null;
1707
+ };
1708
+ const viewer = await waitForViewer();
1709
+ if (!viewer) return;
1710
+ await new Promise((resolve) => requestAnimationFrame(resolve));
1711
+ try {
1712
+ const count = _optionalChain([viewer, 'access', _157 => _157.navigation, 'optionalAccess', _158 => _158.getTotalPages, 'optionalCall', _159 => _159()]);
1713
+ if (count && count > 0) {
1714
+ setTotalPages(count);
1715
+ setIsInternalReady(true);
1716
+ return;
1717
+ }
1718
+ } catch (e) {
1719
+ }
1720
+ };
1721
+ initializePageCount();
1722
+ }, [state, totalPages]);
1723
+ _react.useEffect.call(void 0, () => {
1724
+ if (state === "ready") {
1725
+ const updateInfo = () => {
1726
+ if (!pdfViewerRef.current) return;
1727
+ const current = _optionalChain([pdfViewerRef, 'access', _160 => _160.current, 'optionalAccess', _161 => _161.navigation, 'access', _162 => _162.getCurrentPage, 'call', _163 => _163()]) || 1;
1728
+ const docInfo = _optionalChain([pdfViewerRef, 'access', _164 => _164.current, 'optionalAccess', _165 => _165.document, 'optionalAccess', _166 => _166.getDocumentInfo, 'optionalCall', _167 => _167()]);
1729
+ const navTotal = _optionalChain([pdfViewerRef, 'access', _168 => _168.current, 'optionalAccess', _169 => _169.navigation, 'optionalAccess', _170 => _170.getTotalPages, 'optionalCall', _171 => _171()]);
1730
+ let total = 0;
1731
+ if (docInfo && docInfo.totalPages > 0) {
1732
+ total = docInfo.totalPages;
1733
+ } else if (typeof navTotal === "number" && navTotal > 0) {
1734
+ total = navTotal;
1735
+ }
1736
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _172 => _172.current, 'optionalAccess', _173 => _173.zoom, 'access', _174 => _174.getZoom, 'call', _175 => _175()]);
1737
+ const currentSearchState = _optionalChain([pdfViewerRef, 'access', _176 => _176.current, 'optionalAccess', _177 => _177.search, 'access', _178 => _178.getSearchState, 'call', _179 => _179()]);
1738
+ setCurrentPage(current);
1739
+ if (total > 0 && total !== totalPages) {
1740
+ setTotalPages(total);
1741
+ }
1742
+ if (typeof zoomValue === "number") {
1743
+ setZoom(Math.round(zoomValue * 100));
1744
+ }
1745
+ };
1746
+ updateInfo();
1747
+ const pollInterval = totalPages === 0 ? 50 : 300;
1748
+ const interval = setInterval(updateInfo, pollInterval);
1749
+ return () => clearInterval(interval);
1750
+ }
1751
+ }, [state, totalPages]);
1752
+ _react.useImperativeHandle.call(void 0,
1753
+ ref,
1754
+ () => ({
1755
+ zoomIn: () => {
1756
+ _optionalChain([pdfViewerRef, 'access', _180 => _180.current, 'optionalAccess', _181 => _181.zoom, 'access', _182 => _182.zoomIn, 'call', _183 => _183()]);
1757
+ updateZoomDisplay();
1758
+ },
1759
+ zoomOut: () => {
1760
+ _optionalChain([pdfViewerRef, 'access', _184 => _184.current, 'optionalAccess', _185 => _185.zoom, 'access', _186 => _186.zoomOut, 'call', _187 => _187()]);
1761
+ updateZoomDisplay();
1762
+ },
1763
+ setZoom: (level) => {
1764
+ _optionalChain([pdfViewerRef, 'access', _188 => _188.current, 'optionalAccess', _189 => _189.zoom, 'access', _190 => _190.setZoom, 'call', _191 => _191(level)]);
1765
+ updateZoomDisplay();
1766
+ },
1767
+ resetZoom: () => {
1768
+ _optionalChain([pdfViewerRef, 'access', _192 => _192.current, 'optionalAccess', _193 => _193.zoom, 'access', _194 => _194.resetZoom, 'call', _195 => _195()]);
1769
+ updateZoomDisplay();
1770
+ },
1771
+ getZoom: () => {
1772
+ const zoom2 = _optionalChain([pdfViewerRef, 'access', _196 => _196.current, 'optionalAccess', _197 => _197.zoom, 'access', _198 => _198.getZoom, 'call', _199 => _199()]);
1773
+ return typeof zoom2 === "number" ? zoom2 : 1;
1774
+ },
1775
+ goToPage: (page) => {
1776
+ _optionalChain([pdfViewerRef, 'access', _200 => _200.current, 'optionalAccess', _201 => _201.navigation, 'access', _202 => _202.goToPage, 'call', _203 => _203(page)]);
1777
+ setCurrentPage(page);
1778
+ },
1779
+ getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _204 => _204.current, 'optionalAccess', _205 => _205.navigation, 'access', _206 => _206.getCurrentPage, 'call', _207 => _207()]) || 1,
1780
+ getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _208 => _208.current, 'optionalAccess', _209 => _209.navigation, 'access', _210 => _210.getTotalPages, 'call', _211 => _211()]) || 0,
1781
+ nextPage: () => {
1782
+ _optionalChain([pdfViewerRef, 'access', _212 => _212.current, 'optionalAccess', _213 => _213.navigation, 'access', _214 => _214.nextPage, 'call', _215 => _215()]);
1783
+ updatePageDisplay();
1784
+ },
1785
+ previousPage: () => {
1786
+ _optionalChain([pdfViewerRef, 'access', _216 => _216.current, 'optionalAccess', _217 => _217.navigation, 'access', _218 => _218.previousPage, 'call', _219 => _219()]);
1787
+ updatePageDisplay();
1788
+ },
1789
+ goToFirstPage: () => {
1790
+ _optionalChain([pdfViewerRef, 'access', _220 => _220.current, 'optionalAccess', _221 => _221.navigation, 'access', _222 => _222.goToFirstPage, 'call', _223 => _223()]);
1791
+ updatePageDisplay();
1792
+ },
1793
+ goToLastPage: () => {
1794
+ _optionalChain([pdfViewerRef, 'access', _224 => _224.current, 'optionalAccess', _225 => _225.navigation, 'access', _226 => _226.goToLastPage, 'call', _227 => _227()]);
1795
+ updatePageDisplay();
1796
+ },
1797
+ searchText: async (keyword) => {
1798
+ setIsSearching(true);
1799
+ const results = await _optionalChain([pdfViewerRef, 'access', _228 => _228.current, 'optionalAccess', _229 => _229.search, 'access', _230 => _230.searchText, 'call', _231 => _231(
1800
+ keyword
1801
+ )]);
1802
+ setIsSearching(false);
1803
+ setSearchQuery(keyword);
1804
+ return results;
1805
+ },
1806
+ nextResult: () => {
1807
+ const index = _optionalChain([pdfViewerRef, 'access', _232 => _232.current, 'optionalAccess', _233 => _233.search, 'access', _234 => _234.nextResult, 'call', _235 => _235()]) || -1;
1808
+ return index;
1809
+ },
1810
+ previousResult: () => {
1811
+ const index = _optionalChain([pdfViewerRef, 'access', _236 => _236.current, 'optionalAccess', _237 => _237.search, 'access', _238 => _238.previousResult, 'call', _239 => _239()]) || -1;
1812
+ return index;
1813
+ },
1814
+ goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _240 => _240.current, 'optionalAccess', _241 => _241.search, 'access', _242 => _242.goToResult, 'call', _243 => _243(index)]) || -1,
1815
+ stopSearch: () => {
1816
+ _optionalChain([pdfViewerRef, 'access', _244 => _244.current, 'optionalAccess', _245 => _245.search, 'access', _246 => _246.stopSearch, 'call', _247 => _247()]);
1817
+ setSearchQuery("");
1818
+ },
1819
+ getSearchState: () => _optionalChain([pdfViewerRef, 'access', _248 => _248.current, 'optionalAccess', _249 => _249.search, 'access', _250 => _250.getSearchState, 'call', _251 => _251()]) || null,
1820
+ getSelectedText: async () => {
1821
+ return await _optionalChain([pdfViewerRef, 'access', _252 => _252.current, 'optionalAccess', _253 => _253.selection, 'access', _254 => _254.getSelectedText, 'call', _255 => _255()]) || "";
1822
+ },
1823
+ clearSelection: () => _optionalChain([pdfViewerRef, 'access', _256 => _256.current, 'optionalAccess', _257 => _257.selection, 'access', _258 => _258.clearSelection, 'call', _259 => _259()]),
1824
+ copy: () => _optionalChain([pdfViewerRef, 'access', _260 => _260.current, 'optionalAccess', _261 => _261.selection, 'access', _262 => _262.copy, 'call', _263 => _263()]),
1825
+ rotateForward: () => _optionalChain([pdfViewerRef, 'access', _264 => _264.current, 'optionalAccess', _265 => _265.rotate, 'optionalAccess', _266 => _266.rotateForward, 'call', _267 => _267()]),
1826
+ rotateBackward: () => _optionalChain([pdfViewerRef, 'access', _268 => _268.current, 'optionalAccess', _269 => _269.rotate, 'optionalAccess', _270 => _270.rotateBackward, 'call', _271 => _271()]),
1827
+ getRotation: () => _optionalChain([pdfViewerRef, 'access', _272 => _272.current, 'optionalAccess', _273 => _273.rotate, 'optionalAccess', _274 => _274.getRotation, 'call', _275 => _275()]) || 0,
1828
+ print: () => _optionalChain([pdfViewerRef, 'access', _276 => _276.current, 'optionalAccess', _277 => _277.print, 'optionalAccess', _278 => _278.print, 'call', _279 => _279()]),
1829
+ printWithAnnotations: async () => {
1830
+ await _optionalChain([pdfViewerRef, 'access', _280 => _280.current, 'optionalAccess', _281 => _281.print, 'optionalAccess', _282 => _282.printWithAnnotations, 'optionalCall', _283 => _283()]);
1831
+ },
1832
+ printWithoutAnnotations: async () => {
1833
+ await _optionalChain([pdfViewerRef, 'access', _284 => _284.current, 'optionalAccess', _285 => _285.print, 'optionalAccess', _286 => _286.printWithoutAnnotations, 'optionalCall', _287 => _287()]);
1834
+ },
1835
+ downloadWithAnnotations: async (filename) => {
1836
+ await _optionalChain([pdfViewerRef, 'access', _288 => _288.current, 'optionalAccess', _289 => _289.download, 'optionalAccess', _290 => _290.downloadWithAnnotations, 'optionalCall', _291 => _291(filename)]);
1837
+ },
1838
+ downloadWithoutAnnotations: async (filename) => {
1839
+ await _optionalChain([pdfViewerRef, 'access', _292 => _292.current, 'optionalAccess', _293 => _293.download, 'optionalAccess', _294 => _294.downloadWithoutAnnotations, 'optionalCall', _295 => _295(filename)]);
1840
+ },
1841
+ get annotation() {
1842
+ return _optionalChain([pdfViewerRef, 'access', _296 => _296.current, 'optionalAccess', _297 => _297.annotation]);
1843
+ },
1844
+ get download() {
1845
+ return _optionalChain([pdfViewerRef, 'access', _298 => _298.current, 'optionalAccess', _299 => _299.download]);
1846
+ }
1847
+ }),
1848
+ []
1849
+ );
1850
+ const updatePageDisplay = () => {
1851
+ requestAnimationFrame(() => {
1852
+ const current = _optionalChain([pdfViewerRef, 'access', _300 => _300.current, 'optionalAccess', _301 => _301.navigation, 'access', _302 => _302.getCurrentPage, 'call', _303 => _303()]) || 1;
1853
+ setCurrentPage(current);
1854
+ });
1855
+ };
1856
+ const updateZoomDisplay = () => {
1857
+ requestAnimationFrame(() => {
1858
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _304 => _304.current, 'optionalAccess', _305 => _305.zoom, 'access', _306 => _306.getZoom, 'call', _307 => _307()]);
1859
+ if (typeof zoomValue === "number") {
1860
+ setZoom(Math.round(zoomValue * 100));
1861
+ }
1862
+ });
1863
+ };
1864
+ const handleSearch = async () => {
1865
+ if (!searchQuery.trim()) return;
1866
+ setIsSearching(true);
1867
+ const results = await _optionalChain([pdfViewerRef, 'access', _308 => _308.current, 'optionalAccess', _309 => _309.search, 'access', _310 => _310.searchText, 'call', _311 => _311(
1868
+ searchQuery
1869
+ )]);
1870
+ setIsSearching(false);
1871
+ if (_optionalChain([results, 'optionalAccess', _312 => _312.results]) && Array.isArray(results.results) && results.results.length > 0) {
1872
+ const formattedResults = formatSearchResults(results.results);
1873
+ updateSearchState(formattedResults);
1874
+ } else {
1875
+ clearSearchResults();
1876
+ }
1877
+ };
1878
+ const handleSearchKeyPress = (e) => {
1879
+ if (e.key === "Enter") {
1880
+ handleSearch();
1881
+ }
1882
+ };
1883
+ const handleSidebarSearch = async (keyword, pageNumbers) => {
1884
+ setSearchQuery(keyword);
1885
+ if (!keyword.trim()) {
1886
+ setSearchResults([]);
1887
+ setTotalSearchResults(0);
1888
+ setCurrentSearchResultIndex(0);
1889
+ _optionalChain([pdfViewerRef, 'access', _313 => _313.current, 'optionalAccess', _314 => _314.search, 'access', _315 => _315.stopSearch, 'call', _316 => _316()]);
1890
+ return;
1891
+ }
1892
+ if (!_optionalChain([pdfViewerRef, 'access', _317 => _317.current, 'optionalAccess', _318 => _318.search, 'optionalAccess', _319 => _319.searchText])) {
1893
+ console.warn("Search functionality not yet available");
1894
+ return;
1895
+ }
1896
+ setIsSearching(true);
1897
+ try {
1898
+ const results = await pdfViewerRef.current.search.searchText(keyword);
1899
+ setIsSearching(false);
1900
+ const hasValidResults = _optionalChain([results, 'optionalAccess', _320 => _320.results]) && Array.isArray(results.results) && results.results.length > 0;
1901
+ if (hasValidResults) {
1902
+ const formattedResults = formatSearchResults(results.results);
1903
+ updateSearchState(formattedResults);
1904
+ navigateToFirstResult(formattedResults);
1905
+ } else if (pageNumbers && pageNumbers.length > 0) {
1906
+ const fallbackResults = createFallbackResults(pageNumbers, keyword);
1907
+ updateSearchState(fallbackResults);
1908
+ navigateToPage(pageNumbers[0]);
1909
+ } else {
1910
+ clearSearchResults();
1911
+ }
1912
+ } catch (error2) {
1913
+ console.error("Search failed:", error2);
1914
+ setIsSearching(false);
1915
+ clearSearchResults();
1916
+ }
1917
+ };
1918
+ const formatSearchResults = (results) => {
1919
+ return results.map((result, index) => {
1920
+ let textContent = "";
1921
+ let contextContent = "";
1922
+ if (result.context && typeof result.context === "object") {
1923
+ const { before = "", match = "", after = "" } = result.context;
1924
+ textContent = match;
1925
+ contextContent = `${before}${match}${after}`;
1926
+ } else if (typeof result === "string") {
1927
+ textContent = result;
1928
+ contextContent = result;
1929
+ } else {
1930
+ textContent = String(result.match || result.text || "");
1931
+ contextContent = textContent;
1932
+ }
1933
+ return {
1934
+ pageNumber: (_nullishCoalesce(_nullishCoalesce(result.pageIndex, () => ( result.pageNumber)), () => ( 0))) + 1,
1935
+ text: textContent,
1936
+ context: contextContent,
1937
+ index
1938
+ };
1939
+ });
1940
+ };
1941
+ const createFallbackResults = (pageNumbers, keyword) => {
1942
+ return pageNumbers.map((pageNum, index) => ({
1943
+ pageNumber: pageNum,
1944
+ text: keyword,
1945
+ context: `"${keyword}" found on this page ${pageNum}`,
1946
+ index
1947
+ }));
1948
+ };
1949
+ const updateSearchState = (results) => {
1950
+ setSearchResults(results);
1951
+ setTotalSearchResults(results.length);
1952
+ setCurrentSearchResultIndex(0);
1953
+ };
1954
+ const clearSearchResults = () => {
1955
+ setSearchResults([]);
1956
+ setTotalSearchResults(0);
1957
+ setCurrentSearchResultIndex(0);
1958
+ };
1959
+ const navigateToFirstResult = (results) => {
1960
+ if (results.length > 0) {
1961
+ navigateToPage(results[0].pageNumber);
1962
+ }
1963
+ };
1964
+ const navigateToPage = (pageNumber) => {
1965
+ requestAnimationFrame(() => {
1966
+ _optionalChain([pdfViewerRef, 'access', _321 => _321.current, 'optionalAccess', _322 => _322.navigation, 'access', _323 => _323.goToPage, 'call', _324 => _324(pageNumber)]);
1967
+ setCurrentPage(pageNumber);
1968
+ });
1969
+ };
1970
+ const handleSearchResultClick = (pageNumber, resultIndex) => {
1971
+ _optionalChain([pdfViewerRef, 'access', _325 => _325.current, 'optionalAccess', _326 => _326.navigation, 'access', _327 => _327.goToPage, 'call', _328 => _328(pageNumber)]);
1972
+ setCurrentSearchResultIndex(resultIndex);
1973
+ setCurrentPage(pageNumber);
1974
+ _optionalChain([pdfViewerRef, 'access', _329 => _329.current, 'optionalAccess', _330 => _330.search, 'access', _331 => _331.goToResult, 'call', _332 => _332(resultIndex)]);
1975
+ };
1976
+ const handleNextSearchResult = () => {
1977
+ if (currentSearchResultIndex < totalSearchResults - 1) {
1978
+ const nextIndex = currentSearchResultIndex + 1;
1979
+ setCurrentSearchResultIndex(nextIndex);
1980
+ _optionalChain([pdfViewerRef, 'access', _333 => _333.current, 'optionalAccess', _334 => _334.search, 'access', _335 => _335.nextResult, 'call', _336 => _336()]);
1981
+ if (searchResults[nextIndex]) {
1982
+ const pageNumber = searchResults[nextIndex].pageNumber;
1983
+ _optionalChain([pdfViewerRef, 'access', _337 => _337.current, 'optionalAccess', _338 => _338.navigation, 'access', _339 => _339.goToPage, 'call', _340 => _340(pageNumber)]);
1984
+ setCurrentPage(pageNumber);
1985
+ }
1986
+ }
1987
+ };
1988
+ const handlePreviousSearchResult = () => {
1989
+ if (currentSearchResultIndex > 0) {
1990
+ const prevIndex = currentSearchResultIndex - 1;
1991
+ setCurrentSearchResultIndex(prevIndex);
1992
+ _optionalChain([pdfViewerRef, 'access', _341 => _341.current, 'optionalAccess', _342 => _342.search, 'access', _343 => _343.previousResult, 'call', _344 => _344()]);
1993
+ if (searchResults[prevIndex]) {
1994
+ const pageNumber = searchResults[prevIndex].pageNumber;
1995
+ _optionalChain([pdfViewerRef, 'access', _345 => _345.current, 'optionalAccess', _346 => _346.navigation, 'access', _347 => _347.goToPage, 'call', _348 => _348(pageNumber)]);
1996
+ setCurrentPage(pageNumber);
1997
+ }
1998
+ }
1999
+ };
2000
+ _react.useEffect.call(void 0, () => {
2001
+ if (!file) {
2002
+ setState("error");
2003
+ setError("No file provided");
2004
+ return;
2005
+ }
2006
+ const loadPDF = async () => {
2007
+ try {
2008
+ setState("loading");
2009
+ setError(null);
2010
+ let arrayBuffer;
2011
+ if (file instanceof File) {
2012
+ arrayBuffer = await file.arrayBuffer();
2013
+ } else if (typeof file === "string") {
2014
+ const response = await fetch(file);
2015
+ if (!response.ok) {
2016
+ throw new Error(`Failed to load PDF: ${response.statusText}`);
2017
+ }
2018
+ arrayBuffer = await response.arrayBuffer();
2019
+ } else if (file instanceof ArrayBuffer) {
2020
+ arrayBuffer = file;
2021
+ } else {
2022
+ throw new Error("Unsupported file type");
2023
+ }
2024
+ setPdfBuffer(arrayBuffer);
2025
+ setState("ready");
2026
+ _optionalChain([onLoad, 'optionalCall', _349 => _349()]);
2027
+ } catch (err) {
2028
+ const errorMessage = err.message || "Failed to load PDF";
2029
+ setState("error");
2030
+ setError(errorMessage);
2031
+ _optionalChain([onError, 'optionalCall', _350 => _350(err)]);
2032
+ }
2033
+ };
2034
+ loadPDF();
2035
+ }, [file, onLoad, onError]);
2036
+ const handlePasswordRequest = _react.useCallback.call(void 0,
2037
+ async (fileName2, isRetry) => {
2038
+ return new Promise((resolve) => {
2039
+ setPasswordResolve(() => resolve);
2040
+ if (isRetry) {
2041
+ setPasswordError("Incorrect password. Please try again.");
2042
+ } else {
2043
+ setPasswordError("");
2044
+ }
2045
+ setIsPasswordDialogOpen(true);
2046
+ });
2047
+ },
2048
+ []
2049
+ );
2050
+ const handlePasswordSubmit = _react.useCallback.call(void 0,
2051
+ (password) => {
2052
+ if (passwordResolve) {
2053
+ passwordResolve(password);
2054
+ }
2055
+ setIsPasswordDialogOpen(false);
2056
+ setPasswordResolve(null);
2057
+ setPasswordError("");
2058
+ },
2059
+ [passwordResolve]
2060
+ );
2061
+ const handlePasswordCancel = _react.useCallback.call(void 0, () => {
2062
+ if (passwordResolve) {
2063
+ passwordResolve(null);
2064
+ setPasswordResolve(null);
2065
+ setIsPasswordDialogOpen(false);
2066
+ setPasswordError("");
2067
+ }
2068
+ }, [passwordResolve]);
2069
+ const LoadingSpinner = ({ fileName: fileName2 }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: {
2070
+ position: "absolute",
2071
+ inset: 0,
2072
+ zIndex: 50,
2073
+ backgroundColor: "#fff",
2074
+ display: "flex",
2075
+ flexDirection: "column",
2076
+ alignItems: "center",
2077
+ justifyContent: "center"
2078
+ }, children: [
2079
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "dms-loading-spinner", style: {
2080
+ width: "40px",
2081
+ height: "40px",
2082
+ border: "3px solid #f3f3f3",
2083
+ borderTop: "3px solid #3498db",
2084
+ borderRadius: "50%",
2085
+ animation: "spin 1s linear infinite"
2086
+ } }),
2087
+ fileName2 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { style: { marginTop: "16px", color: "#666", fontSize: "14px" }, children: [
2088
+ "Loading ",
2089
+ fileName2,
2090
+ "..."
2091
+ ] }),
2092
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: `@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }` })
2093
+ ] });
2094
+ if (state === "error" || error) {
2095
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2096
+ "div",
2097
+ {
2098
+ style: {
2099
+ display: "flex",
2100
+ flexDirection: "column",
2101
+ alignItems: "center",
2102
+ justifyContent: "center",
2103
+ height: "100%",
2104
+ padding: "24px"
2105
+ },
2106
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2107
+ "div",
2108
+ {
2109
+ style: {
2110
+ maxWidth: "400px",
2111
+ padding: "16px",
2112
+ backgroundColor: "#fee",
2113
+ border: "1px solid #fcc",
2114
+ borderRadius: "4px"
2115
+ },
2116
+ children: [
2117
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { style: { marginTop: 0 }, children: "Failed to Load PDF" }),
2118
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: error || "Unknown error occurred" })
2119
+ ]
2120
+ }
2121
+ )
2122
+ }
2123
+ );
2124
+ }
2125
+ const isReady = pdfBuffer && state === "ready";
2126
+ const showOverlay = loading || !isReady || !isInternalReady;
2127
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref: containerRef, className: "pdf-viewer-container", style: { position: "relative", height: "100%", width: "100%" }, children: [
2128
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: _chunkECZ6IBOSjs.toolbarStyles }),
2129
+ showOverlay && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoadingSpinner, { fileName: resolvedFileName }),
2130
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: { opacity: !showOverlay ? 1 : 0, height: "100%", display: "flex", flexDirection: "column" }, children: [
2131
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PDFHeader, { fileName: resolvedFileName, fileExtension }),
2132
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2133
+ PDFToolbar,
2134
+ {
2135
+ currentPage,
2136
+ totalPages,
2137
+ zoom,
2138
+ isSidebarOpen,
2139
+ showPageNavigation,
2140
+ showPageCount,
2141
+ showZoomControls,
2142
+ showSearch,
2143
+ showRotation: !toolbar.isHidden("rotation"),
2144
+ showMetadata: !toolbar.isHidden("metadata"),
2145
+ showProperties: !toolbar.isHidden("properties"),
2146
+ showDownload: !toolbar.isHidden("download"),
2147
+ showPrint: !toolbar.isHidden("print"),
2148
+ showTags: !toolbar.isHidden("tags"),
2149
+ showHistory: !toolbar.isHidden("history"),
2150
+ disabledRotateLeft: toolbar.isDisabled("rotateLeft"),
2151
+ disabledRotateRight: false,
2152
+ disabledMetadata: toolbar.isDisabled("metadata"),
2153
+ disabledTags: toolbar.isDisabled("tags"),
2154
+ disabledProperties: toolbar.isDisabled("properties"),
2155
+ disabledHistory: toolbar.isDisabled("history"),
2156
+ disabledDownload: toolbar.isDisabled("download"),
2157
+ disabledPrint: toolbar.isDisabled("print"),
2158
+ onFirstPage: toolbarHandlers.handleFirstPage,
2159
+ onPreviousPage: toolbarHandlers.handlePreviousPage,
2160
+ onNextPage: toolbarHandlers.handleNextPage,
2161
+ onLastPage: toolbarHandlers.handleLastPage,
2162
+ onPageInput: toolbarHandlers.handlePageInput,
2163
+ onPageInputKeyPress: toolbarHandlers.handlePageInputKeyPress,
2164
+ onZoomIn: toolbarHandlers.handleZoomIn,
2165
+ onZoomOut: toolbarHandlers.handleZoomOut,
2166
+ onFitToWidth: toolbarHandlers.handleFitToWidth,
2167
+ onFitToPage: toolbarHandlers.handleFitToPage,
2168
+ onToggleSidebar: toolbarHandlers.toggleSidebar,
2169
+ onToggleFullScreen: toolbarHandlers.handleToggleFullScreen,
2170
+ onRotateLeft: toolbarHandlers.handleRotateLeft,
2171
+ onRotateRight: toolbarHandlers.handleRotateRight,
2172
+ onDownloadClick: toolbar.getHandler("download", onDownloadClick),
2173
+ onDownloadWithAnnotations: toolbarHandlers.handleDownloadWithAnnotations,
2174
+ onDownloadWithoutAnnotations: toolbarHandlers.handleDownloadWithoutAnnotations,
2175
+ onPrintClick: toolbar.getHandler("print", onPrintClick || toolbarHandlers.handlePrint),
2176
+ onPrintWithAnnotations: toolbarHandlers.handlePrintWithAnnotations,
2177
+ onPrintWithoutAnnotations: toolbarHandlers.handlePrintWithoutAnnotations,
2178
+ onCopyClick: toolbarHandlers.handleCopy,
2179
+ onMetadataClick: toolbar.getHandler("metadata", onMetadataClick),
2180
+ onPropertiesClick: toolbar.getHandler(
2181
+ "properties",
2182
+ onPropertiesClick
2183
+ ),
2184
+ onTagsClick: toolbar.getHandler("tags", onTagsClick),
2185
+ onHistoryClick: toolbar.getHandler("history", onHistoryClick),
2186
+ showAnnotations,
2187
+ isHighlighterActive: highlighterActive,
2188
+ isStampActive: stampActive,
2189
+ disabledHighlighter: toolbar.isDisabled("highlighter"),
2190
+ disabledStamp: toolbar.isDisabled("stamp"),
2191
+ disabledSignature: toolbar.isDisabled("signature"),
2192
+ onHighlighterClick: toolbar.getHandler("highlighter", onHighlighterClick || toolbarHandlers.handleHighlighterClick),
2193
+ onStampClick: toolbar.getHandler("stamp", onStampClick || toolbarHandlers.handleStampClick),
2194
+ onSignatureClick: toolbar.getHandler("signature", onSignatureClick || toolbarHandlers.handleSignatureClick),
2195
+ showAnnotate,
2196
+ disabledAnnotate,
2197
+ showPrintOriginal,
2198
+ showPrintWithAnnotations,
2199
+ showDownloadOriginal,
2200
+ showDownloadWithAnnotations,
2201
+ hasUnsavedAnnotations,
2202
+ isSavingAnnotations,
2203
+ canSaveAnnotations,
2204
+ onSaveAnnotations
2205
+ }
2206
+ ),
2207
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-main", children: [
2208
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2209
+ StablePDFViewer,
2210
+ {
2211
+ pdfBuffer: pdfBuffer || new ArrayBuffer(0),
2212
+ onPasswordRequest: handlePasswordRequest,
2213
+ pdfViewerRef,
2214
+ hideInternalLoading: true,
2215
+ showAnnotations,
2216
+ userDetails,
2217
+ annotationSelectionMenu,
2218
+ isHighlighterActive: highlighterActive,
2219
+ isStampActive: stampActive,
2220
+ onHighlighterClick: onHighlighterClick || toolbarHandlers.handleHighlighterClick,
2221
+ onStampClick: onStampClick || toolbarHandlers.handleStampClick,
2222
+ onSignatureClick: onSignatureClick || toolbarHandlers.handleSignatureClick,
2223
+ permissions: props.permissions
2224
+ }
2225
+ ) }),
2226
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2227
+ SearchSidebar,
2228
+ {
2229
+ isOpen: isSidebarOpen,
2230
+ onClose: handleSidebarClose,
2231
+ onSearch: handleSidebarSearch,
2232
+ onSearchResultClick: handleSearchResultClick,
2233
+ onNextResult: handleNextSearchResult,
2234
+ onPreviousResult: handlePreviousSearchResult,
2235
+ currentResultIndex: currentSearchResultIndex,
2236
+ totalResults: totalSearchResults,
2237
+ searchKeyword: searchQuery,
2238
+ searchResults,
2239
+ isSearching
2240
+ }
2241
+ )
2242
+ ] }),
2243
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2244
+ PasswordDialog,
2245
+ {
2246
+ open: isPasswordDialogOpen,
2247
+ fileName: resolvedFileName,
2248
+ onSubmit: handlePasswordSubmit,
2249
+ onCancel: handlePasswordCancel,
2250
+ error: passwordError,
2251
+ isLoading: isVerifyingPassword
2252
+ }
2253
+ )
2254
+ ] })
2255
+ ] });
2256
+ }
2257
+ );
2258
+ PDFViewerContent.displayName = "PDFViewerContent";
2259
+ var PDFViewer = _react.forwardRef.call(void 0,
2260
+ (props, ref) => {
2261
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PDFViewerContent, { ...props, sourceDescription: "doc.pdf", ref });
2262
+ }
2263
+ );
2264
+ PDFViewer.displayName = "PDFViewer";
2265
+
2266
+
2267
+
2268
+ exports.PDFViewer = PDFViewer;
2269
+ //# sourceMappingURL=chunk-7LPCKPN2.js.map