epochs-pdf 0.1.6 → 0.1.8

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.
@@ -1,30 +1,30 @@
1
- var zi = Object.defineProperty;
2
- var ji = (t, e, n) => e in t ? zi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var Je = (t, e, n) => ji(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { useRef as xt, useState as j, useEffect as Pt, useMemo as be, useCallback as K, Fragment as Si } from "react";
5
- import { jsxs as L, jsx as s, Fragment as Fe } from "react/jsx-runtime";
6
- import * as ve from "pdfjs-dist";
7
- import { TextLayer as Bi } from "pdfjs-dist";
8
- const De = "#ffffff", Ln = [
1
+ var ji = Object.defineProperty;
2
+ var Bi = (t, e, n) => e in t ? ji(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var on = (t, e, n) => Bi(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { useRef as xt, useState as O, useEffect as Dt, useMemo as Pe, useCallback as Y, Fragment as Wi } from "react";
5
+ import { jsxs as T, jsx as s, Fragment as je } from "react/jsx-runtime";
6
+ import * as Ie from "pdfjs-dist";
7
+ import { TextLayer as Oi } from "pdfjs-dist";
8
+ const He = "#ffffff", An = [
9
9
  { id: "yellow", label: "Yellow", hex: "#facc15" },
10
10
  { id: "green", label: "Green", hex: "#4ade80" },
11
11
  { id: "pink", label: "Pink", hex: "#f472b6" },
12
12
  { id: "blue", label: "Blue", hex: "#60a5fa" },
13
13
  { id: "orange", label: "Orange", hex: "#fb923c" },
14
14
  { id: "purple", label: "Purple", hex: "#c084fc" }
15
- ], Fn = [
15
+ ], En = [
16
16
  { id: "blue", label: "Blue", hex: "#2563eb" },
17
17
  { id: "red", label: "Red", hex: "#dc2626" },
18
18
  { id: "green", label: "Green", hex: "#16a34a" },
19
19
  { id: "orange", label: "Orange", hex: "#ea580c" },
20
20
  { id: "purple", label: "Purple", hex: "#7c3aed" },
21
21
  { id: "black", label: "Black", hex: "#111827" }
22
- ], Rn = Ln[0].hex, Oi = Fn[0].hex;
23
- An(Rn, "highlight");
24
- function tn() {
22
+ ], Hn = An[0].hex, zi = En[0].hex;
23
+ Un(Hn, "highlight");
24
+ function sn() {
25
25
  return `m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
26
26
  }
27
- function oe(t) {
27
+ function le(t) {
28
28
  const e = t.trim();
29
29
  if (/^#[0-9a-fA-F]{6}$/.test(e)) return e.toLowerCase();
30
30
  if (/^#[0-9a-fA-F]{3}$/.test(e)) {
@@ -33,15 +33,15 @@ function oe(t) {
33
33
  }
34
34
  return e;
35
35
  }
36
- function An(t, e, n = 0.45) {
37
- const i = oe(t);
36
+ function Un(t, e, n = 0.45) {
37
+ const i = le(t);
38
38
  if (e === "underline" || e === "redact") return i;
39
39
  const r = /^#([0-9a-f]{6})$/i.exec(i);
40
40
  if (!r) return `rgba(250, 204, 21, ${n})`;
41
41
  const o = Number.parseInt(r[1], 16), d = o >> 16 & 255, u = o >> 8 & 255, m = o & 255;
42
42
  return `rgba(${d}, ${u}, ${m}, ${n})`;
43
43
  }
44
- function en(t, e) {
44
+ function an(t, e) {
45
45
  const n = window.getSelection();
46
46
  if (!n || n.isCollapsed || n.rangeCount === 0)
47
47
  return null;
@@ -60,7 +60,7 @@ function en(t, e) {
60
60
  h: r.height > 0 ? _.height / r.height * (m / d) : 0
61
61
  })), text: n.toString() };
62
62
  }
63
- function xn(t) {
63
+ function Nn(t) {
64
64
  const n = [...t].sort((i, r) => i.y - r.y || i.x - r.x)[0] ?? { x: 0, y: 0, h: 14 };
65
65
  return {
66
66
  x: n.x,
@@ -68,7 +68,7 @@ function xn(t) {
68
68
  fontSize: Math.max(8, Math.round(n.h * 0.9) || 14)
69
69
  };
70
70
  }
71
- function nn(t, e = 2) {
71
+ function cn(t, e = 2) {
72
72
  return t.map((n) => ({
73
73
  x: Math.max(0, n.x - e),
74
74
  y: Math.max(0, n.y - e),
@@ -76,14 +76,14 @@ function nn(t, e = 2) {
76
76
  h: n.h + e * 2
77
77
  }));
78
78
  }
79
- function En(t, e, n) {
79
+ function jn(t, e, n) {
80
80
  for (const i of e)
81
81
  for (const r of i.rects) {
82
82
  const o = r.x * n, d = r.y * n, u = r.w * n, m = r.h * n;
83
83
  if (i.kind === "highlight")
84
84
  t.save(), t.globalCompositeOperation = "multiply", t.fillStyle = i.color, t.fillRect(o, d, u, m), t.restore();
85
85
  else if (i.kind === "redact")
86
- t.fillStyle = i.color || De, t.fillRect(o, d, u, m);
86
+ t.fillStyle = i.color || He, t.fillRect(o, d, u, m);
87
87
  else {
88
88
  const g = Math.max(2, n * 1.5);
89
89
  t.fillStyle = i.color, t.fillRect(o, d + m - g, u, g);
@@ -93,7 +93,7 @@ function En(t, e, n) {
93
93
  function Se() {
94
94
  return `s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
95
95
  }
96
- async function Un(t, e, n) {
96
+ async function Bn(t, e, n) {
97
97
  for (const i of e) {
98
98
  const r = await Gi(i.imageDataUrl);
99
99
  t.drawImage(
@@ -105,7 +105,7 @@ async function Un(t, e, n) {
105
105
  );
106
106
  }
107
107
  }
108
- function Wi(t, e, n, i) {
108
+ function Si(t, e, n, i) {
109
109
  t.save();
110
110
  for (const r of e) {
111
111
  const o = n.has(r.id), d = r.x * i, u = r.y * i, m = r.width * i, g = r.height * i;
@@ -128,14 +128,14 @@ function Xi(t, e, n = 180, i = 64) {
128
128
  height: Math.max(20, e * r)
129
129
  };
130
130
  }
131
- function He(t, e, n, i) {
131
+ function We(t, e, n, i) {
132
132
  const r = n.getBoundingClientRect(), o = n.clientWidth || r.width, d = n.clientHeight || r.height;
133
133
  return r.width <= 0 || r.height <= 0 || i <= 0 ? { x: 0, y: 0 } : {
134
134
  x: (t - r.left) / r.width * (o / i),
135
135
  y: (e - r.top) / r.height * (d / i)
136
136
  };
137
137
  }
138
- function xe(t, e) {
138
+ function Ce(t, e) {
139
139
  return {
140
140
  width: t.clientWidth / e,
141
141
  height: t.clientHeight / e
@@ -148,8 +148,8 @@ function Vi(t, e, n, i) {
148
148
  dy: e / r.height * (d / i)
149
149
  };
150
150
  }
151
- function Mn(t, e, n) {
152
- const i = e.getBoundingClientRect(), { width: r, height: o } = xe(e, n);
151
+ function Pn(t, e, n) {
152
+ const i = e.getBoundingClientRect(), { width: r, height: o } = Ce(e, n);
153
153
  return i.width <= 0 || i.height <= 0 ? { left: 0, top: 0, right: r, bottom: o } : {
154
154
  left: (t.left - i.left) / i.width * r,
155
155
  top: (t.top - i.top) / i.height * o,
@@ -157,58 +157,58 @@ function Mn(t, e, n) {
157
157
  bottom: (t.bottom - i.top) / i.height * o
158
158
  };
159
159
  }
160
- const he = 14, de = "#111827", rn = 24, on = 20;
161
- function Be() {
160
+ const we = 14, me = "#111827", ln = 24, dn = 20;
161
+ function Ge() {
162
162
  return `t_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
163
163
  }
164
- function Ie(t, e) {
164
+ function Re(t, e) {
165
165
  if (typeof document > "u")
166
166
  return {
167
- width: Math.max(rn, t.length * e * 0.55),
168
- height: Math.max(on, e * 1.25)
167
+ width: Math.max(ln, t.length * e * 0.55),
168
+ height: Math.max(dn, e * 1.25)
169
169
  };
170
170
  const i = document.createElement("canvas").getContext("2d");
171
171
  if (!i)
172
172
  return {
173
- width: Math.max(rn, t.length * e * 0.55),
174
- height: Math.max(on, e * 1.25)
173
+ width: Math.max(ln, t.length * e * 0.55),
174
+ height: Math.max(dn, e * 1.25)
175
175
  };
176
176
  i.font = `${e}px sans-serif`;
177
177
  const r = t.split(`
178
178
  `), o = e * 1.25;
179
- let d = rn;
179
+ let d = ln;
180
180
  for (const u of r)
181
181
  d = Math.max(d, i.measureText(u || " ").width + 4);
182
182
  return {
183
183
  width: d,
184
- height: Math.max(on, r.length * o)
184
+ height: Math.max(dn, r.length * o)
185
185
  };
186
186
  }
187
187
  function qi(t, e, n, i, r) {
188
- var J;
189
- const o = n.getBoundingClientRect(), d = n.clientWidth || o.width, u = n.clientHeight || o.height, m = (T) => o.width > 0 ? (T - o.left) / o.width * (d / r) : 0, g = (T) => o.height > 0 ? (T - o.top) / o.height * (u / r) : 0, _ = (T, at) => {
190
- const ct = at === "x" ? o.width : o.height, Z = at === "x" ? d : u;
191
- return ct > 0 ? T / ct * (Z / r) : 0;
188
+ var A;
189
+ const o = n.getBoundingClientRect(), d = n.clientWidth || o.width, u = n.clientHeight || o.height, m = (C) => o.width > 0 ? (C - o.left) / o.width * (d / r) : 0, g = (C) => o.height > 0 ? (C - o.top) / o.height * (u / r) : 0, _ = (C, nt) => {
190
+ const at = nt === "x" ? o.width : o.height, q = nt === "x" ? d : u;
191
+ return at > 0 ? C / at * (q / r) : 0;
192
192
  };
193
- let b = m(t), y = g(e), M = he;
194
- const $ = Yi(t, e, i);
195
- if ($)
193
+ let y = m(t), b = g(e), x = we;
194
+ const I = Yi(t, e, i);
195
+ if (I)
196
196
  return {
197
- x: m($.x),
198
- y: g($.y),
199
- fontSize: Math.max(8, Math.round(_($.fontSize, "y") * 10) / 10)
197
+ x: m(I.x),
198
+ y: g(I.y),
199
+ fontSize: Math.max(8, Math.round(_(I.fontSize, "y") * 10) / 10)
200
200
  };
201
- const S = document, H = (J = S.caretRangeFromPoint) == null ? void 0 : J.call(S, t, e);
201
+ const S = document, H = (A = S.caretRangeFromPoint) == null ? void 0 : A.call(S, t, e);
202
202
  if (H && i.contains(H.startContainer)) {
203
- const T = H.getClientRects(), at = T.length > 0 ? T[0] : H.getBoundingClientRect();
204
- if (at.height > 0) {
205
- y = g(at.top), M = Zi(H.startContainer, r, n);
206
- const ct = m(at.left);
207
- return Math.abs(ct - b) < _(8, "x") && (b = ct), { x: b, y, fontSize: M };
203
+ const C = H.getClientRects(), nt = C.length > 0 ? C[0] : H.getBoundingClientRect();
204
+ if (nt.height > 0) {
205
+ b = g(nt.top), x = Zi(H.startContainer, r, n);
206
+ const at = m(nt.left);
207
+ return Math.abs(at - y) < _(8, "x") && (y = at), { x: y, y: b, fontSize: x };
208
208
  }
209
209
  }
210
- const F = Ki(t, e, i);
211
- return F && (y = g(F.top), M = Math.max(8, Math.round(_(F.height, "y") * 10) / 10)), { x: b, y, fontSize: M };
210
+ const W = Ki(t, e, i);
211
+ return W && (b = g(W.top), x = Math.max(8, Math.round(_(W.height, "y") * 10) / 10)), { x: y, y: b, fontSize: x };
212
212
  }
213
213
  function Yi(t, e, n) {
214
214
  var o;
@@ -257,7 +257,7 @@ function Ki(t, e, n) {
257
257
  }
258
258
  function Zi(t, e, n) {
259
259
  const i = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
260
- return i ? Qi(i, e, n) : he;
260
+ return i ? Qi(i, e, n) : we;
261
261
  }
262
262
  function Qi(t, e, n) {
263
263
  const i = t.getBoundingClientRect().height;
@@ -273,7 +273,7 @@ function Qi(t, e, n) {
273
273
  return Math.max(8, Math.round(i / e * 10) / 10);
274
274
  }
275
275
  const r = window.getComputedStyle(t).fontSize, o = Number.parseFloat(r);
276
- return Number.isFinite(o) && o > 0 ? Math.max(8, Math.round(o / e * 10) / 10) : he;
276
+ return Number.isFinite(o) && o > 0 ? Math.max(8, Math.round(o / e * 10) / 10) : we;
277
277
  }
278
278
  function Ji(t, e, n, i) {
279
279
  for (const r of n)
@@ -282,26 +282,26 @@ function Ji(t, e, n, i) {
282
282
  return null;
283
283
  }
284
284
  function tr(t, e, n) {
285
- var M;
285
+ var x;
286
286
  if (!n) return null;
287
- const i = document, r = (M = i.caretRangeFromPoint) == null ? void 0 : M.call(i, t, e);
287
+ const i = document, r = (x = i.caretRangeFromPoint) == null ? void 0 : x.call(i, t, e);
288
288
  if (!r || !n.contains(r.startContainer)) return null;
289
289
  const o = r.startContainer;
290
290
  if (o.nodeType !== Node.TEXT_NODE || !o.textContent) return null;
291
291
  const d = o.textContent;
292
292
  let u = r.startOffset;
293
293
  u = Math.min(Math.max(0, u), d.length);
294
- const m = ($) => /[\p{L}\p{N}_'-]/u.test($);
294
+ const m = (I) => /[\p{L}\p{N}_'-]/u.test(I);
295
295
  let g = u, _ = u;
296
296
  for (; g > 0 && m(d[g - 1]); ) g -= 1;
297
297
  for (; _ < d.length && m(d[_]); ) _ += 1;
298
298
  if (g === _) return null;
299
- const b = document.createRange();
300
- b.setStart(o, g), b.setEnd(o, _);
301
- const y = window.getSelection();
302
- return y == null || y.removeAllRanges(), y == null || y.addRange(b), d.slice(g, _);
299
+ const y = document.createRange();
300
+ y.setStart(o, g), y.setEnd(o, _);
301
+ const b = window.getSelection();
302
+ return b == null || b.removeAllRanges(), b == null || b.addRange(y), d.slice(g, _);
303
303
  }
304
- function Hn(t, e, n) {
304
+ function Wn(t, e, n) {
305
305
  t.save();
306
306
  for (const i of e) {
307
307
  if (!i.value.trim()) continue;
@@ -323,7 +323,7 @@ function er(t, e, n, i) {
323
323
  }
324
324
  t.restore();
325
325
  }
326
- function Ut({
326
+ function Bt({
327
327
  size: t = 14,
328
328
  className: e,
329
329
  children: n
@@ -347,27 +347,27 @@ function Ut({
347
347
  );
348
348
  }
349
349
  function nr(t) {
350
- return /* @__PURE__ */ s(Ut, { ...t, children: /* @__PURE__ */ s("polyline", { points: "15 18 9 12 15 6" }) });
350
+ return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("polyline", { points: "15 18 9 12 15 6" }) });
351
351
  }
352
352
  function ir(t) {
353
- return /* @__PURE__ */ s(Ut, { ...t, children: /* @__PURE__ */ s("polyline", { points: "9 18 15 12 9 6" }) });
353
+ return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("polyline", { points: "9 18 15 12 9 6" }) });
354
354
  }
355
355
  function rr(t) {
356
- return /* @__PURE__ */ L(Ut, { ...t, children: [
356
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
357
357
  /* @__PURE__ */ s("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
358
358
  /* @__PURE__ */ s("polyline", { points: "7 10 12 15 17 10" }),
359
359
  /* @__PURE__ */ s("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
360
360
  ] });
361
361
  }
362
362
  function or(t) {
363
- return /* @__PURE__ */ L(Ut, { ...t, children: [
363
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
364
364
  /* @__PURE__ */ s("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
365
365
  /* @__PURE__ */ s("polyline", { points: "15 3 21 3 21 9" }),
366
366
  /* @__PURE__ */ s("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
367
367
  ] });
368
368
  }
369
369
  function sr(t) {
370
- return /* @__PURE__ */ L(Ut, { ...t, children: [
370
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
371
371
  /* @__PURE__ */ s("rect", { x: "3", y: "3", width: "7", height: "7" }),
372
372
  /* @__PURE__ */ s("rect", { x: "14", y: "3", width: "7", height: "7" }),
373
373
  /* @__PURE__ */ s("rect", { x: "14", y: "14", width: "7", height: "7" }),
@@ -375,48 +375,48 @@ function sr(t) {
375
375
  ] });
376
376
  }
377
377
  function ar(t) {
378
- return /* @__PURE__ */ s(Ut, { ...t, children: /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
378
+ return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
379
379
  }
380
380
  function cr(t) {
381
- return /* @__PURE__ */ L(Ut, { ...t, children: [
381
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
382
382
  /* @__PURE__ */ s("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
383
383
  /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
384
384
  ] });
385
385
  }
386
386
  function lr(t) {
387
- return /* @__PURE__ */ L(Ut, { ...t, children: [
387
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
388
388
  /* @__PURE__ */ s("polyline", { points: "6 9 6 2 18 2 18 9" }),
389
389
  /* @__PURE__ */ s("path", { d: "M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" }),
390
390
  /* @__PURE__ */ s("rect", { x: "6", y: "14", width: "12", height: "8" })
391
391
  ] });
392
392
  }
393
393
  function dr(t) {
394
- return /* @__PURE__ */ L(Ut, { ...t, children: [
394
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
395
395
  /* @__PURE__ */ s("polyline", { points: "23 4 23 10 17 10" }),
396
396
  /* @__PURE__ */ s("polyline", { points: "1 20 1 14 7 14" }),
397
397
  /* @__PURE__ */ s("path", { d: "M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" })
398
398
  ] });
399
399
  }
400
400
  function hr(t) {
401
- return /* @__PURE__ */ L(Ut, { ...t, children: [
401
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
402
402
  /* @__PURE__ */ s("polyline", { points: "23 4 23 10 17 10" }),
403
403
  /* @__PURE__ */ s("path", { d: "M20.49 15a9 9 0 1 1-2.12-9.36L23 10" })
404
404
  ] });
405
405
  }
406
406
  function ur(t) {
407
- return /* @__PURE__ */ L(Ut, { ...t, children: [
407
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
408
408
  /* @__PURE__ */ s("path", { d: "M12 20h9" }),
409
409
  /* @__PURE__ */ s("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
410
410
  ] });
411
411
  }
412
412
  function fr(t) {
413
- return /* @__PURE__ */ L(Ut, { ...t, children: [
413
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
414
414
  /* @__PURE__ */ s("path", { d: "M6 3v7a6 6 0 0 0 12 0V3" }),
415
415
  /* @__PURE__ */ s("line", { x1: "4", y1: "21", x2: "20", y2: "21" })
416
416
  ] });
417
417
  }
418
418
  function pr(t) {
419
- return /* @__PURE__ */ L(Ut, { ...t, children: [
419
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
420
420
  /* @__PURE__ */ s("path", { d: "m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21" }),
421
421
  /* @__PURE__ */ s("path", { d: "M22 21H7" }),
422
422
  /* @__PURE__ */ s("path", { d: "m5 11 9 9" })
@@ -441,13 +441,13 @@ function gr({ size: t = 16, className: e }) {
441
441
  );
442
442
  }
443
443
  function mr(t) {
444
- return /* @__PURE__ */ L(Ut, { ...t, children: [
444
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
445
445
  /* @__PURE__ */ s("path", { d: "M12 20h9" }),
446
446
  /* @__PURE__ */ s("path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" })
447
447
  ] });
448
448
  }
449
449
  function wr(t) {
450
- return /* @__PURE__ */ L(Ut, { ...t, children: [
450
+ return /* @__PURE__ */ T(Bt, { ...t, children: [
451
451
  /* @__PURE__ */ s("polyline", { points: "4 7 4 4 20 4 20 7" }),
452
452
  /* @__PURE__ */ s("line", { x1: "9", y1: "20", x2: "15", y2: "20" }),
453
453
  /* @__PURE__ */ s("line", { x1: "12", y1: "4", x2: "12", y2: "20" })
@@ -465,142 +465,142 @@ function yr({
465
465
  annotations: m = [],
466
466
  onAddAnnotation: g,
467
467
  onRemoveAnnotation: _,
468
- signatures: b = [],
469
- pendingSignature: y = null,
470
- onAddSignature: M,
471
- onUpdateSignature: $,
468
+ signatures: y = [],
469
+ pendingSignature: b = null,
470
+ onAddSignature: x,
471
+ onUpdateSignature: I,
472
472
  onRemoveSignature: S,
473
473
  onEditSignature: H,
474
- onDuplicateSignature: F,
475
- selectedSignatureId: J = null,
476
- onSelectSignature: T,
477
- signatureFields: at = [],
478
- selectedSignatureFieldId: ct = null,
479
- onSelectSignatureField: Z,
480
- hasFixedSignatureFields: tt = !1,
481
- onOpenSignaturePad: bt,
474
+ onDuplicateSignature: W,
475
+ selectedSignatureId: A = null,
476
+ onSelectSignature: C,
477
+ signatureFields: nt = [],
478
+ selectedSignatureFieldId: at = null,
479
+ onSelectSignatureField: q,
480
+ hasFixedSignatureFields: pt = !1,
481
+ onOpenSignaturePad: J,
482
482
  fieldValues: Mt = {},
483
- onFieldValueChange: Y,
484
- onFieldValueCommit: Tt,
485
- pendingFieldValue: gt = null,
486
- onPlaceFieldValue: z,
487
- texts: nt = [],
488
- onAddText: it,
489
- onUpdateText: vt,
490
- onRemoveText: q,
491
- selectedTextId: Zt = null,
492
- onSelectText: ut,
493
- textFields: Qt = [],
494
- selectedTextFieldId: Re = null,
495
- onSelectTextField: Bt,
496
- hasFixedTextFields: Yt = !1,
497
- editingTextId: Dt = null,
498
- onEditingTextIdChange: O
483
+ onFieldValueChange: K,
484
+ onFieldValueCommit: Et,
485
+ pendingFieldValue: vt = null,
486
+ onPlaceFieldValue: E,
487
+ texts: ct = [],
488
+ onAddText: ut,
489
+ onUpdateText: gt,
490
+ onRemoveText: tt,
491
+ selectedTextId: kt = null,
492
+ onSelectText: dt,
493
+ textFields: te = [],
494
+ selectedTextFieldId: ye = null,
495
+ onSelectTextField: Vt,
496
+ hasFixedTextFields: qt = !1,
497
+ editingTextId: Kt = null,
498
+ onEditingTextIdChange: G
499
499
  }) {
500
- const $t = xt(null), Lt = xt(null), mt = xt(null), lt = xt(null), Ht = xt(null), rt = xt(null), [wt, It] = j(null), Jt = xt(null), ft = xt(!1);
501
- Pt(() => {
502
- if (!t || !Lt.current || !mt.current || !lt.current)
500
+ const $t = xt(null), yt = xt(null), bt = xt(null), it = xt(null), Wt = xt(null), st = xt(null), [mt, It] = O(null), ee = xt(null), ht = xt(!1);
501
+ Dt(() => {
502
+ if (!t || !yt.current || !bt.current || !it.current)
503
503
  return;
504
504
  let a = !1;
505
- const w = Lt.current, v = mt.current, x = lt.current, R = w.getContext("2d");
506
- return R ? ((async () => {
505
+ const w = yt.current, v = bt.current, M = it.current, D = w.getContext("2d");
506
+ return D ? ((async () => {
507
507
  try {
508
- if (Ht.current) {
508
+ if (Wt.current) {
509
509
  try {
510
- Ht.current.cancel();
510
+ Wt.current.cancel();
511
511
  } catch {
512
512
  }
513
- Ht.current = null;
513
+ Wt.current = null;
514
514
  }
515
- if (rt.current) {
515
+ if (st.current) {
516
516
  try {
517
- rt.current.cancel();
517
+ st.current.cancel();
518
518
  } catch {
519
519
  }
520
- rt.current = null;
520
+ st.current = null;
521
521
  }
522
- const A = await t.getPage(e);
522
+ const F = await t.getPage(e);
523
523
  if (a) return;
524
- const N = A.getViewport({ scale: n, rotation: i }), E = Math.floor(N.width), W = Math.floor(N.height);
525
- w.width = E, w.height = W, x.style.width = `${E}px`, x.style.height = `${W}px`;
526
- const D = A.render({ canvasContext: R, viewport: N });
527
- if (Ht.current = D, await D.promise, a) return;
524
+ const N = F.getViewport({ scale: n, rotation: i }), j = Math.floor(N.width), Z = Math.floor(N.height);
525
+ w.width = j, w.height = Z, M.style.width = `${j}px`, M.style.height = `${Z}px`;
526
+ const R = F.render({ canvasContext: D, viewport: N });
527
+ if (Wt.current = R, await R.promise, a) return;
528
528
  v.replaceChildren(), v.style.setProperty("--scale-factor", String(N.scale));
529
- const ot = await A.getTextContent();
529
+ const lt = await F.getTextContent();
530
530
  if (a) return;
531
- const G = new Bi({
532
- textContentSource: ot,
531
+ const X = new Oi({
532
+ textContentSource: lt,
533
533
  container: v,
534
534
  viewport: N
535
535
  });
536
- if (rt.current = G, await G.render(), a) return;
536
+ if (st.current = X, await X.render(), a) return;
537
537
  o == null || o(e);
538
538
  } catch {
539
539
  }
540
540
  })(), () => {
541
- if (a = !0, Ht.current) {
541
+ if (a = !0, Wt.current) {
542
542
  try {
543
- Ht.current.cancel();
543
+ Wt.current.cancel();
544
544
  } catch {
545
545
  }
546
- Ht.current = null;
546
+ Wt.current = null;
547
547
  }
548
- if (rt.current) {
548
+ if (st.current) {
549
549
  try {
550
- rt.current.cancel();
550
+ st.current.cancel();
551
551
  } catch {
552
552
  }
553
- rt.current = null;
553
+ st.current = null;
554
554
  }
555
555
  }) : void 0;
556
- }, [t, e, n, i, o]), Pt(() => {
557
- const a = lt.current;
556
+ }, [t, e, n, i, o]), Dt(() => {
557
+ const a = it.current;
558
558
  if (!a) return;
559
559
  const w = (P) => {
560
- var W;
560
+ var Z;
561
561
  if (!g) return !1;
562
- const A = P === "redact" ? De : u;
563
- if (!A) return !1;
564
- const N = en(a, n);
562
+ const F = P === "redact" ? He : u;
563
+ if (!F) return !1;
564
+ const N = an(a, n);
565
565
  if (!N) return !1;
566
- const E = P === "redact" ? nn(N.rects) : N.rects;
566
+ const j = P === "redact" ? cn(N.rects) : N.rects;
567
567
  return g({
568
- id: tn(),
568
+ id: sn(),
569
569
  pageNumber: e,
570
570
  kind: P,
571
- color: A,
572
- rects: E,
571
+ color: F,
572
+ rects: j,
573
573
  text: N.text
574
- }), (W = window.getSelection()) == null || W.removeAllRanges(), !0;
574
+ }), (Z = window.getSelection()) == null || Z.removeAllRanges(), !0;
575
575
  }, v = (P) => {
576
- var ot;
577
- if (!g || !it) return !1;
578
- const A = en(a, n);
579
- if (!A) return !1;
580
- const N = nn(A.rects);
576
+ var lt;
577
+ if (!g || !ut) return !1;
578
+ const F = an(a, n);
579
+ if (!F) return !1;
580
+ const N = cn(F.rects);
581
581
  g({
582
- id: tn(),
582
+ id: sn(),
583
583
  pageNumber: e,
584
584
  kind: "redact",
585
- color: De,
585
+ color: He,
586
586
  rects: N,
587
- text: A.text
587
+ text: F.text
588
588
  });
589
- const E = xn(A.rects), W = Ie(P || " ", E.fontSize), D = {
590
- id: Be(),
589
+ const j = Nn(F.rects), Z = Re(P || " ", j.fontSize), R = {
590
+ id: Ge(),
591
591
  pageNumber: e,
592
- x: E.x,
593
- y: E.y,
594
- width: W.width,
595
- height: W.height,
592
+ x: j.x,
593
+ y: j.y,
594
+ width: Z.width,
595
+ height: Z.height,
596
596
  value: P,
597
- fontSize: E.fontSize,
598
- color: de
597
+ fontSize: j.fontSize,
598
+ color: me
599
599
  };
600
- return it(D), ut == null || ut(D.id), O == null || O(D.id), (ot = window.getSelection()) == null || ot.removeAllRanges(), ft.current = !0, window.setTimeout(() => {
601
- ft.current = !1;
600
+ return ut(R), dt == null || dt(R.id), G == null || G(R.id), (lt = window.getSelection()) == null || lt.removeAllRanges(), ht.current = !0, window.setTimeout(() => {
601
+ ht.current = !1;
602
602
  }, 0), !0;
603
- }, x = () => {
603
+ }, M = () => {
604
604
  if (d === "highlight" || d === "underline") {
605
605
  w(d);
606
606
  return;
@@ -613,12 +613,12 @@ function yr({
613
613
  const P = window.getSelection();
614
614
  P && !P.isCollapsed && P.toString().trim() && P.anchorNode && a.contains(P.anchorNode) && v(P.toString());
615
615
  }
616
- }, R = (P) => {
617
- const A = P.target;
618
- if (A != null && A.closest("[contenteditable='true']") || A != null && A.closest("[contenteditable='']") || A != null && A.isContentEditable)
616
+ }, D = (P) => {
617
+ const F = P.target;
618
+ if (F != null && F.closest("[contenteditable='true']") || F != null && F.closest("[contenteditable='']") || F != null && F.isContentEditable)
619
619
  return;
620
- const N = window.getSelection(), E = N != null && !N.isCollapsed && N.toString().trim().length > 0 && N.anchorNode != null && a.contains(N.anchorNode);
621
- if (d === "text" && E) {
620
+ const N = window.getSelection(), j = N != null && !N.isCollapsed && N.toString().trim().length > 0 && N.anchorNode != null && a.contains(N.anchorNode);
621
+ if (d === "text" && j) {
622
622
  if (P.key === "Enter" && !P.shiftKey) {
623
623
  P.preventDefault(), v(N.toString());
624
624
  return;
@@ -628,245 +628,245 @@ function yr({
628
628
  return;
629
629
  }
630
630
  }
631
- d !== "text" && d !== "erase" || P.key !== "Backspace" && P.key !== "Delete" || E && (P.preventDefault(), w("redact"));
631
+ d !== "text" && d !== "erase" || P.key !== "Backspace" && P.key !== "Delete" || j && (P.preventDefault(), w("redact"));
632
632
  };
633
- return a.addEventListener("mouseup", x), window.addEventListener("keydown", R), () => {
634
- a.removeEventListener("mouseup", x), window.removeEventListener("keydown", R);
633
+ return a.addEventListener("mouseup", M), window.addEventListener("keydown", D), () => {
634
+ a.removeEventListener("mouseup", M), window.removeEventListener("keydown", D);
635
635
  };
636
636
  }, [
637
637
  d,
638
638
  u,
639
639
  g,
640
- it,
641
- O,
642
640
  ut,
641
+ G,
642
+ dt,
643
643
  e,
644
644
  n
645
- ]), Pt(() => {
646
- if (!wt) return;
647
- let a = 0, w = 0, v = 0, x = 0;
648
- const R = () => {
649
- var D;
650
- return (D = $t.current) == null ? void 0 : D.closest(".epochs-pdf-viewer__body");
651
- }, P = (D, ot) => {
652
- if (wt.kind !== "resize" || !$ || tt) return;
653
- const G = b.find((pt) => pt.id === wt.id);
654
- if (!G) return;
655
- const dt = lt.current, _t = dt ? xe(dt, n) : { width: 1 / 0, height: 1 / 0 }, { dx: Rt, dy: zt } = dt ? Vi(
656
- D - wt.startX,
657
- ot - wt.startY,
658
- dt,
645
+ ]), Dt(() => {
646
+ if (!mt) return;
647
+ let a = 0, w = 0, v = 0, M = 0;
648
+ const D = () => {
649
+ var R;
650
+ return (R = $t.current) == null ? void 0 : R.closest(".epochs-pdf-viewer__body");
651
+ }, P = (R, lt) => {
652
+ if (mt.kind !== "resize" || !I || pt) return;
653
+ const X = y.find((_t) => _t.id === mt.id);
654
+ if (!X) return;
655
+ const et = it.current, ft = et ? Ce(et, n) : { width: 1 / 0, height: 1 / 0 }, { dx: Ft, dy: Rt } = et ? Vi(
656
+ R - mt.startX,
657
+ lt - mt.startY,
658
+ et,
659
659
  n
660
- ) : { dx: 0, dy: 0 }, qt = _t.width - G.x, At = _t.height - G.y, Ot = Math.min(qt, Math.max(40, wt.startW + Rt)), ht = Math.min(At, Math.max(20, wt.startH + zt));
661
- $(wt.id, { width: Ot, height: ht });
662
- }, A = (D, ot) => {
663
- var te;
664
- if (wt.kind !== "signature" || !$ || tt) return;
665
- const G = b.find((ue) => ue.id === wt.id);
666
- if (!G) return;
667
- let dt = (te = document.elementFromPoint(D, ot)) == null ? void 0 : te.closest("[data-page-number]");
668
- if (dt || (dt = Array.from(
660
+ ) : { dx: 0, dy: 0 }, Ht = ft.width - X.x, At = ft.height - X.y, St = Math.min(Ht, Math.max(40, mt.startW + Ft)), Pt = Math.min(At, Math.max(20, mt.startH + Rt));
661
+ I(mt.id, { width: St, height: Pt });
662
+ }, F = (R, lt) => {
663
+ var Ut;
664
+ if (mt.kind !== "signature" || !I || pt) return;
665
+ const X = y.find((Yt) => Yt.id === mt.id);
666
+ if (!X) return;
667
+ let et = (Ut = document.elementFromPoint(R, lt)) == null ? void 0 : Ut.closest("[data-page-number]");
668
+ if (et || (et = Array.from(
669
669
  document.querySelectorAll(".epochs-pdf-viewer__page[data-page-number]")
670
- ).find((ee) => {
671
- const Ae = ee.getBoundingClientRect();
672
- return ot >= Ae.top && ot <= Ae.bottom;
673
- }) ?? null), dt || (dt = $t.current), !dt) return;
674
- const _t = dt.querySelector(
670
+ ).find((Gt) => {
671
+ const be = Gt.getBoundingClientRect();
672
+ return lt >= be.top && lt <= be.bottom;
673
+ }) ?? null), et || (et = $t.current), !et) return;
674
+ const ft = et.querySelector(
675
675
  ".epochs-pdf-viewer__surface"
676
676
  );
677
- if (!_t) return;
678
- const Rt = Number.parseInt(
679
- dt.getAttribute("data-page-number") || String(G.pageNumber),
677
+ if (!ft) return;
678
+ const Ft = Number.parseInt(
679
+ et.getAttribute("data-page-number") || String(X.pageNumber),
680
680
  10
681
- ), zt = He(D, ot, _t, n), qt = xe(_t, n);
682
- let At = zt.x - wt.offsetX, Ot = zt.y - wt.offsetY;
683
- const ht = Math.max(0, qt.width - G.width), pt = Math.max(0, qt.height - G.height);
684
- At = Math.min(Math.max(0, At), ht), Ot = Math.min(Math.max(0, Ot), pt), $(wt.id, {
685
- pageNumber: Rt,
681
+ ), Rt = We(R, lt, ft, n), Ht = Ce(ft, n);
682
+ let At = Rt.x - mt.offsetX, St = Rt.y - mt.offsetY;
683
+ const Pt = Math.max(0, Ht.width - X.width), _t = Math.max(0, Ht.height - X.height);
684
+ At = Math.min(Math.max(0, At), Pt), St = Math.min(Math.max(0, St), _t), I(mt.id, {
685
+ pageNumber: Ft,
686
686
  x: At,
687
- y: Ot
687
+ y: St
688
688
  });
689
689
  }, N = () => {
690
- if (a = 0, !x) return;
691
- const D = R();
692
- if (!D) return;
693
- const ot = D.scrollHeight - D.clientHeight;
694
- if (ot <= 0) return;
695
- const G = 56, dt = D.getBoundingClientRect(), _t = v - dt.top, Rt = dt.bottom - v;
696
- let zt = 0;
697
- if (x < 0 && _t < G)
698
- zt = -Math.max(6, (G - _t) / G * 28);
699
- else if (x > 0 && Rt < G)
700
- zt = Math.max(6, (G - Rt) / G * 28);
690
+ if (a = 0, !M) return;
691
+ const R = D();
692
+ if (!R) return;
693
+ const lt = R.scrollHeight - R.clientHeight;
694
+ if (lt <= 0) return;
695
+ const X = 56, et = R.getBoundingClientRect(), ft = v - et.top, Ft = et.bottom - v;
696
+ let Rt = 0;
697
+ if (M < 0 && ft < X)
698
+ Rt = -Math.max(6, (X - ft) / X * 28);
699
+ else if (M > 0 && Ft < X)
700
+ Rt = Math.max(6, (X - Ft) / X * 28);
701
701
  else {
702
- x = 0;
702
+ M = 0;
703
703
  return;
704
704
  }
705
- const qt = D.scrollTop;
706
- D.scrollTop = Math.min(ot, Math.max(0, qt + zt)), D.scrollTop !== qt && A(w, v), zt < 0 && D.scrollTop > 0 || zt > 0 && D.scrollTop < ot ? a = window.requestAnimationFrame(N) : x = 0;
707
- }, E = (D) => {
708
- w = D.clientX, v = D.clientY;
709
- const ot = R();
710
- if (ot) {
711
- const dt = ot.getBoundingClientRect(), _t = D.clientY - dt.top, Rt = dt.bottom - D.clientY;
712
- _t < 56 ? (x = -1, a || (a = window.requestAnimationFrame(N))) : Rt < 56 ? (x = 1, a || (a = window.requestAnimationFrame(N))) : x = 0;
705
+ const Ht = R.scrollTop;
706
+ R.scrollTop = Math.min(lt, Math.max(0, Ht + Rt)), R.scrollTop !== Ht && F(w, v), Rt < 0 && R.scrollTop > 0 || Rt > 0 && R.scrollTop < lt ? a = window.requestAnimationFrame(N) : M = 0;
707
+ }, j = (R) => {
708
+ w = R.clientX, v = R.clientY;
709
+ const lt = D();
710
+ if (lt) {
711
+ const et = lt.getBoundingClientRect(), ft = R.clientY - et.top, Ft = et.bottom - R.clientY;
712
+ ft < 56 ? (M = -1, a || (a = window.requestAnimationFrame(N))) : Ft < 56 ? (M = 1, a || (a = window.requestAnimationFrame(N))) : M = 0;
713
713
  }
714
- wt.kind === "resize" ? P(D.clientX, D.clientY) : A(D.clientX, D.clientY);
715
- }, W = () => {
716
- x = 0, a && (window.cancelAnimationFrame(a), a = 0), It(null);
714
+ mt.kind === "resize" ? P(R.clientX, R.clientY) : F(R.clientX, R.clientY);
715
+ }, Z = () => {
716
+ M = 0, a && (window.cancelAnimationFrame(a), a = 0), It(null);
717
717
  };
718
- return window.addEventListener("pointermove", E), window.addEventListener("pointerup", W), window.addEventListener("pointercancel", W), () => {
719
- x = 0, a && window.cancelAnimationFrame(a), window.removeEventListener("pointermove", E), window.removeEventListener("pointerup", W), window.removeEventListener("pointercancel", W);
718
+ return window.addEventListener("pointermove", j), window.addEventListener("pointerup", Z), window.addEventListener("pointercancel", Z), () => {
719
+ M = 0, a && window.cancelAnimationFrame(a), window.removeEventListener("pointermove", j), window.removeEventListener("pointerup", Z), window.removeEventListener("pointercancel", Z);
720
720
  };
721
721
  }, [
722
- wt,
723
- tt,
724
- $,
722
+ mt,
723
+ pt,
724
+ I,
725
725
  n,
726
- b
727
- ]), Pt(() => {
728
- if (!Dt || !Jt.current) return;
729
- const a = Jt.current, w = nt.find((R) => R.id === Dt);
726
+ y
727
+ ]), Dt(() => {
728
+ if (!Kt || !ee.current) return;
729
+ const a = ee.current, w = ct.find((D) => D.id === Kt);
730
730
  a.textContent = (w == null ? void 0 : w.value) ?? "", a.focus();
731
731
  const v = document.createRange();
732
732
  v.selectNodeContents(a), v.collapse(!1);
733
- const x = window.getSelection();
734
- x == null || x.removeAllRanges(), x == null || x.addRange(v);
735
- }, [Dt]);
736
- const Gt = (a) => {
733
+ const M = window.getSelection();
734
+ M == null || M.removeAllRanges(), M == null || M.addRange(v);
735
+ }, [Kt]);
736
+ const ne = (a) => {
737
737
  $t.current = a, r == null || r(a);
738
- }, Ft = m.filter((a) => a.pageNumber === e), f = b.filter((a) => a.pageNumber === e), C = at.filter((a) => a.pageNumber === e), X = nt.filter((a) => a.pageNumber === e), Q = (a, w) => {
738
+ }, Nt = m.filter((a) => a.pageNumber === e), oe = y.filter((a) => a.pageNumber === e), f = nt.filter((a) => a.pageNumber === e), L = ct.filter((a) => a.pageNumber === e), U = (a, w) => {
739
739
  const v = w.trim();
740
740
  if (!v) {
741
- q == null || q(a.id), O == null || O(null);
741
+ tt == null || tt(a.id), G == null || G(null);
742
742
  return;
743
743
  }
744
- const x = Ie(v, a.fontSize);
745
- vt == null || vt(a.id, {
744
+ const M = Re(v, a.fontSize);
745
+ gt == null || gt(a.id, {
746
746
  value: v,
747
- width: x.width,
748
- height: x.height
749
- }), O == null || O(null);
750
- }, Ct = (a, w) => {
751
- if (!it) return;
752
- const v = lt.current, x = mt.current;
753
- if (!v || !x) return;
754
- let R = qi(
747
+ width: M.width,
748
+ height: M.height
749
+ }), G == null || G(null);
750
+ }, rt = (a, w) => {
751
+ if (!ut) return;
752
+ const v = it.current, M = bt.current;
753
+ if (!v || !M) return;
754
+ let D = qi(
755
755
  a,
756
756
  w,
757
757
  v,
758
- x,
758
+ M,
759
759
  n
760
- ), P, A = de;
761
- if (Yt) {
762
- const W = Ji(
763
- R.x,
764
- R.y,
765
- Qt,
760
+ ), P, F = me;
761
+ if (qt) {
762
+ const Z = Ji(
763
+ D.x,
764
+ D.y,
765
+ te,
766
766
  e
767
767
  );
768
- if (!W) return;
769
- const D = nt.find((ot) => ot.fieldId === W.id);
770
- if (D) {
771
- ut == null || ut(D.id), Bt == null || Bt(W.id), O == null || O(D.id);
768
+ if (!Z) return;
769
+ const R = ct.find((lt) => lt.fieldId === Z.id);
770
+ if (R) {
771
+ dt == null || dt(R.id), Vt == null || Vt(Z.id), G == null || G(R.id);
772
772
  return;
773
773
  }
774
- P = W.id, R = {
775
- x: W.x,
776
- y: W.y,
777
- fontSize: W.fontSize ?? he
778
- }, A = W.color ?? de, Bt == null || Bt(W.id);
774
+ P = Z.id, D = {
775
+ x: Z.x,
776
+ y: Z.y,
777
+ fontSize: Z.fontSize ?? we
778
+ }, F = Z.color ?? me, Vt == null || Vt(Z.id);
779
779
  }
780
- const N = Ie("", R.fontSize), E = {
781
- id: Be(),
780
+ const N = Re("", D.fontSize), j = {
781
+ id: Ge(),
782
782
  fieldId: P,
783
783
  pageNumber: e,
784
- x: R.x,
785
- y: R.y,
784
+ x: D.x,
785
+ y: D.y,
786
786
  width: N.width,
787
787
  height: N.height,
788
788
  value: "",
789
- fontSize: R.fontSize,
790
- color: A
789
+ fontSize: D.fontSize,
790
+ color: F
791
791
  };
792
- it(E), ut == null || ut(E.id), O == null || O(E.id);
793
- }, Xt = (a) => {
792
+ ut(j), dt == null || dt(j.id), G == null || G(j.id);
793
+ }, Lt = (a) => {
794
794
  var v;
795
795
  if (d !== "text" || a.target.closest(".epochs-pdf-viewer__inline-text"))
796
796
  return;
797
- if (ft.current) {
798
- ft.current = !1;
797
+ if (ht.current) {
798
+ ht.current = !1;
799
799
  return;
800
800
  }
801
801
  const w = window.getSelection();
802
802
  if (!(w && !w.isCollapsed && w.toString().trim())) {
803
- if (a.detail >= 2 && tr(a.clientX, a.clientY, mt.current)) {
804
- const R = lt.current;
805
- if (R && g && it) {
806
- const P = en(R, n);
803
+ if (a.detail >= 2 && tr(a.clientX, a.clientY, bt.current)) {
804
+ const D = it.current;
805
+ if (D && g && ut) {
806
+ const P = an(D, n);
807
807
  if (P) {
808
808
  g({
809
- id: tn(),
809
+ id: sn(),
810
810
  pageNumber: e,
811
811
  kind: "redact",
812
- color: De,
813
- rects: nn(P.rects),
812
+ color: He,
813
+ rects: cn(P.rects),
814
814
  text: P.text
815
815
  });
816
- const A = xn(P.rects), N = Ie(P.text || " ", A.fontSize), E = {
817
- id: Be(),
816
+ const F = Nn(P.rects), N = Re(P.text || " ", F.fontSize), j = {
817
+ id: Ge(),
818
818
  pageNumber: e,
819
- x: A.x,
820
- y: A.y,
819
+ x: F.x,
820
+ y: F.y,
821
821
  width: N.width,
822
822
  height: N.height,
823
823
  value: P.text,
824
- fontSize: A.fontSize,
825
- color: de
824
+ fontSize: F.fontSize,
825
+ color: me
826
826
  };
827
- it(E), ut == null || ut(E.id), O == null || O(E.id), (v = window.getSelection()) == null || v.removeAllRanges(), ft.current = !0;
827
+ ut(j), dt == null || dt(j.id), G == null || G(j.id), (v = window.getSelection()) == null || v.removeAllRanges(), ht.current = !0;
828
828
  }
829
829
  }
830
830
  return;
831
831
  }
832
- a.stopPropagation(), Ct(a.clientX, a.clientY);
832
+ a.stopPropagation(), rt(a.clientX, a.clientY);
833
833
  }
834
- }, Vt = (a) => {
834
+ }, Zt = (a) => {
835
835
  const w = a.target;
836
836
  if (!(w.closest(".epochs-pdf-viewer__signature") || w.closest(".epochs-pdf-viewer__signature-field") || w.closest(".epochs-pdf-viewer__inline-text"))) {
837
837
  if (d === "text") {
838
- Ct(a.clientX, a.clientY);
838
+ rt(a.clientX, a.clientY);
839
839
  return;
840
840
  }
841
- if (!tt && d === "sign" && gt && z) {
842
- const v = lt.current;
841
+ if (!pt && d === "sign" && vt && E) {
842
+ const v = it.current;
843
843
  if (!v) return;
844
- const x = He(a.clientX, a.clientY, v, n);
845
- z(e, Math.max(0, x.x - 75), Math.max(0, x.y - 12));
844
+ const M = We(a.clientX, a.clientY, v, n);
845
+ E(e, Math.max(0, M.x - 75), Math.max(0, M.y - 12));
846
846
  return;
847
847
  }
848
- if (!tt && d === "sign" && y && M) {
849
- const v = lt.current;
848
+ if (!pt && d === "sign" && b && x) {
849
+ const v = it.current;
850
850
  if (!v) return;
851
- const x = xe(v, n), R = He(a.clientX, a.clientY, v, n);
852
- let P = R.x - y.width / 2, A = R.y - y.height / 2;
853
- const N = Math.max(0, x.width - y.width), E = Math.max(0, x.height - y.height);
854
- P = Math.min(Math.max(0, P), N), A = Math.min(Math.max(0, A), E), M({
851
+ const M = Ce(v, n), D = We(a.clientX, a.clientY, v, n);
852
+ let P = D.x - b.width / 2, F = D.y - b.height / 2;
853
+ const N = Math.max(0, M.width - b.width), j = Math.max(0, M.height - b.height);
854
+ P = Math.min(Math.max(0, P), N), F = Math.min(Math.max(0, F), j), x({
855
855
  id: Se(),
856
856
  pageNumber: e,
857
857
  x: P,
858
- y: A,
859
- width: y.width,
860
- height: y.height,
861
- imageDataUrl: y.imageDataUrl
858
+ y: F,
859
+ width: b.width,
860
+ height: b.height,
861
+ imageDataUrl: b.imageDataUrl
862
862
  });
863
863
  return;
864
864
  }
865
865
  }
866
- }, ie = (a) => Dt === a.id ? /* @__PURE__ */ s(
866
+ }, ie = (a) => Kt === a.id ? /* @__PURE__ */ s(
867
867
  "span",
868
868
  {
869
- ref: Jt,
869
+ ref: ee,
870
870
  contentEditable: !0,
871
871
  suppressContentEditableWarning: !0,
872
872
  role: "textbox",
@@ -883,15 +883,15 @@ function yr({
883
883
  onClick: (v) => v.stopPropagation(),
884
884
  onPointerDown: (v) => v.stopPropagation(),
885
885
  onInput: (v) => {
886
- const x = v.currentTarget.textContent ?? "", R = Ie(x || " ", a.fontSize);
887
- vt == null || vt(a.id, {
888
- value: x,
889
- width: R.width,
890
- height: R.height
886
+ const M = v.currentTarget.textContent ?? "", D = Re(M || " ", a.fontSize);
887
+ gt == null || gt(a.id, {
888
+ value: M,
889
+ width: D.width,
890
+ height: D.height
891
891
  });
892
892
  },
893
893
  onBlur: (v) => {
894
- Q(a, v.currentTarget.textContent ?? "");
894
+ U(a, v.currentTarget.textContent ?? "");
895
895
  },
896
896
  onKeyDown: (v) => {
897
897
  v.stopPropagation(), v.key === "Escape" && (v.preventDefault(), v.currentTarget.blur()), v.key === "Enter" && !v.shiftKey && (v.preventDefault(), v.currentTarget.blur());
@@ -901,7 +901,7 @@ function yr({
901
901
  ) : a.value.trim() ? /* @__PURE__ */ s(
902
902
  "span",
903
903
  {
904
- className: Zt === a.id ? "epochs-pdf-viewer__inline-text epochs-pdf-viewer__inline-text--selected" : "epochs-pdf-viewer__inline-text",
904
+ className: kt === a.id ? "epochs-pdf-viewer__inline-text epochs-pdf-viewer__inline-text--selected" : "epochs-pdf-viewer__inline-text",
905
905
  style: {
906
906
  left: a.x * n,
907
907
  top: a.y * n,
@@ -910,10 +910,10 @@ function yr({
910
910
  },
911
911
  onClick: (v) => {
912
912
  if (v.stopPropagation(), d === "erase") {
913
- q == null || q(a.id);
913
+ tt == null || tt(a.id);
914
914
  return;
915
915
  }
916
- d === "text" && (ut == null || ut(a.id), O == null || O(a.id));
916
+ d === "text" && (dt == null || dt(a.id), G == null || G(a.id));
917
917
  },
918
918
  children: a.value
919
919
  },
@@ -922,18 +922,18 @@ function yr({
922
922
  return /* @__PURE__ */ s(
923
923
  "div",
924
924
  {
925
- ref: Gt,
925
+ ref: ne,
926
926
  "data-page-number": e,
927
927
  className: "epochs-pdf-viewer__page",
928
- children: /* @__PURE__ */ L(
928
+ children: /* @__PURE__ */ T(
929
929
  "div",
930
930
  {
931
- ref: lt,
931
+ ref: it,
932
932
  className: `epochs-pdf-viewer__surface epochs-pdf-viewer__surface--tool-${d}`,
933
- onClick: Vt,
933
+ onClick: Zt,
934
934
  children: [
935
- /* @__PURE__ */ s("canvas", { ref: Lt, className: "epochs-pdf-viewer__canvas" }),
936
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__markup-layer", "aria-hidden": "true", children: Ft.map(
935
+ /* @__PURE__ */ s("canvas", { ref: yt, className: "epochs-pdf-viewer__canvas" }),
936
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__markup-layer", "aria-hidden": "true", children: Nt.map(
937
937
  (a) => a.kind === "redact" ? null : a.rects.map((w, v) => a.kind === "highlight" ? /* @__PURE__ */ s(
938
938
  "div",
939
939
  {
@@ -945,8 +945,8 @@ function yr({
945
945
  height: w.h * n,
946
946
  background: a.color
947
947
  },
948
- onClick: (x) => {
949
- d === "erase" && (x.stopPropagation(), _ == null || _(a.id));
948
+ onClick: (M) => {
949
+ d === "erase" && (M.stopPropagation(), _ == null || _(a.id));
950
950
  }
951
951
  },
952
952
  `${a.id}_${v}`
@@ -961,46 +961,46 @@ function yr({
961
961
  height: Math.max(2, n * 1.5),
962
962
  background: a.color
963
963
  },
964
- onClick: (x) => {
965
- d === "erase" && (x.stopPropagation(), _ == null || _(a.id));
964
+ onClick: (M) => {
965
+ d === "erase" && (M.stopPropagation(), _ == null || _(a.id));
966
966
  }
967
967
  },
968
968
  `${a.id}_${v}`
969
969
  ))
970
970
  ) }),
971
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__signature-layer", children: [
972
- C.map((a) => {
973
- const w = a.type ?? "sign", v = Mt[a.id] ?? a.value ?? "", x = w === "date" || w === "text" ? !!v.trim() : f.some((R) => R.fieldId === a.id);
971
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__signature-layer", children: [
972
+ f.map((a) => {
973
+ const w = a.type ?? "sign", v = Mt[a.id] ?? a.value ?? "", M = w === "date" || w === "text" ? !!v.trim() : oe.some((D) => D.fieldId === a.id);
974
974
  return /* @__PURE__ */ s(
975
975
  "button",
976
976
  {
977
977
  type: "button",
978
978
  "data-signature-field-id": a.id,
979
- className: ct === a.id ? "epochs-pdf-viewer__signature-field epochs-pdf-viewer__signature-field--selected" : x ? "epochs-pdf-viewer__signature-field epochs-pdf-viewer__signature-field--filled" : "epochs-pdf-viewer__signature-field",
979
+ className: at === a.id ? "epochs-pdf-viewer__signature-field epochs-pdf-viewer__signature-field--selected" : M ? "epochs-pdf-viewer__signature-field epochs-pdf-viewer__signature-field--filled" : "epochs-pdf-viewer__signature-field",
980
980
  style: {
981
981
  left: a.x * n,
982
982
  top: a.y * n,
983
983
  width: a.width * n,
984
984
  height: a.height * n
985
985
  },
986
- onClick: (R) => {
987
- if (R.stopPropagation(), Z == null || Z(a.id), w === "date" || w === "text") {
988
- T == null || T(null), bt == null || bt(w);
986
+ onClick: (D) => {
987
+ if (D.stopPropagation(), q == null || q(a.id), w === "date" || w === "text") {
988
+ C == null || C(null), J == null || J(w);
989
989
  return;
990
990
  }
991
- const P = f.find((A) => A.fieldId === a.id);
992
- T == null || T((P == null ? void 0 : P.id) ?? null), P ? H == null || H(P.id) : bt == null || bt(w);
991
+ const P = oe.find((F) => F.fieldId === a.id);
992
+ C == null || C((P == null ? void 0 : P.id) ?? null), P ? H == null || H(P.id) : J == null || J(w);
993
993
  },
994
- title: x ? "Completed field" : w === "date" ? "Date field" : w === "text" ? "Text field" : "Signature field",
995
- children: w === "date" || w === "text" ? v.trim() ? /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__signature-field-value", children: v }) : w === "date" ? /* @__PURE__ */ s("span", { children: "Date here" }) : /* @__PURE__ */ s("span", { children: a.placeholder ?? "Enter text" }) : x ? null : /* @__PURE__ */ s("span", { children: "Sign here" })
994
+ title: M ? "Completed field" : w === "date" ? "Date field" : w === "text" ? "Text field" : "Signature field",
995
+ children: w === "date" || w === "text" ? v.trim() ? /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__signature-field-value", children: v }) : w === "date" ? /* @__PURE__ */ s("span", { children: "Date here" }) : /* @__PURE__ */ s("span", { children: a.placeholder ?? "Enter text" }) : M ? null : /* @__PURE__ */ s("span", { children: "Sign here" })
996
996
  },
997
997
  a.id
998
998
  );
999
999
  }),
1000
- f.map((a) => /* @__PURE__ */ L(
1000
+ oe.map((a) => /* @__PURE__ */ T(
1001
1001
  "div",
1002
1002
  {
1003
- className: J === a.id ? "epochs-pdf-viewer__signature epochs-pdf-viewer__signature--selected" : "epochs-pdf-viewer__signature",
1003
+ className: A === a.id ? "epochs-pdf-viewer__signature epochs-pdf-viewer__signature--selected" : "epochs-pdf-viewer__signature",
1004
1004
  style: {
1005
1005
  left: a.x * n,
1006
1006
  top: a.y * n,
@@ -1008,22 +1008,22 @@ function yr({
1008
1008
  height: a.height * n
1009
1009
  },
1010
1010
  onPointerDown: (w) => {
1011
- if (w.stopPropagation(), w.preventDefault(), T == null || T(a.id), d === "erase" && !tt) {
1011
+ if (w.stopPropagation(), w.preventDefault(), C == null || C(a.id), d === "erase" && !pt) {
1012
1012
  S == null || S(a.id);
1013
1013
  return;
1014
1014
  }
1015
- if (tt) {
1016
- Z == null || Z(a.fieldId ?? null), H == null || H(a.id);
1015
+ if (pt) {
1016
+ q == null || q(a.fieldId ?? null), H == null || H(a.id);
1017
1017
  return;
1018
1018
  }
1019
- const v = lt.current;
1019
+ const v = it.current;
1020
1020
  if (!v) return;
1021
- const x = He(w.clientX, w.clientY, v, n);
1021
+ const M = We(w.clientX, w.clientY, v, n);
1022
1022
  It({
1023
1023
  kind: "signature",
1024
1024
  id: a.id,
1025
- offsetX: x.x - a.x,
1026
- offsetY: x.y - a.y
1025
+ offsetX: M.x - a.x,
1026
+ offsetY: M.y - a.y
1027
1027
  });
1028
1028
  },
1029
1029
  children: [
@@ -1038,12 +1038,12 @@ function yr({
1038
1038
  w.stopPropagation();
1039
1039
  },
1040
1040
  onClick: (w) => {
1041
- w.stopPropagation(), T == null || T(a.id), H == null || H(a.id);
1041
+ w.stopPropagation(), C == null || C(a.id), H == null || H(a.id);
1042
1042
  },
1043
1043
  children: /* @__PURE__ */ s(mr, { size: 12 })
1044
1044
  }
1045
1045
  ),
1046
- tt ? null : /* @__PURE__ */ L(Fe, { children: [
1046
+ pt ? null : /* @__PURE__ */ T(je, { children: [
1047
1047
  /* @__PURE__ */ s(
1048
1048
  "button",
1049
1049
  {
@@ -1055,7 +1055,7 @@ function yr({
1055
1055
  w.stopPropagation();
1056
1056
  },
1057
1057
  onClick: (w) => {
1058
- w.stopPropagation(), T == null || T(a.id), F == null || F(a.id);
1058
+ w.stopPropagation(), C == null || C(a.id), W == null || W(a.id);
1059
1059
  },
1060
1060
  children: "⧉"
1061
1061
  }
@@ -1078,13 +1078,13 @@ function yr({
1078
1078
  )
1079
1079
  ] }),
1080
1080
  /* @__PURE__ */ s("img", { src: a.imageDataUrl, alt: "Signature", draggable: !1 }),
1081
- tt ? null : /* @__PURE__ */ s(
1081
+ pt ? null : /* @__PURE__ */ s(
1082
1082
  "div",
1083
1083
  {
1084
1084
  className: "epochs-pdf-viewer__signature-resize",
1085
1085
  title: "Resize",
1086
1086
  onPointerDown: (w) => {
1087
- w.stopPropagation(), w.preventDefault(), T == null || T(a.id), It({
1087
+ w.stopPropagation(), w.preventDefault(), C == null || C(a.id), It({
1088
1088
  kind: "resize",
1089
1089
  id: a.id,
1090
1090
  startX: w.clientX,
@@ -1101,16 +1101,16 @@ function yr({
1101
1101
  a.id
1102
1102
  ))
1103
1103
  ] }),
1104
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__text-layer-overlay", children: X.map((a) => ie(a)) }),
1104
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__text-layer-overlay", children: L.map((a) => ie(a)) }),
1105
1105
  /* @__PURE__ */ s(
1106
1106
  "div",
1107
1107
  {
1108
- ref: mt,
1108
+ ref: bt,
1109
1109
  className: "textLayer epochs-pdf-viewer__text-layer",
1110
- onClick: Xt
1110
+ onClick: Lt
1111
1111
  }
1112
1112
  ),
1113
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__redact-layer", "aria-hidden": "true", children: Ft.map(
1113
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__redact-layer", "aria-hidden": "true", children: Nt.map(
1114
1114
  (a) => a.kind === "redact" ? a.rects.map((w, v) => /* @__PURE__ */ s(
1115
1115
  "div",
1116
1116
  {
@@ -1120,10 +1120,10 @@ function yr({
1120
1120
  top: w.y * n,
1121
1121
  width: w.w * n,
1122
1122
  height: w.h * n,
1123
- background: a.color || De
1123
+ background: a.color || He
1124
1124
  },
1125
- onClick: (x) => {
1126
- d === "erase" && (x.stopPropagation(), _ == null || _(a.id));
1125
+ onClick: (M) => {
1126
+ d === "erase" && (M.stopPropagation(), _ == null || _(a.id));
1127
1127
  }
1128
1128
  },
1129
1129
  `${a.id}_${v}`
@@ -1148,45 +1148,45 @@ function br({
1148
1148
  texts: g = [],
1149
1149
  textFields: _ = []
1150
1150
  }) {
1151
- const b = xt(null);
1152
- return Pt(() => {
1153
- if (!t || !b.current) return;
1154
- let y = !1;
1155
- const M = b.current, $ = M.getContext("2d");
1156
- if (!$) return;
1151
+ const y = xt(null);
1152
+ return Dt(() => {
1153
+ if (!t || !y.current) return;
1154
+ let b = !1;
1155
+ const x = y.current, I = x.getContext("2d");
1156
+ if (!I) return;
1157
1157
  let S = null;
1158
1158
  return (async () => {
1159
1159
  try {
1160
- const F = await t.getPage(e);
1161
- if (y) return;
1162
- const J = F.getViewport({ scale: 1, rotation: i }), T = o / J.width, at = F.getViewport({ scale: T, rotation: i });
1163
- M.width = Math.floor(at.width), M.height = Math.floor(at.height), S = F.render({ canvasContext: $, viewport: at }), await S.promise;
1164
- const ct = d.filter((Y) => Y.pageNumber === e);
1165
- ct.length > 0 && En($, ct, T);
1166
- const Z = u.filter((Y) => Y.pageNumber === e), tt = m.filter(
1167
- (Y) => Y.pageNumber === e
1160
+ const W = await t.getPage(e);
1161
+ if (b) return;
1162
+ const A = W.getViewport({ scale: 1, rotation: i }), C = o / A.width, nt = W.getViewport({ scale: C, rotation: i });
1163
+ x.width = Math.floor(nt.width), x.height = Math.floor(nt.height), S = W.render({ canvasContext: I, viewport: nt }), await S.promise;
1164
+ const at = d.filter((K) => K.pageNumber === e);
1165
+ at.length > 0 && jn(I, at, C);
1166
+ const q = u.filter((K) => K.pageNumber === e), pt = m.filter(
1167
+ (K) => K.pageNumber === e
1168
1168
  );
1169
- tt.length > 0 && Wi(
1170
- $,
1171
- tt,
1172
- new Set(Z.map((Y) => Y.fieldId).filter(Boolean)),
1173
- T
1174
- ), Z.length > 0 && await Un($, Z, T);
1175
- const bt = g.filter((Y) => Y.pageNumber === e), Mt = _.filter(
1176
- (Y) => Y.pageNumber === e
1169
+ pt.length > 0 && Si(
1170
+ I,
1171
+ pt,
1172
+ new Set(q.map((K) => K.fieldId).filter(Boolean)),
1173
+ C
1174
+ ), q.length > 0 && await Bn(I, q, C);
1175
+ const J = g.filter((K) => K.pageNumber === e), Mt = _.filter(
1176
+ (K) => K.pageNumber === e
1177
1177
  );
1178
1178
  Mt.length > 0 && er(
1179
- $,
1179
+ I,
1180
1180
  Mt,
1181
1181
  new Set(
1182
- bt.filter((Y) => Y.fieldId && Y.value.trim()).map((Y) => Y.fieldId)
1182
+ J.filter((K) => K.fieldId && K.value.trim()).map((K) => K.fieldId)
1183
1183
  ),
1184
- T
1185
- ), bt.length > 0 && Hn($, bt, T);
1184
+ C
1185
+ ), J.length > 0 && Wn(I, J, C);
1186
1186
  } catch {
1187
1187
  }
1188
1188
  })(), () => {
1189
- if (y = !0, S)
1189
+ if (b = !0, S)
1190
1190
  try {
1191
1191
  S.cancel();
1192
1192
  } catch {
@@ -1202,7 +1202,7 @@ function br({
1202
1202
  _,
1203
1203
  g,
1204
1204
  o
1205
- ]), /* @__PURE__ */ L(
1205
+ ]), /* @__PURE__ */ T(
1206
1206
  "button",
1207
1207
  {
1208
1208
  type: "button",
@@ -1210,24 +1210,24 @@ function br({
1210
1210
  className: n ? "epochs-pdf-viewer__thumb epochs-pdf-viewer__thumb--active" : "epochs-pdf-viewer__thumb",
1211
1211
  title: `Page ${e}`,
1212
1212
  children: [
1213
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-frame", children: /* @__PURE__ */ s("canvas", { ref: b }) }),
1213
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-frame", children: /* @__PURE__ */ s("canvas", { ref: y }) }),
1214
1214
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__thumb-label", children: e })
1215
1215
  ]
1216
1216
  }
1217
1217
  );
1218
1218
  }
1219
1219
  const _r = /^(blob:|https?:|data:)/i;
1220
- let zn = !1;
1221
- function kn(t) {
1222
- ve.GlobalWorkerOptions.workerSrc = t, zn = !0;
1220
+ let On = !1;
1221
+ function $n(t) {
1222
+ Ie.GlobalWorkerOptions.workerSrc = t, On = !0;
1223
1223
  }
1224
1224
  function vr(t) {
1225
1225
  if (t) {
1226
- kn(t);
1226
+ $n(t);
1227
1227
  return;
1228
1228
  }
1229
- zn || ve.GlobalWorkerOptions.workerSrc || kn(
1230
- `https://unpkg.com/pdfjs-dist@${ve.version}/build/pdf.worker.min.mjs`
1229
+ On || Ie.GlobalWorkerOptions.workerSrc || $n(
1230
+ `https://unpkg.com/pdfjs-dist@${Ie.version}/build/pdf.worker.min.mjs`
1231
1231
  );
1232
1232
  }
1233
1233
  function xr(t, e, n = "") {
@@ -1243,7 +1243,7 @@ async function Mr(t, e) {
1243
1243
  throw new Error(`Failed to fetch PDF (${n.status})`);
1244
1244
  return n.arrayBuffer();
1245
1245
  }
1246
- async function Nn(t, e) {
1246
+ async function In(t, e) {
1247
1247
  if (typeof t == "string")
1248
1248
  return Mr(t, e);
1249
1249
  if (t instanceof ArrayBuffer) return t.slice(0);
@@ -1262,29 +1262,29 @@ async function kr(t, e, n) {
1262
1262
  texts: u = [],
1263
1263
  mimeType: m = "image/jpeg",
1264
1264
  quality: g = 0.92
1265
- } = n, _ = await t.getPage(e), b = _.getViewport({ scale: i, rotation: r }), y = _.getViewport({ scale: 1, rotation: r }), M = document.createElement("canvas"), $ = M.getContext("2d", { alpha: !1 });
1266
- if (!$)
1265
+ } = n, _ = await t.getPage(e), y = _.getViewport({ scale: i, rotation: r }), b = _.getViewport({ scale: 1, rotation: r }), x = document.createElement("canvas"), I = x.getContext("2d", { alpha: !1 });
1266
+ if (!I)
1267
1267
  throw new Error("Could not create canvas context");
1268
- const S = Math.floor(b.width), H = Math.floor(b.height);
1269
- M.width = S, M.height = H, $.fillStyle = "#ffffff", $.fillRect(0, 0, S, H), await _.render({ canvasContext: $, viewport: b }).promise;
1270
- const F = o.filter((Z) => Z.pageNumber === e);
1271
- F.length > 0 && En($, F, i);
1272
- const J = d.filter((Z) => Z.pageNumber === e);
1273
- J.length > 0 && await Un($, J, i);
1274
- const T = u.filter((Z) => Z.pageNumber === e);
1275
- T.length > 0 && Hn($, T, i);
1276
- const at = M.toDataURL(m, g), ct = Nr(at);
1277
- return M.width = 0, M.height = 0, {
1268
+ const S = Math.floor(y.width), H = Math.floor(y.height);
1269
+ x.width = S, x.height = H, I.fillStyle = "#ffffff", I.fillRect(0, 0, S, H), await _.render({ canvasContext: I, viewport: y }).promise;
1270
+ const W = o.filter((q) => q.pageNumber === e);
1271
+ W.length > 0 && jn(I, W, i);
1272
+ const A = d.filter((q) => q.pageNumber === e);
1273
+ A.length > 0 && await Bn(I, A, i);
1274
+ const C = u.filter((q) => q.pageNumber === e);
1275
+ C.length > 0 && Wn(I, C, i);
1276
+ const nt = x.toDataURL(m, g), at = Nr(nt);
1277
+ return x.width = 0, x.height = 0, {
1278
1278
  pageNumber: e,
1279
1279
  width: S,
1280
1280
  height: H,
1281
- pageWidth: y.width,
1282
- pageHeight: y.height,
1283
- dataUrl: at,
1284
- jpegBytes: ct
1281
+ pageWidth: b.width,
1282
+ pageHeight: b.height,
1283
+ dataUrl: nt,
1284
+ jpegBytes: at
1285
1285
  };
1286
1286
  }
1287
- async function Pn(t, e) {
1287
+ async function Cn(t, e) {
1288
1288
  const n = [];
1289
1289
  for (let i = 1; i <= t.numPages; i += 1)
1290
1290
  n.push(await kr(t, i, e));
@@ -1296,10 +1296,10 @@ function Nr(t) {
1296
1296
  i[r] = n.charCodeAt(r);
1297
1297
  return i;
1298
1298
  }
1299
- function Kt(t) {
1299
+ function Jt(t) {
1300
1300
  return new TextEncoder().encode(t);
1301
1301
  }
1302
- function $n(...t) {
1302
+ function Tn(...t) {
1303
1303
  const e = t.reduce((r, o) => r + o.byteLength, 0), n = new Uint8Array(e);
1304
1304
  let i = 0;
1305
1305
  for (const r of t)
@@ -1307,81 +1307,81 @@ function $n(...t) {
1307
1307
  return n;
1308
1308
  }
1309
1309
  function Pr(t) {
1310
- const e = [], n = (y) => (e.push(y), e.length), i = [];
1311
- for (const y of t) {
1312
- const M = $n(
1313
- Kt(
1314
- `<< /Type /XObject /Subtype /Image /Width ${y.width} /Height ${y.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${y.jpegBytes.byteLength} >>
1310
+ const e = [], n = (b) => (e.push(b), e.length), i = [];
1311
+ for (const b of t) {
1312
+ const x = Tn(
1313
+ Jt(
1314
+ `<< /Type /XObject /Subtype /Image /Width ${b.width} /Height ${b.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${b.jpegBytes.byteLength} >>
1315
1315
  stream
1316
1316
  `
1317
1317
  ),
1318
- y.jpegBytes,
1319
- Kt(`
1318
+ b.jpegBytes,
1319
+ Jt(`
1320
1320
  endstream`)
1321
- ), $ = n(M), S = `q
1322
- ${y.pageWidth.toFixed(2)} 0 0 ${y.pageHeight.toFixed(2)} 0 0 cm
1321
+ ), I = n(x), S = `q
1322
+ ${b.pageWidth.toFixed(2)} 0 0 ${b.pageHeight.toFixed(2)} 0 0 cm
1323
1323
  /Im0 Do
1324
1324
  Q`, H = n(
1325
- Kt(`<< /Length ${S.length} >>
1325
+ Jt(`<< /Length ${S.length} >>
1326
1326
  stream
1327
1327
  ${S}
1328
1328
  endstream`)
1329
- ), F = n(
1330
- Kt(
1331
- `<< /Type /Page /Parent __PAGES__ 0 R /MediaBox [0 0 ${y.pageWidth.toFixed(2)} ${y.pageHeight.toFixed(2)}] /Contents ${H} 0 R /Resources << /XObject << /Im0 ${$} 0 R >> >> >>`
1329
+ ), W = n(
1330
+ Jt(
1331
+ `<< /Type /Page /Parent __PAGES__ 0 R /MediaBox [0 0 ${b.pageWidth.toFixed(2)} ${b.pageHeight.toFixed(2)}] /Contents ${H} 0 R /Resources << /XObject << /Im0 ${I} 0 R >> >> >>`
1332
1332
  )
1333
1333
  );
1334
- i.push(F);
1334
+ i.push(W);
1335
1335
  }
1336
- const r = i.map((y) => `${y} 0 R`).join(" "), o = n(
1337
- Kt(`<< /Type /Pages /Kids [${r}] /Count ${i.length} >>`)
1336
+ const r = i.map((b) => `${b} 0 R`).join(" "), o = n(
1337
+ Jt(`<< /Type /Pages /Kids [${r}] /Count ${i.length} >>`)
1338
1338
  );
1339
- for (const y of i) {
1340
- const M = new TextDecoder().decode(e[y - 1]);
1341
- e[y - 1] = Kt(
1342
- M.replace("/Parent __PAGES__ 0 R", `/Parent ${o} 0 R`)
1339
+ for (const b of i) {
1340
+ const x = new TextDecoder().decode(e[b - 1]);
1341
+ e[b - 1] = Jt(
1342
+ x.replace("/Parent __PAGES__ 0 R", `/Parent ${o} 0 R`)
1343
1343
  );
1344
1344
  }
1345
- const d = n(Kt(`<< /Type /Catalog /Pages ${o} 0 R >>`)), u = [Kt(`%PDF-1.4
1345
+ const d = n(Jt(`<< /Type /Catalog /Pages ${o} 0 R >>`)), u = [Jt(`%PDF-1.4
1346
1346
  `)], m = [0];
1347
1347
  let g = u[0].byteLength;
1348
- for (let y = 0; y < e.length; y += 1) {
1348
+ for (let b = 0; b < e.length; b += 1) {
1349
1349
  m.push(g);
1350
- const M = Kt(`${y + 1} 0 obj
1351
- `), $ = Kt(`
1350
+ const x = Jt(`${b + 1} 0 obj
1351
+ `), I = Jt(`
1352
1352
  endobj
1353
1353
  `);
1354
- u.push(M, e[y], $), g += M.byteLength + e[y].byteLength + $.byteLength;
1354
+ u.push(x, e[b], I), g += x.byteLength + e[b].byteLength + I.byteLength;
1355
1355
  }
1356
1356
  const _ = g;
1357
- let b = `xref
1357
+ let y = `xref
1358
1358
  0 ${e.length + 1}
1359
1359
  `;
1360
- b += `0000000000 65535 f
1360
+ y += `0000000000 65535 f
1361
1361
  `;
1362
- for (let y = 1; y <= e.length; y += 1)
1363
- b += `${String(m[y]).padStart(10, "0")} 00000 n
1362
+ for (let b = 1; b <= e.length; b += 1)
1363
+ y += `${String(m[b]).padStart(10, "0")} 00000 n
1364
1364
  `;
1365
- return b += `trailer
1365
+ return y += `trailer
1366
1366
  << /Size ${e.length + 1} /Root ${d} 0 R >>
1367
- `, b += `startxref
1367
+ `, y += `startxref
1368
1368
  ${_}
1369
- %%EOF`, u.push(Kt(b)), $n(...u);
1369
+ %%EOF`, u.push(Jt(y)), Tn(...u);
1370
1370
  }
1371
- function sn(t, e) {
1371
+ function hn(t, e) {
1372
1372
  const n = URL.createObjectURL(t), i = document.createElement("a");
1373
1373
  i.href = n, i.download = e, i.click(), URL.revokeObjectURL(n);
1374
1374
  }
1375
- const Le = [
1375
+ const Ue = [
1376
1376
  { id: "dancing-script", label: "Dancing Script", family: "Dancing Script" },
1377
1377
  { id: "great-vibes", label: "Great Vibes", family: "Great Vibes" },
1378
1378
  { id: "pacifico", label: "Pacifico", family: "Pacifico" },
1379
1379
  { id: "satisfy", label: "Satisfy", family: "Satisfy" },
1380
1380
  { id: "allura", label: "Allura", family: "Allura" }
1381
1381
  ], $r = "https://fonts.googleapis.com/css2?family=Allura&family=Dancing+Script:wght@500;600&family=Great+Vibes&family=Pacifico&family=Satisfy&display=swap";
1382
- let ze = null;
1382
+ let Oe = null;
1383
1383
  function Ir() {
1384
- return typeof document > "u" ? Promise.resolve() : ze || (ze = new Promise((t) => {
1384
+ return typeof document > "u" ? Promise.resolve() : Oe || (Oe = new Promise((t) => {
1385
1385
  var i;
1386
1386
  if (!document.querySelector(
1387
1387
  'link[data-epochs-signature-fonts="true"]'
@@ -1390,7 +1390,7 @@ function Ir() {
1390
1390
  r.rel = "stylesheet", r.href = $r, r.dataset.epochsSignatureFonts = "true", document.head.appendChild(r);
1391
1391
  }
1392
1392
  const n = () => Promise.all(
1393
- Le.map(
1393
+ Ue.map(
1394
1394
  (r) => document.fonts.load(`48px "${r.family}"`)
1395
1395
  )
1396
1396
  ).then(() => {
@@ -1398,9 +1398,9 @@ function Ir() {
1398
1398
  (i = document.fonts) != null && i.ready ? document.fonts.ready.then(n).then(t).catch(() => t()) : window.setTimeout(() => {
1399
1399
  n().then(t).catch(() => t());
1400
1400
  }, 300);
1401
- }), ze);
1401
+ }), Oe);
1402
1402
  }
1403
- function In(t, e) {
1403
+ function Dn(t, e) {
1404
1404
  return t === "initials" ? 72 : e === "Great Vibes" || e === "Allura" ? 56 : e === "Pacifico" ? 44 : 48;
1405
1405
  }
1406
1406
  function Cr({
@@ -1412,166 +1412,167 @@ function Cr({
1412
1412
  showFieldTypeTabs: o = !1,
1413
1413
  textPlaceholder: d,
1414
1414
  initialFieldValue: u,
1415
- rememberedByType: m,
1416
- onRememberFill: g
1415
+ targetSize: m,
1416
+ rememberedByType: g,
1417
+ onRememberFill: _
1417
1418
  }) {
1418
- const _ = xt(null), b = xt(!1), y = xt(null), M = xt([]), $ = xt([]), S = xt(null), H = r ?? "sign", [F, J] = j(H), [T, at] = j(""), [ct, Z] = j(""), [tt, bt] = j("draw"), [Mt, Y] = j(""), [Tt, gt] = j(""), [z, nt] = j(!1), [it, vt] = j("signature"), [q, Zt] = j("#111827"), [ut, Qt] = j("dancing-script"), [Re, Bt] = j(!1), [Yt, Dt] = j(!1), O = Le.find((f) => f.id === ut) ?? Le[0], $t = it === "initials" ? Tt.trim() : Mt.trim(), Lt = $t || (it === "initials" ? "AB" : "Signature");
1419
- if (Pt(() => {
1420
- var X, Q;
1419
+ const y = xt(null), b = xt(!1), x = xt(null), I = xt([]), S = xt([]), H = xt(null), W = r ?? "sign", [A, C] = O(W), [nt, at] = O(""), [q, pt] = O(""), [J, Mt] = O("draw"), [K, Et] = O(""), [vt, E] = O(""), [ct, ut] = O(!1), [gt, tt] = O("signature"), [kt, dt] = O("#111827"), [te, ye] = O("dancing-script"), [Vt, qt] = O(!1), [Kt, G] = O(!1), $t = Ue.find((f) => f.id === te) ?? Ue[0], yt = gt === "initials" ? vt.trim() : K.trim(), bt = yt || (gt === "initials" ? "AB" : "Signature");
1420
+ if (Dt(() => {
1421
+ var U, rt;
1421
1422
  if (!t) return;
1422
- if (J(H), H === "date") {
1423
+ if (C(W), W === "date") {
1423
1424
  at(
1424
- u || ((X = m == null ? void 0 : m.date) == null ? void 0 : X.value) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
1425
+ u || ((U = g == null ? void 0 : g.date) == null ? void 0 : U.value) || (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
1425
1426
  );
1426
1427
  return;
1427
1428
  }
1428
- if (H === "text") {
1429
- Z(u || ((Q = m == null ? void 0 : m.text) == null ? void 0 : Q.value) || "");
1429
+ if (W === "text") {
1430
+ pt(u || ((rt = g == null ? void 0 : g.text) == null ? void 0 : rt.value) || "");
1430
1431
  return;
1431
1432
  }
1432
- const f = m == null ? void 0 : m.sign;
1433
+ const f = g == null ? void 0 : g.sign;
1433
1434
  if (!f) {
1434
- bt("draw"), Y(""), gt(""), nt(!1), vt("signature"), Zt("#111827"), Qt("dancing-script"), S.current = null, Dt(!1);
1435
+ Mt("draw"), Et(""), E(""), ut(!1), tt("signature"), dt("#111827"), ye("dancing-script"), H.current = null, G(!1);
1435
1436
  return;
1436
1437
  }
1437
- bt(f.mode), Y(f.typedName ?? ""), gt(f.typedInitials ?? ""), nt(!!f.typedInitials), vt(f.typeKind ?? "signature"), Zt(f.inkColor ?? "#111827");
1438
- const C = Le.find((Ct) => Ct.id === f.fontId);
1439
- C && Qt(C.id), f.mode === "draw" ? (S.current = {
1438
+ Mt(f.mode), Et(f.typedName ?? ""), E(f.typedInitials ?? ""), ut(!!f.typedInitials), tt(f.typeKind ?? "signature"), dt(f.inkColor ?? "#111827");
1439
+ const L = Ue.find((Lt) => Lt.id === f.fontId);
1440
+ L && ye(L.id), f.mode === "draw" ? (H.current = {
1440
1441
  imageDataUrl: f.imageDataUrl,
1441
1442
  width: f.width,
1442
1443
  height: f.height
1443
- }, Dt(!0)) : (S.current = null, Dt(!1));
1444
- }, [t, H, m, u]), Pt(() => {
1445
- if (!t || F !== "sign") return;
1446
- const f = _.current;
1444
+ }, G(!0)) : (H.current = null, G(!1));
1445
+ }, [t, W, g, u]), Dt(() => {
1446
+ if (!t || A !== "sign") return;
1447
+ const f = y.current;
1447
1448
  if (!f) return;
1448
- const C = f.getContext("2d");
1449
- if (!C || (f.width = 560, f.height = 200, C.fillStyle = "#ffffff", C.fillRect(0, 0, f.width, f.height), C.lineCap = "round", C.lineJoin = "round", C.strokeStyle = q, C.lineWidth = 2.5, y.current = null, b.current = !1, M.current = [], $.current = [], tt !== "draw")) return;
1450
- const X = S.current;
1451
- if (!(X != null && X.imageDataUrl)) return;
1452
- const Q = new Image();
1453
- Q.onload = () => {
1454
- const Ct = Math.min(
1455
- f.width / Math.max(1, X.width),
1456
- f.height / Math.max(1, X.height),
1449
+ const L = f.getContext("2d");
1450
+ if (!L || (f.width = 560, f.height = 200, L.fillStyle = "#ffffff", L.fillRect(0, 0, f.width, f.height), L.lineCap = "round", L.lineJoin = "round", L.strokeStyle = kt, L.lineWidth = 2.5, x.current = null, b.current = !1, I.current = [], S.current = [], J !== "draw")) return;
1451
+ const U = H.current;
1452
+ if (!(U != null && U.imageDataUrl)) return;
1453
+ const rt = new Image();
1454
+ rt.onload = () => {
1455
+ const Lt = Math.min(
1456
+ f.width / Math.max(1, U.width),
1457
+ f.height / Math.max(1, U.height),
1457
1458
  1
1458
- ), Xt = X.width * Ct, Vt = X.height * Ct;
1459
- C.drawImage(Q, (f.width - Xt) / 2, (f.height - Vt) / 2, Xt, Vt);
1460
- }, Q.src = X.imageDataUrl;
1461
- }, [t, F, tt]), Pt(() => {
1459
+ ), Zt = U.width * Lt, ie = U.height * Lt;
1460
+ L.drawImage(rt, (f.width - Zt) / 2, (f.height - ie) / 2, Zt, ie);
1461
+ }, rt.src = U.imageDataUrl;
1462
+ }, [t, A, J]), Dt(() => {
1462
1463
  if (!t) return;
1463
1464
  let f = !1;
1464
- return Bt(!1), Ir().then(() => {
1465
- f || Bt(!0);
1465
+ return qt(!1), Ir().then(() => {
1466
+ f || qt(!0);
1466
1467
  }), () => {
1467
1468
  f = !0;
1468
1469
  };
1469
- }, [t]), Pt(() => {
1470
- const f = _.current, C = f == null ? void 0 : f.getContext("2d");
1471
- C && (C.strokeStyle = q, C.fillStyle = q);
1472
- }, [q]), Pt(() => {
1473
- if (!t || tt !== "type") return;
1474
- const f = _.current, C = f == null ? void 0 : f.getContext("2d");
1475
- if (!f || !C || (C.fillStyle = "#ffffff", C.fillRect(0, 0, f.width, f.height), !$t)) return;
1476
- const X = In(it, O.family);
1477
- C.fillStyle = q, C.textAlign = "center", C.textBaseline = "middle", C.font = `${X}px "${O.family}", cursive`, C.fillText($t, f.width / 2, f.height / 2);
1470
+ }, [t]), Dt(() => {
1471
+ const f = y.current, L = f == null ? void 0 : f.getContext("2d");
1472
+ L && (L.strokeStyle = kt, L.fillStyle = kt);
1473
+ }, [kt]), Dt(() => {
1474
+ if (!t || J !== "type") return;
1475
+ const f = y.current, L = f == null ? void 0 : f.getContext("2d");
1476
+ if (!f || !L || (L.fillStyle = "#ffffff", L.fillRect(0, 0, f.width, f.height), !yt)) return;
1477
+ const U = Dn(gt, $t.family);
1478
+ L.fillStyle = kt, L.textAlign = "center", L.textBaseline = "middle", L.font = `${U}px "${$t.family}", cursive`, L.fillText(yt, f.width / 2, f.height / 2);
1478
1479
  }, [
1479
- $t,
1480
- it,
1481
- tt,
1482
- q,
1480
+ yt,
1481
+ gt,
1482
+ J,
1483
+ kt,
1483
1484
  t,
1484
- O,
1485
- Re
1485
+ $t,
1486
+ Vt
1486
1487
  ]), !t) return null;
1487
- const mt = (f) => {
1488
- const C = _.current, X = C.getBoundingClientRect();
1488
+ const it = (f) => {
1489
+ const L = y.current, U = L.getBoundingClientRect();
1489
1490
  return {
1490
- x: (f.clientX - X.left) / X.width * C.width,
1491
- y: (f.clientY - X.top) / X.height * C.height
1491
+ x: (f.clientX - U.left) / U.width * L.width,
1492
+ y: (f.clientY - U.top) / U.height * L.height
1492
1493
  };
1493
- }, lt = (f) => {
1494
- if (tt !== "draw") return;
1495
- if (S.current) {
1496
- S.current = null, Dt(!1);
1497
- const X = _.current, Q = X == null ? void 0 : X.getContext("2d");
1498
- X && Q && (Q.fillStyle = "#ffffff", Q.fillRect(0, 0, X.width, X.height), Q.strokeStyle = q, Q.lineWidth = 2.5, Q.lineCap = "round", Q.lineJoin = "round"), M.current = [];
1494
+ }, Wt = (f) => {
1495
+ if (J !== "draw") return;
1496
+ if (H.current) {
1497
+ H.current = null, G(!1);
1498
+ const U = y.current, rt = U == null ? void 0 : U.getContext("2d");
1499
+ U && rt && (rt.fillStyle = "#ffffff", rt.fillRect(0, 0, U.width, U.height), rt.strokeStyle = kt, rt.lineWidth = 2.5, rt.lineCap = "round", rt.lineJoin = "round"), I.current = [];
1499
1500
  }
1500
1501
  f.currentTarget.setPointerCapture(f.pointerId), b.current = !0;
1501
- const C = mt(f);
1502
- y.current = C, $.current = [C];
1503
- }, Ht = (f) => {
1504
- if (!b.current || tt !== "draw") return;
1505
- const C = _.current, X = C == null ? void 0 : C.getContext("2d"), Q = y.current;
1506
- if (!X || !Q) return;
1507
- const Ct = mt(f);
1508
- X.beginPath(), X.moveTo(Q.x, Q.y), X.lineTo(Ct.x, Ct.y), X.stroke(), y.current = Ct, $.current.push(Ct);
1509
- }, rt = () => {
1510
- $.current.length > 1 && M.current.push([...$.current]), $.current = [], b.current = !1, y.current = null;
1511
- }, wt = () => {
1512
- const f = _.current, C = f == null ? void 0 : f.getContext("2d");
1513
- !f || !C || (C.fillStyle = "#ffffff", C.fillRect(0, 0, f.width, f.height), M.current = [], $.current = [], S.current = null, Dt(!1), Y(""), gt(""), nt(!1));
1514
- }, It = (f) => {
1515
- Y(f), z || gt(Tr(f));
1516
- }, Jt = () => {
1517
- if (tt === "draw") {
1518
- const N = M.current, E = S.current;
1519
- if (N.length === 0) {
1520
- if (!E) return;
1521
- g == null || g("sign", {
1502
+ const L = it(f);
1503
+ x.current = L, S.current = [L];
1504
+ }, st = (f) => {
1505
+ if (!b.current || J !== "draw") return;
1506
+ const L = y.current, U = L == null ? void 0 : L.getContext("2d"), rt = x.current;
1507
+ if (!U || !rt) return;
1508
+ const Lt = it(f);
1509
+ U.beginPath(), U.moveTo(rt.x, rt.y), U.lineTo(Lt.x, Lt.y), U.stroke(), x.current = Lt, S.current.push(Lt);
1510
+ }, mt = () => {
1511
+ S.current.length > 1 && I.current.push([...S.current]), S.current = [], b.current = !1, x.current = null;
1512
+ }, It = () => {
1513
+ const f = y.current, L = f == null ? void 0 : f.getContext("2d");
1514
+ !f || !L || (L.fillStyle = "#ffffff", L.fillRect(0, 0, f.width, f.height), I.current = [], S.current = [], H.current = null, G(!1), Et(""), E(""), ut(!1));
1515
+ }, ee = (f) => {
1516
+ Et(f), ct || E(Tr(f));
1517
+ }, ht = () => {
1518
+ if (J === "draw") {
1519
+ const X = I.current, et = H.current;
1520
+ if (X.length === 0) {
1521
+ if (!et) return;
1522
+ _ == null || _("sign", {
1522
1523
  mode: "draw",
1523
- imageDataUrl: E.imageDataUrl,
1524
- width: E.width,
1525
- height: E.height,
1526
- inkColor: q
1527
- }), n(E.imageDataUrl, E.width, E.height);
1524
+ imageDataUrl: et.imageDataUrl,
1525
+ width: et.width,
1526
+ height: et.height,
1527
+ inkColor: kt
1528
+ }), n(et.imageDataUrl, et.width, et.height);
1528
1529
  return;
1529
1530
  }
1530
- let W = 1 / 0, D = 1 / 0, ot = -1 / 0, G = -1 / 0;
1531
- for (const Ot of N)
1532
- for (const ht of Ot)
1533
- ht.x < W && (W = ht.x), ht.y < D && (D = ht.y), ht.x > ot && (ot = ht.x), ht.y > G && (G = ht.y);
1534
- const dt = 8;
1535
- W = Math.max(0, W - dt), D = Math.max(0, D - dt), ot += dt, G += dt;
1536
- const _t = ot - W, Rt = G - D, zt = N.map((Ot) => "M" + Ot.map((pt) => ({ x: pt.x - W, y: pt.y - D })).map((pt) => `${pt.x.toFixed(1)},${pt.y.toFixed(1)}`).join("L")).join(" "), qt = `<svg xmlns="http://www.w3.org/2000/svg" width="${_t.toFixed(0)}" height="${Rt.toFixed(0)}" viewBox="0 0 ${_t.toFixed(0)} ${Rt.toFixed(0)}"><path d="${zt}" fill="none" stroke="${q}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`, At = `data:image/svg+xml;base64,${btoa(qt)}`;
1537
- g == null || g("sign", {
1531
+ let ft = 1 / 0, Ft = 1 / 0, Rt = -1 / 0, Ht = -1 / 0;
1532
+ for (const _e of X)
1533
+ for (const Qt of _e)
1534
+ Qt.x < ft && (ft = Qt.x), Qt.y < Ft && (Ft = Qt.y), Qt.x > Rt && (Rt = Qt.x), Qt.y > Ht && (Ht = Qt.y);
1535
+ const At = 8;
1536
+ ft = Math.max(0, ft - At), Ft = Math.max(0, Ft - At), Rt += At, Ht += At;
1537
+ const St = Rt - ft, Pt = Ht - Ft, _t = X.map((_e) => "M" + _e.map((ae) => ({ x: ae.x - ft, y: ae.y - Ft })).map((ae) => `${ae.x.toFixed(1)},${ae.y.toFixed(1)}`).join("L")).join(" "), Ut = Math.max(1, (m == null ? void 0 : m.width) ?? St), Yt = Math.max(1, (m == null ? void 0 : m.height) ?? Pt), Gt = Math.min(Ut / St, Yt / Pt), be = St * Gt, se = Pt * Gt, Ve = (Ut - be) / 2, de = (Yt - se) / 2, qe = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${Ut} ${Yt}"><g transform="translate(${Ve.toFixed(2)} ${de.toFixed(2)}) scale(${Gt.toFixed(4)})"><path d="${_t}" fill="none" stroke="${kt}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></g></svg>`, he = `data:image/svg+xml;base64,${btoa(qe)}`;
1538
+ _ == null || _("sign", {
1538
1539
  mode: "draw",
1539
- imageDataUrl: At,
1540
- width: _t,
1541
- height: Rt,
1542
- inkColor: q
1543
- }), n(At, _t, Rt);
1540
+ imageDataUrl: he,
1541
+ width: Ut,
1542
+ height: Yt,
1543
+ inkColor: kt
1544
+ }), n(he, Ut, Yt);
1544
1545
  return;
1545
1546
  }
1546
- if (!$t) return;
1547
- const f = 3, C = In(it, O.family), Q = document.createElement("canvas").getContext("2d");
1548
- Q.font = `${C * f}px "${O.family}", cursive`;
1549
- const Ct = Q.measureText($t), Xt = 12 * f, Vt = Math.ceil(Ct.width) + Xt * 2, ie = C * f + Xt * 2, a = document.createElement("canvas");
1550
- a.width = Vt, a.height = ie;
1551
- const w = a.getContext("2d");
1552
- w.clearRect(0, 0, Vt, ie), w.font = `${C * f}px "${O.family}", cursive`, w.fillStyle = q, w.textBaseline = "middle", w.fillText($t, Xt, ie / 2);
1553
- const v = a.toDataURL("image/png"), x = Vt / f, R = ie / f, P = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><image href="${v}"/></svg>`, A = `data:image/svg+xml;base64,${btoa(P)}`;
1554
- g == null || g("sign", {
1547
+ if (!yt) return;
1548
+ const f = 3, L = Dn(gt, $t.family), rt = document.createElement("canvas").getContext("2d");
1549
+ rt.font = `${L}px "${$t.family}", cursive`;
1550
+ const Lt = rt.measureText(yt), Zt = 8, ie = Math.ceil(Lt.width) + Zt * 2, a = L + Zt * 2, w = Math.max(1, (m == null ? void 0 : m.width) ?? ie), v = Math.max(1, (m == null ? void 0 : m.height) ?? a), M = Math.min(w / ie, v / a), D = Math.max(8, L * M), P = Math.max(1, Math.round(w * f)), F = Math.max(1, Math.round(v * f)), N = document.createElement("canvas");
1551
+ N.width = P, N.height = F;
1552
+ const j = N.getContext("2d");
1553
+ j.fillStyle = "#ffffff", j.fillRect(0, 0, P, F), j.font = `${D * f}px "${$t.family}", cursive`, j.fillStyle = kt, j.textAlign = "center", j.textBaseline = "middle", j.fillText(yt, P / 2, F / 2);
1554
+ const Z = N.toDataURL("image/png"), R = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${w} ${v}"><image href="${Z}" width="${w}" height="${v}" preserveAspectRatio="xMidYMid meet"/></svg>`, lt = `data:image/svg+xml;base64,${btoa(R)}`;
1555
+ _ == null || _("sign", {
1555
1556
  mode: "type",
1556
- imageDataUrl: A,
1557
- width: x,
1558
- height: R,
1559
- typedName: Mt,
1560
- typedInitials: Tt,
1561
- fontId: ut,
1562
- inkColor: q,
1563
- typeKind: it
1564
- }), n(A, x, R);
1565
- }, ft = () => {
1566
- if (F !== "date" && F !== "text") return;
1567
- const f = F === "date" ? T : ct.trim();
1568
- f && (g == null || g(F, { value: f }), i == null || i(f, F));
1569
- }, Gt = F === "sign";
1570
- return /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__modal", role: "dialog", "aria-modal": "true", children: [
1557
+ imageDataUrl: lt,
1558
+ width: w,
1559
+ height: v,
1560
+ typedName: K,
1561
+ typedInitials: vt,
1562
+ fontId: te,
1563
+ inkColor: kt,
1564
+ typeKind: gt
1565
+ }), n(lt, w, v);
1566
+ }, ne = () => {
1567
+ if (A !== "date" && A !== "text") return;
1568
+ const f = A === "date" ? nt : q.trim();
1569
+ f && (_ == null || _(A, { value: f }), i == null || i(f, A));
1570
+ }, Nt = A === "sign";
1571
+ return /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal", role: "dialog", "aria-modal": "true", children: [
1571
1572
  /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__modal-backdrop", onClick: e }),
1572
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__modal-card", children: [
1573
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__modal-header", children: [
1574
- /* @__PURE__ */ s("h3", { children: F === "date" ? "Pick a date" : F === "text" ? "Enter text" : "Create e-signature" }),
1573
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-card", children: [
1574
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-header", children: [
1575
+ /* @__PURE__ */ s("h3", { children: A === "date" ? "Pick a date" : A === "text" ? "Enter text" : "Create e-signature" }),
1575
1576
  /* @__PURE__ */ s(
1576
1577
  "button",
1577
1578
  {
@@ -1588,22 +1589,22 @@ function Cr({
1588
1589
  {
1589
1590
  type: "button",
1590
1591
  role: "tab",
1591
- "aria-selected": F === f,
1592
- className: F === f ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1593
- onClick: () => J(f),
1592
+ "aria-selected": A === f,
1593
+ className: A === f ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1594
+ onClick: () => C(f),
1594
1595
  children: f === "sign" ? "Sign" : f === "date" ? "Date" : "Text"
1595
1596
  },
1596
1597
  f
1597
1598
  )) }) : null,
1598
- Gt ? /* @__PURE__ */ L(Fe, { children: [
1599
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__sign-modes", children: [
1599
+ Nt ? /* @__PURE__ */ T(je, { children: [
1600
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__sign-modes", children: [
1600
1601
  /* @__PURE__ */ s(
1601
1602
  "button",
1602
1603
  {
1603
1604
  type: "button",
1604
- className: tt === "draw" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1605
+ className: J === "draw" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1605
1606
  onClick: () => {
1606
- bt("draw"), wt();
1607
+ Mt("draw"), It();
1607
1608
  },
1608
1609
  children: "Draw"
1609
1610
  }
@@ -1612,81 +1613,81 @@ function Cr({
1612
1613
  "button",
1613
1614
  {
1614
1615
  type: "button",
1615
- className: tt === "type" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1616
- onClick: () => bt("type"),
1616
+ className: J === "type" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1617
+ onClick: () => Mt("type"),
1617
1618
  children: "Type"
1618
1619
  }
1619
1620
  ),
1620
- /* @__PURE__ */ L("label", { className: "epochs-pdf-viewer__sign-ink", children: [
1621
+ /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-ink", children: [
1621
1622
  "Ink",
1622
1623
  /* @__PURE__ */ s(
1623
1624
  "input",
1624
1625
  {
1625
1626
  type: "color",
1626
- value: q,
1627
- onChange: (f) => Zt(f.target.value)
1627
+ value: kt,
1628
+ onChange: (f) => dt(f.target.value)
1628
1629
  }
1629
1630
  )
1630
1631
  ] })
1631
1632
  ] }),
1632
- tt === "type" ? /* @__PURE__ */ L(Fe, { children: [
1633
+ J === "type" ? /* @__PURE__ */ T(je, { children: [
1633
1634
  /* @__PURE__ */ s(
1634
1635
  "div",
1635
1636
  {
1636
1637
  className: "epochs-pdf-viewer__sign-fonts",
1637
1638
  role: "group",
1638
1639
  "aria-label": "Handwriting style",
1639
- children: Le.map((f) => /* @__PURE__ */ s(
1640
+ children: Ue.map((f) => /* @__PURE__ */ s(
1640
1641
  "button",
1641
1642
  {
1642
1643
  type: "button",
1643
- className: ut === f.id ? "epochs-pdf-viewer__sign-font epochs-pdf-viewer__sign-font--active" : "epochs-pdf-viewer__sign-font",
1644
+ className: te === f.id ? "epochs-pdf-viewer__sign-font epochs-pdf-viewer__sign-font--active" : "epochs-pdf-viewer__sign-font",
1644
1645
  style: { fontFamily: `"${f.family}", cursive` },
1645
- onClick: () => Qt(f.id),
1646
+ onClick: () => ye(f.id),
1646
1647
  title: f.label,
1647
- children: Lt
1648
+ children: bt
1648
1649
  },
1649
1650
  f.id
1650
1651
  ))
1651
1652
  }
1652
1653
  ),
1653
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__sign-type-fields", children: [
1654
- /* @__PURE__ */ L("label", { className: "epochs-pdf-viewer__sign-type-field", children: [
1654
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__sign-type-fields", children: [
1655
+ /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-type-field", children: [
1655
1656
  /* @__PURE__ */ s("span", { children: "Full name" }),
1656
1657
  /* @__PURE__ */ s(
1657
1658
  "input",
1658
1659
  {
1659
1660
  className: "epochs-pdf-viewer__sign-type-input",
1660
1661
  type: "text",
1661
- value: Mt,
1662
- onChange: (f) => It(f.target.value),
1663
- onFocus: () => vt("signature"),
1662
+ value: K,
1663
+ onChange: (f) => ee(f.target.value),
1664
+ onFocus: () => tt("signature"),
1664
1665
  placeholder: "Type your full name",
1665
- style: { fontFamily: `"${O.family}", cursive` },
1666
+ style: { fontFamily: `"${$t.family}", cursive` },
1666
1667
  autoFocus: !0
1667
1668
  }
1668
1669
  )
1669
1670
  ] }),
1670
- /* @__PURE__ */ L("label", { className: "epochs-pdf-viewer__sign-type-field", children: [
1671
+ /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-type-field", children: [
1671
1672
  /* @__PURE__ */ s("span", { children: "Initials" }),
1672
1673
  /* @__PURE__ */ s(
1673
1674
  "input",
1674
1675
  {
1675
1676
  className: "epochs-pdf-viewer__sign-type-input",
1676
1677
  type: "text",
1677
- value: Tt,
1678
+ value: vt,
1678
1679
  onChange: (f) => {
1679
- nt(!0), gt(f.target.value.toUpperCase());
1680
+ ut(!0), E(f.target.value.toUpperCase());
1680
1681
  },
1681
- onFocus: () => vt("initials"),
1682
+ onFocus: () => tt("initials"),
1682
1683
  placeholder: "e.g. JD",
1683
1684
  maxLength: 4,
1684
- style: { fontFamily: `"${O.family}", cursive` }
1685
+ style: { fontFamily: `"${$t.family}", cursive` }
1685
1686
  }
1686
1687
  )
1687
1688
  ] })
1688
1689
  ] }),
1689
- /* @__PURE__ */ L(
1690
+ /* @__PURE__ */ T(
1690
1691
  "div",
1691
1692
  {
1692
1693
  className: "epochs-pdf-viewer__sign-type-kind",
@@ -1697,8 +1698,8 @@ function Cr({
1697
1698
  "button",
1698
1699
  {
1699
1700
  type: "button",
1700
- className: it === "signature" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1701
- onClick: () => vt("signature"),
1701
+ className: gt === "signature" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1702
+ onClick: () => tt("signature"),
1702
1703
  children: "Use full name"
1703
1704
  }
1704
1705
  ),
@@ -1706,59 +1707,59 @@ function Cr({
1706
1707
  "button",
1707
1708
  {
1708
1709
  type: "button",
1709
- className: it === "initials" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1710
- onClick: () => vt("initials"),
1710
+ className: gt === "initials" ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1711
+ onClick: () => tt("initials"),
1711
1712
  children: "Use initials"
1712
1713
  }
1713
1714
  )
1714
1715
  ]
1715
1716
  }
1716
1717
  )
1717
- ] }) : /* @__PURE__ */ s("p", { className: "epochs-pdf-viewer__sign-hint", children: Yt ? "Previous signature loaded — submit to reuse, or draw a new one" : "Draw your signature below" }),
1718
+ ] }) : /* @__PURE__ */ s("p", { className: "epochs-pdf-viewer__sign-hint", children: Kt ? "Previous signature loaded — submit to reuse, or draw a new one" : "Draw your signature below" }),
1718
1719
  /* @__PURE__ */ s(
1719
1720
  "canvas",
1720
1721
  {
1721
- ref: _,
1722
- className: tt === "draw" ? "epochs-pdf-viewer__sign-canvas" : "epochs-pdf-viewer__sign-canvas epochs-pdf-viewer__sign-canvas--preview",
1723
- onPointerDown: lt,
1724
- onPointerMove: Ht,
1725
- onPointerUp: rt,
1726
- onPointerLeave: rt
1722
+ ref: y,
1723
+ className: J === "draw" ? "epochs-pdf-viewer__sign-canvas" : "epochs-pdf-viewer__sign-canvas epochs-pdf-viewer__sign-canvas--preview",
1724
+ onPointerDown: Wt,
1725
+ onPointerMove: st,
1726
+ onPointerUp: mt,
1727
+ onPointerLeave: mt
1727
1728
  }
1728
1729
  )
1729
- ] }) : F === "date" ? /* @__PURE__ */ L("label", { className: "epochs-pdf-viewer__sign-type-field", style: { padding: "1rem" }, children: [
1730
+ ] }) : A === "date" ? /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-type-field", style: { padding: "1rem" }, children: [
1730
1731
  /* @__PURE__ */ s("span", { children: "Date" }),
1731
1732
  /* @__PURE__ */ s(
1732
1733
  "input",
1733
1734
  {
1734
1735
  className: "epochs-pdf-viewer__sign-type-input",
1735
1736
  type: "date",
1736
- value: T,
1737
+ value: nt,
1737
1738
  onChange: (f) => at(f.target.value),
1738
1739
  autoFocus: !0
1739
1740
  }
1740
1741
  )
1741
- ] }) : /* @__PURE__ */ L("label", { className: "epochs-pdf-viewer__sign-type-field", style: { padding: "1rem" }, children: [
1742
+ ] }) : /* @__PURE__ */ T("label", { className: "epochs-pdf-viewer__sign-type-field", style: { padding: "1rem" }, children: [
1742
1743
  /* @__PURE__ */ s("span", { children: "Text" }),
1743
1744
  /* @__PURE__ */ s(
1744
1745
  "input",
1745
1746
  {
1746
1747
  className: "epochs-pdf-viewer__sign-type-input",
1747
1748
  type: "text",
1748
- value: ct,
1749
- onChange: (f) => Z(f.target.value),
1749
+ value: q,
1750
+ onChange: (f) => pt(f.target.value),
1750
1751
  placeholder: d ?? "Enter text",
1751
1752
  autoFocus: !0
1752
1753
  }
1753
1754
  )
1754
1755
  ] }),
1755
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__modal-actions", children: [
1756
- Gt ? /* @__PURE__ */ s(
1756
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-actions", children: [
1757
+ Nt ? /* @__PURE__ */ s(
1757
1758
  "button",
1758
1759
  {
1759
1760
  type: "button",
1760
1761
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1761
- onClick: wt,
1762
+ onClick: It,
1762
1763
  children: "Clear"
1763
1764
  }
1764
1765
  ) : null,
@@ -1776,9 +1777,9 @@ function Cr({
1776
1777
  {
1777
1778
  type: "button",
1778
1779
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--primary",
1779
- onClick: Gt ? Jt : ft,
1780
- disabled: F === "date" ? !T : F === "text" ? !ct.trim() : !1,
1781
- children: Gt ? "Use signature" : "Place on page"
1780
+ onClick: Nt ? ht : ne,
1781
+ disabled: A === "date" ? !nt : A === "text" ? !q.trim() : !1,
1782
+ children: Nt ? "Use signature" : "Place on page"
1782
1783
  }
1783
1784
  )
1784
1785
  ] })
@@ -1792,50 +1793,50 @@ function Tr(t) {
1792
1793
  return ((i = n[0]) == null ? void 0 : i.toUpperCase()) ?? "";
1793
1794
  }).join("");
1794
1795
  }
1795
- const Oe = "__epochsToolbarToolId";
1796
- function St(t, e) {
1796
+ const Xe = "__epochsToolbarToolId";
1797
+ function zt(t, e) {
1797
1798
  const n = (() => null);
1798
- return n.displayName = e, Object.defineProperty(n, Oe, {
1799
+ return n.displayName = e, Object.defineProperty(n, Xe, {
1799
1800
  value: t,
1800
1801
  enumerable: !0
1801
1802
  }), n;
1802
1803
  }
1803
- function Cn(t) {
1804
- return t[Oe];
1804
+ function Ln(t) {
1805
+ return t[Xe];
1805
1806
  }
1806
1807
  function Dr(t) {
1807
- return typeof t == "function" && Oe in t && typeof t[Oe] == "string";
1808
+ return typeof t == "function" && Xe in t && typeof t[Xe] == "string";
1808
1809
  }
1809
- const jn = St("thumbnail", "Thumbnail"), Sn = St("navigation", "Navigation"), Bn = St("zoom", "Zoom"), On = St("rotate", "Rotate"), Wn = St("reload", "Reload"), Gn = St("print", "Print"), Xn = St("open", "Open"), Vn = St("download", "Download"), qn = St("highlight", "Highlight"), Yn = St("underline", "Underline"), Kn = St("signature", "Signature"), Zn = St("text", "AddText"), Qn = St("erase", "Erase"), Jn = St("clear", "Clear"), ro = [
1810
- jn,
1810
+ const zn = zt("thumbnail", "Thumbnail"), Sn = zt("navigation", "Navigation"), Gn = zt("zoom", "Zoom"), Xn = zt("rotate", "Rotate"), Vn = zt("reload", "Reload"), qn = zt("print", "Print"), Yn = zt("open", "Open"), Kn = zt("download", "Download"), Zn = zt("highlight", "Highlight"), Qn = zt("underline", "Underline"), Jn = zt("signature", "Signature"), ti = zt("text", "AddText"), ei = zt("erase", "Erase"), ni = zt("clear", "Clear"), ro = [
1811
+ zn,
1811
1812
  Sn,
1812
- Bn,
1813
- On,
1814
- qn,
1815
- Yn,
1816
- Kn,
1813
+ Gn,
1814
+ Xn,
1817
1815
  Zn,
1818
1816
  Qn,
1819
1817
  Jn,
1820
- Wn,
1821
- Gn,
1822
- Xn,
1823
- Vn
1824
- ], Tn = [
1825
- [jn, Sn],
1818
+ ti,
1819
+ ei,
1820
+ ni,
1821
+ Vn,
1822
+ qn,
1823
+ Yn,
1824
+ Kn
1825
+ ], Fn = [
1826
+ [zn, Sn],
1826
1827
  [
1827
- Bn,
1828
- On,
1829
- qn,
1830
- Yn,
1831
- Kn,
1828
+ Gn,
1829
+ Xn,
1832
1830
  Zn,
1833
1831
  Qn,
1834
1832
  Jn,
1835
- Wn,
1836
- Gn,
1837
- Xn,
1838
- Vn
1833
+ ti,
1834
+ ei,
1835
+ ni,
1836
+ Vn,
1837
+ qn,
1838
+ Yn,
1839
+ Kn
1839
1840
  ]
1840
1841
  ], Lr = [
1841
1842
  "highlight",
@@ -1845,7 +1846,7 @@ const jn = St("thumbnail", "Thumbnail"), Sn = St("navigation", "Navigation"), Bn
1845
1846
  "erase",
1846
1847
  "clear"
1847
1848
  ];
1848
- function Dn(t) {
1849
+ function Rn(t) {
1849
1850
  return Lr.includes(t);
1850
1851
  }
1851
1852
  function Fr(t, e, n) {
@@ -1889,7 +1890,7 @@ function Fr(t, e, n) {
1889
1890
  },
1890
1891
  "nav-prev"
1891
1892
  ),
1892
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__page-input", children: [
1893
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__page-input", children: [
1893
1894
  /* @__PURE__ */ s(
1894
1895
  "input",
1895
1896
  {
@@ -1907,7 +1908,7 @@ function Fr(t, e, n) {
1907
1908
  "aria-label": "Page number"
1908
1909
  }
1909
1910
  ),
1910
- /* @__PURE__ */ L("span", { children: [
1911
+ /* @__PURE__ */ T("span", { children: [
1911
1912
  "/ ",
1912
1913
  e.numPages || "-"
1913
1914
  ] })
@@ -1940,7 +1941,7 @@ function Fr(t, e, n) {
1940
1941
  },
1941
1942
  "zoom-out"
1942
1943
  ),
1943
- /* @__PURE__ */ L("span", { className: "epochs-pdf-viewer__zoom-label", children: [
1944
+ /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__zoom-label", children: [
1944
1945
  Math.round(e.scale * 100),
1945
1946
  "%"
1946
1947
  ] }, "zoom-label"),
@@ -2163,9 +2164,9 @@ function Rr(t, e) {
2163
2164
  ), t.markupTool === "erase" && e.has("erase") && n.push(
2164
2165
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__markup-hint", children: "Select PDF words to remove · click added text/markup to erase" }, "erase-hint")
2165
2166
  ), t.markupTool === "highlight" && e.has("highlight") || t.markupTool === "underline" && e.has("underline")) {
2166
- const i = t.markupTool === "highlight" ? t.highlightHex : t.underlineHex, r = t.markupTool === "highlight" ? t.setHighlightHex : t.setUnderlineHex, o = t.markupTool === "highlight" ? Ln : Fn;
2167
+ const i = t.markupTool === "highlight" ? t.highlightHex : t.underlineHex, r = t.markupTool === "highlight" ? t.setHighlightHex : t.setUnderlineHex, o = t.markupTool === "highlight" ? An : En;
2167
2168
  n.push(
2168
- /* @__PURE__ */ L(
2169
+ /* @__PURE__ */ T(
2169
2170
  "div",
2170
2171
  {
2171
2172
  className: "epochs-pdf-viewer__color-picker",
@@ -2176,16 +2177,16 @@ function Rr(t, e) {
2176
2177
  "button",
2177
2178
  {
2178
2179
  type: "button",
2179
- className: oe(i) === oe(d.hex) ? "epochs-pdf-viewer__swatch epochs-pdf-viewer__swatch--active" : "epochs-pdf-viewer__swatch",
2180
+ className: le(i) === le(d.hex) ? "epochs-pdf-viewer__swatch epochs-pdf-viewer__swatch--active" : "epochs-pdf-viewer__swatch",
2180
2181
  style: { background: d.hex },
2181
2182
  title: d.label,
2182
2183
  "aria-label": d.label,
2183
- "aria-pressed": oe(i) === oe(d.hex),
2184
- onClick: () => r(oe(d.hex))
2184
+ "aria-pressed": le(i) === le(d.hex),
2185
+ onClick: () => r(le(d.hex))
2185
2186
  },
2186
2187
  d.id
2187
2188
  )),
2188
- /* @__PURE__ */ L(
2189
+ /* @__PURE__ */ T(
2189
2190
  "label",
2190
2191
  {
2191
2192
  className: "epochs-pdf-viewer__custom-color",
@@ -2202,8 +2203,8 @@ function Rr(t, e) {
2202
2203
  "input",
2203
2204
  {
2204
2205
  type: "color",
2205
- value: oe(i),
2206
- onChange: (d) => r(oe(d.target.value)),
2206
+ value: le(i),
2207
+ onChange: (d) => r(le(d.target.value)),
2207
2208
  "aria-label": "Custom color"
2208
2209
  }
2209
2210
  )
@@ -2221,13 +2222,13 @@ function Rr(t, e) {
2221
2222
  function Ar(t, e) {
2222
2223
  if (!t) return null;
2223
2224
  if (Array.isArray(t)) {
2224
- const o = (d) => (d ?? []).filter(Dr).map(Cn);
2225
+ const o = (d) => (d ?? []).filter(Dr).map(Ln);
2225
2226
  return {
2226
2227
  left: o(t[0]),
2227
2228
  right: o(t[1])
2228
2229
  };
2229
2230
  }
2230
- const n = e.enableThumbnails, i = (o, d) => o.map(Cn).filter((u) => d[u] !== !1), r = {
2231
+ const n = e.enableThumbnails, i = (o, d) => o.map(Ln).filter((u) => d[u] !== !1), r = {
2231
2232
  thumbnail: n,
2232
2233
  navigation: e.enableNavigation,
2233
2234
  zoom: e.enableZoom,
@@ -2244,8 +2245,8 @@ function Ar(t, e) {
2244
2245
  clear: e.enableClear
2245
2246
  };
2246
2247
  return {
2247
- left: i(Tn[0], r),
2248
- right: i(Tn[1], r)
2248
+ left: i(Fn[0], r),
2249
+ right: i(Fn[1], r)
2249
2250
  };
2250
2251
  }
2251
2252
  function oo({
@@ -2260,76 +2261,76 @@ function oo({
2260
2261
  thumbnailWidth: m = 140,
2261
2262
  maxThumbnails: g = 60,
2262
2263
  className: _,
2263
- workerSrc: b,
2264
- enableToolbar: y = !1,
2265
- enableThumbnails: M,
2266
- enableNavigation: $ = !0,
2264
+ workerSrc: y,
2265
+ enableToolbar: b = !1,
2266
+ enableThumbnails: x,
2267
+ enableNavigation: I = !0,
2267
2268
  enableZoom: S = !0,
2268
2269
  enableRotate: H = !0,
2269
- enableReload: F = !0,
2270
- enablePrint: J = !0,
2271
- enableOpen: T = !0,
2272
- enableDownload: at = !0,
2273
- enableMarkup: ct = !0,
2274
- enableHighlight: Z = !0,
2275
- enableUnderline: tt = !0,
2276
- enableSignature: bt = !0,
2270
+ enableReload: W = !0,
2271
+ enablePrint: A = !0,
2272
+ enableOpen: C = !0,
2273
+ enableDownload: nt = !0,
2274
+ enableMarkup: at = !0,
2275
+ enableHighlight: q = !0,
2276
+ enableUnderline: pt = !0,
2277
+ enableSignature: J = !0,
2277
2278
  enableText: Mt = !0,
2278
- enableErase: Y = !0,
2279
- enableClear: Tt = !0,
2280
- signatureFields: gt = [],
2281
- textFields: z = [],
2282
- onSignatureComplete: nt,
2283
- onSignatureFieldsChange: it,
2284
- applySignatureToSameTag: vt = !1,
2285
- onFieldValueComplete: q,
2286
- openSignaturePad: Zt = !1,
2287
- onSignaturePadClose: ut,
2288
- onSubmit: Qt,
2289
- submitLabel: Re = "Submit",
2290
- submitLoading: Bt = !1
2279
+ enableErase: K = !0,
2280
+ enableClear: Et = !0,
2281
+ signatureFields: vt = [],
2282
+ textFields: E = [],
2283
+ onSignatureComplete: ct,
2284
+ onSignatureFieldsChange: ut,
2285
+ applySignatureToSameTag: gt = !1,
2286
+ onFieldValueComplete: tt,
2287
+ openSignaturePad: kt = !1,
2288
+ onSignaturePadClose: dt,
2289
+ onSubmit: te,
2290
+ submitLabel: ye = "Submit",
2291
+ submitLoading: Vt = !1
2291
2292
  }) {
2292
- var _n, vn;
2293
- const Yt = xt(null), Dt = xt(null), O = xt(/* @__PURE__ */ new Map()), $t = xt(!1), Lt = be(() => t && typeof t != "string" ? t : null, [t]), mt = be(() => Lt ? "" : xr(typeof t == "string" ? t : void 0, e, n), [Lt, t, e, n]), [lt, Ht] = j("idle"), [rt, wt] = j(null), [It, Jt] = j(0), [ft, Gt] = j(1), [Ft, f] = j(d), [C, X] = j(0), [Q, Ct] = j(null), [Xt, Vt] = j(!1), [ie, a] = j(!1), [w, v] = j(!1), [x, R] = j("none"), [P, A] = j([]), [N, E] = j([]), [W, D] = j([]), [ot, G] = j(!1), [dt, _t] = j(void 0), [Rt, zt] = j({}), [qt, At] = j(null), [Ot, ht] = j(
2293
+ var Mn, kn;
2294
+ const qt = xt(null), Kt = xt(null), G = xt(/* @__PURE__ */ new Map()), $t = xt(!1), yt = Pe(() => t && typeof t != "string" ? t : null, [t]), bt = Pe(() => yt ? "" : xr(typeof t == "string" ? t : void 0, e, n), [yt, t, e, n]), [it, Wt] = O("idle"), [st, mt] = O(null), [It, ee] = O(0), [ht, ne] = O(1), [Nt, oe] = O(d), [f, L] = O(0), [U, rt] = O(null), [Lt, Zt] = O(!1), [ie, a] = O(!1), [w, v] = O(!1), [M, D] = O("none"), [P, F] = O([]), [N, j] = O([]), [Z, R] = O([]), [lt, X] = O(!1), [et, ft] = O(void 0), [Ft, Rt] = O({}), [Ht, At] = O(null), [St, Pt] = O(
2294
2295
  null
2295
- ), [pt, te] = j(
2296
+ ), [_t, Ut] = O(
2296
2297
  null
2297
- ), [ue, ee] = j(null), [Ae, fe] = j(null), [ai, Me] = j(null), [ci, Ee] = j(null), [ln, li] = j(Rn), [dn, di] = j(Oi), ke = z.length > 0, [Wt, We] = j({}), [U, Ge] = j(gt), pe = xt(U);
2298
- pe.current = U, Pt(() => {
2299
- pe.current = gt, Ge(gt), We((c) => {
2298
+ ), [Yt, Gt] = O(null), [be, se] = O(null), [Ve, de] = O(null), [qe, he] = O(null), [_e, Qt] = O(Hn), [ae, di] = O(zi), Te = E.length > 0, [Xt, Ye] = O({}), [B, Ke] = O(vt), ve = xt(B);
2299
+ ve.current = B, Dt(() => {
2300
+ ve.current = vt, Ke(vt), Ye((c) => {
2300
2301
  const h = { ...c };
2301
- for (const l of gt) {
2302
+ for (const l of vt) {
2302
2303
  const p = l.type ?? "sign";
2303
2304
  (p === "date" || p === "text") && l.value != null && l.value !== "" && (h[l.id] = l.value);
2304
2305
  }
2305
2306
  return h;
2306
2307
  });
2307
- }, [gt]);
2308
- const Et = U.length > 0, Ne = K(
2308
+ }, [vt]);
2309
+ const jt = B.length > 0, De = Y(
2309
2310
  (c, h, l) => {
2310
2311
  var k;
2311
2312
  const p = c.type ?? "sign";
2312
- return p === "date" || p === "text" ? !!((k = l[c.id] ?? c.value) != null && k.trim()) : h.some((I) => I.fieldId === c.id) || !!c.signatureDataUrl;
2313
+ return p === "date" || p === "text" ? !!((k = l[c.id] ?? c.value) != null && k.trim()) : h.some(($) => $.fieldId === c.id) || !!c.signatureDataUrl;
2313
2314
  },
2314
2315
  []
2315
- ), hn = K(
2316
+ ), pn = Y(
2316
2317
  (c, h) => {
2317
- const l = new Set(c), k = pe.current.map(
2318
- (I) => l.has(I.id) ? { ...I, value: h } : I
2318
+ const l = new Set(c), k = ve.current.map(
2319
+ ($) => l.has($.id) ? { ...$, value: h } : $
2319
2320
  );
2320
- pe.current = k, Ge(k), it == null || it(k), We((I) => {
2321
- const B = { ...I };
2322
- for (const st of c) B[st] = h;
2323
- return B;
2321
+ ve.current = k, Ke(k), ut == null || ut(k), Ye(($) => {
2322
+ const z = { ...$ };
2323
+ for (const ot of c) z[ot] = h;
2324
+ return z;
2324
2325
  });
2325
- for (const I of c)
2326
- q == null || q(I, h);
2326
+ for (const $ of c)
2327
+ tt == null || tt($, h);
2327
2328
  },
2328
- [q, it]
2329
- ), Pe = K(
2329
+ [tt, ut]
2330
+ ), Le = Y(
2330
2331
  (c, h, l) => {
2331
- const p = pe.current, k = c == null ? null : Array.isArray(c) ? c : [c], I = k ? new Set(k) : null, B = I ? p.map(
2332
- (st) => I.has(st.id) ? { ...st, signatureDataUrl: h.imageDataUrl } : st
2332
+ const p = ve.current, k = c == null ? null : Array.isArray(c) ? c : [c], $ = k ? new Set(k) : null, z = $ ? p.map(
2333
+ (ot) => $.has(ot.id) ? { ...ot, signatureDataUrl: h.imageDataUrl } : ot
2333
2334
  ) : [
2334
2335
  ...p,
2335
2336
  {
@@ -2343,122 +2344,122 @@ function oo({
2343
2344
  signatureDataUrl: h.imageDataUrl
2344
2345
  }
2345
2346
  ];
2346
- if (pe.current = B, Ge(B), it == null || it(B), !k || k.length === 0) {
2347
- nt == null || nt(void 0, h);
2347
+ if (ve.current = z, Ke(z), ut == null || ut(z), !k || k.length === 0) {
2348
+ ct == null || ct(void 0, h);
2348
2349
  return;
2349
2350
  }
2350
- for (const st of k)
2351
- nt == null || nt(
2352
- st,
2353
- (l == null ? void 0 : l.get(st)) ?? h
2351
+ for (const ot of k)
2352
+ ct == null || ct(
2353
+ ot,
2354
+ (l == null ? void 0 : l.get(ot)) ?? h
2354
2355
  );
2355
2356
  },
2356
- [nt, it]
2357
+ [ct, ut]
2357
2358
  );
2358
- Pt(() => {
2359
- Zt && G(!0);
2360
- }, [Zt]);
2361
- const se = be(
2362
- () => Ar(y, {
2363
- enableThumbnails: M,
2364
- enableNavigation: $,
2359
+ Dt(() => {
2360
+ kt && X(!0);
2361
+ }, [kt]);
2362
+ const ue = Pe(
2363
+ () => Ar(b, {
2364
+ enableThumbnails: x,
2365
+ enableNavigation: I,
2365
2366
  enableZoom: S,
2366
2367
  enableRotate: H,
2367
- enableReload: F,
2368
- enablePrint: J,
2369
- enableOpen: T,
2370
- enableDownload: at,
2371
- enableHighlight: Z,
2372
- enableUnderline: tt,
2373
- enableSignature: bt,
2368
+ enableReload: W,
2369
+ enablePrint: A,
2370
+ enableOpen: C,
2371
+ enableDownload: nt,
2372
+ enableHighlight: q,
2373
+ enableUnderline: pt,
2374
+ enableSignature: J,
2374
2375
  enableText: Mt,
2375
- enableErase: Y,
2376
- enableClear: Tt
2376
+ enableErase: K,
2377
+ enableClear: Et
2377
2378
  }),
2378
2379
  [
2379
- y,
2380
- M,
2381
- $,
2380
+ b,
2381
+ x,
2382
+ I,
2382
2383
  S,
2383
2384
  H,
2384
- F,
2385
+ W,
2386
+ A,
2387
+ C,
2388
+ nt,
2389
+ q,
2390
+ pt,
2385
2391
  J,
2386
- T,
2387
- at,
2388
- Z,
2389
- tt,
2390
- bt,
2391
2392
  Mt,
2392
- Y,
2393
- Tt
2393
+ K,
2394
+ Et
2394
2395
  ]
2395
- ), ae = be(() => se ? /* @__PURE__ */ new Set([...se.left, ...se.right]) : /* @__PURE__ */ new Set(), [se]);
2396
- Pt(() => {
2397
- if (!ae.has("thumbnail")) {
2398
- Vt(!1);
2396
+ ), fe = Pe(() => ue ? /* @__PURE__ */ new Set([...ue.left, ...ue.right]) : /* @__PURE__ */ new Set(), [ue]);
2397
+ Dt(() => {
2398
+ if (!fe.has("thumbnail")) {
2399
+ Zt(!1);
2399
2400
  return;
2400
2401
  }
2401
2402
  const h = window.matchMedia("(max-width: 720px)"), l = () => {
2402
- Vt(h.matches ? !1 : u);
2403
+ Zt(h.matches ? !1 : u);
2403
2404
  };
2404
2405
  return l(), h.addEventListener("change", l), () => h.removeEventListener("change", l);
2405
- }, [ae, u]);
2406
- const un = !Et && ae.has("highlight"), fn = !Et && ae.has("underline"), Xe = ae.has("signature") || Et, pn = ae.has("text") || ke, gn = !Et && ae.has("erase"), $e = K(() => {
2407
- Dt.current && (URL.revokeObjectURL(Dt.current), Dt.current = null);
2408
- }, []), Ve = K(async () => {
2409
- if (!(!Lt && !mt)) {
2410
- vr(b), Ht("loading"), wt(null), Jt(0), Gt(1), A([]), E([]), D([]), At(null), ht(null), te(null), ee(null), fe(null), Me(null), Ee(null), R("none");
2406
+ }, [fe, u]);
2407
+ const gn = !jt && fe.has("highlight"), mn = !jt && fe.has("underline"), Ze = fe.has("signature") || jt, wn = fe.has("text") || Te, yn = !jt && fe.has("erase"), Fe = Y(() => {
2408
+ Kt.current && (URL.revokeObjectURL(Kt.current), Kt.current = null);
2409
+ }, []), Qe = Y(async () => {
2410
+ if (!(!yt && !bt)) {
2411
+ vr(y), Wt("loading"), mt(null), ee(0), ne(1), F([]), j([]), R([]), At(null), Pt(null), Ut(null), Gt(null), se(null), de(null), he(null), D("none");
2411
2412
  try {
2412
- const c = Lt ? await Nn(Lt, i) : await Nn(mt, i), h = new Blob([c], { type: "application/pdf" }), l = URL.createObjectURL(h);
2413
- $e(), Dt.current = l, Ct(l);
2414
- const k = await ve.getDocument({
2413
+ const c = yt ? await In(yt, i) : await In(bt, i), h = new Blob([c], { type: "application/pdf" }), l = URL.createObjectURL(h);
2414
+ Fe(), Kt.current = l, rt(l);
2415
+ const k = await Ie.getDocument({
2415
2416
  data: c,
2416
- cMapUrl: `https://unpkg.com/pdfjs-dist@${ve.version}/cmaps/`,
2417
+ cMapUrl: `https://unpkg.com/pdfjs-dist@${Ie.version}/cmaps/`,
2417
2418
  cMapPacked: !0,
2418
- standardFontDataUrl: `https://unpkg.com/pdfjs-dist@${ve.version}/standard_fonts/`
2419
+ standardFontDataUrl: `https://unpkg.com/pdfjs-dist@${Ie.version}/standard_fonts/`
2419
2420
  }).promise;
2420
- wt(k), Jt(k.numPages), Ht("ready");
2421
+ mt(k), ee(k.numPages), Wt("ready");
2421
2422
  } catch {
2422
- Ht("error");
2423
+ Wt("error");
2423
2424
  }
2424
2425
  }
2425
2426
  }, [
2426
- Lt,
2427
- mt,
2427
+ yt,
2428
+ bt,
2428
2429
  i,
2429
- $e,
2430
- b
2430
+ Fe,
2431
+ y
2431
2432
  ]);
2432
- Pt(() => {
2433
- if (!Lt && !mt) {
2434
- Ht("idle"), wt(null), Jt(0), Ct(null), $e();
2433
+ Dt(() => {
2434
+ if (!yt && !bt) {
2435
+ Wt("idle"), mt(null), ee(0), rt(null), Fe();
2435
2436
  return;
2436
2437
  }
2437
- return Ve(), () => {
2438
- $e();
2438
+ return Qe(), () => {
2439
+ Fe();
2439
2440
  };
2440
- }, [Lt, mt, Ve, $e]), Pt(() => {
2441
- (x === "highlight" && !un || x === "underline" && !fn || x === "sign" && !Xe || x === "text" && !pn || x === "erase" && !gn) && R("none");
2442
- }, [un, fn, Xe, pn, gn, x]);
2443
- const ge = K(
2441
+ }, [yt, bt, Qe, Fe]), Dt(() => {
2442
+ (M === "highlight" && !gn || M === "underline" && !mn || M === "sign" && !Ze || M === "text" && !wn || M === "erase" && !yn) && D("none");
2443
+ }, [gn, mn, Ze, wn, yn, M]);
2444
+ const xe = Y(
2444
2445
  (c) => {
2445
- const h = Math.max(1, Math.min(It || 1, c)), l = O.current.get(h);
2446
+ const h = Math.max(1, Math.min(It || 1, c)), l = G.current.get(h);
2446
2447
  if (!l) {
2447
- Gt(h);
2448
+ ne(h);
2448
2449
  return;
2449
2450
  }
2450
- $t.current = !0, l.scrollIntoView({ behavior: "smooth", block: "start" }), Gt(h), window.setTimeout(() => {
2451
+ $t.current = !0, l.scrollIntoView({ behavior: "smooth", block: "start" }), ne(h), window.setTimeout(() => {
2451
2452
  $t.current = !1;
2452
2453
  }, 500);
2453
2454
  },
2454
2455
  [It]
2455
- ), me = K(
2456
+ ), Me = Y(
2456
2457
  (c) => {
2457
- const h = O.current.get(c.pageNumber);
2458
- h && ($t.current = !0, Gt(c.pageNumber));
2458
+ const h = G.current.get(c.pageNumber);
2459
+ h && ($t.current = !0, ne(c.pageNumber));
2459
2460
  const l = () => {
2460
2461
  var k;
2461
- const p = (k = Yt.current) == null ? void 0 : k.querySelector(
2462
+ const p = (k = qt.current) == null ? void 0 : k.querySelector(
2462
2463
  `[data-signature-field-id="${CSS.escape(c.id)}"]`
2463
2464
  );
2464
2465
  p ? p.scrollIntoView({ behavior: "smooth", block: "center" }) : h && h.scrollIntoView({ behavior: "smooth", block: "start" }), window.setTimeout(() => {
@@ -2471,21 +2472,21 @@ function oo({
2471
2472
  },
2472
2473
  []
2473
2474
  );
2474
- Pt(() => {
2475
- if (lt !== "ready" || !Yt.current || !It) return;
2476
- const c = Yt.current, h = new IntersectionObserver(
2475
+ Dt(() => {
2476
+ if (it !== "ready" || !qt.current || !It) return;
2477
+ const c = qt.current, h = new IntersectionObserver(
2477
2478
  (l) => {
2478
2479
  if ($t.current) return;
2479
2480
  let p = null;
2480
2481
  for (const k of l) {
2481
2482
  if (!k.isIntersecting) continue;
2482
- const I = Number.parseInt(
2483
+ const $ = Number.parseInt(
2483
2484
  k.target.dataset.pageNumber || "0",
2484
2485
  10
2485
2486
  );
2486
- I && (!p || k.intersectionRatio > p.ratio) && (p = { page: I, ratio: k.intersectionRatio });
2487
+ $ && (!p || k.intersectionRatio > p.ratio) && (p = { page: $, ratio: k.intersectionRatio });
2487
2488
  }
2488
- p && Gt(p.page);
2489
+ p && ne(p.page);
2489
2490
  },
2490
2491
  {
2491
2492
  root: c,
@@ -2493,56 +2494,56 @@ function oo({
2493
2494
  }
2494
2495
  );
2495
2496
  for (let l = 1; l <= It; l += 1) {
2496
- const p = O.current.get(l);
2497
+ const p = G.current.get(l);
2497
2498
  p && h.observe(p);
2498
2499
  }
2499
2500
  return () => h.disconnect();
2500
- }, [lt, It]);
2501
- const qe = ft > 1, Ye = It ? ft < It : !1, hi = K(() => {
2502
- qe && ge(ft - 1);
2503
- }, [qe, ft, ge]), ui = K(() => {
2504
- Ye && ge(ft + 1);
2505
- }, [Ye, ft, ge]), fi = K(() => {
2506
- X((c) => (c + 90) % 360);
2507
- }, []), pi = K(() => {
2508
- f((c) => Math.max(0.25, Math.round((c - 0.1) * 100) / 100));
2509
- }, []), gi = K(() => {
2510
- f((c) => Math.min(5, Math.round((c + 0.1) * 100) / 100));
2511
- }, []), Ke = K(async () => {
2512
- if (!(!rt || !Yt.current))
2501
+ }, [it, It]);
2502
+ const Je = ht > 1, tn = It ? ht < It : !1, hi = Y(() => {
2503
+ Je && xe(ht - 1);
2504
+ }, [Je, ht, xe]), ui = Y(() => {
2505
+ tn && xe(ht + 1);
2506
+ }, [tn, ht, xe]), fi = Y(() => {
2507
+ L((c) => (c + 90) % 360);
2508
+ }, []), pi = Y(() => {
2509
+ oe((c) => Math.max(0.25, Math.round((c - 0.1) * 100) / 100));
2510
+ }, []), gi = Y(() => {
2511
+ oe((c) => Math.min(5, Math.round((c + 0.1) * 100) / 100));
2512
+ }, []), en = Y(async () => {
2513
+ if (!(!st || !qt.current))
2513
2514
  try {
2514
- const h = (await rt.getPage(ft)).getViewport({ scale: 1, rotation: C }), p = window.matchMedia("(max-width: 720px)").matches ? 16 : 24, I = Math.max(
2515
+ const h = (await st.getPage(ht)).getViewport({ scale: 1, rotation: f }), p = window.matchMedia("(max-width: 720px)").matches ? 16 : 24, $ = Math.max(
2515
2516
  0,
2516
- Yt.current.clientWidth - p
2517
+ qt.current.clientWidth - p
2517
2518
  ) / h.width;
2518
- f(Math.max(0.25, Math.min(5, Math.round(I * 100) / 100)));
2519
+ oe(Math.max(0.25, Math.min(5, Math.round($ * 100) / 100)));
2519
2520
  } catch {
2520
2521
  }
2521
- }, [rt, ft, C]);
2522
- Pt(() => {
2523
- if (lt !== "ready" || !rt || !window.matchMedia("(max-width: 720px)").matches) return;
2522
+ }, [st, ht, f]);
2523
+ Dt(() => {
2524
+ if (it !== "ready" || !st || !window.matchMedia("(max-width: 720px)").matches) return;
2524
2525
  let c = !1;
2525
2526
  const h = () => {
2526
- c || Ke();
2527
+ c || en();
2527
2528
  };
2528
2529
  h();
2529
- const l = Yt.current, p = typeof ResizeObserver < "u" && l ? new ResizeObserver(() => h()) : null;
2530
+ const l = qt.current, p = typeof ResizeObserver < "u" && l ? new ResizeObserver(() => h()) : null;
2530
2531
  p == null || p.observe(l);
2531
- const k = window.matchMedia("(max-width: 720px)"), I = () => {
2532
+ const k = window.matchMedia("(max-width: 720px)"), $ = () => {
2532
2533
  k.matches && h();
2533
2534
  };
2534
- return k.addEventListener("change", I), () => {
2535
- c = !0, p == null || p.disconnect(), k.removeEventListener("change", I);
2535
+ return k.addEventListener("change", $), () => {
2536
+ c = !0, p == null || p.disconnect(), k.removeEventListener("change", $);
2536
2537
  };
2537
- }, [lt, rt, Xt, C, Ke]);
2538
- const mn = be(() => U.flatMap((c) => {
2538
+ }, [it, st, Lt, f, en]);
2539
+ const bn = Pe(() => B.flatMap((c) => {
2539
2540
  const h = c.type ?? "sign";
2540
2541
  if (h !== "date" && h !== "text") return [];
2541
- const l = (Wt[c.id] ?? c.value ?? "").trim();
2542
+ const l = (Xt[c.id] ?? c.value ?? "").trim();
2542
2543
  if (!l) return [];
2543
2544
  const p = Math.max(
2544
2545
  10,
2545
- Math.min(he, c.height * 0.55)
2546
+ Math.min(we, c.height * 0.55)
2546
2547
  );
2547
2548
  return [
2548
2549
  {
@@ -2555,23 +2556,23 @@ function oo({
2555
2556
  height: Math.max(p * 1.2, c.height - 4),
2556
2557
  value: l,
2557
2558
  fontSize: p,
2558
- color: de
2559
+ color: me
2559
2560
  }
2560
2561
  ];
2561
- }), [U, Wt]), we = be(
2562
- () => [...W, ...mn],
2563
- [W, mn]
2564
- ), mi = K(async () => {
2562
+ }), [B, Xt]), ke = Pe(
2563
+ () => [...Z, ...bn],
2564
+ [Z, bn]
2565
+ ), mi = Y(async () => {
2565
2566
  var c;
2566
- if (!(!rt || lt !== "ready")) {
2567
+ if (!(!st || it !== "ready")) {
2567
2568
  a(!0);
2568
2569
  try {
2569
- const h = await Pn(rt, {
2570
+ const h = await Cn(st, {
2570
2571
  scale: 1.5,
2571
- rotation: C,
2572
+ rotation: f,
2572
2573
  annotations: P,
2573
2574
  signatures: N,
2574
- texts: we,
2575
+ texts: ke,
2575
2576
  mimeType: "image/png"
2576
2577
  }), l = document.createElement("iframe");
2577
2578
  l.style.position = "fixed", l.style.right = "0", l.style.bottom = "0", l.style.width = "0", l.style.height = "0", l.style.border = "0", l.setAttribute("aria-hidden", "true"), document.body.appendChild(l);
@@ -2593,24 +2594,24 @@ function oo({
2593
2594
  <body></body>
2594
2595
  </html>`), p.close();
2595
2596
  const k = p.body;
2596
- for (const I of h) {
2597
- const B = p.createElement("img");
2598
- B.src = I.dataUrl;
2599
- const st = p.createElement("div");
2600
- st.className = "page", st.appendChild(B), k.appendChild(st);
2597
+ for (const $ of h) {
2598
+ const z = p.createElement("img");
2599
+ z.src = $.dataUrl;
2600
+ const ot = p.createElement("div");
2601
+ ot.className = "page", ot.appendChild(z), k.appendChild(ot);
2601
2602
  }
2602
2603
  await Promise.all(
2603
2604
  Array.from(k.querySelectorAll("img")).map(
2604
- (I) => {
2605
- var B;
2606
- return ((B = I.decode) == null ? void 0 : B.call(I).catch(() => {
2605
+ ($) => {
2606
+ var z;
2607
+ return ((z = $.decode) == null ? void 0 : z.call($).catch(() => {
2607
2608
  })) ?? Promise.resolve();
2608
2609
  }
2609
2610
  )
2610
2611
  ), setTimeout(() => {
2611
- var I, B;
2612
+ var $, z;
2612
2613
  try {
2613
- (I = l.contentWindow) == null || I.focus(), (B = l.contentWindow) == null || B.print();
2614
+ ($ = l.contentWindow) == null || $.focus(), (z = l.contentWindow) == null || z.print();
2614
2615
  } finally {
2615
2616
  setTimeout(() => {
2616
2617
  try {
@@ -2622,124 +2623,124 @@ function oo({
2622
2623
  }, 50);
2623
2624
  } catch {
2624
2625
  try {
2625
- Q ? window.open(Q, "_blank", "noopener,noreferrer") : mt && window.open(mt, "_blank", "noopener,noreferrer");
2626
+ U ? window.open(U, "_blank", "noopener,noreferrer") : bt && window.open(bt, "_blank", "noopener,noreferrer");
2626
2627
  } catch {
2627
2628
  }
2628
2629
  } finally {
2629
2630
  a(!1);
2630
2631
  }
2631
2632
  }
2632
- }, [rt, lt, C, o, Q, mt, P, N, we]), wi = K(async () => {
2633
- if (!rt || lt !== "ready") return;
2633
+ }, [st, it, f, o, U, bt, P, N, ke]), wi = Y(async () => {
2634
+ if (!st || it !== "ready") return;
2634
2635
  const c = `${o.replace(/[^\w.-]+/g, "_") || "document"}.pdf`;
2635
- if (!(P.length > 0 || N.length > 0 || we.length > 0) && Q) {
2636
- sn(
2637
- await fetch(Q).then((l) => l.blob()),
2636
+ if (!(P.length > 0 || N.length > 0 || ke.length > 0) && U) {
2637
+ hn(
2638
+ await fetch(U).then((l) => l.blob()),
2638
2639
  c
2639
2640
  );
2640
2641
  return;
2641
2642
  }
2642
2643
  v(!0);
2643
2644
  try {
2644
- const l = await Pn(rt, {
2645
+ const l = await Cn(st, {
2645
2646
  scale: 2,
2646
- rotation: C,
2647
+ rotation: f,
2647
2648
  annotations: P,
2648
2649
  signatures: N,
2649
- texts: we,
2650
+ texts: ke,
2650
2651
  mimeType: "image/jpeg",
2651
2652
  quality: 0.92
2652
2653
  }), p = Pr(l), k = new Uint8Array(p.byteLength);
2653
- k.set(p), sn(
2654
+ k.set(p), hn(
2654
2655
  new Blob([k], { type: "application/pdf" }),
2655
2656
  c
2656
2657
  );
2657
2658
  } catch {
2658
- Q && sn(
2659
- await fetch(Q).then((l) => l.blob()),
2659
+ U && hn(
2660
+ await fetch(U).then((l) => l.blob()),
2660
2661
  c
2661
2662
  );
2662
2663
  } finally {
2663
2664
  v(!1);
2664
2665
  }
2665
- }, [rt, lt, C, o, Q, P, N, we]), yi = K((c) => {
2666
- R((h) => h === c ? "none" : c);
2667
- }, []), bi = x === "highlight" || x === "underline" ? An(x === "highlight" ? ln : x === "underline" ? dn : null, x) : void 0, ye = Ot != null ? N.find((c) => c.id === Ot) ?? null : null, _i = K((c) => {
2668
- A((h) => [...h, c]);
2669
- }, []), vi = K((c) => {
2670
- A((h) => h.filter((l) => l.id !== c));
2671
- }, []), xi = K(() => {
2672
- A([]), E([]), D([]), ht(null), fe(null), Me(null), Ee(null);
2673
- }, []), Ue = K(
2666
+ }, [st, it, f, o, U, P, N, ke]), yi = Y((c) => {
2667
+ D((h) => h === c ? "none" : c);
2668
+ }, []), bi = M === "highlight" || M === "underline" ? Un(M === "highlight" ? _e : M === "underline" ? ae : null, M) : void 0, Ne = St != null ? N.find((c) => c.id === St) ?? null : null, _i = Y((c) => {
2669
+ F((h) => [...h, c]);
2670
+ }, []), vi = Y((c) => {
2671
+ F((h) => h.filter((l) => l.id !== c));
2672
+ }, []), xi = Y(() => {
2673
+ F([]), j([]), R([]), Pt(null), se(null), de(null), he(null);
2674
+ }, []), Be = Y(
2674
2675
  (c, h) => {
2675
- const l = U.findIndex(
2676
+ const l = B.findIndex(
2676
2677
  (k) => k.id === c
2677
- ), p = U.slice(l + 1).find((k) => !h.has(k.id)) ?? U.slice(0, Math.max(0, l)).find((k) => !h.has(k.id));
2678
+ ), p = B.slice(l + 1).find((k) => !h.has(k.id)) ?? B.slice(0, Math.max(0, l)).find((k) => !h.has(k.id));
2678
2679
  if (!p) {
2679
- G(!1), ee(null);
2680
+ X(!1), Gt(null);
2680
2681
  return;
2681
2682
  }
2682
- te(p.id), ht(null), ee(null), _t(p.type ?? "sign"), me(p), window.setTimeout(() => {
2683
- G(!0);
2683
+ Ut(p.id), Pt(null), Gt(null), ft(p.type ?? "sign"), Me(p), window.setTimeout(() => {
2684
+ X(!0);
2684
2685
  }, 350);
2685
2686
  },
2686
- [me, U]
2687
- ), Mi = K(
2687
+ [Me, B]
2688
+ ), Mi = Y(
2688
2689
  (c) => {
2689
- _t(c), G(!0);
2690
+ ft(c), X(!0);
2690
2691
  },
2691
2692
  []
2692
- ), ki = K((c, h) => {
2693
- We((l) => ({ ...l, [c]: h }));
2694
- }, []), Ni = K(
2693
+ ), ki = Y((c, h) => {
2694
+ Ye((l) => ({ ...l, [c]: h }));
2695
+ }, []), Ni = Y(
2695
2696
  (c) => {
2696
- const h = Wt[c];
2697
- h && (q == null || q(c, h));
2698
- const l = U.findIndex((I) => I.id === c), p = new Set(
2699
- Object.keys(Wt).filter((I) => {
2700
- var B;
2701
- return (B = Wt[I]) == null ? void 0 : B.trim();
2697
+ const h = Xt[c];
2698
+ h && (tt == null || tt(c, h));
2699
+ const l = B.findIndex(($) => $.id === c), p = new Set(
2700
+ Object.keys(Xt).filter(($) => {
2701
+ var z;
2702
+ return (z = Xt[$]) == null ? void 0 : z.trim();
2702
2703
  })
2703
2704
  );
2704
2705
  p.add(c);
2705
- const k = U.slice(l + 1).find(
2706
- (I) => !p.has(I.id) && !N.some((B) => B.fieldId === I.id)
2707
- ) ?? U.slice(0, Math.max(0, l)).find(
2708
- (I) => !p.has(I.id) && !N.some((B) => B.fieldId === I.id)
2706
+ const k = B.slice(l + 1).find(
2707
+ ($) => !p.has($.id) && !N.some((z) => z.fieldId === $.id)
2708
+ ) ?? B.slice(0, Math.max(0, l)).find(
2709
+ ($) => !p.has($.id) && !N.some((z) => z.fieldId === $.id)
2709
2710
  );
2710
- k && (te(k.id), me(k));
2711
+ k && (Ut(k.id), Me(k));
2711
2712
  },
2712
- [U, Wt, N, me, q]
2713
- ), Pi = K(
2713
+ [B, Xt, N, Me, tt]
2714
+ ), Pi = Y(
2714
2715
  (c, h, l) => {
2715
- var ce;
2716
+ var pe;
2716
2717
  const p = Xi(h, l);
2717
- if (ue) {
2718
- E(
2719
- (et) => et.map(
2720
- (kt) => kt.id === ue ? {
2721
- ...kt,
2718
+ if (Yt) {
2719
+ j(
2720
+ (Q) => Q.map(
2721
+ (Ct) => Ct.id === Yt ? {
2722
+ ...Ct,
2722
2723
  imageDataUrl: c,
2723
- width: kt.fieldId ? kt.width : p.width,
2724
- height: kt.fieldId ? kt.height : p.height
2725
- } : kt
2724
+ width: Ct.fieldId ? Ct.width : p.width,
2725
+ height: Ct.fieldId ? Ct.height : p.height
2726
+ } : Ct
2726
2727
  )
2727
- ), At(null), R("none"), G(!1), ee(null);
2728
+ ), At(null), D("none"), X(!1), Gt(null);
2728
2729
  return;
2729
2730
  }
2730
- if (Et) {
2731
- const et = U.find(
2732
- (V) => V.id === pt && (V.type ?? "sign") === "sign" && !N.some((re) => re.fieldId === V.id)
2733
- ) ?? U.find(
2734
- (V) => (V.type ?? "sign") === "sign" && !N.some((re) => re.fieldId === V.id)
2731
+ if (jt) {
2732
+ const Q = B.find(
2733
+ (V) => V.id === _t && (V.type ?? "sign") === "sign" && !N.some((ce) => ce.fieldId === V.id)
2734
+ ) ?? B.find(
2735
+ (V) => (V.type ?? "sign") === "sign" && !N.some((ce) => ce.fieldId === V.id)
2735
2736
  );
2736
- if (!et) {
2737
- G(!1);
2737
+ if (!Q) {
2738
+ X(!1);
2738
2739
  return;
2739
2740
  }
2740
- const kt = vt && et.signature_tag ? U.filter(
2741
- (V) => (V.type ?? "sign") === "sign" && V.signature_tag === et.signature_tag && !N.some((re) => re.fieldId === V.id)
2742
- ) : [et], Nt = kt.map((V) => ({
2741
+ const Ct = gt && Q.signature_tag ? B.filter(
2742
+ (V) => (V.type ?? "sign") === "sign" && V.signature_tag === Q.signature_tag && !N.some((ce) => ce.fieldId === V.id)
2743
+ ) : [Q], Tt = Ct.map((V) => ({
2743
2744
  id: Se(),
2744
2745
  fieldId: V.id,
2745
2746
  pageNumber: V.pageNumber,
@@ -2748,200 +2749,200 @@ function oo({
2748
2749
  width: V.width,
2749
2750
  height: V.height,
2750
2751
  imageDataUrl: c
2751
- })), ne = new Set(kt.map((V) => V.id));
2752
- E((V) => [
2753
- ...V.filter((re) => !re.fieldId || !ne.has(re.fieldId)),
2754
- ...Nt
2752
+ })), re = new Set(Ct.map((V) => V.id));
2753
+ j((V) => [
2754
+ ...V.filter((ce) => !ce.fieldId || !re.has(ce.fieldId)),
2755
+ ...Tt
2755
2756
  ]);
2756
- const le = new Map(
2757
- Nt.map((V) => [V.fieldId, V])
2757
+ const ge = new Map(
2758
+ Tt.map((V) => [V.fieldId, V])
2758
2759
  );
2759
- Pe(
2760
- kt.map((V) => V.id),
2761
- Nt[0],
2762
- le
2763
- ), At(null), R("none"), ht(((ce = Nt[0]) == null ? void 0 : ce.id) ?? null);
2764
- const yt = new Set(
2765
- U.filter(
2766
- (V) => Ne(
2760
+ Le(
2761
+ Ct.map((V) => V.id),
2762
+ Tt[0],
2763
+ ge
2764
+ ), At(null), D("none"), Pt(((pe = Tt[0]) == null ? void 0 : pe.id) ?? null);
2765
+ const wt = new Set(
2766
+ B.filter(
2767
+ (V) => De(
2767
2768
  V,
2768
- [...N, ...Nt],
2769
- Wt
2769
+ [...N, ...Tt],
2770
+ Xt
2770
2771
  )
2771
2772
  ).map((V) => V.id)
2772
2773
  );
2773
- for (const V of ne) yt.add(V);
2774
- Ue(et.id, yt);
2774
+ for (const V of re) wt.add(V);
2775
+ Be(Q.id, wt);
2775
2776
  return;
2776
2777
  }
2777
- const k = O.current.get(ft), I = k == null ? void 0 : k.querySelector(
2778
+ const k = G.current.get(ht), $ = k == null ? void 0 : k.querySelector(
2778
2779
  ".epochs-pdf-viewer__surface"
2779
2780
  );
2780
- let B = 24, st = 24;
2781
- if (I) {
2782
- const et = xe(I, Ft), kt = I.closest(".epochs-pdf-viewer__body");
2783
- if (kt) {
2784
- const Nt = Mn(
2785
- kt.getBoundingClientRect(),
2786
- I,
2787
- Ft
2788
- ), ne = Math.max(0, Nt.top), le = Math.min(et.height, Nt.bottom), yt = Math.max(0, Nt.left), V = Math.min(et.width, Nt.right);
2789
- B = Math.max(0, (yt + V) / 2 - p.width / 2), st = Math.max(0, (ne + le) / 2 - p.height / 2), B = Math.min(B, Math.max(0, et.width - p.width)), st = Math.min(st, Math.max(0, et.height - p.height));
2781
+ let z = 24, ot = 24;
2782
+ if ($) {
2783
+ const Q = Ce($, Nt), Ct = $.closest(".epochs-pdf-viewer__body");
2784
+ if (Ct) {
2785
+ const Tt = Pn(
2786
+ Ct.getBoundingClientRect(),
2787
+ $,
2788
+ Nt
2789
+ ), re = Math.max(0, Tt.top), ge = Math.min(Q.height, Tt.bottom), wt = Math.max(0, Tt.left), V = Math.min(Q.width, Tt.right);
2790
+ z = Math.max(0, (wt + V) / 2 - p.width / 2), ot = Math.max(0, (re + ge) / 2 - p.height / 2), z = Math.min(z, Math.max(0, Q.width - p.width)), ot = Math.min(ot, Math.max(0, Q.height - p.height));
2790
2791
  } else
2791
- B = Math.max(0, (et.width - p.width) / 2), st = Math.max(0, (et.height - p.height) / 2);
2792
+ z = Math.max(0, (Q.width - p.width) / 2), ot = Math.max(0, (Q.height - p.height) / 2);
2792
2793
  }
2793
- const jt = {
2794
+ const Ot = {
2794
2795
  id: Se(),
2795
- pageNumber: ft,
2796
- x: B,
2797
- y: st,
2796
+ pageNumber: ht,
2797
+ x: z,
2798
+ y: ot,
2798
2799
  width: p.width,
2799
2800
  height: p.height,
2800
2801
  imageDataUrl: c
2801
2802
  };
2802
- E((et) => [...et, jt]), Pe(void 0, jt), ht(jt.id), At(null), R("none"), G(!1), ee(null);
2803
+ j((Q) => [...Q, Ot]), Le(void 0, Ot), Pt(Ot.id), At(null), D("none"), X(!1), Gt(null);
2803
2804
  },
2804
2805
  [
2805
- Ue,
2806
- vt,
2807
- ue,
2808
- Wt,
2809
- Et,
2810
- Ne,
2811
- ft,
2812
- Ft,
2813
- pt,
2814
- U,
2806
+ Be,
2807
+ gt,
2808
+ Yt,
2809
+ Xt,
2810
+ jt,
2811
+ De,
2812
+ ht,
2813
+ Nt,
2814
+ _t,
2815
+ B,
2815
2816
  N,
2816
- Pe
2817
+ Le
2817
2818
  ]
2818
- ), $i = K(
2819
+ ), $i = Y(
2819
2820
  (c, h) => {
2820
- if (Et) {
2821
- const et = U.find(
2822
- (yt) => yt.id === pt && (yt.type ?? "sign") === h
2823
- ) ?? U.find((yt) => (yt.type ?? "sign") === h);
2824
- if (!et) {
2825
- G(!1);
2821
+ if (jt) {
2822
+ const Q = B.find(
2823
+ (wt) => wt.id === _t && (wt.type ?? "sign") === h
2824
+ ) ?? B.find((wt) => (wt.type ?? "sign") === h);
2825
+ if (!Q) {
2826
+ X(!1);
2826
2827
  return;
2827
2828
  }
2828
- const Nt = (vt && et.signature_tag ? U.filter(
2829
- (yt) => (yt.type ?? "sign") === h && yt.signature_tag === et.signature_tag
2830
- ) : [et]).map((yt) => yt.id);
2831
- hn(Nt, c);
2832
- const ne = { ...Wt };
2833
- for (const yt of Nt) ne[yt] = c;
2834
- const le = new Set(
2835
- U.filter(
2836
- (yt) => Ne(yt, N, ne)
2837
- ).map((yt) => yt.id)
2829
+ const Tt = (gt && Q.signature_tag ? B.filter(
2830
+ (wt) => (wt.type ?? "sign") === h && wt.signature_tag === Q.signature_tag
2831
+ ) : [Q]).map((wt) => wt.id);
2832
+ pn(Tt, c);
2833
+ const re = { ...Xt };
2834
+ for (const wt of Tt) re[wt] = c;
2835
+ const ge = new Set(
2836
+ B.filter(
2837
+ (wt) => De(wt, N, re)
2838
+ ).map((wt) => wt.id)
2838
2839
  );
2839
- Ue(et.id, le);
2840
+ Be(Q.id, ge);
2840
2841
  return;
2841
2842
  }
2842
- const l = he, p = Math.max(80, c.length * l * 0.55), k = l * 1.25;
2843
- let I = 24, B = 24;
2844
- const st = O.current.get(ft), jt = st == null ? void 0 : st.querySelector(
2843
+ const l = we, p = Math.max(80, c.length * l * 0.55), k = l * 1.25;
2844
+ let $ = 24, z = 24;
2845
+ const ot = G.current.get(ht), Ot = ot == null ? void 0 : ot.querySelector(
2845
2846
  ".epochs-pdf-viewer__surface"
2846
2847
  );
2847
- if (jt) {
2848
- const et = xe(jt, Ft), kt = jt.closest(
2848
+ if (Ot) {
2849
+ const Q = Ce(Ot, Nt), Ct = Ot.closest(
2849
2850
  ".epochs-pdf-viewer__body"
2850
2851
  );
2851
- if (kt) {
2852
- const Nt = Mn(
2853
- kt.getBoundingClientRect(),
2854
- jt,
2855
- Ft
2856
- ), ne = Math.max(0, Nt.top), le = Math.min(et.height, Nt.bottom), yt = Math.max(0, Nt.left), V = Math.min(et.width, Nt.right);
2857
- I = Math.max(0, (yt + V) / 2 - p / 2), B = Math.max(0, (ne + le) / 2 - k / 2), I = Math.min(I, Math.max(0, et.width - p)), B = Math.min(B, Math.max(0, et.height - k));
2852
+ if (Ct) {
2853
+ const Tt = Pn(
2854
+ Ct.getBoundingClientRect(),
2855
+ Ot,
2856
+ Nt
2857
+ ), re = Math.max(0, Tt.top), ge = Math.min(Q.height, Tt.bottom), wt = Math.max(0, Tt.left), V = Math.min(Q.width, Tt.right);
2858
+ $ = Math.max(0, (wt + V) / 2 - p / 2), z = Math.max(0, (re + ge) / 2 - k / 2), $ = Math.min($, Math.max(0, Q.width - p)), z = Math.min(z, Math.max(0, Q.height - k));
2858
2859
  }
2859
2860
  }
2860
- const ce = {
2861
- id: Be(),
2862
- pageNumber: ft,
2863
- x: I,
2864
- y: B,
2861
+ const pe = {
2862
+ id: Ge(),
2863
+ pageNumber: ht,
2864
+ x: $,
2865
+ y: z,
2865
2866
  width: p,
2866
2867
  height: k,
2867
2868
  value: c,
2868
2869
  fontSize: l,
2869
- color: de
2870
+ color: me
2870
2871
  };
2871
- D((et) => [...et, ce]), fe(ce.id), G(!1), R("none");
2872
+ R((Q) => [...Q, pe]), se(pe.id), X(!1), D("none");
2872
2873
  },
2873
2874
  [
2874
- Ue,
2875
- vt,
2876
- Wt,
2877
- Et,
2878
- Ne,
2879
- ft,
2880
- Ft,
2881
- pt,
2882
- U,
2875
+ Be,
2876
+ gt,
2877
+ Xt,
2878
+ jt,
2879
+ De,
2880
+ ht,
2881
+ Nt,
2882
+ _t,
2883
+ B,
2883
2884
  N,
2884
- hn
2885
+ pn
2885
2886
  ]
2886
- ), Ii = K((c) => {
2887
- E((h) => [...h, c]), Pe(void 0, c), ht(c.id), At(null), R("none");
2888
- }, [Pe]), Ci = K(
2887
+ ), Ii = Y((c) => {
2888
+ j((h) => [...h, c]), Le(void 0, c), Pt(c.id), At(null), D("none");
2889
+ }, [Le]), Ci = Y(
2889
2890
  (c, h) => {
2890
- E(
2891
+ j(
2891
2892
  (l) => l.map((p) => p.id === c ? { ...p, ...h } : p)
2892
2893
  );
2893
2894
  },
2894
2895
  []
2895
- ), Ti = K((c) => {
2896
+ ), Ti = Y((c) => {
2896
2897
  const h = N.find((l) => l.id === c);
2897
- E((l) => l.filter((p) => p.id !== c)), ht((l) => l === c ? null : l), h != null && h.fieldId && te(h.fieldId);
2898
- }, [N]), Di = K((c) => {
2899
- const h = c ? N.find((jt) => jt.id === c) ?? null : ye;
2898
+ j((l) => l.filter((p) => p.id !== c)), Pt((l) => l === c ? null : l), h != null && h.fieldId && Ut(h.fieldId);
2899
+ }, [N]), Di = Y((c) => {
2900
+ const h = c ? N.find((Ot) => Ot.id === c) ?? null : Ne;
2900
2901
  if (!h) return;
2901
- const l = O.current.get(h.pageNumber), p = l == null ? void 0 : l.querySelector(
2902
+ const l = G.current.get(h.pageNumber), p = l == null ? void 0 : l.querySelector(
2902
2903
  ".epochs-pdf-viewer__surface"
2903
2904
  ), k = 18;
2904
- let I = h.x + k, B = h.y + k;
2905
+ let $ = h.x + k, z = h.y + k;
2905
2906
  if (p) {
2906
- const jt = p.clientWidth / Ft, ce = p.clientHeight / Ft;
2907
- I = Math.min(
2908
- Math.max(0, I),
2909
- Math.max(0, jt - h.width)
2910
- ), B = Math.min(
2911
- Math.max(0, B),
2912
- Math.max(0, ce - h.height)
2907
+ const Ot = p.clientWidth / Nt, pe = p.clientHeight / Nt;
2908
+ $ = Math.min(
2909
+ Math.max(0, $),
2910
+ Math.max(0, Ot - h.width)
2911
+ ), z = Math.min(
2912
+ Math.max(0, z),
2913
+ Math.max(0, pe - h.height)
2913
2914
  );
2914
2915
  }
2915
- const st = {
2916
+ const ot = {
2916
2917
  ...h,
2917
2918
  id: Se(),
2918
- x: I,
2919
- y: B
2919
+ x: $,
2920
+ y: z
2920
2921
  };
2921
- E((jt) => [...jt, st]), ht(st.id), At(null), R("none");
2922
- }, [Ft, ye, N]), Li = K((c) => {
2923
- const h = c ?? (ye == null ? void 0 : ye.id);
2922
+ j((Ot) => [...Ot, ot]), Pt(ot.id), At(null), D("none");
2923
+ }, [Nt, Ne, N]), Li = Y((c) => {
2924
+ const h = c ?? (Ne == null ? void 0 : Ne.id);
2924
2925
  if (!h) return;
2925
- const l = N.find((k) => k.id === h), p = l != null && l.fieldId ? U.find((k) => k.id === l.fieldId) : void 0;
2926
- _t((p == null ? void 0 : p.type) ?? "sign"), ht(h), ee(h), G(!0);
2927
- }, [ye, N, U]), Fi = K((c) => {
2928
- D((h) => c.fieldId ? [...h.filter((l) => l.fieldId !== c.fieldId), c] : [...h, c]), fe(c.id), c.fieldId && Me(c.fieldId);
2929
- }, []), Ri = K(
2926
+ const l = N.find((k) => k.id === h), p = l != null && l.fieldId ? B.find((k) => k.id === l.fieldId) : void 0;
2927
+ ft((p == null ? void 0 : p.type) ?? "sign"), Pt(h), Gt(h), X(!0);
2928
+ }, [Ne, N, B]), Fi = Y((c) => {
2929
+ R((h) => c.fieldId ? [...h.filter((l) => l.fieldId !== c.fieldId), c] : [...h, c]), se(c.id), c.fieldId && de(c.fieldId);
2930
+ }, []), Ri = Y(
2930
2931
  (c, h) => {
2931
- D(
2932
+ R(
2932
2933
  (l) => l.map((p) => p.id === c ? { ...p, ...h } : p)
2933
2934
  );
2934
2935
  },
2935
2936
  []
2936
- ), Ai = K((c) => {
2937
- const h = W.find((l) => l.id === c);
2938
- D((l) => l.filter((p) => p.id !== c)), fe((l) => l === c ? null : l), Ee((l) => l === c ? null : l), h != null && h.fieldId && Me(h.fieldId);
2939
- }, [W]);
2940
- Pt(() => {
2941
- ke && D(
2937
+ ), Ai = Y((c) => {
2938
+ const h = Z.find((l) => l.id === c);
2939
+ R((l) => l.filter((p) => p.id !== c)), se((l) => l === c ? null : l), he((l) => l === c ? null : l), h != null && h.fieldId && de(h.fieldId);
2940
+ }, [Z]);
2941
+ Dt(() => {
2942
+ Te && R(
2942
2943
  (c) => c.map((h) => {
2943
2944
  if (!h.fieldId) return h;
2944
- const l = z.find((p) => p.id === h.fieldId);
2945
+ const l = E.find((p) => p.id === h.fieldId);
2945
2946
  return l ? {
2946
2947
  ...h,
2947
2948
  pageNumber: l.pageNumber,
@@ -2949,32 +2950,32 @@ function oo({
2949
2950
  y: l.y,
2950
2951
  width: l.width,
2951
2952
  height: l.height,
2952
- fontSize: l.fontSize ?? h.fontSize ?? he,
2953
- color: l.color ?? h.color ?? de
2953
+ fontSize: l.fontSize ?? h.fontSize ?? we,
2954
+ color: l.color ?? h.color ?? me
2954
2955
  } : h;
2955
2956
  })
2956
2957
  );
2957
- }, [ke, z]);
2958
- const wn = K(
2958
+ }, [Te, E]);
2959
+ const _n = Y(
2959
2960
  (c) => {
2960
2961
  var k;
2961
- if (!U.length) return;
2962
- const h = pt != null ? U.findIndex((I) => I.id === pt) : -1, l = Math.min(
2963
- U.length - 1,
2962
+ if (!B.length) return;
2963
+ const h = _t != null ? B.findIndex(($) => $.id === _t) : -1, l = Math.min(
2964
+ B.length - 1,
2964
2965
  Math.max(0, (h < 0 ? 0 : h) + c)
2965
- ), p = U[l];
2966
- p && (te(p.id), ht(
2967
- ((k = N.find((I) => I.fieldId === p.id)) == null ? void 0 : k.id) ?? null
2968
- ), me(p));
2966
+ ), p = B[l];
2967
+ p && (Ut(p.id), Pt(
2968
+ ((k = N.find(($) => $.fieldId === p.id)) == null ? void 0 : k.id) ?? null
2969
+ ), Me(p));
2969
2970
  },
2970
2971
  [
2971
- me,
2972
- pt,
2973
- U,
2972
+ Me,
2973
+ _t,
2974
+ B,
2974
2975
  N
2975
2976
  ]
2976
2977
  );
2977
- if (!Lt && !mt)
2978
+ if (!yt && !bt)
2978
2979
  return /* @__PURE__ */ s(
2979
2980
  "div",
2980
2981
  {
@@ -2985,106 +2986,113 @@ function oo({
2985
2986
  );
2986
2987
  const Ei = {
2987
2988
  height: r
2988
- }, yn = {
2989
- status: lt,
2990
- showThumbnails: Xt,
2991
- setShowThumbnails: Vt,
2992
- canGoPrev: qe,
2993
- canGoNext: Ye,
2989
+ }, vn = {
2990
+ status: it,
2991
+ showThumbnails: Lt,
2992
+ setShowThumbnails: Zt,
2993
+ canGoPrev: Je,
2994
+ canGoNext: tn,
2994
2995
  handlePrev: hi,
2995
2996
  handleNext: ui,
2996
- pageNumber: ft,
2997
+ pageNumber: ht,
2997
2998
  numPages: It,
2998
- scrollToPage: ge,
2999
- scale: Ft,
2999
+ scrollToPage: xe,
3000
+ scale: Nt,
3000
3001
  handleZoomOut: pi,
3001
3002
  handleZoomIn: gi,
3002
- handleFitWidth: Ke,
3003
+ handleFitWidth: en,
3003
3004
  handleRotate: fi,
3004
- markupTool: x,
3005
+ markupTool: M,
3005
3006
  toggleMarkupTool: (c) => yi(c),
3006
- hasFixedSignatureFields: Et,
3007
- hasFixedTextFields: ke,
3008
- pendingSignature: qt,
3009
- setMarkupTool: R,
3010
- setSignaturePadOpen: G,
3007
+ hasFixedSignatureFields: jt,
3008
+ hasFixedTextFields: Te,
3009
+ pendingSignature: Ht,
3010
+ setMarkupTool: D,
3011
+ setSignaturePadOpen: X,
3011
3012
  annotationsLength: P.length,
3012
3013
  signaturesLength: N.length,
3013
- textsLength: W.length,
3014
+ textsLength: Z.length,
3014
3015
  handleClearAnnotations: xi,
3015
- highlightHex: ln,
3016
- underlineHex: dn,
3017
- setHighlightHex: li,
3016
+ highlightHex: _e,
3017
+ underlineHex: ae,
3018
+ setHighlightHex: Qt,
3018
3019
  setUnderlineHex: di,
3019
- loadDocument: Ve,
3020
+ loadDocument: Qe,
3020
3021
  handlePrint: mi,
3021
3022
  isPrinting: ie,
3022
- pdfDoc: rt,
3023
- displayUrl: Q,
3024
- resolvedUrl: mt,
3023
+ pdfDoc: st,
3024
+ displayUrl: U,
3025
+ resolvedUrl: bt,
3025
3026
  handleDownload: wi,
3026
3027
  isDownloading: w
3027
- }, Ui = (c) => c.filter((h) => !(Et && (h === "highlight" || h === "underline" || h === "erase"))), Ze = pt ? U.findIndex((c) => c.id === pt) : 0, Hi = U.filter(
3028
- (c) => Ne(c, N, Wt)
3029
- ).length, Qe = U.length > 0 ? Math.round(Hi / U.length * 100) : 0, bn = (c, h = !1) => {
3030
- const l = Ui(c);
3028
+ }, Hi = (c) => c.filter((h) => !(jt && (h === "highlight" || h === "underline" || h === "erase"))), nn = _t ? B.findIndex((c) => c.id === _t) : 0, Ui = B.filter(
3029
+ (c) => De(c, N, Xt)
3030
+ ).length, rn = B.length > 0 ? Math.round(Ui / B.length * 100) : 0, xn = (c, h = !1) => {
3031
+ const l = Hi(c);
3031
3032
  if (l.length === 0 && !h)
3032
3033
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__toolbar-group" });
3033
3034
  if (l.length === 0)
3034
3035
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__toolbar-group epochs-pdf-viewer__toolbar-group--end" });
3035
- const p = l.map((k, I) => {
3036
- const B = l[I - 1], st = Dn(k) && (!B || !Dn(B));
3037
- return /* @__PURE__ */ s(Si, { children: Fr(k, yn, { showMarkupSep: st }) }, k);
3036
+ const p = l.map((k, $) => {
3037
+ const z = l[$ - 1], ot = Rn(k) && (!z || !Rn(z));
3038
+ return /* @__PURE__ */ s(Wi, { children: Fr(k, vn, { showMarkupSep: ot }) }, k);
3038
3039
  });
3039
- return /* @__PURE__ */ L(
3040
+ return /* @__PURE__ */ T(
3040
3041
  "div",
3041
3042
  {
3042
3043
  className: h ? "epochs-pdf-viewer__toolbar-group epochs-pdf-viewer__toolbar-group--end" : "epochs-pdf-viewer__toolbar-group",
3043
3044
  children: [
3044
3045
  p,
3045
- Rr(yn, new Set(l))
3046
+ Rr(vn, new Set(l))
3046
3047
  ]
3047
3048
  }
3048
3049
  );
3049
3050
  };
3050
- return /* @__PURE__ */ L(
3051
+ return /* @__PURE__ */ T(
3051
3052
  "div",
3052
3053
  {
3053
3054
  "data-testid": "pdf-viewer",
3054
- "data-file-url": mt || void 0,
3055
+ "data-file-url": bt || void 0,
3055
3056
  className: `epochs-pdf-viewer ${_ ?? ""}`.trim(),
3056
3057
  style: Ei,
3057
3058
  children: [
3058
- se ? /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__toolbar", children: [
3059
- bn(se.left),
3060
- bn(se.right, !0)
3059
+ ue ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__toolbar", children: [
3060
+ xn(ue.left),
3061
+ xn(ue.right, !0)
3061
3062
  ] }) : null,
3062
- Xe || Zt || Et ? /* @__PURE__ */ s(
3063
+ Ze || kt || jt ? /* @__PURE__ */ s(
3063
3064
  Cr,
3064
3065
  {
3065
- open: ot,
3066
+ open: lt,
3066
3067
  onClose: () => {
3067
- G(!1), ee(null), _t(void 0), ut == null || ut();
3068
+ X(!1), Gt(null), ft(void 0), dt == null || dt();
3068
3069
  },
3069
3070
  onSave: Pi,
3070
3071
  onSaveFieldValue: $i,
3071
- fieldType: dt,
3072
- showFieldTypeTabs: !Et,
3073
- textPlaceholder: (_n = U.find((c) => c.id === pt)) == null ? void 0 : _n.placeholder,
3074
- initialFieldValue: pt ? Wt[pt] ?? ((vn = U.find((c) => c.id === pt)) == null ? void 0 : vn.value) : void 0,
3075
- rememberedByType: Rt,
3072
+ fieldType: et,
3073
+ showFieldTypeTabs: !jt,
3074
+ textPlaceholder: (Mn = B.find((c) => c.id === _t)) == null ? void 0 : Mn.placeholder,
3075
+ initialFieldValue: _t ? Xt[_t] ?? ((kn = B.find((c) => c.id === _t)) == null ? void 0 : kn.value) : void 0,
3076
+ targetSize: (() => {
3077
+ const c = B.find(
3078
+ (h) => h.id === _t
3079
+ );
3080
+ if (!(!c || (c.type ?? "sign") !== "sign"))
3081
+ return { width: c.width, height: c.height };
3082
+ })(),
3083
+ rememberedByType: Ft,
3076
3084
  onRememberFill: (c, h) => {
3077
- zt((l) => c === "sign" ? { ...l, sign: h } : c === "date" ? { ...l, date: h } : { ...l, text: h });
3085
+ Rt((l) => c === "sign" ? { ...l, sign: h } : c === "date" ? { ...l, date: h } : { ...l, text: h });
3078
3086
  }
3079
3087
  }
3080
3088
  ) : null,
3081
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__content", children: [
3082
- Xt ? /* @__PURE__ */ s(
3089
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__content", children: [
3090
+ Lt ? /* @__PURE__ */ s(
3083
3091
  "div",
3084
3092
  {
3085
3093
  className: "epochs-pdf-viewer__thumbnails",
3086
3094
  style: { width: m + 24 },
3087
- children: lt === "ready" && rt ? /* @__PURE__ */ L(Fe, { children: [
3095
+ children: it === "ready" && st ? /* @__PURE__ */ T(je, { children: [
3088
3096
  Array.from({
3089
3097
  length: Math.min(It || 0, g)
3090
3098
  }).map((c, h) => {
@@ -3092,21 +3100,21 @@ function oo({
3092
3100
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-wrap", children: /* @__PURE__ */ s(
3093
3101
  br,
3094
3102
  {
3095
- pdfDoc: rt,
3103
+ pdfDoc: st,
3096
3104
  pageNumber: l,
3097
- isActive: l === ft,
3098
- rotation: C,
3099
- onSelect: ge,
3105
+ isActive: l === ht,
3106
+ rotation: f,
3107
+ onSelect: xe,
3100
3108
  width: m,
3101
3109
  annotations: P,
3102
3110
  signatures: N,
3103
- signatureFields: U,
3104
- texts: we,
3105
- textFields: z
3111
+ signatureFields: B,
3112
+ texts: ke,
3113
+ textFields: E
3106
3114
  }
3107
3115
  ) }, l);
3108
3116
  }),
3109
- It > g ? /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__thumb-more", children: [
3117
+ It > g ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__thumb-more", children: [
3110
3118
  "Showing first ",
3111
3119
  g,
3112
3120
  " pages"
@@ -3114,69 +3122,69 @@ function oo({
3114
3122
  ] }) : /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__muted", children: "Thumbnails" })
3115
3123
  }
3116
3124
  ) : null,
3117
- /* @__PURE__ */ L("div", { ref: Yt, className: "epochs-pdf-viewer__body", children: [
3118
- lt === "loading" ? /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__muted", children: [
3125
+ /* @__PURE__ */ T("div", { ref: qt, className: "epochs-pdf-viewer__body", children: [
3126
+ it === "loading" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__muted", children: [
3119
3127
  "Loading PDF…",
3120
3128
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__spinner" })
3121
3129
  ] }) : null,
3122
- lt === "error" ? /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__error", children: [
3130
+ it === "error" ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__overlay epochs-pdf-viewer__error", children: [
3123
3131
  "Unable to load PDF.",
3124
- mt ? /* @__PURE__ */ s(
3132
+ bt ? /* @__PURE__ */ s(
3125
3133
  "a",
3126
3134
  {
3127
3135
  className: "epochs-pdf-viewer__open-link",
3128
- href: mt,
3136
+ href: bt,
3129
3137
  target: "_blank",
3130
3138
  rel: "noopener noreferrer",
3131
3139
  children: "Open file"
3132
3140
  }
3133
3141
  ) : null
3134
3142
  ] }) : null,
3135
- lt === "ready" && rt ? /* @__PURE__ */ s("div", { children: Array.from({ length: It }).map((c, h) => {
3143
+ it === "ready" && st ? /* @__PURE__ */ s("div", { children: Array.from({ length: It }).map((c, h) => {
3136
3144
  const l = h + 1;
3137
3145
  return /* @__PURE__ */ s(
3138
3146
  yr,
3139
3147
  {
3140
- pdfDoc: rt,
3148
+ pdfDoc: st,
3141
3149
  pageNumber: l,
3142
- scale: Ft,
3143
- rotation: C,
3144
- markupTool: ct ? x : "none",
3150
+ scale: Nt,
3151
+ rotation: f,
3152
+ markupTool: at ? M : "none",
3145
3153
  markupColor: bi,
3146
3154
  annotations: P,
3147
3155
  onAddAnnotation: _i,
3148
3156
  onRemoveAnnotation: vi,
3149
3157
  signatures: N,
3150
- pendingSignature: qt,
3158
+ pendingSignature: Ht,
3151
3159
  onAddSignature: Ii,
3152
3160
  onUpdateSignature: Ci,
3153
3161
  onRemoveSignature: Ti,
3154
3162
  onEditSignature: Li,
3155
3163
  onDuplicateSignature: Di,
3156
- selectedSignatureId: Ot,
3157
- onSelectSignature: ht,
3158
- signatureFields: U,
3159
- selectedSignatureFieldId: pt,
3160
- onSelectSignatureField: te,
3161
- hasFixedSignatureFields: Et,
3164
+ selectedSignatureId: St,
3165
+ onSelectSignature: Pt,
3166
+ signatureFields: B,
3167
+ selectedSignatureFieldId: _t,
3168
+ onSelectSignatureField: Ut,
3169
+ hasFixedSignatureFields: jt,
3162
3170
  onOpenSignaturePad: Mi,
3163
- fieldValues: Wt,
3171
+ fieldValues: Xt,
3164
3172
  onFieldValueChange: ki,
3165
3173
  onFieldValueCommit: Ni,
3166
- texts: W,
3174
+ texts: Z,
3167
3175
  onAddText: Fi,
3168
3176
  onUpdateText: Ri,
3169
3177
  onRemoveText: Ai,
3170
- selectedTextId: Ae,
3171
- onSelectText: fe,
3172
- textFields: z,
3173
- selectedTextFieldId: ai,
3174
- onSelectTextField: Me,
3175
- hasFixedTextFields: ke,
3176
- editingTextId: ci,
3177
- onEditingTextIdChange: Ee,
3178
+ selectedTextId: be,
3179
+ onSelectText: se,
3180
+ textFields: E,
3181
+ selectedTextFieldId: Ve,
3182
+ onSelectTextField: de,
3183
+ hasFixedTextFields: Te,
3184
+ editingTextId: qe,
3185
+ onEditingTextIdChange: he,
3178
3186
  pageRef: (p) => {
3179
- p && O.current.set(l, p);
3187
+ p && G.current.set(l, p);
3180
3188
  }
3181
3189
  },
3182
3190
  l
@@ -3184,16 +3192,16 @@ function oo({
3184
3192
  }) }) : null
3185
3193
  ] })
3186
3194
  ] }),
3187
- Et || Qt ? /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__footer", role: "navigation", "aria-label": "Viewer actions", children: [
3188
- Et ? /* @__PURE__ */ L(Fe, { children: [
3189
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__footer-nav", children: [
3195
+ jt || te ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer", role: "navigation", "aria-label": "Viewer actions", children: [
3196
+ jt ? /* @__PURE__ */ T(je, { children: [
3197
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-nav", children: [
3190
3198
  /* @__PURE__ */ s(
3191
3199
  "button",
3192
3200
  {
3193
3201
  type: "button",
3194
3202
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
3195
- disabled: U.length <= 1 || Ze <= 0,
3196
- onClick: () => wn(-1),
3203
+ disabled: B.length <= 1 || nn <= 0,
3204
+ onClick: () => _n(-1),
3197
3205
  children: "Prev"
3198
3206
  }
3199
3207
  ),
@@ -3202,18 +3210,18 @@ function oo({
3202
3210
  {
3203
3211
  type: "button",
3204
3212
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
3205
- disabled: U.length <= 1 || Ze >= U.length - 1,
3206
- onClick: () => wn(1),
3213
+ disabled: B.length <= 1 || nn >= B.length - 1,
3214
+ onClick: () => _n(1),
3207
3215
  children: "Next"
3208
3216
  }
3209
3217
  )
3210
3218
  ] }),
3211
- /* @__PURE__ */ L("div", { className: "epochs-pdf-viewer__footer-center", children: [
3212
- /* @__PURE__ */ L("span", { className: "epochs-pdf-viewer__footer-label", children: [
3219
+ /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-center", children: [
3220
+ /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__footer-label", children: [
3213
3221
  "Field ",
3214
- Math.max(1, Ze + 1),
3222
+ Math.max(1, nn + 1),
3215
3223
  " of ",
3216
- U.length
3224
+ B.length
3217
3225
  ] }),
3218
3226
  /* @__PURE__ */ s(
3219
3227
  "div",
@@ -3222,40 +3230,40 @@ function oo({
3222
3230
  role: "progressbar",
3223
3231
  "aria-valuemin": 0,
3224
3232
  "aria-valuemax": 100,
3225
- "aria-valuenow": Qe,
3233
+ "aria-valuenow": rn,
3226
3234
  "aria-label": "Signature progress",
3227
3235
  children: /* @__PURE__ */ s(
3228
3236
  "div",
3229
3237
  {
3230
3238
  className: "epochs-pdf-viewer__footer-progress-bar",
3231
- style: { width: `${Qe}%` }
3239
+ style: { width: `${rn}%` }
3232
3240
  }
3233
3241
  )
3234
3242
  }
3235
3243
  ),
3236
- /* @__PURE__ */ L("span", { className: "epochs-pdf-viewer__footer-percent", children: [
3237
- Qe,
3244
+ /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__footer-percent", children: [
3245
+ rn,
3238
3246
  "%"
3239
3247
  ] })
3240
3248
  ] })
3241
3249
  ] }) : /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__footer-center" }),
3242
- Qt ? /* @__PURE__ */ L(
3250
+ te ? /* @__PURE__ */ T(
3243
3251
  "button",
3244
3252
  {
3245
3253
  type: "button",
3246
3254
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--primary",
3247
- onClick: Qt,
3248
- disabled: Bt,
3249
- "aria-busy": Bt || void 0,
3255
+ onClick: te,
3256
+ disabled: Vt,
3257
+ "aria-busy": Vt || void 0,
3250
3258
  children: [
3251
- Bt ? /* @__PURE__ */ s(
3259
+ Vt ? /* @__PURE__ */ s(
3252
3260
  "span",
3253
3261
  {
3254
3262
  className: "epochs-pdf-viewer__spinner epochs-pdf-viewer__spinner--btn",
3255
3263
  "aria-hidden": "true"
3256
3264
  }
3257
3265
  ) : null,
3258
- Re
3266
+ ye
3259
3267
  ]
3260
3268
  }
3261
3269
  ) : null
@@ -3268,27 +3276,27 @@ function Er(t) {
3268
3276
  return null;
3269
3277
  }
3270
3278
  Er.displayName = "Document";
3271
- function Ur(t) {
3272
- return null;
3273
- }
3274
- Ur.displayName = "Page";
3275
3279
  function Hr(t) {
3276
3280
  return null;
3277
3281
  }
3278
- Hr.displayName = "View";
3279
- function zr(t) {
3282
+ Hr.displayName = "Page";
3283
+ function Ur(t) {
3280
3284
  return null;
3281
3285
  }
3282
- zr.displayName = "Text";
3286
+ Ur.displayName = "View";
3283
3287
  function jr(t) {
3284
3288
  return null;
3285
3289
  }
3286
- jr.displayName = "Image";
3287
- function Sr(t) {
3290
+ jr.displayName = "Text";
3291
+ function Br(t) {
3288
3292
  return null;
3289
3293
  }
3290
- Sr.displayName = "Link";
3291
- const Br = {
3294
+ Br.displayName = "Image";
3295
+ function Wr(t) {
3296
+ return null;
3297
+ }
3298
+ Wr.displayName = "Link";
3299
+ const Or = {
3292
3300
  Document: "DOCUMENT",
3293
3301
  Page: "PAGE",
3294
3302
  View: "VIEW",
@@ -3296,7 +3304,7 @@ const Br = {
3296
3304
  Image: "IMAGE",
3297
3305
  Link: "LINK"
3298
3306
  };
3299
- function Or(t) {
3307
+ function zr(t) {
3300
3308
  if (typeof t == "string") return t;
3301
3309
  if (typeof t == "function") {
3302
3310
  const e = t;
@@ -3304,7 +3312,7 @@ function Or(t) {
3304
3312
  }
3305
3313
  return null;
3306
3314
  }
3307
- function ti(t) {
3315
+ function ii(t) {
3308
3316
  const e = [], n = (i) => {
3309
3317
  if (!(i == null || typeof i == "boolean")) {
3310
3318
  if (Array.isArray(i)) {
@@ -3316,11 +3324,11 @@ function ti(t) {
3316
3324
  };
3317
3325
  return n(t), e;
3318
3326
  }
3319
- function ei(t) {
3320
- return ti(t).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : e && typeof e == "object" && "props" in e ? ei(e.props.children) : "").join("");
3327
+ function ri(t) {
3328
+ return ii(t).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : e && typeof e == "object" && "props" in e ? ri(e.props.children) : "").join("");
3321
3329
  }
3322
- function ni(t) {
3323
- const e = Or(t.type), n = e ? Br[e] : void 0;
3330
+ function oi(t) {
3331
+ const e = zr(t.type), n = e ? Or[e] : void 0;
3324
3332
  if (!n)
3325
3333
  throw new Error(
3326
3334
  `[epochs-pdf] Unsupported element "${e ?? "unknown"}". Use Document, Page, View, Text, Image, or Link.`
@@ -3331,27 +3339,27 @@ function ni(t) {
3331
3339
  type: n,
3332
3340
  props: i,
3333
3341
  children: [],
3334
- text: ei(r)
3342
+ text: ri(r)
3335
3343
  };
3336
- const o = ti(r).filter(
3344
+ const o = ii(r).filter(
3337
3345
  (d) => !!d && typeof d == "object" && "type" in d
3338
- ).map(ni);
3346
+ ).map(oi);
3339
3347
  return {
3340
3348
  type: n,
3341
3349
  props: i,
3342
3350
  children: o
3343
3351
  };
3344
3352
  }
3345
- const Wr = {
3353
+ const Sr = {
3346
3354
  A4: [595.28, 841.89],
3347
3355
  LETTER: [612, 792],
3348
3356
  LEGAL: [612, 1008]
3349
3357
  };
3350
3358
  function Gr(t = "A4", e = "portrait") {
3351
- const [n, i] = Array.isArray(t) ? t : Wr[t];
3359
+ const [n, i] = Array.isArray(t) ? t : Sr[t];
3352
3360
  return e === "landscape" ? [i, n] : [n, i];
3353
3361
  }
3354
- function ii(t = {}) {
3362
+ function si(t = {}) {
3355
3363
  const e = t.padding ?? 0;
3356
3364
  return {
3357
3365
  top: t.paddingTop ?? e,
@@ -3360,7 +3368,7 @@ function ii(t = {}) {
3360
3368
  left: t.paddingLeft ?? e
3361
3369
  };
3362
3370
  }
3363
- function Ce(t = {}) {
3371
+ function Ae(t = {}) {
3364
3372
  const e = t.margin ?? 0;
3365
3373
  return {
3366
3374
  top: t.marginTop ?? e,
@@ -3369,7 +3377,7 @@ function Ce(t = {}) {
3369
3377
  left: t.marginLeft ?? e
3370
3378
  };
3371
3379
  }
3372
- function je(t) {
3380
+ function ze(t) {
3373
3381
  if (!t) return null;
3374
3382
  const e = t.trim();
3375
3383
  if (e.startsWith("#")) {
@@ -3392,7 +3400,7 @@ function je(t) {
3392
3400
  Math.min(1, Number(n[3]) / 255)
3393
3401
  ] : null;
3394
3402
  }
3395
- function _e(t, e, n = 0) {
3403
+ function $e(t, e, n = 0) {
3396
3404
  if (t == null) return n;
3397
3405
  if (typeof t == "number") return t;
3398
3406
  if (t.endsWith("%")) {
@@ -3402,19 +3410,19 @@ function _e(t, e, n = 0) {
3402
3410
  const i = Number.parseFloat(t);
3403
3411
  return Number.isFinite(i) ? i : n;
3404
3412
  }
3405
- function an(t) {
3413
+ function un(t) {
3406
3414
  return t === "bold" ? !0 : typeof t == "number" ? t >= 600 : !1;
3407
3415
  }
3408
3416
  const Xr = 12, Vr = 1.4, qr = 0.5;
3409
- function ri(t, e, n) {
3410
- const i = e.fontSize ?? Xr, r = (e.lineHeight ?? Vr) * i, o = i * (an(e.fontWeight) ? 0.55 : qr);
3417
+ function ai(t, e, n) {
3418
+ const i = e.fontSize ?? Xr, r = (e.lineHeight ?? Vr) * i, o = i * (un(e.fontWeight) ? 0.55 : qr);
3411
3419
  if (!t)
3412
3420
  return { width: 0, height: r, lines: [""] };
3413
3421
  const d = t.split(/\s+/), u = [];
3414
3422
  let m = "";
3415
3423
  for (const _ of d) {
3416
- const b = m ? `${m} ${_}` : _;
3417
- b.length * o <= n || !m ? m = b : (u.push(m), m = _);
3424
+ const y = m ? `${m} ${_}` : _;
3425
+ y.length * o <= n || !m ? m = y : (u.push(m), m = _);
3418
3426
  }
3419
3427
  m && u.push(m);
3420
3428
  const g = Math.max(...u.map((_) => _.length * o), 0);
@@ -3424,18 +3432,18 @@ function ri(t, e, n) {
3424
3432
  lines: u
3425
3433
  };
3426
3434
  }
3427
- function oi(t, e, n, i, r) {
3428
- const o = t.props.style ?? {}, d = Ce(o), u = ii(o), m = e + d.left, g = n + d.top, _ = Math.max(
3435
+ function ci(t, e, n, i, r) {
3436
+ const o = t.props.style ?? {}, d = Ae(o), u = si(o), m = e + d.left, g = n + d.top, _ = Math.max(
3429
3437
  0,
3430
- _e(o.width, i, i) - d.left - d.right
3431
- ), b = Math.max(0, _ - u.left - u.right);
3438
+ $e(o.width, i, i) - d.left - d.right
3439
+ ), y = Math.max(0, _ - u.left - u.right);
3432
3440
  if (t.type === "TEXT" || t.type === "LINK") {
3433
- const z = ri(t.text ?? "", o, b), nt = _e(o.height, r, z.height + u.top + u.bottom);
3441
+ const E = ai(t.text ?? "", o, y), ct = $e(o.height, r, E.height + u.top + u.bottom);
3434
3442
  return {
3435
3443
  x: m,
3436
3444
  y: g,
3437
3445
  width: _,
3438
- height: nt,
3446
+ height: ct,
3439
3447
  node: t,
3440
3448
  children: [],
3441
3449
  style: o,
@@ -3443,40 +3451,40 @@ function oi(t, e, n, i, r) {
3443
3451
  };
3444
3452
  }
3445
3453
  if (t.type === "IMAGE") {
3446
- const z = _e(o.width, i, Math.min(200, i)), nt = _e(o.height, r, 120);
3454
+ const E = $e(o.width, i, Math.min(200, i)), ct = $e(o.height, r, 120);
3447
3455
  return {
3448
3456
  x: m,
3449
3457
  y: g,
3450
- width: z - d.left - d.right,
3451
- height: nt,
3458
+ width: E - d.left - d.right,
3459
+ height: ct,
3452
3460
  node: t,
3453
3461
  children: [],
3454
3462
  style: o
3455
3463
  };
3456
3464
  }
3457
- const y = o.flexDirection ?? "column", M = o.gap ?? 0, $ = [];
3458
- let S = m + u.left, H = g + u.top, F = 0, J = 0;
3459
- for (let z = 0; z < t.children.length; z++) {
3460
- const nt = t.children[z], it = y === "row" ? Math.max(0, b - F - (z > 0 ? M : 0)) : b, vt = y === "column" ? Math.max(0, r - (H - n) - d.bottom) : r, q = oi(nt, S, H, it, vt);
3461
- $.push(q), y === "row" ? (F += q.width + Ce(nt.props.style ?? {}).left + Ce(nt.props.style ?? {}).right, z < t.children.length - 1 && (F += M), S = m + u.left + F, J = Math.max(J, q.height)) : (F += q.height + Ce(nt.props.style ?? {}).top + Ce(nt.props.style ?? {}).bottom, z < t.children.length - 1 && (F += M), H = g + u.top + F, J = Math.max(J, q.width));
3465
+ const b = o.flexDirection ?? "column", x = o.gap ?? 0, I = [];
3466
+ let S = m + u.left, H = g + u.top, W = 0, A = 0;
3467
+ for (let E = 0; E < t.children.length; E++) {
3468
+ const ct = t.children[E], ut = b === "row" ? Math.max(0, y - W - (E > 0 ? x : 0)) : y, gt = b === "column" ? Math.max(0, r - (H - n) - d.bottom) : r, tt = ci(ct, S, H, ut, gt);
3469
+ I.push(tt), b === "row" ? (W += tt.width + Ae(ct.props.style ?? {}).left + Ae(ct.props.style ?? {}).right, E < t.children.length - 1 && (W += x), S = m + u.left + W, A = Math.max(A, tt.height)) : (W += tt.height + Ae(ct.props.style ?? {}).top + Ae(ct.props.style ?? {}).bottom, E < t.children.length - 1 && (W += x), H = g + u.top + W, A = Math.max(A, tt.width));
3462
3470
  }
3463
- const T = _e(
3471
+ const C = $e(
3464
3472
  o.height,
3465
3473
  r,
3466
- y === "column" ? F + u.top + u.bottom : J + u.top + u.bottom
3467
- ), at = y === "row" ? _e(o.width, i, F + u.left + u.right) : _, ct = o.justifyContent ?? "flex-start", Z = o.alignItems ?? "stretch", tt = y === "column" ? T - u.top - u.bottom : at - u.left - u.right, Mt = Math.max(0, tt - F);
3468
- let Y = 0, Tt = M;
3469
- ct === "center" && (Y = Mt / 2), ct === "flex-end" && (Y = Mt), ct === "space-between" && $.length > 1 && (Tt = M + Mt / ($.length - 1)), ct === "space-around" && $.length > 0 && (Tt = M + Mt / $.length, Y = Tt / 2);
3470
- let gt = 0;
3471
- for (const z of $)
3472
- y === "column" ? (z.y = g + u.top + Y + gt, Z === "center" ? z.x = m + u.left + Math.max(0, (b - z.width) / 2) : Z === "flex-end" ? z.x = m + u.left + Math.max(0, b - z.width) : Z === "stretch" && z.style.width == null && (z.width = b), gt += z.height + Tt) : (z.x = m + u.left + Y + gt, Z === "center" ? z.y = g + u.top + Math.max(0, (T - u.top - u.bottom - z.height) / 2) : Z === "flex-end" ? z.y = g + u.top + Math.max(0, T - u.top - u.bottom - z.height) : Z === "stretch" && z.style.height == null && (z.height = T - u.top - u.bottom), gt += z.width + Tt);
3474
+ b === "column" ? W + u.top + u.bottom : A + u.top + u.bottom
3475
+ ), nt = b === "row" ? $e(o.width, i, W + u.left + u.right) : _, at = o.justifyContent ?? "flex-start", q = o.alignItems ?? "stretch", pt = b === "column" ? C - u.top - u.bottom : nt - u.left - u.right, Mt = Math.max(0, pt - W);
3476
+ let K = 0, Et = x;
3477
+ at === "center" && (K = Mt / 2), at === "flex-end" && (K = Mt), at === "space-between" && I.length > 1 && (Et = x + Mt / (I.length - 1)), at === "space-around" && I.length > 0 && (Et = x + Mt / I.length, K = Et / 2);
3478
+ let vt = 0;
3479
+ for (const E of I)
3480
+ b === "column" ? (E.y = g + u.top + K + vt, q === "center" ? E.x = m + u.left + Math.max(0, (y - E.width) / 2) : q === "flex-end" ? E.x = m + u.left + Math.max(0, y - E.width) : q === "stretch" && E.style.width == null && (E.width = y), vt += E.height + Et) : (E.x = m + u.left + K + vt, q === "center" ? E.y = g + u.top + Math.max(0, (C - u.top - u.bottom - E.height) / 2) : q === "flex-end" ? E.y = g + u.top + Math.max(0, C - u.top - u.bottom - E.height) : q === "stretch" && E.style.height == null && (E.height = C - u.top - u.bottom), vt += E.width + Et);
3473
3481
  return {
3474
3482
  x: m,
3475
3483
  y: g,
3476
- width: at,
3477
- height: T,
3484
+ width: nt,
3485
+ height: C,
3478
3486
  node: t,
3479
- children: $,
3487
+ children: I,
3480
3488
  style: o
3481
3489
  };
3482
3490
  }
@@ -3487,7 +3495,7 @@ function Yr(t) {
3487
3495
  for (const n of t.children) {
3488
3496
  if (n.type !== "PAGE")
3489
3497
  throw new Error("[epochs-pdf] Direct children of <Document> must be <Page>.");
3490
- const i = n.props.size, r = n.props.orientation ?? "portrait", [o, d] = Gr(i, r), u = n.props.style ?? {}, m = ii(u), g = {
3498
+ const i = n.props.size, r = n.props.orientation ?? "portrait", [o, d] = Gr(i, r), u = n.props.style ?? {}, m = si(u), g = {
3491
3499
  type: "VIEW",
3492
3500
  props: {
3493
3501
  style: {
@@ -3501,7 +3509,7 @@ function Yr(t) {
3501
3509
  }
3502
3510
  },
3503
3511
  children: n.children
3504
- }, _ = oi(g, 0, 0, o, d);
3512
+ }, _ = ci(g, 0, 0, o, d);
3505
3513
  e.push({
3506
3514
  width: o,
3507
3515
  height: d,
@@ -3519,44 +3527,44 @@ function Yr(t) {
3519
3527
  pages: e
3520
3528
  };
3521
3529
  }
3522
- function Te(t) {
3530
+ function Ee(t) {
3523
3531
  return t.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
3524
3532
  }
3525
3533
  class Kr {
3526
3534
  constructor() {
3527
- Je(this, "objects", [null]);
3528
- Je(this, "offsets", [0]);
3535
+ on(this, "objects", [null]);
3536
+ on(this, "offsets", [0]);
3529
3537
  }
3530
3538
  addObject(e) {
3531
3539
  return this.objects.push(e), this.objects.length - 1;
3532
3540
  }
3533
3541
  build(e) {
3534
3542
  const n = this.addObject(
3535
- `<< /Title (${Te(e.meta.title)}) /Author (${Te(e.meta.author)}) /Subject (${Te(e.meta.subject)}) /Creator (${Te(e.meta.creator)}) /Producer (epochs-pdf) >>`
3543
+ `<< /Title (${Ee(e.meta.title)}) /Author (${Ee(e.meta.author)}) /Subject (${Ee(e.meta.subject)}) /Creator (${Ee(e.meta.creator)}) /Producer (epochs-pdf) >>`
3536
3544
  ), i = this.addObject(
3537
3545
  "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"
3538
3546
  ), r = this.addObject(
3539
3547
  "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"
3540
3548
  ), o = [];
3541
- for (const b of e.pages) {
3542
- const y = this.renderPageContent(
3543
- b.boxes,
3544
- b.width,
3545
- b.height,
3546
- b.style
3547
- ), M = this.addObject(
3548
- `<< /Length ${y.length} >>
3549
+ for (const y of e.pages) {
3550
+ const b = this.renderPageContent(
3551
+ y.boxes,
3552
+ y.width,
3553
+ y.height,
3554
+ y.style
3555
+ ), x = this.addObject(
3556
+ `<< /Length ${b.length} >>
3549
3557
  stream
3550
- ${y}
3558
+ ${b}
3551
3559
  endstream`
3552
- ), $ = this.addObject("");
3553
- o.push($), this.objects[$] = `<< /Type /Page /Parent 0 0 R /MediaBox [0 0 ${b.width.toFixed(2)} ${b.height.toFixed(2)}] /Contents ${M} 0 R /Resources << /Font << /F1 ${i} 0 R /F2 ${r} 0 R >> >> >>`;
3560
+ ), I = this.addObject("");
3561
+ o.push(I), this.objects[I] = `<< /Type /Page /Parent 0 0 R /MediaBox [0 0 ${y.width.toFixed(2)} ${y.height.toFixed(2)}] /Contents ${x} 0 R /Resources << /Font << /F1 ${i} 0 R /F2 ${r} 0 R >> >> >>`;
3554
3562
  }
3555
- const d = o.map((b) => `${b} 0 R`).join(" "), u = this.addObject(
3563
+ const d = o.map((y) => `${y} 0 R`).join(" "), u = this.addObject(
3556
3564
  `<< /Type /Pages /Kids [${d}] /Count ${o.length} >>`
3557
3565
  );
3558
- for (const b of o)
3559
- this.objects[b] = this.objects[b].replace(
3566
+ for (const y of o)
3567
+ this.objects[y] = this.objects[y].replace(
3560
3568
  "/Parent 0 0 R",
3561
3569
  `/Parent ${u} 0 R`
3562
3570
  );
@@ -3566,9 +3574,9 @@ endstream`
3566
3574
  let g = `%PDF-1.4
3567
3575
  `;
3568
3576
  this.offsets = [0];
3569
- for (let b = 1; b < this.objects.length; b++)
3570
- this.offsets[b] = g.length, g += `${b} 0 obj
3571
- ${this.objects[b]}
3577
+ for (let y = 1; y < this.objects.length; y++)
3578
+ this.offsets[y] = g.length, g += `${y} 0 obj
3579
+ ${this.objects[y]}
3572
3580
  endobj
3573
3581
  `;
3574
3582
  const _ = g.length;
@@ -3576,8 +3584,8 @@ endobj
3576
3584
  0 ${this.objects.length}
3577
3585
  `, g += `0000000000 65535 f
3578
3586
  `;
3579
- for (let b = 1; b < this.objects.length; b++)
3580
- g += `${String(this.offsets[b]).padStart(10, "0")} 00000 n
3587
+ for (let y = 1; y < this.objects.length; y++)
3588
+ g += `${String(this.offsets[y]).padStart(10, "0")} 00000 n
3581
3589
  `;
3582
3590
  return g += `trailer
3583
3591
  << /Size ${this.objects.length} /Root ${m} 0 R /Info ${n} 0 R >>
@@ -3586,33 +3594,33 @@ ${_}
3586
3594
  %%EOF`, new TextEncoder().encode(g);
3587
3595
  }
3588
3596
  renderPageContent(e, n, i, r) {
3589
- const o = [], d = je(r.backgroundColor);
3597
+ const o = [], d = ze(r.backgroundColor);
3590
3598
  d && (o.push("q"), o.push(
3591
3599
  `${d[0].toFixed(3)} ${d[1].toFixed(3)} ${d[2].toFixed(3)} rg`
3592
3600
  ), o.push(
3593
3601
  `0 0 ${n.toFixed(2)} ${i.toFixed(2)} re f`
3594
3602
  ), o.push("Q"));
3595
3603
  const u = (m) => {
3596
- const { x: g, y: _, width: b, height: y, style: M, node: $, text: S } = m, H = i - _ - y, F = je(M.backgroundColor);
3597
- if (F && (o.push("q"), o.push(`${F[0].toFixed(3)} ${F[1].toFixed(3)} ${F[2].toFixed(3)} rg`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${b.toFixed(2)} ${y.toFixed(2)} re f`), o.push("Q")), M.borderWidth && M.borderWidth > 0) {
3598
- const J = je(M.borderColor) ?? [0, 0, 0];
3599
- o.push("q"), o.push(`${M.borderWidth} w`), o.push(`${J[0].toFixed(3)} ${J[1].toFixed(3)} ${J[2].toFixed(3)} RG`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${b.toFixed(2)} ${y.toFixed(2)} re S`), o.push("Q");
3604
+ const { x: g, y: _, width: y, height: b, style: x, node: I, text: S } = m, H = i - _ - b, W = ze(x.backgroundColor);
3605
+ if (W && (o.push("q"), o.push(`${W[0].toFixed(3)} ${W[1].toFixed(3)} ${W[2].toFixed(3)} rg`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re f`), o.push("Q")), x.borderWidth && x.borderWidth > 0) {
3606
+ const A = ze(x.borderColor) ?? [0, 0, 0];
3607
+ o.push("q"), o.push(`${x.borderWidth} w`), o.push(`${A[0].toFixed(3)} ${A[1].toFixed(3)} ${A[2].toFixed(3)} RG`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re S`), o.push("Q");
3600
3608
  }
3601
- if (($.type === "TEXT" || $.type === "LINK") && S != null) {
3602
- const J = M.fontSize ?? 12, T = je(M.color) ?? [0, 0, 0], at = an(M.fontWeight) ? "F2" : "F1", ct = M.paddingLeft ?? M.padding ?? 0, Z = M.paddingTop ?? M.padding ?? 0, tt = Math.max(0, b - ct - (M.paddingRight ?? M.padding ?? 0)), bt = ri(S, M, tt || b), Mt = (M.lineHeight ?? 1.4) * J;
3603
- o.push("q"), o.push("BT"), o.push(`/${at} ${J} Tf`), o.push(`${T[0].toFixed(3)} ${T[1].toFixed(3)} ${T[2].toFixed(3)} rg`), bt.lines.forEach((Y, Tt) => {
3604
- let gt = g + ct;
3605
- const z = Y.length * J * (an(M.fontWeight) ? 0.55 : 0.5);
3606
- M.textAlign === "center" ? gt = g + (b - z) / 2 : M.textAlign === "right" && (gt = g + b - z - (M.paddingRight ?? M.padding ?? 0));
3607
- const nt = i - _ - Z - J - Tt * Mt;
3608
- o.push(`1 0 0 1 ${gt.toFixed(2)} ${nt.toFixed(2)} Tm`), o.push(`(${Te(Y)}) Tj`);
3609
+ if ((I.type === "TEXT" || I.type === "LINK") && S != null) {
3610
+ const A = x.fontSize ?? 12, C = ze(x.color) ?? [0, 0, 0], nt = un(x.fontWeight) ? "F2" : "F1", at = x.paddingLeft ?? x.padding ?? 0, q = x.paddingTop ?? x.padding ?? 0, pt = Math.max(0, y - at - (x.paddingRight ?? x.padding ?? 0)), J = ai(S, x, pt || y), Mt = (x.lineHeight ?? 1.4) * A;
3611
+ o.push("q"), o.push("BT"), o.push(`/${nt} ${A} Tf`), o.push(`${C[0].toFixed(3)} ${C[1].toFixed(3)} ${C[2].toFixed(3)} rg`), J.lines.forEach((K, Et) => {
3612
+ let vt = g + at;
3613
+ const E = K.length * A * (un(x.fontWeight) ? 0.55 : 0.5);
3614
+ x.textAlign === "center" ? vt = g + (y - E) / 2 : x.textAlign === "right" && (vt = g + y - E - (x.paddingRight ?? x.padding ?? 0));
3615
+ const ct = i - _ - q - A - Et * Mt;
3616
+ o.push(`1 0 0 1 ${vt.toFixed(2)} ${ct.toFixed(2)} Tm`), o.push(`(${Ee(K)}) Tj`);
3609
3617
  }), o.push("ET"), o.push("Q");
3610
3618
  }
3611
- $.type === "IMAGE" && (o.push("q"), o.push("0.85 0.85 0.85 rg"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${b.toFixed(2)} ${y.toFixed(2)} re f`), o.push("0.6 0.6 0.6 RG 1 w"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${b.toFixed(2)} ${y.toFixed(2)} re S`), o.push(
3612
- `BT /F1 10 Tf 0.4 0.4 0.4 rg 1 0 0 1 ${(g + 8).toFixed(2)} ${(H + y / 2 - 4).toFixed(2)} Tm (Image) Tj ET`
3619
+ I.type === "IMAGE" && (o.push("q"), o.push("0.85 0.85 0.85 rg"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re f`), o.push("0.6 0.6 0.6 RG 1 w"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${y.toFixed(2)} ${b.toFixed(2)} re S`), o.push(
3620
+ `BT /F1 10 Tf 0.4 0.4 0.4 rg 1 0 0 1 ${(g + 8).toFixed(2)} ${(H + b / 2 - 4).toFixed(2)} Tm (Image) Tj ET`
3613
3621
  ), o.push("Q"));
3614
- for (const J of m.children)
3615
- u(J);
3622
+ for (const A of m.children)
3623
+ u(A);
3616
3624
  };
3617
3625
  for (const m of e)
3618
3626
  u(m);
@@ -3623,66 +3631,66 @@ ${_}
3623
3631
  function Zr(t) {
3624
3632
  return new Kr().build(t);
3625
3633
  }
3626
- function cn(t) {
3627
- const e = ni(t), n = Yr(e);
3634
+ function fn(t) {
3635
+ const e = oi(t), n = Yr(e);
3628
3636
  return Zr(n);
3629
3637
  }
3630
3638
  function so(t) {
3631
- return cn(t);
3639
+ return fn(t);
3632
3640
  }
3633
- function si(t) {
3634
- const e = cn(t), n = new Uint8Array(e.byteLength);
3641
+ function li(t) {
3642
+ const e = fn(t), n = new Uint8Array(e.byteLength);
3635
3643
  return n.set(e), new Blob([n], { type: "application/pdf" });
3636
3644
  }
3637
3645
  function Qr(t) {
3638
- return URL.createObjectURL(si(t));
3646
+ return URL.createObjectURL(li(t));
3639
3647
  }
3640
3648
  function ao(t, e = "document.pdf") {
3641
3649
  const n = Qr(t), i = document.createElement("a");
3642
3650
  i.href = n, i.download = e, i.click(), URL.revokeObjectURL(n);
3643
3651
  }
3644
3652
  async function co(t) {
3645
- return cn(t);
3653
+ return fn(t);
3646
3654
  }
3647
3655
  async function lo(t) {
3648
- return si(t);
3656
+ return li(t);
3649
3657
  }
3650
3658
  export {
3651
3659
  ro as ALL_TOOLBAR_TOOLS,
3652
- Zn as AddText,
3653
- Jn as Clear,
3654
- Tn as DEFAULT_TOOLBAR_LAYOUT,
3660
+ ti as AddText,
3661
+ ni as Clear,
3662
+ Fn as DEFAULT_TOOLBAR_LAYOUT,
3655
3663
  Er as Document,
3656
- Vn as Download,
3657
- Qn as Erase,
3658
- Ln as HIGHLIGHT_PRESETS,
3659
- qn as Highlight,
3660
- jr as Image,
3661
- Sr as Link,
3664
+ Kn as Download,
3665
+ ei as Erase,
3666
+ An as HIGHLIGHT_PRESETS,
3667
+ Zn as Highlight,
3668
+ Br as Image,
3669
+ Wr as Link,
3662
3670
  Sn as Navigation,
3663
- Xn as Open,
3664
- Wr as PAGE_SIZES,
3665
- Ur as Page,
3671
+ Yn as Open,
3672
+ Sr as PAGE_SIZES,
3673
+ Hr as Page,
3666
3674
  oo as PdfViewer,
3667
- Gn as Print,
3668
- Wn as Reload,
3669
- On as Rotate,
3670
- Kn as Signature,
3671
- zr as Text,
3672
- jn as Thumbnail,
3673
- Fn as UNDERLINE_PRESETS,
3674
- Yn as Underline,
3675
- Hr as View,
3676
- Bn as Zoom,
3675
+ qn as Print,
3676
+ Vn as Reload,
3677
+ Xn as Rotate,
3678
+ Jn as Signature,
3679
+ jr as Text,
3680
+ zn as Thumbnail,
3681
+ En as UNDERLINE_PRESETS,
3682
+ Qn as Underline,
3683
+ Ur as View,
3684
+ Gn as Zoom,
3677
3685
  oo as default,
3678
3686
  ao as download,
3679
- An as hexToMarkupColor,
3687
+ Un as hexToMarkupColor,
3680
3688
  so as pdf,
3681
3689
  lo as renderToBlob,
3682
3690
  co as renderToBuffer,
3683
3691
  Gr as resolvePageSize,
3684
- kn as setPdfWorkerSrc,
3685
- si as toBlob,
3692
+ $n as setPdfWorkerSrc,
3693
+ li as toBlob,
3686
3694
  Qr as toUrl
3687
3695
  };
3688
3696
  //# sourceMappingURL=epochs-pdf.js.map