@vaadin-component-factory/vcf-pdf-viewer 4.0.2 → 4.2.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.
@@ -1,1066 +1,855 @@
1
- /* Copyright 2018 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- /* globals process */
17
- // NW.js / Electron is a browser context, but copies some Node.js objects; see
18
- // http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
19
- // https://www.electronjs.org/docs/api/process#processversionselectron-readonly
20
- // https://www.electronjs.org/docs/api/process#processtype-readonly
21
- const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
22
-
23
- /* Copyright 2017 Mozilla Foundation
24
- *
25
- * Licensed under the Apache License, Version 2.0 (the "License");
26
- * you may not use this file except in compliance with the License.
27
- * You may obtain a copy of the License at
28
- *
29
- * http://www.apache.org/licenses/LICENSE-2.0
30
- *
31
- * Unless required by applicable law or agreed to in writing, software
32
- * distributed under the License is distributed on an "AS IS" BASIS,
33
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
- * See the License for the specific language governing permissions and
35
- * limitations under the License.
36
- */
37
-
38
- if ((typeof PDFJSDev === "undefined" || !PDFJSDev.test("SKIP_BABEL")) && (typeof globalThis === "undefined" || !globalThis._pdfjsCompatibilityChecked)) {
39
- // Provides support for globalThis in legacy browsers.
40
- // Support: Firefox<65, Chrome<71, Safari<12.1
41
- if (typeof globalThis === "undefined" || globalThis.Math !== Math) {
42
- // eslint-disable-next-line no-global-assign
43
- globalThis = require("core-js/es/global-this");
44
- }
45
-
46
- globalThis._pdfjsCompatibilityChecked = true; // Support: Node.js
47
-
48
- (function checkNodeBtoa() {
49
- if (globalThis.btoa || !isNodeJS) {
50
- return;
51
- }
52
-
53
- globalThis.btoa = function (chars) {
54
- // eslint-disable-next-line no-undef
55
- return Buffer.from(chars, "binary").toString("base64");
56
- };
57
- })(); // Support: Node.js
58
-
59
-
60
- (function checkNodeAtob() {
61
- if (globalThis.atob || !isNodeJS) {
62
- return;
63
- }
64
-
65
- globalThis.atob = function (input) {
66
- // eslint-disable-next-line no-undef
67
- return Buffer.from(input, "base64").toString("binary");
68
- };
69
- })(); // Support: Node.js
70
-
71
-
72
- (function checkDOMMatrix() {
73
- if (globalThis.DOMMatrix || !isNodeJS) {
74
- return;
75
- }
76
-
77
- globalThis.DOMMatrix = require("dommatrix/dist/dommatrix.js");
78
- })(); // Provides support for Object.fromEntries in legacy browsers.
79
- // Support: Firefox<63, Chrome<73, Safari<12.1, Node.js<12.0.0
80
-
81
-
82
- (function checkObjectFromEntries() {
83
- if (Object.fromEntries) {
84
- return;
85
- }
86
-
87
- require("core-js/es/object/from-entries.js");
88
- })(); // Provides support for *recent* additions to the Promise specification,
89
- // however basic Promise support is assumed to be available natively.
90
- // Support: Firefox<71, Chrome<76, Safari<13, Node.js<12.9.0
91
-
92
-
93
- (function checkPromise() {
94
- if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
95
- // The current image decoders are synchronous, hence `Promise` shouldn't
96
- // need to be polyfilled for the IMAGE_DECODERS build target.
97
- return;
98
- }
99
-
100
- if (globalThis.Promise.allSettled) {
101
- return;
102
- }
103
-
104
- globalThis.Promise = require("core-js/es/promise/index.js");
105
- })(); // Support: Node.js
106
-
107
-
108
- (function checkReadableStream() {
109
- if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
110
- // The current image decoders are synchronous, hence `ReadableStream`
111
- // shouldn't need to be polyfilled for the IMAGE_DECODERS build target.
112
- return;
113
- }
114
-
115
- let isReadableStreamSupported = false;
116
-
117
- if (typeof ReadableStream !== "undefined") {
118
- // MS Edge may say it has ReadableStream but they are not up to spec yet.
119
- try {
120
- // eslint-disable-next-line no-new
121
- new ReadableStream({
122
- start(controller) {
123
- controller.close();
124
- }
125
-
126
- });
127
- isReadableStreamSupported = true;
128
- } catch (e) {// The ReadableStream constructor cannot be used.
129
- }
130
- }
131
-
132
- if (isReadableStreamSupported) {
133
- return;
134
- }
135
-
136
- globalThis.ReadableStream = require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
137
- })();
138
- }
139
-
140
- /* Copyright 2012 Mozilla Foundation
141
- *
142
- * Licensed under the Apache License, Version 2.0 (the "License");
143
- * you may not use this file except in compliance with the License.
144
- * You may obtain a copy of the License at
145
- *
146
- * http://www.apache.org/licenses/LICENSE-2.0
147
- *
148
- * Unless required by applicable law or agreed to in writing, software
149
- * distributed under the License is distributed on an "AS IS" BASIS,
150
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151
- * See the License for the specific language governing permissions and
152
- * limitations under the License.
153
- */
154
- const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
155
- const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; // Permission flags from Table 22, Section 7.6.3.2 of the PDF specification.
156
-
157
- const PermissionFlag = {
158
- PRINT: 0x04,
159
- MODIFY_CONTENTS: 0x08,
160
- COPY: 0x10,
161
- MODIFY_ANNOTATIONS: 0x20,
162
- FILL_INTERACTIVE_FORMS: 0x100,
163
- COPY_FOR_ACCESSIBILITY: 0x200,
164
- ASSEMBLE: 0x400,
165
- PRINT_HIGH_QUALITY: 0x800
166
- };
167
- const TextRenderingMode = {
168
- FILL: 0,
169
- STROKE: 1,
170
- FILL_STROKE: 2,
171
- INVISIBLE: 3,
172
- FILL_ADD_TO_PATH: 4,
173
- STROKE_ADD_TO_PATH: 5,
174
- FILL_STROKE_ADD_TO_PATH: 6,
175
- ADD_TO_PATH: 7,
176
- FILL_STROKE_MASK: 3,
177
- ADD_TO_PATH_FLAG: 4
178
- };
179
- const ImageKind = {
180
- GRAYSCALE_1BPP: 1,
181
- RGB_24BPP: 2,
182
- RGBA_32BPP: 3
183
- };
184
- const AnnotationType = {
185
- TEXT: 1,
186
- LINK: 2,
187
- FREETEXT: 3,
188
- LINE: 4,
189
- SQUARE: 5,
190
- CIRCLE: 6,
191
- POLYGON: 7,
192
- POLYLINE: 8,
193
- HIGHLIGHT: 9,
194
- UNDERLINE: 10,
195
- SQUIGGLY: 11,
196
- STRIKEOUT: 12,
197
- STAMP: 13,
198
- CARET: 14,
199
- INK: 15,
200
- POPUP: 16,
201
- FILEATTACHMENT: 17,
202
- SOUND: 18,
203
- MOVIE: 19,
204
- WIDGET: 20,
205
- SCREEN: 21,
206
- PRINTERMARK: 22,
207
- TRAPNET: 23,
208
- WATERMARK: 24,
209
- THREED: 25,
210
- REDACT: 26
211
- };
212
- const AnnotationReplyType = {
213
- GROUP: "Group",
214
- REPLY: "R"
215
- };
216
- const AnnotationFlag = {
217
- INVISIBLE: 0x01,
218
- HIDDEN: 0x02,
219
- PRINT: 0x04,
220
- NOZOOM: 0x08,
221
- NOROTATE: 0x10,
222
- NOVIEW: 0x20,
223
- READONLY: 0x40,
224
- LOCKED: 0x80,
225
- TOGGLENOVIEW: 0x100,
226
- LOCKEDCONTENTS: 0x200
227
- };
228
- const AnnotationFieldFlag = {
229
- READONLY: 0x0000001,
230
- REQUIRED: 0x0000002,
231
- NOEXPORT: 0x0000004,
232
- MULTILINE: 0x0001000,
233
- PASSWORD: 0x0002000,
234
- NOTOGGLETOOFF: 0x0004000,
235
- RADIO: 0x0008000,
236
- PUSHBUTTON: 0x0010000,
237
- COMBO: 0x0020000,
238
- EDIT: 0x0040000,
239
- SORT: 0x0080000,
240
- FILESELECT: 0x0100000,
241
- MULTISELECT: 0x0200000,
242
- DONOTSPELLCHECK: 0x0400000,
243
- DONOTSCROLL: 0x0800000,
244
- COMB: 0x1000000,
245
- RICHTEXT: 0x2000000,
246
- RADIOSINUNISON: 0x2000000,
247
- COMMITONSELCHANGE: 0x4000000
248
- };
249
- const AnnotationBorderStyleType = {
250
- SOLID: 1,
251
- DASHED: 2,
252
- BEVELED: 3,
253
- INSET: 4,
254
- UNDERLINE: 5
255
- };
256
- const AnnotationActionEventType = {
257
- E: "Mouse Enter",
258
- X: "Mouse Exit",
259
- D: "Mouse Down",
260
- U: "Mouse Up",
261
- Fo: "Focus",
262
- Bl: "Blur",
263
- PO: "PageOpen",
264
- PC: "PageClose",
265
- PV: "PageVisible",
266
- PI: "PageInvisible",
267
- K: "Keystroke",
268
- F: "Format",
269
- V: "Validate",
270
- C: "Calculate"
271
- };
272
- const DocumentActionEventType = {
273
- WC: "WillClose",
274
- WS: "WillSave",
275
- DS: "DidSave",
276
- WP: "WillPrint",
277
- DP: "DidPrint"
278
- };
279
- const PageActionEventType = {
280
- O: "PageOpen",
281
- C: "PageClose"
282
- };
283
- const StreamType = {
284
- UNKNOWN: "UNKNOWN",
285
- FLATE: "FLATE",
286
- LZW: "LZW",
287
- DCT: "DCT",
288
- JPX: "JPX",
289
- JBIG: "JBIG",
290
- A85: "A85",
291
- AHX: "AHX",
292
- CCF: "CCF",
293
- RLX: "RLX" // PDF short name is 'RL', but telemetry requires three chars.
294
-
295
- };
296
- const FontType = {
297
- UNKNOWN: "UNKNOWN",
298
- TYPE1: "TYPE1",
299
- TYPE1STANDARD: "TYPE1STANDARD",
300
- TYPE1C: "TYPE1C",
301
- CIDFONTTYPE0: "CIDFONTTYPE0",
302
- CIDFONTTYPE0C: "CIDFONTTYPE0C",
303
- TRUETYPE: "TRUETYPE",
304
- CIDFONTTYPE2: "CIDFONTTYPE2",
305
- TYPE3: "TYPE3",
306
- OPENTYPE: "OPENTYPE",
307
- TYPE0: "TYPE0",
308
- MMTYPE1: "MMTYPE1"
309
- };
310
- const VerbosityLevel = {
311
- ERRORS: 0,
312
- WARNINGS: 1,
313
- INFOS: 5
314
- };
315
- const CMapCompressionType = {
316
- NONE: 0,
317
- BINARY: 1,
318
- STREAM: 2
319
- }; // All the possible operations for an operator list.
320
-
321
- const OPS = {
322
- // Intentionally start from 1 so it is easy to spot bad operators that will be
323
- // 0's.
324
- dependency: 1,
325
- setLineWidth: 2,
326
- setLineCap: 3,
327
- setLineJoin: 4,
328
- setMiterLimit: 5,
329
- setDash: 6,
330
- setRenderingIntent: 7,
331
- setFlatness: 8,
332
- setGState: 9,
333
- save: 10,
334
- restore: 11,
335
- transform: 12,
336
- moveTo: 13,
337
- lineTo: 14,
338
- curveTo: 15,
339
- curveTo2: 16,
340
- curveTo3: 17,
341
- closePath: 18,
342
- rectangle: 19,
343
- stroke: 20,
344
- closeStroke: 21,
345
- fill: 22,
346
- eoFill: 23,
347
- fillStroke: 24,
348
- eoFillStroke: 25,
349
- closeFillStroke: 26,
350
- closeEOFillStroke: 27,
351
- endPath: 28,
352
- clip: 29,
353
- eoClip: 30,
354
- beginText: 31,
355
- endText: 32,
356
- setCharSpacing: 33,
357
- setWordSpacing: 34,
358
- setHScale: 35,
359
- setLeading: 36,
360
- setFont: 37,
361
- setTextRenderingMode: 38,
362
- setTextRise: 39,
363
- moveText: 40,
364
- setLeadingMoveText: 41,
365
- setTextMatrix: 42,
366
- nextLine: 43,
367
- showText: 44,
368
- showSpacedText: 45,
369
- nextLineShowText: 46,
370
- nextLineSetSpacingShowText: 47,
371
- setCharWidth: 48,
372
- setCharWidthAndBounds: 49,
373
- setStrokeColorSpace: 50,
374
- setFillColorSpace: 51,
375
- setStrokeColor: 52,
376
- setStrokeColorN: 53,
377
- setFillColor: 54,
378
- setFillColorN: 55,
379
- setStrokeGray: 56,
380
- setFillGray: 57,
381
- setStrokeRGBColor: 58,
382
- setFillRGBColor: 59,
383
- setStrokeCMYKColor: 60,
384
- setFillCMYKColor: 61,
385
- shadingFill: 62,
386
- beginInlineImage: 63,
387
- beginImageData: 64,
388
- endInlineImage: 65,
389
- paintXObject: 66,
390
- markPoint: 67,
391
- markPointProps: 68,
392
- beginMarkedContent: 69,
393
- beginMarkedContentProps: 70,
394
- endMarkedContent: 71,
395
- beginCompat: 72,
396
- endCompat: 73,
397
- paintFormXObjectBegin: 74,
398
- paintFormXObjectEnd: 75,
399
- beginGroup: 76,
400
- endGroup: 77,
401
- beginAnnotations: 78,
402
- endAnnotations: 79,
403
- beginAnnotation: 80,
404
- endAnnotation: 81,
405
- paintJpegXObject: 82,
406
- paintImageMaskXObject: 83,
407
- paintImageMaskXObjectGroup: 84,
408
- paintImageXObject: 85,
409
- paintInlineImageXObject: 86,
410
- paintInlineImageXObjectGroup: 87,
411
- paintImageXObjectRepeat: 88,
412
- paintImageMaskXObjectRepeat: 89,
413
- paintSolidColorImageMask: 90,
414
- constructPath: 91
415
- };
416
- const UNSUPPORTED_FEATURES = {
417
- /** @deprecated unused */
418
- unknown: "unknown",
419
- forms: "forms",
420
- javaScript: "javaScript",
421
- signatures: "signatures",
422
- smask: "smask",
423
- shadingPattern: "shadingPattern",
424
-
425
- /** @deprecated unused */
426
- font: "font",
427
- errorTilingPattern: "errorTilingPattern",
428
- errorExtGState: "errorExtGState",
429
- errorXObject: "errorXObject",
430
- errorFontLoadType3: "errorFontLoadType3",
431
- errorFontState: "errorFontState",
432
- errorFontMissing: "errorFontMissing",
433
- errorFontTranslate: "errorFontTranslate",
434
- errorColorSpace: "errorColorSpace",
435
- errorOperatorList: "errorOperatorList",
436
- errorFontToUnicode: "errorFontToUnicode",
437
- errorFontLoadNative: "errorFontLoadNative",
438
- errorFontBuildPath: "errorFontBuildPath",
439
- errorFontGetPath: "errorFontGetPath",
440
- errorMarkedContent: "errorMarkedContent"
441
- };
442
- const PasswordResponses = {
443
- NEED_PASSWORD: 1,
444
- INCORRECT_PASSWORD: 2
445
- };
446
- let verbosity = VerbosityLevel.WARNINGS;
447
-
448
- function setVerbosityLevel(level) {
449
- if (Number.isInteger(level)) {
450
- verbosity = level;
451
- }
452
- }
453
-
454
- function getVerbosityLevel() {
455
- return verbosity;
456
- } // A notice for devs. These are good for things that are helpful to devs, such
457
- // as warning that Workers were disabled, which is important to devs but not
458
- // end users.
459
-
460
-
461
- function info(msg) {
462
- if (verbosity >= VerbosityLevel.INFOS) {
463
- console.log(`Info: ${msg}`);
464
- }
465
- } // Non-fatal warnings.
466
-
467
-
468
- function warn(msg) {
469
- if (verbosity >= VerbosityLevel.WARNINGS) {
470
- console.log(`Warning: ${msg}`);
471
- }
472
- }
473
-
474
- function unreachable(msg) {
475
- throw new Error(msg);
476
- }
477
-
478
- function assert(cond, msg) {
479
- if (!cond) {
480
- unreachable(msg);
481
- }
482
- } // Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
483
-
484
-
485
- function isSameOrigin(baseUrl, otherUrl) {
486
- let base;
487
-
488
- try {
489
- base = new URL(baseUrl);
490
-
491
- if (!base.origin || base.origin === "null") {
492
- return false; // non-HTTP url
493
- }
494
- } catch (e) {
495
- return false;
496
- }
497
-
498
- const other = new URL(otherUrl, base);
499
- return base.origin === other.origin;
500
- } // Checks if URLs use one of the allowed protocols, e.g. to avoid XSS.
501
-
502
-
503
- function _isValidProtocol(url) {
504
- if (!url) {
505
- return false;
506
- }
507
-
508
- switch (url.protocol) {
509
- case "http:":
510
- case "https:":
511
- case "ftp:":
512
- case "mailto:":
513
- case "tel:":
514
- return true;
515
-
516
- default:
517
- return false;
518
- }
519
- }
520
- /**
521
- * Attempts to create a valid absolute URL.
522
- *
523
- * @param {URL|string} url - An absolute, or relative, URL.
524
- * @param {URL|string} baseUrl - An absolute URL.
525
- * @returns Either a valid {URL}, or `null` otherwise.
526
- */
527
-
528
-
529
- function createValidAbsoluteUrl(url, baseUrl) {
530
- if (!url) {
531
- return null;
532
- }
533
-
534
- try {
535
- const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
536
-
537
- if (_isValidProtocol(absoluteUrl)) {
538
- return absoluteUrl;
539
- }
540
- } catch (ex) {
541
- /* `new URL()` will throw on incorrect data. */
542
- }
543
-
544
- return null;
545
- }
546
-
547
- function shadow(obj, prop, value) {
548
- Object.defineProperty(obj, prop, {
549
- value,
550
- enumerable: true,
551
- configurable: true,
552
- writable: false
553
- });
554
- return value;
555
- }
556
- /**
557
- * @type {any}
558
- */
559
-
560
-
561
- const BaseException = function BaseExceptionClosure() {
562
- // eslint-disable-next-line no-shadow
563
- function BaseException(message) {
564
- if (this.constructor === BaseException) {
565
- unreachable("Cannot initialize BaseException.");
566
- }
567
-
568
- this.message = message;
569
- this.name = this.constructor.name;
570
- }
571
-
572
- BaseException.prototype = new Error();
573
- BaseException.constructor = BaseException;
574
- return BaseException;
575
- }();
576
-
577
- class PasswordException extends BaseException {
578
- constructor(msg, code) {
579
- super(msg);
580
- this.code = code;
581
- }
582
-
583
- }
584
-
585
- class UnknownErrorException extends BaseException {
586
- constructor(msg, details) {
587
- super(msg);
588
- this.details = details;
589
- }
590
-
591
- }
592
-
593
- class InvalidPDFException extends BaseException {}
594
-
595
- class MissingPDFException extends BaseException {}
596
-
597
- class UnexpectedResponseException extends BaseException {
598
- constructor(msg, status) {
599
- super(msg);
600
- this.status = status;
601
- }
602
-
603
- }
604
- /**
605
- * Error caused during parsing PDF data.
606
- */
607
-
608
-
609
- class FormatError extends BaseException {}
610
- /**
611
- * Error used to indicate task cancellation.
612
- */
613
-
614
-
615
- class AbortException extends BaseException {}
616
-
617
- const NullCharactersRegExp = /\x00/g;
618
- /**
619
- * @param {string} str
620
- */
621
-
622
- function removeNullCharacters(str) {
623
- if (typeof str !== "string") {
624
- warn("The argument for removeNullCharacters must be a string.");
625
- return str;
626
- }
627
-
628
- return str.replace(NullCharactersRegExp, "");
629
- }
630
-
631
- function bytesToString(bytes) {
632
- assert(bytes !== null && typeof bytes === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
633
- const length = bytes.length;
634
- const MAX_ARGUMENT_COUNT = 8192;
635
-
636
- if (length < MAX_ARGUMENT_COUNT) {
637
- return String.fromCharCode.apply(null, bytes);
638
- }
639
-
640
- const strBuf = [];
641
-
642
- for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
643
- const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
644
- const chunk = bytes.subarray(i, chunkEnd);
645
- strBuf.push(String.fromCharCode.apply(null, chunk));
646
- }
647
-
648
- return strBuf.join("");
649
- }
650
-
651
- function stringToBytes(str) {
652
- assert(typeof str === "string", "Invalid argument for stringToBytes");
653
- const length = str.length;
654
- const bytes = new Uint8Array(length);
655
-
656
- for (let i = 0; i < length; ++i) {
657
- bytes[i] = str.charCodeAt(i) & 0xff;
658
- }
659
-
660
- return bytes;
661
- }
662
- /**
663
- * Gets length of the array (Array, Uint8Array, or string) in bytes.
664
- * @param {Array<any>|Uint8Array|string} arr
665
- * @returns {number}
666
- */
667
-
668
-
669
- function arrayByteLength(arr) {
670
- if (arr.length !== undefined) {
671
- return arr.length;
672
- }
673
-
674
- assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
675
- return arr.byteLength;
676
- }
677
- /**
678
- * Combines array items (arrays) into single Uint8Array object.
679
- * @param {Array<Array<any>|Uint8Array|string>} arr - the array of the arrays
680
- * (Array, Uint8Array, or string).
681
- * @returns {Uint8Array}
682
- */
683
-
684
-
685
- function arraysToBytes(arr) {
686
- const length = arr.length; // Shortcut: if first and only item is Uint8Array, return it.
687
-
688
- if (length === 1 && arr[0] instanceof Uint8Array) {
689
- return arr[0];
690
- }
691
-
692
- let resultLength = 0;
693
-
694
- for (let i = 0; i < length; i++) {
695
- resultLength += arrayByteLength(arr[i]);
696
- }
697
-
698
- let pos = 0;
699
- const data = new Uint8Array(resultLength);
700
-
701
- for (let i = 0; i < length; i++) {
702
- let item = arr[i];
703
-
704
- if (!(item instanceof Uint8Array)) {
705
- if (typeof item === "string") {
706
- item = stringToBytes(item);
707
- } else {
708
- item = new Uint8Array(item);
709
- }
710
- }
711
-
712
- const itemLength = item.byteLength;
713
- data.set(item, pos);
714
- pos += itemLength;
715
- }
716
-
717
- return data;
718
- }
719
-
720
- function string32(value) {
721
- if (typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || TESTING")) {
722
- assert(typeof value === "number" && Math.abs(value) < 2 ** 32, `string32: Unexpected input "${value}".`);
723
- }
724
-
725
- return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
726
- }
727
-
728
- function objectSize(obj) {
729
- return Object.keys(obj).length;
730
- } // Ensure that the returned Object has a `null` prototype; hence why
731
- // `Object.fromEntries(...)` is not used.
732
-
733
-
734
- function objectFromMap(map) {
735
- const obj = Object.create(null);
736
-
737
- for (const [key, value] of map) {
738
- obj[key] = value;
739
- }
740
-
741
- return obj;
742
- } // Checks the endianness of the platform.
743
-
744
-
745
- function isLittleEndian() {
746
- const buffer8 = new Uint8Array(4);
747
- buffer8[0] = 1;
748
- const view32 = new Uint32Array(buffer8.buffer, 0, 1);
749
- return view32[0] === 1;
750
- }
751
-
752
- const IsLittleEndianCached = {
753
- get value() {
754
- return shadow(this, "value", isLittleEndian());
755
- }
756
-
757
- }; // Checks if it's possible to eval JS expressions.
758
-
759
- function isEvalSupported() {
760
- try {
761
- new Function(""); // eslint-disable-line no-new, no-new-func
762
-
763
- return true;
764
- } catch (e) {
765
- return false;
766
- }
767
- }
768
-
769
- const IsEvalSupportedCached = {
770
- get value() {
771
- return shadow(this, "value", isEvalSupported());
772
- }
773
-
774
- };
775
- const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
776
-
777
- class Util {
778
- static makeHexColor(r, g, b) {
779
- return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
780
- } // Concatenates two transformation matrices together and returns the result.
781
-
782
-
783
- static transform(m1, m2) {
784
- return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
785
- } // For 2d affine transforms
786
-
787
-
788
- static applyTransform(p, m) {
789
- const xt = p[0] * m[0] + p[1] * m[2] + m[4];
790
- const yt = p[0] * m[1] + p[1] * m[3] + m[5];
791
- return [xt, yt];
792
- }
793
-
794
- static applyInverseTransform(p, m) {
795
- const d = m[0] * m[3] - m[1] * m[2];
796
- const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
797
- const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
798
- return [xt, yt];
799
- } // Applies the transform to the rectangle and finds the minimum axially
800
- // aligned bounding box.
801
-
802
-
803
- static getAxialAlignedBoundingBox(r, m) {
804
- const p1 = Util.applyTransform(r, m);
805
- const p2 = Util.applyTransform(r.slice(2, 4), m);
806
- const p3 = Util.applyTransform([r[0], r[3]], m);
807
- const p4 = Util.applyTransform([r[2], r[1]], m);
808
- return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
809
- }
810
-
811
- static inverseTransform(m) {
812
- const d = m[0] * m[3] - m[1] * m[2];
813
- return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
814
- } // Apply a generic 3d matrix M on a 3-vector v:
815
- // | a b c | | X |
816
- // | d e f | x | Y |
817
- // | g h i | | Z |
818
- // M is assumed to be serialized as [a,b,c,d,e,f,g,h,i],
819
- // with v as [X,Y,Z]
820
-
821
-
822
- static apply3dTransform(m, v) {
823
- return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
824
- } // This calculation uses Singular Value Decomposition.
825
- // The SVD can be represented with formula A = USV. We are interested in the
826
- // matrix S here because it represents the scale values.
827
-
828
-
829
- static singularValueDecompose2dScale(m) {
830
- const transpose = [m[0], m[2], m[1], m[3]]; // Multiply matrix m with its transpose.
831
-
832
- const a = m[0] * transpose[0] + m[1] * transpose[2];
833
- const b = m[0] * transpose[1] + m[1] * transpose[3];
834
- const c = m[2] * transpose[0] + m[3] * transpose[2];
835
- const d = m[2] * transpose[1] + m[3] * transpose[3]; // Solve the second degree polynomial to get roots.
836
-
837
- const first = (a + d) / 2;
838
- const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
839
- const sx = first + second || 1;
840
- const sy = first - second || 1; // Scale values are the square roots of the eigenvalues.
841
-
842
- return [Math.sqrt(sx), Math.sqrt(sy)];
843
- } // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
844
- // For coordinate systems whose origin lies in the bottom-left, this
845
- // means normalization to (BL,TR) ordering. For systems with origin in the
846
- // top-left, this means (TL,BR) ordering.
847
-
848
-
849
- static normalizeRect(rect) {
850
- const r = rect.slice(0); // clone rect
851
-
852
- if (rect[0] > rect[2]) {
853
- r[0] = rect[2];
854
- r[2] = rect[0];
855
- }
856
-
857
- if (rect[1] > rect[3]) {
858
- r[1] = rect[3];
859
- r[3] = rect[1];
860
- }
861
-
862
- return r;
863
- } // Returns a rectangle [x1, y1, x2, y2] corresponding to the
864
- // intersection of rect1 and rect2. If no intersection, returns 'false'
865
- // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
866
-
867
-
868
- static intersect(rect1, rect2) {
869
- function compare(a, b) {
870
- return a - b;
871
- } // Order points along the axes
872
-
873
-
874
- const orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
875
- const orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
876
- const result = [];
877
- rect1 = Util.normalizeRect(rect1);
878
- rect2 = Util.normalizeRect(rect2); // X: first and second points belong to different rectangles?
879
-
880
- if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
881
- // Intersection must be between second and third points
882
- result[0] = orderedX[1];
883
- result[2] = orderedX[2];
884
- } else {
885
- return null;
886
- } // Y: first and second points belong to different rectangles?
887
-
888
-
889
- if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
890
- // Intersection must be between second and third points
891
- result[1] = orderedY[1];
892
- result[3] = orderedY[2];
893
- } else {
894
- return null;
895
- }
896
-
897
- return result;
898
- }
899
-
900
- }
901
-
902
- const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
903
-
904
- function stringToPDFString(str) {
905
- const length = str.length,
906
- strBuf = [];
907
-
908
- if (str[0] === "\xFE" && str[1] === "\xFF") {
909
- // UTF16BE BOM
910
- for (let i = 2; i < length; i += 2) {
911
- strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
912
- }
913
- } else if (str[0] === "\xFF" && str[1] === "\xFE") {
914
- // UTF16LE BOM
915
- for (let i = 2; i < length; i += 2) {
916
- strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i)));
917
- }
918
- } else {
919
- for (let i = 0; i < length; ++i) {
920
- const code = PDFStringTranslateTable[str.charCodeAt(i)];
921
- strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
922
- }
923
- }
924
-
925
- return strBuf.join("");
926
- }
927
-
928
- function escapeString(str) {
929
- // replace "(", ")", "\n", "\r" and "\"
930
- // by "\(", "\)", "\\n", "\\r" and "\\"
931
- // in order to write it in a PDF file.
932
- return str.replace(/([()\\\n\r])/g, match => {
933
- if (match === "\n") {
934
- return "\\n";
935
- } else if (match === "\r") {
936
- return "\\r";
937
- }
938
-
939
- return `\\${match}`;
940
- });
941
- }
942
-
943
- function isAscii(str) {
944
- return /^[\x00-\x7F]*$/.test(str);
945
- }
946
-
947
- function stringToUTF16BEString(str) {
948
- const buf = ["\xFE\xFF"];
949
-
950
- for (let i = 0, ii = str.length; i < ii; i++) {
951
- const char = str.charCodeAt(i);
952
- buf.push(String.fromCharCode(char >> 8 & 0xff), String.fromCharCode(char & 0xff));
953
- }
954
-
955
- return buf.join("");
956
- }
957
-
958
- function stringToUTF8String(str) {
959
- return decodeURIComponent(escape(str));
960
- }
961
-
962
- function utf8StringToString(str) {
963
- return unescape(encodeURIComponent(str));
964
- }
965
-
966
- function isBool(v) {
967
- return typeof v === "boolean";
968
- }
969
-
970
- function isNum(v) {
971
- return typeof v === "number";
972
- }
973
-
974
- function isString(v) {
975
- return typeof v === "string";
976
- }
977
-
978
- function isArrayBuffer(v) {
979
- return typeof v === "object" && v !== null && v.byteLength !== undefined;
980
- }
981
-
982
- function isArrayEqual(arr1, arr2) {
983
- if (arr1.length !== arr2.length) {
984
- return false;
985
- }
986
-
987
- for (let i = 0, ii = arr1.length; i < ii; i++) {
988
- if (arr1[i] !== arr2[i]) {
989
- return false;
990
- }
991
- }
992
-
993
- return true;
994
- }
995
-
996
- function getModificationDate(date = new Date()) {
997
- const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
998
- return buffer.join("");
999
- }
1000
- /**
1001
- * Promise Capability object.
1002
- *
1003
- * @typedef {Object} PromiseCapability
1004
- * @property {Promise<any>} promise - A Promise object.
1005
- * @property {boolean} settled - If the Promise has been fulfilled/rejected.
1006
- * @property {function} resolve - Fulfills the Promise.
1007
- * @property {function} reject - Rejects the Promise.
1008
- */
1009
-
1010
- /**
1011
- * Creates a promise capability object.
1012
- * @alias createPromiseCapability
1013
- *
1014
- * @returns {PromiseCapability}
1015
- */
1016
-
1017
-
1018
- function createPromiseCapability() {
1019
- const capability = Object.create(null);
1020
- let isSettled = false;
1021
- Object.defineProperty(capability, "settled", {
1022
- get() {
1023
- return isSettled;
1024
- }
1025
-
1026
- });
1027
- capability.promise = new Promise(function (resolve, reject) {
1028
- capability.resolve = function (data) {
1029
- isSettled = true;
1030
- resolve(data);
1031
- };
1032
-
1033
- capability.reject = function (reason) {
1034
- isSettled = true;
1035
- reject(reason);
1036
- };
1037
- });
1038
- return capability;
1039
- }
1040
-
1041
- function createObjectURL(data, contentType = "", forceDataSchema = false) {
1042
- if (URL.createObjectURL && !forceDataSchema) {
1043
- return URL.createObjectURL(new Blob([data], {
1044
- type: contentType
1045
- }));
1046
- } // Blob/createObjectURL is not available, falling back to data schema.
1047
-
1048
-
1049
- const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
1050
- let buffer = `data:${contentType};base64,`;
1051
-
1052
- for (let i = 0, ii = data.length; i < ii; i += 3) {
1053
- const b1 = data[i] & 0xff;
1054
- const b2 = data[i + 1] & 0xff;
1055
- const b3 = data[i + 2] & 0xff;
1056
- const d1 = b1 >> 2,
1057
- d2 = (b1 & 3) << 4 | b2 >> 4;
1058
- const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
1059
- const d4 = i + 2 < ii ? b3 & 0x3f : 64;
1060
- buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
1061
- }
1062
-
1063
- return buffer;
1064
- }
1065
-
1066
- export { utf8StringToString as $, AbortException as A, stringToPDFString as B, createObjectURL as C, CMapCompressionType as D, createValidAbsoluteUrl as E, FormatError as F, PasswordResponses as G, PermissionFlag as H, IsEvalSupportedCached as I, removeNullCharacters as J, BaseException as K, isString as L, MissingPDFException as M, objectSize as N, OPS as O, PasswordException as P, arrayByteLength as Q, arraysToBytes as R, StreamType as S, TextRenderingMode as T, UNSUPPORTED_FEATURES as U, VerbosityLevel as V, FontType as W, isBool as X, isArrayEqual as Y, stringToUTF8String as Z, DocumentActionEventType as _, string32 as a, escapeString as a0, AnnotationFlag as a1, AnnotationFieldFlag as a2, isAscii as a3, stringToUTF16BEString as a4, getModificationDate as a5, AnnotationReplyType as a6, AnnotationActionEventType as a7, PageActionEventType as a8, bytesToString as b, assert as c, info as d, Util as e, IDENTITY_MATRIX as f, FONT_IDENTITY_MATRIX as g, isNum as h, isNodeJS as i, ImageKind as j, IsLittleEndianCached as k, createPromiseCapability as l, isArrayBuffer as m, stringToBytes as n, objectFromMap as o, setVerbosityLevel as p, getVerbosityLevel as q, isSameOrigin as r, shadow as s, UnknownErrorException as t, unreachable as u, UnexpectedResponseException as v, warn as w, InvalidPDFException as x, AnnotationType as y, AnnotationBorderStyleType as z };
1
+ /* Copyright 2012 Mozilla Foundation
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+ /* globals process */
16
+
17
+ // NW.js / Electron is a browser context, but copies some Node.js objects; see
18
+ // http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
19
+ // https://www.electronjs.org/docs/api/process#processversionselectron-readonly
20
+ // https://www.electronjs.org/docs/api/process#processtype-readonly
21
+ const isNodeJS = (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) && typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
22
+ const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
23
+ const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
24
+ const MAX_IMAGE_SIZE_TO_CACHE = 10e6; // Ten megabytes.
25
+
26
+ // Represent the percentage of the height of a single-line field over
27
+ // the font size. Acrobat seems to use this value.
28
+ const LINE_FACTOR = 1.35;
29
+ const LINE_DESCENT_FACTOR = 0.35;
30
+ const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
31
+
32
+ /**
33
+ * Refer to the `WorkerTransport.getRenderingIntent`-method in the API, to see
34
+ * how these flags are being used:
35
+ * - ANY, DISPLAY, and PRINT are the normal rendering intents, note the
36
+ * `PDFPageProxy.{render, getOperatorList, getAnnotations}`-methods.
37
+ * - ANNOTATIONS_FORMS, ANNOTATIONS_STORAGE, ANNOTATIONS_DISABLE control which
38
+ * annotations are rendered onto the canvas (i.e. by being included in the
39
+ * operatorList), note the `PDFPageProxy.{render, getOperatorList}`-methods
40
+ * and their `annotationMode`-option.
41
+ * - OPLIST is used with the `PDFPageProxy.getOperatorList`-method, note the
42
+ * `OperatorList`-constructor (on the worker-thread).
43
+ */
44
+ const RenderingIntentFlag = {
45
+ ANY: 0x01,
46
+ DISPLAY: 0x02,
47
+ PRINT: 0x04,
48
+ SAVE: 0x08,
49
+ ANNOTATIONS_FORMS: 0x10,
50
+ ANNOTATIONS_STORAGE: 0x20,
51
+ ANNOTATIONS_DISABLE: 0x40,
52
+ OPLIST: 0x100
53
+ };
54
+ const AnnotationMode = {
55
+ DISABLE: 0,
56
+ ENABLE: 1,
57
+ ENABLE_FORMS: 2,
58
+ ENABLE_STORAGE: 3
59
+ };
60
+ const AnnotationEditorPrefix = "pdfjs_internal_editor_";
61
+ const AnnotationEditorType = {
62
+ DISABLE: -1,
63
+ NONE: 0,
64
+ FREETEXT: 3,
65
+ HIGHLIGHT: 9,
66
+ STAMP: 13,
67
+ INK: 15
68
+ };
69
+ const AnnotationEditorParamsType = {
70
+ RESIZE: 1,
71
+ CREATE: 2,
72
+ FREETEXT_SIZE: 11,
73
+ FREETEXT_COLOR: 12,
74
+ FREETEXT_OPACITY: 13,
75
+ INK_COLOR: 21,
76
+ INK_THICKNESS: 22,
77
+ INK_OPACITY: 23,
78
+ HIGHLIGHT_COLOR: 31,
79
+ HIGHLIGHT_DEFAULT_COLOR: 32,
80
+ HIGHLIGHT_THICKNESS: 33,
81
+ HIGHLIGHT_FREE: 34,
82
+ HIGHLIGHT_SHOW_ALL: 35
83
+ };
84
+
85
+ // Permission flags from Table 22, Section 7.6.3.2 of the PDF specification.
86
+ const PermissionFlag = {
87
+ PRINT: 0x04,
88
+ MODIFY_CONTENTS: 0x08,
89
+ COPY: 0x10,
90
+ MODIFY_ANNOTATIONS: 0x20,
91
+ FILL_INTERACTIVE_FORMS: 0x100,
92
+ COPY_FOR_ACCESSIBILITY: 0x200,
93
+ ASSEMBLE: 0x400,
94
+ PRINT_HIGH_QUALITY: 0x800
95
+ };
96
+ const TextRenderingMode = {
97
+ FILL: 0,
98
+ STROKE: 1,
99
+ FILL_STROKE: 2,
100
+ INVISIBLE: 3,
101
+ FILL_STROKE_MASK: 3,
102
+ ADD_TO_PATH_FLAG: 4
103
+ };
104
+ const ImageKind = {
105
+ GRAYSCALE_1BPP: 1,
106
+ RGB_24BPP: 2,
107
+ RGBA_32BPP: 3
108
+ };
109
+ const AnnotationType = {
110
+ TEXT: 1,
111
+ LINK: 2,
112
+ FREETEXT: 3,
113
+ LINE: 4,
114
+ SQUARE: 5,
115
+ CIRCLE: 6,
116
+ POLYGON: 7,
117
+ POLYLINE: 8,
118
+ HIGHLIGHT: 9,
119
+ UNDERLINE: 10,
120
+ SQUIGGLY: 11,
121
+ STRIKEOUT: 12,
122
+ STAMP: 13,
123
+ CARET: 14,
124
+ INK: 15,
125
+ POPUP: 16,
126
+ FILEATTACHMENT: 17,
127
+ WIDGET: 20};
128
+ const AnnotationReplyType = {
129
+ GROUP: "Group",
130
+ REPLY: "R"
131
+ };
132
+ const AnnotationFlag = {
133
+ INVISIBLE: 0x01,
134
+ HIDDEN: 0x02,
135
+ PRINT: 0x04,
136
+ NOROTATE: 0x10,
137
+ NOVIEW: 0x20,
138
+ LOCKED: 0x80,
139
+ LOCKEDCONTENTS: 0x200
140
+ };
141
+ const AnnotationFieldFlag = {
142
+ READONLY: 0x0000001,
143
+ REQUIRED: 0x0000002,
144
+ MULTILINE: 0x0001000,
145
+ PASSWORD: 0x0002000,
146
+ RADIO: 0x0008000,
147
+ PUSHBUTTON: 0x0010000,
148
+ COMBO: 0x0020000,
149
+ FILESELECT: 0x0100000,
150
+ MULTISELECT: 0x0200000,
151
+ DONOTSCROLL: 0x0800000,
152
+ COMB: 0x1000000};
153
+ const AnnotationBorderStyleType = {
154
+ SOLID: 1,
155
+ DASHED: 2,
156
+ BEVELED: 3,
157
+ INSET: 4,
158
+ UNDERLINE: 5
159
+ };
160
+ const AnnotationActionEventType = {
161
+ E: "Mouse Enter",
162
+ X: "Mouse Exit",
163
+ D: "Mouse Down",
164
+ U: "Mouse Up",
165
+ Fo: "Focus",
166
+ Bl: "Blur",
167
+ PO: "PageOpen",
168
+ PC: "PageClose",
169
+ PV: "PageVisible",
170
+ PI: "PageInvisible",
171
+ K: "Keystroke",
172
+ F: "Format",
173
+ V: "Validate",
174
+ C: "Calculate"
175
+ };
176
+ const DocumentActionEventType = {
177
+ WC: "WillClose",
178
+ WS: "WillSave",
179
+ DS: "DidSave",
180
+ WP: "WillPrint",
181
+ DP: "DidPrint"
182
+ };
183
+ const PageActionEventType = {
184
+ O: "PageOpen",
185
+ C: "PageClose"
186
+ };
187
+ const VerbosityLevel = {
188
+ ERRORS: 0,
189
+ WARNINGS: 1,
190
+ INFOS: 5
191
+ };
192
+ const CMapCompressionType = {
193
+ NONE: 0,
194
+ BINARY: 1
195
+ };
196
+
197
+ // All the possible operations for an operator list.
198
+ const OPS = {
199
+ // Intentionally start from 1 so it is easy to spot bad operators that will be
200
+ // 0's.
201
+ // PLEASE NOTE: We purposely keep any removed operators commented out, since
202
+ // re-numbering the list would risk breaking third-party users.
203
+ dependency: 1,
204
+ setLineWidth: 2,
205
+ setLineCap: 3,
206
+ setLineJoin: 4,
207
+ setMiterLimit: 5,
208
+ setDash: 6,
209
+ setRenderingIntent: 7,
210
+ setFlatness: 8,
211
+ setGState: 9,
212
+ save: 10,
213
+ restore: 11,
214
+ transform: 12,
215
+ moveTo: 13,
216
+ lineTo: 14,
217
+ curveTo: 15,
218
+ curveTo2: 16,
219
+ curveTo3: 17,
220
+ closePath: 18,
221
+ rectangle: 19,
222
+ stroke: 20,
223
+ closeStroke: 21,
224
+ fill: 22,
225
+ eoFill: 23,
226
+ fillStroke: 24,
227
+ eoFillStroke: 25,
228
+ closeFillStroke: 26,
229
+ closeEOFillStroke: 27,
230
+ endPath: 28,
231
+ clip: 29,
232
+ eoClip: 30,
233
+ beginText: 31,
234
+ endText: 32,
235
+ setCharSpacing: 33,
236
+ setWordSpacing: 34,
237
+ setHScale: 35,
238
+ setLeading: 36,
239
+ setFont: 37,
240
+ setTextRenderingMode: 38,
241
+ setTextRise: 39,
242
+ moveText: 40,
243
+ setLeadingMoveText: 41,
244
+ setTextMatrix: 42,
245
+ nextLine: 43,
246
+ showText: 44,
247
+ showSpacedText: 45,
248
+ nextLineShowText: 46,
249
+ nextLineSetSpacingShowText: 47,
250
+ setCharWidth: 48,
251
+ setCharWidthAndBounds: 49,
252
+ setStrokeColorSpace: 50,
253
+ setFillColorSpace: 51,
254
+ setStrokeColor: 52,
255
+ setStrokeColorN: 53,
256
+ setFillColor: 54,
257
+ setFillColorN: 55,
258
+ setStrokeGray: 56,
259
+ setFillGray: 57,
260
+ setStrokeRGBColor: 58,
261
+ setFillRGBColor: 59,
262
+ setStrokeCMYKColor: 60,
263
+ setFillCMYKColor: 61,
264
+ shadingFill: 62,
265
+ beginInlineImage: 63,
266
+ beginImageData: 64,
267
+ endInlineImage: 65,
268
+ paintXObject: 66,
269
+ markPoint: 67,
270
+ markPointProps: 68,
271
+ beginMarkedContent: 69,
272
+ beginMarkedContentProps: 70,
273
+ endMarkedContent: 71,
274
+ beginCompat: 72,
275
+ endCompat: 73,
276
+ paintFormXObjectBegin: 74,
277
+ paintFormXObjectEnd: 75,
278
+ beginGroup: 76,
279
+ endGroup: 77,
280
+ // beginAnnotations: 78,
281
+ // endAnnotations: 79,
282
+ beginAnnotation: 80,
283
+ endAnnotation: 81,
284
+ // paintJpegXObject: 82,
285
+ paintImageMaskXObject: 83,
286
+ paintImageMaskXObjectGroup: 84,
287
+ paintImageXObject: 85,
288
+ paintInlineImageXObject: 86,
289
+ paintInlineImageXObjectGroup: 87,
290
+ paintImageXObjectRepeat: 88,
291
+ paintImageMaskXObjectRepeat: 89,
292
+ paintSolidColorImageMask: 90,
293
+ constructPath: 91
294
+ };
295
+ const PasswordResponses = {
296
+ NEED_PASSWORD: 1,
297
+ INCORRECT_PASSWORD: 2
298
+ };
299
+ let verbosity = VerbosityLevel.WARNINGS;
300
+ function setVerbosityLevel(level) {
301
+ if (Number.isInteger(level)) {
302
+ verbosity = level;
303
+ }
304
+ }
305
+ function getVerbosityLevel() {
306
+ return verbosity;
307
+ }
308
+
309
+ // A notice for devs. These are good for things that are helpful to devs, such
310
+ // as warning that Workers were disabled, which is important to devs but not
311
+ // end users.
312
+ function info(msg) {
313
+ if (verbosity >= VerbosityLevel.INFOS) {
314
+ console.log(`Info: ${msg}`);
315
+ }
316
+ }
317
+
318
+ // Non-fatal warnings.
319
+ function warn(msg) {
320
+ if (verbosity >= VerbosityLevel.WARNINGS) {
321
+ console.log(`Warning: ${msg}`);
322
+ }
323
+ }
324
+ function unreachable(msg) {
325
+ throw new Error(msg);
326
+ }
327
+ function assert(cond, msg) {
328
+ if (!cond) {
329
+ unreachable(msg);
330
+ }
331
+ }
332
+
333
+ // Checks if URLs use one of the allowed protocols, e.g. to avoid XSS.
334
+ function _isValidProtocol(url) {
335
+ switch (url === null || url === void 0 ? void 0 : url.protocol) {
336
+ case "http:":
337
+ case "https:":
338
+ case "ftp:":
339
+ case "mailto:":
340
+ case "tel:":
341
+ return true;
342
+ default:
343
+ return false;
344
+ }
345
+ }
346
+
347
+ /**
348
+ * Attempts to create a valid absolute URL.
349
+ *
350
+ * @param {URL|string} url - An absolute, or relative, URL.
351
+ * @param {URL|string} [baseUrl] - An absolute URL.
352
+ * @param {Object} [options]
353
+ * @returns Either a valid {URL}, or `null` otherwise.
354
+ */
355
+ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
356
+ if (!url) {
357
+ return null;
358
+ }
359
+ try {
360
+ if (options && typeof url === "string") {
361
+ // Let URLs beginning with "www." default to using the "http://" protocol.
362
+ if (options.addDefaultProtocol && url.startsWith("www.")) {
363
+ const dots = url.match(/\./g);
364
+ // Avoid accidentally matching a *relative* URL pointing to a file named
365
+ // e.g. "www.pdf" or similar.
366
+ if ((dots === null || dots === void 0 ? void 0 : dots.length) >= 2) {
367
+ url = `http://${url}`;
368
+ }
369
+ }
370
+
371
+ // According to ISO 32000-1:2008, section 12.6.4.7, URIs should be encoded
372
+ // in 7-bit ASCII. Some bad PDFs use UTF-8 encoding; see bug 1122280.
373
+ if (options.tryConvertEncoding) {
374
+ try {
375
+ url = stringToUTF8String(url);
376
+ } catch {}
377
+ }
378
+ }
379
+ const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
380
+ if (_isValidProtocol(absoluteUrl)) {
381
+ return absoluteUrl;
382
+ }
383
+ } catch {
384
+ /* `new URL()` will throw on incorrect data. */
385
+ }
386
+ return null;
387
+ }
388
+ function shadow(obj, prop, value, nonSerializable = false) {
389
+ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
390
+ assert(prop in obj, `shadow: Property "${prop && prop.toString()}" not found in object.`);
391
+ }
392
+ Object.defineProperty(obj, prop, {
393
+ value,
394
+ enumerable: !nonSerializable,
395
+ configurable: true,
396
+ writable: false
397
+ });
398
+ return value;
399
+ }
400
+
401
+ /**
402
+ * @type {any}
403
+ */
404
+ const BaseException = function BaseExceptionClosure() {
405
+ // eslint-disable-next-line no-shadow
406
+ function BaseException(message, name) {
407
+ if (this.constructor === BaseException) {
408
+ unreachable("Cannot initialize BaseException.");
409
+ }
410
+ this.message = message;
411
+ this.name = name;
412
+ }
413
+ BaseException.prototype = new Error();
414
+ BaseException.constructor = BaseException;
415
+ return BaseException;
416
+ }();
417
+ class PasswordException extends BaseException {
418
+ constructor(msg, code) {
419
+ super(msg, "PasswordException");
420
+ this.code = code;
421
+ }
422
+ }
423
+ class UnknownErrorException extends BaseException {
424
+ constructor(msg, details) {
425
+ super(msg, "UnknownErrorException");
426
+ this.details = details;
427
+ }
428
+ }
429
+ class InvalidPDFException extends BaseException {
430
+ constructor(msg) {
431
+ super(msg, "InvalidPDFException");
432
+ }
433
+ }
434
+ class MissingPDFException extends BaseException {
435
+ constructor(msg) {
436
+ super(msg, "MissingPDFException");
437
+ }
438
+ }
439
+ class UnexpectedResponseException extends BaseException {
440
+ constructor(msg, status) {
441
+ super(msg, "UnexpectedResponseException");
442
+ this.status = status;
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Error caused during parsing PDF data.
448
+ */
449
+ class FormatError extends BaseException {
450
+ constructor(msg) {
451
+ super(msg, "FormatError");
452
+ }
453
+ }
454
+
455
+ /**
456
+ * Error used to indicate task cancellation.
457
+ */
458
+ class AbortException extends BaseException {
459
+ constructor(msg) {
460
+ super(msg, "AbortException");
461
+ }
462
+ }
463
+ function bytesToString(bytes) {
464
+ if (typeof bytes !== "object" || (bytes === null || bytes === void 0 ? void 0 : bytes.length) === undefined) {
465
+ unreachable("Invalid argument for bytesToString");
466
+ }
467
+ const length = bytes.length;
468
+ const MAX_ARGUMENT_COUNT = 8192;
469
+ if (length < MAX_ARGUMENT_COUNT) {
470
+ return String.fromCharCode.apply(null, bytes);
471
+ }
472
+ const strBuf = [];
473
+ for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
474
+ const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
475
+ const chunk = bytes.subarray(i, chunkEnd);
476
+ strBuf.push(String.fromCharCode.apply(null, chunk));
477
+ }
478
+ return strBuf.join("");
479
+ }
480
+ function stringToBytes(str) {
481
+ if (typeof str !== "string") {
482
+ unreachable("Invalid argument for stringToBytes");
483
+ }
484
+ const length = str.length;
485
+ const bytes = new Uint8Array(length);
486
+ for (let i = 0; i < length; ++i) {
487
+ bytes[i] = str.charCodeAt(i) & 0xff;
488
+ }
489
+ return bytes;
490
+ }
491
+ function string32(value) {
492
+ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
493
+ assert(typeof value === "number" && Math.abs(value) < 2 ** 32, `string32: Unexpected input "${value}".`);
494
+ }
495
+ return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
496
+ }
497
+ function objectSize(obj) {
498
+ return Object.keys(obj).length;
499
+ }
500
+
501
+ // Ensure that the returned Object has a `null` prototype; hence why
502
+ // `Object.fromEntries(...)` is not used.
503
+ function objectFromMap(map) {
504
+ const obj = Object.create(null);
505
+ for (const [key, value] of map) {
506
+ obj[key] = value;
507
+ }
508
+ return obj;
509
+ }
510
+
511
+ // Checks the endianness of the platform.
512
+ function isLittleEndian() {
513
+ const buffer8 = new Uint8Array(4);
514
+ buffer8[0] = 1;
515
+ const view32 = new Uint32Array(buffer8.buffer, 0, 1);
516
+ return view32[0] === 1;
517
+ }
518
+
519
+ // Checks if it's possible to eval JS expressions.
520
+ function isEvalSupported() {
521
+ try {
522
+ new Function(""); // eslint-disable-line no-new, no-new-func
523
+ return true;
524
+ } catch {
525
+ return false;
526
+ }
527
+ }
528
+ class FeatureTest {
529
+ static get isLittleEndian() {
530
+ return shadow(this, "isLittleEndian", isLittleEndian());
531
+ }
532
+ static get isEvalSupported() {
533
+ return shadow(this, "isEvalSupported", isEvalSupported());
534
+ }
535
+ static get isOffscreenCanvasSupported() {
536
+ return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
537
+ }
538
+ static get platform() {
539
+ var _navigator;
540
+ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL") || typeof navigator !== "undefined" && typeof ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.platform) === "string") {
541
+ return shadow(this, "platform", {
542
+ isMac: navigator.platform.includes("Mac")
543
+ });
544
+ }
545
+ return shadow(this, "platform", {
546
+ isMac: false
547
+ });
548
+ }
549
+ static get isCSSRoundSupported() {
550
+ var _globalThis$CSS, _globalThis$CSS$suppo;
551
+ return shadow(this, "isCSSRoundSupported", (_globalThis$CSS = globalThis.CSS) === null || _globalThis$CSS === void 0 ? void 0 : (_globalThis$CSS$suppo = _globalThis$CSS.supports) === null || _globalThis$CSS$suppo === void 0 ? void 0 : _globalThis$CSS$suppo.call(_globalThis$CSS, "width: round(1.5px, 1px)"));
552
+ }
553
+ }
554
+ const hexNumbers = Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0"));
555
+ class Util {
556
+ static makeHexColor(r, g, b) {
557
+ return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
558
+ }
559
+
560
+ // Apply a scaling matrix to some min/max values.
561
+ // If a scaling factor is negative then min and max must be
562
+ // swapped.
563
+ static scaleMinMax(transform, minMax) {
564
+ let temp;
565
+ if (transform[0]) {
566
+ if (transform[0] < 0) {
567
+ temp = minMax[0];
568
+ minMax[0] = minMax[2];
569
+ minMax[2] = temp;
570
+ }
571
+ minMax[0] *= transform[0];
572
+ minMax[2] *= transform[0];
573
+ if (transform[3] < 0) {
574
+ temp = minMax[1];
575
+ minMax[1] = minMax[3];
576
+ minMax[3] = temp;
577
+ }
578
+ minMax[1] *= transform[3];
579
+ minMax[3] *= transform[3];
580
+ } else {
581
+ temp = minMax[0];
582
+ minMax[0] = minMax[1];
583
+ minMax[1] = temp;
584
+ temp = minMax[2];
585
+ minMax[2] = minMax[3];
586
+ minMax[3] = temp;
587
+ if (transform[1] < 0) {
588
+ temp = minMax[1];
589
+ minMax[1] = minMax[3];
590
+ minMax[3] = temp;
591
+ }
592
+ minMax[1] *= transform[1];
593
+ minMax[3] *= transform[1];
594
+ if (transform[2] < 0) {
595
+ temp = minMax[0];
596
+ minMax[0] = minMax[2];
597
+ minMax[2] = temp;
598
+ }
599
+ minMax[0] *= transform[2];
600
+ minMax[2] *= transform[2];
601
+ }
602
+ minMax[0] += transform[4];
603
+ minMax[1] += transform[5];
604
+ minMax[2] += transform[4];
605
+ minMax[3] += transform[5];
606
+ }
607
+
608
+ // Concatenates two transformation matrices together and returns the result.
609
+ static transform(m1, m2) {
610
+ return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
611
+ }
612
+
613
+ // For 2d affine transforms
614
+ static applyTransform(p, m) {
615
+ const xt = p[0] * m[0] + p[1] * m[2] + m[4];
616
+ const yt = p[0] * m[1] + p[1] * m[3] + m[5];
617
+ return [xt, yt];
618
+ }
619
+ static applyInverseTransform(p, m) {
620
+ const d = m[0] * m[3] - m[1] * m[2];
621
+ const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
622
+ const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
623
+ return [xt, yt];
624
+ }
625
+
626
+ // Applies the transform to the rectangle and finds the minimum axially
627
+ // aligned bounding box.
628
+ static getAxialAlignedBoundingBox(r, m) {
629
+ const p1 = this.applyTransform(r, m);
630
+ const p2 = this.applyTransform(r.slice(2, 4), m);
631
+ const p3 = this.applyTransform([r[0], r[3]], m);
632
+ const p4 = this.applyTransform([r[2], r[1]], m);
633
+ return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
634
+ }
635
+ static inverseTransform(m) {
636
+ const d = m[0] * m[3] - m[1] * m[2];
637
+ return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
638
+ }
639
+
640
+ // This calculation uses Singular Value Decomposition.
641
+ // The SVD can be represented with formula A = USV. We are interested in the
642
+ // matrix S here because it represents the scale values.
643
+ static singularValueDecompose2dScale(m) {
644
+ const transpose = [m[0], m[2], m[1], m[3]];
645
+
646
+ // Multiply matrix m with its transpose.
647
+ const a = m[0] * transpose[0] + m[1] * transpose[2];
648
+ const b = m[0] * transpose[1] + m[1] * transpose[3];
649
+ const c = m[2] * transpose[0] + m[3] * transpose[2];
650
+ const d = m[2] * transpose[1] + m[3] * transpose[3];
651
+
652
+ // Solve the second degree polynomial to get roots.
653
+ const first = (a + d) / 2;
654
+ const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
655
+ const sx = first + second || 1;
656
+ const sy = first - second || 1;
657
+
658
+ // Scale values are the square roots of the eigenvalues.
659
+ return [Math.sqrt(sx), Math.sqrt(sy)];
660
+ }
661
+
662
+ // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
663
+ // For coordinate systems whose origin lies in the bottom-left, this
664
+ // means normalization to (BL,TR) ordering. For systems with origin in the
665
+ // top-left, this means (TL,BR) ordering.
666
+ static normalizeRect(rect) {
667
+ const r = rect.slice(0); // clone rect
668
+ if (rect[0] > rect[2]) {
669
+ r[0] = rect[2];
670
+ r[2] = rect[0];
671
+ }
672
+ if (rect[1] > rect[3]) {
673
+ r[1] = rect[3];
674
+ r[3] = rect[1];
675
+ }
676
+ return r;
677
+ }
678
+
679
+ // Returns a rectangle [x1, y1, x2, y2] corresponding to the
680
+ // intersection of rect1 and rect2. If no intersection, returns 'null'
681
+ // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
682
+ static intersect(rect1, rect2) {
683
+ const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
684
+ const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
685
+ if (xLow > xHigh) {
686
+ return null;
687
+ }
688
+ const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
689
+ const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
690
+ if (yLow > yHigh) {
691
+ return null;
692
+ }
693
+ return [xLow, yLow, xHigh, yHigh];
694
+ }
695
+ static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
696
+ if (t <= 0 || t >= 1) {
697
+ return;
698
+ }
699
+ const mt = 1 - t;
700
+ const tt = t * t;
701
+ const ttt = tt * t;
702
+ const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
703
+ const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
704
+ minMax[0] = Math.min(minMax[0], x);
705
+ minMax[1] = Math.min(minMax[1], y);
706
+ minMax[2] = Math.max(minMax[2], x);
707
+ minMax[3] = Math.max(minMax[3], y);
708
+ }
709
+ static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
710
+ if (Math.abs(a) < 1e-12) {
711
+ if (Math.abs(b) >= 1e-12) {
712
+ this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
713
+ }
714
+ return;
715
+ }
716
+ const delta = b ** 2 - 4 * c * a;
717
+ if (delta < 0) {
718
+ return;
719
+ }
720
+ const sqrtDelta = Math.sqrt(delta);
721
+ const a2 = 2 * a;
722
+ this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
723
+ this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
724
+ }
725
+
726
+ // From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852
727
+ static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
728
+ if (minMax) {
729
+ minMax[0] = Math.min(minMax[0], x0, x3);
730
+ minMax[1] = Math.min(minMax[1], y0, y3);
731
+ minMax[2] = Math.max(minMax[2], x0, x3);
732
+ minMax[3] = Math.max(minMax[3], y0, y3);
733
+ } else {
734
+ minMax = [Math.min(x0, x3), Math.min(y0, y3), Math.max(x0, x3), Math.max(y0, y3)];
735
+ }
736
+ this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
737
+ this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
738
+ return minMax;
739
+ }
740
+ }
741
+ const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
742
+ function stringToPDFString(str) {
743
+ // See section 7.9.2.2 Text String Type.
744
+ // The string can contain some language codes bracketed with 0x0b,
745
+ // so we must remove them.
746
+ if (str[0] >= "\xEF") {
747
+ let encoding;
748
+ if (str[0] === "\xFE" && str[1] === "\xFF") {
749
+ encoding = "utf-16be";
750
+ if (str.length % 2 === 1) {
751
+ str = str.slice(0, -1);
752
+ }
753
+ } else if (str[0] === "\xFF" && str[1] === "\xFE") {
754
+ encoding = "utf-16le";
755
+ if (str.length % 2 === 1) {
756
+ str = str.slice(0, -1);
757
+ }
758
+ } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
759
+ encoding = "utf-8";
760
+ }
761
+ if (encoding) {
762
+ try {
763
+ const decoder = new TextDecoder(encoding, {
764
+ fatal: true
765
+ });
766
+ const buffer = stringToBytes(str);
767
+ const decoded = decoder.decode(buffer);
768
+ if (!decoded.includes("\x1b")) {
769
+ return decoded;
770
+ }
771
+ return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
772
+ } catch (ex) {
773
+ warn(`stringToPDFString: "${ex}".`);
774
+ }
775
+ }
776
+ }
777
+ // ISO Latin 1
778
+ const strBuf = [];
779
+ for (let i = 0, ii = str.length; i < ii; i++) {
780
+ const charCode = str.charCodeAt(i);
781
+ if (charCode === 0x1b) {
782
+ // eslint-disable-next-line no-empty
783
+ while (++i < ii && str.charCodeAt(i) !== 0x1b) {}
784
+ continue;
785
+ }
786
+ const code = PDFStringTranslateTable[charCode];
787
+ strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
788
+ }
789
+ return strBuf.join("");
790
+ }
791
+ function stringToUTF8String(str) {
792
+ return decodeURIComponent(escape(str));
793
+ }
794
+ function utf8StringToString(str) {
795
+ return unescape(encodeURIComponent(str));
796
+ }
797
+ function isArrayEqual(arr1, arr2) {
798
+ if (arr1.length !== arr2.length) {
799
+ return false;
800
+ }
801
+ for (let i = 0, ii = arr1.length; i < ii; i++) {
802
+ if (arr1[i] !== arr2[i]) {
803
+ return false;
804
+ }
805
+ }
806
+ return true;
807
+ }
808
+ function getModificationDate(date = new Date()) {
809
+ const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
810
+ return buffer.join("");
811
+ }
812
+ let NormalizeRegex = null;
813
+ let NormalizationMap = null;
814
+ function normalizeUnicode(str) {
815
+ if (!NormalizeRegex) {
816
+ // In order to generate the following regex:
817
+ // - create a PDF containing all the chars in the range 0000-FFFF with
818
+ // a NFKC which is different of the char.
819
+ // - copy and paste all those chars and get the ones where NFKC is
820
+ // required.
821
+ // It appears that most the chars here contain some ligatures.
822
+ NormalizeRegex = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;
823
+ NormalizationMap = new Map([["ſt", "ſt"]]);
824
+ }
825
+ return str.replaceAll(NormalizeRegex, (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2));
826
+ }
827
+ function getUuid() {
828
+ var _crypto, _crypto2;
829
+ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL") || typeof crypto !== "undefined" && typeof ((_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.randomUUID) === "function") {
830
+ return crypto.randomUUID();
831
+ }
832
+ const buf = new Uint8Array(32);
833
+ if (typeof crypto !== "undefined" && typeof ((_crypto2 = crypto) === null || _crypto2 === void 0 ? void 0 : _crypto2.getRandomValues) === "function") {
834
+ crypto.getRandomValues(buf);
835
+ } else {
836
+ for (let i = 0; i < 32; i++) {
837
+ buf[i] = Math.floor(Math.random() * 255);
838
+ }
839
+ }
840
+ return bytesToString(buf);
841
+ }
842
+ const AnnotationPrefix = "pdfjs_internal_id_";
843
+ const FontRenderOps = {
844
+ BEZIER_CURVE_TO: 0,
845
+ MOVE_TO: 1,
846
+ LINE_TO: 2,
847
+ QUADRATIC_CURVE_TO: 3,
848
+ RESTORE: 4,
849
+ SAVE: 5,
850
+ SCALE: 6,
851
+ TRANSFORM: 7,
852
+ TRANSLATE: 8
853
+ };
854
+
855
+ export { getModificationDate as $, AnnotationMode as A, MAX_IMAGE_SIZE_TO_CACHE as B, AnnotationBorderStyleType as C, AnnotationPrefix as D, AnnotationType as E, FeatureTest as F, CMapCompressionType as G, createValidAbsoluteUrl as H, IDENTITY_MATRIX as I, PasswordResponses as J, BaseException as K, LINE_FACTOR as L, MissingPDFException as M, objectSize as N, OPS as O, PermissionFlag as P, stringToPDFString as Q, RenderingIntentFlag as R, isArrayEqual as S, TextRenderingMode as T, Util as U, VerbosityLevel as V, LINE_DESCENT_FACTOR as W, utf8StringToString as X, stringToUTF8String as Y, DocumentActionEventType as Z, AnnotationFlag as _, AbortException as a, AnnotationReplyType as a0, AnnotationFieldFlag as a1, BASELINE_FACTOR as a2, AnnotationActionEventType as a3, PageActionEventType as a4, AnnotationEditorType as b, AnnotationEditorParamsType as c, AnnotationEditorPrefix as d, assert as e, string32 as f, getUuid as g, bytesToString as h, isNodeJS as i, FontRenderOps as j, FormatError as k, info as l, FONT_IDENTITY_MATRIX as m, normalizeUnicode as n, objectFromMap as o, ImageKind as p, stringToBytes as q, setVerbosityLevel as r, shadow as s, getVerbosityLevel as t, unreachable as u, UnknownErrorException as v, warn as w, UnexpectedResponseException as x, InvalidPDFException as y, PasswordException as z };