@cannyminds/dms-file-viewers 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,31 @@
5
5
  var _chunkRE4XRGSVjs = require('./chunk-RE4XRGSV.js');
6
6
 
7
7
  // src/components/viewers/PDFViewer.tsx
8
- var _react = require('react');
8
+ var _react = require('react'); var _react2 = _interopRequireDefault(_react);
9
+
10
+ // src/components/viewers/pdf/StablePDFViewer.tsx
11
+
9
12
  var _pdfviewer = require('@cannyminds/pdf-viewer');
13
+ var _jsxruntime = require('react/jsx-runtime');
14
+ var HeadlessPDFViewer = _pdfviewer.PDFViewer;
15
+ var StablePDFViewer = _react2.default.memo(({
16
+ pdfBuffer,
17
+ onPasswordRequest,
18
+ pdfViewerRef
19
+ }) => {
20
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
21
+ HeadlessPDFViewer,
22
+ {
23
+ ref: pdfViewerRef,
24
+ pdfBuffer,
25
+ onPasswordRequest
26
+ }
27
+ );
28
+ });
29
+ StablePDFViewer.displayName = "StablePDFViewer";
30
+
31
+ // src/components/viewers/pdf/PDFToolbar.tsx
32
+
10
33
  var _FirstPage = require('@mui/icons-material/FirstPage'); var _FirstPage2 = _interopRequireDefault(_FirstPage);
11
34
  var _LastPage = require('@mui/icons-material/LastPage'); var _LastPage2 = _interopRequireDefault(_LastPage);
12
35
  var _ChevronLeft = require('@mui/icons-material/ChevronLeft'); var _ChevronLeft2 = _interopRequireDefault(_ChevronLeft);
@@ -21,6 +44,214 @@ var _Print = require('@mui/icons-material/Print'); var _Print2 = _interopRequire
21
44
  var _Info = require('@mui/icons-material/Info'); var _Info2 = _interopRequireDefault(_Info);
22
45
  var _Description = require('@mui/icons-material/Description'); var _Description2 = _interopRequireDefault(_Description);
23
46
 
47
+ var PDFToolbar = _react2.default.memo(({
48
+ currentPage,
49
+ totalPages,
50
+ zoom,
51
+ isSidebarOpen,
52
+ showPageNavigation,
53
+ showPageCount,
54
+ showZoomControls,
55
+ showSearch,
56
+ showMetadata,
57
+ showProperties,
58
+ showDownload,
59
+ showPrint,
60
+ onFirstPage,
61
+ onPreviousPage,
62
+ onNextPage,
63
+ onLastPage,
64
+ onPageInput,
65
+ onPageInputKeyPress,
66
+ onZoomIn,
67
+ onZoomOut,
68
+ onFitToWidth,
69
+ onFitToPage,
70
+ onToggleSidebar,
71
+ onDownloadClick,
72
+ onPrintClick,
73
+ onMetadataClick,
74
+ onPropertiesClick
75
+ }) => {
76
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar", children: [
77
+ showPageNavigation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
78
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
79
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
80
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
81
+ "button",
82
+ {
83
+ className: "toolbar-button",
84
+ onClick: onFirstPage,
85
+ disabled: currentPage <= 1,
86
+ title: "First Page",
87
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
88
+ }
89
+ ),
90
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
91
+ "button",
92
+ {
93
+ className: "toolbar-button",
94
+ onClick: onPreviousPage,
95
+ disabled: currentPage <= 1,
96
+ title: "Previous Page",
97
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
98
+ }
99
+ ),
100
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
101
+ "input",
102
+ {
103
+ type: "number",
104
+ className: "page-input",
105
+ value: currentPage,
106
+ onChange: onPageInput,
107
+ onKeyPress: onPageInputKeyPress,
108
+ min: 1,
109
+ max: totalPages || void 0
110
+ }
111
+ ),
112
+ showPageCount && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "page-info", children: [
113
+ "of ",
114
+ totalPages || "..."
115
+ ] }),
116
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
117
+ "button",
118
+ {
119
+ className: "toolbar-button",
120
+ onClick: onNextPage,
121
+ disabled: currentPage >= totalPages,
122
+ title: "Next Page",
123
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
124
+ }
125
+ ),
126
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
127
+ "button",
128
+ {
129
+ className: "toolbar-button",
130
+ onClick: onLastPage,
131
+ disabled: currentPage >= totalPages,
132
+ title: "Last Page",
133
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
134
+ }
135
+ )
136
+ ] })
137
+ ] }),
138
+ showZoomControls && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
139
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
140
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
141
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
142
+ "button",
143
+ {
144
+ className: "toolbar-button",
145
+ onClick: onZoomOut,
146
+ title: "Zoom Out",
147
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomOut2.default, { fontSize: "small" })
148
+ }
149
+ ),
150
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "zoom-display", children: [
151
+ zoom,
152
+ "%"
153
+ ] }),
154
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
155
+ "button",
156
+ {
157
+ className: "toolbar-button",
158
+ onClick: onZoomIn,
159
+ title: "Zoom In",
160
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomIn2.default, { fontSize: "small" })
161
+ }
162
+ ),
163
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
164
+ "button",
165
+ {
166
+ className: "toolbar-button",
167
+ onClick: onFitToWidth,
168
+ title: "Fit to Width",
169
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" })
170
+ }
171
+ ),
172
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
173
+ "button",
174
+ {
175
+ className: "toolbar-button",
176
+ onClick: onFitToPage,
177
+ title: "Fit to Page",
178
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" })
179
+ }
180
+ )
181
+ ] })
182
+ ] }),
183
+ showSearch && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
184
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
185
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
186
+ "button",
187
+ {
188
+ className: "toolbar-button",
189
+ onClick: onToggleSidebar,
190
+ title: "Search in PDF",
191
+ style: {
192
+ backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
193
+ color: isSidebarOpen ? "#1976d2" : "inherit"
194
+ },
195
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { fontSize: "small" })
196
+ }
197
+ ) })
198
+ ] }),
199
+ (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
200
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
201
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
202
+ showDownload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
203
+ "button",
204
+ {
205
+ className: "toolbar-button",
206
+ onClick: onDownloadClick,
207
+ title: "Download PDF",
208
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
209
+ }
210
+ ),
211
+ showPrint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
212
+ "button",
213
+ {
214
+ className: "toolbar-button",
215
+ onClick: onPrintClick,
216
+ title: "Print PDF",
217
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
218
+ }
219
+ ),
220
+ showMetadata && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
221
+ "button",
222
+ {
223
+ className: "toolbar-button",
224
+ onClick: onMetadataClick,
225
+ title: "Document Metadata",
226
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
227
+ }
228
+ ),
229
+ showProperties && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
230
+ "button",
231
+ {
232
+ className: "toolbar-button",
233
+ onClick: onPropertiesClick,
234
+ title: "Document Properties",
235
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
236
+ }
237
+ )
238
+ ] })
239
+ ] })
240
+ ] });
241
+ });
242
+ PDFToolbar.displayName = "PDFToolbar";
243
+
244
+ // src/components/viewers/pdf/PDFHeader.tsx
245
+
246
+
247
+ var PDFHeader = _react2.default.memo(({ fileName, fileExtension }) => {
248
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-header", children: [
249
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRE4XRGSVjs.FileIcon_default, { ext: fileExtension, size: 26 }),
250
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "header-file-name", title: fileName, children: fileName })
251
+ ] });
252
+ });
253
+ PDFHeader.displayName = "PDFHeader";
254
+
24
255
  // src/components/viewers/pdf/SearchSidebar.tsx
25
256
 
26
257
 
@@ -37,7 +268,7 @@ var _KeyboardArrowUp = require('@mui/icons-material/KeyboardArrowUp'); var _Keyb
37
268
  var _KeyboardArrowDown = require('@mui/icons-material/KeyboardArrowDown'); var _KeyboardArrowDown2 = _interopRequireDefault(_KeyboardArrowDown);
38
269
  var _Clear = require('@mui/icons-material/Clear'); var _Clear2 = _interopRequireDefault(_Clear);
39
270
  var _FindInPage = require('@mui/icons-material/FindInPage'); var _FindInPage2 = _interopRequireDefault(_FindInPage);
40
- var _jsxruntime = require('react/jsx-runtime');
271
+
41
272
  var SearchSidebar = ({
42
273
  isOpen,
43
274
  onClose,
@@ -661,19 +892,17 @@ var PasswordDialog = ({
661
892
  );
662
893
  };
663
894
 
664
- // src/components/viewers/PDFViewer.tsx
665
-
666
- var HeadlessPDFViewer = _pdfviewer.PDFViewer;
895
+ // src/components/viewers/pdf/PDFStyles.tsx
667
896
  var toolbarStyles = `
668
897
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');
669
-
898
+
670
899
  * {
671
900
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
672
901
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
673
- 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
902
+ 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
674
903
  'Arial Unicode MS', sans-serif !important;
675
904
  }
676
-
905
+
677
906
  /* Target PDF.js text layer */
678
907
  .textLayer,
679
908
  .textLayer span,
@@ -686,10 +915,10 @@ var toolbarStyles = `
686
915
  [role="document"] * {
687
916
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
688
917
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
689
- 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
918
+ 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
690
919
  'Arial Unicode MS', sans-serif !important;
691
920
  }
692
-
921
+
693
922
  .pdf-viewer-header {
694
923
  display: flex;
695
924
  align-items: center;
@@ -815,6 +1044,9 @@ var toolbarStyles = `
815
1044
  -ms-user-select: text !important;
816
1045
  }
817
1046
  `;
1047
+
1048
+ // src/components/viewers/PDFViewer.tsx
1049
+
818
1050
  var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
819
1051
  const {
820
1052
  file,
@@ -867,6 +1099,111 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
867
1099
  const [isPasswordDialogOpen, setIsPasswordDialogOpen] = _react.useState.call(void 0, false);
868
1100
  const [passwordError, setPasswordError] = _react.useState.call(void 0, "");
869
1101
  const [passwordResolve, setPasswordResolve] = _react.useState.call(void 0, null);
1102
+ const hasExecutedInitialSearch = _react.useRef.call(void 0, false);
1103
+ const toolbarHandlers = _react.useMemo.call(void 0, () => ({
1104
+ handleZoomIn: () => {
1105
+ _optionalChain([pdfViewerRef, 'access', _ => _.current, 'optionalAccess', _2 => _2.zoom, 'access', _3 => _3.zoomIn, 'call', _4 => _4()]);
1106
+ requestAnimationFrame(() => {
1107
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _5 => _5.current, 'optionalAccess', _6 => _6.zoom, 'access', _7 => _7.getZoom, 'call', _8 => _8()]);
1108
+ if (typeof zoomValue === "number") {
1109
+ setZoom(Math.round(zoomValue * 100));
1110
+ }
1111
+ });
1112
+ },
1113
+ handleZoomOut: () => {
1114
+ _optionalChain([pdfViewerRef, 'access', _9 => _9.current, 'optionalAccess', _10 => _10.zoom, 'access', _11 => _11.zoomOut, 'call', _12 => _12()]);
1115
+ requestAnimationFrame(() => {
1116
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _13 => _13.current, 'optionalAccess', _14 => _14.zoom, 'access', _15 => _15.getZoom, 'call', _16 => _16()]);
1117
+ if (typeof zoomValue === "number") {
1118
+ setZoom(Math.round(zoomValue * 100));
1119
+ }
1120
+ });
1121
+ },
1122
+ handleFitToWidth: () => {
1123
+ _optionalChain([pdfViewerRef, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.zoom, 'access', _19 => _19.fitToWidth, 'call', _20 => _20()]);
1124
+ requestAnimationFrame(() => {
1125
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _21 => _21.current, 'optionalAccess', _22 => _22.zoom, 'access', _23 => _23.getZoom, 'call', _24 => _24()]);
1126
+ if (typeof zoomValue === "number") {
1127
+ setZoom(Math.round(zoomValue * 100));
1128
+ }
1129
+ });
1130
+ },
1131
+ handleFitToPage: () => {
1132
+ _optionalChain([pdfViewerRef, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.zoom, 'access', _27 => _27.fitToPage, 'call', _28 => _28()]);
1133
+ requestAnimationFrame(() => {
1134
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _29 => _29.current, 'optionalAccess', _30 => _30.zoom, 'access', _31 => _31.getZoom, 'call', _32 => _32()]);
1135
+ if (typeof zoomValue === "number") {
1136
+ setZoom(Math.round(zoomValue * 100));
1137
+ }
1138
+ });
1139
+ },
1140
+ handlePreviousPage: () => {
1141
+ _optionalChain([pdfViewerRef, 'access', _33 => _33.current, 'optionalAccess', _34 => _34.navigation, 'access', _35 => _35.previousPage, 'call', _36 => _36()]);
1142
+ requestAnimationFrame(() => {
1143
+ const current = _optionalChain([pdfViewerRef, 'access', _37 => _37.current, 'optionalAccess', _38 => _38.navigation, 'access', _39 => _39.getCurrentPage, 'call', _40 => _40()]) || 1;
1144
+ setCurrentPage(current);
1145
+ });
1146
+ },
1147
+ handleNextPage: () => {
1148
+ _optionalChain([pdfViewerRef, 'access', _41 => _41.current, 'optionalAccess', _42 => _42.navigation, 'access', _43 => _43.nextPage, 'call', _44 => _44()]);
1149
+ requestAnimationFrame(() => {
1150
+ const current = _optionalChain([pdfViewerRef, 'access', _45 => _45.current, 'optionalAccess', _46 => _46.navigation, 'access', _47 => _47.getCurrentPage, 'call', _48 => _48()]) || 1;
1151
+ setCurrentPage(current);
1152
+ });
1153
+ },
1154
+ handleFirstPage: () => {
1155
+ _optionalChain([pdfViewerRef, 'access', _49 => _49.current, 'optionalAccess', _50 => _50.navigation, 'access', _51 => _51.goToFirstPage, 'call', _52 => _52()]);
1156
+ requestAnimationFrame(() => {
1157
+ const current = _optionalChain([pdfViewerRef, 'access', _53 => _53.current, 'optionalAccess', _54 => _54.navigation, 'access', _55 => _55.getCurrentPage, 'call', _56 => _56()]) || 1;
1158
+ setCurrentPage(current);
1159
+ });
1160
+ },
1161
+ handleLastPage: () => {
1162
+ _optionalChain([pdfViewerRef, 'access', _57 => _57.current, 'optionalAccess', _58 => _58.navigation, 'access', _59 => _59.goToLastPage, 'call', _60 => _60()]);
1163
+ requestAnimationFrame(() => {
1164
+ const current = _optionalChain([pdfViewerRef, 'access', _61 => _61.current, 'optionalAccess', _62 => _62.navigation, 'access', _63 => _63.getCurrentPage, 'call', _64 => _64()]) || 1;
1165
+ setCurrentPage(current);
1166
+ });
1167
+ },
1168
+ toggleSidebar: () => setIsSidebarOpen(!isSidebarOpen),
1169
+ handlePageInput: (e) => {
1170
+ const value = e.target.value;
1171
+ if (/^\d*$/.test(value)) {
1172
+ return;
1173
+ }
1174
+ const page = parseInt(value, 10);
1175
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1176
+ _optionalChain([pdfViewerRef, 'access', _65 => _65.current, 'optionalAccess', _66 => _66.navigation, 'access', _67 => _67.goToPage, 'call', _68 => _68(page)]);
1177
+ setCurrentPage(page);
1178
+ }
1179
+ },
1180
+ handlePageInputKeyPress: (e) => {
1181
+ if (e.key === "Enter") {
1182
+ const value = e.target.value;
1183
+ const page = parseInt(value, 10);
1184
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1185
+ _optionalChain([pdfViewerRef, 'access', _69 => _69.current, 'optionalAccess', _70 => _70.navigation, 'access', _71 => _71.goToPage, 'call', _72 => _72(page)]);
1186
+ setCurrentPage(page);
1187
+ }
1188
+ }
1189
+ }
1190
+ }), [isSidebarOpen, totalPages]);
1191
+ _react.useEffect.call(void 0, () => {
1192
+ console.log("came", initialSearchText, pdfViewerRef.current, hasExecutedInitialSearch.current);
1193
+ if (pdfViewerRef.current && !hasExecutedInitialSearch.current && initialSearchText) {
1194
+ hasExecutedInitialSearch.current = true;
1195
+ setIsSidebarOpen(true);
1196
+ setSearchQuery(initialSearchText);
1197
+ handleSidebarSearch(initialSearchText, initialSearchPages);
1198
+ setAutoExecuteSearch(false);
1199
+ pdfViewerRef.current.search.searchText(initialSearchText).then((results) => {
1200
+ console.log("results", results);
1201
+ if (_optionalChain([results, 'optionalAccess', _73 => _73.results, 'optionalAccess', _74 => _74.length]) > 0) {
1202
+ _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.navigation, 'access', _77 => _77.goToPage, 'call', _78 => _78(results.results[0].pageIndex + 1)]);
1203
+ }
1204
+ });
1205
+ }
1206
+ }, [pdfViewerRef.current, initialSearchText]);
870
1207
  _react.useEffect.call(void 0, () => {
871
1208
  setSearchQuery("");
872
1209
  setSearchResults([]);
@@ -914,7 +1251,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
914
1251
  if (!viewer) return;
915
1252
  await new Promise((resolve) => requestAnimationFrame(resolve));
916
1253
  try {
917
- const count = _optionalChain([viewer, 'access', _ => _.navigation, 'optionalAccess', _2 => _2.getTotalPages, 'optionalCall', _3 => _3()]);
1254
+ const count = _optionalChain([viewer, 'access', _79 => _79.navigation, 'optionalAccess', _80 => _80.getTotalPages, 'optionalCall', _81 => _81()]);
918
1255
  if (count && count > 1) {
919
1256
  setTotalPages(count);
920
1257
  return;
@@ -922,11 +1259,11 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
922
1259
  } catch (e) {
923
1260
  }
924
1261
  try {
925
- const results = await _optionalChain([viewer, 'access', _4 => _4.search, 'optionalAccess', _5 => _5.searchText, 'optionalCall', _6 => _6("e")]);
926
- if (_optionalChain([results, 'optionalAccess', _7 => _7.results]) && results.results.length > 0) {
1262
+ const results = await _optionalChain([viewer, 'access', _82 => _82.search, 'optionalAccess', _83 => _83.searchText, 'optionalCall', _84 => _84("e")]);
1263
+ if (_optionalChain([results, 'optionalAccess', _85 => _85.results]) && results.results.length > 0) {
927
1264
  const pageIndices = results.results.map((m) => m.pageIndex).filter((idx) => typeof idx === "number");
928
1265
  const count = Math.max(...pageIndices) + 1;
929
- _optionalChain([viewer, 'access', _8 => _8.search, 'optionalAccess', _9 => _9.stopSearch, 'optionalCall', _10 => _10()]);
1266
+ _optionalChain([viewer, 'access', _86 => _86.search, 'optionalAccess', _87 => _87.stopSearch, 'optionalCall', _88 => _88()]);
930
1267
  setTotalPages(count);
931
1268
  return;
932
1269
  }
@@ -954,30 +1291,13 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
954
1291
  };
955
1292
  initializePageCount();
956
1293
  }, [state, totalPages]);
957
- _react.useEffect.call(void 0, () => {
958
- if (state !== "ready" || !autoExecuteSearch || !initialSearchText) return;
959
- const scheduleSearch = (callback) => {
960
- if ("requestIdleCallback" in window) {
961
- requestIdleCallback(callback, { timeout: 2e3 });
962
- } else {
963
- requestAnimationFrame(() => setTimeout(callback, 0));
964
- }
965
- };
966
- scheduleSearch(() => {
967
- if (!pdfViewerRef.current) return;
968
- setIsSidebarOpen(true);
969
- setSearchQuery(initialSearchText);
970
- handleSidebarSearch(initialSearchText, initialSearchPages);
971
- setAutoExecuteSearch(false);
972
- });
973
- }, [state, autoExecuteSearch, initialSearchText, initialSearchPages]);
974
1294
  _react.useEffect.call(void 0, () => {
975
1295
  if (state === "ready" && pdfViewerRef.current) {
976
1296
  const updateInfo = () => {
977
- const current = _optionalChain([pdfViewerRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.navigation, 'access', _13 => _13.getCurrentPage, 'call', _14 => _14()]) || 1;
978
- const total = _optionalChain([pdfViewerRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.navigation, 'access', _17 => _17.getTotalPages, 'call', _18 => _18()]) || 0;
979
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.zoom, 'access', _21 => _21.getZoom, 'call', _22 => _22()]);
980
- const currentSearchState = _optionalChain([pdfViewerRef, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.search, 'access', _25 => _25.getSearchState, 'call', _26 => _26()]);
1297
+ const current = _optionalChain([pdfViewerRef, 'access', _89 => _89.current, 'optionalAccess', _90 => _90.navigation, 'access', _91 => _91.getCurrentPage, 'call', _92 => _92()]) || 1;
1298
+ const total = _optionalChain([pdfViewerRef, 'access', _93 => _93.current, 'optionalAccess', _94 => _94.navigation, 'access', _95 => _95.getTotalPages, 'call', _96 => _96()]) || 0;
1299
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _97 => _97.current, 'optionalAccess', _98 => _98.zoom, 'access', _99 => _99.getZoom, 'call', _100 => _100()]);
1300
+ const currentSearchState = _optionalChain([pdfViewerRef, 'access', _101 => _101.current, 'optionalAccess', _102 => _102.search, 'access', _103 => _103.getSearchState, 'call', _104 => _104()]);
981
1301
  setCurrentPage(current);
982
1302
  if (total > 0 && total !== totalPages) {
983
1303
  setTotalPages(total);
@@ -993,142 +1313,89 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
993
1313
  }, [state, totalPages]);
994
1314
  _react.useImperativeHandle.call(void 0, ref, () => ({
995
1315
  zoomIn: () => {
996
- _optionalChain([pdfViewerRef, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.zoom, 'access', _29 => _29.zoomIn, 'call', _30 => _30()]);
1316
+ _optionalChain([pdfViewerRef, 'access', _105 => _105.current, 'optionalAccess', _106 => _106.zoom, 'access', _107 => _107.zoomIn, 'call', _108 => _108()]);
997
1317
  updateZoomDisplay();
998
1318
  },
999
1319
  zoomOut: () => {
1000
- _optionalChain([pdfViewerRef, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.zoom, 'access', _33 => _33.zoomOut, 'call', _34 => _34()]);
1320
+ _optionalChain([pdfViewerRef, 'access', _109 => _109.current, 'optionalAccess', _110 => _110.zoom, 'access', _111 => _111.zoomOut, 'call', _112 => _112()]);
1001
1321
  updateZoomDisplay();
1002
1322
  },
1003
1323
  setZoom: (level) => {
1004
- _optionalChain([pdfViewerRef, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.zoom, 'access', _37 => _37.setZoom, 'call', _38 => _38(level)]);
1324
+ _optionalChain([pdfViewerRef, 'access', _113 => _113.current, 'optionalAccess', _114 => _114.zoom, 'access', _115 => _115.setZoom, 'call', _116 => _116(level)]);
1005
1325
  updateZoomDisplay();
1006
1326
  },
1007
1327
  resetZoom: () => {
1008
- _optionalChain([pdfViewerRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.zoom, 'access', _41 => _41.resetZoom, 'call', _42 => _42()]);
1328
+ _optionalChain([pdfViewerRef, 'access', _117 => _117.current, 'optionalAccess', _118 => _118.zoom, 'access', _119 => _119.resetZoom, 'call', _120 => _120()]);
1009
1329
  updateZoomDisplay();
1010
1330
  },
1011
1331
  getZoom: () => {
1012
- const zoom2 = _optionalChain([pdfViewerRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.zoom, 'access', _45 => _45.getZoom, 'call', _46 => _46()]);
1332
+ const zoom2 = _optionalChain([pdfViewerRef, 'access', _121 => _121.current, 'optionalAccess', _122 => _122.zoom, 'access', _123 => _123.getZoom, 'call', _124 => _124()]);
1013
1333
  return typeof zoom2 === "number" ? zoom2 : 1;
1014
1334
  },
1015
1335
  goToPage: (page) => {
1016
- _optionalChain([pdfViewerRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.navigation, 'access', _49 => _49.goToPage, 'call', _50 => _50(page)]);
1336
+ _optionalChain([pdfViewerRef, 'access', _125 => _125.current, 'optionalAccess', _126 => _126.navigation, 'access', _127 => _127.goToPage, 'call', _128 => _128(page)]);
1017
1337
  setCurrentPage(page);
1018
1338
  },
1019
- getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.navigation, 'access', _53 => _53.getCurrentPage, 'call', _54 => _54()]) || 1,
1020
- getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.navigation, 'access', _57 => _57.getTotalPages, 'call', _58 => _58()]) || 0,
1339
+ getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _129 => _129.current, 'optionalAccess', _130 => _130.navigation, 'access', _131 => _131.getCurrentPage, 'call', _132 => _132()]) || 1,
1340
+ getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.navigation, 'access', _135 => _135.getTotalPages, 'call', _136 => _136()]) || 0,
1021
1341
  nextPage: () => {
1022
- _optionalChain([pdfViewerRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.navigation, 'access', _61 => _61.nextPage, 'call', _62 => _62()]);
1342
+ _optionalChain([pdfViewerRef, 'access', _137 => _137.current, 'optionalAccess', _138 => _138.navigation, 'access', _139 => _139.nextPage, 'call', _140 => _140()]);
1023
1343
  updatePageDisplay();
1024
1344
  },
1025
1345
  previousPage: () => {
1026
- _optionalChain([pdfViewerRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.navigation, 'access', _65 => _65.previousPage, 'call', _66 => _66()]);
1346
+ _optionalChain([pdfViewerRef, 'access', _141 => _141.current, 'optionalAccess', _142 => _142.navigation, 'access', _143 => _143.previousPage, 'call', _144 => _144()]);
1027
1347
  updatePageDisplay();
1028
1348
  },
1029
1349
  goToFirstPage: () => {
1030
- _optionalChain([pdfViewerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.navigation, 'access', _69 => _69.goToFirstPage, 'call', _70 => _70()]);
1350
+ _optionalChain([pdfViewerRef, 'access', _145 => _145.current, 'optionalAccess', _146 => _146.navigation, 'access', _147 => _147.goToFirstPage, 'call', _148 => _148()]);
1031
1351
  updatePageDisplay();
1032
1352
  },
1033
1353
  goToLastPage: () => {
1034
- _optionalChain([pdfViewerRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.navigation, 'access', _73 => _73.goToLastPage, 'call', _74 => _74()]);
1354
+ _optionalChain([pdfViewerRef, 'access', _149 => _149.current, 'optionalAccess', _150 => _150.navigation, 'access', _151 => _151.goToLastPage, 'call', _152 => _152()]);
1035
1355
  updatePageDisplay();
1036
1356
  },
1037
1357
  searchText: async (keyword) => {
1038
1358
  setIsSearching(true);
1039
- const results = await _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.search, 'access', _77 => _77.searchText, 'call', _78 => _78(keyword)]);
1359
+ const results = await _optionalChain([pdfViewerRef, 'access', _153 => _153.current, 'optionalAccess', _154 => _154.search, 'access', _155 => _155.searchText, 'call', _156 => _156(keyword)]);
1040
1360
  setIsSearching(false);
1041
1361
  setSearchQuery(keyword);
1042
1362
  return results;
1043
1363
  },
1044
1364
  nextResult: () => {
1045
- const index = _optionalChain([pdfViewerRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.search, 'access', _81 => _81.nextResult, 'call', _82 => _82()]) || -1;
1365
+ const index = _optionalChain([pdfViewerRef, 'access', _157 => _157.current, 'optionalAccess', _158 => _158.search, 'access', _159 => _159.nextResult, 'call', _160 => _160()]) || -1;
1046
1366
  return index;
1047
1367
  },
1048
1368
  previousResult: () => {
1049
- const index = _optionalChain([pdfViewerRef, 'access', _83 => _83.current, 'optionalAccess', _84 => _84.search, 'access', _85 => _85.previousResult, 'call', _86 => _86()]) || -1;
1369
+ const index = _optionalChain([pdfViewerRef, 'access', _161 => _161.current, 'optionalAccess', _162 => _162.search, 'access', _163 => _163.previousResult, 'call', _164 => _164()]) || -1;
1050
1370
  return index;
1051
1371
  },
1052
- goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _87 => _87.current, 'optionalAccess', _88 => _88.search, 'access', _89 => _89.goToResult, 'call', _90 => _90(index)]) || -1,
1372
+ goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _165 => _165.current, 'optionalAccess', _166 => _166.search, 'access', _167 => _167.goToResult, 'call', _168 => _168(index)]) || -1,
1053
1373
  stopSearch: () => {
1054
- _optionalChain([pdfViewerRef, 'access', _91 => _91.current, 'optionalAccess', _92 => _92.search, 'access', _93 => _93.stopSearch, 'call', _94 => _94()]);
1374
+ _optionalChain([pdfViewerRef, 'access', _169 => _169.current, 'optionalAccess', _170 => _170.search, 'access', _171 => _171.stopSearch, 'call', _172 => _172()]);
1055
1375
  setSearchQuery("");
1056
1376
  },
1057
- getSearchState: () => _optionalChain([pdfViewerRef, 'access', _95 => _95.current, 'optionalAccess', _96 => _96.search, 'access', _97 => _97.getSearchState, 'call', _98 => _98()]) || null,
1058
- getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _99 => _99.current, 'optionalAccess', _100 => _100.selection, 'access', _101 => _101.getSelectedText, 'call', _102 => _102()]) || "",
1059
- clearSelection: () => _optionalChain([pdfViewerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.selection, 'access', _105 => _105.clearSelection, 'call', _106 => _106()])
1377
+ getSearchState: () => _optionalChain([pdfViewerRef, 'access', _173 => _173.current, 'optionalAccess', _174 => _174.search, 'access', _175 => _175.getSearchState, 'call', _176 => _176()]) || null,
1378
+ getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _177 => _177.current, 'optionalAccess', _178 => _178.selection, 'access', _179 => _179.getSelectedText, 'call', _180 => _180()]) || "",
1379
+ clearSelection: () => _optionalChain([pdfViewerRef, 'access', _181 => _181.current, 'optionalAccess', _182 => _182.selection, 'access', _183 => _183.clearSelection, 'call', _184 => _184()])
1060
1380
  }), []);
1061
1381
  const updatePageDisplay = () => {
1062
1382
  requestAnimationFrame(() => {
1063
- const current = _optionalChain([pdfViewerRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.navigation, 'access', _109 => _109.getCurrentPage, 'call', _110 => _110()]) || 1;
1383
+ const current = _optionalChain([pdfViewerRef, 'access', _185 => _185.current, 'optionalAccess', _186 => _186.navigation, 'access', _187 => _187.getCurrentPage, 'call', _188 => _188()]) || 1;
1064
1384
  setCurrentPage(current);
1065
1385
  });
1066
1386
  };
1067
1387
  const updateZoomDisplay = () => {
1068
1388
  requestAnimationFrame(() => {
1069
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _111 => _111.current, 'optionalAccess', _112 => _112.zoom, 'access', _113 => _113.getZoom, 'call', _114 => _114()]);
1389
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _189 => _189.current, 'optionalAccess', _190 => _190.zoom, 'access', _191 => _191.getZoom, 'call', _192 => _192()]);
1070
1390
  if (typeof zoomValue === "number") {
1071
1391
  setZoom(Math.round(zoomValue * 100));
1072
1392
  }
1073
1393
  });
1074
1394
  };
1075
- const handleZoomIn = () => {
1076
- _optionalChain([pdfViewerRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.zoom, 'access', _117 => _117.zoomIn, 'call', _118 => _118()]);
1077
- updateZoomDisplay();
1078
- };
1079
- const handleZoomOut = () => {
1080
- _optionalChain([pdfViewerRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.zoom, 'access', _121 => _121.zoomOut, 'call', _122 => _122()]);
1081
- updateZoomDisplay();
1082
- };
1083
- const handleFitToWidth = () => {
1084
- _optionalChain([pdfViewerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.zoom, 'access', _125 => _125.fitToWidth, 'call', _126 => _126()]);
1085
- updateZoomDisplay();
1086
- };
1087
- const handleFitToPage = () => {
1088
- _optionalChain([pdfViewerRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.zoom, 'access', _129 => _129.fitToPage, 'call', _130 => _130()]);
1089
- updateZoomDisplay();
1090
- };
1091
- const handlePreviousPage = () => {
1092
- _optionalChain([pdfViewerRef, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.navigation, 'access', _133 => _133.previousPage, 'call', _134 => _134()]);
1093
- updatePageDisplay();
1094
- };
1095
- const handleNextPage = () => {
1096
- _optionalChain([pdfViewerRef, 'access', _135 => _135.current, 'optionalAccess', _136 => _136.navigation, 'access', _137 => _137.nextPage, 'call', _138 => _138()]);
1097
- updatePageDisplay();
1098
- };
1099
- const handleFirstPage = () => {
1100
- _optionalChain([pdfViewerRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.navigation, 'access', _141 => _141.goToFirstPage, 'call', _142 => _142()]);
1101
- updatePageDisplay();
1102
- };
1103
- const handleLastPage = () => {
1104
- _optionalChain([pdfViewerRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.navigation, 'access', _145 => _145.goToLastPage, 'call', _146 => _146()]);
1105
- updatePageDisplay();
1106
- };
1107
- const handlePageInput = (e) => {
1108
- const value = e.target.value;
1109
- const page = parseInt(value, 10);
1110
- if (/^\d*$/.test(value)) {
1111
- return;
1112
- }
1113
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1114
- _optionalChain([pdfViewerRef, 'access', _147 => _147.current, 'optionalAccess', _148 => _148.navigation, 'access', _149 => _149.goToPage, 'call', _150 => _150(page)]);
1115
- setCurrentPage(page);
1116
- }
1117
- };
1118
- const handlePageInputKeyPress = (e) => {
1119
- if (e.key === "Enter") {
1120
- const value = e.target.value;
1121
- const page = parseInt(value, 10);
1122
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1123
- _optionalChain([pdfViewerRef, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.navigation, 'access', _153 => _153.goToPage, 'call', _154 => _154(page)]);
1124
- setCurrentPage(page);
1125
- }
1126
- }
1127
- };
1128
1395
  const handleSearch = async () => {
1129
1396
  if (searchQuery.trim()) {
1130
1397
  setIsSearching(true);
1131
- const results = await _optionalChain([pdfViewerRef, 'access', _155 => _155.current, 'optionalAccess', _156 => _156.search, 'access', _157 => _157.searchText, 'call', _158 => _158(searchQuery)]);
1398
+ const results = await _optionalChain([pdfViewerRef, 'access', _193 => _193.current, 'optionalAccess', _194 => _194.search, 'access', _195 => _195.searchText, 'call', _196 => _196(searchQuery)]);
1132
1399
  setIsSearching(false);
1133
1400
  if (results && results.results) {
1134
1401
  const formattedResults = results.results.map((result, index) => {
@@ -1176,7 +1443,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1176
1443
  setSearchQuery(keyword);
1177
1444
  if (keyword.trim()) {
1178
1445
  setIsSearching(true);
1179
- const results = await _optionalChain([pdfViewerRef, 'access', _159 => _159.current, 'optionalAccess', _160 => _160.search, 'access', _161 => _161.searchText, 'call', _162 => _162(keyword)]);
1446
+ const results = await _optionalChain([pdfViewerRef, 'access', _197 => _197.current, 'optionalAccess', _198 => _198.search, 'access', _199 => _199.searchText, 'call', _200 => _200(keyword)]);
1180
1447
  setIsSearching(false);
1181
1448
  if (results && results.results && results.results.length > 0) {
1182
1449
  const formattedResults = results.results.map((result, index) => {
@@ -1207,7 +1474,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1207
1474
  setCurrentSearchResultIndex(0);
1208
1475
  if (formattedResults.length > 0) {
1209
1476
  const firstPageNumber = formattedResults[0].pageNumber;
1210
- _optionalChain([pdfViewerRef, 'access', _163 => _163.current, 'optionalAccess', _164 => _164.navigation, 'access', _165 => _165.goToPage, 'call', _166 => _166(firstPageNumber)]);
1477
+ _optionalChain([pdfViewerRef, 'access', _201 => _201.current, 'optionalAccess', _202 => _202.navigation, 'access', _203 => _203.goToPage, 'call', _204 => _204(firstPageNumber)]);
1211
1478
  setCurrentPage(firstPageNumber);
1212
1479
  }
1213
1480
  } else if (pageNumbers && pageNumbers.length > 0) {
@@ -1220,7 +1487,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1220
1487
  setSearchResults(fallbackResults);
1221
1488
  setTotalSearchResults(fallbackResults.length);
1222
1489
  setCurrentSearchResultIndex(0);
1223
- _optionalChain([pdfViewerRef, 'access', _167 => _167.current, 'optionalAccess', _168 => _168.navigation, 'access', _169 => _169.goToPage, 'call', _170 => _170(pageNumbers[0])]);
1490
+ _optionalChain([pdfViewerRef, 'access', _205 => _205.current, 'optionalAccess', _206 => _206.navigation, 'access', _207 => _207.goToPage, 'call', _208 => _208(pageNumbers[0])]);
1224
1491
  setCurrentPage(pageNumbers[0]);
1225
1492
  } else {
1226
1493
  setSearchResults([]);
@@ -1229,28 +1496,25 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1229
1496
  }
1230
1497
  } else {
1231
1498
  setSearchResults([]);
1232
- _optionalChain([pdfViewerRef, 'access', _171 => _171.current, 'optionalAccess', _172 => _172.search, 'access', _173 => _173.stopSearch, 'call', _174 => _174()]);
1499
+ _optionalChain([pdfViewerRef, 'access', _209 => _209.current, 'optionalAccess', _210 => _210.search, 'access', _211 => _211.stopSearch, 'call', _212 => _212()]);
1233
1500
  setTotalSearchResults(0);
1234
1501
  setCurrentSearchResultIndex(0);
1235
1502
  }
1236
1503
  };
1237
1504
  const handleSearchResultClick = (pageNumber, resultIndex) => {
1238
- _optionalChain([pdfViewerRef, 'access', _175 => _175.current, 'optionalAccess', _176 => _176.navigation, 'access', _177 => _177.goToPage, 'call', _178 => _178(pageNumber)]);
1505
+ _optionalChain([pdfViewerRef, 'access', _213 => _213.current, 'optionalAccess', _214 => _214.navigation, 'access', _215 => _215.goToPage, 'call', _216 => _216(pageNumber)]);
1239
1506
  setCurrentSearchResultIndex(resultIndex);
1240
1507
  setCurrentPage(pageNumber);
1241
- _optionalChain([pdfViewerRef, 'access', _179 => _179.current, 'optionalAccess', _180 => _180.search, 'access', _181 => _181.goToResult, 'call', _182 => _182(resultIndex)]);
1242
- };
1243
- const toggleSidebar = () => {
1244
- setIsSidebarOpen(!isSidebarOpen);
1508
+ _optionalChain([pdfViewerRef, 'access', _217 => _217.current, 'optionalAccess', _218 => _218.search, 'access', _219 => _219.goToResult, 'call', _220 => _220(resultIndex)]);
1245
1509
  };
1246
1510
  const handleNextSearchResult = () => {
1247
1511
  if (currentSearchResultIndex < totalSearchResults - 1) {
1248
1512
  const nextIndex = currentSearchResultIndex + 1;
1249
1513
  setCurrentSearchResultIndex(nextIndex);
1250
- _optionalChain([pdfViewerRef, 'access', _183 => _183.current, 'optionalAccess', _184 => _184.search, 'access', _185 => _185.nextResult, 'call', _186 => _186()]);
1514
+ _optionalChain([pdfViewerRef, 'access', _221 => _221.current, 'optionalAccess', _222 => _222.search, 'access', _223 => _223.nextResult, 'call', _224 => _224()]);
1251
1515
  if (searchResults[nextIndex]) {
1252
1516
  const pageNumber = searchResults[nextIndex].pageNumber;
1253
- _optionalChain([pdfViewerRef, 'access', _187 => _187.current, 'optionalAccess', _188 => _188.navigation, 'access', _189 => _189.goToPage, 'call', _190 => _190(pageNumber)]);
1517
+ _optionalChain([pdfViewerRef, 'access', _225 => _225.current, 'optionalAccess', _226 => _226.navigation, 'access', _227 => _227.goToPage, 'call', _228 => _228(pageNumber)]);
1254
1518
  setCurrentPage(pageNumber);
1255
1519
  }
1256
1520
  }
@@ -1259,77 +1523,14 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1259
1523
  if (currentSearchResultIndex > 0) {
1260
1524
  const prevIndex = currentSearchResultIndex - 1;
1261
1525
  setCurrentSearchResultIndex(prevIndex);
1262
- _optionalChain([pdfViewerRef, 'access', _191 => _191.current, 'optionalAccess', _192 => _192.search, 'access', _193 => _193.previousResult, 'call', _194 => _194()]);
1526
+ _optionalChain([pdfViewerRef, 'access', _229 => _229.current, 'optionalAccess', _230 => _230.search, 'access', _231 => _231.previousResult, 'call', _232 => _232()]);
1263
1527
  if (searchResults[prevIndex]) {
1264
1528
  const pageNumber = searchResults[prevIndex].pageNumber;
1265
- _optionalChain([pdfViewerRef, 'access', _195 => _195.current, 'optionalAccess', _196 => _196.navigation, 'access', _197 => _197.goToPage, 'call', _198 => _198(pageNumber)]);
1529
+ _optionalChain([pdfViewerRef, 'access', _233 => _233.current, 'optionalAccess', _234 => _234.navigation, 'access', _235 => _235.goToPage, 'call', _236 => _236(pageNumber)]);
1266
1530
  setCurrentPage(pageNumber);
1267
1531
  }
1268
1532
  }
1269
1533
  };
1270
- const handlePrint = () => {
1271
- if (onPrintClick) {
1272
- onPrintClick();
1273
- return;
1274
- }
1275
- if (!pdfBuffer) return;
1276
- const blob = new Blob([pdfBuffer], { type: "application/pdf" });
1277
- const blobUrl = URL.createObjectURL(blob);
1278
- const iframe = document.createElement("iframe");
1279
- iframe.style.position = "fixed";
1280
- iframe.style.right = "0";
1281
- iframe.style.bottom = "0";
1282
- iframe.style.width = "0";
1283
- iframe.style.height = "0";
1284
- iframe.style.border = "0";
1285
- document.body.appendChild(iframe);
1286
- iframe.onload = () => {
1287
- try {
1288
- requestAnimationFrame(() => {
1289
- const iframeWindow = iframe.contentWindow;
1290
- if (!iframeWindow) return;
1291
- iframeWindow.focus();
1292
- iframeWindow.print();
1293
- const cleanup = () => {
1294
- requestAnimationFrame(() => {
1295
- try {
1296
- if (document.body.contains(iframe)) {
1297
- document.body.removeChild(iframe);
1298
- }
1299
- URL.revokeObjectURL(blobUrl);
1300
- } catch (e) {
1301
- }
1302
- });
1303
- };
1304
- if ("onafterprint" in iframeWindow) {
1305
- iframeWindow.onafterprint = cleanup;
1306
- } else {
1307
- const visibilityHandler = () => {
1308
- if (!document.hidden) {
1309
- cleanup();
1310
- document.removeEventListener("visibilitychange", visibilityHandler);
1311
- }
1312
- };
1313
- document.addEventListener("visibilitychange", visibilityHandler);
1314
- setTimeout(() => {
1315
- cleanup();
1316
- document.removeEventListener("visibilitychange", visibilityHandler);
1317
- }, 5e3);
1318
- }
1319
- });
1320
- } catch (error2) {
1321
- if (document.body.contains(iframe)) {
1322
- document.body.removeChild(iframe);
1323
- }
1324
- URL.revokeObjectURL(blobUrl);
1325
- }
1326
- };
1327
- iframe.onerror = () => {
1328
- document.body.removeChild(iframe);
1329
- URL.revokeObjectURL(blobUrl);
1330
- };
1331
- iframe.src = blobUrl;
1332
- };
1333
1534
  _react.useEffect.call(void 0, () => {
1334
1535
  if (!file) {
1335
1536
  setState("error");
@@ -1356,12 +1557,12 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1356
1557
  }
1357
1558
  setPdfBuffer(arrayBuffer);
1358
1559
  setState("ready");
1359
- _optionalChain([onLoad, 'optionalCall', _199 => _199()]);
1560
+ _optionalChain([onLoad, 'optionalCall', _237 => _237()]);
1360
1561
  } catch (err) {
1361
1562
  const errorMessage = err.message || "Failed to load PDF";
1362
1563
  setState("error");
1363
1564
  setError(errorMessage);
1364
- _optionalChain([onError, 'optionalCall', _200 => _200(err)]);
1565
+ _optionalChain([onError, 'optionalCall', _238 => _238(err)]);
1365
1566
  }
1366
1567
  };
1367
1568
  loadPDF();
@@ -1444,182 +1645,52 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1444
1645
  }
1445
1646
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-container", children: [
1446
1647
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: toolbarStyles }),
1447
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-header", children: [
1448
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkRE4XRGSVjs.FileIcon_default, { ext: fileExtension, size: 26 }),
1449
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "header-file-name", title: resolvedFileName, children: resolvedFileName })
1450
- ] }),
1451
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-toolbar", children: [
1452
- showPageNavigation && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1453
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1454
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
1455
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1456
- "button",
1457
- {
1458
- className: "toolbar-button",
1459
- onClick: handleFirstPage,
1460
- disabled: currentPage <= 1,
1461
- title: "First Page",
1462
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
1463
- }
1464
- ),
1465
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1466
- "button",
1467
- {
1468
- className: "toolbar-button",
1469
- onClick: handlePreviousPage,
1470
- disabled: currentPage <= 1,
1471
- title: "Previous Page",
1472
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
1473
- }
1474
- ),
1475
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1476
- "input",
1477
- {
1478
- type: "number",
1479
- className: "page-input",
1480
- value: currentPage,
1481
- onChange: handlePageInput,
1482
- onKeyPress: handlePageInputKeyPress,
1483
- min: 1,
1484
- max: totalPages || void 0
1485
- }
1486
- ),
1487
- showPageCount && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "page-info", children: [
1488
- "of ",
1489
- totalPages || "..."
1490
- ] }),
1491
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1492
- "button",
1493
- {
1494
- className: "toolbar-button",
1495
- onClick: handleNextPage,
1496
- disabled: currentPage >= totalPages,
1497
- title: "Next Page",
1498
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
1499
- }
1500
- ),
1501
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1502
- "button",
1503
- {
1504
- className: "toolbar-button",
1505
- onClick: handleLastPage,
1506
- disabled: currentPage >= totalPages,
1507
- title: "Last Page",
1508
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
1509
- }
1510
- )
1511
- ] })
1512
- ] }),
1513
- showZoomControls && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1514
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1515
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
1516
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1517
- "button",
1518
- {
1519
- className: "toolbar-button",
1520
- onClick: handleZoomOut,
1521
- title: "Zoom Out",
1522
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomOut2.default, { fontSize: "small" })
1523
- }
1524
- ),
1525
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "zoom-display", children: [
1526
- zoom,
1527
- "%"
1528
- ] }),
1529
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1530
- "button",
1531
- {
1532
- className: "toolbar-button",
1533
- onClick: handleZoomIn,
1534
- title: "Zoom In",
1535
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomIn2.default, { fontSize: "small" })
1536
- }
1537
- ),
1538
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1539
- "button",
1540
- {
1541
- className: "toolbar-button",
1542
- onClick: handleFitToWidth,
1543
- title: "Fit to Width",
1544
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" })
1545
- }
1546
- ),
1547
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1548
- "button",
1549
- {
1550
- className: "toolbar-button",
1551
- onClick: handleFitToPage,
1552
- title: "Fit to Page",
1553
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" })
1554
- }
1555
- )
1556
- ] })
1557
- ] }),
1558
- showSearch && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1559
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1560
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-section", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1561
- "button",
1562
- {
1563
- className: "toolbar-button",
1564
- onClick: toggleSidebar,
1565
- title: "Search in PDF",
1566
- style: {
1567
- backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
1568
- color: isSidebarOpen ? "#1976d2" : "inherit"
1569
- },
1570
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { fontSize: "small" })
1571
- }
1572
- ) })
1573
- ] }),
1574
- (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1575
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "toolbar-separator" }),
1576
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "toolbar-section", children: [
1577
- showDownload && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1578
- "button",
1579
- {
1580
- className: "toolbar-button",
1581
- onClick: onDownloadClick,
1582
- title: "Download PDF",
1583
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
1584
- }
1585
- ),
1586
- showPrint && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1587
- "button",
1588
- {
1589
- className: "toolbar-button",
1590
- onClick: onPrintClick,
1591
- title: "Print PDF",
1592
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
1593
- }
1594
- ),
1595
- showMetadata && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1596
- "button",
1597
- {
1598
- className: "toolbar-button",
1599
- onClick: onMetadataClick,
1600
- title: "Document Metadata",
1601
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
1602
- }
1603
- ),
1604
- showProperties && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1605
- "button",
1606
- {
1607
- className: "toolbar-button",
1608
- onClick: onPropertiesClick,
1609
- title: "Document Properties",
1610
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
1611
- }
1612
- )
1613
- ] })
1614
- ] })
1615
- ] }),
1648
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1649
+ PDFHeader,
1650
+ {
1651
+ fileName: resolvedFileName,
1652
+ fileExtension
1653
+ }
1654
+ ),
1655
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1656
+ PDFToolbar,
1657
+ {
1658
+ currentPage,
1659
+ totalPages,
1660
+ zoom,
1661
+ isSidebarOpen,
1662
+ showPageNavigation,
1663
+ showPageCount,
1664
+ showZoomControls,
1665
+ showSearch,
1666
+ showMetadata,
1667
+ showProperties,
1668
+ showDownload,
1669
+ showPrint,
1670
+ onFirstPage: toolbarHandlers.handleFirstPage,
1671
+ onPreviousPage: toolbarHandlers.handlePreviousPage,
1672
+ onNextPage: toolbarHandlers.handleNextPage,
1673
+ onLastPage: toolbarHandlers.handleLastPage,
1674
+ onPageInput: toolbarHandlers.handlePageInput,
1675
+ onPageInputKeyPress: toolbarHandlers.handlePageInputKeyPress,
1676
+ onZoomIn: toolbarHandlers.handleZoomIn,
1677
+ onZoomOut: toolbarHandlers.handleZoomOut,
1678
+ onFitToWidth: toolbarHandlers.handleFitToWidth,
1679
+ onFitToPage: toolbarHandlers.handleFitToPage,
1680
+ onToggleSidebar: toolbarHandlers.toggleSidebar,
1681
+ onDownloadClick,
1682
+ onPrintClick,
1683
+ onMetadataClick,
1684
+ onPropertiesClick
1685
+ }
1686
+ ),
1616
1687
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-main", children: [
1617
1688
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1618
- HeadlessPDFViewer,
1689
+ StablePDFViewer,
1619
1690
  {
1620
- ref: pdfViewerRef,
1621
1691
  pdfBuffer,
1622
- onPasswordRequest: handlePasswordRequest
1692
+ onPasswordRequest: handlePasswordRequest,
1693
+ pdfViewerRef
1623
1694
  }
1624
1695
  ) }),
1625
1696
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1660,4 +1731,4 @@ PDFViewer.displayName = "PDFViewer";
1660
1731
 
1661
1732
 
1662
1733
  exports.PDFViewer = PDFViewer;
1663
- //# sourceMappingURL=chunk-DDT3GC3C.js.map
1734
+ //# sourceMappingURL=chunk-QELOFQEB.js.map