@chialab/pdfjs-lib 1.0.0-alpha.18 → 1.0.0-alpha.19

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.
Files changed (37) hide show
  1. package/dist/browser/NodeCanvasFactory-OREYUFNU.js +58 -0
  2. package/dist/browser/chunk-5IWODJWD.js +801 -0
  3. package/dist/browser/chunk-MXRUYXDD.js +1127 -0
  4. package/dist/browser/{chunk-O4CM6PII.js → chunk-NJUB3B5A.js} +5 -787
  5. package/dist/browser/index.js +68 -1107
  6. package/dist/browser/worker.js +16 -14
  7. package/dist/lib/NodeCanvasFactory.d.ts +9 -0
  8. package/dist/lib/NodeFilterFactory.d.ts +10 -0
  9. package/dist/lib/utils.d.ts +1 -1
  10. package/dist/node/NodeCanvasFactory-N32SOXPQ.js +8 -0
  11. package/dist/node/chunk-QCIN557M.js +1424 -0
  12. package/dist/node/{chunk-4FQTXXTH.js → chunk-XMKSLA4K.js} +5 -787
  13. package/dist/node/chunk-ZKUTXCS2.js +801 -0
  14. package/dist/node/index.js +115 -1482
  15. package/dist/node/worker.js +16 -14
  16. package/dist/pdf.js/src/display/api.d.ts +5 -5
  17. package/dist/pdf.js/src/display/display_utils.d.ts +1 -1
  18. package/dist/pdf.js/src/display/draw_layer.d.ts +2 -2
  19. package/dist/pdf.js/src/display/editor/alt_text.d.ts +1 -1
  20. package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +1 -1
  21. package/dist/pdf.js/src/display/editor/color_picker.d.ts +1 -1
  22. package/dist/pdf.js/src/display/editor/draw.d.ts +7 -7
  23. package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +3 -3
  24. package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +13 -13
  25. package/dist/pdf.js/src/display/editor/editor.d.ts +1 -1
  26. package/dist/pdf.js/src/display/editor/freetext.d.ts +2 -2
  27. package/dist/pdf.js/src/display/editor/highlight.d.ts +4 -4
  28. package/dist/pdf.js/src/display/editor/stamp.d.ts +1 -1
  29. package/dist/pdf.js/src/display/editor/toolbar.d.ts +2 -2
  30. package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
  31. package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
  32. package/dist/pdf.js/src/shared/util.d.ts +2 -2
  33. package/dist/pdf.js/web/text_accessibility.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/dist/pdf.js/src/display/cmap_reader_factory.d.ts +0 -25
  36. package/dist/pdf.js/src/display/node_utils.d.ts +0 -32
  37. package/dist/pdf.js/src/display/wasm_factory.d.ts +0 -20
@@ -1,3 +1,42 @@
1
+ import {
2
+ ColorConverters,
3
+ MessageHandler,
4
+ MurmurHash3_64,
5
+ convertBlackAndWhiteToRGBA,
6
+ wrapReason
7
+ } from "./chunk-5IWODJWD.js";
8
+ import {
9
+ DOMCanvasFactory,
10
+ DOMFilterFactory,
11
+ OutputScale,
12
+ PDFDateString,
13
+ PageViewport,
14
+ PixelsPerInch,
15
+ RenderingCancelledException,
16
+ SVG_NS,
17
+ StatTimer,
18
+ SupportedImageMimeTypes,
19
+ canvasToData,
20
+ colorToRgb,
21
+ deprecated,
22
+ fetchData,
23
+ getColorValues,
24
+ getCurrentTransform,
25
+ getCurrentTransformInverse,
26
+ getFilenameFromUrl,
27
+ getPdfFilenameFromUrl,
28
+ getRGB,
29
+ getXfaPageViewport,
30
+ isDataScheme,
31
+ isPdfFile,
32
+ isValidFetchUrl,
33
+ makeSerializable,
34
+ noContextMenu,
35
+ rgbToHex,
36
+ setLayerDimensions,
37
+ stopEvent,
38
+ toDataUrl
39
+ } from "./chunk-MXRUYXDD.js";
1
40
  import {
2
41
  AbortException,
3
42
  AnnotationBorderStyleType,
@@ -7,8 +46,6 @@ import {
7
46
  AnnotationMode,
8
47
  AnnotationPrefix,
9
48
  AnnotationType,
10
- BaseException,
11
- ColorConverters,
12
49
  DrawOPS,
13
50
  FONT_IDENTITY_MATRIX,
14
51
  FeatureTest,
@@ -17,8 +54,6 @@ import {
17
54
  InvalidPDFException,
18
55
  LINE_FACTOR,
19
56
  MathClamp,
20
- MessageHandler,
21
- MurmurHash3_64,
22
57
  OPS,
23
58
  PasswordResponses,
24
59
  PermissionFlag,
@@ -29,7 +64,6 @@ import {
29
64
  VerbosityLevel,
30
65
  _isValidExplicitDest,
31
66
  assert,
32
- convertBlackAndWhiteToRGBA,
33
67
  createValidAbsoluteUrl,
34
68
  fromBase64Util,
35
69
  getUuid,
@@ -44,9 +78,8 @@ import {
44
78
  toBase64Util,
45
79
  unreachable,
46
80
  updateUrlHash,
47
- warn,
48
- wrapReason
49
- } from "./chunk-O4CM6PII.js";
81
+ warn
82
+ } from "./chunk-NJUB3B5A.js";
50
83
  import {
51
84
  __privateAdd,
52
85
  __privateGet,
@@ -56,569 +89,6 @@ import {
56
89
  __publicField
57
90
  } from "./chunk-O4UKW7AD.js";
58
91
 
59
- // src/pdf.js/src/display/display_utils.js
60
- var SVG_NS = "http://www.w3.org/2000/svg";
61
- var _PixelsPerInch = class _PixelsPerInch {
62
- };
63
- __publicField(_PixelsPerInch, "CSS", 96);
64
- __publicField(_PixelsPerInch, "PDF", 72);
65
- __publicField(_PixelsPerInch, "PDF_TO_CSS_UNITS", _PixelsPerInch.CSS / _PixelsPerInch.PDF);
66
- var PixelsPerInch = _PixelsPerInch;
67
- async function fetchData(url, type = "text") {
68
- if (isValidFetchUrl(url, document.baseURI)) {
69
- const response = await fetch(url);
70
- if (!response.ok) {
71
- throw new Error(response.statusText);
72
- }
73
- switch (type) {
74
- case "arraybuffer":
75
- return response.arrayBuffer();
76
- case "blob":
77
- return response.blob();
78
- case "json":
79
- return response.json();
80
- }
81
- return response.text();
82
- }
83
- return new Promise((resolve, reject) => {
84
- const request = new XMLHttpRequest();
85
- request.open(
86
- "GET",
87
- url,
88
- /* async = */
89
- true
90
- );
91
- request.responseType = type;
92
- request.onreadystatechange = () => {
93
- if (request.readyState !== XMLHttpRequest.DONE) {
94
- return;
95
- }
96
- if (request.status === 200 || request.status === 0) {
97
- switch (type) {
98
- case "arraybuffer":
99
- case "blob":
100
- case "json":
101
- resolve(request.response);
102
- return;
103
- }
104
- resolve(request.responseText);
105
- return;
106
- }
107
- reject(new Error(request.statusText));
108
- };
109
- request.send(null);
110
- });
111
- }
112
- var PageViewport = class _PageViewport {
113
- /**
114
- * @param {PageViewportParameters}
115
- */
116
- constructor({
117
- viewBox,
118
- userUnit,
119
- scale,
120
- rotation,
121
- offsetX = 0,
122
- offsetY = 0,
123
- dontFlip = false
124
- }) {
125
- this.viewBox = viewBox;
126
- this.userUnit = userUnit;
127
- this.scale = scale;
128
- this.rotation = rotation;
129
- this.offsetX = offsetX;
130
- this.offsetY = offsetY;
131
- scale *= userUnit;
132
- const centerX = (viewBox[2] + viewBox[0]) / 2;
133
- const centerY = (viewBox[3] + viewBox[1]) / 2;
134
- let rotateA, rotateB, rotateC, rotateD;
135
- rotation %= 360;
136
- if (rotation < 0) {
137
- rotation += 360;
138
- }
139
- switch (rotation) {
140
- case 180:
141
- rotateA = -1;
142
- rotateB = 0;
143
- rotateC = 0;
144
- rotateD = 1;
145
- break;
146
- case 90:
147
- rotateA = 0;
148
- rotateB = 1;
149
- rotateC = 1;
150
- rotateD = 0;
151
- break;
152
- case 270:
153
- rotateA = 0;
154
- rotateB = -1;
155
- rotateC = -1;
156
- rotateD = 0;
157
- break;
158
- case 0:
159
- rotateA = 1;
160
- rotateB = 0;
161
- rotateC = 0;
162
- rotateD = -1;
163
- break;
164
- default:
165
- throw new Error(
166
- "PageViewport: Invalid rotation, must be a multiple of 90 degrees."
167
- );
168
- }
169
- if (dontFlip) {
170
- rotateC = -rotateC;
171
- rotateD = -rotateD;
172
- }
173
- let offsetCanvasX, offsetCanvasY;
174
- let width, height;
175
- if (rotateA === 0) {
176
- offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
177
- offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
178
- width = (viewBox[3] - viewBox[1]) * scale;
179
- height = (viewBox[2] - viewBox[0]) * scale;
180
- } else {
181
- offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
182
- offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
183
- width = (viewBox[2] - viewBox[0]) * scale;
184
- height = (viewBox[3] - viewBox[1]) * scale;
185
- }
186
- this.transform = [
187
- rotateA * scale,
188
- rotateB * scale,
189
- rotateC * scale,
190
- rotateD * scale,
191
- offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
192
- offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
193
- ];
194
- this.width = width;
195
- this.height = height;
196
- }
197
- /**
198
- * The original, un-scaled, viewport dimensions.
199
- * @type {Object}
200
- */
201
- get rawDims() {
202
- const dims = this.viewBox;
203
- return shadow(this, "rawDims", {
204
- pageWidth: dims[2] - dims[0],
205
- pageHeight: dims[3] - dims[1],
206
- pageX: dims[0],
207
- pageY: dims[1]
208
- });
209
- }
210
- /**
211
- * Clones viewport, with optional additional properties.
212
- * @param {PageViewportCloneParameters} [params]
213
- * @returns {PageViewport} Cloned viewport.
214
- */
215
- clone({
216
- scale = this.scale,
217
- rotation = this.rotation,
218
- offsetX = this.offsetX,
219
- offsetY = this.offsetY,
220
- dontFlip = false
221
- } = {}) {
222
- return new _PageViewport({
223
- viewBox: this.viewBox.slice(),
224
- userUnit: this.userUnit,
225
- scale,
226
- rotation,
227
- offsetX,
228
- offsetY,
229
- dontFlip
230
- });
231
- }
232
- /**
233
- * Converts PDF point to the viewport coordinates. For examples, useful for
234
- * converting PDF location into canvas pixel coordinates.
235
- * @param {number} x - The x-coordinate.
236
- * @param {number} y - The y-coordinate.
237
- * @returns {Array} Array containing `x`- and `y`-coordinates of the
238
- * point in the viewport coordinate space.
239
- * @see {@link convertToPdfPoint}
240
- * @see {@link convertToViewportRectangle}
241
- */
242
- convertToViewportPoint(x, y) {
243
- const p = [x, y];
244
- Util.applyTransform(p, this.transform);
245
- return p;
246
- }
247
- /**
248
- * Converts PDF rectangle to the viewport coordinates.
249
- * @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.
250
- * @returns {Array} Array containing corresponding coordinates of the
251
- * rectangle in the viewport coordinate space.
252
- * @see {@link convertToViewportPoint}
253
- */
254
- convertToViewportRectangle(rect) {
255
- const topLeft = [rect[0], rect[1]];
256
- Util.applyTransform(topLeft, this.transform);
257
- const bottomRight = [rect[2], rect[3]];
258
- Util.applyTransform(bottomRight, this.transform);
259
- return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
260
- }
261
- /**
262
- * Converts viewport coordinates to the PDF location. For examples, useful
263
- * for converting canvas pixel location into PDF one.
264
- * @param {number} x - The x-coordinate.
265
- * @param {number} y - The y-coordinate.
266
- * @returns {Array} Array containing `x`- and `y`-coordinates of the
267
- * point in the PDF coordinate space.
268
- * @see {@link convertToViewportPoint}
269
- */
270
- convertToPdfPoint(x, y) {
271
- const p = [x, y];
272
- Util.applyInverseTransform(p, this.transform);
273
- return p;
274
- }
275
- };
276
- var RenderingCancelledException = class extends BaseException {
277
- constructor(msg, extraDelay = 0) {
278
- super(msg, "RenderingCancelledException");
279
- this.extraDelay = extraDelay;
280
- }
281
- };
282
- function isDataScheme(url) {
283
- const ii = url.length;
284
- let i = 0;
285
- while (i < ii && url[i].trim() === "") {
286
- i++;
287
- }
288
- return url.substring(i, i + 5).toLowerCase() === "data:";
289
- }
290
- function isPdfFile(filename) {
291
- return typeof filename === "string" && /\.pdf$/i.test(filename);
292
- }
293
- function getFilenameFromUrl(url) {
294
- [url] = url.split(/[#?]/, 1);
295
- return url.substring(url.lastIndexOf("/") + 1);
296
- }
297
- function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
298
- if (typeof url !== "string") {
299
- return defaultFilename;
300
- }
301
- if (isDataScheme(url)) {
302
- warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');
303
- return defaultFilename;
304
- }
305
- const getURL = (urlString) => {
306
- try {
307
- return new URL(urlString);
308
- } catch {
309
- try {
310
- return new URL(decodeURIComponent(urlString));
311
- } catch {
312
- try {
313
- return new URL(urlString, "https://foo.bar");
314
- } catch {
315
- try {
316
- return new URL(decodeURIComponent(urlString), "https://foo.bar");
317
- } catch {
318
- return null;
319
- }
320
- }
321
- }
322
- }
323
- };
324
- const newURL = getURL(url);
325
- if (!newURL) {
326
- return defaultFilename;
327
- }
328
- const decode = (name) => {
329
- try {
330
- let decoded = decodeURIComponent(name);
331
- if (decoded.includes("/")) {
332
- decoded = decoded.split("/").at(-1);
333
- if (decoded.test(/^\.pdf$/i)) {
334
- return decoded;
335
- }
336
- return name;
337
- }
338
- return decoded;
339
- } catch {
340
- return name;
341
- }
342
- };
343
- const pdfRegex = /\.pdf$/i;
344
- const filename = newURL.pathname.split("/").at(-1);
345
- if (pdfRegex.test(filename)) {
346
- return decode(filename);
347
- }
348
- if (newURL.searchParams.size > 0) {
349
- const values = Array.from(newURL.searchParams.values()).reverse();
350
- for (const value of values) {
351
- if (pdfRegex.test(value)) {
352
- return decode(value);
353
- }
354
- }
355
- const keys = Array.from(newURL.searchParams.keys()).reverse();
356
- for (const key of keys) {
357
- if (pdfRegex.test(key)) {
358
- return decode(key);
359
- }
360
- }
361
- }
362
- if (newURL.hash) {
363
- const reFilename = /[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
364
- const hashFilename = reFilename.exec(newURL.hash);
365
- if (hashFilename) {
366
- return decode(hashFilename[0]);
367
- }
368
- }
369
- return defaultFilename;
370
- }
371
- var StatTimer = class {
372
- constructor() {
373
- __publicField(this, "started", /* @__PURE__ */ Object.create(null));
374
- __publicField(this, "times", []);
375
- }
376
- time(name) {
377
- if (name in this.started) {
378
- warn(`Timer is already running for ${name}`);
379
- }
380
- this.started[name] = Date.now();
381
- }
382
- timeEnd(name) {
383
- if (!(name in this.started)) {
384
- warn(`Timer has not been started for ${name}`);
385
- }
386
- this.times.push({
387
- name,
388
- start: this.started[name],
389
- end: Date.now()
390
- });
391
- delete this.started[name];
392
- }
393
- toString() {
394
- const outBuf = [];
395
- let longest = 0;
396
- for (const { name } of this.times) {
397
- longest = Math.max(name.length, longest);
398
- }
399
- for (const { name, start, end } of this.times) {
400
- outBuf.push(`${name.padEnd(longest)} ${end - start}ms
401
- `);
402
- }
403
- return outBuf.join("");
404
- }
405
- };
406
- function isValidFetchUrl(url, baseUrl) {
407
- if (false) {
408
- throw new Error("Not implemented: isValidFetchUrl");
409
- }
410
- const res = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
411
- return res?.protocol === "http:" || res?.protocol === "https:";
412
- }
413
- function noContextMenu(e) {
414
- e.preventDefault();
415
- }
416
- function stopEvent(e) {
417
- e.preventDefault();
418
- e.stopPropagation();
419
- }
420
- function deprecated(details) {
421
- console.log("Deprecated API usage: " + details);
422
- }
423
- var _regex;
424
- var PDFDateString = class {
425
- /**
426
- * Convert a PDF date string to a JavaScript `Date` object.
427
- *
428
- * The PDF date string format is described in section 7.9.4 of the official
429
- * PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth
430
- * edition) Adobe describes the same format including a trailing apostrophe.
431
- * This syntax in incorrect, but Adobe Acrobat creates PDF files that contain
432
- * them. We ignore all apostrophes as they are not necessary for date parsing.
433
- *
434
- * Moreover, Adobe Acrobat doesn't handle changing the date to universal time
435
- * and doesn't use the user's time zone (effectively ignoring the HH' and mm'
436
- * parts of the date string).
437
- *
438
- * @param {string} input
439
- * @returns {Date|null}
440
- */
441
- static toDateObject(input) {
442
- if (!input || typeof input !== "string") {
443
- return null;
444
- }
445
- __privateGet(this, _regex) || __privateSet(this, _regex, new RegExp(
446
- "^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"
447
- // Trailing apostrophe (optional)
448
- ));
449
- const matches = __privateGet(this, _regex).exec(input);
450
- if (!matches) {
451
- return null;
452
- }
453
- const year = parseInt(matches[1], 10);
454
- let month = parseInt(matches[2], 10);
455
- month = month >= 1 && month <= 12 ? month - 1 : 0;
456
- let day = parseInt(matches[3], 10);
457
- day = day >= 1 && day <= 31 ? day : 1;
458
- let hour = parseInt(matches[4], 10);
459
- hour = hour >= 0 && hour <= 23 ? hour : 0;
460
- let minute = parseInt(matches[5], 10);
461
- minute = minute >= 0 && minute <= 59 ? minute : 0;
462
- let second = parseInt(matches[6], 10);
463
- second = second >= 0 && second <= 59 ? second : 0;
464
- const universalTimeRelation = matches[7] || "Z";
465
- let offsetHour = parseInt(matches[8], 10);
466
- offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;
467
- let offsetMinute = parseInt(matches[9], 10) || 0;
468
- offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;
469
- if (universalTimeRelation === "-") {
470
- hour += offsetHour;
471
- minute += offsetMinute;
472
- } else if (universalTimeRelation === "+") {
473
- hour -= offsetHour;
474
- minute -= offsetMinute;
475
- }
476
- return new Date(Date.UTC(year, month, day, hour, minute, second));
477
- }
478
- };
479
- _regex = new WeakMap();
480
- __privateAdd(PDFDateString, _regex);
481
- function getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) {
482
- const { width, height } = xfaPage.attributes.style;
483
- const viewBox = [0, 0, parseInt(width), parseInt(height)];
484
- return new PageViewport({
485
- viewBox,
486
- userUnit: 1,
487
- scale,
488
- rotation
489
- });
490
- }
491
- function getRGB(color) {
492
- if (color.startsWith("#")) {
493
- const colorRGB = parseInt(color.slice(1), 16);
494
- return [
495
- (colorRGB & 16711680) >> 16,
496
- (colorRGB & 65280) >> 8,
497
- colorRGB & 255
498
- ];
499
- }
500
- if (color.startsWith("rgb(")) {
501
- return color.slice(
502
- /* "rgb(".length */
503
- 4,
504
- -1
505
- ).split(",").map((x) => parseInt(x));
506
- }
507
- if (color.startsWith("rgba(")) {
508
- return color.slice(
509
- /* "rgba(".length */
510
- 5,
511
- -1
512
- ).split(",").map((x) => parseInt(x)).slice(0, 3);
513
- }
514
- warn(`Not a valid color format: "${color}"`);
515
- return [0, 0, 0];
516
- }
517
- function getColorValues(colors) {
518
- const span = document.createElement("span");
519
- span.style.visibility = "hidden";
520
- span.style.colorScheme = "only light";
521
- document.body.append(span);
522
- for (const name of colors.keys()) {
523
- span.style.color = name;
524
- const computedColor = window.getComputedStyle(span).color;
525
- colors.set(name, getRGB(computedColor));
526
- }
527
- span.remove();
528
- }
529
- function getCurrentTransform(ctx) {
530
- const { a, b, c, d, e, f } = ctx.getTransform();
531
- return [a, b, c, d, e, f];
532
- }
533
- function getCurrentTransformInverse(ctx) {
534
- const { a, b, c, d, e, f } = ctx.getTransform().invertSelf();
535
- return [a, b, c, d, e, f];
536
- }
537
- function setLayerDimensions(div, viewport, mustFlip = false, mustRotate = true) {
538
- if (viewport instanceof PageViewport) {
539
- const { pageWidth, pageHeight } = viewport.rawDims;
540
- const { style } = div;
541
- const useRound = FeatureTest.isCSSRoundSupported;
542
- const w = `var(--total-scale-factor) * ${pageWidth}px`, h = `var(--total-scale-factor) * ${pageHeight}px`;
543
- const widthStr = useRound ? `round(down, ${w}, var(--scale-round-x))` : `calc(${w})`, heightStr = useRound ? `round(down, ${h}, var(--scale-round-y))` : `calc(${h})`;
544
- if (!mustFlip || viewport.rotation % 180 === 0) {
545
- style.width = widthStr;
546
- style.height = heightStr;
547
- } else {
548
- style.width = heightStr;
549
- style.height = widthStr;
550
- }
551
- }
552
- if (mustRotate) {
553
- div.setAttribute("data-main-rotation", viewport.rotation);
554
- }
555
- }
556
- var OutputScale = class _OutputScale {
557
- constructor() {
558
- const { pixelRatio } = _OutputScale;
559
- this.sx = pixelRatio;
560
- this.sy = pixelRatio;
561
- }
562
- /**
563
- * @type {boolean} Returns `true` when scaling is required, `false` otherwise.
564
- */
565
- get scaled() {
566
- return this.sx !== 1 || this.sy !== 1;
567
- }
568
- /**
569
- * @type {boolean} Returns `true` when scaling is symmetric,
570
- * `false` otherwise.
571
- */
572
- get symmetric() {
573
- return this.sx === this.sy;
574
- }
575
- /**
576
- * @returns {boolean} Returns `true` if scaling was limited,
577
- * `false` otherwise.
578
- */
579
- limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {
580
- let maxAreaScale = Infinity, maxWidthScale = Infinity, maxHeightScale = Infinity;
581
- maxPixels = _OutputScale.capPixels(maxPixels, capAreaFactor);
582
- if (maxPixels > 0) {
583
- maxAreaScale = Math.sqrt(maxPixels / (width * height));
584
- }
585
- if (maxDim !== -1) {
586
- maxWidthScale = maxDim / width;
587
- maxHeightScale = maxDim / height;
588
- }
589
- const maxScale = Math.min(maxAreaScale, maxWidthScale, maxHeightScale);
590
- if (this.sx > maxScale || this.sy > maxScale) {
591
- this.sx = maxScale;
592
- this.sy = maxScale;
593
- return true;
594
- }
595
- return false;
596
- }
597
- static get pixelRatio() {
598
- return globalThis.devicePixelRatio || 1;
599
- }
600
- static capPixels(maxPixels, capAreaFactor) {
601
- if (capAreaFactor >= 0) {
602
- const winPixels = Math.ceil(
603
- (false ? window.innerWidth * window.innerHeight : window.screen.availWidth * window.screen.availHeight) * this.pixelRatio ** 2 * (1 + capAreaFactor / 100)
604
- );
605
- return maxPixels > 0 ? Math.min(maxPixels, winPixels) : winPixels;
606
- }
607
- return maxPixels;
608
- }
609
- };
610
- var SupportedImageMimeTypes = [
611
- "image/apng",
612
- "image/avif",
613
- "image/bmp",
614
- "image/gif",
615
- "image/jpeg",
616
- "image/png",
617
- "image/svg+xml",
618
- "image/webp",
619
- "image/x-icon"
620
- ];
621
-
622
92
  // src/pdf.js/src/display/editor/toolbar.js
623
93
  var _toolbar, _colorPicker, _editor, _buttons, _altText, _signatureDescriptionButton, _l10nRemove, _EditorToolbar_static, pointerDown_fn, _EditorToolbar_instances, focusIn_fn, focusOut_fn, addListenersToElement_fn, divider_get;
624
94
  var _EditorToolbar = class _EditorToolbar {
@@ -9231,71 +8701,6 @@ for (const op in OPS) {
9231
8701
  }
9232
8702
  }
9233
8703
 
9234
- // src/pdf.js/src/display/canvas_factory.js
9235
- var _enableHWA;
9236
- var BaseCanvasFactory = class {
9237
- constructor({ enableHWA = false }) {
9238
- __privateAdd(this, _enableHWA, false);
9239
- if (false) {
9240
- unreachable("Cannot initialize BaseCanvasFactory.");
9241
- }
9242
- __privateSet(this, _enableHWA, enableHWA);
9243
- }
9244
- create(width, height) {
9245
- if (width <= 0 || height <= 0) {
9246
- throw new Error("Invalid canvas size");
9247
- }
9248
- const canvas = this._createCanvas(width, height);
9249
- return {
9250
- canvas,
9251
- context: canvas.getContext("2d", {
9252
- willReadFrequently: !__privateGet(this, _enableHWA)
9253
- })
9254
- };
9255
- }
9256
- reset(canvasAndContext, width, height) {
9257
- if (!canvasAndContext.canvas) {
9258
- throw new Error("Canvas is not specified");
9259
- }
9260
- if (width <= 0 || height <= 0) {
9261
- throw new Error("Invalid canvas size");
9262
- }
9263
- canvasAndContext.canvas.width = width;
9264
- canvasAndContext.canvas.height = height;
9265
- }
9266
- destroy(canvasAndContext) {
9267
- if (!canvasAndContext.canvas) {
9268
- throw new Error("Canvas is not specified");
9269
- }
9270
- canvasAndContext.canvas.width = 0;
9271
- canvasAndContext.canvas.height = 0;
9272
- canvasAndContext.canvas = null;
9273
- canvasAndContext.context = null;
9274
- }
9275
- /**
9276
- * @ignore
9277
- */
9278
- _createCanvas(width, height) {
9279
- unreachable("Abstract method `_createCanvas` called.");
9280
- }
9281
- };
9282
- _enableHWA = new WeakMap();
9283
- var DOMCanvasFactory = class extends BaseCanvasFactory {
9284
- constructor({ ownerDocument = globalThis.document, enableHWA = false }) {
9285
- super({ enableHWA });
9286
- this._document = ownerDocument;
9287
- }
9288
- /**
9289
- * @ignore
9290
- */
9291
- _createCanvas(width, height) {
9292
- const canvas = this._document.createElement("canvas");
9293
- canvas.width = width;
9294
- canvas.height = height;
9295
- return canvas;
9296
- }
9297
- };
9298
-
9299
8704
  // src/pdf.js/src/display/cmap_reader_factory.js
9300
8705
  var BaseCMapReaderFactory = class {
9301
8706
  constructor({ baseUrl = null, isCompressed = true }) {
@@ -9343,380 +8748,6 @@ var DOMCMapReaderFactory = class extends BaseCMapReaderFactory {
9343
8748
  }
9344
8749
  };
9345
8750
 
9346
- // src/pdf.js/src/display/filter_factory.js
9347
- var BaseFilterFactory = class {
9348
- constructor() {
9349
- if (false) {
9350
- unreachable("Cannot initialize BaseFilterFactory.");
9351
- }
9352
- }
9353
- addFilter(maps) {
9354
- return "none";
9355
- }
9356
- addHCMFilter(fgColor, bgColor) {
9357
- return "none";
9358
- }
9359
- addAlphaFilter(map) {
9360
- return "none";
9361
- }
9362
- addLuminosityFilter(map) {
9363
- return "none";
9364
- }
9365
- addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
9366
- return "none";
9367
- }
9368
- destroy(keepHCM = false) {
9369
- }
9370
- };
9371
- var _baseUrl, __cache, __defs, _docId, _document, __hcmCache, _id3, _DOMFilterFactory_instances, cache_get, hcmCache_get, defs_get, createTables_fn, createUrl_fn, addLuminosityConversion_fn, addGrayConversion_fn, createFilter_fn, appendFeFunc_fn, addTransferMapConversion_fn, addTransferMapAlphaConversion_fn, getRGB_fn;
9372
- var DOMFilterFactory = class extends BaseFilterFactory {
9373
- constructor({ docId, ownerDocument = globalThis.document }) {
9374
- super();
9375
- __privateAdd(this, _DOMFilterFactory_instances);
9376
- __privateAdd(this, _baseUrl);
9377
- __privateAdd(this, __cache);
9378
- __privateAdd(this, __defs);
9379
- __privateAdd(this, _docId);
9380
- __privateAdd(this, _document);
9381
- __privateAdd(this, __hcmCache);
9382
- __privateAdd(this, _id3, 0);
9383
- __privateSet(this, _docId, docId);
9384
- __privateSet(this, _document, ownerDocument);
9385
- }
9386
- addFilter(maps) {
9387
- if (!maps) {
9388
- return "none";
9389
- }
9390
- let value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(maps);
9391
- if (value) {
9392
- return value;
9393
- }
9394
- const [tableR, tableG, tableB] = __privateMethod(this, _DOMFilterFactory_instances, createTables_fn).call(this, maps);
9395
- const key = maps.length === 1 ? tableR : `${tableR}${tableG}${tableB}`;
9396
- value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(key);
9397
- if (value) {
9398
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(maps, value);
9399
- return value;
9400
- }
9401
- const id = `g_${__privateGet(this, _docId)}_transfer_map_${__privateWrapper(this, _id3)._++}`;
9402
- const url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
9403
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(maps, url);
9404
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(key, url);
9405
- const filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
9406
- __privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, tableR, tableG, tableB, filter);
9407
- return url;
9408
- }
9409
- addHCMFilter(fgColor, bgColor) {
9410
- const key = `${fgColor}-${bgColor}`;
9411
- const filterName = "base";
9412
- let info2 = __privateGet(this, _DOMFilterFactory_instances, hcmCache_get).get(filterName);
9413
- if (info2?.key === key) {
9414
- return info2.url;
9415
- }
9416
- if (info2) {
9417
- info2.filter?.remove();
9418
- info2.key = key;
9419
- info2.url = "none";
9420
- info2.filter = null;
9421
- } else {
9422
- info2 = {
9423
- key,
9424
- url: "none",
9425
- filter: null
9426
- };
9427
- __privateGet(this, _DOMFilterFactory_instances, hcmCache_get).set(filterName, info2);
9428
- }
9429
- if (!fgColor || !bgColor) {
9430
- return info2.url;
9431
- }
9432
- const fgRGB = __privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).call(this, fgColor);
9433
- fgColor = Util.makeHexColor(...fgRGB);
9434
- const bgRGB = __privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).call(this, bgColor);
9435
- bgColor = Util.makeHexColor(...bgRGB);
9436
- __privateGet(this, _DOMFilterFactory_instances, defs_get).style.color = "";
9437
- if (fgColor === "#000000" && bgColor === "#ffffff" || fgColor === bgColor) {
9438
- return info2.url;
9439
- }
9440
- const map = new Array(256);
9441
- for (let i = 0; i <= 255; i++) {
9442
- const x = i / 255;
9443
- map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
9444
- }
9445
- const table = map.join(",");
9446
- const id = `g_${__privateGet(this, _docId)}_hcm_filter`;
9447
- const filter = info2.filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
9448
- __privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, table, table, table, filter);
9449
- __privateMethod(this, _DOMFilterFactory_instances, addGrayConversion_fn).call(this, filter);
9450
- const getSteps = (c, n) => {
9451
- const start = fgRGB[c] / 255;
9452
- const end = bgRGB[c] / 255;
9453
- const arr = new Array(n + 1);
9454
- for (let i = 0; i <= n; i++) {
9455
- arr[i] = start + i / n * (end - start);
9456
- }
9457
- return arr.join(",");
9458
- };
9459
- __privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, getSteps(0, 5), getSteps(1, 5), getSteps(2, 5), filter);
9460
- info2.url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
9461
- return info2.url;
9462
- }
9463
- addAlphaFilter(map) {
9464
- let value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(map);
9465
- if (value) {
9466
- return value;
9467
- }
9468
- const [tableA] = __privateMethod(this, _DOMFilterFactory_instances, createTables_fn).call(this, [map]);
9469
- const key = `alpha_${tableA}`;
9470
- value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(key);
9471
- if (value) {
9472
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, value);
9473
- return value;
9474
- }
9475
- const id = `g_${__privateGet(this, _docId)}_alpha_map_${__privateWrapper(this, _id3)._++}`;
9476
- const url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
9477
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, url);
9478
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(key, url);
9479
- const filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
9480
- __privateMethod(this, _DOMFilterFactory_instances, addTransferMapAlphaConversion_fn).call(this, tableA, filter);
9481
- return url;
9482
- }
9483
- addLuminosityFilter(map) {
9484
- let value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(map || "luminosity");
9485
- if (value) {
9486
- return value;
9487
- }
9488
- let tableA, key;
9489
- if (map) {
9490
- [tableA] = __privateMethod(this, _DOMFilterFactory_instances, createTables_fn).call(this, [map]);
9491
- key = `luminosity_${tableA}`;
9492
- } else {
9493
- key = "luminosity";
9494
- }
9495
- value = __privateGet(this, _DOMFilterFactory_instances, cache_get).get(key);
9496
- if (value) {
9497
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, value);
9498
- return value;
9499
- }
9500
- const id = `g_${__privateGet(this, _docId)}_luminosity_map_${__privateWrapper(this, _id3)._++}`;
9501
- const url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
9502
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(map, url);
9503
- __privateGet(this, _DOMFilterFactory_instances, cache_get).set(key, url);
9504
- const filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
9505
- __privateMethod(this, _DOMFilterFactory_instances, addLuminosityConversion_fn).call(this, filter);
9506
- if (map) {
9507
- __privateMethod(this, _DOMFilterFactory_instances, addTransferMapAlphaConversion_fn).call(this, tableA, filter);
9508
- }
9509
- return url;
9510
- }
9511
- addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {
9512
- const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;
9513
- let info2 = __privateGet(this, _DOMFilterFactory_instances, hcmCache_get).get(filterName);
9514
- if (info2?.key === key) {
9515
- return info2.url;
9516
- }
9517
- if (info2) {
9518
- info2.filter?.remove();
9519
- info2.key = key;
9520
- info2.url = "none";
9521
- info2.filter = null;
9522
- } else {
9523
- info2 = {
9524
- key,
9525
- url: "none",
9526
- filter: null
9527
- };
9528
- __privateGet(this, _DOMFilterFactory_instances, hcmCache_get).set(filterName, info2);
9529
- }
9530
- if (!fgColor || !bgColor) {
9531
- return info2.url;
9532
- }
9533
- const [fgRGB, bgRGB] = [fgColor, bgColor].map(__privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).bind(this));
9534
- let fgGray = Math.round(
9535
- 0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]
9536
- );
9537
- let bgGray = Math.round(
9538
- 0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]
9539
- );
9540
- let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(
9541
- __privateMethod(this, _DOMFilterFactory_instances, getRGB_fn).bind(this)
9542
- );
9543
- if (bgGray < fgGray) {
9544
- [fgGray, bgGray, newFgRGB, newBgRGB] = [
9545
- bgGray,
9546
- fgGray,
9547
- newBgRGB,
9548
- newFgRGB
9549
- ];
9550
- }
9551
- __privateGet(this, _DOMFilterFactory_instances, defs_get).style.color = "";
9552
- const getSteps = (fg, bg, n) => {
9553
- const arr = new Array(256);
9554
- const step = (bgGray - fgGray) / n;
9555
- const newStart = fg / 255;
9556
- const newStep = (bg - fg) / (255 * n);
9557
- let prev = 0;
9558
- for (let i = 0; i <= n; i++) {
9559
- const k = Math.round(fgGray + i * step);
9560
- const value = newStart + i * newStep;
9561
- for (let j = prev; j <= k; j++) {
9562
- arr[j] = value;
9563
- }
9564
- prev = k + 1;
9565
- }
9566
- for (let i = prev; i < 256; i++) {
9567
- arr[i] = arr[prev - 1];
9568
- }
9569
- return arr.join(",");
9570
- };
9571
- const id = `g_${__privateGet(this, _docId)}_hcm_${filterName}_filter`;
9572
- const filter = info2.filter = __privateMethod(this, _DOMFilterFactory_instances, createFilter_fn).call(this, id);
9573
- __privateMethod(this, _DOMFilterFactory_instances, addGrayConversion_fn).call(this, filter);
9574
- __privateMethod(this, _DOMFilterFactory_instances, addTransferMapConversion_fn).call(this, getSteps(newFgRGB[0], newBgRGB[0], 5), getSteps(newFgRGB[1], newBgRGB[1], 5), getSteps(newFgRGB[2], newBgRGB[2], 5), filter);
9575
- info2.url = __privateMethod(this, _DOMFilterFactory_instances, createUrl_fn).call(this, id);
9576
- return info2.url;
9577
- }
9578
- destroy(keepHCM = false) {
9579
- if (keepHCM && __privateGet(this, __hcmCache)?.size) {
9580
- return;
9581
- }
9582
- __privateGet(this, __defs)?.parentNode.parentNode.remove();
9583
- __privateSet(this, __defs, null);
9584
- __privateGet(this, __cache)?.clear();
9585
- __privateSet(this, __cache, null);
9586
- __privateGet(this, __hcmCache)?.clear();
9587
- __privateSet(this, __hcmCache, null);
9588
- __privateSet(this, _id3, 0);
9589
- }
9590
- };
9591
- _baseUrl = new WeakMap();
9592
- __cache = new WeakMap();
9593
- __defs = new WeakMap();
9594
- _docId = new WeakMap();
9595
- _document = new WeakMap();
9596
- __hcmCache = new WeakMap();
9597
- _id3 = new WeakMap();
9598
- _DOMFilterFactory_instances = new WeakSet();
9599
- cache_get = function() {
9600
- return __privateGet(this, __cache) || __privateSet(this, __cache, /* @__PURE__ */ new Map());
9601
- };
9602
- hcmCache_get = function() {
9603
- return __privateGet(this, __hcmCache) || __privateSet(this, __hcmCache, /* @__PURE__ */ new Map());
9604
- };
9605
- defs_get = function() {
9606
- if (!__privateGet(this, __defs)) {
9607
- const div = __privateGet(this, _document).createElement("div");
9608
- const { style } = div;
9609
- style.visibility = "hidden";
9610
- style.contain = "strict";
9611
- style.width = style.height = 0;
9612
- style.position = "absolute";
9613
- style.top = style.left = 0;
9614
- style.zIndex = -1;
9615
- const svg = __privateGet(this, _document).createElementNS(SVG_NS, "svg");
9616
- svg.setAttribute("width", 0);
9617
- svg.setAttribute("height", 0);
9618
- __privateSet(this, __defs, __privateGet(this, _document).createElementNS(SVG_NS, "defs"));
9619
- div.append(svg);
9620
- svg.append(__privateGet(this, __defs));
9621
- __privateGet(this, _document).body.append(div);
9622
- }
9623
- return __privateGet(this, __defs);
9624
- };
9625
- createTables_fn = function(maps) {
9626
- if (maps.length === 1) {
9627
- const mapR2 = maps[0];
9628
- const buffer = new Array(256);
9629
- for (let i = 0; i < 256; i++) {
9630
- buffer[i] = mapR2[i] / 255;
9631
- }
9632
- const table = buffer.join(",");
9633
- return [table, table, table];
9634
- }
9635
- const [mapR, mapG, mapB] = maps;
9636
- const bufferR = new Array(256);
9637
- const bufferG = new Array(256);
9638
- const bufferB = new Array(256);
9639
- for (let i = 0; i < 256; i++) {
9640
- bufferR[i] = mapR[i] / 255;
9641
- bufferG[i] = mapG[i] / 255;
9642
- bufferB[i] = mapB[i] / 255;
9643
- }
9644
- return [bufferR.join(","), bufferG.join(","), bufferB.join(",")];
9645
- };
9646
- createUrl_fn = function(id) {
9647
- if (__privateGet(this, _baseUrl) === void 0) {
9648
- __privateSet(this, _baseUrl, "");
9649
- const url = __privateGet(this, _document).URL;
9650
- if (url !== __privateGet(this, _document).baseURI) {
9651
- if (isDataScheme(url)) {
9652
- warn('#createUrl: ignore "data:"-URL for performance reasons.');
9653
- } else {
9654
- __privateSet(this, _baseUrl, updateUrlHash(url, ""));
9655
- }
9656
- }
9657
- }
9658
- return `url(${__privateGet(this, _baseUrl)}#${id})`;
9659
- };
9660
- addLuminosityConversion_fn = function(filter) {
9661
- const feColorMatrix = __privateGet(this, _document).createElementNS(
9662
- SVG_NS,
9663
- "feColorMatrix"
9664
- );
9665
- feColorMatrix.setAttribute("type", "matrix");
9666
- feColorMatrix.setAttribute(
9667
- "values",
9668
- "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"
9669
- );
9670
- filter.append(feColorMatrix);
9671
- };
9672
- addGrayConversion_fn = function(filter) {
9673
- const feColorMatrix = __privateGet(this, _document).createElementNS(
9674
- SVG_NS,
9675
- "feColorMatrix"
9676
- );
9677
- feColorMatrix.setAttribute("type", "matrix");
9678
- feColorMatrix.setAttribute(
9679
- "values",
9680
- "0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"
9681
- );
9682
- filter.append(feColorMatrix);
9683
- };
9684
- createFilter_fn = function(id) {
9685
- const filter = __privateGet(this, _document).createElementNS(SVG_NS, "filter");
9686
- filter.setAttribute("color-interpolation-filters", "sRGB");
9687
- filter.setAttribute("id", id);
9688
- __privateGet(this, _DOMFilterFactory_instances, defs_get).append(filter);
9689
- return filter;
9690
- };
9691
- appendFeFunc_fn = function(feComponentTransfer, func, table) {
9692
- const feFunc = __privateGet(this, _document).createElementNS(SVG_NS, func);
9693
- feFunc.setAttribute("type", "discrete");
9694
- feFunc.setAttribute("tableValues", table);
9695
- feComponentTransfer.append(feFunc);
9696
- };
9697
- addTransferMapConversion_fn = function(rTable, gTable, bTable, filter) {
9698
- const feComponentTransfer = __privateGet(this, _document).createElementNS(
9699
- SVG_NS,
9700
- "feComponentTransfer"
9701
- );
9702
- filter.append(feComponentTransfer);
9703
- __privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncR", rTable);
9704
- __privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncG", gTable);
9705
- __privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncB", bTable);
9706
- };
9707
- addTransferMapAlphaConversion_fn = function(aTable, filter) {
9708
- const feComponentTransfer = __privateGet(this, _document).createElementNS(
9709
- SVG_NS,
9710
- "feComponentTransfer"
9711
- );
9712
- filter.append(feComponentTransfer);
9713
- __privateMethod(this, _DOMFilterFactory_instances, appendFeFunc_fn).call(this, feComponentTransfer, "feFuncA", aTable);
9714
- };
9715
- getRGB_fn = function(color) {
9716
- __privateGet(this, _DOMFilterFactory_instances, defs_get).style.color = color;
9717
- return getRGB(getComputedStyle(__privateGet(this, _DOMFilterFactory_instances, defs_get)).getPropertyValue("color"));
9718
- };
9719
-
9720
8751
  // src/pdf.js/src/display/standard_fontdata_factory.js
9721
8752
  var BaseStandardFontDataFactory = class {
9722
8753
  constructor({ baseUrl = null }) {
@@ -11915,7 +10946,7 @@ function getDocument(src = {}) {
11915
10946
  }).catch(task._capability.reject);
11916
10947
  return task;
11917
10948
  }
11918
- var _docId2;
10949
+ var _docId;
11919
10950
  var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
11920
10951
  constructor() {
11921
10952
  /**
@@ -11934,7 +10965,7 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
11934
10965
  * Unique identifier for the document loading task.
11935
10966
  * @type {string}
11936
10967
  */
11937
- __publicField(this, "docId", `d${__privateWrapper(_PDFDocumentLoadingTask, _docId2)._++}`);
10968
+ __publicField(this, "docId", `d${__privateWrapper(_PDFDocumentLoadingTask, _docId)._++}`);
11938
10969
  /**
11939
10970
  * Whether the loading task is destroyed or not.
11940
10971
  * @type {boolean}
@@ -11994,8 +11025,8 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
11994
11025
  return this._transport.getData();
11995
11026
  }
11996
11027
  };
11997
- _docId2 = new WeakMap();
11998
- __privateAdd(_PDFDocumentLoadingTask, _docId2, 0);
11028
+ _docId = new WeakMap();
11029
+ __privateAdd(_PDFDocumentLoadingTask, _docId, 0);
11999
11030
  var PDFDocumentLoadingTask = _PDFDocumentLoadingTask;
12000
11031
  var _capability2, _progressiveDoneListeners, _progressiveReadListeners, _progressListeners, _rangeListeners;
12001
11032
  var PDFDataRangeTransport = class {
@@ -19023,7 +18054,7 @@ __privateAdd(_ColorPicker, _l10nColor, null);
19023
18054
  var ColorPicker = _ColorPicker;
19024
18055
 
19025
18056
  // src/pdf.js/src/display/editor/highlight.js
19026
- var _anchorNode, _anchorOffset, _boxes, _clipPathId, _colorPicker2, _focusOutlines, _focusNode, _focusOffset, _highlightDiv, _highlightOutlines, _id4, _isFreeHighlight, _lastPoint2, _opacity, _outlineId, _text, _thickness2, _methodOfCreation, _HighlightEditor_instances, createOutlines_fn, createFreeOutlines_fn, updateColor_fn2, updateThickness_fn, changeThickness_fn, cleanDrawLayer_fn, addToDrawLayer_fn, _HighlightEditor_static, rotateBbox_fn, keydown_fn, setCaret_fn, getRotation_fn, serializeBoxes_fn, serializeOutlines_fn, highlightMove_fn, endHighlight_fn, hasElementChanged_fn2;
18057
+ var _anchorNode, _anchorOffset, _boxes, _clipPathId, _colorPicker2, _focusOutlines, _focusNode, _focusOffset, _highlightDiv, _highlightOutlines, _id3, _isFreeHighlight, _lastPoint2, _opacity, _outlineId, _text, _thickness2, _methodOfCreation, _HighlightEditor_instances, createOutlines_fn, createFreeOutlines_fn, updateColor_fn2, updateThickness_fn, changeThickness_fn, cleanDrawLayer_fn, addToDrawLayer_fn, _HighlightEditor_static, rotateBbox_fn, keydown_fn, setCaret_fn, getRotation_fn, serializeBoxes_fn, serializeOutlines_fn, highlightMove_fn, endHighlight_fn, hasElementChanged_fn2;
19027
18058
  var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
19028
18059
  constructor(params) {
19029
18060
  super({ ...params, name: "highlightEditor" });
@@ -19038,7 +18069,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
19038
18069
  __privateAdd(this, _focusOffset, 0);
19039
18070
  __privateAdd(this, _highlightDiv, null);
19040
18071
  __privateAdd(this, _highlightOutlines, null);
19041
- __privateAdd(this, _id4, null);
18072
+ __privateAdd(this, _id3, null);
19042
18073
  __privateAdd(this, _isFreeHighlight, false);
19043
18074
  __privateAdd(this, _lastPoint2, null);
19044
18075
  __privateAdd(this, _opacity);
@@ -19252,7 +18283,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
19252
18283
  } else {
19253
18284
  box = __privateMethod(_b = _HighlightEditor, _HighlightEditor_static, rotateBbox_fn).call(_b, [this.x, this.y, this.width, this.height], angle);
19254
18285
  }
19255
- drawLayer.updateProperties(__privateGet(this, _id4), {
18286
+ drawLayer.updateProperties(__privateGet(this, _id3), {
19256
18287
  bbox: box,
19257
18288
  root: {
19258
18289
  "data-main-rotation": angle
@@ -19372,7 +18403,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
19372
18403
  show(visible = this._isVisible) {
19373
18404
  super.show(visible);
19374
18405
  if (this.parent) {
19375
- this.parent.drawLayer.updateProperties(__privateGet(this, _id4), {
18406
+ this.parent.drawLayer.updateProperties(__privateGet(this, _id3), {
19376
18407
  rootClass: {
19377
18408
  hidden: !visible
19378
18409
  }
@@ -19623,7 +18654,7 @@ _focusNode = new WeakMap();
19623
18654
  _focusOffset = new WeakMap();
19624
18655
  _highlightDiv = new WeakMap();
19625
18656
  _highlightOutlines = new WeakMap();
19626
- _id4 = new WeakMap();
18657
+ _id3 = new WeakMap();
19627
18658
  _isFreeHighlight = new WeakMap();
19628
18659
  _lastPoint2 = new WeakMap();
19629
18660
  _opacity = new WeakMap();
@@ -19667,7 +18698,7 @@ createFreeOutlines_fn = function({ highlightOutlines, highlightId, clipPathId })
19667
18698
  25e-4
19668
18699
  ));
19669
18700
  if (highlightId >= 0) {
19670
- __privateSet(this, _id4, highlightId);
18701
+ __privateSet(this, _id3, highlightId);
19671
18702
  __privateSet(this, _clipPathId, clipPathId);
19672
18703
  this.parent.drawLayer.finalizeDraw(highlightId, {
19673
18704
  bbox: highlightOutlines.box,
@@ -19691,7 +18722,7 @@ createFreeOutlines_fn = function({ highlightOutlines, highlightId, clipPathId })
19691
18722
  ));
19692
18723
  } else if (this.parent) {
19693
18724
  const angle = this.parent.viewport.rotation;
19694
- this.parent.drawLayer.updateProperties(__privateGet(this, _id4), {
18725
+ this.parent.drawLayer.updateProperties(__privateGet(this, _id3), {
19695
18726
  bbox: __privateMethod(_a2 = _HighlightEditor, _HighlightEditor_static, rotateBbox_fn).call(_a2, __privateGet(this, _highlightOutlines).box, (angle - this.rotation + 360) % 360),
19696
18727
  path: {
19697
18728
  d: highlightOutlines.toSVGPath()
@@ -19746,7 +18777,7 @@ updateColor_fn2 = function(color) {
19746
18777
  const setColorAndOpacity = (col, opa) => {
19747
18778
  this.color = col;
19748
18779
  __privateSet(this, _opacity, opa);
19749
- this.parent?.drawLayer.updateProperties(__privateGet(this, _id4), {
18780
+ this.parent?.drawLayer.updateProperties(__privateGet(this, _id3), {
19750
18781
  root: {
19751
18782
  fill: col,
19752
18783
  "fill-opacity": opa
@@ -19815,19 +18846,19 @@ changeThickness_fn = function(thickness) {
19815
18846
  this.setDims(this.width * parentWidth, this.height * parentHeight);
19816
18847
  };
19817
18848
  cleanDrawLayer_fn = function() {
19818
- if (__privateGet(this, _id4) === null || !this.parent) {
18849
+ if (__privateGet(this, _id3) === null || !this.parent) {
19819
18850
  return;
19820
18851
  }
19821
- this.parent.drawLayer.remove(__privateGet(this, _id4));
19822
- __privateSet(this, _id4, null);
18852
+ this.parent.drawLayer.remove(__privateGet(this, _id3));
18853
+ __privateSet(this, _id3, null);
19823
18854
  this.parent.drawLayer.remove(__privateGet(this, _outlineId));
19824
18855
  __privateSet(this, _outlineId, null);
19825
18856
  };
19826
18857
  addToDrawLayer_fn = function(parent = this.parent) {
19827
- if (__privateGet(this, _id4) !== null) {
18858
+ if (__privateGet(this, _id3) !== null) {
19828
18859
  return;
19829
18860
  }
19830
- ({ id: __privateWrapper(this, _id4)._, clipPathId: __privateWrapper(this, _clipPathId)._ } = parent.drawLayer.draw(
18861
+ ({ id: __privateWrapper(this, _id3)._, clipPathId: __privateWrapper(this, _clipPathId)._ } = parent.drawLayer.draw(
19831
18862
  {
19832
18863
  bbox: __privateGet(this, _highlightOutlines).box,
19833
18864
  root: {
@@ -24348,7 +23379,7 @@ __privateAdd(_AnnotationEditorLayer, _editorTypes2, new Map(
24348
23379
  var AnnotationEditorLayer = _AnnotationEditorLayer;
24349
23380
 
24350
23381
  // src/pdf.js/src/display/draw_layer.js
24351
- var _parent2, _mapping, _toUpdate, _id5, _DrawLayer_static, setBox_fn, _DrawLayer_instances, createSVG_fn, createClipPath_fn, updateProperties_fn;
23382
+ var _parent2, _mapping, _toUpdate, _id4, _DrawLayer_static, setBox_fn, _DrawLayer_instances, createSVG_fn, createClipPath_fn, updateProperties_fn;
24352
23383
  var _DrawLayer = class _DrawLayer {
24353
23384
  constructor({ pageIndex }) {
24354
23385
  __privateAdd(this, _DrawLayer_instances);
@@ -24376,7 +23407,7 @@ var _DrawLayer = class _DrawLayer {
24376
23407
  return shadow(this, "_svgFactory", new DOMSVGFactory());
24377
23408
  }
24378
23409
  draw(properties, isPathUpdatable = false, hasClip = false) {
24379
- const id = __privateWrapper(_DrawLayer, _id5)._++;
23410
+ const id = __privateWrapper(_DrawLayer, _id4)._++;
24380
23411
  const root = __privateMethod(this, _DrawLayer_instances, createSVG_fn).call(this);
24381
23412
  const defs = _DrawLayer._svgFactory.createElement("defs");
24382
23413
  root.append(defs);
@@ -24397,7 +23428,7 @@ var _DrawLayer = class _DrawLayer {
24397
23428
  return { id, clipPathId: `url(#${clipPathId})` };
24398
23429
  }
24399
23430
  drawOutline(properties, mustRemoveSelfIntersections) {
24400
- const id = __privateWrapper(_DrawLayer, _id5)._++;
23431
+ const id = __privateWrapper(_DrawLayer, _id4)._++;
24401
23432
  const root = __privateMethod(this, _DrawLayer_instances, createSVG_fn).call(this);
24402
23433
  const defs = _DrawLayer._svgFactory.createElement("defs");
24403
23434
  root.append(defs);
@@ -24504,7 +23535,7 @@ var _DrawLayer = class _DrawLayer {
24504
23535
  _parent2 = new WeakMap();
24505
23536
  _mapping = new WeakMap();
24506
23537
  _toUpdate = new WeakMap();
24507
- _id5 = new WeakMap();
23538
+ _id4 = new WeakMap();
24508
23539
  _DrawLayer_static = new WeakSet();
24509
23540
  setBox_fn = function(element, [x, y, width, height]) {
24510
23541
  const { style } = element;
@@ -24547,7 +23578,7 @@ updateProperties_fn = function(element, properties) {
24547
23578
  }
24548
23579
  };
24549
23580
  __privateAdd(_DrawLayer, _DrawLayer_static);
24550
- __privateAdd(_DrawLayer, _id5, 0);
23581
+ __privateAdd(_DrawLayer, _id4, 0);
24551
23582
  var DrawLayer = _DrawLayer;
24552
23583
 
24553
23584
  // src/pdf.js/src/pdf.js
@@ -25619,81 +24650,11 @@ async function toSvgNode(ctx) {
25619
24650
  return ctx.getNode();
25620
24651
  }
25621
24652
 
25622
- // src/lib/utils.ts
25623
- async function canvasToData(canvas) {
25624
- if ("toBlob" in canvas) {
25625
- const blob = await new Promise(
25626
- (resolve) => canvas.toBlob((data) => resolve(data))
25627
- );
25628
- if (!blob) {
25629
- throw new Error("Failed to generate graphics");
25630
- }
25631
- return new Uint8Array(await blob.arrayBuffer());
25632
- }
25633
- const buffer = await canvas.encode("png");
25634
- return new Uint8Array(buffer);
25635
- }
25636
- async function toDataUrl(data, type = "image/png") {
25637
- if (typeof FileReader !== "undefined") {
25638
- return new Promise((resolve) => {
25639
- const reader = new FileReader();
25640
- reader.onload = () => {
25641
- resolve(reader.result);
25642
- };
25643
- reader.readAsDataURL(new Blob([data], { type }));
25644
- });
25645
- }
25646
- return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
25647
- }
25648
- function makeSerializable(object) {
25649
- if (typeof object !== "object" || object === null) {
25650
- return object;
25651
- }
25652
- if (object instanceof Int8Array || object instanceof Uint8Array || object instanceof Uint8ClampedArray || object instanceof Int16Array || object instanceof Uint16Array || object instanceof Int32Array || object instanceof Uint32Array || object instanceof Float32Array || object instanceof Float64Array) {
25653
- return makeSerializable(Array.from(object));
25654
- }
25655
- if (object instanceof BigInt64Array || object instanceof BigUint64Array) {
25656
- return makeSerializable(Array.from(object));
25657
- }
25658
- if (Array.isArray(object)) {
25659
- return object.map(makeSerializable);
25660
- }
25661
- return Object.fromEntries(
25662
- Object.entries(object).map(([key, value]) => [
25663
- key,
25664
- makeSerializable(value)
25665
- ])
25666
- );
25667
- }
25668
- function colorToRgb(color) {
25669
- if (color.startsWith("#")) {
25670
- const hex = color.slice(1);
25671
- if (hex.length === 3) {
25672
- return [
25673
- Number.parseInt(hex[0] + hex[0], 16),
25674
- Number.parseInt(hex[1] + hex[1], 16),
25675
- Number.parseInt(hex[2] + hex[2], 16)
25676
- ];
25677
- }
25678
- if (hex.length === 6) {
25679
- return [
25680
- Number.parseInt(hex.slice(0, 2), 16),
25681
- Number.parseInt(hex.slice(2, 4), 16),
25682
- Number.parseInt(hex.slice(4, 6), 16)
25683
- ];
25684
- }
25685
- }
25686
- throw new Error(`Invalid color format: ${color}`);
25687
- }
25688
- function rgbToHex(r, g, b) {
25689
- const toHex = (value) => value.toString(16).padStart(2, "0");
25690
- if (Array.isArray(r)) {
25691
- return `#${toHex(r[0])}${toHex(r[1])}${toHex(r[2])}`;
25692
- }
25693
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
25694
- }
25695
-
25696
24653
  // src/lib/PDFPageProxy.ts
24654
+ async function loadNodeCanvasFactory() {
24655
+ const { NodeCanvasFactory: NodeCanvasFactory2 } = await import("./NodeCanvasFactory-OREYUFNU.js");
24656
+ return new NodeCanvasFactory2({});
24657
+ }
25697
24658
  var getAnnotations = PDFPageProxy.prototype.getAnnotations;
25698
24659
  PDFPageProxy.prototype.getAnnotations = async function(params) {
25699
24660
  const annotations = await getAnnotations.call(this, params);
@@ -25706,7 +24667,7 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
25706
24667
  if (opList) {
25707
24668
  if (annotation.subtype === "Stamp") {
25708
24669
  try {
25709
- const canvasFactory = isNodeJS ? new NodeCanvasFactory({}) : new DOMCanvasFactory({});
24670
+ const canvasFactory = isNodeJS ? await loadNodeCanvasFactory() : new DOMCanvasFactory({});
25710
24671
  const scale = 2;
25711
24672
  const viewport = this.getViewport({ scale });
25712
24673
  const svgContext = await createSvgContext(