teamsync-pdf-viewer 1.3.3 → 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 +8 -0
- package/dist/src/utils/zoomUtils.d.ts +5 -3
- package/dist/teamsync-pdf-viewer.js +351 -348
- 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)");
|
|
@@ -1986,21 +1988,21 @@ function lt(e) {
|
|
|
1986
1988
|
}
|
|
1987
1989
|
//#endregion
|
|
1988
1990
|
//#region src/utils/zoomUtils.ts
|
|
1989
|
-
var ut = .1, dt = 10, ft = () => typeof navigator < "u" && (/
|
|
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
|
}
|
|
2003
|
-
function
|
|
2005
|
+
function xt(e) {
|
|
2004
2006
|
let { prevScale: t, newScale: n, containerWidth: r, containerHeight: i, currentScrollLeft: a, currentScrollTop: o, basePageWidth: s, focusPoint: c, isProgrammatic: l = !1 } = e;
|
|
2005
2007
|
if (l) return {
|
|
2006
2008
|
scrollLeft: 0,
|
|
@@ -2019,7 +2021,7 @@ function bt(e) {
|
|
|
2019
2021
|
}
|
|
2020
2022
|
//#endregion
|
|
2021
2023
|
//#region src/components/PageRenderer.tsx
|
|
2022
|
-
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 }) {
|
|
2023
2025
|
let E = s(oe);
|
|
2024
2026
|
E.current = oe;
|
|
2025
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;
|
|
@@ -2027,89 +2029,90 @@ function xt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2027
2029
|
A.current = !1;
|
|
2028
2030
|
}, [n, t]), i(() => {
|
|
2029
2031
|
let e = !1, i = null, o = async () => {
|
|
2030
|
-
if (!
|
|
2031
|
-
|
|
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) {
|
|
2032
2043
|
try {
|
|
2033
|
-
|
|
2044
|
+
o.cleanup?.();
|
|
2034
2045
|
} catch {}
|
|
2035
|
-
|
|
2046
|
+
return;
|
|
2036
2047
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
f.save(), f.setTransform(1, 0, 0, 1, 0, 0);
|
|
2066
|
-
let e = a % 180 == 0 ? m : h, n = a % 180 == 0 ? h : m;
|
|
2067
|
-
for (let i of T) if (i.pageIndex === t) {
|
|
2068
|
-
let t = H(i.x, i.y, i.width, i.height, a, e, n), o = t.x * l, s = t.y * l, c = t.width * l, u = t.height * l;
|
|
2069
|
-
i.status === "applied" || i.status === void 0 ? (f.fillStyle = "#000000", f.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u))) : (f.fillStyle = "rgba(0, 0, 0, 0.45)", f.fillRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u)), f.lineWidth = Math.max(1, l / (r || 1) * 2), f.strokeStyle = "#dc2626", f.strokeRect(Math.floor(o), Math.floor(s), Math.ceil(c), Math.ceil(u)));
|
|
2070
|
-
}
|
|
2071
|
-
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)));
|
|
2072
2076
|
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
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);
|
|
2093
2098
|
}
|
|
2094
|
-
f.restore();
|
|
2095
|
-
}
|
|
2096
|
-
let _ = D.current;
|
|
2097
|
-
if (_ && !e) {
|
|
2098
|
-
_.width = d.width, _.height = d.height;
|
|
2099
|
-
let e = _.getContext("2d");
|
|
2100
|
-
e && e.drawImage(d, 0, 0), A.current = !0, E.current?.(t);
|
|
2101
|
-
}
|
|
2102
|
-
d.width = 0, d.height = 0;
|
|
2103
|
-
} catch (e) {
|
|
2104
|
-
e?.name !== "RenderingCancelledException" && console.error(`Page ${t} render failed:`, e);
|
|
2105
|
-
} finally {
|
|
2106
|
-
if (se.current) {
|
|
2107
|
-
try {
|
|
2108
|
-
se.current.cleanup?.();
|
|
2109
|
-
} catch {}
|
|
2110
|
-
se.current = null;
|
|
2111
2099
|
}
|
|
2100
|
+
p.restore();
|
|
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);
|
|
2112
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);
|
|
2113
2116
|
}
|
|
2114
2117
|
}, s = A.current ? 150 : 0;
|
|
2115
2118
|
return i = setTimeout(o, s), () => {
|
|
@@ -2712,7 +2715,7 @@ function xt({ pageNum: t, pdfDoc: n, scale: r, rotation: a, containerWidth: o, c
|
|
|
2712
2715
|
]
|
|
2713
2716
|
});
|
|
2714
2717
|
}
|
|
2715
|
-
var St = e.memo(
|
|
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);
|
|
2716
2719
|
//#endregion
|
|
2717
2720
|
//#region src/annotations/ids.ts
|
|
2718
2721
|
function Ct() {
|
|
@@ -2792,7 +2795,7 @@ function Dt(e, t, n, r = 16) {
|
|
|
2792
2795
|
total: o
|
|
2793
2796
|
};
|
|
2794
2797
|
}
|
|
2795
|
-
function
|
|
2798
|
+
function W(e, t, n = .5) {
|
|
2796
2799
|
if (e.length !== t.length) return !0;
|
|
2797
2800
|
for (let r = 0; r < e.length; r++) {
|
|
2798
2801
|
let i = e[r], a = t[r];
|
|
@@ -2802,30 +2805,30 @@ function U(e, t, n = .5) {
|
|
|
2802
2805
|
}
|
|
2803
2806
|
//#endregion
|
|
2804
2807
|
//#region src/core/pdfAssets.ts
|
|
2805
|
-
var
|
|
2808
|
+
var G = {};
|
|
2806
2809
|
function Ot(e) {
|
|
2807
|
-
|
|
2808
|
-
...
|
|
2810
|
+
G = {
|
|
2811
|
+
...G,
|
|
2809
2812
|
...e
|
|
2810
2813
|
}, e.workerSrc && (L.GlobalWorkerOptions.workerSrc = e.workerSrc);
|
|
2811
2814
|
}
|
|
2812
|
-
function G() {
|
|
2813
|
-
return W;
|
|
2814
|
-
}
|
|
2815
2815
|
function kt() {
|
|
2816
|
-
return
|
|
2816
|
+
return G;
|
|
2817
2817
|
}
|
|
2818
2818
|
function At() {
|
|
2819
|
-
|
|
2819
|
+
return !!(G.workerSrc || L.GlobalWorkerOptions.workerSrc);
|
|
2820
2820
|
}
|
|
2821
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>.");
|
|
2823
|
+
}
|
|
2824
|
+
function Mt() {
|
|
2822
2825
|
let e = {};
|
|
2823
|
-
return
|
|
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;
|
|
2824
2827
|
}
|
|
2825
|
-
var
|
|
2828
|
+
var Nt = L.version;
|
|
2826
2829
|
//#endregion
|
|
2827
2830
|
//#region src/components/DiffHighlightOverlay.tsx
|
|
2828
|
-
function
|
|
2831
|
+
function Pt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onSelectDiff: i }) {
|
|
2829
2832
|
let [a, o] = c(null);
|
|
2830
2833
|
if (!e || e.length === 0) return null;
|
|
2831
2834
|
let s = e.filter((e) => n === "deletions" ? e.type === "deletion" || e.type === "modification" : n !== "additions" || e.type === "addition" || e.type === "modification");
|
|
@@ -2930,7 +2933,7 @@ function Nt({ boxes: e, scale: t, colorScheme: n = "all", selectedDiffId: r, onS
|
|
|
2930
2933
|
}
|
|
2931
2934
|
//#endregion
|
|
2932
2935
|
//#region src/components/SideBySideViewer.tsx
|
|
2933
|
-
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 }) {
|
|
2934
2937
|
let y = s(null), b = s(null), x = s(!1);
|
|
2935
2938
|
i(() => {
|
|
2936
2939
|
let e = y.current, t = b.current;
|
|
@@ -3062,7 +3065,7 @@ function Pt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3062
3065
|
watermark: f,
|
|
3063
3066
|
watermarkText: p,
|
|
3064
3067
|
redactions: m
|
|
3065
|
-
}), /* @__PURE__ */ F(
|
|
3068
|
+
}), /* @__PURE__ */ F(Pt, {
|
|
3066
3069
|
boxes: h,
|
|
3067
3070
|
scale: r,
|
|
3068
3071
|
colorScheme: "deletions",
|
|
@@ -3126,7 +3129,7 @@ function Pt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3126
3129
|
watermark: f,
|
|
3127
3130
|
watermarkText: p,
|
|
3128
3131
|
redactions: m
|
|
3129
|
-
}), /* @__PURE__ */ F(
|
|
3132
|
+
}), /* @__PURE__ */ F(Pt, {
|
|
3130
3133
|
boxes: g,
|
|
3131
3134
|
scale: r,
|
|
3132
3135
|
colorScheme: "additions",
|
|
@@ -3139,7 +3142,7 @@ function Pt({ pdfDocA: e, pdfDocB: t, pageNum: n, scale: r, rotation: a, basePag
|
|
|
3139
3142
|
}
|
|
3140
3143
|
//#endregion
|
|
3141
3144
|
//#region src/components/CompareToolbar.tsx
|
|
3142
|
-
function
|
|
3145
|
+
function It({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r, onPrevDiff: i, onNextDiff: a, onExit: o }) {
|
|
3143
3146
|
let { mode: s, colorA: c, colorB: l, showCurtain: u, diffItems: d, currentDiffIndex: f } = e;
|
|
3144
3147
|
return /* @__PURE__ */ I("div", {
|
|
3145
3148
|
style: {
|
|
@@ -3395,7 +3398,7 @@ function Ft({ compareState: e, onSetMode: t, onSetColors: n, onToggleCurtain: r,
|
|
|
3395
3398
|
}
|
|
3396
3399
|
//#endregion
|
|
3397
3400
|
//#region src/components/DiffSummarySidebar.tsx
|
|
3398
|
-
function
|
|
3401
|
+
function Lt({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSelectDiff: i, onJumpToPage: a }) {
|
|
3399
3402
|
return e ? /* @__PURE__ */ I("div", {
|
|
3400
3403
|
style: {
|
|
3401
3404
|
width: "320px",
|
|
@@ -3626,7 +3629,7 @@ function It({ isOpen: e, diffItems: t, textDiffs: n, currentDiffIndex: r, onSele
|
|
|
3626
3629
|
}
|
|
3627
3630
|
//#endregion
|
|
3628
3631
|
//#region src/components/CompareCurtainSlider.tsx
|
|
3629
|
-
function
|
|
3632
|
+
function Rt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
3630
3633
|
let [r, a] = c(!1), o = s(null);
|
|
3631
3634
|
return i(() => {
|
|
3632
3635
|
let e = (e) => {
|
|
@@ -3683,7 +3686,7 @@ function Lt({ positionPercent: e, onChangePosition: t, containerRef: n }) {
|
|
|
3683
3686
|
}
|
|
3684
3687
|
//#endregion
|
|
3685
3688
|
//#region src/utils/pdfDiffEngine.ts
|
|
3686
|
-
async function
|
|
3689
|
+
async function zt(e) {
|
|
3687
3690
|
let t = e.getViewport({
|
|
3688
3691
|
scale: 1,
|
|
3689
3692
|
rotation: e.rotate
|
|
@@ -3706,8 +3709,8 @@ async function Rt(e) {
|
|
|
3706
3709
|
}
|
|
3707
3710
|
return r;
|
|
3708
3711
|
}
|
|
3709
|
-
async function
|
|
3710
|
-
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);
|
|
3711
3714
|
f[1] = 0;
|
|
3712
3715
|
let p = [];
|
|
3713
3716
|
for (let e = 0; e <= d; e++) {
|
|
@@ -3730,7 +3733,7 @@ async function zt(e, t, n) {
|
|
|
3730
3733
|
e > 0 && (m === i ? (_.push(h - 1), h--) : h === a && (g.push(m - 1), m--));
|
|
3731
3734
|
}
|
|
3732
3735
|
g.reverse(), _.reverse();
|
|
3733
|
-
let v =
|
|
3736
|
+
let v = Vt(g.map((e) => a[e]), n, "deletion"), y = Vt(_.map((e) => o[e]), n, "addition"), b = [];
|
|
3734
3737
|
for (let e of v) b.push({
|
|
3735
3738
|
id: e.id,
|
|
3736
3739
|
pageIndex: n,
|
|
@@ -3757,16 +3760,16 @@ async function zt(e, t, n) {
|
|
|
3757
3760
|
summary: b
|
|
3758
3761
|
};
|
|
3759
3762
|
}
|
|
3760
|
-
function
|
|
3763
|
+
function Vt(e, t, n) {
|
|
3761
3764
|
if (e.length === 0) return [];
|
|
3762
3765
|
let r = [], i = [e[0]];
|
|
3763
3766
|
for (let a = 1; a < e.length; a++) {
|
|
3764
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;
|
|
3765
|
-
c && l ? i.push(s) : (r.push(
|
|
3768
|
+
c && l ? i.push(s) : (r.push(Ht(i, t, n, r.length + 1)), i = [s]);
|
|
3766
3769
|
}
|
|
3767
|
-
return i.length > 0 && r.push(
|
|
3770
|
+
return i.length > 0 && r.push(Ht(i, t, n, r.length + 1)), r;
|
|
3768
3771
|
}
|
|
3769
|
-
function
|
|
3772
|
+
function Ht(e, t, n, r) {
|
|
3770
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(" ");
|
|
3771
3774
|
return {
|
|
3772
3775
|
id: `diff-box-${t}-${n}-${r}-${Math.round(i)}-${Math.round(a)}`,
|
|
@@ -3779,7 +3782,7 @@ function Vt(e, t, n, r) {
|
|
|
3779
3782
|
height: s - a + 2
|
|
3780
3783
|
};
|
|
3781
3784
|
}
|
|
3782
|
-
function
|
|
3785
|
+
function Ut(e, t, n) {
|
|
3783
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);
|
|
3784
3787
|
c[1] = 0;
|
|
3785
3788
|
let l = [];
|
|
@@ -3790,7 +3793,7 @@ function Ht(e, t, n) {
|
|
|
3790
3793
|
u = t === -e || t !== e && c[t - 1 + s] < c[t + 1 + s] ? c[t + 1 + s] : c[t - 1 + s] + 1;
|
|
3791
3794
|
let d = u - t;
|
|
3792
3795
|
for (; u < a && d < o && r[u] === i[d];) u++, d++;
|
|
3793
|
-
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);
|
|
3794
3797
|
}
|
|
3795
3798
|
}
|
|
3796
3799
|
return [{
|
|
@@ -3803,7 +3806,7 @@ function Ht(e, t, n) {
|
|
|
3803
3806
|
pageIndex: n
|
|
3804
3807
|
}];
|
|
3805
3808
|
}
|
|
3806
|
-
function
|
|
3809
|
+
function Wt(e, t, n, r) {
|
|
3807
3810
|
let i = t.length, a = n.length, o = t.length + n.length, s = [];
|
|
3808
3811
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
3809
3812
|
let c = e[r], l = i - a, u;
|
|
@@ -3829,10 +3832,10 @@ function Ut(e, t, n, r) {
|
|
|
3829
3832
|
});
|
|
3830
3833
|
return c;
|
|
3831
3834
|
}
|
|
3832
|
-
function
|
|
3835
|
+
function Gt(e, t, n, r, i = .75) {
|
|
3833
3836
|
e.save(), e.globalCompositeOperation = "source-atop", e.fillStyle = r, e.globalAlpha = i, e.fillRect(0, 0, t, n), e.restore();
|
|
3834
3837
|
}
|
|
3835
|
-
function
|
|
3838
|
+
function Kt(e, t, n, r) {
|
|
3836
3839
|
let i = Math.min(e.width, t.width), a = Math.min(e.height, t.height);
|
|
3837
3840
|
if (i === 0 || a === 0) return [];
|
|
3838
3841
|
let o = e.getContext("2d"), s = t.getContext("2d");
|
|
@@ -3859,7 +3862,7 @@ function Gt(e, t, n, r) {
|
|
|
3859
3862
|
}
|
|
3860
3863
|
//#endregion
|
|
3861
3864
|
//#region src/components/DocumentViewer.tsx
|
|
3862
|
-
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 }) {
|
|
3863
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({
|
|
3864
3867
|
isActive: !1,
|
|
3865
3868
|
mode: "overlay",
|
|
@@ -3890,9 +3893,9 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3890
3893
|
Be.current = g;
|
|
3891
3894
|
let Ve = n(async (e) => {
|
|
3892
3895
|
try {
|
|
3893
|
-
|
|
3896
|
+
jt(), Be.current && Ot(Be.current);
|
|
3894
3897
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
3895
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
3898
|
+
h && (t.withCredentials = !0), Object.assign(t, Mt());
|
|
3896
3899
|
let n = await L.getDocument(t).promise;
|
|
3897
3900
|
xe(n), ze.current.onDocumentLoaded?.(n, typeof e == "string" ? e : "documentA.pdf");
|
|
3898
3901
|
} catch (e) {
|
|
@@ -3900,9 +3903,9 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3900
3903
|
}
|
|
3901
3904
|
}, [h]), V = n(async (e) => {
|
|
3902
3905
|
try {
|
|
3903
|
-
|
|
3906
|
+
jt(), Be.current && Ot(Be.current);
|
|
3904
3907
|
let t = typeof e == "string" ? { url: e } : { data: e };
|
|
3905
|
-
h && (t.withCredentials = !0), Object.assign(t,
|
|
3908
|
+
h && (t.withCredentials = !0), Object.assign(t, Mt());
|
|
3906
3909
|
let n = await L.getDocument(t).promise;
|
|
3907
3910
|
P(n), z((e) => ({
|
|
3908
3911
|
...e,
|
|
@@ -3925,7 +3928,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3925
3928
|
try {
|
|
3926
3929
|
let t = Math.min(M.numPages, ke.numPages), n = [], r = {}, i = {};
|
|
3927
3930
|
for (let a = 1; a <= t; a++) {
|
|
3928
|
-
let { diffsA: t, diffsB: o, summary: s } = await
|
|
3931
|
+
let { diffsA: t, diffsB: o, summary: s } = await Bt(M, ke, a);
|
|
3929
3932
|
if (e) return;
|
|
3930
3933
|
r[a] = t, i[a] = o, n = n.concat(s);
|
|
3931
3934
|
}
|
|
@@ -3935,7 +3938,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
3935
3938
|
pageDiffsA: r,
|
|
3936
3939
|
pageDiffsB: i
|
|
3937
3940
|
}));
|
|
3938
|
-
let a = await M.getPage(N), o = await ke.getPage(Math.min(N, ke.numPages)), s = await a.getTextContent(), c = await o.getTextContent(), l =
|
|
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);
|
|
3939
3942
|
e || Fe(l);
|
|
3940
3943
|
} catch (e) {
|
|
3941
3944
|
console.error("Error computing document diffs:", e);
|
|
@@ -4045,9 +4048,9 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4045
4048
|
t(), window.removeEventListener("action-go-to-page", n);
|
|
4046
4049
|
};
|
|
4047
4050
|
}, [ye, _t]);
|
|
4048
|
-
let
|
|
4051
|
+
let vt = (e) => {
|
|
4049
4052
|
we(e.pageIndex), Ge(e), _t(e.pageIndex);
|
|
4050
|
-
},
|
|
4053
|
+
}, bt = n((e, t) => {
|
|
4051
4054
|
let n = t || R.diffItems[e];
|
|
4052
4055
|
if (z((t) => ({
|
|
4053
4056
|
...t,
|
|
@@ -4072,17 +4075,17 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4072
4075
|
ct.tops
|
|
4073
4076
|
]), U = l(u.subscribe, u.getSnapshot, u.getSnapshot), [W, G] = c("pan");
|
|
4074
4077
|
i(() => {
|
|
4075
|
-
a === "Annotate" ? (G("highlight"),
|
|
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");
|
|
4076
4079
|
}, [a]), i(() => {
|
|
4077
4080
|
ye.emit("action-tool-changed", { tool: W });
|
|
4078
4081
|
}, [W, ye]);
|
|
4079
|
-
let [kt,
|
|
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({
|
|
4080
4083
|
x: 0,
|
|
4081
4084
|
y: 0
|
|
4082
4085
|
}), [q, Xt] = c({
|
|
4083
4086
|
x: 0,
|
|
4084
4087
|
y: 0
|
|
4085
|
-
}), [Zt, Qt] = c([]), [J, $t] = c(null), [en, tn] = c(""), nn = s(null), [Y, X] = c(null), [rn, an] = c(null), [on, sn] = c(!1),
|
|
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);
|
|
4086
4089
|
Re("action-set-tool", (e) => G(e?.tool ?? null));
|
|
4087
4090
|
let ln = s({
|
|
4088
4091
|
vx: null,
|
|
@@ -4098,7 +4101,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4098
4101
|
if (!n) return;
|
|
4099
4102
|
let r = dn.current || !fn.current || On.current !== M;
|
|
4100
4103
|
fn.current = !0, dn.current = !1;
|
|
4101
|
-
let i =
|
|
4104
|
+
let i = xt({
|
|
4102
4105
|
prevScale: e,
|
|
4103
4106
|
newScale: t,
|
|
4104
4107
|
containerWidth: n.clientWidth,
|
|
@@ -4125,7 +4128,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4125
4128
|
t.preventDefault();
|
|
4126
4129
|
let n = e.getBoundingClientRect(), r = t.clientX, i = t.clientY, a = Math.exp(-t.deltaY * .002);
|
|
4127
4130
|
C((e) => {
|
|
4128
|
-
let t =
|
|
4131
|
+
let t = yt(e * a);
|
|
4129
4132
|
return t !== e && (ln.current = {
|
|
4130
4133
|
vx: r - n.left,
|
|
4131
4134
|
vy: i - n.top
|
|
@@ -4175,12 +4178,12 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4175
4178
|
if (!t && !J) {
|
|
4176
4179
|
if (et(e, De("COPY")) && Y) {
|
|
4177
4180
|
let t = U.find((e) => e.id === Y);
|
|
4178
|
-
t && (e.preventDefault(),
|
|
4181
|
+
t && (e.preventDefault(), Z.current = t);
|
|
4179
4182
|
return;
|
|
4180
4183
|
}
|
|
4181
|
-
if (et(e, De("PASTE")) &&
|
|
4184
|
+
if (et(e, De("PASTE")) && Z.current) {
|
|
4182
4185
|
e.preventDefault();
|
|
4183
|
-
let t =
|
|
4186
|
+
let t = Z.current, n = {
|
|
4184
4187
|
...t,
|
|
4185
4188
|
id: Ct(),
|
|
4186
4189
|
pageIndex: N,
|
|
@@ -4232,7 +4235,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4232
4235
|
i(() => {
|
|
4233
4236
|
ze.current.onRedactionsChange?.(yn);
|
|
4234
4237
|
}, [yn]);
|
|
4235
|
-
let
|
|
4238
|
+
let bn = o(() => yn.filter((e) => e.status === "pending").length, [yn]), $ = n(() => {
|
|
4236
4239
|
Ee((e) => e.filter((e) => e.status === "applied")), gn((e) => e.filter((e) => e.status === "applied"));
|
|
4237
4240
|
}, []), xn = n((e) => {
|
|
4238
4241
|
Ee((t) => t.filter((t) => t !== e && t.id !== e.id)), gn((t) => t.filter((t) => t !== e && t.id !== e.id));
|
|
@@ -4246,10 +4249,10 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4246
4249
|
let e = d, t = !1, n = null;
|
|
4247
4250
|
return (async () => {
|
|
4248
4251
|
try {
|
|
4249
|
-
Be.current && Ot(Be.current),
|
|
4252
|
+
Be.current && Ot(Be.current), jt(), n = L.getDocument({
|
|
4250
4253
|
url: e,
|
|
4251
4254
|
withCredentials: h,
|
|
4252
|
-
...
|
|
4255
|
+
...Mt()
|
|
4253
4256
|
});
|
|
4254
4257
|
let r = await n.promise;
|
|
4255
4258
|
if (t) return;
|
|
@@ -4364,7 +4367,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4364
4367
|
if (!j.current || !e.width) return;
|
|
4365
4368
|
let t = j.current.clientWidth - 48;
|
|
4366
4369
|
if (t > 0 && e.width > 0) {
|
|
4367
|
-
let n =
|
|
4370
|
+
let n = yt(t / e.width);
|
|
4368
4371
|
dn.current = !0, j.current && (N === 1 || j.current.scrollTop <= 1) && (j.current.scrollTop = 0, j.current.scrollLeft = 0), C(n);
|
|
4369
4372
|
}
|
|
4370
4373
|
}, [
|
|
@@ -4376,7 +4379,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4376
4379
|
if (!j.current || !e.width || !e.height) return;
|
|
4377
4380
|
let t = j.current.clientWidth - 48, n = j.current.clientHeight - 48;
|
|
4378
4381
|
if (t > 0 && n > 0 && e.width > 0 && e.height > 0) {
|
|
4379
|
-
let r = t / e.width, i = n / e.height, a =
|
|
4382
|
+
let r = t / e.width, i = n / e.height, a = yt(Math.min(r, i));
|
|
4380
4383
|
dn.current = !0, j.current && (N === 1 || j.current.scrollTop <= 1) && (j.current.scrollTop = 0, j.current.scrollLeft = 0), C(a);
|
|
4381
4384
|
}
|
|
4382
4385
|
}, [
|
|
@@ -4408,14 +4411,14 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4408
4411
|
}), W === "freehand" ? (Gt(!0), Qt([{
|
|
4409
4412
|
x: n,
|
|
4410
4413
|
y: r
|
|
4411
|
-
}]),
|
|
4414
|
+
}]), qt(t)) : ([
|
|
4412
4415
|
"rectangle",
|
|
4413
4416
|
"ellipse",
|
|
4414
4417
|
"line",
|
|
4415
4418
|
"arrow",
|
|
4416
4419
|
"highlight",
|
|
4417
4420
|
"redaction"
|
|
4418
|
-
].includes(W) || ["callout", "link"].includes(W)) && (Gt(!0),
|
|
4421
|
+
].includes(W) || ["callout", "link"].includes(W)) && (Gt(!0), qt(t));
|
|
4419
4422
|
}, Pn = () => {
|
|
4420
4423
|
if (J && en.trim()) {
|
|
4421
4424
|
if (J.annId) Q(U.map((e) => e.id === J.annId ? {
|
|
@@ -4435,7 +4438,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4435
4438
|
text: en,
|
|
4436
4439
|
points: J.points,
|
|
4437
4440
|
color: kt,
|
|
4438
|
-
strokeWidth:
|
|
4441
|
+
strokeWidth: Nt,
|
|
4439
4442
|
opacity: Vt
|
|
4440
4443
|
}]);
|
|
4441
4444
|
}
|
|
@@ -4471,7 +4474,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4471
4474
|
strokeWidth: 0,
|
|
4472
4475
|
opacity: 1,
|
|
4473
4476
|
text: ""
|
|
4474
|
-
}]), Gt(!1),
|
|
4477
|
+
}]), Gt(!1), qt(null), cn.current = !0, X(s), sn(!0), G(null);
|
|
4475
4478
|
return;
|
|
4476
4479
|
}
|
|
4477
4480
|
(W === "text" || W === "note") && (J && Pn(), $t({
|
|
@@ -4482,7 +4485,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4482
4485
|
}), tn(""));
|
|
4483
4486
|
return;
|
|
4484
4487
|
}
|
|
4485
|
-
if (Wt && (Gt(!1),
|
|
4488
|
+
if (Wt && (Gt(!1), qt(null), W)) {
|
|
4486
4489
|
if (W === "freehand") {
|
|
4487
4490
|
if (Zt.length > 2) {
|
|
4488
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);
|
|
@@ -4497,7 +4500,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4497
4500
|
points: [...Zt],
|
|
4498
4501
|
strokes: [[...Zt]],
|
|
4499
4502
|
color: kt,
|
|
4500
|
-
strokeWidth:
|
|
4503
|
+
strokeWidth: Nt,
|
|
4501
4504
|
opacity: Vt
|
|
4502
4505
|
}]);
|
|
4503
4506
|
}
|
|
@@ -4541,7 +4544,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4541
4544
|
height: n,
|
|
4542
4545
|
points: a,
|
|
4543
4546
|
color: kt,
|
|
4544
|
-
strokeWidth:
|
|
4547
|
+
strokeWidth: Nt,
|
|
4545
4548
|
opacity: Vt
|
|
4546
4549
|
}]);
|
|
4547
4550
|
}
|
|
@@ -4579,7 +4582,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4579
4582
|
annId: n.id,
|
|
4580
4583
|
points: n.points,
|
|
4581
4584
|
pageIndex: n.pageIndex
|
|
4582
|
-
}), tn(n.text || ""), n.color &&
|
|
4585
|
+
}), tn(n.text || ""), n.color && At(n.color);
|
|
4583
4586
|
} else if (n && n.type === "link") {
|
|
4584
4587
|
if (ve?.canEditAnnotations === !1 || !u.canEdit(n)) {
|
|
4585
4588
|
X(e);
|
|
@@ -4634,7 +4637,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4634
4637
|
overflow: "hidden"
|
|
4635
4638
|
},
|
|
4636
4639
|
children: [
|
|
4637
|
-
R.isActive && /* @__PURE__ */ F(
|
|
4640
|
+
R.isActive && /* @__PURE__ */ F(It, {
|
|
4638
4641
|
compareState: R,
|
|
4639
4642
|
onSetMode: (e) => z((t) => ({
|
|
4640
4643
|
...t,
|
|
@@ -4652,12 +4655,12 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4652
4655
|
onPrevDiff: () => {
|
|
4653
4656
|
if (R.diffItems.length === 0) return;
|
|
4654
4657
|
let e = (R.currentDiffIndex - 1 + R.diffItems.length) % R.diffItems.length;
|
|
4655
|
-
|
|
4658
|
+
bt(e);
|
|
4656
4659
|
},
|
|
4657
4660
|
onNextDiff: () => {
|
|
4658
4661
|
if (R.diffItems.length === 0) return;
|
|
4659
4662
|
let e = (R.currentDiffIndex + 1) % R.diffItems.length;
|
|
4660
|
-
|
|
4663
|
+
bt(e);
|
|
4661
4664
|
},
|
|
4662
4665
|
onExit: () => {
|
|
4663
4666
|
z((e) => ({
|
|
@@ -4677,35 +4680,35 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4677
4680
|
height: "40px"
|
|
4678
4681
|
},
|
|
4679
4682
|
children: [
|
|
4680
|
-
/* @__PURE__ */ F(
|
|
4683
|
+
/* @__PURE__ */ F(Jt, {
|
|
4681
4684
|
icon: /* @__PURE__ */ F(k, { size: 16 }),
|
|
4682
4685
|
active: W === "highlight",
|
|
4683
4686
|
onClick: () => {
|
|
4684
|
-
G("highlight"),
|
|
4687
|
+
G("highlight"), At("#fbc02d"), Ht(.5), zt(16);
|
|
4685
4688
|
},
|
|
4686
4689
|
label: "Text Highlight"
|
|
4687
4690
|
}),
|
|
4688
|
-
/* @__PURE__ */ F(
|
|
4691
|
+
/* @__PURE__ */ F(Jt, {
|
|
4689
4692
|
icon: /* @__PURE__ */ F(m, { size: 16 }),
|
|
4690
4693
|
active: W === "freehand",
|
|
4691
4694
|
onClick: () => {
|
|
4692
|
-
G("freehand"),
|
|
4695
|
+
G("freehand"), At("#000000"), Ht(1), zt(2);
|
|
4693
4696
|
},
|
|
4694
4697
|
label: "Marker"
|
|
4695
4698
|
}),
|
|
4696
|
-
/* @__PURE__ */ F(
|
|
4699
|
+
/* @__PURE__ */ F(Jt, {
|
|
4697
4700
|
icon: /* @__PURE__ */ F(Me, { size: 16 }),
|
|
4698
4701
|
active: W === "text",
|
|
4699
4702
|
onClick: () => {
|
|
4700
|
-
G("text"),
|
|
4703
|
+
G("text"), At("#000000"), Ht(1);
|
|
4701
4704
|
},
|
|
4702
4705
|
label: "Text"
|
|
4703
4706
|
}),
|
|
4704
|
-
ve?.canRedact !== !1 && /* @__PURE__ */ F(
|
|
4707
|
+
ve?.canRedact !== !1 && /* @__PURE__ */ F(Jt, {
|
|
4705
4708
|
icon: /* @__PURE__ */ F(w, { size: 16 }),
|
|
4706
4709
|
active: W === "redaction",
|
|
4707
4710
|
onClick: () => {
|
|
4708
|
-
G("redaction"),
|
|
4711
|
+
G("redaction"), At("#000000"), Ht(1);
|
|
4709
4712
|
},
|
|
4710
4713
|
label: "Redact"
|
|
4711
4714
|
}),
|
|
@@ -4722,11 +4725,11 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4722
4725
|
borderRight: "1px solid var(--border-color)",
|
|
4723
4726
|
paddingRight: "8px"
|
|
4724
4727
|
},
|
|
4725
|
-
children: /* @__PURE__ */ F(
|
|
4728
|
+
children: /* @__PURE__ */ F(Jt, {
|
|
4726
4729
|
icon: /* @__PURE__ */ F(he, { size: 16 }),
|
|
4727
4730
|
active: W === "callout",
|
|
4728
4731
|
onClick: () => {
|
|
4729
|
-
G("callout"),
|
|
4732
|
+
G("callout"), Ht(1), zt(2);
|
|
4730
4733
|
},
|
|
4731
4734
|
label: "Callout"
|
|
4732
4735
|
})
|
|
@@ -4736,14 +4739,14 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4736
4739
|
display: "flex",
|
|
4737
4740
|
gap: "4px"
|
|
4738
4741
|
},
|
|
4739
|
-
children: [/* @__PURE__ */ F(
|
|
4742
|
+
children: [/* @__PURE__ */ F(Jt, {
|
|
4740
4743
|
icon: /* @__PURE__ */ F(be, { size: 16 }),
|
|
4741
4744
|
active: W === "freehand" && Vt === 1,
|
|
4742
4745
|
onClick: () => {
|
|
4743
|
-
G("freehand"),
|
|
4746
|
+
G("freehand"), Ht(1), zt(2);
|
|
4744
4747
|
},
|
|
4745
4748
|
label: "Freehand"
|
|
4746
|
-
}), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(
|
|
4749
|
+
}), ve?.canDeleteAnnotations !== !1 && /* @__PURE__ */ F(Jt, {
|
|
4747
4750
|
icon: /* @__PURE__ */ F(re, { size: 16 }),
|
|
4748
4751
|
active: W === "eraser",
|
|
4749
4752
|
onClick: () => G("eraser"),
|
|
@@ -4762,31 +4765,31 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4762
4765
|
gap: "4px"
|
|
4763
4766
|
},
|
|
4764
4767
|
children: [
|
|
4765
|
-
/* @__PURE__ */ F(
|
|
4768
|
+
/* @__PURE__ */ F(Jt, {
|
|
4766
4769
|
icon: /* @__PURE__ */ F(ge, { size: 16 }),
|
|
4767
4770
|
active: W === "line",
|
|
4768
4771
|
onClick: () => G("line"),
|
|
4769
4772
|
label: "Line"
|
|
4770
4773
|
}),
|
|
4771
|
-
/* @__PURE__ */ F(
|
|
4774
|
+
/* @__PURE__ */ F(Jt, {
|
|
4772
4775
|
icon: /* @__PURE__ */ F(f, { size: 16 }),
|
|
4773
4776
|
active: W === "arrow",
|
|
4774
4777
|
onClick: () => G("arrow"),
|
|
4775
4778
|
label: "Arrow"
|
|
4776
4779
|
}),
|
|
4777
|
-
/* @__PURE__ */ F(
|
|
4780
|
+
/* @__PURE__ */ F(Jt, {
|
|
4778
4781
|
icon: /* @__PURE__ */ F(Ae, { size: 16 }),
|
|
4779
4782
|
active: W === "rectangle",
|
|
4780
4783
|
onClick: () => G("rectangle"),
|
|
4781
4784
|
label: "Rectangle"
|
|
4782
4785
|
}),
|
|
4783
|
-
/* @__PURE__ */ F(
|
|
4786
|
+
/* @__PURE__ */ F(Jt, {
|
|
4784
4787
|
icon: /* @__PURE__ */ F(ee, { size: 16 }),
|
|
4785
4788
|
active: W === "ellipse",
|
|
4786
4789
|
onClick: () => G("ellipse"),
|
|
4787
4790
|
label: "Ellipse"
|
|
4788
4791
|
}),
|
|
4789
|
-
/* @__PURE__ */ F(
|
|
4792
|
+
/* @__PURE__ */ F(Jt, {
|
|
4790
4793
|
icon: /* @__PURE__ */ F(ce, { size: 16 }),
|
|
4791
4794
|
active: W === "link",
|
|
4792
4795
|
onClick: () => G("link"),
|
|
@@ -4823,16 +4826,16 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4823
4826
|
color: "#666",
|
|
4824
4827
|
minWidth: "85px"
|
|
4825
4828
|
},
|
|
4826
|
-
children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [
|
|
4829
|
+
children: ["Thickness: ", /* @__PURE__ */ I("strong", { children: [Nt, "px"] })]
|
|
4827
4830
|
}), /* @__PURE__ */ F("input", {
|
|
4828
4831
|
type: "range",
|
|
4829
4832
|
min: "1",
|
|
4830
4833
|
max: "24",
|
|
4831
|
-
value: Math.min(24, Math.max(1,
|
|
4834
|
+
value: Math.min(24, Math.max(1, Nt)),
|
|
4832
4835
|
onMouseDown: (e) => e.stopPropagation(),
|
|
4833
4836
|
onChange: (e) => {
|
|
4834
4837
|
let t = parseInt(e.target.value, 10);
|
|
4835
|
-
|
|
4838
|
+
zt(t), Y && !J && Q(U.map((e) => e.id === Y ? {
|
|
4836
4839
|
...e,
|
|
4837
4840
|
strokeWidth: t
|
|
4838
4841
|
} : e));
|
|
@@ -4859,7 +4862,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4859
4862
|
].map((e) => /* @__PURE__ */ F("button", {
|
|
4860
4863
|
onMouseDown: (e) => e.preventDefault(),
|
|
4861
4864
|
onClick: () => {
|
|
4862
|
-
|
|
4865
|
+
At(e), Y && !J && Q(U.map((t) => t.id === Y ? {
|
|
4863
4866
|
...t,
|
|
4864
4867
|
color: e
|
|
4865
4868
|
} : t));
|
|
@@ -4876,7 +4879,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4876
4879
|
}
|
|
4877
4880
|
}, e))
|
|
4878
4881
|
}),
|
|
4879
|
-
|
|
4882
|
+
bn > 0 && /* @__PURE__ */ I("div", {
|
|
4880
4883
|
style: {
|
|
4881
4884
|
display: "flex",
|
|
4882
4885
|
alignItems: "center",
|
|
@@ -4903,11 +4906,11 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
4903
4906
|
children: [
|
|
4904
4907
|
/* @__PURE__ */ F(Oe, { size: 16 }),
|
|
4905
4908
|
"Apply Redactions (",
|
|
4906
|
-
|
|
4909
|
+
bn,
|
|
4907
4910
|
")"
|
|
4908
4911
|
]
|
|
4909
4912
|
}), /* @__PURE__ */ I("button", {
|
|
4910
|
-
onClick:
|
|
4913
|
+
onClick: $,
|
|
4911
4914
|
style: {
|
|
4912
4915
|
display: "flex",
|
|
4913
4916
|
alignItems: "center",
|
|
@@ -5000,7 +5003,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5000
5003
|
},
|
|
5001
5004
|
children: [
|
|
5002
5005
|
"You are about to permanently apply ",
|
|
5003
|
-
/* @__PURE__ */ I("strong", { children: [
|
|
5006
|
+
/* @__PURE__ */ I("strong", { children: [bn, " redaction(s)"] }),
|
|
5004
5007
|
". Marked areas will be blacked out and underlying text will be permanently removed. This action cannot be undone."
|
|
5005
5008
|
]
|
|
5006
5009
|
}),
|
|
@@ -5027,7 +5030,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5027
5030
|
}),
|
|
5028
5031
|
/* @__PURE__ */ F("button", {
|
|
5029
5032
|
onClick: () => {
|
|
5030
|
-
|
|
5033
|
+
$(), vn(!1);
|
|
5031
5034
|
},
|
|
5032
5035
|
style: {
|
|
5033
5036
|
padding: "8px 14px",
|
|
@@ -5080,7 +5083,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5080
5083
|
overflow: "hidden",
|
|
5081
5084
|
position: "relative"
|
|
5082
5085
|
},
|
|
5083
|
-
children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(
|
|
5086
|
+
children: [R.isActive && R.mode === "side-by-side" ? /* @__PURE__ */ F(Ft, {
|
|
5084
5087
|
pdfDocA: M,
|
|
5085
5088
|
pdfDocB: ke,
|
|
5086
5089
|
pageNum: N,
|
|
@@ -5099,7 +5102,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5099
5102
|
selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
|
|
5100
5103
|
onSelectDiff: (e) => {
|
|
5101
5104
|
let t = R.diffItems.findIndex((t) => t.id === e);
|
|
5102
|
-
t !== -1 &&
|
|
5105
|
+
t !== -1 && bt(t);
|
|
5103
5106
|
}
|
|
5104
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", {
|
|
5105
5108
|
className: "pdf-viewer-area",
|
|
@@ -5170,7 +5173,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5170
5173
|
height: 0,
|
|
5171
5174
|
points: Zt,
|
|
5172
5175
|
color: kt,
|
|
5173
|
-
strokeWidth:
|
|
5176
|
+
strokeWidth: Nt,
|
|
5174
5177
|
opacity: Vt
|
|
5175
5178
|
};
|
|
5176
5179
|
if (W === "highlight") {
|
|
@@ -5184,7 +5187,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5184
5187
|
width: e,
|
|
5185
5188
|
height: t,
|
|
5186
5189
|
color: kt,
|
|
5187
|
-
strokeWidth:
|
|
5190
|
+
strokeWidth: Nt,
|
|
5188
5191
|
opacity: Vt
|
|
5189
5192
|
};
|
|
5190
5193
|
}
|
|
@@ -5222,7 +5225,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5222
5225
|
height: t,
|
|
5223
5226
|
points: W === "line" || W === "arrow" || W === "callout" ? [K, q] : void 0,
|
|
5224
5227
|
color: kt,
|
|
5225
|
-
strokeWidth:
|
|
5228
|
+
strokeWidth: Nt,
|
|
5226
5229
|
opacity: Vt
|
|
5227
5230
|
};
|
|
5228
5231
|
}
|
|
@@ -5257,8 +5260,8 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5257
5260
|
onAnnotationClick: Rn,
|
|
5258
5261
|
onAnnotationMouseEnter: Ln,
|
|
5259
5262
|
onClearSelection: () => {
|
|
5260
|
-
if (
|
|
5261
|
-
|
|
5263
|
+
if (cn.current || on) {
|
|
5264
|
+
cn.current = !1;
|
|
5262
5265
|
return;
|
|
5263
5266
|
}
|
|
5264
5267
|
X(null), an(null);
|
|
@@ -5318,13 +5321,13 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5318
5321
|
pointerEvents: "none",
|
|
5319
5322
|
zIndex: 16
|
|
5320
5323
|
},
|
|
5321
|
-
children: /* @__PURE__ */ F(
|
|
5324
|
+
children: /* @__PURE__ */ F(Pt, {
|
|
5322
5325
|
boxes: [...R.pageDiffsA?.[n] || [], ...R.pageDiffsB?.[n] || []],
|
|
5323
5326
|
scale: S,
|
|
5324
5327
|
selectedDiffId: R.diffItems[R.currentDiffIndex]?.id,
|
|
5325
5328
|
onSelectDiff: (e) => {
|
|
5326
5329
|
let t = R.diffItems.findIndex((t) => t.id === e);
|
|
5327
|
-
t !== -1 &&
|
|
5330
|
+
t !== -1 && bt(t);
|
|
5328
5331
|
}
|
|
5329
5332
|
})
|
|
5330
5333
|
}),
|
|
@@ -5599,7 +5602,7 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5599
5602
|
},
|
|
5600
5603
|
permissions: ve
|
|
5601
5604
|
}),
|
|
5602
|
-
R.isActive && R.showCurtain && /* @__PURE__ */ F(
|
|
5605
|
+
R.isActive && R.showCurtain && /* @__PURE__ */ F(Rt, {
|
|
5603
5606
|
positionPercent: R.curtainPosition,
|
|
5604
5607
|
onChangePosition: (e) => z((t) => ({
|
|
5605
5608
|
...t,
|
|
@@ -5608,13 +5611,13 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5608
5611
|
containerRef: j
|
|
5609
5612
|
})
|
|
5610
5613
|
]
|
|
5611
|
-
})] }), R.isActive && /* @__PURE__ */ F(
|
|
5614
|
+
})] }), R.isActive && /* @__PURE__ */ F(Lt, {
|
|
5612
5615
|
isOpen: B,
|
|
5613
5616
|
onClose: () => Ie(!1),
|
|
5614
5617
|
diffItems: R.diffItems,
|
|
5615
5618
|
textDiffs: Pe,
|
|
5616
5619
|
currentDiffIndex: R.currentDiffIndex,
|
|
5617
|
-
onSelectDiff: (e, t) =>
|
|
5620
|
+
onSelectDiff: (e, t) => bt(e, t),
|
|
5618
5621
|
onJumpToPage: (e) => _t(e)
|
|
5619
5622
|
})]
|
|
5620
5623
|
})
|
|
@@ -5655,12 +5658,12 @@ function Kt({ leftSidebarOpen: t, rightSidebarOpen: r, activeTab: a, annotationM
|
|
|
5655
5658
|
searchResults: Cn,
|
|
5656
5659
|
isSearching: wn,
|
|
5657
5660
|
searchProgress: Tn,
|
|
5658
|
-
onResultClick:
|
|
5661
|
+
onResultClick: vt
|
|
5659
5662
|
})
|
|
5660
5663
|
]
|
|
5661
5664
|
});
|
|
5662
5665
|
}
|
|
5663
|
-
function
|
|
5666
|
+
function Jt({ icon: e, active: t, onClick: n, label: r }) {
|
|
5664
5667
|
return /* @__PURE__ */ F("button", {
|
|
5665
5668
|
onClick: n,
|
|
5666
5669
|
title: r,
|
|
@@ -5687,7 +5690,7 @@ function qt({ icon: e, active: t, onClick: n, label: r }) {
|
|
|
5687
5690
|
}
|
|
5688
5691
|
//#endregion
|
|
5689
5692
|
//#region src/components/SettingsModal.tsx
|
|
5690
|
-
function
|
|
5693
|
+
function K({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
5691
5694
|
let { shortcuts: r, updateShortcut: i, resetShortcuts: a } = Qe(), [s, l] = c("Keyboard Shortcuts"), [u, d] = c(null), [f, p] = c(""), m = (e, t) => {
|
|
5692
5695
|
if (e.preventDefault(), e.stopPropagation(), e.key === "Escape") {
|
|
5693
5696
|
d(null);
|
|
@@ -6216,7 +6219,7 @@ function Jt({ onClose: e, watermarkText: t, setWatermarkText: n }) {
|
|
|
6216
6219
|
}
|
|
6217
6220
|
//#endregion
|
|
6218
6221
|
//#region src/components/AboutModal.tsx
|
|
6219
|
-
function
|
|
6222
|
+
function Yt({ onClose: e }) {
|
|
6220
6223
|
return /* @__PURE__ */ F("div", {
|
|
6221
6224
|
style: {
|
|
6222
6225
|
position: "fixed",
|
|
@@ -6437,7 +6440,7 @@ function K({ onClose: e }) {
|
|
|
6437
6440
|
}
|
|
6438
6441
|
//#endregion
|
|
6439
6442
|
//#region src/core/eventBus.ts
|
|
6440
|
-
var
|
|
6443
|
+
var q = class {
|
|
6441
6444
|
listeners = /* @__PURE__ */ new Map();
|
|
6442
6445
|
destroyed = !1;
|
|
6443
6446
|
on(e, t) {
|
|
@@ -6479,21 +6482,21 @@ var Yt = class {
|
|
|
6479
6482
|
get isDestroyed() {
|
|
6480
6483
|
return this.destroyed;
|
|
6481
6484
|
}
|
|
6482
|
-
},
|
|
6483
|
-
function
|
|
6485
|
+
}, Xt = (e) => e === 0 ? 0 : e;
|
|
6486
|
+
function Zt(e, t) {
|
|
6484
6487
|
return {
|
|
6485
|
-
x:
|
|
6486
|
-
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])
|
|
6487
6490
|
};
|
|
6488
6491
|
}
|
|
6489
|
-
function
|
|
6492
|
+
function Qt(e, t) {
|
|
6490
6493
|
let n = t[0] * t[3] - t[1] * t[2];
|
|
6491
6494
|
return {
|
|
6492
|
-
x:
|
|
6493
|
-
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)
|
|
6494
6497
|
};
|
|
6495
6498
|
}
|
|
6496
|
-
function
|
|
6499
|
+
function J(e, t, n) {
|
|
6497
6500
|
let r = lt(n), [i, a, o, s] = t, c = (o + i) / 2, l = (s + a) / 2, u, d, f, p;
|
|
6498
6501
|
switch (r) {
|
|
6499
6502
|
case 180:
|
|
@@ -6531,33 +6534,33 @@ function Qt(e, t, n) {
|
|
|
6531
6534
|
transform: v
|
|
6532
6535
|
};
|
|
6533
6536
|
}
|
|
6534
|
-
function
|
|
6537
|
+
function $t(e) {
|
|
6535
6538
|
let t = e.view;
|
|
6536
|
-
return
|
|
6539
|
+
return J(e.pageNumber, [
|
|
6537
6540
|
t[0],
|
|
6538
6541
|
t[1],
|
|
6539
6542
|
t[2],
|
|
6540
6543
|
t[3]
|
|
6541
6544
|
], e.rotate);
|
|
6542
6545
|
}
|
|
6543
|
-
function
|
|
6546
|
+
function en(e) {
|
|
6544
6547
|
let t = /* @__PURE__ */ new Map();
|
|
6545
6548
|
return (n) => {
|
|
6546
6549
|
let r = Math.max(1, Math.min(e.numPages, n)), i = t.get(r);
|
|
6547
|
-
return i || (i = e.getPage(r).then(
|
|
6550
|
+
return i || (i = e.getPage(r).then($t), t.set(r, i)), i;
|
|
6548
6551
|
};
|
|
6549
6552
|
}
|
|
6550
|
-
function en(e, t) {
|
|
6551
|
-
return Zt(t, e.transform);
|
|
6552
|
-
}
|
|
6553
6553
|
function tn(e, t) {
|
|
6554
|
-
return
|
|
6554
|
+
return Qt(t, e.transform);
|
|
6555
6555
|
}
|
|
6556
6556
|
function nn(e, t) {
|
|
6557
|
-
|
|
6557
|
+
return Zt(t, e.transform);
|
|
6558
|
+
}
|
|
6559
|
+
function Y(e, t) {
|
|
6560
|
+
let n = tn(e, {
|
|
6558
6561
|
x: t.x,
|
|
6559
6562
|
y: t.y
|
|
6560
|
-
}), r =
|
|
6563
|
+
}), r = tn(e, {
|
|
6561
6564
|
x: t.x + t.width,
|
|
6562
6565
|
y: t.y + t.height
|
|
6563
6566
|
});
|
|
@@ -6568,11 +6571,11 @@ function nn(e, t) {
|
|
|
6568
6571
|
Math.max(n.y, r.y)
|
|
6569
6572
|
];
|
|
6570
6573
|
}
|
|
6571
|
-
function
|
|
6572
|
-
let n =
|
|
6574
|
+
function X(e, t) {
|
|
6575
|
+
let n = nn(e, {
|
|
6573
6576
|
x: t[0],
|
|
6574
6577
|
y: t[1]
|
|
6575
|
-
}), r =
|
|
6578
|
+
}), r = nn(e, {
|
|
6576
6579
|
x: t[2],
|
|
6577
6580
|
y: t[3]
|
|
6578
6581
|
});
|
|
@@ -6583,14 +6586,14 @@ function Y(e, t) {
|
|
|
6583
6586
|
height: Math.abs(r.y - n.y)
|
|
6584
6587
|
};
|
|
6585
6588
|
}
|
|
6586
|
-
function X(e, t) {
|
|
6587
|
-
return t.map((t) => en(e, t));
|
|
6588
|
-
}
|
|
6589
6589
|
function rn(e, t) {
|
|
6590
6590
|
return t.map((t) => tn(e, t));
|
|
6591
6591
|
}
|
|
6592
6592
|
function an(e, t) {
|
|
6593
|
-
|
|
6593
|
+
return t.map((t) => nn(e, t));
|
|
6594
|
+
}
|
|
6595
|
+
function on(e, t) {
|
|
6596
|
+
let [n, r, i, a] = Y(e, t);
|
|
6594
6597
|
return [
|
|
6595
6598
|
n,
|
|
6596
6599
|
a,
|
|
@@ -6602,7 +6605,7 @@ function an(e, t) {
|
|
|
6602
6605
|
r
|
|
6603
6606
|
];
|
|
6604
6607
|
}
|
|
6605
|
-
function
|
|
6608
|
+
function sn(e, t) {
|
|
6606
6609
|
let n = [];
|
|
6607
6610
|
for (let r = 0; r + 7 < t.length; r += 8) {
|
|
6608
6611
|
let i = [
|
|
@@ -6616,7 +6619,7 @@ function on(e, t) {
|
|
|
6616
6619
|
t[r + 5],
|
|
6617
6620
|
t[r + 7]
|
|
6618
6621
|
];
|
|
6619
|
-
n.push(
|
|
6622
|
+
n.push(X(e, [
|
|
6620
6623
|
Math.min(...i),
|
|
6621
6624
|
Math.min(...a),
|
|
6622
6625
|
Math.max(...i),
|
|
@@ -6625,7 +6628,7 @@ function on(e, t) {
|
|
|
6625
6628
|
}
|
|
6626
6629
|
return n;
|
|
6627
6630
|
}
|
|
6628
|
-
function
|
|
6631
|
+
function cn(e) {
|
|
6629
6632
|
if (e.length === 0) return {
|
|
6630
6633
|
x: 0,
|
|
6631
6634
|
y: 0,
|
|
@@ -6640,17 +6643,17 @@ function sn(e) {
|
|
|
6640
6643
|
height: i - n
|
|
6641
6644
|
};
|
|
6642
6645
|
}
|
|
6643
|
-
var Z = (e) => (Math.round(e * 1e3) / 1e3).toString(),
|
|
6646
|
+
var Z = (e) => (Math.round(e * 1e3) / 1e3).toString(), ln = 524288e3, un = (e) => {
|
|
6644
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;
|
|
6645
6648
|
return B(n, r, i);
|
|
6646
6649
|
};
|
|
6647
|
-
async function
|
|
6648
|
-
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, {
|
|
6649
6652
|
x: r.x,
|
|
6650
6653
|
y: r.y,
|
|
6651
6654
|
width: r.width,
|
|
6652
6655
|
height: r.height
|
|
6653
|
-
}), 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, {
|
|
6654
6657
|
x: e,
|
|
6655
6658
|
y: t + r
|
|
6656
6659
|
});
|
|
@@ -6689,7 +6692,7 @@ async function un(e, t, n, r, i) {
|
|
|
6689
6692
|
height: r.height
|
|
6690
6693
|
}];
|
|
6691
6694
|
for (let r of e) {
|
|
6692
|
-
let [e, i, s, c] =
|
|
6695
|
+
let [e, i, s, c] = Y(n, r);
|
|
6693
6696
|
t.drawRectangle({
|
|
6694
6697
|
x: e,
|
|
6695
6698
|
y: i,
|
|
@@ -6710,7 +6713,7 @@ async function un(e, t, n, r, i) {
|
|
|
6710
6713
|
}, {
|
|
6711
6714
|
x: r.x + r.width,
|
|
6712
6715
|
y: r.y + r.height
|
|
6713
|
-
}], [i, c] =
|
|
6716
|
+
}], [i, c] = rn(n, [e[0], e[1]]);
|
|
6714
6717
|
if (t.drawLine({
|
|
6715
6718
|
start: i,
|
|
6716
6719
|
end: c,
|
|
@@ -6718,7 +6721,7 @@ async function un(e, t, n, r, i) {
|
|
|
6718
6721
|
opacity: o,
|
|
6719
6722
|
thickness: s
|
|
6720
6723
|
}), r.type === "arrow") {
|
|
6721
|
-
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, [{
|
|
6722
6725
|
x: i.x - u * Math.cos(l - Math.PI / 6),
|
|
6723
6726
|
y: i.y - u * Math.sin(l - Math.PI / 6)
|
|
6724
6727
|
}, {
|
|
@@ -6744,7 +6747,7 @@ async function un(e, t, n, r, i) {
|
|
|
6744
6747
|
case "freehand": {
|
|
6745
6748
|
let e = r.strokes && r.strokes.length > 0 ? r.strokes : r.points ? [r.points] : [];
|
|
6746
6749
|
for (let r of e) {
|
|
6747
|
-
let e =
|
|
6750
|
+
let e = rn(n, r);
|
|
6748
6751
|
for (let n = 1; n < e.length; n++) t.drawLine({
|
|
6749
6752
|
start: e[n - 1],
|
|
6750
6753
|
end: e[n],
|
|
@@ -6770,7 +6773,7 @@ async function un(e, t, n, r, i) {
|
|
|
6770
6773
|
return;
|
|
6771
6774
|
}
|
|
6772
6775
|
case "note": {
|
|
6773
|
-
let [e, i, c, l] =
|
|
6776
|
+
let [e, i, c, l] = Y(n, {
|
|
6774
6777
|
x: r.x,
|
|
6775
6778
|
y: r.y,
|
|
6776
6779
|
width: 24,
|
|
@@ -6804,7 +6807,7 @@ async function un(e, t, n, r, i) {
|
|
|
6804
6807
|
}, {
|
|
6805
6808
|
x: r.x,
|
|
6806
6809
|
y: r.y
|
|
6807
|
-
}], [i, c] =
|
|
6810
|
+
}], [i, c] = rn(n, [e[0], e[1]]);
|
|
6808
6811
|
if (t.drawLine({
|
|
6809
6812
|
start: i,
|
|
6810
6813
|
end: c,
|
|
@@ -6812,7 +6815,7 @@ async function un(e, t, n, r, i) {
|
|
|
6812
6815
|
opacity: o,
|
|
6813
6816
|
thickness: s
|
|
6814
6817
|
}), r.text) {
|
|
6815
|
-
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, {
|
|
6816
6819
|
x: e[1].x,
|
|
6817
6820
|
y: e[1].y,
|
|
6818
6821
|
width: i,
|
|
@@ -6905,8 +6908,8 @@ async function un(e, t, n, r, i) {
|
|
|
6905
6908
|
default: return;
|
|
6906
6909
|
}
|
|
6907
6910
|
}
|
|
6908
|
-
async function
|
|
6909
|
-
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);
|
|
6910
6913
|
for (let a of e.getPages()) {
|
|
6911
6914
|
let { width: e, height: c } = a.getSize();
|
|
6912
6915
|
if (t.mode === "single") {
|
|
@@ -6937,10 +6940,10 @@ async function dn(e, t) {
|
|
|
6937
6940
|
}
|
|
6938
6941
|
}
|
|
6939
6942
|
}
|
|
6940
|
-
async function
|
|
6943
|
+
async function Q(e, t) {
|
|
6941
6944
|
let n = await e.save(), r = L.getDocument({
|
|
6942
6945
|
data: n,
|
|
6943
|
-
...
|
|
6946
|
+
...Mt()
|
|
6944
6947
|
}), i = await r.promise, a = await z.create();
|
|
6945
6948
|
try {
|
|
6946
6949
|
for (let n = 1; n <= i.numPages; n++) {
|
|
@@ -6977,7 +6980,7 @@ async function fn(e, t) {
|
|
|
6977
6980
|
}
|
|
6978
6981
|
return a;
|
|
6979
6982
|
}
|
|
6980
|
-
async function
|
|
6983
|
+
async function pn(e, t = {}) {
|
|
6981
6984
|
t.xfdfString && console.warn("[teamsync-pdf-viewer] getFileData({ xfdfString }) is ignored; import the XFDF through annotationManager.importAnnotations() first.");
|
|
6982
6985
|
let n = await e.getSourceBytes(), r = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
6983
6986
|
if (r.byteLength > 524288e3) {
|
|
@@ -6987,33 +6990,33 @@ async function Q(e, t = {}) {
|
|
|
6987
6990
|
let i = await z.load(r, { ignoreEncryption: !0 }), a = i.getPages(), o = t.explicitAnnotations || e.annotations, s = e.getPageGeometry, c = null;
|
|
6988
6991
|
!s && o.length > 0 && (c = L.getDocument({
|
|
6989
6992
|
data: r.slice(),
|
|
6990
|
-
...
|
|
6991
|
-
}), s =
|
|
6993
|
+
...Mt()
|
|
6994
|
+
}), s = en(await c.promise));
|
|
6992
6995
|
try {
|
|
6993
6996
|
for (let t of o) {
|
|
6994
6997
|
let n = Math.max(0, Math.min((t.pageIndex || 1) - 1, a.length - 1)), r = await s(n + 1);
|
|
6995
|
-
await
|
|
6998
|
+
await dn(i, a[n], r, t, e.signerName);
|
|
6996
6999
|
}
|
|
6997
7000
|
} finally {
|
|
6998
7001
|
c && await c.destroy().catch(() => {});
|
|
6999
7002
|
}
|
|
7000
|
-
e.watermark?.text && await
|
|
7003
|
+
e.watermark?.text && await fn(i, e.watermark);
|
|
7001
7004
|
let l = e.redactions || [];
|
|
7002
|
-
return await (l.length > 0 ? await
|
|
7005
|
+
return await (l.length > 0 ? await Q(i, l) : i).save();
|
|
7003
7006
|
}
|
|
7004
7007
|
//#endregion
|
|
7005
7008
|
//#region src/annotations/xfdf.ts
|
|
7006
|
-
var
|
|
7007
|
-
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) {
|
|
7008
7011
|
return String(e).padStart(t, "0");
|
|
7009
7012
|
}
|
|
7010
|
-
function
|
|
7013
|
+
function vn(e) {
|
|
7011
7014
|
let t = e ? new Date(e) : /* @__PURE__ */ new Date();
|
|
7012
|
-
if (Number.isNaN(t.getTime())) return
|
|
7013
|
-
let n = -t.getTimezoneOffset(), r = n >= 0 ? "+" : "-", i =
|
|
7014
|
-
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}'`;
|
|
7015
7018
|
}
|
|
7016
|
-
function
|
|
7019
|
+
function yn(e) {
|
|
7017
7020
|
if (!e) return;
|
|
7018
7021
|
let t = /^D:(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([+\-Z])?(\d{2})?'?(\d{2})?/.exec(e.trim());
|
|
7019
7022
|
if (!t) {
|
|
@@ -7025,41 +7028,41 @@ function vn(e) {
|
|
|
7025
7028
|
let f = Date.parse(`${n}-${r}-${i}T${a}:${o}:${s}${d}`);
|
|
7026
7029
|
return Number.isNaN(f) ? void 0 : new Date(f).toISOString();
|
|
7027
7030
|
}
|
|
7028
|
-
var
|
|
7031
|
+
var bn = (e) => {
|
|
7029
7032
|
if (!(!e || e === "transparent")) {
|
|
7030
7033
|
if (/^#[0-9a-f]{6}$/i.test(e)) return e.toUpperCase();
|
|
7031
7034
|
if (/^#[0-9a-f]{3}$/i.test(e)) return `#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`.toUpperCase();
|
|
7032
7035
|
}
|
|
7033
|
-
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${
|
|
7034
|
-
function bn(e) {
|
|
7035
|
-
return `<trn-custom-data bytes="${hn(JSON.stringify({ [mn]: e }))}"/>`;
|
|
7036
|
-
}
|
|
7036
|
+
}, $ = (e, t) => t == null || t === "" ? "" : ` ${e}="${gn(String(t))}"`;
|
|
7037
7037
|
function xn(e) {
|
|
7038
|
+
return `<trn-custom-data bytes="${gn(JSON.stringify({ [hn]: e }))}"/>`;
|
|
7039
|
+
}
|
|
7040
|
+
function Sn(e) {
|
|
7038
7041
|
let t = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
7039
7042
|
if (!t) return {};
|
|
7040
7043
|
try {
|
|
7041
|
-
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[
|
|
7044
|
+
let e = JSON.parse(t.getAttribute("bytes") || "{}")?.[hn];
|
|
7042
7045
|
return e && typeof e == "object" ? e : {};
|
|
7043
7046
|
} catch {
|
|
7044
7047
|
return {};
|
|
7045
7048
|
}
|
|
7046
7049
|
}
|
|
7047
|
-
function
|
|
7050
|
+
function Cn(e) {
|
|
7048
7051
|
return e.map((e) => `${Z(e.x)},${Z(e.y)}`).join(";");
|
|
7049
7052
|
}
|
|
7050
|
-
function
|
|
7053
|
+
function wn(e) {
|
|
7051
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]) => ({
|
|
7052
7055
|
x: e,
|
|
7053
7056
|
y: t
|
|
7054
7057
|
})) : [];
|
|
7055
7058
|
}
|
|
7056
|
-
function
|
|
7059
|
+
function Tn(e) {
|
|
7057
7060
|
return e ? e.split(/[,\s]+/).map(Number).filter((e) => Number.isFinite(e)) : [];
|
|
7058
7061
|
}
|
|
7059
|
-
function
|
|
7062
|
+
function En(e) {
|
|
7060
7063
|
return e.map(Z).join(",");
|
|
7061
7064
|
}
|
|
7062
|
-
var
|
|
7065
|
+
var Dn = /* @__PURE__ */ new Set([
|
|
7063
7066
|
"page",
|
|
7064
7067
|
"rect",
|
|
7065
7068
|
"color",
|
|
@@ -7081,7 +7084,7 @@ var En = /* @__PURE__ */ new Set([
|
|
|
7081
7084
|
"IT",
|
|
7082
7085
|
"callout",
|
|
7083
7086
|
"style"
|
|
7084
|
-
]),
|
|
7087
|
+
]), On = /* @__PURE__ */ new Set([
|
|
7085
7088
|
"contents",
|
|
7086
7089
|
"contents-richtext",
|
|
7087
7090
|
"inklist",
|
|
@@ -7093,33 +7096,33 @@ var En = /* @__PURE__ */ new Set([
|
|
|
7093
7096
|
"popup",
|
|
7094
7097
|
"vertices"
|
|
7095
7098
|
]);
|
|
7096
|
-
function
|
|
7097
|
-
let i = r ??
|
|
7099
|
+
function kn(e, t, n, r) {
|
|
7100
|
+
let i = r ?? Y(t, {
|
|
7098
7101
|
x: e.x,
|
|
7099
7102
|
y: e.y,
|
|
7100
7103
|
width: e.width,
|
|
7101
7104
|
height: e.height
|
|
7102
7105
|
}), a = e.createdAt ?? (e.timestamp ? new Date(e.timestamp).toISOString() : void 0), o = ["print", ...e.readOnly ? ["readonly", "locked"] : []].join(",");
|
|
7103
|
-
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);
|
|
7104
7107
|
}
|
|
7105
|
-
function
|
|
7108
|
+
function An(e) {
|
|
7106
7109
|
let t = e.xfdfExtras?.attrs;
|
|
7107
|
-
return t ? Object.entries(t).filter(([e]) => !
|
|
7110
|
+
return t ? Object.entries(t).filter(([e]) => !Dn.has(e)).map(([e, t]) => $(e, t)).join("") : "";
|
|
7108
7111
|
}
|
|
7109
|
-
function
|
|
7112
|
+
function jn(e) {
|
|
7110
7113
|
return (e.xfdfExtras?.children ?? []).join("");
|
|
7111
7114
|
}
|
|
7112
|
-
function
|
|
7115
|
+
function Mn(e, t = {}) {
|
|
7113
7116
|
let n = {
|
|
7114
7117
|
type: e.type,
|
|
7115
7118
|
...t
|
|
7116
7119
|
};
|
|
7117
|
-
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);
|
|
7118
7121
|
}
|
|
7119
|
-
var
|
|
7120
|
-
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 = {}) {
|
|
7121
7124
|
if (e.type === "opaque" && e.rawXfdf) return e.rawXfdf;
|
|
7122
|
-
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);
|
|
7123
7126
|
switch (e.type) {
|
|
7124
7127
|
case "rectangle": return `<square${s()}${o}${$("interior-color", a)} subject="Rectangle">${c()}</square>`;
|
|
7125
7128
|
case "ellipse": return `<circle${s()}${o}${$("interior-color", a)} subject="Ellipse">${c()}</circle>`;
|
|
@@ -7131,7 +7134,7 @@ async function Pn(e, t, n = {}) {
|
|
|
7131
7134
|
}, {
|
|
7132
7135
|
x: e.x + e.width,
|
|
7133
7136
|
y: e.y + e.height
|
|
7134
|
-
}], [n, i] =
|
|
7137
|
+
}], [n, i] = rn(r, [t[0], t[1]]), a = [
|
|
7135
7138
|
Math.min(n.x, i.x),
|
|
7136
7139
|
Math.min(n.y, i.y),
|
|
7137
7140
|
Math.max(n.x, i.x),
|
|
@@ -7140,8 +7143,8 @@ async function Pn(e, t, n = {}) {
|
|
|
7140
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>`;
|
|
7141
7144
|
}
|
|
7142
7145
|
case "freehand": {
|
|
7143
|
-
let t = e.strokes && e.strokes.length > 0 ? e.strokes : e.points ? [e.points] : [], n = t.map((e) => `<gesture>${
|
|
7144
|
-
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>`;
|
|
7145
7148
|
}
|
|
7146
7149
|
case "highlight": {
|
|
7147
7150
|
let t = e.rects && e.rects.length > 0 ? e.rects : [{
|
|
@@ -7149,10 +7152,10 @@ async function Pn(e, t, n = {}) {
|
|
|
7149
7152
|
y: e.y,
|
|
7150
7153
|
width: e.width,
|
|
7151
7154
|
height: e.height
|
|
7152
|
-
}], n = t.flatMap((e) =>
|
|
7153
|
-
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>`;
|
|
7154
7157
|
}
|
|
7155
|
-
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>`;
|
|
7156
7159
|
case "callout": {
|
|
7157
7160
|
let t = e.points && e.points.length >= 2 ? e.points : [{
|
|
7158
7161
|
x: e.x,
|
|
@@ -7160,7 +7163,7 @@ async function Pn(e, t, n = {}) {
|
|
|
7160
7163
|
}, {
|
|
7161
7164
|
x: e.x,
|
|
7162
7165
|
y: e.y
|
|
7163
|
-
}], [n, i] =
|
|
7166
|
+
}], [n, i] = rn(r, [t[0], t[1]]), a = Y(r, {
|
|
7164
7167
|
x: t[1].x,
|
|
7165
7168
|
y: t[1].y,
|
|
7166
7169
|
width: e.text ? e.text.length * 8 + 20 : 100,
|
|
@@ -7171,19 +7174,19 @@ async function Pn(e, t, n = {}) {
|
|
|
7171
7174
|
Math.min(n.y, a[1]),
|
|
7172
7175
|
Math.max(i.x, a[2]),
|
|
7173
7176
|
Math.max(i.y, a[3])
|
|
7174
|
-
])}${o} IT="FreeTextCallout" callout="${Z(n.x)},${Z(n.y)},${Z(i.x)},${Z(i.y)}" subject="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>`;
|
|
7175
7178
|
}
|
|
7176
|
-
case "note": return `<text${s(
|
|
7179
|
+
case "note": return `<text${s(Y(r, {
|
|
7177
7180
|
x: e.x,
|
|
7178
7181
|
y: e.y,
|
|
7179
7182
|
width: 24,
|
|
7180
7183
|
height: 24
|
|
7181
|
-
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${
|
|
7184
|
+
}))}${$("color", a)} icon="Comment" subject="Sticky Note">${Nn(e.text)}${c()}</text>`;
|
|
7182
7185
|
case "link": {
|
|
7183
|
-
let t = e.linkUrl ?? "", n = t.startsWith("#page=") ? `<OnActivation><Action Trigger="U"><GoTo><Dest><Fit Page="${Math.max(0, (parseInt(t.slice(6), 10) || 1) - 1)}"/></Dest></GoTo></Action></OnActivation>` : t ? `<OnActivation><Action Trigger="U"><URI Name="${
|
|
7184
|
-
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>`;
|
|
7185
7188
|
}
|
|
7186
|
-
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({
|
|
7187
7190
|
signer: e.signer,
|
|
7188
7191
|
signType: e.signType,
|
|
7189
7192
|
timestamp: e.timestamp
|
|
@@ -7196,7 +7199,7 @@ async function Pn(e, t, n = {}) {
|
|
|
7196
7199
|
default: return "";
|
|
7197
7200
|
}
|
|
7198
7201
|
}
|
|
7199
|
-
function
|
|
7202
|
+
function In(e, t = 0) {
|
|
7200
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;
|
|
7201
7204
|
return {
|
|
7202
7205
|
x: a,
|
|
@@ -7205,21 +7208,21 @@ function Fn(e, t = 0) {
|
|
|
7205
7208
|
height: Math.max(...r) - o + i
|
|
7206
7209
|
};
|
|
7207
7210
|
}
|
|
7208
|
-
async function
|
|
7211
|
+
async function Ln(e, t, n = {}) {
|
|
7209
7212
|
let r = n.annotList ?? e;
|
|
7210
|
-
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>`;
|
|
7211
7214
|
}
|
|
7212
|
-
function
|
|
7215
|
+
function Rn(e) {
|
|
7213
7216
|
let t = {};
|
|
7214
|
-
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);
|
|
7215
7218
|
let n = [];
|
|
7216
|
-
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));
|
|
7217
7220
|
let r = Array.from(e.children).find((e) => e.localName === "trn-custom-data");
|
|
7218
7221
|
if (r) try {
|
|
7219
7222
|
let e = JSON.parse(r.getAttribute("bytes") || "{}");
|
|
7220
7223
|
if (e && typeof e == "object") {
|
|
7221
7224
|
let t = { ...e };
|
|
7222
|
-
delete t[
|
|
7225
|
+
delete t[hn], Object.keys(t).length > 0 && n.push(`<trn-custom-data bytes="${gn(JSON.stringify(t))}"/>`);
|
|
7223
7226
|
}
|
|
7224
7227
|
} catch {
|
|
7225
7228
|
n.push(new XMLSerializer().serializeToString(r));
|
|
@@ -7227,11 +7230,11 @@ function Ln(e) {
|
|
|
7227
7230
|
let i = {};
|
|
7228
7231
|
return Object.keys(t).length && (i.attrs = t), n.length && (i.children = n), Object.keys(i).length ? i : void 0;
|
|
7229
7232
|
}
|
|
7230
|
-
function
|
|
7233
|
+
function zn(e, t) {
|
|
7231
7234
|
return Array.from(e.children).find((e) => e.localName === t)?.textContent ?? void 0;
|
|
7232
7235
|
}
|
|
7233
|
-
function
|
|
7234
|
-
let n =
|
|
7236
|
+
function Bn(e, t) {
|
|
7237
|
+
let n = Tn(e.getAttribute("rect")), r = n.length === 4 ? X(t, [
|
|
7235
7238
|
n[0],
|
|
7236
7239
|
n[1],
|
|
7237
7240
|
n[2],
|
|
@@ -7241,7 +7244,7 @@ function zn(e, t) {
|
|
|
7241
7244
|
y: 0,
|
|
7242
7245
|
width: 0,
|
|
7243
7246
|
height: 0
|
|
7244
|
-
}, 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");
|
|
7245
7248
|
return {
|
|
7246
7249
|
id: e.getAttribute("name") || Ct(),
|
|
7247
7250
|
pageIndex: (parseInt(e.getAttribute("page") || "0", 10) || 0) + 1,
|
|
@@ -7254,14 +7257,14 @@ function zn(e, t) {
|
|
|
7254
7257
|
opacity: s,
|
|
7255
7258
|
author: e.getAttribute("title") || void 0,
|
|
7256
7259
|
authorId: typeof i.authorId == "string" ? i.authorId : void 0,
|
|
7257
|
-
createdAt:
|
|
7258
|
-
modifiedAt:
|
|
7260
|
+
createdAt: yn(e.getAttribute("creationdate")),
|
|
7261
|
+
modifiedAt: yn(e.getAttribute("date")),
|
|
7259
7262
|
readOnly: d || void 0,
|
|
7260
|
-
xfdfExtras:
|
|
7263
|
+
xfdfExtras: Rn(e)
|
|
7261
7264
|
};
|
|
7262
7265
|
}
|
|
7263
|
-
function
|
|
7264
|
-
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 = () => ({
|
|
7265
7268
|
...i,
|
|
7266
7269
|
type: "opaque",
|
|
7267
7270
|
opaqueKind: n,
|
|
@@ -7278,15 +7281,15 @@ function Bn(e, t) {
|
|
|
7278
7281
|
type: "ellipse"
|
|
7279
7282
|
};
|
|
7280
7283
|
case "line": {
|
|
7281
|
-
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();
|
|
7282
7285
|
if (n.length < 2 || r.length < 2) return a();
|
|
7283
|
-
let [c, l] =
|
|
7286
|
+
let [c, l] = an(t, [{
|
|
7284
7287
|
x: n[0],
|
|
7285
7288
|
y: n[1]
|
|
7286
7289
|
}, {
|
|
7287
7290
|
x: r[0],
|
|
7288
7291
|
y: r[1]
|
|
7289
|
-
}]), u =
|
|
7292
|
+
}]), u = In([c, l]), d = o !== "none" || s !== "none";
|
|
7290
7293
|
return {
|
|
7291
7294
|
...i,
|
|
7292
7295
|
...u,
|
|
@@ -7295,24 +7298,24 @@ function Bn(e, t) {
|
|
|
7295
7298
|
};
|
|
7296
7299
|
}
|
|
7297
7300
|
case "ink": {
|
|
7298
|
-
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);
|
|
7299
7302
|
if (n.length === 0) return a();
|
|
7300
7303
|
let r = n.flat();
|
|
7301
7304
|
return {
|
|
7302
7305
|
...i,
|
|
7303
|
-
...
|
|
7306
|
+
...In(r),
|
|
7304
7307
|
type: "freehand",
|
|
7305
7308
|
points: n[0],
|
|
7306
7309
|
strokes: n
|
|
7307
7310
|
};
|
|
7308
7311
|
}
|
|
7309
7312
|
case "highlight": {
|
|
7310
|
-
let n =
|
|
7313
|
+
let n = Tn(e.getAttribute("coords")), r = n.length >= 8 ? sn(t, n) : [{
|
|
7311
7314
|
x: i.x,
|
|
7312
7315
|
y: i.y,
|
|
7313
7316
|
width: i.width,
|
|
7314
7317
|
height: i.height
|
|
7315
|
-
}], a =
|
|
7318
|
+
}], a = cn(r);
|
|
7316
7319
|
return {
|
|
7317
7320
|
...i,
|
|
7318
7321
|
...a,
|
|
@@ -7322,9 +7325,9 @@ function Bn(e, t) {
|
|
|
7322
7325
|
};
|
|
7323
7326
|
}
|
|
7324
7327
|
case "freetext": {
|
|
7325
|
-
let n =
|
|
7328
|
+
let n = zn(e, "contents") ?? "", a = e.getAttribute("IT") || "", o = Tn(e.getAttribute("callout"));
|
|
7326
7329
|
if (a === "FreeTextCallout" || r.type === "callout" || o.length >= 4) {
|
|
7327
|
-
let e = o.length >= 4 ?
|
|
7330
|
+
let e = o.length >= 4 ? an(t, [{
|
|
7328
7331
|
x: o[0],
|
|
7329
7332
|
y: o[1]
|
|
7330
7333
|
}, {
|
|
@@ -7359,7 +7362,7 @@ function Bn(e, t) {
|
|
|
7359
7362
|
case "text": return {
|
|
7360
7363
|
...i,
|
|
7361
7364
|
type: "note",
|
|
7362
|
-
text:
|
|
7365
|
+
text: zn(e, "contents") ?? "",
|
|
7363
7366
|
width: 24,
|
|
7364
7367
|
height: 24
|
|
7365
7368
|
};
|
|
@@ -7369,7 +7372,7 @@ function Bn(e, t) {
|
|
|
7369
7372
|
...i,
|
|
7370
7373
|
type: "link",
|
|
7371
7374
|
linkUrl: r,
|
|
7372
|
-
text:
|
|
7375
|
+
text: zn(e, "contents") ?? "",
|
|
7373
7376
|
color: "transparent",
|
|
7374
7377
|
strokeWidth: 0,
|
|
7375
7378
|
opacity: 1,
|
|
@@ -7377,7 +7380,7 @@ function Bn(e, t) {
|
|
|
7377
7380
|
};
|
|
7378
7381
|
}
|
|
7379
7382
|
case "stamp": {
|
|
7380
|
-
let t =
|
|
7383
|
+
let t = zn(e, "imagedata");
|
|
7381
7384
|
return r.type === "digital_signature_placeholder" ? {
|
|
7382
7385
|
...i,
|
|
7383
7386
|
type: "digital_signature_placeholder",
|
|
@@ -7394,7 +7397,7 @@ function Bn(e, t) {
|
|
|
7394
7397
|
default: return a();
|
|
7395
7398
|
}
|
|
7396
7399
|
}
|
|
7397
|
-
function
|
|
7400
|
+
function Hn(e) {
|
|
7398
7401
|
let t = "", n = 0;
|
|
7399
7402
|
for (;;) {
|
|
7400
7403
|
let r = e.indexOf("<?xml", n);
|
|
@@ -7405,11 +7408,11 @@ function Vn(e) {
|
|
|
7405
7408
|
}
|
|
7406
7409
|
return t + e.slice(n);
|
|
7407
7410
|
}
|
|
7408
|
-
async function
|
|
7409
|
-
let n =
|
|
7411
|
+
async function Un(e, t) {
|
|
7412
|
+
let n = Hn(e).trim();
|
|
7410
7413
|
if (!n) return [];
|
|
7411
7414
|
if (/<!DOCTYPE|<!ENTITY/i.test(n)) throw Error("[teamsync-pdf-viewer] invalid XFDF: DOCTYPE/ENTITY declarations are not allowed");
|
|
7412
|
-
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];
|
|
7413
7416
|
if (a) throw Error(`[teamsync-pdf-viewer] invalid XFDF: ${a.textContent?.slice(0, 200)}`);
|
|
7414
7417
|
let o = /* @__PURE__ */ new Set([
|
|
7415
7418
|
"xfdf",
|
|
@@ -7419,14 +7422,14 @@ async function Hn(e, t) {
|
|
|
7419
7422
|
"ids"
|
|
7420
7423
|
]), s = Array.from(i.getElementsByTagName("*")).filter((e) => e.parentElement?.localName === "annots" && !o.has(e.localName)), c = [];
|
|
7421
7424
|
for (let e of s) {
|
|
7422
|
-
let n =
|
|
7425
|
+
let n = Vn(e, await t((parseInt(e.getAttribute("page") || "0", 10) || 0) + 1));
|
|
7423
7426
|
n && c.push(n);
|
|
7424
7427
|
}
|
|
7425
7428
|
return c;
|
|
7426
7429
|
}
|
|
7427
7430
|
//#endregion
|
|
7428
7431
|
//#region src/annotations/AnnotationManager.ts
|
|
7429
|
-
var
|
|
7432
|
+
var Wn = 100, Gn = () => (/* @__PURE__ */ new Date()).toISOString(), Kn = class {
|
|
7430
7433
|
list = [];
|
|
7431
7434
|
past = [];
|
|
7432
7435
|
future = [];
|
|
@@ -7437,7 +7440,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7437
7440
|
canEditOthers = !1;
|
|
7438
7441
|
resolver = null;
|
|
7439
7442
|
setDocument(e) {
|
|
7440
|
-
this.resolver = e ?
|
|
7443
|
+
this.resolver = e ? en(e) : null;
|
|
7441
7444
|
}
|
|
7442
7445
|
hasDocument() {
|
|
7443
7446
|
return this.resolver !== null;
|
|
@@ -7552,7 +7555,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7552
7555
|
});
|
|
7553
7556
|
}
|
|
7554
7557
|
async importAnnotations(e) {
|
|
7555
|
-
let t = await
|
|
7558
|
+
let t = await Un(e, this.requireResolver());
|
|
7556
7559
|
if (t.length === 0) return [];
|
|
7557
7560
|
let n = new Map(t.map((e) => [e.id, e])), r = this.list.map((e) => n.get(e.id) ?? e);
|
|
7558
7561
|
for (let e of t) this.list.some((t) => t.id === e.id) || r.push(e);
|
|
@@ -7564,7 +7567,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7564
7567
|
}
|
|
7565
7568
|
async exportAnnotations(e = {}) {
|
|
7566
7569
|
let t = this.requireResolver();
|
|
7567
|
-
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);
|
|
7568
7571
|
}
|
|
7569
7572
|
exportAnnotationsLegacyJson() {
|
|
7570
7573
|
return JSON.stringify(this.list, null, 2);
|
|
@@ -7588,7 +7591,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7588
7591
|
}
|
|
7589
7592
|
let n = r ? t : {
|
|
7590
7593
|
...t,
|
|
7591
|
-
modifiedAt:
|
|
7594
|
+
modifiedAt: Gn()
|
|
7592
7595
|
};
|
|
7593
7596
|
c.push(n), l.push({
|
|
7594
7597
|
before: e,
|
|
@@ -7608,7 +7611,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7608
7611
|
added: s,
|
|
7609
7612
|
modified: l,
|
|
7610
7613
|
deleted: u
|
|
7611
|
-
}), this.past.length >
|
|
7614
|
+
}), this.past.length > Wn && this.past.shift(), this.future = []), this.list = d;
|
|
7612
7615
|
for (let e of Array.from(this.listListeners)) try {
|
|
7613
7616
|
e();
|
|
7614
7617
|
} catch (e) {
|
|
@@ -7630,7 +7633,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7630
7633
|
}
|
|
7631
7634
|
stampNew(e, t) {
|
|
7632
7635
|
if (t) return e;
|
|
7633
|
-
let n = e.createdAt ??
|
|
7636
|
+
let n = e.createdAt ?? Gn();
|
|
7634
7637
|
return {
|
|
7635
7638
|
...e,
|
|
7636
7639
|
author: e.author ?? this.user.name,
|
|
@@ -7646,16 +7649,16 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7646
7649
|
console.error("[teamsync-pdf-viewer] annotationChanged listener threw", e);
|
|
7647
7650
|
}
|
|
7648
7651
|
}
|
|
7649
|
-
},
|
|
7652
|
+
}, qn = () => {
|
|
7650
7653
|
throw Error("[teamsync-pdf-viewer] viewer is not mounted (was destroy() called?)");
|
|
7651
|
-
},
|
|
7654
|
+
}, Jn = class {
|
|
7652
7655
|
bus;
|
|
7653
7656
|
annotationManager;
|
|
7654
7657
|
element = null;
|
|
7655
7658
|
binding = null;
|
|
7656
7659
|
unmountRoot = null;
|
|
7657
7660
|
destroyed = !1;
|
|
7658
|
-
constructor(e, t = new
|
|
7661
|
+
constructor(e, t = new Kn()) {
|
|
7659
7662
|
this.bus = e, this.annotationManager = t;
|
|
7660
7663
|
}
|
|
7661
7664
|
_bind(e, t) {
|
|
@@ -7691,7 +7694,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7691
7694
|
this.bus.off(e, t);
|
|
7692
7695
|
}
|
|
7693
7696
|
loadDocument(e) {
|
|
7694
|
-
let t = this.binding ??
|
|
7697
|
+
let t = this.binding ?? qn();
|
|
7695
7698
|
return new Promise((n, r) => {
|
|
7696
7699
|
let i = this.bus.on("documentLoaded", (t) => {
|
|
7697
7700
|
t.url === e && (o(), n(t));
|
|
@@ -7766,16 +7769,16 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7766
7769
|
this.bus.emit("action-print");
|
|
7767
7770
|
}
|
|
7768
7771
|
async getFileData(e = {}) {
|
|
7769
|
-
let t = this.binding ??
|
|
7772
|
+
let t = this.binding ?? qn(), n = t.getPdfDocument(), r = t.getDocumentUrl();
|
|
7770
7773
|
if (!n && !r) throw Error("No document loaded");
|
|
7771
|
-
return
|
|
7774
|
+
return pn({
|
|
7772
7775
|
getSourceBytes: async () => {
|
|
7773
7776
|
if (n) return n.getData();
|
|
7774
7777
|
let e = await fetch(r);
|
|
7775
7778
|
if (!e.ok) throw Error(`Failed to fetch document (${e.status})`);
|
|
7776
7779
|
return e.arrayBuffer();
|
|
7777
7780
|
},
|
|
7778
|
-
getPageGeometry: n ?
|
|
7781
|
+
getPageGeometry: n ? en(n) : void 0,
|
|
7779
7782
|
annotations: this.annotationManager.getAnnotationsList(),
|
|
7780
7783
|
redactions: t.getRedactions(),
|
|
7781
7784
|
watermark: t.getWatermark(),
|
|
@@ -7834,7 +7837,7 @@ var Un = 100, Wn = () => (/* @__PURE__ */ new Date()).toISOString(), Gn = class
|
|
|
7834
7837
|
};
|
|
7835
7838
|
//#endregion
|
|
7836
7839
|
//#region src/core/print.ts
|
|
7837
|
-
async function
|
|
7840
|
+
async function Yn(e, t = {}) {
|
|
7838
7841
|
if (typeof document > "u") throw Error("[teamsync-pdf-viewer] printing needs a browser");
|
|
7839
7842
|
let n = new Blob([e], { type: "application/pdf" }), r = URL.createObjectURL(n), i = document.createElement("iframe");
|
|
7840
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) => {
|
|
@@ -7859,11 +7862,11 @@ async function Jn(e, t = {}) {
|
|
|
7859
7862
|
}
|
|
7860
7863
|
//#endregion
|
|
7861
7864
|
//#region src/components/TeamSyncViewer.tsx
|
|
7862
|
-
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) {
|
|
7863
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);
|
|
7864
7867
|
E.current = e;
|
|
7865
|
-
let D = s(null), O = o(() => new
|
|
7866
|
-
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);
|
|
7867
7870
|
let A = se.current;
|
|
7868
7871
|
a(t, () => A, [A]);
|
|
7869
7872
|
let ce = r ?? l, [le, ue] = c(ce), [de, fe] = c(0);
|
|
@@ -7967,7 +7970,7 @@ var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
7967
7970
|
O.on("action-tool-changed", (e) => O.emit("toolChanged", { tool: e?.tool ?? null })),
|
|
7968
7971
|
O.on("action-print", async () => {
|
|
7969
7972
|
try {
|
|
7970
|
-
await
|
|
7973
|
+
await Yn(await A.getFileData(), { title: E.current.fileName });
|
|
7971
7974
|
} catch (e) {
|
|
7972
7975
|
console.error("[teamsync-pdf-viewer] print failed", e), O.emit("action-print-error", { error: e });
|
|
7973
7976
|
}
|
|
@@ -7985,7 +7988,7 @@ var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
7985
7988
|
O.on("action-process-digital-signature", async (e) => {
|
|
7986
7989
|
try {
|
|
7987
7990
|
let { pageIndex: t, x: n, y: r, width: i, height: a } = e, o = {
|
|
7988
|
-
id:
|
|
7991
|
+
id: Xn(),
|
|
7989
7992
|
type: "digital_signature_placeholder",
|
|
7990
7993
|
pageIndex: t,
|
|
7991
7994
|
x: n,
|
|
@@ -8145,9 +8148,9 @@ var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8145
8148
|
setRightSidebarOpen: j,
|
|
8146
8149
|
sidebarTab: ye,
|
|
8147
8150
|
scale: M,
|
|
8148
|
-
onZoomIn: () => xe((e) =>
|
|
8149
|
-
onZoomOut: () => xe((e) =>
|
|
8150
|
-
onZoomSet: (e) => xe(
|
|
8151
|
+
onZoomIn: () => xe((e) => _t(e)),
|
|
8152
|
+
onZoomOut: () => xe((e) => vt(e)),
|
|
8153
|
+
onZoomSet: (e) => xe(yt(e)),
|
|
8151
8154
|
onOpenFile: nt,
|
|
8152
8155
|
onDownload: () => O.emit("action-download"),
|
|
8153
8156
|
onFullScreen: () => {
|
|
@@ -8194,7 +8197,7 @@ var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8194
8197
|
minHeight: 0,
|
|
8195
8198
|
overflow: "hidden"
|
|
8196
8199
|
},
|
|
8197
|
-
children: /* @__PURE__ */ F(
|
|
8200
|
+
children: /* @__PURE__ */ F(qt, {
|
|
8198
8201
|
leftSidebarOpen: w && ge,
|
|
8199
8202
|
rightSidebarOpen: w && ve,
|
|
8200
8203
|
sidebarTab: ye,
|
|
@@ -8229,22 +8232,22 @@ var Yn = () => typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID
|
|
|
8229
8232
|
permissions: P
|
|
8230
8233
|
})
|
|
8231
8234
|
}),
|
|
8232
|
-
Se && /* @__PURE__ */ F(
|
|
8235
|
+
Se && /* @__PURE__ */ F(K, {
|
|
8233
8236
|
onClose: () => Ce(!1),
|
|
8234
8237
|
watermarkText: je,
|
|
8235
8238
|
setWatermarkText: Me
|
|
8236
8239
|
}),
|
|
8237
|
-
N && /* @__PURE__ */ F(
|
|
8240
|
+
N && /* @__PURE__ */ F(Yt, { onClose: () => we(!1) })
|
|
8238
8241
|
]
|
|
8239
8242
|
})
|
|
8240
8243
|
});
|
|
8241
8244
|
});
|
|
8242
8245
|
//#endregion
|
|
8243
8246
|
//#region src/core/createWebViewer.tsx
|
|
8244
|
-
function
|
|
8247
|
+
function Qn(e, t) {
|
|
8245
8248
|
return typeof window > "u" || typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() requires a browser environment.")) : t ? new Promise((n) => {
|
|
8246
8249
|
let r = u.createRoot(t), { path: i, ...a } = e;
|
|
8247
|
-
r.render(/* @__PURE__ */ F(
|
|
8250
|
+
r.render(/* @__PURE__ */ F(Zn, {
|
|
8248
8251
|
...a,
|
|
8249
8252
|
style: {
|
|
8250
8253
|
width: "100%",
|
|
@@ -8256,8 +8259,8 @@ function Zn(e, t) {
|
|
|
8256
8259
|
}));
|
|
8257
8260
|
}) : Promise.reject(/* @__PURE__ */ Error("[teamsync-pdf-viewer] createWebViewer() needs a container element."));
|
|
8258
8261
|
}
|
|
8259
|
-
var
|
|
8262
|
+
var $n = Qn;
|
|
8260
8263
|
//#endregion
|
|
8261
|
-
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 };
|
|
8262
8265
|
|
|
8263
8266
|
//# sourceMappingURL=teamsync-pdf-viewer.js.map
|