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