@chialab/pdfjs-lib 1.0.0-alpha.35 → 1.0.0-alpha.37

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,21 +1,10 @@
1
- import {
2
- AbortException,
3
- FeatureTest,
4
- ImageKind,
5
- InvalidPDFException,
6
- PasswordException,
7
- ResponseException,
8
- UnknownErrorException,
9
- assert,
10
- unreachable
11
- } from "./chunk-T2JWSGAF.js";
12
1
  import {
13
2
  __privateAdd,
14
3
  __privateGet,
15
4
  __privateMethod,
16
5
  __privateSet,
17
6
  __publicField
18
- } from "./chunk-ZFIGV5OT.js";
7
+ } from "./chunk-7YYVRRNF.js";
19
8
 
20
9
  // src/lib/polyfills.ts
21
10
  if (!Array.prototype.at) {
@@ -58,6 +47,1163 @@ if (!("try" in Promise)) {
58
47
  });
59
48
  }
60
49
 
50
+ // src/pdf.js/src/shared/util.js
51
+ var isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
52
+ var FONT_IDENTITY_MATRIX = [1e-3, 0, 0, 1e-3, 0, 0];
53
+ var LINE_FACTOR = 1.35;
54
+ var LINE_DESCENT_FACTOR = 0.35;
55
+ var BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
56
+ var RenderingIntentFlag = {
57
+ ANY: 1,
58
+ DISPLAY: 2,
59
+ PRINT: 4,
60
+ SAVE: 8,
61
+ ANNOTATIONS_FORMS: 16,
62
+ ANNOTATIONS_STORAGE: 32,
63
+ ANNOTATIONS_DISABLE: 64,
64
+ IS_EDITING: 128,
65
+ OPLIST: 256
66
+ };
67
+ var AnnotationMode = {
68
+ DISABLE: 0,
69
+ ENABLE: 1,
70
+ ENABLE_FORMS: 2,
71
+ ENABLE_STORAGE: 3
72
+ };
73
+ var AnnotationEditorPrefix = "pdfjs_internal_editor_";
74
+ var AnnotationEditorType = {
75
+ DISABLE: -1,
76
+ NONE: 0,
77
+ FREETEXT: 3,
78
+ HIGHLIGHT: 9,
79
+ STAMP: 13,
80
+ INK: 15,
81
+ POPUP: 16,
82
+ SIGNATURE: 101,
83
+ COMMENT: 102
84
+ };
85
+ var AnnotationEditorParamsType = {
86
+ RESIZE: 1,
87
+ CREATE: 2,
88
+ FREETEXT_SIZE: 11,
89
+ FREETEXT_COLOR: 12,
90
+ FREETEXT_OPACITY: 13,
91
+ INK_COLOR: 21,
92
+ INK_THICKNESS: 22,
93
+ INK_OPACITY: 23,
94
+ HIGHLIGHT_COLOR: 31,
95
+ HIGHLIGHT_THICKNESS: 32,
96
+ HIGHLIGHT_FREE: 33,
97
+ HIGHLIGHT_SHOW_ALL: 34,
98
+ DRAW_STEP: 41
99
+ };
100
+ var PermissionFlag = {
101
+ PRINT: 4,
102
+ MODIFY_CONTENTS: 8,
103
+ COPY: 16,
104
+ MODIFY_ANNOTATIONS: 32,
105
+ FILL_INTERACTIVE_FORMS: 256,
106
+ COPY_FOR_ACCESSIBILITY: 512,
107
+ ASSEMBLE: 1024,
108
+ PRINT_HIGH_QUALITY: 2048
109
+ };
110
+ var TextRenderingMode = {
111
+ FILL: 0,
112
+ STROKE: 1,
113
+ FILL_STROKE: 2,
114
+ INVISIBLE: 3,
115
+ FILL_ADD_TO_PATH: 4,
116
+ STROKE_ADD_TO_PATH: 5,
117
+ FILL_STROKE_ADD_TO_PATH: 6,
118
+ ADD_TO_PATH: 7,
119
+ FILL_STROKE_MASK: 3,
120
+ ADD_TO_PATH_FLAG: 4
121
+ };
122
+ var ImageKind = {
123
+ GRAYSCALE_1BPP: 1,
124
+ RGB_24BPP: 2,
125
+ RGBA_32BPP: 3
126
+ };
127
+ var AnnotationType = {
128
+ TEXT: 1,
129
+ LINK: 2,
130
+ FREETEXT: 3,
131
+ LINE: 4,
132
+ SQUARE: 5,
133
+ CIRCLE: 6,
134
+ POLYGON: 7,
135
+ POLYLINE: 8,
136
+ HIGHLIGHT: 9,
137
+ UNDERLINE: 10,
138
+ SQUIGGLY: 11,
139
+ STRIKEOUT: 12,
140
+ STAMP: 13,
141
+ CARET: 14,
142
+ INK: 15,
143
+ POPUP: 16,
144
+ FILEATTACHMENT: 17,
145
+ SOUND: 18,
146
+ MOVIE: 19,
147
+ WIDGET: 20,
148
+ SCREEN: 21,
149
+ PRINTERMARK: 22,
150
+ TRAPNET: 23,
151
+ WATERMARK: 24,
152
+ THREED: 25,
153
+ REDACT: 26
154
+ };
155
+ var AnnotationReplyType = {
156
+ GROUP: "Group",
157
+ REPLY: "R"
158
+ };
159
+ var AnnotationFlag = {
160
+ INVISIBLE: 1,
161
+ HIDDEN: 2,
162
+ PRINT: 4,
163
+ NOZOOM: 8,
164
+ NOROTATE: 16,
165
+ NOVIEW: 32,
166
+ READONLY: 64,
167
+ LOCKED: 128,
168
+ TOGGLENOVIEW: 256,
169
+ LOCKEDCONTENTS: 512
170
+ };
171
+ var AnnotationFieldFlag = {
172
+ READONLY: 1,
173
+ REQUIRED: 2,
174
+ NOEXPORT: 4,
175
+ MULTILINE: 4096,
176
+ PASSWORD: 8192,
177
+ NOTOGGLETOOFF: 16384,
178
+ RADIO: 32768,
179
+ PUSHBUTTON: 65536,
180
+ COMBO: 131072,
181
+ EDIT: 262144,
182
+ SORT: 524288,
183
+ FILESELECT: 1048576,
184
+ MULTISELECT: 2097152,
185
+ DONOTSPELLCHECK: 4194304,
186
+ DONOTSCROLL: 8388608,
187
+ COMB: 16777216,
188
+ RICHTEXT: 33554432,
189
+ RADIOSINUNISON: 33554432,
190
+ COMMITONSELCHANGE: 67108864
191
+ };
192
+ var AnnotationBorderStyleType = {
193
+ SOLID: 1,
194
+ DASHED: 2,
195
+ BEVELED: 3,
196
+ INSET: 4,
197
+ UNDERLINE: 5
198
+ };
199
+ var AnnotationActionEventType = {
200
+ E: "Mouse Enter",
201
+ X: "Mouse Exit",
202
+ D: "Mouse Down",
203
+ U: "Mouse Up",
204
+ Fo: "Focus",
205
+ Bl: "Blur",
206
+ PO: "PageOpen",
207
+ PC: "PageClose",
208
+ PV: "PageVisible",
209
+ PI: "PageInvisible",
210
+ K: "Keystroke",
211
+ F: "Format",
212
+ V: "Validate",
213
+ C: "Calculate"
214
+ };
215
+ var DocumentActionEventType = {
216
+ WC: "WillClose",
217
+ WS: "WillSave",
218
+ DS: "DidSave",
219
+ WP: "WillPrint",
220
+ DP: "DidPrint"
221
+ };
222
+ var PageActionEventType = {
223
+ O: "PageOpen",
224
+ C: "PageClose"
225
+ };
226
+ var VerbosityLevel = {
227
+ ERRORS: 0,
228
+ WARNINGS: 1,
229
+ INFOS: 5
230
+ };
231
+ var OPS = {
232
+ // Intentionally start from 1 so it is easy to spot bad operators that will be
233
+ // 0's.
234
+ // PLEASE NOTE: We purposely keep any removed operators commented out, since
235
+ // re-numbering the list would risk breaking third-party users.
236
+ dependency: 1,
237
+ setLineWidth: 2,
238
+ setLineCap: 3,
239
+ setLineJoin: 4,
240
+ setMiterLimit: 5,
241
+ setDash: 6,
242
+ setRenderingIntent: 7,
243
+ setFlatness: 8,
244
+ setGState: 9,
245
+ save: 10,
246
+ restore: 11,
247
+ transform: 12,
248
+ moveTo: 13,
249
+ lineTo: 14,
250
+ curveTo: 15,
251
+ curveTo2: 16,
252
+ curveTo3: 17,
253
+ closePath: 18,
254
+ rectangle: 19,
255
+ stroke: 20,
256
+ closeStroke: 21,
257
+ fill: 22,
258
+ eoFill: 23,
259
+ fillStroke: 24,
260
+ eoFillStroke: 25,
261
+ closeFillStroke: 26,
262
+ closeEOFillStroke: 27,
263
+ endPath: 28,
264
+ clip: 29,
265
+ eoClip: 30,
266
+ beginText: 31,
267
+ endText: 32,
268
+ setCharSpacing: 33,
269
+ setWordSpacing: 34,
270
+ setHScale: 35,
271
+ setLeading: 36,
272
+ setFont: 37,
273
+ setTextRenderingMode: 38,
274
+ setTextRise: 39,
275
+ moveText: 40,
276
+ setLeadingMoveText: 41,
277
+ setTextMatrix: 42,
278
+ nextLine: 43,
279
+ showText: 44,
280
+ showSpacedText: 45,
281
+ nextLineShowText: 46,
282
+ nextLineSetSpacingShowText: 47,
283
+ setCharWidth: 48,
284
+ setCharWidthAndBounds: 49,
285
+ setStrokeColorSpace: 50,
286
+ setFillColorSpace: 51,
287
+ setStrokeColor: 52,
288
+ setStrokeColorN: 53,
289
+ setFillColor: 54,
290
+ setFillColorN: 55,
291
+ setStrokeGray: 56,
292
+ setFillGray: 57,
293
+ setStrokeRGBColor: 58,
294
+ setFillRGBColor: 59,
295
+ setStrokeCMYKColor: 60,
296
+ setFillCMYKColor: 61,
297
+ shadingFill: 62,
298
+ beginInlineImage: 63,
299
+ beginImageData: 64,
300
+ endInlineImage: 65,
301
+ paintXObject: 66,
302
+ markPoint: 67,
303
+ markPointProps: 68,
304
+ beginMarkedContent: 69,
305
+ beginMarkedContentProps: 70,
306
+ endMarkedContent: 71,
307
+ beginCompat: 72,
308
+ endCompat: 73,
309
+ paintFormXObjectBegin: 74,
310
+ paintFormXObjectEnd: 75,
311
+ beginGroup: 76,
312
+ endGroup: 77,
313
+ // beginAnnotations: 78,
314
+ // endAnnotations: 79,
315
+ beginAnnotation: 80,
316
+ endAnnotation: 81,
317
+ // paintJpegXObject: 82,
318
+ paintImageMaskXObject: 83,
319
+ paintImageMaskXObjectGroup: 84,
320
+ paintImageXObject: 85,
321
+ paintInlineImageXObject: 86,
322
+ paintInlineImageXObjectGroup: 87,
323
+ paintImageXObjectRepeat: 88,
324
+ paintImageMaskXObjectRepeat: 89,
325
+ paintSolidColorImageMask: 90,
326
+ constructPath: 91,
327
+ setStrokeTransparent: 92,
328
+ setFillTransparent: 93,
329
+ rawFillPath: 94
330
+ };
331
+ var DrawOPS = {
332
+ moveTo: 0,
333
+ lineTo: 1,
334
+ curveTo: 2,
335
+ closePath: 3
336
+ };
337
+ var PasswordResponses = {
338
+ NEED_PASSWORD: 1,
339
+ INCORRECT_PASSWORD: 2
340
+ };
341
+ var verbosity = VerbosityLevel.WARNINGS;
342
+ function setVerbosityLevel(level) {
343
+ if (Number.isInteger(level)) {
344
+ verbosity = level;
345
+ }
346
+ }
347
+ function getVerbosityLevel() {
348
+ return verbosity;
349
+ }
350
+ function info(msg) {
351
+ if (verbosity >= VerbosityLevel.INFOS) {
352
+ console.info(`Info: ${msg}`);
353
+ }
354
+ }
355
+ function warn(msg) {
356
+ if (verbosity >= VerbosityLevel.WARNINGS) {
357
+ console.warn(`Warning: ${msg}`);
358
+ }
359
+ }
360
+ function unreachable(msg) {
361
+ throw new Error(msg);
362
+ }
363
+ function assert(cond, msg) {
364
+ if (!cond) {
365
+ unreachable(msg);
366
+ }
367
+ }
368
+ function _isValidProtocol(url) {
369
+ switch (url?.protocol) {
370
+ case "http:":
371
+ case "https:":
372
+ case "ftp:":
373
+ case "mailto:":
374
+ case "tel:":
375
+ return true;
376
+ default:
377
+ return false;
378
+ }
379
+ }
380
+ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
381
+ if (!url) {
382
+ return null;
383
+ }
384
+ if (options && typeof url === "string") {
385
+ if (options.addDefaultProtocol && url.startsWith("www.")) {
386
+ const dots = url.match(/\./g);
387
+ if (dots?.length >= 2) {
388
+ url = `http://${url}`;
389
+ }
390
+ }
391
+ if (options.tryConvertEncoding) {
392
+ try {
393
+ url = stringToUTF8String(url);
394
+ } catch {
395
+ }
396
+ }
397
+ }
398
+ const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
399
+ return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;
400
+ }
401
+ function updateUrlHash(url, hash, allowRel = false) {
402
+ const res = URL.parse(url);
403
+ if (res) {
404
+ res.hash = hash;
405
+ return res.href;
406
+ }
407
+ if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
408
+ return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
409
+ }
410
+ return "";
411
+ }
412
+ function shadow(obj, prop, value, nonSerializable = false) {
413
+ if (false) {
414
+ assert(
415
+ prop in obj,
416
+ `shadow: Property "${prop && prop.toString()}" not found in object.`
417
+ );
418
+ }
419
+ Object.defineProperty(obj, prop, {
420
+ value,
421
+ enumerable: !nonSerializable,
422
+ configurable: true,
423
+ writable: false
424
+ });
425
+ return value;
426
+ }
427
+ var BaseException = (function BaseExceptionClosure() {
428
+ function BaseException2(message, name) {
429
+ if (false) {
430
+ unreachable("Cannot initialize BaseException.");
431
+ }
432
+ this.message = message;
433
+ this.name = name;
434
+ }
435
+ BaseException2.prototype = new Error();
436
+ BaseException2.constructor = BaseException2;
437
+ return BaseException2;
438
+ })();
439
+ var PasswordException = class extends BaseException {
440
+ constructor(msg, code) {
441
+ super(msg, "PasswordException");
442
+ this.code = code;
443
+ }
444
+ };
445
+ var UnknownErrorException = class extends BaseException {
446
+ constructor(msg, details) {
447
+ super(msg, "UnknownErrorException");
448
+ this.details = details;
449
+ }
450
+ };
451
+ var InvalidPDFException = class extends BaseException {
452
+ constructor(msg) {
453
+ super(msg, "InvalidPDFException");
454
+ }
455
+ };
456
+ var ResponseException = class extends BaseException {
457
+ constructor(msg, status, missing) {
458
+ super(msg, "ResponseException");
459
+ this.status = status;
460
+ this.missing = missing;
461
+ }
462
+ };
463
+ var FormatError = class extends BaseException {
464
+ constructor(msg) {
465
+ super(msg, "FormatError");
466
+ }
467
+ };
468
+ var AbortException = class extends BaseException {
469
+ constructor(msg) {
470
+ super(msg, "AbortException");
471
+ }
472
+ };
473
+ function bytesToString(bytes) {
474
+ if (typeof bytes !== "object" || bytes?.length === void 0) {
475
+ unreachable("Invalid argument for bytesToString");
476
+ }
477
+ const length = bytes.length;
478
+ const MAX_ARGUMENT_COUNT = 8192;
479
+ if (length < MAX_ARGUMENT_COUNT) {
480
+ return String.fromCharCode.apply(null, bytes);
481
+ }
482
+ const strBuf = [];
483
+ for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
484
+ const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
485
+ const chunk = bytes.subarray(i, chunkEnd);
486
+ strBuf.push(String.fromCharCode.apply(null, chunk));
487
+ }
488
+ return strBuf.join("");
489
+ }
490
+ function stringToBytes(str) {
491
+ if (typeof str !== "string") {
492
+ unreachable("Invalid argument for stringToBytes");
493
+ }
494
+ const length = str.length;
495
+ const bytes = new Uint8Array(length);
496
+ for (let i = 0; i < length; ++i) {
497
+ bytes[i] = str.charCodeAt(i) & 255;
498
+ }
499
+ return bytes;
500
+ }
501
+ function string32(value) {
502
+ if (false) {
503
+ assert(
504
+ typeof value === "number" && Math.abs(value) < 2 ** 32,
505
+ `string32: Unexpected input "${value}".`
506
+ );
507
+ }
508
+ return String.fromCharCode(
509
+ value >> 24 & 255,
510
+ value >> 16 & 255,
511
+ value >> 8 & 255,
512
+ value & 255
513
+ );
514
+ }
515
+ function objectSize(obj) {
516
+ return Object.keys(obj).length;
517
+ }
518
+ function isLittleEndian() {
519
+ const buffer8 = new Uint8Array(4);
520
+ buffer8[0] = 1;
521
+ const view32 = new Uint32Array(buffer8.buffer, 0, 1);
522
+ return view32[0] === 1;
523
+ }
524
+ function isEvalSupported() {
525
+ try {
526
+ new Function("");
527
+ return true;
528
+ } catch {
529
+ return false;
530
+ }
531
+ }
532
+ var FeatureTest = class {
533
+ static get isLittleEndian() {
534
+ return shadow(this, "isLittleEndian", isLittleEndian());
535
+ }
536
+ static get isEvalSupported() {
537
+ return shadow(this, "isEvalSupported", isEvalSupported());
538
+ }
539
+ static get isOffscreenCanvasSupported() {
540
+ return shadow(
541
+ this,
542
+ "isOffscreenCanvasSupported",
543
+ typeof OffscreenCanvas !== "undefined"
544
+ );
545
+ }
546
+ static get isImageDecoderSupported() {
547
+ return shadow(
548
+ this,
549
+ "isImageDecoderSupported",
550
+ typeof ImageDecoder !== "undefined"
551
+ );
552
+ }
553
+ static get platform() {
554
+ const { platform, userAgent } = navigator;
555
+ return shadow(this, "platform", {
556
+ isAndroid: userAgent.includes("Android"),
557
+ isLinux: platform.includes("Linux"),
558
+ isMac: platform.includes("Mac"),
559
+ isWindows: platform.includes("Win"),
560
+ isFirefox: userAgent.includes("Firefox")
561
+ });
562
+ }
563
+ static get isCSSRoundSupported() {
564
+ return shadow(
565
+ this,
566
+ "isCSSRoundSupported",
567
+ globalThis.CSS?.supports?.("width: round(1.5px, 1px)")
568
+ );
569
+ }
570
+ };
571
+ var hexNumbers = Array.from(
572
+ Array(256).keys(),
573
+ (n) => n.toString(16).padStart(2, "0")
574
+ );
575
+ var _Util_static, getExtremumOnCurve_fn, getExtremum_fn;
576
+ var Util = class {
577
+ static makeHexColor(r, g, b) {
578
+ return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
579
+ }
580
+ static domMatrixToTransform(dm) {
581
+ return [dm.a, dm.b, dm.c, dm.d, dm.e, dm.f];
582
+ }
583
+ // Apply a scaling matrix to some min/max values.
584
+ // If a scaling factor is negative then min and max must be
585
+ // swapped.
586
+ static scaleMinMax(transform, minMax) {
587
+ let temp;
588
+ if (transform[0]) {
589
+ if (transform[0] < 0) {
590
+ temp = minMax[0];
591
+ minMax[0] = minMax[2];
592
+ minMax[2] = temp;
593
+ }
594
+ minMax[0] *= transform[0];
595
+ minMax[2] *= transform[0];
596
+ if (transform[3] < 0) {
597
+ temp = minMax[1];
598
+ minMax[1] = minMax[3];
599
+ minMax[3] = temp;
600
+ }
601
+ minMax[1] *= transform[3];
602
+ minMax[3] *= transform[3];
603
+ } else {
604
+ temp = minMax[0];
605
+ minMax[0] = minMax[1];
606
+ minMax[1] = temp;
607
+ temp = minMax[2];
608
+ minMax[2] = minMax[3];
609
+ minMax[3] = temp;
610
+ if (transform[1] < 0) {
611
+ temp = minMax[1];
612
+ minMax[1] = minMax[3];
613
+ minMax[3] = temp;
614
+ }
615
+ minMax[1] *= transform[1];
616
+ minMax[3] *= transform[1];
617
+ if (transform[2] < 0) {
618
+ temp = minMax[0];
619
+ minMax[0] = minMax[2];
620
+ minMax[2] = temp;
621
+ }
622
+ minMax[0] *= transform[2];
623
+ minMax[2] *= transform[2];
624
+ }
625
+ minMax[0] += transform[4];
626
+ minMax[1] += transform[5];
627
+ minMax[2] += transform[4];
628
+ minMax[3] += transform[5];
629
+ }
630
+ // Concatenates two transformation matrices together and returns the result.
631
+ static transform(m1, m2) {
632
+ return [
633
+ m1[0] * m2[0] + m1[2] * m2[1],
634
+ m1[1] * m2[0] + m1[3] * m2[1],
635
+ m1[0] * m2[2] + m1[2] * m2[3],
636
+ m1[1] * m2[2] + m1[3] * m2[3],
637
+ m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
638
+ m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
639
+ ];
640
+ }
641
+ // Multiplies m (an array-based transform) by md (a DOMMatrix transform).
642
+ static multiplyByDOMMatrix(m, md) {
643
+ return [
644
+ m[0] * md.a + m[2] * md.b,
645
+ m[1] * md.a + m[3] * md.b,
646
+ m[0] * md.c + m[2] * md.d,
647
+ m[1] * md.c + m[3] * md.d,
648
+ m[0] * md.e + m[2] * md.f + m[4],
649
+ m[1] * md.e + m[3] * md.f + m[5]
650
+ ];
651
+ }
652
+ // For 2d affine transforms
653
+ static applyTransform(p, m, pos = 0) {
654
+ const p0 = p[pos];
655
+ const p1 = p[pos + 1];
656
+ p[pos] = p0 * m[0] + p1 * m[2] + m[4];
657
+ p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];
658
+ }
659
+ static applyTransformToBezier(p, transform, pos = 0) {
660
+ const m0 = transform[0];
661
+ const m1 = transform[1];
662
+ const m2 = transform[2];
663
+ const m3 = transform[3];
664
+ const m4 = transform[4];
665
+ const m5 = transform[5];
666
+ for (let i = 0; i < 6; i += 2) {
667
+ const pI = p[pos + i];
668
+ const pI1 = p[pos + i + 1];
669
+ p[pos + i] = pI * m0 + pI1 * m2 + m4;
670
+ p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;
671
+ }
672
+ }
673
+ static applyInverseTransform(p, m) {
674
+ const p0 = p[0];
675
+ const p1 = p[1];
676
+ const d = m[0] * m[3] - m[1] * m[2];
677
+ p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
678
+ p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
679
+ }
680
+ // Applies the transform to the rectangle and finds the minimum axially
681
+ // aligned bounding box.
682
+ static axialAlignedBoundingBox(rect, transform, output) {
683
+ const m0 = transform[0];
684
+ const m1 = transform[1];
685
+ const m2 = transform[2];
686
+ const m3 = transform[3];
687
+ const m4 = transform[4];
688
+ const m5 = transform[5];
689
+ const r0 = rect[0];
690
+ const r1 = rect[1];
691
+ const r2 = rect[2];
692
+ const r3 = rect[3];
693
+ let a0 = m0 * r0 + m4;
694
+ let a2 = a0;
695
+ let a1 = m0 * r2 + m4;
696
+ let a3 = a1;
697
+ let b0 = m3 * r1 + m5;
698
+ let b2 = b0;
699
+ let b1 = m3 * r3 + m5;
700
+ let b3 = b1;
701
+ if (m1 !== 0 || m2 !== 0) {
702
+ const m1r0 = m1 * r0;
703
+ const m1r2 = m1 * r2;
704
+ const m2r1 = m2 * r1;
705
+ const m2r3 = m2 * r3;
706
+ a0 += m2r1;
707
+ a3 += m2r1;
708
+ a1 += m2r3;
709
+ a2 += m2r3;
710
+ b0 += m1r0;
711
+ b3 += m1r0;
712
+ b1 += m1r2;
713
+ b2 += m1r2;
714
+ }
715
+ output[0] = Math.min(output[0], a0, a1, a2, a3);
716
+ output[1] = Math.min(output[1], b0, b1, b2, b3);
717
+ output[2] = Math.max(output[2], a0, a1, a2, a3);
718
+ output[3] = Math.max(output[3], b0, b1, b2, b3);
719
+ }
720
+ static inverseTransform(m) {
721
+ const d = m[0] * m[3] - m[1] * m[2];
722
+ return [
723
+ m[3] / d,
724
+ -m[1] / d,
725
+ -m[2] / d,
726
+ m[0] / d,
727
+ (m[2] * m[5] - m[4] * m[3]) / d,
728
+ (m[4] * m[1] - m[5] * m[0]) / d
729
+ ];
730
+ }
731
+ // This calculation uses Singular Value Decomposition.
732
+ // The SVD can be represented with formula A = USV. We are interested in the
733
+ // matrix S here because it represents the scale values.
734
+ static singularValueDecompose2dScale(matrix, output) {
735
+ const m0 = matrix[0];
736
+ const m1 = matrix[1];
737
+ const m2 = matrix[2];
738
+ const m3 = matrix[3];
739
+ const a = m0 ** 2 + m1 ** 2;
740
+ const b = m0 * m2 + m1 * m3;
741
+ const c = m2 ** 2 + m3 ** 2;
742
+ const first = (a + c) / 2;
743
+ const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
744
+ output[0] = Math.sqrt(first + second || 1);
745
+ output[1] = Math.sqrt(first - second || 1);
746
+ }
747
+ // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
748
+ // For coordinate systems whose origin lies in the bottom-left, this
749
+ // means normalization to (BL,TR) ordering. For systems with origin in the
750
+ // top-left, this means (TL,BR) ordering.
751
+ static normalizeRect(rect) {
752
+ const r = rect.slice(0);
753
+ if (rect[0] > rect[2]) {
754
+ r[0] = rect[2];
755
+ r[2] = rect[0];
756
+ }
757
+ if (rect[1] > rect[3]) {
758
+ r[1] = rect[3];
759
+ r[3] = rect[1];
760
+ }
761
+ return r;
762
+ }
763
+ // Returns a rectangle [x1, y1, x2, y2] corresponding to the
764
+ // intersection of rect1 and rect2. If no intersection, returns 'null'
765
+ // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
766
+ static intersect(rect1, rect2) {
767
+ const xLow = Math.max(
768
+ Math.min(rect1[0], rect1[2]),
769
+ Math.min(rect2[0], rect2[2])
770
+ );
771
+ const xHigh = Math.min(
772
+ Math.max(rect1[0], rect1[2]),
773
+ Math.max(rect2[0], rect2[2])
774
+ );
775
+ if (xLow > xHigh) {
776
+ return null;
777
+ }
778
+ const yLow = Math.max(
779
+ Math.min(rect1[1], rect1[3]),
780
+ Math.min(rect2[1], rect2[3])
781
+ );
782
+ const yHigh = Math.min(
783
+ Math.max(rect1[1], rect1[3]),
784
+ Math.max(rect2[1], rect2[3])
785
+ );
786
+ if (yLow > yHigh) {
787
+ return null;
788
+ }
789
+ return [xLow, yLow, xHigh, yHigh];
790
+ }
791
+ static pointBoundingBox(x, y, minMax) {
792
+ minMax[0] = Math.min(minMax[0], x);
793
+ minMax[1] = Math.min(minMax[1], y);
794
+ minMax[2] = Math.max(minMax[2], x);
795
+ minMax[3] = Math.max(minMax[3], y);
796
+ }
797
+ static rectBoundingBox(x0, y0, x1, y1, minMax) {
798
+ minMax[0] = Math.min(minMax[0], x0, x1);
799
+ minMax[1] = Math.min(minMax[1], y0, y1);
800
+ minMax[2] = Math.max(minMax[2], x0, x1);
801
+ minMax[3] = Math.max(minMax[3], y0, y1);
802
+ }
803
+ // From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852
804
+ static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
805
+ minMax[0] = Math.min(minMax[0], x0, x3);
806
+ minMax[1] = Math.min(minMax[1], y0, y3);
807
+ minMax[2] = Math.max(minMax[2], x0, x3);
808
+ minMax[3] = Math.max(minMax[3], y0, y3);
809
+ __privateMethod(this, _Util_static, getExtremum_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
810
+ __privateMethod(this, _Util_static, getExtremum_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
811
+ }
812
+ };
813
+ _Util_static = new WeakSet();
814
+ getExtremumOnCurve_fn = function(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
815
+ if (t <= 0 || t >= 1) {
816
+ return;
817
+ }
818
+ const mt = 1 - t;
819
+ const tt = t * t;
820
+ const ttt = tt * t;
821
+ const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
822
+ const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
823
+ minMax[0] = Math.min(minMax[0], x);
824
+ minMax[1] = Math.min(minMax[1], y);
825
+ minMax[2] = Math.max(minMax[2], x);
826
+ minMax[3] = Math.max(minMax[3], y);
827
+ };
828
+ getExtremum_fn = function(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
829
+ if (Math.abs(a) < 1e-12) {
830
+ if (Math.abs(b) >= 1e-12) {
831
+ __privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
832
+ }
833
+ return;
834
+ }
835
+ const delta = b ** 2 - 4 * c * a;
836
+ if (delta < 0) {
837
+ return;
838
+ }
839
+ const sqrtDelta = Math.sqrt(delta);
840
+ const a2 = 2 * a;
841
+ __privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
842
+ __privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
843
+ };
844
+ __privateAdd(Util, _Util_static);
845
+ var PDFStringTranslateTable = [
846
+ 0,
847
+ 0,
848
+ 0,
849
+ 0,
850
+ 0,
851
+ 0,
852
+ 0,
853
+ 0,
854
+ 0,
855
+ 0,
856
+ 0,
857
+ 0,
858
+ 0,
859
+ 0,
860
+ 0,
861
+ 0,
862
+ 0,
863
+ 0,
864
+ 0,
865
+ 0,
866
+ 0,
867
+ 0,
868
+ 0,
869
+ 0,
870
+ 728,
871
+ 711,
872
+ 710,
873
+ 729,
874
+ 733,
875
+ 731,
876
+ 730,
877
+ 732,
878
+ 0,
879
+ 0,
880
+ 0,
881
+ 0,
882
+ 0,
883
+ 0,
884
+ 0,
885
+ 0,
886
+ 0,
887
+ 0,
888
+ 0,
889
+ 0,
890
+ 0,
891
+ 0,
892
+ 0,
893
+ 0,
894
+ 0,
895
+ 0,
896
+ 0,
897
+ 0,
898
+ 0,
899
+ 0,
900
+ 0,
901
+ 0,
902
+ 0,
903
+ 0,
904
+ 0,
905
+ 0,
906
+ 0,
907
+ 0,
908
+ 0,
909
+ 0,
910
+ 0,
911
+ 0,
912
+ 0,
913
+ 0,
914
+ 0,
915
+ 0,
916
+ 0,
917
+ 0,
918
+ 0,
919
+ 0,
920
+ 0,
921
+ 0,
922
+ 0,
923
+ 0,
924
+ 0,
925
+ 0,
926
+ 0,
927
+ 0,
928
+ 0,
929
+ 0,
930
+ 0,
931
+ 0,
932
+ 0,
933
+ 0,
934
+ 0,
935
+ 0,
936
+ 0,
937
+ 0,
938
+ 0,
939
+ 0,
940
+ 0,
941
+ 0,
942
+ 0,
943
+ 0,
944
+ 0,
945
+ 0,
946
+ 0,
947
+ 0,
948
+ 0,
949
+ 0,
950
+ 0,
951
+ 0,
952
+ 0,
953
+ 0,
954
+ 0,
955
+ 0,
956
+ 0,
957
+ 0,
958
+ 0,
959
+ 0,
960
+ 0,
961
+ 0,
962
+ 0,
963
+ 0,
964
+ 0,
965
+ 0,
966
+ 0,
967
+ 0,
968
+ 0,
969
+ 0,
970
+ 0,
971
+ 0,
972
+ 0,
973
+ 0,
974
+ 8226,
975
+ 8224,
976
+ 8225,
977
+ 8230,
978
+ 8212,
979
+ 8211,
980
+ 402,
981
+ 8260,
982
+ 8249,
983
+ 8250,
984
+ 8722,
985
+ 8240,
986
+ 8222,
987
+ 8220,
988
+ 8221,
989
+ 8216,
990
+ 8217,
991
+ 8218,
992
+ 8482,
993
+ 64257,
994
+ 64258,
995
+ 321,
996
+ 338,
997
+ 352,
998
+ 376,
999
+ 381,
1000
+ 305,
1001
+ 322,
1002
+ 339,
1003
+ 353,
1004
+ 382,
1005
+ 0,
1006
+ 8364
1007
+ ];
1008
+ function stringToPDFString(str, keepEscapeSequence = false) {
1009
+ if (str[0] >= "\xEF") {
1010
+ let encoding;
1011
+ if (str[0] === "\xFE" && str[1] === "\xFF") {
1012
+ encoding = "utf-16be";
1013
+ if (str.length % 2 === 1) {
1014
+ str = str.slice(0, -1);
1015
+ }
1016
+ } else if (str[0] === "\xFF" && str[1] === "\xFE") {
1017
+ encoding = "utf-16le";
1018
+ if (str.length % 2 === 1) {
1019
+ str = str.slice(0, -1);
1020
+ }
1021
+ } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
1022
+ encoding = "utf-8";
1023
+ }
1024
+ if (encoding) {
1025
+ try {
1026
+ const decoder = new TextDecoder(encoding, { fatal: true });
1027
+ const buffer = stringToBytes(str);
1028
+ const decoded = decoder.decode(buffer);
1029
+ if (keepEscapeSequence || !decoded.includes("\x1B")) {
1030
+ return decoded;
1031
+ }
1032
+ return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
1033
+ } catch (ex) {
1034
+ warn(`stringToPDFString: "${ex}".`);
1035
+ }
1036
+ }
1037
+ }
1038
+ const strBuf = [];
1039
+ for (let i = 0, ii = str.length; i < ii; i++) {
1040
+ const charCode = str.charCodeAt(i);
1041
+ if (!keepEscapeSequence && charCode === 27) {
1042
+ while (++i < ii && str.charCodeAt(i) !== 27) {
1043
+ }
1044
+ continue;
1045
+ }
1046
+ const code = PDFStringTranslateTable[charCode];
1047
+ strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
1048
+ }
1049
+ return strBuf.join("");
1050
+ }
1051
+ function stringToUTF8String(str) {
1052
+ return decodeURIComponent(escape(str));
1053
+ }
1054
+ function utf8StringToString(str) {
1055
+ return unescape(encodeURIComponent(str));
1056
+ }
1057
+ function isArrayEqual(arr1, arr2) {
1058
+ if (arr1.length !== arr2.length) {
1059
+ return false;
1060
+ }
1061
+ for (let i = 0, ii = arr1.length; i < ii; i++) {
1062
+ if (arr1[i] !== arr2[i]) {
1063
+ return false;
1064
+ }
1065
+ }
1066
+ return true;
1067
+ }
1068
+ function getModificationDate(date = /* @__PURE__ */ new Date()) {
1069
+ if (!(date instanceof Date)) {
1070
+ date = new Date(date);
1071
+ }
1072
+ const buffer = [
1073
+ date.getUTCFullYear().toString(),
1074
+ (date.getUTCMonth() + 1).toString().padStart(2, "0"),
1075
+ date.getUTCDate().toString().padStart(2, "0"),
1076
+ date.getUTCHours().toString().padStart(2, "0"),
1077
+ date.getUTCMinutes().toString().padStart(2, "0"),
1078
+ date.getUTCSeconds().toString().padStart(2, "0")
1079
+ ];
1080
+ return buffer.join("");
1081
+ }
1082
+ var NormalizeRegex = null;
1083
+ var NormalizationMap = null;
1084
+ function normalizeUnicode(str) {
1085
+ if (!NormalizeRegex) {
1086
+ 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;
1087
+ NormalizationMap = /* @__PURE__ */ new Map([["\uFB05", "\u017Ft"]]);
1088
+ }
1089
+ return str.replaceAll(
1090
+ NormalizeRegex,
1091
+ (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2)
1092
+ );
1093
+ }
1094
+ function getUuid() {
1095
+ if (typeof crypto.randomUUID === "function") {
1096
+ return crypto.randomUUID();
1097
+ }
1098
+ const buf = new Uint8Array(32);
1099
+ crypto.getRandomValues(buf);
1100
+ return bytesToString(buf);
1101
+ }
1102
+ var AnnotationPrefix = "pdfjs_internal_id_";
1103
+ function _isValidExplicitDest(validRef, validName, dest) {
1104
+ if (!Array.isArray(dest) || dest.length < 2) {
1105
+ return false;
1106
+ }
1107
+ const [page, zoom, ...args] = dest;
1108
+ if (!validRef(page) && !Number.isInteger(page)) {
1109
+ return false;
1110
+ }
1111
+ if (!validName(zoom)) {
1112
+ return false;
1113
+ }
1114
+ const argsLen = args.length;
1115
+ let allowNull = true;
1116
+ switch (zoom.name) {
1117
+ case "XYZ":
1118
+ if (argsLen < 2 || argsLen > 3) {
1119
+ return false;
1120
+ }
1121
+ break;
1122
+ case "Fit":
1123
+ case "FitB":
1124
+ return argsLen === 0;
1125
+ case "FitH":
1126
+ case "FitBH":
1127
+ case "FitV":
1128
+ case "FitBV":
1129
+ if (argsLen > 1) {
1130
+ return false;
1131
+ }
1132
+ break;
1133
+ case "FitR":
1134
+ if (argsLen !== 4) {
1135
+ return false;
1136
+ }
1137
+ allowNull = false;
1138
+ break;
1139
+ default:
1140
+ return false;
1141
+ }
1142
+ for (const arg of args) {
1143
+ if (typeof arg === "number" || allowNull && arg === null) {
1144
+ continue;
1145
+ }
1146
+ return false;
1147
+ }
1148
+ return true;
1149
+ }
1150
+ function MathClamp(v, min, max) {
1151
+ return Math.min(Math.max(v, min), max);
1152
+ }
1153
+ function toHexUtil(arr) {
1154
+ if (Uint8Array.prototype.toHex) {
1155
+ return arr.toHex();
1156
+ }
1157
+ return Array.from(arr, (num) => hexNumbers[num]).join("");
1158
+ }
1159
+ function toBase64Util(arr) {
1160
+ if (Uint8Array.prototype.toBase64) {
1161
+ return arr.toBase64();
1162
+ }
1163
+ return btoa(bytesToString(arr));
1164
+ }
1165
+ function fromBase64Util(str) {
1166
+ if (Uint8Array.fromBase64) {
1167
+ return Uint8Array.fromBase64(str);
1168
+ }
1169
+ return stringToBytes(atob(str));
1170
+ }
1171
+ if (false) {
1172
+ Promise.try = function(fn, ...args) {
1173
+ return new Promise((resolve) => {
1174
+ resolve(fn(...args));
1175
+ });
1176
+ };
1177
+ }
1178
+ if (typeof Math.sumPrecise !== "function") {
1179
+ Math.sumPrecise = function(numbers) {
1180
+ return numbers.reduce((a, b) => a + b, 0);
1181
+ };
1182
+ }
1183
+ if (false) {
1184
+ AbortSignal.any = function(iterable) {
1185
+ const ac = new AbortController();
1186
+ const { signal } = ac;
1187
+ for (const s of iterable) {
1188
+ if (s.aborted) {
1189
+ ac.abort(s.reason);
1190
+ return signal;
1191
+ }
1192
+ }
1193
+ for (const s of iterable) {
1194
+ s.addEventListener(
1195
+ "abort",
1196
+ () => {
1197
+ ac.abort(s.reason);
1198
+ },
1199
+ { signal }
1200
+ // Automatically remove the listener.
1201
+ );
1202
+ }
1203
+ return signal;
1204
+ };
1205
+ }
1206
+
61
1207
  // src/pdf.js/src/shared/message_handler.js
62
1208
  var CallbackKind = {
63
1209
  DATA: 1,
@@ -525,12 +1671,12 @@ var _CssFontInfo = class _CssFontInfo {
525
1671
  __privateSet(this, _view, new DataView(__privateGet(this, _buffer)));
526
1672
  __privateSet(this, _decoder, new TextDecoder());
527
1673
  }
528
- static write(info) {
1674
+ static write(info2) {
529
1675
  const encoder = new TextEncoder();
530
1676
  const encodedStrings = {};
531
1677
  let stringsLength = 0;
532
1678
  for (const prop of _CssFontInfo.strings) {
533
- const encoded = encoder.encode(info[prop]);
1679
+ const encoded = encoder.encode(info2[prop]);
534
1680
  encodedStrings[prop] = encoded;
535
1681
  stringsLength += 4 + encoded.length;
536
1682
  }
@@ -586,27 +1732,27 @@ var _SystemFontInfo = class _SystemFontInfo {
586
1732
  __privateSet(this, _view2, new DataView(__privateGet(this, _buffer2)));
587
1733
  __privateSet(this, _decoder2, new TextDecoder());
588
1734
  }
589
- static write(info) {
1735
+ static write(info2) {
590
1736
  const encoder = new TextEncoder();
591
1737
  const encodedStrings = {};
592
1738
  let stringsLength = 0;
593
1739
  for (const prop of _SystemFontInfo.strings) {
594
- const encoded = encoder.encode(info[prop]);
1740
+ const encoded = encoder.encode(info2[prop]);
595
1741
  encodedStrings[prop] = encoded;
596
1742
  stringsLength += 4 + encoded.length;
597
1743
  }
598
1744
  stringsLength += 4;
599
1745
  let encodedStyleStyle, encodedStyleWeight, lengthEstimate = 1 + stringsLength;
600
- if (info.style) {
601
- encodedStyleStyle = encoder.encode(info.style.style);
602
- encodedStyleWeight = encoder.encode(info.style.weight);
1746
+ if (info2.style) {
1747
+ encodedStyleStyle = encoder.encode(info2.style.style);
1748
+ encodedStyleWeight = encoder.encode(info2.style.weight);
603
1749
  lengthEstimate += 4 + encodedStyleStyle.length + 4 + encodedStyleWeight.length;
604
1750
  }
605
1751
  const buffer = new ArrayBuffer(lengthEstimate);
606
1752
  const data = new Uint8Array(buffer);
607
1753
  const view = new DataView(buffer);
608
1754
  let offset = 0;
609
- view.setUint8(offset++, info.guessFallback ? 1 : 0);
1755
+ view.setUint8(offset++, info2.guessFallback ? 1 : 0);
610
1756
  view.setUint32(offset, 0);
611
1757
  offset += 4;
612
1758
  stringsLength = 0;
@@ -619,7 +1765,7 @@ var _SystemFontInfo = class _SystemFontInfo {
619
1765
  offset += 4 + length;
620
1766
  }
621
1767
  view.setUint32(offset - stringsLength - 4, stringsLength);
622
- if (info.style) {
1768
+ if (info2.style) {
623
1769
  view.setUint32(offset, encodedStyleStyle.length);
624
1770
  data.set(encodedStyleStyle, offset + 4);
625
1771
  offset += 4 + encodedStyleStyle.length;
@@ -1029,6 +2175,750 @@ __privateAdd(_FontInfo, _OFFSET_DEFAULT_VMETRICS, __privateGet(_FontInfo, _OFFSE
1029
2175
  __privateAdd(_FontInfo, _OFFSET_STRINGS, __privateGet(_FontInfo, _OFFSET_DEFAULT_VMETRICS) + 1 + 2 * 3);
1030
2176
  var FontInfo = _FontInfo;
1031
2177
 
2178
+ // src/pdf.js/src/core/bidi.js
2179
+ var baseTypes = [
2180
+ "BN",
2181
+ "BN",
2182
+ "BN",
2183
+ "BN",
2184
+ "BN",
2185
+ "BN",
2186
+ "BN",
2187
+ "BN",
2188
+ "BN",
2189
+ "S",
2190
+ "B",
2191
+ "S",
2192
+ "WS",
2193
+ "B",
2194
+ "BN",
2195
+ "BN",
2196
+ "BN",
2197
+ "BN",
2198
+ "BN",
2199
+ "BN",
2200
+ "BN",
2201
+ "BN",
2202
+ "BN",
2203
+ "BN",
2204
+ "BN",
2205
+ "BN",
2206
+ "BN",
2207
+ "BN",
2208
+ "B",
2209
+ "B",
2210
+ "B",
2211
+ "S",
2212
+ "WS",
2213
+ "ON",
2214
+ "ON",
2215
+ "ET",
2216
+ "ET",
2217
+ "ET",
2218
+ "ON",
2219
+ "ON",
2220
+ "ON",
2221
+ "ON",
2222
+ "ON",
2223
+ "ES",
2224
+ "CS",
2225
+ "ES",
2226
+ "CS",
2227
+ "CS",
2228
+ "EN",
2229
+ "EN",
2230
+ "EN",
2231
+ "EN",
2232
+ "EN",
2233
+ "EN",
2234
+ "EN",
2235
+ "EN",
2236
+ "EN",
2237
+ "EN",
2238
+ "CS",
2239
+ "ON",
2240
+ "ON",
2241
+ "ON",
2242
+ "ON",
2243
+ "ON",
2244
+ "ON",
2245
+ "L",
2246
+ "L",
2247
+ "L",
2248
+ "L",
2249
+ "L",
2250
+ "L",
2251
+ "L",
2252
+ "L",
2253
+ "L",
2254
+ "L",
2255
+ "L",
2256
+ "L",
2257
+ "L",
2258
+ "L",
2259
+ "L",
2260
+ "L",
2261
+ "L",
2262
+ "L",
2263
+ "L",
2264
+ "L",
2265
+ "L",
2266
+ "L",
2267
+ "L",
2268
+ "L",
2269
+ "L",
2270
+ "L",
2271
+ "ON",
2272
+ "ON",
2273
+ "ON",
2274
+ "ON",
2275
+ "ON",
2276
+ "ON",
2277
+ "L",
2278
+ "L",
2279
+ "L",
2280
+ "L",
2281
+ "L",
2282
+ "L",
2283
+ "L",
2284
+ "L",
2285
+ "L",
2286
+ "L",
2287
+ "L",
2288
+ "L",
2289
+ "L",
2290
+ "L",
2291
+ "L",
2292
+ "L",
2293
+ "L",
2294
+ "L",
2295
+ "L",
2296
+ "L",
2297
+ "L",
2298
+ "L",
2299
+ "L",
2300
+ "L",
2301
+ "L",
2302
+ "L",
2303
+ "ON",
2304
+ "ON",
2305
+ "ON",
2306
+ "ON",
2307
+ "BN",
2308
+ "BN",
2309
+ "BN",
2310
+ "BN",
2311
+ "BN",
2312
+ "BN",
2313
+ "B",
2314
+ "BN",
2315
+ "BN",
2316
+ "BN",
2317
+ "BN",
2318
+ "BN",
2319
+ "BN",
2320
+ "BN",
2321
+ "BN",
2322
+ "BN",
2323
+ "BN",
2324
+ "BN",
2325
+ "BN",
2326
+ "BN",
2327
+ "BN",
2328
+ "BN",
2329
+ "BN",
2330
+ "BN",
2331
+ "BN",
2332
+ "BN",
2333
+ "BN",
2334
+ "BN",
2335
+ "BN",
2336
+ "BN",
2337
+ "BN",
2338
+ "BN",
2339
+ "BN",
2340
+ "CS",
2341
+ "ON",
2342
+ "ET",
2343
+ "ET",
2344
+ "ET",
2345
+ "ET",
2346
+ "ON",
2347
+ "ON",
2348
+ "ON",
2349
+ "ON",
2350
+ "L",
2351
+ "ON",
2352
+ "ON",
2353
+ "BN",
2354
+ "ON",
2355
+ "ON",
2356
+ "ET",
2357
+ "ET",
2358
+ "EN",
2359
+ "EN",
2360
+ "ON",
2361
+ "L",
2362
+ "ON",
2363
+ "ON",
2364
+ "ON",
2365
+ "EN",
2366
+ "L",
2367
+ "ON",
2368
+ "ON",
2369
+ "ON",
2370
+ "ON",
2371
+ "ON",
2372
+ "L",
2373
+ "L",
2374
+ "L",
2375
+ "L",
2376
+ "L",
2377
+ "L",
2378
+ "L",
2379
+ "L",
2380
+ "L",
2381
+ "L",
2382
+ "L",
2383
+ "L",
2384
+ "L",
2385
+ "L",
2386
+ "L",
2387
+ "L",
2388
+ "L",
2389
+ "L",
2390
+ "L",
2391
+ "L",
2392
+ "L",
2393
+ "L",
2394
+ "L",
2395
+ "ON",
2396
+ "L",
2397
+ "L",
2398
+ "L",
2399
+ "L",
2400
+ "L",
2401
+ "L",
2402
+ "L",
2403
+ "L",
2404
+ "L",
2405
+ "L",
2406
+ "L",
2407
+ "L",
2408
+ "L",
2409
+ "L",
2410
+ "L",
2411
+ "L",
2412
+ "L",
2413
+ "L",
2414
+ "L",
2415
+ "L",
2416
+ "L",
2417
+ "L",
2418
+ "L",
2419
+ "L",
2420
+ "L",
2421
+ "L",
2422
+ "L",
2423
+ "L",
2424
+ "L",
2425
+ "L",
2426
+ "L",
2427
+ "ON",
2428
+ "L",
2429
+ "L",
2430
+ "L",
2431
+ "L",
2432
+ "L",
2433
+ "L",
2434
+ "L",
2435
+ "L"
2436
+ ];
2437
+ var arabicTypes = [
2438
+ "AN",
2439
+ "AN",
2440
+ "AN",
2441
+ "AN",
2442
+ "AN",
2443
+ "AN",
2444
+ "ON",
2445
+ "ON",
2446
+ "AL",
2447
+ "ET",
2448
+ "ET",
2449
+ "AL",
2450
+ "CS",
2451
+ "AL",
2452
+ "ON",
2453
+ "ON",
2454
+ "NSM",
2455
+ "NSM",
2456
+ "NSM",
2457
+ "NSM",
2458
+ "NSM",
2459
+ "NSM",
2460
+ "NSM",
2461
+ "NSM",
2462
+ "NSM",
2463
+ "NSM",
2464
+ "NSM",
2465
+ "AL",
2466
+ "AL",
2467
+ "",
2468
+ "AL",
2469
+ "AL",
2470
+ "AL",
2471
+ "AL",
2472
+ "AL",
2473
+ "AL",
2474
+ "AL",
2475
+ "AL",
2476
+ "AL",
2477
+ "AL",
2478
+ "AL",
2479
+ "AL",
2480
+ "AL",
2481
+ "AL",
2482
+ "AL",
2483
+ "AL",
2484
+ "AL",
2485
+ "AL",
2486
+ "AL",
2487
+ "AL",
2488
+ "AL",
2489
+ "AL",
2490
+ "AL",
2491
+ "AL",
2492
+ "AL",
2493
+ "AL",
2494
+ "AL",
2495
+ "AL",
2496
+ "AL",
2497
+ "AL",
2498
+ "AL",
2499
+ "AL",
2500
+ "AL",
2501
+ "AL",
2502
+ "AL",
2503
+ "AL",
2504
+ "AL",
2505
+ "AL",
2506
+ "AL",
2507
+ "AL",
2508
+ "AL",
2509
+ "AL",
2510
+ "AL",
2511
+ "AL",
2512
+ "AL",
2513
+ "NSM",
2514
+ "NSM",
2515
+ "NSM",
2516
+ "NSM",
2517
+ "NSM",
2518
+ "NSM",
2519
+ "NSM",
2520
+ "NSM",
2521
+ "NSM",
2522
+ "NSM",
2523
+ "NSM",
2524
+ "NSM",
2525
+ "NSM",
2526
+ "NSM",
2527
+ "NSM",
2528
+ "NSM",
2529
+ "NSM",
2530
+ "NSM",
2531
+ "NSM",
2532
+ "NSM",
2533
+ "NSM",
2534
+ "AN",
2535
+ "AN",
2536
+ "AN",
2537
+ "AN",
2538
+ "AN",
2539
+ "AN",
2540
+ "AN",
2541
+ "AN",
2542
+ "AN",
2543
+ "AN",
2544
+ "ET",
2545
+ "AN",
2546
+ "AN",
2547
+ "AL",
2548
+ "AL",
2549
+ "AL",
2550
+ "NSM",
2551
+ "AL",
2552
+ "AL",
2553
+ "AL",
2554
+ "AL",
2555
+ "AL",
2556
+ "AL",
2557
+ "AL",
2558
+ "AL",
2559
+ "AL",
2560
+ "AL",
2561
+ "AL",
2562
+ "AL",
2563
+ "AL",
2564
+ "AL",
2565
+ "AL",
2566
+ "AL",
2567
+ "AL",
2568
+ "AL",
2569
+ "AL",
2570
+ "AL",
2571
+ "AL",
2572
+ "AL",
2573
+ "AL",
2574
+ "AL",
2575
+ "AL",
2576
+ "AL",
2577
+ "AL",
2578
+ "AL",
2579
+ "AL",
2580
+ "AL",
2581
+ "AL",
2582
+ "AL",
2583
+ "AL",
2584
+ "AL",
2585
+ "AL",
2586
+ "AL",
2587
+ "AL",
2588
+ "AL",
2589
+ "AL",
2590
+ "AL",
2591
+ "AL",
2592
+ "AL",
2593
+ "AL",
2594
+ "AL",
2595
+ "AL",
2596
+ "AL",
2597
+ "AL",
2598
+ "AL",
2599
+ "AL",
2600
+ "AL",
2601
+ "AL",
2602
+ "AL",
2603
+ "AL",
2604
+ "AL",
2605
+ "AL",
2606
+ "AL",
2607
+ "AL",
2608
+ "AL",
2609
+ "AL",
2610
+ "AL",
2611
+ "AL",
2612
+ "AL",
2613
+ "AL",
2614
+ "AL",
2615
+ "AL",
2616
+ "AL",
2617
+ "AL",
2618
+ "AL",
2619
+ "AL",
2620
+ "AL",
2621
+ "AL",
2622
+ "AL",
2623
+ "AL",
2624
+ "AL",
2625
+ "AL",
2626
+ "AL",
2627
+ "AL",
2628
+ "AL",
2629
+ "AL",
2630
+ "AL",
2631
+ "AL",
2632
+ "AL",
2633
+ "AL",
2634
+ "AL",
2635
+ "AL",
2636
+ "AL",
2637
+ "AL",
2638
+ "AL",
2639
+ "AL",
2640
+ "AL",
2641
+ "AL",
2642
+ "AL",
2643
+ "AL",
2644
+ "AL",
2645
+ "AL",
2646
+ "AL",
2647
+ "AL",
2648
+ "AL",
2649
+ "AL",
2650
+ "AL",
2651
+ "AL",
2652
+ "NSM",
2653
+ "NSM",
2654
+ "NSM",
2655
+ "NSM",
2656
+ "NSM",
2657
+ "NSM",
2658
+ "NSM",
2659
+ "AN",
2660
+ "ON",
2661
+ "NSM",
2662
+ "NSM",
2663
+ "NSM",
2664
+ "NSM",
2665
+ "NSM",
2666
+ "NSM",
2667
+ "AL",
2668
+ "AL",
2669
+ "NSM",
2670
+ "NSM",
2671
+ "ON",
2672
+ "NSM",
2673
+ "NSM",
2674
+ "NSM",
2675
+ "NSM",
2676
+ "AL",
2677
+ "AL",
2678
+ "EN",
2679
+ "EN",
2680
+ "EN",
2681
+ "EN",
2682
+ "EN",
2683
+ "EN",
2684
+ "EN",
2685
+ "EN",
2686
+ "EN",
2687
+ "EN",
2688
+ "AL",
2689
+ "AL",
2690
+ "AL",
2691
+ "AL",
2692
+ "AL",
2693
+ "AL"
2694
+ ];
2695
+ function isOdd(i) {
2696
+ return (i & 1) !== 0;
2697
+ }
2698
+ function isEven(i) {
2699
+ return (i & 1) === 0;
2700
+ }
2701
+ function findUnequal(arr, start, value) {
2702
+ let j, jj;
2703
+ for (j = start, jj = arr.length; j < jj; ++j) {
2704
+ if (arr[j] !== value) {
2705
+ return j;
2706
+ }
2707
+ }
2708
+ return j;
2709
+ }
2710
+ function reverseValues(arr, start, end) {
2711
+ for (let i = start, j = end - 1; i < j; ++i, --j) {
2712
+ const temp = arr[i];
2713
+ arr[i] = arr[j];
2714
+ arr[j] = temp;
2715
+ }
2716
+ }
2717
+ function createBidiText(str, isLTR, vertical = false) {
2718
+ let dir = "ltr";
2719
+ if (vertical) {
2720
+ dir = "ttb";
2721
+ } else if (!isLTR) {
2722
+ dir = "rtl";
2723
+ }
2724
+ return { str, dir };
2725
+ }
2726
+ var chars = [];
2727
+ var types = [];
2728
+ function bidi(str, startLevel = -1, vertical = false) {
2729
+ let isLTR = true;
2730
+ const strLength = str.length;
2731
+ if (strLength === 0 || vertical) {
2732
+ return createBidiText(str, isLTR, vertical);
2733
+ }
2734
+ chars.length = strLength;
2735
+ types.length = strLength;
2736
+ let numBidi = 0;
2737
+ let i, ii;
2738
+ for (i = 0; i < strLength; ++i) {
2739
+ chars[i] = str.charAt(i);
2740
+ const charCode = str.charCodeAt(i);
2741
+ let charType = "L";
2742
+ if (charCode <= 255) {
2743
+ charType = baseTypes[charCode];
2744
+ } else if (1424 <= charCode && charCode <= 1524) {
2745
+ charType = "R";
2746
+ } else if (1536 <= charCode && charCode <= 1791) {
2747
+ charType = arabicTypes[charCode & 255];
2748
+ if (!charType) {
2749
+ warn("Bidi: invalid Unicode character " + charCode.toString(16));
2750
+ }
2751
+ } else if (1792 <= charCode && charCode <= 2220 || 64336 <= charCode && charCode <= 65023 || 65136 <= charCode && charCode <= 65279) {
2752
+ charType = "AL";
2753
+ }
2754
+ if (charType === "R" || charType === "AL" || charType === "AN") {
2755
+ numBidi++;
2756
+ }
2757
+ types[i] = charType;
2758
+ }
2759
+ if (numBidi === 0) {
2760
+ isLTR = true;
2761
+ return createBidiText(str, isLTR);
2762
+ }
2763
+ if (startLevel === -1) {
2764
+ if (numBidi / strLength < 0.3 && strLength > 4) {
2765
+ isLTR = true;
2766
+ startLevel = 0;
2767
+ } else {
2768
+ isLTR = false;
2769
+ startLevel = 1;
2770
+ }
2771
+ }
2772
+ const levels = [];
2773
+ for (i = 0; i < strLength; ++i) {
2774
+ levels[i] = startLevel;
2775
+ }
2776
+ const e = isOdd(startLevel) ? "R" : "L";
2777
+ const sor = e;
2778
+ const eor = sor;
2779
+ let lastType = sor;
2780
+ for (i = 0; i < strLength; ++i) {
2781
+ if (types[i] === "NSM") {
2782
+ types[i] = lastType;
2783
+ } else {
2784
+ lastType = types[i];
2785
+ }
2786
+ }
2787
+ lastType = sor;
2788
+ let t;
2789
+ for (i = 0; i < strLength; ++i) {
2790
+ t = types[i];
2791
+ if (t === "EN") {
2792
+ types[i] = lastType === "AL" ? "AN" : "EN";
2793
+ } else if (t === "R" || t === "L" || t === "AL") {
2794
+ lastType = t;
2795
+ }
2796
+ }
2797
+ for (i = 0; i < strLength; ++i) {
2798
+ t = types[i];
2799
+ if (t === "AL") {
2800
+ types[i] = "R";
2801
+ }
2802
+ }
2803
+ for (i = 1; i < strLength - 1; ++i) {
2804
+ if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
2805
+ types[i] = "EN";
2806
+ }
2807
+ if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
2808
+ types[i] = types[i - 1];
2809
+ }
2810
+ }
2811
+ for (i = 0; i < strLength; ++i) {
2812
+ if (types[i] === "EN") {
2813
+ for (let j = i - 1; j >= 0; --j) {
2814
+ if (types[j] !== "ET") {
2815
+ break;
2816
+ }
2817
+ types[j] = "EN";
2818
+ }
2819
+ for (let j = i + 1; j < strLength; ++j) {
2820
+ if (types[j] !== "ET") {
2821
+ break;
2822
+ }
2823
+ types[j] = "EN";
2824
+ }
2825
+ }
2826
+ }
2827
+ for (i = 0; i < strLength; ++i) {
2828
+ t = types[i];
2829
+ if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
2830
+ types[i] = "ON";
2831
+ }
2832
+ }
2833
+ lastType = sor;
2834
+ for (i = 0; i < strLength; ++i) {
2835
+ t = types[i];
2836
+ if (t === "EN") {
2837
+ types[i] = lastType === "L" ? "L" : "EN";
2838
+ } else if (t === "R" || t === "L") {
2839
+ lastType = t;
2840
+ }
2841
+ }
2842
+ for (i = 0; i < strLength; ++i) {
2843
+ if (types[i] === "ON") {
2844
+ const end = findUnequal(types, i + 1, "ON");
2845
+ let before = sor;
2846
+ if (i > 0) {
2847
+ before = types[i - 1];
2848
+ }
2849
+ let after = eor;
2850
+ if (end + 1 < strLength) {
2851
+ after = types[end + 1];
2852
+ }
2853
+ if (before !== "L") {
2854
+ before = "R";
2855
+ }
2856
+ if (after !== "L") {
2857
+ after = "R";
2858
+ }
2859
+ if (before === after) {
2860
+ types.fill(before, i, end);
2861
+ }
2862
+ i = end - 1;
2863
+ }
2864
+ }
2865
+ for (i = 0; i < strLength; ++i) {
2866
+ if (types[i] === "ON") {
2867
+ types[i] = e;
2868
+ }
2869
+ }
2870
+ for (i = 0; i < strLength; ++i) {
2871
+ t = types[i];
2872
+ if (isEven(levels[i])) {
2873
+ if (t === "R") {
2874
+ levels[i] += 1;
2875
+ } else if (t === "AN" || t === "EN") {
2876
+ levels[i] += 2;
2877
+ }
2878
+ } else if (
2879
+ /* isOdd && */
2880
+ t === "L" || t === "AN" || t === "EN"
2881
+ ) {
2882
+ levels[i] += 1;
2883
+ }
2884
+ }
2885
+ let highestLevel = -1;
2886
+ let lowestOddLevel = 99;
2887
+ let level;
2888
+ for (i = 0, ii = levels.length; i < ii; ++i) {
2889
+ level = levels[i];
2890
+ if (highestLevel < level) {
2891
+ highestLevel = level;
2892
+ }
2893
+ if (lowestOddLevel > level && isOdd(level)) {
2894
+ lowestOddLevel = level;
2895
+ }
2896
+ }
2897
+ for (level = highestLevel; level >= lowestOddLevel; --level) {
2898
+ let start = -1;
2899
+ for (i = 0, ii = levels.length; i < ii; ++i) {
2900
+ if (levels[i] < level) {
2901
+ if (start >= 0) {
2902
+ reverseValues(chars, start, i);
2903
+ start = -1;
2904
+ }
2905
+ } else if (start < 0) {
2906
+ start = i;
2907
+ }
2908
+ }
2909
+ if (start >= 0) {
2910
+ reverseValues(chars, start, levels.length);
2911
+ }
2912
+ }
2913
+ for (i = 0, ii = chars.length; i < ii; ++i) {
2914
+ const ch = chars[i];
2915
+ if (ch === "<" || ch === ">") {
2916
+ chars[i] = "";
2917
+ }
2918
+ }
2919
+ return createBidiText(chars.join(""), isLTR);
2920
+ }
2921
+
1032
2922
  // src/pdf.js/src/shared/scripting_utils.js
1033
2923
  function makeColorComp(n) {
1034
2924
  return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
@@ -1306,6 +3196,66 @@ function grayToRGBA(src, dest) {
1306
3196
  }
1307
3197
 
1308
3198
  export {
3199
+ isNodeJS,
3200
+ FONT_IDENTITY_MATRIX,
3201
+ LINE_FACTOR,
3202
+ LINE_DESCENT_FACTOR,
3203
+ BASELINE_FACTOR,
3204
+ RenderingIntentFlag,
3205
+ AnnotationMode,
3206
+ AnnotationEditorPrefix,
3207
+ AnnotationEditorType,
3208
+ AnnotationEditorParamsType,
3209
+ PermissionFlag,
3210
+ TextRenderingMode,
3211
+ ImageKind,
3212
+ AnnotationType,
3213
+ AnnotationReplyType,
3214
+ AnnotationFlag,
3215
+ AnnotationFieldFlag,
3216
+ AnnotationBorderStyleType,
3217
+ AnnotationActionEventType,
3218
+ DocumentActionEventType,
3219
+ PageActionEventType,
3220
+ VerbosityLevel,
3221
+ OPS,
3222
+ DrawOPS,
3223
+ PasswordResponses,
3224
+ setVerbosityLevel,
3225
+ getVerbosityLevel,
3226
+ info,
3227
+ warn,
3228
+ unreachable,
3229
+ assert,
3230
+ createValidAbsoluteUrl,
3231
+ updateUrlHash,
3232
+ shadow,
3233
+ BaseException,
3234
+ PasswordException,
3235
+ InvalidPDFException,
3236
+ ResponseException,
3237
+ FormatError,
3238
+ AbortException,
3239
+ bytesToString,
3240
+ stringToBytes,
3241
+ string32,
3242
+ objectSize,
3243
+ FeatureTest,
3244
+ hexNumbers,
3245
+ Util,
3246
+ stringToPDFString,
3247
+ stringToUTF8String,
3248
+ utf8StringToString,
3249
+ isArrayEqual,
3250
+ getModificationDate,
3251
+ normalizeUnicode,
3252
+ getUuid,
3253
+ AnnotationPrefix,
3254
+ _isValidExplicitDest,
3255
+ MathClamp,
3256
+ toHexUtil,
3257
+ toBase64Util,
3258
+ fromBase64Util,
1309
3259
  MurmurHash3_64,
1310
3260
  wrapReason,
1311
3261
  MessageHandler,
@@ -1313,6 +3263,7 @@ export {
1313
3263
  convertBlackAndWhiteToRGBA,
1314
3264
  grayToRGBA,
1315
3265
  FontInfo,
3266
+ bidi,
1316
3267
  ColorConverters,
1317
3268
  DateFormats,
1318
3269
  TimeFormats