hazo_pdf 1.7.1 → 2.0.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.
- package/SETUP_CHECKLIST.md +693 -0
- package/config/hazo_pdf_config.ini.sample +42 -0
- package/db_setup_postgres.sql +17 -0
- package/db_setup_sqlite.sql +13 -0
- package/dist/{chunk-NQ6KUJWG.js → chunk-7M53O3HF.js} +14 -4
- package/dist/chunk-7M53O3HF.js.map +1 -0
- package/dist/{chunk-4JJOUQ62.js → chunk-KDOQ3FIO.js} +176 -87
- package/dist/chunk-KDOQ3FIO.js.map +1 -0
- package/dist/{chunk-KHB3VZJQ.js → chunk-LFFCPDWC.js} +14 -3
- package/dist/chunk-LFFCPDWC.js.map +1 -0
- package/dist/{chunk-264BTVJT.js → chunk-TZJ5S57X.js} +18 -31
- package/dist/chunk-TZJ5S57X.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +35 -16
- package/dist/index.js.map +1 -1
- package/dist/{pdf_saver-7FA4DAXI.js → pdf_saver-T6SEDYEE.js} +3 -3
- package/dist/{pdf_viewer-B6S5PJJB.js → pdf_viewer-TFCSUGWU.js} +3 -3
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.js +219 -81
- package/dist/server/index.js.map +1 -1
- package/dist/server/{text_search-2OZOVUIP.js → text_search-PVDG5Y6I.js} +14 -3
- package/dist/server/text_search-PVDG5Y6I.js.map +1 -0
- package/dist/styles/full.css +5879 -7264
- package/dist/styles/full.css.map +1 -1
- package/dist/styles/index.css +4845 -3955
- package/dist/styles/index.css.map +1 -1
- package/dist/{text_search-I2KZ7DTW.js → text_search-SO4ZOMIZ.js} +2 -2
- package/package.json +51 -36
- package/dist/chunk-264BTVJT.js.map +0 -1
- package/dist/chunk-4JJOUQ62.js.map +0 -1
- package/dist/chunk-KHB3VZJQ.js.map +0 -1
- package/dist/chunk-NQ6KUJWG.js.map +0 -1
- package/dist/server/text_search-2OZOVUIP.js.map +0 -1
- /package/dist/{pdf_saver-7FA4DAXI.js.map → pdf_saver-T6SEDYEE.js.map} +0 -0
- /package/dist/{pdf_viewer-B6S5PJJB.js.map → pdf_viewer-TFCSUGWU.js.map} +0 -0
- /package/dist/{text_search-I2KZ7DTW.js.map → text_search-SO4ZOMIZ.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
default_config,
|
|
4
4
|
get_logger,
|
|
5
5
|
set_logger
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TZJ5S57X.js";
|
|
7
7
|
import {
|
|
8
8
|
__require
|
|
9
9
|
} from "./chunk-AOSHQP7D.js";
|
|
@@ -15,15 +15,7 @@ import { Save, Download, Undo2 as Undo22, Redo2, PanelRight, PanelRightOpen, Zoo
|
|
|
15
15
|
// src/components/pdf_viewer/toolbar_dropdown_button.tsx
|
|
16
16
|
import { useState, useRef, useEffect } from "react";
|
|
17
17
|
import { ChevronDown } from "lucide-react";
|
|
18
|
-
|
|
19
|
-
// src/utils/cn.ts
|
|
20
|
-
import { clsx } from "clsx";
|
|
21
|
-
import { twMerge } from "tailwind-merge";
|
|
22
|
-
function cn(...inputs) {
|
|
23
|
-
return twMerge(clsx(inputs));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/components/pdf_viewer/toolbar_dropdown_button.tsx
|
|
18
|
+
import { cn } from "hazo_ui";
|
|
27
19
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
20
|
var ToolbarDropdownButton = ({
|
|
29
21
|
icon,
|
|
@@ -235,6 +227,7 @@ var ToolbarDropdownButton = ({
|
|
|
235
227
|
};
|
|
236
228
|
|
|
237
229
|
// src/components/pdf_viewer/pdf_worker_setup.ts
|
|
230
|
+
import { HazoExternalError, HazoInternalError } from "hazo_core/errors";
|
|
238
231
|
var worker_configured = false;
|
|
239
232
|
async function configure_worker() {
|
|
240
233
|
const logger = get_logger();
|
|
@@ -247,7 +240,11 @@ async function configure_worker() {
|
|
|
247
240
|
try {
|
|
248
241
|
const pdfjs_module = await (async () => {
|
|
249
242
|
if (typeof window === "undefined") {
|
|
250
|
-
throw new
|
|
243
|
+
throw new HazoInternalError({
|
|
244
|
+
code: "HAZO_PDF_BROWSER_ONLY",
|
|
245
|
+
pkg: "hazo_pdf",
|
|
246
|
+
message: "Cannot configure PDF.js worker in non-browser environment"
|
|
247
|
+
});
|
|
251
248
|
}
|
|
252
249
|
return await import("pdfjs-dist");
|
|
253
250
|
})();
|
|
@@ -265,10 +262,18 @@ async function configure_worker() {
|
|
|
265
262
|
}
|
|
266
263
|
async function load_pdf_document(source) {
|
|
267
264
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
268
|
-
throw new
|
|
265
|
+
throw new HazoInternalError({
|
|
266
|
+
code: "HAZO_PDF_BROWSER_ONLY",
|
|
267
|
+
pkg: "hazo_pdf",
|
|
268
|
+
message: "load_pdf_document can only be called in the browser"
|
|
269
|
+
});
|
|
269
270
|
}
|
|
270
271
|
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
271
|
-
throw new
|
|
272
|
+
throw new HazoInternalError({
|
|
273
|
+
code: "HAZO_PDF_BROWSER_ONLY",
|
|
274
|
+
pkg: "hazo_pdf",
|
|
275
|
+
message: "load_pdf_document cannot be called in Node.js environment"
|
|
276
|
+
});
|
|
272
277
|
}
|
|
273
278
|
await configure_worker();
|
|
274
279
|
const logger = get_logger();
|
|
@@ -283,7 +288,12 @@ async function load_pdf_document(source) {
|
|
|
283
288
|
try {
|
|
284
289
|
const response = await fetch(source);
|
|
285
290
|
if (!response.ok) {
|
|
286
|
-
throw new
|
|
291
|
+
throw new HazoExternalError({
|
|
292
|
+
code: "HAZO_PDF_EXTERNAL_FETCH_FAILED",
|
|
293
|
+
pkg: "hazo_pdf",
|
|
294
|
+
message: `Failed to fetch PDF: ${response.status} ${response.statusText}`,
|
|
295
|
+
httpStatus: 502
|
|
296
|
+
});
|
|
287
297
|
}
|
|
288
298
|
pdfData = await response.arrayBuffer();
|
|
289
299
|
logger.info("PDF fetched successfully", { data: { size: pdfData.byteLength } });
|
|
@@ -354,6 +364,7 @@ function get_viewport_dimensions(page, scale, rotation = 0) {
|
|
|
354
364
|
}
|
|
355
365
|
|
|
356
366
|
// src/components/pdf_viewer/pdf_page_renderer.tsx
|
|
367
|
+
import { cn as cn2 } from "hazo_ui";
|
|
357
368
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
358
369
|
var PdfPageRenderer = ({
|
|
359
370
|
page,
|
|
@@ -472,13 +483,13 @@ var PdfPageRenderer = ({
|
|
|
472
483
|
};
|
|
473
484
|
}, [page, scale, rotation, page_index]);
|
|
474
485
|
if (!page) {
|
|
475
|
-
return /* @__PURE__ */ jsx2("div", { className:
|
|
486
|
+
return /* @__PURE__ */ jsx2("div", { className: cn2("cls_pdf_page_loading", className), children: /* @__PURE__ */ jsx2("div", { className: "cls_pdf_page_spinner", children: "Loading page..." }) });
|
|
476
487
|
}
|
|
477
488
|
const page_config = config?.page_styling || default_config.page_styling;
|
|
478
489
|
return /* @__PURE__ */ jsx2(
|
|
479
490
|
"div",
|
|
480
491
|
{
|
|
481
|
-
className:
|
|
492
|
+
className: cn2("cls_pdf_page_container", className),
|
|
482
493
|
style: {
|
|
483
494
|
position: "relative",
|
|
484
495
|
width: viewport_dimensions.width,
|
|
@@ -541,6 +552,8 @@ function is_rectangle_too_small(rect, min_size = 5) {
|
|
|
541
552
|
}
|
|
542
553
|
|
|
543
554
|
// src/components/pdf_viewer/annotation_overlay.tsx
|
|
555
|
+
import { cn as cn3 } from "hazo_ui";
|
|
556
|
+
import { generateRequestId } from "hazo_core";
|
|
544
557
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
545
558
|
var TempDrawBox = ({ start, current, tool_type = "Square", config = null }) => {
|
|
546
559
|
if (!start || !current) return null;
|
|
@@ -725,7 +738,7 @@ var AnnotationOverlay = ({
|
|
|
725
738
|
const highlight_config = config?.highlight_annotation || default_config.highlight_annotation;
|
|
726
739
|
const square_config = config?.square_annotation || default_config.square_annotation;
|
|
727
740
|
const new_annotation = {
|
|
728
|
-
id:
|
|
741
|
+
id: generateRequestId().slice(4),
|
|
729
742
|
type: current_tool || "Square",
|
|
730
743
|
page_index,
|
|
731
744
|
rect: pdf_rect,
|
|
@@ -1059,7 +1072,7 @@ var AnnotationOverlay = ({
|
|
|
1059
1072
|
"svg",
|
|
1060
1073
|
{
|
|
1061
1074
|
ref: svg_ref,
|
|
1062
|
-
className:
|
|
1075
|
+
className: cn3("cls_annotation_overlay", className),
|
|
1063
1076
|
style: {
|
|
1064
1077
|
position: "absolute",
|
|
1065
1078
|
top: 0,
|
|
@@ -1103,6 +1116,7 @@ var AnnotationOverlay = ({
|
|
|
1103
1116
|
};
|
|
1104
1117
|
|
|
1105
1118
|
// src/components/pdf_viewer/pdf_viewer_layout.tsx
|
|
1119
|
+
import { cn as cn4 } from "hazo_ui";
|
|
1106
1120
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1107
1121
|
var PdfViewerLayout = ({
|
|
1108
1122
|
pdf_document,
|
|
@@ -1273,13 +1287,13 @@ var PdfViewerLayout = ({
|
|
|
1273
1287
|
return void 0;
|
|
1274
1288
|
}, [is_panning, handle_mouse_move, handle_mouse_up]);
|
|
1275
1289
|
if (loading) {
|
|
1276
|
-
return /* @__PURE__ */ jsx4("div", { className:
|
|
1290
|
+
return /* @__PURE__ */ jsx4("div", { className: cn4("cls_pdf_viewer_loading", className), children: /* @__PURE__ */ jsx4("div", { className: "cls_pdf_viewer_spinner", children: "Loading PDF..." }) });
|
|
1277
1291
|
}
|
|
1278
1292
|
return /* @__PURE__ */ jsx4(
|
|
1279
1293
|
"div",
|
|
1280
1294
|
{
|
|
1281
1295
|
ref: container_ref,
|
|
1282
|
-
className:
|
|
1296
|
+
className: cn4("cls_pdf_viewer_layout", className),
|
|
1283
1297
|
style: {
|
|
1284
1298
|
// Don't constrain width/height - let content determine size
|
|
1285
1299
|
// This allows container to expand beyond viewport when zoomed
|
|
@@ -1387,6 +1401,7 @@ var PdfViewerLayout = ({
|
|
|
1387
1401
|
import { useEffect as useEffect4, useRef as useRef5, useState as useState4 } from "react";
|
|
1388
1402
|
import { createPortal } from "react-dom";
|
|
1389
1403
|
import { Undo2, FileText } from "lucide-react";
|
|
1404
|
+
import { cn as cn5 } from "hazo_ui";
|
|
1390
1405
|
import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1391
1406
|
var ContextMenu = ({
|
|
1392
1407
|
x,
|
|
@@ -1515,7 +1530,7 @@ var ContextMenu = ({
|
|
|
1515
1530
|
type: "button",
|
|
1516
1531
|
onClick: () => handle_item_click(on_undo),
|
|
1517
1532
|
disabled: !can_undo,
|
|
1518
|
-
className:
|
|
1533
|
+
className: cn5(
|
|
1519
1534
|
"cls_pdf_viewer_context_menu_item",
|
|
1520
1535
|
!can_undo && "cls_pdf_viewer_context_menu_item_disabled"
|
|
1521
1536
|
),
|
|
@@ -1605,6 +1620,7 @@ var ContextMenu = ({
|
|
|
1605
1620
|
import { useState as useState5, useEffect as useEffect5, useRef as useRef6 } from "react";
|
|
1606
1621
|
import { createPortal as createPortal2 } from "react-dom";
|
|
1607
1622
|
import { Check, X, Trash2 } from "lucide-react";
|
|
1623
|
+
import { cn as cn6 } from "hazo_ui";
|
|
1608
1624
|
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1609
1625
|
var TextAnnotationDialog = ({
|
|
1610
1626
|
open,
|
|
@@ -1724,7 +1740,7 @@ var TextAnnotationDialog = ({
|
|
|
1724
1740
|
{
|
|
1725
1741
|
type: "button",
|
|
1726
1742
|
onClick: handle_delete,
|
|
1727
|
-
className:
|
|
1743
|
+
className: cn6(
|
|
1728
1744
|
"cls_pdf_viewer_dialog_button",
|
|
1729
1745
|
"cls_pdf_viewer_dialog_button_delete"
|
|
1730
1746
|
),
|
|
@@ -1747,7 +1763,7 @@ var TextAnnotationDialog = ({
|
|
|
1747
1763
|
{
|
|
1748
1764
|
type: "button",
|
|
1749
1765
|
onClick: handle_cancel,
|
|
1750
|
-
className:
|
|
1766
|
+
className: cn6(
|
|
1751
1767
|
"cls_pdf_viewer_dialog_button",
|
|
1752
1768
|
"cls_pdf_viewer_dialog_button_cancel"
|
|
1753
1769
|
),
|
|
@@ -1770,7 +1786,7 @@ var TextAnnotationDialog = ({
|
|
|
1770
1786
|
{
|
|
1771
1787
|
type: "submit",
|
|
1772
1788
|
disabled: !text.trim(),
|
|
1773
|
-
className:
|
|
1789
|
+
className: cn6(
|
|
1774
1790
|
"cls_pdf_viewer_dialog_button",
|
|
1775
1791
|
"cls_pdf_viewer_dialog_button_submit",
|
|
1776
1792
|
!text.trim() && "cls_pdf_viewer_dialog_button_disabled"
|
|
@@ -1805,23 +1821,24 @@ var TextAnnotationDialog = ({
|
|
|
1805
1821
|
// src/components/pdf_viewer/metadata_sidepanel.tsx
|
|
1806
1822
|
import { useState as useState6, useRef as useRef7, useEffect as useEffect6 } from "react";
|
|
1807
1823
|
import { ChevronLeft, ChevronRight, ChevronDown as ChevronDown2, ChevronUp, Pencil, CheckCircle2, X as X2 } from "lucide-react";
|
|
1824
|
+
import { cn as cn7 } from "hazo_ui";
|
|
1808
1825
|
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1809
1826
|
var FormatText = ({ style, children, className }) => {
|
|
1810
|
-
const baseClassName =
|
|
1827
|
+
const baseClassName = cn7("cls_metadata_text", className);
|
|
1811
1828
|
switch (style) {
|
|
1812
1829
|
case "h1":
|
|
1813
|
-
return /* @__PURE__ */ jsx7("h1", { className:
|
|
1830
|
+
return /* @__PURE__ */ jsx7("h1", { className: cn7(baseClassName, "cls_metadata_h1"), children });
|
|
1814
1831
|
case "h2":
|
|
1815
|
-
return /* @__PURE__ */ jsx7("h2", { className:
|
|
1832
|
+
return /* @__PURE__ */ jsx7("h2", { className: cn7(baseClassName, "cls_metadata_h2"), children });
|
|
1816
1833
|
case "h3":
|
|
1817
|
-
return /* @__PURE__ */ jsx7("h3", { className:
|
|
1834
|
+
return /* @__PURE__ */ jsx7("h3", { className: cn7(baseClassName, "cls_metadata_h3"), children });
|
|
1818
1835
|
case "h4":
|
|
1819
|
-
return /* @__PURE__ */ jsx7("h4", { className:
|
|
1836
|
+
return /* @__PURE__ */ jsx7("h4", { className: cn7(baseClassName, "cls_metadata_h4"), children });
|
|
1820
1837
|
case "h5":
|
|
1821
|
-
return /* @__PURE__ */ jsx7("h5", { className:
|
|
1838
|
+
return /* @__PURE__ */ jsx7("h5", { className: cn7(baseClassName, "cls_metadata_h5"), children });
|
|
1822
1839
|
case "body":
|
|
1823
1840
|
default:
|
|
1824
|
-
return /* @__PURE__ */ jsx7("p", { className:
|
|
1841
|
+
return /* @__PURE__ */ jsx7("p", { className: cn7(baseClassName, "cls_metadata_body"), children });
|
|
1825
1842
|
}
|
|
1826
1843
|
};
|
|
1827
1844
|
var MetadataSidepanel = ({
|
|
@@ -1919,7 +1936,7 @@ var MetadataSidepanel = ({
|
|
|
1919
1936
|
/* @__PURE__ */ jsxs6(
|
|
1920
1937
|
"div",
|
|
1921
1938
|
{
|
|
1922
|
-
className:
|
|
1939
|
+
className: cn7("cls_metadata_sidepanel", is_open && "cls_metadata_sidepanel_open"),
|
|
1923
1940
|
style: { width: is_open ? `${width}px` : "0", display: is_open ? "flex" : "none" },
|
|
1924
1941
|
children: [
|
|
1925
1942
|
is_open && /* @__PURE__ */ jsx7(
|
|
@@ -2031,6 +2048,7 @@ var MetadataSidepanel = ({
|
|
|
2031
2048
|
// src/components/pdf_viewer/file_info_sidepanel.tsx
|
|
2032
2049
|
import { useState as useState7, useRef as useRef8, useEffect as useEffect7 } from "react";
|
|
2033
2050
|
import { ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight2, ChevronDown as ChevronDown3, ChevronUp as ChevronUp2 } from "lucide-react";
|
|
2051
|
+
import { cn as cn8 } from "hazo_ui";
|
|
2034
2052
|
import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2035
2053
|
var format_field_name = (name) => {
|
|
2036
2054
|
return name.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
@@ -2133,7 +2151,7 @@ var FileInfoSidepanel = ({
|
|
|
2133
2151
|
/* @__PURE__ */ jsxs7(
|
|
2134
2152
|
"div",
|
|
2135
2153
|
{
|
|
2136
|
-
className:
|
|
2154
|
+
className: cn8("cls_file_info_sidepanel", is_open && "cls_file_info_sidepanel_open"),
|
|
2137
2155
|
style: { width: is_open ? `${width}px` : "0", display: is_open ? "flex" : "none" },
|
|
2138
2156
|
children: [
|
|
2139
2157
|
is_open && /* @__PURE__ */ jsx8(
|
|
@@ -2306,6 +2324,7 @@ var FileInfoSidepanel = ({
|
|
|
2306
2324
|
};
|
|
2307
2325
|
|
|
2308
2326
|
// src/utils/config_loader.ts
|
|
2327
|
+
import { HazoExternalError as HazoExternalError2 } from "hazo_core/errors";
|
|
2309
2328
|
function parse_ini_browser(ini_text) {
|
|
2310
2329
|
const result = {};
|
|
2311
2330
|
let current_section = "";
|
|
@@ -2338,7 +2357,12 @@ async function load_config_browser(config_file) {
|
|
|
2338
2357
|
const config_url = config_file === "config/hazo_pdf_config.ini" || config_file.includes("config/hazo_pdf_config.ini") ? "/api/config" : config_file;
|
|
2339
2358
|
const response = await fetch(config_url);
|
|
2340
2359
|
if (!response.ok) {
|
|
2341
|
-
throw new
|
|
2360
|
+
throw new HazoExternalError2({
|
|
2361
|
+
code: "HAZO_PDF_EXTERNAL_FETCH_FAILED",
|
|
2362
|
+
pkg: "hazo_pdf",
|
|
2363
|
+
message: `Failed to fetch config file: ${response.status} ${response.statusText}`,
|
|
2364
|
+
httpStatus: 502
|
|
2365
|
+
});
|
|
2342
2366
|
}
|
|
2343
2367
|
const ini_text = await response.text();
|
|
2344
2368
|
const parsed = parse_ini_browser(ini_text);
|
|
@@ -3014,6 +3038,11 @@ function load_pdf_config(config_file) {
|
|
|
3014
3038
|
}
|
|
3015
3039
|
}
|
|
3016
3040
|
|
|
3041
|
+
// src/components/pdf_viewer/pdf_viewer.tsx
|
|
3042
|
+
import { cn as cn15 } from "hazo_ui";
|
|
3043
|
+
import { generateRequestId as generateRequestId2, optional_import } from "hazo_core";
|
|
3044
|
+
import { HazoExternalError as HazoExternalError5, HazoInternalError as HazoInternalError4 } from "hazo_core/errors";
|
|
3045
|
+
|
|
3017
3046
|
// src/components/file_manager/index.tsx
|
|
3018
3047
|
import { useState as useState12, useCallback as useCallback4, useEffect as useEffect9 } from "react";
|
|
3019
3048
|
|
|
@@ -3024,6 +3053,7 @@ import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight3, Plus } from
|
|
|
3024
3053
|
// src/components/file_manager/file_list_item.tsx
|
|
3025
3054
|
import { useState as useState8 } from "react";
|
|
3026
3055
|
import { X as X3, FileText as FileText2, Loader2 } from "lucide-react";
|
|
3056
|
+
import { cn as cn9 } from "hazo_ui";
|
|
3027
3057
|
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3028
3058
|
function get_display_name(filename, max_length = 24) {
|
|
3029
3059
|
if (filename.length <= max_length) {
|
|
@@ -3064,7 +3094,7 @@ var FileListItem = ({
|
|
|
3064
3094
|
return /* @__PURE__ */ jsxs8(
|
|
3065
3095
|
"div",
|
|
3066
3096
|
{
|
|
3067
|
-
className:
|
|
3097
|
+
className: cn9(
|
|
3068
3098
|
"cls_file_tab",
|
|
3069
3099
|
is_selected && "cls_file_tab_selected"
|
|
3070
3100
|
),
|
|
@@ -3105,6 +3135,7 @@ var FileListItem = ({
|
|
|
3105
3135
|
};
|
|
3106
3136
|
|
|
3107
3137
|
// src/components/file_manager/file_list.tsx
|
|
3138
|
+
import { cn as cn10 } from "hazo_ui";
|
|
3108
3139
|
import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3109
3140
|
var FileList = ({
|
|
3110
3141
|
files,
|
|
@@ -3211,7 +3242,7 @@ var FileList = ({
|
|
|
3211
3242
|
return /* @__PURE__ */ jsxs9(
|
|
3212
3243
|
"div",
|
|
3213
3244
|
{
|
|
3214
|
-
className:
|
|
3245
|
+
className: cn10("cls_file_list_container", className),
|
|
3215
3246
|
style: {
|
|
3216
3247
|
minHeight: `${height}px`,
|
|
3217
3248
|
backgroundColor: background_color,
|
|
@@ -3221,7 +3252,7 @@ var FileList = ({
|
|
|
3221
3252
|
/* @__PURE__ */ jsx10(
|
|
3222
3253
|
"button",
|
|
3223
3254
|
{
|
|
3224
|
-
className:
|
|
3255
|
+
className: cn10(
|
|
3225
3256
|
"cls_file_list_scroll_btn cls_file_list_scroll_btn_left",
|
|
3226
3257
|
!can_scroll_left && "cls_file_list_scroll_btn_disabled"
|
|
3227
3258
|
),
|
|
@@ -3255,7 +3286,7 @@ var FileList = ({
|
|
|
3255
3286
|
/* @__PURE__ */ jsxs9(
|
|
3256
3287
|
"button",
|
|
3257
3288
|
{
|
|
3258
|
-
className:
|
|
3289
|
+
className: cn10(
|
|
3259
3290
|
"cls_file_list_add_btn",
|
|
3260
3291
|
is_dragging && "cls_file_list_add_btn_dragging"
|
|
3261
3292
|
),
|
|
@@ -3292,7 +3323,7 @@ var FileList = ({
|
|
|
3292
3323
|
/* @__PURE__ */ jsx10(
|
|
3293
3324
|
"button",
|
|
3294
3325
|
{
|
|
3295
|
-
className:
|
|
3326
|
+
className: cn10(
|
|
3296
3327
|
"cls_file_list_scroll_btn cls_file_list_scroll_btn_right",
|
|
3297
3328
|
!can_scroll_right && "cls_file_list_scroll_btn_disabled"
|
|
3298
3329
|
),
|
|
@@ -3314,6 +3345,7 @@ import { Upload, X as X4 } from "lucide-react";
|
|
|
3314
3345
|
|
|
3315
3346
|
// src/components/file_manager/upload_progress.tsx
|
|
3316
3347
|
import { Loader2 as Loader22, CheckCircle, XCircle } from "lucide-react";
|
|
3348
|
+
import { cn as cn11 } from "hazo_ui";
|
|
3317
3349
|
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3318
3350
|
function get_status_icon(status) {
|
|
3319
3351
|
switch (status) {
|
|
@@ -3352,10 +3384,10 @@ var UploadProgressDisplay = ({
|
|
|
3352
3384
|
if (uploads.length === 0) {
|
|
3353
3385
|
return null;
|
|
3354
3386
|
}
|
|
3355
|
-
return /* @__PURE__ */ jsx11("div", { className:
|
|
3387
|
+
return /* @__PURE__ */ jsx11("div", { className: cn11("cls_upload_progress_container", className), children: uploads.map((upload) => /* @__PURE__ */ jsxs10(
|
|
3356
3388
|
"div",
|
|
3357
3389
|
{
|
|
3358
|
-
className:
|
|
3390
|
+
className: cn11(
|
|
3359
3391
|
"cls_upload_progress_item",
|
|
3360
3392
|
upload.status === "error" && "cls_upload_progress_item_error",
|
|
3361
3393
|
upload.status === "complete" && "cls_upload_progress_item_complete"
|
|
@@ -3366,7 +3398,7 @@ var UploadProgressDisplay = ({
|
|
|
3366
3398
|
/* @__PURE__ */ jsx11("div", { className: "cls_upload_progress_bar_container", children: /* @__PURE__ */ jsx11(
|
|
3367
3399
|
"div",
|
|
3368
3400
|
{
|
|
3369
|
-
className:
|
|
3401
|
+
className: cn11(
|
|
3370
3402
|
"cls_upload_progress_bar",
|
|
3371
3403
|
upload.status === "error" && "cls_upload_progress_bar_error",
|
|
3372
3404
|
upload.status === "complete" && "cls_upload_progress_bar_complete"
|
|
@@ -3382,6 +3414,7 @@ var UploadProgressDisplay = ({
|
|
|
3382
3414
|
};
|
|
3383
3415
|
|
|
3384
3416
|
// src/components/file_manager/upload_dropzone.tsx
|
|
3417
|
+
import { cn as cn12 } from "hazo_ui";
|
|
3385
3418
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3386
3419
|
var UploadDropzone = ({
|
|
3387
3420
|
config,
|
|
@@ -3489,7 +3522,7 @@ var UploadDropzone = ({
|
|
|
3489
3522
|
const accept_string = allowed_types.join(",");
|
|
3490
3523
|
const border_color = is_dragging ? upload_config?.dropzone_border_color_active || "#3b82f6" : upload_config?.dropzone_border_color || "#d1d5db";
|
|
3491
3524
|
const background_color = upload_config?.dropzone_background_color || "#f9fafb";
|
|
3492
|
-
return /* @__PURE__ */ jsxs11("div", { className:
|
|
3525
|
+
return /* @__PURE__ */ jsxs11("div", { className: cn12("cls_upload_dropzone_wrapper", className), children: [
|
|
3493
3526
|
on_close && /* @__PURE__ */ jsx12(
|
|
3494
3527
|
"button",
|
|
3495
3528
|
{
|
|
@@ -3502,7 +3535,7 @@ var UploadDropzone = ({
|
|
|
3502
3535
|
/* @__PURE__ */ jsxs11(
|
|
3503
3536
|
"div",
|
|
3504
3537
|
{
|
|
3505
|
-
className:
|
|
3538
|
+
className: cn12(
|
|
3506
3539
|
"cls_upload_dropzone",
|
|
3507
3540
|
is_dragging && "cls_upload_dropzone_active",
|
|
3508
3541
|
disabled && "cls_upload_dropzone_disabled"
|
|
@@ -3544,7 +3577,7 @@ var UploadDropzone = ({
|
|
|
3544
3577
|
Upload,
|
|
3545
3578
|
{
|
|
3546
3579
|
size: 40,
|
|
3547
|
-
className:
|
|
3580
|
+
className: cn12(
|
|
3548
3581
|
"cls_upload_dropzone_icon",
|
|
3549
3582
|
is_dragging && "cls_upload_dropzone_icon_active"
|
|
3550
3583
|
),
|
|
@@ -3564,6 +3597,7 @@ var UploadDropzone = ({
|
|
|
3564
3597
|
// src/components/file_manager/file_manager_button.tsx
|
|
3565
3598
|
import { useState as useState11 } from "react";
|
|
3566
3599
|
import { FaFileAlt, FaFolderOpen } from "react-icons/fa";
|
|
3600
|
+
import { cn as cn13 } from "hazo_ui";
|
|
3567
3601
|
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3568
3602
|
var FileManagerButton = ({
|
|
3569
3603
|
file_count,
|
|
@@ -3593,7 +3627,7 @@ var FileManagerButton = ({
|
|
|
3593
3627
|
return /* @__PURE__ */ jsxs12(
|
|
3594
3628
|
"button",
|
|
3595
3629
|
{
|
|
3596
|
-
className:
|
|
3630
|
+
className: cn13(
|
|
3597
3631
|
"cls_file_manager_button",
|
|
3598
3632
|
disabled && "cls_file_manager_button_disabled",
|
|
3599
3633
|
className
|
|
@@ -3623,6 +3657,7 @@ var FileManagerButton = ({
|
|
|
3623
3657
|
};
|
|
3624
3658
|
|
|
3625
3659
|
// src/utils/pdf_converter.ts
|
|
3660
|
+
import { HazoInternalError as HazoInternalError2 } from "hazo_core/errors";
|
|
3626
3661
|
var PAGE_SIZES = {
|
|
3627
3662
|
letter: { width: 612, height: 792 },
|
|
3628
3663
|
a4: { width: 595, height: 842 },
|
|
@@ -4165,7 +4200,11 @@ function truncate_text(text, font, font_size, max_width) {
|
|
|
4165
4200
|
}
|
|
4166
4201
|
async function convert_image_via_canvas(image_bytes, mime_type) {
|
|
4167
4202
|
if (typeof document === "undefined" || typeof Image === "undefined") {
|
|
4168
|
-
throw new
|
|
4203
|
+
throw new HazoInternalError2({
|
|
4204
|
+
code: "HAZO_PDF_BROWSER_ONLY",
|
|
4205
|
+
pkg: "hazo_pdf",
|
|
4206
|
+
message: "Image conversion requires browser environment (canvas support)"
|
|
4207
|
+
});
|
|
4169
4208
|
}
|
|
4170
4209
|
return new Promise((resolve, reject) => {
|
|
4171
4210
|
const blob = new Blob([new Uint8Array(image_bytes)], { type: mime_type });
|
|
@@ -4178,7 +4217,11 @@ async function convert_image_via_canvas(image_bytes, mime_type) {
|
|
|
4178
4217
|
canvas.height = img.height;
|
|
4179
4218
|
const ctx = canvas.getContext("2d");
|
|
4180
4219
|
if (!ctx) {
|
|
4181
|
-
throw new
|
|
4220
|
+
throw new HazoInternalError2({
|
|
4221
|
+
code: "HAZO_PDF_CANVAS_CONTEXT_FAILED",
|
|
4222
|
+
pkg: "hazo_pdf",
|
|
4223
|
+
message: "Failed to get canvas 2D context"
|
|
4224
|
+
});
|
|
4182
4225
|
}
|
|
4183
4226
|
ctx.drawImage(img, 0, 0);
|
|
4184
4227
|
canvas.toBlob((blob2) => {
|
|
@@ -4249,6 +4292,8 @@ function wrap_text(text, font, font_size, max_width) {
|
|
|
4249
4292
|
}
|
|
4250
4293
|
|
|
4251
4294
|
// src/components/file_manager/index.tsx
|
|
4295
|
+
import { cn as cn14 } from "hazo_ui";
|
|
4296
|
+
import { HazoExternalError as HazoExternalError3, HazoInternalError as HazoInternalError3 } from "hazo_core/errors";
|
|
4252
4297
|
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4253
4298
|
function generate_file_id() {
|
|
4254
4299
|
return `file_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -4354,7 +4399,11 @@ var FileManager = ({
|
|
|
4354
4399
|
(u) => u.file_id === file_id ? { ...u, progress: 60 } : u
|
|
4355
4400
|
));
|
|
4356
4401
|
} else {
|
|
4357
|
-
throw new
|
|
4402
|
+
throw new HazoInternalError3({
|
|
4403
|
+
code: "HAZO_PDF_CONVERSION_FAILED",
|
|
4404
|
+
pkg: "hazo_pdf",
|
|
4405
|
+
message: result.error || "Conversion failed"
|
|
4406
|
+
});
|
|
4358
4407
|
}
|
|
4359
4408
|
}
|
|
4360
4409
|
if (on_upload) {
|
|
@@ -4386,7 +4435,12 @@ var FileManager = ({
|
|
|
4386
4435
|
));
|
|
4387
4436
|
handle_file_select(new_file);
|
|
4388
4437
|
} else {
|
|
4389
|
-
throw new
|
|
4438
|
+
throw new HazoExternalError3({
|
|
4439
|
+
code: "HAZO_PDF_EXTERNAL_UPLOAD_FAILED",
|
|
4440
|
+
pkg: "hazo_pdf",
|
|
4441
|
+
message: upload_result.error || "Upload failed",
|
|
4442
|
+
httpStatus: 502
|
|
4443
|
+
});
|
|
4390
4444
|
}
|
|
4391
4445
|
} else {
|
|
4392
4446
|
const blob = converted_pdf ? new Blob([new Uint8Array(converted_pdf)], { type: "application/pdf" }) : file;
|
|
@@ -4449,7 +4503,7 @@ var FileManager = ({
|
|
|
4449
4503
|
}
|
|
4450
4504
|
);
|
|
4451
4505
|
}
|
|
4452
|
-
return /* @__PURE__ */ jsxs13("div", { className:
|
|
4506
|
+
return /* @__PURE__ */ jsxs13("div", { className: cn14("cls_file_manager", className), children: [
|
|
4453
4507
|
file_manager_config?.show_file_list !== false && /* @__PURE__ */ jsx14(
|
|
4454
4508
|
FileList,
|
|
4455
4509
|
{
|
|
@@ -4475,6 +4529,7 @@ var FileManager = ({
|
|
|
4475
4529
|
};
|
|
4476
4530
|
|
|
4477
4531
|
// src/utils/file_access_middleware.ts
|
|
4532
|
+
import { HazoExternalError as HazoExternalError4, HazoValidationError } from "hazo_core/errors";
|
|
4478
4533
|
async function load_pdf_data(source, file_manager) {
|
|
4479
4534
|
const logger = get_logger();
|
|
4480
4535
|
if (file_manager && file_manager.isInitialized()) {
|
|
@@ -4482,8 +4537,13 @@ async function load_pdf_data(source, file_manager) {
|
|
|
4482
4537
|
const result = await file_manager.downloadFile(source);
|
|
4483
4538
|
if (!result.success || !result.data) {
|
|
4484
4539
|
const error_msg = result.error || "Unknown error loading file";
|
|
4485
|
-
logger.error(
|
|
4486
|
-
throw new
|
|
4540
|
+
logger.error("file_access.load.failed", { error: error_msg, source });
|
|
4541
|
+
throw new HazoExternalError4({
|
|
4542
|
+
code: "HAZO_PDF_EXTERNAL_STORAGE_FAILED",
|
|
4543
|
+
pkg: "hazo_pdf",
|
|
4544
|
+
message: `Failed to load PDF from storage: ${error_msg}`,
|
|
4545
|
+
httpStatus: 502
|
|
4546
|
+
});
|
|
4487
4547
|
}
|
|
4488
4548
|
const data = result.data;
|
|
4489
4549
|
if (data instanceof ArrayBuffer) {
|
|
@@ -4496,12 +4556,21 @@ async function load_pdf_data(source, file_manager) {
|
|
|
4496
4556
|
logger.debug(`[file_access_middleware] PDF loaded via hazo_files (Buffer), size: ${data.length} bytes`);
|
|
4497
4557
|
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
4498
4558
|
}
|
|
4499
|
-
throw new
|
|
4559
|
+
throw new HazoValidationError({
|
|
4560
|
+
code: "HAZO_PDF_UNSUPPORTED_TYPE",
|
|
4561
|
+
pkg: "hazo_pdf",
|
|
4562
|
+
message: "Unexpected data type from file manager"
|
|
4563
|
+
});
|
|
4500
4564
|
}
|
|
4501
4565
|
logger.debug(`[file_access_middleware] Loading PDF via fetch: ${source}`);
|
|
4502
4566
|
const response = await fetch(source);
|
|
4503
4567
|
if (!response.ok) {
|
|
4504
|
-
throw new
|
|
4568
|
+
throw new HazoExternalError4({
|
|
4569
|
+
code: "HAZO_PDF_EXTERNAL_FETCH_FAILED",
|
|
4570
|
+
pkg: "hazo_pdf",
|
|
4571
|
+
message: `Failed to fetch PDF: ${response.status} ${response.statusText}`,
|
|
4572
|
+
httpStatus: 502
|
|
4573
|
+
});
|
|
4505
4574
|
}
|
|
4506
4575
|
const array_buffer = await response.arrayBuffer();
|
|
4507
4576
|
logger.debug(`[file_access_middleware] PDF loaded via fetch, size: ${array_buffer.byteLength} bytes`);
|
|
@@ -4641,7 +4710,11 @@ var PdfViewer = forwardRef(({
|
|
|
4641
4710
|
useEffect10(() => {
|
|
4642
4711
|
const check_hazo_files = async () => {
|
|
4643
4712
|
try {
|
|
4644
|
-
const module = await
|
|
4713
|
+
const module = await optional_import("hazo_files/ui");
|
|
4714
|
+
if (!module) {
|
|
4715
|
+
setHazoFilesAvailable(false);
|
|
4716
|
+
return;
|
|
4717
|
+
}
|
|
4645
4718
|
if ("FileInfoPanel" in module && typeof module.FileInfoPanel === "function") {
|
|
4646
4719
|
setHazoFilesAvailable(true);
|
|
4647
4720
|
} else {
|
|
@@ -4990,9 +5063,12 @@ ${suffix_line}`;
|
|
|
4990
5063
|
if (!response.ok) {
|
|
4991
5064
|
const error_text = await response.text().catch(() => "");
|
|
4992
5065
|
const truncated = error_text.length > 200 ? error_text.slice(0, 200) + "..." : error_text;
|
|
4993
|
-
throw new
|
|
4994
|
-
|
|
4995
|
-
|
|
5066
|
+
throw new HazoExternalError5({
|
|
5067
|
+
code: "HAZO_PDF_EXTERNAL_FETCH_FAILED",
|
|
5068
|
+
pkg: "hazo_pdf",
|
|
5069
|
+
message: `Failed to fetch PDF (${response.status} ${response.statusText}): ${truncated || "No response body"}`,
|
|
5070
|
+
httpStatus: 502
|
|
5071
|
+
});
|
|
4996
5072
|
}
|
|
4997
5073
|
const content_type = response.headers.get("content-type") || "";
|
|
4998
5074
|
if (!content_type.includes("application/pdf") && !content_type.includes("application/octet-stream")) {
|
|
@@ -5334,7 +5410,7 @@ ${suffix_line}`;
|
|
|
5334
5410
|
});
|
|
5335
5411
|
setAutoHighlightIds(/* @__PURE__ */ new Set());
|
|
5336
5412
|
const perform_auto_highlights = async () => {
|
|
5337
|
-
const { find_text_in_pdf } = await import("./text_search-
|
|
5413
|
+
const { find_text_in_pdf } = await import("./text_search-SO4ZOMIZ.js");
|
|
5338
5414
|
const new_ids = /* @__PURE__ */ new Set();
|
|
5339
5415
|
const auto_config = config_ref.current?.auto_highlight || default_config.auto_highlight;
|
|
5340
5416
|
const search_opts = {
|
|
@@ -5436,7 +5512,7 @@ ${suffix_line}`;
|
|
|
5436
5512
|
const original_filename = is_multi_file_mode && current_file ? current_file.name : effective_url.split("/").pop() || "document.pdf";
|
|
5437
5513
|
const filename_without_ext = original_filename.replace(/\.pdf$/i, "");
|
|
5438
5514
|
const output_filename = `${filename_without_ext}_annotated.pdf`;
|
|
5439
|
-
const { save_annotations_to_pdf, download_pdf } = await import("./pdf_saver-
|
|
5515
|
+
const { save_annotations_to_pdf, download_pdf } = await import("./pdf_saver-T6SEDYEE.js");
|
|
5440
5516
|
const pdf_source = cached_pdf_data || effective_url;
|
|
5441
5517
|
logger2.debug("[PdfViewer] Saving PDF", { source_type: cached_pdf_data ? "cached ArrayBuffer" : "URL" });
|
|
5442
5518
|
const pdf_bytes = await save_annotations_to_pdf(pdf_source, annotations, output_filename, config_ref.current, page_rotations);
|
|
@@ -5444,7 +5520,12 @@ ${suffix_line}`;
|
|
|
5444
5520
|
logger2.info("[PdfViewer] Saving PDF to remote storage via hazo_files", { path: save_path });
|
|
5445
5521
|
const save_result = await save_pdf_data(pdf_bytes, save_path, file_manager);
|
|
5446
5522
|
if (!save_result.success) {
|
|
5447
|
-
throw new
|
|
5523
|
+
throw new HazoExternalError5({
|
|
5524
|
+
code: "HAZO_PDF_EXTERNAL_STORAGE_FAILED",
|
|
5525
|
+
pkg: "hazo_pdf",
|
|
5526
|
+
message: `Failed to save to remote storage: ${save_result.error}`,
|
|
5527
|
+
httpStatus: 502
|
|
5528
|
+
});
|
|
5448
5529
|
}
|
|
5449
5530
|
logger2.info("[PdfViewer] PDF saved to remote storage successfully");
|
|
5450
5531
|
}
|
|
@@ -5471,7 +5552,7 @@ ${suffix_line}`;
|
|
|
5471
5552
|
setDownloading(true);
|
|
5472
5553
|
try {
|
|
5473
5554
|
const logger2 = get_logger();
|
|
5474
|
-
const { save_annotations_to_pdf, download_pdf } = await import("./pdf_saver-
|
|
5555
|
+
const { save_annotations_to_pdf, download_pdf } = await import("./pdf_saver-T6SEDYEE.js");
|
|
5475
5556
|
const original_filename = is_multi_file_mode && current_file ? current_file.name : effective_url?.split("/").pop() || "document.pdf";
|
|
5476
5557
|
const output_filename = download_filename || original_filename;
|
|
5477
5558
|
const pdf_source = cached_pdf_data || effective_url;
|
|
@@ -5543,11 +5624,20 @@ ${suffix_line}`;
|
|
|
5543
5624
|
});
|
|
5544
5625
|
if (!api_response.ok) {
|
|
5545
5626
|
const error_text = await api_response.text();
|
|
5546
|
-
throw new
|
|
5627
|
+
throw new HazoExternalError5({
|
|
5628
|
+
code: "HAZO_PDF_EXTERNAL_API_FAILED",
|
|
5629
|
+
pkg: "hazo_pdf",
|
|
5630
|
+
message: `Extract API error: ${api_response.status} - ${error_text}`,
|
|
5631
|
+
httpStatus: 502
|
|
5632
|
+
});
|
|
5547
5633
|
}
|
|
5548
5634
|
const result = await api_response.json();
|
|
5549
5635
|
if (!result.success) {
|
|
5550
|
-
throw new
|
|
5636
|
+
throw new HazoInternalError4({
|
|
5637
|
+
code: "HAZO_PDF_EXTRACT_FAILED",
|
|
5638
|
+
pkg: "hazo_pdf",
|
|
5639
|
+
message: result.error || "Unknown extraction error"
|
|
5640
|
+
});
|
|
5551
5641
|
}
|
|
5552
5642
|
logger2.info("[PdfViewer] Extraction completed successfully");
|
|
5553
5643
|
on_extract_complete?.(result.data);
|
|
@@ -5561,17 +5651,17 @@ ${suffix_line}`;
|
|
|
5561
5651
|
}
|
|
5562
5652
|
};
|
|
5563
5653
|
if (loading) {
|
|
5564
|
-
return /* @__PURE__ */ jsx15("div", { className:
|
|
5654
|
+
return /* @__PURE__ */ jsx15("div", { className: cn15("cls_pdf_viewer", "cls_pdf_viewer_loading", className), children: /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_spinner", children: "Loading PDF document..." }) });
|
|
5565
5655
|
}
|
|
5566
5656
|
if (error) {
|
|
5567
|
-
return /* @__PURE__ */ jsx15("div", { className:
|
|
5657
|
+
return /* @__PURE__ */ jsx15("div", { className: cn15("cls_pdf_viewer", "cls_pdf_viewer_error", className), children: /* @__PURE__ */ jsxs14("div", { className: "cls_pdf_viewer_error_message", children: [
|
|
5568
5658
|
"Error loading PDF: ",
|
|
5569
5659
|
error.message
|
|
5570
5660
|
] }) });
|
|
5571
5661
|
}
|
|
5572
5662
|
if (!pdf_document) {
|
|
5573
5663
|
if (is_multi_file_mode) {
|
|
5574
|
-
return /* @__PURE__ */ jsxs14("div", { className:
|
|
5664
|
+
return /* @__PURE__ */ jsxs14("div", { className: cn15("hazo-pdf-root cls_pdf_viewer", className), children: [
|
|
5575
5665
|
/* @__PURE__ */ jsx15(
|
|
5576
5666
|
FileManager,
|
|
5577
5667
|
{
|
|
@@ -5587,7 +5677,7 @@ ${suffix_line}`;
|
|
|
5587
5677
|
/* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_empty_state", children: /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_empty_message", children: "Click the + button above to upload a file" }) })
|
|
5588
5678
|
] });
|
|
5589
5679
|
}
|
|
5590
|
-
return /* @__PURE__ */ jsx15("div", { className:
|
|
5680
|
+
return /* @__PURE__ */ jsx15("div", { className: cn15("cls_pdf_viewer", className), children: /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_no_document", children: "No PDF document loaded" }) });
|
|
5591
5681
|
}
|
|
5592
5682
|
const base_toolbar_config = config_ref.current?.toolbar || default_config.toolbar;
|
|
5593
5683
|
const toolbar_config = {
|
|
@@ -5606,7 +5696,7 @@ ${suffix_line}`;
|
|
|
5606
5696
|
toolbar_show_rotation_controls: base_toolbar_config.toolbar_show_rotation_controls ?? true
|
|
5607
5697
|
};
|
|
5608
5698
|
const is_toolbar_enabled = toolbar_enabled ?? true;
|
|
5609
|
-
return /* @__PURE__ */ jsxs14("div", { className:
|
|
5699
|
+
return /* @__PURE__ */ jsxs14("div", { className: cn15("hazo-pdf-root cls_pdf_viewer", className), children: [
|
|
5610
5700
|
is_multi_file_mode && /* @__PURE__ */ jsx15(
|
|
5611
5701
|
FileManager,
|
|
5612
5702
|
{
|
|
@@ -5743,7 +5833,7 @@ ${suffix_line}`;
|
|
|
5743
5833
|
{
|
|
5744
5834
|
type: "button",
|
|
5745
5835
|
onClick: () => setCurrentTool(current_tool === "Square" ? null : "Square"),
|
|
5746
|
-
className:
|
|
5836
|
+
className: cn15(
|
|
5747
5837
|
"cls_pdf_viewer_toolbar_button",
|
|
5748
5838
|
current_tool === "Square" && "cls_pdf_viewer_toolbar_button_active"
|
|
5749
5839
|
),
|
|
@@ -5771,7 +5861,7 @@ ${suffix_line}`;
|
|
|
5771
5861
|
{
|
|
5772
5862
|
type: "button",
|
|
5773
5863
|
onClick: () => setCurrentTool(current_tool === "FreeText" ? null : "FreeText"),
|
|
5774
|
-
className:
|
|
5864
|
+
className: cn15(
|
|
5775
5865
|
"cls_pdf_viewer_toolbar_button",
|
|
5776
5866
|
current_tool === "FreeText" && "cls_pdf_viewer_toolbar_button_active"
|
|
5777
5867
|
),
|
|
@@ -5801,7 +5891,7 @@ ${suffix_line}`;
|
|
|
5801
5891
|
type: "button",
|
|
5802
5892
|
onClick: handle_undo,
|
|
5803
5893
|
disabled: history_index === 0,
|
|
5804
|
-
className:
|
|
5894
|
+
className: cn15(
|
|
5805
5895
|
"cls_pdf_viewer_toolbar_button",
|
|
5806
5896
|
history_index === 0 && "cls_pdf_viewer_toolbar_button_disabled"
|
|
5807
5897
|
),
|
|
@@ -5829,7 +5919,7 @@ ${suffix_line}`;
|
|
|
5829
5919
|
type: "button",
|
|
5830
5920
|
onClick: handle_redo,
|
|
5831
5921
|
disabled: history_index >= history.length - 1,
|
|
5832
|
-
className:
|
|
5922
|
+
className: cn15(
|
|
5833
5923
|
"cls_pdf_viewer_toolbar_button",
|
|
5834
5924
|
history_index >= history.length - 1 && "cls_pdf_viewer_toolbar_button_disabled"
|
|
5835
5925
|
),
|
|
@@ -5858,7 +5948,7 @@ ${suffix_line}`;
|
|
|
5858
5948
|
type: "button",
|
|
5859
5949
|
onClick: handle_save,
|
|
5860
5950
|
disabled: saving || !has_changes_to_save,
|
|
5861
|
-
className:
|
|
5951
|
+
className: cn15(
|
|
5862
5952
|
"cls_pdf_viewer_toolbar_button",
|
|
5863
5953
|
"cls_pdf_viewer_toolbar_button_save",
|
|
5864
5954
|
(saving || !has_changes_to_save) && "cls_pdf_viewer_toolbar_button_disabled"
|
|
@@ -5887,7 +5977,7 @@ ${suffix_line}`;
|
|
|
5887
5977
|
type: "button",
|
|
5888
5978
|
onClick: handle_download,
|
|
5889
5979
|
disabled: downloading || !pdf_document,
|
|
5890
|
-
className:
|
|
5980
|
+
className: cn15(
|
|
5891
5981
|
"cls_pdf_viewer_toolbar_button",
|
|
5892
5982
|
"cls_pdf_viewer_toolbar_button_download",
|
|
5893
5983
|
(downloading || !pdf_document) && "cls_pdf_viewer_toolbar_button_disabled"
|
|
@@ -5916,7 +6006,7 @@ ${suffix_line}`;
|
|
|
5916
6006
|
type: "button",
|
|
5917
6007
|
onClick: handle_extract,
|
|
5918
6008
|
disabled: extracting || !pdf_document,
|
|
5919
|
-
className:
|
|
6009
|
+
className: cn15(
|
|
5920
6010
|
"cls_pdf_viewer_toolbar_button",
|
|
5921
6011
|
(extracting || !pdf_document) && "cls_pdf_viewer_toolbar_button_disabled"
|
|
5922
6012
|
),
|
|
@@ -5935,7 +6025,7 @@ ${suffix_line}`;
|
|
|
5935
6025
|
onMouseLeave: (e) => {
|
|
5936
6026
|
e.currentTarget.style.backgroundColor = toolbar_config.toolbar_button_background_color;
|
|
5937
6027
|
},
|
|
5938
|
-
children: /* @__PURE__ */ jsx15(Sparkles, { className:
|
|
6028
|
+
children: /* @__PURE__ */ jsx15(Sparkles, { className: cn15("cls_pdf_viewer_toolbar_icon", extracting && "animate-spin"), size: 16 })
|
|
5939
6029
|
}
|
|
5940
6030
|
) }),
|
|
5941
6031
|
sidepanel_metadata_enabled && metadata_input && toolbar_config.toolbar_show_metadata_button && /* @__PURE__ */ jsx15("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsx15(
|
|
@@ -5943,7 +6033,7 @@ ${suffix_line}`;
|
|
|
5943
6033
|
{
|
|
5944
6034
|
type: "button",
|
|
5945
6035
|
onClick: handle_sidepanel_toggle,
|
|
5946
|
-
className:
|
|
6036
|
+
className: cn15(
|
|
5947
6037
|
"cls_pdf_viewer_toolbar_button",
|
|
5948
6038
|
sidepanel_open && "cls_pdf_viewer_toolbar_button_active"
|
|
5949
6039
|
),
|
|
@@ -5969,7 +6059,7 @@ ${suffix_line}`;
|
|
|
5969
6059
|
{
|
|
5970
6060
|
type: "button",
|
|
5971
6061
|
onClick: handle_file_info_sidepanel_toggle,
|
|
5972
|
-
className:
|
|
6062
|
+
className: cn15(
|
|
5973
6063
|
"cls_pdf_viewer_toolbar_button",
|
|
5974
6064
|
file_info_sidepanel_open && "cls_pdf_viewer_toolbar_button_active"
|
|
5975
6065
|
),
|
|
@@ -6018,7 +6108,7 @@ ${suffix_line}`;
|
|
|
6018
6108
|
type: "button",
|
|
6019
6109
|
onClick: handle_download,
|
|
6020
6110
|
disabled: downloading || !pdf_document,
|
|
6021
|
-
className:
|
|
6111
|
+
className: cn15(
|
|
6022
6112
|
"cls_pdf_viewer_toolbar_button",
|
|
6023
6113
|
(downloading || !pdf_document) && "cls_pdf_viewer_toolbar_button_disabled"
|
|
6024
6114
|
),
|
|
@@ -6070,7 +6160,7 @@ ${suffix_line}`;
|
|
|
6070
6160
|
const has_metadata_sidepanel = sidepanel_metadata_enabled && metadata_input;
|
|
6071
6161
|
const has_file_info_sidepanel = (file_metadata && file_metadata.length > 0 || hazo_files_available || doc_data || highlight_fields_info || extractions && extractions.length > 0) && toolbar_config.toolbar_show_file_info_button;
|
|
6072
6162
|
const any_sidepanel_available = has_metadata_sidepanel || has_file_info_sidepanel;
|
|
6073
|
-
return /* @__PURE__ */ jsxs14("div", { className:
|
|
6163
|
+
return /* @__PURE__ */ jsxs14("div", { className: cn15("cls_pdf_viewer_content_wrapper", any_sidepanel_open && "cls_pdf_viewer_content_wrapper_with_sidepanel"), children: [
|
|
6074
6164
|
any_sidepanel_available && !any_sidepanel_open && /* @__PURE__ */ jsxs14(
|
|
6075
6165
|
"button",
|
|
6076
6166
|
{
|
|
@@ -6095,7 +6185,7 @@ ${suffix_line}`;
|
|
|
6095
6185
|
"div",
|
|
6096
6186
|
{
|
|
6097
6187
|
ref: content_container_ref,
|
|
6098
|
-
className:
|
|
6188
|
+
className: cn15("cls_pdf_viewer_content", any_sidepanel_open && "cls_pdf_viewer_content_with_sidepanel"),
|
|
6099
6189
|
style: any_sidepanel_open ? { width: `calc(100% - ${total_sidepanel_width}px)` } : void 0,
|
|
6100
6190
|
children: /* @__PURE__ */ jsx15(
|
|
6101
6191
|
PdfViewerLayout,
|
|
@@ -6253,7 +6343,7 @@ ${suffix_line}`;
|
|
|
6253
6343
|
font_name: stamp.font_name
|
|
6254
6344
|
};
|
|
6255
6345
|
const annotation = {
|
|
6256
|
-
id:
|
|
6346
|
+
id: generateRequestId2().slice(4),
|
|
6257
6347
|
type: "FreeText",
|
|
6258
6348
|
page_index: context_menu.page_index,
|
|
6259
6349
|
rect: [pdf_x, pdf_y, pdf_x + 10, pdf_y + 10],
|
|
@@ -6311,7 +6401,7 @@ ${suffix_line}`;
|
|
|
6311
6401
|
const font_foreground_color = config_ref.current?.fonts.font_foreground_color;
|
|
6312
6402
|
const text_color = freetext_text_color && freetext_text_color !== "#000000" ? freetext_text_color : font_foreground_color || "#000000";
|
|
6313
6403
|
const annotation = {
|
|
6314
|
-
id:
|
|
6404
|
+
id: generateRequestId2().slice(4),
|
|
6315
6405
|
type: "FreeText",
|
|
6316
6406
|
page_index: text_dialog.page_index,
|
|
6317
6407
|
rect: [
|
|
@@ -6365,7 +6455,6 @@ PdfViewer.displayName = "PdfViewer";
|
|
|
6365
6455
|
var pdf_viewer_default = PdfViewer;
|
|
6366
6456
|
|
|
6367
6457
|
export {
|
|
6368
|
-
cn,
|
|
6369
6458
|
load_pdf_document,
|
|
6370
6459
|
create_coordinate_mapper,
|
|
6371
6460
|
get_viewport_dimensions,
|
|
@@ -6401,4 +6490,4 @@ export {
|
|
|
6401
6490
|
PdfViewer,
|
|
6402
6491
|
pdf_viewer_default
|
|
6403
6492
|
};
|
|
6404
|
-
//# sourceMappingURL=chunk-
|
|
6493
|
+
//# sourceMappingURL=chunk-KDOQ3FIO.js.map
|