teamsync-pdf-viewer 1.3.2 → 1.3.3
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.
|
@@ -1607,7 +1607,7 @@ var it = ({ pdfDoc: e, pageIndex: t, isActive: n, onClick: r, scale: a }) => {
|
|
|
1607
1607
|
if (!c) return;
|
|
1608
1608
|
let u = c.getContext("2d");
|
|
1609
1609
|
if (!u) return;
|
|
1610
|
-
let d = window.devicePixelRatio || 1;
|
|
1610
|
+
let d = Math.min(window.devicePixelRatio || 1, 2);
|
|
1611
1611
|
c.width = Math.floor(s.width * d), c.height = Math.floor(s.height * d), c.style.width = `${s.width}px`, c.style.height = `${s.height}px`, n = i.render({
|
|
1612
1612
|
canvasContext: u,
|
|
1613
1613
|
canvas: c,
|
|
@@ -1951,7 +1951,7 @@ function st(e, t, n, r, i) {
|
|
|
1951
1951
|
y: t
|
|
1952
1952
|
};
|
|
1953
1953
|
}
|
|
1954
|
-
function
|
|
1954
|
+
function H(e, t, n, r, i, a, o) {
|
|
1955
1955
|
let s = (i % 360 + 360) % 360;
|
|
1956
1956
|
return s === 90 ? {
|
|
1957
1957
|
x: o - (t + r),
|
|
@@ -1975,34 +1975,51 @@ function ct(e, t, n, r, i, a, o) {
|
|
|
1975
1975
|
height: r
|
|
1976
1976
|
};
|
|
1977
1977
|
}
|
|
1978
|
-
function
|
|
1978
|
+
function ct(e, t, n) {
|
|
1979
1979
|
let r = (e % 360 + 360) % 360;
|
|
1980
1980
|
if (r === 90) return `translate(${n}, 0) rotate(90)`;
|
|
1981
1981
|
if (r === 180) return `translate(${t}, ${n}) rotate(180)`;
|
|
1982
1982
|
if (r === 270) return `translate(0, ${t}) rotate(270)`;
|
|
1983
1983
|
}
|
|
1984
|
-
function
|
|
1984
|
+
function lt(e) {
|
|
1985
1985
|
return (e % 360 + 360) % 360;
|
|
1986
1986
|
}
|
|
1987
1987
|
//#endregion
|
|
1988
1988
|
//#region src/utils/zoomUtils.ts
|
|
1989
|
-
var
|
|
1990
|
-
function
|
|
1989
|
+
var ut = .1, dt = 10, ft = () => typeof navigator < "u" && (/iPad|iPhone|iPod/.test(navigator.userAgent) || /^((?!chrome|android).)*safari/i.test(navigator.userAgent)), pt = 8192, mt = 4096, ht = 16777216;
|
|
1990
|
+
function gt(e, t = 10) {
|
|
1991
1991
|
return Math.min(t, Math.round((e + (e < 2 ? .25 : e < 5 ? .5 : 1)) * 100) / 100);
|
|
1992
1992
|
}
|
|
1993
|
-
function
|
|
1993
|
+
function _t(e, t = ut) {
|
|
1994
1994
|
return Math.max(t, Math.round((e - (e <= 2 ? .25 : e <= 5 ? .5 : 1)) * 100) / 100);
|
|
1995
1995
|
}
|
|
1996
|
-
function
|
|
1996
|
+
function vt(e, t = ut, n = 10) {
|
|
1997
1997
|
return Math.min(n, Math.max(t, Math.round(e * 100) / 100));
|
|
1998
1998
|
}
|
|
1999
|
-
function
|
|
1999
|
+
function yt(e, t, n, r, i = ft() ? mt : pt, a = ht) {
|
|
2000
2000
|
let o = e * t;
|
|
2001
2001
|
return n * o > i && (o = i / n), r * o > i && (o = i / r), n * o * (r * o) > a && (o = Math.sqrt(a / (n * r))), o;
|
|
2002
2002
|
}
|
|
2003
|
+
function bt(e) {
|
|
2004
|
+
let { prevScale: t, newScale: n, containerWidth: r, containerHeight: i, currentScrollLeft: a, currentScrollTop: o, basePageWidth: s, focusPoint: c, isProgrammatic: l = !1 } = e;
|
|
2005
|
+
if (l) return {
|
|
2006
|
+
scrollLeft: 0,
|
|
2007
|
+
scrollTop: o <= 1 ? 0 : o
|
|
2008
|
+
};
|
|
2009
|
+
let u = c?.vx != null && c?.vy != null;
|
|
2010
|
+
if (!u && o <= 0) return {
|
|
2011
|
+
scrollLeft: 0,
|
|
2012
|
+
scrollTop: 0
|
|
2013
|
+
};
|
|
2014
|
+
let d = u ? c.vx : r / 2, f = u ? c.vy : i / 2, p = d + a, m = f + o, h = Math.max(0, r / 2 - s * t / 2), g = Math.max(0, r / 2 - s * n / 2) + (p - h) * (n / t);
|
|
2015
|
+
return {
|
|
2016
|
+
scrollLeft: Math.max(0, g - d),
|
|
2017
|
+
scrollTop: Math.max(0, n / t * m - f)
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2003
2020
|
//#endregion
|
|
2004
2021
|
//#region src/components/PageRenderer.tsx
|
|
2005
|
-
function
|
|
2022
|
+
function xt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, containerHeight: l, scrollTop: u, scrollLeft: d, pageTop: f, pageLeft: p = 0, basePageWidth: m, basePageHeight: h, activeTab: g, activeTool: _, annotations: v, selectedAnnotationId: y, activeSearchResult: b, transientHighlights: x, onMouseDown: ee, onMouseMove: S, onMouseUp: C, onAnnotationClick: te, onAnnotationMouseEnter: ne, onClearSelection: re, watermark: ie, watermarkText: w, redactions: T, onDiscardRedaction: ae, onRendered: oe }) {
|
|
2006
2023
|
let E = s(oe);
|
|
2007
2024
|
E.current = oe;
|
|
2008
2025
|
let D = s(null), O = s(null), k = s(null), se = s(null), A = s(!1), [ce, le] = c(null), ue = m * r, de = h * r;
|
|
@@ -2026,10 +2043,10 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2026
2043
|
return;
|
|
2027
2044
|
}
|
|
2028
2045
|
se.current = i;
|
|
2029
|
-
let o = window.devicePixelRatio || 1, s =
|
|
2046
|
+
let o = Math.min(window.devicePixelRatio || 1, 2), s = lt(i.rotate + a), c = i.getViewport({
|
|
2030
2047
|
scale: 1,
|
|
2031
2048
|
rotation: s
|
|
2032
|
-
}), l =
|
|
2049
|
+
}), l = yt(r, o, c.width, c.height), u = i.getViewport({
|
|
2033
2050
|
scale: l,
|
|
2034
2051
|
rotation: s
|
|
2035
2052
|
}), d = document.createElement("canvas");
|
|
@@ -2048,7 +2065,7 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2048
2065
|
f.save(), f.setTransform(1, 0, 0, 1, 0, 0);
|
|
2049
2066
|
let e = a % 180 == 0 ? m : h, n = a % 180 == 0 ? h : m;
|
|
2050
2067
|
for (let i of T) if (i.pageIndex === t) {
|
|
2051
|
-
let t =
|
|
2068
|
+
let t = H(i.x, i.y, i.width, i.height, a, e, n), o = t.x * l, s = t.y * l, c = t.width * l, u = t.height * l;
|
|
2052
2069
|
i.status === "applied" || i.status === void 0 ? (f.fillStyle = "#000000", f.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u))) : (f.fillStyle = "rgba(0, 0, 0, 0.45)", f.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u)), f.lineWidth = Math.max(1, l / (r || 1) * 2), f.strokeStyle = "#dc2626", f.strokeRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u)));
|
|
2053
2070
|
}
|
|
2054
2071
|
f.restore();
|
|
@@ -2151,7 +2168,7 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2151
2168
|
try {
|
|
2152
2169
|
let r = await n.getPage(t), i = r.getViewport({
|
|
2153
2170
|
scale: 1,
|
|
2154
|
-
rotation:
|
|
2171
|
+
rotation: lt(r.rotate + a)
|
|
2155
2172
|
}), o = ce;
|
|
2156
2173
|
if (T && T.length > 0) {
|
|
2157
2174
|
let e = T.filter((e) => e.pageIndex === t);
|
|
@@ -2245,7 +2262,7 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2245
2262
|
children: [
|
|
2246
2263
|
/* @__PURE__ */ F("style", { children: "\n @keyframes tspdf-transient-pulse {\n 0% {\n box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.75), 0 0 8px rgba(234, 179, 8, 0.4);\n }\n 50% {\n box-shadow: 0 0 0 6px rgba(234, 179, 8, 0.25), 0 0 18px rgba(234, 179, 8, 0.7);\n }\n 100% {\n box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.75), 0 0 8px rgba(234, 179, 8, 0.4);\n }\n }\n " }),
|
|
2247
2264
|
b && b.pageIndex === t && b.bounds.map((e, t) => {
|
|
2248
|
-
let o =
|
|
2265
|
+
let o = H(e.x, i - e.y - e.height, e.width, e.height, a, n, i);
|
|
2249
2266
|
return /* @__PURE__ */ F("div", { style: {
|
|
2250
2267
|
position: "absolute",
|
|
2251
2268
|
left: `${o.x * r}px`,
|
|
@@ -2259,7 +2276,7 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2259
2276
|
} }, `search-${t}`);
|
|
2260
2277
|
}),
|
|
2261
2278
|
x && x.filter((e) => e.pageIndex === t).map((t, o) => /* @__PURE__ */ F(e.Fragment, { children: t.bounds.map((e, o) => {
|
|
2262
|
-
let s =
|
|
2279
|
+
let s = H(e.x, i - e.y - e.height, e.width, e.height, a, n, i), c = t.color || "rgba(250, 204, 21, 0.45)", l = t.borderColor || "rgba(234, 179, 8, 0.85)";
|
|
2263
2280
|
return /* @__PURE__ */ F("div", {
|
|
2264
2281
|
style: {
|
|
2265
2282
|
position: "absolute",
|
|
@@ -2300,7 +2317,7 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2300
2317
|
});
|
|
2301
2318
|
})(),
|
|
2302
2319
|
(() => {
|
|
2303
|
-
let n =
|
|
2320
|
+
let n = ct(a, a % 180 == 0 ? m : h, a % 180 == 0 ? h : m);
|
|
2304
2321
|
return /* @__PURE__ */ F("svg", {
|
|
2305
2322
|
style: {
|
|
2306
2323
|
position: "absolute",
|
|
@@ -2695,17 +2712,17 @@ function vt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2695
2712
|
]
|
|
2696
2713
|
});
|
|
2697
2714
|
}
|
|
2698
|
-
var
|
|
2715
|
+
var St = e.memo(xt, (e, t) => e.pageNum === t.pageNum && e.pdfDoc === t.pdfDoc && e.scale === t.scale && e.rotation === t.rotation && e.basePageWidth === t.basePageWidth && e.basePageHeight === t.basePageHeight && e.pageTop === t.pageTop && e.pageLeft === t.pageLeft && e.activeTab === t.activeTab && e.activeTool === t.activeTool && e.selectedAnnotationId === t.selectedAnnotationId && e.activeSearchResult === t.activeSearchResult && e.watermark === t.watermark && e.watermarkText === t.watermarkText && e.redactions === t.redactions && e.annotations === t.annotations && e.transientHighlights === t.transientHighlights);
|
|
2699
2716
|
//#endregion
|
|
2700
2717
|
//#region src/annotations/ids.ts
|
|
2701
|
-
function
|
|
2718
|
+
function Ct() {
|
|
2702
2719
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
2703
2720
|
let e = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
2704
2721
|
return `${e.slice(0, 8)}-${e.slice(8, 12)}-4${e.slice(13, 16)}-a${e.slice(17, 20)}-${e.slice(20, 32)}`;
|
|
2705
2722
|
}
|
|
2706
2723
|
//#endregion
|
|
2707
2724
|
//#region src/utils/findRegexRedactions.ts
|
|
2708
|
-
async function
|
|
2725
|
+
async function wt(e, t) {
|
|
2709
2726
|
let n = [];
|
|
2710
2727
|
if (!e || !t || t.length === 0) return n;
|
|
2711
2728
|
let r = e.numPages, i = t.map((e) => new RegExp(e, e.flags.includes("g") ? e.flags : e.flags + "g"));
|
|
@@ -2753,31 +2770,62 @@ async function xt(e, t) {
|
|
|
2753
2770
|
return n;
|
|
2754
2771
|
}
|
|
2755
2772
|
//#endregion
|
|
2773
|
+
//#region src/utils/layoutUtils.ts
|
|
2774
|
+
var Tt = {
|
|
2775
|
+
width: 612,
|
|
2776
|
+
height: 792
|
|
2777
|
+
};
|
|
2778
|
+
function Et(e, t = Tt) {
|
|
2779
|
+
if (e <= 0) return [];
|
|
2780
|
+
let n = {
|
|
2781
|
+
width: t.width,
|
|
2782
|
+
height: t.height
|
|
2783
|
+
};
|
|
2784
|
+
return Array.from({ length: e }, () => ({ ...n }));
|
|
2785
|
+
}
|
|
2786
|
+
function Dt(e, t, n, r = 16) {
|
|
2787
|
+
let i = e.map((e) => e.length === 0 ? r : Math.max(...e.map((e) => t(e).height)) * n + r), a = [], o = 0;
|
|
2788
|
+
for (let e of i) a.push(o), o += e;
|
|
2789
|
+
return {
|
|
2790
|
+
heights: i,
|
|
2791
|
+
tops: a,
|
|
2792
|
+
total: o
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
function U(e, t, n = .5) {
|
|
2796
|
+
if (e.length !== t.length) return !0;
|
|
2797
|
+
for (let r = 0; r < e.length; r++) {
|
|
2798
|
+
let i = e[r], a = t[r];
|
|
2799
|
+
if (Math.abs(i.width - a.width) > n || Math.abs(i.height - a.height) > n) return !0;
|
|
2800
|
+
}
|
|
2801
|
+
return !1;
|
|
2802
|
+
}
|
|
2803
|
+
//#endregion
|
|
2756
2804
|
//#region src/core/pdfAssets.ts
|
|
2757
|
-
var
|
|
2758
|
-
function
|
|
2759
|
-
|
|
2760
|
-
...
|
|
2805
|
+
var W = {};
|
|
2806
|
+
function Ot(e) {
|
|
2807
|
+
W = {
|
|
2808
|
+
...W,
|
|
2761
2809
|
...e
|
|
2762
2810
|
}, e.workerSrc && (L.GlobalWorkerOptions.workerSrc = e.workerSrc);
|
|
2763
2811
|
}
|
|
2764
|
-
function
|
|
2765
|
-
return
|
|
2812
|
+
function G() {
|
|
2813
|
+
return W;
|
|
2766
2814
|
}
|
|
2767
|
-
function
|
|
2768
|
-
return !!(
|
|
2815
|
+
function kt() {
|
|
2816
|
+
return !!(W.workerSrc || L.GlobalWorkerOptions.workerSrc);
|
|
2769
2817
|
}
|
|
2770
|
-
function
|
|
2771
|
-
if (!
|
|
2818
|
+
function At() {
|
|
2819
|
+
if (!kt()) throw Error("[teamsync-pdf-viewer] pdf.js worker not configured. Call configurePdfAssets({ workerSrc }) with the URL of pdf.worker.min.mjs (same pdfjs-dist version) before loading a document, or pass `assets={{ workerSrc }}` to <TeamSyncViewer>.");
|
|
2772
2820
|
}
|
|
2773
|
-
function
|
|
2821
|
+
function jt() {
|
|
2774
2822
|
let e = {};
|
|
2775
|
-
return
|
|
2823
|
+
return W.cMapUrl && (e.cMapUrl = W.cMapUrl, e.cMapPacked = !0), W.standardFontDataUrl && (e.standardFontDataUrl = W.standardFontDataUrl), W.wasmUrl && (e.wasmUrl = W.wasmUrl), W.iccUrl && (e.iccUrl = W.iccUrl), e;
|
|
2776
2824
|
}
|
|
2777
|
-
var
|
|
2825
|
+
var Mt = L.version;
|
|
2778
2826
|
//#endregion
|
|
2779
2827
|
//#region src/components/DiffHighlightOverlay.tsx
|
|
2780
|
-
function
|
|
2828
|
+
function Nt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onSelectDiff: i }) {
|
|
2781
2829
|
let [a, o] = c(null);
|
|
2782
2830
|
if (!e || e.length === 0) return null;
|
|
2783
2831
|
let s = e.filter((e) => n === "deletions" ? e.type === "deletion" || e.type === "modification" : n !== "additions" || e.type === "addition" || e.type === "modification");
|
|
@@ -2882,7 +2930,7 @@ function Ot({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onS
|
|
|
2882
2930
|
}
|
|
2883
2931
|
//#endregion
|
|
2884
2932
|
//#region src/components/SideBySideViewer.tsx
|
|
2885
|
-
function
|
|
2933
|
+
function Pt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePageDims: o, activeTab: l, activeTool: u, annotations: d, watermark: f, watermarkText: p, redactions: m, diffsA: h = [], diffsB: g = [], selectedDiffId: _, onSelectDiff: v }) {
|
|
2886
2934
|
let y = s(null), b = s(null), x = s(!1);
|
|
2887
2935
|
i(() => {
|
|
2888
2936
|
let e = y.current, t = b.current;
|
|
@@ -2988,7 +3036,7 @@ function kt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
2988
3036
|
height: `${re}px`,
|
|
2989
3037
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
|
|
2990
3038
|
},
|
|
2991
|
-
children: [e && /* @__PURE__ */ F(
|
|
3039
|
+
children: [e && /* @__PURE__ */ F(St, {
|
|
2992
3040
|
pageNum: n,
|
|
2993
3041
|
pdfDoc: e,
|
|
2994
3042
|
scale: r,
|
|
@@ -3014,7 +3062,7 @@ function kt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3014
3062
|
watermark: f,
|
|
3015
3063
|
watermarkText: p,
|
|
3016
3064
|
redactions: m
|
|
3017
|
-
}), /* @__PURE__ */ F(
|
|
3065
|
+
}), /* @__PURE__ */ F(Nt, {
|
|
3018
3066
|
boxes: h,
|
|
3019
3067
|
scale: r,
|
|
3020
3068
|
colorScheme: "deletions",
|
|
@@ -3052,7 +3100,7 @@ function kt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3052
3100
|
height: `${w}px`,
|
|
3053
3101
|
boxShadow: "0 4px 12px rgba(0,0,0,0.15)"
|
|
3054
3102
|
},
|
|
3055
|
-
children: [t && /* @__PURE__ */ F(
|
|
3103
|
+
children: [t && /* @__PURE__ */ F(St, {
|
|
3056
3104
|
pageNum: n,
|
|
3057
3105
|
pdfDoc: t,
|
|
3058
3106
|
scale: r,
|
|
@@ -3078,7 +3126,7 @@ function kt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3078
3126
|
watermark: f,
|
|
3079
3127
|
watermarkText: p,
|
|
3080
3128
|
redactions: m
|
|
3081
|
-
}), /* @__PURE__ */ F(
|
|
3129
|
+
}), /* @__PURE__ */ F(Nt, {
|
|
3082
3130
|
boxes: g,
|
|
3083
3131
|
scale: r,
|
|
3084
3132
|
colorScheme: "additions",
|
|
@@ -3091,7 +3139,7 @@ function kt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3091
3139
|
}
|
|
3092
3140
|
//#endregion
|
|
3093
3141
|
//#region src/components/CompareToolbar.tsx
|
|
3094
|
-
function
|
|
3142
|
+
function Ft({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r, onPrevDiff: i, onNextDiff: a, onExit: o }) {
|
|
3095
3143
|
let { mode: s, colorA: c, colorB: l, showCurtain: u, diffItems: d, currentDiffIndex: f } = e;
|
|
3096
3144
|
return /* @__PURE__ */ I("div", {
|
|
3097
3145
|
style: {
|
|
@@ -3347,7 +3395,7 @@ function At({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r,
|
|
|
3347
3395
|
}
|
|
3348
3396
|
//#endregion
|
|
3349
3397
|
//#region src/components/DiffSummarySidebar.tsx
|
|
3350
|
-
function
|
|
3398
|
+
function It({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSelectDiff: i, onJumpToPage: a }) {
|
|
3351
3399
|
return e ? /* @__PURE__ */ I("div", {
|
|
3352
3400
|
style: {
|
|
3353
3401
|
width: "320px",
|
|
@@ -3578,7 +3626,7 @@ function jt({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSele
|
|
|
3578
3626
|
}
|
|
3579
3627
|
//#endregion
|
|
3580
3628
|
//#region src/components/CompareCurtainSlider.tsx
|
|
3581
|
-
function
|
|
3629
|
+
function Lt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
3582
3630
|
let [r, a] = c(!1), o = s(null);
|
|
3583
3631
|
return i(() => {
|
|
3584
3632
|
let e = (e) => {
|
|
@@ -3635,7 +3683,7 @@ function Mt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
|
3635
3683
|
}
|
|
3636
3684
|
//#endregion
|
|
3637
3685
|
//#region src/utils/pdfDiffEngine.ts
|
|
3638
|
-
async function
|
|
3686
|
+
async function Rt(e) {
|
|
3639
3687
|
let t = e.getViewport({
|
|
3640
3688
|
scale: 1,
|
|
3641
3689
|
rotation: e.rotate
|
|
@@ -3658,8 +3706,8 @@ async function Nt(e) {
|
|
|
3658
3706
|
}
|
|
3659
3707
|
return r;
|
|
3660
3708
|
}
|
|
3661
|
-
async function
|
|
3662
|
-
let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([
|
|
3709
|
+
async function zt(e, t, n) {
|
|
3710
|
+
let [r, i] = await Promise.all([e.getPage(n), t.getPage(Math.min(n, t.numPages))]), [a, o] = await Promise.all([Rt(r), Rt(i)]), s = a.map((e) => e.text), c = o.map((e) => e.text), l = s.length, u = c.length, d = l + u, f = new Int32Array(2 * d + 1);
|
|
3663
3711
|
f[1] = 0;
|
|
3664
3712
|
let p = [];
|
|
3665
3713
|
for (let e = 0; e <= d; e++) {
|
|
@@ -3682,7 +3730,7 @@ async function Pt(e, t, n) {
|
|
|
3682
3730
|
e > 0 && (m === i ? (_.push(h - 1), h--) : h === a && (g.push(m - 1), m--));
|
|
3683
3731
|
}
|
|
3684
3732
|
g.reverse(), _.reverse();
|
|
3685
|
-
let v =
|
|
3733
|
+
let v = Bt(g.map((e) => a[e]), n, "deletion"), y = Bt(_.map((e) => o[e]), n, "addition"), b = [];
|
|
3686
3734
|
for (let e of v) b.push({
|
|
3687
3735
|
id: e.id,
|
|
3688
3736
|
pageIndex: n,
|
|
@@ -3709,16 +3757,16 @@ async function Pt(e, t, n) {
|
|
|
3709
3757
|
summary: b
|
|
3710
3758
|
};
|
|
3711
3759
|
}
|
|
3712
|
-
function
|
|
3760
|
+
function Bt(e, t, n) {
|
|
3713
3761
|
if (e.length === 0) return [];
|
|
3714
3762
|
let r = [], i = [e[0]];
|
|
3715
3763
|
for (let a = 1; a < e.length; a++) {
|
|
3716
3764
|
let o = i[i.length - 1], s = e[a], c = Math.abs(s.y - o.y) < Math.max(o.height, s.height) * .6, l = s.x - (o.x + o.width) < 30;
|
|
3717
|
-
c && l ? i.push(s) : (r.push(
|
|
3765
|
+
c && l ? i.push(s) : (r.push(Vt(i, t, n, r.length + 1)), i = [s]);
|
|
3718
3766
|
}
|
|
3719
|
-
return i.length > 0 && r.push(
|
|
3767
|
+
return i.length > 0 && r.push(Vt(i, t, n, r.length + 1)), r;
|
|
3720
3768
|
}
|
|
3721
|
-
function
|
|
3769
|
+
function Vt(e, t, n, r) {
|
|
3722
3770
|
let i = Math.min(...e.map((e) => e.x)), a = Math.min(...e.map((e) => e.y)), o = Math.max(...e.map((e) => e.x + e.width)), s = Math.max(...e.map((e) => e.y + e.height)), c = e.map((e) => e.text).join(" ");
|
|
3723
3771
|
return {
|
|
3724
3772
|
id: `diff-box-${t}-${n}-${r}-${Math.round(i)}-${Math.round(a)}`,
|
|
@@ -3731,7 +3779,7 @@ function It(e, t, n, r) {
|
|
|
3731
3779
|
height: s - a + 2
|
|
3732
3780
|
};
|
|
3733
3781
|
}
|
|
3734
|
-
function
|
|
3782
|
+
function Ht(e, t, n) {
|
|
3735
3783
|
let r = e.split(/(\s+)/), i = t.split(/(\s+)/), a = r.length, o = i.length, s = a + o, c = new Int32Array(2 * s + 1);
|
|
3736
3784
|
c[1] = 0;
|
|
3737
3785
|
let l = [];
|
|
@@ -3742,7 +3790,7 @@ function Lt(e, t, n) {
|
|
|
3742
3790
|
u = t === -e || t !== e && c[t - 1 + s] < c[t + 1 + s] ? c[t + 1 + s] : c[t - 1 + s] + 1;
|
|
3743
3791
|
let d = u - t;
|
|
3744
3792
|
for (; u < a && d < o && r[u] === i[d];) u++, d++;
|
|
3745
|
-
if (c[t + s] = u, u >= a && d >= o) return
|
|
3793
|
+
if (c[t + s] = u, u >= a && d >= o) return Ut(l, r, i, n);
|
|
3746
3794
|
}
|
|
3747
3795
|
}
|
|
3748
3796
|
return [{
|
|
@@ -3755,7 +3803,7 @@ function Lt(e, t, n) {
|
|
|
3755
3803
|
pageIndex: n
|
|
3756
3804
|
}];
|
|
3757
3805
|
}
|
|
3758
|
-
function
|
|
3806
|
+
function Ut(e, t, n, r) {
|
|
3759
3807
|
let i = t.length, a = n.length, o = t.length + n.length, s = [];
|
|
3760
3808
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
3761
3809
|
let c = e[r], l = i - a, u;
|
|
@@ -3781,10 +3829,10 @@ function Rt(e, t, n, r) {
|
|
|
3781
3829
|
});
|
|
3782
3830
|
return c;
|
|
3783
3831
|
}
|
|
3784
|
-
function
|
|
3832
|
+
function Wt(e, t, n, r, i = .75) {
|
|
3785
3833
|
e.save(), e.globalCompositeOperation = "source-atop", e.fillStyle = r, e.globalAlpha = i, e.fillRect(0, 0, t, n), e.restore();
|
|
3786
3834
|
}
|
|
3787
|
-
function
|
|
3835
|
+
function Gt(e, t, n, r) {
|
|
3788
3836
|
let i = Math.min(e.width, t.width), a = Math.min(e.height, t.height);
|
|
3789
3837
|
if (i === 0 || a === 0) return [];
|
|
3790
3838
|
let o = e.getContext("2d"), s = t.getContext("2d");
|
|
@@ -3811,7 +3859,7 @@ function zt(e, t, n, r) {
|
|
|
3811
3859
|
}
|
|
3812
3860
|
//#endregion
|
|
3813
3861
|
//#region src/components/DocumentViewer.tsx
|
|
3814
|
-
function
|
|
3862
|
+
function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationManager: u, initialDoc: d, loadNonce: p = 0, withCredentials: h = !1, assets: g, sidebars: _ = !0, redactions: v, regexRedactions: x, scale: S, setScale: C, sidebarTab: te, setSidebarTab: ne, onAnnotationsChange: ie, onRedactionsChange: T, onDocumentLoaded: ae, onLoadError: oe, onFirstPageRendered: E, onPageChange: D, pageTransition: O, pageLayout: se, rotation: A, setRotation: le, watermark: ue, watermarkText: de, enableAnnotations: fe, initialPage: pe, page: me, transientHighlights: _e, permissions: ve }) {
|
|
3815
3863
|
let j = s(null), ye = Le(), [M, xe] = c(null), [Se, Ce] = c(null), [N, we] = c(1), [Te, Ee] = c([]), { getCommand: De } = Qe(), [ke, P] = c(null), [R, z] = c({
|
|
3816
3864
|
isActive: !1,
|
|
3817
3865
|
mode: "overlay",
|
|
@@ -3842,9 +3890,9 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3842
3890
|
Be.current = g;
|
|
3843
3891
|
let Ve = n(async (e) => {
|
|
3844
3892
|
try {
|
|
3845
|
-
|
|
3893
|
+
At(), Be.current && Ot(Be.current);
|
|
3846
3894
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
3847
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
3895
|
+
h && (t.withCredentials = !0), Object.assign(t, jt());
|
|
3848
3896
|
let n = await L.getDocument(t).promise;
|
|
3849
3897
|
xe(n), ze.current.onDocumentLoaded?.(n, typeof e == "string" ? e : "documentA.pdf");
|
|
3850
3898
|
} catch (e) {
|
|
@@ -3852,9 +3900,9 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3852
3900
|
}
|
|
3853
3901
|
}, [h]), V = n(async (e) => {
|
|
3854
3902
|
try {
|
|
3855
|
-
|
|
3903
|
+
At(), Be.current && Ot(Be.current);
|
|
3856
3904
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
3857
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
3905
|
+
h && (t.withCredentials = !0), Object.assign(t, jt());
|
|
3858
3906
|
let n = await L.getDocument(t).promise;
|
|
3859
3907
|
P(n), z((e) => ({
|
|
3860
3908
|
...e,
|
|
@@ -3877,7 +3925,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3877
3925
|
try {
|
|
3878
3926
|
let t = Math.min(M.numPages, ke.numPages), n = [], r = {}, i = {};
|
|
3879
3927
|
for (let a = 1; a <= t; a++) {
|
|
3880
|
-
let { diffsA: t, diffsB: o, summary: s } = await
|
|
3928
|
+
let { diffsA: t, diffsB: o, summary: s } = await zt(M, ke, a);
|
|
3881
3929
|
if (e) return;
|
|
3882
3930
|
r[a] = t, i[a] = o, n = n.concat(s);
|
|
3883
3931
|
}
|
|
@@ -3887,7 +3935,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3887
3935
|
pageDiffsA: r,
|
|
3888
3936
|
pageDiffsB: i
|
|
3889
3937
|
}));
|
|
3890
|
-
let a = await M.getPage(N), o = await ke.getPage(Math.min(N, ke.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l =
|
|
3938
|
+
let a = await M.getPage(N), o = await ke.getPage(Math.min(N, ke.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l = Ht(s.items.map((e) => e.str).join(" "), c.items.map((e) => e.str).join(" "), N);
|
|
3891
3939
|
e || Fe(l);
|
|
3892
3940
|
} catch (e) {
|
|
3893
3941
|
console.error("Error computing document diffs:", e);
|
|
@@ -3938,17 +3986,14 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3938
3986
|
Ve,
|
|
3939
3987
|
V
|
|
3940
3988
|
]);
|
|
3941
|
-
let [Ue, Ge] = c(null), [Ke, qe] = c([]), Je = Ke[0] ??
|
|
3942
|
-
width: 800,
|
|
3943
|
-
height: 1100
|
|
3944
|
-
}, Ye = n((e) => Ke[e - 1] ?? Je, [
|
|
3989
|
+
let [Ue, Ge] = c(null), [Ke, qe] = c([]), Je = Ke[0] ?? Tt, Ye = n((e) => Ke[e - 1] ?? Je, [
|
|
3945
3990
|
Ke,
|
|
3946
3991
|
Je.width,
|
|
3947
3992
|
Je.height
|
|
3948
3993
|
]), [Xe, Ze] = c({
|
|
3949
3994
|
top: 0,
|
|
3950
3995
|
left: 0
|
|
3951
|
-
}), [$e, tt] = c(!1), it = s(null),
|
|
3996
|
+
}), [$e, tt] = c(!1), it = s(null), H = o(() => {
|
|
3952
3997
|
let e = [];
|
|
3953
3998
|
if (!M) return e;
|
|
3954
3999
|
if (se === "single") for (let t = 1; t <= M.numPages; t++) e.push([t]);
|
|
@@ -3958,20 +4003,20 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3958
4003
|
for (let t = 2; t <= M.numPages; t += 2) e.push([t, t + 1].filter((e) => e <= M.numPages));
|
|
3959
4004
|
}
|
|
3960
4005
|
return e;
|
|
3961
|
-
}, [M, se]),
|
|
3962
|
-
|
|
3963
|
-
for (let r of e) t.push(n), n += r;
|
|
3964
|
-
return {
|
|
3965
|
-
heights: e,
|
|
3966
|
-
tops: t,
|
|
3967
|
-
total: n
|
|
3968
|
-
};
|
|
3969
|
-
}, [
|
|
3970
|
-
ct,
|
|
4006
|
+
}, [M, se]), ct = o(() => Dt(H, Ye, S, 16), [
|
|
4007
|
+
H,
|
|
3971
4008
|
S,
|
|
3972
4009
|
Ye
|
|
3973
|
-
]),
|
|
3974
|
-
|
|
4010
|
+
]), ut = s(H);
|
|
4011
|
+
ut.current = H;
|
|
4012
|
+
let dt = s(S);
|
|
4013
|
+
dt.current = S;
|
|
4014
|
+
let ft = s(ct);
|
|
4015
|
+
ft.current = ct;
|
|
4016
|
+
let pt = s(O);
|
|
4017
|
+
pt.current = O;
|
|
4018
|
+
let mt = s(0), ht = n((e) => H.findIndex((t) => t.includes(e)), [H]), gt = n((e) => {
|
|
4019
|
+
let t = ct.tops;
|
|
3975
4020
|
if (t.length === 0) return 0;
|
|
3976
4021
|
let n = 0, r = t.length - 1;
|
|
3977
4022
|
for (; n < r;) {
|
|
@@ -3979,30 +4024,30 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
3979
4024
|
t[i] <= e ? n = i : r = i - 1;
|
|
3980
4025
|
}
|
|
3981
4026
|
return n;
|
|
3982
|
-
}, [
|
|
4027
|
+
}, [ct]), _t = n((e, t = {}) => {
|
|
3983
4028
|
let n = M ? Math.max(1, Math.min(e, M.numPages)) : Math.max(1, e);
|
|
3984
4029
|
we(n);
|
|
3985
|
-
let r =
|
|
4030
|
+
let r = ht(n);
|
|
3986
4031
|
r >= 0 && j.current && (t.smooth ? j.current.scrollTo({
|
|
3987
|
-
top:
|
|
4032
|
+
top: ct.tops[r],
|
|
3988
4033
|
behavior: "smooth"
|
|
3989
|
-
}) : j.current.scrollTop =
|
|
4034
|
+
}) : j.current.scrollTop = ct.tops[r]);
|
|
3990
4035
|
}, [
|
|
3991
4036
|
M,
|
|
3992
|
-
|
|
3993
|
-
|
|
4037
|
+
ht,
|
|
4038
|
+
ct
|
|
3994
4039
|
]);
|
|
3995
4040
|
i(() => {
|
|
3996
4041
|
let e = (e) => {
|
|
3997
|
-
e?.page &&
|
|
4042
|
+
e?.page && _t(e.page, { smooth: e.smooth ?? !0 });
|
|
3998
4043
|
}, t = ye.on("action-go-to-page", (t) => e(t)), n = (t) => e(t.detail);
|
|
3999
4044
|
return window.addEventListener("action-go-to-page", n), () => {
|
|
4000
4045
|
t(), window.removeEventListener("action-go-to-page", n);
|
|
4001
4046
|
};
|
|
4002
|
-
}, [ye,
|
|
4003
|
-
let
|
|
4004
|
-
we(e.pageIndex), Ge(e),
|
|
4005
|
-
},
|
|
4047
|
+
}, [ye, _t]);
|
|
4048
|
+
let yt = (e) => {
|
|
4049
|
+
we(e.pageIndex), Ge(e), _t(e.pageIndex);
|
|
4050
|
+
}, xt = n((e, t) => {
|
|
4006
4051
|
let n = t || R.diffItems[e];
|
|
4007
4052
|
if (z((t) => ({
|
|
4008
4053
|
...t,
|
|
@@ -4011,7 +4056,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4011
4056
|
n.pageIndex && n.pageIndex !== N && we(n.pageIndex);
|
|
4012
4057
|
let r = (n.y ?? 0) * S, i = (n.x ?? 0) * S;
|
|
4013
4058
|
if (j.current) {
|
|
4014
|
-
let e = n.pageIndex || N, t =
|
|
4059
|
+
let e = n.pageIndex || N, t = ht(e), a = O === "continuous" && t >= 0 ? ct.tops[t] ?? 0 : 0, o = j.current.clientHeight || 600, s = j.current.clientWidth || 800, c = Math.max(0, a + r - o / 3), l = Math.max(0, i - s / 4);
|
|
4015
4060
|
j.current.scrollTo({
|
|
4016
4061
|
top: c,
|
|
4017
4062
|
left: l,
|
|
@@ -4023,40 +4068,54 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4023
4068
|
N,
|
|
4024
4069
|
S,
|
|
4025
4070
|
O,
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
]),
|
|
4071
|
+
ht,
|
|
4072
|
+
ct.tops
|
|
4073
|
+
]), U = l(u.subscribe, u.getSnapshot, u.getSnapshot), [W, G] = c("pan");
|
|
4029
4074
|
i(() => {
|
|
4030
|
-
a === "Annotate" ? (
|
|
4075
|
+
a === "Annotate" ? (G("highlight"), Mt("#fbc02d"), Ut(.5), Bt(16)) : a === "Shapes" ? (G("rectangle"), Ut(1), Bt(2)) : a === "Fill and Sign" ? G("signature") : a === "View" && G("pan");
|
|
4031
4076
|
}, [a]), i(() => {
|
|
4032
|
-
ye.emit("action-tool-changed", { tool:
|
|
4033
|
-
}, [
|
|
4034
|
-
let [
|
|
4077
|
+
ye.emit("action-tool-changed", { tool: W });
|
|
4078
|
+
}, [W, ye]);
|
|
4079
|
+
let [kt, Mt] = c("#d32f2f"), [Rt, Bt] = c(2), [Vt, Ut] = c(.8), [Wt, Gt] = c(!1), [Kt, Jt] = c(null), [K, Yt] = c({
|
|
4035
4080
|
x: 0,
|
|
4036
4081
|
y: 0
|
|
4037
|
-
}), [q,
|
|
4082
|
+
}), [q, Xt] = c({
|
|
4038
4083
|
x: 0,
|
|
4039
4084
|
y: 0
|
|
4040
|
-
}), [
|
|
4041
|
-
Re("action-set-tool", (e) =>
|
|
4042
|
-
let
|
|
4085
|
+
}), [Zt, Qt] = c([]), [J, $t] = c(null), [en, tn] = c(""), nn = s(null), [Y, X] = c(null), [rn, an] = c(null), [on, sn] = c(!1), Z = s(!1), cn = s(null);
|
|
4086
|
+
Re("action-set-tool", (e) => G(e?.tool ?? null));
|
|
4087
|
+
let ln = s({
|
|
4043
4088
|
vx: null,
|
|
4044
4089
|
vy: null
|
|
4045
|
-
}),
|
|
4090
|
+
}), un = s(S), dn = s(!1), fn = s(!1);
|
|
4046
4091
|
i(() => {
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4092
|
+
fn.current = !1;
|
|
4093
|
+
}, [M]), i(() => {
|
|
4094
|
+
if (un.current !== S) {
|
|
4095
|
+
let e = un.current, t = S;
|
|
4096
|
+
un.current = S;
|
|
4050
4097
|
let n = j.current;
|
|
4051
|
-
if (n)
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
n.
|
|
4059
|
-
|
|
4098
|
+
if (!n) return;
|
|
4099
|
+
let r = dn.current || !fn.current || On.current !== M;
|
|
4100
|
+
fn.current = !0, dn.current = !1;
|
|
4101
|
+
let i = bt({
|
|
4102
|
+
prevScale: e,
|
|
4103
|
+
newScale: t,
|
|
4104
|
+
containerWidth: n.clientWidth,
|
|
4105
|
+
containerHeight: n.clientHeight,
|
|
4106
|
+
currentScrollLeft: n.scrollLeft,
|
|
4107
|
+
currentScrollTop: n.scrollTop,
|
|
4108
|
+
basePageWidth: Ye(N).width,
|
|
4109
|
+
focusPoint: ln.current,
|
|
4110
|
+
isProgrammatic: r
|
|
4111
|
+
});
|
|
4112
|
+
if (ln.current = {
|
|
4113
|
+
vx: null,
|
|
4114
|
+
vy: null
|
|
4115
|
+
}, r && N > 1 && O === "continuous") {
|
|
4116
|
+
let e = ht(N);
|
|
4117
|
+
e >= 0 && (n.scrollTop = ct.tops[e] ?? 0), n.scrollLeft = 0;
|
|
4118
|
+
} else n.scrollLeft = i.scrollLeft, n.scrollTop = i.scrollTop;
|
|
4060
4119
|
}
|
|
4061
4120
|
}, [S]), i(() => {
|
|
4062
4121
|
let e = j.current;
|
|
@@ -4066,8 +4125,8 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4066
4125
|
t.preventDefault();
|
|
4067
4126
|
let n = e.getBoundingClientRect(), r = t.clientX, i = t.clientY, a = Math.exp(-t.deltaY * .002);
|
|
4068
4127
|
C((e) => {
|
|
4069
|
-
let t =
|
|
4070
|
-
return t !== e && (
|
|
4128
|
+
let t = vt(e * a);
|
|
4129
|
+
return t !== e && (ln.current = {
|
|
4071
4130
|
vx: r - n.left,
|
|
4072
4131
|
vy: i - n.top
|
|
4073
4132
|
}), t;
|
|
@@ -4080,11 +4139,11 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4080
4139
|
u.commit(e);
|
|
4081
4140
|
}, [u]);
|
|
4082
4141
|
Re("action-commit-digital-signature-local", (e) => {
|
|
4083
|
-
e?.tempAnn && Q([...
|
|
4142
|
+
e?.tempAnn && Q([...U, e.tempAnn]);
|
|
4084
4143
|
});
|
|
4085
|
-
let
|
|
4144
|
+
let pn = n(() => {
|
|
4086
4145
|
u.undo();
|
|
4087
|
-
}, [u]),
|
|
4146
|
+
}, [u]), mn = n(() => {
|
|
4088
4147
|
u.redo();
|
|
4089
4148
|
}, [u]);
|
|
4090
4149
|
Re("viewer-keydown", (e) => {
|
|
@@ -4098,11 +4157,11 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4098
4157
|
return;
|
|
4099
4158
|
}
|
|
4100
4159
|
if (et(e, De("UNDO"))) {
|
|
4101
|
-
e.preventDefault(),
|
|
4160
|
+
e.preventDefault(), pn();
|
|
4102
4161
|
return;
|
|
4103
4162
|
}
|
|
4104
4163
|
if (et(e, De("REDO"))) {
|
|
4105
|
-
e.preventDefault(),
|
|
4164
|
+
e.preventDefault(), mn();
|
|
4106
4165
|
return;
|
|
4107
4166
|
}
|
|
4108
4167
|
if (et(e, De("SEARCH"))) {
|
|
@@ -4115,15 +4174,15 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4115
4174
|
}
|
|
4116
4175
|
if (!t && !J) {
|
|
4117
4176
|
if (et(e, De("COPY")) && Y) {
|
|
4118
|
-
let t =
|
|
4119
|
-
t && (e.preventDefault(),
|
|
4177
|
+
let t = U.find((e) => e.id === Y);
|
|
4178
|
+
t && (e.preventDefault(), cn.current = t);
|
|
4120
4179
|
return;
|
|
4121
4180
|
}
|
|
4122
|
-
if (et(e, De("PASTE")) &&
|
|
4181
|
+
if (et(e, De("PASTE")) && cn.current) {
|
|
4123
4182
|
e.preventDefault();
|
|
4124
|
-
let t =
|
|
4183
|
+
let t = cn.current, n = {
|
|
4125
4184
|
...t,
|
|
4126
|
-
id:
|
|
4185
|
+
id: Ct(),
|
|
4127
4186
|
pageIndex: N,
|
|
4128
4187
|
x: t.x + 20,
|
|
4129
4188
|
y: t.y + 20,
|
|
@@ -4134,66 +4193,80 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4134
4193
|
readOnly: void 0,
|
|
4135
4194
|
xfdfExtras: void 0
|
|
4136
4195
|
};
|
|
4137
|
-
Q([...
|
|
4196
|
+
Q([...U, n]), X(n.id);
|
|
4138
4197
|
return;
|
|
4139
4198
|
}
|
|
4140
4199
|
if (et(e, De("DELETE")) && Y) {
|
|
4141
|
-
e.preventDefault(), Q(
|
|
4200
|
+
e.preventDefault(), Q(U.filter((e) => e.id !== Y)), X(null);
|
|
4142
4201
|
return;
|
|
4143
4202
|
}
|
|
4144
4203
|
}
|
|
4145
4204
|
}), i(() => {
|
|
4146
|
-
J &&
|
|
4147
|
-
|
|
4205
|
+
J && nn.current && setTimeout(() => {
|
|
4206
|
+
nn.current?.focus();
|
|
4148
4207
|
}, 10);
|
|
4149
4208
|
}, [J]), i(() => {
|
|
4150
|
-
ie && ie(
|
|
4151
|
-
}, [
|
|
4152
|
-
let [
|
|
4209
|
+
ie && ie(U);
|
|
4210
|
+
}, [U, ie]);
|
|
4211
|
+
let [hn, gn] = c([]);
|
|
4153
4212
|
i(() => {
|
|
4154
4213
|
if (M && x && x.length > 0) {
|
|
4155
4214
|
let e = !1;
|
|
4156
|
-
return
|
|
4157
|
-
e ||
|
|
4215
|
+
return wt(M, x).then((t) => {
|
|
4216
|
+
e || gn(t);
|
|
4158
4217
|
}), () => {
|
|
4159
4218
|
e = !0;
|
|
4160
4219
|
};
|
|
4161
4220
|
}
|
|
4162
|
-
|
|
4221
|
+
gn([]);
|
|
4163
4222
|
}, [M, x]);
|
|
4164
|
-
let [
|
|
4223
|
+
let [_n, vn] = c(!1), yn = o(() => [
|
|
4165
4224
|
...v || [],
|
|
4166
|
-
...
|
|
4225
|
+
...hn,
|
|
4167
4226
|
...Te
|
|
4168
4227
|
], [
|
|
4169
4228
|
v,
|
|
4170
|
-
|
|
4229
|
+
hn,
|
|
4171
4230
|
Te
|
|
4172
4231
|
]);
|
|
4173
4232
|
i(() => {
|
|
4174
|
-
ze.current.onRedactionsChange?.(
|
|
4175
|
-
}, [
|
|
4176
|
-
let
|
|
4177
|
-
Ee((e) => e.filter((e) => e.status === "applied")),
|
|
4178
|
-
}, []),
|
|
4179
|
-
Ee((t) => t.filter((t) => t !== e && t.id !== e.id)),
|
|
4180
|
-
}, []), { search:
|
|
4233
|
+
ze.current.onRedactionsChange?.(yn);
|
|
4234
|
+
}, [yn]);
|
|
4235
|
+
let $ = o(() => yn.filter((e) => e.status === "pending").length, [yn]), bn = n(() => {
|
|
4236
|
+
Ee((e) => e.filter((e) => e.status === "applied")), gn((e) => e.filter((e) => e.status === "applied"));
|
|
4237
|
+
}, []), xn = n((e) => {
|
|
4238
|
+
Ee((t) => t.filter((t) => t !== e && t.id !== e.id)), gn((t) => t.filter((t) => t !== e && t.id !== e.id));
|
|
4239
|
+
}, []), { search: Sn, searchResults: Cn, isSearching: wn, searchProgress: Tn } = nt(M, yn);
|
|
4181
4240
|
i(() => {
|
|
4182
|
-
|
|
4183
|
-
}, [
|
|
4184
|
-
let
|
|
4241
|
+
Cn.length === 0 && Ge(null);
|
|
4242
|
+
}, [Cn]);
|
|
4243
|
+
let En = s(!1);
|
|
4185
4244
|
i(() => {
|
|
4186
|
-
if (xe(null), Ce(null), we(1), qe([]),
|
|
4245
|
+
if (xe(null), Ce(null), we(1), qe([]), En.current = !1, !d) return;
|
|
4187
4246
|
let e = d, t = !1, n = null;
|
|
4188
4247
|
return (async () => {
|
|
4189
4248
|
try {
|
|
4190
|
-
Be.current &&
|
|
4249
|
+
Be.current && Ot(Be.current), At(), n = L.getDocument({
|
|
4191
4250
|
url: e,
|
|
4192
4251
|
withCredentials: h,
|
|
4193
|
-
...
|
|
4252
|
+
...jt()
|
|
4194
4253
|
});
|
|
4195
4254
|
let r = await n.promise;
|
|
4196
4255
|
if (t) return;
|
|
4256
|
+
try {
|
|
4257
|
+
let e = await r.getPage(1);
|
|
4258
|
+
if (!t) {
|
|
4259
|
+
let t = e.getViewport({
|
|
4260
|
+
scale: 1,
|
|
4261
|
+
rotation: lt(e.rotate + A)
|
|
4262
|
+
});
|
|
4263
|
+
qe(Et(r.numPages, {
|
|
4264
|
+
width: t.width,
|
|
4265
|
+
height: t.height
|
|
4266
|
+
}));
|
|
4267
|
+
}
|
|
4268
|
+
} catch {}
|
|
4269
|
+
if (t) return;
|
|
4197
4270
|
xe(r), ze.current.onDocumentLoaded?.(r, e);
|
|
4198
4271
|
} catch (n) {
|
|
4199
4272
|
if (t) return;
|
|
@@ -4209,155 +4282,183 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4209
4282
|
}, [
|
|
4210
4283
|
d,
|
|
4211
4284
|
p,
|
|
4212
|
-
h
|
|
4285
|
+
h,
|
|
4286
|
+
A
|
|
4213
4287
|
]);
|
|
4214
|
-
let
|
|
4215
|
-
|
|
4288
|
+
let Dn = n((e) => {
|
|
4289
|
+
En.current || (En.current = !0, ze.current.onFirstPageRendered?.(e));
|
|
4216
4290
|
}, []);
|
|
4217
4291
|
i(() => {
|
|
4218
4292
|
M && ze.current.onPageChange?.(N, M.numPages);
|
|
4219
4293
|
}, [N, M]);
|
|
4220
|
-
let
|
|
4294
|
+
let On = s(null), kn = s(void 0);
|
|
4221
4295
|
i(() => {
|
|
4222
4296
|
let e = me ?? pe;
|
|
4223
|
-
if (!M || !e ||
|
|
4224
|
-
let t =
|
|
4225
|
-
|
|
4226
|
-
let n = setTimeout(() =>
|
|
4297
|
+
if (!M || !e || On.current === M && kn.current === e || Ke.length < Math.min(e, M.numPages)) return;
|
|
4298
|
+
let t = On.current !== M;
|
|
4299
|
+
On.current = M, kn.current = e;
|
|
4300
|
+
let n = setTimeout(() => _t(e, { smooth: !t }), 50);
|
|
4227
4301
|
return () => clearTimeout(n);
|
|
4228
4302
|
}, [
|
|
4229
4303
|
M,
|
|
4230
4304
|
me,
|
|
4231
4305
|
pe,
|
|
4232
4306
|
Ke.length,
|
|
4233
|
-
|
|
4307
|
+
_t
|
|
4234
4308
|
]), i(() => {
|
|
4235
4309
|
if (!M) return;
|
|
4236
4310
|
let e = !1, t = M;
|
|
4237
4311
|
return (async () => {
|
|
4238
|
-
let n
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4312
|
+
let n;
|
|
4313
|
+
try {
|
|
4314
|
+
n = await t.getPage(1);
|
|
4315
|
+
} catch {
|
|
4316
|
+
return;
|
|
4317
|
+
}
|
|
4318
|
+
if (e) return;
|
|
4319
|
+
let r = n.getViewport({
|
|
4320
|
+
scale: 1,
|
|
4321
|
+
rotation: lt(n.rotate + A)
|
|
4322
|
+
}), i = {
|
|
4323
|
+
width: r.width,
|
|
4324
|
+
height: r.height
|
|
4325
|
+
};
|
|
4326
|
+
if (qe((e) => e.length === t.numPages && Math.abs((e[0]?.width ?? 0) - i.width) <= .5 && Math.abs((e[0]?.height ?? 0) - i.height) <= .5 ? e : Et(t.numPages, i)), t.numPages <= 1) return;
|
|
4327
|
+
let a = Et(t.numPages, i), o = !1;
|
|
4328
|
+
for (let n = 2; n <= t.numPages; n += 25) {
|
|
4246
4329
|
if (e) return;
|
|
4247
|
-
let
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4330
|
+
let r = Math.min(t.numPages, n + 25 - 1), s = [];
|
|
4331
|
+
for (let c = n; c <= r; c++) {
|
|
4332
|
+
let n = c;
|
|
4333
|
+
s.push((async () => {
|
|
4334
|
+
try {
|
|
4335
|
+
let r = await t.getPage(n);
|
|
4336
|
+
if (e) return;
|
|
4337
|
+
let s = r.getViewport({
|
|
4338
|
+
scale: 1,
|
|
4339
|
+
rotation: lt(r.rotate + A)
|
|
4340
|
+
});
|
|
4341
|
+
(Math.abs(s.width - i.width) > .5 || Math.abs(s.height - i.height) > .5) && (o = !0), a[n - 1] = {
|
|
4342
|
+
width: s.width,
|
|
4343
|
+
height: s.height
|
|
4344
|
+
};
|
|
4345
|
+
} catch {}
|
|
4346
|
+
})());
|
|
4347
|
+
}
|
|
4348
|
+
await Promise.all(s);
|
|
4349
|
+
}
|
|
4350
|
+
if (!e && o) {
|
|
4351
|
+
let e = j.current;
|
|
4352
|
+
if (e && e.scrollTop > 0 && pt.current === "continuous") {
|
|
4353
|
+
let t = mt.current, n = Dt(ut.current, (e) => a[e - 1] ?? i, dt.current, 16), r = ft.current.tops[t] ?? 0, o = (n.tops[t] ?? 0) - r;
|
|
4354
|
+
o !== 0 && (e.scrollTop += o);
|
|
4355
|
+
}
|
|
4356
|
+
qe(a);
|
|
4255
4357
|
}
|
|
4256
|
-
e || qe(n);
|
|
4257
4358
|
})(), () => {
|
|
4258
4359
|
e = !0;
|
|
4259
4360
|
};
|
|
4260
4361
|
}, [M, A]);
|
|
4261
|
-
let
|
|
4362
|
+
let An = n(() => {
|
|
4262
4363
|
let e = Ye(N);
|
|
4263
4364
|
if (!j.current || !e.width) return;
|
|
4264
4365
|
let t = j.current.clientWidth - 48;
|
|
4265
4366
|
if (t > 0 && e.width > 0) {
|
|
4266
|
-
let n = t / e.width;
|
|
4267
|
-
|
|
4367
|
+
let n = vt(t / e.width);
|
|
4368
|
+
dn.current = !0, j.current && (N === 1 || j.current.scrollTop <= 1) && (j.current.scrollTop = 0, j.current.scrollLeft = 0), C(n);
|
|
4268
4369
|
}
|
|
4269
4370
|
}, [
|
|
4270
4371
|
Ye,
|
|
4271
4372
|
N,
|
|
4272
4373
|
C
|
|
4273
|
-
]),
|
|
4374
|
+
]), jn = n(() => {
|
|
4274
4375
|
let e = Ye(N);
|
|
4275
4376
|
if (!j.current || !e.width || !e.height) return;
|
|
4276
4377
|
let t = j.current.clientWidth - 48, n = j.current.clientHeight - 48;
|
|
4277
4378
|
if (t > 0 && n > 0 && e.width > 0 && e.height > 0) {
|
|
4278
|
-
let r = t / e.width, i = n / e.height;
|
|
4279
|
-
|
|
4379
|
+
let r = t / e.width, i = n / e.height, a = vt(Math.min(r, i));
|
|
4380
|
+
dn.current = !0, j.current && (N === 1 || j.current.scrollTop <= 1) && (j.current.scrollTop = 0, j.current.scrollLeft = 0), C(a);
|
|
4280
4381
|
}
|
|
4281
4382
|
}, [
|
|
4282
4383
|
Ye,
|
|
4283
4384
|
N,
|
|
4284
4385
|
C
|
|
4285
4386
|
]);
|
|
4286
|
-
Re("action-fit-to-width", () =>
|
|
4287
|
-
let
|
|
4387
|
+
Re("action-fit-to-width", () => An()), Re("action-fit-to-page", () => jn());
|
|
4388
|
+
let Mn = (e, t) => {
|
|
4288
4389
|
let n = e.currentTarget.getBoundingClientRect(), r = (e.clientX - n.left) / S, i = (e.clientY - n.top) / S, a = Ye(t);
|
|
4289
4390
|
return ot(r, i, A, A % 180 == 0 ? a.width : a.height, A % 180 == 0 ? a.height : a.width);
|
|
4290
|
-
},
|
|
4291
|
-
if (!
|
|
4292
|
-
let { x: n, y: r } =
|
|
4293
|
-
if (
|
|
4391
|
+
}, Nn = (e, t) => {
|
|
4392
|
+
if (!W) return;
|
|
4393
|
+
let { x: n, y: r } = Mn(e, t);
|
|
4394
|
+
if (W === "text" || W === "note") {
|
|
4294
4395
|
e.preventDefault();
|
|
4295
4396
|
return;
|
|
4296
4397
|
}
|
|
4297
|
-
if (
|
|
4298
|
-
|
|
4398
|
+
if (W === "eraser") {
|
|
4399
|
+
Gt(!0);
|
|
4299
4400
|
return;
|
|
4300
4401
|
}
|
|
4301
|
-
|
|
4402
|
+
Yt({
|
|
4302
4403
|
x: n,
|
|
4303
4404
|
y: r
|
|
4304
|
-
}),
|
|
4405
|
+
}), Xt({
|
|
4305
4406
|
x: n,
|
|
4306
4407
|
y: r
|
|
4307
|
-
}),
|
|
4408
|
+
}), W === "freehand" ? (Gt(!0), Qt([{
|
|
4308
4409
|
x: n,
|
|
4309
4410
|
y: r
|
|
4310
|
-
}]),
|
|
4411
|
+
}]), Jt(t)) : ([
|
|
4311
4412
|
"rectangle",
|
|
4312
4413
|
"ellipse",
|
|
4313
4414
|
"line",
|
|
4314
4415
|
"arrow",
|
|
4315
4416
|
"highlight",
|
|
4316
4417
|
"redaction"
|
|
4317
|
-
].includes(
|
|
4318
|
-
},
|
|
4319
|
-
if (J &&
|
|
4320
|
-
if (J.annId) Q(
|
|
4418
|
+
].includes(W) || ["callout", "link"].includes(W)) && (Gt(!0), Jt(t));
|
|
4419
|
+
}, Pn = () => {
|
|
4420
|
+
if (J && en.trim()) {
|
|
4421
|
+
if (J.annId) Q(U.map((e) => e.id === J.annId ? {
|
|
4321
4422
|
...e,
|
|
4322
|
-
text:
|
|
4423
|
+
text: en
|
|
4323
4424
|
} : e));
|
|
4324
4425
|
else {
|
|
4325
|
-
let e =
|
|
4326
|
-
Q([...
|
|
4426
|
+
let e = Ct();
|
|
4427
|
+
Q([...U, {
|
|
4327
4428
|
id: e,
|
|
4328
4429
|
type: J.type,
|
|
4329
4430
|
pageIndex: J.pageIndex,
|
|
4330
4431
|
x: J.x,
|
|
4331
4432
|
y: J.y,
|
|
4332
|
-
width: Math.max(100,
|
|
4433
|
+
width: Math.max(100, en.length * 8 + 20),
|
|
4333
4434
|
height: 30,
|
|
4334
|
-
text:
|
|
4435
|
+
text: en,
|
|
4335
4436
|
points: J.points,
|
|
4336
|
-
color:
|
|
4337
|
-
strokeWidth:
|
|
4338
|
-
opacity:
|
|
4437
|
+
color: kt,
|
|
4438
|
+
strokeWidth: Rt,
|
|
4439
|
+
opacity: Vt
|
|
4339
4440
|
}]);
|
|
4340
4441
|
}
|
|
4341
4442
|
}
|
|
4342
|
-
|
|
4343
|
-
},
|
|
4344
|
-
if (!
|
|
4345
|
-
let { x: n, y: r } =
|
|
4346
|
-
|
|
4443
|
+
$t(null), tn(""), W === "text" && G(null);
|
|
4444
|
+
}, Fn = (e, t) => {
|
|
4445
|
+
if (!Wt) return;
|
|
4446
|
+
let { x: n, y: r } = Mn(e, t);
|
|
4447
|
+
Xt({
|
|
4347
4448
|
x: n,
|
|
4348
4449
|
y: r
|
|
4349
|
-
}),
|
|
4450
|
+
}), W === "freehand" && Qt((e) => [...e, {
|
|
4350
4451
|
x: n,
|
|
4351
4452
|
y: r
|
|
4352
4453
|
}]);
|
|
4353
|
-
},
|
|
4354
|
-
if (
|
|
4355
|
-
let { x: n, y: r } =
|
|
4356
|
-
if (
|
|
4454
|
+
}, In = (e, t) => {
|
|
4455
|
+
if (W === "text" || W === "note" || W === "digital_signature" || W === "link") {
|
|
4456
|
+
let { x: n, y: r } = Mn(e, t);
|
|
4457
|
+
if (W === "link") {
|
|
4357
4458
|
let e = Math.abs(q.x - K.x), i = Math.abs(q.y - K.y), a = Math.min(K.x, q.x), o = Math.min(K.y, q.y);
|
|
4358
4459
|
(e < 5 || i < 5) && (a = n, o = r, e = 120, i = 35);
|
|
4359
|
-
let s =
|
|
4360
|
-
Q([...
|
|
4460
|
+
let s = Ct();
|
|
4461
|
+
Q([...U, {
|
|
4361
4462
|
id: s,
|
|
4362
4463
|
type: "link",
|
|
4363
4464
|
pageIndex: t,
|
|
@@ -4370,53 +4471,53 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4370
4471
|
strokeWidth: 0,
|
|
4371
4472
|
opacity: 1,
|
|
4372
4473
|
text: ""
|
|
4373
|
-
}]),
|
|
4474
|
+
}]), Gt(!1), Jt(null), Z.current = !0, X(s), sn(!0), G(null);
|
|
4374
4475
|
return;
|
|
4375
4476
|
}
|
|
4376
|
-
(
|
|
4477
|
+
(W === "text" || W === "note") && (J && Pn(), $t({
|
|
4377
4478
|
x: n,
|
|
4378
4479
|
y: r,
|
|
4379
|
-
type:
|
|
4480
|
+
type: W,
|
|
4380
4481
|
pageIndex: t
|
|
4381
|
-
}),
|
|
4482
|
+
}), tn(""));
|
|
4382
4483
|
return;
|
|
4383
4484
|
}
|
|
4384
|
-
if (
|
|
4385
|
-
if (
|
|
4386
|
-
if (
|
|
4387
|
-
let e =
|
|
4388
|
-
Q([...
|
|
4389
|
-
id:
|
|
4390
|
-
type:
|
|
4485
|
+
if (Wt && (Gt(!1), Jt(null), W)) {
|
|
4486
|
+
if (W === "freehand") {
|
|
4487
|
+
if (Zt.length > 2) {
|
|
4488
|
+
let e = Zt.map((e) => e.x), n = Zt.map((e) => e.y), r = Math.min(...e), i = Math.max(...e), a = Math.min(...n), o = Math.max(...n);
|
|
4489
|
+
Q([...U, {
|
|
4490
|
+
id: Ct(),
|
|
4491
|
+
type: W,
|
|
4391
4492
|
pageIndex: t,
|
|
4392
4493
|
x: r,
|
|
4393
4494
|
y: a,
|
|
4394
4495
|
width: i - r,
|
|
4395
4496
|
height: o - a,
|
|
4396
|
-
points: [...
|
|
4397
|
-
strokes: [[...
|
|
4398
|
-
color:
|
|
4399
|
-
strokeWidth:
|
|
4400
|
-
opacity:
|
|
4497
|
+
points: [...Zt],
|
|
4498
|
+
strokes: [[...Zt]],
|
|
4499
|
+
color: kt,
|
|
4500
|
+
strokeWidth: Rt,
|
|
4501
|
+
opacity: Vt
|
|
4401
4502
|
}]);
|
|
4402
4503
|
}
|
|
4403
|
-
|
|
4504
|
+
Qt([]);
|
|
4404
4505
|
} else {
|
|
4405
4506
|
let e = Math.abs(q.x - K.x), n = Math.abs(q.y - K.y);
|
|
4406
4507
|
if (e > 5 || n > 5) {
|
|
4407
|
-
let r = Math.min(K.x, q.x), i = Math.min(K.y, q.y), a =
|
|
4408
|
-
if ((
|
|
4508
|
+
let r = Math.min(K.x, q.x), i = Math.min(K.y, q.y), a = W === "line" || W === "arrow" || W === "callout" ? [K, q] : void 0;
|
|
4509
|
+
if ((W === "highlight" || W === "redaction") && n < 18 && (n = Math.max(18, n), i = K.y - 9), W === "callout") {
|
|
4409
4510
|
if (ve?.canAddAnnotations === !1) return;
|
|
4410
|
-
|
|
4511
|
+
$t({
|
|
4411
4512
|
x: q.x,
|
|
4412
4513
|
y: q.y,
|
|
4413
4514
|
type: "callout",
|
|
4414
4515
|
points: a,
|
|
4415
4516
|
pageIndex: t
|
|
4416
|
-
}),
|
|
4517
|
+
}), tn("");
|
|
4417
4518
|
return;
|
|
4418
4519
|
}
|
|
4419
|
-
if (
|
|
4520
|
+
if (W === "redaction") {
|
|
4420
4521
|
if (ve?.canRedact === !1) return;
|
|
4421
4522
|
Ee((a) => [...a, {
|
|
4422
4523
|
id: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`,
|
|
@@ -4430,34 +4531,34 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4430
4531
|
return;
|
|
4431
4532
|
}
|
|
4432
4533
|
if (ve?.canAddAnnotations === !1) return;
|
|
4433
|
-
Q([...
|
|
4434
|
-
id:
|
|
4435
|
-
type:
|
|
4534
|
+
Q([...U, {
|
|
4535
|
+
id: Ct(),
|
|
4536
|
+
type: W,
|
|
4436
4537
|
pageIndex: t,
|
|
4437
4538
|
x: r,
|
|
4438
4539
|
y: i,
|
|
4439
4540
|
width: e,
|
|
4440
4541
|
height: n,
|
|
4441
4542
|
points: a,
|
|
4442
|
-
color:
|
|
4443
|
-
strokeWidth:
|
|
4444
|
-
opacity:
|
|
4543
|
+
color: kt,
|
|
4544
|
+
strokeWidth: Rt,
|
|
4545
|
+
opacity: Vt
|
|
4445
4546
|
}]);
|
|
4446
4547
|
}
|
|
4447
4548
|
}
|
|
4448
4549
|
}
|
|
4449
|
-
},
|
|
4450
|
-
|
|
4451
|
-
},
|
|
4452
|
-
if (t.stopPropagation(),
|
|
4550
|
+
}, Ln = (e) => {
|
|
4551
|
+
W === "eraser" && Wt && Q(U.filter((t) => t.id !== e));
|
|
4552
|
+
}, Rn = (e, t) => {
|
|
4553
|
+
if (t.stopPropagation(), W === "eraser") {
|
|
4453
4554
|
if (ve?.canDeleteAnnotations === !1) return;
|
|
4454
|
-
Q(
|
|
4455
|
-
} else if (
|
|
4456
|
-
let n =
|
|
4555
|
+
Q(U.filter((t) => t.id !== e)), Y === e && (X(null), an(null));
|
|
4556
|
+
} else if (W === null || W === "pan") {
|
|
4557
|
+
let n = U.find((t) => t.id === e);
|
|
4457
4558
|
if (n && n.linkUrl && a === "View") {
|
|
4458
4559
|
if (n.linkUrl.startsWith("#page=")) {
|
|
4459
4560
|
let e = parseInt(n.linkUrl.split("=")[1]);
|
|
4460
|
-
|
|
4561
|
+
_t(e);
|
|
4461
4562
|
} else {
|
|
4462
4563
|
let e = n.linkUrl;
|
|
4463
4564
|
/^https?:\/\//i.test(e) || (e = "https://" + e);
|
|
@@ -4471,32 +4572,32 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4471
4572
|
X(e);
|
|
4472
4573
|
return;
|
|
4473
4574
|
}
|
|
4474
|
-
|
|
4575
|
+
$t({
|
|
4475
4576
|
x: n.x,
|
|
4476
4577
|
y: n.y,
|
|
4477
4578
|
type: n.type,
|
|
4478
4579
|
annId: n.id,
|
|
4479
4580
|
points: n.points,
|
|
4480
4581
|
pageIndex: n.pageIndex
|
|
4481
|
-
}),
|
|
4582
|
+
}), tn(n.text || ""), n.color && Mt(n.color);
|
|
4482
4583
|
} else if (n && n.type === "link") {
|
|
4483
4584
|
if (ve?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
4484
4585
|
X(e);
|
|
4485
4586
|
return;
|
|
4486
4587
|
}
|
|
4487
|
-
|
|
4588
|
+
sn(!0);
|
|
4488
4589
|
}
|
|
4489
4590
|
X(e);
|
|
4490
4591
|
let r = j.current, i = r?.getBoundingClientRect();
|
|
4491
|
-
i && r &&
|
|
4592
|
+
i && r && an({
|
|
4492
4593
|
top: t.clientY - i.top + r.scrollTop,
|
|
4493
4594
|
left: t.clientX - i.left + r.scrollLeft
|
|
4494
4595
|
});
|
|
4495
4596
|
}
|
|
4496
|
-
}
|
|
4597
|
+
};
|
|
4497
4598
|
return i(() => {
|
|
4498
4599
|
if (M && j.current && O === "continuous") {
|
|
4499
|
-
let e = Xe.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(
|
|
4600
|
+
let e = Xe.top + j.current.clientHeight / 2, t = Math.max(0, Math.min(H.length - 1, gt(e))), n = H[t] ? H[t][0] : 1;
|
|
4500
4601
|
n !== N && we(n);
|
|
4501
4602
|
}
|
|
4502
4603
|
}, [
|
|
@@ -4504,9 +4605,9 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4504
4605
|
S,
|
|
4505
4606
|
M,
|
|
4506
4607
|
N,
|
|
4507
|
-
|
|
4608
|
+
gt,
|
|
4508
4609
|
O,
|
|
4509
|
-
|
|
4610
|
+
H
|
|
4510
4611
|
]), /* @__PURE__ */ I("div", {
|
|
4511
4612
|
style: {
|
|
4512
4613
|
flex: 1,
|
|
@@ -4520,7 +4621,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4520
4621
|
isOpen: t,
|
|
4521
4622
|
pdfDoc: M,
|
|
4522
4623
|
pageNum: N,
|
|
4523
|
-
setPageNum: (e) =>
|
|
4624
|
+
setPageNum: (e) => _t(e)
|
|
4524
4625
|
}),
|
|
4525
4626
|
/* @__PURE__ */ I("div", {
|
|
4526
4627
|
style: {
|
|
@@ -4533,7 +4634,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4533
4634
|
overflow: "hidden"
|
|
4534
4635
|
},
|
|
4535
4636
|
children: [
|
|
4536
|
-
R.isActive && /* @__PURE__ */ F(
|
|
4637
|
+
R.isActive && /* @__PURE__ */ F(Ft, {
|
|
4537
4638
|
compareState: R,
|
|
4538
4639
|
onSetMode: (e) => z((t) => ({
|
|
4539
4640
|
...t,
|
|
@@ -4551,12 +4652,12 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4551
4652
|
onPrevDiff: () => {
|
|
4552
4653
|
if (R.diffItems.length === 0) return;
|
|
4553
4654
|
let e = (R.currentDiffIndex - 1 + R.diffItems.length) % R.diffItems.length;
|
|
4554
|
-
|
|
4655
|
+
xt(e);
|
|
4555
4656
|
},
|
|
4556
4657
|
onNextDiff: () => {
|
|
4557
4658
|
if (R.diffItems.length === 0) return;
|
|
4558
4659
|
let e = (R.currentDiffIndex + 1) % R.diffItems.length;
|
|
4559
|
-
|
|
4660
|
+
xt(e);
|
|
4560
4661
|
},
|
|
4561
4662
|
onExit: () => {
|
|
4562
4663
|
z((e) => ({
|
|
@@ -4576,35 +4677,35 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4576
4677
|
height: "40px"
|
|
4577
4678
|
},
|
|
4578
4679
|
children: [
|
|
4579
|
-
/* @__PURE__ */ F(
|
|
4680
|
+
/* @__PURE__ */ F(qt, {
|
|
4580
4681
|
icon: /* @__PURE__ */ F(k, { size: 16 }),
|
|
4581
|
-
active:
|
|
4682
|
+
active: W === "highlight",
|
|
4582
4683
|
onClick: () => {
|
|
4583
|
-
|
|
4684
|
+
G("highlight"), Mt("#fbc02d"), Ut(.5), Bt(16);
|
|
4584
4685
|
},
|
|
4585
4686
|
label: "Text Highlight"
|
|
4586
4687
|
}),
|
|
4587
|
-
/* @__PURE__ */ F(
|
|
4688
|
+
/* @__PURE__ */ F(qt, {
|
|
4588
4689
|
icon: /* @__PURE__ */ F(m, { size: 16 }),
|
|
4589
|
-
active:
|
|
4690
|
+
active: W === "freehand",
|
|
4590
4691
|
onClick: () => {
|
|
4591
|
-
|
|
4692
|
+
G("freehand"), Mt("#000000"), Ut(1), Bt(2);
|
|
4592
4693
|
},
|
|
4593
4694
|
label: "Marker"
|
|
4594
4695
|
}),
|
|
4595
|
-
/* @__PURE__ */ F(
|
|
4696
|
+
/* @__PURE__ */ F(qt, {
|
|
4596
4697
|
icon: /* @__PURE__ */ F(Me, { size: 16 }),
|
|
4597
|
-
active:
|
|
4698
|
+
active: W === "text",
|
|
4598
4699
|
onClick: () => {
|
|
4599
|
-
|
|
4700
|
+
G("text"), Mt("#000000"), Ut(1);
|
|
4600
4701
|
},
|
|
4601
4702
|
label: "Text"
|
|
4602
4703
|
}),
|
|
4603
|
-
ve?.canRedact !== !1 && /* @__PURE__ */ F(
|
|
4704
|
+
ve?.canRedact !== !1 && /* @__PURE__ */ F(qt, {
|
|
4604
4705
|
icon: /* @__PURE__ */ F(w, { size: 16 }),
|
|
4605
|
-
active:
|
|
4706
|
+
active: W === "redaction",
|
|
4606
4707
|
onClick: () => {
|
|
4607
|
-
|
|
4708
|
+
G("redaction"), Mt("#000000"), Ut(1);
|
|
4608
4709
|
},
|
|
4609
4710
|
label: "Redact"
|
|
4610
4711
|
}),
|
|
@@ -4621,11 +4722,11 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4621
4722
|
borderRight: "1px solid var(--border-color)",
|
|
4622
4723
|
paddingRight: "8px"
|
|
4623
4724
|
},
|
|
4624
|
-
children: /* @__PURE__ */ F(
|
|
4725
|
+
children: /* @__PURE__ */ F(qt, {
|
|
4625
4726
|
icon: /* @__PURE__ */ F(he, { size: 16 }),
|
|
4626
|
-
active:
|
|
4727
|
+
active: W === "callout",
|
|
4627
4728
|
onClick: () => {
|
|
4628
|
-
|
|
4729
|
+
G("callout"), Ut(1), Bt(2);
|
|
4629
4730
|
},
|
|
4630
4731
|
label: "Callout"
|
|
4631
4732
|
})
|
|
@@ -4635,17 +4736,17 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4635
4736
|
display: "flex",
|
|
4636
4737
|
gap: "4px"
|
|
4637
4738
|
},
|
|
4638
|
-
children: [/* @__PURE__ */ F(
|
|
4739
|
+
children: [/* @__PURE__ */ F(qt, {
|
|
4639
4740
|
icon: /* @__PURE__ */ F(be, { size: 16 }),
|
|
4640
|
-
active:
|
|
4741
|
+
active: W === "freehand" && Vt === 1,
|
|
4641
4742
|
onClick: () => {
|
|
4642
|
-
|
|
4743
|
+
G("freehand"), Ut(1), Bt(2);
|
|
4643
4744
|
},
|
|
4644
4745
|
label: "Freehand"
|
|
4645
|
-
}), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(
|
|
4746
|
+
}), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(qt, {
|
|
4646
4747
|
icon: /* @__PURE__ */ F(re, { size: 16 }),
|
|
4647
|
-
active:
|
|
4648
|
-
onClick: () =>
|
|
4748
|
+
active: W === "eraser",
|
|
4749
|
+
onClick: () => G("eraser"),
|
|
4649
4750
|
label: "Eraser"
|
|
4650
4751
|
})]
|
|
4651
4752
|
}),
|
|
@@ -4661,34 +4762,34 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4661
4762
|
gap: "4px"
|
|
4662
4763
|
},
|
|
4663
4764
|
children: [
|
|
4664
|
-
/* @__PURE__ */ F(
|
|
4765
|
+
/* @__PURE__ */ F(qt, {
|
|
4665
4766
|
icon: /* @__PURE__ */ F(ge, { size: 16 }),
|
|
4666
|
-
active:
|
|
4667
|
-
onClick: () =>
|
|
4767
|
+
active: W === "line",
|
|
4768
|
+
onClick: () => G("line"),
|
|
4668
4769
|
label: "Line"
|
|
4669
4770
|
}),
|
|
4670
|
-
/* @__PURE__ */ F(
|
|
4771
|
+
/* @__PURE__ */ F(qt, {
|
|
4671
4772
|
icon: /* @__PURE__ */ F(f, { size: 16 }),
|
|
4672
|
-
active:
|
|
4673
|
-
onClick: () =>
|
|
4773
|
+
active: W === "arrow",
|
|
4774
|
+
onClick: () => G("arrow"),
|
|
4674
4775
|
label: "Arrow"
|
|
4675
4776
|
}),
|
|
4676
|
-
/* @__PURE__ */ F(
|
|
4777
|
+
/* @__PURE__ */ F(qt, {
|
|
4677
4778
|
icon: /* @__PURE__ */ F(Ae, { size: 16 }),
|
|
4678
|
-
active:
|
|
4679
|
-
onClick: () =>
|
|
4779
|
+
active: W === "rectangle",
|
|
4780
|
+
onClick: () => G("rectangle"),
|
|
4680
4781
|
label: "Rectangle"
|
|
4681
4782
|
}),
|
|
4682
|
-
/* @__PURE__ */ F(
|
|
4783
|
+
/* @__PURE__ */ F(qt, {
|
|
4683
4784
|
icon: /* @__PURE__ */ F(ee, { size: 16 }),
|
|
4684
|
-
active:
|
|
4685
|
-
onClick: () =>
|
|
4785
|
+
active: W === "ellipse",
|
|
4786
|
+
onClick: () => G("ellipse"),
|
|
4686
4787
|
label: "Ellipse"
|
|
4687
4788
|
}),
|
|
4688
|
-
/* @__PURE__ */ F(
|
|
4789
|
+
/* @__PURE__ */ F(qt, {
|
|
4689
4790
|
icon: /* @__PURE__ */ F(ce, { size: 16 }),
|
|
4690
|
-
active:
|
|
4691
|
-
onClick: () =>
|
|
4791
|
+
active: W === "link",
|
|
4792
|
+
onClick: () => G("link"),
|
|
4692
4793
|
label: "Link"
|
|
4693
4794
|
})
|
|
4694
4795
|
]
|
|
@@ -4708,7 +4809,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4708
4809
|
"ellipse",
|
|
4709
4810
|
"freehand",
|
|
4710
4811
|
"highlight"
|
|
4711
|
-
].includes(
|
|
4812
|
+
].includes(W || "") && /* @__PURE__ */ I("div", {
|
|
4712
4813
|
style: {
|
|
4713
4814
|
display: "flex",
|
|
4714
4815
|
alignItems: "center",
|
|
@@ -4722,16 +4823,16 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4722
4823
|
color: "#666",
|
|
4723
4824
|
minWidth: "85px"
|
|
4724
4825
|
},
|
|
4725
|
-
children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [
|
|
4826
|
+
children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [Rt, "px"] })]
|
|
4726
4827
|
}), /* @__PURE__ */ F("input", {
|
|
4727
4828
|
type: "range",
|
|
4728
4829
|
min: "1",
|
|
4729
4830
|
max: "24",
|
|
4730
|
-
value: Math.min(24, Math.max(1,
|
|
4831
|
+
value: Math.min(24, Math.max(1, Rt)),
|
|
4731
4832
|
onMouseDown: (e) => e.stopPropagation(),
|
|
4732
4833
|
onChange: (e) => {
|
|
4733
4834
|
let t = parseInt(e.target.value, 10);
|
|
4734
|
-
|
|
4835
|
+
Bt(t), Y && !J && Q(U.map((e) => e.id === Y ? {
|
|
4735
4836
|
...e,
|
|
4736
4837
|
strokeWidth: t
|
|
4737
4838
|
} : e));
|
|
@@ -4758,7 +4859,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4758
4859
|
].map((e) => /* @__PURE__ */ F("button", {
|
|
4759
4860
|
onMouseDown: (e) => e.preventDefault(),
|
|
4760
4861
|
onClick: () => {
|
|
4761
|
-
|
|
4862
|
+
Mt(e), Y && !J && Q(U.map((t) => t.id === Y ? {
|
|
4762
4863
|
...t,
|
|
4763
4864
|
color: e
|
|
4764
4865
|
} : t));
|
|
@@ -4768,14 +4869,14 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4768
4869
|
height: "18px",
|
|
4769
4870
|
borderRadius: "50%",
|
|
4770
4871
|
backgroundColor: e,
|
|
4771
|
-
border:
|
|
4872
|
+
border: kt === e ? "2px solid #000" : "1px solid transparent",
|
|
4772
4873
|
cursor: "pointer",
|
|
4773
4874
|
outline: "none",
|
|
4774
4875
|
padding: 0
|
|
4775
4876
|
}
|
|
4776
4877
|
}, e))
|
|
4777
4878
|
}),
|
|
4778
|
-
|
|
4879
|
+
$ > 0 && /* @__PURE__ */ I("div", {
|
|
4779
4880
|
style: {
|
|
4780
4881
|
display: "flex",
|
|
4781
4882
|
alignItems: "center",
|
|
@@ -4783,7 +4884,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4783
4884
|
marginLeft: "8px"
|
|
4784
4885
|
},
|
|
4785
4886
|
children: [/* @__PURE__ */ I("button", {
|
|
4786
|
-
onClick: () =>
|
|
4887
|
+
onClick: () => vn(!0),
|
|
4787
4888
|
style: {
|
|
4788
4889
|
display: "flex",
|
|
4789
4890
|
alignItems: "center",
|
|
@@ -4802,11 +4903,11 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4802
4903
|
children: [
|
|
4803
4904
|
/* @__PURE__ */ F(Oe, { size: 16 }),
|
|
4804
4905
|
"Apply Redactions (",
|
|
4805
|
-
|
|
4906
|
+
$,
|
|
4806
4907
|
")"
|
|
4807
4908
|
]
|
|
4808
4909
|
}), /* @__PURE__ */ I("button", {
|
|
4809
|
-
onClick:
|
|
4910
|
+
onClick: bn,
|
|
4810
4911
|
style: {
|
|
4811
4912
|
display: "flex",
|
|
4812
4913
|
alignItems: "center",
|
|
@@ -4831,7 +4932,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4831
4932
|
})
|
|
4832
4933
|
]
|
|
4833
4934
|
}),
|
|
4834
|
-
|
|
4935
|
+
_n && /* @__PURE__ */ F("div", {
|
|
4835
4936
|
style: {
|
|
4836
4937
|
position: "fixed",
|
|
4837
4938
|
top: 0,
|
|
@@ -4899,7 +5000,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4899
5000
|
},
|
|
4900
5001
|
children: [
|
|
4901
5002
|
"You are about to permanently apply ",
|
|
4902
|
-
/* @__PURE__ */ I("strong", { children: [
|
|
5003
|
+
/* @__PURE__ */ I("strong", { children: [$, " redaction(s)"] }),
|
|
4903
5004
|
". Marked areas will be blacked out and underlying text will be permanently removed. This action cannot be undone."
|
|
4904
5005
|
]
|
|
4905
5006
|
}),
|
|
@@ -4911,7 +5012,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4911
5012
|
},
|
|
4912
5013
|
children: [
|
|
4913
5014
|
/* @__PURE__ */ F("button", {
|
|
4914
|
-
onClick: () =>
|
|
5015
|
+
onClick: () => vn(!1),
|
|
4915
5016
|
style: {
|
|
4916
5017
|
padding: "8px 14px",
|
|
4917
5018
|
borderRadius: "6px",
|
|
@@ -4926,7 +5027,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4926
5027
|
}),
|
|
4927
5028
|
/* @__PURE__ */ F("button", {
|
|
4928
5029
|
onClick: () => {
|
|
4929
|
-
|
|
5030
|
+
bn(), vn(!1);
|
|
4930
5031
|
},
|
|
4931
5032
|
style: {
|
|
4932
5033
|
padding: "8px 14px",
|
|
@@ -4945,10 +5046,10 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4945
5046
|
Ee((e) => e.map((e) => ({
|
|
4946
5047
|
...e,
|
|
4947
5048
|
status: "applied"
|
|
4948
|
-
}))),
|
|
5049
|
+
}))), gn((e) => e.map((e) => ({
|
|
4949
5050
|
...e,
|
|
4950
5051
|
status: "applied"
|
|
4951
|
-
}))),
|
|
5052
|
+
}))), vn(!1);
|
|
4952
5053
|
},
|
|
4953
5054
|
style: {
|
|
4954
5055
|
padding: "8px 14px",
|
|
@@ -4979,7 +5080,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4979
5080
|
overflow: "hidden",
|
|
4980
5081
|
position: "relative"
|
|
4981
5082
|
},
|
|
4982
|
-
children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(
|
|
5083
|
+
children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(Pt, {
|
|
4983
5084
|
pdfDocA: M,
|
|
4984
5085
|
pdfDocB: ke,
|
|
4985
5086
|
pageNum: N,
|
|
@@ -4987,20 +5088,20 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
4987
5088
|
rotation: A,
|
|
4988
5089
|
basePageDims: Ye(N),
|
|
4989
5090
|
activeTab: a,
|
|
4990
|
-
activeTool:
|
|
4991
|
-
annotations:
|
|
5091
|
+
activeTool: W,
|
|
5092
|
+
annotations: U,
|
|
4992
5093
|
permissions: ve,
|
|
4993
5094
|
watermark: ue,
|
|
4994
5095
|
watermarkText: de,
|
|
4995
|
-
redactions:
|
|
5096
|
+
redactions: yn,
|
|
4996
5097
|
diffsA: R.pageDiffsA?.[N] || [],
|
|
4997
5098
|
diffsB: R.pageDiffsB?.[N] || [],
|
|
4998
5099
|
selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
|
|
4999
5100
|
onSelectDiff: (e) => {
|
|
5000
5101
|
let t = R.diffItems.findIndex((t) => t.id === e);
|
|
5001
|
-
t !== -1 &&
|
|
5102
|
+
t !== -1 && xt(t);
|
|
5002
5103
|
}
|
|
5003
|
-
}) : /* @__PURE__ */ I(Ne, { children: [
|
|
5104
|
+
}) : /* @__PURE__ */ I(Ne, { children: [W === "highlight" && /* @__PURE__ */ F("style", { children: "\n .pdf-viewer-area, .pdf-viewer-area * {\n cursor: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImJsYWNrIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggZD0iTTkgMTFsLTYgNnYzaDlsMy0zIi8+PHBhdGggZD0iTTIyIDEybC00LjYgNC42YTIgMiAwIDAgMS0yLjggMGwtNS4yLTUuMmEyIDIgMCAwIDEgMC0yLjhMMTQgNCIvPjwvc3ZnPg==') 0 24, auto !important;\n }\n " }), /* @__PURE__ */ I("div", {
|
|
5004
5105
|
className: "pdf-viewer-area",
|
|
5005
5106
|
style: {
|
|
5006
5107
|
flex: 1,
|
|
@@ -5011,7 +5112,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5011
5112
|
overflow: "hidden",
|
|
5012
5113
|
position: "relative",
|
|
5013
5114
|
backgroundColor: "var(--bg-color)",
|
|
5014
|
-
cursor: $e ? "grabbing" :
|
|
5115
|
+
cursor: $e ? "grabbing" : W === "pan" || W === null ? "grab" : W === "eraser" ? "cell" : "crosshair"
|
|
5015
5116
|
},
|
|
5016
5117
|
onMouseMove: (e) => {
|
|
5017
5118
|
if ($e && it.current && j.current) {
|
|
@@ -5029,10 +5130,10 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5029
5130
|
Ze({
|
|
5030
5131
|
top: e.currentTarget.scrollTop,
|
|
5031
5132
|
left: e.currentTarget.scrollLeft
|
|
5032
|
-
}),
|
|
5133
|
+
}), mt.current = gt(e.currentTarget.scrollTop);
|
|
5033
5134
|
},
|
|
5034
5135
|
onMouseDown: (e) => {
|
|
5035
|
-
(
|
|
5136
|
+
(W === "pan" || W === null) && e.button === 0 && (tt(!0), it.current = {
|
|
5036
5137
|
x: e.clientX,
|
|
5037
5138
|
y: e.clientY,
|
|
5038
5139
|
scrollLeft: e.currentTarget.scrollLeft,
|
|
@@ -5053,46 +5154,46 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5053
5154
|
},
|
|
5054
5155
|
children: (() => {
|
|
5055
5156
|
let t = (t, n, r) => {
|
|
5056
|
-
let i = r ?
|
|
5157
|
+
let i = r ? ct.tops[n] ?? 0 : 0;
|
|
5057
5158
|
if (r && j.current) {
|
|
5058
5159
|
let e = S >= 4 ? 1 : S >= 2 ? 2 : 4, t = S >= 4 ? 1 : S >= 2 ? 2 : 5;
|
|
5059
|
-
if (n <
|
|
5160
|
+
if (n < mt.current - e || n > mt.current + t) return null;
|
|
5060
5161
|
}
|
|
5061
|
-
let o =
|
|
5062
|
-
if (
|
|
5162
|
+
let o = Wt && Kt && W && W !== "eraser" ? (() => {
|
|
5163
|
+
if (W === "freehand") return {
|
|
5063
5164
|
id: "temp-live-drawing",
|
|
5064
5165
|
type: "freehand",
|
|
5065
|
-
pageIndex:
|
|
5166
|
+
pageIndex: Kt,
|
|
5066
5167
|
x: 0,
|
|
5067
5168
|
y: 0,
|
|
5068
5169
|
width: 0,
|
|
5069
5170
|
height: 0,
|
|
5070
|
-
points:
|
|
5071
|
-
color:
|
|
5072
|
-
strokeWidth:
|
|
5073
|
-
opacity:
|
|
5171
|
+
points: Zt,
|
|
5172
|
+
color: kt,
|
|
5173
|
+
strokeWidth: Rt,
|
|
5174
|
+
opacity: Vt
|
|
5074
5175
|
};
|
|
5075
|
-
if (
|
|
5176
|
+
if (W === "highlight") {
|
|
5076
5177
|
let e = Math.abs(q.x - K.x), t = Math.abs(q.y - K.y), n = Math.min(K.x, q.x), r = Math.min(K.y, q.y);
|
|
5077
5178
|
return t < 18 && (t = Math.max(18, t), r = K.y - 9), {
|
|
5078
5179
|
id: "temp-live-drawing",
|
|
5079
5180
|
type: "highlight",
|
|
5080
|
-
pageIndex:
|
|
5181
|
+
pageIndex: Kt,
|
|
5081
5182
|
x: n,
|
|
5082
5183
|
y: r,
|
|
5083
5184
|
width: e,
|
|
5084
5185
|
height: t,
|
|
5085
|
-
color:
|
|
5086
|
-
strokeWidth:
|
|
5087
|
-
opacity:
|
|
5186
|
+
color: kt,
|
|
5187
|
+
strokeWidth: Rt,
|
|
5188
|
+
opacity: Vt
|
|
5088
5189
|
};
|
|
5089
5190
|
}
|
|
5090
|
-
if (
|
|
5191
|
+
if (W === "redaction") {
|
|
5091
5192
|
let e = Math.abs(q.x - K.x), t = Math.abs(q.y - K.y), n = Math.min(K.x, q.x), r = Math.min(K.y, q.y);
|
|
5092
5193
|
return t < 18 && (t = Math.max(18, t), r = K.y - 9), {
|
|
5093
5194
|
id: "temp-live-drawing",
|
|
5094
5195
|
type: "rectangle",
|
|
5095
|
-
pageIndex:
|
|
5196
|
+
pageIndex: Kt,
|
|
5096
5197
|
x: n,
|
|
5097
5198
|
y: r,
|
|
5098
5199
|
width: e,
|
|
@@ -5109,29 +5210,29 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5109
5210
|
"rectangle",
|
|
5110
5211
|
"ellipse",
|
|
5111
5212
|
"link"
|
|
5112
|
-
].includes(
|
|
5213
|
+
].includes(W)) {
|
|
5113
5214
|
let e = Math.abs(q.x - K.x), t = Math.abs(q.y - K.y), n = Math.min(K.x, q.x), r = Math.min(K.y, q.y);
|
|
5114
5215
|
return {
|
|
5115
5216
|
id: "temp-live-drawing",
|
|
5116
|
-
type:
|
|
5117
|
-
pageIndex:
|
|
5217
|
+
type: W,
|
|
5218
|
+
pageIndex: Kt,
|
|
5118
5219
|
x: n,
|
|
5119
5220
|
y: r,
|
|
5120
5221
|
width: e,
|
|
5121
5222
|
height: t,
|
|
5122
|
-
points:
|
|
5123
|
-
color:
|
|
5124
|
-
strokeWidth:
|
|
5125
|
-
opacity:
|
|
5223
|
+
points: W === "line" || W === "arrow" || W === "callout" ? [K, q] : void 0,
|
|
5224
|
+
color: kt,
|
|
5225
|
+
strokeWidth: Rt,
|
|
5226
|
+
opacity: Vt
|
|
5126
5227
|
};
|
|
5127
5228
|
}
|
|
5128
5229
|
})() : null;
|
|
5129
5230
|
return t.map((n, r) => {
|
|
5130
5231
|
let s, c = j.current?.clientWidth || 0, l = Ye(n), u = Ye(t[0]).width * S, d = l.width * S;
|
|
5131
5232
|
t.length === 2 ? (r === 0 && (s = Math.max(0, c / 2 - u)), r === 1 && (s = Math.max(u, c / 2))) : s = Math.max(0, c / 2 - d / 2);
|
|
5132
|
-
let f = o && o.pageIndex === n ? [...
|
|
5233
|
+
let f = o && o.pageIndex === n ? [...U, o] : U;
|
|
5133
5234
|
return /* @__PURE__ */ I(e.Fragment, { children: [
|
|
5134
|
-
/* @__PURE__ */ F(
|
|
5235
|
+
/* @__PURE__ */ F(St, {
|
|
5135
5236
|
pageNum: n,
|
|
5136
5237
|
pdfDoc: M,
|
|
5137
5238
|
scale: S,
|
|
@@ -5145,28 +5246,28 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5145
5246
|
basePageWidth: l.width,
|
|
5146
5247
|
basePageHeight: l.height,
|
|
5147
5248
|
activeTab: a,
|
|
5148
|
-
activeTool:
|
|
5249
|
+
activeTool: W,
|
|
5149
5250
|
annotations: f,
|
|
5150
5251
|
transientHighlights: _e?.filter((e) => e.pageIndex === n) || [],
|
|
5151
5252
|
selectedAnnotationId: Y,
|
|
5152
5253
|
activeSearchResult: Ue,
|
|
5153
|
-
onMouseDown:
|
|
5154
|
-
onMouseMove:
|
|
5155
|
-
onMouseUp:
|
|
5156
|
-
onAnnotationClick:
|
|
5157
|
-
onAnnotationMouseEnter:
|
|
5254
|
+
onMouseDown: Nn,
|
|
5255
|
+
onMouseMove: Fn,
|
|
5256
|
+
onMouseUp: In,
|
|
5257
|
+
onAnnotationClick: Rn,
|
|
5258
|
+
onAnnotationMouseEnter: Ln,
|
|
5158
5259
|
onClearSelection: () => {
|
|
5159
|
-
if (
|
|
5160
|
-
|
|
5260
|
+
if (Z.current || on) {
|
|
5261
|
+
Z.current = !1;
|
|
5161
5262
|
return;
|
|
5162
5263
|
}
|
|
5163
|
-
X(null),
|
|
5264
|
+
X(null), an(null);
|
|
5164
5265
|
},
|
|
5165
5266
|
watermark: ue,
|
|
5166
5267
|
watermarkText: de,
|
|
5167
|
-
redactions:
|
|
5168
|
-
onDiscardRedaction:
|
|
5169
|
-
onRendered:
|
|
5268
|
+
redactions: yn,
|
|
5269
|
+
onDiscardRedaction: xn,
|
|
5270
|
+
onRendered: Dn
|
|
5170
5271
|
}),
|
|
5171
5272
|
R.isActive && R.mode === "overlay" && ke && /* @__PURE__ */ F("div", {
|
|
5172
5273
|
style: {
|
|
@@ -5181,7 +5282,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5181
5282
|
zIndex: 12,
|
|
5182
5283
|
filter: "contrast(1.2) brightness(0.95)"
|
|
5183
5284
|
},
|
|
5184
|
-
children: /* @__PURE__ */ F(
|
|
5285
|
+
children: /* @__PURE__ */ F(St, {
|
|
5185
5286
|
pageNum: n,
|
|
5186
5287
|
pdfDoc: ke,
|
|
5187
5288
|
scale: S,
|
|
@@ -5217,13 +5318,13 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5217
5318
|
pointerEvents: "none",
|
|
5218
5319
|
zIndex: 16
|
|
5219
5320
|
},
|
|
5220
|
-
children: /* @__PURE__ */ F(
|
|
5321
|
+
children: /* @__PURE__ */ F(Nt, {
|
|
5221
5322
|
boxes: [...R.pageDiffsA?.[n] || [], ...R.pageDiffsB?.[n] || []],
|
|
5222
5323
|
scale: S,
|
|
5223
5324
|
selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
|
|
5224
5325
|
onSelectDiff: (e) => {
|
|
5225
5326
|
let t = R.diffItems.findIndex((t) => t.id === e);
|
|
5226
|
-
t !== -1 &&
|
|
5327
|
+
t !== -1 && xt(t);
|
|
5227
5328
|
}
|
|
5228
5329
|
})
|
|
5229
5330
|
}),
|
|
@@ -5242,19 +5343,19 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5242
5343
|
flexDirection: "column"
|
|
5243
5344
|
},
|
|
5244
5345
|
children: [/* @__PURE__ */ F("textarea", {
|
|
5245
|
-
ref:
|
|
5246
|
-
value:
|
|
5247
|
-
onChange: (e) =>
|
|
5346
|
+
ref: nn,
|
|
5347
|
+
value: en,
|
|
5348
|
+
onChange: (e) => tn(e.target.value),
|
|
5248
5349
|
onBlur: (e) => {
|
|
5249
|
-
e.currentTarget.parentElement?.contains(e.relatedTarget) ||
|
|
5350
|
+
e.currentTarget.parentElement?.contains(e.relatedTarget) || Pn();
|
|
5250
5351
|
},
|
|
5251
5352
|
onKeyDown: (e) => {
|
|
5252
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(),
|
|
5353
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), Pn());
|
|
5253
5354
|
},
|
|
5254
5355
|
style: {
|
|
5255
5356
|
backgroundColor: "transparent",
|
|
5256
5357
|
border: "none",
|
|
5257
|
-
color:
|
|
5358
|
+
color: kt,
|
|
5258
5359
|
fontSize: "16px",
|
|
5259
5360
|
fontFamily: "sans-serif",
|
|
5260
5361
|
minWidth: "150px",
|
|
@@ -5274,7 +5375,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5274
5375
|
},
|
|
5275
5376
|
children: /* @__PURE__ */ F("button", {
|
|
5276
5377
|
onMouseDown: (e) => {
|
|
5277
|
-
e.preventDefault(),
|
|
5378
|
+
e.preventDefault(), Pn();
|
|
5278
5379
|
},
|
|
5279
5380
|
style: {
|
|
5280
5381
|
padding: "4px 12px",
|
|
@@ -5297,17 +5398,17 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5297
5398
|
style: {
|
|
5298
5399
|
position: "relative",
|
|
5299
5400
|
width: "100%",
|
|
5300
|
-
height: `${
|
|
5401
|
+
height: `${ct.total}px`
|
|
5301
5402
|
},
|
|
5302
|
-
children:
|
|
5403
|
+
children: H.map((e, n) => t(e, n, !0))
|
|
5303
5404
|
});
|
|
5304
5405
|
{
|
|
5305
|
-
let e = Math.max(0,
|
|
5406
|
+
let e = Math.max(0, H.findIndex((e) => e.includes(N))), n = H[e] || [];
|
|
5306
5407
|
return /* @__PURE__ */ F("div", {
|
|
5307
5408
|
style: {
|
|
5308
5409
|
position: "relative",
|
|
5309
5410
|
width: "100%",
|
|
5310
|
-
minHeight: `${
|
|
5411
|
+
minHeight: `${ct.heights[e] ?? 0}px`
|
|
5311
5412
|
},
|
|
5312
5413
|
children: t(n, e, !1)
|
|
5313
5414
|
});
|
|
@@ -5421,7 +5522,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5421
5522
|
},
|
|
5422
5523
|
children: [
|
|
5423
5524
|
/* @__PURE__ */ F("button", {
|
|
5424
|
-
onClick: () =>
|
|
5525
|
+
onClick: () => _t(Math.max(1, N - 1)),
|
|
5425
5526
|
disabled: N <= 1,
|
|
5426
5527
|
style: {
|
|
5427
5528
|
background: "none",
|
|
@@ -5448,7 +5549,7 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5448
5549
|
]
|
|
5449
5550
|
}),
|
|
5450
5551
|
/* @__PURE__ */ F("button", {
|
|
5451
|
-
onClick: () =>
|
|
5552
|
+
onClick: () => _t(Math.min(M.numPages, N + 1)),
|
|
5452
5553
|
disabled: N >= M.numPages,
|
|
5453
5554
|
style: {
|
|
5454
5555
|
background: "none",
|
|
@@ -5462,15 +5563,15 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5462
5563
|
})
|
|
5463
5564
|
]
|
|
5464
5565
|
}),
|
|
5465
|
-
Y &&
|
|
5466
|
-
annotation:
|
|
5467
|
-
position:
|
|
5566
|
+
Y && rn && /* @__PURE__ */ F(He, {
|
|
5567
|
+
annotation: U.find((e) => e.id === Y),
|
|
5568
|
+
position: rn,
|
|
5468
5569
|
onCopy: () => {
|
|
5469
|
-
let e =
|
|
5570
|
+
let e = U.find((e) => e.id === Y);
|
|
5470
5571
|
if (e) {
|
|
5471
5572
|
let t = {
|
|
5472
5573
|
...e,
|
|
5473
|
-
id:
|
|
5574
|
+
id: Ct(),
|
|
5474
5575
|
author: void 0,
|
|
5475
5576
|
authorId: void 0,
|
|
5476
5577
|
createdAt: void 0,
|
|
@@ -5480,25 +5581,25 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5480
5581
|
x: e.x + 20,
|
|
5481
5582
|
y: e.y + 20
|
|
5482
5583
|
};
|
|
5483
|
-
Q([...
|
|
5584
|
+
Q([...U, t]);
|
|
5484
5585
|
}
|
|
5485
|
-
X(null),
|
|
5586
|
+
X(null), an(null);
|
|
5486
5587
|
},
|
|
5487
5588
|
onDelete: () => {
|
|
5488
|
-
Q(
|
|
5589
|
+
Q(U.filter((e) => e.id !== Y)), X(null), an(null);
|
|
5489
5590
|
},
|
|
5490
5591
|
onUpdateColor: (e) => {
|
|
5491
|
-
Q(
|
|
5592
|
+
Q(U.map((t) => t.id === Y ? {
|
|
5492
5593
|
...t,
|
|
5493
5594
|
color: e
|
|
5494
5595
|
} : t));
|
|
5495
5596
|
},
|
|
5496
5597
|
onOpenLinkModal: () => {
|
|
5497
|
-
|
|
5598
|
+
sn(!0), an(null);
|
|
5498
5599
|
},
|
|
5499
5600
|
permissions: ve
|
|
5500
5601
|
}),
|
|
5501
|
-
R.isActive && R.showCurtain && /* @__PURE__ */ F(
|
|
5602
|
+
R.isActive && R.showCurtain && /* @__PURE__ */ F(Lt, {
|
|
5502
5603
|
positionPercent: R.curtainPosition,
|
|
5503
5604
|
onChangePosition: (e) => z((t) => ({
|
|
5504
5605
|
...t,
|
|
@@ -5507,28 +5608,28 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5507
5608
|
containerRef: j
|
|
5508
5609
|
})
|
|
5509
5610
|
]
|
|
5510
|
-
})] }), R.isActive && /* @__PURE__ */ F(
|
|
5611
|
+
})] }), R.isActive && /* @__PURE__ */ F(It, {
|
|
5511
5612
|
isOpen: B,
|
|
5512
5613
|
onClose: () => Ie(!1),
|
|
5513
5614
|
diffItems: R.diffItems,
|
|
5514
5615
|
textDiffs: Pe,
|
|
5515
5616
|
currentDiffIndex: R.currentDiffIndex,
|
|
5516
|
-
onSelectDiff: (e, t) =>
|
|
5517
|
-
onJumpToPage: (e) =>
|
|
5617
|
+
onSelectDiff: (e, t) => xt(e, t),
|
|
5618
|
+
onJumpToPage: (e) => _t(e)
|
|
5518
5619
|
})]
|
|
5519
5620
|
})
|
|
5520
5621
|
]
|
|
5521
5622
|
}),
|
|
5522
|
-
|
|
5523
|
-
initialUrl:
|
|
5524
|
-
initialText:
|
|
5525
|
-
showTextInput: !
|
|
5623
|
+
on && Y && /* @__PURE__ */ F(We, {
|
|
5624
|
+
initialUrl: U.find((e) => e.id === Y)?.linkUrl || "",
|
|
5625
|
+
initialText: U.find((e) => e.id === Y)?.text || "",
|
|
5626
|
+
showTextInput: !U.find((e) => e.id === Y)?.width || U.find((e) => e.id === Y)?.text === "" || U.find((e) => e.id === Y)?.text !== void 0,
|
|
5526
5627
|
onClose: () => {
|
|
5527
|
-
let e =
|
|
5528
|
-
e && !e.linkUrl && Q(
|
|
5628
|
+
let e = U.find((e) => e.id === Y);
|
|
5629
|
+
e && !e.linkUrl && Q(U.filter((e) => e.id !== Y)), sn(!1), X(null);
|
|
5529
5630
|
},
|
|
5530
5631
|
onSave: (e, t) => {
|
|
5531
|
-
Q(
|
|
5632
|
+
Q(U.map((n) => {
|
|
5532
5633
|
if (n.id === Y) {
|
|
5533
5634
|
let r = t === void 0 ? n.text : t, i = r ? Math.max(100, r.length * 8 + 20) : n.width;
|
|
5534
5635
|
return {
|
|
@@ -5539,27 +5640,27 @@ function q({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationMa
|
|
|
5539
5640
|
};
|
|
5540
5641
|
}
|
|
5541
5642
|
return n;
|
|
5542
|
-
})),
|
|
5643
|
+
})), sn(!1), X(null);
|
|
5543
5644
|
}
|
|
5544
5645
|
}),
|
|
5545
5646
|
_ && /* @__PURE__ */ F(rt, {
|
|
5546
5647
|
isOpen: r,
|
|
5547
5648
|
activeTab: te,
|
|
5548
5649
|
setActiveTab: ne,
|
|
5549
|
-
annotations:
|
|
5650
|
+
annotations: U,
|
|
5550
5651
|
setAnnotations: Q,
|
|
5551
5652
|
selectedAnnotationId: Y,
|
|
5552
5653
|
setSelectedAnnotationId: X,
|
|
5553
|
-
onSearch:
|
|
5554
|
-
searchResults:
|
|
5555
|
-
isSearching:
|
|
5556
|
-
searchProgress:
|
|
5557
|
-
onResultClick:
|
|
5654
|
+
onSearch: Sn,
|
|
5655
|
+
searchResults: Cn,
|
|
5656
|
+
isSearching: wn,
|
|
5657
|
+
searchProgress: Tn,
|
|
5658
|
+
onResultClick: yt
|
|
5558
5659
|
})
|
|
5559
5660
|
]
|
|
5560
5661
|
});
|
|
5561
5662
|
}
|
|
5562
|
-
function
|
|
5663
|
+
function qt({ icon: e, active: t, onClick: n, label: r }) {
|
|
5563
5664
|
return /* @__PURE__ */ F("button", {
|
|
5564
5665
|
onClick: n,
|
|
5565
5666
|
title: r,
|
|
@@ -5586,7 +5687,7 @@ function Bt({ icon: e, active: t, onClick: n, label: r }) {
|
|
|
5586
5687
|
}
|
|
5587
5688
|
//#endregion
|
|
5588
5689
|
//#region src/components/SettingsModal.tsx
|
|
5589
|
-
function
|
|
5690
|
+
function Jt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
5590
5691
|
let { shortcuts: r, updateShortcut: i, resetShortcuts: a } = Qe(), [s, l] = c("Keyboard Shortcuts"), [u, d] = c(null), [f, p] = c(""), m = (e, t) => {
|
|
5591
5692
|
if (e.preventDefault(), e.stopPropagation(), e.key === "Escape") {
|
|
5592
5693
|
d(null);
|
|
@@ -6115,7 +6216,7 @@ function Vt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
|
6115
6216
|
}
|
|
6116
6217
|
//#endregion
|
|
6117
6218
|
//#region src/components/AboutModal.tsx
|
|
6118
|
-
function
|
|
6219
|
+
function K({ onClose: e }) {
|
|
6119
6220
|
return /* @__PURE__ */ F("div", {
|
|
6120
6221
|
style: {
|
|
6121
6222
|
position: "fixed",
|
|
@@ -6336,7 +6437,7 @@ function Ht({ onClose: e }) {
|
|
|
6336
6437
|
}
|
|
6337
6438
|
//#endregion
|
|
6338
6439
|
//#region src/core/eventBus.ts
|
|
6339
|
-
var
|
|
6440
|
+
var Yt = class {
|
|
6340
6441
|
listeners = /* @__PURE__ */ new Map();
|
|
6341
6442
|
destroyed = !1;
|
|
6342
6443
|
on(e, t) {
|
|
@@ -6378,22 +6479,22 @@ var Ut = class {
|
|
|
6378
6479
|
get isDestroyed() {
|
|
6379
6480
|
return this.destroyed;
|
|
6380
6481
|
}
|
|
6381
|
-
},
|
|
6382
|
-
function
|
|
6482
|
+
}, q = (e) => e === 0 ? 0 : e;
|
|
6483
|
+
function Xt(e, t) {
|
|
6383
6484
|
return {
|
|
6384
|
-
x:
|
|
6385
|
-
y:
|
|
6485
|
+
x: q(e.x * t[0] + e.y * t[2] + t[4]),
|
|
6486
|
+
y: q(e.x * t[1] + e.y * t[3] + t[5])
|
|
6386
6487
|
};
|
|
6387
6488
|
}
|
|
6388
|
-
function
|
|
6489
|
+
function Zt(e, t) {
|
|
6389
6490
|
let n = t[0] * t[3] - t[1] * t[2];
|
|
6390
6491
|
return {
|
|
6391
|
-
x:
|
|
6392
|
-
y:
|
|
6492
|
+
x: q((e.x * t[3] - e.y * t[2] + t[2] * t[5] - t[4] * t[3]) / n),
|
|
6493
|
+
y: q((-e.x * t[1] + e.y * t[0] + t[4] * t[1] - t[5] * t[0]) / n)
|
|
6393
6494
|
};
|
|
6394
6495
|
}
|
|
6395
|
-
function
|
|
6396
|
-
let r =
|
|
6496
|
+
function Qt(e, t, n) {
|
|
6497
|
+
let r = lt(n), [i, a, o, s] = t, c = (o + i) / 2, l = (s + a) / 2, u, d, f, p;
|
|
6397
6498
|
switch (r) {
|
|
6398
6499
|
case 180:
|
|
6399
6500
|
u = -1, d = 0, f = 0, p = 1;
|
|
@@ -6430,33 +6531,33 @@ function Kt(e, t, n) {
|
|
|
6430
6531
|
transform: v
|
|
6431
6532
|
};
|
|
6432
6533
|
}
|
|
6433
|
-
function
|
|
6534
|
+
function J(e) {
|
|
6434
6535
|
let t = e.view;
|
|
6435
|
-
return
|
|
6536
|
+
return Qt(e.pageNumber, [
|
|
6436
6537
|
t[0],
|
|
6437
6538
|
t[1],
|
|
6438
6539
|
t[2],
|
|
6439
6540
|
t[3]
|
|
6440
6541
|
], e.rotate);
|
|
6441
6542
|
}
|
|
6442
|
-
function
|
|
6543
|
+
function $t(e) {
|
|
6443
6544
|
let t = /* @__PURE__ */ new Map();
|
|
6444
6545
|
return (n) => {
|
|
6445
6546
|
let r = Math.max(1, Math.min(e.numPages, n)), i = t.get(r);
|
|
6446
|
-
return i || (i = e.getPage(r).then(
|
|
6547
|
+
return i || (i = e.getPage(r).then(J), t.set(r, i)), i;
|
|
6447
6548
|
};
|
|
6448
6549
|
}
|
|
6449
|
-
function
|
|
6450
|
-
return
|
|
6550
|
+
function en(e, t) {
|
|
6551
|
+
return Zt(t, e.transform);
|
|
6451
6552
|
}
|
|
6452
|
-
function
|
|
6453
|
-
return
|
|
6553
|
+
function tn(e, t) {
|
|
6554
|
+
return Xt(t, e.transform);
|
|
6454
6555
|
}
|
|
6455
|
-
function
|
|
6456
|
-
let n =
|
|
6556
|
+
function nn(e, t) {
|
|
6557
|
+
let n = en(e, {
|
|
6457
6558
|
x: t.x,
|
|
6458
6559
|
y: t.y
|
|
6459
|
-
}), r =
|
|
6560
|
+
}), r = en(e, {
|
|
6460
6561
|
x: t.x + t.width,
|
|
6461
6562
|
y: t.y + t.height
|
|
6462
6563
|
});
|
|
@@ -6467,11 +6568,11 @@ function Z(e, t) {
|
|
|
6467
6568
|
Math.max(n.y, r.y)
|
|
6468
6569
|
];
|
|
6469
6570
|
}
|
|
6470
|
-
function
|
|
6471
|
-
let n =
|
|
6571
|
+
function Y(e, t) {
|
|
6572
|
+
let n = tn(e, {
|
|
6472
6573
|
x: t[0],
|
|
6473
6574
|
y: t[1]
|
|
6474
|
-
}), r =
|
|
6575
|
+
}), r = tn(e, {
|
|
6475
6576
|
x: t[2],
|
|
6476
6577
|
y: t[3]
|
|
6477
6578
|
});
|
|
@@ -6482,14 +6583,14 @@ function Yt(e, t) {
|
|
|
6482
6583
|
height: Math.abs(r.y - n.y)
|
|
6483
6584
|
};
|
|
6484
6585
|
}
|
|
6485
|
-
function
|
|
6486
|
-
return t.map((t) =>
|
|
6586
|
+
function X(e, t) {
|
|
6587
|
+
return t.map((t) => en(e, t));
|
|
6487
6588
|
}
|
|
6488
|
-
function
|
|
6489
|
-
return t.map((t) =>
|
|
6589
|
+
function rn(e, t) {
|
|
6590
|
+
return t.map((t) => tn(e, t));
|
|
6490
6591
|
}
|
|
6491
|
-
function
|
|
6492
|
-
let [n, r, i, a] =
|
|
6592
|
+
function an(e, t) {
|
|
6593
|
+
let [n, r, i, a] = nn(e, t);
|
|
6493
6594
|
return [
|
|
6494
6595
|
n,
|
|
6495
6596
|
a,
|
|
@@ -6501,7 +6602,7 @@ function Qt(e, t) {
|
|
|
6501
6602
|
r
|
|
6502
6603
|
];
|
|
6503
6604
|
}
|
|
6504
|
-
function
|
|
6605
|
+
function on(e, t) {
|
|
6505
6606
|
let n = [];
|
|
6506
6607
|
for (let r = 0; r + 7 < t.length; r += 8) {
|
|
6507
6608
|
let i = [
|
|
@@ -6515,7 +6616,7 @@ function $t(e, t) {
|
|
|
6515
6616
|
t[r + 5],
|
|
6516
6617
|
t[r + 7]
|
|
6517
6618
|
];
|
|
6518
|
-
n.push(
|
|
6619
|
+
n.push(Y(e, [
|
|
6519
6620
|
Math.min(...i),
|
|
6520
6621
|
Math.min(...a),
|
|
6521
6622
|
Math.max(...i),
|
|
@@ -6524,7 +6625,7 @@ function $t(e, t) {
|
|
|
6524
6625
|
}
|
|
6525
6626
|
return n;
|
|
6526
6627
|
}
|
|
6527
|
-
function
|
|
6628
|
+
function sn(e) {
|
|
6528
6629
|
if (e.length === 0) return {
|
|
6529
6630
|
x: 0,
|
|
6530
6631
|
y: 0,
|
|
@@ -6539,17 +6640,17 @@ function en(e) {
|
|
|
6539
6640
|
height: i - n
|
|
6540
6641
|
};
|
|
6541
6642
|
}
|
|
6542
|
-
var
|
|
6643
|
+
var Z = (e) => (Math.round(e * 1e3) / 1e3).toString(), cn = 524288e3, ln = (e) => {
|
|
6543
6644
|
let t = e && /^#[0-9a-f]{6}$/i.test(e) ? e : "#000000", n = parseInt(t.slice(1, 3), 16) / 255, r = parseInt(t.slice(3, 5), 16) / 255, i = parseInt(t.slice(5, 7), 16) / 255;
|
|
6544
6645
|
return B(n, r, i);
|
|
6545
6646
|
};
|
|
6546
|
-
async function
|
|
6547
|
-
let a =
|
|
6647
|
+
async function un(e, t, n, r, i) {
|
|
6648
|
+
let a = ln(r.color), o = r.opacity ?? 1, s = r.strokeWidth || 1, [c, l, u, d] = nn(n, {
|
|
6548
6649
|
x: r.x,
|
|
6549
6650
|
y: r.y,
|
|
6550
6651
|
width: r.width,
|
|
6551
6652
|
height: r.height
|
|
6552
|
-
}), f = u - c, p = d - l, m = Fe(n.rotate), h = (e, t, r) =>
|
|
6653
|
+
}), f = u - c, p = d - l, m = Fe(n.rotate), h = (e, t, r) => en(n, {
|
|
6553
6654
|
x: e,
|
|
6554
6655
|
y: t + r
|
|
6555
6656
|
});
|
|
@@ -6588,7 +6689,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6588
6689
|
height: r.height
|
|
6589
6690
|
}];
|
|
6590
6691
|
for (let r of e) {
|
|
6591
|
-
let [e, i, s, c] =
|
|
6692
|
+
let [e, i, s, c] = nn(n, r);
|
|
6592
6693
|
t.drawRectangle({
|
|
6593
6694
|
x: e,
|
|
6594
6695
|
y: i,
|
|
@@ -6609,7 +6710,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6609
6710
|
}, {
|
|
6610
6711
|
x: r.x + r.width,
|
|
6611
6712
|
y: r.y + r.height
|
|
6612
|
-
}], [i, c] =
|
|
6713
|
+
}], [i, c] = X(n, [e[0], e[1]]);
|
|
6613
6714
|
if (t.drawLine({
|
|
6614
6715
|
start: i,
|
|
6615
6716
|
end: c,
|
|
@@ -6617,7 +6718,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6617
6718
|
opacity: o,
|
|
6618
6719
|
thickness: s
|
|
6619
6720
|
}), r.type === "arrow") {
|
|
6620
|
-
let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] =
|
|
6721
|
+
let r = e[0], i = e[1], l = Math.atan2(i.y - r.y, i.x - r.x), u = 15 + s, [d, f] = X(n, [{
|
|
6621
6722
|
x: i.x - u * Math.cos(l - Math.PI / 6),
|
|
6622
6723
|
y: i.y - u * Math.sin(l - Math.PI / 6)
|
|
6623
6724
|
}, {
|
|
@@ -6643,7 +6744,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6643
6744
|
case "freehand": {
|
|
6644
6745
|
let e = r.strokes && r.strokes.length > 0 ? r.strokes : r.points ? [r.points] : [];
|
|
6645
6746
|
for (let r of e) {
|
|
6646
|
-
let e =
|
|
6747
|
+
let e = X(n, r);
|
|
6647
6748
|
for (let n = 1; n < e.length; n++) t.drawLine({
|
|
6648
6749
|
start: e[n - 1],
|
|
6649
6750
|
end: e[n],
|
|
@@ -6669,7 +6770,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6669
6770
|
return;
|
|
6670
6771
|
}
|
|
6671
6772
|
case "note": {
|
|
6672
|
-
let [e, i, c, l] =
|
|
6773
|
+
let [e, i, c, l] = nn(n, {
|
|
6673
6774
|
x: r.x,
|
|
6674
6775
|
y: r.y,
|
|
6675
6776
|
width: 24,
|
|
@@ -6703,7 +6804,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6703
6804
|
}, {
|
|
6704
6805
|
x: r.x,
|
|
6705
6806
|
y: r.y
|
|
6706
|
-
}], [i, c] =
|
|
6807
|
+
}], [i, c] = X(n, [e[0], e[1]]);
|
|
6707
6808
|
if (t.drawLine({
|
|
6708
6809
|
start: i,
|
|
6709
6810
|
end: c,
|
|
@@ -6711,7 +6812,7 @@ async function rn(e, t, n, r, i) {
|
|
|
6711
6812
|
opacity: o,
|
|
6712
6813
|
thickness: s
|
|
6713
6814
|
}), r.text) {
|
|
6714
|
-
let i = r.text.length * 8 + 20, [c, l, u, d] =
|
|
6815
|
+
let i = r.text.length * 8 + 20, [c, l, u, d] = nn(n, {
|
|
6715
6816
|
x: e[1].x,
|
|
6716
6817
|
y: e[1].y,
|
|
6717
6818
|
width: i,
|
|
@@ -6804,8 +6905,8 @@ async function rn(e, t, n, r, i) {
|
|
|
6804
6905
|
default: return;
|
|
6805
6906
|
}
|
|
6806
6907
|
}
|
|
6807
|
-
async function
|
|
6808
|
-
let n =
|
|
6908
|
+
async function dn(e, t) {
|
|
6909
|
+
let n = ln(t.color || "#737373"), r = t.opacity ?? .08, i = await e.embedFont(Pe.Helvetica), a = -Math.PI / 4, o = Math.cos(a), s = Math.sin(a);
|
|
6809
6910
|
for (let a of e.getPages()) {
|
|
6810
6911
|
let { width: e, height: c } = a.getSize();
|
|
6811
6912
|
if (t.mode === "single") {
|
|
@@ -6836,10 +6937,10 @@ async function an(e, t) {
|
|
|
6836
6937
|
}
|
|
6837
6938
|
}
|
|
6838
6939
|
}
|
|
6839
|
-
async function
|
|
6940
|
+
async function fn(e, t) {
|
|
6840
6941
|
let n = await e.save(), r = L.getDocument({
|
|
6841
6942
|
data: n,
|
|
6842
|
-
...
|
|
6943
|
+
...jt()
|
|
6843
6944
|
}), i = await r.promise, a = await z.create();
|
|
6844
6945
|
try {
|
|
6845
6946
|
for (let n = 1; n <= i.numPages; n++) {
|
|
@@ -6876,7 +6977,7 @@ async function on(e, t) {
|
|
|
6876
6977
|
}
|
|
6877
6978
|
return a;
|
|
6878
6979
|
}
|
|
6879
|
-
async function
|
|
6980
|
+
async function Q(e, t = {}) {
|
|
6880
6981
|
t.xfdfString && console.warn("[teamsync-pdf-viewer] getFileData({ xfdfString }) is ignored; import the XFDF through annotationManager.importAnnotations() first.");
|
|
6881
6982
|
let n = await e.getSourceBytes(), r = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
6882
6983
|
if (r.byteLength > 524288e3) {
|
|
@@ -6886,33 +6987,33 @@ async function sn(e, t = {}) {
|
|
|
6886
6987
|
let i = await z.load(r, { ignoreEncryption: !0 }), a = i.getPages(), o = t.explicitAnnotations || e.annotations, s = e.getPageGeometry, c = null;
|
|
6887
6988
|
!s && o.length > 0 && (c = L.getDocument({
|
|
6888
6989
|
data: r.slice(),
|
|
6889
|
-
...
|
|
6890
|
-
}), s =
|
|
6990
|
+
...jt()
|
|
6991
|
+
}), s = $t(await c.promise));
|
|
6891
6992
|
try {
|
|
6892
6993
|
for (let t of o) {
|
|
6893
6994
|
let n = Math.max(0, Math.min((t.pageIndex || 1) - 1, a.length - 1)), r = await s(n + 1);
|
|
6894
|
-
await
|
|
6995
|
+
await un(i, a[n], r, t, e.signerName);
|
|
6895
6996
|
}
|
|
6896
6997
|
} finally {
|
|
6897
6998
|
c && await c.destroy().catch(() => {});
|
|
6898
6999
|
}
|
|
6899
|
-
e.watermark?.text && await
|
|
7000
|
+
e.watermark?.text && await dn(i, e.watermark);
|
|
6900
7001
|
let l = e.redactions || [];
|
|
6901
|
-
return await (l.length > 0 ? await
|
|
7002
|
+
return await (l.length > 0 ? await fn(i, l) : i).save();
|
|
6902
7003
|
}
|
|
6903
7004
|
//#endregion
|
|
6904
7005
|
//#region src/annotations/xfdf.ts
|
|
6905
|
-
var
|
|
6906
|
-
function
|
|
7006
|
+
var pn = "http://ns.adobe.com/xfdf/", mn = "tspdf", hn = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
7007
|
+
function gn(e, t = 2) {
|
|
6907
7008
|
return String(e).padStart(t, "0");
|
|
6908
7009
|
}
|
|
6909
|
-
function
|
|
7010
|
+
function _n(e) {
|
|
6910
7011
|
let t = e ? new Date(e) : /* @__PURE__ */ new Date();
|
|
6911
|
-
if (Number.isNaN(t.getTime())) return
|
|
6912
|
-
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i =
|
|
6913
|
-
return `D:${t.getFullYear()}${
|
|
7012
|
+
if (Number.isNaN(t.getTime())) return _n(void 0);
|
|
7013
|
+
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i = gn(Math.floor(Math.abs(n) / 60)), a = gn(Math.abs(n) % 60);
|
|
7014
|
+
return `D:${t.getFullYear()}${gn(t.getMonth() + 1)}${gn(t.getDate())}${gn(t.getHours())}${gn(t.getMinutes())}${gn(t.getSeconds())}${r}${i}'${a}'`;
|
|
6914
7015
|
}
|
|
6915
|
-
function
|
|
7016
|
+
function vn(e) {
|
|
6916
7017
|
if (!e) return;
|
|
6917
7018
|
let t = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?/.exec(e.trim());
|
|
6918
7019
|
if (!t) {
|
|
@@ -6924,41 +7025,41 @@ function pn(e) {
|
|
|
6924
7025
|
let f = Date.parse(`${n}-${r}-${i}T${a}:${o}:${s}${d}`);
|
|
6925
7026
|
return Number.isNaN(f) ? void 0 : new Date(f).toISOString();
|
|
6926
7027
|
}
|
|
6927
|
-
var
|
|
7028
|
+
var yn = (e) => {
|
|
6928
7029
|
if (!(!e || e === "transparent")) {
|
|
6929
7030
|
if (/^#[0-9a-f]{6}$/i.test(e)) return e.toUpperCase();
|
|
6930
7031
|
if (/^#[0-9a-f]{3}$/i.test(e)) return `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`.toUpperCase();
|
|
6931
7032
|
}
|
|
6932
|
-
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${
|
|
6933
|
-
function
|
|
6934
|
-
return `<trn-custom-data bytes="${
|
|
7033
|
+
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${hn(String(t))}"`;
|
|
7034
|
+
function bn(e) {
|
|
7035
|
+
return `<trn-custom-data bytes="${hn(JSON.stringify({ [mn]: e }))}"/>`;
|
|
6935
7036
|
}
|
|
6936
|
-
function
|
|
7037
|
+
function xn(e) {
|
|
6937
7038
|
let t = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
6938
7039
|
if (!t) return {};
|
|
6939
7040
|
try {
|
|
6940
|
-
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[
|
|
7041
|
+
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[mn];
|
|
6941
7042
|
return e && typeof e == "object" ? e : {};
|
|
6942
7043
|
} catch {
|
|
6943
7044
|
return {};
|
|
6944
7045
|
}
|
|
6945
7046
|
}
|
|
6946
|
-
function
|
|
6947
|
-
return e.map((e) => `${
|
|
7047
|
+
function Sn(e) {
|
|
7048
|
+
return e.map((e) => `${Z(e.x)},${Z(e.y)}`).join(";");
|
|
6948
7049
|
}
|
|
6949
|
-
function
|
|
7050
|
+
function Cn(e) {
|
|
6950
7051
|
return e ? e.split(";").map((e) => e.trim().split(/[,\s]+/).map(Number)).filter((e) => e.length >= 2 && e.every((e) => Number.isFinite(e))).map(([e, t]) => ({
|
|
6951
7052
|
x: e,
|
|
6952
7053
|
y: t
|
|
6953
7054
|
})) : [];
|
|
6954
7055
|
}
|
|
6955
|
-
function
|
|
7056
|
+
function wn(e) {
|
|
6956
7057
|
return e ? e.split(/[,\s]+/).map(Number).filter((e) => Number.isFinite(e)) : [];
|
|
6957
7058
|
}
|
|
6958
|
-
function
|
|
6959
|
-
return e.map(
|
|
7059
|
+
function Tn(e) {
|
|
7060
|
+
return e.map(Z).join(",");
|
|
6960
7061
|
}
|
|
6961
|
-
var
|
|
7062
|
+
var En = /* @__PURE__ */ new Set([
|
|
6962
7063
|
"page",
|
|
6963
7064
|
"rect",
|
|
6964
7065
|
"color",
|
|
@@ -6980,7 +7081,7 @@ var xn = /* @__PURE__ */ new Set([
|
|
|
6980
7081
|
"IT",
|
|
6981
7082
|
"callout",
|
|
6982
7083
|
"style"
|
|
6983
|
-
]),
|
|
7084
|
+
]), Dn = /* @__PURE__ */ new Set([
|
|
6984
7085
|
"contents",
|
|
6985
7086
|
"contents-richtext",
|
|
6986
7087
|
"inklist",
|
|
@@ -6992,33 +7093,33 @@ var xn = /* @__PURE__ */ new Set([
|
|
|
6992
7093
|
"popup",
|
|
6993
7094
|
"vertices"
|
|
6994
7095
|
]);
|
|
6995
|
-
function
|
|
6996
|
-
let i = r ??
|
|
7096
|
+
function On(e, t, n, r) {
|
|
7097
|
+
let i = r ?? nn(t, {
|
|
6997
7098
|
x: e.x,
|
|
6998
7099
|
y: e.y,
|
|
6999
7100
|
width: e.width,
|
|
7000
7101
|
height: e.height
|
|
7001
7102
|
}), a = e.createdAt ?? (e.timestamp ? new Date(e.timestamp).toISOString() : void 0), o = ["print", ...e.readOnly ? ["readonly", "locked"] : []].join(",");
|
|
7002
|
-
return $("page", e.pageIndex - 1) + $("rect",
|
|
7103
|
+
return $("page", e.pageIndex - 1) + $("rect", Tn(i)) + $("name", e.id) + (n ? $("title", e.author) : "") + $("date", _n(e.modifiedAt ?? a)) + $("creationdate", _n(a)) + $("flags", o) + $("opacity", e.opacity !== void 0 && e.opacity !== 1 ? Z(e.opacity) : void 0);
|
|
7003
7104
|
}
|
|
7004
|
-
function
|
|
7105
|
+
function kn(e) {
|
|
7005
7106
|
let t = e.xfdfExtras?.attrs;
|
|
7006
|
-
return t ? Object.entries(t).filter(([e]) => !
|
|
7107
|
+
return t ? Object.entries(t).filter(([e]) => !En.has(e)).map(([e, t]) => $(e, t)).join("") : "";
|
|
7007
7108
|
}
|
|
7008
|
-
function
|
|
7109
|
+
function An(e) {
|
|
7009
7110
|
return (e.xfdfExtras?.children ?? []).join("");
|
|
7010
7111
|
}
|
|
7011
|
-
function
|
|
7112
|
+
function jn(e, t = {}) {
|
|
7012
7113
|
let n = {
|
|
7013
7114
|
type: e.type,
|
|
7014
7115
|
...t
|
|
7015
7116
|
};
|
|
7016
|
-
return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth),
|
|
7117
|
+
return e.authorId && (n.authorId = e.authorId), e.strokeWidth !== void 0 && (n.strokeWidth = e.strokeWidth), bn(n);
|
|
7017
7118
|
}
|
|
7018
|
-
var
|
|
7019
|
-
async function
|
|
7119
|
+
var Mn = (e) => e ? `<contents>${hn(e)}</contents>` : "", Nn = (e, t) => `<defaultstyle>font: Helvetica ${t}pt; text-align: left; color: ${yn(e.color) ?? "#000000"}</defaultstyle><defaultappearance>0 0 0 rg /Helv ${t} Tf</defaultappearance>`;
|
|
7120
|
+
async function Pn(e, t, n = {}) {
|
|
7020
7121
|
if (e.type === "opaque" && e.rawXfdf) return e.rawXfdf;
|
|
7021
|
-
let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a =
|
|
7122
|
+
let r = await t(e.pageIndex), i = n.useDisplayAuthor !== !1, a = yn(e.color), o = $("color", a) + $("width", e.strokeWidth), s = (t) => On(e, r, i, t) + kn(e), c = (t = {}) => jn(e, t) + An(e);
|
|
7022
7123
|
switch (e.type) {
|
|
7023
7124
|
case "rectangle": return `<square${s()}${o}${$("interior-color", a)} subject="Rectangle">${c()}</square>`;
|
|
7024
7125
|
case "ellipse": return `<circle${s()}${o}${$("interior-color", a)} subject="Ellipse">${c()}</circle>`;
|
|
@@ -7030,17 +7131,17 @@ async function kn(e, t, n = {}) {
|
|
|
7030
7131
|
}, {
|
|
7031
7132
|
x: e.x + e.width,
|
|
7032
7133
|
y: e.y + e.height
|
|
7033
|
-
}], [n, i] =
|
|
7134
|
+
}], [n, i] = X(r, [t[0], t[1]]), a = [
|
|
7034
7135
|
Math.min(n.x, i.x),
|
|
7035
7136
|
Math.min(n.y, i.y),
|
|
7036
7137
|
Math.max(n.x, i.x),
|
|
7037
7138
|
Math.max(n.y, i.y)
|
|
7038
7139
|
], l = e.type === "arrow" ? $("head", "OpenArrow") : "";
|
|
7039
|
-
return `<line${s(a)}${o} start="${
|
|
7140
|
+
return `<line${s(a)}${o} start="${Z(n.x)},${Z(n.y)}" end="${Z(i.x)},${Z(i.y)}"${l} subject="${e.type === "arrow" ? "Arrow" : "Line"}">${c()}</line>`;
|
|
7040
7141
|
}
|
|
7041
7142
|
case "freehand": {
|
|
7042
|
-
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${
|
|
7043
|
-
return `<ink${s(i.length ?
|
|
7143
|
+
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${Sn(X(r, e))}</gesture>`).join(""), i = t.flat();
|
|
7144
|
+
return `<ink${s(i.length ? nn(r, Fn(i, e.strokeWidth)) : void 0)}${o} subject="Free Hand"><inklist>${n}</inklist>${c()}</ink>`;
|
|
7044
7145
|
}
|
|
7045
7146
|
case "highlight": {
|
|
7046
7147
|
let t = e.rects && e.rects.length > 0 ? e.rects : [{
|
|
@@ -7048,10 +7149,10 @@ async function kn(e, t, n = {}) {
|
|
|
7048
7149
|
y: e.y,
|
|
7049
7150
|
width: e.width,
|
|
7050
7151
|
height: e.height
|
|
7051
|
-
}], n = t.flatMap((e) =>
|
|
7052
|
-
return `<highlight${s(
|
|
7152
|
+
}], n = t.flatMap((e) => an(r, e)).map(Z).join(",");
|
|
7153
|
+
return `<highlight${s(nn(r, sn(t)))}${$("color", a)} coords="${n}" subject="Highlight">${c()}</highlight>`;
|
|
7053
7154
|
}
|
|
7054
|
-
case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${
|
|
7155
|
+
case "text": return `<freetext${s()}${$("color", a)} subject="Free Text">${Mn(e.text)}${Nn(e, 16)}${c()}</freetext>`;
|
|
7055
7156
|
case "callout": {
|
|
7056
7157
|
let t = e.points && e.points.length >= 2 ? e.points : [{
|
|
7057
7158
|
x: e.x,
|
|
@@ -7059,7 +7160,7 @@ async function kn(e, t, n = {}) {
|
|
|
7059
7160
|
}, {
|
|
7060
7161
|
x: e.x,
|
|
7061
7162
|
y: e.y
|
|
7062
|
-
}], [n, i] =
|
|
7163
|
+
}], [n, i] = X(r, [t[0], t[1]]), a = nn(r, {
|
|
7063
7164
|
x: t[1].x,
|
|
7064
7165
|
y: t[1].y,
|
|
7065
7166
|
width: e.text ? e.text.length * 8 + 20 : 100,
|
|
@@ -7070,19 +7171,19 @@ async function kn(e, t, n = {}) {
|
|
|
7070
7171
|
Math.min(n.y, a[1]),
|
|
7071
7172
|
Math.max(i.x, a[2]),
|
|
7072
7173
|
Math.max(i.y, a[3])
|
|
7073
|
-
])}${o} IT="FreeTextCallout" callout="${
|
|
7174
|
+
])}${o} IT="FreeTextCallout" callout="${Z(n.x)},${Z(n.y)},${Z(i.x)},${Z(i.y)}" subject="Callout">${Mn(e.text)}${Nn(e, 14)}${c({ box: a })}</freetext>`;
|
|
7074
7175
|
}
|
|
7075
|
-
case "note": return `<text${s(
|
|
7176
|
+
case "note": return `<text${s(nn(r, {
|
|
7076
7177
|
x: e.x,
|
|
7077
7178
|
y: e.y,
|
|
7078
7179
|
width: 24,
|
|
7079
7180
|
height: 24
|
|
7080
|
-
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${
|
|
7181
|
+
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${Mn(e.text)}${c()}</text>`;
|
|
7081
7182
|
case "link": {
|
|
7082
|
-
let t = e.linkUrl ?? "", n = t.startsWith("#page=") ? `<OnActivation><Action Trigger="U"><GoTo><Dest><Fit Page="${Math.max(0, (parseInt(t.slice(6), 10) || 1) - 1)}"/></Dest></GoTo></Action></OnActivation>` : t ? `<OnActivation><Action Trigger="U"><URI Name="${
|
|
7083
|
-
return `<link${s()}${$("color", a)} subject="Link">${n}${
|
|
7183
|
+
let t = e.linkUrl ?? "", n = t.startsWith("#page=") ? `<OnActivation><Action Trigger="U"><GoTo><Dest><Fit Page="${Math.max(0, (parseInt(t.slice(6), 10) || 1) - 1)}"/></Dest></GoTo></Action></OnActivation>` : t ? `<OnActivation><Action Trigger="U"><URI Name="${hn(t)}"/></Action></OnActivation>` : "";
|
|
7184
|
+
return `<link${s()}${$("color", a)} subject="Link">${n}${Mn(e.text)}${c()}</link>`;
|
|
7084
7185
|
}
|
|
7085
|
-
case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${
|
|
7186
|
+
case "signature": return `<stamp${s()} subject="Signature">${e.imageUrl ? `<imagedata>${hn(e.imageUrl)}</imagedata>` : ""}${c({
|
|
7086
7187
|
signer: e.signer,
|
|
7087
7188
|
signType: e.signType,
|
|
7088
7189
|
timestamp: e.timestamp
|
|
@@ -7095,7 +7196,7 @@ async function kn(e, t, n = {}) {
|
|
|
7095
7196
|
default: return "";
|
|
7096
7197
|
}
|
|
7097
7198
|
}
|
|
7098
|
-
function
|
|
7199
|
+
function Fn(e, t = 0) {
|
|
7099
7200
|
let n = e.map((e) => e.x), r = e.map((e) => e.y), i = t / 2, a = Math.min(...n) - i, o = Math.min(...r) - i;
|
|
7100
7201
|
return {
|
|
7101
7202
|
x: a,
|
|
@@ -7104,21 +7205,21 @@ function An(e, t = 0) {
|
|
|
7104
7205
|
height: Math.max(...r) - o + i
|
|
7105
7206
|
};
|
|
7106
7207
|
}
|
|
7107
|
-
async function
|
|
7208
|
+
async function In(e, t, n = {}) {
|
|
7108
7209
|
let r = n.annotList ?? e;
|
|
7109
|
-
return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${
|
|
7210
|
+
return `<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="${pn}" xml:space="preserve"><annots>${(await Promise.all(r.map((e) => Pn(e, t, n)))).filter(Boolean).join("")}</annots></xfdf>`;
|
|
7110
7211
|
}
|
|
7111
|
-
function
|
|
7212
|
+
function Ln(e) {
|
|
7112
7213
|
let t = {};
|
|
7113
|
-
for (let n of Array.from(e.attributes)) !
|
|
7214
|
+
for (let n of Array.from(e.attributes)) !En.has(n.name) && !n.name.startsWith("xmlns") && (t[n.name] = n.value);
|
|
7114
7215
|
let n = [];
|
|
7115
|
-
for (let t of Array.from(e.children))
|
|
7216
|
+
for (let t of Array.from(e.children)) Dn.has(t.localName) || n.push(new XMLSerializer().serializeToString(t));
|
|
7116
7217
|
let r = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
7117
7218
|
if (r) try {
|
|
7118
7219
|
let e = JSON.parse(r.getAttribute("bytes") || "{}");
|
|
7119
7220
|
if (e && typeof e == "object") {
|
|
7120
7221
|
let t = { ...e };
|
|
7121
|
-
delete t[
|
|
7222
|
+
delete t[mn], Object.keys(t).length > 0 && n.push(`<trn-custom-data bytes="${hn(JSON.stringify(t))}"/>`);
|
|
7122
7223
|
}
|
|
7123
7224
|
} catch {
|
|
7124
7225
|
n.push(new XMLSerializer().serializeToString(r));
|
|
@@ -7126,11 +7227,11 @@ function Mn(e) {
|
|
|
7126
7227
|
let i = {};
|
|
7127
7228
|
return Object.keys(t).length && (i.attrs = t), n.length && (i.children = n), Object.keys(i).length ? i : void 0;
|
|
7128
7229
|
}
|
|
7129
|
-
function
|
|
7230
|
+
function Rn(e, t) {
|
|
7130
7231
|
return Array.from(e.children).find((e) => e.localName === t)?.textContent ?? void 0;
|
|
7131
7232
|
}
|
|
7132
|
-
function
|
|
7133
|
-
let n =
|
|
7233
|
+
function zn(e, t) {
|
|
7234
|
+
let n = wn(e.getAttribute("rect")), r = n.length === 4 ? Y(t, [
|
|
7134
7235
|
n[0],
|
|
7135
7236
|
n[1],
|
|
7136
7237
|
n[2],
|
|
@@ -7140,9 +7241,9 @@ function Pn(e, t) {
|
|
|
7140
7241
|
y: 0,
|
|
7141
7242
|
width: 0,
|
|
7142
7243
|
height: 0
|
|
7143
|
-
}, i =
|
|
7244
|
+
}, i = xn(e), a = yn(e.getAttribute("color") || e.getAttribute("interior-color") || void 0) ?? "#000000", o = e.getAttribute("opacity"), s = o !== null && Number.isFinite(Number(o)) ? Number(o) : 1, c = e.getAttribute("width"), l = typeof i.strokeWidth == "number" ? i.strokeWidth : c !== null && Number.isFinite(Number(c)) ? Number(c) : 1, u = (e.getAttribute("flags") || "").toLowerCase(), d = u.includes("readonly") || u.includes("locked");
|
|
7144
7245
|
return {
|
|
7145
|
-
id: e.getAttribute("name") ||
|
|
7246
|
+
id: e.getAttribute("name") || Ct(),
|
|
7146
7247
|
pageIndex: (parseInt(e.getAttribute("page") || "0", 10) || 0) + 1,
|
|
7147
7248
|
x: r.x,
|
|
7148
7249
|
y: r.y,
|
|
@@ -7153,14 +7254,14 @@ function Pn(e, t) {
|
|
|
7153
7254
|
opacity: s,
|
|
7154
7255
|
author: e.getAttribute("title") || void 0,
|
|
7155
7256
|
authorId: typeof i.authorId == "string" ? i.authorId : void 0,
|
|
7156
|
-
createdAt:
|
|
7157
|
-
modifiedAt:
|
|
7257
|
+
createdAt: vn(e.getAttribute("creationdate")),
|
|
7258
|
+
modifiedAt: vn(e.getAttribute("date")),
|
|
7158
7259
|
readOnly: d || void 0,
|
|
7159
|
-
xfdfExtras:
|
|
7260
|
+
xfdfExtras: Ln(e)
|
|
7160
7261
|
};
|
|
7161
7262
|
}
|
|
7162
|
-
function
|
|
7163
|
-
let n = e.localName.toLowerCase(), r =
|
|
7263
|
+
function Bn(e, t) {
|
|
7264
|
+
let n = e.localName.toLowerCase(), r = xn(e), i = zn(e, t), a = () => ({
|
|
7164
7265
|
...i,
|
|
7165
7266
|
type: "opaque",
|
|
7166
7267
|
opaqueKind: n,
|
|
@@ -7177,15 +7278,15 @@ function Fn(e, t) {
|
|
|
7177
7278
|
type: "ellipse"
|
|
7178
7279
|
};
|
|
7179
7280
|
case "line": {
|
|
7180
|
-
let n =
|
|
7281
|
+
let n = wn(e.getAttribute("start")), r = wn(e.getAttribute("end")), o = (e.getAttribute("head") || "None").toLowerCase(), s = (e.getAttribute("tail") || "None").toLowerCase();
|
|
7181
7282
|
if (n.length < 2 || r.length < 2) return a();
|
|
7182
|
-
let [c, l] =
|
|
7283
|
+
let [c, l] = rn(t, [{
|
|
7183
7284
|
x: n[0],
|
|
7184
7285
|
y: n[1]
|
|
7185
7286
|
}, {
|
|
7186
7287
|
x: r[0],
|
|
7187
7288
|
y: r[1]
|
|
7188
|
-
}]), u =
|
|
7289
|
+
}]), u = Fn([c, l]), d = o !== "none" || s !== "none";
|
|
7189
7290
|
return {
|
|
7190
7291
|
...i,
|
|
7191
7292
|
...u,
|
|
@@ -7194,24 +7295,24 @@ function Fn(e, t) {
|
|
|
7194
7295
|
};
|
|
7195
7296
|
}
|
|
7196
7297
|
case "ink": {
|
|
7197
|
-
let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) =>
|
|
7298
|
+
let n = Array.from(e.getElementsByTagName("*")).filter((e) => e.localName === "gesture").map((e) => rn(t, Cn(e.textContent))).filter((e) => e.length > 0);
|
|
7198
7299
|
if (n.length === 0) return a();
|
|
7199
7300
|
let r = n.flat();
|
|
7200
7301
|
return {
|
|
7201
7302
|
...i,
|
|
7202
|
-
...
|
|
7303
|
+
...Fn(r),
|
|
7203
7304
|
type: "freehand",
|
|
7204
7305
|
points: n[0],
|
|
7205
7306
|
strokes: n
|
|
7206
7307
|
};
|
|
7207
7308
|
}
|
|
7208
7309
|
case "highlight": {
|
|
7209
|
-
let n =
|
|
7310
|
+
let n = wn(e.getAttribute("coords")), r = n.length >= 8 ? on(t, n) : [{
|
|
7210
7311
|
x: i.x,
|
|
7211
7312
|
y: i.y,
|
|
7212
7313
|
width: i.width,
|
|
7213
7314
|
height: i.height
|
|
7214
|
-
}], a =
|
|
7315
|
+
}], a = sn(r);
|
|
7215
7316
|
return {
|
|
7216
7317
|
...i,
|
|
7217
7318
|
...a,
|
|
@@ -7221,9 +7322,9 @@ function Fn(e, t) {
|
|
|
7221
7322
|
};
|
|
7222
7323
|
}
|
|
7223
7324
|
case "freetext": {
|
|
7224
|
-
let n =
|
|
7325
|
+
let n = Rn(e, "contents") ?? "", a = e.getAttribute("IT") || "", o = wn(e.getAttribute("callout"));
|
|
7225
7326
|
if (a === "FreeTextCallout" || r.type === "callout" || o.length >= 4) {
|
|
7226
|
-
let e = o.length >= 4 ?
|
|
7327
|
+
let e = o.length >= 4 ? rn(t, [{
|
|
7227
7328
|
x: o[0],
|
|
7228
7329
|
y: o[1]
|
|
7229
7330
|
}, {
|
|
@@ -7258,7 +7359,7 @@ function Fn(e, t) {
|
|
|
7258
7359
|
case "text": return {
|
|
7259
7360
|
...i,
|
|
7260
7361
|
type: "note",
|
|
7261
|
-
text:
|
|
7362
|
+
text: Rn(e, "contents") ?? "",
|
|
7262
7363
|
width: 24,
|
|
7263
7364
|
height: 24
|
|
7264
7365
|
};
|
|
@@ -7268,7 +7369,7 @@ function Fn(e, t) {
|
|
|
7268
7369
|
...i,
|
|
7269
7370
|
type: "link",
|
|
7270
7371
|
linkUrl: r,
|
|
7271
|
-
text:
|
|
7372
|
+
text: Rn(e, "contents") ?? "",
|
|
7272
7373
|
color: "transparent",
|
|
7273
7374
|
strokeWidth: 0,
|
|
7274
7375
|
opacity: 1,
|
|
@@ -7276,7 +7377,7 @@ function Fn(e, t) {
|
|
|
7276
7377
|
};
|
|
7277
7378
|
}
|
|
7278
7379
|
case "stamp": {
|
|
7279
|
-
let t =
|
|
7380
|
+
let t = Rn(e, "imagedata");
|
|
7280
7381
|
return r.type === "digital_signature_placeholder" ? {
|
|
7281
7382
|
...i,
|
|
7282
7383
|
type: "digital_signature_placeholder",
|
|
@@ -7293,7 +7394,7 @@ function Fn(e, t) {
|
|
|
7293
7394
|
default: return a();
|
|
7294
7395
|
}
|
|
7295
7396
|
}
|
|
7296
|
-
function
|
|
7397
|
+
function Vn(e) {
|
|
7297
7398
|
let t = "", n = 0;
|
|
7298
7399
|
for (;;) {
|
|
7299
7400
|
let r = e.indexOf("<?xml", n);
|
|
@@ -7304,11 +7405,11 @@ function In(e) {
|
|
|
7304
7405
|
}
|
|
7305
7406
|
return t + e.slice(n);
|
|
7306
7407
|
}
|
|
7307
|
-
async function
|
|
7308
|
-
let n =
|
|
7408
|
+
async function Hn(e, t) {
|
|
7409
|
+
let n = Vn(e).trim();
|
|
7309
7410
|
if (!n) return [];
|
|
7310
7411
|
if (/<!DOCTYPE|<!ENTITY/i.test(n)) throw Error("[teamsync-pdf-viewer] invalid XFDF: DOCTYPE/ENTITY declarations are not allowed");
|
|
7311
|
-
let r = `<xfdf xmlns="${
|
|
7412
|
+
let r = `<xfdf xmlns="${pn}"><annots>${n}</annots></xfdf>`, i = new DOMParser().parseFromString(r, "application/xml"), a = i.getElementsByTagName("parsererror")[0];
|
|
7312
7413
|
if (a) throw Error(`[teamsync-pdf-viewer] invalid XFDF: ${a.textContent?.slice(0, 200)}`);
|
|
7313
7414
|
let o = /* @__PURE__ */ new Set([
|
|
7314
7415
|
"xfdf",
|
|
@@ -7318,14 +7419,14 @@ async function Ln(e, t) {
|
|
|
7318
7419
|
"ids"
|
|
7319
7420
|
]), s = Array.from(i.getElementsByTagName("*")).filter((e) => e.parentElement?.localName === "annots" && !o.has(e.localName)), c = [];
|
|
7320
7421
|
for (let e of s) {
|
|
7321
|
-
let n =
|
|
7422
|
+
let n = Bn(e, await t((parseInt(e.getAttribute("page") || "0", 10) || 0) + 1));
|
|
7322
7423
|
n && c.push(n);
|
|
7323
7424
|
}
|
|
7324
7425
|
return c;
|
|
7325
7426
|
}
|
|
7326
7427
|
//#endregion
|
|
7327
7428
|
//#region src/annotations/AnnotationManager.ts
|
|
7328
|
-
var
|
|
7429
|
+
var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class {
|
|
7329
7430
|
list = [];
|
|
7330
7431
|
past = [];
|
|
7331
7432
|
future = [];
|
|
@@ -7336,7 +7437,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7336
7437
|
canEditOthers = !1;
|
|
7337
7438
|
resolver = null;
|
|
7338
7439
|
setDocument(e) {
|
|
7339
|
-
this.resolver = e ?
|
|
7440
|
+
this.resolver = e ? $t(e) : null;
|
|
7340
7441
|
}
|
|
7341
7442
|
hasDocument() {
|
|
7342
7443
|
return this.resolver !== null;
|
|
@@ -7427,7 +7528,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7427
7528
|
addAnnotations(e, t = {}) {
|
|
7428
7529
|
let n = e.map((e) => ({
|
|
7429
7530
|
...e,
|
|
7430
|
-
id: e.id ??
|
|
7531
|
+
id: e.id ?? Ct()
|
|
7431
7532
|
}));
|
|
7432
7533
|
return this.commit([...this.list, ...n], t), n.map((e) => this.getAnnotationById(e.id)).filter((e) => !!e);
|
|
7433
7534
|
}
|
|
@@ -7451,7 +7552,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7451
7552
|
});
|
|
7452
7553
|
}
|
|
7453
7554
|
async importAnnotations(e) {
|
|
7454
|
-
let t = await
|
|
7555
|
+
let t = await Hn(e, this.requireResolver());
|
|
7455
7556
|
if (t.length === 0) return [];
|
|
7456
7557
|
let n = new Map(t.map((e) => [e.id, e])), r = this.list.map((e) => n.get(e.id) ?? e);
|
|
7457
7558
|
for (let e of t) this.list.some((t) => t.id === e.id) || r.push(e);
|
|
@@ -7463,7 +7564,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7463
7564
|
}
|
|
7464
7565
|
async exportAnnotations(e = {}) {
|
|
7465
7566
|
let t = this.requireResolver();
|
|
7466
|
-
return e.annotList ? (await Promise.all(e.annotList.map((n) =>
|
|
7567
|
+
return e.annotList ? (await Promise.all(e.annotList.map((n) => Pn(n, t, e)))).join("") : In(this.list, t, e);
|
|
7467
7568
|
}
|
|
7468
7569
|
exportAnnotationsLegacyJson() {
|
|
7469
7570
|
return JSON.stringify(this.list, null, 2);
|
|
@@ -7487,7 +7588,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7487
7588
|
}
|
|
7488
7589
|
let n = r ? t : {
|
|
7489
7590
|
...t,
|
|
7490
|
-
modifiedAt:
|
|
7591
|
+
modifiedAt: Wn()
|
|
7491
7592
|
};
|
|
7492
7593
|
c.push(n), l.push({
|
|
7493
7594
|
before: e,
|
|
@@ -7507,7 +7608,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7507
7608
|
added: s,
|
|
7508
7609
|
modified: l,
|
|
7509
7610
|
deleted: u
|
|
7510
|
-
}), this.past.length >
|
|
7611
|
+
}), this.past.length > Un && this.past.shift(), this.future = []), this.list = d;
|
|
7511
7612
|
for (let e of Array.from(this.listListeners)) try {
|
|
7512
7613
|
e();
|
|
7513
7614
|
} catch (e) {
|
|
@@ -7529,7 +7630,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7529
7630
|
}
|
|
7530
7631
|
stampNew(e, t) {
|
|
7531
7632
|
if (t) return e;
|
|
7532
|
-
let n = e.createdAt ??
|
|
7633
|
+
let n = e.createdAt ?? Wn();
|
|
7533
7634
|
return {
|
|
7534
7635
|
...e,
|
|
7535
7636
|
author: e.author ?? this.user.name,
|
|
@@ -7545,16 +7646,16 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7545
7646
|
console.error("[teamsync-pdf-viewer] annotationChanged listener threw", e);
|
|
7546
7647
|
}
|
|
7547
7648
|
}
|
|
7548
|
-
},
|
|
7649
|
+
}, Kn = () => {
|
|
7549
7650
|
throw Error("[teamsync-pdf-viewer] viewer is not mounted (was destroy() called?)");
|
|
7550
|
-
},
|
|
7651
|
+
}, qn = class {
|
|
7551
7652
|
bus;
|
|
7552
7653
|
annotationManager;
|
|
7553
7654
|
element = null;
|
|
7554
7655
|
binding = null;
|
|
7555
7656
|
unmountRoot = null;
|
|
7556
7657
|
destroyed = !1;
|
|
7557
|
-
constructor(e, t = new
|
|
7658
|
+
constructor(e, t = new Gn()) {
|
|
7558
7659
|
this.bus = e, this.annotationManager = t;
|
|
7559
7660
|
}
|
|
7560
7661
|
_bind(e, t) {
|
|
@@ -7590,7 +7691,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7590
7691
|
this.bus.off(e, t);
|
|
7591
7692
|
}
|
|
7592
7693
|
loadDocument(e) {
|
|
7593
|
-
let t = this.binding ??
|
|
7694
|
+
let t = this.binding ?? Kn();
|
|
7594
7695
|
return new Promise((n, r) => {
|
|
7595
7696
|
let i = this.bus.on("documentLoaded", (t) => {
|
|
7596
7697
|
t.url === e && (o(), n(t));
|
|
@@ -7665,16 +7766,16 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7665
7766
|
this.bus.emit("action-print");
|
|
7666
7767
|
}
|
|
7667
7768
|
async getFileData(e = {}) {
|
|
7668
|
-
let t = this.binding ??
|
|
7769
|
+
let t = this.binding ?? Kn(), n = t.getPdfDocument(), r = t.getDocumentUrl();
|
|
7669
7770
|
if (!n && !r) throw Error("No document loaded");
|
|
7670
|
-
return
|
|
7771
|
+
return Q({
|
|
7671
7772
|
getSourceBytes: async () => {
|
|
7672
7773
|
if (n) return n.getData();
|
|
7673
7774
|
let e = await fetch(r);
|
|
7674
7775
|
if (!e.ok) throw Error(`Failed to fetch document (${e.status})`);
|
|
7675
7776
|
return e.arrayBuffer();
|
|
7676
7777
|
},
|
|
7677
|
-
getPageGeometry: n ?
|
|
7778
|
+
getPageGeometry: n ? $t(n) : void 0,
|
|
7678
7779
|
annotations: this.annotationManager.getAnnotationsList(),
|
|
7679
7780
|
redactions: t.getRedactions(),
|
|
7680
7781
|
watermark: t.getWatermark(),
|
|
@@ -7733,7 +7834,7 @@ var Rn = 100, zn = () => (/* @__PURE__ */ new Date()).toISOString(), Bn = class
|
|
|
7733
7834
|
};
|
|
7734
7835
|
//#endregion
|
|
7735
7836
|
//#region src/core/print.ts
|
|
7736
|
-
async function
|
|
7837
|
+
async function Jn(e, t = {}) {
|
|
7737
7838
|
if (typeof document > "u") throw Error("[teamsync-pdf-viewer] printing needs a browser");
|
|
7738
7839
|
let n = new Blob([e], { type: "application/pdf" }), r = URL.createObjectURL(n), i = document.createElement("iframe");
|
|
7739
7840
|
i.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", i.title = t.title ?? "Print", i.setAttribute("aria-hidden", "true"), await new Promise((e, n) => {
|
|
@@ -7758,11 +7859,11 @@ async function Un(e, t = {}) {
|
|
|
7758
7859
|
}
|
|
7759
7860
|
//#endregion
|
|
7760
7861
|
//#region src/components/TeamSyncViewer.tsx
|
|
7761
|
-
var
|
|
7862
|
+
var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Xn = e.forwardRef(function(e, t) {
|
|
7762
7863
|
let { fileUrl: r, initialDoc: l, initialScale: u, initialPage: d, page: f, transientHighlights: p, plugins: m, redactions: h, regexRedactions: g, enableAnnotations: _, enableSign: v = !1, watermark: y, permissions: b, enableRedactions: x, canAddAnnotations: ee, canEditAnnotations: S, canDeleteAnnotations: C, readOnly: te = !1, assets: ne, withCredentials: re = !1, toolbar: ie = !0, sidebars: w = !0, leftPanelOpen: T = !0, className: ae, style: oe } = e, E = s(e);
|
|
7763
7864
|
E.current = e;
|
|
7764
|
-
let D = s(null), O = o(() => new
|
|
7765
|
-
se.current ||= new
|
|
7865
|
+
let D = s(null), O = o(() => new Yt(), []), k = o(() => new Gn(), []), se = s(null);
|
|
7866
|
+
se.current ||= new qn(O, k);
|
|
7766
7867
|
let A = se.current;
|
|
7767
7868
|
a(t, () => A, [A]);
|
|
7768
7869
|
let ce = r ?? l, [le, ue] = c(ce), [de, fe] = c(0);
|
|
@@ -7866,7 +7967,7 @@ var Wn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
7866
7967
|
O.on("action-tool-changed", (e) => O.emit("toolChanged", { tool: e?.tool ?? null })),
|
|
7867
7968
|
O.on("action-print", async () => {
|
|
7868
7969
|
try {
|
|
7869
|
-
await
|
|
7970
|
+
await Jn(await A.getFileData(), { title: E.current.fileName });
|
|
7870
7971
|
} catch (e) {
|
|
7871
7972
|
console.error("[teamsync-pdf-viewer] print failed", e), O.emit("action-print-error", { error: e });
|
|
7872
7973
|
}
|
|
@@ -7884,7 +7985,7 @@ var Wn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
7884
7985
|
O.on("action-process-digital-signature", async (e) => {
|
|
7885
7986
|
try {
|
|
7886
7987
|
let { pageIndex: t, x: n, y: r, width: i, height: a } = e, o = {
|
|
7887
|
-
id:
|
|
7988
|
+
id: Yn(),
|
|
7888
7989
|
type: "digital_signature_placeholder",
|
|
7889
7990
|
pageIndex: t,
|
|
7890
7991
|
x: n,
|
|
@@ -8044,9 +8145,9 @@ var Wn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8044
8145
|
setRightSidebarOpen: j,
|
|
8045
8146
|
sidebarTab: ye,
|
|
8046
8147
|
scale: M,
|
|
8047
|
-
onZoomIn: () => xe((e) =>
|
|
8048
|
-
onZoomOut: () => xe((e) =>
|
|
8049
|
-
onZoomSet: (e) => xe(
|
|
8148
|
+
onZoomIn: () => xe((e) => gt(e)),
|
|
8149
|
+
onZoomOut: () => xe((e) => _t(e)),
|
|
8150
|
+
onZoomSet: (e) => xe(vt(e)),
|
|
8050
8151
|
onOpenFile: nt,
|
|
8051
8152
|
onDownload: () => O.emit("action-download"),
|
|
8052
8153
|
onFullScreen: () => {
|
|
@@ -8093,7 +8194,7 @@ var Wn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8093
8194
|
minHeight: 0,
|
|
8094
8195
|
overflow: "hidden"
|
|
8095
8196
|
},
|
|
8096
|
-
children: /* @__PURE__ */ F(
|
|
8197
|
+
children: /* @__PURE__ */ F(Kt, {
|
|
8097
8198
|
leftSidebarOpen: w && ge,
|
|
8098
8199
|
rightSidebarOpen: w && ve,
|
|
8099
8200
|
sidebarTab: ye,
|
|
@@ -8128,22 +8229,22 @@ var Wn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8128
8229
|
permissions: P
|
|
8129
8230
|
})
|
|
8130
8231
|
}),
|
|
8131
|
-
Se && /* @__PURE__ */ F(
|
|
8232
|
+
Se && /* @__PURE__ */ F(Jt, {
|
|
8132
8233
|
onClose: () => Ce(!1),
|
|
8133
8234
|
watermarkText: je,
|
|
8134
8235
|
setWatermarkText: Me
|
|
8135
8236
|
}),
|
|
8136
|
-
N && /* @__PURE__ */ F(
|
|
8237
|
+
N && /* @__PURE__ */ F(K, { onClose: () => we(!1) })
|
|
8137
8238
|
]
|
|
8138
8239
|
})
|
|
8139
8240
|
});
|
|
8140
8241
|
});
|
|
8141
8242
|
//#endregion
|
|
8142
8243
|
//#region src/core/createWebViewer.tsx
|
|
8143
|
-
function
|
|
8244
|
+
function Zn(e, t) {
|
|
8144
8245
|
return typeof window > "u" || typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() requires a browser environment.")) : t ? new Promise((n) => {
|
|
8145
8246
|
let r = u.createRoot(t), { path: i, ...a } = e;
|
|
8146
|
-
r.render(/* @__PURE__ */ F(
|
|
8247
|
+
r.render(/* @__PURE__ */ F(Xn, {
|
|
8147
8248
|
...a,
|
|
8148
8249
|
style: {
|
|
8149
8250
|
width: "100%",
|
|
@@ -8155,8 +8256,8 @@ function Kn(e, t) {
|
|
|
8155
8256
|
}));
|
|
8156
8257
|
}) : Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() needs a container element."));
|
|
8157
8258
|
}
|
|
8158
|
-
var
|
|
8259
|
+
var Qn = Zn;
|
|
8159
8260
|
//#endregion
|
|
8160
|
-
export {
|
|
8261
|
+
export { Gn as AnnotationManager, Tt as DEFAULT_FALLBACK_DIMS, cn as MAX_EXPORT_BYTES, dt as MAX_SCALE, ut as MIN_SCALE, Xn as TeamSyncViewer, Yt as ViewerBus, Qn as WebViewer, qn as WebViewerInstance, pn as XFDF_NS, Pn as annotationToXfdfFragment, In as annotationsToXfdf, Q as buildPdfBytes, gt as calculateNextZoomIn, _t as calculateNextZoomOut, bt as calculateScrollCompensation, vt as clampScale, Gt as computeCanvasPixelDiff, zt as computePageDiffBoxes, Dt as computeRowLayout, Ht as computeTextDiff, Ot as configurePdfAssets, $t as createGeometryResolver, Qt as createPageGeometry, Zn as createWebViewer, Et as estimatePageDimensions, Rt as extractWordsFromPage, vn as fromPdfDate, tn as fromPdfPoint, J as geometryFromPage, G as getPdfAssetPaths, U as hasDimensionMismatch, kt as isWorkerConfigured, Ct as newAnnotationId, Hn as parseXfdf, Mt as pdfjsVersion, Jn as printPdfBytes, on as quadPointsToRects, Y as rectFromPdf, nn as rectToPdf, an as rectToQuadPoints, tt as searchPdfText, Wt as tintCanvas, _n as toPdfDate, en as toPdfPoint, nt as usePdfSearch };
|
|
8161
8262
|
|
|
8162
8263
|
//# sourceMappingURL=teamsync-pdf-viewer.js.map
|