epochs-pdf 0.1.7 → 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 Hi = Object.defineProperty;
2
- var ji = (t, e, n) => e in t ? Hi(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 z, useEffect as Tt, useMemo as xe, useCallback as K, Fragment as Bi } from "react";
5
- import { jsxs as T, jsx as s, Fragment as Ae } from "react/jsx-runtime";
6
- import * as ke from "pdfjs-dist";
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
7
  import { TextLayer as Oi } from "pdfjs-dist";
8
- const Re = "#ffffff", Dn = [
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 = Dn[0].hex, Wi = 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 ce(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 ce(t) {
33
33
  }
34
34
  return e;
35
35
  }
36
- function An(t, e, n = 0.45) {
37
- const i = ce(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,26 +76,26 @@ 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 || Re, 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);
90
90
  }
91
91
  }
92
92
  }
93
- function Oe() {
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
- const r = await Si(i.imageDataUrl);
98
+ const r = await Gi(i.imageDataUrl);
99
99
  t.drawImage(
100
100
  r,
101
101
  i.x * n,
@@ -105,7 +105,7 @@ async function Un(t, e, n) {
105
105
  );
106
106
  }
107
107
  }
108
- function zi(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;
@@ -113,7 +113,7 @@ function zi(t, e, n, i) {
113
113
  }
114
114
  t.restore();
115
115
  }
116
- function Si(t) {
116
+ function Gi(t) {
117
117
  return new Promise((e, n) => {
118
118
  const i = new Image();
119
119
  i.onload = () => e(i), i.onerror = () => n(new Error("Failed to load signature image")), i.src = t;
@@ -128,28 +128,28 @@ 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 Ne(t, e) {
138
+ function Ce(t, e) {
139
139
  return {
140
140
  width: t.clientWidth / e,
141
141
  height: t.clientHeight / e
142
142
  };
143
143
  }
144
- function Gi(t, e, n, i) {
144
+ function Vi(t, e, n, i) {
145
145
  const r = n.getBoundingClientRect(), o = n.clientWidth || r.width, d = n.clientHeight || r.height;
146
146
  return r.width <= 0 || r.height <= 0 || i <= 0 ? { dx: 0, dy: 0 } : {
147
147
  dx: t / r.width * (o / 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 } = Ne(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,60 +157,60 @@ function Mn(t, e, n) {
157
157
  bottom: (t.bottom - i.top) / i.height * o
158
158
  };
159
159
  }
160
- const ge = 14, pe = "#111827", rn = 24, on = 20;
161
- function We() {
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 Le(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 E;
189
- const o = n.getBoundingClientRect(), d = n.clientWidth || o.width, u = n.clientHeight || o.height, m = (I) => o.width > 0 ? (I - o.left) / o.width * (d / r) : 0, g = (I) => o.height > 0 ? (I - o.top) / o.height * (u / r) : 0, _ = (I, et) => {
190
- const at = et === "x" ? o.width : o.height, Y = et === "x" ? d : u;
191
- return at > 0 ? I / at * (Y / 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 w = m(t), b = g(e), x = ge;
194
- const C = Vi(t, e, i);
195
- if (C)
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(C.x),
198
- y: g(C.y),
199
- fontSize: Math.max(8, Math.round(_(C.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 = (E = S.caretRangeFromPoint) == null ? void 0 : E.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 I = H.getClientRects(), et = I.length > 0 ? I[0] : H.getBoundingClientRect();
204
- if (et.height > 0) {
205
- b = g(et.top), x = Ki(H.startContainer, r, n);
206
- const at = m(et.left);
207
- return Math.abs(at - w) < _(8, "x") && (w = at), { x: w, y: b, fontSize: x };
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 O = Yi(t, e, i);
211
- return O && (b = g(O.top), x = Math.max(8, Math.round(_(O.height, "y") * 10) / 10)), { x: w, y: b, fontSize: x };
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
- function Vi(t, e, n) {
213
+ function Yi(t, e, n) {
214
214
  var o;
215
215
  const i = Array.from(
216
216
  n.querySelectorAll("span")
@@ -240,7 +240,7 @@ function Vi(t, e, n) {
240
240
  }
241
241
  return null;
242
242
  }
243
- function Yi(t, e, n) {
243
+ function Ki(t, e, n) {
244
244
  var o;
245
245
  const i = Array.from(
246
246
  n.querySelectorAll("span")
@@ -255,11 +255,11 @@ function Yi(t, e, n) {
255
255
  }
256
256
  return r ? { top: r.top, height: r.height } : null;
257
257
  }
258
- function Ki(t, e, n) {
258
+ function Zi(t, e, n) {
259
259
  const i = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
260
- return i ? Zi(i, e, n) : ge;
260
+ return i ? Qi(i, e, n) : we;
261
261
  }
262
- function Zi(t, e, n) {
262
+ function Qi(t, e, n) {
263
263
  const i = t.getBoundingClientRect().height;
264
264
  if (i > 0) {
265
265
  if (n) {
@@ -273,15 +273,15 @@ function Zi(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) : ge;
276
+ return Number.isFinite(o) && o > 0 ? Math.max(8, Math.round(o / e * 10) / 10) : we;
277
277
  }
278
- function Qi(t, e, n, i) {
278
+ function Ji(t, e, n, i) {
279
279
  for (const r of n)
280
280
  if (r.pageNumber === i && t >= r.x && t <= r.x + r.width && e >= r.y && e <= r.y + r.height)
281
281
  return r;
282
282
  return null;
283
283
  }
284
- function Ji(t, e, n) {
284
+ function tr(t, e, n) {
285
285
  var x;
286
286
  if (!n) return null;
287
287
  const i = document, r = (x = i.caretRangeFromPoint) == null ? void 0 : x.call(i, t, e);
@@ -291,17 +291,17 @@ function Ji(t, e, n) {
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 = (C) => /[\p{L}\p{N}_'-]/u.test(C);
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 w = document.createRange();
300
- w.setStart(o, g), w.setEnd(o, _);
299
+ const y = document.createRange();
300
+ y.setStart(o, g), y.setEnd(o, _);
301
301
  const b = window.getSelection();
302
- return b == null || b.removeAllRanges(), b == null || b.addRange(w), d.slice(g, _);
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;
@@ -315,7 +315,7 @@ function Hn(t, e, n) {
315
315
  }
316
316
  t.restore();
317
317
  }
318
- function tr(t, e, n, i) {
318
+ function er(t, e, n, i) {
319
319
  t.save();
320
320
  for (const r of e) {
321
321
  const o = n.has(r.id), d = r.x * i, u = r.y * i, m = r.width * i, g = r.height * i;
@@ -346,27 +346,27 @@ function Bt({
346
346
  }
347
347
  );
348
348
  }
349
- function er(t) {
349
+ function nr(t) {
350
350
  return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("polyline", { points: "15 18 9 12 15 6" }) });
351
351
  }
352
- function nr(t) {
352
+ function ir(t) {
353
353
  return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("polyline", { points: "9 18 15 12 9 6" }) });
354
354
  }
355
- function ir(t) {
355
+ function rr(t) {
356
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
- function rr(t) {
362
+ function or(t) {
363
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
- function or(t) {
369
+ function sr(t) {
370
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" }),
@@ -374,55 +374,55 @@ function or(t) {
374
374
  /* @__PURE__ */ s("rect", { x: "3", y: "14", width: "7", height: "7" })
375
375
  ] });
376
376
  }
377
- function sr(t) {
377
+ function ar(t) {
378
378
  return /* @__PURE__ */ s(Bt, { ...t, children: /* @__PURE__ */ s("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
379
379
  }
380
- function ar(t) {
380
+ function cr(t) {
381
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
- function cr(t) {
386
+ function lr(t) {
387
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
- function lr(t) {
393
+ function dr(t) {
394
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
- function dr(t) {
400
+ function hr(t) {
401
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
- function hr(t) {
406
+ function ur(t) {
407
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
- function ur(t) {
412
+ function fr(t) {
413
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
- function fr(t) {
418
+ function pr(t) {
419
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" })
423
423
  ] });
424
424
  }
425
- function pr({ size: t = 16, className: e }) {
425
+ function gr({ size: t = 16, className: e }) {
426
426
  return /* @__PURE__ */ s(
427
427
  "svg",
428
428
  {
@@ -440,20 +440,20 @@ function pr({ size: t = 16, className: e }) {
440
440
  }
441
441
  );
442
442
  }
443
- function gr(t) {
443
+ function mr(t) {
444
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
- function mr(t) {
449
+ function wr(t) {
450
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" })
454
454
  ] });
455
455
  }
456
- function wr({
456
+ function yr({
457
457
  pdfDoc: t,
458
458
  pageNumber: e,
459
459
  scale: n,
@@ -465,148 +465,148 @@ function wr({
465
465
  annotations: m = [],
466
466
  onAddAnnotation: g,
467
467
  onRemoveAnnotation: _,
468
- signatures: w = [],
468
+ signatures: y = [],
469
469
  pendingSignature: b = null,
470
470
  onAddSignature: x,
471
- onUpdateSignature: C,
471
+ onUpdateSignature: I,
472
472
  onRemoveSignature: S,
473
473
  onEditSignature: H,
474
- onDuplicateSignature: O,
475
- selectedSignatureId: E = null,
476
- onSelectSignature: I,
477
- signatureFields: et = [],
474
+ onDuplicateSignature: W,
475
+ selectedSignatureId: A = null,
476
+ onSelectSignature: C,
477
+ signatureFields: nt = [],
478
478
  selectedSignatureFieldId: at = null,
479
- onSelectSignatureField: Y,
479
+ onSelectSignatureField: q,
480
480
  hasFixedSignatureFields: pt = !1,
481
481
  onOpenSignaturePad: J,
482
482
  fieldValues: Mt = {},
483
- onFieldValueChange: Z,
484
- onFieldValueCommit: Lt,
485
- pendingFieldValue: _t = null,
486
- onPlaceFieldValue: U,
483
+ onFieldValueChange: K,
484
+ onFieldValueCommit: Et,
485
+ pendingFieldValue: vt = null,
486
+ onPlaceFieldValue: E,
487
487
  texts: ct = [],
488
- onAddText: ft,
488
+ onAddText: ut,
489
489
  onUpdateText: gt,
490
490
  onRemoveText: tt,
491
491
  selectedTextId: kt = null,
492
- onSelectText: lt,
492
+ onSelectText: dt,
493
493
  textFields: te = [],
494
- selectedTextFieldId: me = null,
495
- onSelectTextField: St,
496
- hasFixedTextFields: Ut = !1,
497
- editingTextId: Dt = null,
498
- onEditingTextIdChange: X
494
+ selectedTextFieldId: ye = null,
495
+ onSelectTextField: Vt,
496
+ hasFixedTextFields: qt = !1,
497
+ editingTextId: Kt = null,
498
+ onEditingTextIdChange: G
499
499
  }) {
500
- const qt = xt(null), Ft = xt(null), wt = xt(null), st = xt(null), Ht = xt(null), nt = xt(null), [yt, Ct] = z(null), ee = xt(null), it = xt(!1);
501
- Tt(() => {
502
- if (!t || !Ft.current || !wt.current || !st.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 y = Ft.current, v = wt.current, M = st.current, D = y.getContext("2d");
505
+ const w = yt.current, v = bt.current, M = it.current, D = w.getContext("2d");
506
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 (nt.current) {
515
+ if (st.current) {
516
516
  try {
517
- nt.current.cancel();
517
+ st.current.cancel();
518
518
  } catch {
519
519
  }
520
- nt.current = null;
520
+ st.current = null;
521
521
  }
522
- const R = await t.getPage(e);
522
+ const F = await t.getPage(e);
523
523
  if (a) return;
524
- const k = R.getViewport({ scale: n, rotation: i }), B = Math.floor(k.width), G = Math.floor(k.height);
525
- y.width = B, y.height = G, M.style.width = `${B}px`, M.style.height = `${G}px`;
526
- const L = R.render({ canvasContext: D, viewport: k });
527
- if (Ht.current = L, await L.promise, a) return;
528
- v.replaceChildren(), v.style.setProperty("--scale-factor", String(k.scale));
529
- const rt = await R.getTextContent();
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
+ v.replaceChildren(), v.style.setProperty("--scale-factor", String(N.scale));
529
+ const lt = await F.getTextContent();
530
530
  if (a) return;
531
- const q = new Oi({
532
- textContentSource: rt,
531
+ const X = new Oi({
532
+ textContentSource: lt,
533
533
  container: v,
534
- viewport: k
534
+ viewport: N
535
535
  });
536
- if (nt.current = q, await q.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 (nt.current) {
548
+ if (st.current) {
549
549
  try {
550
- nt.current.cancel();
550
+ st.current.cancel();
551
551
  } catch {
552
552
  }
553
- nt.current = null;
553
+ st.current = null;
554
554
  }
555
555
  }) : void 0;
556
- }, [t, e, n, i, o]), Tt(() => {
557
- const a = st.current;
556
+ }, [t, e, n, i, o]), Dt(() => {
557
+ const a = it.current;
558
558
  if (!a) return;
559
- const y = (P) => {
560
- var G;
559
+ const w = (P) => {
560
+ var Z;
561
561
  if (!g) return !1;
562
- const R = P === "redact" ? Re : u;
563
- if (!R) return !1;
564
- const k = en(a, n);
565
- if (!k) return !1;
566
- const B = P === "redact" ? nn(k.rects) : k.rects;
562
+ const F = P === "redact" ? He : u;
563
+ if (!F) return !1;
564
+ const N = an(a, n);
565
+ if (!N) return !1;
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: R,
572
- rects: B,
573
- text: k.text
574
- }), (G = window.getSelection()) == null || G.removeAllRanges(), !0;
571
+ color: F,
572
+ rects: j,
573
+ text: N.text
574
+ }), (Z = window.getSelection()) == null || Z.removeAllRanges(), !0;
575
575
  }, v = (P) => {
576
- var rt;
577
- if (!g || !ft) return !1;
578
- const R = en(a, n);
579
- if (!R) return !1;
580
- const k = nn(R.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: Re,
586
- rects: k,
587
- text: R.text
585
+ color: He,
586
+ rects: N,
587
+ text: F.text
588
588
  });
589
- const B = xn(R.rects), G = Le(P || " ", B.fontSize), L = {
590
- id: We(),
589
+ const j = Nn(F.rects), Z = Re(P || " ", j.fontSize), R = {
590
+ id: Ge(),
591
591
  pageNumber: e,
592
- x: B.x,
593
- y: B.y,
594
- width: G.width,
595
- height: G.height,
592
+ x: j.x,
593
+ y: j.y,
594
+ width: Z.width,
595
+ height: Z.height,
596
596
  value: P,
597
- fontSize: B.fontSize,
598
- color: pe
597
+ fontSize: j.fontSize,
598
+ color: me
599
599
  };
600
- return ft(L), lt == null || lt(L.id), X == null || X(L.id), (rt = window.getSelection()) == null || rt.removeAllRanges(), it.current = !0, window.setTimeout(() => {
601
- it.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
603
  }, M = () => {
604
604
  if (d === "highlight" || d === "underline") {
605
- y(d);
605
+ w(d);
606
606
  return;
607
607
  }
608
608
  if (d === "erase") {
609
- y("redact");
609
+ w("redact");
610
610
  return;
611
611
  }
612
612
  if (d === "text") {
@@ -614,13 +614,13 @@ function wr({
614
614
  P && !P.isCollapsed && P.toString().trim() && P.anchorNode && a.contains(P.anchorNode) && v(P.toString());
615
615
  }
616
616
  }, D = (P) => {
617
- const R = P.target;
618
- if (R != null && R.closest("[contenteditable='true']") || R != null && R.closest("[contenteditable='']") || R != null && R.isContentEditable)
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 k = window.getSelection(), B = k != null && !k.isCollapsed && k.toString().trim().length > 0 && k.anchorNode != null && a.contains(k.anchorNode);
621
- if (d === "text" && B) {
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
- P.preventDefault(), v(k.toString());
623
+ P.preventDefault(), v(N.toString());
624
624
  return;
625
625
  }
626
626
  if (P.key.length === 1 && !P.ctrlKey && !P.metaKey && !P.altKey) {
@@ -628,7 +628,7 @@ function wr({
628
628
  return;
629
629
  }
630
630
  }
631
- d !== "text" && d !== "erase" || P.key !== "Backspace" && P.key !== "Delete" || B && (P.preventDefault(), y("redact"));
631
+ d !== "text" && d !== "erase" || P.key !== "Backspace" && P.key !== "Delete" || j && (P.preventDefault(), w("redact"));
632
632
  };
633
633
  return a.addEventListener("mouseup", M), window.addEventListener("keydown", D), () => {
634
634
  a.removeEventListener("mouseup", M), window.removeEventListener("keydown", D);
@@ -637,225 +637,225 @@ function wr({
637
637
  d,
638
638
  u,
639
639
  g,
640
- ft,
641
- X,
642
- lt,
640
+ ut,
641
+ G,
642
+ dt,
643
643
  e,
644
644
  n
645
- ]), Tt(() => {
646
- if (!yt) return;
647
- let a = 0, y = 0, v = 0, M = 0;
645
+ ]), Dt(() => {
646
+ if (!mt) return;
647
+ let a = 0, w = 0, v = 0, M = 0;
648
648
  const D = () => {
649
- var L;
650
- return (L = qt.current) == null ? void 0 : L.closest(".epochs-pdf-viewer__body");
651
- }, P = (L, rt) => {
652
- if (yt.kind !== "resize" || !C || pt) return;
653
- const q = w.find((bt) => bt.id === yt.id);
654
- if (!q) return;
655
- const ut = st.current, vt = ut ? Ne(ut, n) : { width: 1 / 0, height: 1 / 0 }, { dx: Xt, dy: Nt } = ut ? Gi(
656
- L - yt.startX,
657
- rt - yt.startY,
658
- ut,
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 }, Rt = vt.width - q.x, At = vt.height - q.y, Zt = Math.min(Rt, Math.max(40, yt.startW + Xt)), It = Math.min(At, Math.max(20, yt.startH + Nt));
661
- C(yt.id, { width: Zt, height: It });
662
- }, R = (L, rt) => {
663
- var Qt;
664
- if (yt.kind !== "signature" || !C || pt) return;
665
- const q = w.find((oe) => oe.id === yt.id);
666
- if (!q) return;
667
- let ut = (Qt = document.elementFromPoint(L, rt)) == null ? void 0 : Qt.closest("[data-page-number]");
668
- if (ut || (ut = 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
670
  ).find((Gt) => {
671
- const se = Gt.getBoundingClientRect();
672
- return rt >= se.top && rt <= se.bottom;
673
- }) ?? null), ut || (ut = qt.current), !ut) return;
674
- const vt = ut.querySelector(
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 (!vt) return;
678
- const Xt = Number.parseInt(
679
- ut.getAttribute("data-page-number") || String(q.pageNumber),
677
+ if (!ft) return;
678
+ const Ft = Number.parseInt(
679
+ et.getAttribute("data-page-number") || String(X.pageNumber),
680
680
  10
681
- ), Nt = He(L, rt, vt, n), Rt = Ne(vt, n);
682
- let At = Nt.x - yt.offsetX, Zt = Nt.y - yt.offsetY;
683
- const It = Math.max(0, Rt.width - q.width), bt = Math.max(0, Rt.height - q.height);
684
- At = Math.min(Math.max(0, At), It), Zt = Math.min(Math.max(0, Zt), bt), C(yt.id, {
685
- pageNumber: Xt,
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: Zt
687
+ y: St
688
688
  });
689
- }, k = () => {
689
+ }, N = () => {
690
690
  if (a = 0, !M) return;
691
- const L = D();
692
- if (!L) return;
693
- const rt = L.scrollHeight - L.clientHeight;
694
- if (rt <= 0) return;
695
- const q = 56, ut = L.getBoundingClientRect(), vt = v - ut.top, Xt = ut.bottom - v;
696
- let Nt = 0;
697
- if (M < 0 && vt < q)
698
- Nt = -Math.max(6, (q - vt) / q * 28);
699
- else if (M > 0 && Xt < q)
700
- Nt = Math.max(6, (q - Xt) / q * 28);
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
702
  M = 0;
703
703
  return;
704
704
  }
705
- const Rt = L.scrollTop;
706
- L.scrollTop = Math.min(rt, Math.max(0, Rt + Nt)), L.scrollTop !== Rt && R(y, v), Nt < 0 && L.scrollTop > 0 || Nt > 0 && L.scrollTop < rt ? a = window.requestAnimationFrame(k) : M = 0;
707
- }, B = (L) => {
708
- y = L.clientX, v = L.clientY;
709
- const rt = D();
710
- if (rt) {
711
- const ut = rt.getBoundingClientRect(), vt = L.clientY - ut.top, Xt = ut.bottom - L.clientY;
712
- vt < 56 ? (M = -1, a || (a = window.requestAnimationFrame(k))) : Xt < 56 ? (M = 1, a || (a = window.requestAnimationFrame(k))) : M = 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
- yt.kind === "resize" ? P(L.clientX, L.clientY) : R(L.clientX, L.clientY);
715
- }, G = () => {
716
- M = 0, a && (window.cancelAnimationFrame(a), a = 0), Ct(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", B), window.addEventListener("pointerup", G), window.addEventListener("pointercancel", G), () => {
719
- M = 0, a && window.cancelAnimationFrame(a), window.removeEventListener("pointermove", B), window.removeEventListener("pointerup", G), window.removeEventListener("pointercancel", G);
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
- yt,
722
+ mt,
723
723
  pt,
724
- C,
724
+ I,
725
725
  n,
726
- w
727
- ]), Tt(() => {
728
- if (!Dt || !ee.current) return;
729
- const a = ee.current, y = ct.find((D) => D.id === Dt);
730
- a.textContent = (y == null ? void 0 : y.value) ?? "", a.focus();
726
+ y
727
+ ]), Dt(() => {
728
+ if (!Kt || !ee.current) return;
729
+ const a = ee.current, w = ct.find((D) => D.id === Kt);
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
733
  const M = window.getSelection();
734
734
  M == null || M.removeAllRanges(), M == null || M.addRange(v);
735
- }, [Dt]);
736
- const re = (a) => {
737
- qt.current = a, r == null || r(a);
738
- }, f = m.filter((a) => a.pageNumber === e), F = w.filter((a) => a.pageNumber === e), A = et.filter((a) => a.pageNumber === e), dt = ct.filter((a) => a.pageNumber === e), ht = (a, y) => {
739
- const v = y.trim();
735
+ }, [Kt]);
736
+ const ne = (a) => {
737
+ $t.current = a, r == null || r(a);
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
+ const v = w.trim();
740
740
  if (!v) {
741
- tt == null || tt(a.id), X == null || X(null);
741
+ tt == null || tt(a.id), G == null || G(null);
742
742
  return;
743
743
  }
744
- const M = Le(v, a.fontSize);
744
+ const M = Re(v, a.fontSize);
745
745
  gt == null || gt(a.id, {
746
746
  value: v,
747
747
  width: M.width,
748
748
  height: M.height
749
- }), X == null || X(null);
750
- }, Vt = (a, y) => {
751
- if (!ft) return;
752
- const v = st.current, M = wt.current;
749
+ }), G == null || G(null);
750
+ }, rt = (a, w) => {
751
+ if (!ut) return;
752
+ const v = it.current, M = bt.current;
753
753
  if (!v || !M) return;
754
754
  let D = qi(
755
755
  a,
756
- y,
756
+ w,
757
757
  v,
758
758
  M,
759
759
  n
760
- ), P, R = pe;
761
- if (Ut) {
762
- const G = Qi(
760
+ ), P, F = me;
761
+ if (qt) {
762
+ const Z = Ji(
763
763
  D.x,
764
764
  D.y,
765
765
  te,
766
766
  e
767
767
  );
768
- if (!G) return;
769
- const L = ct.find((rt) => rt.fieldId === G.id);
770
- if (L) {
771
- lt == null || lt(L.id), St == null || St(G.id), X == null || X(L.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 = G.id, D = {
775
- x: G.x,
776
- y: G.y,
777
- fontSize: G.fontSize ?? ge
778
- }, R = G.color ?? pe, St == null || St(G.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 k = Le("", D.fontSize), B = {
781
- id: We(),
780
+ const N = Re("", D.fontSize), j = {
781
+ id: Ge(),
782
782
  fieldId: P,
783
783
  pageNumber: e,
784
784
  x: D.x,
785
785
  y: D.y,
786
- width: k.width,
787
- height: k.height,
786
+ width: N.width,
787
+ height: N.height,
788
788
  value: "",
789
789
  fontSize: D.fontSize,
790
- color: R
790
+ color: F
791
791
  };
792
- ft(B), lt == null || lt(B.id), X == null || X(B.id);
793
- }, Yt = (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 (it.current) {
798
- it.current = !1;
797
+ if (ht.current) {
798
+ ht.current = !1;
799
799
  return;
800
800
  }
801
- const y = window.getSelection();
802
- if (!(y && !y.isCollapsed && y.toString().trim())) {
803
- if (a.detail >= 2 && Ji(a.clientX, a.clientY, wt.current)) {
804
- const D = st.current;
805
- if (D && g && ft) {
806
- const P = en(D, n);
801
+ const w = window.getSelection();
802
+ if (!(w && !w.isCollapsed && w.toString().trim())) {
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: Re,
813
- rects: nn(P.rects),
812
+ color: He,
813
+ rects: cn(P.rects),
814
814
  text: P.text
815
815
  });
816
- const R = xn(P.rects), k = Le(P.text || " ", R.fontSize), B = {
817
- id: We(),
816
+ const F = Nn(P.rects), N = Re(P.text || " ", F.fontSize), j = {
817
+ id: Ge(),
818
818
  pageNumber: e,
819
- x: R.x,
820
- y: R.y,
821
- width: k.width,
822
- height: k.height,
819
+ x: F.x,
820
+ y: F.y,
821
+ width: N.width,
822
+ height: N.height,
823
823
  value: P.text,
824
- fontSize: R.fontSize,
825
- color: pe
824
+ fontSize: F.fontSize,
825
+ color: me
826
826
  };
827
- ft(B), lt == null || lt(B.id), X == null || X(B.id), (v = window.getSelection()) == null || v.removeAllRanges(), it.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(), Vt(a.clientX, a.clientY);
832
+ a.stopPropagation(), rt(a.clientX, a.clientY);
833
833
  }
834
- }, Kt = (a) => {
835
- const y = a.target;
836
- if (!(y.closest(".epochs-pdf-viewer__signature") || y.closest(".epochs-pdf-viewer__signature-field") || y.closest(".epochs-pdf-viewer__inline-text"))) {
834
+ }, Zt = (a) => {
835
+ const w = a.target;
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
- Vt(a.clientX, a.clientY);
838
+ rt(a.clientX, a.clientY);
839
839
  return;
840
840
  }
841
- if (!pt && d === "sign" && _t && U) {
842
- const v = st.current;
841
+ if (!pt && d === "sign" && vt && E) {
842
+ const v = it.current;
843
843
  if (!v) return;
844
- const M = He(a.clientX, a.clientY, v, n);
845
- U(e, Math.max(0, M.x - 75), Math.max(0, M.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
848
  if (!pt && d === "sign" && b && x) {
849
- const v = st.current;
849
+ const v = it.current;
850
850
  if (!v) return;
851
- const M = Ne(v, n), D = He(a.clientX, a.clientY, v, n);
852
- let P = D.x - b.width / 2, R = D.y - b.height / 2;
853
- const k = Math.max(0, M.width - b.width), B = Math.max(0, M.height - b.height);
854
- P = Math.min(Math.max(0, P), k), R = Math.min(Math.max(0, R), B), x({
855
- id: Oe(),
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
+ id: Se(),
856
856
  pageNumber: e,
857
857
  x: P,
858
- y: R,
858
+ y: F,
859
859
  width: b.width,
860
860
  height: b.height,
861
861
  imageDataUrl: b.imageDataUrl
@@ -863,7 +863,7 @@ function wr({
863
863
  return;
864
864
  }
865
865
  }
866
- }, ne = (a) => Dt === a.id ? /* @__PURE__ */ s(
866
+ }, ie = (a) => Kt === a.id ? /* @__PURE__ */ s(
867
867
  "span",
868
868
  {
869
869
  ref: ee,
@@ -883,7 +883,7 @@ function wr({
883
883
  onClick: (v) => v.stopPropagation(),
884
884
  onPointerDown: (v) => v.stopPropagation(),
885
885
  onInput: (v) => {
886
- const M = v.currentTarget.textContent ?? "", D = Le(M || " ", a.fontSize);
886
+ const M = v.currentTarget.textContent ?? "", D = Re(M || " ", a.fontSize);
887
887
  gt == null || gt(a.id, {
888
888
  value: M,
889
889
  width: D.width,
@@ -891,7 +891,7 @@ function wr({
891
891
  });
892
892
  },
893
893
  onBlur: (v) => {
894
- ht(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());
@@ -913,7 +913,7 @@ function wr({
913
913
  tt == null || tt(a.id);
914
914
  return;
915
915
  }
916
- d === "text" && (lt == null || lt(a.id), X == null || X(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,27 +922,27 @@ function wr({
922
922
  return /* @__PURE__ */ s(
923
923
  "div",
924
924
  {
925
- ref: re,
925
+ ref: ne,
926
926
  "data-page-number": e,
927
927
  className: "epochs-pdf-viewer__page",
928
928
  children: /* @__PURE__ */ T(
929
929
  "div",
930
930
  {
931
- ref: st,
931
+ ref: it,
932
932
  className: `epochs-pdf-viewer__surface epochs-pdf-viewer__surface--tool-${d}`,
933
- onClick: Kt,
933
+ onClick: Zt,
934
934
  children: [
935
- /* @__PURE__ */ s("canvas", { ref: Ft, className: "epochs-pdf-viewer__canvas" }),
936
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__markup-layer", "aria-hidden": "true", children: f.map(
937
- (a) => a.kind === "redact" ? null : a.rects.map((y, v) => a.kind === "highlight" ? /* @__PURE__ */ s(
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
+ (a) => a.kind === "redact" ? null : a.rects.map((w, v) => a.kind === "highlight" ? /* @__PURE__ */ s(
938
938
  "div",
939
939
  {
940
940
  className: "epochs-pdf-viewer__markup epochs-pdf-viewer__markup--highlight",
941
941
  style: {
942
- left: y.x * n,
943
- top: y.y * n,
944
- width: y.w * n,
945
- height: y.h * n,
942
+ left: w.x * n,
943
+ top: w.y * n,
944
+ width: w.w * n,
945
+ height: w.h * n,
946
946
  background: a.color
947
947
  },
948
948
  onClick: (M) => {
@@ -955,9 +955,9 @@ function wr({
955
955
  {
956
956
  className: "epochs-pdf-viewer__markup epochs-pdf-viewer__markup--underline",
957
957
  style: {
958
- left: y.x * n,
959
- top: (y.y + y.h) * n - Math.max(2, n * 1.5),
960
- width: y.w * n,
958
+ left: w.x * n,
959
+ top: (w.y + w.h) * n - Math.max(2, n * 1.5),
960
+ width: w.w * n,
961
961
  height: Math.max(2, n * 1.5),
962
962
  background: a.color
963
963
  },
@@ -969,8 +969,8 @@ function wr({
969
969
  ))
970
970
  ) }),
971
971
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__signature-layer", children: [
972
- A.map((a) => {
973
- const y = a.type ?? "sign", v = Mt[a.id] ?? a.value ?? "", M = y === "date" || y === "text" ? !!v.trim() : F.some((D) => D.fieldId === a.id);
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
  {
@@ -984,42 +984,42 @@ function wr({
984
984
  height: a.height * n
985
985
  },
986
986
  onClick: (D) => {
987
- if (D.stopPropagation(), Y == null || Y(a.id), y === "date" || y === "text") {
988
- I == null || I(null), J == null || J(y);
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((R) => R.fieldId === a.id);
992
- I == null || I((P == null ? void 0 : P.id) ?? null), P ? H == null || H(P.id) : J == null || J(y);
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: M ? "Completed field" : y === "date" ? "Date field" : y === "text" ? "Text field" : "Signature field",
995
- children: y === "date" || y === "text" ? v.trim() ? /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__signature-field-value", children: v }) : y === "date" ? /* @__PURE__ */ s("span", { children: "Date here" }) : /* @__PURE__ */ s("span", { children: a.placeholder ?? "Enter text" }) : M ? 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__ */ T(
1000
+ oe.map((a) => /* @__PURE__ */ T(
1001
1001
  "div",
1002
1002
  {
1003
- className: E === 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,
1007
1007
  width: a.width * n,
1008
1008
  height: a.height * n
1009
1009
  },
1010
- onPointerDown: (y) => {
1011
- if (y.stopPropagation(), y.preventDefault(), I == null || I(a.id), d === "erase" && !pt) {
1010
+ onPointerDown: (w) => {
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
1015
  if (pt) {
1016
- Y == null || Y(a.fieldId ?? null), H == null || H(a.id);
1016
+ q == null || q(a.fieldId ?? null), H == null || H(a.id);
1017
1017
  return;
1018
1018
  }
1019
- const v = st.current;
1019
+ const v = it.current;
1020
1020
  if (!v) return;
1021
- const M = He(y.clientX, y.clientY, v, n);
1022
- Ct({
1021
+ const M = We(w.clientX, w.clientY, v, n);
1022
+ It({
1023
1023
  kind: "signature",
1024
1024
  id: a.id,
1025
1025
  offsetX: M.x - a.x,
@@ -1034,16 +1034,16 @@ function wr({
1034
1034
  className: "epochs-pdf-viewer__signature-edit",
1035
1035
  title: "Edit signature",
1036
1036
  "aria-label": "Edit signature",
1037
- onPointerDown: (y) => {
1038
- y.stopPropagation();
1037
+ onPointerDown: (w) => {
1038
+ w.stopPropagation();
1039
1039
  },
1040
- onClick: (y) => {
1041
- y.stopPropagation(), I == null || I(a.id), H == null || H(a.id);
1040
+ onClick: (w) => {
1041
+ w.stopPropagation(), C == null || C(a.id), H == null || H(a.id);
1042
1042
  },
1043
- children: /* @__PURE__ */ s(gr, { size: 12 })
1043
+ children: /* @__PURE__ */ s(mr, { size: 12 })
1044
1044
  }
1045
1045
  ),
1046
- pt ? null : /* @__PURE__ */ T(Ae, { children: [
1046
+ pt ? null : /* @__PURE__ */ T(je, { children: [
1047
1047
  /* @__PURE__ */ s(
1048
1048
  "button",
1049
1049
  {
@@ -1051,11 +1051,11 @@ function wr({
1051
1051
  className: "epochs-pdf-viewer__signature-duplicate",
1052
1052
  title: "Duplicate signature",
1053
1053
  "aria-label": "Duplicate signature",
1054
- onPointerDown: (y) => {
1055
- y.stopPropagation();
1054
+ onPointerDown: (w) => {
1055
+ w.stopPropagation();
1056
1056
  },
1057
- onClick: (y) => {
1058
- y.stopPropagation(), I == null || I(a.id), O == null || O(a.id);
1057
+ onClick: (w) => {
1058
+ w.stopPropagation(), C == null || C(a.id), W == null || W(a.id);
1059
1059
  },
1060
1060
  children: "⧉"
1061
1061
  }
@@ -1067,11 +1067,11 @@ function wr({
1067
1067
  className: "epochs-pdf-viewer__signature-remove",
1068
1068
  title: "Remove signature",
1069
1069
  "aria-label": "Remove signature",
1070
- onPointerDown: (y) => {
1071
- y.stopPropagation();
1070
+ onPointerDown: (w) => {
1071
+ w.stopPropagation();
1072
1072
  },
1073
- onClick: (y) => {
1074
- y.stopPropagation(), S == null || S(a.id);
1073
+ onClick: (w) => {
1074
+ w.stopPropagation(), S == null || S(a.id);
1075
1075
  },
1076
1076
  children: "×"
1077
1077
  }
@@ -1083,12 +1083,12 @@ function wr({
1083
1083
  {
1084
1084
  className: "epochs-pdf-viewer__signature-resize",
1085
1085
  title: "Resize",
1086
- onPointerDown: (y) => {
1087
- y.stopPropagation(), y.preventDefault(), I == null || I(a.id), Ct({
1086
+ onPointerDown: (w) => {
1087
+ w.stopPropagation(), w.preventDefault(), C == null || C(a.id), It({
1088
1088
  kind: "resize",
1089
1089
  id: a.id,
1090
- startX: y.clientX,
1091
- startY: y.clientY,
1090
+ startX: w.clientX,
1091
+ startY: w.clientY,
1092
1092
  startW: a.width,
1093
1093
  startH: a.height
1094
1094
  });
@@ -1101,26 +1101,26 @@ function wr({
1101
1101
  a.id
1102
1102
  ))
1103
1103
  ] }),
1104
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__text-layer-overlay", children: dt.map((a) => ne(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: wt,
1108
+ ref: bt,
1109
1109
  className: "textLayer epochs-pdf-viewer__text-layer",
1110
- onClick: Yt
1110
+ onClick: Lt
1111
1111
  }
1112
1112
  ),
1113
- /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__redact-layer", "aria-hidden": "true", children: f.map(
1114
- (a) => a.kind === "redact" ? a.rects.map((y, v) => /* @__PURE__ */ s(
1113
+ /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__redact-layer", "aria-hidden": "true", children: Nt.map(
1114
+ (a) => a.kind === "redact" ? a.rects.map((w, v) => /* @__PURE__ */ s(
1115
1115
  "div",
1116
1116
  {
1117
1117
  className: "epochs-pdf-viewer__markup epochs-pdf-viewer__markup--redact",
1118
1118
  style: {
1119
- left: y.x * n,
1120
- top: y.y * n,
1121
- width: y.w * n,
1122
- height: y.h * n,
1123
- background: a.color || Re
1119
+ left: w.x * n,
1120
+ top: w.y * n,
1121
+ width: w.w * n,
1122
+ height: w.h * n,
1123
+ background: a.color || He
1124
1124
  },
1125
1125
  onClick: (M) => {
1126
1126
  d === "erase" && (M.stopPropagation(), _ == null || _(a.id));
@@ -1135,7 +1135,7 @@ function wr({
1135
1135
  }
1136
1136
  );
1137
1137
  }
1138
- function yr({
1138
+ function br({
1139
1139
  pdfDoc: t,
1140
1140
  pageNumber: e,
1141
1141
  isActive: n,
@@ -1148,41 +1148,41 @@ function yr({
1148
1148
  texts: g = [],
1149
1149
  textFields: _ = []
1150
1150
  }) {
1151
- const w = xt(null);
1152
- return Tt(() => {
1153
- if (!t || !w.current) return;
1151
+ const y = xt(null);
1152
+ return Dt(() => {
1153
+ if (!t || !y.current) return;
1154
1154
  let b = !1;
1155
- const x = w.current, C = x.getContext("2d");
1156
- if (!C) return;
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 O = await t.getPage(e);
1160
+ const W = await t.getPage(e);
1161
1161
  if (b) return;
1162
- const E = O.getViewport({ scale: 1, rotation: i }), I = o / E.width, et = O.getViewport({ scale: I, rotation: i });
1163
- x.width = Math.floor(et.width), x.height = Math.floor(et.height), S = O.render({ canvasContext: C, viewport: et }), await S.promise;
1164
- const at = d.filter((Z) => Z.pageNumber === e);
1165
- at.length > 0 && En(C, at, I);
1166
- const Y = u.filter((Z) => Z.pageNumber === e), pt = m.filter(
1167
- (Z) => Z.pageNumber === e
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
- pt.length > 0 && zi(
1170
- C,
1169
+ pt.length > 0 && Si(
1170
+ I,
1171
1171
  pt,
1172
- new Set(Y.map((Z) => Z.fieldId).filter(Boolean)),
1173
- I
1174
- ), Y.length > 0 && await Un(C, Y, I);
1175
- const J = g.filter((Z) => Z.pageNumber === e), Mt = _.filter(
1176
- (Z) => Z.pageNumber === e
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
- Mt.length > 0 && tr(
1179
- C,
1178
+ Mt.length > 0 && er(
1179
+ I,
1180
1180
  Mt,
1181
1181
  new Set(
1182
- J.filter((Z) => Z.fieldId && Z.value.trim()).map((Z) => Z.fieldId)
1182
+ J.filter((K) => K.fieldId && K.value.trim()).map((K) => K.fieldId)
1183
1183
  ),
1184
- I
1185
- ), J.length > 0 && Hn(C, J, I);
1184
+ C
1185
+ ), J.length > 0 && Wn(I, J, C);
1186
1186
  } catch {
1187
1187
  }
1188
1188
  })(), () => {
@@ -1210,42 +1210,42 @@ function yr({
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: w }) }),
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
- const br = /^(blob:|https?:|data:)/i;
1220
- let jn = !1;
1221
- function kn(t) {
1222
- ke.GlobalWorkerOptions.workerSrc = t, jn = !0;
1219
+ const _r = /^(blob:|https?:|data:)/i;
1220
+ let On = !1;
1221
+ function $n(t) {
1222
+ Ie.GlobalWorkerOptions.workerSrc = t, On = !0;
1223
1223
  }
1224
- function _r(t) {
1224
+ function vr(t) {
1225
1225
  if (t) {
1226
- kn(t);
1226
+ $n(t);
1227
1227
  return;
1228
1228
  }
1229
- jn || ke.GlobalWorkerOptions.workerSrc || kn(
1230
- `https://unpkg.com/pdfjs-dist@${ke.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
- function vr(t, e, n = "") {
1233
+ function xr(t, e, n = "") {
1234
1234
  const i = e || t;
1235
1235
  if (!i) return "";
1236
- if (br.test(i)) return i;
1236
+ if (_r.test(i)) return i;
1237
1237
  const r = i.startsWith("/") ? i : `/${i}`;
1238
1238
  return n ? `${n.replace(/\/$/, "")}${r}` : r;
1239
1239
  }
1240
- async function xr(t, e) {
1240
+ async function Mr(t, e) {
1241
1241
  const n = await fetch(t, e);
1242
1242
  if (!n.ok)
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
- return xr(t, e);
1248
+ return Mr(t, e);
1249
1249
  if (t instanceof ArrayBuffer) return t.slice(0);
1250
1250
  if (t instanceof Uint8Array) {
1251
1251
  const n = new Uint8Array(t.byteLength);
@@ -1253,7 +1253,7 @@ async function Nn(t, e) {
1253
1253
  }
1254
1254
  return t.arrayBuffer();
1255
1255
  }
1256
- async function Mr(t, e, n) {
1256
+ async function kr(t, e, n) {
1257
1257
  const {
1258
1258
  scale: i,
1259
1259
  rotation: r,
@@ -1262,35 +1262,35 @@ async function Mr(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), w = _.getViewport({ scale: i, rotation: r }), b = _.getViewport({ scale: 1, rotation: r }), x = document.createElement("canvas"), C = x.getContext("2d", { alpha: !1 });
1266
- if (!C)
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(w.width), H = Math.floor(w.height);
1269
- x.width = S, x.height = H, C.fillStyle = "#ffffff", C.fillRect(0, 0, S, H), await _.render({ canvasContext: C, viewport: w }).promise;
1270
- const O = o.filter((Y) => Y.pageNumber === e);
1271
- O.length > 0 && En(C, O, i);
1272
- const E = d.filter((Y) => Y.pageNumber === e);
1273
- E.length > 0 && await Un(C, E, i);
1274
- const I = u.filter((Y) => Y.pageNumber === e);
1275
- I.length > 0 && Hn(C, I, i);
1276
- const et = x.toDataURL(m, g), at = kr(et);
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
1277
  return x.width = 0, x.height = 0, {
1278
1278
  pageNumber: e,
1279
1279
  width: S,
1280
1280
  height: H,
1281
1281
  pageWidth: b.width,
1282
1282
  pageHeight: b.height,
1283
- dataUrl: et,
1283
+ dataUrl: nt,
1284
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
- n.push(await Mr(t, i, e));
1290
+ n.push(await kr(t, i, e));
1291
1291
  return n;
1292
1292
  }
1293
- function kr(t) {
1293
+ function Nr(t) {
1294
1294
  const e = t.split(",")[1] ?? "", n = atob(e), i = new Uint8Array(n.length);
1295
1295
  for (let r = 0; r < n.length; r += 1)
1296
1296
  i[r] = n.charCodeAt(r);
@@ -1299,17 +1299,17 @@ function kr(t) {
1299
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)
1306
1306
  n.set(r, i), i += r.byteLength;
1307
1307
  return n;
1308
1308
  }
1309
- function Nr(t) {
1309
+ function Pr(t) {
1310
1310
  const e = [], n = (b) => (e.push(b), e.length), i = [];
1311
1311
  for (const b of t) {
1312
- const x = $n(
1312
+ const x = Tn(
1313
1313
  Jt(
1314
1314
  `<< /Type /XObject /Subtype /Image /Width ${b.width} /Height ${b.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${b.jpegBytes.byteLength} >>
1315
1315
  stream
@@ -1318,7 +1318,7 @@ stream
1318
1318
  b.jpegBytes,
1319
1319
  Jt(`
1320
1320
  endstream`)
1321
- ), C = n(x), S = `q
1321
+ ), I = n(x), S = `q
1322
1322
  ${b.pageWidth.toFixed(2)} 0 0 ${b.pageHeight.toFixed(2)} 0 0 cm
1323
1323
  /Im0 Do
1324
1324
  Q`, H = n(
@@ -1326,12 +1326,12 @@ Q`, H = n(
1326
1326
  stream
1327
1327
  ${S}
1328
1328
  endstream`)
1329
- ), O = n(
1329
+ ), W = n(
1330
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 ${C} 0 R >> >> >>`
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(O);
1334
+ i.push(W);
1335
1335
  }
1336
1336
  const r = i.map((b) => `${b} 0 R`).join(" "), o = n(
1337
1337
  Jt(`<< /Type /Pages /Kids [${r}] /Count ${i.length} >>`)
@@ -1348,50 +1348,60 @@ endstream`)
1348
1348
  for (let b = 0; b < e.length; b += 1) {
1349
1349
  m.push(g);
1350
1350
  const x = Jt(`${b + 1} 0 obj
1351
- `), C = Jt(`
1351
+ `), I = Jt(`
1352
1352
  endobj
1353
1353
  `);
1354
- u.push(x, e[b], C), g += x.byteLength + e[b].byteLength + C.byteLength;
1354
+ u.push(x, e[b], I), g += x.byteLength + e[b].byteLength + I.byteLength;
1355
1355
  }
1356
1356
  const _ = g;
1357
- let w = `xref
1357
+ let y = `xref
1358
1358
  0 ${e.length + 1}
1359
1359
  `;
1360
- w += `0000000000 65535 f
1360
+ y += `0000000000 65535 f
1361
1361
  `;
1362
1362
  for (let b = 1; b <= e.length; b += 1)
1363
- w += `${String(m[b]).padStart(10, "0")} 00000 n
1363
+ y += `${String(m[b]).padStart(10, "0")} 00000 n
1364
1364
  `;
1365
- return w += `trailer
1365
+ return y += `trailer
1366
1366
  << /Size ${e.length + 1} /Root ${d} 0 R >>
1367
- `, w += `startxref
1367
+ `, y += `startxref
1368
1368
  ${_}
1369
- %%EOF`, u.push(Jt(w)), $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 je = [
1376
- { id: "cursive", label: "Cursive", family: "cursive" },
1377
- { id: "serif", label: "Serif", family: "serif" },
1378
- { id: "sans", label: "Sans", family: "sans-serif" },
1379
- { id: "mono", label: "Mono", family: "monospace" },
1380
- { id: "fantasy", label: "Fantasy", family: "fantasy" }
1381
- ];
1382
- function Pr(t) {
1383
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1384
- }
1385
- function $r(t) {
1386
- const e = new TextEncoder().encode(t);
1387
- let n = "";
1388
- const i = 32768;
1389
- for (let r = 0; r < e.length; r += i)
1390
- n += String.fromCharCode(...e.subarray(r, r + i));
1391
- return `data:image/svg+xml;base64,${btoa(n)}`;
1375
+ const Ue = [
1376
+ { id: "dancing-script", label: "Dancing Script", family: "Dancing Script" },
1377
+ { id: "great-vibes", label: "Great Vibes", family: "Great Vibes" },
1378
+ { id: "pacifico", label: "Pacifico", family: "Pacifico" },
1379
+ { id: "satisfy", label: "Satisfy", family: "Satisfy" },
1380
+ { id: "allura", label: "Allura", family: "Allura" }
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 Oe = null;
1383
+ function Ir() {
1384
+ return typeof document > "u" ? Promise.resolve() : Oe || (Oe = new Promise((t) => {
1385
+ var i;
1386
+ if (!document.querySelector(
1387
+ 'link[data-epochs-signature-fonts="true"]'
1388
+ )) {
1389
+ const r = document.createElement("link");
1390
+ r.rel = "stylesheet", r.href = $r, r.dataset.epochsSignatureFonts = "true", document.head.appendChild(r);
1391
+ }
1392
+ const n = () => Promise.all(
1393
+ Ue.map(
1394
+ (r) => document.fonts.load(`48px "${r.family}"`)
1395
+ )
1396
+ ).then(() => {
1397
+ });
1398
+ (i = document.fonts) != null && i.ready ? document.fonts.ready.then(n).then(t).catch(() => t()) : window.setTimeout(() => {
1399
+ n().then(t).catch(() => t());
1400
+ }, 300);
1401
+ }), Oe);
1392
1402
  }
1393
- function Cn(t) {
1394
- return t === "initials" ? 64 : 48;
1403
+ function Dn(t, e) {
1404
+ return t === "initials" ? 72 : e === "Great Vibes" || e === "Allura" ? 56 : e === "Pacifico" ? 44 : 48;
1395
1405
  }
1396
1406
  function Cr({
1397
1407
  open: t,
@@ -1406,150 +1416,163 @@ function Cr({
1406
1416
  rememberedByType: g,
1407
1417
  onRememberFill: _
1408
1418
  }) {
1409
- const w = xt(null), b = xt(!1), x = xt(null), C = xt([]), S = xt([]), H = xt(null), O = r ?? "sign", [E, I] = z(O), [et, at] = z(""), [Y, pt] = z(""), [J, Mt] = z("draw"), [Z, Lt] = z(""), [_t, U] = z(""), [ct, ft] = z(!1), [gt, tt] = z("signature"), [kt, lt] = z("#111827"), [te, me] = z("cursive"), [St, Ut] = z(!1), Dt = je.find((f) => f.id === te) ?? je[0], X = gt === "initials" ? _t.trim() : Z.trim(), qt = X || (gt === "initials" ? "AB" : "Signature");
1410
- if (Tt(() => {
1411
- var A, dt;
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;
1412
1422
  if (!t) return;
1413
- if (I(O), O === "date") {
1423
+ if (C(W), W === "date") {
1414
1424
  at(
1415
- u || ((A = g == null ? void 0 : g.date) == null ? void 0 : A.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)
1416
1426
  );
1417
1427
  return;
1418
1428
  }
1419
- if (O === "text") {
1420
- pt(u || ((dt = g == null ? void 0 : g.text) == null ? void 0 : dt.value) || "");
1429
+ if (W === "text") {
1430
+ pt(u || ((rt = g == null ? void 0 : g.text) == null ? void 0 : rt.value) || "");
1421
1431
  return;
1422
1432
  }
1423
1433
  const f = g == null ? void 0 : g.sign;
1424
1434
  if (!f) {
1425
- Mt("draw"), Lt(""), U(""), ft(!1), tt("signature"), lt("#111827"), me("cursive"), H.current = null, Ut(!1);
1435
+ Mt("draw"), Et(""), E(""), ut(!1), tt("signature"), dt("#111827"), ye("dancing-script"), H.current = null, G(!1);
1426
1436
  return;
1427
1437
  }
1428
- Mt(f.mode), Lt(f.typedName ?? ""), U(f.typedInitials ?? ""), ft(!!f.typedInitials), tt(f.typeKind ?? "signature"), lt(f.inkColor ?? "#111827");
1429
- const F = je.find((ht) => ht.id === f.fontId);
1430
- F && me(F.id), f.mode === "draw" ? (H.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 = {
1431
1441
  imageDataUrl: f.imageDataUrl,
1432
1442
  width: f.width,
1433
1443
  height: f.height
1434
- }, Ut(!0)) : (H.current = null, Ut(!1));
1435
- }, [t, O, g, u]), Tt(() => {
1436
- if (!t || E !== "sign") return;
1437
- const f = w.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;
1438
1448
  if (!f) return;
1439
- const F = f.getContext("2d");
1440
- if (!F || (f.width = 560, f.height = 200, F.fillStyle = "#ffffff", F.fillRect(0, 0, f.width, f.height), F.lineCap = "round", F.lineJoin = "round", F.strokeStyle = kt, F.lineWidth = 2.5, x.current = null, b.current = !1, C.current = [], S.current = [], J !== "draw")) return;
1441
- const A = H.current;
1442
- if (!(A != null && A.imageDataUrl)) return;
1443
- const dt = new Image();
1444
- dt.onload = () => {
1445
- const ht = Math.min(
1446
- f.width / Math.max(1, A.width),
1447
- f.height / Math.max(1, A.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),
1448
1458
  1
1449
- ), Vt = A.width * ht, Yt = A.height * ht;
1450
- F.drawImage(dt, (f.width - Vt) / 2, (f.height - Yt) / 2, Vt, Yt);
1451
- }, dt.src = A.imageDataUrl;
1452
- }, [t, E, J]), Tt(() => {
1453
- const f = w.current, F = f == null ? void 0 : f.getContext("2d");
1454
- F && (F.strokeStyle = kt, F.fillStyle = kt);
1455
- }, [kt]), Tt(() => {
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(() => {
1463
+ if (!t) return;
1464
+ let f = !1;
1465
+ return qt(!1), Ir().then(() => {
1466
+ f || qt(!0);
1467
+ }), () => {
1468
+ f = !0;
1469
+ };
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(() => {
1456
1474
  if (!t || J !== "type") return;
1457
- const f = w.current, F = f == null ? void 0 : f.getContext("2d");
1458
- if (!f || !F || (F.clearRect(0, 0, f.width, f.height), !X)) return;
1459
- const A = Cn(gt);
1460
- F.fillStyle = kt, F.textAlign = "center", F.textBaseline = "middle", F.font = `${A}px ${Dt.family}`, F.fillText(X, f.width / 2, f.height / 2);
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);
1461
1479
  }, [
1462
- X,
1480
+ yt,
1463
1481
  gt,
1464
1482
  J,
1465
1483
  kt,
1466
1484
  t,
1467
- Dt
1485
+ $t,
1486
+ Vt
1468
1487
  ]), !t) return null;
1469
- const Ft = (f) => {
1470
- const F = w.current, A = F.getBoundingClientRect();
1488
+ const it = (f) => {
1489
+ const L = y.current, U = L.getBoundingClientRect();
1471
1490
  return {
1472
- x: (f.clientX - A.left) / A.width * F.width,
1473
- y: (f.clientY - A.top) / A.height * F.height
1491
+ x: (f.clientX - U.left) / U.width * L.width,
1492
+ y: (f.clientY - U.top) / U.height * L.height
1474
1493
  };
1475
- }, wt = (f) => {
1494
+ }, Wt = (f) => {
1476
1495
  if (J !== "draw") return;
1477
1496
  if (H.current) {
1478
- H.current = null, Ut(!1);
1479
- const A = w.current, dt = A == null ? void 0 : A.getContext("2d");
1480
- A && dt && (dt.fillStyle = "#ffffff", dt.fillRect(0, 0, A.width, A.height), dt.strokeStyle = kt, dt.lineWidth = 2.5, dt.lineCap = "round", dt.lineJoin = "round"), C.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 = [];
1481
1500
  }
1482
1501
  f.currentTarget.setPointerCapture(f.pointerId), b.current = !0;
1483
- const F = Ft(f);
1484
- x.current = F, S.current = [F];
1502
+ const L = it(f);
1503
+ x.current = L, S.current = [L];
1485
1504
  }, st = (f) => {
1486
1505
  if (!b.current || J !== "draw") return;
1487
- const F = w.current, A = F == null ? void 0 : F.getContext("2d"), dt = x.current;
1488
- if (!A || !dt) return;
1489
- const ht = Ft(f);
1490
- A.beginPath(), A.moveTo(dt.x, dt.y), A.lineTo(ht.x, ht.y), A.stroke(), x.current = ht, S.current.push(ht);
1491
- }, Ht = () => {
1492
- S.current.length > 1 && C.current.push([...S.current]), S.current = [], b.current = !1, x.current = null;
1493
- }, nt = () => {
1494
- const f = w.current, F = f == null ? void 0 : f.getContext("2d");
1495
- !f || !F || (F.fillStyle = "#ffffff", F.fillRect(0, 0, f.width, f.height), C.current = [], S.current = [], H.current = null, Ut(!1), Lt(""), U(""), ft(!1));
1496
- }, yt = (f) => {
1497
- Lt(f), ct || U(Ir(f));
1498
- }, Ct = () => {
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 = () => {
1499
1518
  if (J === "draw") {
1500
- const R = C.current, k = H.current;
1501
- if (R.length === 0) {
1502
- if (!k) return;
1519
+ const X = I.current, et = H.current;
1520
+ if (X.length === 0) {
1521
+ if (!et) return;
1503
1522
  _ == null || _("sign", {
1504
1523
  mode: "draw",
1505
- imageDataUrl: k.imageDataUrl,
1506
- width: k.width,
1507
- height: k.height,
1524
+ imageDataUrl: et.imageDataUrl,
1525
+ width: et.width,
1526
+ height: et.height,
1508
1527
  inkColor: kt
1509
- }), n(k.imageDataUrl, k.width, k.height);
1528
+ }), n(et.imageDataUrl, et.width, et.height);
1510
1529
  return;
1511
1530
  }
1512
- let B = 1 / 0, G = 1 / 0, L = -1 / 0, rt = -1 / 0;
1513
- for (const se of R)
1514
- for (const Et of se)
1515
- Et.x < B && (B = Et.x), Et.y < G && (G = Et.y), Et.x > L && (L = Et.x), Et.y > rt && (rt = Et.y);
1516
- const q = 8;
1517
- B = Math.max(0, B - q), G = Math.max(0, G - q), L += q, rt += q;
1518
- const ut = L - B, vt = rt - G, Xt = R.map((se) => "M" + se.map((le) => ({ x: le.x - B, y: le.y - G })).map((le) => `${le.x.toFixed(1)},${le.y.toFixed(1)}`).join("L")).join(" "), Nt = Math.max(1, (m == null ? void 0 : m.width) ?? ut), Rt = Math.max(1, (m == null ? void 0 : m.height) ?? vt), At = Math.min(Nt / ut, Rt / vt), Zt = ut * At, It = vt * At, bt = (Nt - Zt) / 2, Qt = (Rt - It) / 2, oe = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${Nt} ${Rt}"><g transform="translate(${bt.toFixed(2)} ${Qt.toFixed(2)}) scale(${At.toFixed(4)})"><path d="${Xt}" fill="none" stroke="${kt}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></g></svg>`, Gt = `data:image/svg+xml;base64,${btoa(oe)}`;
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)}`;
1519
1538
  _ == null || _("sign", {
1520
1539
  mode: "draw",
1521
- imageDataUrl: Gt,
1522
- width: Nt,
1523
- height: Rt,
1540
+ imageDataUrl: he,
1541
+ width: Ut,
1542
+ height: Yt,
1524
1543
  inkColor: kt
1525
- }), n(Gt, Nt, Rt);
1544
+ }), n(he, Ut, Yt);
1526
1545
  return;
1527
1546
  }
1528
- if (!X) return;
1529
- const f = Cn(gt), A = document.createElement("canvas").getContext("2d");
1530
- A.font = `${f}px ${Dt.family}`;
1531
- const dt = A.measureText(X), ht = 8, Vt = Math.ceil(dt.width) + ht * 2, Yt = f + ht * 2, Kt = Math.max(1, (m == null ? void 0 : m.width) ?? Vt), ne = Math.max(1, (m == null ? void 0 : m.height) ?? Yt), a = Math.min(Kt / Vt, ne / Yt), y = Math.max(8, f * a), v = (Kt / 2).toFixed(1), M = (ne / 2).toFixed(1), D = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 ${Kt} ${ne}"><text x="${v}" y="${M}" text-anchor="middle" dominant-baseline="central" alignment-baseline="middle" font-family="${Dt.family}" font-size="${y.toFixed(1)}" fill="${kt}">${Pr(X)}</text></svg>`, P = $r(D);
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)}`;
1532
1555
  _ == null || _("sign", {
1533
1556
  mode: "type",
1534
- imageDataUrl: P,
1535
- width: Kt,
1536
- height: ne,
1537
- typedName: Z,
1538
- typedInitials: _t,
1557
+ imageDataUrl: lt,
1558
+ width: w,
1559
+ height: v,
1560
+ typedName: K,
1561
+ typedInitials: vt,
1539
1562
  fontId: te,
1540
1563
  inkColor: kt,
1541
1564
  typeKind: gt
1542
- }), n(P, Kt, ne);
1543
- }, ee = () => {
1544
- if (E !== "date" && E !== "text") return;
1545
- const f = E === "date" ? et : Y.trim();
1546
- f && (_ == null || _(E, { value: f }), i == null || i(f, E));
1547
- }, it = E === "sign";
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";
1548
1571
  return /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal", role: "dialog", "aria-modal": "true", children: [
1549
1572
  /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__modal-backdrop", onClick: e }),
1550
1573
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-card", children: [
1551
1574
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-header", children: [
1552
- /* @__PURE__ */ s("h3", { children: E === "date" ? "Pick a date" : E === "text" ? "Enter text" : "Create e-signature" }),
1575
+ /* @__PURE__ */ s("h3", { children: A === "date" ? "Pick a date" : A === "text" ? "Enter text" : "Create e-signature" }),
1553
1576
  /* @__PURE__ */ s(
1554
1577
  "button",
1555
1578
  {
@@ -1566,14 +1589,14 @@ function Cr({
1566
1589
  {
1567
1590
  type: "button",
1568
1591
  role: "tab",
1569
- "aria-selected": E === f,
1570
- className: E === f ? "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--active" : "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1571
- onClick: () => I(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),
1572
1595
  children: f === "sign" ? "Sign" : f === "date" ? "Date" : "Text"
1573
1596
  },
1574
1597
  f
1575
1598
  )) }) : null,
1576
- it ? /* @__PURE__ */ T(Ae, { children: [
1599
+ Nt ? /* @__PURE__ */ T(je, { children: [
1577
1600
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__sign-modes", children: [
1578
1601
  /* @__PURE__ */ s(
1579
1602
  "button",
@@ -1581,7 +1604,7 @@ function Cr({
1581
1604
  type: "button",
1582
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",
1583
1606
  onClick: () => {
1584
- Mt("draw"), nt();
1607
+ Mt("draw"), It();
1585
1608
  },
1586
1609
  children: "Draw"
1587
1610
  }
@@ -1602,27 +1625,27 @@ function Cr({
1602
1625
  {
1603
1626
  type: "color",
1604
1627
  value: kt,
1605
- onChange: (f) => lt(f.target.value)
1628
+ onChange: (f) => dt(f.target.value)
1606
1629
  }
1607
1630
  )
1608
1631
  ] })
1609
1632
  ] }),
1610
- J === "type" ? /* @__PURE__ */ T(Ae, { children: [
1633
+ J === "type" ? /* @__PURE__ */ T(je, { children: [
1611
1634
  /* @__PURE__ */ s(
1612
1635
  "div",
1613
1636
  {
1614
1637
  className: "epochs-pdf-viewer__sign-fonts",
1615
1638
  role: "group",
1616
1639
  "aria-label": "Handwriting style",
1617
- children: je.map((f) => /* @__PURE__ */ s(
1640
+ children: Ue.map((f) => /* @__PURE__ */ s(
1618
1641
  "button",
1619
1642
  {
1620
1643
  type: "button",
1621
1644
  className: te === f.id ? "epochs-pdf-viewer__sign-font epochs-pdf-viewer__sign-font--active" : "epochs-pdf-viewer__sign-font",
1622
- style: { fontFamily: f.family },
1623
- onClick: () => me(f.id),
1645
+ style: { fontFamily: `"${f.family}", cursive` },
1646
+ onClick: () => ye(f.id),
1624
1647
  title: f.label,
1625
- children: qt
1648
+ children: bt
1626
1649
  },
1627
1650
  f.id
1628
1651
  ))
@@ -1636,11 +1659,11 @@ function Cr({
1636
1659
  {
1637
1660
  className: "epochs-pdf-viewer__sign-type-input",
1638
1661
  type: "text",
1639
- value: Z,
1640
- onChange: (f) => yt(f.target.value),
1662
+ value: K,
1663
+ onChange: (f) => ee(f.target.value),
1641
1664
  onFocus: () => tt("signature"),
1642
1665
  placeholder: "Type your full name",
1643
- style: { fontFamily: Dt.family },
1666
+ style: { fontFamily: `"${$t.family}", cursive` },
1644
1667
  autoFocus: !0
1645
1668
  }
1646
1669
  )
@@ -1652,14 +1675,14 @@ function Cr({
1652
1675
  {
1653
1676
  className: "epochs-pdf-viewer__sign-type-input",
1654
1677
  type: "text",
1655
- value: _t,
1678
+ value: vt,
1656
1679
  onChange: (f) => {
1657
- ft(!0), U(f.target.value.toUpperCase());
1680
+ ut(!0), E(f.target.value.toUpperCase());
1658
1681
  },
1659
1682
  onFocus: () => tt("initials"),
1660
1683
  placeholder: "e.g. JD",
1661
1684
  maxLength: 4,
1662
- style: { fontFamily: Dt.family }
1685
+ style: { fontFamily: `"${$t.family}", cursive` }
1663
1686
  }
1664
1687
  )
1665
1688
  ] })
@@ -1692,26 +1715,26 @@ function Cr({
1692
1715
  ]
1693
1716
  }
1694
1717
  )
1695
- ] }) : /* @__PURE__ */ s("p", { className: "epochs-pdf-viewer__sign-hint", children: St ? "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" }),
1696
1719
  /* @__PURE__ */ s(
1697
1720
  "canvas",
1698
1721
  {
1699
- ref: w,
1722
+ ref: y,
1700
1723
  className: J === "draw" ? "epochs-pdf-viewer__sign-canvas" : "epochs-pdf-viewer__sign-canvas epochs-pdf-viewer__sign-canvas--preview",
1701
- onPointerDown: wt,
1724
+ onPointerDown: Wt,
1702
1725
  onPointerMove: st,
1703
- onPointerUp: Ht,
1704
- onPointerLeave: Ht
1726
+ onPointerUp: mt,
1727
+ onPointerLeave: mt
1705
1728
  }
1706
1729
  )
1707
- ] }) : E === "date" ? /* @__PURE__ */ T("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: [
1708
1731
  /* @__PURE__ */ s("span", { children: "Date" }),
1709
1732
  /* @__PURE__ */ s(
1710
1733
  "input",
1711
1734
  {
1712
1735
  className: "epochs-pdf-viewer__sign-type-input",
1713
1736
  type: "date",
1714
- value: et,
1737
+ value: nt,
1715
1738
  onChange: (f) => at(f.target.value),
1716
1739
  autoFocus: !0
1717
1740
  }
@@ -1723,7 +1746,7 @@ function Cr({
1723
1746
  {
1724
1747
  className: "epochs-pdf-viewer__sign-type-input",
1725
1748
  type: "text",
1726
- value: Y,
1749
+ value: q,
1727
1750
  onChange: (f) => pt(f.target.value),
1728
1751
  placeholder: d ?? "Enter text",
1729
1752
  autoFocus: !0
@@ -1731,12 +1754,12 @@ function Cr({
1731
1754
  )
1732
1755
  ] }),
1733
1756
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__modal-actions", children: [
1734
- it ? /* @__PURE__ */ s(
1757
+ Nt ? /* @__PURE__ */ s(
1735
1758
  "button",
1736
1759
  {
1737
1760
  type: "button",
1738
1761
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
1739
- onClick: nt,
1762
+ onClick: It,
1740
1763
  children: "Clear"
1741
1764
  }
1742
1765
  ) : null,
@@ -1754,66 +1777,66 @@ function Cr({
1754
1777
  {
1755
1778
  type: "button",
1756
1779
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--primary",
1757
- onClick: it ? Ct : ee,
1758
- disabled: E === "date" ? !et : E === "text" ? !Y.trim() : !1,
1759
- children: it ? "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"
1760
1783
  }
1761
1784
  )
1762
1785
  ] })
1763
1786
  ] })
1764
1787
  ] });
1765
1788
  }
1766
- function Ir(t) {
1789
+ function Tr(t) {
1767
1790
  const e = t.trim().split(/\s+/).filter(Boolean);
1768
1791
  return e.length === 0 ? "" : e.length === 1 ? e[0].slice(0, 2).toUpperCase() : e.slice(0, 3).map((n) => {
1769
1792
  var i;
1770
1793
  return ((i = n[0]) == null ? void 0 : i.toUpperCase()) ?? "";
1771
1794
  }).join("");
1772
1795
  }
1773
- const ze = "__epochsToolbarToolId";
1774
- function Wt(t, e) {
1796
+ const Xe = "__epochsToolbarToolId";
1797
+ function zt(t, e) {
1775
1798
  const n = (() => null);
1776
- return n.displayName = e, Object.defineProperty(n, ze, {
1799
+ return n.displayName = e, Object.defineProperty(n, Xe, {
1777
1800
  value: t,
1778
1801
  enumerable: !0
1779
1802
  }), n;
1780
1803
  }
1781
- function In(t) {
1782
- return t[ze];
1804
+ function Ln(t) {
1805
+ return t[Xe];
1783
1806
  }
1784
- function Tr(t) {
1785
- return typeof t == "function" && ze in t && typeof t[ze] == "string";
1807
+ function Dr(t) {
1808
+ return typeof t == "function" && Xe in t && typeof t[Xe] == "string";
1786
1809
  }
1787
- const Bn = Wt("thumbnail", "Thumbnail"), On = Wt("navigation", "Navigation"), Wn = Wt("zoom", "Zoom"), zn = Wt("rotate", "Rotate"), Sn = Wt("reload", "Reload"), Xn = Wt("print", "Print"), Gn = Wt("open", "Open"), qn = Wt("download", "Download"), Vn = Wt("highlight", "Highlight"), Yn = Wt("underline", "Underline"), Kn = Wt("signature", "Signature"), Zn = Wt("text", "AddText"), Qn = Wt("erase", "Erase"), Jn = Wt("clear", "Clear"), io = [
1788
- Bn,
1789
- On,
1790
- Wn,
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 = [
1791
1811
  zn,
1792
- Vn,
1793
- Yn,
1794
- Kn,
1812
+ Sn,
1813
+ Gn,
1814
+ Xn,
1795
1815
  Zn,
1796
1816
  Qn,
1797
1817
  Jn,
1798
- Sn,
1799
- Xn,
1800
- Gn,
1801
- qn
1802
- ], Tn = [
1803
- [Bn, On],
1818
+ ti,
1819
+ ei,
1820
+ ni,
1821
+ Vn,
1822
+ qn,
1823
+ Yn,
1824
+ Kn
1825
+ ], Fn = [
1826
+ [zn, Sn],
1804
1827
  [
1805
- Wn,
1806
- zn,
1807
- Vn,
1808
- Yn,
1809
- Kn,
1828
+ Gn,
1829
+ Xn,
1810
1830
  Zn,
1811
1831
  Qn,
1812
1832
  Jn,
1813
- Sn,
1814
- Xn,
1815
- Gn,
1816
- qn
1833
+ ti,
1834
+ ei,
1835
+ ni,
1836
+ Vn,
1837
+ qn,
1838
+ Yn,
1839
+ Kn
1817
1840
  ]
1818
1841
  ], Lr = [
1819
1842
  "highlight",
@@ -1823,10 +1846,10 @@ const Bn = Wt("thumbnail", "Thumbnail"), On = Wt("navigation", "Navigation"), Wn
1823
1846
  "erase",
1824
1847
  "clear"
1825
1848
  ];
1826
- function Ln(t) {
1849
+ function Rn(t) {
1827
1850
  return Lr.includes(t);
1828
1851
  }
1829
- function Dr(t, e, n) {
1852
+ function Fr(t, e, n) {
1830
1853
  const i = [];
1831
1854
  switch (n != null && n.showMarkupSep && i.push(
1832
1855
  /* @__PURE__ */ s(
@@ -1847,7 +1870,7 @@ function Dr(t, e, n) {
1847
1870
  className: "epochs-pdf-viewer__btn",
1848
1871
  onClick: () => e.setShowThumbnails((r) => !r),
1849
1872
  title: e.showThumbnails ? "Hide thumbnails" : "Show thumbnails",
1850
- children: /* @__PURE__ */ s(or, {})
1873
+ children: /* @__PURE__ */ s(sr, {})
1851
1874
  },
1852
1875
  "thumbnail"
1853
1876
  )
@@ -1863,7 +1886,7 @@ function Dr(t, e, n) {
1863
1886
  onClick: e.handlePrev,
1864
1887
  disabled: !e.canGoPrev || e.status !== "ready",
1865
1888
  title: "Previous page",
1866
- children: /* @__PURE__ */ s(er, {})
1889
+ children: /* @__PURE__ */ s(nr, {})
1867
1890
  },
1868
1891
  "nav-prev"
1869
1892
  ),
@@ -1898,7 +1921,7 @@ function Dr(t, e, n) {
1898
1921
  onClick: e.handleNext,
1899
1922
  disabled: !e.canGoNext || e.status !== "ready",
1900
1923
  title: "Next page",
1901
- children: /* @__PURE__ */ s(nr, {})
1924
+ children: /* @__PURE__ */ s(ir, {})
1902
1925
  },
1903
1926
  "nav-next"
1904
1927
  )
@@ -1914,7 +1937,7 @@ function Dr(t, e, n) {
1914
1937
  onClick: e.handleZoomOut,
1915
1938
  disabled: e.status !== "ready",
1916
1939
  title: "Zoom out",
1917
- children: /* @__PURE__ */ s(sr, {})
1940
+ children: /* @__PURE__ */ s(ar, {})
1918
1941
  },
1919
1942
  "zoom-out"
1920
1943
  ),
@@ -1930,7 +1953,7 @@ function Dr(t, e, n) {
1930
1953
  onClick: e.handleZoomIn,
1931
1954
  disabled: e.status !== "ready",
1932
1955
  title: "Zoom in",
1933
- children: /* @__PURE__ */ s(ar, {})
1956
+ children: /* @__PURE__ */ s(cr, {})
1934
1957
  },
1935
1958
  "zoom-in"
1936
1959
  ),
@@ -1958,7 +1981,7 @@ function Dr(t, e, n) {
1958
1981
  onClick: e.handleRotate,
1959
1982
  disabled: e.status !== "ready",
1960
1983
  title: "Rotate",
1961
- children: /* @__PURE__ */ s(dr, {})
1984
+ children: /* @__PURE__ */ s(hr, {})
1962
1985
  },
1963
1986
  "rotate"
1964
1987
  )
@@ -1974,7 +1997,7 @@ function Dr(t, e, n) {
1974
1997
  onClick: () => e.toggleMarkupTool("highlight"),
1975
1998
  disabled: e.status !== "ready",
1976
1999
  title: "Highlight text — select text to highlight",
1977
- children: /* @__PURE__ */ s(hr, {})
2000
+ children: /* @__PURE__ */ s(ur, {})
1978
2001
  },
1979
2002
  "highlight"
1980
2003
  )
@@ -1990,7 +2013,7 @@ function Dr(t, e, n) {
1990
2013
  onClick: () => e.toggleMarkupTool("underline"),
1991
2014
  disabled: e.status !== "ready",
1992
2015
  title: "Underline text — select text to underline",
1993
- children: /* @__PURE__ */ s(ur, {})
2016
+ children: /* @__PURE__ */ s(fr, {})
1994
2017
  },
1995
2018
  "underline"
1996
2019
  )
@@ -2012,7 +2035,7 @@ function Dr(t, e, n) {
2012
2035
  },
2013
2036
  disabled: e.status !== "ready",
2014
2037
  title: e.hasFixedSignatureFields ? "Create e-signature for a fixed field" : e.pendingSignature ? "Place signature — click on the page, then drag to move" : "Create e-signature",
2015
- children: /* @__PURE__ */ s(pr, {})
2038
+ children: /* @__PURE__ */ s(gr, {})
2016
2039
  },
2017
2040
  "signature"
2018
2041
  )
@@ -2028,7 +2051,7 @@ function Dr(t, e, n) {
2028
2051
  onClick: () => e.toggleMarkupTool("text"),
2029
2052
  disabled: e.status !== "ready",
2030
2053
  title: e.hasFixedTextFields ? "Edit text in predefined areas — click to type" : "Edit PDF text — select words, then change them",
2031
- children: /* @__PURE__ */ s(mr, {})
2054
+ children: /* @__PURE__ */ s(wr, {})
2032
2055
  },
2033
2056
  "text"
2034
2057
  )
@@ -2044,7 +2067,7 @@ function Dr(t, e, n) {
2044
2067
  onClick: () => e.toggleMarkupTool("erase"),
2045
2068
  disabled: e.status !== "ready",
2046
2069
  title: "Remove text — select PDF words to cover them, or click added markup",
2047
- children: /* @__PURE__ */ s(fr, {})
2070
+ children: /* @__PURE__ */ s(pr, {})
2048
2071
  },
2049
2072
  "erase"
2050
2073
  )
@@ -2075,7 +2098,7 @@ function Dr(t, e, n) {
2075
2098
  className: "epochs-pdf-viewer__btn",
2076
2099
  onClick: () => void e.loadDocument(),
2077
2100
  title: "Reload",
2078
- children: /* @__PURE__ */ s(lr, {})
2101
+ children: /* @__PURE__ */ s(dr, {})
2079
2102
  },
2080
2103
  "reload"
2081
2104
  )
@@ -2091,7 +2114,7 @@ function Dr(t, e, n) {
2091
2114
  onClick: () => void e.handlePrint(),
2092
2115
  disabled: e.status !== "ready" || !e.pdfDoc || e.isPrinting,
2093
2116
  title: e.isPrinting ? "Preparing print…" : "Print (includes highlights & underlines)",
2094
- children: /* @__PURE__ */ s(cr, {})
2117
+ children: /* @__PURE__ */ s(lr, {})
2095
2118
  },
2096
2119
  "print"
2097
2120
  )
@@ -2107,7 +2130,7 @@ function Dr(t, e, n) {
2107
2130
  target: "_blank",
2108
2131
  rel: "noopener noreferrer",
2109
2132
  title: "Open in new tab",
2110
- children: /* @__PURE__ */ s(rr, {})
2133
+ children: /* @__PURE__ */ s(or, {})
2111
2134
  },
2112
2135
  "open"
2113
2136
  )
@@ -2123,7 +2146,7 @@ function Dr(t, e, n) {
2123
2146
  onClick: () => void e.handleDownload(),
2124
2147
  disabled: e.status !== "ready" || !e.pdfDoc || e.isDownloading,
2125
2148
  title: e.isDownloading ? "Preparing download…" : e.annotationsLength > 0 || e.signaturesLength > 0 || e.textsLength > 0 ? "Download PDF with markup" : "Download PDF",
2126
- children: /* @__PURE__ */ s(ir, {})
2149
+ children: /* @__PURE__ */ s(rr, {})
2127
2150
  },
2128
2151
  "download"
2129
2152
  )
@@ -2132,7 +2155,7 @@ function Dr(t, e, n) {
2132
2155
  }
2133
2156
  return i.length > 0 ? i : null;
2134
2157
  }
2135
- function Fr(t, e) {
2158
+ function Rr(t, e) {
2136
2159
  const n = [];
2137
2160
  if (t.markupTool === "sign" && t.pendingSignature && !t.hasFixedSignatureFields && e.has("signature") && n.push(
2138
2161
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__markup-hint", children: "Click page to place duplicate/new signature" }, "sign-hint")
@@ -2141,7 +2164,7 @@ function Fr(t, e) {
2141
2164
  ), t.markupTool === "erase" && e.has("erase") && n.push(
2142
2165
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__markup-hint", children: "Select PDF words to remove · click added text/markup to erase" }, "erase-hint")
2143
2166
  ), t.markupTool === "highlight" && e.has("highlight") || t.markupTool === "underline" && e.has("underline")) {
2144
- const i = t.markupTool === "highlight" ? t.highlightHex : t.underlineHex, r = t.markupTool === "highlight" ? t.setHighlightHex : t.setUnderlineHex, o = t.markupTool === "highlight" ? Dn : 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;
2145
2168
  n.push(
2146
2169
  /* @__PURE__ */ T(
2147
2170
  "div",
@@ -2154,12 +2177,12 @@ function Fr(t, e) {
2154
2177
  "button",
2155
2178
  {
2156
2179
  type: "button",
2157
- className: ce(i) === ce(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",
2158
2181
  style: { background: d.hex },
2159
2182
  title: d.label,
2160
2183
  "aria-label": d.label,
2161
- "aria-pressed": ce(i) === ce(d.hex),
2162
- onClick: () => r(ce(d.hex))
2184
+ "aria-pressed": le(i) === le(d.hex),
2185
+ onClick: () => r(le(d.hex))
2163
2186
  },
2164
2187
  d.id
2165
2188
  )),
@@ -2180,8 +2203,8 @@ function Fr(t, e) {
2180
2203
  "input",
2181
2204
  {
2182
2205
  type: "color",
2183
- value: ce(i),
2184
- onChange: (d) => r(ce(d.target.value)),
2206
+ value: le(i),
2207
+ onChange: (d) => r(le(d.target.value)),
2185
2208
  "aria-label": "Custom color"
2186
2209
  }
2187
2210
  )
@@ -2196,16 +2219,16 @@ function Fr(t, e) {
2196
2219
  }
2197
2220
  return n.length > 0 ? n : null;
2198
2221
  }
2199
- function Rr(t, e) {
2222
+ function Ar(t, e) {
2200
2223
  if (!t) return null;
2201
2224
  if (Array.isArray(t)) {
2202
- const o = (d) => (d ?? []).filter(Tr).map(In);
2225
+ const o = (d) => (d ?? []).filter(Dr).map(Ln);
2203
2226
  return {
2204
2227
  left: o(t[0]),
2205
2228
  right: o(t[1])
2206
2229
  };
2207
2230
  }
2208
- const n = e.enableThumbnails, i = (o, d) => o.map(In).filter((u) => d[u] !== !1), r = {
2231
+ const n = e.enableThumbnails, i = (o, d) => o.map(Ln).filter((u) => d[u] !== !1), r = {
2209
2232
  thumbnail: n,
2210
2233
  navigation: e.enableNavigation,
2211
2234
  zoom: e.enableZoom,
@@ -2222,11 +2245,11 @@ function Rr(t, e) {
2222
2245
  clear: e.enableClear
2223
2246
  };
2224
2247
  return {
2225
- left: i(Tn[0], r),
2226
- right: i(Tn[1], r)
2248
+ left: i(Fn[0], r),
2249
+ right: i(Fn[1], r)
2227
2250
  };
2228
2251
  }
2229
- function ro({
2252
+ function oo({
2230
2253
  file: t,
2231
2254
  fileUrl: e,
2232
2255
  baseUrl: n = "",
@@ -2238,75 +2261,75 @@ function ro({
2238
2261
  thumbnailWidth: m = 140,
2239
2262
  maxThumbnails: g = 60,
2240
2263
  className: _,
2241
- workerSrc: w,
2264
+ workerSrc: y,
2242
2265
  enableToolbar: b = !1,
2243
2266
  enableThumbnails: x,
2244
- enableNavigation: C = !0,
2267
+ enableNavigation: I = !0,
2245
2268
  enableZoom: S = !0,
2246
2269
  enableRotate: H = !0,
2247
- enableReload: O = !0,
2248
- enablePrint: E = !0,
2249
- enableOpen: I = !0,
2250
- enableDownload: et = !0,
2270
+ enableReload: W = !0,
2271
+ enablePrint: A = !0,
2272
+ enableOpen: C = !0,
2273
+ enableDownload: nt = !0,
2251
2274
  enableMarkup: at = !0,
2252
- enableHighlight: Y = !0,
2275
+ enableHighlight: q = !0,
2253
2276
  enableUnderline: pt = !0,
2254
2277
  enableSignature: J = !0,
2255
2278
  enableText: Mt = !0,
2256
- enableErase: Z = !0,
2257
- enableClear: Lt = !0,
2258
- signatureFields: _t = [],
2259
- textFields: U = [],
2279
+ enableErase: K = !0,
2280
+ enableClear: Et = !0,
2281
+ signatureFields: vt = [],
2282
+ textFields: E = [],
2260
2283
  onSignatureComplete: ct,
2261
- onSignatureFieldsChange: ft,
2284
+ onSignatureFieldsChange: ut,
2262
2285
  applySignatureToSameTag: gt = !1,
2263
2286
  onFieldValueComplete: tt,
2264
2287
  openSignaturePad: kt = !1,
2265
- onSignaturePadClose: lt,
2288
+ onSignaturePadClose: dt,
2266
2289
  onSubmit: te,
2267
- submitLabel: me = "Submit",
2268
- submitLoading: St = !1
2290
+ submitLabel: ye = "Submit",
2291
+ submitLoading: Vt = !1
2269
2292
  }) {
2270
- var _n, vn;
2271
- const Ut = xt(null), Dt = xt(null), X = xt(/* @__PURE__ */ new Map()), qt = xt(!1), Ft = xe(() => t && typeof t != "string" ? t : null, [t]), wt = xe(() => Ft ? "" : vr(typeof t == "string" ? t : void 0, e, n), [Ft, t, e, n]), [st, Ht] = z("idle"), [nt, yt] = z(null), [Ct, ee] = z(0), [it, re] = z(1), [f, F] = z(d), [A, dt] = z(0), [ht, Vt] = z(null), [Yt, Kt] = z(!1), [ne, a] = z(!1), [y, v] = z(!1), [M, D] = z("none"), [P, R] = z([]), [k, B] = z([]), [G, L] = z([]), [rt, q] = z(!1), [ut, vt] = z(void 0), [Xt, Nt] = z({}), [Rt, At] = z(null), [Zt, It] = z(
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(
2272
2295
  null
2273
- ), [bt, Qt] = z(
2296
+ ), [_t, Ut] = O(
2274
2297
  null
2275
- ), [oe, Gt] = z(null), [se, Et] = z(null), [le, Pe] = z(null), [ai, Ee] = z(null), [ln, ci] = z(Rn), [dn, li] = z(Wi), $e = U.length > 0, [zt, Se] = z({}), [j, Xe] = z(_t), we = xt(j);
2276
- we.current = j, Tt(() => {
2277
- we.current = _t, Xe(_t), Se((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) => {
2278
2301
  const h = { ...c };
2279
- for (const l of _t) {
2302
+ for (const l of vt) {
2280
2303
  const p = l.type ?? "sign";
2281
2304
  (p === "date" || p === "text") && l.value != null && l.value !== "" && (h[l.id] = l.value);
2282
2305
  }
2283
2306
  return h;
2284
2307
  });
2285
- }, [_t]);
2286
- const jt = j.length > 0, Ce = K(
2308
+ }, [vt]);
2309
+ const jt = B.length > 0, De = Y(
2287
2310
  (c, h, l) => {
2288
- var N;
2311
+ var k;
2289
2312
  const p = c.type ?? "sign";
2290
- return p === "date" || p === "text" ? !!((N = l[c.id] ?? c.value) != null && N.trim()) : h.some(($) => $.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;
2291
2314
  },
2292
2315
  []
2293
- ), hn = K(
2316
+ ), pn = Y(
2294
2317
  (c, h) => {
2295
- const l = new Set(c), N = we.current.map(
2318
+ const l = new Set(c), k = ve.current.map(
2296
2319
  ($) => l.has($.id) ? { ...$, value: h } : $
2297
2320
  );
2298
- we.current = N, Xe(N), ft == null || ft(N), Se(($) => {
2299
- const W = { ...$ };
2300
- for (const ot of c) W[ot] = h;
2301
- return W;
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;
2302
2325
  });
2303
2326
  for (const $ of c)
2304
2327
  tt == null || tt($, h);
2305
2328
  },
2306
- [tt, ft]
2307
- ), Ie = K(
2329
+ [tt, ut]
2330
+ ), Le = Y(
2308
2331
  (c, h, l) => {
2309
- const p = we.current, N = c == null ? null : Array.isArray(c) ? c : [c], $ = N ? new Set(N) : null, W = $ ? p.map(
2332
+ const p = ve.current, k = c == null ? null : Array.isArray(c) ? c : [c], $ = k ? new Set(k) : null, z = $ ? p.map(
2310
2333
  (ot) => $.has(ot.id) ? { ...ot, signatureDataUrl: h.imageDataUrl } : ot
2311
2334
  ) : [
2312
2335
  ...p,
@@ -2321,126 +2344,126 @@ function ro({
2321
2344
  signatureDataUrl: h.imageDataUrl
2322
2345
  }
2323
2346
  ];
2324
- if (we.current = W, Xe(W), ft == null || ft(W), !N || N.length === 0) {
2347
+ if (ve.current = z, Ke(z), ut == null || ut(z), !k || k.length === 0) {
2325
2348
  ct == null || ct(void 0, h);
2326
2349
  return;
2327
2350
  }
2328
- for (const ot of N)
2351
+ for (const ot of k)
2329
2352
  ct == null || ct(
2330
2353
  ot,
2331
2354
  (l == null ? void 0 : l.get(ot)) ?? h
2332
2355
  );
2333
2356
  },
2334
- [ct, ft]
2357
+ [ct, ut]
2335
2358
  );
2336
- Tt(() => {
2337
- kt && q(!0);
2359
+ Dt(() => {
2360
+ kt && X(!0);
2338
2361
  }, [kt]);
2339
- const de = xe(
2340
- () => Rr(b, {
2362
+ const ue = Pe(
2363
+ () => Ar(b, {
2341
2364
  enableThumbnails: x,
2342
- enableNavigation: C,
2365
+ enableNavigation: I,
2343
2366
  enableZoom: S,
2344
2367
  enableRotate: H,
2345
- enableReload: O,
2346
- enablePrint: E,
2347
- enableOpen: I,
2348
- enableDownload: et,
2349
- enableHighlight: Y,
2368
+ enableReload: W,
2369
+ enablePrint: A,
2370
+ enableOpen: C,
2371
+ enableDownload: nt,
2372
+ enableHighlight: q,
2350
2373
  enableUnderline: pt,
2351
2374
  enableSignature: J,
2352
2375
  enableText: Mt,
2353
- enableErase: Z,
2354
- enableClear: Lt
2376
+ enableErase: K,
2377
+ enableClear: Et
2355
2378
  }),
2356
2379
  [
2357
2380
  b,
2358
2381
  x,
2359
- C,
2382
+ I,
2360
2383
  S,
2361
2384
  H,
2362
- O,
2363
- E,
2364
- I,
2365
- et,
2366
- Y,
2385
+ W,
2386
+ A,
2387
+ C,
2388
+ nt,
2389
+ q,
2367
2390
  pt,
2368
2391
  J,
2369
2392
  Mt,
2370
- Z,
2371
- Lt
2393
+ K,
2394
+ Et
2372
2395
  ]
2373
- ), he = xe(() => de ? /* @__PURE__ */ new Set([...de.left, ...de.right]) : /* @__PURE__ */ new Set(), [de]);
2374
- Tt(() => {
2375
- if (!he.has("thumbnail")) {
2376
- Kt(!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);
2377
2400
  return;
2378
2401
  }
2379
2402
  const h = window.matchMedia("(max-width: 720px)"), l = () => {
2380
- Kt(h.matches ? !1 : u);
2403
+ Zt(h.matches ? !1 : u);
2381
2404
  };
2382
2405
  return l(), h.addEventListener("change", l), () => h.removeEventListener("change", l);
2383
- }, [he, u]);
2384
- const un = !jt && he.has("highlight"), fn = !jt && he.has("underline"), Ge = he.has("signature") || jt, pn = he.has("text") || $e, gn = !jt && he.has("erase"), Te = K(() => {
2385
- Dt.current && (URL.revokeObjectURL(Dt.current), Dt.current = null);
2386
- }, []), qe = K(async () => {
2387
- if (!(!Ft && !wt)) {
2388
- _r(w), Ht("loading"), yt(null), ee(0), re(1), R([]), B([]), L([]), At(null), It(null), Qt(null), Gt(null), Et(null), Pe(null), Ee(null), D("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");
2389
2412
  try {
2390
- const c = Ft ? await Nn(Ft, i) : await Nn(wt, i), h = new Blob([c], { type: "application/pdf" }), l = URL.createObjectURL(h);
2391
- Te(), Dt.current = l, Vt(l);
2392
- const N = await ke.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({
2393
2416
  data: c,
2394
- cMapUrl: `https://unpkg.com/pdfjs-dist@${ke.version}/cmaps/`,
2417
+ cMapUrl: `https://unpkg.com/pdfjs-dist@${Ie.version}/cmaps/`,
2395
2418
  cMapPacked: !0,
2396
- standardFontDataUrl: `https://unpkg.com/pdfjs-dist@${ke.version}/standard_fonts/`
2419
+ standardFontDataUrl: `https://unpkg.com/pdfjs-dist@${Ie.version}/standard_fonts/`
2397
2420
  }).promise;
2398
- yt(N), ee(N.numPages), Ht("ready");
2421
+ mt(k), ee(k.numPages), Wt("ready");
2399
2422
  } catch {
2400
- Ht("error");
2423
+ Wt("error");
2401
2424
  }
2402
2425
  }
2403
2426
  }, [
2404
- Ft,
2405
- wt,
2427
+ yt,
2428
+ bt,
2406
2429
  i,
2407
- Te,
2408
- w
2430
+ Fe,
2431
+ y
2409
2432
  ]);
2410
- Tt(() => {
2411
- if (!Ft && !wt) {
2412
- Ht("idle"), yt(null), ee(0), Vt(null), Te();
2433
+ Dt(() => {
2434
+ if (!yt && !bt) {
2435
+ Wt("idle"), mt(null), ee(0), rt(null), Fe();
2413
2436
  return;
2414
2437
  }
2415
- return qe(), () => {
2416
- Te();
2438
+ return Qe(), () => {
2439
+ Fe();
2417
2440
  };
2418
- }, [Ft, wt, qe, Te]), Tt(() => {
2419
- (M === "highlight" && !un || M === "underline" && !fn || M === "sign" && !Ge || M === "text" && !pn || M === "erase" && !gn) && D("none");
2420
- }, [un, fn, Ge, pn, gn, M]);
2421
- const ye = 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(
2422
2445
  (c) => {
2423
- const h = Math.max(1, Math.min(Ct || 1, c)), l = X.current.get(h);
2446
+ const h = Math.max(1, Math.min(It || 1, c)), l = G.current.get(h);
2424
2447
  if (!l) {
2425
- re(h);
2448
+ ne(h);
2426
2449
  return;
2427
2450
  }
2428
- qt.current = !0, l.scrollIntoView({ behavior: "smooth", block: "start" }), re(h), window.setTimeout(() => {
2429
- qt.current = !1;
2451
+ $t.current = !0, l.scrollIntoView({ behavior: "smooth", block: "start" }), ne(h), window.setTimeout(() => {
2452
+ $t.current = !1;
2430
2453
  }, 500);
2431
2454
  },
2432
- [Ct]
2433
- ), be = K(
2455
+ [It]
2456
+ ), Me = Y(
2434
2457
  (c) => {
2435
- const h = X.current.get(c.pageNumber);
2436
- h && (qt.current = !0, re(c.pageNumber));
2458
+ const h = G.current.get(c.pageNumber);
2459
+ h && ($t.current = !0, ne(c.pageNumber));
2437
2460
  const l = () => {
2438
- var N;
2439
- const p = (N = Ut.current) == null ? void 0 : N.querySelector(
2461
+ var k;
2462
+ const p = (k = qt.current) == null ? void 0 : k.querySelector(
2440
2463
  `[data-signature-field-id="${CSS.escape(c.id)}"]`
2441
2464
  );
2442
2465
  p ? p.scrollIntoView({ behavior: "smooth", block: "center" }) : h && h.scrollIntoView({ behavior: "smooth", block: "start" }), window.setTimeout(() => {
2443
- qt.current = !1;
2466
+ $t.current = !1;
2444
2467
  }, 500);
2445
2468
  };
2446
2469
  window.requestAnimationFrame(() => {
@@ -2449,78 +2472,78 @@ function ro({
2449
2472
  },
2450
2473
  []
2451
2474
  );
2452
- Tt(() => {
2453
- if (st !== "ready" || !Ut.current || !Ct) return;
2454
- const c = Ut.current, h = new IntersectionObserver(
2475
+ Dt(() => {
2476
+ if (it !== "ready" || !qt.current || !It) return;
2477
+ const c = qt.current, h = new IntersectionObserver(
2455
2478
  (l) => {
2456
- if (qt.current) return;
2479
+ if ($t.current) return;
2457
2480
  let p = null;
2458
- for (const N of l) {
2459
- if (!N.isIntersecting) continue;
2481
+ for (const k of l) {
2482
+ if (!k.isIntersecting) continue;
2460
2483
  const $ = Number.parseInt(
2461
- N.target.dataset.pageNumber || "0",
2484
+ k.target.dataset.pageNumber || "0",
2462
2485
  10
2463
2486
  );
2464
- $ && (!p || N.intersectionRatio > p.ratio) && (p = { page: $, ratio: N.intersectionRatio });
2487
+ $ && (!p || k.intersectionRatio > p.ratio) && (p = { page: $, ratio: k.intersectionRatio });
2465
2488
  }
2466
- p && re(p.page);
2489
+ p && ne(p.page);
2467
2490
  },
2468
2491
  {
2469
2492
  root: c,
2470
2493
  threshold: [0.25, 0.5, 0.75]
2471
2494
  }
2472
2495
  );
2473
- for (let l = 1; l <= Ct; l += 1) {
2474
- const p = X.current.get(l);
2496
+ for (let l = 1; l <= It; l += 1) {
2497
+ const p = G.current.get(l);
2475
2498
  p && h.observe(p);
2476
2499
  }
2477
2500
  return () => h.disconnect();
2478
- }, [st, Ct]);
2479
- const Ve = it > 1, Ye = Ct ? it < Ct : !1, di = K(() => {
2480
- Ve && ye(it - 1);
2481
- }, [Ve, it, ye]), hi = K(() => {
2482
- Ye && ye(it + 1);
2483
- }, [Ye, it, ye]), ui = K(() => {
2484
- dt((c) => (c + 90) % 360);
2485
- }, []), fi = K(() => {
2486
- F((c) => Math.max(0.25, Math.round((c - 0.1) * 100) / 100));
2487
- }, []), pi = K(() => {
2488
- F((c) => Math.min(5, Math.round((c + 0.1) * 100) / 100));
2489
- }, []), Ke = K(async () => {
2490
- if (!(!nt || !Ut.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))
2491
2514
  try {
2492
- const h = (await nt.getPage(it)).getViewport({ scale: 1, rotation: A }), p = window.matchMedia("(max-width: 720px)").matches ? 16 : 24, $ = 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(
2493
2516
  0,
2494
- Ut.current.clientWidth - p
2517
+ qt.current.clientWidth - p
2495
2518
  ) / h.width;
2496
- F(Math.max(0.25, Math.min(5, Math.round($ * 100) / 100)));
2519
+ oe(Math.max(0.25, Math.min(5, Math.round($ * 100) / 100)));
2497
2520
  } catch {
2498
2521
  }
2499
- }, [nt, it, A]);
2500
- Tt(() => {
2501
- if (st !== "ready" || !nt || !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;
2502
2525
  let c = !1;
2503
2526
  const h = () => {
2504
- c || Ke();
2527
+ c || en();
2505
2528
  };
2506
2529
  h();
2507
- const l = Ut.current, p = typeof ResizeObserver < "u" && l ? new ResizeObserver(() => h()) : null;
2530
+ const l = qt.current, p = typeof ResizeObserver < "u" && l ? new ResizeObserver(() => h()) : null;
2508
2531
  p == null || p.observe(l);
2509
- const N = window.matchMedia("(max-width: 720px)"), $ = () => {
2510
- N.matches && h();
2532
+ const k = window.matchMedia("(max-width: 720px)"), $ = () => {
2533
+ k.matches && h();
2511
2534
  };
2512
- return N.addEventListener("change", $), () => {
2513
- c = !0, p == null || p.disconnect(), N.removeEventListener("change", $);
2535
+ return k.addEventListener("change", $), () => {
2536
+ c = !0, p == null || p.disconnect(), k.removeEventListener("change", $);
2514
2537
  };
2515
- }, [st, nt, Yt, A, Ke]);
2516
- const mn = xe(() => j.flatMap((c) => {
2538
+ }, [it, st, Lt, f, en]);
2539
+ const bn = Pe(() => B.flatMap((c) => {
2517
2540
  const h = c.type ?? "sign";
2518
2541
  if (h !== "date" && h !== "text") return [];
2519
- const l = (zt[c.id] ?? c.value ?? "").trim();
2542
+ const l = (Xt[c.id] ?? c.value ?? "").trim();
2520
2543
  if (!l) return [];
2521
2544
  const p = Math.max(
2522
2545
  10,
2523
- Math.min(ge, c.height * 0.55)
2546
+ Math.min(we, c.height * 0.55)
2524
2547
  );
2525
2548
  return [
2526
2549
  {
@@ -2533,23 +2556,23 @@ function ro({
2533
2556
  height: Math.max(p * 1.2, c.height - 4),
2534
2557
  value: l,
2535
2558
  fontSize: p,
2536
- color: pe
2559
+ color: me
2537
2560
  }
2538
2561
  ];
2539
- }), [j, zt]), _e = xe(
2540
- () => [...G, ...mn],
2541
- [G, mn]
2542
- ), gi = K(async () => {
2562
+ }), [B, Xt]), ke = Pe(
2563
+ () => [...Z, ...bn],
2564
+ [Z, bn]
2565
+ ), mi = Y(async () => {
2543
2566
  var c;
2544
- if (!(!nt || st !== "ready")) {
2567
+ if (!(!st || it !== "ready")) {
2545
2568
  a(!0);
2546
2569
  try {
2547
- const h = await Pn(nt, {
2570
+ const h = await Cn(st, {
2548
2571
  scale: 1.5,
2549
- rotation: A,
2572
+ rotation: f,
2550
2573
  annotations: P,
2551
- signatures: k,
2552
- texts: _e,
2574
+ signatures: N,
2575
+ texts: ke,
2553
2576
  mimeType: "image/png"
2554
2577
  }), l = document.createElement("iframe");
2555
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);
@@ -2570,25 +2593,25 @@ function ro({
2570
2593
  </head>
2571
2594
  <body></body>
2572
2595
  </html>`), p.close();
2573
- const N = p.body;
2596
+ const k = p.body;
2574
2597
  for (const $ of h) {
2575
- const W = p.createElement("img");
2576
- W.src = $.dataUrl;
2598
+ const z = p.createElement("img");
2599
+ z.src = $.dataUrl;
2577
2600
  const ot = p.createElement("div");
2578
- ot.className = "page", ot.appendChild(W), N.appendChild(ot);
2601
+ ot.className = "page", ot.appendChild(z), k.appendChild(ot);
2579
2602
  }
2580
2603
  await Promise.all(
2581
- Array.from(N.querySelectorAll("img")).map(
2604
+ Array.from(k.querySelectorAll("img")).map(
2582
2605
  ($) => {
2583
- var W;
2584
- return ((W = $.decode) == null ? void 0 : W.call($).catch(() => {
2606
+ var z;
2607
+ return ((z = $.decode) == null ? void 0 : z.call($).catch(() => {
2585
2608
  })) ?? Promise.resolve();
2586
2609
  }
2587
2610
  )
2588
2611
  ), setTimeout(() => {
2589
- var $, W;
2612
+ var $, z;
2590
2613
  try {
2591
- ($ = l.contentWindow) == null || $.focus(), (W = l.contentWindow) == null || W.print();
2614
+ ($ = l.contentWindow) == null || $.focus(), (z = l.contentWindow) == null || z.print();
2592
2615
  } finally {
2593
2616
  setTimeout(() => {
2594
2617
  try {
@@ -2600,125 +2623,125 @@ function ro({
2600
2623
  }, 50);
2601
2624
  } catch {
2602
2625
  try {
2603
- ht ? window.open(ht, "_blank", "noopener,noreferrer") : wt && window.open(wt, "_blank", "noopener,noreferrer");
2626
+ U ? window.open(U, "_blank", "noopener,noreferrer") : bt && window.open(bt, "_blank", "noopener,noreferrer");
2604
2627
  } catch {
2605
2628
  }
2606
2629
  } finally {
2607
2630
  a(!1);
2608
2631
  }
2609
2632
  }
2610
- }, [nt, st, A, o, ht, wt, P, k, _e]), mi = K(async () => {
2611
- if (!nt || st !== "ready") return;
2633
+ }, [st, it, f, o, U, bt, P, N, ke]), wi = Y(async () => {
2634
+ if (!st || it !== "ready") return;
2612
2635
  const c = `${o.replace(/[^\w.-]+/g, "_") || "document"}.pdf`;
2613
- if (!(P.length > 0 || k.length > 0 || _e.length > 0) && ht) {
2614
- sn(
2615
- await fetch(ht).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()),
2616
2639
  c
2617
2640
  );
2618
2641
  return;
2619
2642
  }
2620
2643
  v(!0);
2621
2644
  try {
2622
- const l = await Pn(nt, {
2645
+ const l = await Cn(st, {
2623
2646
  scale: 2,
2624
- rotation: A,
2647
+ rotation: f,
2625
2648
  annotations: P,
2626
- signatures: k,
2627
- texts: _e,
2649
+ signatures: N,
2650
+ texts: ke,
2628
2651
  mimeType: "image/jpeg",
2629
2652
  quality: 0.92
2630
- }), p = Nr(l), N = new Uint8Array(p.byteLength);
2631
- N.set(p), sn(
2632
- new Blob([N], { type: "application/pdf" }),
2653
+ }), p = Pr(l), k = new Uint8Array(p.byteLength);
2654
+ k.set(p), hn(
2655
+ new Blob([k], { type: "application/pdf" }),
2633
2656
  c
2634
2657
  );
2635
2658
  } catch {
2636
- ht && sn(
2637
- await fetch(ht).then((l) => l.blob()),
2659
+ U && hn(
2660
+ await fetch(U).then((l) => l.blob()),
2638
2661
  c
2639
2662
  );
2640
2663
  } finally {
2641
2664
  v(!1);
2642
2665
  }
2643
- }, [nt, st, A, o, ht, P, k, _e]), wi = K((c) => {
2666
+ }, [st, it, f, o, U, P, N, ke]), yi = Y((c) => {
2644
2667
  D((h) => h === c ? "none" : c);
2645
- }, []), yi = M === "highlight" || M === "underline" ? An(M === "highlight" ? ln : M === "underline" ? dn : null, M) : void 0, ve = Zt != null ? k.find((c) => c.id === Zt) ?? null : null, bi = K((c) => {
2646
- R((h) => [...h, c]);
2647
- }, []), _i = K((c) => {
2648
- R((h) => h.filter((l) => l.id !== c));
2649
- }, []), vi = K(() => {
2650
- R([]), B([]), L([]), It(null), Et(null), Pe(null), Ee(null);
2651
- }, []), Ue = K(
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(
2652
2675
  (c, h) => {
2653
- const l = j.findIndex(
2654
- (N) => N.id === c
2655
- ), p = j.slice(l + 1).find((N) => !h.has(N.id)) ?? j.slice(0, Math.max(0, l)).find((N) => !h.has(N.id));
2676
+ const l = B.findIndex(
2677
+ (k) => k.id === c
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));
2656
2679
  if (!p) {
2657
- q(!1), Gt(null);
2680
+ X(!1), Gt(null);
2658
2681
  return;
2659
2682
  }
2660
- Qt(p.id), It(null), Gt(null), vt(p.type ?? "sign"), be(p), window.setTimeout(() => {
2661
- q(!0);
2683
+ Ut(p.id), Pt(null), Gt(null), ft(p.type ?? "sign"), Me(p), window.setTimeout(() => {
2684
+ X(!0);
2662
2685
  }, 350);
2663
2686
  },
2664
- [be, j]
2665
- ), xi = K(
2687
+ [Me, B]
2688
+ ), Mi = Y(
2666
2689
  (c) => {
2667
- vt(c), q(!0);
2690
+ ft(c), X(!0);
2668
2691
  },
2669
2692
  []
2670
- ), Mi = K((c, h) => {
2671
- Se((l) => ({ ...l, [c]: h }));
2672
- }, []), ki = K(
2693
+ ), ki = Y((c, h) => {
2694
+ Ye((l) => ({ ...l, [c]: h }));
2695
+ }, []), Ni = Y(
2673
2696
  (c) => {
2674
- const h = zt[c];
2697
+ const h = Xt[c];
2675
2698
  h && (tt == null || tt(c, h));
2676
- const l = j.findIndex(($) => $.id === c), p = new Set(
2677
- Object.keys(zt).filter(($) => {
2678
- var W;
2679
- return (W = zt[$]) == null ? void 0 : W.trim();
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();
2680
2703
  })
2681
2704
  );
2682
2705
  p.add(c);
2683
- const N = j.slice(l + 1).find(
2684
- ($) => !p.has($.id) && !k.some((W) => W.fieldId === $.id)
2685
- ) ?? j.slice(0, Math.max(0, l)).find(
2686
- ($) => !p.has($.id) && !k.some((W) => W.fieldId === $.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)
2687
2710
  );
2688
- N && (Qt(N.id), be(N));
2711
+ k && (Ut(k.id), Me(k));
2689
2712
  },
2690
- [j, zt, k, be, tt]
2691
- ), Ni = K(
2713
+ [B, Xt, N, Me, tt]
2714
+ ), Pi = Y(
2692
2715
  (c, h, l) => {
2693
- var ue;
2716
+ var pe;
2694
2717
  const p = Xi(h, l);
2695
- if (oe) {
2696
- B(
2718
+ if (Yt) {
2719
+ j(
2697
2720
  (Q) => Q.map(
2698
- (Pt) => Pt.id === oe ? {
2699
- ...Pt,
2721
+ (Ct) => Ct.id === Yt ? {
2722
+ ...Ct,
2700
2723
  imageDataUrl: c,
2701
- width: Pt.fieldId ? Pt.width : p.width,
2702
- height: Pt.fieldId ? Pt.height : p.height
2703
- } : Pt
2724
+ width: Ct.fieldId ? Ct.width : p.width,
2725
+ height: Ct.fieldId ? Ct.height : p.height
2726
+ } : Ct
2704
2727
  )
2705
- ), At(null), D("none"), q(!1), Gt(null);
2728
+ ), At(null), D("none"), X(!1), Gt(null);
2706
2729
  return;
2707
2730
  }
2708
2731
  if (jt) {
2709
- const Q = j.find(
2710
- (V) => V.id === bt && (V.type ?? "sign") === "sign" && !k.some((ae) => ae.fieldId === V.id)
2711
- ) ?? j.find(
2712
- (V) => (V.type ?? "sign") === "sign" && !k.some((ae) => ae.fieldId === V.id)
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)
2713
2736
  );
2714
2737
  if (!Q) {
2715
- q(!1);
2738
+ X(!1);
2716
2739
  return;
2717
2740
  }
2718
- const Pt = gt && Q.signature_tag ? j.filter(
2719
- (V) => (V.type ?? "sign") === "sign" && V.signature_tag === Q.signature_tag && !k.some((ae) => ae.fieldId === V.id)
2720
- ) : [Q], $t = Pt.map((V) => ({
2721
- id: Oe(),
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) => ({
2744
+ id: Se(),
2722
2745
  fieldId: V.id,
2723
2746
  pageNumber: V.pageNumber,
2724
2747
  x: V.x,
@@ -2726,200 +2749,200 @@ function ro({
2726
2749
  width: V.width,
2727
2750
  height: V.height,
2728
2751
  imageDataUrl: c
2729
- })), ie = new Set(Pt.map((V) => V.id));
2730
- B((V) => [
2731
- ...V.filter((ae) => !ae.fieldId || !ie.has(ae.fieldId)),
2732
- ...$t
2752
+ })), re = new Set(Ct.map((V) => V.id));
2753
+ j((V) => [
2754
+ ...V.filter((ce) => !ce.fieldId || !re.has(ce.fieldId)),
2755
+ ...Tt
2733
2756
  ]);
2734
- const fe = new Map(
2735
- $t.map((V) => [V.fieldId, V])
2757
+ const ge = new Map(
2758
+ Tt.map((V) => [V.fieldId, V])
2736
2759
  );
2737
- Ie(
2738
- Pt.map((V) => V.id),
2739
- $t[0],
2740
- fe
2741
- ), At(null), D("none"), It(((ue = $t[0]) == null ? void 0 : ue.id) ?? null);
2742
- const mt = new Set(
2743
- j.filter(
2744
- (V) => Ce(
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(
2745
2768
  V,
2746
- [...k, ...$t],
2747
- zt
2769
+ [...N, ...Tt],
2770
+ Xt
2748
2771
  )
2749
2772
  ).map((V) => V.id)
2750
2773
  );
2751
- for (const V of ie) mt.add(V);
2752
- Ue(Q.id, mt);
2774
+ for (const V of re) wt.add(V);
2775
+ Be(Q.id, wt);
2753
2776
  return;
2754
2777
  }
2755
- const N = X.current.get(it), $ = N == null ? void 0 : N.querySelector(
2778
+ const k = G.current.get(ht), $ = k == null ? void 0 : k.querySelector(
2756
2779
  ".epochs-pdf-viewer__surface"
2757
2780
  );
2758
- let W = 24, ot = 24;
2781
+ let z = 24, ot = 24;
2759
2782
  if ($) {
2760
- const Q = Ne($, f), Pt = $.closest(".epochs-pdf-viewer__body");
2761
- if (Pt) {
2762
- const $t = Mn(
2763
- Pt.getBoundingClientRect(),
2783
+ const Q = Ce($, Nt), Ct = $.closest(".epochs-pdf-viewer__body");
2784
+ if (Ct) {
2785
+ const Tt = Pn(
2786
+ Ct.getBoundingClientRect(),
2764
2787
  $,
2765
- f
2766
- ), ie = Math.max(0, $t.top), fe = Math.min(Q.height, $t.bottom), mt = Math.max(0, $t.left), V = Math.min(Q.width, $t.right);
2767
- W = Math.max(0, (mt + V) / 2 - p.width / 2), ot = Math.max(0, (ie + fe) / 2 - p.height / 2), W = Math.min(W, Math.max(0, Q.width - p.width)), ot = Math.min(ot, Math.max(0, Q.height - p.height));
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));
2768
2791
  } else
2769
- W = Math.max(0, (Q.width - p.width) / 2), ot = Math.max(0, (Q.height - p.height) / 2);
2792
+ z = Math.max(0, (Q.width - p.width) / 2), ot = Math.max(0, (Q.height - p.height) / 2);
2770
2793
  }
2771
2794
  const Ot = {
2772
- id: Oe(),
2773
- pageNumber: it,
2774
- x: W,
2795
+ id: Se(),
2796
+ pageNumber: ht,
2797
+ x: z,
2775
2798
  y: ot,
2776
2799
  width: p.width,
2777
2800
  height: p.height,
2778
2801
  imageDataUrl: c
2779
2802
  };
2780
- B((Q) => [...Q, Ot]), Ie(void 0, Ot), It(Ot.id), At(null), D("none"), q(!1), Gt(null);
2803
+ j((Q) => [...Q, Ot]), Le(void 0, Ot), Pt(Ot.id), At(null), D("none"), X(!1), Gt(null);
2781
2804
  },
2782
2805
  [
2783
- Ue,
2806
+ Be,
2784
2807
  gt,
2785
- oe,
2786
- zt,
2808
+ Yt,
2809
+ Xt,
2787
2810
  jt,
2788
- Ce,
2789
- it,
2790
- f,
2791
- bt,
2792
- j,
2793
- k,
2794
- Ie
2811
+ De,
2812
+ ht,
2813
+ Nt,
2814
+ _t,
2815
+ B,
2816
+ N,
2817
+ Le
2795
2818
  ]
2796
- ), Pi = K(
2819
+ ), $i = Y(
2797
2820
  (c, h) => {
2798
2821
  if (jt) {
2799
- const Q = j.find(
2800
- (mt) => mt.id === bt && (mt.type ?? "sign") === h
2801
- ) ?? j.find((mt) => (mt.type ?? "sign") === h);
2822
+ const Q = B.find(
2823
+ (wt) => wt.id === _t && (wt.type ?? "sign") === h
2824
+ ) ?? B.find((wt) => (wt.type ?? "sign") === h);
2802
2825
  if (!Q) {
2803
- q(!1);
2826
+ X(!1);
2804
2827
  return;
2805
2828
  }
2806
- const $t = (gt && Q.signature_tag ? j.filter(
2807
- (mt) => (mt.type ?? "sign") === h && mt.signature_tag === Q.signature_tag
2808
- ) : [Q]).map((mt) => mt.id);
2809
- hn($t, c);
2810
- const ie = { ...zt };
2811
- for (const mt of $t) ie[mt] = c;
2812
- const fe = new Set(
2813
- j.filter(
2814
- (mt) => Ce(mt, k, ie)
2815
- ).map((mt) => mt.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)
2816
2839
  );
2817
- Ue(Q.id, fe);
2840
+ Be(Q.id, ge);
2818
2841
  return;
2819
2842
  }
2820
- const l = ge, p = Math.max(80, c.length * l * 0.55), N = l * 1.25;
2821
- let $ = 24, W = 24;
2822
- const ot = X.current.get(it), Ot = ot == null ? void 0 : ot.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(
2823
2846
  ".epochs-pdf-viewer__surface"
2824
2847
  );
2825
2848
  if (Ot) {
2826
- const Q = Ne(Ot, f), Pt = Ot.closest(
2849
+ const Q = Ce(Ot, Nt), Ct = Ot.closest(
2827
2850
  ".epochs-pdf-viewer__body"
2828
2851
  );
2829
- if (Pt) {
2830
- const $t = Mn(
2831
- Pt.getBoundingClientRect(),
2852
+ if (Ct) {
2853
+ const Tt = Pn(
2854
+ Ct.getBoundingClientRect(),
2832
2855
  Ot,
2833
- f
2834
- ), ie = Math.max(0, $t.top), fe = Math.min(Q.height, $t.bottom), mt = Math.max(0, $t.left), V = Math.min(Q.width, $t.right);
2835
- $ = Math.max(0, (mt + V) / 2 - p / 2), W = Math.max(0, (ie + fe) / 2 - N / 2), $ = Math.min($, Math.max(0, Q.width - p)), W = Math.min(W, Math.max(0, Q.height - N));
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));
2836
2859
  }
2837
2860
  }
2838
- const ue = {
2839
- id: We(),
2840
- pageNumber: it,
2861
+ const pe = {
2862
+ id: Ge(),
2863
+ pageNumber: ht,
2841
2864
  x: $,
2842
- y: W,
2865
+ y: z,
2843
2866
  width: p,
2844
- height: N,
2867
+ height: k,
2845
2868
  value: c,
2846
2869
  fontSize: l,
2847
- color: pe
2870
+ color: me
2848
2871
  };
2849
- L((Q) => [...Q, ue]), Et(ue.id), q(!1), D("none");
2872
+ R((Q) => [...Q, pe]), se(pe.id), X(!1), D("none");
2850
2873
  },
2851
2874
  [
2852
- Ue,
2875
+ Be,
2853
2876
  gt,
2854
- zt,
2877
+ Xt,
2855
2878
  jt,
2856
- Ce,
2857
- it,
2858
- f,
2859
- bt,
2860
- j,
2861
- k,
2862
- hn
2879
+ De,
2880
+ ht,
2881
+ Nt,
2882
+ _t,
2883
+ B,
2884
+ N,
2885
+ pn
2863
2886
  ]
2864
- ), $i = K((c) => {
2865
- B((h) => [...h, c]), Ie(void 0, c), It(c.id), At(null), D("none");
2866
- }, [Ie]), 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(
2867
2890
  (c, h) => {
2868
- B(
2891
+ j(
2869
2892
  (l) => l.map((p) => p.id === c ? { ...p, ...h } : p)
2870
2893
  );
2871
2894
  },
2872
2895
  []
2873
- ), Ii = K((c) => {
2874
- const h = k.find((l) => l.id === c);
2875
- B((l) => l.filter((p) => p.id !== c)), It((l) => l === c ? null : l), h != null && h.fieldId && Qt(h.fieldId);
2876
- }, [k]), Ti = K((c) => {
2877
- const h = c ? k.find((Ot) => Ot.id === c) ?? null : ve;
2896
+ ), Ti = Y((c) => {
2897
+ const h = N.find((l) => l.id === c);
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;
2878
2901
  if (!h) return;
2879
- const l = X.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(
2880
2903
  ".epochs-pdf-viewer__surface"
2881
- ), N = 18;
2882
- let $ = h.x + N, W = h.y + N;
2904
+ ), k = 18;
2905
+ let $ = h.x + k, z = h.y + k;
2883
2906
  if (p) {
2884
- const Ot = p.clientWidth / f, ue = p.clientHeight / f;
2907
+ const Ot = p.clientWidth / Nt, pe = p.clientHeight / Nt;
2885
2908
  $ = Math.min(
2886
2909
  Math.max(0, $),
2887
2910
  Math.max(0, Ot - h.width)
2888
- ), W = Math.min(
2889
- Math.max(0, W),
2890
- Math.max(0, ue - h.height)
2911
+ ), z = Math.min(
2912
+ Math.max(0, z),
2913
+ Math.max(0, pe - h.height)
2891
2914
  );
2892
2915
  }
2893
2916
  const ot = {
2894
2917
  ...h,
2895
- id: Oe(),
2918
+ id: Se(),
2896
2919
  x: $,
2897
- y: W
2920
+ y: z
2898
2921
  };
2899
- B((Ot) => [...Ot, ot]), It(ot.id), At(null), D("none");
2900
- }, [f, ve, k]), Li = K((c) => {
2901
- const h = c ?? (ve == null ? void 0 : ve.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);
2902
2925
  if (!h) return;
2903
- const l = k.find((N) => N.id === h), p = l != null && l.fieldId ? j.find((N) => N.id === l.fieldId) : void 0;
2904
- vt((p == null ? void 0 : p.type) ?? "sign"), It(h), Gt(h), q(!0);
2905
- }, [ve, k, j]), Di = K((c) => {
2906
- L((h) => c.fieldId ? [...h.filter((l) => l.fieldId !== c.fieldId), c] : [...h, c]), Et(c.id), c.fieldId && Pe(c.fieldId);
2907
- }, []), Fi = 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(
2908
2931
  (c, h) => {
2909
- L(
2932
+ R(
2910
2933
  (l) => l.map((p) => p.id === c ? { ...p, ...h } : p)
2911
2934
  );
2912
2935
  },
2913
2936
  []
2914
- ), Ri = K((c) => {
2915
- const h = G.find((l) => l.id === c);
2916
- L((l) => l.filter((p) => p.id !== c)), Et((l) => l === c ? null : l), Ee((l) => l === c ? null : l), h != null && h.fieldId && Pe(h.fieldId);
2917
- }, [G]);
2918
- Tt(() => {
2919
- $e && L(
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(
2920
2943
  (c) => c.map((h) => {
2921
2944
  if (!h.fieldId) return h;
2922
- const l = U.find((p) => p.id === h.fieldId);
2945
+ const l = E.find((p) => p.id === h.fieldId);
2923
2946
  return l ? {
2924
2947
  ...h,
2925
2948
  pageNumber: l.pageNumber,
@@ -2927,32 +2950,32 @@ function ro({
2927
2950
  y: l.y,
2928
2951
  width: l.width,
2929
2952
  height: l.height,
2930
- fontSize: l.fontSize ?? h.fontSize ?? ge,
2931
- color: l.color ?? h.color ?? pe
2953
+ fontSize: l.fontSize ?? h.fontSize ?? we,
2954
+ color: l.color ?? h.color ?? me
2932
2955
  } : h;
2933
2956
  })
2934
2957
  );
2935
- }, [$e, U]);
2936
- const wn = K(
2958
+ }, [Te, E]);
2959
+ const _n = Y(
2937
2960
  (c) => {
2938
- var N;
2939
- if (!j.length) return;
2940
- const h = bt != null ? j.findIndex(($) => $.id === bt) : -1, l = Math.min(
2941
- j.length - 1,
2961
+ var k;
2962
+ if (!B.length) return;
2963
+ const h = _t != null ? B.findIndex(($) => $.id === _t) : -1, l = Math.min(
2964
+ B.length - 1,
2942
2965
  Math.max(0, (h < 0 ? 0 : h) + c)
2943
- ), p = j[l];
2944
- p && (Qt(p.id), It(
2945
- ((N = k.find(($) => $.fieldId === p.id)) == null ? void 0 : N.id) ?? null
2946
- ), be(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));
2947
2970
  },
2948
2971
  [
2949
- be,
2950
- bt,
2951
- j,
2952
- k
2972
+ Me,
2973
+ _t,
2974
+ B,
2975
+ N
2953
2976
  ]
2954
2977
  );
2955
- if (!Ft && !wt)
2978
+ if (!yt && !bt)
2956
2979
  return /* @__PURE__ */ s(
2957
2980
  "div",
2958
2981
  {
@@ -2961,58 +2984,58 @@ function ro({
2961
2984
  children: "No PDF file provided."
2962
2985
  }
2963
2986
  );
2964
- const Ai = {
2987
+ const Ei = {
2965
2988
  height: r
2966
- }, yn = {
2967
- status: st,
2968
- showThumbnails: Yt,
2969
- setShowThumbnails: Kt,
2970
- canGoPrev: Ve,
2971
- canGoNext: Ye,
2972
- handlePrev: di,
2973
- handleNext: hi,
2974
- pageNumber: it,
2975
- numPages: Ct,
2976
- scrollToPage: ye,
2977
- scale: f,
2978
- handleZoomOut: fi,
2979
- handleZoomIn: pi,
2980
- handleFitWidth: Ke,
2981
- handleRotate: ui,
2989
+ }, vn = {
2990
+ status: it,
2991
+ showThumbnails: Lt,
2992
+ setShowThumbnails: Zt,
2993
+ canGoPrev: Je,
2994
+ canGoNext: tn,
2995
+ handlePrev: hi,
2996
+ handleNext: ui,
2997
+ pageNumber: ht,
2998
+ numPages: It,
2999
+ scrollToPage: xe,
3000
+ scale: Nt,
3001
+ handleZoomOut: pi,
3002
+ handleZoomIn: gi,
3003
+ handleFitWidth: en,
3004
+ handleRotate: fi,
2982
3005
  markupTool: M,
2983
- toggleMarkupTool: (c) => wi(c),
3006
+ toggleMarkupTool: (c) => yi(c),
2984
3007
  hasFixedSignatureFields: jt,
2985
- hasFixedTextFields: $e,
2986
- pendingSignature: Rt,
3008
+ hasFixedTextFields: Te,
3009
+ pendingSignature: Ht,
2987
3010
  setMarkupTool: D,
2988
- setSignaturePadOpen: q,
3011
+ setSignaturePadOpen: X,
2989
3012
  annotationsLength: P.length,
2990
- signaturesLength: k.length,
2991
- textsLength: G.length,
2992
- handleClearAnnotations: vi,
2993
- highlightHex: ln,
2994
- underlineHex: dn,
2995
- setHighlightHex: ci,
2996
- setUnderlineHex: li,
2997
- loadDocument: qe,
2998
- handlePrint: gi,
2999
- isPrinting: ne,
3000
- pdfDoc: nt,
3001
- displayUrl: ht,
3002
- resolvedUrl: wt,
3003
- handleDownload: mi,
3004
- isDownloading: y
3005
- }, Ei = (c) => c.filter((h) => !(jt && (h === "highlight" || h === "underline" || h === "erase"))), Ze = bt ? j.findIndex((c) => c.id === bt) : 0, Ui = j.filter(
3006
- (c) => Ce(c, k, zt)
3007
- ).length, Qe = j.length > 0 ? Math.round(Ui / j.length * 100) : 0, bn = (c, h = !1) => {
3008
- const l = Ei(c);
3013
+ signaturesLength: N.length,
3014
+ textsLength: Z.length,
3015
+ handleClearAnnotations: xi,
3016
+ highlightHex: _e,
3017
+ underlineHex: ae,
3018
+ setHighlightHex: Qt,
3019
+ setUnderlineHex: di,
3020
+ loadDocument: Qe,
3021
+ handlePrint: mi,
3022
+ isPrinting: ie,
3023
+ pdfDoc: st,
3024
+ displayUrl: U,
3025
+ resolvedUrl: bt,
3026
+ handleDownload: wi,
3027
+ isDownloading: w
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);
3009
3032
  if (l.length === 0 && !h)
3010
3033
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__toolbar-group" });
3011
3034
  if (l.length === 0)
3012
3035
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__toolbar-group epochs-pdf-viewer__toolbar-group--end" });
3013
- const p = l.map((N, $) => {
3014
- const W = l[$ - 1], ot = Ln(N) && (!W || !Ln(W));
3015
- return /* @__PURE__ */ s(Bi, { children: Dr(N, yn, { showMarkupSep: ot }) }, N);
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);
3016
3039
  });
3017
3040
  return /* @__PURE__ */ T(
3018
3041
  "div",
@@ -3020,7 +3043,7 @@ function ro({
3020
3043
  className: h ? "epochs-pdf-viewer__toolbar-group epochs-pdf-viewer__toolbar-group--end" : "epochs-pdf-viewer__toolbar-group",
3021
3044
  children: [
3022
3045
  p,
3023
- Fr(yn, new Set(l))
3046
+ Rr(vn, new Set(l))
3024
3047
  ]
3025
3048
  }
3026
3049
  );
@@ -3029,69 +3052,69 @@ function ro({
3029
3052
  "div",
3030
3053
  {
3031
3054
  "data-testid": "pdf-viewer",
3032
- "data-file-url": wt || void 0,
3055
+ "data-file-url": bt || void 0,
3033
3056
  className: `epochs-pdf-viewer ${_ ?? ""}`.trim(),
3034
- style: Ai,
3057
+ style: Ei,
3035
3058
  children: [
3036
- de ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__toolbar", children: [
3037
- bn(de.left),
3038
- bn(de.right, !0)
3059
+ ue ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__toolbar", children: [
3060
+ xn(ue.left),
3061
+ xn(ue.right, !0)
3039
3062
  ] }) : null,
3040
- Ge || kt || jt ? /* @__PURE__ */ s(
3063
+ Ze || kt || jt ? /* @__PURE__ */ s(
3041
3064
  Cr,
3042
3065
  {
3043
- open: rt,
3066
+ open: lt,
3044
3067
  onClose: () => {
3045
- q(!1), Gt(null), vt(void 0), lt == null || lt();
3068
+ X(!1), Gt(null), ft(void 0), dt == null || dt();
3046
3069
  },
3047
- onSave: Ni,
3048
- onSaveFieldValue: Pi,
3049
- fieldType: ut,
3070
+ onSave: Pi,
3071
+ onSaveFieldValue: $i,
3072
+ fieldType: et,
3050
3073
  showFieldTypeTabs: !jt,
3051
- textPlaceholder: (_n = j.find((c) => c.id === bt)) == null ? void 0 : _n.placeholder,
3052
- initialFieldValue: bt ? zt[bt] ?? ((vn = j.find((c) => c.id === bt)) == null ? void 0 : vn.value) : void 0,
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,
3053
3076
  targetSize: (() => {
3054
- const c = j.find(
3055
- (h) => h.id === bt
3077
+ const c = B.find(
3078
+ (h) => h.id === _t
3056
3079
  );
3057
3080
  if (!(!c || (c.type ?? "sign") !== "sign"))
3058
3081
  return { width: c.width, height: c.height };
3059
3082
  })(),
3060
- rememberedByType: Xt,
3083
+ rememberedByType: Ft,
3061
3084
  onRememberFill: (c, h) => {
3062
- Nt((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 });
3063
3086
  }
3064
3087
  }
3065
3088
  ) : null,
3066
3089
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__content", children: [
3067
- Yt ? /* @__PURE__ */ s(
3090
+ Lt ? /* @__PURE__ */ s(
3068
3091
  "div",
3069
3092
  {
3070
3093
  className: "epochs-pdf-viewer__thumbnails",
3071
3094
  style: { width: m + 24 },
3072
- children: st === "ready" && nt ? /* @__PURE__ */ T(Ae, { children: [
3095
+ children: it === "ready" && st ? /* @__PURE__ */ T(je, { children: [
3073
3096
  Array.from({
3074
- length: Math.min(Ct || 0, g)
3097
+ length: Math.min(It || 0, g)
3075
3098
  }).map((c, h) => {
3076
3099
  const l = h + 1;
3077
3100
  return /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__thumb-wrap", children: /* @__PURE__ */ s(
3078
- yr,
3101
+ br,
3079
3102
  {
3080
- pdfDoc: nt,
3103
+ pdfDoc: st,
3081
3104
  pageNumber: l,
3082
- isActive: l === it,
3083
- rotation: A,
3084
- onSelect: ye,
3105
+ isActive: l === ht,
3106
+ rotation: f,
3107
+ onSelect: xe,
3085
3108
  width: m,
3086
3109
  annotations: P,
3087
- signatures: k,
3088
- signatureFields: j,
3089
- texts: _e,
3090
- textFields: U
3110
+ signatures: N,
3111
+ signatureFields: B,
3112
+ texts: ke,
3113
+ textFields: E
3091
3114
  }
3092
3115
  ) }, l);
3093
3116
  }),
3094
- Ct > g ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__thumb-more", children: [
3117
+ It > g ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__thumb-more", children: [
3095
3118
  "Showing first ",
3096
3119
  g,
3097
3120
  " pages"
@@ -3099,69 +3122,69 @@ function ro({
3099
3122
  ] }) : /* @__PURE__ */ s("div", { className: "epochs-pdf-viewer__muted", children: "Thumbnails" })
3100
3123
  }
3101
3124
  ) : null,
3102
- /* @__PURE__ */ T("div", { ref: Ut, className: "epochs-pdf-viewer__body", children: [
3103
- st === "loading" ? /* @__PURE__ */ T("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: [
3104
3127
  "Loading PDF…",
3105
3128
  /* @__PURE__ */ s("span", { className: "epochs-pdf-viewer__spinner" })
3106
3129
  ] }) : null,
3107
- st === "error" ? /* @__PURE__ */ T("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: [
3108
3131
  "Unable to load PDF.",
3109
- wt ? /* @__PURE__ */ s(
3132
+ bt ? /* @__PURE__ */ s(
3110
3133
  "a",
3111
3134
  {
3112
3135
  className: "epochs-pdf-viewer__open-link",
3113
- href: wt,
3136
+ href: bt,
3114
3137
  target: "_blank",
3115
3138
  rel: "noopener noreferrer",
3116
3139
  children: "Open file"
3117
3140
  }
3118
3141
  ) : null
3119
3142
  ] }) : null,
3120
- st === "ready" && nt ? /* @__PURE__ */ s("div", { children: Array.from({ length: Ct }).map((c, h) => {
3143
+ it === "ready" && st ? /* @__PURE__ */ s("div", { children: Array.from({ length: It }).map((c, h) => {
3121
3144
  const l = h + 1;
3122
3145
  return /* @__PURE__ */ s(
3123
- wr,
3146
+ yr,
3124
3147
  {
3125
- pdfDoc: nt,
3148
+ pdfDoc: st,
3126
3149
  pageNumber: l,
3127
- scale: f,
3128
- rotation: A,
3150
+ scale: Nt,
3151
+ rotation: f,
3129
3152
  markupTool: at ? M : "none",
3130
- markupColor: yi,
3153
+ markupColor: bi,
3131
3154
  annotations: P,
3132
- onAddAnnotation: bi,
3133
- onRemoveAnnotation: _i,
3134
- signatures: k,
3135
- pendingSignature: Rt,
3136
- onAddSignature: $i,
3155
+ onAddAnnotation: _i,
3156
+ onRemoveAnnotation: vi,
3157
+ signatures: N,
3158
+ pendingSignature: Ht,
3159
+ onAddSignature: Ii,
3137
3160
  onUpdateSignature: Ci,
3138
- onRemoveSignature: Ii,
3161
+ onRemoveSignature: Ti,
3139
3162
  onEditSignature: Li,
3140
- onDuplicateSignature: Ti,
3141
- selectedSignatureId: Zt,
3142
- onSelectSignature: It,
3143
- signatureFields: j,
3144
- selectedSignatureFieldId: bt,
3145
- onSelectSignatureField: Qt,
3163
+ onDuplicateSignature: Di,
3164
+ selectedSignatureId: St,
3165
+ onSelectSignature: Pt,
3166
+ signatureFields: B,
3167
+ selectedSignatureFieldId: _t,
3168
+ onSelectSignatureField: Ut,
3146
3169
  hasFixedSignatureFields: jt,
3147
- onOpenSignaturePad: xi,
3148
- fieldValues: zt,
3149
- onFieldValueChange: Mi,
3150
- onFieldValueCommit: ki,
3151
- texts: G,
3152
- onAddText: Di,
3153
- onUpdateText: Fi,
3154
- onRemoveText: Ri,
3155
- selectedTextId: se,
3156
- onSelectText: Et,
3157
- textFields: U,
3158
- selectedTextFieldId: le,
3159
- onSelectTextField: Pe,
3160
- hasFixedTextFields: $e,
3161
- editingTextId: ai,
3162
- onEditingTextIdChange: Ee,
3170
+ onOpenSignaturePad: Mi,
3171
+ fieldValues: Xt,
3172
+ onFieldValueChange: ki,
3173
+ onFieldValueCommit: Ni,
3174
+ texts: Z,
3175
+ onAddText: Fi,
3176
+ onUpdateText: Ri,
3177
+ onRemoveText: Ai,
3178
+ selectedTextId: be,
3179
+ onSelectText: se,
3180
+ textFields: E,
3181
+ selectedTextFieldId: Ve,
3182
+ onSelectTextField: de,
3183
+ hasFixedTextFields: Te,
3184
+ editingTextId: qe,
3185
+ onEditingTextIdChange: he,
3163
3186
  pageRef: (p) => {
3164
- p && X.current.set(l, p);
3187
+ p && G.current.set(l, p);
3165
3188
  }
3166
3189
  },
3167
3190
  l
@@ -3170,15 +3193,15 @@ function ro({
3170
3193
  ] })
3171
3194
  ] }),
3172
3195
  jt || te ? /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer", role: "navigation", "aria-label": "Viewer actions", children: [
3173
- jt ? /* @__PURE__ */ T(Ae, { children: [
3196
+ jt ? /* @__PURE__ */ T(je, { children: [
3174
3197
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-nav", children: [
3175
3198
  /* @__PURE__ */ s(
3176
3199
  "button",
3177
3200
  {
3178
3201
  type: "button",
3179
3202
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
3180
- disabled: j.length <= 1 || Ze <= 0,
3181
- onClick: () => wn(-1),
3203
+ disabled: B.length <= 1 || nn <= 0,
3204
+ onClick: () => _n(-1),
3182
3205
  children: "Prev"
3183
3206
  }
3184
3207
  ),
@@ -3187,8 +3210,8 @@ function ro({
3187
3210
  {
3188
3211
  type: "button",
3189
3212
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text",
3190
- disabled: j.length <= 1 || Ze >= j.length - 1,
3191
- onClick: () => wn(1),
3213
+ disabled: B.length <= 1 || nn >= B.length - 1,
3214
+ onClick: () => _n(1),
3192
3215
  children: "Next"
3193
3216
  }
3194
3217
  )
@@ -3196,9 +3219,9 @@ function ro({
3196
3219
  /* @__PURE__ */ T("div", { className: "epochs-pdf-viewer__footer-center", children: [
3197
3220
  /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__footer-label", children: [
3198
3221
  "Field ",
3199
- Math.max(1, Ze + 1),
3222
+ Math.max(1, nn + 1),
3200
3223
  " of ",
3201
- j.length
3224
+ B.length
3202
3225
  ] }),
3203
3226
  /* @__PURE__ */ s(
3204
3227
  "div",
@@ -3207,19 +3230,19 @@ function ro({
3207
3230
  role: "progressbar",
3208
3231
  "aria-valuemin": 0,
3209
3232
  "aria-valuemax": 100,
3210
- "aria-valuenow": Qe,
3233
+ "aria-valuenow": rn,
3211
3234
  "aria-label": "Signature progress",
3212
3235
  children: /* @__PURE__ */ s(
3213
3236
  "div",
3214
3237
  {
3215
3238
  className: "epochs-pdf-viewer__footer-progress-bar",
3216
- style: { width: `${Qe}%` }
3239
+ style: { width: `${rn}%` }
3217
3240
  }
3218
3241
  )
3219
3242
  }
3220
3243
  ),
3221
3244
  /* @__PURE__ */ T("span", { className: "epochs-pdf-viewer__footer-percent", children: [
3222
- Qe,
3245
+ rn,
3223
3246
  "%"
3224
3247
  ] })
3225
3248
  ] })
@@ -3230,17 +3253,17 @@ function ro({
3230
3253
  type: "button",
3231
3254
  className: "epochs-pdf-viewer__btn epochs-pdf-viewer__btn--text epochs-pdf-viewer__btn--primary",
3232
3255
  onClick: te,
3233
- disabled: St,
3234
- "aria-busy": St || void 0,
3256
+ disabled: Vt,
3257
+ "aria-busy": Vt || void 0,
3235
3258
  children: [
3236
- St ? /* @__PURE__ */ s(
3259
+ Vt ? /* @__PURE__ */ s(
3237
3260
  "span",
3238
3261
  {
3239
3262
  className: "epochs-pdf-viewer__spinner epochs-pdf-viewer__spinner--btn",
3240
3263
  "aria-hidden": "true"
3241
3264
  }
3242
3265
  ) : null,
3243
- me
3266
+ ye
3244
3267
  ]
3245
3268
  }
3246
3269
  ) : null
@@ -3249,30 +3272,30 @@ function ro({
3249
3272
  }
3250
3273
  );
3251
3274
  }
3252
- function Ar(t) {
3275
+ function Er(t) {
3253
3276
  return null;
3254
3277
  }
3255
- Ar.displayName = "Document";
3256
- function Er(t) {
3278
+ Er.displayName = "Document";
3279
+ function Hr(t) {
3257
3280
  return null;
3258
3281
  }
3259
- Er.displayName = "Page";
3282
+ Hr.displayName = "Page";
3260
3283
  function Ur(t) {
3261
3284
  return null;
3262
3285
  }
3263
3286
  Ur.displayName = "View";
3264
- function Hr(t) {
3265
- return null;
3266
- }
3267
- Hr.displayName = "Text";
3268
3287
  function jr(t) {
3269
3288
  return null;
3270
3289
  }
3271
- jr.displayName = "Image";
3290
+ jr.displayName = "Text";
3272
3291
  function Br(t) {
3273
3292
  return null;
3274
3293
  }
3275
- Br.displayName = "Link";
3294
+ Br.displayName = "Image";
3295
+ function Wr(t) {
3296
+ return null;
3297
+ }
3298
+ Wr.displayName = "Link";
3276
3299
  const Or = {
3277
3300
  Document: "DOCUMENT",
3278
3301
  Page: "PAGE",
@@ -3281,7 +3304,7 @@ const Or = {
3281
3304
  Image: "IMAGE",
3282
3305
  Link: "LINK"
3283
3306
  };
3284
- function Wr(t) {
3307
+ function zr(t) {
3285
3308
  if (typeof t == "string") return t;
3286
3309
  if (typeof t == "function") {
3287
3310
  const e = t;
@@ -3289,7 +3312,7 @@ function Wr(t) {
3289
3312
  }
3290
3313
  return null;
3291
3314
  }
3292
- function ti(t) {
3315
+ function ii(t) {
3293
3316
  const e = [], n = (i) => {
3294
3317
  if (!(i == null || typeof i == "boolean")) {
3295
3318
  if (Array.isArray(i)) {
@@ -3301,11 +3324,11 @@ function ti(t) {
3301
3324
  };
3302
3325
  return n(t), e;
3303
3326
  }
3304
- function ei(t) {
3305
- 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("");
3306
3329
  }
3307
- function ni(t) {
3308
- const e = Wr(t.type), n = e ? Or[e] : void 0;
3330
+ function oi(t) {
3331
+ const e = zr(t.type), n = e ? Or[e] : void 0;
3309
3332
  if (!n)
3310
3333
  throw new Error(
3311
3334
  `[epochs-pdf] Unsupported element "${e ?? "unknown"}". Use Document, Page, View, Text, Image, or Link.`
@@ -3316,27 +3339,27 @@ function ni(t) {
3316
3339
  type: n,
3317
3340
  props: i,
3318
3341
  children: [],
3319
- text: ei(r)
3342
+ text: ri(r)
3320
3343
  };
3321
- const o = ti(r).filter(
3344
+ const o = ii(r).filter(
3322
3345
  (d) => !!d && typeof d == "object" && "type" in d
3323
- ).map(ni);
3346
+ ).map(oi);
3324
3347
  return {
3325
3348
  type: n,
3326
3349
  props: i,
3327
3350
  children: o
3328
3351
  };
3329
3352
  }
3330
- const zr = {
3353
+ const Sr = {
3331
3354
  A4: [595.28, 841.89],
3332
3355
  LETTER: [612, 792],
3333
3356
  LEGAL: [612, 1008]
3334
3357
  };
3335
- function Sr(t = "A4", e = "portrait") {
3336
- const [n, i] = Array.isArray(t) ? t : zr[t];
3358
+ function Gr(t = "A4", e = "portrait") {
3359
+ const [n, i] = Array.isArray(t) ? t : Sr[t];
3337
3360
  return e === "landscape" ? [i, n] : [n, i];
3338
3361
  }
3339
- function ii(t = {}) {
3362
+ function si(t = {}) {
3340
3363
  const e = t.padding ?? 0;
3341
3364
  return {
3342
3365
  top: t.paddingTop ?? e,
@@ -3345,7 +3368,7 @@ function ii(t = {}) {
3345
3368
  left: t.paddingLeft ?? e
3346
3369
  };
3347
3370
  }
3348
- function De(t = {}) {
3371
+ function Ae(t = {}) {
3349
3372
  const e = t.margin ?? 0;
3350
3373
  return {
3351
3374
  top: t.marginTop ?? e,
@@ -3354,7 +3377,7 @@ function De(t = {}) {
3354
3377
  left: t.marginLeft ?? e
3355
3378
  };
3356
3379
  }
3357
- function Be(t) {
3380
+ function ze(t) {
3358
3381
  if (!t) return null;
3359
3382
  const e = t.trim();
3360
3383
  if (e.startsWith("#")) {
@@ -3377,7 +3400,7 @@ function Be(t) {
3377
3400
  Math.min(1, Number(n[3]) / 255)
3378
3401
  ] : null;
3379
3402
  }
3380
- function Me(t, e, n = 0) {
3403
+ function $e(t, e, n = 0) {
3381
3404
  if (t == null) return n;
3382
3405
  if (typeof t == "number") return t;
3383
3406
  if (t.endsWith("%")) {
@@ -3387,19 +3410,19 @@ function Me(t, e, n = 0) {
3387
3410
  const i = Number.parseFloat(t);
3388
3411
  return Number.isFinite(i) ? i : n;
3389
3412
  }
3390
- function an(t) {
3413
+ function un(t) {
3391
3414
  return t === "bold" ? !0 : typeof t == "number" ? t >= 600 : !1;
3392
3415
  }
3393
- const Xr = 12, Gr = 1.4, qr = 0.5;
3394
- function ri(t, e, n) {
3395
- const i = e.fontSize ?? Xr, r = (e.lineHeight ?? Gr) * i, o = i * (an(e.fontWeight) ? 0.55 : qr);
3416
+ const Xr = 12, Vr = 1.4, qr = 0.5;
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);
3396
3419
  if (!t)
3397
3420
  return { width: 0, height: r, lines: [""] };
3398
3421
  const d = t.split(/\s+/), u = [];
3399
3422
  let m = "";
3400
3423
  for (const _ of d) {
3401
- const w = m ? `${m} ${_}` : _;
3402
- w.length * o <= n || !m ? m = w : (u.push(m), m = _);
3424
+ const y = m ? `${m} ${_}` : _;
3425
+ y.length * o <= n || !m ? m = y : (u.push(m), m = _);
3403
3426
  }
3404
3427
  m && u.push(m);
3405
3428
  const g = Math.max(...u.map((_) => _.length * o), 0);
@@ -3409,13 +3432,13 @@ function ri(t, e, n) {
3409
3432
  lines: u
3410
3433
  };
3411
3434
  }
3412
- function oi(t, e, n, i, r) {
3413
- const o = t.props.style ?? {}, d = De(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(
3414
3437
  0,
3415
- Me(o.width, i, i) - d.left - d.right
3416
- ), w = 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);
3417
3440
  if (t.type === "TEXT" || t.type === "LINK") {
3418
- const U = ri(t.text ?? "", o, w), ct = Me(o.height, r, U.height + u.top + u.bottom);
3441
+ const E = ai(t.text ?? "", o, y), ct = $e(o.height, r, E.height + u.top + u.bottom);
3419
3442
  return {
3420
3443
  x: m,
3421
3444
  y: g,
@@ -3428,51 +3451,51 @@ function oi(t, e, n, i, r) {
3428
3451
  };
3429
3452
  }
3430
3453
  if (t.type === "IMAGE") {
3431
- const U = Me(o.width, i, Math.min(200, i)), ct = Me(o.height, r, 120);
3454
+ const E = $e(o.width, i, Math.min(200, i)), ct = $e(o.height, r, 120);
3432
3455
  return {
3433
3456
  x: m,
3434
3457
  y: g,
3435
- width: U - d.left - d.right,
3458
+ width: E - d.left - d.right,
3436
3459
  height: ct,
3437
3460
  node: t,
3438
3461
  children: [],
3439
3462
  style: o
3440
3463
  };
3441
3464
  }
3442
- const b = o.flexDirection ?? "column", x = o.gap ?? 0, C = [];
3443
- let S = m + u.left, H = g + u.top, O = 0, E = 0;
3444
- for (let U = 0; U < t.children.length; U++) {
3445
- const ct = t.children[U], ft = b === "row" ? Math.max(0, w - O - (U > 0 ? x : 0)) : w, gt = b === "column" ? Math.max(0, r - (H - n) - d.bottom) : r, tt = oi(ct, S, H, ft, gt);
3446
- C.push(tt), b === "row" ? (O += tt.width + De(ct.props.style ?? {}).left + De(ct.props.style ?? {}).right, U < t.children.length - 1 && (O += x), S = m + u.left + O, E = Math.max(E, tt.height)) : (O += tt.height + De(ct.props.style ?? {}).top + De(ct.props.style ?? {}).bottom, U < t.children.length - 1 && (O += x), H = g + u.top + O, E = Math.max(E, tt.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));
3447
3470
  }
3448
- const I = Me(
3471
+ const C = $e(
3449
3472
  o.height,
3450
3473
  r,
3451
- b === "column" ? O + u.top + u.bottom : E + u.top + u.bottom
3452
- ), et = b === "row" ? Me(o.width, i, O + u.left + u.right) : _, at = o.justifyContent ?? "flex-start", Y = o.alignItems ?? "stretch", pt = b === "column" ? I - u.top - u.bottom : et - u.left - u.right, Mt = Math.max(0, pt - O);
3453
- let Z = 0, Lt = x;
3454
- at === "center" && (Z = Mt / 2), at === "flex-end" && (Z = Mt), at === "space-between" && C.length > 1 && (Lt = x + Mt / (C.length - 1)), at === "space-around" && C.length > 0 && (Lt = x + Mt / C.length, Z = Lt / 2);
3455
- let _t = 0;
3456
- for (const U of C)
3457
- b === "column" ? (U.y = g + u.top + Z + _t, Y === "center" ? U.x = m + u.left + Math.max(0, (w - U.width) / 2) : Y === "flex-end" ? U.x = m + u.left + Math.max(0, w - U.width) : Y === "stretch" && U.style.width == null && (U.width = w), _t += U.height + Lt) : (U.x = m + u.left + Z + _t, Y === "center" ? U.y = g + u.top + Math.max(0, (I - u.top - u.bottom - U.height) / 2) : Y === "flex-end" ? U.y = g + u.top + Math.max(0, I - u.top - u.bottom - U.height) : Y === "stretch" && U.style.height == null && (U.height = I - u.top - u.bottom), _t += U.width + Lt);
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);
3458
3481
  return {
3459
3482
  x: m,
3460
3483
  y: g,
3461
- width: et,
3462
- height: I,
3484
+ width: nt,
3485
+ height: C,
3463
3486
  node: t,
3464
- children: C,
3487
+ children: I,
3465
3488
  style: o
3466
3489
  };
3467
3490
  }
3468
- function Vr(t) {
3491
+ function Yr(t) {
3469
3492
  if (t.type !== "DOCUMENT")
3470
3493
  throw new Error("[epochs-pdf] Root element must be <Document>.");
3471
3494
  const e = [];
3472
3495
  for (const n of t.children) {
3473
3496
  if (n.type !== "PAGE")
3474
3497
  throw new Error("[epochs-pdf] Direct children of <Document> must be <Page>.");
3475
- const i = n.props.size, r = n.props.orientation ?? "portrait", [o, d] = Sr(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 = {
3476
3499
  type: "VIEW",
3477
3500
  props: {
3478
3501
  style: {
@@ -3486,7 +3509,7 @@ function Vr(t) {
3486
3509
  }
3487
3510
  },
3488
3511
  children: n.children
3489
- }, _ = oi(g, 0, 0, o, d);
3512
+ }, _ = ci(g, 0, 0, o, d);
3490
3513
  e.push({
3491
3514
  width: o,
3492
3515
  height: d,
@@ -3504,44 +3527,44 @@ function Vr(t) {
3504
3527
  pages: e
3505
3528
  };
3506
3529
  }
3507
- function Fe(t) {
3530
+ function Ee(t) {
3508
3531
  return t.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
3509
3532
  }
3510
- class Yr {
3533
+ class Kr {
3511
3534
  constructor() {
3512
- Je(this, "objects", [null]);
3513
- Je(this, "offsets", [0]);
3535
+ on(this, "objects", [null]);
3536
+ on(this, "offsets", [0]);
3514
3537
  }
3515
3538
  addObject(e) {
3516
3539
  return this.objects.push(e), this.objects.length - 1;
3517
3540
  }
3518
3541
  build(e) {
3519
3542
  const n = this.addObject(
3520
- `<< /Title (${Fe(e.meta.title)}) /Author (${Fe(e.meta.author)}) /Subject (${Fe(e.meta.subject)}) /Creator (${Fe(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) >>`
3521
3544
  ), i = this.addObject(
3522
3545
  "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"
3523
3546
  ), r = this.addObject(
3524
3547
  "<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"
3525
3548
  ), o = [];
3526
- for (const w of e.pages) {
3549
+ for (const y of e.pages) {
3527
3550
  const b = this.renderPageContent(
3528
- w.boxes,
3529
- w.width,
3530
- w.height,
3531
- w.style
3551
+ y.boxes,
3552
+ y.width,
3553
+ y.height,
3554
+ y.style
3532
3555
  ), x = this.addObject(
3533
3556
  `<< /Length ${b.length} >>
3534
3557
  stream
3535
3558
  ${b}
3536
3559
  endstream`
3537
- ), C = this.addObject("");
3538
- o.push(C), this.objects[C] = `<< /Type /Page /Parent 0 0 R /MediaBox [0 0 ${w.width.toFixed(2)} ${w.height.toFixed(2)}] /Contents ${x} 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 >> >> >>`;
3539
3562
  }
3540
- const d = o.map((w) => `${w} 0 R`).join(" "), u = this.addObject(
3563
+ const d = o.map((y) => `${y} 0 R`).join(" "), u = this.addObject(
3541
3564
  `<< /Type /Pages /Kids [${d}] /Count ${o.length} >>`
3542
3565
  );
3543
- for (const w of o)
3544
- this.objects[w] = this.objects[w].replace(
3566
+ for (const y of o)
3567
+ this.objects[y] = this.objects[y].replace(
3545
3568
  "/Parent 0 0 R",
3546
3569
  `/Parent ${u} 0 R`
3547
3570
  );
@@ -3551,9 +3574,9 @@ endstream`
3551
3574
  let g = `%PDF-1.4
3552
3575
  `;
3553
3576
  this.offsets = [0];
3554
- for (let w = 1; w < this.objects.length; w++)
3555
- this.offsets[w] = g.length, g += `${w} 0 obj
3556
- ${this.objects[w]}
3577
+ for (let y = 1; y < this.objects.length; y++)
3578
+ this.offsets[y] = g.length, g += `${y} 0 obj
3579
+ ${this.objects[y]}
3557
3580
  endobj
3558
3581
  `;
3559
3582
  const _ = g.length;
@@ -3561,8 +3584,8 @@ endobj
3561
3584
  0 ${this.objects.length}
3562
3585
  `, g += `0000000000 65535 f
3563
3586
  `;
3564
- for (let w = 1; w < this.objects.length; w++)
3565
- g += `${String(this.offsets[w]).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
3566
3589
  `;
3567
3590
  return g += `trailer
3568
3591
  << /Size ${this.objects.length} /Root ${m} 0 R /Info ${n} 0 R >>
@@ -3571,33 +3594,33 @@ ${_}
3571
3594
  %%EOF`, new TextEncoder().encode(g);
3572
3595
  }
3573
3596
  renderPageContent(e, n, i, r) {
3574
- const o = [], d = Be(r.backgroundColor);
3597
+ const o = [], d = ze(r.backgroundColor);
3575
3598
  d && (o.push("q"), o.push(
3576
3599
  `${d[0].toFixed(3)} ${d[1].toFixed(3)} ${d[2].toFixed(3)} rg`
3577
3600
  ), o.push(
3578
3601
  `0 0 ${n.toFixed(2)} ${i.toFixed(2)} re f`
3579
3602
  ), o.push("Q"));
3580
3603
  const u = (m) => {
3581
- const { x: g, y: _, width: w, height: b, style: x, node: C, text: S } = m, H = i - _ - b, O = Be(x.backgroundColor);
3582
- if (O && (o.push("q"), o.push(`${O[0].toFixed(3)} ${O[1].toFixed(3)} ${O[2].toFixed(3)} rg`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.toFixed(2)} ${b.toFixed(2)} re f`), o.push("Q")), x.borderWidth && x.borderWidth > 0) {
3583
- const E = Be(x.borderColor) ?? [0, 0, 0];
3584
- o.push("q"), o.push(`${x.borderWidth} w`), o.push(`${E[0].toFixed(3)} ${E[1].toFixed(3)} ${E[2].toFixed(3)} RG`), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.toFixed(2)} ${b.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");
3585
3608
  }
3586
- if ((C.type === "TEXT" || C.type === "LINK") && S != null) {
3587
- const E = x.fontSize ?? 12, I = Be(x.color) ?? [0, 0, 0], et = an(x.fontWeight) ? "F2" : "F1", at = x.paddingLeft ?? x.padding ?? 0, Y = x.paddingTop ?? x.padding ?? 0, pt = Math.max(0, w - at - (x.paddingRight ?? x.padding ?? 0)), J = ri(S, x, pt || w), Mt = (x.lineHeight ?? 1.4) * E;
3588
- o.push("q"), o.push("BT"), o.push(`/${et} ${E} Tf`), o.push(`${I[0].toFixed(3)} ${I[1].toFixed(3)} ${I[2].toFixed(3)} rg`), J.lines.forEach((Z, Lt) => {
3589
- let _t = g + at;
3590
- const U = Z.length * E * (an(x.fontWeight) ? 0.55 : 0.5);
3591
- x.textAlign === "center" ? _t = g + (w - U) / 2 : x.textAlign === "right" && (_t = g + w - U - (x.paddingRight ?? x.padding ?? 0));
3592
- const ct = i - _ - Y - E - Lt * Mt;
3593
- o.push(`1 0 0 1 ${_t.toFixed(2)} ${ct.toFixed(2)} Tm`), o.push(`(${Fe(Z)}) 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`);
3594
3617
  }), o.push("ET"), o.push("Q");
3595
3618
  }
3596
- C.type === "IMAGE" && (o.push("q"), o.push("0.85 0.85 0.85 rg"), o.push(`${g.toFixed(2)} ${H.toFixed(2)} ${w.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)} ${w.toFixed(2)} ${b.toFixed(2)} re S`), o.push(
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(
3597
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`
3598
3621
  ), o.push("Q"));
3599
- for (const E of m.children)
3600
- u(E);
3622
+ for (const A of m.children)
3623
+ u(A);
3601
3624
  };
3602
3625
  for (const m of e)
3603
3626
  u(m);
@@ -3605,69 +3628,69 @@ ${_}
3605
3628
  `);
3606
3629
  }
3607
3630
  }
3608
- function Kr(t) {
3609
- return new Yr().build(t);
3631
+ function Zr(t) {
3632
+ return new Kr().build(t);
3610
3633
  }
3611
- function cn(t) {
3612
- const e = ni(t), n = Vr(e);
3613
- return Kr(n);
3634
+ function fn(t) {
3635
+ const e = oi(t), n = Yr(e);
3636
+ return Zr(n);
3614
3637
  }
3615
- function oo(t) {
3616
- return cn(t);
3638
+ function so(t) {
3639
+ return fn(t);
3617
3640
  }
3618
- function si(t) {
3619
- const e = cn(t), n = new Uint8Array(e.byteLength);
3641
+ function li(t) {
3642
+ const e = fn(t), n = new Uint8Array(e.byteLength);
3620
3643
  return n.set(e), new Blob([n], { type: "application/pdf" });
3621
3644
  }
3622
- function Zr(t) {
3623
- return URL.createObjectURL(si(t));
3645
+ function Qr(t) {
3646
+ return URL.createObjectURL(li(t));
3624
3647
  }
3625
- function so(t, e = "document.pdf") {
3626
- const n = Zr(t), i = document.createElement("a");
3648
+ function ao(t, e = "document.pdf") {
3649
+ const n = Qr(t), i = document.createElement("a");
3627
3650
  i.href = n, i.download = e, i.click(), URL.revokeObjectURL(n);
3628
3651
  }
3629
- async function ao(t) {
3630
- return cn(t);
3631
- }
3632
3652
  async function co(t) {
3633
- return si(t);
3653
+ return fn(t);
3654
+ }
3655
+ async function lo(t) {
3656
+ return li(t);
3634
3657
  }
3635
3658
  export {
3636
- io as ALL_TOOLBAR_TOOLS,
3637
- Zn as AddText,
3638
- Jn as Clear,
3639
- Tn as DEFAULT_TOOLBAR_LAYOUT,
3640
- Ar as Document,
3641
- qn as Download,
3642
- Qn as Erase,
3643
- Dn as HIGHLIGHT_PRESETS,
3644
- Vn as Highlight,
3645
- jr as Image,
3646
- Br as Link,
3647
- On as Navigation,
3648
- Gn as Open,
3649
- zr as PAGE_SIZES,
3650
- Er as Page,
3651
- ro as PdfViewer,
3652
- Xn as Print,
3653
- Sn as Reload,
3654
- zn as Rotate,
3655
- Kn as Signature,
3656
- Hr as Text,
3657
- Bn as Thumbnail,
3658
- Fn as UNDERLINE_PRESETS,
3659
- Yn as Underline,
3659
+ ro as ALL_TOOLBAR_TOOLS,
3660
+ ti as AddText,
3661
+ ni as Clear,
3662
+ Fn as DEFAULT_TOOLBAR_LAYOUT,
3663
+ Er as Document,
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,
3670
+ Sn as Navigation,
3671
+ Yn as Open,
3672
+ Sr as PAGE_SIZES,
3673
+ Hr as Page,
3674
+ oo as PdfViewer,
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,
3660
3683
  Ur as View,
3661
- Wn as Zoom,
3662
- ro as default,
3663
- so as download,
3664
- An as hexToMarkupColor,
3665
- oo as pdf,
3666
- co as renderToBlob,
3667
- ao as renderToBuffer,
3668
- Sr as resolvePageSize,
3669
- kn as setPdfWorkerSrc,
3670
- si as toBlob,
3671
- Zr as toUrl
3684
+ Gn as Zoom,
3685
+ oo as default,
3686
+ ao as download,
3687
+ Un as hexToMarkupColor,
3688
+ so as pdf,
3689
+ lo as renderToBlob,
3690
+ co as renderToBuffer,
3691
+ Gr as resolvePageSize,
3692
+ $n as setPdfWorkerSrc,
3693
+ li as toBlob,
3694
+ Qr as toUrl
3672
3695
  };
3673
3696
  //# sourceMappingURL=epochs-pdf.js.map