@alfadocs/ui-kit-debug 0.60.0 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/pdf-viewer-chMpwpA4.js +979 -0
- package/dist/_chunks/pdf-viewer-chMpwpA4.js.map +1 -0
- package/dist/_chunks/{sign-document-BmAT0kKD.js → sign-document--nr5cxsB.js} +2 -2
- package/dist/_chunks/{sign-document-BmAT0kKD.js.map → sign-document--nr5cxsB.js.map} +1 -1
- package/dist/_chunks/signature-field-DbhbpLha.js +190 -0
- package/dist/_chunks/signature-field-DbhbpLha.js.map +1 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/pdf-viewer/index.js +1 -1
- package/dist/components/pdf-viewer/pdf-viewer.d.ts +7 -0
- package/dist/components/pdf-viewer/pdf-viewer.d.ts.map +1 -1
- package/dist/components/sign-document/index.js +1 -1
- package/dist/components/signature-field/index.js +1 -1
- package/dist/components/signature-field/signature-field.d.ts +8 -0
- package/dist/components/signature-field/signature-field.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/tokens.css +1 -1
- package/package.json +3 -1
- package/dist/_chunks/pdf-viewer-XxWdtKfD.js +0 -965
- package/dist/_chunks/pdf-viewer-XxWdtKfD.js.map +0 -1
- package/dist/_chunks/signature-field-DhscKdgk.js +0 -152
- package/dist/_chunks/signature-field-DhscKdgk.js.map +0 -1
|
@@ -0,0 +1,979 @@
|
|
|
1
|
+
import { jsx as a, jsxs as _, Fragment as we } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Le, useId as Ze, useMemo as ke, useState as y, useEffect as O, useRef as E, useCallback as Q, useImperativeHandle as Ke } from "react";
|
|
3
|
+
import * as pe from "pdfjs-dist/legacy/build/pdf.min.mjs";
|
|
4
|
+
import { c as X } from "./index-D2ZczOXr.js";
|
|
5
|
+
import { useTranslation as me } from "react-i18next";
|
|
6
|
+
import * as re from "@radix-ui/react-popover";
|
|
7
|
+
import De from "pdfjs-dist/legacy/build/pdf.worker.min.mjs?url";
|
|
8
|
+
import { S as Be } from "./spinner-OjQNn8oN.js";
|
|
9
|
+
import { A as ze } from "./alert-_mUKLmwA.js";
|
|
10
|
+
import { u as He } from "./registry-nPAVE19X.js";
|
|
11
|
+
import { X as Qe } from "./x-CCcI3eJp.js";
|
|
12
|
+
import { C as We } from "./chevron-left-CX1jqD2M.js";
|
|
13
|
+
import { C as qe } from "./chevron-right-BrpYejk0.js";
|
|
14
|
+
import { c as Oe } from "./createLucideIcon-CrFbzy84.js";
|
|
15
|
+
import { S as Ue } from "./search-BonnQsHv.js";
|
|
16
|
+
import { P as Je } from "./printer-CeVEWfQq.js";
|
|
17
|
+
/**
|
|
18
|
+
* @license lucide-react v1.8.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/
|
|
23
|
+
const $e = [
|
|
24
|
+
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
25
|
+
["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
|
|
26
|
+
["line", { x1: "11", x2: "11", y1: "8", y2: "14", key: "1vmskp" }],
|
|
27
|
+
["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
|
|
28
|
+
], Xe = Oe("zoom-in", $e);
|
|
29
|
+
/**
|
|
30
|
+
* @license lucide-react v1.8.0 - ISC
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the ISC license.
|
|
33
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
34
|
+
*/
|
|
35
|
+
const Ge = [
|
|
36
|
+
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
37
|
+
["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
|
|
38
|
+
["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
|
|
39
|
+
], Ye = Oe("zoom-out", Ge), et = {
|
|
40
|
+
id: "pdf-viewer",
|
|
41
|
+
capabilities: ["paginate", "view_change", "filter"],
|
|
42
|
+
state: {},
|
|
43
|
+
actions: {
|
|
44
|
+
go_to_page: {
|
|
45
|
+
safety: "read",
|
|
46
|
+
argsType: "{ page: number }",
|
|
47
|
+
description: "Navigate to a specific 1-indexed page.",
|
|
48
|
+
invoke: (o, t) => {
|
|
49
|
+
o.goToPage(t.page);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
set_zoom: {
|
|
53
|
+
safety: "read",
|
|
54
|
+
argsType: "{ zoom: PDFZoomPreset }",
|
|
55
|
+
description: "Apply a zoom preset.",
|
|
56
|
+
invoke: (o, t) => {
|
|
57
|
+
o.setZoom(t.zoom);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
search: {
|
|
61
|
+
safety: "read",
|
|
62
|
+
argsType: "{ query: string }",
|
|
63
|
+
description: "Search the document for the given query and highlight matches.",
|
|
64
|
+
invoke: (o, t) => {
|
|
65
|
+
o.search(t.query);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
print: {
|
|
69
|
+
safety: "read",
|
|
70
|
+
description: "Open the browser print dialog for the document.",
|
|
71
|
+
invoke: (o) => {
|
|
72
|
+
o.print();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
domHooks: {
|
|
77
|
+
root: { attr: "data-component", value: "pdf-viewer" },
|
|
78
|
+
instanceId: {
|
|
79
|
+
attr: "data-component-id",
|
|
80
|
+
sourceProp: "id",
|
|
81
|
+
description: "Sourced from the id prop."
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
pe.GlobalWorkerOptions.workerSrc = De;
|
|
86
|
+
const Pe = X(
|
|
87
|
+
[
|
|
88
|
+
"ds:pdf-viewer-alfadocs ds:flex ds:flex-col",
|
|
89
|
+
// Allow the viewer to shrink below its content's intrinsic width when it
|
|
90
|
+
// sits in a constrained flex/grid context (mobile signing flows): without
|
|
91
|
+
// min-inline-size:0 the page canvas's natural width pins the flex item
|
|
92
|
+
// open, fit-width then measures that inflated width and never scales down.
|
|
93
|
+
"ds:min-w-0",
|
|
94
|
+
"ds:gap-[var(--spacing-sm)]",
|
|
95
|
+
"ds:bg-[var(--background)] ds:text-[var(--foreground)]",
|
|
96
|
+
"ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)] ds:[.theme-accessible_&]:border-2",
|
|
97
|
+
"ds:overflow-hidden",
|
|
98
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)]",
|
|
99
|
+
"ds:focus-visible:outline-solid",
|
|
100
|
+
"ds:focus-visible:outline-[var(--ring)]",
|
|
101
|
+
"ds:forced-colors:focus-visible:outline-[CanvasText]"
|
|
102
|
+
].join(" ")
|
|
103
|
+
), tt = X(
|
|
104
|
+
[
|
|
105
|
+
"ds:flex ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)]",
|
|
106
|
+
"ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]",
|
|
107
|
+
"ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]",
|
|
108
|
+
"ds:bg-[var(--background)]",
|
|
109
|
+
"ds:border-b ds:border-[color:var(--border)]"
|
|
110
|
+
].join(" ")
|
|
111
|
+
), Se = X(
|
|
112
|
+
[
|
|
113
|
+
"ds:inline-flex ds:items-center ds:justify-center",
|
|
114
|
+
"ds:[min-block-size:var(--min-target-size)]",
|
|
115
|
+
"ds:[min-inline-size:var(--min-target-size)]",
|
|
116
|
+
"ds:gap-[var(--spacing-xs)]",
|
|
117
|
+
"ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]",
|
|
118
|
+
"ds:rounded-[var(--radius-sm)] ds:bg-transparent ds:text-[var(--foreground)]",
|
|
119
|
+
"ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
120
|
+
"ds:hover:bg-[var(--muted)]",
|
|
121
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)]",
|
|
122
|
+
"ds:focus-visible:outline-solid",
|
|
123
|
+
"ds:focus-visible:outline-[var(--ring)]",
|
|
124
|
+
"ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
125
|
+
"ds:forced-colors:focus-visible:outline-[CanvasText]",
|
|
126
|
+
"ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed"
|
|
127
|
+
].join(" ")
|
|
128
|
+
), Ie = X(
|
|
129
|
+
[
|
|
130
|
+
"ds:[min-block-size:var(--min-target-size)]",
|
|
131
|
+
"ds:inline-size-[4rem] ds:text-center",
|
|
132
|
+
"ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)]",
|
|
133
|
+
"ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)]",
|
|
134
|
+
"ds:bg-[var(--background)] ds:text-[var(--foreground)]",
|
|
135
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)]",
|
|
136
|
+
"ds:focus-visible:outline-solid",
|
|
137
|
+
"ds:focus-visible:outline-[var(--ring)]",
|
|
138
|
+
"ds:forced-colors:focus-visible:outline-[CanvasText]"
|
|
139
|
+
].join(" ")
|
|
140
|
+
), rt = X(
|
|
141
|
+
[
|
|
142
|
+
"ds:[min-block-size:var(--min-target-size)]",
|
|
143
|
+
"ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]",
|
|
144
|
+
"ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)]",
|
|
145
|
+
"ds:bg-[var(--background)] ds:text-[var(--foreground)]",
|
|
146
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)]",
|
|
147
|
+
"ds:focus-visible:outline-solid",
|
|
148
|
+
"ds:focus-visible:outline-[var(--ring)]",
|
|
149
|
+
"ds:forced-colors:focus-visible:outline-[CanvasText]"
|
|
150
|
+
].join(" ")
|
|
151
|
+
), nt = X(
|
|
152
|
+
[
|
|
153
|
+
"ds:relative ds:flex ds:flex-col ds:items-center",
|
|
154
|
+
"ds:gap-[var(--spacing-md)]",
|
|
155
|
+
"ds:p-[var(--spacing-md)]",
|
|
156
|
+
"ds:bg-[var(--muted)]",
|
|
157
|
+
"ds:overflow-auto",
|
|
158
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)]",
|
|
159
|
+
"ds:focus-visible:outline-solid",
|
|
160
|
+
"ds:focus-visible:outline-[var(--ring)]",
|
|
161
|
+
"ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
162
|
+
"ds:forced-colors:focus-visible:outline-[CanvasText]",
|
|
163
|
+
// NB: `min-block-size-[…]` / `max-block-size-[…]` arbitrary utilities don't
|
|
164
|
+
// generate any CSS in this Tailwind setup (silent no-op) — using them left
|
|
165
|
+
// the container uncapped, so it rendered all pages at full height and never
|
|
166
|
+
// scrolled, which froze the page tracker at 1 and broke SignDocument's
|
|
167
|
+
// read-to-end gate. `min-h`/`max-h` are block-axis height (writing-mode
|
|
168
|
+
// agnostic) and generate correctly.
|
|
169
|
+
"ds:min-h-[30rem]",
|
|
170
|
+
"ds:max-h-[80vh]"
|
|
171
|
+
].join(" ")
|
|
172
|
+
), at = X(
|
|
173
|
+
[
|
|
174
|
+
"ds:relative ds:flex ds:items-center ds:justify-center",
|
|
175
|
+
"ds:bg-[var(--background)]",
|
|
176
|
+
"ds:shadow-[var(--shadow-md)]",
|
|
177
|
+
"ds:rounded-[var(--radius-sm)]"
|
|
178
|
+
].join(" ")
|
|
179
|
+
), st = [
|
|
180
|
+
"fit-width",
|
|
181
|
+
"fit-page",
|
|
182
|
+
"actual-size",
|
|
183
|
+
0.5,
|
|
184
|
+
0.75,
|
|
185
|
+
1,
|
|
186
|
+
1.25,
|
|
187
|
+
1.5,
|
|
188
|
+
2
|
|
189
|
+
];
|
|
190
|
+
function Y(o) {
|
|
191
|
+
return typeof o == "number";
|
|
192
|
+
}
|
|
193
|
+
function Me(o, t, v) {
|
|
194
|
+
if (Y(o)) return o;
|
|
195
|
+
if (o === "actual-size" || !v) return 1;
|
|
196
|
+
const m = window.getComputedStyle(v), h = parseFloat(m.paddingInlineStart || "0") + parseFloat(m.paddingInlineEnd || "0"), g = parseFloat(m.paddingBlockStart || "0") + parseFloat(m.paddingBlockEnd || "0"), x = Math.max(v.clientWidth - h, 1), w = Math.max(v.clientHeight - g, 1), k = t.width, z = t.height;
|
|
197
|
+
return o === "fit-width" ? x / k : Math.min(x / k, w / z);
|
|
198
|
+
}
|
|
199
|
+
const ot = Le(
|
|
200
|
+
({
|
|
201
|
+
id: o,
|
|
202
|
+
src: t,
|
|
203
|
+
initialPage: v = 1,
|
|
204
|
+
initialZoom: m = "fit-width",
|
|
205
|
+
pageRotation: h,
|
|
206
|
+
renderPageOverlay: g,
|
|
207
|
+
onPageChange: x,
|
|
208
|
+
onLoadComplete: w,
|
|
209
|
+
onError: k,
|
|
210
|
+
toolbar: z = !0,
|
|
211
|
+
toolbarVariant: L = "full",
|
|
212
|
+
ariaLabel: P,
|
|
213
|
+
className: S
|
|
214
|
+
}, b) => {
|
|
215
|
+
const { t: l } = me(), I = Ze(), M = ke(
|
|
216
|
+
() => `pdf-${I.replace(/[^a-zA-Z0-9-_]/g, "")}`,
|
|
217
|
+
[I]
|
|
218
|
+
), [A, p] = y(!1), [K, W] = y(!1);
|
|
219
|
+
O(() => {
|
|
220
|
+
if (typeof document > "u") return;
|
|
221
|
+
p(document.documentElement.dir === "rtl");
|
|
222
|
+
const e = window.matchMedia("(prefers-reduced-motion: reduce)"), r = () => W(e.matches);
|
|
223
|
+
return r(), e.addEventListener("change", r), () => e.removeEventListener("change", r);
|
|
224
|
+
}, []);
|
|
225
|
+
const [s, q] = y(null), [i, N] = y(null), [u, R] = y(v), [C, D] = y(m), [Z, B] = y({ start: Math.max(1, v - 1), end: v + 1 }), [U, T] = y(""), [n, f] = y(!1), [ee, he] = y(""), [Re, Te] = y({ current: 0, total: 0 }), ne = E(x), ae = E(w), se = E(k);
|
|
226
|
+
O(() => {
|
|
227
|
+
ne.current = x, ae.current = w, se.current = k;
|
|
228
|
+
}, [x, w, k]);
|
|
229
|
+
const ce = E(null);
|
|
230
|
+
O(() => {
|
|
231
|
+
ce.current = s;
|
|
232
|
+
}, [s]), O(() => {
|
|
233
|
+
let e = !1;
|
|
234
|
+
q(null), N(null);
|
|
235
|
+
const r = {
|
|
236
|
+
disableJavaScript: !0,
|
|
237
|
+
isEvalSupported: !1
|
|
238
|
+
}, c = pe.getDocument(
|
|
239
|
+
typeof t == "string" ? { url: t, ...r } : t instanceof Uint8Array ? { data: t, ...r } : { data: new Uint8Array(t), ...r }
|
|
240
|
+
);
|
|
241
|
+
return c.promise.then(
|
|
242
|
+
async (d) => {
|
|
243
|
+
var J;
|
|
244
|
+
if (e) return;
|
|
245
|
+
let j;
|
|
246
|
+
try {
|
|
247
|
+
const $ = await d.getMetadata(), V = $ == null ? void 0 : $.info;
|
|
248
|
+
j = V == null ? void 0 : V.Title;
|
|
249
|
+
} catch {
|
|
250
|
+
j = void 0;
|
|
251
|
+
}
|
|
252
|
+
if (e) {
|
|
253
|
+
try {
|
|
254
|
+
await d.destroy();
|
|
255
|
+
} catch {
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const H = { doc: d, numPages: d.numPages, title: j };
|
|
260
|
+
q(H), (J = ae.current) == null || J.call(ae, { numPages: d.numPages, title: j });
|
|
261
|
+
},
|
|
262
|
+
(d) => {
|
|
263
|
+
var H;
|
|
264
|
+
if (e) return;
|
|
265
|
+
const j = d instanceof Error ? d : new Error(String(d));
|
|
266
|
+
N(j), (H = se.current) == null || H.call(se, j);
|
|
267
|
+
}
|
|
268
|
+
), () => {
|
|
269
|
+
e = !0, c.destroy();
|
|
270
|
+
const d = ce.current;
|
|
271
|
+
if (d) {
|
|
272
|
+
try {
|
|
273
|
+
d.doc.destroy();
|
|
274
|
+
} catch {
|
|
275
|
+
}
|
|
276
|
+
ce.current = null;
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}, [t]), O(() => {
|
|
280
|
+
var e;
|
|
281
|
+
s && (T(
|
|
282
|
+
l("pdf.pageOf", { current: u, total: s.numPages })
|
|
283
|
+
), (e = ne.current) == null || e.call(ne, u));
|
|
284
|
+
}, [u, s, l]);
|
|
285
|
+
const oe = E(null), le = E([]), F = Q(
|
|
286
|
+
(e) => {
|
|
287
|
+
if (!s) return;
|
|
288
|
+
const r = Math.max(1, Math.min(e, s.numPages));
|
|
289
|
+
R(r);
|
|
290
|
+
const c = le.current[r - 1];
|
|
291
|
+
c && c.scrollIntoView({
|
|
292
|
+
behavior: "auto",
|
|
293
|
+
block: "start"
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
[s, K]
|
|
297
|
+
), ge = Q((e) => {
|
|
298
|
+
D(e);
|
|
299
|
+
}, []), te = Q(() => {
|
|
300
|
+
typeof window < "u" && window.print();
|
|
301
|
+
}, []), ve = Q((e) => {
|
|
302
|
+
he(e), f(e.length > 0);
|
|
303
|
+
}, []), ue = ke(
|
|
304
|
+
() => ({
|
|
305
|
+
goToPage: F,
|
|
306
|
+
setZoom: ge,
|
|
307
|
+
search: ve,
|
|
308
|
+
print: te
|
|
309
|
+
}),
|
|
310
|
+
[F, ge, ve, te]
|
|
311
|
+
);
|
|
312
|
+
Ke(b, () => ue, [ue]), He(et, ue, o);
|
|
313
|
+
const Ae = Q(
|
|
314
|
+
(e) => {
|
|
315
|
+
if (!s) return;
|
|
316
|
+
const r = e.metaKey || e.ctrlKey;
|
|
317
|
+
if (e.key === "PageDown") {
|
|
318
|
+
e.preventDefault(), F(u + 1);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (e.key === "PageUp") {
|
|
322
|
+
e.preventDefault(), F(u - 1);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (e.key === "Home") {
|
|
326
|
+
e.preventDefault(), F(1);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (e.key === "End") {
|
|
330
|
+
e.preventDefault(), F(s.numPages);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (r && e.key.toLowerCase() === "f") {
|
|
334
|
+
e.preventDefault(), f(!0);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (r && (e.key === "+" || e.key === "=")) {
|
|
338
|
+
e.preventDefault(), D((c) => Y(c) ? Math.min(c * 1.25, 4) : 1.25);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (r && e.key === "-") {
|
|
342
|
+
e.preventDefault(), D(
|
|
343
|
+
(c) => Y(c) ? Math.max(c / 1.25, 0.25) : 0.75
|
|
344
|
+
);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (r && e.key === "0") {
|
|
348
|
+
e.preventDefault(), D("fit-width");
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
r && e.key.toLowerCase() === "p" && (e.preventDefault(), te());
|
|
352
|
+
},
|
|
353
|
+
[u, F, te, s]
|
|
354
|
+
), fe = E(u);
|
|
355
|
+
O(() => {
|
|
356
|
+
fe.current = u;
|
|
357
|
+
}, [u]), O(() => {
|
|
358
|
+
if (!s) return;
|
|
359
|
+
const e = oe.current;
|
|
360
|
+
if (!e) return;
|
|
361
|
+
const r = /* @__PURE__ */ new Map(), c = new IntersectionObserver(
|
|
362
|
+
(d) => {
|
|
363
|
+
for (const V of d) {
|
|
364
|
+
const G = V.target.dataset.pageNumber;
|
|
365
|
+
if (!G) continue;
|
|
366
|
+
const _e = Number(G);
|
|
367
|
+
r.set(_e, V.intersectionRatio);
|
|
368
|
+
}
|
|
369
|
+
let j = fe.current, H = 0, J = 1 / 0, $ = -1 / 0;
|
|
370
|
+
for (const [V, G] of r.entries())
|
|
371
|
+
G > H && (j = V, H = G), G > 0 && (J = Math.min(J, V), $ = Math.max($, V));
|
|
372
|
+
H > 0 && j !== fe.current && R(j), J !== 1 / 0 && B({
|
|
373
|
+
start: Math.max(1, J - 1),
|
|
374
|
+
end: Math.min(s.numPages, $ + 1)
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
{ root: e, threshold: [0, 0.25, 0.5, 0.75, 1] }
|
|
378
|
+
);
|
|
379
|
+
return le.current.forEach((d) => {
|
|
380
|
+
d && c.observe(d);
|
|
381
|
+
}), () => c.disconnect();
|
|
382
|
+
}, [s]);
|
|
383
|
+
const [je, Fe] = y(0);
|
|
384
|
+
O(() => {
|
|
385
|
+
const e = oe.current;
|
|
386
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
387
|
+
const r = new ResizeObserver(() => {
|
|
388
|
+
(C === "fit-width" || C === "fit-page") && Fe((c) => c + 1);
|
|
389
|
+
});
|
|
390
|
+
return r.observe(e), () => r.disconnect();
|
|
391
|
+
}, [C]);
|
|
392
|
+
const be = E([]), [ie, ye] = y(0), Ve = Q(
|
|
393
|
+
(e) => (r) => {
|
|
394
|
+
be.current[e] = r;
|
|
395
|
+
},
|
|
396
|
+
[]
|
|
397
|
+
), xe = Q((e) => {
|
|
398
|
+
const r = be.current[e];
|
|
399
|
+
r && r.focus();
|
|
400
|
+
}, []), de = L === "minimal" ? 2 : 8, Ee = Q(
|
|
401
|
+
(e) => {
|
|
402
|
+
const r = A ? "ArrowLeft" : "ArrowRight", c = A ? "ArrowRight" : "ArrowLeft";
|
|
403
|
+
let d = null;
|
|
404
|
+
e.key === r ? d = (ie + 1) % de : e.key === c ? d = (ie - 1 + de) % de : e.key === "Home" ? d = 0 : e.key === "End" && (d = de - 1), d !== null && (e.preventDefault(), ye(d), xe(d));
|
|
405
|
+
},
|
|
406
|
+
[xe, A, ie]
|
|
407
|
+
);
|
|
408
|
+
return i ? /* @__PURE__ */ a(
|
|
409
|
+
"div",
|
|
410
|
+
{
|
|
411
|
+
className: [Pe(), S].filter(Boolean).join(" "),
|
|
412
|
+
"aria-label": P ?? l("pdf.error"),
|
|
413
|
+
children: /* @__PURE__ */ a("div", { className: "ds:p-[var(--spacing-lg)]", children: /* @__PURE__ */ a(ze, { variant: "error", live: "polite", children: /* @__PURE__ */ _(ze.Description, { children: [
|
|
414
|
+
l("pdf.error"),
|
|
415
|
+
": ",
|
|
416
|
+
i.message
|
|
417
|
+
] }) }) })
|
|
418
|
+
}
|
|
419
|
+
) : (
|
|
420
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- region-level keyboard shortcuts (search, zoom) intentionally captured at the wrapper for the entire PDF viewer
|
|
421
|
+
/* @__PURE__ */ _(
|
|
422
|
+
"div",
|
|
423
|
+
{
|
|
424
|
+
id: M,
|
|
425
|
+
role: "region",
|
|
426
|
+
"aria-label": P ?? l("pdf.toolbarLabel"),
|
|
427
|
+
className: [Pe(), S].filter(Boolean).join(" "),
|
|
428
|
+
dir: A ? "rtl" : void 0,
|
|
429
|
+
onKeyDown: Ae,
|
|
430
|
+
tabIndex: -1,
|
|
431
|
+
"data-component": "pdf-viewer",
|
|
432
|
+
"data-component-id": o,
|
|
433
|
+
"data-pdfjs-worker-src": De,
|
|
434
|
+
children: [
|
|
435
|
+
z ? /* @__PURE__ */ a(
|
|
436
|
+
it,
|
|
437
|
+
{
|
|
438
|
+
variant: L,
|
|
439
|
+
currentPage: u,
|
|
440
|
+
numPages: (s == null ? void 0 : s.numPages) ?? 0,
|
|
441
|
+
zoom: C,
|
|
442
|
+
onPrev: () => F(u - 1),
|
|
443
|
+
onNext: () => F(u + 1),
|
|
444
|
+
onJump: (e) => F(e),
|
|
445
|
+
onZoomIn: () => {
|
|
446
|
+
D(
|
|
447
|
+
(e) => Y(e) ? Math.min(e * 1.25, 4) : 1.25
|
|
448
|
+
);
|
|
449
|
+
},
|
|
450
|
+
onZoomOut: () => {
|
|
451
|
+
D(
|
|
452
|
+
(e) => Y(e) ? Math.max(e / 1.25, 0.25) : 0.75
|
|
453
|
+
);
|
|
454
|
+
},
|
|
455
|
+
onZoomPreset: (e) => D(e),
|
|
456
|
+
onOpenSearch: () => f(!0),
|
|
457
|
+
onPrint: te,
|
|
458
|
+
searchOpen: n,
|
|
459
|
+
onSearchOpenChange: f,
|
|
460
|
+
searchQuery: ee,
|
|
461
|
+
onSearchQueryChange: (e) => {
|
|
462
|
+
he(e);
|
|
463
|
+
},
|
|
464
|
+
searchMatches: Re,
|
|
465
|
+
register: Ve,
|
|
466
|
+
focusIndex: ie,
|
|
467
|
+
setFocusIndex: ye,
|
|
468
|
+
onToolbarKeyDown: Ee,
|
|
469
|
+
isRtl: A
|
|
470
|
+
}
|
|
471
|
+
) : null,
|
|
472
|
+
/* @__PURE__ */ a("div", { "aria-live": "polite", "aria-atomic": "true", className: "ds:sr-only", children: U }),
|
|
473
|
+
/* @__PURE__ */ a(
|
|
474
|
+
"div",
|
|
475
|
+
{
|
|
476
|
+
ref: oe,
|
|
477
|
+
className: nt(),
|
|
478
|
+
"data-testid": "pdf-pages-container",
|
|
479
|
+
tabIndex: 0,
|
|
480
|
+
"aria-label": l("pdf.pagesRegionLabel"),
|
|
481
|
+
children: s ? Array.from({ length: s.numPages }, (e, r) => r + 1).map(
|
|
482
|
+
(e) => /* @__PURE__ */ a(
|
|
483
|
+
dt,
|
|
484
|
+
{
|
|
485
|
+
pageNumber: e,
|
|
486
|
+
totalPages: s.numPages,
|
|
487
|
+
doc: s.doc,
|
|
488
|
+
zoom: C,
|
|
489
|
+
pageRotation: h,
|
|
490
|
+
renderPageOverlay: g,
|
|
491
|
+
container: oe.current,
|
|
492
|
+
resizeTick: je,
|
|
493
|
+
shouldRender: e >= Z.start && e <= Z.end,
|
|
494
|
+
registerRef: (r) => {
|
|
495
|
+
le.current[e - 1] = r;
|
|
496
|
+
},
|
|
497
|
+
searchQuery: ee,
|
|
498
|
+
onMatchCount: (r) => {
|
|
499
|
+
Te((c) => r === 0 && c.total === 0 ? c : {
|
|
500
|
+
current: Math.min(c.current || 1, r || 1),
|
|
501
|
+
total: Math.max(c.total, r)
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
e
|
|
506
|
+
)
|
|
507
|
+
) : /* @__PURE__ */ _("div", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)] ds:text-[var(--muted-foreground)] ds:p-[var(--spacing-lg)]", children: [
|
|
508
|
+
/* @__PURE__ */ a(Be, { size: "sm", label: l("pdf.loading") }),
|
|
509
|
+
/* @__PURE__ */ a("span", { children: l("pdf.loading") })
|
|
510
|
+
] })
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
]
|
|
514
|
+
}
|
|
515
|
+
)
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
);
|
|
519
|
+
ot.displayName = "PDFViewer";
|
|
520
|
+
function it(o) {
|
|
521
|
+
const { t } = me(), {
|
|
522
|
+
variant: v,
|
|
523
|
+
currentPage: m,
|
|
524
|
+
numPages: h,
|
|
525
|
+
zoom: g,
|
|
526
|
+
onPrev: x,
|
|
527
|
+
onNext: w,
|
|
528
|
+
onJump: k,
|
|
529
|
+
onZoomIn: z,
|
|
530
|
+
onZoomOut: L,
|
|
531
|
+
onZoomPreset: P,
|
|
532
|
+
onOpenSearch: S,
|
|
533
|
+
onPrint: b,
|
|
534
|
+
searchOpen: l,
|
|
535
|
+
onSearchOpenChange: I,
|
|
536
|
+
searchQuery: M,
|
|
537
|
+
onSearchQueryChange: A,
|
|
538
|
+
searchMatches: p,
|
|
539
|
+
register: K,
|
|
540
|
+
focusIndex: W,
|
|
541
|
+
setFocusIndex: s,
|
|
542
|
+
onToolbarKeyDown: q
|
|
543
|
+
} = o, i = v === "minimal", N = i ? 0 : 3, u = i ? 1 : 4, R = 5, [C, D] = y(String(m));
|
|
544
|
+
O(() => {
|
|
545
|
+
D(String(m));
|
|
546
|
+
}, [m]);
|
|
547
|
+
const Z = m <= 1, B = m >= h;
|
|
548
|
+
function U() {
|
|
549
|
+
const n = Number(C);
|
|
550
|
+
Number.isFinite(n) && n >= 1 ? k(Math.min(n, h)) : D(String(m));
|
|
551
|
+
}
|
|
552
|
+
function T(n) {
|
|
553
|
+
return /* @__PURE__ */ a(
|
|
554
|
+
"button",
|
|
555
|
+
{
|
|
556
|
+
type: "button",
|
|
557
|
+
ref: K(n.index),
|
|
558
|
+
tabIndex: n.index === W ? 0 : -1,
|
|
559
|
+
onFocus: () => s(n.index),
|
|
560
|
+
onKeyDown: q,
|
|
561
|
+
"aria-label": n.label,
|
|
562
|
+
"aria-disabled": n.disabled || void 0,
|
|
563
|
+
title: n.label,
|
|
564
|
+
onClick: (f) => {
|
|
565
|
+
if (n.disabled) {
|
|
566
|
+
f.preventDefault();
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
n.onActivate();
|
|
570
|
+
},
|
|
571
|
+
className: Se(),
|
|
572
|
+
children: n.icon
|
|
573
|
+
}
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
return /* @__PURE__ */ _(
|
|
577
|
+
"div",
|
|
578
|
+
{
|
|
579
|
+
role: "toolbar",
|
|
580
|
+
"aria-label": t("pdf.toolbarLabel"),
|
|
581
|
+
className: tt(),
|
|
582
|
+
children: [
|
|
583
|
+
!i && /* @__PURE__ */ _(we, { children: [
|
|
584
|
+
T({
|
|
585
|
+
index: 0,
|
|
586
|
+
label: t("pdf.previousPage"),
|
|
587
|
+
disabled: Z,
|
|
588
|
+
onActivate: x,
|
|
589
|
+
icon: /* @__PURE__ */ a(
|
|
590
|
+
We,
|
|
591
|
+
{
|
|
592
|
+
"aria-hidden": "true",
|
|
593
|
+
className: "ds:block-size-4 ds:inline-size-4 ds:rtl:rotate-180"
|
|
594
|
+
}
|
|
595
|
+
)
|
|
596
|
+
}),
|
|
597
|
+
T({
|
|
598
|
+
index: 1,
|
|
599
|
+
label: t("pdf.nextPage"),
|
|
600
|
+
disabled: B,
|
|
601
|
+
onActivate: w,
|
|
602
|
+
icon: /* @__PURE__ */ a(
|
|
603
|
+
qe,
|
|
604
|
+
{
|
|
605
|
+
"aria-hidden": "true",
|
|
606
|
+
className: "ds:block-size-4 ds:inline-size-4 ds:rtl:rotate-180"
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
}),
|
|
610
|
+
/* @__PURE__ */ a(
|
|
611
|
+
"input",
|
|
612
|
+
{
|
|
613
|
+
type: "number",
|
|
614
|
+
min: 1,
|
|
615
|
+
max: Math.max(h, 1),
|
|
616
|
+
value: C,
|
|
617
|
+
onChange: (n) => D(n.target.value),
|
|
618
|
+
onKeyDown: (n) => {
|
|
619
|
+
n.key === "Enter" && (n.preventDefault(), U());
|
|
620
|
+
},
|
|
621
|
+
onBlur: U,
|
|
622
|
+
onFocus: () => s(2),
|
|
623
|
+
ref: K(2),
|
|
624
|
+
tabIndex: W === 2 ? 0 : -1,
|
|
625
|
+
"aria-label": t("pdf.currentPageInput"),
|
|
626
|
+
className: Ie()
|
|
627
|
+
}
|
|
628
|
+
),
|
|
629
|
+
/* @__PURE__ */ a(
|
|
630
|
+
"span",
|
|
631
|
+
{
|
|
632
|
+
"aria-hidden": "true",
|
|
633
|
+
className: "type-body-sm ds:text-[var(--muted-foreground)]",
|
|
634
|
+
children: t("pdf.pageOf", { current: m, total: h || 0 })
|
|
635
|
+
}
|
|
636
|
+
),
|
|
637
|
+
/* @__PURE__ */ a(
|
|
638
|
+
"span",
|
|
639
|
+
{
|
|
640
|
+
"aria-hidden": "true",
|
|
641
|
+
className: "ds:inline-block ds:block-size-6 ds:inline-size-px ds:bg-[var(--border)] ds:ms-[var(--spacing-xs)] ds:me-[var(--spacing-xs)]"
|
|
642
|
+
}
|
|
643
|
+
)
|
|
644
|
+
] }),
|
|
645
|
+
T({
|
|
646
|
+
index: N,
|
|
647
|
+
label: t("pdf.zoom.out"),
|
|
648
|
+
onActivate: L,
|
|
649
|
+
icon: /* @__PURE__ */ a(
|
|
650
|
+
Ye,
|
|
651
|
+
{
|
|
652
|
+
"aria-hidden": "true",
|
|
653
|
+
className: "ds:block-size-4 ds:inline-size-4"
|
|
654
|
+
}
|
|
655
|
+
)
|
|
656
|
+
}),
|
|
657
|
+
T({
|
|
658
|
+
index: u,
|
|
659
|
+
label: t("pdf.zoom.in"),
|
|
660
|
+
onActivate: z,
|
|
661
|
+
icon: /* @__PURE__ */ a(
|
|
662
|
+
Xe,
|
|
663
|
+
{
|
|
664
|
+
"aria-hidden": "true",
|
|
665
|
+
className: "ds:block-size-4 ds:inline-size-4"
|
|
666
|
+
}
|
|
667
|
+
)
|
|
668
|
+
}),
|
|
669
|
+
!i && /* @__PURE__ */ _(
|
|
670
|
+
"select",
|
|
671
|
+
{
|
|
672
|
+
"aria-label": t("pdf.zoom.preset"),
|
|
673
|
+
value: typeof g == "number" ? String(g) : g,
|
|
674
|
+
onChange: (n) => {
|
|
675
|
+
const f = n.target.value;
|
|
676
|
+
if (f === "fit-width" || f === "fit-page" || f === "actual-size")
|
|
677
|
+
P(f);
|
|
678
|
+
else {
|
|
679
|
+
const ee = Number(f);
|
|
680
|
+
Number.isFinite(ee) && P(ee);
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
ref: K(R),
|
|
684
|
+
tabIndex: W === R ? 0 : -1,
|
|
685
|
+
onFocus: () => s(R),
|
|
686
|
+
onKeyDown: q,
|
|
687
|
+
className: rt(),
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ a("option", { value: "fit-width", children: t("pdf.zoom.fitWidth") }),
|
|
690
|
+
/* @__PURE__ */ a("option", { value: "fit-page", children: t("pdf.zoom.fitPage") }),
|
|
691
|
+
/* @__PURE__ */ a("option", { value: "actual-size", children: t("pdf.zoom.actualSize") }),
|
|
692
|
+
st.filter(Y).map((n) => /* @__PURE__ */ a("option", { value: String(n), children: `${Math.round(n * 100)}%` }, n))
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
),
|
|
696
|
+
!i && /* @__PURE__ */ _(we, { children: [
|
|
697
|
+
/* @__PURE__ */ _(
|
|
698
|
+
re.Root,
|
|
699
|
+
{
|
|
700
|
+
open: l,
|
|
701
|
+
onOpenChange: I,
|
|
702
|
+
children: [
|
|
703
|
+
/* @__PURE__ */ a(re.Trigger, { asChild: !0, children: T({
|
|
704
|
+
index: 6,
|
|
705
|
+
label: t("pdf.search.open"),
|
|
706
|
+
onActivate: S,
|
|
707
|
+
icon: /* @__PURE__ */ a(
|
|
708
|
+
Ue,
|
|
709
|
+
{
|
|
710
|
+
"aria-hidden": "true",
|
|
711
|
+
className: "ds:block-size-4 ds:inline-size-4"
|
|
712
|
+
}
|
|
713
|
+
)
|
|
714
|
+
}) }),
|
|
715
|
+
/* @__PURE__ */ a(re.Portal, { children: /* @__PURE__ */ _(
|
|
716
|
+
re.Content,
|
|
717
|
+
{
|
|
718
|
+
sideOffset: 8,
|
|
719
|
+
className: [
|
|
720
|
+
"ds:z-[var(--z-popover)]",
|
|
721
|
+
"ds:bg-[var(--popover)] ds:text-[var(--popover-foreground)]",
|
|
722
|
+
"ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
|
|
723
|
+
"ds:shadow-[var(--shadow-lg)]",
|
|
724
|
+
"ds:p-[var(--spacing-sm)]",
|
|
725
|
+
"ds:flex ds:items-center ds:gap-[var(--spacing-xs)]"
|
|
726
|
+
].join(" "),
|
|
727
|
+
children: [
|
|
728
|
+
/* @__PURE__ */ a(
|
|
729
|
+
"input",
|
|
730
|
+
{
|
|
731
|
+
type: "search",
|
|
732
|
+
autoFocus: !0,
|
|
733
|
+
value: M,
|
|
734
|
+
onChange: (n) => A(n.target.value),
|
|
735
|
+
placeholder: t("pdf.search.placeholder"),
|
|
736
|
+
"aria-label": t("pdf.search.placeholder"),
|
|
737
|
+
className: Ie({
|
|
738
|
+
className: "ds:inline-size-[16rem] ds:text-start"
|
|
739
|
+
})
|
|
740
|
+
}
|
|
741
|
+
),
|
|
742
|
+
/* @__PURE__ */ a(
|
|
743
|
+
"span",
|
|
744
|
+
{
|
|
745
|
+
"aria-live": "polite",
|
|
746
|
+
className: "type-meta ds:text-[var(--muted-foreground)]",
|
|
747
|
+
children: p.total > 0 ? t("pdf.search.countOfTotal", {
|
|
748
|
+
current: p.current,
|
|
749
|
+
total: p.total
|
|
750
|
+
}) : M ? t("pdf.search.noResults") : ""
|
|
751
|
+
}
|
|
752
|
+
),
|
|
753
|
+
/* @__PURE__ */ a(re.Close, { asChild: !0, children: /* @__PURE__ */ a(
|
|
754
|
+
"button",
|
|
755
|
+
{
|
|
756
|
+
type: "button",
|
|
757
|
+
"aria-label": t("pdf.search.close"),
|
|
758
|
+
className: Se(),
|
|
759
|
+
children: /* @__PURE__ */ a(
|
|
760
|
+
Qe,
|
|
761
|
+
{
|
|
762
|
+
"aria-hidden": "true",
|
|
763
|
+
className: "ds:block-size-4 ds:inline-size-4"
|
|
764
|
+
}
|
|
765
|
+
)
|
|
766
|
+
}
|
|
767
|
+
) })
|
|
768
|
+
]
|
|
769
|
+
}
|
|
770
|
+
) })
|
|
771
|
+
]
|
|
772
|
+
}
|
|
773
|
+
),
|
|
774
|
+
T({
|
|
775
|
+
index: 7,
|
|
776
|
+
label: t("pdf.print"),
|
|
777
|
+
onActivate: b,
|
|
778
|
+
icon: /* @__PURE__ */ a(
|
|
779
|
+
Je,
|
|
780
|
+
{
|
|
781
|
+
"aria-hidden": "true",
|
|
782
|
+
className: "ds:block-size-4 ds:inline-size-4"
|
|
783
|
+
}
|
|
784
|
+
)
|
|
785
|
+
})
|
|
786
|
+
] })
|
|
787
|
+
]
|
|
788
|
+
}
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
function dt(o) {
|
|
792
|
+
const {
|
|
793
|
+
pageNumber: t,
|
|
794
|
+
totalPages: v,
|
|
795
|
+
doc: m,
|
|
796
|
+
zoom: h,
|
|
797
|
+
pageRotation: g,
|
|
798
|
+
renderPageOverlay: x,
|
|
799
|
+
container: w,
|
|
800
|
+
resizeTick: k,
|
|
801
|
+
shouldRender: z,
|
|
802
|
+
registerRef: L,
|
|
803
|
+
searchQuery: P,
|
|
804
|
+
onMatchCount: S
|
|
805
|
+
} = o, { t: b } = me(), l = E(null), I = E(null), [M, A] = y({
|
|
806
|
+
width: 612,
|
|
807
|
+
height: 792
|
|
808
|
+
}), [p, K] = y(null);
|
|
809
|
+
O(() => {
|
|
810
|
+
let i = !1;
|
|
811
|
+
return m.getPage(t).then((N) => {
|
|
812
|
+
i || K(N);
|
|
813
|
+
}), () => {
|
|
814
|
+
i = !0;
|
|
815
|
+
};
|
|
816
|
+
}, [m, t]), O(() => {
|
|
817
|
+
if (!p) return;
|
|
818
|
+
const i = (C) => g === void 0 ? { scale: C } : { scale: C, rotation: g }, N = p.getViewport(i(1)), u = Me(h, N, w), R = p.getViewport(i(u));
|
|
819
|
+
A({
|
|
820
|
+
width: Math.floor(R.width),
|
|
821
|
+
height: Math.floor(R.height)
|
|
822
|
+
});
|
|
823
|
+
}, [p, h, w, k, g]);
|
|
824
|
+
const W = g ?? (p == null ? void 0 : p.rotate) ?? 0;
|
|
825
|
+
O(() => {
|
|
826
|
+
if (!p || !z) {
|
|
827
|
+
const f = l.current;
|
|
828
|
+
f && !z && (f.width = 0);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
const i = l.current, N = I.current;
|
|
832
|
+
if (!i) return;
|
|
833
|
+
const u = i.getContext("2d");
|
|
834
|
+
if (!u) return;
|
|
835
|
+
const R = (f) => g === void 0 ? { scale: f } : { scale: f, rotation: g }, C = p.getViewport(R(1)), D = Me(h, C, w), Z = p.getViewport(R(D)), B = Math.max(1, window.devicePixelRatio || 1);
|
|
836
|
+
i.width = Math.floor(Z.width * B), i.height = Math.floor(Z.height * B), u.setTransform(B, 0, 0, B, 0, 0);
|
|
837
|
+
const U = p.render({
|
|
838
|
+
canvas: i,
|
|
839
|
+
canvasContext: u,
|
|
840
|
+
viewport: Z
|
|
841
|
+
});
|
|
842
|
+
let T = !1, n = null;
|
|
843
|
+
return U.promise.then(async () => {
|
|
844
|
+
if (T || !N) return;
|
|
845
|
+
N.textContent = "";
|
|
846
|
+
const f = await p.getTextContent();
|
|
847
|
+
T || (n = new pe.TextLayer({
|
|
848
|
+
textContentSource: f,
|
|
849
|
+
container: N,
|
|
850
|
+
viewport: Z
|
|
851
|
+
}), await n.render(), Ce(N, P, S));
|
|
852
|
+
}).catch(() => {
|
|
853
|
+
}), () => {
|
|
854
|
+
T = !0;
|
|
855
|
+
try {
|
|
856
|
+
U.cancel();
|
|
857
|
+
} catch {
|
|
858
|
+
}
|
|
859
|
+
if (n)
|
|
860
|
+
try {
|
|
861
|
+
n.cancel();
|
|
862
|
+
} catch {
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
}, [
|
|
866
|
+
p,
|
|
867
|
+
z,
|
|
868
|
+
h,
|
|
869
|
+
w,
|
|
870
|
+
k,
|
|
871
|
+
P,
|
|
872
|
+
S,
|
|
873
|
+
g
|
|
874
|
+
]), O(() => {
|
|
875
|
+
if (!z) return;
|
|
876
|
+
const i = I.current;
|
|
877
|
+
i && Ce(i, P, S);
|
|
878
|
+
}, [P, z, S]);
|
|
879
|
+
const s = {
|
|
880
|
+
width: M.width,
|
|
881
|
+
height: M.height
|
|
882
|
+
}, q = {
|
|
883
|
+
width: M.width,
|
|
884
|
+
height: M.height
|
|
885
|
+
};
|
|
886
|
+
return /* @__PURE__ */ _(
|
|
887
|
+
"article",
|
|
888
|
+
{
|
|
889
|
+
ref: (i) => {
|
|
890
|
+
L(i);
|
|
891
|
+
},
|
|
892
|
+
"data-page-number": t,
|
|
893
|
+
"aria-label": b("pdf.pageOf", { current: t, total: v }),
|
|
894
|
+
className: at(),
|
|
895
|
+
style: q,
|
|
896
|
+
children: [
|
|
897
|
+
/* @__PURE__ */ a("canvas", { ref: l, style: s }),
|
|
898
|
+
/* @__PURE__ */ a(
|
|
899
|
+
"div",
|
|
900
|
+
{
|
|
901
|
+
ref: I,
|
|
902
|
+
"aria-hidden": "false",
|
|
903
|
+
className: [
|
|
904
|
+
"ds:absolute ds:inset-0",
|
|
905
|
+
"ds:overflow-hidden",
|
|
906
|
+
"ds:select-text",
|
|
907
|
+
"ds:opacity-100",
|
|
908
|
+
"ds:[&>span]:absolute ds:[&>span]:whitespace-pre",
|
|
909
|
+
"ds:[&>span]:text-transparent ds:[&>span]:origin-[0_0]",
|
|
910
|
+
"ds:[&_[data-match=true]]:bg-[color-mix(in_srgb,var(--warning)_35%,transparent)]",
|
|
911
|
+
"ds:[&_[data-match=current]]:bg-[color-mix(in_srgb,var(--warning)_60%,transparent)]"
|
|
912
|
+
].join(" ")
|
|
913
|
+
}
|
|
914
|
+
),
|
|
915
|
+
z && x ? /* @__PURE__ */ a(
|
|
916
|
+
"div",
|
|
917
|
+
{
|
|
918
|
+
role: "group",
|
|
919
|
+
"aria-label": b("pdf.pageOverlay", { page: t }),
|
|
920
|
+
className: "ds:absolute ds:inset-0 ds:pointer-events-auto",
|
|
921
|
+
"data-pdf-page-overlay": "",
|
|
922
|
+
"data-page-number": t,
|
|
923
|
+
children: x({
|
|
924
|
+
pageNumber: t,
|
|
925
|
+
pageWidthCss: M.width,
|
|
926
|
+
pageHeightCss: M.height,
|
|
927
|
+
rotation: W
|
|
928
|
+
})
|
|
929
|
+
}
|
|
930
|
+
) : null
|
|
931
|
+
]
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function Ne(o) {
|
|
936
|
+
return o.normalize("NFKD").replace(new RegExp("\\p{Diacritic}", "gu"), "").toLowerCase();
|
|
937
|
+
}
|
|
938
|
+
function Ce(o, t, v) {
|
|
939
|
+
if (o.querySelectorAll("[data-match]").forEach((b) => {
|
|
940
|
+
b.removeAttribute("data-match");
|
|
941
|
+
}), !t) {
|
|
942
|
+
v(0);
|
|
943
|
+
return;
|
|
944
|
+
}
|
|
945
|
+
const h = Ne(t);
|
|
946
|
+
if (!h) {
|
|
947
|
+
v(0);
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
const g = Array.from(o.querySelectorAll("span")), x = [], w = [];
|
|
951
|
+
let k = 0;
|
|
952
|
+
for (const b of g) {
|
|
953
|
+
const l = Ne(b.textContent ?? "");
|
|
954
|
+
x.push({ start: k, end: k + l.length }), w.push(l), k += l.length;
|
|
955
|
+
}
|
|
956
|
+
const z = w.join("");
|
|
957
|
+
let L = 0;
|
|
958
|
+
const P = /* @__PURE__ */ new Set();
|
|
959
|
+
let S = 0;
|
|
960
|
+
for (; S <= z.length - h.length; ) {
|
|
961
|
+
const b = z.indexOf(h, S);
|
|
962
|
+
if (b === -1) break;
|
|
963
|
+
L += 1;
|
|
964
|
+
const l = b + h.length;
|
|
965
|
+
for (let I = 0; I < x.length; I++) {
|
|
966
|
+
const { start: M, end: A } = x[I];
|
|
967
|
+
M < l && A > b && P.add(I);
|
|
968
|
+
}
|
|
969
|
+
S = l;
|
|
970
|
+
}
|
|
971
|
+
P.forEach((b) => {
|
|
972
|
+
g[b].setAttribute("data-match", "true");
|
|
973
|
+
}), v(L);
|
|
974
|
+
}
|
|
975
|
+
export {
|
|
976
|
+
ot as P,
|
|
977
|
+
et as p
|
|
978
|
+
};
|
|
979
|
+
//# sourceMappingURL=pdf-viewer-chMpwpA4.js.map
|