@chialab/pdfjs-lib 1.0.0-alpha.37 → 1.0.0-alpha.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +7 -7
- package/dist/node/{NodeUtils-DMZFO2HQ.js → NodeUtils-U752HDWU.js} +2 -2
- package/dist/node/{chunk-7NGJYFOM.js → chunk-FGBCMLPZ.js} +888 -1307
- package/dist/node/chunk-T2JWSGAF.js +1225 -0
- package/dist/node/chunk-XAT2FF6L.js +2090 -0
- package/dist/node/index.js +26345 -259
- package/dist/node/worker.js +13 -13
- package/package.json +1 -1
- package/dist/node/chunk-AFWVANFS.js +0 -792
- package/dist/node/chunk-YYN3HV7W.js +0 -28201
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbortException,
|
|
3
|
+
FeatureTest,
|
|
4
|
+
ImageKind,
|
|
5
|
+
InvalidPDFException,
|
|
6
|
+
PasswordException,
|
|
7
|
+
ResponseException,
|
|
8
|
+
UnknownErrorException,
|
|
9
|
+
assert,
|
|
10
|
+
unreachable,
|
|
11
|
+
warn
|
|
12
|
+
} from "./chunk-T2JWSGAF.js";
|
|
1
13
|
import {
|
|
2
14
|
__privateAdd,
|
|
3
15
|
__privateGet,
|
|
@@ -6,1161 +18,45 @@ import {
|
|
|
6
18
|
__publicField
|
|
7
19
|
} from "./chunk-ZFIGV5OT.js";
|
|
8
20
|
|
|
9
|
-
// src/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ANY: 1,
|
|
17
|
-
DISPLAY: 2,
|
|
18
|
-
PRINT: 4,
|
|
19
|
-
SAVE: 8,
|
|
20
|
-
ANNOTATIONS_FORMS: 16,
|
|
21
|
-
ANNOTATIONS_STORAGE: 32,
|
|
22
|
-
ANNOTATIONS_DISABLE: 64,
|
|
23
|
-
IS_EDITING: 128,
|
|
24
|
-
OPLIST: 256
|
|
25
|
-
};
|
|
26
|
-
var AnnotationMode = {
|
|
27
|
-
DISABLE: 0,
|
|
28
|
-
ENABLE: 1,
|
|
29
|
-
ENABLE_FORMS: 2,
|
|
30
|
-
ENABLE_STORAGE: 3
|
|
31
|
-
};
|
|
32
|
-
var AnnotationEditorPrefix = "pdfjs_internal_editor_";
|
|
33
|
-
var AnnotationEditorType = {
|
|
34
|
-
DISABLE: -1,
|
|
35
|
-
NONE: 0,
|
|
36
|
-
FREETEXT: 3,
|
|
37
|
-
HIGHLIGHT: 9,
|
|
38
|
-
STAMP: 13,
|
|
39
|
-
INK: 15,
|
|
40
|
-
POPUP: 16,
|
|
41
|
-
SIGNATURE: 101,
|
|
42
|
-
COMMENT: 102
|
|
43
|
-
};
|
|
44
|
-
var AnnotationEditorParamsType = {
|
|
45
|
-
RESIZE: 1,
|
|
46
|
-
CREATE: 2,
|
|
47
|
-
FREETEXT_SIZE: 11,
|
|
48
|
-
FREETEXT_COLOR: 12,
|
|
49
|
-
FREETEXT_OPACITY: 13,
|
|
50
|
-
INK_COLOR: 21,
|
|
51
|
-
INK_THICKNESS: 22,
|
|
52
|
-
INK_OPACITY: 23,
|
|
53
|
-
HIGHLIGHT_COLOR: 31,
|
|
54
|
-
HIGHLIGHT_THICKNESS: 32,
|
|
55
|
-
HIGHLIGHT_FREE: 33,
|
|
56
|
-
HIGHLIGHT_SHOW_ALL: 34,
|
|
57
|
-
DRAW_STEP: 41
|
|
58
|
-
};
|
|
59
|
-
var PermissionFlag = {
|
|
60
|
-
PRINT: 4,
|
|
61
|
-
MODIFY_CONTENTS: 8,
|
|
62
|
-
COPY: 16,
|
|
63
|
-
MODIFY_ANNOTATIONS: 32,
|
|
64
|
-
FILL_INTERACTIVE_FORMS: 256,
|
|
65
|
-
COPY_FOR_ACCESSIBILITY: 512,
|
|
66
|
-
ASSEMBLE: 1024,
|
|
67
|
-
PRINT_HIGH_QUALITY: 2048
|
|
68
|
-
};
|
|
69
|
-
var TextRenderingMode = {
|
|
70
|
-
FILL: 0,
|
|
71
|
-
STROKE: 1,
|
|
72
|
-
FILL_STROKE: 2,
|
|
73
|
-
INVISIBLE: 3,
|
|
74
|
-
FILL_ADD_TO_PATH: 4,
|
|
75
|
-
STROKE_ADD_TO_PATH: 5,
|
|
76
|
-
FILL_STROKE_ADD_TO_PATH: 6,
|
|
77
|
-
ADD_TO_PATH: 7,
|
|
78
|
-
FILL_STROKE_MASK: 3,
|
|
79
|
-
ADD_TO_PATH_FLAG: 4
|
|
80
|
-
};
|
|
81
|
-
var ImageKind = {
|
|
82
|
-
GRAYSCALE_1BPP: 1,
|
|
83
|
-
RGB_24BPP: 2,
|
|
84
|
-
RGBA_32BPP: 3
|
|
85
|
-
};
|
|
86
|
-
var AnnotationType = {
|
|
87
|
-
TEXT: 1,
|
|
88
|
-
LINK: 2,
|
|
89
|
-
FREETEXT: 3,
|
|
90
|
-
LINE: 4,
|
|
91
|
-
SQUARE: 5,
|
|
92
|
-
CIRCLE: 6,
|
|
93
|
-
POLYGON: 7,
|
|
94
|
-
POLYLINE: 8,
|
|
95
|
-
HIGHLIGHT: 9,
|
|
96
|
-
UNDERLINE: 10,
|
|
97
|
-
SQUIGGLY: 11,
|
|
98
|
-
STRIKEOUT: 12,
|
|
99
|
-
STAMP: 13,
|
|
100
|
-
CARET: 14,
|
|
101
|
-
INK: 15,
|
|
102
|
-
POPUP: 16,
|
|
103
|
-
FILEATTACHMENT: 17,
|
|
104
|
-
SOUND: 18,
|
|
105
|
-
MOVIE: 19,
|
|
106
|
-
WIDGET: 20,
|
|
107
|
-
SCREEN: 21,
|
|
108
|
-
PRINTERMARK: 22,
|
|
109
|
-
TRAPNET: 23,
|
|
110
|
-
WATERMARK: 24,
|
|
111
|
-
THREED: 25,
|
|
112
|
-
REDACT: 26
|
|
113
|
-
};
|
|
114
|
-
var AnnotationReplyType = {
|
|
115
|
-
GROUP: "Group",
|
|
116
|
-
REPLY: "R"
|
|
117
|
-
};
|
|
118
|
-
var AnnotationFlag = {
|
|
119
|
-
INVISIBLE: 1,
|
|
120
|
-
HIDDEN: 2,
|
|
121
|
-
PRINT: 4,
|
|
122
|
-
NOZOOM: 8,
|
|
123
|
-
NOROTATE: 16,
|
|
124
|
-
NOVIEW: 32,
|
|
125
|
-
READONLY: 64,
|
|
126
|
-
LOCKED: 128,
|
|
127
|
-
TOGGLENOVIEW: 256,
|
|
128
|
-
LOCKEDCONTENTS: 512
|
|
129
|
-
};
|
|
130
|
-
var AnnotationFieldFlag = {
|
|
131
|
-
READONLY: 1,
|
|
132
|
-
REQUIRED: 2,
|
|
133
|
-
NOEXPORT: 4,
|
|
134
|
-
MULTILINE: 4096,
|
|
135
|
-
PASSWORD: 8192,
|
|
136
|
-
NOTOGGLETOOFF: 16384,
|
|
137
|
-
RADIO: 32768,
|
|
138
|
-
PUSHBUTTON: 65536,
|
|
139
|
-
COMBO: 131072,
|
|
140
|
-
EDIT: 262144,
|
|
141
|
-
SORT: 524288,
|
|
142
|
-
FILESELECT: 1048576,
|
|
143
|
-
MULTISELECT: 2097152,
|
|
144
|
-
DONOTSPELLCHECK: 4194304,
|
|
145
|
-
DONOTSCROLL: 8388608,
|
|
146
|
-
COMB: 16777216,
|
|
147
|
-
RICHTEXT: 33554432,
|
|
148
|
-
RADIOSINUNISON: 33554432,
|
|
149
|
-
COMMITONSELCHANGE: 67108864
|
|
150
|
-
};
|
|
151
|
-
var AnnotationBorderStyleType = {
|
|
152
|
-
SOLID: 1,
|
|
153
|
-
DASHED: 2,
|
|
154
|
-
BEVELED: 3,
|
|
155
|
-
INSET: 4,
|
|
156
|
-
UNDERLINE: 5
|
|
157
|
-
};
|
|
158
|
-
var AnnotationActionEventType = {
|
|
159
|
-
E: "Mouse Enter",
|
|
160
|
-
X: "Mouse Exit",
|
|
161
|
-
D: "Mouse Down",
|
|
162
|
-
U: "Mouse Up",
|
|
163
|
-
Fo: "Focus",
|
|
164
|
-
Bl: "Blur",
|
|
165
|
-
PO: "PageOpen",
|
|
166
|
-
PC: "PageClose",
|
|
167
|
-
PV: "PageVisible",
|
|
168
|
-
PI: "PageInvisible",
|
|
169
|
-
K: "Keystroke",
|
|
170
|
-
F: "Format",
|
|
171
|
-
V: "Validate",
|
|
172
|
-
C: "Calculate"
|
|
173
|
-
};
|
|
174
|
-
var DocumentActionEventType = {
|
|
175
|
-
WC: "WillClose",
|
|
176
|
-
WS: "WillSave",
|
|
177
|
-
DS: "DidSave",
|
|
178
|
-
WP: "WillPrint",
|
|
179
|
-
DP: "DidPrint"
|
|
180
|
-
};
|
|
181
|
-
var PageActionEventType = {
|
|
182
|
-
O: "PageOpen",
|
|
183
|
-
C: "PageClose"
|
|
184
|
-
};
|
|
185
|
-
var VerbosityLevel = {
|
|
186
|
-
ERRORS: 0,
|
|
187
|
-
WARNINGS: 1,
|
|
188
|
-
INFOS: 5
|
|
189
|
-
};
|
|
190
|
-
var OPS = {
|
|
191
|
-
// Intentionally start from 1 so it is easy to spot bad operators that will be
|
|
192
|
-
// 0's.
|
|
193
|
-
// PLEASE NOTE: We purposely keep any removed operators commented out, since
|
|
194
|
-
// re-numbering the list would risk breaking third-party users.
|
|
195
|
-
dependency: 1,
|
|
196
|
-
setLineWidth: 2,
|
|
197
|
-
setLineCap: 3,
|
|
198
|
-
setLineJoin: 4,
|
|
199
|
-
setMiterLimit: 5,
|
|
200
|
-
setDash: 6,
|
|
201
|
-
setRenderingIntent: 7,
|
|
202
|
-
setFlatness: 8,
|
|
203
|
-
setGState: 9,
|
|
204
|
-
save: 10,
|
|
205
|
-
restore: 11,
|
|
206
|
-
transform: 12,
|
|
207
|
-
moveTo: 13,
|
|
208
|
-
lineTo: 14,
|
|
209
|
-
curveTo: 15,
|
|
210
|
-
curveTo2: 16,
|
|
211
|
-
curveTo3: 17,
|
|
212
|
-
closePath: 18,
|
|
213
|
-
rectangle: 19,
|
|
214
|
-
stroke: 20,
|
|
215
|
-
closeStroke: 21,
|
|
216
|
-
fill: 22,
|
|
217
|
-
eoFill: 23,
|
|
218
|
-
fillStroke: 24,
|
|
219
|
-
eoFillStroke: 25,
|
|
220
|
-
closeFillStroke: 26,
|
|
221
|
-
closeEOFillStroke: 27,
|
|
222
|
-
endPath: 28,
|
|
223
|
-
clip: 29,
|
|
224
|
-
eoClip: 30,
|
|
225
|
-
beginText: 31,
|
|
226
|
-
endText: 32,
|
|
227
|
-
setCharSpacing: 33,
|
|
228
|
-
setWordSpacing: 34,
|
|
229
|
-
setHScale: 35,
|
|
230
|
-
setLeading: 36,
|
|
231
|
-
setFont: 37,
|
|
232
|
-
setTextRenderingMode: 38,
|
|
233
|
-
setTextRise: 39,
|
|
234
|
-
moveText: 40,
|
|
235
|
-
setLeadingMoveText: 41,
|
|
236
|
-
setTextMatrix: 42,
|
|
237
|
-
nextLine: 43,
|
|
238
|
-
showText: 44,
|
|
239
|
-
showSpacedText: 45,
|
|
240
|
-
nextLineShowText: 46,
|
|
241
|
-
nextLineSetSpacingShowText: 47,
|
|
242
|
-
setCharWidth: 48,
|
|
243
|
-
setCharWidthAndBounds: 49,
|
|
244
|
-
setStrokeColorSpace: 50,
|
|
245
|
-
setFillColorSpace: 51,
|
|
246
|
-
setStrokeColor: 52,
|
|
247
|
-
setStrokeColorN: 53,
|
|
248
|
-
setFillColor: 54,
|
|
249
|
-
setFillColorN: 55,
|
|
250
|
-
setStrokeGray: 56,
|
|
251
|
-
setFillGray: 57,
|
|
252
|
-
setStrokeRGBColor: 58,
|
|
253
|
-
setFillRGBColor: 59,
|
|
254
|
-
setStrokeCMYKColor: 60,
|
|
255
|
-
setFillCMYKColor: 61,
|
|
256
|
-
shadingFill: 62,
|
|
257
|
-
beginInlineImage: 63,
|
|
258
|
-
beginImageData: 64,
|
|
259
|
-
endInlineImage: 65,
|
|
260
|
-
paintXObject: 66,
|
|
261
|
-
markPoint: 67,
|
|
262
|
-
markPointProps: 68,
|
|
263
|
-
beginMarkedContent: 69,
|
|
264
|
-
beginMarkedContentProps: 70,
|
|
265
|
-
endMarkedContent: 71,
|
|
266
|
-
beginCompat: 72,
|
|
267
|
-
endCompat: 73,
|
|
268
|
-
paintFormXObjectBegin: 74,
|
|
269
|
-
paintFormXObjectEnd: 75,
|
|
270
|
-
beginGroup: 76,
|
|
271
|
-
endGroup: 77,
|
|
272
|
-
// beginAnnotations: 78,
|
|
273
|
-
// endAnnotations: 79,
|
|
274
|
-
beginAnnotation: 80,
|
|
275
|
-
endAnnotation: 81,
|
|
276
|
-
// paintJpegXObject: 82,
|
|
277
|
-
paintImageMaskXObject: 83,
|
|
278
|
-
paintImageMaskXObjectGroup: 84,
|
|
279
|
-
paintImageXObject: 85,
|
|
280
|
-
paintInlineImageXObject: 86,
|
|
281
|
-
paintInlineImageXObjectGroup: 87,
|
|
282
|
-
paintImageXObjectRepeat: 88,
|
|
283
|
-
paintImageMaskXObjectRepeat: 89,
|
|
284
|
-
paintSolidColorImageMask: 90,
|
|
285
|
-
constructPath: 91,
|
|
286
|
-
setStrokeTransparent: 92,
|
|
287
|
-
setFillTransparent: 93,
|
|
288
|
-
rawFillPath: 94
|
|
289
|
-
};
|
|
290
|
-
var DrawOPS = {
|
|
291
|
-
moveTo: 0,
|
|
292
|
-
lineTo: 1,
|
|
293
|
-
curveTo: 2,
|
|
294
|
-
closePath: 3
|
|
295
|
-
};
|
|
296
|
-
var PasswordResponses = {
|
|
297
|
-
NEED_PASSWORD: 1,
|
|
298
|
-
INCORRECT_PASSWORD: 2
|
|
299
|
-
};
|
|
300
|
-
var verbosity = VerbosityLevel.WARNINGS;
|
|
301
|
-
function setVerbosityLevel(level) {
|
|
302
|
-
if (Number.isInteger(level)) {
|
|
303
|
-
verbosity = level;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
function getVerbosityLevel() {
|
|
307
|
-
return verbosity;
|
|
308
|
-
}
|
|
309
|
-
function info(msg) {
|
|
310
|
-
if (verbosity >= VerbosityLevel.INFOS) {
|
|
311
|
-
console.info(`Info: ${msg}`);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function warn(msg) {
|
|
315
|
-
if (verbosity >= VerbosityLevel.WARNINGS) {
|
|
316
|
-
console.warn(`Warning: ${msg}`);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
function unreachable(msg) {
|
|
320
|
-
throw new Error(msg);
|
|
321
|
-
}
|
|
322
|
-
function assert(cond, msg) {
|
|
323
|
-
if (!cond) {
|
|
324
|
-
unreachable(msg);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
function _isValidProtocol(url) {
|
|
328
|
-
switch (url?.protocol) {
|
|
329
|
-
case "http:":
|
|
330
|
-
case "https:":
|
|
331
|
-
case "ftp:":
|
|
332
|
-
case "mailto:":
|
|
333
|
-
case "tel:":
|
|
334
|
-
return true;
|
|
335
|
-
default:
|
|
336
|
-
return false;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
|
|
340
|
-
if (!url) {
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
if (options && typeof url === "string") {
|
|
344
|
-
if (options.addDefaultProtocol && url.startsWith("www.")) {
|
|
345
|
-
const dots = url.match(/\./g);
|
|
346
|
-
if (dots?.length >= 2) {
|
|
347
|
-
url = `http://${url}`;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
if (options.tryConvertEncoding) {
|
|
351
|
-
try {
|
|
352
|
-
url = stringToUTF8String(url);
|
|
353
|
-
} catch {
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
|
|
358
|
-
return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;
|
|
359
|
-
}
|
|
360
|
-
function updateUrlHash(url, hash, allowRel = false) {
|
|
361
|
-
const res = URL.parse(url);
|
|
362
|
-
if (res) {
|
|
363
|
-
res.hash = hash;
|
|
364
|
-
return res.href;
|
|
365
|
-
}
|
|
366
|
-
if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
|
|
367
|
-
return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
|
|
368
|
-
}
|
|
369
|
-
return "";
|
|
370
|
-
}
|
|
371
|
-
function shadow(obj, prop, value, nonSerializable = false) {
|
|
372
|
-
if (false) {
|
|
373
|
-
assert(
|
|
374
|
-
prop in obj,
|
|
375
|
-
`shadow: Property "${prop && prop.toString()}" not found in object.`
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
Object.defineProperty(obj, prop, {
|
|
379
|
-
value,
|
|
380
|
-
enumerable: !nonSerializable,
|
|
381
|
-
configurable: true,
|
|
382
|
-
writable: false
|
|
21
|
+
// src/lib/polyfills.ts
|
|
22
|
+
if (!Array.prototype.at) {
|
|
23
|
+
Object.defineProperty(Array.prototype, "at", {
|
|
24
|
+
value: function at(index) {
|
|
25
|
+
return this[index >= 0 ? index : this.length + index];
|
|
26
|
+
},
|
|
27
|
+
enumerable: false
|
|
383
28
|
});
|
|
384
|
-
return value;
|
|
385
|
-
}
|
|
386
|
-
var BaseException = (function BaseExceptionClosure() {
|
|
387
|
-
function BaseException2(message, name) {
|
|
388
|
-
if (false) {
|
|
389
|
-
unreachable("Cannot initialize BaseException.");
|
|
390
|
-
}
|
|
391
|
-
this.message = message;
|
|
392
|
-
this.name = name;
|
|
393
|
-
}
|
|
394
|
-
BaseException2.prototype = new Error();
|
|
395
|
-
BaseException2.constructor = BaseException2;
|
|
396
|
-
return BaseException2;
|
|
397
|
-
})();
|
|
398
|
-
var PasswordException = class extends BaseException {
|
|
399
|
-
constructor(msg, code) {
|
|
400
|
-
super(msg, "PasswordException");
|
|
401
|
-
this.code = code;
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
var UnknownErrorException = class extends BaseException {
|
|
405
|
-
constructor(msg, details) {
|
|
406
|
-
super(msg, "UnknownErrorException");
|
|
407
|
-
this.details = details;
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
var InvalidPDFException = class extends BaseException {
|
|
411
|
-
constructor(msg) {
|
|
412
|
-
super(msg, "InvalidPDFException");
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
var ResponseException = class extends BaseException {
|
|
416
|
-
constructor(msg, status, missing) {
|
|
417
|
-
super(msg, "ResponseException");
|
|
418
|
-
this.status = status;
|
|
419
|
-
this.missing = missing;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
var FormatError = class extends BaseException {
|
|
423
|
-
constructor(msg) {
|
|
424
|
-
super(msg, "FormatError");
|
|
425
|
-
}
|
|
426
|
-
};
|
|
427
|
-
var AbortException = class extends BaseException {
|
|
428
|
-
constructor(msg) {
|
|
429
|
-
super(msg, "AbortException");
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
function bytesToString(bytes) {
|
|
433
|
-
if (typeof bytes !== "object" || bytes?.length === void 0) {
|
|
434
|
-
unreachable("Invalid argument for bytesToString");
|
|
435
|
-
}
|
|
436
|
-
const length = bytes.length;
|
|
437
|
-
const MAX_ARGUMENT_COUNT = 8192;
|
|
438
|
-
if (length < MAX_ARGUMENT_COUNT) {
|
|
439
|
-
return String.fromCharCode.apply(null, bytes);
|
|
440
|
-
}
|
|
441
|
-
const strBuf = [];
|
|
442
|
-
for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
|
|
443
|
-
const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
|
|
444
|
-
const chunk = bytes.subarray(i, chunkEnd);
|
|
445
|
-
strBuf.push(String.fromCharCode.apply(null, chunk));
|
|
446
|
-
}
|
|
447
|
-
return strBuf.join("");
|
|
448
|
-
}
|
|
449
|
-
function stringToBytes(str) {
|
|
450
|
-
if (typeof str !== "string") {
|
|
451
|
-
unreachable("Invalid argument for stringToBytes");
|
|
452
|
-
}
|
|
453
|
-
const length = str.length;
|
|
454
|
-
const bytes = new Uint8Array(length);
|
|
455
|
-
for (let i = 0; i < length; ++i) {
|
|
456
|
-
bytes[i] = str.charCodeAt(i) & 255;
|
|
457
|
-
}
|
|
458
|
-
return bytes;
|
|
459
|
-
}
|
|
460
|
-
function string32(value) {
|
|
461
|
-
if (false) {
|
|
462
|
-
assert(
|
|
463
|
-
typeof value === "number" && Math.abs(value) < 2 ** 32,
|
|
464
|
-
`string32: Unexpected input "${value}".`
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
return String.fromCharCode(
|
|
468
|
-
value >> 24 & 255,
|
|
469
|
-
value >> 16 & 255,
|
|
470
|
-
value >> 8 & 255,
|
|
471
|
-
value & 255
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
function objectSize(obj) {
|
|
475
|
-
return Object.keys(obj).length;
|
|
476
|
-
}
|
|
477
|
-
function isLittleEndian() {
|
|
478
|
-
const buffer8 = new Uint8Array(4);
|
|
479
|
-
buffer8[0] = 1;
|
|
480
|
-
const view32 = new Uint32Array(buffer8.buffer, 0, 1);
|
|
481
|
-
return view32[0] === 1;
|
|
482
|
-
}
|
|
483
|
-
function isEvalSupported() {
|
|
484
|
-
try {
|
|
485
|
-
new Function("");
|
|
486
|
-
return true;
|
|
487
|
-
} catch {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
var FeatureTest = class {
|
|
492
|
-
static get isLittleEndian() {
|
|
493
|
-
return shadow(this, "isLittleEndian", isLittleEndian());
|
|
494
|
-
}
|
|
495
|
-
static get isEvalSupported() {
|
|
496
|
-
return shadow(this, "isEvalSupported", isEvalSupported());
|
|
497
|
-
}
|
|
498
|
-
static get isOffscreenCanvasSupported() {
|
|
499
|
-
return shadow(
|
|
500
|
-
this,
|
|
501
|
-
"isOffscreenCanvasSupported",
|
|
502
|
-
typeof OffscreenCanvas !== "undefined"
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
static get isImageDecoderSupported() {
|
|
506
|
-
return shadow(
|
|
507
|
-
this,
|
|
508
|
-
"isImageDecoderSupported",
|
|
509
|
-
typeof ImageDecoder !== "undefined"
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
static get platform() {
|
|
513
|
-
const { platform, userAgent } = navigator;
|
|
514
|
-
return shadow(this, "platform", {
|
|
515
|
-
isAndroid: userAgent.includes("Android"),
|
|
516
|
-
isLinux: platform.includes("Linux"),
|
|
517
|
-
isMac: platform.includes("Mac"),
|
|
518
|
-
isWindows: platform.includes("Win"),
|
|
519
|
-
isFirefox: userAgent.includes("Firefox")
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
static get isCSSRoundSupported() {
|
|
523
|
-
return shadow(
|
|
524
|
-
this,
|
|
525
|
-
"isCSSRoundSupported",
|
|
526
|
-
globalThis.CSS?.supports?.("width: round(1.5px, 1px)")
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
var hexNumbers = Array.from(
|
|
531
|
-
Array(256).keys(),
|
|
532
|
-
(n) => n.toString(16).padStart(2, "0")
|
|
533
|
-
);
|
|
534
|
-
var _Util_static, getExtremumOnCurve_fn, getExtremum_fn;
|
|
535
|
-
var Util = class {
|
|
536
|
-
static makeHexColor(r, g, b) {
|
|
537
|
-
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
|
|
538
|
-
}
|
|
539
|
-
static domMatrixToTransform(dm) {
|
|
540
|
-
return [dm.a, dm.b, dm.c, dm.d, dm.e, dm.f];
|
|
541
|
-
}
|
|
542
|
-
// Apply a scaling matrix to some min/max values.
|
|
543
|
-
// If a scaling factor is negative then min and max must be
|
|
544
|
-
// swapped.
|
|
545
|
-
static scaleMinMax(transform, minMax) {
|
|
546
|
-
let temp;
|
|
547
|
-
if (transform[0]) {
|
|
548
|
-
if (transform[0] < 0) {
|
|
549
|
-
temp = minMax[0];
|
|
550
|
-
minMax[0] = minMax[2];
|
|
551
|
-
minMax[2] = temp;
|
|
552
|
-
}
|
|
553
|
-
minMax[0] *= transform[0];
|
|
554
|
-
minMax[2] *= transform[0];
|
|
555
|
-
if (transform[3] < 0) {
|
|
556
|
-
temp = minMax[1];
|
|
557
|
-
minMax[1] = minMax[3];
|
|
558
|
-
minMax[3] = temp;
|
|
559
|
-
}
|
|
560
|
-
minMax[1] *= transform[3];
|
|
561
|
-
minMax[3] *= transform[3];
|
|
562
|
-
} else {
|
|
563
|
-
temp = minMax[0];
|
|
564
|
-
minMax[0] = minMax[1];
|
|
565
|
-
minMax[1] = temp;
|
|
566
|
-
temp = minMax[2];
|
|
567
|
-
minMax[2] = minMax[3];
|
|
568
|
-
minMax[3] = temp;
|
|
569
|
-
if (transform[1] < 0) {
|
|
570
|
-
temp = minMax[1];
|
|
571
|
-
minMax[1] = minMax[3];
|
|
572
|
-
minMax[3] = temp;
|
|
573
|
-
}
|
|
574
|
-
minMax[1] *= transform[1];
|
|
575
|
-
minMax[3] *= transform[1];
|
|
576
|
-
if (transform[2] < 0) {
|
|
577
|
-
temp = minMax[0];
|
|
578
|
-
minMax[0] = minMax[2];
|
|
579
|
-
minMax[2] = temp;
|
|
580
|
-
}
|
|
581
|
-
minMax[0] *= transform[2];
|
|
582
|
-
minMax[2] *= transform[2];
|
|
583
|
-
}
|
|
584
|
-
minMax[0] += transform[4];
|
|
585
|
-
minMax[1] += transform[5];
|
|
586
|
-
minMax[2] += transform[4];
|
|
587
|
-
minMax[3] += transform[5];
|
|
588
|
-
}
|
|
589
|
-
// Concatenates two transformation matrices together and returns the result.
|
|
590
|
-
static transform(m1, m2) {
|
|
591
|
-
return [
|
|
592
|
-
m1[0] * m2[0] + m1[2] * m2[1],
|
|
593
|
-
m1[1] * m2[0] + m1[3] * m2[1],
|
|
594
|
-
m1[0] * m2[2] + m1[2] * m2[3],
|
|
595
|
-
m1[1] * m2[2] + m1[3] * m2[3],
|
|
596
|
-
m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
|
|
597
|
-
m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
|
|
598
|
-
];
|
|
599
|
-
}
|
|
600
|
-
// Multiplies m (an array-based transform) by md (a DOMMatrix transform).
|
|
601
|
-
static multiplyByDOMMatrix(m, md) {
|
|
602
|
-
return [
|
|
603
|
-
m[0] * md.a + m[2] * md.b,
|
|
604
|
-
m[1] * md.a + m[3] * md.b,
|
|
605
|
-
m[0] * md.c + m[2] * md.d,
|
|
606
|
-
m[1] * md.c + m[3] * md.d,
|
|
607
|
-
m[0] * md.e + m[2] * md.f + m[4],
|
|
608
|
-
m[1] * md.e + m[3] * md.f + m[5]
|
|
609
|
-
];
|
|
610
|
-
}
|
|
611
|
-
// For 2d affine transforms
|
|
612
|
-
static applyTransform(p, m, pos = 0) {
|
|
613
|
-
const p0 = p[pos];
|
|
614
|
-
const p1 = p[pos + 1];
|
|
615
|
-
p[pos] = p0 * m[0] + p1 * m[2] + m[4];
|
|
616
|
-
p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
617
|
-
}
|
|
618
|
-
static applyTransformToBezier(p, transform, pos = 0) {
|
|
619
|
-
const m0 = transform[0];
|
|
620
|
-
const m1 = transform[1];
|
|
621
|
-
const m2 = transform[2];
|
|
622
|
-
const m3 = transform[3];
|
|
623
|
-
const m4 = transform[4];
|
|
624
|
-
const m5 = transform[5];
|
|
625
|
-
for (let i = 0; i < 6; i += 2) {
|
|
626
|
-
const pI = p[pos + i];
|
|
627
|
-
const pI1 = p[pos + i + 1];
|
|
628
|
-
p[pos + i] = pI * m0 + pI1 * m2 + m4;
|
|
629
|
-
p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
static applyInverseTransform(p, m) {
|
|
633
|
-
const p0 = p[0];
|
|
634
|
-
const p1 = p[1];
|
|
635
|
-
const d = m[0] * m[3] - m[1] * m[2];
|
|
636
|
-
p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
|
|
637
|
-
p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
|
|
638
|
-
}
|
|
639
|
-
// Applies the transform to the rectangle and finds the minimum axially
|
|
640
|
-
// aligned bounding box.
|
|
641
|
-
static axialAlignedBoundingBox(rect, transform, output) {
|
|
642
|
-
const m0 = transform[0];
|
|
643
|
-
const m1 = transform[1];
|
|
644
|
-
const m2 = transform[2];
|
|
645
|
-
const m3 = transform[3];
|
|
646
|
-
const m4 = transform[4];
|
|
647
|
-
const m5 = transform[5];
|
|
648
|
-
const r0 = rect[0];
|
|
649
|
-
const r1 = rect[1];
|
|
650
|
-
const r2 = rect[2];
|
|
651
|
-
const r3 = rect[3];
|
|
652
|
-
let a0 = m0 * r0 + m4;
|
|
653
|
-
let a2 = a0;
|
|
654
|
-
let a1 = m0 * r2 + m4;
|
|
655
|
-
let a3 = a1;
|
|
656
|
-
let b0 = m3 * r1 + m5;
|
|
657
|
-
let b2 = b0;
|
|
658
|
-
let b1 = m3 * r3 + m5;
|
|
659
|
-
let b3 = b1;
|
|
660
|
-
if (m1 !== 0 || m2 !== 0) {
|
|
661
|
-
const m1r0 = m1 * r0;
|
|
662
|
-
const m1r2 = m1 * r2;
|
|
663
|
-
const m2r1 = m2 * r1;
|
|
664
|
-
const m2r3 = m2 * r3;
|
|
665
|
-
a0 += m2r1;
|
|
666
|
-
a3 += m2r1;
|
|
667
|
-
a1 += m2r3;
|
|
668
|
-
a2 += m2r3;
|
|
669
|
-
b0 += m1r0;
|
|
670
|
-
b3 += m1r0;
|
|
671
|
-
b1 += m1r2;
|
|
672
|
-
b2 += m1r2;
|
|
673
|
-
}
|
|
674
|
-
output[0] = Math.min(output[0], a0, a1, a2, a3);
|
|
675
|
-
output[1] = Math.min(output[1], b0, b1, b2, b3);
|
|
676
|
-
output[2] = Math.max(output[2], a0, a1, a2, a3);
|
|
677
|
-
output[3] = Math.max(output[3], b0, b1, b2, b3);
|
|
678
|
-
}
|
|
679
|
-
static inverseTransform(m) {
|
|
680
|
-
const d = m[0] * m[3] - m[1] * m[2];
|
|
681
|
-
return [
|
|
682
|
-
m[3] / d,
|
|
683
|
-
-m[1] / d,
|
|
684
|
-
-m[2] / d,
|
|
685
|
-
m[0] / d,
|
|
686
|
-
(m[2] * m[5] - m[4] * m[3]) / d,
|
|
687
|
-
(m[4] * m[1] - m[5] * m[0]) / d
|
|
688
|
-
];
|
|
689
|
-
}
|
|
690
|
-
// This calculation uses Singular Value Decomposition.
|
|
691
|
-
// The SVD can be represented with formula A = USV. We are interested in the
|
|
692
|
-
// matrix S here because it represents the scale values.
|
|
693
|
-
static singularValueDecompose2dScale(matrix, output) {
|
|
694
|
-
const m0 = matrix[0];
|
|
695
|
-
const m1 = matrix[1];
|
|
696
|
-
const m2 = matrix[2];
|
|
697
|
-
const m3 = matrix[3];
|
|
698
|
-
const a = m0 ** 2 + m1 ** 2;
|
|
699
|
-
const b = m0 * m2 + m1 * m3;
|
|
700
|
-
const c = m2 ** 2 + m3 ** 2;
|
|
701
|
-
const first = (a + c) / 2;
|
|
702
|
-
const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
|
|
703
|
-
output[0] = Math.sqrt(first + second || 1);
|
|
704
|
-
output[1] = Math.sqrt(first - second || 1);
|
|
705
|
-
}
|
|
706
|
-
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
|
|
707
|
-
// For coordinate systems whose origin lies in the bottom-left, this
|
|
708
|
-
// means normalization to (BL,TR) ordering. For systems with origin in the
|
|
709
|
-
// top-left, this means (TL,BR) ordering.
|
|
710
|
-
static normalizeRect(rect) {
|
|
711
|
-
const r = rect.slice(0);
|
|
712
|
-
if (rect[0] > rect[2]) {
|
|
713
|
-
r[0] = rect[2];
|
|
714
|
-
r[2] = rect[0];
|
|
715
|
-
}
|
|
716
|
-
if (rect[1] > rect[3]) {
|
|
717
|
-
r[1] = rect[3];
|
|
718
|
-
r[3] = rect[1];
|
|
719
|
-
}
|
|
720
|
-
return r;
|
|
721
|
-
}
|
|
722
|
-
// Returns a rectangle [x1, y1, x2, y2] corresponding to the
|
|
723
|
-
// intersection of rect1 and rect2. If no intersection, returns 'null'
|
|
724
|
-
// The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
|
|
725
|
-
static intersect(rect1, rect2) {
|
|
726
|
-
const xLow = Math.max(
|
|
727
|
-
Math.min(rect1[0], rect1[2]),
|
|
728
|
-
Math.min(rect2[0], rect2[2])
|
|
729
|
-
);
|
|
730
|
-
const xHigh = Math.min(
|
|
731
|
-
Math.max(rect1[0], rect1[2]),
|
|
732
|
-
Math.max(rect2[0], rect2[2])
|
|
733
|
-
);
|
|
734
|
-
if (xLow > xHigh) {
|
|
735
|
-
return null;
|
|
736
|
-
}
|
|
737
|
-
const yLow = Math.max(
|
|
738
|
-
Math.min(rect1[1], rect1[3]),
|
|
739
|
-
Math.min(rect2[1], rect2[3])
|
|
740
|
-
);
|
|
741
|
-
const yHigh = Math.min(
|
|
742
|
-
Math.max(rect1[1], rect1[3]),
|
|
743
|
-
Math.max(rect2[1], rect2[3])
|
|
744
|
-
);
|
|
745
|
-
if (yLow > yHigh) {
|
|
746
|
-
return null;
|
|
747
|
-
}
|
|
748
|
-
return [xLow, yLow, xHigh, yHigh];
|
|
749
|
-
}
|
|
750
|
-
static pointBoundingBox(x, y, minMax) {
|
|
751
|
-
minMax[0] = Math.min(minMax[0], x);
|
|
752
|
-
minMax[1] = Math.min(minMax[1], y);
|
|
753
|
-
minMax[2] = Math.max(minMax[2], x);
|
|
754
|
-
minMax[3] = Math.max(minMax[3], y);
|
|
755
|
-
}
|
|
756
|
-
static rectBoundingBox(x0, y0, x1, y1, minMax) {
|
|
757
|
-
minMax[0] = Math.min(minMax[0], x0, x1);
|
|
758
|
-
minMax[1] = Math.min(minMax[1], y0, y1);
|
|
759
|
-
minMax[2] = Math.max(minMax[2], x0, x1);
|
|
760
|
-
minMax[3] = Math.max(minMax[3], y0, y1);
|
|
761
|
-
}
|
|
762
|
-
// From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852
|
|
763
|
-
static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
|
|
764
|
-
minMax[0] = Math.min(minMax[0], x0, x3);
|
|
765
|
-
minMax[1] = Math.min(minMax[1], y0, y3);
|
|
766
|
-
minMax[2] = Math.max(minMax[2], x0, x3);
|
|
767
|
-
minMax[3] = Math.max(minMax[3], y0, y3);
|
|
768
|
-
__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);
|
|
769
|
-
__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);
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
_Util_static = new WeakSet();
|
|
773
|
-
getExtremumOnCurve_fn = function(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
|
|
774
|
-
if (t <= 0 || t >= 1) {
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
const mt = 1 - t;
|
|
778
|
-
const tt = t * t;
|
|
779
|
-
const ttt = tt * t;
|
|
780
|
-
const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
|
|
781
|
-
const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
|
|
782
|
-
minMax[0] = Math.min(minMax[0], x);
|
|
783
|
-
minMax[1] = Math.min(minMax[1], y);
|
|
784
|
-
minMax[2] = Math.max(minMax[2], x);
|
|
785
|
-
minMax[3] = Math.max(minMax[3], y);
|
|
786
|
-
};
|
|
787
|
-
getExtremum_fn = function(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
|
|
788
|
-
if (Math.abs(a) < 1e-12) {
|
|
789
|
-
if (Math.abs(b) >= 1e-12) {
|
|
790
|
-
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
|
|
791
|
-
}
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
const delta = b ** 2 - 4 * c * a;
|
|
795
|
-
if (delta < 0) {
|
|
796
|
-
return;
|
|
797
|
-
}
|
|
798
|
-
const sqrtDelta = Math.sqrt(delta);
|
|
799
|
-
const a2 = 2 * a;
|
|
800
|
-
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
|
|
801
|
-
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
|
|
802
|
-
};
|
|
803
|
-
__privateAdd(Util, _Util_static);
|
|
804
|
-
var PDFStringTranslateTable = [
|
|
805
|
-
0,
|
|
806
|
-
0,
|
|
807
|
-
0,
|
|
808
|
-
0,
|
|
809
|
-
0,
|
|
810
|
-
0,
|
|
811
|
-
0,
|
|
812
|
-
0,
|
|
813
|
-
0,
|
|
814
|
-
0,
|
|
815
|
-
0,
|
|
816
|
-
0,
|
|
817
|
-
0,
|
|
818
|
-
0,
|
|
819
|
-
0,
|
|
820
|
-
0,
|
|
821
|
-
0,
|
|
822
|
-
0,
|
|
823
|
-
0,
|
|
824
|
-
0,
|
|
825
|
-
0,
|
|
826
|
-
0,
|
|
827
|
-
0,
|
|
828
|
-
0,
|
|
829
|
-
728,
|
|
830
|
-
711,
|
|
831
|
-
710,
|
|
832
|
-
729,
|
|
833
|
-
733,
|
|
834
|
-
731,
|
|
835
|
-
730,
|
|
836
|
-
732,
|
|
837
|
-
0,
|
|
838
|
-
0,
|
|
839
|
-
0,
|
|
840
|
-
0,
|
|
841
|
-
0,
|
|
842
|
-
0,
|
|
843
|
-
0,
|
|
844
|
-
0,
|
|
845
|
-
0,
|
|
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
|
-
0,
|
|
871
|
-
0,
|
|
872
|
-
0,
|
|
873
|
-
0,
|
|
874
|
-
0,
|
|
875
|
-
0,
|
|
876
|
-
0,
|
|
877
|
-
0,
|
|
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
|
-
8226,
|
|
934
|
-
8224,
|
|
935
|
-
8225,
|
|
936
|
-
8230,
|
|
937
|
-
8212,
|
|
938
|
-
8211,
|
|
939
|
-
402,
|
|
940
|
-
8260,
|
|
941
|
-
8249,
|
|
942
|
-
8250,
|
|
943
|
-
8722,
|
|
944
|
-
8240,
|
|
945
|
-
8222,
|
|
946
|
-
8220,
|
|
947
|
-
8221,
|
|
948
|
-
8216,
|
|
949
|
-
8217,
|
|
950
|
-
8218,
|
|
951
|
-
8482,
|
|
952
|
-
64257,
|
|
953
|
-
64258,
|
|
954
|
-
321,
|
|
955
|
-
338,
|
|
956
|
-
352,
|
|
957
|
-
376,
|
|
958
|
-
381,
|
|
959
|
-
305,
|
|
960
|
-
322,
|
|
961
|
-
339,
|
|
962
|
-
353,
|
|
963
|
-
382,
|
|
964
|
-
0,
|
|
965
|
-
8364
|
|
966
|
-
];
|
|
967
|
-
function stringToPDFString(str, keepEscapeSequence = false) {
|
|
968
|
-
if (str[0] >= "\xEF") {
|
|
969
|
-
let encoding;
|
|
970
|
-
if (str[0] === "\xFE" && str[1] === "\xFF") {
|
|
971
|
-
encoding = "utf-16be";
|
|
972
|
-
if (str.length % 2 === 1) {
|
|
973
|
-
str = str.slice(0, -1);
|
|
974
|
-
}
|
|
975
|
-
} else if (str[0] === "\xFF" && str[1] === "\xFE") {
|
|
976
|
-
encoding = "utf-16le";
|
|
977
|
-
if (str.length % 2 === 1) {
|
|
978
|
-
str = str.slice(0, -1);
|
|
979
|
-
}
|
|
980
|
-
} else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
|
|
981
|
-
encoding = "utf-8";
|
|
982
|
-
}
|
|
983
|
-
if (encoding) {
|
|
984
|
-
try {
|
|
985
|
-
const decoder = new TextDecoder(encoding, { fatal: true });
|
|
986
|
-
const buffer = stringToBytes(str);
|
|
987
|
-
const decoded = decoder.decode(buffer);
|
|
988
|
-
if (keepEscapeSequence || !decoded.includes("\x1B")) {
|
|
989
|
-
return decoded;
|
|
990
|
-
}
|
|
991
|
-
return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
|
|
992
|
-
} catch (ex) {
|
|
993
|
-
warn(`stringToPDFString: "${ex}".`);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
const strBuf = [];
|
|
998
|
-
for (let i = 0, ii = str.length; i < ii; i++) {
|
|
999
|
-
const charCode = str.charCodeAt(i);
|
|
1000
|
-
if (!keepEscapeSequence && charCode === 27) {
|
|
1001
|
-
while (++i < ii && str.charCodeAt(i) !== 27) {
|
|
1002
|
-
}
|
|
1003
|
-
continue;
|
|
1004
|
-
}
|
|
1005
|
-
const code = PDFStringTranslateTable[charCode];
|
|
1006
|
-
strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
|
|
1007
|
-
}
|
|
1008
|
-
return strBuf.join("");
|
|
1009
|
-
}
|
|
1010
|
-
function stringToUTF8String(str) {
|
|
1011
|
-
return decodeURIComponent(escape(str));
|
|
1012
|
-
}
|
|
1013
|
-
function utf8StringToString(str) {
|
|
1014
|
-
return unescape(encodeURIComponent(str));
|
|
1015
|
-
}
|
|
1016
|
-
function isArrayEqual(arr1, arr2) {
|
|
1017
|
-
if (arr1.length !== arr2.length) {
|
|
1018
|
-
return false;
|
|
1019
|
-
}
|
|
1020
|
-
for (let i = 0, ii = arr1.length; i < ii; i++) {
|
|
1021
|
-
if (arr1[i] !== arr2[i]) {
|
|
1022
|
-
return false;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
return true;
|
|
1026
|
-
}
|
|
1027
|
-
function getModificationDate(date = /* @__PURE__ */ new Date()) {
|
|
1028
|
-
if (!(date instanceof Date)) {
|
|
1029
|
-
date = new Date(date);
|
|
1030
|
-
}
|
|
1031
|
-
const buffer = [
|
|
1032
|
-
date.getUTCFullYear().toString(),
|
|
1033
|
-
(date.getUTCMonth() + 1).toString().padStart(2, "0"),
|
|
1034
|
-
date.getUTCDate().toString().padStart(2, "0"),
|
|
1035
|
-
date.getUTCHours().toString().padStart(2, "0"),
|
|
1036
|
-
date.getUTCMinutes().toString().padStart(2, "0"),
|
|
1037
|
-
date.getUTCSeconds().toString().padStart(2, "0")
|
|
1038
|
-
];
|
|
1039
|
-
return buffer.join("");
|
|
1040
|
-
}
|
|
1041
|
-
var NormalizeRegex = null;
|
|
1042
|
-
var NormalizationMap = null;
|
|
1043
|
-
function normalizeUnicode(str) {
|
|
1044
|
-
if (!NormalizeRegex) {
|
|
1045
|
-
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;
|
|
1046
|
-
NormalizationMap = /* @__PURE__ */ new Map([["\uFB05", "\u017Ft"]]);
|
|
1047
|
-
}
|
|
1048
|
-
return str.replaceAll(
|
|
1049
|
-
NormalizeRegex,
|
|
1050
|
-
(_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2)
|
|
1051
|
-
);
|
|
1052
|
-
}
|
|
1053
|
-
function getUuid() {
|
|
1054
|
-
if (typeof crypto.randomUUID === "function") {
|
|
1055
|
-
return crypto.randomUUID();
|
|
1056
|
-
}
|
|
1057
|
-
const buf = new Uint8Array(32);
|
|
1058
|
-
crypto.getRandomValues(buf);
|
|
1059
|
-
return bytesToString(buf);
|
|
1060
|
-
}
|
|
1061
|
-
var AnnotationPrefix = "pdfjs_internal_id_";
|
|
1062
|
-
function _isValidExplicitDest(validRef, validName, dest) {
|
|
1063
|
-
if (!Array.isArray(dest) || dest.length < 2) {
|
|
1064
|
-
return false;
|
|
1065
|
-
}
|
|
1066
|
-
const [page, zoom, ...args] = dest;
|
|
1067
|
-
if (!validRef(page) && !Number.isInteger(page)) {
|
|
1068
|
-
return false;
|
|
1069
|
-
}
|
|
1070
|
-
if (!validName(zoom)) {
|
|
1071
|
-
return false;
|
|
1072
|
-
}
|
|
1073
|
-
const argsLen = args.length;
|
|
1074
|
-
let allowNull = true;
|
|
1075
|
-
switch (zoom.name) {
|
|
1076
|
-
case "XYZ":
|
|
1077
|
-
if (argsLen < 2 || argsLen > 3) {
|
|
1078
|
-
return false;
|
|
1079
|
-
}
|
|
1080
|
-
break;
|
|
1081
|
-
case "Fit":
|
|
1082
|
-
case "FitB":
|
|
1083
|
-
return argsLen === 0;
|
|
1084
|
-
case "FitH":
|
|
1085
|
-
case "FitBH":
|
|
1086
|
-
case "FitV":
|
|
1087
|
-
case "FitBV":
|
|
1088
|
-
if (argsLen > 1) {
|
|
1089
|
-
return false;
|
|
1090
|
-
}
|
|
1091
|
-
break;
|
|
1092
|
-
case "FitR":
|
|
1093
|
-
if (argsLen !== 4) {
|
|
1094
|
-
return false;
|
|
1095
|
-
}
|
|
1096
|
-
allowNull = false;
|
|
1097
|
-
break;
|
|
1098
|
-
default:
|
|
1099
|
-
return false;
|
|
1100
|
-
}
|
|
1101
|
-
for (const arg of args) {
|
|
1102
|
-
if (typeof arg === "number" || allowNull && arg === null) {
|
|
1103
|
-
continue;
|
|
1104
|
-
}
|
|
1105
|
-
return false;
|
|
1106
|
-
}
|
|
1107
|
-
return true;
|
|
1108
|
-
}
|
|
1109
|
-
function MathClamp(v, min, max) {
|
|
1110
|
-
return Math.min(Math.max(v, min), max);
|
|
1111
|
-
}
|
|
1112
|
-
function toHexUtil(arr) {
|
|
1113
|
-
if (Uint8Array.prototype.toHex) {
|
|
1114
|
-
return arr.toHex();
|
|
1115
|
-
}
|
|
1116
|
-
return Array.from(arr, (num) => hexNumbers[num]).join("");
|
|
1117
|
-
}
|
|
1118
|
-
function toBase64Util(arr) {
|
|
1119
|
-
if (Uint8Array.prototype.toBase64) {
|
|
1120
|
-
return arr.toBase64();
|
|
1121
|
-
}
|
|
1122
|
-
return btoa(bytesToString(arr));
|
|
1123
|
-
}
|
|
1124
|
-
function fromBase64Util(str) {
|
|
1125
|
-
if (Uint8Array.fromBase64) {
|
|
1126
|
-
return Uint8Array.fromBase64(str);
|
|
1127
|
-
}
|
|
1128
|
-
return stringToBytes(atob(str));
|
|
1129
29
|
}
|
|
1130
|
-
if (
|
|
1131
|
-
Promise.
|
|
1132
|
-
|
|
1133
|
-
|
|
30
|
+
if (!Promise.withResolvers) {
|
|
31
|
+
Promise.withResolvers = function withResolvers() {
|
|
32
|
+
let resolve;
|
|
33
|
+
let reject;
|
|
34
|
+
const promise = new this((res, rej) => {
|
|
35
|
+
resolve = res;
|
|
36
|
+
reject = rej;
|
|
1134
37
|
});
|
|
38
|
+
return {
|
|
39
|
+
resolve,
|
|
40
|
+
reject,
|
|
41
|
+
promise
|
|
42
|
+
};
|
|
1135
43
|
};
|
|
1136
44
|
}
|
|
1137
|
-
if (
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
ac.abort(s.reason);
|
|
1149
|
-
return signal;
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
for (const s of iterable) {
|
|
1153
|
-
s.addEventListener(
|
|
1154
|
-
"abort",
|
|
1155
|
-
() => {
|
|
1156
|
-
ac.abort(s.reason);
|
|
1157
|
-
},
|
|
1158
|
-
{ signal }
|
|
1159
|
-
// Automatically remove the listener.
|
|
45
|
+
if (!("try" in Promise)) {
|
|
46
|
+
Object.defineProperty(Promise, "try", {
|
|
47
|
+
value: function tryFn(fn, ...args) {
|
|
48
|
+
return new this(
|
|
49
|
+
(resolve, reject) => {
|
|
50
|
+
try {
|
|
51
|
+
resolve(fn(...args));
|
|
52
|
+
} catch (error) {
|
|
53
|
+
reject(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
1160
56
|
);
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
};
|
|
57
|
+
},
|
|
58
|
+
enumerable: false
|
|
59
|
+
});
|
|
1164
60
|
}
|
|
1165
61
|
|
|
1166
62
|
// src/pdf.js/src/shared/message_handler.js
|
|
@@ -1618,91 +514,6 @@ deleteStreamController_fn = async function(streamController, streamId) {
|
|
|
1618
514
|
delete this.streamControllers[streamId];
|
|
1619
515
|
};
|
|
1620
516
|
|
|
1621
|
-
// src/pdf.js/src/shared/scripting_utils.js
|
|
1622
|
-
function makeColorComp(n) {
|
|
1623
|
-
return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
|
|
1624
|
-
}
|
|
1625
|
-
function scaleAndClamp(x) {
|
|
1626
|
-
return Math.max(0, Math.min(255, 255 * x));
|
|
1627
|
-
}
|
|
1628
|
-
var ColorConverters = class {
|
|
1629
|
-
static CMYK_G([c, y, m, k]) {
|
|
1630
|
-
return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
|
|
1631
|
-
}
|
|
1632
|
-
static G_CMYK([g]) {
|
|
1633
|
-
return ["CMYK", 0, 0, 0, 1 - g];
|
|
1634
|
-
}
|
|
1635
|
-
static G_RGB([g]) {
|
|
1636
|
-
return ["RGB", g, g, g];
|
|
1637
|
-
}
|
|
1638
|
-
static G_rgb([g]) {
|
|
1639
|
-
g = scaleAndClamp(g);
|
|
1640
|
-
return [g, g, g];
|
|
1641
|
-
}
|
|
1642
|
-
static G_HTML([g]) {
|
|
1643
|
-
const G = makeColorComp(g);
|
|
1644
|
-
return `#${G}${G}${G}`;
|
|
1645
|
-
}
|
|
1646
|
-
static RGB_G([r, g, b]) {
|
|
1647
|
-
return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
|
|
1648
|
-
}
|
|
1649
|
-
static RGB_rgb(color) {
|
|
1650
|
-
return color.map(scaleAndClamp);
|
|
1651
|
-
}
|
|
1652
|
-
static RGB_HTML(color) {
|
|
1653
|
-
return `#${color.map(makeColorComp).join("")}`;
|
|
1654
|
-
}
|
|
1655
|
-
static T_HTML() {
|
|
1656
|
-
return "#00000000";
|
|
1657
|
-
}
|
|
1658
|
-
static T_rgb() {
|
|
1659
|
-
return [null];
|
|
1660
|
-
}
|
|
1661
|
-
static CMYK_RGB([c, y, m, k]) {
|
|
1662
|
-
return [
|
|
1663
|
-
"RGB",
|
|
1664
|
-
1 - Math.min(1, c + k),
|
|
1665
|
-
1 - Math.min(1, m + k),
|
|
1666
|
-
1 - Math.min(1, y + k)
|
|
1667
|
-
];
|
|
1668
|
-
}
|
|
1669
|
-
static CMYK_rgb([c, y, m, k]) {
|
|
1670
|
-
return [
|
|
1671
|
-
scaleAndClamp(1 - Math.min(1, c + k)),
|
|
1672
|
-
scaleAndClamp(1 - Math.min(1, m + k)),
|
|
1673
|
-
scaleAndClamp(1 - Math.min(1, y + k))
|
|
1674
|
-
];
|
|
1675
|
-
}
|
|
1676
|
-
static CMYK_HTML(components) {
|
|
1677
|
-
const rgb = this.CMYK_RGB(components).slice(1);
|
|
1678
|
-
return this.RGB_HTML(rgb);
|
|
1679
|
-
}
|
|
1680
|
-
static RGB_CMYK([r, g, b]) {
|
|
1681
|
-
const c = 1 - r;
|
|
1682
|
-
const m = 1 - g;
|
|
1683
|
-
const y = 1 - b;
|
|
1684
|
-
const k = Math.min(c, m, y);
|
|
1685
|
-
return ["CMYK", c, m, y, k];
|
|
1686
|
-
}
|
|
1687
|
-
};
|
|
1688
|
-
var DateFormats = [
|
|
1689
|
-
"m/d",
|
|
1690
|
-
"m/d/yy",
|
|
1691
|
-
"mm/dd/yy",
|
|
1692
|
-
"mm/yy",
|
|
1693
|
-
"d-mmm",
|
|
1694
|
-
"d-mmm-yy",
|
|
1695
|
-
"dd-mmm-yy",
|
|
1696
|
-
"yy-mm-dd",
|
|
1697
|
-
"mmm-yy",
|
|
1698
|
-
"mmmm-yy",
|
|
1699
|
-
"mmm d, yyyy",
|
|
1700
|
-
"mmmm d, yyyy",
|
|
1701
|
-
"m/d/yy h:MM tt",
|
|
1702
|
-
"m/d/yy HH:MM"
|
|
1703
|
-
];
|
|
1704
|
-
var TimeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
|
|
1705
|
-
|
|
1706
517
|
// src/pdf.js/src/shared/obj-bin-transform.js
|
|
1707
518
|
var _buffer, _view, _decoder, _CssFontInfo_instances, readString_fn;
|
|
1708
519
|
var _CssFontInfo = class _CssFontInfo {
|
|
@@ -1715,12 +526,12 @@ var _CssFontInfo = class _CssFontInfo {
|
|
|
1715
526
|
__privateSet(this, _view, new DataView(__privateGet(this, _buffer)));
|
|
1716
527
|
__privateSet(this, _decoder, new TextDecoder());
|
|
1717
528
|
}
|
|
1718
|
-
static write(
|
|
529
|
+
static write(info) {
|
|
1719
530
|
const encoder = new TextEncoder();
|
|
1720
531
|
const encodedStrings = {};
|
|
1721
532
|
let stringsLength = 0;
|
|
1722
533
|
for (const prop of _CssFontInfo.strings) {
|
|
1723
|
-
const encoded = encoder.encode(
|
|
534
|
+
const encoded = encoder.encode(info[prop]);
|
|
1724
535
|
encodedStrings[prop] = encoded;
|
|
1725
536
|
stringsLength += 4 + encoded.length;
|
|
1726
537
|
}
|
|
@@ -1776,27 +587,27 @@ var _SystemFontInfo = class _SystemFontInfo {
|
|
|
1776
587
|
__privateSet(this, _view2, new DataView(__privateGet(this, _buffer2)));
|
|
1777
588
|
__privateSet(this, _decoder2, new TextDecoder());
|
|
1778
589
|
}
|
|
1779
|
-
static write(
|
|
590
|
+
static write(info) {
|
|
1780
591
|
const encoder = new TextEncoder();
|
|
1781
592
|
const encodedStrings = {};
|
|
1782
593
|
let stringsLength = 0;
|
|
1783
594
|
for (const prop of _SystemFontInfo.strings) {
|
|
1784
|
-
const encoded = encoder.encode(
|
|
595
|
+
const encoded = encoder.encode(info[prop]);
|
|
1785
596
|
encodedStrings[prop] = encoded;
|
|
1786
597
|
stringsLength += 4 + encoded.length;
|
|
1787
598
|
}
|
|
1788
599
|
stringsLength += 4;
|
|
1789
600
|
let encodedStyleStyle, encodedStyleWeight, lengthEstimate = 1 + stringsLength;
|
|
1790
|
-
if (
|
|
1791
|
-
encodedStyleStyle = encoder.encode(
|
|
1792
|
-
encodedStyleWeight = encoder.encode(
|
|
601
|
+
if (info.style) {
|
|
602
|
+
encodedStyleStyle = encoder.encode(info.style.style);
|
|
603
|
+
encodedStyleWeight = encoder.encode(info.style.weight);
|
|
1793
604
|
lengthEstimate += 4 + encodedStyleStyle.length + 4 + encodedStyleWeight.length;
|
|
1794
605
|
}
|
|
1795
606
|
const buffer = new ArrayBuffer(lengthEstimate);
|
|
1796
607
|
const data = new Uint8Array(buffer);
|
|
1797
608
|
const view = new DataView(buffer);
|
|
1798
609
|
let offset = 0;
|
|
1799
|
-
view.setUint8(offset++,
|
|
610
|
+
view.setUint8(offset++, info.guessFallback ? 1 : 0);
|
|
1800
611
|
view.setUint32(offset, 0);
|
|
1801
612
|
offset += 4;
|
|
1802
613
|
stringsLength = 0;
|
|
@@ -1809,7 +620,7 @@ var _SystemFontInfo = class _SystemFontInfo {
|
|
|
1809
620
|
offset += 4 + length;
|
|
1810
621
|
}
|
|
1811
622
|
view.setUint32(offset - stringsLength - 4, stringsLength);
|
|
1812
|
-
if (
|
|
623
|
+
if (info.style) {
|
|
1813
624
|
view.setUint32(offset, encodedStyleStyle.length);
|
|
1814
625
|
data.set(encodedStyleStyle, offset + 4);
|
|
1815
626
|
offset += 4 + encodedStyleStyle.length;
|
|
@@ -2219,6 +1030,835 @@ __privateAdd(_FontInfo, _OFFSET_DEFAULT_VMETRICS, __privateGet(_FontInfo, _OFFSE
|
|
|
2219
1030
|
__privateAdd(_FontInfo, _OFFSET_STRINGS, __privateGet(_FontInfo, _OFFSET_DEFAULT_VMETRICS) + 1 + 2 * 3);
|
|
2220
1031
|
var FontInfo = _FontInfo;
|
|
2221
1032
|
|
|
1033
|
+
// src/pdf.js/src/core/bidi.js
|
|
1034
|
+
var baseTypes = [
|
|
1035
|
+
"BN",
|
|
1036
|
+
"BN",
|
|
1037
|
+
"BN",
|
|
1038
|
+
"BN",
|
|
1039
|
+
"BN",
|
|
1040
|
+
"BN",
|
|
1041
|
+
"BN",
|
|
1042
|
+
"BN",
|
|
1043
|
+
"BN",
|
|
1044
|
+
"S",
|
|
1045
|
+
"B",
|
|
1046
|
+
"S",
|
|
1047
|
+
"WS",
|
|
1048
|
+
"B",
|
|
1049
|
+
"BN",
|
|
1050
|
+
"BN",
|
|
1051
|
+
"BN",
|
|
1052
|
+
"BN",
|
|
1053
|
+
"BN",
|
|
1054
|
+
"BN",
|
|
1055
|
+
"BN",
|
|
1056
|
+
"BN",
|
|
1057
|
+
"BN",
|
|
1058
|
+
"BN",
|
|
1059
|
+
"BN",
|
|
1060
|
+
"BN",
|
|
1061
|
+
"BN",
|
|
1062
|
+
"BN",
|
|
1063
|
+
"B",
|
|
1064
|
+
"B",
|
|
1065
|
+
"B",
|
|
1066
|
+
"S",
|
|
1067
|
+
"WS",
|
|
1068
|
+
"ON",
|
|
1069
|
+
"ON",
|
|
1070
|
+
"ET",
|
|
1071
|
+
"ET",
|
|
1072
|
+
"ET",
|
|
1073
|
+
"ON",
|
|
1074
|
+
"ON",
|
|
1075
|
+
"ON",
|
|
1076
|
+
"ON",
|
|
1077
|
+
"ON",
|
|
1078
|
+
"ES",
|
|
1079
|
+
"CS",
|
|
1080
|
+
"ES",
|
|
1081
|
+
"CS",
|
|
1082
|
+
"CS",
|
|
1083
|
+
"EN",
|
|
1084
|
+
"EN",
|
|
1085
|
+
"EN",
|
|
1086
|
+
"EN",
|
|
1087
|
+
"EN",
|
|
1088
|
+
"EN",
|
|
1089
|
+
"EN",
|
|
1090
|
+
"EN",
|
|
1091
|
+
"EN",
|
|
1092
|
+
"EN",
|
|
1093
|
+
"CS",
|
|
1094
|
+
"ON",
|
|
1095
|
+
"ON",
|
|
1096
|
+
"ON",
|
|
1097
|
+
"ON",
|
|
1098
|
+
"ON",
|
|
1099
|
+
"ON",
|
|
1100
|
+
"L",
|
|
1101
|
+
"L",
|
|
1102
|
+
"L",
|
|
1103
|
+
"L",
|
|
1104
|
+
"L",
|
|
1105
|
+
"L",
|
|
1106
|
+
"L",
|
|
1107
|
+
"L",
|
|
1108
|
+
"L",
|
|
1109
|
+
"L",
|
|
1110
|
+
"L",
|
|
1111
|
+
"L",
|
|
1112
|
+
"L",
|
|
1113
|
+
"L",
|
|
1114
|
+
"L",
|
|
1115
|
+
"L",
|
|
1116
|
+
"L",
|
|
1117
|
+
"L",
|
|
1118
|
+
"L",
|
|
1119
|
+
"L",
|
|
1120
|
+
"L",
|
|
1121
|
+
"L",
|
|
1122
|
+
"L",
|
|
1123
|
+
"L",
|
|
1124
|
+
"L",
|
|
1125
|
+
"L",
|
|
1126
|
+
"ON",
|
|
1127
|
+
"ON",
|
|
1128
|
+
"ON",
|
|
1129
|
+
"ON",
|
|
1130
|
+
"ON",
|
|
1131
|
+
"ON",
|
|
1132
|
+
"L",
|
|
1133
|
+
"L",
|
|
1134
|
+
"L",
|
|
1135
|
+
"L",
|
|
1136
|
+
"L",
|
|
1137
|
+
"L",
|
|
1138
|
+
"L",
|
|
1139
|
+
"L",
|
|
1140
|
+
"L",
|
|
1141
|
+
"L",
|
|
1142
|
+
"L",
|
|
1143
|
+
"L",
|
|
1144
|
+
"L",
|
|
1145
|
+
"L",
|
|
1146
|
+
"L",
|
|
1147
|
+
"L",
|
|
1148
|
+
"L",
|
|
1149
|
+
"L",
|
|
1150
|
+
"L",
|
|
1151
|
+
"L",
|
|
1152
|
+
"L",
|
|
1153
|
+
"L",
|
|
1154
|
+
"L",
|
|
1155
|
+
"L",
|
|
1156
|
+
"L",
|
|
1157
|
+
"L",
|
|
1158
|
+
"ON",
|
|
1159
|
+
"ON",
|
|
1160
|
+
"ON",
|
|
1161
|
+
"ON",
|
|
1162
|
+
"BN",
|
|
1163
|
+
"BN",
|
|
1164
|
+
"BN",
|
|
1165
|
+
"BN",
|
|
1166
|
+
"BN",
|
|
1167
|
+
"BN",
|
|
1168
|
+
"B",
|
|
1169
|
+
"BN",
|
|
1170
|
+
"BN",
|
|
1171
|
+
"BN",
|
|
1172
|
+
"BN",
|
|
1173
|
+
"BN",
|
|
1174
|
+
"BN",
|
|
1175
|
+
"BN",
|
|
1176
|
+
"BN",
|
|
1177
|
+
"BN",
|
|
1178
|
+
"BN",
|
|
1179
|
+
"BN",
|
|
1180
|
+
"BN",
|
|
1181
|
+
"BN",
|
|
1182
|
+
"BN",
|
|
1183
|
+
"BN",
|
|
1184
|
+
"BN",
|
|
1185
|
+
"BN",
|
|
1186
|
+
"BN",
|
|
1187
|
+
"BN",
|
|
1188
|
+
"BN",
|
|
1189
|
+
"BN",
|
|
1190
|
+
"BN",
|
|
1191
|
+
"BN",
|
|
1192
|
+
"BN",
|
|
1193
|
+
"BN",
|
|
1194
|
+
"BN",
|
|
1195
|
+
"CS",
|
|
1196
|
+
"ON",
|
|
1197
|
+
"ET",
|
|
1198
|
+
"ET",
|
|
1199
|
+
"ET",
|
|
1200
|
+
"ET",
|
|
1201
|
+
"ON",
|
|
1202
|
+
"ON",
|
|
1203
|
+
"ON",
|
|
1204
|
+
"ON",
|
|
1205
|
+
"L",
|
|
1206
|
+
"ON",
|
|
1207
|
+
"ON",
|
|
1208
|
+
"BN",
|
|
1209
|
+
"ON",
|
|
1210
|
+
"ON",
|
|
1211
|
+
"ET",
|
|
1212
|
+
"ET",
|
|
1213
|
+
"EN",
|
|
1214
|
+
"EN",
|
|
1215
|
+
"ON",
|
|
1216
|
+
"L",
|
|
1217
|
+
"ON",
|
|
1218
|
+
"ON",
|
|
1219
|
+
"ON",
|
|
1220
|
+
"EN",
|
|
1221
|
+
"L",
|
|
1222
|
+
"ON",
|
|
1223
|
+
"ON",
|
|
1224
|
+
"ON",
|
|
1225
|
+
"ON",
|
|
1226
|
+
"ON",
|
|
1227
|
+
"L",
|
|
1228
|
+
"L",
|
|
1229
|
+
"L",
|
|
1230
|
+
"L",
|
|
1231
|
+
"L",
|
|
1232
|
+
"L",
|
|
1233
|
+
"L",
|
|
1234
|
+
"L",
|
|
1235
|
+
"L",
|
|
1236
|
+
"L",
|
|
1237
|
+
"L",
|
|
1238
|
+
"L",
|
|
1239
|
+
"L",
|
|
1240
|
+
"L",
|
|
1241
|
+
"L",
|
|
1242
|
+
"L",
|
|
1243
|
+
"L",
|
|
1244
|
+
"L",
|
|
1245
|
+
"L",
|
|
1246
|
+
"L",
|
|
1247
|
+
"L",
|
|
1248
|
+
"L",
|
|
1249
|
+
"L",
|
|
1250
|
+
"ON",
|
|
1251
|
+
"L",
|
|
1252
|
+
"L",
|
|
1253
|
+
"L",
|
|
1254
|
+
"L",
|
|
1255
|
+
"L",
|
|
1256
|
+
"L",
|
|
1257
|
+
"L",
|
|
1258
|
+
"L",
|
|
1259
|
+
"L",
|
|
1260
|
+
"L",
|
|
1261
|
+
"L",
|
|
1262
|
+
"L",
|
|
1263
|
+
"L",
|
|
1264
|
+
"L",
|
|
1265
|
+
"L",
|
|
1266
|
+
"L",
|
|
1267
|
+
"L",
|
|
1268
|
+
"L",
|
|
1269
|
+
"L",
|
|
1270
|
+
"L",
|
|
1271
|
+
"L",
|
|
1272
|
+
"L",
|
|
1273
|
+
"L",
|
|
1274
|
+
"L",
|
|
1275
|
+
"L",
|
|
1276
|
+
"L",
|
|
1277
|
+
"L",
|
|
1278
|
+
"L",
|
|
1279
|
+
"L",
|
|
1280
|
+
"L",
|
|
1281
|
+
"L",
|
|
1282
|
+
"ON",
|
|
1283
|
+
"L",
|
|
1284
|
+
"L",
|
|
1285
|
+
"L",
|
|
1286
|
+
"L",
|
|
1287
|
+
"L",
|
|
1288
|
+
"L",
|
|
1289
|
+
"L",
|
|
1290
|
+
"L"
|
|
1291
|
+
];
|
|
1292
|
+
var arabicTypes = [
|
|
1293
|
+
"AN",
|
|
1294
|
+
"AN",
|
|
1295
|
+
"AN",
|
|
1296
|
+
"AN",
|
|
1297
|
+
"AN",
|
|
1298
|
+
"AN",
|
|
1299
|
+
"ON",
|
|
1300
|
+
"ON",
|
|
1301
|
+
"AL",
|
|
1302
|
+
"ET",
|
|
1303
|
+
"ET",
|
|
1304
|
+
"AL",
|
|
1305
|
+
"CS",
|
|
1306
|
+
"AL",
|
|
1307
|
+
"ON",
|
|
1308
|
+
"ON",
|
|
1309
|
+
"NSM",
|
|
1310
|
+
"NSM",
|
|
1311
|
+
"NSM",
|
|
1312
|
+
"NSM",
|
|
1313
|
+
"NSM",
|
|
1314
|
+
"NSM",
|
|
1315
|
+
"NSM",
|
|
1316
|
+
"NSM",
|
|
1317
|
+
"NSM",
|
|
1318
|
+
"NSM",
|
|
1319
|
+
"NSM",
|
|
1320
|
+
"AL",
|
|
1321
|
+
"AL",
|
|
1322
|
+
"",
|
|
1323
|
+
"AL",
|
|
1324
|
+
"AL",
|
|
1325
|
+
"AL",
|
|
1326
|
+
"AL",
|
|
1327
|
+
"AL",
|
|
1328
|
+
"AL",
|
|
1329
|
+
"AL",
|
|
1330
|
+
"AL",
|
|
1331
|
+
"AL",
|
|
1332
|
+
"AL",
|
|
1333
|
+
"AL",
|
|
1334
|
+
"AL",
|
|
1335
|
+
"AL",
|
|
1336
|
+
"AL",
|
|
1337
|
+
"AL",
|
|
1338
|
+
"AL",
|
|
1339
|
+
"AL",
|
|
1340
|
+
"AL",
|
|
1341
|
+
"AL",
|
|
1342
|
+
"AL",
|
|
1343
|
+
"AL",
|
|
1344
|
+
"AL",
|
|
1345
|
+
"AL",
|
|
1346
|
+
"AL",
|
|
1347
|
+
"AL",
|
|
1348
|
+
"AL",
|
|
1349
|
+
"AL",
|
|
1350
|
+
"AL",
|
|
1351
|
+
"AL",
|
|
1352
|
+
"AL",
|
|
1353
|
+
"AL",
|
|
1354
|
+
"AL",
|
|
1355
|
+
"AL",
|
|
1356
|
+
"AL",
|
|
1357
|
+
"AL",
|
|
1358
|
+
"AL",
|
|
1359
|
+
"AL",
|
|
1360
|
+
"AL",
|
|
1361
|
+
"AL",
|
|
1362
|
+
"AL",
|
|
1363
|
+
"AL",
|
|
1364
|
+
"AL",
|
|
1365
|
+
"AL",
|
|
1366
|
+
"AL",
|
|
1367
|
+
"AL",
|
|
1368
|
+
"NSM",
|
|
1369
|
+
"NSM",
|
|
1370
|
+
"NSM",
|
|
1371
|
+
"NSM",
|
|
1372
|
+
"NSM",
|
|
1373
|
+
"NSM",
|
|
1374
|
+
"NSM",
|
|
1375
|
+
"NSM",
|
|
1376
|
+
"NSM",
|
|
1377
|
+
"NSM",
|
|
1378
|
+
"NSM",
|
|
1379
|
+
"NSM",
|
|
1380
|
+
"NSM",
|
|
1381
|
+
"NSM",
|
|
1382
|
+
"NSM",
|
|
1383
|
+
"NSM",
|
|
1384
|
+
"NSM",
|
|
1385
|
+
"NSM",
|
|
1386
|
+
"NSM",
|
|
1387
|
+
"NSM",
|
|
1388
|
+
"NSM",
|
|
1389
|
+
"AN",
|
|
1390
|
+
"AN",
|
|
1391
|
+
"AN",
|
|
1392
|
+
"AN",
|
|
1393
|
+
"AN",
|
|
1394
|
+
"AN",
|
|
1395
|
+
"AN",
|
|
1396
|
+
"AN",
|
|
1397
|
+
"AN",
|
|
1398
|
+
"AN",
|
|
1399
|
+
"ET",
|
|
1400
|
+
"AN",
|
|
1401
|
+
"AN",
|
|
1402
|
+
"AL",
|
|
1403
|
+
"AL",
|
|
1404
|
+
"AL",
|
|
1405
|
+
"NSM",
|
|
1406
|
+
"AL",
|
|
1407
|
+
"AL",
|
|
1408
|
+
"AL",
|
|
1409
|
+
"AL",
|
|
1410
|
+
"AL",
|
|
1411
|
+
"AL",
|
|
1412
|
+
"AL",
|
|
1413
|
+
"AL",
|
|
1414
|
+
"AL",
|
|
1415
|
+
"AL",
|
|
1416
|
+
"AL",
|
|
1417
|
+
"AL",
|
|
1418
|
+
"AL",
|
|
1419
|
+
"AL",
|
|
1420
|
+
"AL",
|
|
1421
|
+
"AL",
|
|
1422
|
+
"AL",
|
|
1423
|
+
"AL",
|
|
1424
|
+
"AL",
|
|
1425
|
+
"AL",
|
|
1426
|
+
"AL",
|
|
1427
|
+
"AL",
|
|
1428
|
+
"AL",
|
|
1429
|
+
"AL",
|
|
1430
|
+
"AL",
|
|
1431
|
+
"AL",
|
|
1432
|
+
"AL",
|
|
1433
|
+
"AL",
|
|
1434
|
+
"AL",
|
|
1435
|
+
"AL",
|
|
1436
|
+
"AL",
|
|
1437
|
+
"AL",
|
|
1438
|
+
"AL",
|
|
1439
|
+
"AL",
|
|
1440
|
+
"AL",
|
|
1441
|
+
"AL",
|
|
1442
|
+
"AL",
|
|
1443
|
+
"AL",
|
|
1444
|
+
"AL",
|
|
1445
|
+
"AL",
|
|
1446
|
+
"AL",
|
|
1447
|
+
"AL",
|
|
1448
|
+
"AL",
|
|
1449
|
+
"AL",
|
|
1450
|
+
"AL",
|
|
1451
|
+
"AL",
|
|
1452
|
+
"AL",
|
|
1453
|
+
"AL",
|
|
1454
|
+
"AL",
|
|
1455
|
+
"AL",
|
|
1456
|
+
"AL",
|
|
1457
|
+
"AL",
|
|
1458
|
+
"AL",
|
|
1459
|
+
"AL",
|
|
1460
|
+
"AL",
|
|
1461
|
+
"AL",
|
|
1462
|
+
"AL",
|
|
1463
|
+
"AL",
|
|
1464
|
+
"AL",
|
|
1465
|
+
"AL",
|
|
1466
|
+
"AL",
|
|
1467
|
+
"AL",
|
|
1468
|
+
"AL",
|
|
1469
|
+
"AL",
|
|
1470
|
+
"AL",
|
|
1471
|
+
"AL",
|
|
1472
|
+
"AL",
|
|
1473
|
+
"AL",
|
|
1474
|
+
"AL",
|
|
1475
|
+
"AL",
|
|
1476
|
+
"AL",
|
|
1477
|
+
"AL",
|
|
1478
|
+
"AL",
|
|
1479
|
+
"AL",
|
|
1480
|
+
"AL",
|
|
1481
|
+
"AL",
|
|
1482
|
+
"AL",
|
|
1483
|
+
"AL",
|
|
1484
|
+
"AL",
|
|
1485
|
+
"AL",
|
|
1486
|
+
"AL",
|
|
1487
|
+
"AL",
|
|
1488
|
+
"AL",
|
|
1489
|
+
"AL",
|
|
1490
|
+
"AL",
|
|
1491
|
+
"AL",
|
|
1492
|
+
"AL",
|
|
1493
|
+
"AL",
|
|
1494
|
+
"AL",
|
|
1495
|
+
"AL",
|
|
1496
|
+
"AL",
|
|
1497
|
+
"AL",
|
|
1498
|
+
"AL",
|
|
1499
|
+
"AL",
|
|
1500
|
+
"AL",
|
|
1501
|
+
"AL",
|
|
1502
|
+
"AL",
|
|
1503
|
+
"AL",
|
|
1504
|
+
"AL",
|
|
1505
|
+
"AL",
|
|
1506
|
+
"AL",
|
|
1507
|
+
"NSM",
|
|
1508
|
+
"NSM",
|
|
1509
|
+
"NSM",
|
|
1510
|
+
"NSM",
|
|
1511
|
+
"NSM",
|
|
1512
|
+
"NSM",
|
|
1513
|
+
"NSM",
|
|
1514
|
+
"AN",
|
|
1515
|
+
"ON",
|
|
1516
|
+
"NSM",
|
|
1517
|
+
"NSM",
|
|
1518
|
+
"NSM",
|
|
1519
|
+
"NSM",
|
|
1520
|
+
"NSM",
|
|
1521
|
+
"NSM",
|
|
1522
|
+
"AL",
|
|
1523
|
+
"AL",
|
|
1524
|
+
"NSM",
|
|
1525
|
+
"NSM",
|
|
1526
|
+
"ON",
|
|
1527
|
+
"NSM",
|
|
1528
|
+
"NSM",
|
|
1529
|
+
"NSM",
|
|
1530
|
+
"NSM",
|
|
1531
|
+
"AL",
|
|
1532
|
+
"AL",
|
|
1533
|
+
"EN",
|
|
1534
|
+
"EN",
|
|
1535
|
+
"EN",
|
|
1536
|
+
"EN",
|
|
1537
|
+
"EN",
|
|
1538
|
+
"EN",
|
|
1539
|
+
"EN",
|
|
1540
|
+
"EN",
|
|
1541
|
+
"EN",
|
|
1542
|
+
"EN",
|
|
1543
|
+
"AL",
|
|
1544
|
+
"AL",
|
|
1545
|
+
"AL",
|
|
1546
|
+
"AL",
|
|
1547
|
+
"AL",
|
|
1548
|
+
"AL"
|
|
1549
|
+
];
|
|
1550
|
+
function isOdd(i) {
|
|
1551
|
+
return (i & 1) !== 0;
|
|
1552
|
+
}
|
|
1553
|
+
function isEven(i) {
|
|
1554
|
+
return (i & 1) === 0;
|
|
1555
|
+
}
|
|
1556
|
+
function findUnequal(arr, start, value) {
|
|
1557
|
+
let j, jj;
|
|
1558
|
+
for (j = start, jj = arr.length; j < jj; ++j) {
|
|
1559
|
+
if (arr[j] !== value) {
|
|
1560
|
+
return j;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
return j;
|
|
1564
|
+
}
|
|
1565
|
+
function reverseValues(arr, start, end) {
|
|
1566
|
+
for (let i = start, j = end - 1; i < j; ++i, --j) {
|
|
1567
|
+
const temp = arr[i];
|
|
1568
|
+
arr[i] = arr[j];
|
|
1569
|
+
arr[j] = temp;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
function createBidiText(str, isLTR, vertical = false) {
|
|
1573
|
+
let dir = "ltr";
|
|
1574
|
+
if (vertical) {
|
|
1575
|
+
dir = "ttb";
|
|
1576
|
+
} else if (!isLTR) {
|
|
1577
|
+
dir = "rtl";
|
|
1578
|
+
}
|
|
1579
|
+
return { str, dir };
|
|
1580
|
+
}
|
|
1581
|
+
var chars = [];
|
|
1582
|
+
var types = [];
|
|
1583
|
+
function bidi(str, startLevel = -1, vertical = false) {
|
|
1584
|
+
let isLTR = true;
|
|
1585
|
+
const strLength = str.length;
|
|
1586
|
+
if (strLength === 0 || vertical) {
|
|
1587
|
+
return createBidiText(str, isLTR, vertical);
|
|
1588
|
+
}
|
|
1589
|
+
chars.length = strLength;
|
|
1590
|
+
types.length = strLength;
|
|
1591
|
+
let numBidi = 0;
|
|
1592
|
+
let i, ii;
|
|
1593
|
+
for (i = 0; i < strLength; ++i) {
|
|
1594
|
+
chars[i] = str.charAt(i);
|
|
1595
|
+
const charCode = str.charCodeAt(i);
|
|
1596
|
+
let charType = "L";
|
|
1597
|
+
if (charCode <= 255) {
|
|
1598
|
+
charType = baseTypes[charCode];
|
|
1599
|
+
} else if (1424 <= charCode && charCode <= 1524) {
|
|
1600
|
+
charType = "R";
|
|
1601
|
+
} else if (1536 <= charCode && charCode <= 1791) {
|
|
1602
|
+
charType = arabicTypes[charCode & 255];
|
|
1603
|
+
if (!charType) {
|
|
1604
|
+
warn("Bidi: invalid Unicode character " + charCode.toString(16));
|
|
1605
|
+
}
|
|
1606
|
+
} else if (1792 <= charCode && charCode <= 2220 || 64336 <= charCode && charCode <= 65023 || 65136 <= charCode && charCode <= 65279) {
|
|
1607
|
+
charType = "AL";
|
|
1608
|
+
}
|
|
1609
|
+
if (charType === "R" || charType === "AL" || charType === "AN") {
|
|
1610
|
+
numBidi++;
|
|
1611
|
+
}
|
|
1612
|
+
types[i] = charType;
|
|
1613
|
+
}
|
|
1614
|
+
if (numBidi === 0) {
|
|
1615
|
+
isLTR = true;
|
|
1616
|
+
return createBidiText(str, isLTR);
|
|
1617
|
+
}
|
|
1618
|
+
if (startLevel === -1) {
|
|
1619
|
+
if (numBidi / strLength < 0.3 && strLength > 4) {
|
|
1620
|
+
isLTR = true;
|
|
1621
|
+
startLevel = 0;
|
|
1622
|
+
} else {
|
|
1623
|
+
isLTR = false;
|
|
1624
|
+
startLevel = 1;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
const levels = [];
|
|
1628
|
+
for (i = 0; i < strLength; ++i) {
|
|
1629
|
+
levels[i] = startLevel;
|
|
1630
|
+
}
|
|
1631
|
+
const e = isOdd(startLevel) ? "R" : "L";
|
|
1632
|
+
const sor = e;
|
|
1633
|
+
const eor = sor;
|
|
1634
|
+
let lastType = sor;
|
|
1635
|
+
for (i = 0; i < strLength; ++i) {
|
|
1636
|
+
if (types[i] === "NSM") {
|
|
1637
|
+
types[i] = lastType;
|
|
1638
|
+
} else {
|
|
1639
|
+
lastType = types[i];
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
lastType = sor;
|
|
1643
|
+
let t;
|
|
1644
|
+
for (i = 0; i < strLength; ++i) {
|
|
1645
|
+
t = types[i];
|
|
1646
|
+
if (t === "EN") {
|
|
1647
|
+
types[i] = lastType === "AL" ? "AN" : "EN";
|
|
1648
|
+
} else if (t === "R" || t === "L" || t === "AL") {
|
|
1649
|
+
lastType = t;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
for (i = 0; i < strLength; ++i) {
|
|
1653
|
+
t = types[i];
|
|
1654
|
+
if (t === "AL") {
|
|
1655
|
+
types[i] = "R";
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
for (i = 1; i < strLength - 1; ++i) {
|
|
1659
|
+
if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
|
|
1660
|
+
types[i] = "EN";
|
|
1661
|
+
}
|
|
1662
|
+
if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
|
|
1663
|
+
types[i] = types[i - 1];
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
for (i = 0; i < strLength; ++i) {
|
|
1667
|
+
if (types[i] === "EN") {
|
|
1668
|
+
for (let j = i - 1; j >= 0; --j) {
|
|
1669
|
+
if (types[j] !== "ET") {
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1672
|
+
types[j] = "EN";
|
|
1673
|
+
}
|
|
1674
|
+
for (let j = i + 1; j < strLength; ++j) {
|
|
1675
|
+
if (types[j] !== "ET") {
|
|
1676
|
+
break;
|
|
1677
|
+
}
|
|
1678
|
+
types[j] = "EN";
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
for (i = 0; i < strLength; ++i) {
|
|
1683
|
+
t = types[i];
|
|
1684
|
+
if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
|
|
1685
|
+
types[i] = "ON";
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
lastType = sor;
|
|
1689
|
+
for (i = 0; i < strLength; ++i) {
|
|
1690
|
+
t = types[i];
|
|
1691
|
+
if (t === "EN") {
|
|
1692
|
+
types[i] = lastType === "L" ? "L" : "EN";
|
|
1693
|
+
} else if (t === "R" || t === "L") {
|
|
1694
|
+
lastType = t;
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
for (i = 0; i < strLength; ++i) {
|
|
1698
|
+
if (types[i] === "ON") {
|
|
1699
|
+
const end = findUnequal(types, i + 1, "ON");
|
|
1700
|
+
let before = sor;
|
|
1701
|
+
if (i > 0) {
|
|
1702
|
+
before = types[i - 1];
|
|
1703
|
+
}
|
|
1704
|
+
let after = eor;
|
|
1705
|
+
if (end + 1 < strLength) {
|
|
1706
|
+
after = types[end + 1];
|
|
1707
|
+
}
|
|
1708
|
+
if (before !== "L") {
|
|
1709
|
+
before = "R";
|
|
1710
|
+
}
|
|
1711
|
+
if (after !== "L") {
|
|
1712
|
+
after = "R";
|
|
1713
|
+
}
|
|
1714
|
+
if (before === after) {
|
|
1715
|
+
types.fill(before, i, end);
|
|
1716
|
+
}
|
|
1717
|
+
i = end - 1;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
for (i = 0; i < strLength; ++i) {
|
|
1721
|
+
if (types[i] === "ON") {
|
|
1722
|
+
types[i] = e;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
for (i = 0; i < strLength; ++i) {
|
|
1726
|
+
t = types[i];
|
|
1727
|
+
if (isEven(levels[i])) {
|
|
1728
|
+
if (t === "R") {
|
|
1729
|
+
levels[i] += 1;
|
|
1730
|
+
} else if (t === "AN" || t === "EN") {
|
|
1731
|
+
levels[i] += 2;
|
|
1732
|
+
}
|
|
1733
|
+
} else if (
|
|
1734
|
+
/* isOdd && */
|
|
1735
|
+
t === "L" || t === "AN" || t === "EN"
|
|
1736
|
+
) {
|
|
1737
|
+
levels[i] += 1;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
let highestLevel = -1;
|
|
1741
|
+
let lowestOddLevel = 99;
|
|
1742
|
+
let level;
|
|
1743
|
+
for (i = 0, ii = levels.length; i < ii; ++i) {
|
|
1744
|
+
level = levels[i];
|
|
1745
|
+
if (highestLevel < level) {
|
|
1746
|
+
highestLevel = level;
|
|
1747
|
+
}
|
|
1748
|
+
if (lowestOddLevel > level && isOdd(level)) {
|
|
1749
|
+
lowestOddLevel = level;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
for (level = highestLevel; level >= lowestOddLevel; --level) {
|
|
1753
|
+
let start = -1;
|
|
1754
|
+
for (i = 0, ii = levels.length; i < ii; ++i) {
|
|
1755
|
+
if (levels[i] < level) {
|
|
1756
|
+
if (start >= 0) {
|
|
1757
|
+
reverseValues(chars, start, i);
|
|
1758
|
+
start = -1;
|
|
1759
|
+
}
|
|
1760
|
+
} else if (start < 0) {
|
|
1761
|
+
start = i;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
if (start >= 0) {
|
|
1765
|
+
reverseValues(chars, start, levels.length);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
for (i = 0, ii = chars.length; i < ii; ++i) {
|
|
1769
|
+
const ch = chars[i];
|
|
1770
|
+
if (ch === "<" || ch === ">") {
|
|
1771
|
+
chars[i] = "";
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
return createBidiText(chars.join(""), isLTR);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
// src/pdf.js/src/shared/scripting_utils.js
|
|
1778
|
+
function makeColorComp(n) {
|
|
1779
|
+
return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
|
|
1780
|
+
}
|
|
1781
|
+
function scaleAndClamp(x) {
|
|
1782
|
+
return Math.max(0, Math.min(255, 255 * x));
|
|
1783
|
+
}
|
|
1784
|
+
var ColorConverters = class {
|
|
1785
|
+
static CMYK_G([c, y, m, k]) {
|
|
1786
|
+
return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
|
|
1787
|
+
}
|
|
1788
|
+
static G_CMYK([g]) {
|
|
1789
|
+
return ["CMYK", 0, 0, 0, 1 - g];
|
|
1790
|
+
}
|
|
1791
|
+
static G_RGB([g]) {
|
|
1792
|
+
return ["RGB", g, g, g];
|
|
1793
|
+
}
|
|
1794
|
+
static G_rgb([g]) {
|
|
1795
|
+
g = scaleAndClamp(g);
|
|
1796
|
+
return [g, g, g];
|
|
1797
|
+
}
|
|
1798
|
+
static G_HTML([g]) {
|
|
1799
|
+
const G = makeColorComp(g);
|
|
1800
|
+
return `#${G}${G}${G}`;
|
|
1801
|
+
}
|
|
1802
|
+
static RGB_G([r, g, b]) {
|
|
1803
|
+
return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
|
|
1804
|
+
}
|
|
1805
|
+
static RGB_rgb(color) {
|
|
1806
|
+
return color.map(scaleAndClamp);
|
|
1807
|
+
}
|
|
1808
|
+
static RGB_HTML(color) {
|
|
1809
|
+
return `#${color.map(makeColorComp).join("")}`;
|
|
1810
|
+
}
|
|
1811
|
+
static T_HTML() {
|
|
1812
|
+
return "#00000000";
|
|
1813
|
+
}
|
|
1814
|
+
static T_rgb() {
|
|
1815
|
+
return [null];
|
|
1816
|
+
}
|
|
1817
|
+
static CMYK_RGB([c, y, m, k]) {
|
|
1818
|
+
return [
|
|
1819
|
+
"RGB",
|
|
1820
|
+
1 - Math.min(1, c + k),
|
|
1821
|
+
1 - Math.min(1, m + k),
|
|
1822
|
+
1 - Math.min(1, y + k)
|
|
1823
|
+
];
|
|
1824
|
+
}
|
|
1825
|
+
static CMYK_rgb([c, y, m, k]) {
|
|
1826
|
+
return [
|
|
1827
|
+
scaleAndClamp(1 - Math.min(1, c + k)),
|
|
1828
|
+
scaleAndClamp(1 - Math.min(1, m + k)),
|
|
1829
|
+
scaleAndClamp(1 - Math.min(1, y + k))
|
|
1830
|
+
];
|
|
1831
|
+
}
|
|
1832
|
+
static CMYK_HTML(components) {
|
|
1833
|
+
const rgb = this.CMYK_RGB(components).slice(1);
|
|
1834
|
+
return this.RGB_HTML(rgb);
|
|
1835
|
+
}
|
|
1836
|
+
static RGB_CMYK([r, g, b]) {
|
|
1837
|
+
const c = 1 - r;
|
|
1838
|
+
const m = 1 - g;
|
|
1839
|
+
const y = 1 - b;
|
|
1840
|
+
const k = Math.min(c, m, y);
|
|
1841
|
+
return ["CMYK", c, m, y, k];
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
var DateFormats = [
|
|
1845
|
+
"m/d",
|
|
1846
|
+
"m/d/yy",
|
|
1847
|
+
"mm/dd/yy",
|
|
1848
|
+
"mm/yy",
|
|
1849
|
+
"d-mmm",
|
|
1850
|
+
"d-mmm-yy",
|
|
1851
|
+
"dd-mmm-yy",
|
|
1852
|
+
"yy-mm-dd",
|
|
1853
|
+
"mmm-yy",
|
|
1854
|
+
"mmmm-yy",
|
|
1855
|
+
"mmm d, yyyy",
|
|
1856
|
+
"mmmm d, yyyy",
|
|
1857
|
+
"m/d/yy h:MM tt",
|
|
1858
|
+
"m/d/yy HH:MM"
|
|
1859
|
+
];
|
|
1860
|
+
var TimeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
|
|
1861
|
+
|
|
2222
1862
|
// src/pdf.js/src/shared/murmurhash3.js
|
|
2223
1863
|
var SEED = 3285377520;
|
|
2224
1864
|
var MASK_HIGH = 4294901760;
|
|
@@ -2411,74 +2051,15 @@ function grayToRGBA(src, dest) {
|
|
|
2411
2051
|
}
|
|
2412
2052
|
|
|
2413
2053
|
export {
|
|
2414
|
-
isNodeJS,
|
|
2415
|
-
FONT_IDENTITY_MATRIX,
|
|
2416
|
-
LINE_FACTOR,
|
|
2417
|
-
LINE_DESCENT_FACTOR,
|
|
2418
|
-
BASELINE_FACTOR,
|
|
2419
|
-
RenderingIntentFlag,
|
|
2420
|
-
AnnotationMode,
|
|
2421
|
-
AnnotationEditorPrefix,
|
|
2422
|
-
AnnotationEditorType,
|
|
2423
|
-
AnnotationEditorParamsType,
|
|
2424
|
-
PermissionFlag,
|
|
2425
|
-
TextRenderingMode,
|
|
2426
|
-
ImageKind,
|
|
2427
|
-
AnnotationType,
|
|
2428
|
-
AnnotationReplyType,
|
|
2429
|
-
AnnotationFlag,
|
|
2430
|
-
AnnotationFieldFlag,
|
|
2431
|
-
AnnotationBorderStyleType,
|
|
2432
|
-
AnnotationActionEventType,
|
|
2433
|
-
DocumentActionEventType,
|
|
2434
|
-
PageActionEventType,
|
|
2435
|
-
VerbosityLevel,
|
|
2436
|
-
OPS,
|
|
2437
|
-
DrawOPS,
|
|
2438
|
-
PasswordResponses,
|
|
2439
|
-
setVerbosityLevel,
|
|
2440
|
-
getVerbosityLevel,
|
|
2441
|
-
info,
|
|
2442
|
-
warn,
|
|
2443
|
-
unreachable,
|
|
2444
|
-
assert,
|
|
2445
|
-
createValidAbsoluteUrl,
|
|
2446
|
-
updateUrlHash,
|
|
2447
|
-
shadow,
|
|
2448
|
-
BaseException,
|
|
2449
|
-
PasswordException,
|
|
2450
|
-
InvalidPDFException,
|
|
2451
|
-
ResponseException,
|
|
2452
|
-
FormatError,
|
|
2453
|
-
AbortException,
|
|
2454
|
-
bytesToString,
|
|
2455
|
-
stringToBytes,
|
|
2456
|
-
string32,
|
|
2457
|
-
objectSize,
|
|
2458
|
-
FeatureTest,
|
|
2459
|
-
hexNumbers,
|
|
2460
|
-
Util,
|
|
2461
|
-
stringToPDFString,
|
|
2462
|
-
stringToUTF8String,
|
|
2463
|
-
utf8StringToString,
|
|
2464
|
-
isArrayEqual,
|
|
2465
|
-
getModificationDate,
|
|
2466
|
-
normalizeUnicode,
|
|
2467
|
-
getUuid,
|
|
2468
|
-
AnnotationPrefix,
|
|
2469
|
-
_isValidExplicitDest,
|
|
2470
|
-
MathClamp,
|
|
2471
|
-
toHexUtil,
|
|
2472
|
-
toBase64Util,
|
|
2473
|
-
fromBase64Util,
|
|
2474
2054
|
MurmurHash3_64,
|
|
2475
2055
|
wrapReason,
|
|
2476
2056
|
MessageHandler,
|
|
2477
|
-
ColorConverters,
|
|
2478
|
-
DateFormats,
|
|
2479
|
-
TimeFormats,
|
|
2480
2057
|
convertToRGBA,
|
|
2481
2058
|
convertBlackAndWhiteToRGBA,
|
|
2482
2059
|
grayToRGBA,
|
|
2483
|
-
FontInfo
|
|
2060
|
+
FontInfo,
|
|
2061
|
+
bidi,
|
|
2062
|
+
ColorConverters,
|
|
2063
|
+
DateFormats,
|
|
2064
|
+
TimeFormats
|
|
2484
2065
|
};
|