UNPKG

1.28 MBJavaScriptView Raw
1/**
2 * @licstart The following is the entire license notice for the
3 * Javascript code in this page
4 *
5 * Copyright 2020 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * Javascript code in this page
21 */
22
23(function webpackUniversalModuleDefinition(root, factory) {
24 if(typeof exports === 'object' && typeof module === 'object')
25 module.exports = factory();
26 else if(typeof define === 'function' && define.amd)
27 define("pdfjs-dist/build/pdf.worker", [], factory);
28 else if(typeof exports === 'object')
29 exports["pdfjs-dist/build/pdf.worker"] = factory();
30 else
31 root["pdfjs-dist/build/pdf.worker"] = root.pdfjsWorker = factory();
32})(this, function() {
33return /******/ (function(modules) { // webpackBootstrap
34/******/ // The module cache
35/******/ var installedModules = {};
36/******/
37/******/ // The require function
38/******/ function __w_pdfjs_require__(moduleId) {
39/******/
40/******/ // Check if module is in cache
41/******/ if(installedModules[moduleId]) {
42/******/ return installedModules[moduleId].exports;
43/******/ }
44/******/ // Create a new module (and put it into the cache)
45/******/ var module = installedModules[moduleId] = {
46/******/ i: moduleId,
47/******/ l: false,
48/******/ exports: {}
49/******/ };
50/******/
51/******/ // Execute the module function
52/******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
53/******/
54/******/ // Flag the module as loaded
55/******/ module.l = true;
56/******/
57/******/ // Return the exports of the module
58/******/ return module.exports;
59/******/ }
60/******/
61/******/
62/******/ // expose the modules object (__webpack_modules__)
63/******/ __w_pdfjs_require__.m = modules;
64/******/
65/******/ // expose the module cache
66/******/ __w_pdfjs_require__.c = installedModules;
67/******/
68/******/ // define getter function for harmony exports
69/******/ __w_pdfjs_require__.d = function(exports, name, getter) {
70/******/ if(!__w_pdfjs_require__.o(exports, name)) {
71/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
72/******/ }
73/******/ };
74/******/
75/******/ // define __esModule on exports
76/******/ __w_pdfjs_require__.r = function(exports) {
77/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
78/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
79/******/ }
80/******/ Object.defineProperty(exports, '__esModule', { value: true });
81/******/ };
82/******/
83/******/ // create a fake namespace object
84/******/ // mode & 1: value is a module id, require it
85/******/ // mode & 2: merge all properties of value into the ns
86/******/ // mode & 4: return value when already ns object
87/******/ // mode & 8|1: behave like require
88/******/ __w_pdfjs_require__.t = function(value, mode) {
89/******/ if(mode & 1) value = __w_pdfjs_require__(value);
90/******/ if(mode & 8) return value;
91/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
92/******/ var ns = Object.create(null);
93/******/ __w_pdfjs_require__.r(ns);
94/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
95/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
96/******/ return ns;
97/******/ };
98/******/
99/******/ // getDefaultExport function for compatibility with non-harmony modules
100/******/ __w_pdfjs_require__.n = function(module) {
101/******/ var getter = module && module.__esModule ?
102/******/ function getDefault() { return module['default']; } :
103/******/ function getModuleExports() { return module; };
104/******/ __w_pdfjs_require__.d(getter, 'a', getter);
105/******/ return getter;
106/******/ };
107/******/
108/******/ // Object.prototype.hasOwnProperty.call
109/******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
110/******/
111/******/ // __webpack_public_path__
112/******/ __w_pdfjs_require__.p = "";
113/******/
114/******/
115/******/ // Load entry module and return exports
116/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
117/******/ })
118/************************************************************************/
119/******/ ([
120/* 0 */
121/***/ (function(module, exports, __w_pdfjs_require__) {
122
123"use strict";
124
125
126Object.defineProperty(exports, "__esModule", {
127 value: true
128});
129Object.defineProperty(exports, "WorkerMessageHandler", {
130 enumerable: true,
131 get: function () {
132 return _worker.WorkerMessageHandler;
133 }
134});
135
136var _worker = __w_pdfjs_require__(1);
137
138const pdfjsVersion = '2.5.207';
139const pdfjsBuild = '0974d605';
140
141/***/ }),
142/* 1 */
143/***/ (function(module, exports, __w_pdfjs_require__) {
144
145"use strict";
146
147
148Object.defineProperty(exports, "__esModule", {
149 value: true
150});
151exports.WorkerMessageHandler = exports.WorkerTask = void 0;
152
153var _util = __w_pdfjs_require__(2);
154
155var _primitives = __w_pdfjs_require__(5);
156
157var _pdf_manager = __w_pdfjs_require__(6);
158
159var _is_node = __w_pdfjs_require__(4);
160
161var _message_handler = __w_pdfjs_require__(45);
162
163var _worker_stream = __w_pdfjs_require__(46);
164
165var _core_utils = __w_pdfjs_require__(8);
166
167var WorkerTask = function WorkerTaskClosure() {
168 function WorkerTask(name) {
169 this.name = name;
170 this.terminated = false;
171 this._capability = (0, _util.createPromiseCapability)();
172 }
173
174 WorkerTask.prototype = {
175 get finished() {
176 return this._capability.promise;
177 },
178
179 finish() {
180 this._capability.resolve();
181 },
182
183 terminate() {
184 this.terminated = true;
185 },
186
187 ensureNotTerminated() {
188 if (this.terminated) {
189 throw new Error("Worker task was terminated");
190 }
191 }
192
193 };
194 return WorkerTask;
195}();
196
197exports.WorkerTask = WorkerTask;
198var WorkerMessageHandler = {
199 setup(handler, port) {
200 var testMessageProcessed = false;
201 handler.on("test", function wphSetupTest(data) {
202 if (testMessageProcessed) {
203 return;
204 }
205
206 testMessageProcessed = true;
207
208 if (!(data instanceof Uint8Array)) {
209 handler.send("test", null);
210 return;
211 }
212
213 const supportTransfers = data[0] === 255;
214 handler.postMessageTransfers = supportTransfers;
215 handler.send("test", {
216 supportTransfers
217 });
218 });
219 handler.on("configure", function wphConfigure(data) {
220 (0, _util.setVerbosityLevel)(data.verbosity);
221 });
222 handler.on("GetDocRequest", function wphSetupDoc(data) {
223 return WorkerMessageHandler.createDocumentHandler(data, port);
224 });
225 },
226
227 createDocumentHandler(docParams, port) {
228 var pdfManager;
229 var terminated = false;
230 var cancelXHRs = null;
231 var WorkerTasks = [];
232 const verbosity = (0, _util.getVerbosityLevel)();
233 const apiVersion = docParams.apiVersion;
234 const workerVersion = '2.5.207';
235
236 if (apiVersion !== workerVersion) {
237 throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
238 }
239
240 const enumerableProperties = [];
241
242 for (const property in []) {
243 enumerableProperties.push(property);
244 }
245
246 if (enumerableProperties.length) {
247 throw new Error("The `Array.prototype` contains unexpected enumerable properties: " + enumerableProperties.join(", ") + "; thus breaking e.g. `for...in` iteration of `Array`s.");
248 }
249
250 if (typeof ReadableStream === "undefined" || typeof Promise.allSettled === "undefined") {
251 throw new Error("The browser/environment lacks native support for critical " + "functionality used by the PDF.js library (e.g. " + "`ReadableStream` and/or `Promise.allSettled`); " + "please use an ES5-compatible build instead.");
252 }
253
254 var docId = docParams.docId;
255 var docBaseUrl = docParams.docBaseUrl;
256 var workerHandlerName = docParams.docId + "_worker";
257 var handler = new _message_handler.MessageHandler(workerHandlerName, docId, port);
258 handler.postMessageTransfers = docParams.postMessageTransfers;
259
260 function ensureNotTerminated() {
261 if (terminated) {
262 throw new Error("Worker was terminated");
263 }
264 }
265
266 function startWorkerTask(task) {
267 WorkerTasks.push(task);
268 }
269
270 function finishWorkerTask(task) {
271 task.finish();
272 var i = WorkerTasks.indexOf(task);
273 WorkerTasks.splice(i, 1);
274 }
275
276 async function loadDocument(recoveryMode) {
277 await pdfManager.ensureDoc("checkHeader");
278 await pdfManager.ensureDoc("parseStartXRef");
279 await pdfManager.ensureDoc("parse", [recoveryMode]);
280
281 if (!recoveryMode) {
282 await pdfManager.ensureDoc("checkFirstPage");
283 }
284
285 const [numPages, fingerprint] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprint")]);
286 return {
287 numPages,
288 fingerprint
289 };
290 }
291
292 function getPdfManager(data, evaluatorOptions) {
293 var pdfManagerCapability = (0, _util.createPromiseCapability)();
294 let newPdfManager;
295 var source = data.source;
296
297 if (source.data) {
298 try {
299 newPdfManager = new _pdf_manager.LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
300 pdfManagerCapability.resolve(newPdfManager);
301 } catch (ex) {
302 pdfManagerCapability.reject(ex);
303 }
304
305 return pdfManagerCapability.promise;
306 }
307
308 var pdfStream,
309 cachedChunks = [];
310
311 try {
312 pdfStream = new _worker_stream.PDFWorkerStream(handler);
313 } catch (ex) {
314 pdfManagerCapability.reject(ex);
315 return pdfManagerCapability.promise;
316 }
317
318 var fullRequest = pdfStream.getFullReader();
319 fullRequest.headersReady.then(function () {
320 if (!fullRequest.isRangeSupported) {
321 return;
322 }
323
324 var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
325 newPdfManager = new _pdf_manager.NetworkPdfManager(docId, pdfStream, {
326 msgHandler: handler,
327 password: source.password,
328 length: fullRequest.contentLength,
329 disableAutoFetch,
330 rangeChunkSize: source.rangeChunkSize
331 }, evaluatorOptions, docBaseUrl);
332
333 for (let i = 0; i < cachedChunks.length; i++) {
334 newPdfManager.sendProgressiveData(cachedChunks[i]);
335 }
336
337 cachedChunks = [];
338 pdfManagerCapability.resolve(newPdfManager);
339 cancelXHRs = null;
340 }).catch(function (reason) {
341 pdfManagerCapability.reject(reason);
342 cancelXHRs = null;
343 });
344 var loaded = 0;
345
346 var flushChunks = function () {
347 var pdfFile = (0, _util.arraysToBytes)(cachedChunks);
348
349 if (source.length && pdfFile.length !== source.length) {
350 (0, _util.warn)("reported HTTP length is different from actual");
351 }
352
353 try {
354 newPdfManager = new _pdf_manager.LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
355 pdfManagerCapability.resolve(newPdfManager);
356 } catch (ex) {
357 pdfManagerCapability.reject(ex);
358 }
359
360 cachedChunks = [];
361 };
362
363 var readPromise = new Promise(function (resolve, reject) {
364 var readChunk = function ({
365 value,
366 done
367 }) {
368 try {
369 ensureNotTerminated();
370
371 if (done) {
372 if (!newPdfManager) {
373 flushChunks();
374 }
375
376 cancelXHRs = null;
377 return;
378 }
379
380 loaded += (0, _util.arrayByteLength)(value);
381
382 if (!fullRequest.isStreamingSupported) {
383 handler.send("DocProgress", {
384 loaded,
385 total: Math.max(loaded, fullRequest.contentLength || 0)
386 });
387 }
388
389 if (newPdfManager) {
390 newPdfManager.sendProgressiveData(value);
391 } else {
392 cachedChunks.push(value);
393 }
394
395 fullRequest.read().then(readChunk, reject);
396 } catch (e) {
397 reject(e);
398 }
399 };
400
401 fullRequest.read().then(readChunk, reject);
402 });
403 readPromise.catch(function (e) {
404 pdfManagerCapability.reject(e);
405 cancelXHRs = null;
406 });
407
408 cancelXHRs = function (reason) {
409 pdfStream.cancelAllRequests(reason);
410 };
411
412 return pdfManagerCapability.promise;
413 }
414
415 function setupDoc(data) {
416 function onSuccess(doc) {
417 ensureNotTerminated();
418 handler.send("GetDoc", {
419 pdfInfo: doc
420 });
421 }
422
423 function onFailure(ex) {
424 ensureNotTerminated();
425
426 if (ex instanceof _util.PasswordException) {
427 var task = new WorkerTask(`PasswordException: response ${ex.code}`);
428 startWorkerTask(task);
429 handler.sendWithPromise("PasswordRequest", ex).then(function ({
430 password
431 }) {
432 finishWorkerTask(task);
433 pdfManager.updatePassword(password);
434 pdfManagerReady();
435 }).catch(function () {
436 finishWorkerTask(task);
437 handler.send("DocException", ex);
438 });
439 } else if (ex instanceof _util.InvalidPDFException || ex instanceof _util.MissingPDFException || ex instanceof _util.UnexpectedResponseException || ex instanceof _util.UnknownErrorException) {
440 handler.send("DocException", ex);
441 } else {
442 handler.send("DocException", new _util.UnknownErrorException(ex.message, ex.toString()));
443 }
444 }
445
446 function pdfManagerReady() {
447 ensureNotTerminated();
448 loadDocument(false).then(onSuccess, function loadFailure(ex) {
449 ensureNotTerminated();
450
451 if (!(ex instanceof _core_utils.XRefParseException)) {
452 onFailure(ex);
453 return;
454 }
455
456 pdfManager.requestLoadedStream();
457 pdfManager.onLoadedStream().then(function () {
458 ensureNotTerminated();
459 loadDocument(true).then(onSuccess, onFailure);
460 });
461 }, onFailure);
462 }
463
464 ensureNotTerminated();
465 var evaluatorOptions = {
466 maxImageSize: data.maxImageSize,
467 disableFontFace: data.disableFontFace,
468 ignoreErrors: data.ignoreErrors,
469 isEvalSupported: data.isEvalSupported,
470 fontExtraProperties: data.fontExtraProperties
471 };
472 getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
473 if (terminated) {
474 newPdfManager.terminate(new _util.AbortException("Worker was terminated."));
475 throw new Error("Worker was terminated");
476 }
477
478 pdfManager = newPdfManager;
479 pdfManager.onLoadedStream().then(function (stream) {
480 handler.send("DataLoaded", {
481 length: stream.bytes.byteLength
482 });
483 });
484 }).then(pdfManagerReady, onFailure);
485 }
486
487 handler.on("GetPage", function wphSetupGetPage(data) {
488 return pdfManager.getPage(data.pageIndex).then(function (page) {
489 return Promise.all([pdfManager.ensure(page, "rotate"), pdfManager.ensure(page, "ref"), pdfManager.ensure(page, "userUnit"), pdfManager.ensure(page, "view")]).then(function ([rotate, ref, userUnit, view]) {
490 return {
491 rotate,
492 ref,
493 userUnit,
494 view
495 };
496 });
497 });
498 });
499 handler.on("GetPageIndex", function wphSetupGetPageIndex(data) {
500 var ref = _primitives.Ref.get(data.ref.num, data.ref.gen);
501
502 var catalog = pdfManager.pdfDocument.catalog;
503 return catalog.getPageIndex(ref);
504 });
505 handler.on("GetDestinations", function wphSetupGetDestinations(data) {
506 return pdfManager.ensureCatalog("destinations");
507 });
508 handler.on("GetDestination", function wphSetupGetDestination(data) {
509 return pdfManager.ensureCatalog("getDestination", [data.id]);
510 });
511 handler.on("GetPageLabels", function wphSetupGetPageLabels(data) {
512 return pdfManager.ensureCatalog("pageLabels");
513 });
514 handler.on("GetPageLayout", function wphSetupGetPageLayout(data) {
515 return pdfManager.ensureCatalog("pageLayout");
516 });
517 handler.on("GetPageMode", function wphSetupGetPageMode(data) {
518 return pdfManager.ensureCatalog("pageMode");
519 });
520 handler.on("GetViewerPreferences", function (data) {
521 return pdfManager.ensureCatalog("viewerPreferences");
522 });
523 handler.on("GetOpenAction", function (data) {
524 return pdfManager.ensureCatalog("openAction");
525 });
526 handler.on("GetAttachments", function wphSetupGetAttachments(data) {
527 return pdfManager.ensureCatalog("attachments");
528 });
529 handler.on("GetJavaScript", function wphSetupGetJavaScript(data) {
530 return pdfManager.ensureCatalog("javaScript");
531 });
532 handler.on("GetOutline", function wphSetupGetOutline(data) {
533 return pdfManager.ensureCatalog("documentOutline");
534 });
535 handler.on("GetPermissions", function (data) {
536 return pdfManager.ensureCatalog("permissions");
537 });
538 handler.on("GetMetadata", function wphSetupGetMetadata(data) {
539 return Promise.all([pdfManager.ensureDoc("documentInfo"), pdfManager.ensureCatalog("metadata")]);
540 });
541 handler.on("GetData", function wphSetupGetData(data) {
542 pdfManager.requestLoadedStream();
543 return pdfManager.onLoadedStream().then(function (stream) {
544 return stream.bytes;
545 });
546 });
547 handler.on("GetStats", function wphSetupGetStats(data) {
548 return pdfManager.pdfDocument.xref.stats;
549 });
550 handler.on("GetAnnotations", function ({
551 pageIndex,
552 intent
553 }) {
554 return pdfManager.getPage(pageIndex).then(function (page) {
555 return page.getAnnotationsData(intent);
556 });
557 });
558 handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) {
559 var pageIndex = data.pageIndex;
560 pdfManager.getPage(pageIndex).then(function (page) {
561 var task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
562 startWorkerTask(task);
563 const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
564 page.getOperatorList({
565 handler,
566 sink,
567 task,
568 intent: data.intent,
569 renderInteractiveForms: data.renderInteractiveForms
570 }).then(function (operatorListInfo) {
571 finishWorkerTask(task);
572
573 if (start) {
574 (0, _util.info)(`page=${pageIndex + 1} - getOperatorList: time=` + `${Date.now() - start}ms, len=${operatorListInfo.length}`);
575 }
576
577 sink.close();
578 }, function (reason) {
579 finishWorkerTask(task);
580
581 if (task.terminated) {
582 return;
583 }
584
585 handler.send("UnsupportedFeature", {
586 featureId: _util.UNSUPPORTED_FEATURES.errorOperatorList
587 });
588 sink.error(reason);
589 });
590 });
591 }, this);
592 handler.on("GetTextContent", function wphExtractText(data, sink) {
593 var pageIndex = data.pageIndex;
594
595 sink.onPull = function (desiredSize) {};
596
597 sink.onCancel = function (reason) {};
598
599 pdfManager.getPage(pageIndex).then(function (page) {
600 var task = new WorkerTask("GetTextContent: page " + pageIndex);
601 startWorkerTask(task);
602 const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
603 page.extractTextContent({
604 handler,
605 task,
606 sink,
607 normalizeWhitespace: data.normalizeWhitespace,
608 combineTextItems: data.combineTextItems
609 }).then(function () {
610 finishWorkerTask(task);
611
612 if (start) {
613 (0, _util.info)(`page=${pageIndex + 1} - getTextContent: time=` + `${Date.now() - start}ms`);
614 }
615
616 sink.close();
617 }, function (reason) {
618 finishWorkerTask(task);
619
620 if (task.terminated) {
621 return;
622 }
623
624 sink.error(reason);
625 });
626 });
627 });
628 handler.on("FontFallback", function (data) {
629 return pdfManager.fontFallback(data.id, handler);
630 });
631 handler.on("Cleanup", function wphCleanup(data) {
632 return pdfManager.cleanup(true);
633 });
634 handler.on("Terminate", function wphTerminate(data) {
635 terminated = true;
636 const waitOn = [];
637
638 if (pdfManager) {
639 pdfManager.terminate(new _util.AbortException("Worker was terminated."));
640 const cleanupPromise = pdfManager.cleanup();
641 waitOn.push(cleanupPromise);
642 pdfManager = null;
643 } else {
644 (0, _primitives.clearPrimitiveCaches)();
645 }
646
647 if (cancelXHRs) {
648 cancelXHRs(new _util.AbortException("Worker was terminated."));
649 }
650
651 WorkerTasks.forEach(function (task) {
652 waitOn.push(task.finished);
653 task.terminate();
654 });
655 return Promise.all(waitOn).then(function () {
656 handler.destroy();
657 handler = null;
658 });
659 });
660 handler.on("Ready", function wphReady(data) {
661 setupDoc(docParams);
662 docParams = null;
663 });
664 return workerHandlerName;
665 },
666
667 initializeFromPort(port) {
668 var handler = new _message_handler.MessageHandler("worker", "main", port);
669 WorkerMessageHandler.setup(handler, port);
670 handler.send("ready", null);
671 }
672
673};
674exports.WorkerMessageHandler = WorkerMessageHandler;
675
676function isMessagePort(maybePort) {
677 return typeof maybePort.postMessage === "function" && "onmessage" in maybePort;
678}
679
680if (typeof window === "undefined" && !_is_node.isNodeJS && typeof self !== "undefined" && isMessagePort(self)) {
681 WorkerMessageHandler.initializeFromPort(self);
682}
683
684/***/ }),
685/* 2 */
686/***/ (function(module, exports, __w_pdfjs_require__) {
687
688"use strict";
689
690
691Object.defineProperty(exports, "__esModule", {
692 value: true
693});
694exports.arrayByteLength = arrayByteLength;
695exports.arraysToBytes = arraysToBytes;
696exports.assert = assert;
697exports.bytesToString = bytesToString;
698exports.createPromiseCapability = createPromiseCapability;
699exports.getVerbosityLevel = getVerbosityLevel;
700exports.info = info;
701exports.isArrayBuffer = isArrayBuffer;
702exports.isArrayEqual = isArrayEqual;
703exports.isBool = isBool;
704exports.isEmptyObj = isEmptyObj;
705exports.isNum = isNum;
706exports.isString = isString;
707exports.isSameOrigin = isSameOrigin;
708exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
709exports.removeNullCharacters = removeNullCharacters;
710exports.setVerbosityLevel = setVerbosityLevel;
711exports.shadow = shadow;
712exports.string32 = string32;
713exports.stringToBytes = stringToBytes;
714exports.stringToPDFString = stringToPDFString;
715exports.stringToUTF8String = stringToUTF8String;
716exports.utf8StringToString = utf8StringToString;
717exports.warn = warn;
718exports.unreachable = unreachable;
719exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
720
721__w_pdfjs_require__(3);
722
723const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
724exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
725const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
726exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
727const PermissionFlag = {
728 PRINT: 0x04,
729 MODIFY_CONTENTS: 0x08,
730 COPY: 0x10,
731 MODIFY_ANNOTATIONS: 0x20,
732 FILL_INTERACTIVE_FORMS: 0x100,
733 COPY_FOR_ACCESSIBILITY: 0x200,
734 ASSEMBLE: 0x400,
735 PRINT_HIGH_QUALITY: 0x800
736};
737exports.PermissionFlag = PermissionFlag;
738const TextRenderingMode = {
739 FILL: 0,
740 STROKE: 1,
741 FILL_STROKE: 2,
742 INVISIBLE: 3,
743 FILL_ADD_TO_PATH: 4,
744 STROKE_ADD_TO_PATH: 5,
745 FILL_STROKE_ADD_TO_PATH: 6,
746 ADD_TO_PATH: 7,
747 FILL_STROKE_MASK: 3,
748 ADD_TO_PATH_FLAG: 4
749};
750exports.TextRenderingMode = TextRenderingMode;
751const ImageKind = {
752 GRAYSCALE_1BPP: 1,
753 RGB_24BPP: 2,
754 RGBA_32BPP: 3
755};
756exports.ImageKind = ImageKind;
757const AnnotationType = {
758 TEXT: 1,
759 LINK: 2,
760 FREETEXT: 3,
761 LINE: 4,
762 SQUARE: 5,
763 CIRCLE: 6,
764 POLYGON: 7,
765 POLYLINE: 8,
766 HIGHLIGHT: 9,
767 UNDERLINE: 10,
768 SQUIGGLY: 11,
769 STRIKEOUT: 12,
770 STAMP: 13,
771 CARET: 14,
772 INK: 15,
773 POPUP: 16,
774 FILEATTACHMENT: 17,
775 SOUND: 18,
776 MOVIE: 19,
777 WIDGET: 20,
778 SCREEN: 21,
779 PRINTERMARK: 22,
780 TRAPNET: 23,
781 WATERMARK: 24,
782 THREED: 25,
783 REDACT: 26
784};
785exports.AnnotationType = AnnotationType;
786const AnnotationStateModelType = {
787 MARKED: "Marked",
788 REVIEW: "Review"
789};
790exports.AnnotationStateModelType = AnnotationStateModelType;
791const AnnotationMarkedState = {
792 MARKED: "Marked",
793 UNMARKED: "Unmarked"
794};
795exports.AnnotationMarkedState = AnnotationMarkedState;
796const AnnotationReviewState = {
797 ACCEPTED: "Accepted",
798 REJECTED: "Rejected",
799 CANCELLED: "Cancelled",
800 COMPLETED: "Completed",
801 NONE: "None"
802};
803exports.AnnotationReviewState = AnnotationReviewState;
804const AnnotationReplyType = {
805 GROUP: "Group",
806 REPLY: "R"
807};
808exports.AnnotationReplyType = AnnotationReplyType;
809const AnnotationFlag = {
810 INVISIBLE: 0x01,
811 HIDDEN: 0x02,
812 PRINT: 0x04,
813 NOZOOM: 0x08,
814 NOROTATE: 0x10,
815 NOVIEW: 0x20,
816 READONLY: 0x40,
817 LOCKED: 0x80,
818 TOGGLENOVIEW: 0x100,
819 LOCKEDCONTENTS: 0x200
820};
821exports.AnnotationFlag = AnnotationFlag;
822const AnnotationFieldFlag = {
823 READONLY: 0x0000001,
824 REQUIRED: 0x0000002,
825 NOEXPORT: 0x0000004,
826 MULTILINE: 0x0001000,
827 PASSWORD: 0x0002000,
828 NOTOGGLETOOFF: 0x0004000,
829 RADIO: 0x0008000,
830 PUSHBUTTON: 0x0010000,
831 COMBO: 0x0020000,
832 EDIT: 0x0040000,
833 SORT: 0x0080000,
834 FILESELECT: 0x0100000,
835 MULTISELECT: 0x0200000,
836 DONOTSPELLCHECK: 0x0400000,
837 DONOTSCROLL: 0x0800000,
838 COMB: 0x1000000,
839 RICHTEXT: 0x2000000,
840 RADIOSINUNISON: 0x2000000,
841 COMMITONSELCHANGE: 0x4000000
842};
843exports.AnnotationFieldFlag = AnnotationFieldFlag;
844const AnnotationBorderStyleType = {
845 SOLID: 1,
846 DASHED: 2,
847 BEVELED: 3,
848 INSET: 4,
849 UNDERLINE: 5
850};
851exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
852const StreamType = {
853 UNKNOWN: "UNKNOWN",
854 FLATE: "FLATE",
855 LZW: "LZW",
856 DCT: "DCT",
857 JPX: "JPX",
858 JBIG: "JBIG",
859 A85: "A85",
860 AHX: "AHX",
861 CCF: "CCF",
862 RLX: "RLX"
863};
864exports.StreamType = StreamType;
865const FontType = {
866 UNKNOWN: "UNKNOWN",
867 TYPE1: "TYPE1",
868 TYPE1C: "TYPE1C",
869 CIDFONTTYPE0: "CIDFONTTYPE0",
870 CIDFONTTYPE0C: "CIDFONTTYPE0C",
871 TRUETYPE: "TRUETYPE",
872 CIDFONTTYPE2: "CIDFONTTYPE2",
873 TYPE3: "TYPE3",
874 OPENTYPE: "OPENTYPE",
875 TYPE0: "TYPE0",
876 MMTYPE1: "MMTYPE1"
877};
878exports.FontType = FontType;
879const VerbosityLevel = {
880 ERRORS: 0,
881 WARNINGS: 1,
882 INFOS: 5
883};
884exports.VerbosityLevel = VerbosityLevel;
885const CMapCompressionType = {
886 NONE: 0,
887 BINARY: 1,
888 STREAM: 2
889};
890exports.CMapCompressionType = CMapCompressionType;
891const OPS = {
892 dependency: 1,
893 setLineWidth: 2,
894 setLineCap: 3,
895 setLineJoin: 4,
896 setMiterLimit: 5,
897 setDash: 6,
898 setRenderingIntent: 7,
899 setFlatness: 8,
900 setGState: 9,
901 save: 10,
902 restore: 11,
903 transform: 12,
904 moveTo: 13,
905 lineTo: 14,
906 curveTo: 15,
907 curveTo2: 16,
908 curveTo3: 17,
909 closePath: 18,
910 rectangle: 19,
911 stroke: 20,
912 closeStroke: 21,
913 fill: 22,
914 eoFill: 23,
915 fillStroke: 24,
916 eoFillStroke: 25,
917 closeFillStroke: 26,
918 closeEOFillStroke: 27,
919 endPath: 28,
920 clip: 29,
921 eoClip: 30,
922 beginText: 31,
923 endText: 32,
924 setCharSpacing: 33,
925 setWordSpacing: 34,
926 setHScale: 35,
927 setLeading: 36,
928 setFont: 37,
929 setTextRenderingMode: 38,
930 setTextRise: 39,
931 moveText: 40,
932 setLeadingMoveText: 41,
933 setTextMatrix: 42,
934 nextLine: 43,
935 showText: 44,
936 showSpacedText: 45,
937 nextLineShowText: 46,
938 nextLineSetSpacingShowText: 47,
939 setCharWidth: 48,
940 setCharWidthAndBounds: 49,
941 setStrokeColorSpace: 50,
942 setFillColorSpace: 51,
943 setStrokeColor: 52,
944 setStrokeColorN: 53,
945 setFillColor: 54,
946 setFillColorN: 55,
947 setStrokeGray: 56,
948 setFillGray: 57,
949 setStrokeRGBColor: 58,
950 setFillRGBColor: 59,
951 setStrokeCMYKColor: 60,
952 setFillCMYKColor: 61,
953 shadingFill: 62,
954 beginInlineImage: 63,
955 beginImageData: 64,
956 endInlineImage: 65,
957 paintXObject: 66,
958 markPoint: 67,
959 markPointProps: 68,
960 beginMarkedContent: 69,
961 beginMarkedContentProps: 70,
962 endMarkedContent: 71,
963 beginCompat: 72,
964 endCompat: 73,
965 paintFormXObjectBegin: 74,
966 paintFormXObjectEnd: 75,
967 beginGroup: 76,
968 endGroup: 77,
969 beginAnnotations: 78,
970 endAnnotations: 79,
971 beginAnnotation: 80,
972 endAnnotation: 81,
973 paintJpegXObject: 82,
974 paintImageMaskXObject: 83,
975 paintImageMaskXObjectGroup: 84,
976 paintImageXObject: 85,
977 paintInlineImageXObject: 86,
978 paintInlineImageXObjectGroup: 87,
979 paintImageXObjectRepeat: 88,
980 paintImageMaskXObjectRepeat: 89,
981 paintSolidColorImageMask: 90,
982 constructPath: 91
983};
984exports.OPS = OPS;
985const UNSUPPORTED_FEATURES = {
986 unknown: "unknown",
987 forms: "forms",
988 javaScript: "javaScript",
989 smask: "smask",
990 shadingPattern: "shadingPattern",
991 font: "font",
992 errorTilingPattern: "errorTilingPattern",
993 errorExtGState: "errorExtGState",
994 errorXObject: "errorXObject",
995 errorFontLoadType3: "errorFontLoadType3",
996 errorFontState: "errorFontState",
997 errorFontMissing: "errorFontMissing",
998 errorFontTranslate: "errorFontTranslate",
999 errorColorSpace: "errorColorSpace",
1000 errorOperatorList: "errorOperatorList",
1001 errorFontToUnicode: "errorFontToUnicode",
1002 errorFontLoadNative: "errorFontLoadNative",
1003 errorFontGetPath: "errorFontGetPath"
1004};
1005exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
1006const PasswordResponses = {
1007 NEED_PASSWORD: 1,
1008 INCORRECT_PASSWORD: 2
1009};
1010exports.PasswordResponses = PasswordResponses;
1011let verbosity = VerbosityLevel.WARNINGS;
1012
1013function setVerbosityLevel(level) {
1014 if (Number.isInteger(level)) {
1015 verbosity = level;
1016 }
1017}
1018
1019function getVerbosityLevel() {
1020 return verbosity;
1021}
1022
1023function info(msg) {
1024 if (verbosity >= VerbosityLevel.INFOS) {
1025 console.log(`Info: ${msg}`);
1026 }
1027}
1028
1029function warn(msg) {
1030 if (verbosity >= VerbosityLevel.WARNINGS) {
1031 console.log(`Warning: ${msg}`);
1032 }
1033}
1034
1035function unreachable(msg) {
1036 throw new Error(msg);
1037}
1038
1039function assert(cond, msg) {
1040 if (!cond) {
1041 unreachable(msg);
1042 }
1043}
1044
1045function isSameOrigin(baseUrl, otherUrl) {
1046 let base;
1047
1048 try {
1049 base = new URL(baseUrl);
1050
1051 if (!base.origin || base.origin === "null") {
1052 return false;
1053 }
1054 } catch (e) {
1055 return false;
1056 }
1057
1058 const other = new URL(otherUrl, base);
1059 return base.origin === other.origin;
1060}
1061
1062function _isValidProtocol(url) {
1063 if (!url) {
1064 return false;
1065 }
1066
1067 switch (url.protocol) {
1068 case "http:":
1069 case "https:":
1070 case "ftp:":
1071 case "mailto:":
1072 case "tel:":
1073 return true;
1074
1075 default:
1076 return false;
1077 }
1078}
1079
1080function createValidAbsoluteUrl(url, baseUrl) {
1081 if (!url) {
1082 return null;
1083 }
1084
1085 try {
1086 const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
1087
1088 if (_isValidProtocol(absoluteUrl)) {
1089 return absoluteUrl;
1090 }
1091 } catch (ex) {}
1092
1093 return null;
1094}
1095
1096function shadow(obj, prop, value) {
1097 Object.defineProperty(obj, prop, {
1098 value,
1099 enumerable: true,
1100 configurable: true,
1101 writable: false
1102 });
1103 return value;
1104}
1105
1106const BaseException = function BaseExceptionClosure() {
1107 function BaseException(message) {
1108 if (this.constructor === BaseException) {
1109 unreachable("Cannot initialize BaseException.");
1110 }
1111
1112 this.message = message;
1113 this.name = this.constructor.name;
1114 }
1115
1116 BaseException.prototype = new Error();
1117 BaseException.constructor = BaseException;
1118 return BaseException;
1119}();
1120
1121exports.BaseException = BaseException;
1122
1123class PasswordException extends BaseException {
1124 constructor(msg, code) {
1125 super(msg);
1126 this.code = code;
1127 }
1128
1129}
1130
1131exports.PasswordException = PasswordException;
1132
1133class UnknownErrorException extends BaseException {
1134 constructor(msg, details) {
1135 super(msg);
1136 this.details = details;
1137 }
1138
1139}
1140
1141exports.UnknownErrorException = UnknownErrorException;
1142
1143class InvalidPDFException extends BaseException {}
1144
1145exports.InvalidPDFException = InvalidPDFException;
1146
1147class MissingPDFException extends BaseException {}
1148
1149exports.MissingPDFException = MissingPDFException;
1150
1151class UnexpectedResponseException extends BaseException {
1152 constructor(msg, status) {
1153 super(msg);
1154 this.status = status;
1155 }
1156
1157}
1158
1159exports.UnexpectedResponseException = UnexpectedResponseException;
1160
1161class FormatError extends BaseException {}
1162
1163exports.FormatError = FormatError;
1164
1165class AbortException extends BaseException {}
1166
1167exports.AbortException = AbortException;
1168const NullCharactersRegExp = /\x00/g;
1169
1170function removeNullCharacters(str) {
1171 if (typeof str !== "string") {
1172 warn("The argument for removeNullCharacters must be a string.");
1173 return str;
1174 }
1175
1176 return str.replace(NullCharactersRegExp, "");
1177}
1178
1179function bytesToString(bytes) {
1180 assert(bytes !== null && typeof bytes === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
1181 const length = bytes.length;
1182 const MAX_ARGUMENT_COUNT = 8192;
1183
1184 if (length < MAX_ARGUMENT_COUNT) {
1185 return String.fromCharCode.apply(null, bytes);
1186 }
1187
1188 const strBuf = [];
1189
1190 for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
1191 const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
1192 const chunk = bytes.subarray(i, chunkEnd);
1193 strBuf.push(String.fromCharCode.apply(null, chunk));
1194 }
1195
1196 return strBuf.join("");
1197}
1198
1199function stringToBytes(str) {
1200 assert(typeof str === "string", "Invalid argument for stringToBytes");
1201 const length = str.length;
1202 const bytes = new Uint8Array(length);
1203
1204 for (let i = 0; i < length; ++i) {
1205 bytes[i] = str.charCodeAt(i) & 0xff;
1206 }
1207
1208 return bytes;
1209}
1210
1211function arrayByteLength(arr) {
1212 if (arr.length !== undefined) {
1213 return arr.length;
1214 }
1215
1216 assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
1217 return arr.byteLength;
1218}
1219
1220function arraysToBytes(arr) {
1221 const length = arr.length;
1222
1223 if (length === 1 && arr[0] instanceof Uint8Array) {
1224 return arr[0];
1225 }
1226
1227 let resultLength = 0;
1228
1229 for (let i = 0; i < length; i++) {
1230 resultLength += arrayByteLength(arr[i]);
1231 }
1232
1233 let pos = 0;
1234 const data = new Uint8Array(resultLength);
1235
1236 for (let i = 0; i < length; i++) {
1237 let item = arr[i];
1238
1239 if (!(item instanceof Uint8Array)) {
1240 if (typeof item === "string") {
1241 item = stringToBytes(item);
1242 } else {
1243 item = new Uint8Array(item);
1244 }
1245 }
1246
1247 const itemLength = item.byteLength;
1248 data.set(item, pos);
1249 pos += itemLength;
1250 }
1251
1252 return data;
1253}
1254
1255function string32(value) {
1256 return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
1257}
1258
1259function isLittleEndian() {
1260 const buffer8 = new Uint8Array(4);
1261 buffer8[0] = 1;
1262 const view32 = new Uint32Array(buffer8.buffer, 0, 1);
1263 return view32[0] === 1;
1264}
1265
1266const IsLittleEndianCached = {
1267 get value() {
1268 return shadow(this, "value", isLittleEndian());
1269 }
1270
1271};
1272exports.IsLittleEndianCached = IsLittleEndianCached;
1273
1274function isEvalSupported() {
1275 try {
1276 new Function("");
1277 return true;
1278 } catch (e) {
1279 return false;
1280 }
1281}
1282
1283const IsEvalSupportedCached = {
1284 get value() {
1285 return shadow(this, "value", isEvalSupported());
1286 }
1287
1288};
1289exports.IsEvalSupportedCached = IsEvalSupportedCached;
1290const rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
1291
1292class Util {
1293 static makeCssRgb(r, g, b) {
1294 rgbBuf[1] = r;
1295 rgbBuf[3] = g;
1296 rgbBuf[5] = b;
1297 return rgbBuf.join("");
1298 }
1299
1300 static transform(m1, m2) {
1301 return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
1302 }
1303
1304 static applyTransform(p, m) {
1305 const xt = p[0] * m[0] + p[1] * m[2] + m[4];
1306 const yt = p[0] * m[1] + p[1] * m[3] + m[5];
1307 return [xt, yt];
1308 }
1309
1310 static applyInverseTransform(p, m) {
1311 const d = m[0] * m[3] - m[1] * m[2];
1312 const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
1313 const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
1314 return [xt, yt];
1315 }
1316
1317 static getAxialAlignedBoundingBox(r, m) {
1318 const p1 = Util.applyTransform(r, m);
1319 const p2 = Util.applyTransform(r.slice(2, 4), m);
1320 const p3 = Util.applyTransform([r[0], r[3]], m);
1321 const p4 = Util.applyTransform([r[2], r[1]], m);
1322 return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
1323 }
1324
1325 static inverseTransform(m) {
1326 const d = m[0] * m[3] - m[1] * m[2];
1327 return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
1328 }
1329
1330 static apply3dTransform(m, v) {
1331 return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
1332 }
1333
1334 static singularValueDecompose2dScale(m) {
1335 const transpose = [m[0], m[2], m[1], m[3]];
1336 const a = m[0] * transpose[0] + m[1] * transpose[2];
1337 const b = m[0] * transpose[1] + m[1] * transpose[3];
1338 const c = m[2] * transpose[0] + m[3] * transpose[2];
1339 const d = m[2] * transpose[1] + m[3] * transpose[3];
1340 const first = (a + d) / 2;
1341 const second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
1342 const sx = first + second || 1;
1343 const sy = first - second || 1;
1344 return [Math.sqrt(sx), Math.sqrt(sy)];
1345 }
1346
1347 static normalizeRect(rect) {
1348 const r = rect.slice(0);
1349
1350 if (rect[0] > rect[2]) {
1351 r[0] = rect[2];
1352 r[2] = rect[0];
1353 }
1354
1355 if (rect[1] > rect[3]) {
1356 r[1] = rect[3];
1357 r[3] = rect[1];
1358 }
1359
1360 return r;
1361 }
1362
1363 static intersect(rect1, rect2) {
1364 function compare(a, b) {
1365 return a - b;
1366 }
1367
1368 const orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
1369 const orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
1370 const result = [];
1371 rect1 = Util.normalizeRect(rect1);
1372 rect2 = Util.normalizeRect(rect2);
1373
1374 if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
1375 result[0] = orderedX[1];
1376 result[2] = orderedX[2];
1377 } else {
1378 return null;
1379 }
1380
1381 if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
1382 result[1] = orderedY[1];
1383 result[3] = orderedY[2];
1384 } else {
1385 return null;
1386 }
1387
1388 return result;
1389 }
1390
1391}
1392
1393exports.Util = Util;
1394const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
1395
1396function stringToPDFString(str) {
1397 const length = str.length,
1398 strBuf = [];
1399
1400 if (str[0] === "\xFE" && str[1] === "\xFF") {
1401 for (let i = 2; i < length; i += 2) {
1402 strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
1403 }
1404 } else if (str[0] === "\xFF" && str[1] === "\xFE") {
1405 for (let i = 2; i < length; i += 2) {
1406 strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i)));
1407 }
1408 } else {
1409 for (let i = 0; i < length; ++i) {
1410 const code = PDFStringTranslateTable[str.charCodeAt(i)];
1411 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
1412 }
1413 }
1414
1415 return strBuf.join("");
1416}
1417
1418function stringToUTF8String(str) {
1419 return decodeURIComponent(escape(str));
1420}
1421
1422function utf8StringToString(str) {
1423 return unescape(encodeURIComponent(str));
1424}
1425
1426function isEmptyObj(obj) {
1427 for (const key in obj) {
1428 return false;
1429 }
1430
1431 return true;
1432}
1433
1434function isBool(v) {
1435 return typeof v === "boolean";
1436}
1437
1438function isNum(v) {
1439 return typeof v === "number";
1440}
1441
1442function isString(v) {
1443 return typeof v === "string";
1444}
1445
1446function isArrayBuffer(v) {
1447 return typeof v === "object" && v !== null && v.byteLength !== undefined;
1448}
1449
1450function isArrayEqual(arr1, arr2) {
1451 if (arr1.length !== arr2.length) {
1452 return false;
1453 }
1454
1455 return arr1.every(function (element, index) {
1456 return element === arr2[index];
1457 });
1458}
1459
1460function createPromiseCapability() {
1461 const capability = Object.create(null);
1462 let isSettled = false;
1463 Object.defineProperty(capability, "settled", {
1464 get() {
1465 return isSettled;
1466 }
1467
1468 });
1469 capability.promise = new Promise(function (resolve, reject) {
1470 capability.resolve = function (data) {
1471 isSettled = true;
1472 resolve(data);
1473 };
1474
1475 capability.reject = function (reason) {
1476 isSettled = true;
1477 reject(reason);
1478 };
1479 });
1480 return capability;
1481}
1482
1483const createObjectURL = function createObjectURLClosure() {
1484 const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
1485 return function createObjectURL(data, contentType, forceDataSchema = false) {
1486 if (!forceDataSchema && URL.createObjectURL) {
1487 const blob = new Blob([data], {
1488 type: contentType
1489 });
1490 return URL.createObjectURL(blob);
1491 }
1492
1493 let buffer = `data:${contentType};base64,`;
1494
1495 for (let i = 0, ii = data.length; i < ii; i += 3) {
1496 const b1 = data[i] & 0xff;
1497 const b2 = data[i + 1] & 0xff;
1498 const b3 = data[i + 2] & 0xff;
1499 const d1 = b1 >> 2,
1500 d2 = (b1 & 3) << 4 | b2 >> 4;
1501 const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
1502 const d4 = i + 2 < ii ? b3 & 0x3f : 64;
1503 buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
1504 }
1505
1506 return buffer;
1507 };
1508}();
1509
1510exports.createObjectURL = createObjectURL;
1511
1512/***/ }),
1513/* 3 */
1514/***/ (function(module, exports, __w_pdfjs_require__) {
1515
1516"use strict";
1517
1518
1519var _is_node = __w_pdfjs_require__(4);
1520
1521;
1522
1523/***/ }),
1524/* 4 */
1525/***/ (function(module, exports, __w_pdfjs_require__) {
1526
1527"use strict";
1528
1529
1530Object.defineProperty(exports, "__esModule", {
1531 value: true
1532});
1533exports.isNodeJS = void 0;
1534const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !process.versions.electron;
1535exports.isNodeJS = isNodeJS;
1536
1537/***/ }),
1538/* 5 */
1539/***/ (function(module, exports, __w_pdfjs_require__) {
1540
1541"use strict";
1542
1543
1544Object.defineProperty(exports, "__esModule", {
1545 value: true
1546});
1547exports.clearPrimitiveCaches = clearPrimitiveCaches;
1548exports.isEOF = isEOF;
1549exports.isCmd = isCmd;
1550exports.isDict = isDict;
1551exports.isName = isName;
1552exports.isRef = isRef;
1553exports.isRefsEqual = isRefsEqual;
1554exports.isStream = isStream;
1555exports.RefSetCache = exports.RefSet = exports.Ref = exports.Name = exports.Dict = exports.Cmd = exports.EOF = void 0;
1556
1557var _util = __w_pdfjs_require__(2);
1558
1559var EOF = {};
1560exports.EOF = EOF;
1561
1562var Name = function NameClosure() {
1563 let nameCache = Object.create(null);
1564
1565 function Name(name) {
1566 this.name = name;
1567 }
1568
1569 Name.prototype = {};
1570
1571 Name.get = function Name_get(name) {
1572 var nameValue = nameCache[name];
1573 return nameValue ? nameValue : nameCache[name] = new Name(name);
1574 };
1575
1576 Name._clearCache = function () {
1577 nameCache = Object.create(null);
1578 };
1579
1580 return Name;
1581}();
1582
1583exports.Name = Name;
1584
1585var Cmd = function CmdClosure() {
1586 let cmdCache = Object.create(null);
1587
1588 function Cmd(cmd) {
1589 this.cmd = cmd;
1590 }
1591
1592 Cmd.prototype = {};
1593
1594 Cmd.get = function Cmd_get(cmd) {
1595 var cmdValue = cmdCache[cmd];
1596 return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
1597 };
1598
1599 Cmd._clearCache = function () {
1600 cmdCache = Object.create(null);
1601 };
1602
1603 return Cmd;
1604}();
1605
1606exports.Cmd = Cmd;
1607
1608var Dict = function DictClosure() {
1609 var nonSerializable = function nonSerializableClosure() {
1610 return nonSerializable;
1611 };
1612
1613 function Dict(xref) {
1614 this._map = Object.create(null);
1615 this.xref = xref;
1616 this.objId = null;
1617 this.suppressEncryption = false;
1618 this.__nonSerializable__ = nonSerializable;
1619 }
1620
1621 Dict.prototype = {
1622 assignXref: function Dict_assignXref(newXref) {
1623 this.xref = newXref;
1624 },
1625
1626 get(key1, key2, key3) {
1627 let value = this._map[key1];
1628
1629 if (value === undefined && key2 !== undefined) {
1630 value = this._map[key2];
1631
1632 if (value === undefined && key3 !== undefined) {
1633 value = this._map[key3];
1634 }
1635 }
1636
1637 if (value instanceof Ref && this.xref) {
1638 return this.xref.fetch(value, this.suppressEncryption);
1639 }
1640
1641 return value;
1642 },
1643
1644 async getAsync(key1, key2, key3) {
1645 let value = this._map[key1];
1646
1647 if (value === undefined && key2 !== undefined) {
1648 value = this._map[key2];
1649
1650 if (value === undefined && key3 !== undefined) {
1651 value = this._map[key3];
1652 }
1653 }
1654
1655 if (value instanceof Ref && this.xref) {
1656 return this.xref.fetchAsync(value, this.suppressEncryption);
1657 }
1658
1659 return value;
1660 },
1661
1662 getArray(key1, key2, key3) {
1663 let value = this.get(key1, key2, key3);
1664
1665 if (!Array.isArray(value) || !this.xref) {
1666 return value;
1667 }
1668
1669 value = value.slice();
1670
1671 for (let i = 0, ii = value.length; i < ii; i++) {
1672 if (!(value[i] instanceof Ref)) {
1673 continue;
1674 }
1675
1676 value[i] = this.xref.fetch(value[i], this.suppressEncryption);
1677 }
1678
1679 return value;
1680 },
1681
1682 getRaw: function Dict_getRaw(key) {
1683 return this._map[key];
1684 },
1685 getKeys: function Dict_getKeys() {
1686 return Object.keys(this._map);
1687 },
1688 set: function Dict_set(key, value) {
1689 this._map[key] = value;
1690 },
1691 has: function Dict_has(key) {
1692 return this._map[key] !== undefined;
1693 },
1694 forEach: function Dict_forEach(callback) {
1695 for (var key in this._map) {
1696 callback(key, this.get(key));
1697 }
1698 }
1699 };
1700 Dict.empty = new Dict(null);
1701
1702 Dict.merge = function (xref, dictArray) {
1703 const mergedDict = new Dict(xref);
1704
1705 for (let i = 0, ii = dictArray.length; i < ii; i++) {
1706 const dict = dictArray[i];
1707
1708 if (!isDict(dict)) {
1709 continue;
1710 }
1711
1712 for (const keyName in dict._map) {
1713 if (mergedDict._map[keyName] !== undefined) {
1714 continue;
1715 }
1716
1717 mergedDict._map[keyName] = dict._map[keyName];
1718 }
1719 }
1720
1721 return mergedDict;
1722 };
1723
1724 return Dict;
1725}();
1726
1727exports.Dict = Dict;
1728
1729var Ref = function RefClosure() {
1730 let refCache = Object.create(null);
1731
1732 function Ref(num, gen) {
1733 this.num = num;
1734 this.gen = gen;
1735 }
1736
1737 Ref.prototype = {
1738 toString: function Ref_toString() {
1739 if (this.gen === 0) {
1740 return `${this.num}R`;
1741 }
1742
1743 return `${this.num}R${this.gen}`;
1744 }
1745 };
1746
1747 Ref.get = function (num, gen) {
1748 const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
1749 const refValue = refCache[key];
1750 return refValue ? refValue : refCache[key] = new Ref(num, gen);
1751 };
1752
1753 Ref._clearCache = function () {
1754 refCache = Object.create(null);
1755 };
1756
1757 return Ref;
1758}();
1759
1760exports.Ref = Ref;
1761
1762var RefSet = function RefSetClosure() {
1763 function RefSet() {
1764 this.dict = Object.create(null);
1765 }
1766
1767 RefSet.prototype = {
1768 has: function RefSet_has(ref) {
1769 return ref.toString() in this.dict;
1770 },
1771 put: function RefSet_put(ref) {
1772 this.dict[ref.toString()] = true;
1773 },
1774 remove: function RefSet_remove(ref) {
1775 delete this.dict[ref.toString()];
1776 }
1777 };
1778 return RefSet;
1779}();
1780
1781exports.RefSet = RefSet;
1782
1783var RefSetCache = function RefSetCacheClosure() {
1784 function RefSetCache() {
1785 this.dict = Object.create(null);
1786 }
1787
1788 RefSetCache.prototype = {
1789 get size() {
1790 return Object.keys(this.dict).length;
1791 },
1792
1793 get: function RefSetCache_get(ref) {
1794 return this.dict[ref.toString()];
1795 },
1796 has: function RefSetCache_has(ref) {
1797 return ref.toString() in this.dict;
1798 },
1799 put: function RefSetCache_put(ref, obj) {
1800 this.dict[ref.toString()] = obj;
1801 },
1802 putAlias: function RefSetCache_putAlias(ref, aliasRef) {
1803 this.dict[ref.toString()] = this.get(aliasRef);
1804 },
1805 forEach: function RefSetCache_forEach(callback) {
1806 for (const i in this.dict) {
1807 callback(this.dict[i]);
1808 }
1809 },
1810 clear: function RefSetCache_clear() {
1811 this.dict = Object.create(null);
1812 }
1813 };
1814 return RefSetCache;
1815}();
1816
1817exports.RefSetCache = RefSetCache;
1818
1819function isEOF(v) {
1820 return v === EOF;
1821}
1822
1823function isName(v, name) {
1824 return v instanceof Name && (name === undefined || v.name === name);
1825}
1826
1827function isCmd(v, cmd) {
1828 return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
1829}
1830
1831function isDict(v, type) {
1832 return v instanceof Dict && (type === undefined || isName(v.get("Type"), type));
1833}
1834
1835function isRef(v) {
1836 return v instanceof Ref;
1837}
1838
1839function isRefsEqual(v1, v2) {
1840 return v1.num === v2.num && v1.gen === v2.gen;
1841}
1842
1843function isStream(v) {
1844 return typeof v === "object" && v !== null && v.getBytes !== undefined;
1845}
1846
1847function clearPrimitiveCaches() {
1848 Cmd._clearCache();
1849
1850 Name._clearCache();
1851
1852 Ref._clearCache();
1853}
1854
1855/***/ }),
1856/* 6 */
1857/***/ (function(module, exports, __w_pdfjs_require__) {
1858
1859"use strict";
1860
1861
1862Object.defineProperty(exports, "__esModule", {
1863 value: true
1864});
1865exports.NetworkPdfManager = exports.LocalPdfManager = void 0;
1866
1867var _util = __w_pdfjs_require__(2);
1868
1869var _chunked_stream = __w_pdfjs_require__(7);
1870
1871var _core_utils = __w_pdfjs_require__(8);
1872
1873var _document = __w_pdfjs_require__(9);
1874
1875var _stream = __w_pdfjs_require__(12);
1876
1877class BasePdfManager {
1878 constructor() {
1879 if (this.constructor === BasePdfManager) {
1880 (0, _util.unreachable)("Cannot initialize BasePdfManager.");
1881 }
1882 }
1883
1884 get docId() {
1885 return this._docId;
1886 }
1887
1888 get password() {
1889 return this._password;
1890 }
1891
1892 get docBaseUrl() {
1893 let docBaseUrl = null;
1894
1895 if (this._docBaseUrl) {
1896 const absoluteUrl = (0, _util.createValidAbsoluteUrl)(this._docBaseUrl);
1897
1898 if (absoluteUrl) {
1899 docBaseUrl = absoluteUrl.href;
1900 } else {
1901 (0, _util.warn)(`Invalid absolute docBaseUrl: "${this._docBaseUrl}".`);
1902 }
1903 }
1904
1905 return (0, _util.shadow)(this, "docBaseUrl", docBaseUrl);
1906 }
1907
1908 onLoadedStream() {
1909 (0, _util.unreachable)("Abstract method `onLoadedStream` called");
1910 }
1911
1912 ensureDoc(prop, args) {
1913 return this.ensure(this.pdfDocument, prop, args);
1914 }
1915
1916 ensureXRef(prop, args) {
1917 return this.ensure(this.pdfDocument.xref, prop, args);
1918 }
1919
1920 ensureCatalog(prop, args) {
1921 return this.ensure(this.pdfDocument.catalog, prop, args);
1922 }
1923
1924 getPage(pageIndex) {
1925 return this.pdfDocument.getPage(pageIndex);
1926 }
1927
1928 fontFallback(id, handler) {
1929 return this.pdfDocument.fontFallback(id, handler);
1930 }
1931
1932 cleanup(manuallyTriggered = false) {
1933 return this.pdfDocument.cleanup(manuallyTriggered);
1934 }
1935
1936 async ensure(obj, prop, args) {
1937 (0, _util.unreachable)("Abstract method `ensure` called");
1938 }
1939
1940 requestRange(begin, end) {
1941 (0, _util.unreachable)("Abstract method `requestRange` called");
1942 }
1943
1944 requestLoadedStream() {
1945 (0, _util.unreachable)("Abstract method `requestLoadedStream` called");
1946 }
1947
1948 sendProgressiveData(chunk) {
1949 (0, _util.unreachable)("Abstract method `sendProgressiveData` called");
1950 }
1951
1952 updatePassword(password) {
1953 this._password = password;
1954 }
1955
1956 terminate(reason) {
1957 (0, _util.unreachable)("Abstract method `terminate` called");
1958 }
1959
1960}
1961
1962class LocalPdfManager extends BasePdfManager {
1963 constructor(docId, data, password, evaluatorOptions, docBaseUrl) {
1964 super();
1965 this._docId = docId;
1966 this._password = password;
1967 this._docBaseUrl = docBaseUrl;
1968 this.evaluatorOptions = evaluatorOptions;
1969 const stream = new _stream.Stream(data);
1970 this.pdfDocument = new _document.PDFDocument(this, stream);
1971 this._loadedStreamPromise = Promise.resolve(stream);
1972 }
1973
1974 async ensure(obj, prop, args) {
1975 const value = obj[prop];
1976
1977 if (typeof value === "function") {
1978 return value.apply(obj, args);
1979 }
1980
1981 return value;
1982 }
1983
1984 requestRange(begin, end) {
1985 return Promise.resolve();
1986 }
1987
1988 requestLoadedStream() {}
1989
1990 onLoadedStream() {
1991 return this._loadedStreamPromise;
1992 }
1993
1994 terminate(reason) {}
1995
1996}
1997
1998exports.LocalPdfManager = LocalPdfManager;
1999
2000class NetworkPdfManager extends BasePdfManager {
2001 constructor(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
2002 super();
2003 this._docId = docId;
2004 this._password = args.password;
2005 this._docBaseUrl = docBaseUrl;
2006 this.msgHandler = args.msgHandler;
2007 this.evaluatorOptions = evaluatorOptions;
2008 this.streamManager = new _chunked_stream.ChunkedStreamManager(pdfNetworkStream, {
2009 msgHandler: args.msgHandler,
2010 length: args.length,
2011 disableAutoFetch: args.disableAutoFetch,
2012 rangeChunkSize: args.rangeChunkSize
2013 });
2014 this.pdfDocument = new _document.PDFDocument(this, this.streamManager.getStream());
2015 }
2016
2017 async ensure(obj, prop, args) {
2018 try {
2019 const value = obj[prop];
2020
2021 if (typeof value === "function") {
2022 return value.apply(obj, args);
2023 }
2024
2025 return value;
2026 } catch (ex) {
2027 if (!(ex instanceof _core_utils.MissingDataException)) {
2028 throw ex;
2029 }
2030
2031 await this.requestRange(ex.begin, ex.end);
2032 return this.ensure(obj, prop, args);
2033 }
2034 }
2035
2036 requestRange(begin, end) {
2037 return this.streamManager.requestRange(begin, end);
2038 }
2039
2040 requestLoadedStream() {
2041 this.streamManager.requestAllChunks();
2042 }
2043
2044 sendProgressiveData(chunk) {
2045 this.streamManager.onReceiveData({
2046 chunk
2047 });
2048 }
2049
2050 onLoadedStream() {
2051 return this.streamManager.onLoadedStream();
2052 }
2053
2054 terminate(reason) {
2055 this.streamManager.abort(reason);
2056 }
2057
2058}
2059
2060exports.NetworkPdfManager = NetworkPdfManager;
2061
2062/***/ }),
2063/* 7 */
2064/***/ (function(module, exports, __w_pdfjs_require__) {
2065
2066"use strict";
2067
2068
2069Object.defineProperty(exports, "__esModule", {
2070 value: true
2071});
2072exports.ChunkedStreamManager = exports.ChunkedStream = void 0;
2073
2074var _util = __w_pdfjs_require__(2);
2075
2076var _core_utils = __w_pdfjs_require__(8);
2077
2078class ChunkedStream {
2079 constructor(length, chunkSize, manager) {
2080 this.bytes = new Uint8Array(length);
2081 this.start = 0;
2082 this.pos = 0;
2083 this.end = length;
2084 this.chunkSize = chunkSize;
2085 this.loadedChunks = [];
2086 this.numChunksLoaded = 0;
2087 this.numChunks = Math.ceil(length / chunkSize);
2088 this.manager = manager;
2089 this.progressiveDataLength = 0;
2090 this.lastSuccessfulEnsureByteChunk = -1;
2091 }
2092
2093 getMissingChunks() {
2094 const chunks = [];
2095
2096 for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
2097 if (!this.loadedChunks[chunk]) {
2098 chunks.push(chunk);
2099 }
2100 }
2101
2102 return chunks;
2103 }
2104
2105 getBaseStreams() {
2106 return [this];
2107 }
2108
2109 allChunksLoaded() {
2110 return this.numChunksLoaded === this.numChunks;
2111 }
2112
2113 onReceiveData(begin, chunk) {
2114 const chunkSize = this.chunkSize;
2115
2116 if (begin % chunkSize !== 0) {
2117 throw new Error(`Bad begin offset: ${begin}`);
2118 }
2119
2120 const end = begin + chunk.byteLength;
2121
2122 if (end % chunkSize !== 0 && end !== this.bytes.length) {
2123 throw new Error(`Bad end offset: ${end}`);
2124 }
2125
2126 this.bytes.set(new Uint8Array(chunk), begin);
2127 const beginChunk = Math.floor(begin / chunkSize);
2128 const endChunk = Math.floor((end - 1) / chunkSize) + 1;
2129
2130 for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
2131 if (!this.loadedChunks[curChunk]) {
2132 this.loadedChunks[curChunk] = true;
2133 ++this.numChunksLoaded;
2134 }
2135 }
2136 }
2137
2138 onReceiveProgressiveData(data) {
2139 let position = this.progressiveDataLength;
2140 const beginChunk = Math.floor(position / this.chunkSize);
2141 this.bytes.set(new Uint8Array(data), position);
2142 position += data.byteLength;
2143 this.progressiveDataLength = position;
2144 const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
2145
2146 for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
2147 if (!this.loadedChunks[curChunk]) {
2148 this.loadedChunks[curChunk] = true;
2149 ++this.numChunksLoaded;
2150 }
2151 }
2152 }
2153
2154 ensureByte(pos) {
2155 if (pos < this.progressiveDataLength) {
2156 return;
2157 }
2158
2159 const chunk = Math.floor(pos / this.chunkSize);
2160
2161 if (chunk === this.lastSuccessfulEnsureByteChunk) {
2162 return;
2163 }
2164
2165 if (!this.loadedChunks[chunk]) {
2166 throw new _core_utils.MissingDataException(pos, pos + 1);
2167 }
2168
2169 this.lastSuccessfulEnsureByteChunk = chunk;
2170 }
2171
2172 ensureRange(begin, end) {
2173 if (begin >= end) {
2174 return;
2175 }
2176
2177 if (end <= this.progressiveDataLength) {
2178 return;
2179 }
2180
2181 const chunkSize = this.chunkSize;
2182 const beginChunk = Math.floor(begin / chunkSize);
2183 const endChunk = Math.floor((end - 1) / chunkSize) + 1;
2184
2185 for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
2186 if (!this.loadedChunks[chunk]) {
2187 throw new _core_utils.MissingDataException(begin, end);
2188 }
2189 }
2190 }
2191
2192 nextEmptyChunk(beginChunk) {
2193 const numChunks = this.numChunks;
2194
2195 for (let i = 0; i < numChunks; ++i) {
2196 const chunk = (beginChunk + i) % numChunks;
2197
2198 if (!this.loadedChunks[chunk]) {
2199 return chunk;
2200 }
2201 }
2202
2203 return null;
2204 }
2205
2206 hasChunk(chunk) {
2207 return !!this.loadedChunks[chunk];
2208 }
2209
2210 get length() {
2211 return this.end - this.start;
2212 }
2213
2214 get isEmpty() {
2215 return this.length === 0;
2216 }
2217
2218 getByte() {
2219 const pos = this.pos;
2220
2221 if (pos >= this.end) {
2222 return -1;
2223 }
2224
2225 if (pos >= this.progressiveDataLength) {
2226 this.ensureByte(pos);
2227 }
2228
2229 return this.bytes[this.pos++];
2230 }
2231
2232 getUint16() {
2233 const b0 = this.getByte();
2234 const b1 = this.getByte();
2235
2236 if (b0 === -1 || b1 === -1) {
2237 return -1;
2238 }
2239
2240 return (b0 << 8) + b1;
2241 }
2242
2243 getInt32() {
2244 const b0 = this.getByte();
2245 const b1 = this.getByte();
2246 const b2 = this.getByte();
2247 const b3 = this.getByte();
2248 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
2249 }
2250
2251 getBytes(length, forceClamped = false) {
2252 const bytes = this.bytes;
2253 const pos = this.pos;
2254 const strEnd = this.end;
2255
2256 if (!length) {
2257 if (strEnd > this.progressiveDataLength) {
2258 this.ensureRange(pos, strEnd);
2259 }
2260
2261 const subarray = bytes.subarray(pos, strEnd);
2262 return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
2263 }
2264
2265 let end = pos + length;
2266
2267 if (end > strEnd) {
2268 end = strEnd;
2269 }
2270
2271 if (end > this.progressiveDataLength) {
2272 this.ensureRange(pos, end);
2273 }
2274
2275 this.pos = end;
2276 const subarray = bytes.subarray(pos, end);
2277 return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
2278 }
2279
2280 peekByte() {
2281 const peekedByte = this.getByte();
2282
2283 if (peekedByte !== -1) {
2284 this.pos--;
2285 }
2286
2287 return peekedByte;
2288 }
2289
2290 peekBytes(length, forceClamped = false) {
2291 const bytes = this.getBytes(length, forceClamped);
2292 this.pos -= bytes.length;
2293 return bytes;
2294 }
2295
2296 getByteRange(begin, end) {
2297 if (begin < 0) {
2298 begin = 0;
2299 }
2300
2301 if (end > this.end) {
2302 end = this.end;
2303 }
2304
2305 if (end > this.progressiveDataLength) {
2306 this.ensureRange(begin, end);
2307 }
2308
2309 return this.bytes.subarray(begin, end);
2310 }
2311
2312 skip(n) {
2313 if (!n) {
2314 n = 1;
2315 }
2316
2317 this.pos += n;
2318 }
2319
2320 reset() {
2321 this.pos = this.start;
2322 }
2323
2324 moveStart() {
2325 this.start = this.pos;
2326 }
2327
2328 makeSubStream(start, length, dict) {
2329 if (length) {
2330 if (start + length > this.progressiveDataLength) {
2331 this.ensureRange(start, start + length);
2332 }
2333 } else {
2334 if (start >= this.progressiveDataLength) {
2335 this.ensureByte(start);
2336 }
2337 }
2338
2339 function ChunkedStreamSubstream() {}
2340
2341 ChunkedStreamSubstream.prototype = Object.create(this);
2342
2343 ChunkedStreamSubstream.prototype.getMissingChunks = function () {
2344 const chunkSize = this.chunkSize;
2345 const beginChunk = Math.floor(this.start / chunkSize);
2346 const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
2347 const missingChunks = [];
2348
2349 for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
2350 if (!this.loadedChunks[chunk]) {
2351 missingChunks.push(chunk);
2352 }
2353 }
2354
2355 return missingChunks;
2356 };
2357
2358 ChunkedStreamSubstream.prototype.allChunksLoaded = function () {
2359 if (this.numChunksLoaded === this.numChunks) {
2360 return true;
2361 }
2362
2363 return this.getMissingChunks().length === 0;
2364 };
2365
2366 const subStream = new ChunkedStreamSubstream();
2367 subStream.pos = subStream.start = start;
2368 subStream.end = start + length || this.end;
2369 subStream.dict = dict;
2370 return subStream;
2371 }
2372
2373}
2374
2375exports.ChunkedStream = ChunkedStream;
2376
2377class ChunkedStreamManager {
2378 constructor(pdfNetworkStream, args) {
2379 this.length = args.length;
2380 this.chunkSize = args.rangeChunkSize;
2381 this.stream = new ChunkedStream(this.length, this.chunkSize, this);
2382 this.pdfNetworkStream = pdfNetworkStream;
2383 this.disableAutoFetch = args.disableAutoFetch;
2384 this.msgHandler = args.msgHandler;
2385 this.currRequestId = 0;
2386 this.chunksNeededByRequest = Object.create(null);
2387 this.requestsByChunk = Object.create(null);
2388 this.promisesByRequest = Object.create(null);
2389 this.progressiveDataLength = 0;
2390 this.aborted = false;
2391 this._loadedStreamCapability = (0, _util.createPromiseCapability)();
2392 }
2393
2394 onLoadedStream() {
2395 return this._loadedStreamCapability.promise;
2396 }
2397
2398 sendRequest(begin, end) {
2399 const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
2400
2401 if (!rangeReader.isStreamingSupported) {
2402 rangeReader.onProgress = this.onProgress.bind(this);
2403 }
2404
2405 let chunks = [],
2406 loaded = 0;
2407 const promise = new Promise((resolve, reject) => {
2408 const readChunk = chunk => {
2409 try {
2410 if (!chunk.done) {
2411 const data = chunk.value;
2412 chunks.push(data);
2413 loaded += (0, _util.arrayByteLength)(data);
2414
2415 if (rangeReader.isStreamingSupported) {
2416 this.onProgress({
2417 loaded
2418 });
2419 }
2420
2421 rangeReader.read().then(readChunk, reject);
2422 return;
2423 }
2424
2425 const chunkData = (0, _util.arraysToBytes)(chunks);
2426 chunks = null;
2427 resolve(chunkData);
2428 } catch (e) {
2429 reject(e);
2430 }
2431 };
2432
2433 rangeReader.read().then(readChunk, reject);
2434 });
2435 promise.then(data => {
2436 if (this.aborted) {
2437 return;
2438 }
2439
2440 this.onReceiveData({
2441 chunk: data,
2442 begin
2443 });
2444 });
2445 }
2446
2447 requestAllChunks() {
2448 const missingChunks = this.stream.getMissingChunks();
2449
2450 this._requestChunks(missingChunks);
2451
2452 return this._loadedStreamCapability.promise;
2453 }
2454
2455 _requestChunks(chunks) {
2456 const requestId = this.currRequestId++;
2457 const chunksNeeded = Object.create(null);
2458 this.chunksNeededByRequest[requestId] = chunksNeeded;
2459
2460 for (const chunk of chunks) {
2461 if (!this.stream.hasChunk(chunk)) {
2462 chunksNeeded[chunk] = true;
2463 }
2464 }
2465
2466 if ((0, _util.isEmptyObj)(chunksNeeded)) {
2467 return Promise.resolve();
2468 }
2469
2470 const capability = (0, _util.createPromiseCapability)();
2471 this.promisesByRequest[requestId] = capability;
2472 const chunksToRequest = [];
2473
2474 for (let chunk in chunksNeeded) {
2475 chunk = chunk | 0;
2476
2477 if (!(chunk in this.requestsByChunk)) {
2478 this.requestsByChunk[chunk] = [];
2479 chunksToRequest.push(chunk);
2480 }
2481
2482 this.requestsByChunk[chunk].push(requestId);
2483 }
2484
2485 if (!chunksToRequest.length) {
2486 return capability.promise;
2487 }
2488
2489 const groupedChunksToRequest = this.groupChunks(chunksToRequest);
2490
2491 for (const groupedChunk of groupedChunksToRequest) {
2492 const begin = groupedChunk.beginChunk * this.chunkSize;
2493 const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
2494 this.sendRequest(begin, end);
2495 }
2496
2497 return capability.promise;
2498 }
2499
2500 getStream() {
2501 return this.stream;
2502 }
2503
2504 requestRange(begin, end) {
2505 end = Math.min(end, this.length);
2506 const beginChunk = this.getBeginChunk(begin);
2507 const endChunk = this.getEndChunk(end);
2508 const chunks = [];
2509
2510 for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
2511 chunks.push(chunk);
2512 }
2513
2514 return this._requestChunks(chunks);
2515 }
2516
2517 requestRanges(ranges = []) {
2518 const chunksToRequest = [];
2519
2520 for (const range of ranges) {
2521 const beginChunk = this.getBeginChunk(range.begin);
2522 const endChunk = this.getEndChunk(range.end);
2523
2524 for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
2525 if (!chunksToRequest.includes(chunk)) {
2526 chunksToRequest.push(chunk);
2527 }
2528 }
2529 }
2530
2531 chunksToRequest.sort(function (a, b) {
2532 return a - b;
2533 });
2534 return this._requestChunks(chunksToRequest);
2535 }
2536
2537 groupChunks(chunks) {
2538 const groupedChunks = [];
2539 let beginChunk = -1;
2540 let prevChunk = -1;
2541
2542 for (let i = 0, ii = chunks.length; i < ii; ++i) {
2543 const chunk = chunks[i];
2544
2545 if (beginChunk < 0) {
2546 beginChunk = chunk;
2547 }
2548
2549 if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
2550 groupedChunks.push({
2551 beginChunk,
2552 endChunk: prevChunk + 1
2553 });
2554 beginChunk = chunk;
2555 }
2556
2557 if (i + 1 === chunks.length) {
2558 groupedChunks.push({
2559 beginChunk,
2560 endChunk: chunk + 1
2561 });
2562 }
2563
2564 prevChunk = chunk;
2565 }
2566
2567 return groupedChunks;
2568 }
2569
2570 onProgress(args) {
2571 this.msgHandler.send("DocProgress", {
2572 loaded: this.stream.numChunksLoaded * this.chunkSize + args.loaded,
2573 total: this.length
2574 });
2575 }
2576
2577 onReceiveData(args) {
2578 const chunk = args.chunk;
2579 const isProgressive = args.begin === undefined;
2580 const begin = isProgressive ? this.progressiveDataLength : args.begin;
2581 const end = begin + chunk.byteLength;
2582 const beginChunk = Math.floor(begin / this.chunkSize);
2583 const endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
2584
2585 if (isProgressive) {
2586 this.stream.onReceiveProgressiveData(chunk);
2587 this.progressiveDataLength = end;
2588 } else {
2589 this.stream.onReceiveData(begin, chunk);
2590 }
2591
2592 if (this.stream.allChunksLoaded()) {
2593 this._loadedStreamCapability.resolve(this.stream);
2594 }
2595
2596 const loadedRequests = [];
2597
2598 for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
2599 const requestIds = this.requestsByChunk[curChunk] || [];
2600 delete this.requestsByChunk[curChunk];
2601
2602 for (const requestId of requestIds) {
2603 const chunksNeeded = this.chunksNeededByRequest[requestId];
2604
2605 if (curChunk in chunksNeeded) {
2606 delete chunksNeeded[curChunk];
2607 }
2608
2609 if (!(0, _util.isEmptyObj)(chunksNeeded)) {
2610 continue;
2611 }
2612
2613 loadedRequests.push(requestId);
2614 }
2615 }
2616
2617 if (!this.disableAutoFetch && (0, _util.isEmptyObj)(this.requestsByChunk)) {
2618 let nextEmptyChunk;
2619
2620 if (this.stream.numChunksLoaded === 1) {
2621 const lastChunk = this.stream.numChunks - 1;
2622
2623 if (!this.stream.hasChunk(lastChunk)) {
2624 nextEmptyChunk = lastChunk;
2625 }
2626 } else {
2627 nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
2628 }
2629
2630 if (Number.isInteger(nextEmptyChunk)) {
2631 this._requestChunks([nextEmptyChunk]);
2632 }
2633 }
2634
2635 for (const requestId of loadedRequests) {
2636 const capability = this.promisesByRequest[requestId];
2637 delete this.promisesByRequest[requestId];
2638 capability.resolve();
2639 }
2640
2641 this.msgHandler.send("DocProgress", {
2642 loaded: this.stream.numChunksLoaded * this.chunkSize,
2643 total: this.length
2644 });
2645 }
2646
2647 onError(err) {
2648 this._loadedStreamCapability.reject(err);
2649 }
2650
2651 getBeginChunk(begin) {
2652 return Math.floor(begin / this.chunkSize);
2653 }
2654
2655 getEndChunk(end) {
2656 return Math.floor((end - 1) / this.chunkSize) + 1;
2657 }
2658
2659 abort(reason) {
2660 this.aborted = true;
2661
2662 if (this.pdfNetworkStream) {
2663 this.pdfNetworkStream.cancelAllRequests(reason);
2664 }
2665
2666 for (const requestId in this.promisesByRequest) {
2667 this.promisesByRequest[requestId].reject(reason);
2668 }
2669 }
2670
2671}
2672
2673exports.ChunkedStreamManager = ChunkedStreamManager;
2674
2675/***/ }),
2676/* 8 */
2677/***/ (function(module, exports, __w_pdfjs_require__) {
2678
2679"use strict";
2680
2681
2682Object.defineProperty(exports, "__esModule", {
2683 value: true
2684});
2685exports.getLookupTableFactory = getLookupTableFactory;
2686exports.getInheritableProperty = getInheritableProperty;
2687exports.toRomanNumerals = toRomanNumerals;
2688exports.log2 = log2;
2689exports.readInt8 = readInt8;
2690exports.readUint16 = readUint16;
2691exports.readUint32 = readUint32;
2692exports.isWhiteSpace = isWhiteSpace;
2693exports.XRefParseException = exports.XRefEntryException = exports.MissingDataException = void 0;
2694
2695var _util = __w_pdfjs_require__(2);
2696
2697function getLookupTableFactory(initializer) {
2698 let lookup;
2699 return function () {
2700 if (initializer) {
2701 lookup = Object.create(null);
2702 initializer(lookup);
2703 initializer = null;
2704 }
2705
2706 return lookup;
2707 };
2708}
2709
2710class MissingDataException extends _util.BaseException {
2711 constructor(begin, end) {
2712 super(`Missing data [${begin}, ${end})`);
2713 this.begin = begin;
2714 this.end = end;
2715 }
2716
2717}
2718
2719exports.MissingDataException = MissingDataException;
2720
2721class XRefEntryException extends _util.BaseException {}
2722
2723exports.XRefEntryException = XRefEntryException;
2724
2725class XRefParseException extends _util.BaseException {}
2726
2727exports.XRefParseException = XRefParseException;
2728
2729function getInheritableProperty({
2730 dict,
2731 key,
2732 getArray = false,
2733 stopWhenFound = true
2734}) {
2735 const LOOP_LIMIT = 100;
2736 let loopCount = 0;
2737 let values;
2738
2739 while (dict) {
2740 const value = getArray ? dict.getArray(key) : dict.get(key);
2741
2742 if (value !== undefined) {
2743 if (stopWhenFound) {
2744 return value;
2745 }
2746
2747 if (!values) {
2748 values = [];
2749 }
2750
2751 values.push(value);
2752 }
2753
2754 if (++loopCount > LOOP_LIMIT) {
2755 (0, _util.warn)(`getInheritableProperty: maximum loop count exceeded for "${key}"`);
2756 break;
2757 }
2758
2759 dict = dict.get("Parent");
2760 }
2761
2762 return values;
2763}
2764
2765const ROMAN_NUMBER_MAP = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
2766
2767function toRomanNumerals(number, lowerCase = false) {
2768 (0, _util.assert)(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
2769 const romanBuf = [];
2770 let pos;
2771
2772 while (number >= 1000) {
2773 number -= 1000;
2774 romanBuf.push("M");
2775 }
2776
2777 pos = number / 100 | 0;
2778 number %= 100;
2779 romanBuf.push(ROMAN_NUMBER_MAP[pos]);
2780 pos = number / 10 | 0;
2781 number %= 10;
2782 romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
2783 romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
2784 const romanStr = romanBuf.join("");
2785 return lowerCase ? romanStr.toLowerCase() : romanStr;
2786}
2787
2788function log2(x) {
2789 if (x <= 0) {
2790 return 0;
2791 }
2792
2793 return Math.ceil(Math.log2(x));
2794}
2795
2796function readInt8(data, offset) {
2797 return data[offset] << 24 >> 24;
2798}
2799
2800function readUint16(data, offset) {
2801 return data[offset] << 8 | data[offset + 1];
2802}
2803
2804function readUint32(data, offset) {
2805 return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
2806}
2807
2808function isWhiteSpace(ch) {
2809 return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
2810}
2811
2812/***/ }),
2813/* 9 */
2814/***/ (function(module, exports, __w_pdfjs_require__) {
2815
2816"use strict";
2817
2818
2819Object.defineProperty(exports, "__esModule", {
2820 value: true
2821});
2822exports.PDFDocument = exports.Page = void 0;
2823
2824var _util = __w_pdfjs_require__(2);
2825
2826var _obj = __w_pdfjs_require__(10);
2827
2828var _primitives = __w_pdfjs_require__(5);
2829
2830var _core_utils = __w_pdfjs_require__(8);
2831
2832var _stream = __w_pdfjs_require__(12);
2833
2834var _annotation = __w_pdfjs_require__(25);
2835
2836var _crypto = __w_pdfjs_require__(22);
2837
2838var _parser = __w_pdfjs_require__(11);
2839
2840var _operator_list = __w_pdfjs_require__(26);
2841
2842var _evaluator = __w_pdfjs_require__(27);
2843
2844var _function = __w_pdfjs_require__(41);
2845
2846const DEFAULT_USER_UNIT = 1.0;
2847const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
2848
2849function isAnnotationRenderable(annotation, intent) {
2850 return intent === "display" && annotation.viewable || intent === "print" && annotation.printable;
2851}
2852
2853class Page {
2854 constructor({
2855 pdfManager,
2856 xref,
2857 pageIndex,
2858 pageDict,
2859 ref,
2860 fontCache,
2861 builtInCMapCache,
2862 globalImageCache,
2863 pdfFunctionFactory
2864 }) {
2865 this.pdfManager = pdfManager;
2866 this.pageIndex = pageIndex;
2867 this.pageDict = pageDict;
2868 this.xref = xref;
2869 this.ref = ref;
2870 this.fontCache = fontCache;
2871 this.builtInCMapCache = builtInCMapCache;
2872 this.globalImageCache = globalImageCache;
2873 this.pdfFunctionFactory = pdfFunctionFactory;
2874 this.evaluatorOptions = pdfManager.evaluatorOptions;
2875 this.resourcesPromise = null;
2876 const idCounters = {
2877 obj: 0
2878 };
2879 this.idFactory = {
2880 createObjId() {
2881 return `p${pageIndex}_${++idCounters.obj}`;
2882 },
2883
2884 getDocId() {
2885 return `g_${pdfManager.docId}`;
2886 }
2887
2888 };
2889 }
2890
2891 _getInheritableProperty(key, getArray = false) {
2892 const value = (0, _core_utils.getInheritableProperty)({
2893 dict: this.pageDict,
2894 key,
2895 getArray,
2896 stopWhenFound: false
2897 });
2898
2899 if (!Array.isArray(value)) {
2900 return value;
2901 }
2902
2903 if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
2904 return value[0];
2905 }
2906
2907 return _primitives.Dict.merge(this.xref, value);
2908 }
2909
2910 get content() {
2911 return this.pageDict.get("Contents");
2912 }
2913
2914 get resources() {
2915 return (0, _util.shadow)(this, "resources", this._getInheritableProperty("Resources") || _primitives.Dict.empty);
2916 }
2917
2918 _getBoundingBox(name) {
2919 const box = this._getInheritableProperty(name, true);
2920
2921 if (Array.isArray(box) && box.length === 4) {
2922 if (box[2] - box[0] !== 0 && box[3] - box[1] !== 0) {
2923 return box;
2924 }
2925
2926 (0, _util.warn)(`Empty /${name} entry.`);
2927 }
2928
2929 return null;
2930 }
2931
2932 get mediaBox() {
2933 return (0, _util.shadow)(this, "mediaBox", this._getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX);
2934 }
2935
2936 get cropBox() {
2937 return (0, _util.shadow)(this, "cropBox", this._getBoundingBox("CropBox") || this.mediaBox);
2938 }
2939
2940 get userUnit() {
2941 let obj = this.pageDict.get("UserUnit");
2942
2943 if (!(0, _util.isNum)(obj) || obj <= 0) {
2944 obj = DEFAULT_USER_UNIT;
2945 }
2946
2947 return (0, _util.shadow)(this, "userUnit", obj);
2948 }
2949
2950 get view() {
2951 const {
2952 cropBox,
2953 mediaBox
2954 } = this;
2955 let view;
2956
2957 if (cropBox === mediaBox || (0, _util.isArrayEqual)(cropBox, mediaBox)) {
2958 view = mediaBox;
2959 } else {
2960 const box = _util.Util.intersect(cropBox, mediaBox);
2961
2962 if (box && box[2] - box[0] !== 0 && box[3] - box[1] !== 0) {
2963 view = box;
2964 } else {
2965 (0, _util.warn)("Empty /CropBox and /MediaBox intersection.");
2966 }
2967 }
2968
2969 return (0, _util.shadow)(this, "view", view || mediaBox);
2970 }
2971
2972 get rotate() {
2973 let rotate = this._getInheritableProperty("Rotate") || 0;
2974
2975 if (rotate % 90 !== 0) {
2976 rotate = 0;
2977 } else if (rotate >= 360) {
2978 rotate = rotate % 360;
2979 } else if (rotate < 0) {
2980 rotate = (rotate % 360 + 360) % 360;
2981 }
2982
2983 return (0, _util.shadow)(this, "rotate", rotate);
2984 }
2985
2986 getContentStream() {
2987 const content = this.content;
2988 let stream;
2989
2990 if (Array.isArray(content)) {
2991 const xref = this.xref;
2992 const streams = [];
2993
2994 for (const subStream of content) {
2995 streams.push(xref.fetchIfRef(subStream));
2996 }
2997
2998 stream = new _stream.StreamsSequenceStream(streams);
2999 } else if ((0, _primitives.isStream)(content)) {
3000 stream = content;
3001 } else {
3002 stream = new _stream.NullStream();
3003 }
3004
3005 return stream;
3006 }
3007
3008 loadResources(keys) {
3009 if (!this.resourcesPromise) {
3010 this.resourcesPromise = this.pdfManager.ensure(this, "resources");
3011 }
3012
3013 return this.resourcesPromise.then(() => {
3014 const objectLoader = new _obj.ObjectLoader(this.resources, keys, this.xref);
3015 return objectLoader.load();
3016 });
3017 }
3018
3019 getOperatorList({
3020 handler,
3021 sink,
3022 task,
3023 intent,
3024 renderInteractiveForms
3025 }) {
3026 const contentStreamPromise = this.pdfManager.ensure(this, "getContentStream");
3027 const resourcesPromise = this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"]);
3028 const partialEvaluator = new _evaluator.PartialEvaluator({
3029 xref: this.xref,
3030 handler,
3031 pageIndex: this.pageIndex,
3032 idFactory: this.idFactory,
3033 fontCache: this.fontCache,
3034 builtInCMapCache: this.builtInCMapCache,
3035 globalImageCache: this.globalImageCache,
3036 options: this.evaluatorOptions,
3037 pdfFunctionFactory: this.pdfFunctionFactory
3038 });
3039 const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
3040 const pageListPromise = dataPromises.then(([contentStream]) => {
3041 const opList = new _operator_list.OperatorList(intent, sink, this.pageIndex);
3042 handler.send("StartRenderPage", {
3043 transparency: partialEvaluator.hasBlendModes(this.resources),
3044 pageIndex: this.pageIndex,
3045 intent
3046 });
3047 return partialEvaluator.getOperatorList({
3048 stream: contentStream,
3049 task,
3050 resources: this.resources,
3051 operatorList: opList
3052 }).then(function () {
3053 return opList;
3054 });
3055 });
3056 return Promise.all([pageListPromise, this._parsedAnnotations]).then(function ([pageOpList, annotations]) {
3057 if (annotations.length === 0) {
3058 pageOpList.flush(true);
3059 return {
3060 length: pageOpList.totalLength
3061 };
3062 }
3063
3064 const opListPromises = [];
3065
3066 for (const annotation of annotations) {
3067 if (isAnnotationRenderable(annotation, intent)) {
3068 opListPromises.push(annotation.getOperatorList(partialEvaluator, task, renderInteractiveForms).catch(function (reason) {
3069 (0, _util.warn)("getOperatorList - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
3070 return null;
3071 }));
3072 }
3073 }
3074
3075 return Promise.all(opListPromises).then(function (opLists) {
3076 pageOpList.addOp(_util.OPS.beginAnnotations, []);
3077
3078 for (const opList of opLists) {
3079 pageOpList.addOpList(opList);
3080 }
3081
3082 pageOpList.addOp(_util.OPS.endAnnotations, []);
3083 pageOpList.flush(true);
3084 return {
3085 length: pageOpList.totalLength
3086 };
3087 });
3088 });
3089 }
3090
3091 extractTextContent({
3092 handler,
3093 task,
3094 normalizeWhitespace,
3095 sink,
3096 combineTextItems
3097 }) {
3098 const contentStreamPromise = this.pdfManager.ensure(this, "getContentStream");
3099 const resourcesPromise = this.loadResources(["ExtGState", "XObject", "Font"]);
3100 const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
3101 return dataPromises.then(([contentStream]) => {
3102 const partialEvaluator = new _evaluator.PartialEvaluator({
3103 xref: this.xref,
3104 handler,
3105 pageIndex: this.pageIndex,
3106 idFactory: this.idFactory,
3107 fontCache: this.fontCache,
3108 builtInCMapCache: this.builtInCMapCache,
3109 globalImageCache: this.globalImageCache,
3110 options: this.evaluatorOptions,
3111 pdfFunctionFactory: this.pdfFunctionFactory
3112 });
3113 return partialEvaluator.getTextContent({
3114 stream: contentStream,
3115 task,
3116 resources: this.resources,
3117 normalizeWhitespace,
3118 combineTextItems,
3119 sink
3120 });
3121 });
3122 }
3123
3124 getAnnotationsData(intent) {
3125 return this._parsedAnnotations.then(function (annotations) {
3126 const annotationsData = [];
3127
3128 for (let i = 0, ii = annotations.length; i < ii; i++) {
3129 if (!intent || isAnnotationRenderable(annotations[i], intent)) {
3130 annotationsData.push(annotations[i].data);
3131 }
3132 }
3133
3134 return annotationsData;
3135 });
3136 }
3137
3138 get annotations() {
3139 return (0, _util.shadow)(this, "annotations", this._getInheritableProperty("Annots") || []);
3140 }
3141
3142 get _parsedAnnotations() {
3143 const parsedAnnotations = this.pdfManager.ensure(this, "annotations").then(() => {
3144 const annotationPromises = [];
3145
3146 for (const annotationRef of this.annotations) {
3147 annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory).catch(function (reason) {
3148 (0, _util.warn)(`_parsedAnnotations: "${reason}".`);
3149 return null;
3150 }));
3151 }
3152
3153 return Promise.all(annotationPromises).then(function (annotations) {
3154 return annotations.filter(annotation => !!annotation);
3155 });
3156 });
3157 return (0, _util.shadow)(this, "_parsedAnnotations", parsedAnnotations);
3158 }
3159
3160}
3161
3162exports.Page = Page;
3163const PDF_HEADER_SIGNATURE = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
3164const STARTXREF_SIGNATURE = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
3165const ENDOBJ_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
3166const FINGERPRINT_FIRST_BYTES = 1024;
3167const EMPTY_FINGERPRINT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
3168const PDF_HEADER_VERSION_REGEXP = /^[1-9]\.[0-9]$/;
3169
3170function find(stream, signature, limit = 1024, backwards = false) {
3171 const signatureLength = signature.length;
3172 const scanBytes = stream.peekBytes(limit);
3173 const scanLength = scanBytes.length - signatureLength;
3174
3175 if (scanLength <= 0) {
3176 return false;
3177 }
3178
3179 if (backwards) {
3180 const signatureEnd = signatureLength - 1;
3181 let pos = scanBytes.length - 1;
3182
3183 while (pos >= signatureEnd) {
3184 let j = 0;
3185
3186 while (j < signatureLength && scanBytes[pos - j] === signature[signatureEnd - j]) {
3187 j++;
3188 }
3189
3190 if (j >= signatureLength) {
3191 stream.pos += pos - signatureEnd;
3192 return true;
3193 }
3194
3195 pos--;
3196 }
3197 } else {
3198 let pos = 0;
3199
3200 while (pos <= scanLength) {
3201 let j = 0;
3202
3203 while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
3204 j++;
3205 }
3206
3207 if (j >= signatureLength) {
3208 stream.pos += pos;
3209 return true;
3210 }
3211
3212 pos++;
3213 }
3214 }
3215
3216 return false;
3217}
3218
3219class PDFDocument {
3220 constructor(pdfManager, arg) {
3221 let stream;
3222
3223 if ((0, _primitives.isStream)(arg)) {
3224 stream = arg;
3225 } else if ((0, _util.isArrayBuffer)(arg)) {
3226 stream = new _stream.Stream(arg);
3227 } else {
3228 throw new Error("PDFDocument: Unknown argument type");
3229 }
3230
3231 if (stream.length <= 0) {
3232 throw new _util.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");
3233 }
3234
3235 this.pdfManager = pdfManager;
3236 this.stream = stream;
3237 this.xref = new _obj.XRef(stream, pdfManager);
3238 this.pdfFunctionFactory = new _function.PDFFunctionFactory({
3239 xref: this.xref,
3240 isEvalSupported: pdfManager.evaluatorOptions.isEvalSupported
3241 });
3242 this._pagePromises = [];
3243 }
3244
3245 parse(recoveryMode) {
3246 this.setup(recoveryMode);
3247 const version = this.catalog.catDict.get("Version");
3248
3249 if ((0, _primitives.isName)(version)) {
3250 this.pdfFormatVersion = version.name;
3251 }
3252
3253 try {
3254 this.acroForm = this.catalog.catDict.get("AcroForm");
3255
3256 if (this.acroForm) {
3257 this.xfa = this.acroForm.get("XFA");
3258 const fields = this.acroForm.get("Fields");
3259
3260 if ((!Array.isArray(fields) || fields.length === 0) && !this.xfa) {
3261 this.acroForm = null;
3262 }
3263 }
3264 } catch (ex) {
3265 if (ex instanceof _core_utils.MissingDataException) {
3266 throw ex;
3267 }
3268
3269 (0, _util.info)("Cannot fetch AcroForm entry; assuming no AcroForms are present");
3270 this.acroForm = null;
3271 }
3272
3273 try {
3274 const collection = this.catalog.catDict.get("Collection");
3275
3276 if ((0, _primitives.isDict)(collection) && collection.getKeys().length > 0) {
3277 this.collection = collection;
3278 }
3279 } catch (ex) {
3280 if (ex instanceof _core_utils.MissingDataException) {
3281 throw ex;
3282 }
3283
3284 (0, _util.info)("Cannot fetch Collection dictionary.");
3285 }
3286 }
3287
3288 get linearization() {
3289 let linearization = null;
3290
3291 try {
3292 linearization = _parser.Linearization.create(this.stream);
3293 } catch (err) {
3294 if (err instanceof _core_utils.MissingDataException) {
3295 throw err;
3296 }
3297
3298 (0, _util.info)(err);
3299 }
3300
3301 return (0, _util.shadow)(this, "linearization", linearization);
3302 }
3303
3304 get startXRef() {
3305 const stream = this.stream;
3306 let startXRef = 0;
3307
3308 if (this.linearization) {
3309 stream.reset();
3310
3311 if (find(stream, ENDOBJ_SIGNATURE)) {
3312 startXRef = stream.pos + 6 - stream.start;
3313 }
3314 } else {
3315 const step = 1024;
3316 const startXRefLength = STARTXREF_SIGNATURE.length;
3317 let found = false,
3318 pos = stream.end;
3319
3320 while (!found && pos > 0) {
3321 pos -= step - startXRefLength;
3322
3323 if (pos < 0) {
3324 pos = 0;
3325 }
3326
3327 stream.pos = pos;
3328 found = find(stream, STARTXREF_SIGNATURE, step, true);
3329 }
3330
3331 if (found) {
3332 stream.skip(9);
3333 let ch;
3334
3335 do {
3336 ch = stream.getByte();
3337 } while ((0, _core_utils.isWhiteSpace)(ch));
3338
3339 let str = "";
3340
3341 while (ch >= 0x20 && ch <= 0x39) {
3342 str += String.fromCharCode(ch);
3343 ch = stream.getByte();
3344 }
3345
3346 startXRef = parseInt(str, 10);
3347
3348 if (isNaN(startXRef)) {
3349 startXRef = 0;
3350 }
3351 }
3352 }
3353
3354 return (0, _util.shadow)(this, "startXRef", startXRef);
3355 }
3356
3357 checkHeader() {
3358 const stream = this.stream;
3359 stream.reset();
3360
3361 if (!find(stream, PDF_HEADER_SIGNATURE)) {
3362 return;
3363 }
3364
3365 stream.moveStart();
3366 const MAX_PDF_VERSION_LENGTH = 12;
3367 let version = "",
3368 ch;
3369
3370 while ((ch = stream.getByte()) > 0x20) {
3371 if (version.length >= MAX_PDF_VERSION_LENGTH) {
3372 break;
3373 }
3374
3375 version += String.fromCharCode(ch);
3376 }
3377
3378 if (!this.pdfFormatVersion) {
3379 this.pdfFormatVersion = version.substring(5);
3380 }
3381 }
3382
3383 parseStartXRef() {
3384 this.xref.setStartXRef(this.startXRef);
3385 }
3386
3387 setup(recoveryMode) {
3388 this.xref.parse(recoveryMode);
3389 this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
3390 }
3391
3392 get numPages() {
3393 const linearization = this.linearization;
3394 const num = linearization ? linearization.numPages : this.catalog.numPages;
3395 return (0, _util.shadow)(this, "numPages", num);
3396 }
3397
3398 get documentInfo() {
3399 const DocumentInfoValidators = {
3400 Title: _util.isString,
3401 Author: _util.isString,
3402 Subject: _util.isString,
3403 Keywords: _util.isString,
3404 Creator: _util.isString,
3405 Producer: _util.isString,
3406 CreationDate: _util.isString,
3407 ModDate: _util.isString,
3408 Trapped: _primitives.isName
3409 };
3410 let version = this.pdfFormatVersion;
3411
3412 if (typeof version !== "string" || !PDF_HEADER_VERSION_REGEXP.test(version)) {
3413 (0, _util.warn)(`Invalid PDF header version number: ${version}`);
3414 version = null;
3415 }
3416
3417 const docInfo = {
3418 PDFFormatVersion: version,
3419 IsLinearized: !!this.linearization,
3420 IsAcroFormPresent: !!this.acroForm,
3421 IsXFAPresent: !!this.xfa,
3422 IsCollectionPresent: !!this.collection
3423 };
3424 let infoDict;
3425
3426 try {
3427 infoDict = this.xref.trailer.get("Info");
3428 } catch (err) {
3429 if (err instanceof _core_utils.MissingDataException) {
3430 throw err;
3431 }
3432
3433 (0, _util.info)("The document information dictionary is invalid.");
3434 }
3435
3436 if ((0, _primitives.isDict)(infoDict)) {
3437 for (const key of infoDict.getKeys()) {
3438 const value = infoDict.get(key);
3439
3440 if (DocumentInfoValidators[key]) {
3441 if (DocumentInfoValidators[key](value)) {
3442 docInfo[key] = typeof value !== "string" ? value : (0, _util.stringToPDFString)(value);
3443 } else {
3444 (0, _util.info)(`Bad value in document info for "${key}".`);
3445 }
3446 } else if (typeof key === "string") {
3447 let customValue;
3448
3449 if ((0, _util.isString)(value)) {
3450 customValue = (0, _util.stringToPDFString)(value);
3451 } else if ((0, _primitives.isName)(value) || (0, _util.isNum)(value) || (0, _util.isBool)(value)) {
3452 customValue = value;
3453 } else {
3454 (0, _util.info)(`Unsupported value in document info for (custom) "${key}".`);
3455 continue;
3456 }
3457
3458 if (!docInfo.Custom) {
3459 docInfo.Custom = Object.create(null);
3460 }
3461
3462 docInfo.Custom[key] = customValue;
3463 }
3464 }
3465 }
3466
3467 return (0, _util.shadow)(this, "documentInfo", docInfo);
3468 }
3469
3470 get fingerprint() {
3471 let hash;
3472 const idArray = this.xref.trailer.get("ID");
3473
3474 if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
3475 hash = (0, _util.stringToBytes)(idArray[0]);
3476 } else {
3477 hash = (0, _crypto.calculateMD5)(this.stream.getByteRange(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
3478 }
3479
3480 const fingerprintBuf = [];
3481
3482 for (let i = 0, ii = hash.length; i < ii; i++) {
3483 const hex = hash[i].toString(16);
3484 fingerprintBuf.push(hex.padStart(2, "0"));
3485 }
3486
3487 return (0, _util.shadow)(this, "fingerprint", fingerprintBuf.join(""));
3488 }
3489
3490 _getLinearizationPage(pageIndex) {
3491 const {
3492 catalog,
3493 linearization
3494 } = this;
3495
3496 const ref = _primitives.Ref.get(linearization.objectNumberFirst, 0);
3497
3498 return this.xref.fetchAsync(ref).then(obj => {
3499 if ((0, _primitives.isDict)(obj, "Page") || (0, _primitives.isDict)(obj) && !obj.has("Type") && obj.has("Contents")) {
3500 if (ref && !catalog.pageKidsCountCache.has(ref)) {
3501 catalog.pageKidsCountCache.put(ref, 1);
3502 }
3503
3504 return [obj, ref];
3505 }
3506
3507 throw new _util.FormatError("The Linearization dictionary doesn't point " + "to a valid Page dictionary.");
3508 }).catch(reason => {
3509 (0, _util.info)(reason);
3510 return catalog.getPageDict(pageIndex);
3511 });
3512 }
3513
3514 getPage(pageIndex) {
3515 if (this._pagePromises[pageIndex] !== undefined) {
3516 return this._pagePromises[pageIndex];
3517 }
3518
3519 const {
3520 catalog,
3521 linearization
3522 } = this;
3523 const promise = linearization && linearization.pageFirst === pageIndex ? this._getLinearizationPage(pageIndex) : catalog.getPageDict(pageIndex);
3524 return this._pagePromises[pageIndex] = promise.then(([pageDict, ref]) => {
3525 return new Page({
3526 pdfManager: this.pdfManager,
3527 xref: this.xref,
3528 pageIndex,
3529 pageDict,
3530 ref,
3531 fontCache: catalog.fontCache,
3532 builtInCMapCache: catalog.builtInCMapCache,
3533 globalImageCache: catalog.globalImageCache,
3534 pdfFunctionFactory: this.pdfFunctionFactory
3535 });
3536 });
3537 }
3538
3539 checkFirstPage() {
3540 return this.getPage(0).catch(async reason => {
3541 if (reason instanceof _core_utils.XRefEntryException) {
3542 this._pagePromises.length = 0;
3543 await this.cleanup();
3544 throw new _core_utils.XRefParseException();
3545 }
3546 });
3547 }
3548
3549 fontFallback(id, handler) {
3550 return this.catalog.fontFallback(id, handler);
3551 }
3552
3553 async cleanup(manuallyTriggered = false) {
3554 return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _primitives.clearPrimitiveCaches)();
3555 }
3556
3557}
3558
3559exports.PDFDocument = PDFDocument;
3560
3561/***/ }),
3562/* 10 */
3563/***/ (function(module, exports, __w_pdfjs_require__) {
3564
3565"use strict";
3566
3567
3568Object.defineProperty(exports, "__esModule", {
3569 value: true
3570});
3571exports.FileSpec = exports.XRef = exports.ObjectLoader = exports.Catalog = void 0;
3572
3573var _util = __w_pdfjs_require__(2);
3574
3575var _primitives = __w_pdfjs_require__(5);
3576
3577var _parser = __w_pdfjs_require__(11);
3578
3579var _core_utils = __w_pdfjs_require__(8);
3580
3581var _crypto = __w_pdfjs_require__(22);
3582
3583var _colorspace = __w_pdfjs_require__(23);
3584
3585var _image_utils = __w_pdfjs_require__(24);
3586
3587function fetchDestination(dest) {
3588 return (0, _primitives.isDict)(dest) ? dest.get("D") : dest;
3589}
3590
3591class Catalog {
3592 constructor(pdfManager, xref) {
3593 this.pdfManager = pdfManager;
3594 this.xref = xref;
3595 this.catDict = xref.getCatalogObj();
3596
3597 if (!(0, _primitives.isDict)(this.catDict)) {
3598 throw new _util.FormatError("Catalog object is not a dictionary.");
3599 }
3600
3601 this.fontCache = new _primitives.RefSetCache();
3602 this.builtInCMapCache = new Map();
3603 this.globalImageCache = new _image_utils.GlobalImageCache();
3604 this.pageKidsCountCache = new _primitives.RefSetCache();
3605 }
3606
3607 get metadata() {
3608 const streamRef = this.catDict.getRaw("Metadata");
3609
3610 if (!(0, _primitives.isRef)(streamRef)) {
3611 return (0, _util.shadow)(this, "metadata", null);
3612 }
3613
3614 const suppressEncryption = !(this.xref.encrypt && this.xref.encrypt.encryptMetadata);
3615 const stream = this.xref.fetch(streamRef, suppressEncryption);
3616 let metadata;
3617
3618 if (stream && (0, _primitives.isDict)(stream.dict)) {
3619 const type = stream.dict.get("Type");
3620 const subtype = stream.dict.get("Subtype");
3621
3622 if ((0, _primitives.isName)(type, "Metadata") && (0, _primitives.isName)(subtype, "XML")) {
3623 try {
3624 metadata = (0, _util.stringToUTF8String)((0, _util.bytesToString)(stream.getBytes()));
3625 } catch (e) {
3626 if (e instanceof _core_utils.MissingDataException) {
3627 throw e;
3628 }
3629
3630 (0, _util.info)("Skipping invalid metadata.");
3631 }
3632 }
3633 }
3634
3635 return (0, _util.shadow)(this, "metadata", metadata);
3636 }
3637
3638 get toplevelPagesDict() {
3639 const pagesObj = this.catDict.get("Pages");
3640
3641 if (!(0, _primitives.isDict)(pagesObj)) {
3642 throw new _util.FormatError("Invalid top-level pages dictionary.");
3643 }
3644
3645 return (0, _util.shadow)(this, "toplevelPagesDict", pagesObj);
3646 }
3647
3648 get documentOutline() {
3649 let obj = null;
3650
3651 try {
3652 obj = this._readDocumentOutline();
3653 } catch (ex) {
3654 if (ex instanceof _core_utils.MissingDataException) {
3655 throw ex;
3656 }
3657
3658 (0, _util.warn)("Unable to read document outline.");
3659 }
3660
3661 return (0, _util.shadow)(this, "documentOutline", obj);
3662 }
3663
3664 _readDocumentOutline() {
3665 let obj = this.catDict.get("Outlines");
3666
3667 if (!(0, _primitives.isDict)(obj)) {
3668 return null;
3669 }
3670
3671 obj = obj.getRaw("First");
3672
3673 if (!(0, _primitives.isRef)(obj)) {
3674 return null;
3675 }
3676
3677 const root = {
3678 items: []
3679 };
3680 const queue = [{
3681 obj,
3682 parent: root
3683 }];
3684 const processed = new _primitives.RefSet();
3685 processed.put(obj);
3686 const xref = this.xref,
3687 blackColor = new Uint8ClampedArray(3);
3688
3689 while (queue.length > 0) {
3690 const i = queue.shift();
3691 const outlineDict = xref.fetchIfRef(i.obj);
3692
3693 if (outlineDict === null) {
3694 continue;
3695 }
3696
3697 if (!outlineDict.has("Title")) {
3698 throw new _util.FormatError("Invalid outline item encountered.");
3699 }
3700
3701 const data = {
3702 url: null,
3703 dest: null
3704 };
3705 Catalog.parseDestDictionary({
3706 destDict: outlineDict,
3707 resultObj: data,
3708 docBaseUrl: this.pdfManager.docBaseUrl
3709 });
3710 const title = outlineDict.get("Title");
3711 const flags = outlineDict.get("F") || 0;
3712 const color = outlineDict.getArray("C");
3713 const count = outlineDict.get("Count");
3714 let rgbColor = blackColor;
3715
3716 if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
3717 rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
3718 }
3719
3720 const outlineItem = {
3721 dest: data.dest,
3722 url: data.url,
3723 unsafeUrl: data.unsafeUrl,
3724 newWindow: data.newWindow,
3725 title: (0, _util.stringToPDFString)(title),
3726 color: rgbColor,
3727 count: Number.isInteger(count) ? count : undefined,
3728 bold: !!(flags & 2),
3729 italic: !!(flags & 1),
3730 items: []
3731 };
3732 i.parent.items.push(outlineItem);
3733 obj = outlineDict.getRaw("First");
3734
3735 if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
3736 queue.push({
3737 obj,
3738 parent: outlineItem
3739 });
3740 processed.put(obj);
3741 }
3742
3743 obj = outlineDict.getRaw("Next");
3744
3745 if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
3746 queue.push({
3747 obj,
3748 parent: i.parent
3749 });
3750 processed.put(obj);
3751 }
3752 }
3753
3754 return root.items.length > 0 ? root.items : null;
3755 }
3756
3757 get permissions() {
3758 let permissions = null;
3759
3760 try {
3761 permissions = this._readPermissions();
3762 } catch (ex) {
3763 if (ex instanceof _core_utils.MissingDataException) {
3764 throw ex;
3765 }
3766
3767 (0, _util.warn)("Unable to read permissions.");
3768 }
3769
3770 return (0, _util.shadow)(this, "permissions", permissions);
3771 }
3772
3773 _readPermissions() {
3774 const encrypt = this.xref.trailer.get("Encrypt");
3775
3776 if (!(0, _primitives.isDict)(encrypt)) {
3777 return null;
3778 }
3779
3780 let flags = encrypt.get("P");
3781
3782 if (!(0, _util.isNum)(flags)) {
3783 return null;
3784 }
3785
3786 flags += 2 ** 32;
3787 const permissions = [];
3788
3789 for (const key in _util.PermissionFlag) {
3790 const value = _util.PermissionFlag[key];
3791
3792 if (flags & value) {
3793 permissions.push(value);
3794 }
3795 }
3796
3797 return permissions;
3798 }
3799
3800 get numPages() {
3801 const obj = this.toplevelPagesDict.get("Count");
3802
3803 if (!Number.isInteger(obj)) {
3804 throw new _util.FormatError("Page count in top-level pages dictionary is not an integer.");
3805 }
3806
3807 return (0, _util.shadow)(this, "numPages", obj);
3808 }
3809
3810 get destinations() {
3811 const obj = this._readDests(),
3812 dests = Object.create(null);
3813
3814 if (obj instanceof NameTree) {
3815 const names = obj.getAll();
3816
3817 for (const name in names) {
3818 dests[name] = fetchDestination(names[name]);
3819 }
3820 } else if (obj instanceof _primitives.Dict) {
3821 obj.forEach(function (key, value) {
3822 if (value) {
3823 dests[key] = fetchDestination(value);
3824 }
3825 });
3826 }
3827
3828 return (0, _util.shadow)(this, "destinations", dests);
3829 }
3830
3831 getDestination(destinationId) {
3832 const obj = this._readDests();
3833
3834 if (obj instanceof NameTree || obj instanceof _primitives.Dict) {
3835 return fetchDestination(obj.get(destinationId) || null);
3836 }
3837
3838 return null;
3839 }
3840
3841 _readDests() {
3842 const obj = this.catDict.get("Names");
3843
3844 if (obj && obj.has("Dests")) {
3845 return new NameTree(obj.getRaw("Dests"), this.xref);
3846 } else if (this.catDict.has("Dests")) {
3847 return this.catDict.get("Dests");
3848 }
3849
3850 return undefined;
3851 }
3852
3853 get pageLabels() {
3854 let obj = null;
3855
3856 try {
3857 obj = this._readPageLabels();
3858 } catch (ex) {
3859 if (ex instanceof _core_utils.MissingDataException) {
3860 throw ex;
3861 }
3862
3863 (0, _util.warn)("Unable to read page labels.");
3864 }
3865
3866 return (0, _util.shadow)(this, "pageLabels", obj);
3867 }
3868
3869 _readPageLabels() {
3870 const obj = this.catDict.getRaw("PageLabels");
3871
3872 if (!obj) {
3873 return null;
3874 }
3875
3876 const pageLabels = new Array(this.numPages);
3877 let style = null,
3878 prefix = "";
3879 const numberTree = new NumberTree(obj, this.xref);
3880 const nums = numberTree.getAll();
3881 let currentLabel = "",
3882 currentIndex = 1;
3883
3884 for (let i = 0, ii = this.numPages; i < ii; i++) {
3885 if (i in nums) {
3886 const labelDict = nums[i];
3887
3888 if (!(0, _primitives.isDict)(labelDict)) {
3889 throw new _util.FormatError("PageLabel is not a dictionary.");
3890 }
3891
3892 if (labelDict.has("Type") && !(0, _primitives.isName)(labelDict.get("Type"), "PageLabel")) {
3893 throw new _util.FormatError("Invalid type in PageLabel dictionary.");
3894 }
3895
3896 if (labelDict.has("S")) {
3897 const s = labelDict.get("S");
3898
3899 if (!(0, _primitives.isName)(s)) {
3900 throw new _util.FormatError("Invalid style in PageLabel dictionary.");
3901 }
3902
3903 style = s.name;
3904 } else {
3905 style = null;
3906 }
3907
3908 if (labelDict.has("P")) {
3909 const p = labelDict.get("P");
3910
3911 if (!(0, _util.isString)(p)) {
3912 throw new _util.FormatError("Invalid prefix in PageLabel dictionary.");
3913 }
3914
3915 prefix = (0, _util.stringToPDFString)(p);
3916 } else {
3917 prefix = "";
3918 }
3919
3920 if (labelDict.has("St")) {
3921 const st = labelDict.get("St");
3922
3923 if (!(Number.isInteger(st) && st >= 1)) {
3924 throw new _util.FormatError("Invalid start in PageLabel dictionary.");
3925 }
3926
3927 currentIndex = st;
3928 } else {
3929 currentIndex = 1;
3930 }
3931 }
3932
3933 switch (style) {
3934 case "D":
3935 currentLabel = currentIndex;
3936 break;
3937
3938 case "R":
3939 case "r":
3940 currentLabel = (0, _core_utils.toRomanNumerals)(currentIndex, style === "r");
3941 break;
3942
3943 case "A":
3944 case "a":
3945 const LIMIT = 26;
3946 const A_UPPER_CASE = 0x41,
3947 A_LOWER_CASE = 0x61;
3948 const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
3949 const letterIndex = currentIndex - 1;
3950 const character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
3951 const charBuf = [];
3952
3953 for (let j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
3954 charBuf.push(character);
3955 }
3956
3957 currentLabel = charBuf.join("");
3958 break;
3959
3960 default:
3961 if (style) {
3962 throw new _util.FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
3963 }
3964
3965 currentLabel = "";
3966 }
3967
3968 pageLabels[i] = prefix + currentLabel;
3969 currentIndex++;
3970 }
3971
3972 return pageLabels;
3973 }
3974
3975 get pageLayout() {
3976 const obj = this.catDict.get("PageLayout");
3977 let pageLayout = "";
3978
3979 if ((0, _primitives.isName)(obj)) {
3980 switch (obj.name) {
3981 case "SinglePage":
3982 case "OneColumn":
3983 case "TwoColumnLeft":
3984 case "TwoColumnRight":
3985 case "TwoPageLeft":
3986 case "TwoPageRight":
3987 pageLayout = obj.name;
3988 }
3989 }
3990
3991 return (0, _util.shadow)(this, "pageLayout", pageLayout);
3992 }
3993
3994 get pageMode() {
3995 const obj = this.catDict.get("PageMode");
3996 let pageMode = "UseNone";
3997
3998 if ((0, _primitives.isName)(obj)) {
3999 switch (obj.name) {
4000 case "UseNone":
4001 case "UseOutlines":
4002 case "UseThumbs":
4003 case "FullScreen":
4004 case "UseOC":
4005 case "UseAttachments":
4006 pageMode = obj.name;
4007 }
4008 }
4009
4010 return (0, _util.shadow)(this, "pageMode", pageMode);
4011 }
4012
4013 get viewerPreferences() {
4014 const ViewerPreferencesValidators = {
4015 HideToolbar: _util.isBool,
4016 HideMenubar: _util.isBool,
4017 HideWindowUI: _util.isBool,
4018 FitWindow: _util.isBool,
4019 CenterWindow: _util.isBool,
4020 DisplayDocTitle: _util.isBool,
4021 NonFullScreenPageMode: _primitives.isName,
4022 Direction: _primitives.isName,
4023 ViewArea: _primitives.isName,
4024 ViewClip: _primitives.isName,
4025 PrintArea: _primitives.isName,
4026 PrintClip: _primitives.isName,
4027 PrintScaling: _primitives.isName,
4028 Duplex: _primitives.isName,
4029 PickTrayByPDFSize: _util.isBool,
4030 PrintPageRange: Array.isArray,
4031 NumCopies: Number.isInteger
4032 };
4033 const obj = this.catDict.get("ViewerPreferences");
4034 let prefs = null;
4035
4036 if ((0, _primitives.isDict)(obj)) {
4037 for (const key in ViewerPreferencesValidators) {
4038 if (!obj.has(key)) {
4039 continue;
4040 }
4041
4042 const value = obj.get(key);
4043
4044 if (!ViewerPreferencesValidators[key](value)) {
4045 (0, _util.info)(`Bad value in ViewerPreferences for "${key}".`);
4046 continue;
4047 }
4048
4049 let prefValue;
4050
4051 switch (key) {
4052 case "NonFullScreenPageMode":
4053 switch (value.name) {
4054 case "UseNone":
4055 case "UseOutlines":
4056 case "UseThumbs":
4057 case "UseOC":
4058 prefValue = value.name;
4059 break;
4060
4061 default:
4062 prefValue = "UseNone";
4063 }
4064
4065 break;
4066
4067 case "Direction":
4068 switch (value.name) {
4069 case "L2R":
4070 case "R2L":
4071 prefValue = value.name;
4072 break;
4073
4074 default:
4075 prefValue = "L2R";
4076 }
4077
4078 break;
4079
4080 case "ViewArea":
4081 case "ViewClip":
4082 case "PrintArea":
4083 case "PrintClip":
4084 switch (value.name) {
4085 case "MediaBox":
4086 case "CropBox":
4087 case "BleedBox":
4088 case "TrimBox":
4089 case "ArtBox":
4090 prefValue = value.name;
4091 break;
4092
4093 default:
4094 prefValue = "CropBox";
4095 }
4096
4097 break;
4098
4099 case "PrintScaling":
4100 switch (value.name) {
4101 case "None":
4102 case "AppDefault":
4103 prefValue = value.name;
4104 break;
4105
4106 default:
4107 prefValue = "AppDefault";
4108 }
4109
4110 break;
4111
4112 case "Duplex":
4113 switch (value.name) {
4114 case "Simplex":
4115 case "DuplexFlipShortEdge":
4116 case "DuplexFlipLongEdge":
4117 prefValue = value.name;
4118 break;
4119
4120 default:
4121 prefValue = "None";
4122 }
4123
4124 break;
4125
4126 case "PrintPageRange":
4127 const length = value.length;
4128
4129 if (length % 2 !== 0) {
4130 break;
4131 }
4132
4133 const isValid = value.every((page, i, arr) => {
4134 return Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages;
4135 });
4136
4137 if (isValid) {
4138 prefValue = value;
4139 }
4140
4141 break;
4142
4143 case "NumCopies":
4144 if (value > 0) {
4145 prefValue = value;
4146 }
4147
4148 break;
4149
4150 default:
4151 if (typeof value !== "boolean") {
4152 throw new _util.FormatError(`viewerPreferences - expected a boolean value for: ${key}`);
4153 }
4154
4155 prefValue = value;
4156 }
4157
4158 if (prefValue !== undefined) {
4159 if (!prefs) {
4160 prefs = Object.create(null);
4161 }
4162
4163 prefs[key] = prefValue;
4164 } else {
4165 (0, _util.info)(`Bad value in ViewerPreferences for "${key}".`);
4166 }
4167 }
4168 }
4169
4170 return (0, _util.shadow)(this, "viewerPreferences", prefs);
4171 }
4172
4173 get openAction() {
4174 const obj = this.catDict.get("OpenAction");
4175 let openAction = null;
4176
4177 if ((0, _primitives.isDict)(obj)) {
4178 const destDict = new _primitives.Dict(this.xref);
4179 destDict.set("A", obj);
4180 const resultObj = {
4181 url: null,
4182 dest: null,
4183 action: null
4184 };
4185 Catalog.parseDestDictionary({
4186 destDict,
4187 resultObj
4188 });
4189
4190 if (Array.isArray(resultObj.dest)) {
4191 if (!openAction) {
4192 openAction = Object.create(null);
4193 }
4194
4195 openAction.dest = resultObj.dest;
4196 } else if (resultObj.action) {
4197 if (!openAction) {
4198 openAction = Object.create(null);
4199 }
4200
4201 openAction.action = resultObj.action;
4202 }
4203 } else if (Array.isArray(obj)) {
4204 if (!openAction) {
4205 openAction = Object.create(null);
4206 }
4207
4208 openAction.dest = obj;
4209 }
4210
4211 return (0, _util.shadow)(this, "openAction", openAction);
4212 }
4213
4214 get attachments() {
4215 const obj = this.catDict.get("Names");
4216 let attachments = null;
4217
4218 if (obj && obj.has("EmbeddedFiles")) {
4219 const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
4220 const names = nameTree.getAll();
4221
4222 for (const name in names) {
4223 const fs = new FileSpec(names[name], this.xref);
4224
4225 if (!attachments) {
4226 attachments = Object.create(null);
4227 }
4228
4229 attachments[(0, _util.stringToPDFString)(name)] = fs.serializable;
4230 }
4231 }
4232
4233 return (0, _util.shadow)(this, "attachments", attachments);
4234 }
4235
4236 get javaScript() {
4237 const obj = this.catDict.get("Names");
4238 let javaScript = null;
4239
4240 function appendIfJavaScriptDict(jsDict) {
4241 const type = jsDict.get("S");
4242
4243 if (!(0, _primitives.isName)(type, "JavaScript")) {
4244 return;
4245 }
4246
4247 let js = jsDict.get("JS");
4248
4249 if ((0, _primitives.isStream)(js)) {
4250 js = (0, _util.bytesToString)(js.getBytes());
4251 } else if (!(0, _util.isString)(js)) {
4252 return;
4253 }
4254
4255 if (!javaScript) {
4256 javaScript = [];
4257 }
4258
4259 javaScript.push((0, _util.stringToPDFString)(js));
4260 }
4261
4262 if (obj && obj.has("JavaScript")) {
4263 const nameTree = new NameTree(obj.getRaw("JavaScript"), this.xref);
4264 const names = nameTree.getAll();
4265
4266 for (const name in names) {
4267 const jsDict = names[name];
4268
4269 if ((0, _primitives.isDict)(jsDict)) {
4270 appendIfJavaScriptDict(jsDict);
4271 }
4272 }
4273 }
4274
4275 const openAction = this.catDict.get("OpenAction");
4276
4277 if ((0, _primitives.isDict)(openAction) && (0, _primitives.isName)(openAction.get("S"), "JavaScript")) {
4278 appendIfJavaScriptDict(openAction);
4279 }
4280
4281 return (0, _util.shadow)(this, "javaScript", javaScript);
4282 }
4283
4284 fontFallback(id, handler) {
4285 const promises = [];
4286 this.fontCache.forEach(function (promise) {
4287 promises.push(promise);
4288 });
4289 return Promise.all(promises).then(translatedFonts => {
4290 for (const translatedFont of translatedFonts) {
4291 if (translatedFont.loadedName === id) {
4292 translatedFont.fallback(handler);
4293 return;
4294 }
4295 }
4296 });
4297 }
4298
4299 cleanup(manuallyTriggered = false) {
4300 (0, _primitives.clearPrimitiveCaches)();
4301 this.globalImageCache.clear(manuallyTriggered);
4302 this.pageKidsCountCache.clear();
4303 const promises = [];
4304 this.fontCache.forEach(function (promise) {
4305 promises.push(promise);
4306 });
4307 return Promise.all(promises).then(translatedFonts => {
4308 for (const {
4309 dict
4310 } of translatedFonts) {
4311 delete dict.translated;
4312 }
4313
4314 this.fontCache.clear();
4315 this.builtInCMapCache.clear();
4316 });
4317 }
4318
4319 getPageDict(pageIndex) {
4320 const capability = (0, _util.createPromiseCapability)();
4321 const nodesToVisit = [this.catDict.getRaw("Pages")];
4322 const visitedNodes = new _primitives.RefSet();
4323 const xref = this.xref,
4324 pageKidsCountCache = this.pageKidsCountCache;
4325 let count,
4326 currentPageIndex = 0;
4327
4328 function next() {
4329 while (nodesToVisit.length) {
4330 const currentNode = nodesToVisit.pop();
4331
4332 if ((0, _primitives.isRef)(currentNode)) {
4333 count = pageKidsCountCache.get(currentNode);
4334
4335 if (count > 0 && currentPageIndex + count < pageIndex) {
4336 currentPageIndex += count;
4337 continue;
4338 }
4339
4340 if (visitedNodes.has(currentNode)) {
4341 capability.reject(new _util.FormatError("Pages tree contains circular reference."));
4342 return;
4343 }
4344
4345 visitedNodes.put(currentNode);
4346 xref.fetchAsync(currentNode).then(function (obj) {
4347 if ((0, _primitives.isDict)(obj, "Page") || (0, _primitives.isDict)(obj) && !obj.has("Kids")) {
4348 if (pageIndex === currentPageIndex) {
4349 if (currentNode && !pageKidsCountCache.has(currentNode)) {
4350 pageKidsCountCache.put(currentNode, 1);
4351 }
4352
4353 capability.resolve([obj, currentNode]);
4354 } else {
4355 currentPageIndex++;
4356 next();
4357 }
4358
4359 return;
4360 }
4361
4362 nodesToVisit.push(obj);
4363 next();
4364 }, capability.reject);
4365 return;
4366 }
4367
4368 if (!(0, _primitives.isDict)(currentNode)) {
4369 capability.reject(new _util.FormatError("Page dictionary kid reference points to wrong type of object."));
4370 return;
4371 }
4372
4373 count = currentNode.get("Count");
4374
4375 if (Number.isInteger(count) && count >= 0) {
4376 const objId = currentNode.objId;
4377
4378 if (objId && !pageKidsCountCache.has(objId)) {
4379 pageKidsCountCache.put(objId, count);
4380 }
4381
4382 if (currentPageIndex + count <= pageIndex) {
4383 currentPageIndex += count;
4384 continue;
4385 }
4386 }
4387
4388 const kids = currentNode.get("Kids");
4389
4390 if (!Array.isArray(kids)) {
4391 if ((0, _primitives.isName)(currentNode.get("Type"), "Page") || !currentNode.has("Type") && currentNode.has("Contents")) {
4392 if (currentPageIndex === pageIndex) {
4393 capability.resolve([currentNode, null]);
4394 return;
4395 }
4396
4397 currentPageIndex++;
4398 continue;
4399 }
4400
4401 capability.reject(new _util.FormatError("Page dictionary kids object is not an array."));
4402 return;
4403 }
4404
4405 for (let last = kids.length - 1; last >= 0; last--) {
4406 nodesToVisit.push(kids[last]);
4407 }
4408 }
4409
4410 capability.reject(new Error(`Page index ${pageIndex} not found.`));
4411 }
4412
4413 next();
4414 return capability.promise;
4415 }
4416
4417 getPageIndex(pageRef) {
4418 const xref = this.xref;
4419
4420 function pagesBeforeRef(kidRef) {
4421 let total = 0,
4422 parentRef;
4423 return xref.fetchAsync(kidRef).then(function (node) {
4424 if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, "Page") && !((0, _primitives.isDict)(node) && !node.has("Type") && node.has("Contents"))) {
4425 throw new _util.FormatError("The reference does not point to a /Page dictionary.");
4426 }
4427
4428 if (!node) {
4429 return null;
4430 }
4431
4432 if (!(0, _primitives.isDict)(node)) {
4433 throw new _util.FormatError("Node must be a dictionary.");
4434 }
4435
4436 parentRef = node.getRaw("Parent");
4437 return node.getAsync("Parent");
4438 }).then(function (parent) {
4439 if (!parent) {
4440 return null;
4441 }
4442
4443 if (!(0, _primitives.isDict)(parent)) {
4444 throw new _util.FormatError("Parent must be a dictionary.");
4445 }
4446
4447 return parent.getAsync("Kids");
4448 }).then(function (kids) {
4449 if (!kids) {
4450 return null;
4451 }
4452
4453 const kidPromises = [];
4454 let found = false;
4455
4456 for (let i = 0, ii = kids.length; i < ii; i++) {
4457 const kid = kids[i];
4458
4459 if (!(0, _primitives.isRef)(kid)) {
4460 throw new _util.FormatError("Kid must be a reference.");
4461 }
4462
4463 if ((0, _primitives.isRefsEqual)(kid, kidRef)) {
4464 found = true;
4465 break;
4466 }
4467
4468 kidPromises.push(xref.fetchAsync(kid).then(function (obj) {
4469 if (!(0, _primitives.isDict)(obj)) {
4470 throw new _util.FormatError("Kid node must be a dictionary.");
4471 }
4472
4473 if (obj.has("Count")) {
4474 total += obj.get("Count");
4475 } else {
4476 total++;
4477 }
4478 }));
4479 }
4480
4481 if (!found) {
4482 throw new _util.FormatError("Kid reference not found in parent's kids.");
4483 }
4484
4485 return Promise.all(kidPromises).then(function () {
4486 return [total, parentRef];
4487 });
4488 });
4489 }
4490
4491 let total = 0;
4492
4493 function next(ref) {
4494 return pagesBeforeRef(ref).then(function (args) {
4495 if (!args) {
4496 return total;
4497 }
4498
4499 const [count, parentRef] = args;
4500 total += count;
4501 return next(parentRef);
4502 });
4503 }
4504
4505 return next(pageRef);
4506 }
4507
4508 static parseDestDictionary(params) {
4509 function addDefaultProtocolToUrl(url) {
4510 return url.startsWith("www.") ? `http://${url}` : url;
4511 }
4512
4513 function tryConvertUrlEncoding(url) {
4514 try {
4515 return (0, _util.stringToUTF8String)(url);
4516 } catch (e) {
4517 return url;
4518 }
4519 }
4520
4521 const destDict = params.destDict;
4522
4523 if (!(0, _primitives.isDict)(destDict)) {
4524 (0, _util.warn)("parseDestDictionary: `destDict` must be a dictionary.");
4525 return;
4526 }
4527
4528 const resultObj = params.resultObj;
4529
4530 if (typeof resultObj !== "object") {
4531 (0, _util.warn)("parseDestDictionary: `resultObj` must be an object.");
4532 return;
4533 }
4534
4535 const docBaseUrl = params.docBaseUrl || null;
4536 let action = destDict.get("A"),
4537 url,
4538 dest;
4539
4540 if (!(0, _primitives.isDict)(action) && destDict.has("Dest")) {
4541 action = destDict.get("Dest");
4542 }
4543
4544 if ((0, _primitives.isDict)(action)) {
4545 const actionType = action.get("S");
4546
4547 if (!(0, _primitives.isName)(actionType)) {
4548 (0, _util.warn)("parseDestDictionary: Invalid type in Action dictionary.");
4549 return;
4550 }
4551
4552 const actionName = actionType.name;
4553
4554 switch (actionName) {
4555 case "URI":
4556 url = action.get("URI");
4557
4558 if ((0, _primitives.isName)(url)) {
4559 url = "/" + url.name;
4560 } else if ((0, _util.isString)(url)) {
4561 url = addDefaultProtocolToUrl(url);
4562 }
4563
4564 break;
4565
4566 case "GoTo":
4567 dest = action.get("D");
4568 break;
4569
4570 case "Launch":
4571 case "GoToR":
4572 const urlDict = action.get("F");
4573
4574 if ((0, _primitives.isDict)(urlDict)) {
4575 url = urlDict.get("F") || null;
4576 } else if ((0, _util.isString)(urlDict)) {
4577 url = urlDict;
4578 }
4579
4580 let remoteDest = action.get("D");
4581
4582 if (remoteDest) {
4583 if ((0, _primitives.isName)(remoteDest)) {
4584 remoteDest = remoteDest.name;
4585 }
4586
4587 if ((0, _util.isString)(url)) {
4588 const baseUrl = url.split("#")[0];
4589
4590 if ((0, _util.isString)(remoteDest)) {
4591 url = baseUrl + "#" + remoteDest;
4592 } else if (Array.isArray(remoteDest)) {
4593 url = baseUrl + "#" + JSON.stringify(remoteDest);
4594 }
4595 }
4596 }
4597
4598 const newWindow = action.get("NewWindow");
4599
4600 if ((0, _util.isBool)(newWindow)) {
4601 resultObj.newWindow = newWindow;
4602 }
4603
4604 break;
4605
4606 case "Named":
4607 const namedAction = action.get("N");
4608
4609 if ((0, _primitives.isName)(namedAction)) {
4610 resultObj.action = namedAction.name;
4611 }
4612
4613 break;
4614
4615 case "JavaScript":
4616 const jsAction = action.get("JS");
4617 let js;
4618
4619 if ((0, _primitives.isStream)(jsAction)) {
4620 js = (0, _util.bytesToString)(jsAction.getBytes());
4621 } else if ((0, _util.isString)(jsAction)) {
4622 js = jsAction;
4623 }
4624
4625 if (js) {
4626 const URL_OPEN_METHODS = ["app.launchURL", "window.open"];
4627 const regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").split(".").join("\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
4628 const jsUrl = regex.exec((0, _util.stringToPDFString)(js));
4629
4630 if (jsUrl && jsUrl[2]) {
4631 url = jsUrl[2];
4632
4633 if (jsUrl[3] === "true" && jsUrl[1] === "app.launchURL") {
4634 resultObj.newWindow = true;
4635 }
4636
4637 break;
4638 }
4639 }
4640
4641 default:
4642 (0, _util.warn)(`parseDestDictionary: unsupported action type "${actionName}".`);
4643 break;
4644 }
4645 } else if (destDict.has("Dest")) {
4646 dest = destDict.get("Dest");
4647 }
4648
4649 if ((0, _util.isString)(url)) {
4650 url = tryConvertUrlEncoding(url);
4651 const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl);
4652
4653 if (absoluteUrl) {
4654 resultObj.url = absoluteUrl.href;
4655 }
4656
4657 resultObj.unsafeUrl = url;
4658 }
4659
4660 if (dest) {
4661 if ((0, _primitives.isName)(dest)) {
4662 dest = dest.name;
4663 }
4664
4665 if ((0, _util.isString)(dest) || Array.isArray(dest)) {
4666 resultObj.dest = dest;
4667 }
4668 }
4669 }
4670
4671}
4672
4673exports.Catalog = Catalog;
4674
4675var XRef = function XRefClosure() {
4676 function XRef(stream, pdfManager) {
4677 this.stream = stream;
4678 this.pdfManager = pdfManager;
4679 this.entries = [];
4680 this.xrefstms = Object.create(null);
4681 this._cacheMap = new Map();
4682 this.stats = {
4683 streamTypes: Object.create(null),
4684 fontTypes: Object.create(null)
4685 };
4686 }
4687
4688 XRef.prototype = {
4689 setStartXRef: function XRef_setStartXRef(startXRef) {
4690 this.startXRefQueue = [startXRef];
4691 },
4692 parse: function XRef_parse(recoveryMode) {
4693 var trailerDict;
4694
4695 if (!recoveryMode) {
4696 trailerDict = this.readXRef();
4697 } else {
4698 (0, _util.warn)("Indexing all PDF objects");
4699 trailerDict = this.indexObjects();
4700 }
4701
4702 trailerDict.assignXref(this);
4703 this.trailer = trailerDict;
4704 let encrypt;
4705
4706 try {
4707 encrypt = trailerDict.get("Encrypt");
4708 } catch (ex) {
4709 if (ex instanceof _core_utils.MissingDataException) {
4710 throw ex;
4711 }
4712
4713 (0, _util.warn)(`XRef.parse - Invalid "Encrypt" reference: "${ex}".`);
4714 }
4715
4716 if ((0, _primitives.isDict)(encrypt)) {
4717 var ids = trailerDict.get("ID");
4718 var fileId = ids && ids.length ? ids[0] : "";
4719 encrypt.suppressEncryption = true;
4720 this.encrypt = new _crypto.CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
4721 }
4722
4723 let root;
4724
4725 try {
4726 root = trailerDict.get("Root");
4727 } catch (ex) {
4728 if (ex instanceof _core_utils.MissingDataException) {
4729 throw ex;
4730 }
4731
4732 (0, _util.warn)(`XRef.parse - Invalid "Root" reference: "${ex}".`);
4733 }
4734
4735 if ((0, _primitives.isDict)(root) && root.has("Pages")) {
4736 this.root = root;
4737 } else {
4738 if (!recoveryMode) {
4739 throw new _core_utils.XRefParseException();
4740 }
4741
4742 throw new _util.FormatError("Invalid root reference");
4743 }
4744 },
4745 processXRefTable: function XRef_processXRefTable(parser) {
4746 if (!("tableState" in this)) {
4747 this.tableState = {
4748 entryNum: 0,
4749 streamPos: parser.lexer.stream.pos,
4750 parserBuf1: parser.buf1,
4751 parserBuf2: parser.buf2
4752 };
4753 }
4754
4755 var obj = this.readXRefTable(parser);
4756
4757 if (!(0, _primitives.isCmd)(obj, "trailer")) {
4758 throw new _util.FormatError("Invalid XRef table: could not find trailer dictionary");
4759 }
4760
4761 var dict = parser.getObj();
4762
4763 if (!(0, _primitives.isDict)(dict) && dict.dict) {
4764 dict = dict.dict;
4765 }
4766
4767 if (!(0, _primitives.isDict)(dict)) {
4768 throw new _util.FormatError("Invalid XRef table: could not parse trailer dictionary");
4769 }
4770
4771 delete this.tableState;
4772 return dict;
4773 },
4774 readXRefTable: function XRef_readXRefTable(parser) {
4775 var stream = parser.lexer.stream;
4776 var tableState = this.tableState;
4777 stream.pos = tableState.streamPos;
4778 parser.buf1 = tableState.parserBuf1;
4779 parser.buf2 = tableState.parserBuf2;
4780 var obj;
4781
4782 while (true) {
4783 if (!("firstEntryNum" in tableState) || !("entryCount" in tableState)) {
4784 if ((0, _primitives.isCmd)(obj = parser.getObj(), "trailer")) {
4785 break;
4786 }
4787
4788 tableState.firstEntryNum = obj;
4789 tableState.entryCount = parser.getObj();
4790 }
4791
4792 var first = tableState.firstEntryNum;
4793 var count = tableState.entryCount;
4794
4795 if (!Number.isInteger(first) || !Number.isInteger(count)) {
4796 throw new _util.FormatError("Invalid XRef table: wrong types in subsection header");
4797 }
4798
4799 for (var i = tableState.entryNum; i < count; i++) {
4800 tableState.streamPos = stream.pos;
4801 tableState.entryNum = i;
4802 tableState.parserBuf1 = parser.buf1;
4803 tableState.parserBuf2 = parser.buf2;
4804 var entry = {};
4805 entry.offset = parser.getObj();
4806 entry.gen = parser.getObj();
4807 var type = parser.getObj();
4808
4809 if (type instanceof _primitives.Cmd) {
4810 switch (type.cmd) {
4811 case "f":
4812 entry.free = true;
4813 break;
4814
4815 case "n":
4816 entry.uncompressed = true;
4817 break;
4818 }
4819 }
4820
4821 if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) || !(entry.free || entry.uncompressed)) {
4822 throw new _util.FormatError(`Invalid entry in XRef subsection: ${first}, ${count}`);
4823 }
4824
4825 if (i === 0 && entry.free && first === 1) {
4826 first = 0;
4827 }
4828
4829 if (!this.entries[i + first]) {
4830 this.entries[i + first] = entry;
4831 }
4832 }
4833
4834 tableState.entryNum = 0;
4835 tableState.streamPos = stream.pos;
4836 tableState.parserBuf1 = parser.buf1;
4837 tableState.parserBuf2 = parser.buf2;
4838 delete tableState.firstEntryNum;
4839 delete tableState.entryCount;
4840 }
4841
4842 if (this.entries[0] && !this.entries[0].free) {
4843 throw new _util.FormatError("Invalid XRef table: unexpected first object");
4844 }
4845
4846 return obj;
4847 },
4848 processXRefStream: function XRef_processXRefStream(stream) {
4849 if (!("streamState" in this)) {
4850 var streamParameters = stream.dict;
4851 var byteWidths = streamParameters.get("W");
4852 var range = streamParameters.get("Index");
4853
4854 if (!range) {
4855 range = [0, streamParameters.get("Size")];
4856 }
4857
4858 this.streamState = {
4859 entryRanges: range,
4860 byteWidths,
4861 entryNum: 0,
4862 streamPos: stream.pos
4863 };
4864 }
4865
4866 this.readXRefStream(stream);
4867 delete this.streamState;
4868 return stream.dict;
4869 },
4870 readXRefStream: function XRef_readXRefStream(stream) {
4871 var i, j;
4872 var streamState = this.streamState;
4873 stream.pos = streamState.streamPos;
4874 var byteWidths = streamState.byteWidths;
4875 var typeFieldWidth = byteWidths[0];
4876 var offsetFieldWidth = byteWidths[1];
4877 var generationFieldWidth = byteWidths[2];
4878 var entryRanges = streamState.entryRanges;
4879
4880 while (entryRanges.length > 0) {
4881 var first = entryRanges[0];
4882 var n = entryRanges[1];
4883
4884 if (!Number.isInteger(first) || !Number.isInteger(n)) {
4885 throw new _util.FormatError(`Invalid XRef range fields: ${first}, ${n}`);
4886 }
4887
4888 if (!Number.isInteger(typeFieldWidth) || !Number.isInteger(offsetFieldWidth) || !Number.isInteger(generationFieldWidth)) {
4889 throw new _util.FormatError(`Invalid XRef entry fields length: ${first}, ${n}`);
4890 }
4891
4892 for (i = streamState.entryNum; i < n; ++i) {
4893 streamState.entryNum = i;
4894 streamState.streamPos = stream.pos;
4895 var type = 0,
4896 offset = 0,
4897 generation = 0;
4898
4899 for (j = 0; j < typeFieldWidth; ++j) {
4900 type = type << 8 | stream.getByte();
4901 }
4902
4903 if (typeFieldWidth === 0) {
4904 type = 1;
4905 }
4906
4907 for (j = 0; j < offsetFieldWidth; ++j) {
4908 offset = offset << 8 | stream.getByte();
4909 }
4910
4911 for (j = 0; j < generationFieldWidth; ++j) {
4912 generation = generation << 8 | stream.getByte();
4913 }
4914
4915 var entry = {};
4916 entry.offset = offset;
4917 entry.gen = generation;
4918
4919 switch (type) {
4920 case 0:
4921 entry.free = true;
4922 break;
4923
4924 case 1:
4925 entry.uncompressed = true;
4926 break;
4927
4928 case 2:
4929 break;
4930
4931 default:
4932 throw new _util.FormatError(`Invalid XRef entry type: ${type}`);
4933 }
4934
4935 if (!this.entries[first + i]) {
4936 this.entries[first + i] = entry;
4937 }
4938 }
4939
4940 streamState.entryNum = 0;
4941 streamState.streamPos = stream.pos;
4942 entryRanges.splice(0, 2);
4943 }
4944 },
4945 indexObjects: function XRef_indexObjects() {
4946 var TAB = 0x9,
4947 LF = 0xa,
4948 CR = 0xd,
4949 SPACE = 0x20;
4950 var PERCENT = 0x25,
4951 LT = 0x3c;
4952
4953 function readToken(data, offset) {
4954 var token = "",
4955 ch = data[offset];
4956
4957 while (ch !== LF && ch !== CR && ch !== LT) {
4958 if (++offset >= data.length) {
4959 break;
4960 }
4961
4962 token += String.fromCharCode(ch);
4963 ch = data[offset];
4964 }
4965
4966 return token;
4967 }
4968
4969 function skipUntil(data, offset, what) {
4970 var length = what.length,
4971 dataLength = data.length;
4972 var skipped = 0;
4973
4974 while (offset < dataLength) {
4975 var i = 0;
4976
4977 while (i < length && data[offset + i] === what[i]) {
4978 ++i;
4979 }
4980
4981 if (i >= length) {
4982 break;
4983 }
4984
4985 offset++;
4986 skipped++;
4987 }
4988
4989 return skipped;
4990 }
4991
4992 var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
4993 const endobjRegExp = /\bendobj[\b\s]$/;
4994 const nestedObjRegExp = /\s+(\d+\s+\d+\s+obj[\b\s<])$/;
4995 const CHECK_CONTENT_LENGTH = 25;
4996 var trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
4997 var startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]);
4998 const objBytes = new Uint8Array([111, 98, 106]);
4999 var xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
5000 this.entries.length = 0;
5001 var stream = this.stream;
5002 stream.pos = 0;
5003 var buffer = stream.getBytes();
5004 var position = stream.start,
5005 length = buffer.length;
5006 var trailers = [],
5007 xrefStms = [];
5008
5009 while (position < length) {
5010 var ch = buffer[position];
5011
5012 if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
5013 ++position;
5014 continue;
5015 }
5016
5017 if (ch === PERCENT) {
5018 do {
5019 ++position;
5020
5021 if (position >= length) {
5022 break;
5023 }
5024
5025 ch = buffer[position];
5026 } while (ch !== LF && ch !== CR);
5027
5028 continue;
5029 }
5030
5031 var token = readToken(buffer, position);
5032 var m;
5033
5034 if (token.startsWith("xref") && (token.length === 4 || /\s/.test(token[4]))) {
5035 position += skipUntil(buffer, position, trailerBytes);
5036 trailers.push(position);
5037 position += skipUntil(buffer, position, startxrefBytes);
5038 } else if (m = objRegExp.exec(token)) {
5039 const num = m[1] | 0,
5040 gen = m[2] | 0;
5041
5042 if (!this.entries[num] || this.entries[num].gen === gen) {
5043 this.entries[num] = {
5044 offset: position - stream.start,
5045 gen,
5046 uncompressed: true
5047 };
5048 }
5049
5050 let contentLength,
5051 startPos = position + token.length;
5052
5053 while (startPos < buffer.length) {
5054 const endPos = startPos + skipUntil(buffer, startPos, objBytes) + 4;
5055 contentLength = endPos - position;
5056 const checkPos = Math.max(endPos - CHECK_CONTENT_LENGTH, startPos);
5057 const tokenStr = (0, _util.bytesToString)(buffer.subarray(checkPos, endPos));
5058
5059 if (endobjRegExp.test(tokenStr)) {
5060 break;
5061 } else {
5062 const objToken = nestedObjRegExp.exec(tokenStr);
5063
5064 if (objToken && objToken[1]) {
5065 (0, _util.warn)('indexObjects: Found new "obj" inside of another "obj", ' + 'caused by missing "endobj" -- trying to recover.');
5066 contentLength -= objToken[1].length;
5067 break;
5068 }
5069 }
5070
5071 startPos = endPos;
5072 }
5073
5074 const content = buffer.subarray(position, position + contentLength);
5075 var xrefTagOffset = skipUntil(content, 0, xrefBytes);
5076
5077 if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
5078 xrefStms.push(position - stream.start);
5079 this.xrefstms[position - stream.start] = 1;
5080 }
5081
5082 position += contentLength;
5083 } else if (token.startsWith("trailer") && (token.length === 7 || /\s/.test(token[7]))) {
5084 trailers.push(position);
5085 position += skipUntil(buffer, position, startxrefBytes);
5086 } else {
5087 position += token.length + 1;
5088 }
5089 }
5090
5091 var i, ii;
5092
5093 for (i = 0, ii = xrefStms.length; i < ii; ++i) {
5094 this.startXRefQueue.push(xrefStms[i]);
5095 this.readXRef(true);
5096 }
5097
5098 let trailerDict;
5099
5100 for (i = 0, ii = trailers.length; i < ii; ++i) {
5101 stream.pos = trailers[i];
5102 const parser = new _parser.Parser({
5103 lexer: new _parser.Lexer(stream),
5104 xref: this,
5105 allowStreams: true,
5106 recoveryMode: true
5107 });
5108 var obj = parser.getObj();
5109
5110 if (!(0, _primitives.isCmd)(obj, "trailer")) {
5111 continue;
5112 }
5113
5114 const dict = parser.getObj();
5115
5116 if (!(0, _primitives.isDict)(dict)) {
5117 continue;
5118 }
5119
5120 let rootDict;
5121
5122 try {
5123 rootDict = dict.get("Root");
5124 } catch (ex) {
5125 if (ex instanceof _core_utils.MissingDataException) {
5126 throw ex;
5127 }
5128
5129 continue;
5130 }
5131
5132 if (!(0, _primitives.isDict)(rootDict) || !rootDict.has("Pages")) {
5133 continue;
5134 }
5135
5136 if (dict.has("ID")) {
5137 return dict;
5138 }
5139
5140 trailerDict = dict;
5141 }
5142
5143 if (trailerDict) {
5144 return trailerDict;
5145 }
5146
5147 throw new _util.InvalidPDFException("Invalid PDF structure.");
5148 },
5149 readXRef: function XRef_readXRef(recoveryMode) {
5150 var stream = this.stream;
5151 const startXRefParsedCache = Object.create(null);
5152
5153 try {
5154 while (this.startXRefQueue.length) {
5155 var startXRef = this.startXRefQueue[0];
5156
5157 if (startXRefParsedCache[startXRef]) {
5158 (0, _util.warn)("readXRef - skipping XRef table since it was already parsed.");
5159 this.startXRefQueue.shift();
5160 continue;
5161 }
5162
5163 startXRefParsedCache[startXRef] = true;
5164 stream.pos = startXRef + stream.start;
5165 const parser = new _parser.Parser({
5166 lexer: new _parser.Lexer(stream),
5167 xref: this,
5168 allowStreams: true
5169 });
5170 var obj = parser.getObj();
5171 var dict;
5172
5173 if ((0, _primitives.isCmd)(obj, "xref")) {
5174 dict = this.processXRefTable(parser);
5175
5176 if (!this.topDict) {
5177 this.topDict = dict;
5178 }
5179
5180 obj = dict.get("XRefStm");
5181
5182 if (Number.isInteger(obj)) {
5183 var pos = obj;
5184
5185 if (!(pos in this.xrefstms)) {
5186 this.xrefstms[pos] = 1;
5187 this.startXRefQueue.push(pos);
5188 }
5189 }
5190 } else if (Number.isInteger(obj)) {
5191 if (!Number.isInteger(parser.getObj()) || !(0, _primitives.isCmd)(parser.getObj(), "obj") || !(0, _primitives.isStream)(obj = parser.getObj())) {
5192 throw new _util.FormatError("Invalid XRef stream");
5193 }
5194
5195 dict = this.processXRefStream(obj);
5196
5197 if (!this.topDict) {
5198 this.topDict = dict;
5199 }
5200
5201 if (!dict) {
5202 throw new _util.FormatError("Failed to read XRef stream");
5203 }
5204 } else {
5205 throw new _util.FormatError("Invalid XRef stream header");
5206 }
5207
5208 obj = dict.get("Prev");
5209
5210 if (Number.isInteger(obj)) {
5211 this.startXRefQueue.push(obj);
5212 } else if ((0, _primitives.isRef)(obj)) {
5213 this.startXRefQueue.push(obj.num);
5214 }
5215
5216 this.startXRefQueue.shift();
5217 }
5218
5219 return this.topDict;
5220 } catch (e) {
5221 if (e instanceof _core_utils.MissingDataException) {
5222 throw e;
5223 }
5224
5225 (0, _util.info)("(while reading XRef): " + e);
5226 }
5227
5228 if (recoveryMode) {
5229 return undefined;
5230 }
5231
5232 throw new _core_utils.XRefParseException();
5233 },
5234 getEntry: function XRef_getEntry(i) {
5235 var xrefEntry = this.entries[i];
5236
5237 if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
5238 return xrefEntry;
5239 }
5240
5241 return null;
5242 },
5243 fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
5244 if (obj instanceof _primitives.Ref) {
5245 return this.fetch(obj, suppressEncryption);
5246 }
5247
5248 return obj;
5249 },
5250 fetch: function XRef_fetch(ref, suppressEncryption) {
5251 if (!(ref instanceof _primitives.Ref)) {
5252 throw new Error("ref object is not a reference");
5253 }
5254
5255 const num = ref.num;
5256
5257 const cacheEntry = this._cacheMap.get(num);
5258
5259 if (cacheEntry !== undefined) {
5260 if (cacheEntry instanceof _primitives.Dict && !cacheEntry.objId) {
5261 cacheEntry.objId = ref.toString();
5262 }
5263
5264 return cacheEntry;
5265 }
5266
5267 let xrefEntry = this.getEntry(num);
5268
5269 if (xrefEntry === null) {
5270 this._cacheMap.set(num, xrefEntry);
5271
5272 return xrefEntry;
5273 }
5274
5275 if (xrefEntry.uncompressed) {
5276 xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
5277 } else {
5278 xrefEntry = this.fetchCompressed(ref, xrefEntry, suppressEncryption);
5279 }
5280
5281 if ((0, _primitives.isDict)(xrefEntry)) {
5282 xrefEntry.objId = ref.toString();
5283 } else if ((0, _primitives.isStream)(xrefEntry)) {
5284 xrefEntry.dict.objId = ref.toString();
5285 }
5286
5287 return xrefEntry;
5288 },
5289
5290 fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
5291 var gen = ref.gen;
5292 var num = ref.num;
5293
5294 if (xrefEntry.gen !== gen) {
5295 throw new _core_utils.XRefEntryException(`Inconsistent generation in XRef: ${ref}`);
5296 }
5297
5298 var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
5299 const parser = new _parser.Parser({
5300 lexer: new _parser.Lexer(stream),
5301 xref: this,
5302 allowStreams: true
5303 });
5304 var obj1 = parser.getObj();
5305 var obj2 = parser.getObj();
5306 var obj3 = parser.getObj();
5307
5308 if (obj1 !== num || obj2 !== gen || !(obj3 instanceof _primitives.Cmd)) {
5309 throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
5310 }
5311
5312 if (obj3.cmd !== "obj") {
5313 if (obj3.cmd.startsWith("obj")) {
5314 num = parseInt(obj3.cmd.substring(3), 10);
5315
5316 if (!Number.isNaN(num)) {
5317 return num;
5318 }
5319 }
5320
5321 throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
5322 }
5323
5324 if (this.encrypt && !suppressEncryption) {
5325 xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
5326 } else {
5327 xrefEntry = parser.getObj();
5328 }
5329
5330 if (!(0, _primitives.isStream)(xrefEntry)) {
5331 this._cacheMap.set(num, xrefEntry);
5332 }
5333
5334 return xrefEntry;
5335 },
5336
5337 fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
5338 const tableOffset = xrefEntry.offset;
5339 const stream = this.fetch(_primitives.Ref.get(tableOffset, 0));
5340
5341 if (!(0, _primitives.isStream)(stream)) {
5342 throw new _util.FormatError("bad ObjStm stream");
5343 }
5344
5345 const first = stream.dict.get("First");
5346 const n = stream.dict.get("N");
5347
5348 if (!Number.isInteger(first) || !Number.isInteger(n)) {
5349 throw new _util.FormatError("invalid first and n parameters for ObjStm stream");
5350 }
5351
5352 const parser = new _parser.Parser({
5353 lexer: new _parser.Lexer(stream),
5354 xref: this,
5355 allowStreams: true
5356 });
5357 const nums = new Array(n);
5358
5359 for (let i = 0; i < n; ++i) {
5360 const num = parser.getObj();
5361
5362 if (!Number.isInteger(num)) {
5363 throw new _util.FormatError(`invalid object number in the ObjStm stream: ${num}`);
5364 }
5365
5366 const offset = parser.getObj();
5367
5368 if (!Number.isInteger(offset)) {
5369 throw new _util.FormatError(`invalid object offset in the ObjStm stream: ${offset}`);
5370 }
5371
5372 nums[i] = num;
5373 }
5374
5375 const entries = new Array(n);
5376
5377 for (let i = 0; i < n; ++i) {
5378 const obj = parser.getObj();
5379 entries[i] = obj;
5380
5381 if (parser.buf1 instanceof _primitives.Cmd && parser.buf1.cmd === "endobj") {
5382 parser.shift();
5383 }
5384
5385 if ((0, _primitives.isStream)(obj)) {
5386 continue;
5387 }
5388
5389 const num = nums[i],
5390 entry = this.entries[num];
5391
5392 if (entry && entry.offset === tableOffset && entry.gen === i) {
5393 this._cacheMap.set(num, obj);
5394 }
5395 }
5396
5397 xrefEntry = entries[xrefEntry.gen];
5398
5399 if (xrefEntry === undefined) {
5400 throw new _core_utils.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
5401 }
5402
5403 return xrefEntry;
5404 },
5405
5406 async fetchIfRefAsync(obj, suppressEncryption) {
5407 if (obj instanceof _primitives.Ref) {
5408 return this.fetchAsync(obj, suppressEncryption);
5409 }
5410
5411 return obj;
5412 },
5413
5414 async fetchAsync(ref, suppressEncryption) {
5415 try {
5416 return this.fetch(ref, suppressEncryption);
5417 } catch (ex) {
5418 if (!(ex instanceof _core_utils.MissingDataException)) {
5419 throw ex;
5420 }
5421
5422 await this.pdfManager.requestRange(ex.begin, ex.end);
5423 return this.fetchAsync(ref, suppressEncryption);
5424 }
5425 },
5426
5427 getCatalogObj: function XRef_getCatalogObj() {
5428 return this.root;
5429 }
5430 };
5431 return XRef;
5432}();
5433
5434exports.XRef = XRef;
5435
5436class NameOrNumberTree {
5437 constructor(root, xref, type) {
5438 if (this.constructor === NameOrNumberTree) {
5439 (0, _util.unreachable)("Cannot initialize NameOrNumberTree.");
5440 }
5441
5442 this.root = root;
5443 this.xref = xref;
5444 this._type = type;
5445 }
5446
5447 getAll() {
5448 const dict = Object.create(null);
5449
5450 if (!this.root) {
5451 return dict;
5452 }
5453
5454 const xref = this.xref;
5455 const processed = new _primitives.RefSet();
5456 processed.put(this.root);
5457 const queue = [this.root];
5458
5459 while (queue.length > 0) {
5460 const obj = xref.fetchIfRef(queue.shift());
5461
5462 if (!(0, _primitives.isDict)(obj)) {
5463 continue;
5464 }
5465
5466 if (obj.has("Kids")) {
5467 const kids = obj.get("Kids");
5468
5469 for (let i = 0, ii = kids.length; i < ii; i++) {
5470 const kid = kids[i];
5471
5472 if (processed.has(kid)) {
5473 throw new _util.FormatError(`Duplicate entry in "${this._type}" tree.`);
5474 }
5475
5476 queue.push(kid);
5477 processed.put(kid);
5478 }
5479
5480 continue;
5481 }
5482
5483 const entries = obj.get(this._type);
5484
5485 if (Array.isArray(entries)) {
5486 for (let i = 0, ii = entries.length; i < ii; i += 2) {
5487 dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
5488 }
5489 }
5490 }
5491
5492 return dict;
5493 }
5494
5495 get(key) {
5496 if (!this.root) {
5497 return null;
5498 }
5499
5500 const xref = this.xref;
5501 let kidsOrEntries = xref.fetchIfRef(this.root);
5502 let loopCount = 0;
5503 const MAX_LEVELS = 10;
5504
5505 while (kidsOrEntries.has("Kids")) {
5506 if (++loopCount > MAX_LEVELS) {
5507 (0, _util.warn)(`Search depth limit reached for "${this._type}" tree.`);
5508 return null;
5509 }
5510
5511 const kids = kidsOrEntries.get("Kids");
5512
5513 if (!Array.isArray(kids)) {
5514 return null;
5515 }
5516
5517 let l = 0,
5518 r = kids.length - 1;
5519
5520 while (l <= r) {
5521 const m = l + r >> 1;
5522 const kid = xref.fetchIfRef(kids[m]);
5523 const limits = kid.get("Limits");
5524
5525 if (key < xref.fetchIfRef(limits[0])) {
5526 r = m - 1;
5527 } else if (key > xref.fetchIfRef(limits[1])) {
5528 l = m + 1;
5529 } else {
5530 kidsOrEntries = xref.fetchIfRef(kids[m]);
5531 break;
5532 }
5533 }
5534
5535 if (l > r) {
5536 return null;
5537 }
5538 }
5539
5540 const entries = kidsOrEntries.get(this._type);
5541
5542 if (Array.isArray(entries)) {
5543 let l = 0,
5544 r = entries.length - 2;
5545
5546 while (l <= r) {
5547 const tmp = l + r >> 1,
5548 m = tmp + (tmp & 1);
5549 const currentKey = xref.fetchIfRef(entries[m]);
5550
5551 if (key < currentKey) {
5552 r = m - 2;
5553 } else if (key > currentKey) {
5554 l = m + 2;
5555 } else {
5556 return xref.fetchIfRef(entries[m + 1]);
5557 }
5558 }
5559
5560 (0, _util.info)(`Falling back to an exhaustive search, for key "${key}", ` + `in "${this._type}" tree.`);
5561
5562 for (let m = 0, mm = entries.length; m < mm; m += 2) {
5563 const currentKey = xref.fetchIfRef(entries[m]);
5564
5565 if (currentKey === key) {
5566 (0, _util.warn)(`The "${key}" key was found at an incorrect, ` + `i.e. out-of-order, position in "${this._type}" tree.`);
5567 return xref.fetchIfRef(entries[m + 1]);
5568 }
5569 }
5570 }
5571
5572 return null;
5573 }
5574
5575}
5576
5577class NameTree extends NameOrNumberTree {
5578 constructor(root, xref) {
5579 super(root, xref, "Names");
5580 }
5581
5582}
5583
5584class NumberTree extends NameOrNumberTree {
5585 constructor(root, xref) {
5586 super(root, xref, "Nums");
5587 }
5588
5589}
5590
5591var FileSpec = function FileSpecClosure() {
5592 function FileSpec(root, xref) {
5593 if (!root || !(0, _primitives.isDict)(root)) {
5594 return;
5595 }
5596
5597 this.xref = xref;
5598 this.root = root;
5599
5600 if (root.has("FS")) {
5601 this.fs = root.get("FS");
5602 }
5603
5604 this.description = root.has("Desc") ? (0, _util.stringToPDFString)(root.get("Desc")) : "";
5605
5606 if (root.has("RF")) {
5607 (0, _util.warn)("Related file specifications are not supported");
5608 }
5609
5610 this.contentAvailable = true;
5611
5612 if (!root.has("EF")) {
5613 this.contentAvailable = false;
5614 (0, _util.warn)("Non-embedded file specifications are not supported");
5615 }
5616 }
5617
5618 function pickPlatformItem(dict) {
5619 if (dict.has("UF")) {
5620 return dict.get("UF");
5621 } else if (dict.has("F")) {
5622 return dict.get("F");
5623 } else if (dict.has("Unix")) {
5624 return dict.get("Unix");
5625 } else if (dict.has("Mac")) {
5626 return dict.get("Mac");
5627 } else if (dict.has("DOS")) {
5628 return dict.get("DOS");
5629 }
5630
5631 return null;
5632 }
5633
5634 FileSpec.prototype = {
5635 get filename() {
5636 if (!this._filename && this.root) {
5637 var filename = pickPlatformItem(this.root) || "unnamed";
5638 this._filename = (0, _util.stringToPDFString)(filename).replace(/\\\\/g, "\\").replace(/\\\//g, "/").replace(/\\/g, "/");
5639 }
5640
5641 return this._filename;
5642 },
5643
5644 get content() {
5645 if (!this.contentAvailable) {
5646 return null;
5647 }
5648
5649 if (!this.contentRef && this.root) {
5650 this.contentRef = pickPlatformItem(this.root.get("EF"));
5651 }
5652
5653 var content = null;
5654
5655 if (this.contentRef) {
5656 var xref = this.xref;
5657 var fileObj = xref.fetchIfRef(this.contentRef);
5658
5659 if (fileObj && (0, _primitives.isStream)(fileObj)) {
5660 content = fileObj.getBytes();
5661 } else {
5662 (0, _util.warn)("Embedded file specification points to non-existing/invalid " + "content");
5663 }
5664 } else {
5665 (0, _util.warn)("Embedded file specification does not have a content");
5666 }
5667
5668 return content;
5669 },
5670
5671 get serializable() {
5672 return {
5673 filename: this.filename,
5674 content: this.content
5675 };
5676 }
5677
5678 };
5679 return FileSpec;
5680}();
5681
5682exports.FileSpec = FileSpec;
5683
5684const ObjectLoader = function () {
5685 function mayHaveChildren(value) {
5686 return value instanceof _primitives.Ref || value instanceof _primitives.Dict || Array.isArray(value) || (0, _primitives.isStream)(value);
5687 }
5688
5689 function addChildren(node, nodesToVisit) {
5690 if (node instanceof _primitives.Dict || (0, _primitives.isStream)(node)) {
5691 const dict = node instanceof _primitives.Dict ? node : node.dict;
5692 const dictKeys = dict.getKeys();
5693
5694 for (let i = 0, ii = dictKeys.length; i < ii; i++) {
5695 const rawValue = dict.getRaw(dictKeys[i]);
5696
5697 if (mayHaveChildren(rawValue)) {
5698 nodesToVisit.push(rawValue);
5699 }
5700 }
5701 } else if (Array.isArray(node)) {
5702 for (let i = 0, ii = node.length; i < ii; i++) {
5703 const value = node[i];
5704
5705 if (mayHaveChildren(value)) {
5706 nodesToVisit.push(value);
5707 }
5708 }
5709 }
5710 }
5711
5712 function ObjectLoader(dict, keys, xref) {
5713 this.dict = dict;
5714 this.keys = keys;
5715 this.xref = xref;
5716 this.refSet = null;
5717 }
5718
5719 ObjectLoader.prototype = {
5720 async load() {
5721 if (!this.xref.stream.allChunksLoaded || this.xref.stream.allChunksLoaded()) {
5722 return undefined;
5723 }
5724
5725 const {
5726 keys,
5727 dict
5728 } = this;
5729 this.refSet = new _primitives.RefSet();
5730 const nodesToVisit = [];
5731
5732 for (let i = 0, ii = keys.length; i < ii; i++) {
5733 const rawValue = dict.getRaw(keys[i]);
5734
5735 if (rawValue !== undefined) {
5736 nodesToVisit.push(rawValue);
5737 }
5738 }
5739
5740 return this._walk(nodesToVisit);
5741 },
5742
5743 async _walk(nodesToVisit) {
5744 const nodesToRevisit = [];
5745 const pendingRequests = [];
5746
5747 while (nodesToVisit.length) {
5748 let currentNode = nodesToVisit.pop();
5749
5750 if (currentNode instanceof _primitives.Ref) {
5751 if (this.refSet.has(currentNode)) {
5752 continue;
5753 }
5754
5755 try {
5756 this.refSet.put(currentNode);
5757 currentNode = this.xref.fetch(currentNode);
5758 } catch (ex) {
5759 if (!(ex instanceof _core_utils.MissingDataException)) {
5760 throw ex;
5761 }
5762
5763 nodesToRevisit.push(currentNode);
5764 pendingRequests.push({
5765 begin: ex.begin,
5766 end: ex.end
5767 });
5768 }
5769 }
5770
5771 if (currentNode && currentNode.getBaseStreams) {
5772 const baseStreams = currentNode.getBaseStreams();
5773 let foundMissingData = false;
5774
5775 for (let i = 0, ii = baseStreams.length; i < ii; i++) {
5776 const stream = baseStreams[i];
5777
5778 if (stream.allChunksLoaded && !stream.allChunksLoaded()) {
5779 foundMissingData = true;
5780 pendingRequests.push({
5781 begin: stream.start,
5782 end: stream.end
5783 });
5784 }
5785 }
5786
5787 if (foundMissingData) {
5788 nodesToRevisit.push(currentNode);
5789 }
5790 }
5791
5792 addChildren(currentNode, nodesToVisit);
5793 }
5794
5795 if (pendingRequests.length) {
5796 await this.xref.stream.manager.requestRanges(pendingRequests);
5797
5798 for (let i = 0, ii = nodesToRevisit.length; i < ii; i++) {
5799 const node = nodesToRevisit[i];
5800
5801 if (node instanceof _primitives.Ref) {
5802 this.refSet.remove(node);
5803 }
5804 }
5805
5806 return this._walk(nodesToRevisit);
5807 }
5808
5809 this.refSet = null;
5810 return undefined;
5811 }
5812
5813 };
5814 return ObjectLoader;
5815}();
5816
5817exports.ObjectLoader = ObjectLoader;
5818
5819/***/ }),
5820/* 11 */
5821/***/ (function(module, exports, __w_pdfjs_require__) {
5822
5823"use strict";
5824
5825
5826Object.defineProperty(exports, "__esModule", {
5827 value: true
5828});
5829exports.Parser = exports.Linearization = exports.Lexer = void 0;
5830
5831var _stream = __w_pdfjs_require__(12);
5832
5833var _util = __w_pdfjs_require__(2);
5834
5835var _primitives = __w_pdfjs_require__(5);
5836
5837var _core_utils = __w_pdfjs_require__(8);
5838
5839var _ccitt_stream = __w_pdfjs_require__(13);
5840
5841var _jbig2_stream = __w_pdfjs_require__(15);
5842
5843var _jpeg_stream = __w_pdfjs_require__(18);
5844
5845var _jpx_stream = __w_pdfjs_require__(20);
5846
5847const MAX_LENGTH_TO_CACHE = 1000;
5848const MAX_ADLER32_LENGTH = 5552;
5849
5850function computeAdler32(bytes) {
5851 const bytesLength = bytes.length;
5852 let a = 1,
5853 b = 0;
5854
5855 for (let i = 0; i < bytesLength; ++i) {
5856 a += bytes[i] & 0xff;
5857 b += a;
5858 }
5859
5860 return b % 65521 << 16 | a % 65521;
5861}
5862
5863class Parser {
5864 constructor({
5865 lexer,
5866 xref,
5867 allowStreams = false,
5868 recoveryMode = false
5869 }) {
5870 this.lexer = lexer;
5871 this.xref = xref;
5872 this.allowStreams = allowStreams;
5873 this.recoveryMode = recoveryMode;
5874 this.imageCache = Object.create(null);
5875 this.refill();
5876 }
5877
5878 refill() {
5879 this.buf1 = this.lexer.getObj();
5880 this.buf2 = this.lexer.getObj();
5881 }
5882
5883 shift() {
5884 if (this.buf2 instanceof _primitives.Cmd && this.buf2.cmd === "ID") {
5885 this.buf1 = this.buf2;
5886 this.buf2 = null;
5887 } else {
5888 this.buf1 = this.buf2;
5889 this.buf2 = this.lexer.getObj();
5890 }
5891 }
5892
5893 tryShift() {
5894 try {
5895 this.shift();
5896 return true;
5897 } catch (e) {
5898 if (e instanceof _core_utils.MissingDataException) {
5899 throw e;
5900 }
5901
5902 return false;
5903 }
5904 }
5905
5906 getObj(cipherTransform = null) {
5907 const buf1 = this.buf1;
5908 this.shift();
5909
5910 if (buf1 instanceof _primitives.Cmd) {
5911 switch (buf1.cmd) {
5912 case "BI":
5913 return this.makeInlineImage(cipherTransform);
5914
5915 case "[":
5916 const array = [];
5917
5918 while (!(0, _primitives.isCmd)(this.buf1, "]") && !(0, _primitives.isEOF)(this.buf1)) {
5919 array.push(this.getObj(cipherTransform));
5920 }
5921
5922 if ((0, _primitives.isEOF)(this.buf1)) {
5923 if (!this.recoveryMode) {
5924 throw new _util.FormatError("End of file inside array");
5925 }
5926
5927 return array;
5928 }
5929
5930 this.shift();
5931 return array;
5932
5933 case "<<":
5934 const dict = new _primitives.Dict(this.xref);
5935
5936 while (!(0, _primitives.isCmd)(this.buf1, ">>") && !(0, _primitives.isEOF)(this.buf1)) {
5937 if (!(0, _primitives.isName)(this.buf1)) {
5938 (0, _util.info)("Malformed dictionary: key must be a name object");
5939 this.shift();
5940 continue;
5941 }
5942
5943 const key = this.buf1.name;
5944 this.shift();
5945
5946 if ((0, _primitives.isEOF)(this.buf1)) {
5947 break;
5948 }
5949
5950 dict.set(key, this.getObj(cipherTransform));
5951 }
5952
5953 if ((0, _primitives.isEOF)(this.buf1)) {
5954 if (!this.recoveryMode) {
5955 throw new _util.FormatError("End of file inside dictionary");
5956 }
5957
5958 return dict;
5959 }
5960
5961 if ((0, _primitives.isCmd)(this.buf2, "stream")) {
5962 return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
5963 }
5964
5965 this.shift();
5966 return dict;
5967
5968 default:
5969 return buf1;
5970 }
5971 }
5972
5973 if (Number.isInteger(buf1)) {
5974 if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, "R")) {
5975 const ref = _primitives.Ref.get(buf1, this.buf1);
5976
5977 this.shift();
5978 this.shift();
5979 return ref;
5980 }
5981
5982 return buf1;
5983 }
5984
5985 if (typeof buf1 === "string") {
5986 if (cipherTransform) {
5987 return cipherTransform.decryptString(buf1);
5988 }
5989
5990 return buf1;
5991 }
5992
5993 return buf1;
5994 }
5995
5996 findDefaultInlineStreamEnd(stream) {
5997 const E = 0x45,
5998 I = 0x49,
5999 SPACE = 0x20,
6000 LF = 0xa,
6001 CR = 0xd;
6002 const n = 10,
6003 NUL = 0x0;
6004 const startPos = stream.pos;
6005 let state = 0,
6006 ch,
6007 maybeEIPos;
6008
6009 while ((ch = stream.getByte()) !== -1) {
6010 if (state === 0) {
6011 state = ch === E ? 1 : 0;
6012 } else if (state === 1) {
6013 state = ch === I ? 2 : 0;
6014 } else {
6015 (0, _util.assert)(state === 2, "findDefaultInlineStreamEnd - invalid state.");
6016
6017 if (ch === SPACE || ch === LF || ch === CR) {
6018 maybeEIPos = stream.pos;
6019 const followingBytes = stream.peekBytes(n);
6020
6021 for (let i = 0, ii = followingBytes.length; i < ii; i++) {
6022 ch = followingBytes[i];
6023
6024 if (ch === NUL && followingBytes[i + 1] !== NUL) {
6025 continue;
6026 }
6027
6028 if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7f)) {
6029 state = 0;
6030 break;
6031 }
6032 }
6033
6034 if (state === 2) {
6035 break;
6036 }
6037 } else {
6038 state = 0;
6039 }
6040 }
6041 }
6042
6043 if (ch === -1) {
6044 (0, _util.warn)("findDefaultInlineStreamEnd: " + "Reached the end of the stream without finding a valid EI marker");
6045
6046 if (maybeEIPos) {
6047 (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');
6048 stream.skip(-(stream.pos - maybeEIPos));
6049 }
6050 }
6051
6052 let endOffset = 4;
6053 stream.skip(-endOffset);
6054 ch = stream.peekByte();
6055 stream.skip(endOffset);
6056
6057 if (!(0, _core_utils.isWhiteSpace)(ch)) {
6058 endOffset--;
6059 }
6060
6061 return stream.pos - endOffset - startPos;
6062 }
6063
6064 findDCTDecodeInlineStreamEnd(stream) {
6065 const startPos = stream.pos;
6066 let foundEOI = false,
6067 b,
6068 markerLength;
6069
6070 while ((b = stream.getByte()) !== -1) {
6071 if (b !== 0xff) {
6072 continue;
6073 }
6074
6075 switch (stream.getByte()) {
6076 case 0x00:
6077 break;
6078
6079 case 0xff:
6080 stream.skip(-1);
6081 break;
6082
6083 case 0xd9:
6084 foundEOI = true;
6085 break;
6086
6087 case 0xc0:
6088 case 0xc1:
6089 case 0xc2:
6090 case 0xc3:
6091 case 0xc5:
6092 case 0xc6:
6093 case 0xc7:
6094 case 0xc9:
6095 case 0xca:
6096 case 0xcb:
6097 case 0xcd:
6098 case 0xce:
6099 case 0xcf:
6100 case 0xc4:
6101 case 0xcc:
6102 case 0xda:
6103 case 0xdb:
6104 case 0xdc:
6105 case 0xdd:
6106 case 0xde:
6107 case 0xdf:
6108 case 0xe0:
6109 case 0xe1:
6110 case 0xe2:
6111 case 0xe3:
6112 case 0xe4:
6113 case 0xe5:
6114 case 0xe6:
6115 case 0xe7:
6116 case 0xe8:
6117 case 0xe9:
6118 case 0xea:
6119 case 0xeb:
6120 case 0xec:
6121 case 0xed:
6122 case 0xee:
6123 case 0xef:
6124 case 0xfe:
6125 markerLength = stream.getUint16();
6126
6127 if (markerLength > 2) {
6128 stream.skip(markerLength - 2);
6129 } else {
6130 stream.skip(-2);
6131 }
6132
6133 break;
6134 }
6135
6136 if (foundEOI) {
6137 break;
6138 }
6139 }
6140
6141 const length = stream.pos - startPos;
6142
6143 if (b === -1) {
6144 (0, _util.warn)("Inline DCTDecode image stream: " + "EOI marker not found, searching for /EI/ instead.");
6145 stream.skip(-length);
6146 return this.findDefaultInlineStreamEnd(stream);
6147 }
6148
6149 this.inlineStreamSkipEI(stream);
6150 return length;
6151 }
6152
6153 findASCII85DecodeInlineStreamEnd(stream) {
6154 const TILDE = 0x7e,
6155 GT = 0x3e;
6156 const startPos = stream.pos;
6157 let ch;
6158
6159 while ((ch = stream.getByte()) !== -1) {
6160 if (ch === TILDE) {
6161 const tildePos = stream.pos;
6162 ch = stream.peekByte();
6163
6164 while ((0, _core_utils.isWhiteSpace)(ch)) {
6165 stream.skip();
6166 ch = stream.peekByte();
6167 }
6168
6169 if (ch === GT) {
6170 stream.skip();
6171 break;
6172 }
6173
6174 if (stream.pos > tildePos) {
6175 const maybeEI = stream.peekBytes(2);
6176
6177 if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
6178 break;
6179 }
6180 }
6181 }
6182 }
6183
6184 const length = stream.pos - startPos;
6185
6186 if (ch === -1) {
6187 (0, _util.warn)("Inline ASCII85Decode image stream: " + "EOD marker not found, searching for /EI/ instead.");
6188 stream.skip(-length);
6189 return this.findDefaultInlineStreamEnd(stream);
6190 }
6191
6192 this.inlineStreamSkipEI(stream);
6193 return length;
6194 }
6195
6196 findASCIIHexDecodeInlineStreamEnd(stream) {
6197 const GT = 0x3e;
6198 const startPos = stream.pos;
6199 let ch;
6200
6201 while ((ch = stream.getByte()) !== -1) {
6202 if (ch === GT) {
6203 break;
6204 }
6205 }
6206
6207 const length = stream.pos - startPos;
6208
6209 if (ch === -1) {
6210 (0, _util.warn)("Inline ASCIIHexDecode image stream: " + "EOD marker not found, searching for /EI/ instead.");
6211 stream.skip(-length);
6212 return this.findDefaultInlineStreamEnd(stream);
6213 }
6214
6215 this.inlineStreamSkipEI(stream);
6216 return length;
6217 }
6218
6219 inlineStreamSkipEI(stream) {
6220 const E = 0x45,
6221 I = 0x49;
6222 let state = 0,
6223 ch;
6224
6225 while ((ch = stream.getByte()) !== -1) {
6226 if (state === 0) {
6227 state = ch === E ? 1 : 0;
6228 } else if (state === 1) {
6229 state = ch === I ? 2 : 0;
6230 } else if (state === 2) {
6231 break;
6232 }
6233 }
6234 }
6235
6236 makeInlineImage(cipherTransform) {
6237 const lexer = this.lexer;
6238 const stream = lexer.stream;
6239 const dict = new _primitives.Dict(this.xref);
6240 let dictLength;
6241
6242 while (!(0, _primitives.isCmd)(this.buf1, "ID") && !(0, _primitives.isEOF)(this.buf1)) {
6243 if (!(0, _primitives.isName)(this.buf1)) {
6244 throw new _util.FormatError("Dictionary key must be a name object");
6245 }
6246
6247 const key = this.buf1.name;
6248 this.shift();
6249
6250 if ((0, _primitives.isEOF)(this.buf1)) {
6251 break;
6252 }
6253
6254 dict.set(key, this.getObj(cipherTransform));
6255 }
6256
6257 if (lexer.beginInlineImagePos !== -1) {
6258 dictLength = stream.pos - lexer.beginInlineImagePos;
6259 }
6260
6261 const filter = dict.get("Filter", "F");
6262 let filterName;
6263
6264 if ((0, _primitives.isName)(filter)) {
6265 filterName = filter.name;
6266 } else if (Array.isArray(filter)) {
6267 const filterZero = this.xref.fetchIfRef(filter[0]);
6268
6269 if ((0, _primitives.isName)(filterZero)) {
6270 filterName = filterZero.name;
6271 }
6272 }
6273
6274 const startPos = stream.pos;
6275 let length;
6276
6277 if (filterName === "DCTDecode" || filterName === "DCT") {
6278 length = this.findDCTDecodeInlineStreamEnd(stream);
6279 } else if (filterName === "ASCII85Decode" || filterName === "A85") {
6280 length = this.findASCII85DecodeInlineStreamEnd(stream);
6281 } else if (filterName === "ASCIIHexDecode" || filterName === "AHx") {
6282 length = this.findASCIIHexDecodeInlineStreamEnd(stream);
6283 } else {
6284 length = this.findDefaultInlineStreamEnd(stream);
6285 }
6286
6287 let imageStream = stream.makeSubStream(startPos, length, dict);
6288 let cacheKey;
6289
6290 if (length < MAX_LENGTH_TO_CACHE && dictLength < MAX_ADLER32_LENGTH) {
6291 const imageBytes = imageStream.getBytes();
6292 imageStream.reset();
6293 const initialStreamPos = stream.pos;
6294 stream.pos = lexer.beginInlineImagePos;
6295 const dictBytes = stream.getBytes(dictLength);
6296 stream.pos = initialStreamPos;
6297 cacheKey = computeAdler32(imageBytes) + "_" + computeAdler32(dictBytes);
6298 const cacheEntry = this.imageCache[cacheKey];
6299
6300 if (cacheEntry !== undefined) {
6301 this.buf2 = _primitives.Cmd.get("EI");
6302 this.shift();
6303 cacheEntry.reset();
6304 return cacheEntry;
6305 }
6306 }
6307
6308 if (cipherTransform) {
6309 imageStream = cipherTransform.createStream(imageStream, length);
6310 }
6311
6312 imageStream = this.filter(imageStream, dict, length);
6313 imageStream.dict = dict;
6314
6315 if (cacheKey !== undefined) {
6316 imageStream.cacheKey = `inline_${length}_${cacheKey}`;
6317 this.imageCache[cacheKey] = imageStream;
6318 }
6319
6320 this.buf2 = _primitives.Cmd.get("EI");
6321 this.shift();
6322 return imageStream;
6323 }
6324
6325 _findStreamLength(startPos, signature) {
6326 const {
6327 stream
6328 } = this.lexer;
6329 stream.pos = startPos;
6330 const SCAN_BLOCK_LENGTH = 2048;
6331 const signatureLength = signature.length;
6332
6333 while (stream.pos < stream.end) {
6334 const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
6335 const scanLength = scanBytes.length - signatureLength;
6336
6337 if (scanLength <= 0) {
6338 break;
6339 }
6340
6341 let pos = 0;
6342
6343 while (pos < scanLength) {
6344 let j = 0;
6345
6346 while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
6347 j++;
6348 }
6349
6350 if (j >= signatureLength) {
6351 stream.pos += pos;
6352 return stream.pos - startPos;
6353 }
6354
6355 pos++;
6356 }
6357
6358 stream.pos += scanLength;
6359 }
6360
6361 return -1;
6362 }
6363
6364 makeStream(dict, cipherTransform) {
6365 const lexer = this.lexer;
6366 let stream = lexer.stream;
6367 lexer.skipToNextLine();
6368 const startPos = stream.pos - 1;
6369 let length = dict.get("Length");
6370
6371 if (!Number.isInteger(length)) {
6372 (0, _util.info)(`Bad length "${length}" in stream`);
6373 length = 0;
6374 }
6375
6376 stream.pos = startPos + length;
6377 lexer.nextChar();
6378
6379 if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, "endstream")) {
6380 this.shift();
6381 } else {
6382 const ENDSTREAM_SIGNATURE = new Uint8Array([0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D]);
6383
6384 let actualLength = this._findStreamLength(startPos, ENDSTREAM_SIGNATURE);
6385
6386 if (actualLength < 0) {
6387 const MAX_TRUNCATION = 1;
6388
6389 for (let i = 1; i <= MAX_TRUNCATION; i++) {
6390 const end = ENDSTREAM_SIGNATURE.length - i;
6391 const TRUNCATED_SIGNATURE = ENDSTREAM_SIGNATURE.slice(0, end);
6392
6393 const maybeLength = this._findStreamLength(startPos, TRUNCATED_SIGNATURE);
6394
6395 if (maybeLength >= 0) {
6396 const lastByte = stream.peekBytes(end + 1)[end];
6397
6398 if (!(0, _core_utils.isWhiteSpace)(lastByte)) {
6399 break;
6400 }
6401
6402 (0, _util.info)(`Found "${(0, _util.bytesToString)(TRUNCATED_SIGNATURE)}" when ` + "searching for endstream command.");
6403 actualLength = maybeLength;
6404 break;
6405 }
6406 }
6407
6408 if (actualLength < 0) {
6409 throw new _util.FormatError("Missing endstream command.");
6410 }
6411 }
6412
6413 length = actualLength;
6414 lexer.nextChar();
6415 this.shift();
6416 this.shift();
6417 }
6418
6419 this.shift();
6420 stream = stream.makeSubStream(startPos, length, dict);
6421
6422 if (cipherTransform) {
6423 stream = cipherTransform.createStream(stream, length);
6424 }
6425
6426 stream = this.filter(stream, dict, length);
6427 stream.dict = dict;
6428 return stream;
6429 }
6430
6431 filter(stream, dict, length) {
6432 let filter = dict.get("Filter", "F");
6433 let params = dict.get("DecodeParms", "DP");
6434
6435 if ((0, _primitives.isName)(filter)) {
6436 if (Array.isArray(params)) {
6437 (0, _util.warn)("/DecodeParms should not contain an Array, " + "when /Filter contains a Name.");
6438 }
6439
6440 return this.makeFilter(stream, filter.name, length, params);
6441 }
6442
6443 let maybeLength = length;
6444
6445 if (Array.isArray(filter)) {
6446 const filterArray = filter;
6447 const paramsArray = params;
6448
6449 for (let i = 0, ii = filterArray.length; i < ii; ++i) {
6450 filter = this.xref.fetchIfRef(filterArray[i]);
6451
6452 if (!(0, _primitives.isName)(filter)) {
6453 throw new _util.FormatError(`Bad filter name "${filter}"`);
6454 }
6455
6456 params = null;
6457
6458 if (Array.isArray(paramsArray) && i in paramsArray) {
6459 params = this.xref.fetchIfRef(paramsArray[i]);
6460 }
6461
6462 stream = this.makeFilter(stream, filter.name, maybeLength, params);
6463 maybeLength = null;
6464 }
6465 }
6466
6467 return stream;
6468 }
6469
6470 makeFilter(stream, name, maybeLength, params) {
6471 if (maybeLength === 0) {
6472 (0, _util.warn)(`Empty "${name}" stream.`);
6473 return new _stream.NullStream();
6474 }
6475
6476 try {
6477 const xrefStreamStats = this.xref.stats.streamTypes;
6478
6479 if (name === "FlateDecode" || name === "Fl") {
6480 xrefStreamStats[_util.StreamType.FLATE] = true;
6481
6482 if (params) {
6483 return new _stream.PredictorStream(new _stream.FlateStream(stream, maybeLength), maybeLength, params);
6484 }
6485
6486 return new _stream.FlateStream(stream, maybeLength);
6487 }
6488
6489 if (name === "LZWDecode" || name === "LZW") {
6490 xrefStreamStats[_util.StreamType.LZW] = true;
6491 let earlyChange = 1;
6492
6493 if (params) {
6494 if (params.has("EarlyChange")) {
6495 earlyChange = params.get("EarlyChange");
6496 }
6497
6498 return new _stream.PredictorStream(new _stream.LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
6499 }
6500
6501 return new _stream.LZWStream(stream, maybeLength, earlyChange);
6502 }
6503
6504 if (name === "DCTDecode" || name === "DCT") {
6505 xrefStreamStats[_util.StreamType.DCT] = true;
6506 return new _jpeg_stream.JpegStream(stream, maybeLength, stream.dict, params);
6507 }
6508
6509 if (name === "JPXDecode" || name === "JPX") {
6510 xrefStreamStats[_util.StreamType.JPX] = true;
6511 return new _jpx_stream.JpxStream(stream, maybeLength, stream.dict, params);
6512 }
6513
6514 if (name === "ASCII85Decode" || name === "A85") {
6515 xrefStreamStats[_util.StreamType.A85] = true;
6516 return new _stream.Ascii85Stream(stream, maybeLength);
6517 }
6518
6519 if (name === "ASCIIHexDecode" || name === "AHx") {
6520 xrefStreamStats[_util.StreamType.AHX] = true;
6521 return new _stream.AsciiHexStream(stream, maybeLength);
6522 }
6523
6524 if (name === "CCITTFaxDecode" || name === "CCF") {
6525 xrefStreamStats[_util.StreamType.CCF] = true;
6526 return new _ccitt_stream.CCITTFaxStream(stream, maybeLength, params);
6527 }
6528
6529 if (name === "RunLengthDecode" || name === "RL") {
6530 xrefStreamStats[_util.StreamType.RLX] = true;
6531 return new _stream.RunLengthStream(stream, maybeLength);
6532 }
6533
6534 if (name === "JBIG2Decode") {
6535 xrefStreamStats[_util.StreamType.JBIG] = true;
6536 return new _jbig2_stream.Jbig2Stream(stream, maybeLength, stream.dict, params);
6537 }
6538
6539 (0, _util.warn)(`Filter "${name}" is not supported.`);
6540 return stream;
6541 } catch (ex) {
6542 if (ex instanceof _core_utils.MissingDataException) {
6543 throw ex;
6544 }
6545
6546 (0, _util.warn)(`Invalid stream: "${ex}"`);
6547 return new _stream.NullStream();
6548 }
6549 }
6550
6551}
6552
6553exports.Parser = Parser;
6554const specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
6555
6556function toHexDigit(ch) {
6557 if (ch >= 0x30 && ch <= 0x39) {
6558 return ch & 0x0f;
6559 }
6560
6561 if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
6562 return (ch & 0x0f) + 9;
6563 }
6564
6565 return -1;
6566}
6567
6568class Lexer {
6569 constructor(stream, knownCommands = null) {
6570 this.stream = stream;
6571 this.nextChar();
6572 this.strBuf = [];
6573 this.knownCommands = knownCommands;
6574 this._hexStringNumWarn = 0;
6575 this.beginInlineImagePos = -1;
6576 }
6577
6578 nextChar() {
6579 return this.currentChar = this.stream.getByte();
6580 }
6581
6582 peekChar() {
6583 return this.stream.peekByte();
6584 }
6585
6586 getNumber() {
6587 let ch = this.currentChar;
6588 let eNotation = false;
6589 let divideBy = 0;
6590 let sign = 0;
6591
6592 if (ch === 0x2d) {
6593 sign = -1;
6594 ch = this.nextChar();
6595
6596 if (ch === 0x2d) {
6597 ch = this.nextChar();
6598 }
6599 } else if (ch === 0x2b) {
6600 sign = 1;
6601 ch = this.nextChar();
6602 }
6603
6604 if (ch === 0x0a || ch === 0x0d) {
6605 do {
6606 ch = this.nextChar();
6607 } while (ch === 0x0a || ch === 0x0d);
6608 }
6609
6610 if (ch === 0x2e) {
6611 divideBy = 10;
6612 ch = this.nextChar();
6613 }
6614
6615 if (ch < 0x30 || ch > 0x39) {
6616 if (divideBy === 10 && sign === 0 && ((0, _core_utils.isWhiteSpace)(ch) || ch === -1)) {
6617 (0, _util.warn)("Lexer.getNumber - treating a single decimal point as zero.");
6618 return 0;
6619 }
6620
6621 throw new _util.FormatError(`Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`);
6622 }
6623
6624 sign = sign || 1;
6625 let baseValue = ch - 0x30;
6626 let powerValue = 0;
6627 let powerValueSign = 1;
6628
6629 while ((ch = this.nextChar()) >= 0) {
6630 if (ch >= 0x30 && ch <= 0x39) {
6631 const currentDigit = ch - 0x30;
6632
6633 if (eNotation) {
6634 powerValue = powerValue * 10 + currentDigit;
6635 } else {
6636 if (divideBy !== 0) {
6637 divideBy *= 10;
6638 }
6639
6640 baseValue = baseValue * 10 + currentDigit;
6641 }
6642 } else if (ch === 0x2e) {
6643 if (divideBy === 0) {
6644 divideBy = 1;
6645 } else {
6646 break;
6647 }
6648 } else if (ch === 0x2d) {
6649 (0, _util.warn)("Badly formatted number: minus sign in the middle");
6650 } else if (ch === 0x45 || ch === 0x65) {
6651 ch = this.peekChar();
6652
6653 if (ch === 0x2b || ch === 0x2d) {
6654 powerValueSign = ch === 0x2d ? -1 : 1;
6655 this.nextChar();
6656 } else if (ch < 0x30 || ch > 0x39) {
6657 break;
6658 }
6659
6660 eNotation = true;
6661 } else {
6662 break;
6663 }
6664 }
6665
6666 if (divideBy !== 0) {
6667 baseValue /= divideBy;
6668 }
6669
6670 if (eNotation) {
6671 baseValue *= 10 ** (powerValueSign * powerValue);
6672 }
6673
6674 return sign * baseValue;
6675 }
6676
6677 getString() {
6678 let numParen = 1;
6679 let done = false;
6680 const strBuf = this.strBuf;
6681 strBuf.length = 0;
6682 let ch = this.nextChar();
6683
6684 while (true) {
6685 let charBuffered = false;
6686
6687 switch (ch | 0) {
6688 case -1:
6689 (0, _util.warn)("Unterminated string");
6690 done = true;
6691 break;
6692
6693 case 0x28:
6694 ++numParen;
6695 strBuf.push("(");
6696 break;
6697
6698 case 0x29:
6699 if (--numParen === 0) {
6700 this.nextChar();
6701 done = true;
6702 } else {
6703 strBuf.push(")");
6704 }
6705
6706 break;
6707
6708 case 0x5c:
6709 ch = this.nextChar();
6710
6711 switch (ch) {
6712 case -1:
6713 (0, _util.warn)("Unterminated string");
6714 done = true;
6715 break;
6716
6717 case 0x6e:
6718 strBuf.push("\n");
6719 break;
6720
6721 case 0x72:
6722 strBuf.push("\r");
6723 break;
6724
6725 case 0x74:
6726 strBuf.push("\t");
6727 break;
6728
6729 case 0x62:
6730 strBuf.push("\b");
6731 break;
6732
6733 case 0x66:
6734 strBuf.push("\f");
6735 break;
6736
6737 case 0x5c:
6738 case 0x28:
6739 case 0x29:
6740 strBuf.push(String.fromCharCode(ch));
6741 break;
6742
6743 case 0x30:
6744 case 0x31:
6745 case 0x32:
6746 case 0x33:
6747 case 0x34:
6748 case 0x35:
6749 case 0x36:
6750 case 0x37:
6751 let x = ch & 0x0f;
6752 ch = this.nextChar();
6753 charBuffered = true;
6754
6755 if (ch >= 0x30 && ch <= 0x37) {
6756 x = (x << 3) + (ch & 0x0f);
6757 ch = this.nextChar();
6758
6759 if (ch >= 0x30 && ch <= 0x37) {
6760 charBuffered = false;
6761 x = (x << 3) + (ch & 0x0f);
6762 }
6763 }
6764
6765 strBuf.push(String.fromCharCode(x));
6766 break;
6767
6768 case 0x0d:
6769 if (this.peekChar() === 0x0a) {
6770 this.nextChar();
6771 }
6772
6773 break;
6774
6775 case 0x0a:
6776 break;
6777
6778 default:
6779 strBuf.push(String.fromCharCode(ch));
6780 break;
6781 }
6782
6783 break;
6784
6785 default:
6786 strBuf.push(String.fromCharCode(ch));
6787 break;
6788 }
6789
6790 if (done) {
6791 break;
6792 }
6793
6794 if (!charBuffered) {
6795 ch = this.nextChar();
6796 }
6797 }
6798
6799 return strBuf.join("");
6800 }
6801
6802 getName() {
6803 let ch, previousCh;
6804 const strBuf = this.strBuf;
6805 strBuf.length = 0;
6806
6807 while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
6808 if (ch === 0x23) {
6809 ch = this.nextChar();
6810
6811 if (specialChars[ch]) {
6812 (0, _util.warn)("Lexer_getName: " + "NUMBER SIGN (#) should be followed by a hexadecimal number.");
6813 strBuf.push("#");
6814 break;
6815 }
6816
6817 const x = toHexDigit(ch);
6818
6819 if (x !== -1) {
6820 previousCh = ch;
6821 ch = this.nextChar();
6822 const x2 = toHexDigit(ch);
6823
6824 if (x2 === -1) {
6825 (0, _util.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(ch)}) ` + "in hexadecimal number.");
6826 strBuf.push("#", String.fromCharCode(previousCh));
6827
6828 if (specialChars[ch]) {
6829 break;
6830 }
6831
6832 strBuf.push(String.fromCharCode(ch));
6833 continue;
6834 }
6835
6836 strBuf.push(String.fromCharCode(x << 4 | x2));
6837 } else {
6838 strBuf.push("#", String.fromCharCode(ch));
6839 }
6840 } else {
6841 strBuf.push(String.fromCharCode(ch));
6842 }
6843 }
6844
6845 if (strBuf.length > 127) {
6846 (0, _util.warn)(`Name token is longer than allowed by the spec: ${strBuf.length}`);
6847 }
6848
6849 return _primitives.Name.get(strBuf.join(""));
6850 }
6851
6852 _hexStringWarn(ch) {
6853 const MAX_HEX_STRING_NUM_WARN = 5;
6854
6855 if (this._hexStringNumWarn++ === MAX_HEX_STRING_NUM_WARN) {
6856 (0, _util.warn)("getHexString - ignoring additional invalid characters.");
6857 return;
6858 }
6859
6860 if (this._hexStringNumWarn > MAX_HEX_STRING_NUM_WARN) {
6861 return;
6862 }
6863
6864 (0, _util.warn)(`getHexString - ignoring invalid character: ${ch}`);
6865 }
6866
6867 getHexString() {
6868 const strBuf = this.strBuf;
6869 strBuf.length = 0;
6870 let ch = this.currentChar;
6871 let isFirstHex = true;
6872 let firstDigit, secondDigit;
6873 this._hexStringNumWarn = 0;
6874
6875 while (true) {
6876 if (ch < 0) {
6877 (0, _util.warn)("Unterminated hex string");
6878 break;
6879 } else if (ch === 0x3e) {
6880 this.nextChar();
6881 break;
6882 } else if (specialChars[ch] === 1) {
6883 ch = this.nextChar();
6884 continue;
6885 } else {
6886 if (isFirstHex) {
6887 firstDigit = toHexDigit(ch);
6888
6889 if (firstDigit === -1) {
6890 this._hexStringWarn(ch);
6891
6892 ch = this.nextChar();
6893 continue;
6894 }
6895 } else {
6896 secondDigit = toHexDigit(ch);
6897
6898 if (secondDigit === -1) {
6899 this._hexStringWarn(ch);
6900
6901 ch = this.nextChar();
6902 continue;
6903 }
6904
6905 strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
6906 }
6907
6908 isFirstHex = !isFirstHex;
6909 ch = this.nextChar();
6910 }
6911 }
6912
6913 return strBuf.join("");
6914 }
6915
6916 getObj() {
6917 let comment = false;
6918 let ch = this.currentChar;
6919
6920 while (true) {
6921 if (ch < 0) {
6922 return _primitives.EOF;
6923 }
6924
6925 if (comment) {
6926 if (ch === 0x0a || ch === 0x0d) {
6927 comment = false;
6928 }
6929 } else if (ch === 0x25) {
6930 comment = true;
6931 } else if (specialChars[ch] !== 1) {
6932 break;
6933 }
6934
6935 ch = this.nextChar();
6936 }
6937
6938 switch (ch | 0) {
6939 case 0x30:
6940 case 0x31:
6941 case 0x32:
6942 case 0x33:
6943 case 0x34:
6944 case 0x35:
6945 case 0x36:
6946 case 0x37:
6947 case 0x38:
6948 case 0x39:
6949 case 0x2b:
6950 case 0x2d:
6951 case 0x2e:
6952 return this.getNumber();
6953
6954 case 0x28:
6955 return this.getString();
6956
6957 case 0x2f:
6958 return this.getName();
6959
6960 case 0x5b:
6961 this.nextChar();
6962 return _primitives.Cmd.get("[");
6963
6964 case 0x5d:
6965 this.nextChar();
6966 return _primitives.Cmd.get("]");
6967
6968 case 0x3c:
6969 ch = this.nextChar();
6970
6971 if (ch === 0x3c) {
6972 this.nextChar();
6973 return _primitives.Cmd.get("<<");
6974 }
6975
6976 return this.getHexString();
6977
6978 case 0x3e:
6979 ch = this.nextChar();
6980
6981 if (ch === 0x3e) {
6982 this.nextChar();
6983 return _primitives.Cmd.get(">>");
6984 }
6985
6986 return _primitives.Cmd.get(">");
6987
6988 case 0x7b:
6989 this.nextChar();
6990 return _primitives.Cmd.get("{");
6991
6992 case 0x7d:
6993 this.nextChar();
6994 return _primitives.Cmd.get("}");
6995
6996 case 0x29:
6997 this.nextChar();
6998 throw new _util.FormatError(`Illegal character: ${ch}`);
6999 }
7000
7001 let str = String.fromCharCode(ch);
7002 const knownCommands = this.knownCommands;
7003 let knownCommandFound = knownCommands && knownCommands[str] !== undefined;
7004
7005 while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
7006 const possibleCommand = str + String.fromCharCode(ch);
7007
7008 if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
7009 break;
7010 }
7011
7012 if (str.length === 128) {
7013 throw new _util.FormatError(`Command token too long: ${str.length}`);
7014 }
7015
7016 str = possibleCommand;
7017 knownCommandFound = knownCommands && knownCommands[str] !== undefined;
7018 }
7019
7020 if (str === "true") {
7021 return true;
7022 }
7023
7024 if (str === "false") {
7025 return false;
7026 }
7027
7028 if (str === "null") {
7029 return null;
7030 }
7031
7032 if (str === "BI") {
7033 this.beginInlineImagePos = this.stream.pos;
7034 }
7035
7036 return _primitives.Cmd.get(str);
7037 }
7038
7039 skipToNextLine() {
7040 let ch = this.currentChar;
7041
7042 while (ch >= 0) {
7043 if (ch === 0x0d) {
7044 ch = this.nextChar();
7045
7046 if (ch === 0x0a) {
7047 this.nextChar();
7048 }
7049
7050 break;
7051 } else if (ch === 0x0a) {
7052 this.nextChar();
7053 break;
7054 }
7055
7056 ch = this.nextChar();
7057 }
7058 }
7059
7060}
7061
7062exports.Lexer = Lexer;
7063
7064class Linearization {
7065 static create(stream) {
7066 function getInt(linDict, name, allowZeroValue = false) {
7067 const obj = linDict.get(name);
7068
7069 if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
7070 return obj;
7071 }
7072
7073 throw new Error(`The "${name}" parameter in the linearization ` + "dictionary is invalid.");
7074 }
7075
7076 function getHints(linDict) {
7077 const hints = linDict.get("H");
7078 let hintsLength;
7079
7080 if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
7081 for (let index = 0; index < hintsLength; index++) {
7082 const hint = hints[index];
7083
7084 if (!(Number.isInteger(hint) && hint > 0)) {
7085 throw new Error(`Hint (${index}) in the linearization dictionary is invalid.`);
7086 }
7087 }
7088
7089 return hints;
7090 }
7091
7092 throw new Error("Hint array in the linearization dictionary is invalid.");
7093 }
7094
7095 const parser = new Parser({
7096 lexer: new Lexer(stream),
7097 xref: null
7098 });
7099 const obj1 = parser.getObj();
7100 const obj2 = parser.getObj();
7101 const obj3 = parser.getObj();
7102 const linDict = parser.getObj();
7103 let obj, length;
7104
7105 if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, "obj") && (0, _primitives.isDict)(linDict) && (0, _util.isNum)(obj = linDict.get("Linearized")) && obj > 0)) {
7106 return null;
7107 } else if ((length = getInt(linDict, "L")) !== stream.length) {
7108 throw new Error('The "L" parameter in the linearization dictionary ' + "does not equal the stream length.");
7109 }
7110
7111 return {
7112 length,
7113 hints: getHints(linDict),
7114 objectNumberFirst: getInt(linDict, "O"),
7115 endFirst: getInt(linDict, "E"),
7116 numPages: getInt(linDict, "N"),
7117 mainXRefEntriesOffset: getInt(linDict, "T"),
7118 pageFirst: linDict.has("P") ? getInt(linDict, "P", true) : 0
7119 };
7120 }
7121
7122}
7123
7124exports.Linearization = Linearization;
7125
7126/***/ }),
7127/* 12 */
7128/***/ (function(module, exports, __w_pdfjs_require__) {
7129
7130"use strict";
7131
7132
7133Object.defineProperty(exports, "__esModule", {
7134 value: true
7135});
7136exports.LZWStream = exports.StringStream = exports.StreamsSequenceStream = exports.Stream = exports.RunLengthStream = exports.PredictorStream = exports.NullStream = exports.FlateStream = exports.DecodeStream = exports.DecryptStream = exports.AsciiHexStream = exports.Ascii85Stream = void 0;
7137
7138var _util = __w_pdfjs_require__(2);
7139
7140var _primitives = __w_pdfjs_require__(5);
7141
7142var _core_utils = __w_pdfjs_require__(8);
7143
7144var Stream = function StreamClosure() {
7145 function Stream(arrayBuffer, start, length, dict) {
7146 this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
7147 this.start = start || 0;
7148 this.pos = this.start;
7149 this.end = start + length || this.bytes.length;
7150 this.dict = dict;
7151 }
7152
7153 Stream.prototype = {
7154 get length() {
7155 return this.end - this.start;
7156 },
7157
7158 get isEmpty() {
7159 return this.length === 0;
7160 },
7161
7162 getByte: function Stream_getByte() {
7163 if (this.pos >= this.end) {
7164 return -1;
7165 }
7166
7167 return this.bytes[this.pos++];
7168 },
7169 getUint16: function Stream_getUint16() {
7170 var b0 = this.getByte();
7171 var b1 = this.getByte();
7172
7173 if (b0 === -1 || b1 === -1) {
7174 return -1;
7175 }
7176
7177 return (b0 << 8) + b1;
7178 },
7179 getInt32: function Stream_getInt32() {
7180 var b0 = this.getByte();
7181 var b1 = this.getByte();
7182 var b2 = this.getByte();
7183 var b3 = this.getByte();
7184 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
7185 },
7186
7187 getBytes(length, forceClamped = false) {
7188 var bytes = this.bytes;
7189 var pos = this.pos;
7190 var strEnd = this.end;
7191
7192 if (!length) {
7193 const subarray = bytes.subarray(pos, strEnd);
7194 return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
7195 }
7196
7197 var end = pos + length;
7198
7199 if (end > strEnd) {
7200 end = strEnd;
7201 }
7202
7203 this.pos = end;
7204 const subarray = bytes.subarray(pos, end);
7205 return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
7206 },
7207
7208 peekByte: function Stream_peekByte() {
7209 var peekedByte = this.getByte();
7210
7211 if (peekedByte !== -1) {
7212 this.pos--;
7213 }
7214
7215 return peekedByte;
7216 },
7217
7218 peekBytes(length, forceClamped = false) {
7219 var bytes = this.getBytes(length, forceClamped);
7220 this.pos -= bytes.length;
7221 return bytes;
7222 },
7223
7224 getByteRange(begin, end) {
7225 if (begin < 0) {
7226 begin = 0;
7227 }
7228
7229 if (end > this.end) {
7230 end = this.end;
7231 }
7232
7233 return this.bytes.subarray(begin, end);
7234 },
7235
7236 skip: function Stream_skip(n) {
7237 if (!n) {
7238 n = 1;
7239 }
7240
7241 this.pos += n;
7242 },
7243 reset: function Stream_reset() {
7244 this.pos = this.start;
7245 },
7246 moveStart: function Stream_moveStart() {
7247 this.start = this.pos;
7248 },
7249 makeSubStream: function Stream_makeSubStream(start, length, dict) {
7250 return new Stream(this.bytes.buffer, start, length, dict);
7251 }
7252 };
7253 return Stream;
7254}();
7255
7256exports.Stream = Stream;
7257
7258var StringStream = function StringStreamClosure() {
7259 function StringStream(str) {
7260 const bytes = (0, _util.stringToBytes)(str);
7261 Stream.call(this, bytes);
7262 }
7263
7264 StringStream.prototype = Stream.prototype;
7265 return StringStream;
7266}();
7267
7268exports.StringStream = StringStream;
7269
7270var DecodeStream = function DecodeStreamClosure() {
7271 var emptyBuffer = new Uint8Array(0);
7272
7273 function DecodeStream(maybeMinBufferLength) {
7274 this._rawMinBufferLength = maybeMinBufferLength || 0;
7275 this.pos = 0;
7276 this.bufferLength = 0;
7277 this.eof = false;
7278 this.buffer = emptyBuffer;
7279 this.minBufferLength = 512;
7280
7281 if (maybeMinBufferLength) {
7282 while (this.minBufferLength < maybeMinBufferLength) {
7283 this.minBufferLength *= 2;
7284 }
7285 }
7286 }
7287
7288 DecodeStream.prototype = {
7289 get isEmpty() {
7290 while (!this.eof && this.bufferLength === 0) {
7291 this.readBlock();
7292 }
7293
7294 return this.bufferLength === 0;
7295 },
7296
7297 ensureBuffer: function DecodeStream_ensureBuffer(requested) {
7298 var buffer = this.buffer;
7299
7300 if (requested <= buffer.byteLength) {
7301 return buffer;
7302 }
7303
7304 var size = this.minBufferLength;
7305
7306 while (size < requested) {
7307 size *= 2;
7308 }
7309
7310 var buffer2 = new Uint8Array(size);
7311 buffer2.set(buffer);
7312 return this.buffer = buffer2;
7313 },
7314 getByte: function DecodeStream_getByte() {
7315 var pos = this.pos;
7316
7317 while (this.bufferLength <= pos) {
7318 if (this.eof) {
7319 return -1;
7320 }
7321
7322 this.readBlock();
7323 }
7324
7325 return this.buffer[this.pos++];
7326 },
7327 getUint16: function DecodeStream_getUint16() {
7328 var b0 = this.getByte();
7329 var b1 = this.getByte();
7330
7331 if (b0 === -1 || b1 === -1) {
7332 return -1;
7333 }
7334
7335 return (b0 << 8) + b1;
7336 },
7337 getInt32: function DecodeStream_getInt32() {
7338 var b0 = this.getByte();
7339 var b1 = this.getByte();
7340 var b2 = this.getByte();
7341 var b3 = this.getByte();
7342 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
7343 },
7344
7345 getBytes(length, forceClamped = false) {
7346 var end,
7347 pos = this.pos;
7348
7349 if (length) {
7350 this.ensureBuffer(pos + length);
7351 end = pos + length;
7352
7353 while (!this.eof && this.bufferLength < end) {
7354 this.readBlock();
7355 }
7356
7357 var bufEnd = this.bufferLength;
7358
7359 if (end > bufEnd) {
7360 end = bufEnd;
7361 }
7362 } else {
7363 while (!this.eof) {
7364 this.readBlock();
7365 }
7366
7367 end = this.bufferLength;
7368 }
7369
7370 this.pos = end;
7371 const subarray = this.buffer.subarray(pos, end);
7372 return forceClamped && !(subarray instanceof Uint8ClampedArray) ? new Uint8ClampedArray(subarray) : subarray;
7373 },
7374
7375 peekByte: function DecodeStream_peekByte() {
7376 var peekedByte = this.getByte();
7377
7378 if (peekedByte !== -1) {
7379 this.pos--;
7380 }
7381
7382 return peekedByte;
7383 },
7384
7385 peekBytes(length, forceClamped = false) {
7386 var bytes = this.getBytes(length, forceClamped);
7387 this.pos -= bytes.length;
7388 return bytes;
7389 },
7390
7391 makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
7392 var end = start + length;
7393
7394 while (this.bufferLength <= end && !this.eof) {
7395 this.readBlock();
7396 }
7397
7398 return new Stream(this.buffer, start, length, dict);
7399 },
7400
7401 getByteRange(begin, end) {
7402 (0, _util.unreachable)("Should not call DecodeStream.getByteRange");
7403 },
7404
7405 skip: function DecodeStream_skip(n) {
7406 if (!n) {
7407 n = 1;
7408 }
7409
7410 this.pos += n;
7411 },
7412 reset: function DecodeStream_reset() {
7413 this.pos = 0;
7414 },
7415 getBaseStreams: function DecodeStream_getBaseStreams() {
7416 if (this.str && this.str.getBaseStreams) {
7417 return this.str.getBaseStreams();
7418 }
7419
7420 return [];
7421 }
7422 };
7423 return DecodeStream;
7424}();
7425
7426exports.DecodeStream = DecodeStream;
7427
7428var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
7429 function StreamsSequenceStream(streams) {
7430 this.streams = streams;
7431 let maybeLength = 0;
7432
7433 for (let i = 0, ii = streams.length; i < ii; i++) {
7434 const stream = streams[i];
7435
7436 if (stream instanceof DecodeStream) {
7437 maybeLength += stream._rawMinBufferLength;
7438 } else {
7439 maybeLength += stream.length;
7440 }
7441 }
7442
7443 DecodeStream.call(this, maybeLength);
7444 }
7445
7446 StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
7447
7448 StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
7449 var streams = this.streams;
7450
7451 if (streams.length === 0) {
7452 this.eof = true;
7453 return;
7454 }
7455
7456 var stream = streams.shift();
7457 var chunk = stream.getBytes();
7458 var bufferLength = this.bufferLength;
7459 var newLength = bufferLength + chunk.length;
7460 var buffer = this.ensureBuffer(newLength);
7461 buffer.set(chunk, bufferLength);
7462 this.bufferLength = newLength;
7463 };
7464
7465 StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
7466 var baseStreams = [];
7467
7468 for (var i = 0, ii = this.streams.length; i < ii; i++) {
7469 var stream = this.streams[i];
7470
7471 if (stream.getBaseStreams) {
7472 baseStreams.push(...stream.getBaseStreams());
7473 }
7474 }
7475
7476 return baseStreams;
7477 };
7478
7479 return StreamsSequenceStream;
7480}();
7481
7482exports.StreamsSequenceStream = StreamsSequenceStream;
7483
7484var FlateStream = function FlateStreamClosure() {
7485 var codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
7486 var lengthDecode = new Int32Array([0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a, 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f, 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073, 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102]);
7487 var distDecode = new Int32Array([0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001]);
7488 var fixedLitCodeTab = [new Int32Array([0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0, 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0, 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0, 0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8, 0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8, 0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8, 0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4, 0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4, 0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4, 0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc, 0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec, 0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc, 0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2, 0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2, 0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2, 0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca, 0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea, 0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da, 0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6, 0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6, 0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6, 0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce, 0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee, 0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de, 0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe, 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1, 0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1, 0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1, 0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9, 0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9, 0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9, 0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5, 0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5, 0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5, 0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd, 0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed, 0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd, 0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3, 0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3, 0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3, 0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb, 0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb, 0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db, 0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7, 0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7, 0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7, 0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf, 0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef, 0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df, 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff]), 9];
7489 var fixedDistCodeTab = [new Int32Array([0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c, 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000, 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d, 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000]), 5];
7490
7491 function FlateStream(str, maybeLength) {
7492 this.str = str;
7493 this.dict = str.dict;
7494 var cmf = str.getByte();
7495 var flg = str.getByte();
7496
7497 if (cmf === -1 || flg === -1) {
7498 throw new _util.FormatError(`Invalid header in flate stream: ${cmf}, ${flg}`);
7499 }
7500
7501 if ((cmf & 0x0f) !== 0x08) {
7502 throw new _util.FormatError(`Unknown compression method in flate stream: ${cmf}, ${flg}`);
7503 }
7504
7505 if (((cmf << 8) + flg) % 31 !== 0) {
7506 throw new _util.FormatError(`Bad FCHECK in flate stream: ${cmf}, ${flg}`);
7507 }
7508
7509 if (flg & 0x20) {
7510 throw new _util.FormatError(`FDICT bit set in flate stream: ${cmf}, ${flg}`);
7511 }
7512
7513 this.codeSize = 0;
7514 this.codeBuf = 0;
7515 DecodeStream.call(this, maybeLength);
7516 }
7517
7518 FlateStream.prototype = Object.create(DecodeStream.prototype);
7519
7520 FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
7521 var str = this.str;
7522 var codeSize = this.codeSize;
7523 var codeBuf = this.codeBuf;
7524 var b;
7525
7526 while (codeSize < bits) {
7527 if ((b = str.getByte()) === -1) {
7528 throw new _util.FormatError("Bad encoding in flate stream");
7529 }
7530
7531 codeBuf |= b << codeSize;
7532 codeSize += 8;
7533 }
7534
7535 b = codeBuf & (1 << bits) - 1;
7536 this.codeBuf = codeBuf >> bits;
7537 this.codeSize = codeSize -= bits;
7538 return b;
7539 };
7540
7541 FlateStream.prototype.getCode = function FlateStream_getCode(table) {
7542 var str = this.str;
7543 var codes = table[0];
7544 var maxLen = table[1];
7545 var codeSize = this.codeSize;
7546 var codeBuf = this.codeBuf;
7547 var b;
7548
7549 while (codeSize < maxLen) {
7550 if ((b = str.getByte()) === -1) {
7551 break;
7552 }
7553
7554 codeBuf |= b << codeSize;
7555 codeSize += 8;
7556 }
7557
7558 var code = codes[codeBuf & (1 << maxLen) - 1];
7559 var codeLen = code >> 16;
7560 var codeVal = code & 0xffff;
7561
7562 if (codeLen < 1 || codeSize < codeLen) {
7563 throw new _util.FormatError("Bad encoding in flate stream");
7564 }
7565
7566 this.codeBuf = codeBuf >> codeLen;
7567 this.codeSize = codeSize - codeLen;
7568 return codeVal;
7569 };
7570
7571 FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
7572 var n = lengths.length;
7573 var maxLen = 0;
7574 var i;
7575
7576 for (i = 0; i < n; ++i) {
7577 if (lengths[i] > maxLen) {
7578 maxLen = lengths[i];
7579 }
7580 }
7581
7582 var size = 1 << maxLen;
7583 var codes = new Int32Array(size);
7584
7585 for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
7586 for (var val = 0; val < n; ++val) {
7587 if (lengths[val] === len) {
7588 var code2 = 0;
7589 var t = code;
7590
7591 for (i = 0; i < len; ++i) {
7592 code2 = code2 << 1 | t & 1;
7593 t >>= 1;
7594 }
7595
7596 for (i = code2; i < size; i += skip) {
7597 codes[i] = len << 16 | val;
7598 }
7599
7600 ++code;
7601 }
7602 }
7603 }
7604
7605 return [codes, maxLen];
7606 };
7607
7608 FlateStream.prototype.readBlock = function FlateStream_readBlock() {
7609 var buffer, len;
7610 var str = this.str;
7611 var hdr = this.getBits(3);
7612
7613 if (hdr & 1) {
7614 this.eof = true;
7615 }
7616
7617 hdr >>= 1;
7618
7619 if (hdr === 0) {
7620 var b;
7621
7622 if ((b = str.getByte()) === -1) {
7623 throw new _util.FormatError("Bad block header in flate stream");
7624 }
7625
7626 var blockLen = b;
7627
7628 if ((b = str.getByte()) === -1) {
7629 throw new _util.FormatError("Bad block header in flate stream");
7630 }
7631
7632 blockLen |= b << 8;
7633
7634 if ((b = str.getByte()) === -1) {
7635 throw new _util.FormatError("Bad block header in flate stream");
7636 }
7637
7638 var check = b;
7639
7640 if ((b = str.getByte()) === -1) {
7641 throw new _util.FormatError("Bad block header in flate stream");
7642 }
7643
7644 check |= b << 8;
7645
7646 if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
7647 throw new _util.FormatError("Bad uncompressed block length in flate stream");
7648 }
7649
7650 this.codeBuf = 0;
7651 this.codeSize = 0;
7652 const bufferLength = this.bufferLength,
7653 end = bufferLength + blockLen;
7654 buffer = this.ensureBuffer(end);
7655 this.bufferLength = end;
7656
7657 if (blockLen === 0) {
7658 if (str.peekByte() === -1) {
7659 this.eof = true;
7660 }
7661 } else {
7662 const block = str.getBytes(blockLen);
7663 buffer.set(block, bufferLength);
7664
7665 if (block.length < blockLen) {
7666 this.eof = true;
7667 }
7668 }
7669
7670 return;
7671 }
7672
7673 var litCodeTable;
7674 var distCodeTable;
7675
7676 if (hdr === 1) {
7677 litCodeTable = fixedLitCodeTab;
7678 distCodeTable = fixedDistCodeTab;
7679 } else if (hdr === 2) {
7680 var numLitCodes = this.getBits(5) + 257;
7681 var numDistCodes = this.getBits(5) + 1;
7682 var numCodeLenCodes = this.getBits(4) + 4;
7683 var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
7684 var i;
7685
7686 for (i = 0; i < numCodeLenCodes; ++i) {
7687 codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
7688 }
7689
7690 var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
7691 len = 0;
7692 i = 0;
7693 var codes = numLitCodes + numDistCodes;
7694 var codeLengths = new Uint8Array(codes);
7695 var bitsLength, bitsOffset, what;
7696
7697 while (i < codes) {
7698 var code = this.getCode(codeLenCodeTab);
7699
7700 if (code === 16) {
7701 bitsLength = 2;
7702 bitsOffset = 3;
7703 what = len;
7704 } else if (code === 17) {
7705 bitsLength = 3;
7706 bitsOffset = 3;
7707 what = len = 0;
7708 } else if (code === 18) {
7709 bitsLength = 7;
7710 bitsOffset = 11;
7711 what = len = 0;
7712 } else {
7713 codeLengths[i++] = len = code;
7714 continue;
7715 }
7716
7717 var repeatLength = this.getBits(bitsLength) + bitsOffset;
7718
7719 while (repeatLength-- > 0) {
7720 codeLengths[i++] = what;
7721 }
7722 }
7723
7724 litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
7725 distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
7726 } else {
7727 throw new _util.FormatError("Unknown block type in flate stream");
7728 }
7729
7730 buffer = this.buffer;
7731 var limit = buffer ? buffer.length : 0;
7732 var pos = this.bufferLength;
7733
7734 while (true) {
7735 var code1 = this.getCode(litCodeTable);
7736
7737 if (code1 < 256) {
7738 if (pos + 1 >= limit) {
7739 buffer = this.ensureBuffer(pos + 1);
7740 limit = buffer.length;
7741 }
7742
7743 buffer[pos++] = code1;
7744 continue;
7745 }
7746
7747 if (code1 === 256) {
7748 this.bufferLength = pos;
7749 return;
7750 }
7751
7752 code1 -= 257;
7753 code1 = lengthDecode[code1];
7754 var code2 = code1 >> 16;
7755
7756 if (code2 > 0) {
7757 code2 = this.getBits(code2);
7758 }
7759
7760 len = (code1 & 0xffff) + code2;
7761 code1 = this.getCode(distCodeTable);
7762 code1 = distDecode[code1];
7763 code2 = code1 >> 16;
7764
7765 if (code2 > 0) {
7766 code2 = this.getBits(code2);
7767 }
7768
7769 var dist = (code1 & 0xffff) + code2;
7770
7771 if (pos + len >= limit) {
7772 buffer = this.ensureBuffer(pos + len);
7773 limit = buffer.length;
7774 }
7775
7776 for (var k = 0; k < len; ++k, ++pos) {
7777 buffer[pos] = buffer[pos - dist];
7778 }
7779 }
7780 };
7781
7782 return FlateStream;
7783}();
7784
7785exports.FlateStream = FlateStream;
7786
7787var PredictorStream = function PredictorStreamClosure() {
7788 function PredictorStream(str, maybeLength, params) {
7789 if (!(0, _primitives.isDict)(params)) {
7790 return str;
7791 }
7792
7793 var predictor = this.predictor = params.get("Predictor") || 1;
7794
7795 if (predictor <= 1) {
7796 return str;
7797 }
7798
7799 if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
7800 throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
7801 }
7802
7803 if (predictor === 2) {
7804 this.readBlock = this.readBlockTiff;
7805 } else {
7806 this.readBlock = this.readBlockPng;
7807 }
7808
7809 this.str = str;
7810 this.dict = str.dict;
7811 var colors = this.colors = params.get("Colors") || 1;
7812 var bits = this.bits = params.get("BitsPerComponent") || 8;
7813 var columns = this.columns = params.get("Columns") || 1;
7814 this.pixBytes = colors * bits + 7 >> 3;
7815 this.rowBytes = columns * colors * bits + 7 >> 3;
7816 DecodeStream.call(this, maybeLength);
7817 return this;
7818 }
7819
7820 PredictorStream.prototype = Object.create(DecodeStream.prototype);
7821
7822 PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
7823 var rowBytes = this.rowBytes;
7824 var bufferLength = this.bufferLength;
7825 var buffer = this.ensureBuffer(bufferLength + rowBytes);
7826 var bits = this.bits;
7827 var colors = this.colors;
7828 var rawBytes = this.str.getBytes(rowBytes);
7829 this.eof = !rawBytes.length;
7830
7831 if (this.eof) {
7832 return;
7833 }
7834
7835 var inbuf = 0,
7836 outbuf = 0;
7837 var inbits = 0,
7838 outbits = 0;
7839 var pos = bufferLength;
7840 var i;
7841
7842 if (bits === 1 && colors === 1) {
7843 for (i = 0; i < rowBytes; ++i) {
7844 var c = rawBytes[i] ^ inbuf;
7845 c ^= c >> 1;
7846 c ^= c >> 2;
7847 c ^= c >> 4;
7848 inbuf = (c & 1) << 7;
7849 buffer[pos++] = c;
7850 }
7851 } else if (bits === 8) {
7852 for (i = 0; i < colors; ++i) {
7853 buffer[pos++] = rawBytes[i];
7854 }
7855
7856 for (; i < rowBytes; ++i) {
7857 buffer[pos] = buffer[pos - colors] + rawBytes[i];
7858 pos++;
7859 }
7860 } else if (bits === 16) {
7861 var bytesPerPixel = colors * 2;
7862
7863 for (i = 0; i < bytesPerPixel; ++i) {
7864 buffer[pos++] = rawBytes[i];
7865 }
7866
7867 for (; i < rowBytes; i += 2) {
7868 var sum = ((rawBytes[i] & 0xff) << 8) + (rawBytes[i + 1] & 0xff) + ((buffer[pos - bytesPerPixel] & 0xff) << 8) + (buffer[pos - bytesPerPixel + 1] & 0xff);
7869 buffer[pos++] = sum >> 8 & 0xff;
7870 buffer[pos++] = sum & 0xff;
7871 }
7872 } else {
7873 var compArray = new Uint8Array(colors + 1);
7874 var bitMask = (1 << bits) - 1;
7875 var j = 0,
7876 k = bufferLength;
7877 var columns = this.columns;
7878
7879 for (i = 0; i < columns; ++i) {
7880 for (var kk = 0; kk < colors; ++kk) {
7881 if (inbits < bits) {
7882 inbuf = inbuf << 8 | rawBytes[j++] & 0xff;
7883 inbits += 8;
7884 }
7885
7886 compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
7887 inbits -= bits;
7888 outbuf = outbuf << bits | compArray[kk];
7889 outbits += bits;
7890
7891 if (outbits >= 8) {
7892 buffer[k++] = outbuf >> outbits - 8 & 0xff;
7893 outbits -= 8;
7894 }
7895 }
7896 }
7897
7898 if (outbits > 0) {
7899 buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
7900 }
7901 }
7902
7903 this.bufferLength += rowBytes;
7904 };
7905
7906 PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
7907 var rowBytes = this.rowBytes;
7908 var pixBytes = this.pixBytes;
7909 var predictor = this.str.getByte();
7910 var rawBytes = this.str.getBytes(rowBytes);
7911 this.eof = !rawBytes.length;
7912
7913 if (this.eof) {
7914 return;
7915 }
7916
7917 var bufferLength = this.bufferLength;
7918 var buffer = this.ensureBuffer(bufferLength + rowBytes);
7919 var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
7920
7921 if (prevRow.length === 0) {
7922 prevRow = new Uint8Array(rowBytes);
7923 }
7924
7925 var i,
7926 j = bufferLength,
7927 up,
7928 c;
7929
7930 switch (predictor) {
7931 case 0:
7932 for (i = 0; i < rowBytes; ++i) {
7933 buffer[j++] = rawBytes[i];
7934 }
7935
7936 break;
7937
7938 case 1:
7939 for (i = 0; i < pixBytes; ++i) {
7940 buffer[j++] = rawBytes[i];
7941 }
7942
7943 for (; i < rowBytes; ++i) {
7944 buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xff;
7945 j++;
7946 }
7947
7948 break;
7949
7950 case 2:
7951 for (i = 0; i < rowBytes; ++i) {
7952 buffer[j++] = prevRow[i] + rawBytes[i] & 0xff;
7953 }
7954
7955 break;
7956
7957 case 3:
7958 for (i = 0; i < pixBytes; ++i) {
7959 buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
7960 }
7961
7962 for (; i < rowBytes; ++i) {
7963 buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xff;
7964 j++;
7965 }
7966
7967 break;
7968
7969 case 4:
7970 for (i = 0; i < pixBytes; ++i) {
7971 up = prevRow[i];
7972 c = rawBytes[i];
7973 buffer[j++] = up + c;
7974 }
7975
7976 for (; i < rowBytes; ++i) {
7977 up = prevRow[i];
7978 var upLeft = prevRow[i - pixBytes];
7979 var left = buffer[j - pixBytes];
7980 var p = left + up - upLeft;
7981 var pa = p - left;
7982
7983 if (pa < 0) {
7984 pa = -pa;
7985 }
7986
7987 var pb = p - up;
7988
7989 if (pb < 0) {
7990 pb = -pb;
7991 }
7992
7993 var pc = p - upLeft;
7994
7995 if (pc < 0) {
7996 pc = -pc;
7997 }
7998
7999 c = rawBytes[i];
8000
8001 if (pa <= pb && pa <= pc) {
8002 buffer[j++] = left + c;
8003 } else if (pb <= pc) {
8004 buffer[j++] = up + c;
8005 } else {
8006 buffer[j++] = upLeft + c;
8007 }
8008 }
8009
8010 break;
8011
8012 default:
8013 throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
8014 }
8015
8016 this.bufferLength += rowBytes;
8017 };
8018
8019 return PredictorStream;
8020}();
8021
8022exports.PredictorStream = PredictorStream;
8023
8024var DecryptStream = function DecryptStreamClosure() {
8025 function DecryptStream(str, maybeLength, decrypt) {
8026 this.str = str;
8027 this.dict = str.dict;
8028 this.decrypt = decrypt;
8029 this.nextChunk = null;
8030 this.initialized = false;
8031 DecodeStream.call(this, maybeLength);
8032 }
8033
8034 var chunkSize = 512;
8035 DecryptStream.prototype = Object.create(DecodeStream.prototype);
8036
8037 DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
8038 var chunk;
8039
8040 if (this.initialized) {
8041 chunk = this.nextChunk;
8042 } else {
8043 chunk = this.str.getBytes(chunkSize);
8044 this.initialized = true;
8045 }
8046
8047 if (!chunk || chunk.length === 0) {
8048 this.eof = true;
8049 return;
8050 }
8051
8052 this.nextChunk = this.str.getBytes(chunkSize);
8053 var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
8054 var decrypt = this.decrypt;
8055 chunk = decrypt(chunk, !hasMoreData);
8056 var bufferLength = this.bufferLength;
8057 var i,
8058 n = chunk.length;
8059 var buffer = this.ensureBuffer(bufferLength + n);
8060
8061 for (i = 0; i < n; i++) {
8062 buffer[bufferLength++] = chunk[i];
8063 }
8064
8065 this.bufferLength = bufferLength;
8066 };
8067
8068 return DecryptStream;
8069}();
8070
8071exports.DecryptStream = DecryptStream;
8072
8073var Ascii85Stream = function Ascii85StreamClosure() {
8074 function Ascii85Stream(str, maybeLength) {
8075 this.str = str;
8076 this.dict = str.dict;
8077 this.input = new Uint8Array(5);
8078
8079 if (maybeLength) {
8080 maybeLength = 0.8 * maybeLength;
8081 }
8082
8083 DecodeStream.call(this, maybeLength);
8084 }
8085
8086 Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
8087
8088 Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
8089 var TILDA_CHAR = 0x7e;
8090 var Z_LOWER_CHAR = 0x7a;
8091 var EOF = -1;
8092 var str = this.str;
8093 var c = str.getByte();
8094
8095 while ((0, _core_utils.isWhiteSpace)(c)) {
8096 c = str.getByte();
8097 }
8098
8099 if (c === EOF || c === TILDA_CHAR) {
8100 this.eof = true;
8101 return;
8102 }
8103
8104 var bufferLength = this.bufferLength,
8105 buffer;
8106 var i;
8107
8108 if (c === Z_LOWER_CHAR) {
8109 buffer = this.ensureBuffer(bufferLength + 4);
8110
8111 for (i = 0; i < 4; ++i) {
8112 buffer[bufferLength + i] = 0;
8113 }
8114
8115 this.bufferLength += 4;
8116 } else {
8117 var input = this.input;
8118 input[0] = c;
8119
8120 for (i = 1; i < 5; ++i) {
8121 c = str.getByte();
8122
8123 while ((0, _core_utils.isWhiteSpace)(c)) {
8124 c = str.getByte();
8125 }
8126
8127 input[i] = c;
8128
8129 if (c === EOF || c === TILDA_CHAR) {
8130 break;
8131 }
8132 }
8133
8134 buffer = this.ensureBuffer(bufferLength + i - 1);
8135 this.bufferLength += i - 1;
8136
8137 if (i < 5) {
8138 for (; i < 5; ++i) {
8139 input[i] = 0x21 + 84;
8140 }
8141
8142 this.eof = true;
8143 }
8144
8145 var t = 0;
8146
8147 for (i = 0; i < 5; ++i) {
8148 t = t * 85 + (input[i] - 0x21);
8149 }
8150
8151 for (i = 3; i >= 0; --i) {
8152 buffer[bufferLength + i] = t & 0xff;
8153 t >>= 8;
8154 }
8155 }
8156 };
8157
8158 return Ascii85Stream;
8159}();
8160
8161exports.Ascii85Stream = Ascii85Stream;
8162
8163var AsciiHexStream = function AsciiHexStreamClosure() {
8164 function AsciiHexStream(str, maybeLength) {
8165 this.str = str;
8166 this.dict = str.dict;
8167 this.firstDigit = -1;
8168
8169 if (maybeLength) {
8170 maybeLength = 0.5 * maybeLength;
8171 }
8172
8173 DecodeStream.call(this, maybeLength);
8174 }
8175
8176 AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
8177
8178 AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
8179 var UPSTREAM_BLOCK_SIZE = 8000;
8180 var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
8181
8182 if (!bytes.length) {
8183 this.eof = true;
8184 return;
8185 }
8186
8187 var maxDecodeLength = bytes.length + 1 >> 1;
8188 var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
8189 var bufferLength = this.bufferLength;
8190 var firstDigit = this.firstDigit;
8191
8192 for (var i = 0, ii = bytes.length; i < ii; i++) {
8193 var ch = bytes[i],
8194 digit;
8195
8196 if (ch >= 0x30 && ch <= 0x39) {
8197 digit = ch & 0x0f;
8198 } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
8199 digit = (ch & 0x0f) + 9;
8200 } else if (ch === 0x3e) {
8201 this.eof = true;
8202 break;
8203 } else {
8204 continue;
8205 }
8206
8207 if (firstDigit < 0) {
8208 firstDigit = digit;
8209 } else {
8210 buffer[bufferLength++] = firstDigit << 4 | digit;
8211 firstDigit = -1;
8212 }
8213 }
8214
8215 if (firstDigit >= 0 && this.eof) {
8216 buffer[bufferLength++] = firstDigit << 4;
8217 firstDigit = -1;
8218 }
8219
8220 this.firstDigit = firstDigit;
8221 this.bufferLength = bufferLength;
8222 };
8223
8224 return AsciiHexStream;
8225}();
8226
8227exports.AsciiHexStream = AsciiHexStream;
8228
8229var RunLengthStream = function RunLengthStreamClosure() {
8230 function RunLengthStream(str, maybeLength) {
8231 this.str = str;
8232 this.dict = str.dict;
8233 DecodeStream.call(this, maybeLength);
8234 }
8235
8236 RunLengthStream.prototype = Object.create(DecodeStream.prototype);
8237
8238 RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
8239 var repeatHeader = this.str.getBytes(2);
8240
8241 if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
8242 this.eof = true;
8243 return;
8244 }
8245
8246 var buffer;
8247 var bufferLength = this.bufferLength;
8248 var n = repeatHeader[0];
8249
8250 if (n < 128) {
8251 buffer = this.ensureBuffer(bufferLength + n + 1);
8252 buffer[bufferLength++] = repeatHeader[1];
8253
8254 if (n > 0) {
8255 var source = this.str.getBytes(n);
8256 buffer.set(source, bufferLength);
8257 bufferLength += n;
8258 }
8259 } else {
8260 n = 257 - n;
8261 var b = repeatHeader[1];
8262 buffer = this.ensureBuffer(bufferLength + n + 1);
8263
8264 for (var i = 0; i < n; i++) {
8265 buffer[bufferLength++] = b;
8266 }
8267 }
8268
8269 this.bufferLength = bufferLength;
8270 };
8271
8272 return RunLengthStream;
8273}();
8274
8275exports.RunLengthStream = RunLengthStream;
8276
8277var LZWStream = function LZWStreamClosure() {
8278 function LZWStream(str, maybeLength, earlyChange) {
8279 this.str = str;
8280 this.dict = str.dict;
8281 this.cachedData = 0;
8282 this.bitsCached = 0;
8283 var maxLzwDictionarySize = 4096;
8284 var lzwState = {
8285 earlyChange,
8286 codeLength: 9,
8287 nextCode: 258,
8288 dictionaryValues: new Uint8Array(maxLzwDictionarySize),
8289 dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
8290 dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
8291 currentSequence: new Uint8Array(maxLzwDictionarySize),
8292 currentSequenceLength: 0
8293 };
8294
8295 for (var i = 0; i < 256; ++i) {
8296 lzwState.dictionaryValues[i] = i;
8297 lzwState.dictionaryLengths[i] = 1;
8298 }
8299
8300 this.lzwState = lzwState;
8301 DecodeStream.call(this, maybeLength);
8302 }
8303
8304 LZWStream.prototype = Object.create(DecodeStream.prototype);
8305
8306 LZWStream.prototype.readBits = function LZWStream_readBits(n) {
8307 var bitsCached = this.bitsCached;
8308 var cachedData = this.cachedData;
8309
8310 while (bitsCached < n) {
8311 var c = this.str.getByte();
8312
8313 if (c === -1) {
8314 this.eof = true;
8315 return null;
8316 }
8317
8318 cachedData = cachedData << 8 | c;
8319 bitsCached += 8;
8320 }
8321
8322 this.bitsCached = bitsCached -= n;
8323 this.cachedData = cachedData;
8324 this.lastCode = null;
8325 return cachedData >>> bitsCached & (1 << n) - 1;
8326 };
8327
8328 LZWStream.prototype.readBlock = function LZWStream_readBlock() {
8329 var blockSize = 512;
8330 var estimatedDecodedSize = blockSize * 2,
8331 decodedSizeDelta = blockSize;
8332 var i, j, q;
8333 var lzwState = this.lzwState;
8334
8335 if (!lzwState) {
8336 return;
8337 }
8338
8339 var earlyChange = lzwState.earlyChange;
8340 var nextCode = lzwState.nextCode;
8341 var dictionaryValues = lzwState.dictionaryValues;
8342 var dictionaryLengths = lzwState.dictionaryLengths;
8343 var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
8344 var codeLength = lzwState.codeLength;
8345 var prevCode = lzwState.prevCode;
8346 var currentSequence = lzwState.currentSequence;
8347 var currentSequenceLength = lzwState.currentSequenceLength;
8348 var decodedLength = 0;
8349 var currentBufferLength = this.bufferLength;
8350 var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
8351
8352 for (i = 0; i < blockSize; i++) {
8353 var code = this.readBits(codeLength);
8354 var hasPrev = currentSequenceLength > 0;
8355
8356 if (code < 256) {
8357 currentSequence[0] = code;
8358 currentSequenceLength = 1;
8359 } else if (code >= 258) {
8360 if (code < nextCode) {
8361 currentSequenceLength = dictionaryLengths[code];
8362
8363 for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
8364 currentSequence[j] = dictionaryValues[q];
8365 q = dictionaryPrevCodes[q];
8366 }
8367 } else {
8368 currentSequence[currentSequenceLength++] = currentSequence[0];
8369 }
8370 } else if (code === 256) {
8371 codeLength = 9;
8372 nextCode = 258;
8373 currentSequenceLength = 0;
8374 continue;
8375 } else {
8376 this.eof = true;
8377 delete this.lzwState;
8378 break;
8379 }
8380
8381 if (hasPrev) {
8382 dictionaryPrevCodes[nextCode] = prevCode;
8383 dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
8384 dictionaryValues[nextCode] = currentSequence[0];
8385 nextCode++;
8386 codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
8387 }
8388
8389 prevCode = code;
8390 decodedLength += currentSequenceLength;
8391
8392 if (estimatedDecodedSize < decodedLength) {
8393 do {
8394 estimatedDecodedSize += decodedSizeDelta;
8395 } while (estimatedDecodedSize < decodedLength);
8396
8397 buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
8398 }
8399
8400 for (j = 0; j < currentSequenceLength; j++) {
8401 buffer[currentBufferLength++] = currentSequence[j];
8402 }
8403 }
8404
8405 lzwState.nextCode = nextCode;
8406 lzwState.codeLength = codeLength;
8407 lzwState.prevCode = prevCode;
8408 lzwState.currentSequenceLength = currentSequenceLength;
8409 this.bufferLength = currentBufferLength;
8410 };
8411
8412 return LZWStream;
8413}();
8414
8415exports.LZWStream = LZWStream;
8416
8417var NullStream = function NullStreamClosure() {
8418 function NullStream() {
8419 Stream.call(this, new Uint8Array(0));
8420 }
8421
8422 NullStream.prototype = Stream.prototype;
8423 return NullStream;
8424}();
8425
8426exports.NullStream = NullStream;
8427
8428/***/ }),
8429/* 13 */
8430/***/ (function(module, exports, __w_pdfjs_require__) {
8431
8432"use strict";
8433
8434
8435Object.defineProperty(exports, "__esModule", {
8436 value: true
8437});
8438exports.CCITTFaxStream = void 0;
8439
8440var _primitives = __w_pdfjs_require__(5);
8441
8442var _ccitt = __w_pdfjs_require__(14);
8443
8444var _stream = __w_pdfjs_require__(12);
8445
8446var CCITTFaxStream = function CCITTFaxStreamClosure() {
8447 function CCITTFaxStream(str, maybeLength, params) {
8448 this.str = str;
8449 this.dict = str.dict;
8450
8451 if (!(0, _primitives.isDict)(params)) {
8452 params = _primitives.Dict.empty;
8453 }
8454
8455 const source = {
8456 next() {
8457 return str.getByte();
8458 }
8459
8460 };
8461 this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
8462 K: params.get("K"),
8463 EndOfLine: params.get("EndOfLine"),
8464 EncodedByteAlign: params.get("EncodedByteAlign"),
8465 Columns: params.get("Columns"),
8466 Rows: params.get("Rows"),
8467 EndOfBlock: params.get("EndOfBlock"),
8468 BlackIs1: params.get("BlackIs1")
8469 });
8470
8471 _stream.DecodeStream.call(this, maybeLength);
8472 }
8473
8474 CCITTFaxStream.prototype = Object.create(_stream.DecodeStream.prototype);
8475
8476 CCITTFaxStream.prototype.readBlock = function () {
8477 while (!this.eof) {
8478 const c = this.ccittFaxDecoder.readNextChar();
8479
8480 if (c === -1) {
8481 this.eof = true;
8482 return;
8483 }
8484
8485 this.ensureBuffer(this.bufferLength + 1);
8486 this.buffer[this.bufferLength++] = c;
8487 }
8488 };
8489
8490 return CCITTFaxStream;
8491}();
8492
8493exports.CCITTFaxStream = CCITTFaxStream;
8494
8495/***/ }),
8496/* 14 */
8497/***/ (function(module, exports, __w_pdfjs_require__) {
8498
8499"use strict";
8500
8501
8502Object.defineProperty(exports, "__esModule", {
8503 value: true
8504});
8505exports.CCITTFaxDecoder = void 0;
8506
8507var _util = __w_pdfjs_require__(2);
8508
8509const CCITTFaxDecoder = function CCITTFaxDecoder() {
8510 const ccittEOL = -2;
8511 const ccittEOF = -1;
8512 const twoDimPass = 0;
8513 const twoDimHoriz = 1;
8514 const twoDimVert0 = 2;
8515 const twoDimVertR1 = 3;
8516 const twoDimVertL1 = 4;
8517 const twoDimVertR2 = 5;
8518 const twoDimVertL2 = 6;
8519 const twoDimVertR3 = 7;
8520 const twoDimVertL3 = 8;
8521 const twoDimTable = [[-1, -1], [-1, -1], [7, twoDimVertL3], [7, twoDimVertR3], [6, twoDimVertL2], [6, twoDimVertL2], [6, twoDimVertR2], [6, twoDimVertR2], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0]];
8522 const whiteTable1 = [[-1, -1], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [12, 1984], [12, 2048], [12, 2112], [12, 2176], [12, 2240], [12, 2304], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [12, 2368], [12, 2432], [12, 2496], [12, 2560]];
8523 const whiteTable2 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [8, 29], [8, 29], [8, 30], [8, 30], [8, 45], [8, 45], [8, 46], [8, 46], [7, 22], [7, 22], [7, 22], [7, 22], [7, 23], [7, 23], [7, 23], [7, 23], [8, 47], [8, 47], [8, 48], [8, 48], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [7, 20], [7, 20], [7, 20], [7, 20], [8, 33], [8, 33], [8, 34], [8, 34], [8, 35], [8, 35], [8, 36], [8, 36], [8, 37], [8, 37], [8, 38], [8, 38], [7, 19], [7, 19], [7, 19], [7, 19], [8, 31], [8, 31], [8, 32], [8, 32], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [8, 53], [8, 53], [8, 54], [8, 54], [7, 26], [7, 26], [7, 26], [7, 26], [8, 39], [8, 39], [8, 40], [8, 40], [8, 41], [8, 41], [8, 42], [8, 42], [8, 43], [8, 43], [8, 44], [8, 44], [7, 21], [7, 21], [7, 21], [7, 21], [7, 28], [7, 28], [7, 28], [7, 28], [8, 61], [8, 61], [8, 62], [8, 62], [8, 63], [8, 63], [8, 0], [8, 0], [8, 320], [8, 320], [8, 384], [8, 384], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [7, 27], [7, 27], [7, 27], [7, 27], [8, 59], [8, 59], [8, 60], [8, 60], [9, 1472], [9, 1536], [9, 1600], [9, 1728], [7, 18], [7, 18], [7, 18], [7, 18], [7, 24], [7, 24], [7, 24], [7, 24], [8, 49], [8, 49], [8, 50], [8, 50], [8, 51], [8, 51], [8, 52], [8, 52], [7, 25], [7, 25], [7, 25], [7, 25], [8, 55], [8, 55], [8, 56], [8, 56], [8, 57], [8, 57], [8, 58], [8, 58], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [8, 448], [8, 448], [8, 512], [8, 512], [9, 704], [9, 768], [8, 640], [8, 640], [8, 576], [8, 576], [9, 832], [9, 896], [9, 960], [9, 1024], [9, 1088], [9, 1152], [9, 1216], [9, 1280], [9, 1344], [9, 1408], [7, 256], [7, 256], [7, 256], [7, 256], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7]];
8524 const blackTable1 = [[-1, -1], [-1, -1], [12, ccittEOL], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [11, 1792], [11, 1792], [12, 1984], [12, 1984], [12, 2048], [12, 2048], [12, 2112], [12, 2112], [12, 2176], [12, 2176], [12, 2240], [12, 2240], [12, 2304], [12, 2304], [11, 1856], [11, 1856], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [11, 1920], [11, 1920], [12, 2368], [12, 2368], [12, 2432], [12, 2432], [12, 2496], [12, 2496], [12, 2560], [12, 2560], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [12, 52], [12, 52], [13, 640], [13, 704], [13, 768], [13, 832], [12, 55], [12, 55], [12, 56], [12, 56], [13, 1280], [13, 1344], [13, 1408], [13, 1472], [12, 59], [12, 59], [12, 60], [12, 60], [13, 1536], [13, 1600], [11, 24], [11, 24], [11, 24], [11, 24], [11, 25], [11, 25], [11, 25], [11, 25], [13, 1664], [13, 1728], [12, 320], [12, 320], [12, 384], [12, 384], [12, 448], [12, 448], [13, 512], [13, 576], [12, 53], [12, 53], [12, 54], [12, 54], [13, 896], [13, 960], [13, 1024], [13, 1088], [13, 1152], [13, 1216], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64]];
8525 const blackTable2 = [[8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [11, 23], [11, 23], [12, 50], [12, 51], [12, 44], [12, 45], [12, 46], [12, 47], [12, 57], [12, 58], [12, 61], [12, 256], [10, 16], [10, 16], [10, 16], [10, 16], [10, 17], [10, 17], [10, 17], [10, 17], [12, 48], [12, 49], [12, 62], [12, 63], [12, 30], [12, 31], [12, 32], [12, 33], [12, 40], [12, 41], [11, 22], [11, 22], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [12, 128], [12, 192], [12, 26], [12, 27], [12, 28], [12, 29], [11, 19], [11, 19], [11, 20], [11, 20], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [11, 21], [11, 21], [12, 42], [12, 43], [10, 0], [10, 0], [10, 0], [10, 0], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12]];
8526 const blackTable3 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [6, 9], [6, 8], [5, 7], [5, 7], [4, 6], [4, 6], [4, 6], [4, 6], [4, 5], [4, 5], [4, 5], [4, 5], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]];
8527
8528 function CCITTFaxDecoder(source, options = {}) {
8529 if (!source || typeof source.next !== "function") {
8530 throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
8531 }
8532
8533 this.source = source;
8534 this.eof = false;
8535 this.encoding = options.K || 0;
8536 this.eoline = options.EndOfLine || false;
8537 this.byteAlign = options.EncodedByteAlign || false;
8538 this.columns = options.Columns || 1728;
8539 this.rows = options.Rows || 0;
8540 let eoblock = options.EndOfBlock;
8541
8542 if (eoblock === null || eoblock === undefined) {
8543 eoblock = true;
8544 }
8545
8546 this.eoblock = eoblock;
8547 this.black = options.BlackIs1 || false;
8548 this.codingLine = new Uint32Array(this.columns + 1);
8549 this.refLine = new Uint32Array(this.columns + 2);
8550 this.codingLine[0] = this.columns;
8551 this.codingPos = 0;
8552 this.row = 0;
8553 this.nextLine2D = this.encoding < 0;
8554 this.inputBits = 0;
8555 this.inputBuf = 0;
8556 this.outputBits = 0;
8557 this.rowsDone = false;
8558 let code1;
8559
8560 while ((code1 = this._lookBits(12)) === 0) {
8561 this._eatBits(1);
8562 }
8563
8564 if (code1 === 1) {
8565 this._eatBits(12);
8566 }
8567
8568 if (this.encoding > 0) {
8569 this.nextLine2D = !this._lookBits(1);
8570
8571 this._eatBits(1);
8572 }
8573 }
8574
8575 CCITTFaxDecoder.prototype = {
8576 readNextChar() {
8577 if (this.eof) {
8578 return -1;
8579 }
8580
8581 const refLine = this.refLine;
8582 const codingLine = this.codingLine;
8583 const columns = this.columns;
8584 let refPos, blackPixels, bits, i;
8585
8586 if (this.outputBits === 0) {
8587 if (this.rowsDone) {
8588 this.eof = true;
8589 }
8590
8591 if (this.eof) {
8592 return -1;
8593 }
8594
8595 this.err = false;
8596 let code1, code2, code3;
8597
8598 if (this.nextLine2D) {
8599 for (i = 0; codingLine[i] < columns; ++i) {
8600 refLine[i] = codingLine[i];
8601 }
8602
8603 refLine[i++] = columns;
8604 refLine[i] = columns;
8605 codingLine[0] = 0;
8606 this.codingPos = 0;
8607 refPos = 0;
8608 blackPixels = 0;
8609
8610 while (codingLine[this.codingPos] < columns) {
8611 code1 = this._getTwoDimCode();
8612
8613 switch (code1) {
8614 case twoDimPass:
8615 this._addPixels(refLine[refPos + 1], blackPixels);
8616
8617 if (refLine[refPos + 1] < columns) {
8618 refPos += 2;
8619 }
8620
8621 break;
8622
8623 case twoDimHoriz:
8624 code1 = code2 = 0;
8625
8626 if (blackPixels) {
8627 do {
8628 code1 += code3 = this._getBlackCode();
8629 } while (code3 >= 64);
8630
8631 do {
8632 code2 += code3 = this._getWhiteCode();
8633 } while (code3 >= 64);
8634 } else {
8635 do {
8636 code1 += code3 = this._getWhiteCode();
8637 } while (code3 >= 64);
8638
8639 do {
8640 code2 += code3 = this._getBlackCode();
8641 } while (code3 >= 64);
8642 }
8643
8644 this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
8645
8646 if (codingLine[this.codingPos] < columns) {
8647 this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
8648 }
8649
8650 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8651 refPos += 2;
8652 }
8653
8654 break;
8655
8656 case twoDimVertR3:
8657 this._addPixels(refLine[refPos] + 3, blackPixels);
8658
8659 blackPixels ^= 1;
8660
8661 if (codingLine[this.codingPos] < columns) {
8662 ++refPos;
8663
8664 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8665 refPos += 2;
8666 }
8667 }
8668
8669 break;
8670
8671 case twoDimVertR2:
8672 this._addPixels(refLine[refPos] + 2, blackPixels);
8673
8674 blackPixels ^= 1;
8675
8676 if (codingLine[this.codingPos] < columns) {
8677 ++refPos;
8678
8679 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8680 refPos += 2;
8681 }
8682 }
8683
8684 break;
8685
8686 case twoDimVertR1:
8687 this._addPixels(refLine[refPos] + 1, blackPixels);
8688
8689 blackPixels ^= 1;
8690
8691 if (codingLine[this.codingPos] < columns) {
8692 ++refPos;
8693
8694 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8695 refPos += 2;
8696 }
8697 }
8698
8699 break;
8700
8701 case twoDimVert0:
8702 this._addPixels(refLine[refPos], blackPixels);
8703
8704 blackPixels ^= 1;
8705
8706 if (codingLine[this.codingPos] < columns) {
8707 ++refPos;
8708
8709 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8710 refPos += 2;
8711 }
8712 }
8713
8714 break;
8715
8716 case twoDimVertL3:
8717 this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
8718
8719 blackPixels ^= 1;
8720
8721 if (codingLine[this.codingPos] < columns) {
8722 if (refPos > 0) {
8723 --refPos;
8724 } else {
8725 ++refPos;
8726 }
8727
8728 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8729 refPos += 2;
8730 }
8731 }
8732
8733 break;
8734
8735 case twoDimVertL2:
8736 this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
8737
8738 blackPixels ^= 1;
8739
8740 if (codingLine[this.codingPos] < columns) {
8741 if (refPos > 0) {
8742 --refPos;
8743 } else {
8744 ++refPos;
8745 }
8746
8747 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8748 refPos += 2;
8749 }
8750 }
8751
8752 break;
8753
8754 case twoDimVertL1:
8755 this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
8756
8757 blackPixels ^= 1;
8758
8759 if (codingLine[this.codingPos] < columns) {
8760 if (refPos > 0) {
8761 --refPos;
8762 } else {
8763 ++refPos;
8764 }
8765
8766 while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
8767 refPos += 2;
8768 }
8769 }
8770
8771 break;
8772
8773 case ccittEOF:
8774 this._addPixels(columns, 0);
8775
8776 this.eof = true;
8777 break;
8778
8779 default:
8780 (0, _util.info)("bad 2d code");
8781
8782 this._addPixels(columns, 0);
8783
8784 this.err = true;
8785 }
8786 }
8787 } else {
8788 codingLine[0] = 0;
8789 this.codingPos = 0;
8790 blackPixels = 0;
8791
8792 while (codingLine[this.codingPos] < columns) {
8793 code1 = 0;
8794
8795 if (blackPixels) {
8796 do {
8797 code1 += code3 = this._getBlackCode();
8798 } while (code3 >= 64);
8799 } else {
8800 do {
8801 code1 += code3 = this._getWhiteCode();
8802 } while (code3 >= 64);
8803 }
8804
8805 this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
8806
8807 blackPixels ^= 1;
8808 }
8809 }
8810
8811 let gotEOL = false;
8812
8813 if (this.byteAlign) {
8814 this.inputBits &= ~7;
8815 }
8816
8817 if (!this.eoblock && this.row === this.rows - 1) {
8818 this.rowsDone = true;
8819 } else {
8820 code1 = this._lookBits(12);
8821
8822 if (this.eoline) {
8823 while (code1 !== ccittEOF && code1 !== 1) {
8824 this._eatBits(1);
8825
8826 code1 = this._lookBits(12);
8827 }
8828 } else {
8829 while (code1 === 0) {
8830 this._eatBits(1);
8831
8832 code1 = this._lookBits(12);
8833 }
8834 }
8835
8836 if (code1 === 1) {
8837 this._eatBits(12);
8838
8839 gotEOL = true;
8840 } else if (code1 === ccittEOF) {
8841 this.eof = true;
8842 }
8843 }
8844
8845 if (!this.eof && this.encoding > 0 && !this.rowsDone) {
8846 this.nextLine2D = !this._lookBits(1);
8847
8848 this._eatBits(1);
8849 }
8850
8851 if (this.eoblock && gotEOL && this.byteAlign) {
8852 code1 = this._lookBits(12);
8853
8854 if (code1 === 1) {
8855 this._eatBits(12);
8856
8857 if (this.encoding > 0) {
8858 this._lookBits(1);
8859
8860 this._eatBits(1);
8861 }
8862
8863 if (this.encoding >= 0) {
8864 for (i = 0; i < 4; ++i) {
8865 code1 = this._lookBits(12);
8866
8867 if (code1 !== 1) {
8868 (0, _util.info)("bad rtc code: " + code1);
8869 }
8870
8871 this._eatBits(12);
8872
8873 if (this.encoding > 0) {
8874 this._lookBits(1);
8875
8876 this._eatBits(1);
8877 }
8878 }
8879 }
8880
8881 this.eof = true;
8882 }
8883 } else if (this.err && this.eoline) {
8884 while (true) {
8885 code1 = this._lookBits(13);
8886
8887 if (code1 === ccittEOF) {
8888 this.eof = true;
8889 return -1;
8890 }
8891
8892 if (code1 >> 1 === 1) {
8893 break;
8894 }
8895
8896 this._eatBits(1);
8897 }
8898
8899 this._eatBits(12);
8900
8901 if (this.encoding > 0) {
8902 this._eatBits(1);
8903
8904 this.nextLine2D = !(code1 & 1);
8905 }
8906 }
8907
8908 if (codingLine[0] > 0) {
8909 this.outputBits = codingLine[this.codingPos = 0];
8910 } else {
8911 this.outputBits = codingLine[this.codingPos = 1];
8912 }
8913
8914 this.row++;
8915 }
8916
8917 let c;
8918
8919 if (this.outputBits >= 8) {
8920 c = this.codingPos & 1 ? 0 : 0xff;
8921 this.outputBits -= 8;
8922
8923 if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
8924 this.codingPos++;
8925 this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
8926 }
8927 } else {
8928 bits = 8;
8929 c = 0;
8930
8931 do {
8932 if (this.outputBits > bits) {
8933 c <<= bits;
8934
8935 if (!(this.codingPos & 1)) {
8936 c |= 0xff >> 8 - bits;
8937 }
8938
8939 this.outputBits -= bits;
8940 bits = 0;
8941 } else {
8942 c <<= this.outputBits;
8943
8944 if (!(this.codingPos & 1)) {
8945 c |= 0xff >> 8 - this.outputBits;
8946 }
8947
8948 bits -= this.outputBits;
8949 this.outputBits = 0;
8950
8951 if (codingLine[this.codingPos] < columns) {
8952 this.codingPos++;
8953 this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
8954 } else if (bits > 0) {
8955 c <<= bits;
8956 bits = 0;
8957 }
8958 }
8959 } while (bits);
8960 }
8961
8962 if (this.black) {
8963 c ^= 0xff;
8964 }
8965
8966 return c;
8967 },
8968
8969 _addPixels(a1, blackPixels) {
8970 const codingLine = this.codingLine;
8971 let codingPos = this.codingPos;
8972
8973 if (a1 > codingLine[codingPos]) {
8974 if (a1 > this.columns) {
8975 (0, _util.info)("row is wrong length");
8976 this.err = true;
8977 a1 = this.columns;
8978 }
8979
8980 if (codingPos & 1 ^ blackPixels) {
8981 ++codingPos;
8982 }
8983
8984 codingLine[codingPos] = a1;
8985 }
8986
8987 this.codingPos = codingPos;
8988 },
8989
8990 _addPixelsNeg(a1, blackPixels) {
8991 const codingLine = this.codingLine;
8992 let codingPos = this.codingPos;
8993
8994 if (a1 > codingLine[codingPos]) {
8995 if (a1 > this.columns) {
8996 (0, _util.info)("row is wrong length");
8997 this.err = true;
8998 a1 = this.columns;
8999 }
9000
9001 if (codingPos & 1 ^ blackPixels) {
9002 ++codingPos;
9003 }
9004
9005 codingLine[codingPos] = a1;
9006 } else if (a1 < codingLine[codingPos]) {
9007 if (a1 < 0) {
9008 (0, _util.info)("invalid code");
9009 this.err = true;
9010 a1 = 0;
9011 }
9012
9013 while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
9014 --codingPos;
9015 }
9016
9017 codingLine[codingPos] = a1;
9018 }
9019
9020 this.codingPos = codingPos;
9021 },
9022
9023 _findTableCode(start, end, table, limit) {
9024 const limitValue = limit || 0;
9025
9026 for (let i = start; i <= end; ++i) {
9027 let code = this._lookBits(i);
9028
9029 if (code === ccittEOF) {
9030 return [true, 1, false];
9031 }
9032
9033 if (i < end) {
9034 code <<= end - i;
9035 }
9036
9037 if (!limitValue || code >= limitValue) {
9038 const p = table[code - limitValue];
9039
9040 if (p[0] === i) {
9041 this._eatBits(i);
9042
9043 return [true, p[1], true];
9044 }
9045 }
9046 }
9047
9048 return [false, 0, false];
9049 },
9050
9051 _getTwoDimCode() {
9052 let code = 0;
9053 let p;
9054
9055 if (this.eoblock) {
9056 code = this._lookBits(7);
9057 p = twoDimTable[code];
9058
9059 if (p && p[0] > 0) {
9060 this._eatBits(p[0]);
9061
9062 return p[1];
9063 }
9064 } else {
9065 const result = this._findTableCode(1, 7, twoDimTable);
9066
9067 if (result[0] && result[2]) {
9068 return result[1];
9069 }
9070 }
9071
9072 (0, _util.info)("Bad two dim code");
9073 return ccittEOF;
9074 },
9075
9076 _getWhiteCode() {
9077 let code = 0;
9078 let p;
9079
9080 if (this.eoblock) {
9081 code = this._lookBits(12);
9082
9083 if (code === ccittEOF) {
9084 return 1;
9085 }
9086
9087 if (code >> 5 === 0) {
9088 p = whiteTable1[code];
9089 } else {
9090 p = whiteTable2[code >> 3];
9091 }
9092
9093 if (p[0] > 0) {
9094 this._eatBits(p[0]);
9095
9096 return p[1];
9097 }
9098 } else {
9099 let result = this._findTableCode(1, 9, whiteTable2);
9100
9101 if (result[0]) {
9102 return result[1];
9103 }
9104
9105 result = this._findTableCode(11, 12, whiteTable1);
9106
9107 if (result[0]) {
9108 return result[1];
9109 }
9110 }
9111
9112 (0, _util.info)("bad white code");
9113
9114 this._eatBits(1);
9115
9116 return 1;
9117 },
9118
9119 _getBlackCode() {
9120 let code, p;
9121
9122 if (this.eoblock) {
9123 code = this._lookBits(13);
9124
9125 if (code === ccittEOF) {
9126 return 1;
9127 }
9128
9129 if (code >> 7 === 0) {
9130 p = blackTable1[code];
9131 } else if (code >> 9 === 0 && code >> 7 !== 0) {
9132 p = blackTable2[(code >> 1) - 64];
9133 } else {
9134 p = blackTable3[code >> 7];
9135 }
9136
9137 if (p[0] > 0) {
9138 this._eatBits(p[0]);
9139
9140 return p[1];
9141 }
9142 } else {
9143 let result = this._findTableCode(2, 6, blackTable3);
9144
9145 if (result[0]) {
9146 return result[1];
9147 }
9148
9149 result = this._findTableCode(7, 12, blackTable2, 64);
9150
9151 if (result[0]) {
9152 return result[1];
9153 }
9154
9155 result = this._findTableCode(10, 13, blackTable1);
9156
9157 if (result[0]) {
9158 return result[1];
9159 }
9160 }
9161
9162 (0, _util.info)("bad black code");
9163
9164 this._eatBits(1);
9165
9166 return 1;
9167 },
9168
9169 _lookBits(n) {
9170 let c;
9171
9172 while (this.inputBits < n) {
9173 if ((c = this.source.next()) === -1) {
9174 if (this.inputBits === 0) {
9175 return ccittEOF;
9176 }
9177
9178 return this.inputBuf << n - this.inputBits & 0xffff >> 16 - n;
9179 }
9180
9181 this.inputBuf = this.inputBuf << 8 | c;
9182 this.inputBits += 8;
9183 }
9184
9185 return this.inputBuf >> this.inputBits - n & 0xffff >> 16 - n;
9186 },
9187
9188 _eatBits(n) {
9189 if ((this.inputBits -= n) < 0) {
9190 this.inputBits = 0;
9191 }
9192 }
9193
9194 };
9195 return CCITTFaxDecoder;
9196}();
9197
9198exports.CCITTFaxDecoder = CCITTFaxDecoder;
9199
9200/***/ }),
9201/* 15 */
9202/***/ (function(module, exports, __w_pdfjs_require__) {
9203
9204"use strict";
9205
9206
9207Object.defineProperty(exports, "__esModule", {
9208 value: true
9209});
9210exports.Jbig2Stream = void 0;
9211
9212var _primitives = __w_pdfjs_require__(5);
9213
9214var _stream = __w_pdfjs_require__(12);
9215
9216var _jbig = __w_pdfjs_require__(16);
9217
9218var _util = __w_pdfjs_require__(2);
9219
9220const Jbig2Stream = function Jbig2StreamClosure() {
9221 function Jbig2Stream(stream, maybeLength, dict, params) {
9222 this.stream = stream;
9223 this.maybeLength = maybeLength;
9224 this.dict = dict;
9225 this.params = params;
9226
9227 _stream.DecodeStream.call(this, maybeLength);
9228 }
9229
9230 Jbig2Stream.prototype = Object.create(_stream.DecodeStream.prototype);
9231 Object.defineProperty(Jbig2Stream.prototype, "bytes", {
9232 get() {
9233 return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
9234 },
9235
9236 configurable: true
9237 });
9238
9239 Jbig2Stream.prototype.ensureBuffer = function (requested) {};
9240
9241 Jbig2Stream.prototype.readBlock = function () {
9242 if (this.eof) {
9243 return;
9244 }
9245
9246 const jbig2Image = new _jbig.Jbig2Image();
9247 const chunks = [];
9248
9249 if ((0, _primitives.isDict)(this.params)) {
9250 const globalsStream = this.params.get("JBIG2Globals");
9251
9252 if ((0, _primitives.isStream)(globalsStream)) {
9253 const globals = globalsStream.getBytes();
9254 chunks.push({
9255 data: globals,
9256 start: 0,
9257 end: globals.length
9258 });
9259 }
9260 }
9261
9262 chunks.push({
9263 data: this.bytes,
9264 start: 0,
9265 end: this.bytes.length
9266 });
9267 const data = jbig2Image.parseChunks(chunks);
9268 const dataLength = data.length;
9269
9270 for (let i = 0; i < dataLength; i++) {
9271 data[i] ^= 0xff;
9272 }
9273
9274 this.buffer = data;
9275 this.bufferLength = dataLength;
9276 this.eof = true;
9277 };
9278
9279 return Jbig2Stream;
9280}();
9281
9282exports.Jbig2Stream = Jbig2Stream;
9283
9284/***/ }),
9285/* 16 */
9286/***/ (function(module, exports, __w_pdfjs_require__) {
9287
9288"use strict";
9289
9290
9291Object.defineProperty(exports, "__esModule", {
9292 value: true
9293});
9294exports.Jbig2Image = void 0;
9295
9296var _util = __w_pdfjs_require__(2);
9297
9298var _core_utils = __w_pdfjs_require__(8);
9299
9300var _arithmetic_decoder = __w_pdfjs_require__(17);
9301
9302var _ccitt = __w_pdfjs_require__(14);
9303
9304class Jbig2Error extends _util.BaseException {
9305 constructor(msg) {
9306 super(`JBIG2 error: ${msg}`);
9307 }
9308
9309}
9310
9311var Jbig2Image = function Jbig2ImageClosure() {
9312 function ContextCache() {}
9313
9314 ContextCache.prototype = {
9315 getContexts(id) {
9316 if (id in this) {
9317 return this[id];
9318 }
9319
9320 return this[id] = new Int8Array(1 << 16);
9321 }
9322
9323 };
9324
9325 function DecodingContext(data, start, end) {
9326 this.data = data;
9327 this.start = start;
9328 this.end = end;
9329 }
9330
9331 DecodingContext.prototype = {
9332 get decoder() {
9333 var decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
9334 return (0, _util.shadow)(this, "decoder", decoder);
9335 },
9336
9337 get contextCache() {
9338 var cache = new ContextCache();
9339 return (0, _util.shadow)(this, "contextCache", cache);
9340 }
9341
9342 };
9343
9344 function decodeInteger(contextCache, procedure, decoder) {
9345 var contexts = contextCache.getContexts(procedure);
9346 var prev = 1;
9347
9348 function readBits(length) {
9349 var v = 0;
9350
9351 for (var i = 0; i < length; i++) {
9352 var bit = decoder.readBit(contexts, prev);
9353 prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
9354 v = v << 1 | bit;
9355 }
9356
9357 return v >>> 0;
9358 }
9359
9360 var sign = readBits(1);
9361 var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
9362
9363 if (sign === 0) {
9364 return value;
9365 } else if (value > 0) {
9366 return -value;
9367 }
9368
9369 return null;
9370 }
9371
9372 function decodeIAID(contextCache, decoder, codeLength) {
9373 var contexts = contextCache.getContexts("IAID");
9374 var prev = 1;
9375
9376 for (var i = 0; i < codeLength; i++) {
9377 var bit = decoder.readBit(contexts, prev);
9378 prev = prev << 1 | bit;
9379 }
9380
9381 if (codeLength < 31) {
9382 return prev & (1 << codeLength) - 1;
9383 }
9384
9385 return prev & 0x7fffffff;
9386 }
9387
9388 var SegmentTypes = ["SymbolDictionary", null, null, null, "IntermediateTextRegion", null, "ImmediateTextRegion", "ImmediateLosslessTextRegion", null, null, null, null, null, null, null, null, "PatternDictionary", null, null, null, "IntermediateHalftoneRegion", null, "ImmediateHalftoneRegion", "ImmediateLosslessHalftoneRegion", null, null, null, null, null, null, null, null, null, null, null, null, "IntermediateGenericRegion", null, "ImmediateGenericRegion", "ImmediateLosslessGenericRegion", "IntermediateGenericRefinementRegion", null, "ImmediateGenericRefinementRegion", "ImmediateLosslessGenericRefinementRegion", null, null, null, null, "PageInformation", "EndOfPage", "EndOfStripe", "EndOfFile", "Profiles", "Tables", null, null, null, null, null, null, null, null, "Extension"];
9389 var CodingTemplates = [[{
9390 x: -1,
9391 y: -2
9392 }, {
9393 x: 0,
9394 y: -2
9395 }, {
9396 x: 1,
9397 y: -2
9398 }, {
9399 x: -2,
9400 y: -1
9401 }, {
9402 x: -1,
9403 y: -1
9404 }, {
9405 x: 0,
9406 y: -1
9407 }, {
9408 x: 1,
9409 y: -1
9410 }, {
9411 x: 2,
9412 y: -1
9413 }, {
9414 x: -4,
9415 y: 0
9416 }, {
9417 x: -3,
9418 y: 0
9419 }, {
9420 x: -2,
9421 y: 0
9422 }, {
9423 x: -1,
9424 y: 0
9425 }], [{
9426 x: -1,
9427 y: -2
9428 }, {
9429 x: 0,
9430 y: -2
9431 }, {
9432 x: 1,
9433 y: -2
9434 }, {
9435 x: 2,
9436 y: -2
9437 }, {
9438 x: -2,
9439 y: -1
9440 }, {
9441 x: -1,
9442 y: -1
9443 }, {
9444 x: 0,
9445 y: -1
9446 }, {
9447 x: 1,
9448 y: -1
9449 }, {
9450 x: 2,
9451 y: -1
9452 }, {
9453 x: -3,
9454 y: 0
9455 }, {
9456 x: -2,
9457 y: 0
9458 }, {
9459 x: -1,
9460 y: 0
9461 }], [{
9462 x: -1,
9463 y: -2
9464 }, {
9465 x: 0,
9466 y: -2
9467 }, {
9468 x: 1,
9469 y: -2
9470 }, {
9471 x: -2,
9472 y: -1
9473 }, {
9474 x: -1,
9475 y: -1
9476 }, {
9477 x: 0,
9478 y: -1
9479 }, {
9480 x: 1,
9481 y: -1
9482 }, {
9483 x: -2,
9484 y: 0
9485 }, {
9486 x: -1,
9487 y: 0
9488 }], [{
9489 x: -3,
9490 y: -1
9491 }, {
9492 x: -2,
9493 y: -1
9494 }, {
9495 x: -1,
9496 y: -1
9497 }, {
9498 x: 0,
9499 y: -1
9500 }, {
9501 x: 1,
9502 y: -1
9503 }, {
9504 x: -4,
9505 y: 0
9506 }, {
9507 x: -3,
9508 y: 0
9509 }, {
9510 x: -2,
9511 y: 0
9512 }, {
9513 x: -1,
9514 y: 0
9515 }]];
9516 var RefinementTemplates = [{
9517 coding: [{
9518 x: 0,
9519 y: -1
9520 }, {
9521 x: 1,
9522 y: -1
9523 }, {
9524 x: -1,
9525 y: 0
9526 }],
9527 reference: [{
9528 x: 0,
9529 y: -1
9530 }, {
9531 x: 1,
9532 y: -1
9533 }, {
9534 x: -1,
9535 y: 0
9536 }, {
9537 x: 0,
9538 y: 0
9539 }, {
9540 x: 1,
9541 y: 0
9542 }, {
9543 x: -1,
9544 y: 1
9545 }, {
9546 x: 0,
9547 y: 1
9548 }, {
9549 x: 1,
9550 y: 1
9551 }]
9552 }, {
9553 coding: [{
9554 x: -1,
9555 y: -1
9556 }, {
9557 x: 0,
9558 y: -1
9559 }, {
9560 x: 1,
9561 y: -1
9562 }, {
9563 x: -1,
9564 y: 0
9565 }],
9566 reference: [{
9567 x: 0,
9568 y: -1
9569 }, {
9570 x: -1,
9571 y: 0
9572 }, {
9573 x: 0,
9574 y: 0
9575 }, {
9576 x: 1,
9577 y: 0
9578 }, {
9579 x: 0,
9580 y: 1
9581 }, {
9582 x: 1,
9583 y: 1
9584 }]
9585 }];
9586 var ReusedContexts = [0x9b25, 0x0795, 0x00e5, 0x0195];
9587 var RefinementReusedContexts = [0x0020, 0x0008];
9588
9589 function decodeBitmapTemplate0(width, height, decodingContext) {
9590 var decoder = decodingContext.decoder;
9591 var contexts = decodingContext.contextCache.getContexts("GB");
9592 var contextLabel,
9593 i,
9594 j,
9595 pixel,
9596 row,
9597 row1,
9598 row2,
9599 bitmap = [];
9600 var OLD_PIXEL_MASK = 0x7bf7;
9601
9602 for (i = 0; i < height; i++) {
9603 row = bitmap[i] = new Uint8Array(width);
9604 row1 = i < 1 ? row : bitmap[i - 1];
9605 row2 = i < 2 ? row : bitmap[i - 2];
9606 contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
9607
9608 for (j = 0; j < width; j++) {
9609 row[j] = pixel = decoder.readBit(contexts, contextLabel);
9610 contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
9611 }
9612 }
9613
9614 return bitmap;
9615 }
9616
9617 function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
9618 if (mmr) {
9619 const input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
9620 return decodeMMRBitmap(input, width, height, false);
9621 }
9622
9623 if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
9624 return decodeBitmapTemplate0(width, height, decodingContext);
9625 }
9626
9627 var useskip = !!skip;
9628 var template = CodingTemplates[templateIndex].concat(at);
9629 template.sort(function (a, b) {
9630 return a.y - b.y || a.x - b.x;
9631 });
9632 var templateLength = template.length;
9633 var templateX = new Int8Array(templateLength);
9634 var templateY = new Int8Array(templateLength);
9635 var changingTemplateEntries = [];
9636 var reuseMask = 0,
9637 minX = 0,
9638 maxX = 0,
9639 minY = 0;
9640 var c, k;
9641
9642 for (k = 0; k < templateLength; k++) {
9643 templateX[k] = template[k].x;
9644 templateY[k] = template[k].y;
9645 minX = Math.min(minX, template[k].x);
9646 maxX = Math.max(maxX, template[k].x);
9647 minY = Math.min(minY, template[k].y);
9648
9649 if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
9650 reuseMask |= 1 << templateLength - 1 - k;
9651 } else {
9652 changingTemplateEntries.push(k);
9653 }
9654 }
9655
9656 var changingEntriesLength = changingTemplateEntries.length;
9657 var changingTemplateX = new Int8Array(changingEntriesLength);
9658 var changingTemplateY = new Int8Array(changingEntriesLength);
9659 var changingTemplateBit = new Uint16Array(changingEntriesLength);
9660
9661 for (c = 0; c < changingEntriesLength; c++) {
9662 k = changingTemplateEntries[c];
9663 changingTemplateX[c] = template[k].x;
9664 changingTemplateY[c] = template[k].y;
9665 changingTemplateBit[c] = 1 << templateLength - 1 - k;
9666 }
9667
9668 var sbb_left = -minX;
9669 var sbb_top = -minY;
9670 var sbb_right = width - maxX;
9671 var pseudoPixelContext = ReusedContexts[templateIndex];
9672 var row = new Uint8Array(width);
9673 var bitmap = [];
9674 var decoder = decodingContext.decoder;
9675 var contexts = decodingContext.contextCache.getContexts("GB");
9676 var ltp = 0,
9677 j,
9678 i0,
9679 j0,
9680 contextLabel = 0,
9681 bit,
9682 shift;
9683
9684 for (var i = 0; i < height; i++) {
9685 if (prediction) {
9686 var sltp = decoder.readBit(contexts, pseudoPixelContext);
9687 ltp ^= sltp;
9688
9689 if (ltp) {
9690 bitmap.push(row);
9691 continue;
9692 }
9693 }
9694
9695 row = new Uint8Array(row);
9696 bitmap.push(row);
9697
9698 for (j = 0; j < width; j++) {
9699 if (useskip && skip[i][j]) {
9700 row[j] = 0;
9701 continue;
9702 }
9703
9704 if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
9705 contextLabel = contextLabel << 1 & reuseMask;
9706
9707 for (k = 0; k < changingEntriesLength; k++) {
9708 i0 = i + changingTemplateY[k];
9709 j0 = j + changingTemplateX[k];
9710 bit = bitmap[i0][j0];
9711
9712 if (bit) {
9713 bit = changingTemplateBit[k];
9714 contextLabel |= bit;
9715 }
9716 }
9717 } else {
9718 contextLabel = 0;
9719 shift = templateLength - 1;
9720
9721 for (k = 0; k < templateLength; k++, shift--) {
9722 j0 = j + templateX[k];
9723
9724 if (j0 >= 0 && j0 < width) {
9725 i0 = i + templateY[k];
9726
9727 if (i0 >= 0) {
9728 bit = bitmap[i0][j0];
9729
9730 if (bit) {
9731 contextLabel |= bit << shift;
9732 }
9733 }
9734 }
9735 }
9736 }
9737
9738 var pixel = decoder.readBit(contexts, contextLabel);
9739 row[j] = pixel;
9740 }
9741 }
9742
9743 return bitmap;
9744 }
9745
9746 function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
9747 var codingTemplate = RefinementTemplates[templateIndex].coding;
9748
9749 if (templateIndex === 0) {
9750 codingTemplate = codingTemplate.concat([at[0]]);
9751 }
9752
9753 var codingTemplateLength = codingTemplate.length;
9754 var codingTemplateX = new Int32Array(codingTemplateLength);
9755 var codingTemplateY = new Int32Array(codingTemplateLength);
9756 var k;
9757
9758 for (k = 0; k < codingTemplateLength; k++) {
9759 codingTemplateX[k] = codingTemplate[k].x;
9760 codingTemplateY[k] = codingTemplate[k].y;
9761 }
9762
9763 var referenceTemplate = RefinementTemplates[templateIndex].reference;
9764
9765 if (templateIndex === 0) {
9766 referenceTemplate = referenceTemplate.concat([at[1]]);
9767 }
9768
9769 var referenceTemplateLength = referenceTemplate.length;
9770 var referenceTemplateX = new Int32Array(referenceTemplateLength);
9771 var referenceTemplateY = new Int32Array(referenceTemplateLength);
9772
9773 for (k = 0; k < referenceTemplateLength; k++) {
9774 referenceTemplateX[k] = referenceTemplate[k].x;
9775 referenceTemplateY[k] = referenceTemplate[k].y;
9776 }
9777
9778 var referenceWidth = referenceBitmap[0].length;
9779 var referenceHeight = referenceBitmap.length;
9780 var pseudoPixelContext = RefinementReusedContexts[templateIndex];
9781 var bitmap = [];
9782 var decoder = decodingContext.decoder;
9783 var contexts = decodingContext.contextCache.getContexts("GR");
9784 var ltp = 0;
9785
9786 for (var i = 0; i < height; i++) {
9787 if (prediction) {
9788 var sltp = decoder.readBit(contexts, pseudoPixelContext);
9789 ltp ^= sltp;
9790
9791 if (ltp) {
9792 throw new Jbig2Error("prediction is not supported");
9793 }
9794 }
9795
9796 var row = new Uint8Array(width);
9797 bitmap.push(row);
9798
9799 for (var j = 0; j < width; j++) {
9800 var i0, j0;
9801 var contextLabel = 0;
9802
9803 for (k = 0; k < codingTemplateLength; k++) {
9804 i0 = i + codingTemplateY[k];
9805 j0 = j + codingTemplateX[k];
9806
9807 if (i0 < 0 || j0 < 0 || j0 >= width) {
9808 contextLabel <<= 1;
9809 } else {
9810 contextLabel = contextLabel << 1 | bitmap[i0][j0];
9811 }
9812 }
9813
9814 for (k = 0; k < referenceTemplateLength; k++) {
9815 i0 = i + referenceTemplateY[k] - offsetY;
9816 j0 = j + referenceTemplateX[k] - offsetX;
9817
9818 if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
9819 contextLabel <<= 1;
9820 } else {
9821 contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
9822 }
9823 }
9824
9825 var pixel = decoder.readBit(contexts, contextLabel);
9826 row[j] = pixel;
9827 }
9828 }
9829
9830 return bitmap;
9831 }
9832
9833 function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext, huffmanInput) {
9834 if (huffman && refinement) {
9835 throw new Jbig2Error("symbol refinement with Huffman is not supported");
9836 }
9837
9838 var newSymbols = [];
9839 var currentHeight = 0;
9840 var symbolCodeLength = (0, _core_utils.log2)(symbols.length + numberOfNewSymbols);
9841 var decoder = decodingContext.decoder;
9842 var contextCache = decodingContext.contextCache;
9843 let tableB1, symbolWidths;
9844
9845 if (huffman) {
9846 tableB1 = getStandardTable(1);
9847 symbolWidths = [];
9848 symbolCodeLength = Math.max(symbolCodeLength, 1);
9849 }
9850
9851 while (newSymbols.length < numberOfNewSymbols) {
9852 var deltaHeight = huffman ? huffmanTables.tableDeltaHeight.decode(huffmanInput) : decodeInteger(contextCache, "IADH", decoder);
9853 currentHeight += deltaHeight;
9854 let currentWidth = 0,
9855 totalWidth = 0;
9856 const firstSymbol = huffman ? symbolWidths.length : 0;
9857
9858 while (true) {
9859 var deltaWidth = huffman ? huffmanTables.tableDeltaWidth.decode(huffmanInput) : decodeInteger(contextCache, "IADW", decoder);
9860
9861 if (deltaWidth === null) {
9862 break;
9863 }
9864
9865 currentWidth += deltaWidth;
9866 totalWidth += currentWidth;
9867 var bitmap;
9868
9869 if (refinement) {
9870 var numberOfInstances = decodeInteger(contextCache, "IAAI", decoder);
9871
9872 if (numberOfInstances > 1) {
9873 bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, 0, huffmanInput);
9874 } else {
9875 var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
9876 var rdx = decodeInteger(contextCache, "IARDX", decoder);
9877 var rdy = decodeInteger(contextCache, "IARDY", decoder);
9878 var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
9879 bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
9880 }
9881
9882 newSymbols.push(bitmap);
9883 } else if (huffman) {
9884 symbolWidths.push(currentWidth);
9885 } else {
9886 bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
9887 newSymbols.push(bitmap);
9888 }
9889 }
9890
9891 if (huffman && !refinement) {
9892 const bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
9893 huffmanInput.byteAlign();
9894 let collectiveBitmap;
9895
9896 if (bitmapSize === 0) {
9897 collectiveBitmap = readUncompressedBitmap(huffmanInput, totalWidth, currentHeight);
9898 } else {
9899 const originalEnd = huffmanInput.end;
9900 const bitmapEnd = huffmanInput.position + bitmapSize;
9901 huffmanInput.end = bitmapEnd;
9902 collectiveBitmap = decodeMMRBitmap(huffmanInput, totalWidth, currentHeight, false);
9903 huffmanInput.end = originalEnd;
9904 huffmanInput.position = bitmapEnd;
9905 }
9906
9907 const numberOfSymbolsDecoded = symbolWidths.length;
9908
9909 if (firstSymbol === numberOfSymbolsDecoded - 1) {
9910 newSymbols.push(collectiveBitmap);
9911 } else {
9912 let i,
9913 y,
9914 xMin = 0,
9915 xMax,
9916 bitmapWidth,
9917 symbolBitmap;
9918
9919 for (i = firstSymbol; i < numberOfSymbolsDecoded; i++) {
9920 bitmapWidth = symbolWidths[i];
9921 xMax = xMin + bitmapWidth;
9922 symbolBitmap = [];
9923
9924 for (y = 0; y < currentHeight; y++) {
9925 symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
9926 }
9927
9928 newSymbols.push(symbolBitmap);
9929 xMin = xMax;
9930 }
9931 }
9932 }
9933 }
9934
9935 var exportedSymbols = [];
9936 var flags = [],
9937 currentFlag = false;
9938 var totalSymbolsLength = symbols.length + numberOfNewSymbols;
9939
9940 while (flags.length < totalSymbolsLength) {
9941 var runLength = huffman ? tableB1.decode(huffmanInput) : decodeInteger(contextCache, "IAEX", decoder);
9942
9943 while (runLength--) {
9944 flags.push(currentFlag);
9945 }
9946
9947 currentFlag = !currentFlag;
9948 }
9949
9950 for (var i = 0, ii = symbols.length; i < ii; i++) {
9951 if (flags[i]) {
9952 exportedSymbols.push(symbols[i]);
9953 }
9954 }
9955
9956 for (var j = 0; j < numberOfNewSymbols; i++, j++) {
9957 if (flags[i]) {
9958 exportedSymbols.push(newSymbols[j]);
9959 }
9960 }
9961
9962 return exportedSymbols;
9963 }
9964
9965 function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, logStripSize, huffmanInput) {
9966 if (huffman && refinement) {
9967 throw new Jbig2Error("refinement with Huffman is not supported");
9968 }
9969
9970 var bitmap = [];
9971 var i, row;
9972
9973 for (i = 0; i < height; i++) {
9974 row = new Uint8Array(width);
9975
9976 if (defaultPixelValue) {
9977 for (var j = 0; j < width; j++) {
9978 row[j] = defaultPixelValue;
9979 }
9980 }
9981
9982 bitmap.push(row);
9983 }
9984
9985 var decoder = decodingContext.decoder;
9986 var contextCache = decodingContext.contextCache;
9987 var stripT = huffman ? -huffmanTables.tableDeltaT.decode(huffmanInput) : -decodeInteger(contextCache, "IADT", decoder);
9988 var firstS = 0;
9989 i = 0;
9990
9991 while (i < numberOfSymbolInstances) {
9992 var deltaT = huffman ? huffmanTables.tableDeltaT.decode(huffmanInput) : decodeInteger(contextCache, "IADT", decoder);
9993 stripT += deltaT;
9994 var deltaFirstS = huffman ? huffmanTables.tableFirstS.decode(huffmanInput) : decodeInteger(contextCache, "IAFS", decoder);
9995 firstS += deltaFirstS;
9996 var currentS = firstS;
9997
9998 do {
9999 let currentT = 0;
10000
10001 if (stripSize > 1) {
10002 currentT = huffman ? huffmanInput.readBits(logStripSize) : decodeInteger(contextCache, "IAIT", decoder);
10003 }
10004
10005 var t = stripSize * stripT + currentT;
10006 var symbolId = huffman ? huffmanTables.symbolIDTable.decode(huffmanInput) : decodeIAID(contextCache, decoder, symbolCodeLength);
10007 var applyRefinement = refinement && (huffman ? huffmanInput.readBit() : decodeInteger(contextCache, "IARI", decoder));
10008 var symbolBitmap = inputSymbols[symbolId];
10009 var symbolWidth = symbolBitmap[0].length;
10010 var symbolHeight = symbolBitmap.length;
10011
10012 if (applyRefinement) {
10013 var rdw = decodeInteger(contextCache, "IARDW", decoder);
10014 var rdh = decodeInteger(contextCache, "IARDH", decoder);
10015 var rdx = decodeInteger(contextCache, "IARDX", decoder);
10016 var rdy = decodeInteger(contextCache, "IARDY", decoder);
10017 symbolWidth += rdw;
10018 symbolHeight += rdh;
10019 symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
10020 }
10021
10022 var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
10023 var offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
10024 var s2, t2, symbolRow;
10025
10026 if (transposed) {
10027 for (s2 = 0; s2 < symbolHeight; s2++) {
10028 row = bitmap[offsetS + s2];
10029
10030 if (!row) {
10031 continue;
10032 }
10033
10034 symbolRow = symbolBitmap[s2];
10035 var maxWidth = Math.min(width - offsetT, symbolWidth);
10036
10037 switch (combinationOperator) {
10038 case 0:
10039 for (t2 = 0; t2 < maxWidth; t2++) {
10040 row[offsetT + t2] |= symbolRow[t2];
10041 }
10042
10043 break;
10044
10045 case 2:
10046 for (t2 = 0; t2 < maxWidth; t2++) {
10047 row[offsetT + t2] ^= symbolRow[t2];
10048 }
10049
10050 break;
10051
10052 default:
10053 throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
10054 }
10055 }
10056
10057 currentS += symbolHeight - 1;
10058 } else {
10059 for (t2 = 0; t2 < symbolHeight; t2++) {
10060 row = bitmap[offsetT + t2];
10061
10062 if (!row) {
10063 continue;
10064 }
10065
10066 symbolRow = symbolBitmap[t2];
10067
10068 switch (combinationOperator) {
10069 case 0:
10070 for (s2 = 0; s2 < symbolWidth; s2++) {
10071 row[offsetS + s2] |= symbolRow[s2];
10072 }
10073
10074 break;
10075
10076 case 2:
10077 for (s2 = 0; s2 < symbolWidth; s2++) {
10078 row[offsetS + s2] ^= symbolRow[s2];
10079 }
10080
10081 break;
10082
10083 default:
10084 throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
10085 }
10086 }
10087
10088 currentS += symbolWidth - 1;
10089 }
10090
10091 i++;
10092 var deltaS = huffman ? huffmanTables.tableDeltaS.decode(huffmanInput) : decodeInteger(contextCache, "IADS", decoder);
10093
10094 if (deltaS === null) {
10095 break;
10096 }
10097
10098 currentS += deltaS + dsOffset;
10099 } while (true);
10100 }
10101
10102 return bitmap;
10103 }
10104
10105 function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
10106 const at = [];
10107
10108 if (!mmr) {
10109 at.push({
10110 x: -patternWidth,
10111 y: 0
10112 });
10113
10114 if (template === 0) {
10115 at.push({
10116 x: -3,
10117 y: -1
10118 });
10119 at.push({
10120 x: 2,
10121 y: -2
10122 });
10123 at.push({
10124 x: -2,
10125 y: -2
10126 });
10127 }
10128 }
10129
10130 const collectiveWidth = (maxPatternIndex + 1) * patternWidth;
10131 const collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
10132 const patterns = [];
10133
10134 for (let i = 0; i <= maxPatternIndex; i++) {
10135 const patternBitmap = [];
10136 const xMin = patternWidth * i;
10137 const xMax = xMin + patternWidth;
10138
10139 for (let y = 0; y < patternHeight; y++) {
10140 patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
10141 }
10142
10143 patterns.push(patternBitmap);
10144 }
10145
10146 return patterns;
10147 }
10148
10149 function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
10150 const skip = null;
10151
10152 if (enableSkip) {
10153 throw new Jbig2Error("skip is not supported");
10154 }
10155
10156 if (combinationOperator !== 0) {
10157 throw new Jbig2Error("operator " + combinationOperator + " is not supported in halftone region");
10158 }
10159
10160 const regionBitmap = [];
10161 let i, j, row;
10162
10163 for (i = 0; i < regionHeight; i++) {
10164 row = new Uint8Array(regionWidth);
10165
10166 if (defaultPixelValue) {
10167 for (j = 0; j < regionWidth; j++) {
10168 row[j] = defaultPixelValue;
10169 }
10170 }
10171
10172 regionBitmap.push(row);
10173 }
10174
10175 const numberOfPatterns = patterns.length;
10176 const pattern0 = patterns[0];
10177 const patternWidth = pattern0[0].length,
10178 patternHeight = pattern0.length;
10179 const bitsPerValue = (0, _core_utils.log2)(numberOfPatterns);
10180 const at = [];
10181
10182 if (!mmr) {
10183 at.push({
10184 x: template <= 1 ? 3 : 2,
10185 y: -1
10186 });
10187
10188 if (template === 0) {
10189 at.push({
10190 x: -3,
10191 y: -1
10192 });
10193 at.push({
10194 x: 2,
10195 y: -2
10196 });
10197 at.push({
10198 x: -2,
10199 y: -2
10200 });
10201 }
10202 }
10203
10204 const grayScaleBitPlanes = [];
10205 let mmrInput, bitmap;
10206
10207 if (mmr) {
10208 mmrInput = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
10209 }
10210
10211 for (i = bitsPerValue - 1; i >= 0; i--) {
10212 if (mmr) {
10213 bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
10214 } else {
10215 bitmap = decodeBitmap(false, gridWidth, gridHeight, template, false, skip, at, decodingContext);
10216 }
10217
10218 grayScaleBitPlanes[i] = bitmap;
10219 }
10220
10221 let mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
10222
10223 for (mg = 0; mg < gridHeight; mg++) {
10224 for (ng = 0; ng < gridWidth; ng++) {
10225 bit = 0;
10226 patternIndex = 0;
10227
10228 for (j = bitsPerValue - 1; j >= 0; j--) {
10229 bit = grayScaleBitPlanes[j][mg][ng] ^ bit;
10230 patternIndex |= bit << j;
10231 }
10232
10233 patternBitmap = patterns[patternIndex];
10234 x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
10235 y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
10236
10237 if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
10238 for (i = 0; i < patternHeight; i++) {
10239 regionRow = regionBitmap[y + i];
10240 patternRow = patternBitmap[i];
10241
10242 for (j = 0; j < patternWidth; j++) {
10243 regionRow[x + j] |= patternRow[j];
10244 }
10245 }
10246 } else {
10247 let regionX, regionY;
10248
10249 for (i = 0; i < patternHeight; i++) {
10250 regionY = y + i;
10251
10252 if (regionY < 0 || regionY >= regionHeight) {
10253 continue;
10254 }
10255
10256 regionRow = regionBitmap[regionY];
10257 patternRow = patternBitmap[i];
10258
10259 for (j = 0; j < patternWidth; j++) {
10260 regionX = x + j;
10261
10262 if (regionX >= 0 && regionX < regionWidth) {
10263 regionRow[regionX] |= patternRow[j];
10264 }
10265 }
10266 }
10267 }
10268 }
10269 }
10270
10271 return regionBitmap;
10272 }
10273
10274 function readSegmentHeader(data, start) {
10275 var segmentHeader = {};
10276 segmentHeader.number = (0, _core_utils.readUint32)(data, start);
10277 var flags = data[start + 4];
10278 var segmentType = flags & 0x3f;
10279
10280 if (!SegmentTypes[segmentType]) {
10281 throw new Jbig2Error("invalid segment type: " + segmentType);
10282 }
10283
10284 segmentHeader.type = segmentType;
10285 segmentHeader.typeName = SegmentTypes[segmentType];
10286 segmentHeader.deferredNonRetain = !!(flags & 0x80);
10287 var pageAssociationFieldSize = !!(flags & 0x40);
10288 var referredFlags = data[start + 5];
10289 var referredToCount = referredFlags >> 5 & 7;
10290 var retainBits = [referredFlags & 31];
10291 var position = start + 6;
10292
10293 if (referredFlags === 7) {
10294 referredToCount = (0, _core_utils.readUint32)(data, position - 1) & 0x1fffffff;
10295 position += 3;
10296 var bytes = referredToCount + 7 >> 3;
10297 retainBits[0] = data[position++];
10298
10299 while (--bytes > 0) {
10300 retainBits.push(data[position++]);
10301 }
10302 } else if (referredFlags === 5 || referredFlags === 6) {
10303 throw new Jbig2Error("invalid referred-to flags");
10304 }
10305
10306 segmentHeader.retainBits = retainBits;
10307 let referredToSegmentNumberSize = 4;
10308
10309 if (segmentHeader.number <= 256) {
10310 referredToSegmentNumberSize = 1;
10311 } else if (segmentHeader.number <= 65536) {
10312 referredToSegmentNumberSize = 2;
10313 }
10314
10315 var referredTo = [];
10316 var i, ii;
10317
10318 for (i = 0; i < referredToCount; i++) {
10319 let number;
10320
10321 if (referredToSegmentNumberSize === 1) {
10322 number = data[position];
10323 } else if (referredToSegmentNumberSize === 2) {
10324 number = (0, _core_utils.readUint16)(data, position);
10325 } else {
10326 number = (0, _core_utils.readUint32)(data, position);
10327 }
10328
10329 referredTo.push(number);
10330 position += referredToSegmentNumberSize;
10331 }
10332
10333 segmentHeader.referredTo = referredTo;
10334
10335 if (!pageAssociationFieldSize) {
10336 segmentHeader.pageAssociation = data[position++];
10337 } else {
10338 segmentHeader.pageAssociation = (0, _core_utils.readUint32)(data, position);
10339 position += 4;
10340 }
10341
10342 segmentHeader.length = (0, _core_utils.readUint32)(data, position);
10343 position += 4;
10344
10345 if (segmentHeader.length === 0xffffffff) {
10346 if (segmentType === 38) {
10347 var genericRegionInfo = readRegionSegmentInformation(data, position);
10348 var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
10349 var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
10350 var searchPatternLength = 6;
10351 var searchPattern = new Uint8Array(searchPatternLength);
10352
10353 if (!genericRegionMmr) {
10354 searchPattern[0] = 0xff;
10355 searchPattern[1] = 0xac;
10356 }
10357
10358 searchPattern[2] = genericRegionInfo.height >>> 24 & 0xff;
10359 searchPattern[3] = genericRegionInfo.height >> 16 & 0xff;
10360 searchPattern[4] = genericRegionInfo.height >> 8 & 0xff;
10361 searchPattern[5] = genericRegionInfo.height & 0xff;
10362
10363 for (i = position, ii = data.length; i < ii; i++) {
10364 var j = 0;
10365
10366 while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
10367 j++;
10368 }
10369
10370 if (j === searchPatternLength) {
10371 segmentHeader.length = i + searchPatternLength;
10372 break;
10373 }
10374 }
10375
10376 if (segmentHeader.length === 0xffffffff) {
10377 throw new Jbig2Error("segment end was not found");
10378 }
10379 } else {
10380 throw new Jbig2Error("invalid unknown segment length");
10381 }
10382 }
10383
10384 segmentHeader.headerEnd = position;
10385 return segmentHeader;
10386 }
10387
10388 function readSegments(header, data, start, end) {
10389 var segments = [];
10390 var position = start;
10391
10392 while (position < end) {
10393 var segmentHeader = readSegmentHeader(data, position);
10394 position = segmentHeader.headerEnd;
10395 var segment = {
10396 header: segmentHeader,
10397 data
10398 };
10399
10400 if (!header.randomAccess) {
10401 segment.start = position;
10402 position += segmentHeader.length;
10403 segment.end = position;
10404 }
10405
10406 segments.push(segment);
10407
10408 if (segmentHeader.type === 51) {
10409 break;
10410 }
10411 }
10412
10413 if (header.randomAccess) {
10414 for (var i = 0, ii = segments.length; i < ii; i++) {
10415 segments[i].start = position;
10416 position += segments[i].header.length;
10417 segments[i].end = position;
10418 }
10419 }
10420
10421 return segments;
10422 }
10423
10424 function readRegionSegmentInformation(data, start) {
10425 return {
10426 width: (0, _core_utils.readUint32)(data, start),
10427 height: (0, _core_utils.readUint32)(data, start + 4),
10428 x: (0, _core_utils.readUint32)(data, start + 8),
10429 y: (0, _core_utils.readUint32)(data, start + 12),
10430 combinationOperator: data[start + 16] & 7
10431 };
10432 }
10433
10434 var RegionSegmentInformationFieldLength = 17;
10435
10436 function processSegment(segment, visitor) {
10437 var header = segment.header;
10438 var data = segment.data,
10439 position = segment.start,
10440 end = segment.end;
10441 var args, at, i, atLength;
10442
10443 switch (header.type) {
10444 case 0:
10445 var dictionary = {};
10446 var dictionaryFlags = (0, _core_utils.readUint16)(data, position);
10447 dictionary.huffman = !!(dictionaryFlags & 1);
10448 dictionary.refinement = !!(dictionaryFlags & 2);
10449 dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
10450 dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
10451 dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
10452 dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
10453 dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
10454 dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
10455 dictionary.template = dictionaryFlags >> 10 & 3;
10456 dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
10457 position += 2;
10458
10459 if (!dictionary.huffman) {
10460 atLength = dictionary.template === 0 ? 4 : 1;
10461 at = [];
10462
10463 for (i = 0; i < atLength; i++) {
10464 at.push({
10465 x: (0, _core_utils.readInt8)(data, position),
10466 y: (0, _core_utils.readInt8)(data, position + 1)
10467 });
10468 position += 2;
10469 }
10470
10471 dictionary.at = at;
10472 }
10473
10474 if (dictionary.refinement && !dictionary.refinementTemplate) {
10475 at = [];
10476
10477 for (i = 0; i < 2; i++) {
10478 at.push({
10479 x: (0, _core_utils.readInt8)(data, position),
10480 y: (0, _core_utils.readInt8)(data, position + 1)
10481 });
10482 position += 2;
10483 }
10484
10485 dictionary.refinementAt = at;
10486 }
10487
10488 dictionary.numberOfExportedSymbols = (0, _core_utils.readUint32)(data, position);
10489 position += 4;
10490 dictionary.numberOfNewSymbols = (0, _core_utils.readUint32)(data, position);
10491 position += 4;
10492 args = [dictionary, header.number, header.referredTo, data, position, end];
10493 break;
10494
10495 case 6:
10496 case 7:
10497 var textRegion = {};
10498 textRegion.info = readRegionSegmentInformation(data, position);
10499 position += RegionSegmentInformationFieldLength;
10500 var textRegionSegmentFlags = (0, _core_utils.readUint16)(data, position);
10501 position += 2;
10502 textRegion.huffman = !!(textRegionSegmentFlags & 1);
10503 textRegion.refinement = !!(textRegionSegmentFlags & 2);
10504 textRegion.logStripSize = textRegionSegmentFlags >> 2 & 3;
10505 textRegion.stripSize = 1 << textRegion.logStripSize;
10506 textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
10507 textRegion.transposed = !!(textRegionSegmentFlags & 64);
10508 textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
10509 textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
10510 textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
10511 textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
10512
10513 if (textRegion.huffman) {
10514 var textRegionHuffmanFlags = (0, _core_utils.readUint16)(data, position);
10515 position += 2;
10516 textRegion.huffmanFS = textRegionHuffmanFlags & 3;
10517 textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
10518 textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
10519 textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
10520 textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
10521 textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
10522 textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
10523 textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 0x4000);
10524 }
10525
10526 if (textRegion.refinement && !textRegion.refinementTemplate) {
10527 at = [];
10528
10529 for (i = 0; i < 2; i++) {
10530 at.push({
10531 x: (0, _core_utils.readInt8)(data, position),
10532 y: (0, _core_utils.readInt8)(data, position + 1)
10533 });
10534 position += 2;
10535 }
10536
10537 textRegion.refinementAt = at;
10538 }
10539
10540 textRegion.numberOfSymbolInstances = (0, _core_utils.readUint32)(data, position);
10541 position += 4;
10542 args = [textRegion, header.referredTo, data, position, end];
10543 break;
10544
10545 case 16:
10546 const patternDictionary = {};
10547 const patternDictionaryFlags = data[position++];
10548 patternDictionary.mmr = !!(patternDictionaryFlags & 1);
10549 patternDictionary.template = patternDictionaryFlags >> 1 & 3;
10550 patternDictionary.patternWidth = data[position++];
10551 patternDictionary.patternHeight = data[position++];
10552 patternDictionary.maxPatternIndex = (0, _core_utils.readUint32)(data, position);
10553 position += 4;
10554 args = [patternDictionary, header.number, data, position, end];
10555 break;
10556
10557 case 22:
10558 case 23:
10559 const halftoneRegion = {};
10560 halftoneRegion.info = readRegionSegmentInformation(data, position);
10561 position += RegionSegmentInformationFieldLength;
10562 const halftoneRegionFlags = data[position++];
10563 halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
10564 halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
10565 halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
10566 halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
10567 halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
10568 halftoneRegion.gridWidth = (0, _core_utils.readUint32)(data, position);
10569 position += 4;
10570 halftoneRegion.gridHeight = (0, _core_utils.readUint32)(data, position);
10571 position += 4;
10572 halftoneRegion.gridOffsetX = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
10573 position += 4;
10574 halftoneRegion.gridOffsetY = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
10575 position += 4;
10576 halftoneRegion.gridVectorX = (0, _core_utils.readUint16)(data, position);
10577 position += 2;
10578 halftoneRegion.gridVectorY = (0, _core_utils.readUint16)(data, position);
10579 position += 2;
10580 args = [halftoneRegion, header.referredTo, data, position, end];
10581 break;
10582
10583 case 38:
10584 case 39:
10585 var genericRegion = {};
10586 genericRegion.info = readRegionSegmentInformation(data, position);
10587 position += RegionSegmentInformationFieldLength;
10588 var genericRegionSegmentFlags = data[position++];
10589 genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
10590 genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
10591 genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
10592
10593 if (!genericRegion.mmr) {
10594 atLength = genericRegion.template === 0 ? 4 : 1;
10595 at = [];
10596
10597 for (i = 0; i < atLength; i++) {
10598 at.push({
10599 x: (0, _core_utils.readInt8)(data, position),
10600 y: (0, _core_utils.readInt8)(data, position + 1)
10601 });
10602 position += 2;
10603 }
10604
10605 genericRegion.at = at;
10606 }
10607
10608 args = [genericRegion, data, position, end];
10609 break;
10610
10611 case 48:
10612 var pageInfo = {
10613 width: (0, _core_utils.readUint32)(data, position),
10614 height: (0, _core_utils.readUint32)(data, position + 4),
10615 resolutionX: (0, _core_utils.readUint32)(data, position + 8),
10616 resolutionY: (0, _core_utils.readUint32)(data, position + 12)
10617 };
10618
10619 if (pageInfo.height === 0xffffffff) {
10620 delete pageInfo.height;
10621 }
10622
10623 var pageSegmentFlags = data[position + 16];
10624 (0, _core_utils.readUint16)(data, position + 17);
10625 pageInfo.lossless = !!(pageSegmentFlags & 1);
10626 pageInfo.refinement = !!(pageSegmentFlags & 2);
10627 pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
10628 pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
10629 pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
10630 pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
10631 args = [pageInfo];
10632 break;
10633
10634 case 49:
10635 break;
10636
10637 case 50:
10638 break;
10639
10640 case 51:
10641 break;
10642
10643 case 53:
10644 args = [header.number, data, position, end];
10645 break;
10646
10647 case 62:
10648 break;
10649
10650 default:
10651 throw new Jbig2Error(`segment type ${header.typeName}(${header.type})` + " is not implemented");
10652 }
10653
10654 var callbackName = "on" + header.typeName;
10655
10656 if (callbackName in visitor) {
10657 visitor[callbackName].apply(visitor, args);
10658 }
10659 }
10660
10661 function processSegments(segments, visitor) {
10662 for (var i = 0, ii = segments.length; i < ii; i++) {
10663 processSegment(segments[i], visitor);
10664 }
10665 }
10666
10667 function parseJbig2Chunks(chunks) {
10668 var visitor = new SimpleSegmentVisitor();
10669
10670 for (var i = 0, ii = chunks.length; i < ii; i++) {
10671 var chunk = chunks[i];
10672 var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
10673 processSegments(segments, visitor);
10674 }
10675
10676 return visitor.buffer;
10677 }
10678
10679 function parseJbig2(data) {
10680 const end = data.length;
10681 let position = 0;
10682
10683 if (data[position] !== 0x97 || data[position + 1] !== 0x4a || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0d || data[position + 5] !== 0x0a || data[position + 6] !== 0x1a || data[position + 7] !== 0x0a) {
10684 throw new Jbig2Error("parseJbig2 - invalid header.");
10685 }
10686
10687 const header = Object.create(null);
10688 position += 8;
10689 const flags = data[position++];
10690 header.randomAccess = !(flags & 1);
10691
10692 if (!(flags & 2)) {
10693 header.numberOfPages = (0, _core_utils.readUint32)(data, position);
10694 position += 4;
10695 }
10696
10697 const segments = readSegments(header, data, position, end);
10698 const visitor = new SimpleSegmentVisitor();
10699 processSegments(segments, visitor);
10700 const {
10701 width,
10702 height
10703 } = visitor.currentPageInfo;
10704 const bitPacked = visitor.buffer;
10705 const imgData = new Uint8ClampedArray(width * height);
10706 let q = 0,
10707 k = 0;
10708
10709 for (let i = 0; i < height; i++) {
10710 let mask = 0,
10711 buffer;
10712
10713 for (let j = 0; j < width; j++) {
10714 if (!mask) {
10715 mask = 128;
10716 buffer = bitPacked[k++];
10717 }
10718
10719 imgData[q++] = buffer & mask ? 0 : 255;
10720 mask >>= 1;
10721 }
10722 }
10723
10724 return {
10725 imgData,
10726 width,
10727 height
10728 };
10729 }
10730
10731 function SimpleSegmentVisitor() {}
10732
10733 SimpleSegmentVisitor.prototype = {
10734 onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
10735 this.currentPageInfo = info;
10736 var rowSize = info.width + 7 >> 3;
10737 var buffer = new Uint8ClampedArray(rowSize * info.height);
10738
10739 if (info.defaultPixelValue) {
10740 for (var i = 0, ii = buffer.length; i < ii; i++) {
10741 buffer[i] = 0xff;
10742 }
10743 }
10744
10745 this.buffer = buffer;
10746 },
10747 drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
10748 var pageInfo = this.currentPageInfo;
10749 var width = regionInfo.width,
10750 height = regionInfo.height;
10751 var rowSize = pageInfo.width + 7 >> 3;
10752 var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
10753 var buffer = this.buffer;
10754 var mask0 = 128 >> (regionInfo.x & 7);
10755 var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
10756 var i, j, mask, offset;
10757
10758 switch (combinationOperator) {
10759 case 0:
10760 for (i = 0; i < height; i++) {
10761 mask = mask0;
10762 offset = offset0;
10763
10764 for (j = 0; j < width; j++) {
10765 if (bitmap[i][j]) {
10766 buffer[offset] |= mask;
10767 }
10768
10769 mask >>= 1;
10770
10771 if (!mask) {
10772 mask = 128;
10773 offset++;
10774 }
10775 }
10776
10777 offset0 += rowSize;
10778 }
10779
10780 break;
10781
10782 case 2:
10783 for (i = 0; i < height; i++) {
10784 mask = mask0;
10785 offset = offset0;
10786
10787 for (j = 0; j < width; j++) {
10788 if (bitmap[i][j]) {
10789 buffer[offset] ^= mask;
10790 }
10791
10792 mask >>= 1;
10793
10794 if (!mask) {
10795 mask = 128;
10796 offset++;
10797 }
10798 }
10799
10800 offset0 += rowSize;
10801 }
10802
10803 break;
10804
10805 default:
10806 throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
10807 }
10808 },
10809 onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
10810 var regionInfo = region.info;
10811 var decodingContext = new DecodingContext(data, start, end);
10812 var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
10813 this.drawBitmap(regionInfo, bitmap);
10814 },
10815 onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
10816 this.onImmediateGenericRegion.apply(this, arguments);
10817 },
10818 onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
10819 let huffmanTables, huffmanInput;
10820
10821 if (dictionary.huffman) {
10822 huffmanTables = getSymbolDictionaryHuffmanTables(dictionary, referredSegments, this.customTables);
10823 huffmanInput = new Reader(data, start, end);
10824 }
10825
10826 var symbols = this.symbols;
10827
10828 if (!symbols) {
10829 this.symbols = symbols = {};
10830 }
10831
10832 var inputSymbols = [];
10833
10834 for (var i = 0, ii = referredSegments.length; i < ii; i++) {
10835 const referredSymbols = symbols[referredSegments[i]];
10836
10837 if (referredSymbols) {
10838 inputSymbols = inputSymbols.concat(referredSymbols);
10839 }
10840 }
10841
10842 var decodingContext = new DecodingContext(data, start, end);
10843 symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext, huffmanInput);
10844 },
10845 onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
10846 var regionInfo = region.info;
10847 let huffmanTables, huffmanInput;
10848 var symbols = this.symbols;
10849 var inputSymbols = [];
10850
10851 for (var i = 0, ii = referredSegments.length; i < ii; i++) {
10852 const referredSymbols = symbols[referredSegments[i]];
10853
10854 if (referredSymbols) {
10855 inputSymbols = inputSymbols.concat(referredSymbols);
10856 }
10857 }
10858
10859 var symbolCodeLength = (0, _core_utils.log2)(inputSymbols.length);
10860
10861 if (region.huffman) {
10862 huffmanInput = new Reader(data, start, end);
10863 huffmanTables = getTextRegionHuffmanTables(region, referredSegments, this.customTables, inputSymbols.length, huffmanInput);
10864 }
10865
10866 var decodingContext = new DecodingContext(data, start, end);
10867 var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext, region.logStripSize, huffmanInput);
10868 this.drawBitmap(regionInfo, bitmap);
10869 },
10870 onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
10871 this.onImmediateTextRegion.apply(this, arguments);
10872 },
10873
10874 onPatternDictionary(dictionary, currentSegment, data, start, end) {
10875 let patterns = this.patterns;
10876
10877 if (!patterns) {
10878 this.patterns = patterns = {};
10879 }
10880
10881 const decodingContext = new DecodingContext(data, start, end);
10882 patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
10883 },
10884
10885 onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
10886 const patterns = this.patterns[referredSegments[0]];
10887 const regionInfo = region.info;
10888 const decodingContext = new DecodingContext(data, start, end);
10889 const bitmap = decodeHalftoneRegion(region.mmr, patterns, region.template, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.enableSkip, region.combinationOperator, region.gridWidth, region.gridHeight, region.gridOffsetX, region.gridOffsetY, region.gridVectorX, region.gridVectorY, decodingContext);
10890 this.drawBitmap(regionInfo, bitmap);
10891 },
10892
10893 onImmediateLosslessHalftoneRegion() {
10894 this.onImmediateHalftoneRegion.apply(this, arguments);
10895 },
10896
10897 onTables(currentSegment, data, start, end) {
10898 let customTables = this.customTables;
10899
10900 if (!customTables) {
10901 this.customTables = customTables = {};
10902 }
10903
10904 customTables[currentSegment] = decodeTablesSegment(data, start, end);
10905 }
10906
10907 };
10908
10909 function HuffmanLine(lineData) {
10910 if (lineData.length === 2) {
10911 this.isOOB = true;
10912 this.rangeLow = 0;
10913 this.prefixLength = lineData[0];
10914 this.rangeLength = 0;
10915 this.prefixCode = lineData[1];
10916 this.isLowerRange = false;
10917 } else {
10918 this.isOOB = false;
10919 this.rangeLow = lineData[0];
10920 this.prefixLength = lineData[1];
10921 this.rangeLength = lineData[2];
10922 this.prefixCode = lineData[3];
10923 this.isLowerRange = lineData[4] === "lower";
10924 }
10925 }
10926
10927 function HuffmanTreeNode(line) {
10928 this.children = [];
10929
10930 if (line) {
10931 this.isLeaf = true;
10932 this.rangeLength = line.rangeLength;
10933 this.rangeLow = line.rangeLow;
10934 this.isLowerRange = line.isLowerRange;
10935 this.isOOB = line.isOOB;
10936 } else {
10937 this.isLeaf = false;
10938 }
10939 }
10940
10941 HuffmanTreeNode.prototype = {
10942 buildTree(line, shift) {
10943 const bit = line.prefixCode >> shift & 1;
10944
10945 if (shift <= 0) {
10946 this.children[bit] = new HuffmanTreeNode(line);
10947 } else {
10948 let node = this.children[bit];
10949
10950 if (!node) {
10951 this.children[bit] = node = new HuffmanTreeNode(null);
10952 }
10953
10954 node.buildTree(line, shift - 1);
10955 }
10956 },
10957
10958 decodeNode(reader) {
10959 if (this.isLeaf) {
10960 if (this.isOOB) {
10961 return null;
10962 }
10963
10964 const htOffset = reader.readBits(this.rangeLength);
10965 return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
10966 }
10967
10968 const node = this.children[reader.readBit()];
10969
10970 if (!node) {
10971 throw new Jbig2Error("invalid Huffman data");
10972 }
10973
10974 return node.decodeNode(reader);
10975 }
10976
10977 };
10978
10979 function HuffmanTable(lines, prefixCodesDone) {
10980 if (!prefixCodesDone) {
10981 this.assignPrefixCodes(lines);
10982 }
10983
10984 this.rootNode = new HuffmanTreeNode(null);
10985
10986 for (let i = 0, ii = lines.length; i < ii; i++) {
10987 const line = lines[i];
10988
10989 if (line.prefixLength > 0) {
10990 this.rootNode.buildTree(line, line.prefixLength - 1);
10991 }
10992 }
10993 }
10994
10995 HuffmanTable.prototype = {
10996 decode(reader) {
10997 return this.rootNode.decodeNode(reader);
10998 },
10999
11000 assignPrefixCodes(lines) {
11001 const linesLength = lines.length;
11002 let prefixLengthMax = 0;
11003
11004 for (let i = 0; i < linesLength; i++) {
11005 prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
11006 }
11007
11008 const histogram = new Uint32Array(prefixLengthMax + 1);
11009
11010 for (let i = 0; i < linesLength; i++) {
11011 histogram[lines[i].prefixLength]++;
11012 }
11013
11014 let currentLength = 1,
11015 firstCode = 0,
11016 currentCode,
11017 currentTemp,
11018 line;
11019 histogram[0] = 0;
11020
11021 while (currentLength <= prefixLengthMax) {
11022 firstCode = firstCode + histogram[currentLength - 1] << 1;
11023 currentCode = firstCode;
11024 currentTemp = 0;
11025
11026 while (currentTemp < linesLength) {
11027 line = lines[currentTemp];
11028
11029 if (line.prefixLength === currentLength) {
11030 line.prefixCode = currentCode;
11031 currentCode++;
11032 }
11033
11034 currentTemp++;
11035 }
11036
11037 currentLength++;
11038 }
11039 }
11040
11041 };
11042
11043 function decodeTablesSegment(data, start, end) {
11044 const flags = data[start];
11045 const lowestValue = (0, _core_utils.readUint32)(data, start + 1) & 0xffffffff;
11046 const highestValue = (0, _core_utils.readUint32)(data, start + 5) & 0xffffffff;
11047 const reader = new Reader(data, start + 9, end);
11048 const prefixSizeBits = (flags >> 1 & 7) + 1;
11049 const rangeSizeBits = (flags >> 4 & 7) + 1;
11050 const lines = [];
11051 let prefixLength,
11052 rangeLength,
11053 currentRangeLow = lowestValue;
11054
11055 do {
11056 prefixLength = reader.readBits(prefixSizeBits);
11057 rangeLength = reader.readBits(rangeSizeBits);
11058 lines.push(new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0]));
11059 currentRangeLow += 1 << rangeLength;
11060 } while (currentRangeLow < highestValue);
11061
11062 prefixLength = reader.readBits(prefixSizeBits);
11063 lines.push(new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, "lower"]));
11064 prefixLength = reader.readBits(prefixSizeBits);
11065 lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
11066
11067 if (flags & 1) {
11068 prefixLength = reader.readBits(prefixSizeBits);
11069 lines.push(new HuffmanLine([prefixLength, 0]));
11070 }
11071
11072 return new HuffmanTable(lines, false);
11073 }
11074
11075 const standardTablesCache = {};
11076
11077 function getStandardTable(number) {
11078 let table = standardTablesCache[number];
11079
11080 if (table) {
11081 return table;
11082 }
11083
11084 let lines;
11085
11086 switch (number) {
11087 case 1:
11088 lines = [[0, 1, 4, 0x0], [16, 2, 8, 0x2], [272, 3, 16, 0x6], [65808, 3, 32, 0x7]];
11089 break;
11090
11091 case 2:
11092 lines = [[0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xe], [11, 5, 6, 0x1e], [75, 6, 32, 0x3e], [6, 0x3f]];
11093 break;
11094
11095 case 3:
11096 lines = [[-256, 8, 8, 0xfe], [0, 1, 0, 0x0], [1, 2, 0, 0x2], [2, 3, 0, 0x6], [3, 4, 3, 0xe], [11, 5, 6, 0x1e], [-257, 8, 32, 0xff, "lower"], [75, 7, 32, 0x7e], [6, 0x3e]];
11097 break;
11098
11099 case 4:
11100 lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xe], [12, 5, 6, 0x1e], [76, 5, 32, 0x1f]];
11101 break;
11102
11103 case 5:
11104 lines = [[-255, 7, 8, 0x7e], [1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 0, 0x6], [4, 4, 3, 0xe], [12, 5, 6, 0x1e], [-256, 7, 32, 0x7f, "lower"], [76, 6, 32, 0x3e]];
11105 break;
11106
11107 case 6:
11108 lines = [[-2048, 5, 10, 0x1c], [-1024, 4, 9, 0x8], [-512, 4, 8, 0x9], [-256, 4, 7, 0xa], [-128, 5, 6, 0x1d], [-64, 5, 5, 0x1e], [-32, 4, 5, 0xb], [0, 2, 7, 0x0], [128, 3, 7, 0x2], [256, 3, 8, 0x3], [512, 4, 9, 0xc], [1024, 4, 10, 0xd], [-2049, 6, 32, 0x3e, "lower"], [2048, 6, 32, 0x3f]];
11109 break;
11110
11111 case 7:
11112 lines = [[-1024, 4, 9, 0x8], [-512, 3, 8, 0x0], [-256, 4, 7, 0x9], [-128, 5, 6, 0x1a], [-64, 5, 5, 0x1b], [-32, 4, 5, 0xa], [0, 4, 5, 0xb], [32, 5, 5, 0x1c], [64, 5, 6, 0x1d], [128, 4, 7, 0xc], [256, 3, 8, 0x1], [512, 3, 9, 0x2], [1024, 3, 10, 0x3], [-1025, 5, 32, 0x1e, "lower"], [2048, 5, 32, 0x1f]];
11113 break;
11114
11115 case 8:
11116 lines = [[-15, 8, 3, 0xfc], [-7, 9, 1, 0x1fc], [-5, 8, 1, 0xfd], [-3, 9, 0, 0x1fd], [-2, 7, 0, 0x7c], [-1, 4, 0, 0xa], [0, 2, 1, 0x0], [2, 5, 0, 0x1a], [3, 6, 0, 0x3a], [4, 3, 4, 0x4], [20, 6, 1, 0x3b], [22, 4, 4, 0xb], [38, 4, 5, 0xc], [70, 5, 6, 0x1b], [134, 5, 7, 0x1c], [262, 6, 7, 0x3c], [390, 7, 8, 0x7d], [646, 6, 10, 0x3d], [-16, 9, 32, 0x1fe, "lower"], [1670, 9, 32, 0x1ff], [2, 0x1]];
11117 break;
11118
11119 case 9:
11120 lines = [[-31, 8, 4, 0xfc], [-15, 9, 2, 0x1fc], [-11, 8, 2, 0xfd], [-7, 9, 1, 0x1fd], [-5, 7, 1, 0x7c], [-3, 4, 1, 0xa], [-1, 3, 1, 0x2], [1, 3, 1, 0x3], [3, 5, 1, 0x1a], [5, 6, 1, 0x3a], [7, 3, 5, 0x4], [39, 6, 2, 0x3b], [43, 4, 5, 0xb], [75, 4, 6, 0xc], [139, 5, 7, 0x1b], [267, 5, 8, 0x1c], [523, 6, 8, 0x3c], [779, 7, 9, 0x7d], [1291, 6, 11, 0x3d], [-32, 9, 32, 0x1fe, "lower"], [3339, 9, 32, 0x1ff], [2, 0x0]];
11121 break;
11122
11123 case 10:
11124 lines = [[-21, 7, 4, 0x7a], [-5, 8, 0, 0xfc], [-4, 7, 0, 0x7b], [-3, 5, 0, 0x18], [-2, 2, 2, 0x0], [2, 5, 0, 0x19], [3, 6, 0, 0x36], [4, 7, 0, 0x7c], [5, 8, 0, 0xfd], [6, 2, 6, 0x1], [70, 5, 5, 0x1a], [102, 6, 5, 0x37], [134, 6, 6, 0x38], [198, 6, 7, 0x39], [326, 6, 8, 0x3a], [582, 6, 9, 0x3b], [1094, 6, 10, 0x3c], [2118, 7, 11, 0x7d], [-22, 8, 32, 0xfe, "lower"], [4166, 8, 32, 0xff], [2, 0x2]];
11125 break;
11126
11127 case 11:
11128 lines = [[1, 1, 0, 0x0], [2, 2, 1, 0x2], [4, 4, 0, 0xc], [5, 4, 1, 0xd], [7, 5, 1, 0x1c], [9, 5, 2, 0x1d], [13, 6, 2, 0x3c], [17, 7, 2, 0x7a], [21, 7, 3, 0x7b], [29, 7, 4, 0x7c], [45, 7, 5, 0x7d], [77, 7, 6, 0x7e], [141, 7, 32, 0x7f]];
11129 break;
11130
11131 case 12:
11132 lines = [[1, 1, 0, 0x0], [2, 2, 0, 0x2], [3, 3, 1, 0x6], [5, 5, 0, 0x1c], [6, 5, 1, 0x1d], [8, 6, 1, 0x3c], [10, 7, 0, 0x7a], [11, 7, 1, 0x7b], [13, 7, 2, 0x7c], [17, 7, 3, 0x7d], [25, 7, 4, 0x7e], [41, 8, 5, 0xfe], [73, 8, 32, 0xff]];
11133 break;
11134
11135 case 13:
11136 lines = [[1, 1, 0, 0x0], [2, 3, 0, 0x4], [3, 4, 0, 0xc], [4, 5, 0, 0x1c], [5, 4, 1, 0xd], [7, 3, 3, 0x5], [15, 6, 1, 0x3a], [17, 6, 2, 0x3b], [21, 6, 3, 0x3c], [29, 6, 4, 0x3d], [45, 6, 5, 0x3e], [77, 7, 6, 0x7e], [141, 7, 32, 0x7f]];
11137 break;
11138
11139 case 14:
11140 lines = [[-2, 3, 0, 0x4], [-1, 3, 0, 0x5], [0, 1, 0, 0x0], [1, 3, 0, 0x6], [2, 3, 0, 0x7]];
11141 break;
11142
11143 case 15:
11144 lines = [[-24, 7, 4, 0x7c], [-8, 6, 2, 0x3c], [-4, 5, 1, 0x1c], [-2, 4, 0, 0xc], [-1, 3, 0, 0x4], [0, 1, 0, 0x0], [1, 3, 0, 0x5], [2, 4, 0, 0xd], [3, 5, 1, 0x1d], [5, 6, 2, 0x3d], [9, 7, 4, 0x7d], [-25, 7, 32, 0x7e, "lower"], [25, 7, 32, 0x7f]];
11145 break;
11146
11147 default:
11148 throw new Jbig2Error(`standard table B.${number} does not exist`);
11149 }
11150
11151 for (let i = 0, ii = lines.length; i < ii; i++) {
11152 lines[i] = new HuffmanLine(lines[i]);
11153 }
11154
11155 table = new HuffmanTable(lines, true);
11156 standardTablesCache[number] = table;
11157 return table;
11158 }
11159
11160 function Reader(data, start, end) {
11161 this.data = data;
11162 this.start = start;
11163 this.end = end;
11164 this.position = start;
11165 this.shift = -1;
11166 this.currentByte = 0;
11167 }
11168
11169 Reader.prototype = {
11170 readBit() {
11171 if (this.shift < 0) {
11172 if (this.position >= this.end) {
11173 throw new Jbig2Error("end of data while reading bit");
11174 }
11175
11176 this.currentByte = this.data[this.position++];
11177 this.shift = 7;
11178 }
11179
11180 const bit = this.currentByte >> this.shift & 1;
11181 this.shift--;
11182 return bit;
11183 },
11184
11185 readBits(numBits) {
11186 let result = 0,
11187 i;
11188
11189 for (i = numBits - 1; i >= 0; i--) {
11190 result |= this.readBit() << i;
11191 }
11192
11193 return result;
11194 },
11195
11196 byteAlign() {
11197 this.shift = -1;
11198 },
11199
11200 next() {
11201 if (this.position >= this.end) {
11202 return -1;
11203 }
11204
11205 return this.data[this.position++];
11206 }
11207
11208 };
11209
11210 function getCustomHuffmanTable(index, referredTo, customTables) {
11211 let currentIndex = 0;
11212
11213 for (let i = 0, ii = referredTo.length; i < ii; i++) {
11214 const table = customTables[referredTo[i]];
11215
11216 if (table) {
11217 if (index === currentIndex) {
11218 return table;
11219 }
11220
11221 currentIndex++;
11222 }
11223 }
11224
11225 throw new Jbig2Error("can't find custom Huffman table");
11226 }
11227
11228 function getTextRegionHuffmanTables(textRegion, referredTo, customTables, numberOfSymbols, reader) {
11229 const codes = [];
11230
11231 for (let i = 0; i <= 34; i++) {
11232 const codeLength = reader.readBits(4);
11233 codes.push(new HuffmanLine([i, codeLength, 0, 0]));
11234 }
11235
11236 const runCodesTable = new HuffmanTable(codes, false);
11237 codes.length = 0;
11238
11239 for (let i = 0; i < numberOfSymbols;) {
11240 const codeLength = runCodesTable.decode(reader);
11241
11242 if (codeLength >= 32) {
11243 let repeatedLength, numberOfRepeats, j;
11244
11245 switch (codeLength) {
11246 case 32:
11247 if (i === 0) {
11248 throw new Jbig2Error("no previous value in symbol ID table");
11249 }
11250
11251 numberOfRepeats = reader.readBits(2) + 3;
11252 repeatedLength = codes[i - 1].prefixLength;
11253 break;
11254
11255 case 33:
11256 numberOfRepeats = reader.readBits(3) + 3;
11257 repeatedLength = 0;
11258 break;
11259
11260 case 34:
11261 numberOfRepeats = reader.readBits(7) + 11;
11262 repeatedLength = 0;
11263 break;
11264
11265 default:
11266 throw new Jbig2Error("invalid code length in symbol ID table");
11267 }
11268
11269 for (j = 0; j < numberOfRepeats; j++) {
11270 codes.push(new HuffmanLine([i, repeatedLength, 0, 0]));
11271 i++;
11272 }
11273 } else {
11274 codes.push(new HuffmanLine([i, codeLength, 0, 0]));
11275 i++;
11276 }
11277 }
11278
11279 reader.byteAlign();
11280 const symbolIDTable = new HuffmanTable(codes, false);
11281 let customIndex = 0,
11282 tableFirstS,
11283 tableDeltaS,
11284 tableDeltaT;
11285
11286 switch (textRegion.huffmanFS) {
11287 case 0:
11288 case 1:
11289 tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
11290 break;
11291
11292 case 3:
11293 tableFirstS = getCustomHuffmanTable(customIndex, referredTo, customTables);
11294 customIndex++;
11295 break;
11296
11297 default:
11298 throw new Jbig2Error("invalid Huffman FS selector");
11299 }
11300
11301 switch (textRegion.huffmanDS) {
11302 case 0:
11303 case 1:
11304 case 2:
11305 tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
11306 break;
11307
11308 case 3:
11309 tableDeltaS = getCustomHuffmanTable(customIndex, referredTo, customTables);
11310 customIndex++;
11311 break;
11312
11313 default:
11314 throw new Jbig2Error("invalid Huffman DS selector");
11315 }
11316
11317 switch (textRegion.huffmanDT) {
11318 case 0:
11319 case 1:
11320 case 2:
11321 tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
11322 break;
11323
11324 case 3:
11325 tableDeltaT = getCustomHuffmanTable(customIndex, referredTo, customTables);
11326 customIndex++;
11327 break;
11328
11329 default:
11330 throw new Jbig2Error("invalid Huffman DT selector");
11331 }
11332
11333 if (textRegion.refinement) {
11334 throw new Jbig2Error("refinement with Huffman is not supported");
11335 }
11336
11337 return {
11338 symbolIDTable,
11339 tableFirstS,
11340 tableDeltaS,
11341 tableDeltaT
11342 };
11343 }
11344
11345 function getSymbolDictionaryHuffmanTables(dictionary, referredTo, customTables) {
11346 let customIndex = 0,
11347 tableDeltaHeight,
11348 tableDeltaWidth;
11349
11350 switch (dictionary.huffmanDHSelector) {
11351 case 0:
11352 case 1:
11353 tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
11354 break;
11355
11356 case 3:
11357 tableDeltaHeight = getCustomHuffmanTable(customIndex, referredTo, customTables);
11358 customIndex++;
11359 break;
11360
11361 default:
11362 throw new Jbig2Error("invalid Huffman DH selector");
11363 }
11364
11365 switch (dictionary.huffmanDWSelector) {
11366 case 0:
11367 case 1:
11368 tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
11369 break;
11370
11371 case 3:
11372 tableDeltaWidth = getCustomHuffmanTable(customIndex, referredTo, customTables);
11373 customIndex++;
11374 break;
11375
11376 default:
11377 throw new Jbig2Error("invalid Huffman DW selector");
11378 }
11379
11380 let tableBitmapSize, tableAggregateInstances;
11381
11382 if (dictionary.bitmapSizeSelector) {
11383 tableBitmapSize = getCustomHuffmanTable(customIndex, referredTo, customTables);
11384 customIndex++;
11385 } else {
11386 tableBitmapSize = getStandardTable(1);
11387 }
11388
11389 if (dictionary.aggregationInstancesSelector) {
11390 tableAggregateInstances = getCustomHuffmanTable(customIndex, referredTo, customTables);
11391 } else {
11392 tableAggregateInstances = getStandardTable(1);
11393 }
11394
11395 return {
11396 tableDeltaHeight,
11397 tableDeltaWidth,
11398 tableBitmapSize,
11399 tableAggregateInstances
11400 };
11401 }
11402
11403 function readUncompressedBitmap(reader, width, height) {
11404 const bitmap = [];
11405
11406 for (let y = 0; y < height; y++) {
11407 const row = new Uint8Array(width);
11408 bitmap.push(row);
11409
11410 for (let x = 0; x < width; x++) {
11411 row[x] = reader.readBit();
11412 }
11413
11414 reader.byteAlign();
11415 }
11416
11417 return bitmap;
11418 }
11419
11420 function decodeMMRBitmap(input, width, height, endOfBlock) {
11421 const params = {
11422 K: -1,
11423 Columns: width,
11424 Rows: height,
11425 BlackIs1: true,
11426 EndOfBlock: endOfBlock
11427 };
11428 const decoder = new _ccitt.CCITTFaxDecoder(input, params);
11429 const bitmap = [];
11430 let currentByte,
11431 eof = false;
11432
11433 for (let y = 0; y < height; y++) {
11434 const row = new Uint8Array(width);
11435 bitmap.push(row);
11436 let shift = -1;
11437
11438 for (let x = 0; x < width; x++) {
11439 if (shift < 0) {
11440 currentByte = decoder.readNextChar();
11441
11442 if (currentByte === -1) {
11443 currentByte = 0;
11444 eof = true;
11445 }
11446
11447 shift = 7;
11448 }
11449
11450 row[x] = currentByte >> shift & 1;
11451 shift--;
11452 }
11453 }
11454
11455 if (endOfBlock && !eof) {
11456 const lookForEOFLimit = 5;
11457
11458 for (let i = 0; i < lookForEOFLimit; i++) {
11459 if (decoder.readNextChar() === -1) {
11460 break;
11461 }
11462 }
11463 }
11464
11465 return bitmap;
11466 }
11467
11468 function Jbig2Image() {}
11469
11470 Jbig2Image.prototype = {
11471 parseChunks(chunks) {
11472 return parseJbig2Chunks(chunks);
11473 },
11474
11475 parse(data) {
11476 const {
11477 imgData,
11478 width,
11479 height
11480 } = parseJbig2(data);
11481 this.width = width;
11482 this.height = height;
11483 return imgData;
11484 }
11485
11486 };
11487 return Jbig2Image;
11488}();
11489
11490exports.Jbig2Image = Jbig2Image;
11491
11492/***/ }),
11493/* 17 */
11494/***/ (function(module, exports, __w_pdfjs_require__) {
11495
11496"use strict";
11497
11498
11499Object.defineProperty(exports, "__esModule", {
11500 value: true
11501});
11502exports.ArithmeticDecoder = void 0;
11503const QeTable = [{
11504 qe: 0x5601,
11505 nmps: 1,
11506 nlps: 1,
11507 switchFlag: 1
11508}, {
11509 qe: 0x3401,
11510 nmps: 2,
11511 nlps: 6,
11512 switchFlag: 0
11513}, {
11514 qe: 0x1801,
11515 nmps: 3,
11516 nlps: 9,
11517 switchFlag: 0
11518}, {
11519 qe: 0x0ac1,
11520 nmps: 4,
11521 nlps: 12,
11522 switchFlag: 0
11523}, {
11524 qe: 0x0521,
11525 nmps: 5,
11526 nlps: 29,
11527 switchFlag: 0
11528}, {
11529 qe: 0x0221,
11530 nmps: 38,
11531 nlps: 33,
11532 switchFlag: 0
11533}, {
11534 qe: 0x5601,
11535 nmps: 7,
11536 nlps: 6,
11537 switchFlag: 1
11538}, {
11539 qe: 0x5401,
11540 nmps: 8,
11541 nlps: 14,
11542 switchFlag: 0
11543}, {
11544 qe: 0x4801,
11545 nmps: 9,
11546 nlps: 14,
11547 switchFlag: 0
11548}, {
11549 qe: 0x3801,
11550 nmps: 10,
11551 nlps: 14,
11552 switchFlag: 0
11553}, {
11554 qe: 0x3001,
11555 nmps: 11,
11556 nlps: 17,
11557 switchFlag: 0
11558}, {
11559 qe: 0x2401,
11560 nmps: 12,
11561 nlps: 18,
11562 switchFlag: 0
11563}, {
11564 qe: 0x1c01,
11565 nmps: 13,
11566 nlps: 20,
11567 switchFlag: 0
11568}, {
11569 qe: 0x1601,
11570 nmps: 29,
11571 nlps: 21,
11572 switchFlag: 0
11573}, {
11574 qe: 0x5601,
11575 nmps: 15,
11576 nlps: 14,
11577 switchFlag: 1
11578}, {
11579 qe: 0x5401,
11580 nmps: 16,
11581 nlps: 14,
11582 switchFlag: 0
11583}, {
11584 qe: 0x5101,
11585 nmps: 17,
11586 nlps: 15,
11587 switchFlag: 0
11588}, {
11589 qe: 0x4801,
11590 nmps: 18,
11591 nlps: 16,
11592 switchFlag: 0
11593}, {
11594 qe: 0x3801,
11595 nmps: 19,
11596 nlps: 17,
11597 switchFlag: 0
11598}, {
11599 qe: 0x3401,
11600 nmps: 20,
11601 nlps: 18,
11602 switchFlag: 0
11603}, {
11604 qe: 0x3001,
11605 nmps: 21,
11606 nlps: 19,
11607 switchFlag: 0
11608}, {
11609 qe: 0x2801,
11610 nmps: 22,
11611 nlps: 19,
11612 switchFlag: 0
11613}, {
11614 qe: 0x2401,
11615 nmps: 23,
11616 nlps: 20,
11617 switchFlag: 0
11618}, {
11619 qe: 0x2201,
11620 nmps: 24,
11621 nlps: 21,
11622 switchFlag: 0
11623}, {
11624 qe: 0x1c01,
11625 nmps: 25,
11626 nlps: 22,
11627 switchFlag: 0
11628}, {
11629 qe: 0x1801,
11630 nmps: 26,
11631 nlps: 23,
11632 switchFlag: 0
11633}, {
11634 qe: 0x1601,
11635 nmps: 27,
11636 nlps: 24,
11637 switchFlag: 0
11638}, {
11639 qe: 0x1401,
11640 nmps: 28,
11641 nlps: 25,
11642 switchFlag: 0
11643}, {
11644 qe: 0x1201,
11645 nmps: 29,
11646 nlps: 26,
11647 switchFlag: 0
11648}, {
11649 qe: 0x1101,
11650 nmps: 30,
11651 nlps: 27,
11652 switchFlag: 0
11653}, {
11654 qe: 0x0ac1,
11655 nmps: 31,
11656 nlps: 28,
11657 switchFlag: 0
11658}, {
11659 qe: 0x09c1,
11660 nmps: 32,
11661 nlps: 29,
11662 switchFlag: 0
11663}, {
11664 qe: 0x08a1,
11665 nmps: 33,
11666 nlps: 30,
11667 switchFlag: 0
11668}, {
11669 qe: 0x0521,
11670 nmps: 34,
11671 nlps: 31,
11672 switchFlag: 0
11673}, {
11674 qe: 0x0441,
11675 nmps: 35,
11676 nlps: 32,
11677 switchFlag: 0
11678}, {
11679 qe: 0x02a1,
11680 nmps: 36,
11681 nlps: 33,
11682 switchFlag: 0
11683}, {
11684 qe: 0x0221,
11685 nmps: 37,
11686 nlps: 34,
11687 switchFlag: 0
11688}, {
11689 qe: 0x0141,
11690 nmps: 38,
11691 nlps: 35,
11692 switchFlag: 0
11693}, {
11694 qe: 0x0111,
11695 nmps: 39,
11696 nlps: 36,
11697 switchFlag: 0
11698}, {
11699 qe: 0x0085,
11700 nmps: 40,
11701 nlps: 37,
11702 switchFlag: 0
11703}, {
11704 qe: 0x0049,
11705 nmps: 41,
11706 nlps: 38,
11707 switchFlag: 0
11708}, {
11709 qe: 0x0025,
11710 nmps: 42,
11711 nlps: 39,
11712 switchFlag: 0
11713}, {
11714 qe: 0x0015,
11715 nmps: 43,
11716 nlps: 40,
11717 switchFlag: 0
11718}, {
11719 qe: 0x0009,
11720 nmps: 44,
11721 nlps: 41,
11722 switchFlag: 0
11723}, {
11724 qe: 0x0005,
11725 nmps: 45,
11726 nlps: 42,
11727 switchFlag: 0
11728}, {
11729 qe: 0x0001,
11730 nmps: 45,
11731 nlps: 43,
11732 switchFlag: 0
11733}, {
11734 qe: 0x5601,
11735 nmps: 46,
11736 nlps: 46,
11737 switchFlag: 0
11738}];
11739
11740class ArithmeticDecoder {
11741 constructor(data, start, end) {
11742 this.data = data;
11743 this.bp = start;
11744 this.dataEnd = end;
11745 this.chigh = data[start];
11746 this.clow = 0;
11747 this.byteIn();
11748 this.chigh = this.chigh << 7 & 0xffff | this.clow >> 9 & 0x7f;
11749 this.clow = this.clow << 7 & 0xffff;
11750 this.ct -= 7;
11751 this.a = 0x8000;
11752 }
11753
11754 byteIn() {
11755 const data = this.data;
11756 let bp = this.bp;
11757
11758 if (data[bp] === 0xff) {
11759 if (data[bp + 1] > 0x8f) {
11760 this.clow += 0xff00;
11761 this.ct = 8;
11762 } else {
11763 bp++;
11764 this.clow += data[bp] << 9;
11765 this.ct = 7;
11766 this.bp = bp;
11767 }
11768 } else {
11769 bp++;
11770 this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
11771 this.ct = 8;
11772 this.bp = bp;
11773 }
11774
11775 if (this.clow > 0xffff) {
11776 this.chigh += this.clow >> 16;
11777 this.clow &= 0xffff;
11778 }
11779 }
11780
11781 readBit(contexts, pos) {
11782 let cx_index = contexts[pos] >> 1,
11783 cx_mps = contexts[pos] & 1;
11784 const qeTableIcx = QeTable[cx_index];
11785 const qeIcx = qeTableIcx.qe;
11786 let d;
11787 let a = this.a - qeIcx;
11788
11789 if (this.chigh < qeIcx) {
11790 if (a < qeIcx) {
11791 a = qeIcx;
11792 d = cx_mps;
11793 cx_index = qeTableIcx.nmps;
11794 } else {
11795 a = qeIcx;
11796 d = 1 ^ cx_mps;
11797
11798 if (qeTableIcx.switchFlag === 1) {
11799 cx_mps = d;
11800 }
11801
11802 cx_index = qeTableIcx.nlps;
11803 }
11804 } else {
11805 this.chigh -= qeIcx;
11806
11807 if ((a & 0x8000) !== 0) {
11808 this.a = a;
11809 return cx_mps;
11810 }
11811
11812 if (a < qeIcx) {
11813 d = 1 ^ cx_mps;
11814
11815 if (qeTableIcx.switchFlag === 1) {
11816 cx_mps = d;
11817 }
11818
11819 cx_index = qeTableIcx.nlps;
11820 } else {
11821 d = cx_mps;
11822 cx_index = qeTableIcx.nmps;
11823 }
11824 }
11825
11826 do {
11827 if (this.ct === 0) {
11828 this.byteIn();
11829 }
11830
11831 a <<= 1;
11832 this.chigh = this.chigh << 1 & 0xffff | this.clow >> 15 & 1;
11833 this.clow = this.clow << 1 & 0xffff;
11834 this.ct--;
11835 } while ((a & 0x8000) === 0);
11836
11837 this.a = a;
11838 contexts[pos] = cx_index << 1 | cx_mps;
11839 return d;
11840 }
11841
11842}
11843
11844exports.ArithmeticDecoder = ArithmeticDecoder;
11845
11846/***/ }),
11847/* 18 */
11848/***/ (function(module, exports, __w_pdfjs_require__) {
11849
11850"use strict";
11851
11852
11853Object.defineProperty(exports, "__esModule", {
11854 value: true
11855});
11856exports.JpegStream = void 0;
11857
11858var _stream = __w_pdfjs_require__(12);
11859
11860var _primitives = __w_pdfjs_require__(5);
11861
11862var _jpg = __w_pdfjs_require__(19);
11863
11864var _util = __w_pdfjs_require__(2);
11865
11866const JpegStream = function JpegStreamClosure() {
11867 function JpegStream(stream, maybeLength, dict, params) {
11868 let ch;
11869
11870 while ((ch = stream.getByte()) !== -1) {
11871 if (ch === 0xff) {
11872 stream.skip(-1);
11873 break;
11874 }
11875 }
11876
11877 this.stream = stream;
11878 this.maybeLength = maybeLength;
11879 this.dict = dict;
11880 this.params = params;
11881
11882 _stream.DecodeStream.call(this, maybeLength);
11883 }
11884
11885 JpegStream.prototype = Object.create(_stream.DecodeStream.prototype);
11886 Object.defineProperty(JpegStream.prototype, "bytes", {
11887 get: function JpegStream_bytes() {
11888 return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
11889 },
11890 configurable: true
11891 });
11892
11893 JpegStream.prototype.ensureBuffer = function (requested) {};
11894
11895 JpegStream.prototype.readBlock = function () {
11896 if (this.eof) {
11897 return;
11898 }
11899
11900 const jpegOptions = {
11901 decodeTransform: undefined,
11902 colorTransform: undefined
11903 };
11904 const decodeArr = this.dict.getArray("Decode", "D");
11905
11906 if (this.forceRGB && Array.isArray(decodeArr)) {
11907 const bitsPerComponent = this.dict.get("BitsPerComponent") || 8;
11908 const decodeArrLength = decodeArr.length;
11909 const transform = new Int32Array(decodeArrLength);
11910 let transformNeeded = false;
11911 const maxValue = (1 << bitsPerComponent) - 1;
11912
11913 for (let i = 0; i < decodeArrLength; i += 2) {
11914 transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
11915 transform[i + 1] = decodeArr[i] * maxValue | 0;
11916
11917 if (transform[i] !== 256 || transform[i + 1] !== 0) {
11918 transformNeeded = true;
11919 }
11920 }
11921
11922 if (transformNeeded) {
11923 jpegOptions.decodeTransform = transform;
11924 }
11925 }
11926
11927 if ((0, _primitives.isDict)(this.params)) {
11928 const colorTransform = this.params.get("ColorTransform");
11929
11930 if (Number.isInteger(colorTransform)) {
11931 jpegOptions.colorTransform = colorTransform;
11932 }
11933 }
11934
11935 const jpegImage = new _jpg.JpegImage(jpegOptions);
11936 jpegImage.parse(this.bytes);
11937 const data = jpegImage.getData({
11938 width: this.drawWidth,
11939 height: this.drawHeight,
11940 forceRGB: this.forceRGB,
11941 isSourcePDF: true
11942 });
11943 this.buffer = data;
11944 this.bufferLength = data.length;
11945 this.eof = true;
11946 };
11947
11948 return JpegStream;
11949}();
11950
11951exports.JpegStream = JpegStream;
11952
11953/***/ }),
11954/* 19 */
11955/***/ (function(module, exports, __w_pdfjs_require__) {
11956
11957"use strict";
11958
11959
11960Object.defineProperty(exports, "__esModule", {
11961 value: true
11962});
11963exports.JpegImage = void 0;
11964
11965var _util = __w_pdfjs_require__(2);
11966
11967var _core_utils = __w_pdfjs_require__(8);
11968
11969class JpegError extends _util.BaseException {
11970 constructor(msg) {
11971 super(`JPEG error: ${msg}`);
11972 }
11973
11974}
11975
11976class DNLMarkerError extends _util.BaseException {
11977 constructor(message, scanLines) {
11978 super(message);
11979 this.scanLines = scanLines;
11980 }
11981
11982}
11983
11984class EOIMarkerError extends _util.BaseException {}
11985
11986var JpegImage = function JpegImageClosure() {
11987 var dctZigZag = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]);
11988 var dctCos1 = 4017;
11989 var dctSin1 = 799;
11990 var dctCos3 = 3406;
11991 var dctSin3 = 2276;
11992 var dctCos6 = 1567;
11993 var dctSin6 = 3784;
11994 var dctSqrt2 = 5793;
11995 var dctSqrt1d2 = 2896;
11996
11997 function JpegImage({
11998 decodeTransform = null,
11999 colorTransform = -1
12000 } = {}) {
12001 this._decodeTransform = decodeTransform;
12002 this._colorTransform = colorTransform;
12003 }
12004
12005 function buildHuffmanTable(codeLengths, values) {
12006 var k = 0,
12007 code = [],
12008 i,
12009 j,
12010 length = 16;
12011
12012 while (length > 0 && !codeLengths[length - 1]) {
12013 length--;
12014 }
12015
12016 code.push({
12017 children: [],
12018 index: 0
12019 });
12020 var p = code[0],
12021 q;
12022
12023 for (i = 0; i < length; i++) {
12024 for (j = 0; j < codeLengths[i]; j++) {
12025 p = code.pop();
12026 p.children[p.index] = values[k];
12027
12028 while (p.index > 0) {
12029 p = code.pop();
12030 }
12031
12032 p.index++;
12033 code.push(p);
12034
12035 while (code.length <= i) {
12036 code.push(q = {
12037 children: [],
12038 index: 0
12039 });
12040 p.children[p.index] = q.children;
12041 p = q;
12042 }
12043
12044 k++;
12045 }
12046
12047 if (i + 1 < length) {
12048 code.push(q = {
12049 children: [],
12050 index: 0
12051 });
12052 p.children[p.index] = q.children;
12053 p = q;
12054 }
12055 }
12056
12057 return code[0].children;
12058 }
12059
12060 function getBlockBufferOffset(component, row, col) {
12061 return 64 * ((component.blocksPerLine + 1) * row + col);
12062 }
12063
12064 function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive, parseDNLMarker = false) {
12065 var mcusPerLine = frame.mcusPerLine;
12066 var progressive = frame.progressive;
12067 const startOffset = offset;
12068 let bitsData = 0,
12069 bitsCount = 0;
12070
12071 function readBit() {
12072 if (bitsCount > 0) {
12073 bitsCount--;
12074 return bitsData >> bitsCount & 1;
12075 }
12076
12077 bitsData = data[offset++];
12078
12079 if (bitsData === 0xff) {
12080 var nextByte = data[offset++];
12081
12082 if (nextByte) {
12083 if (nextByte === 0xdc && parseDNLMarker) {
12084 offset += 2;
12085 const scanLines = (0, _core_utils.readUint16)(data, offset);
12086 offset += 2;
12087
12088 if (scanLines > 0 && scanLines !== frame.scanLines) {
12089 throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", scanLines);
12090 }
12091 } else if (nextByte === 0xd9) {
12092 if (parseDNLMarker) {
12093 const maybeScanLines = blockRow * 8;
12094
12095 if (maybeScanLines > 0 && maybeScanLines < frame.scanLines / 10) {
12096 throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, " + "possibly caused by incorrect `scanLines` parameter", maybeScanLines);
12097 }
12098 }
12099
12100 throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data");
12101 }
12102
12103 throw new JpegError(`unexpected marker ${(bitsData << 8 | nextByte).toString(16)}`);
12104 }
12105 }
12106
12107 bitsCount = 7;
12108 return bitsData >>> 7;
12109 }
12110
12111 function decodeHuffman(tree) {
12112 var node = tree;
12113
12114 while (true) {
12115 node = node[readBit()];
12116
12117 switch (typeof node) {
12118 case "number":
12119 return node;
12120
12121 case "object":
12122 continue;
12123 }
12124
12125 throw new JpegError("invalid huffman sequence");
12126 }
12127 }
12128
12129 function receive(length) {
12130 var n = 0;
12131
12132 while (length > 0) {
12133 n = n << 1 | readBit();
12134 length--;
12135 }
12136
12137 return n;
12138 }
12139
12140 function receiveAndExtend(length) {
12141 if (length === 1) {
12142 return readBit() === 1 ? 1 : -1;
12143 }
12144
12145 var n = receive(length);
12146
12147 if (n >= 1 << length - 1) {
12148 return n;
12149 }
12150
12151 return n + (-1 << length) + 1;
12152 }
12153
12154 function decodeBaseline(component, blockOffset) {
12155 var t = decodeHuffman(component.huffmanTableDC);
12156 var diff = t === 0 ? 0 : receiveAndExtend(t);
12157 component.blockData[blockOffset] = component.pred += diff;
12158 var k = 1;
12159
12160 while (k < 64) {
12161 var rs = decodeHuffman(component.huffmanTableAC);
12162 var s = rs & 15,
12163 r = rs >> 4;
12164
12165 if (s === 0) {
12166 if (r < 15) {
12167 break;
12168 }
12169
12170 k += 16;
12171 continue;
12172 }
12173
12174 k += r;
12175 var z = dctZigZag[k];
12176 component.blockData[blockOffset + z] = receiveAndExtend(s);
12177 k++;
12178 }
12179 }
12180
12181 function decodeDCFirst(component, blockOffset) {
12182 var t = decodeHuffman(component.huffmanTableDC);
12183 var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
12184 component.blockData[blockOffset] = component.pred += diff;
12185 }
12186
12187 function decodeDCSuccessive(component, blockOffset) {
12188 component.blockData[blockOffset] |= readBit() << successive;
12189 }
12190
12191 var eobrun = 0;
12192
12193 function decodeACFirst(component, blockOffset) {
12194 if (eobrun > 0) {
12195 eobrun--;
12196 return;
12197 }
12198
12199 var k = spectralStart,
12200 e = spectralEnd;
12201
12202 while (k <= e) {
12203 var rs = decodeHuffman(component.huffmanTableAC);
12204 var s = rs & 15,
12205 r = rs >> 4;
12206
12207 if (s === 0) {
12208 if (r < 15) {
12209 eobrun = receive(r) + (1 << r) - 1;
12210 break;
12211 }
12212
12213 k += 16;
12214 continue;
12215 }
12216
12217 k += r;
12218 var z = dctZigZag[k];
12219 component.blockData[blockOffset + z] = receiveAndExtend(s) * (1 << successive);
12220 k++;
12221 }
12222 }
12223
12224 var successiveACState = 0,
12225 successiveACNextValue;
12226
12227 function decodeACSuccessive(component, blockOffset) {
12228 var k = spectralStart;
12229 var e = spectralEnd;
12230 var r = 0;
12231 var s;
12232 var rs;
12233
12234 while (k <= e) {
12235 const offsetZ = blockOffset + dctZigZag[k];
12236 const sign = component.blockData[offsetZ] < 0 ? -1 : 1;
12237
12238 switch (successiveACState) {
12239 case 0:
12240 rs = decodeHuffman(component.huffmanTableAC);
12241 s = rs & 15;
12242 r = rs >> 4;
12243
12244 if (s === 0) {
12245 if (r < 15) {
12246 eobrun = receive(r) + (1 << r);
12247 successiveACState = 4;
12248 } else {
12249 r = 16;
12250 successiveACState = 1;
12251 }
12252 } else {
12253 if (s !== 1) {
12254 throw new JpegError("invalid ACn encoding");
12255 }
12256
12257 successiveACNextValue = receiveAndExtend(s);
12258 successiveACState = r ? 2 : 3;
12259 }
12260
12261 continue;
12262
12263 case 1:
12264 case 2:
12265 if (component.blockData[offsetZ]) {
12266 component.blockData[offsetZ] += sign * (readBit() << successive);
12267 } else {
12268 r--;
12269
12270 if (r === 0) {
12271 successiveACState = successiveACState === 2 ? 3 : 0;
12272 }
12273 }
12274
12275 break;
12276
12277 case 3:
12278 if (component.blockData[offsetZ]) {
12279 component.blockData[offsetZ] += sign * (readBit() << successive);
12280 } else {
12281 component.blockData[offsetZ] = successiveACNextValue << successive;
12282 successiveACState = 0;
12283 }
12284
12285 break;
12286
12287 case 4:
12288 if (component.blockData[offsetZ]) {
12289 component.blockData[offsetZ] += sign * (readBit() << successive);
12290 }
12291
12292 break;
12293 }
12294
12295 k++;
12296 }
12297
12298 if (successiveACState === 4) {
12299 eobrun--;
12300
12301 if (eobrun === 0) {
12302 successiveACState = 0;
12303 }
12304 }
12305 }
12306
12307 let blockRow = 0;
12308
12309 function decodeMcu(component, decode, mcu, row, col) {
12310 var mcuRow = mcu / mcusPerLine | 0;
12311 var mcuCol = mcu % mcusPerLine;
12312 blockRow = mcuRow * component.v + row;
12313 var blockCol = mcuCol * component.h + col;
12314 const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
12315 decode(component, blockOffset);
12316 }
12317
12318 function decodeBlock(component, decode, mcu) {
12319 blockRow = mcu / component.blocksPerLine | 0;
12320 var blockCol = mcu % component.blocksPerLine;
12321 const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
12322 decode(component, blockOffset);
12323 }
12324
12325 var componentsLength = components.length;
12326 var component, i, j, k, n;
12327 var decodeFn;
12328
12329 if (progressive) {
12330 if (spectralStart === 0) {
12331 decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
12332 } else {
12333 decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
12334 }
12335 } else {
12336 decodeFn = decodeBaseline;
12337 }
12338
12339 var mcu = 0,
12340 fileMarker;
12341 var mcuExpected;
12342
12343 if (componentsLength === 1) {
12344 mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
12345 } else {
12346 mcuExpected = mcusPerLine * frame.mcusPerColumn;
12347 }
12348
12349 var h, v;
12350
12351 while (mcu <= mcuExpected) {
12352 var mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
12353
12354 if (mcuToRead > 0) {
12355 for (i = 0; i < componentsLength; i++) {
12356 components[i].pred = 0;
12357 }
12358
12359 eobrun = 0;
12360
12361 if (componentsLength === 1) {
12362 component = components[0];
12363
12364 for (n = 0; n < mcuToRead; n++) {
12365 decodeBlock(component, decodeFn, mcu);
12366 mcu++;
12367 }
12368 } else {
12369 for (n = 0; n < mcuToRead; n++) {
12370 for (i = 0; i < componentsLength; i++) {
12371 component = components[i];
12372 h = component.h;
12373 v = component.v;
12374
12375 for (j = 0; j < v; j++) {
12376 for (k = 0; k < h; k++) {
12377 decodeMcu(component, decodeFn, mcu, j, k);
12378 }
12379 }
12380 }
12381
12382 mcu++;
12383 }
12384 }
12385 }
12386
12387 bitsCount = 0;
12388 fileMarker = findNextFileMarker(data, offset);
12389
12390 if (!fileMarker) {
12391 break;
12392 }
12393
12394 if (fileMarker.invalid) {
12395 const partialMsg = mcuToRead > 0 ? "unexpected" : "excessive";
12396 (0, _util.warn)(`decodeScan - ${partialMsg} MCU data, current marker is: ${fileMarker.invalid}`);
12397 offset = fileMarker.offset;
12398 }
12399
12400 if (fileMarker.marker >= 0xffd0 && fileMarker.marker <= 0xffd7) {
12401 offset += 2;
12402 } else {
12403 break;
12404 }
12405 }
12406
12407 return offset - startOffset;
12408 }
12409
12410 function quantizeAndInverse(component, blockBufferOffset, p) {
12411 var qt = component.quantizationTable,
12412 blockData = component.blockData;
12413 var v0, v1, v2, v3, v4, v5, v6, v7;
12414 var p0, p1, p2, p3, p4, p5, p6, p7;
12415 var t;
12416
12417 if (!qt) {
12418 throw new JpegError("missing required Quantization Table.");
12419 }
12420
12421 for (var row = 0; row < 64; row += 8) {
12422 p0 = blockData[blockBufferOffset + row];
12423 p1 = blockData[blockBufferOffset + row + 1];
12424 p2 = blockData[blockBufferOffset + row + 2];
12425 p3 = blockData[blockBufferOffset + row + 3];
12426 p4 = blockData[blockBufferOffset + row + 4];
12427 p5 = blockData[blockBufferOffset + row + 5];
12428 p6 = blockData[blockBufferOffset + row + 6];
12429 p7 = blockData[blockBufferOffset + row + 7];
12430 p0 *= qt[row];
12431
12432 if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
12433 t = dctSqrt2 * p0 + 512 >> 10;
12434 p[row] = t;
12435 p[row + 1] = t;
12436 p[row + 2] = t;
12437 p[row + 3] = t;
12438 p[row + 4] = t;
12439 p[row + 5] = t;
12440 p[row + 6] = t;
12441 p[row + 7] = t;
12442 continue;
12443 }
12444
12445 p1 *= qt[row + 1];
12446 p2 *= qt[row + 2];
12447 p3 *= qt[row + 3];
12448 p4 *= qt[row + 4];
12449 p5 *= qt[row + 5];
12450 p6 *= qt[row + 6];
12451 p7 *= qt[row + 7];
12452 v0 = dctSqrt2 * p0 + 128 >> 8;
12453 v1 = dctSqrt2 * p4 + 128 >> 8;
12454 v2 = p2;
12455 v3 = p6;
12456 v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
12457 v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
12458 v5 = p3 << 4;
12459 v6 = p5 << 4;
12460 v0 = v0 + v1 + 1 >> 1;
12461 v1 = v0 - v1;
12462 t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
12463 v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
12464 v3 = t;
12465 v4 = v4 + v6 + 1 >> 1;
12466 v6 = v4 - v6;
12467 v7 = v7 + v5 + 1 >> 1;
12468 v5 = v7 - v5;
12469 v0 = v0 + v3 + 1 >> 1;
12470 v3 = v0 - v3;
12471 v1 = v1 + v2 + 1 >> 1;
12472 v2 = v1 - v2;
12473 t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
12474 v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
12475 v7 = t;
12476 t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
12477 v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
12478 v6 = t;
12479 p[row] = v0 + v7;
12480 p[row + 7] = v0 - v7;
12481 p[row + 1] = v1 + v6;
12482 p[row + 6] = v1 - v6;
12483 p[row + 2] = v2 + v5;
12484 p[row + 5] = v2 - v5;
12485 p[row + 3] = v3 + v4;
12486 p[row + 4] = v3 - v4;
12487 }
12488
12489 for (var col = 0; col < 8; ++col) {
12490 p0 = p[col];
12491 p1 = p[col + 8];
12492 p2 = p[col + 16];
12493 p3 = p[col + 24];
12494 p4 = p[col + 32];
12495 p5 = p[col + 40];
12496 p6 = p[col + 48];
12497 p7 = p[col + 56];
12498
12499 if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
12500 t = dctSqrt2 * p0 + 8192 >> 14;
12501
12502 if (t < -2040) {
12503 t = 0;
12504 } else if (t >= 2024) {
12505 t = 255;
12506 } else {
12507 t = t + 2056 >> 4;
12508 }
12509
12510 blockData[blockBufferOffset + col] = t;
12511 blockData[blockBufferOffset + col + 8] = t;
12512 blockData[blockBufferOffset + col + 16] = t;
12513 blockData[blockBufferOffset + col + 24] = t;
12514 blockData[blockBufferOffset + col + 32] = t;
12515 blockData[blockBufferOffset + col + 40] = t;
12516 blockData[blockBufferOffset + col + 48] = t;
12517 blockData[blockBufferOffset + col + 56] = t;
12518 continue;
12519 }
12520
12521 v0 = dctSqrt2 * p0 + 2048 >> 12;
12522 v1 = dctSqrt2 * p4 + 2048 >> 12;
12523 v2 = p2;
12524 v3 = p6;
12525 v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
12526 v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
12527 v5 = p3;
12528 v6 = p5;
12529 v0 = (v0 + v1 + 1 >> 1) + 4112;
12530 v1 = v0 - v1;
12531 t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
12532 v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
12533 v3 = t;
12534 v4 = v4 + v6 + 1 >> 1;
12535 v6 = v4 - v6;
12536 v7 = v7 + v5 + 1 >> 1;
12537 v5 = v7 - v5;
12538 v0 = v0 + v3 + 1 >> 1;
12539 v3 = v0 - v3;
12540 v1 = v1 + v2 + 1 >> 1;
12541 v2 = v1 - v2;
12542 t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
12543 v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
12544 v7 = t;
12545 t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
12546 v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
12547 v6 = t;
12548 p0 = v0 + v7;
12549 p7 = v0 - v7;
12550 p1 = v1 + v6;
12551 p6 = v1 - v6;
12552 p2 = v2 + v5;
12553 p5 = v2 - v5;
12554 p3 = v3 + v4;
12555 p4 = v3 - v4;
12556
12557 if (p0 < 16) {
12558 p0 = 0;
12559 } else if (p0 >= 4080) {
12560 p0 = 255;
12561 } else {
12562 p0 >>= 4;
12563 }
12564
12565 if (p1 < 16) {
12566 p1 = 0;
12567 } else if (p1 >= 4080) {
12568 p1 = 255;
12569 } else {
12570 p1 >>= 4;
12571 }
12572
12573 if (p2 < 16) {
12574 p2 = 0;
12575 } else if (p2 >= 4080) {
12576 p2 = 255;
12577 } else {
12578 p2 >>= 4;
12579 }
12580
12581 if (p3 < 16) {
12582 p3 = 0;
12583 } else if (p3 >= 4080) {
12584 p3 = 255;
12585 } else {
12586 p3 >>= 4;
12587 }
12588
12589 if (p4 < 16) {
12590 p4 = 0;
12591 } else if (p4 >= 4080) {
12592 p4 = 255;
12593 } else {
12594 p4 >>= 4;
12595 }
12596
12597 if (p5 < 16) {
12598 p5 = 0;
12599 } else if (p5 >= 4080) {
12600 p5 = 255;
12601 } else {
12602 p5 >>= 4;
12603 }
12604
12605 if (p6 < 16) {
12606 p6 = 0;
12607 } else if (p6 >= 4080) {
12608 p6 = 255;
12609 } else {
12610 p6 >>= 4;
12611 }
12612
12613 if (p7 < 16) {
12614 p7 = 0;
12615 } else if (p7 >= 4080) {
12616 p7 = 255;
12617 } else {
12618 p7 >>= 4;
12619 }
12620
12621 blockData[blockBufferOffset + col] = p0;
12622 blockData[blockBufferOffset + col + 8] = p1;
12623 blockData[blockBufferOffset + col + 16] = p2;
12624 blockData[blockBufferOffset + col + 24] = p3;
12625 blockData[blockBufferOffset + col + 32] = p4;
12626 blockData[blockBufferOffset + col + 40] = p5;
12627 blockData[blockBufferOffset + col + 48] = p6;
12628 blockData[blockBufferOffset + col + 56] = p7;
12629 }
12630 }
12631
12632 function buildComponentData(frame, component) {
12633 var blocksPerLine = component.blocksPerLine;
12634 var blocksPerColumn = component.blocksPerColumn;
12635 var computationBuffer = new Int16Array(64);
12636
12637 for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
12638 for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
12639 var offset = getBlockBufferOffset(component, blockRow, blockCol);
12640 quantizeAndInverse(component, offset, computationBuffer);
12641 }
12642 }
12643
12644 return component.blockData;
12645 }
12646
12647 function findNextFileMarker(data, currentPos, startPos = currentPos) {
12648 const maxPos = data.length - 1;
12649 var newPos = startPos < currentPos ? startPos : currentPos;
12650
12651 if (currentPos >= maxPos) {
12652 return null;
12653 }
12654
12655 var currentMarker = (0, _core_utils.readUint16)(data, currentPos);
12656
12657 if (currentMarker >= 0xffc0 && currentMarker <= 0xfffe) {
12658 return {
12659 invalid: null,
12660 marker: currentMarker,
12661 offset: currentPos
12662 };
12663 }
12664
12665 var newMarker = (0, _core_utils.readUint16)(data, newPos);
12666
12667 while (!(newMarker >= 0xffc0 && newMarker <= 0xfffe)) {
12668 if (++newPos >= maxPos) {
12669 return null;
12670 }
12671
12672 newMarker = (0, _core_utils.readUint16)(data, newPos);
12673 }
12674
12675 return {
12676 invalid: currentMarker.toString(16),
12677 marker: newMarker,
12678 offset: newPos
12679 };
12680 }
12681
12682 JpegImage.prototype = {
12683 parse(data, {
12684 dnlScanLines = null
12685 } = {}) {
12686 function readDataBlock() {
12687 const length = (0, _core_utils.readUint16)(data, offset);
12688 offset += 2;
12689 let endOffset = offset + length - 2;
12690 var fileMarker = findNextFileMarker(data, endOffset, offset);
12691
12692 if (fileMarker && fileMarker.invalid) {
12693 (0, _util.warn)("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
12694 endOffset = fileMarker.offset;
12695 }
12696
12697 var array = data.subarray(offset, endOffset);
12698 offset += array.length;
12699 return array;
12700 }
12701
12702 function prepareComponents(frame) {
12703 var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
12704 var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
12705
12706 for (var i = 0; i < frame.components.length; i++) {
12707 component = frame.components[i];
12708 var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
12709 var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
12710 var blocksPerLineForMcu = mcusPerLine * component.h;
12711 var blocksPerColumnForMcu = mcusPerColumn * component.v;
12712 var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
12713 component.blockData = new Int16Array(blocksBufferSize);
12714 component.blocksPerLine = blocksPerLine;
12715 component.blocksPerColumn = blocksPerColumn;
12716 }
12717
12718 frame.mcusPerLine = mcusPerLine;
12719 frame.mcusPerColumn = mcusPerColumn;
12720 }
12721
12722 var offset = 0;
12723 var jfif = null;
12724 var adobe = null;
12725 var frame, resetInterval;
12726 let numSOSMarkers = 0;
12727 var quantizationTables = [];
12728 var huffmanTablesAC = [],
12729 huffmanTablesDC = [];
12730 let fileMarker = (0, _core_utils.readUint16)(data, offset);
12731 offset += 2;
12732
12733 if (fileMarker !== 0xffd8) {
12734 throw new JpegError("SOI not found");
12735 }
12736
12737 fileMarker = (0, _core_utils.readUint16)(data, offset);
12738 offset += 2;
12739
12740 markerLoop: while (fileMarker !== 0xffd9) {
12741 var i, j, l;
12742
12743 switch (fileMarker) {
12744 case 0xffe0:
12745 case 0xffe1:
12746 case 0xffe2:
12747 case 0xffe3:
12748 case 0xffe4:
12749 case 0xffe5:
12750 case 0xffe6:
12751 case 0xffe7:
12752 case 0xffe8:
12753 case 0xffe9:
12754 case 0xffea:
12755 case 0xffeb:
12756 case 0xffec:
12757 case 0xffed:
12758 case 0xffee:
12759 case 0xffef:
12760 case 0xfffe:
12761 var appData = readDataBlock();
12762
12763 if (fileMarker === 0xffe0) {
12764 if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
12765 jfif = {
12766 version: {
12767 major: appData[5],
12768 minor: appData[6]
12769 },
12770 densityUnits: appData[7],
12771 xDensity: appData[8] << 8 | appData[9],
12772 yDensity: appData[10] << 8 | appData[11],
12773 thumbWidth: appData[12],
12774 thumbHeight: appData[13],
12775 thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
12776 };
12777 }
12778 }
12779
12780 if (fileMarker === 0xffee) {
12781 if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6f && appData[3] === 0x62 && appData[4] === 0x65) {
12782 adobe = {
12783 version: appData[5] << 8 | appData[6],
12784 flags0: appData[7] << 8 | appData[8],
12785 flags1: appData[9] << 8 | appData[10],
12786 transformCode: appData[11]
12787 };
12788 }
12789 }
12790
12791 break;
12792
12793 case 0xffdb:
12794 const quantizationTablesLength = (0, _core_utils.readUint16)(data, offset);
12795 offset += 2;
12796 var quantizationTablesEnd = quantizationTablesLength + offset - 2;
12797 var z;
12798
12799 while (offset < quantizationTablesEnd) {
12800 var quantizationTableSpec = data[offset++];
12801 var tableData = new Uint16Array(64);
12802
12803 if (quantizationTableSpec >> 4 === 0) {
12804 for (j = 0; j < 64; j++) {
12805 z = dctZigZag[j];
12806 tableData[z] = data[offset++];
12807 }
12808 } else if (quantizationTableSpec >> 4 === 1) {
12809 for (j = 0; j < 64; j++) {
12810 z = dctZigZag[j];
12811 tableData[z] = (0, _core_utils.readUint16)(data, offset);
12812 offset += 2;
12813 }
12814 } else {
12815 throw new JpegError("DQT - invalid table spec");
12816 }
12817
12818 quantizationTables[quantizationTableSpec & 15] = tableData;
12819 }
12820
12821 break;
12822
12823 case 0xffc0:
12824 case 0xffc1:
12825 case 0xffc2:
12826 if (frame) {
12827 throw new JpegError("Only single frame JPEGs supported");
12828 }
12829
12830 offset += 2;
12831 frame = {};
12832 frame.extended = fileMarker === 0xffc1;
12833 frame.progressive = fileMarker === 0xffc2;
12834 frame.precision = data[offset++];
12835 const sofScanLines = (0, _core_utils.readUint16)(data, offset);
12836 offset += 2;
12837 frame.scanLines = dnlScanLines || sofScanLines;
12838 frame.samplesPerLine = (0, _core_utils.readUint16)(data, offset);
12839 offset += 2;
12840 frame.components = [];
12841 frame.componentIds = {};
12842 var componentsCount = data[offset++],
12843 componentId;
12844 var maxH = 0,
12845 maxV = 0;
12846
12847 for (i = 0; i < componentsCount; i++) {
12848 componentId = data[offset];
12849 var h = data[offset + 1] >> 4;
12850 var v = data[offset + 1] & 15;
12851
12852 if (maxH < h) {
12853 maxH = h;
12854 }
12855
12856 if (maxV < v) {
12857 maxV = v;
12858 }
12859
12860 var qId = data[offset + 2];
12861 l = frame.components.push({
12862 h,
12863 v,
12864 quantizationId: qId,
12865 quantizationTable: null
12866 });
12867 frame.componentIds[componentId] = l - 1;
12868 offset += 3;
12869 }
12870
12871 frame.maxH = maxH;
12872 frame.maxV = maxV;
12873 prepareComponents(frame);
12874 break;
12875
12876 case 0xffc4:
12877 const huffmanLength = (0, _core_utils.readUint16)(data, offset);
12878 offset += 2;
12879
12880 for (i = 2; i < huffmanLength;) {
12881 var huffmanTableSpec = data[offset++];
12882 var codeLengths = new Uint8Array(16);
12883 var codeLengthSum = 0;
12884
12885 for (j = 0; j < 16; j++, offset++) {
12886 codeLengthSum += codeLengths[j] = data[offset];
12887 }
12888
12889 var huffmanValues = new Uint8Array(codeLengthSum);
12890
12891 for (j = 0; j < codeLengthSum; j++, offset++) {
12892 huffmanValues[j] = data[offset];
12893 }
12894
12895 i += 17 + codeLengthSum;
12896 (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
12897 }
12898
12899 break;
12900
12901 case 0xffdd:
12902 offset += 2;
12903 resetInterval = (0, _core_utils.readUint16)(data, offset);
12904 offset += 2;
12905 break;
12906
12907 case 0xffda:
12908 const parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
12909 offset += 2;
12910 var selectorsCount = data[offset++];
12911 var components = [],
12912 component;
12913
12914 for (i = 0; i < selectorsCount; i++) {
12915 var componentIndex = frame.componentIds[data[offset++]];
12916 component = frame.components[componentIndex];
12917 var tableSpec = data[offset++];
12918 component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
12919 component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
12920 components.push(component);
12921 }
12922
12923 var spectralStart = data[offset++];
12924 var spectralEnd = data[offset++];
12925 var successiveApproximation = data[offset++];
12926
12927 try {
12928 var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
12929 offset += processed;
12930 } catch (ex) {
12931 if (ex instanceof DNLMarkerError) {
12932 (0, _util.warn)(`${ex.message} -- attempting to re-parse the JPEG image.`);
12933 return this.parse(data, {
12934 dnlScanLines: ex.scanLines
12935 });
12936 } else if (ex instanceof EOIMarkerError) {
12937 (0, _util.warn)(`${ex.message} -- ignoring the rest of the image data.`);
12938 break markerLoop;
12939 }
12940
12941 throw ex;
12942 }
12943
12944 break;
12945
12946 case 0xffdc:
12947 offset += 4;
12948 break;
12949
12950 case 0xffff:
12951 if (data[offset] !== 0xff) {
12952 offset--;
12953 }
12954
12955 break;
12956
12957 default:
12958 const nextFileMarker = findNextFileMarker(data, offset - 2, offset - 3);
12959
12960 if (nextFileMarker && nextFileMarker.invalid) {
12961 (0, _util.warn)("JpegImage.parse - unexpected data, current marker is: " + nextFileMarker.invalid);
12962 offset = nextFileMarker.offset;
12963 break;
12964 }
12965
12966 if (offset >= data.length - 1) {
12967 (0, _util.warn)("JpegImage.parse - reached the end of the image data " + "without finding an EOI marker (0xFFD9).");
12968 break markerLoop;
12969 }
12970
12971 throw new JpegError("JpegImage.parse - unknown marker: " + fileMarker.toString(16));
12972 }
12973
12974 fileMarker = (0, _core_utils.readUint16)(data, offset);
12975 offset += 2;
12976 }
12977
12978 this.width = frame.samplesPerLine;
12979 this.height = frame.scanLines;
12980 this.jfif = jfif;
12981 this.adobe = adobe;
12982 this.components = [];
12983
12984 for (i = 0; i < frame.components.length; i++) {
12985 component = frame.components[i];
12986 var quantizationTable = quantizationTables[component.quantizationId];
12987
12988 if (quantizationTable) {
12989 component.quantizationTable = quantizationTable;
12990 }
12991
12992 this.components.push({
12993 output: buildComponentData(frame, component),
12994 scaleX: component.h / frame.maxH,
12995 scaleY: component.v / frame.maxV,
12996 blocksPerLine: component.blocksPerLine,
12997 blocksPerColumn: component.blocksPerColumn
12998 });
12999 }
13000
13001 this.numComponents = this.components.length;
13002 return undefined;
13003 },
13004
13005 _getLinearizedBlockData(width, height, isSourcePDF = false) {
13006 var scaleX = this.width / width,
13007 scaleY = this.height / height;
13008 var component, componentScaleX, componentScaleY, blocksPerScanline;
13009 var x, y, i, j, k;
13010 var index;
13011 var offset = 0;
13012 var output;
13013 var numComponents = this.components.length;
13014 var dataLength = width * height * numComponents;
13015 var data = new Uint8ClampedArray(dataLength);
13016 var xScaleBlockOffset = new Uint32Array(width);
13017 var mask3LSB = 0xfffffff8;
13018 let lastComponentScaleX;
13019
13020 for (i = 0; i < numComponents; i++) {
13021 component = this.components[i];
13022 componentScaleX = component.scaleX * scaleX;
13023 componentScaleY = component.scaleY * scaleY;
13024 offset = i;
13025 output = component.output;
13026 blocksPerScanline = component.blocksPerLine + 1 << 3;
13027
13028 if (componentScaleX !== lastComponentScaleX) {
13029 for (x = 0; x < width; x++) {
13030 j = 0 | x * componentScaleX;
13031 xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
13032 }
13033
13034 lastComponentScaleX = componentScaleX;
13035 }
13036
13037 for (y = 0; y < height; y++) {
13038 j = 0 | y * componentScaleY;
13039 index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
13040
13041 for (x = 0; x < width; x++) {
13042 data[offset] = output[index + xScaleBlockOffset[x]];
13043 offset += numComponents;
13044 }
13045 }
13046 }
13047
13048 let transform = this._decodeTransform;
13049
13050 if (!isSourcePDF && numComponents === 4 && !transform) {
13051 transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
13052 }
13053
13054 if (transform) {
13055 for (i = 0; i < dataLength;) {
13056 for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
13057 data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
13058 }
13059 }
13060 }
13061
13062 return data;
13063 },
13064
13065 get _isColorConversionNeeded() {
13066 if (this.adobe) {
13067 return !!this.adobe.transformCode;
13068 }
13069
13070 if (this.numComponents === 3) {
13071 if (this._colorTransform === 0) {
13072 return false;
13073 }
13074
13075 return true;
13076 }
13077
13078 if (this._colorTransform === 1) {
13079 return true;
13080 }
13081
13082 return false;
13083 },
13084
13085 _convertYccToRgb: function convertYccToRgb(data) {
13086 var Y, Cb, Cr;
13087
13088 for (var i = 0, length = data.length; i < length; i += 3) {
13089 Y = data[i];
13090 Cb = data[i + 1];
13091 Cr = data[i + 2];
13092 data[i] = Y - 179.456 + 1.402 * Cr;
13093 data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
13094 data[i + 2] = Y - 226.816 + 1.772 * Cb;
13095 }
13096
13097 return data;
13098 },
13099 _convertYcckToRgb: function convertYcckToRgb(data) {
13100 var Y, Cb, Cr, k;
13101 var offset = 0;
13102
13103 for (var i = 0, length = data.length; i < length; i += 4) {
13104 Y = data[i];
13105 Cb = data[i + 1];
13106 Cr = data[i + 2];
13107 k = data[i + 3];
13108 data[offset++] = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
13109 data[offset++] = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
13110 data[offset++] = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
13111 }
13112
13113 return data.subarray(0, offset);
13114 },
13115 _convertYcckToCmyk: function convertYcckToCmyk(data) {
13116 var Y, Cb, Cr;
13117
13118 for (var i = 0, length = data.length; i < length; i += 4) {
13119 Y = data[i];
13120 Cb = data[i + 1];
13121 Cr = data[i + 2];
13122 data[i] = 434.456 - Y - 1.402 * Cr;
13123 data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
13124 data[i + 2] = 481.816 - Y - 1.772 * Cb;
13125 }
13126
13127 return data;
13128 },
13129 _convertCmykToRgb: function convertCmykToRgb(data) {
13130 var c, m, y, k;
13131 var offset = 0;
13132
13133 for (var i = 0, length = data.length; i < length; i += 4) {
13134 c = data[i];
13135 m = data[i + 1];
13136 y = data[i + 2];
13137 k = data[i + 3];
13138 data[offset++] = 255 + c * (-0.00006747147073602441 * c + 0.0008379262121013727 * m + 0.0002894718188643294 * y + 0.003264231057537806 * k - 1.1185611867203937) + m * (0.000026374107616089405 * m - 0.00008626949158638572 * y - 0.0002748769067499491 * k - 0.02155688794978967) + y * (-0.00003878099212869363 * y - 0.0003267808279485286 * k + 0.0686742238595345) - k * (0.0003361971776183937 * k + 0.7430659151342254);
13139 data[offset++] = 255 + c * (0.00013596372813588848 * c + 0.000924537132573585 * m + 0.00010567359618683593 * y + 0.0004791864687436512 * k - 0.3109689587515875) + m * (-0.00023545346108370344 * m + 0.0002702845253534714 * y + 0.0020200308977307156 * k - 0.7488052167015494) + y * (0.00006834815998235662 * y + 0.00015168452363460973 * k - 0.09751927774728933) - k * (0.00031891311758832814 * k + 0.7364883807733168);
13140 data[offset++] = 255 + c * (0.000013598650411385307 * c + 0.00012423956175490851 * m + 0.0004751985097583589 * y - 0.0000036729317476630422 * k - 0.05562186980264034) + m * (0.00016141380598724676 * m + 0.0009692239130725186 * y + 0.0007782692450036253 * k - 0.44015232367526463) + y * (5.068882914068769e-7 * y + 0.0017778369011375071 * k - 0.7591454649749609) - k * (0.0003435319965105553 * k + 0.7063770186160144);
13141 }
13142
13143 return data.subarray(0, offset);
13144 },
13145
13146 getData({
13147 width,
13148 height,
13149 forceRGB = false,
13150 isSourcePDF = false
13151 }) {
13152 if (this.numComponents > 4) {
13153 throw new JpegError("Unsupported color mode");
13154 }
13155
13156 var data = this._getLinearizedBlockData(width, height, isSourcePDF);
13157
13158 if (this.numComponents === 1 && forceRGB) {
13159 var dataLength = data.length;
13160 var rgbData = new Uint8ClampedArray(dataLength * 3);
13161 var offset = 0;
13162
13163 for (var i = 0; i < dataLength; i++) {
13164 var grayColor = data[i];
13165 rgbData[offset++] = grayColor;
13166 rgbData[offset++] = grayColor;
13167 rgbData[offset++] = grayColor;
13168 }
13169
13170 return rgbData;
13171 } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
13172 return this._convertYccToRgb(data);
13173 } else if (this.numComponents === 4) {
13174 if (this._isColorConversionNeeded) {
13175 if (forceRGB) {
13176 return this._convertYcckToRgb(data);
13177 }
13178
13179 return this._convertYcckToCmyk(data);
13180 } else if (forceRGB) {
13181 return this._convertCmykToRgb(data);
13182 }
13183 }
13184
13185 return data;
13186 }
13187
13188 };
13189 return JpegImage;
13190}();
13191
13192exports.JpegImage = JpegImage;
13193
13194/***/ }),
13195/* 20 */
13196/***/ (function(module, exports, __w_pdfjs_require__) {
13197
13198"use strict";
13199
13200
13201Object.defineProperty(exports, "__esModule", {
13202 value: true
13203});
13204exports.JpxStream = void 0;
13205
13206var _stream = __w_pdfjs_require__(12);
13207
13208var _jpx = __w_pdfjs_require__(21);
13209
13210var _util = __w_pdfjs_require__(2);
13211
13212const JpxStream = function JpxStreamClosure() {
13213 function JpxStream(stream, maybeLength, dict, params) {
13214 this.stream = stream;
13215 this.maybeLength = maybeLength;
13216 this.dict = dict;
13217 this.params = params;
13218
13219 _stream.DecodeStream.call(this, maybeLength);
13220 }
13221
13222 JpxStream.prototype = Object.create(_stream.DecodeStream.prototype);
13223 Object.defineProperty(JpxStream.prototype, "bytes", {
13224 get: function JpxStream_bytes() {
13225 return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
13226 },
13227 configurable: true
13228 });
13229
13230 JpxStream.prototype.ensureBuffer = function (requested) {};
13231
13232 JpxStream.prototype.readBlock = function () {
13233 if (this.eof) {
13234 return;
13235 }
13236
13237 const jpxImage = new _jpx.JpxImage();
13238 jpxImage.parse(this.bytes);
13239 const width = jpxImage.width;
13240 const height = jpxImage.height;
13241 const componentsCount = jpxImage.componentsCount;
13242 const tileCount = jpxImage.tiles.length;
13243
13244 if (tileCount === 1) {
13245 this.buffer = jpxImage.tiles[0].items;
13246 } else {
13247 const data = new Uint8ClampedArray(width * height * componentsCount);
13248
13249 for (let k = 0; k < tileCount; k++) {
13250 const tileComponents = jpxImage.tiles[k];
13251 const tileWidth = tileComponents.width;
13252 const tileHeight = tileComponents.height;
13253 const tileLeft = tileComponents.left;
13254 const tileTop = tileComponents.top;
13255 const src = tileComponents.items;
13256 let srcPosition = 0;
13257 let dataPosition = (width * tileTop + tileLeft) * componentsCount;
13258 const imgRowSize = width * componentsCount;
13259 const tileRowSize = tileWidth * componentsCount;
13260
13261 for (let j = 0; j < tileHeight; j++) {
13262 const rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
13263 data.set(rowBytes, dataPosition);
13264 srcPosition += tileRowSize;
13265 dataPosition += imgRowSize;
13266 }
13267 }
13268
13269 this.buffer = data;
13270 }
13271
13272 this.bufferLength = this.buffer.length;
13273 this.eof = true;
13274 };
13275
13276 return JpxStream;
13277}();
13278
13279exports.JpxStream = JpxStream;
13280
13281/***/ }),
13282/* 21 */
13283/***/ (function(module, exports, __w_pdfjs_require__) {
13284
13285"use strict";
13286
13287
13288Object.defineProperty(exports, "__esModule", {
13289 value: true
13290});
13291exports.JpxImage = void 0;
13292
13293var _util = __w_pdfjs_require__(2);
13294
13295var _core_utils = __w_pdfjs_require__(8);
13296
13297var _arithmetic_decoder = __w_pdfjs_require__(17);
13298
13299class JpxError extends _util.BaseException {
13300 constructor(msg) {
13301 super(`JPX error: ${msg}`);
13302 }
13303
13304}
13305
13306var JpxImage = function JpxImageClosure() {
13307 var SubbandsGainLog2 = {
13308 LL: 0,
13309 LH: 1,
13310 HL: 1,
13311 HH: 2
13312 };
13313
13314 function JpxImage() {
13315 this.failOnCorruptedImage = false;
13316 }
13317
13318 JpxImage.prototype = {
13319 parse: function JpxImage_parse(data) {
13320 var head = (0, _core_utils.readUint16)(data, 0);
13321
13322 if (head === 0xff4f) {
13323 this.parseCodestream(data, 0, data.length);
13324 return;
13325 }
13326
13327 var position = 0,
13328 length = data.length;
13329
13330 while (position < length) {
13331 var headerSize = 8;
13332 var lbox = (0, _core_utils.readUint32)(data, position);
13333 var tbox = (0, _core_utils.readUint32)(data, position + 4);
13334 position += headerSize;
13335
13336 if (lbox === 1) {
13337 lbox = (0, _core_utils.readUint32)(data, position) * 4294967296 + (0, _core_utils.readUint32)(data, position + 4);
13338 position += 8;
13339 headerSize += 8;
13340 }
13341
13342 if (lbox === 0) {
13343 lbox = length - position + headerSize;
13344 }
13345
13346 if (lbox < headerSize) {
13347 throw new JpxError("Invalid box field size");
13348 }
13349
13350 var dataLength = lbox - headerSize;
13351 var jumpDataLength = true;
13352
13353 switch (tbox) {
13354 case 0x6a703268:
13355 jumpDataLength = false;
13356 break;
13357
13358 case 0x636f6c72:
13359 var method = data[position];
13360
13361 if (method === 1) {
13362 var colorspace = (0, _core_utils.readUint32)(data, position + 3);
13363
13364 switch (colorspace) {
13365 case 16:
13366 case 17:
13367 case 18:
13368 break;
13369
13370 default:
13371 (0, _util.warn)("Unknown colorspace " + colorspace);
13372 break;
13373 }
13374 } else if (method === 2) {
13375 (0, _util.info)("ICC profile not supported");
13376 }
13377
13378 break;
13379
13380 case 0x6a703263:
13381 this.parseCodestream(data, position, position + dataLength);
13382 break;
13383
13384 case 0x6a502020:
13385 if ((0, _core_utils.readUint32)(data, position) !== 0x0d0a870a) {
13386 (0, _util.warn)("Invalid JP2 signature");
13387 }
13388
13389 break;
13390
13391 case 0x6a501a1a:
13392 case 0x66747970:
13393 case 0x72726571:
13394 case 0x72657320:
13395 case 0x69686472:
13396 break;
13397
13398 default:
13399 var headerType = String.fromCharCode(tbox >> 24 & 0xff, tbox >> 16 & 0xff, tbox >> 8 & 0xff, tbox & 0xff);
13400 (0, _util.warn)("Unsupported header type " + tbox + " (" + headerType + ")");
13401 break;
13402 }
13403
13404 if (jumpDataLength) {
13405 position += dataLength;
13406 }
13407 }
13408 },
13409 parseImageProperties: function JpxImage_parseImageProperties(stream) {
13410 var newByte = stream.getByte();
13411
13412 while (newByte >= 0) {
13413 var oldByte = newByte;
13414 newByte = stream.getByte();
13415 var code = oldByte << 8 | newByte;
13416
13417 if (code === 0xff51) {
13418 stream.skip(4);
13419 var Xsiz = stream.getInt32() >>> 0;
13420 var Ysiz = stream.getInt32() >>> 0;
13421 var XOsiz = stream.getInt32() >>> 0;
13422 var YOsiz = stream.getInt32() >>> 0;
13423 stream.skip(16);
13424 var Csiz = stream.getUint16();
13425 this.width = Xsiz - XOsiz;
13426 this.height = Ysiz - YOsiz;
13427 this.componentsCount = Csiz;
13428 this.bitsPerComponent = 8;
13429 return;
13430 }
13431 }
13432
13433 throw new JpxError("No size marker found in JPX stream");
13434 },
13435 parseCodestream: function JpxImage_parseCodestream(data, start, end) {
13436 var context = {};
13437 var doNotRecover = false;
13438
13439 try {
13440 var position = start;
13441
13442 while (position + 1 < end) {
13443 var code = (0, _core_utils.readUint16)(data, position);
13444 position += 2;
13445 var length = 0,
13446 j,
13447 sqcd,
13448 spqcds,
13449 spqcdSize,
13450 scalarExpounded,
13451 tile;
13452
13453 switch (code) {
13454 case 0xff4f:
13455 context.mainHeader = true;
13456 break;
13457
13458 case 0xffd9:
13459 break;
13460
13461 case 0xff51:
13462 length = (0, _core_utils.readUint16)(data, position);
13463 var siz = {};
13464 siz.Xsiz = (0, _core_utils.readUint32)(data, position + 4);
13465 siz.Ysiz = (0, _core_utils.readUint32)(data, position + 8);
13466 siz.XOsiz = (0, _core_utils.readUint32)(data, position + 12);
13467 siz.YOsiz = (0, _core_utils.readUint32)(data, position + 16);
13468 siz.XTsiz = (0, _core_utils.readUint32)(data, position + 20);
13469 siz.YTsiz = (0, _core_utils.readUint32)(data, position + 24);
13470 siz.XTOsiz = (0, _core_utils.readUint32)(data, position + 28);
13471 siz.YTOsiz = (0, _core_utils.readUint32)(data, position + 32);
13472 var componentsCount = (0, _core_utils.readUint16)(data, position + 36);
13473 siz.Csiz = componentsCount;
13474 var components = [];
13475 j = position + 38;
13476
13477 for (var i = 0; i < componentsCount; i++) {
13478 var component = {
13479 precision: (data[j] & 0x7f) + 1,
13480 isSigned: !!(data[j] & 0x80),
13481 XRsiz: data[j + 1],
13482 YRsiz: data[j + 2]
13483 };
13484 j += 3;
13485 calculateComponentDimensions(component, siz);
13486 components.push(component);
13487 }
13488
13489 context.SIZ = siz;
13490 context.components = components;
13491 calculateTileGrids(context, components);
13492 context.QCC = [];
13493 context.COC = [];
13494 break;
13495
13496 case 0xff5c:
13497 length = (0, _core_utils.readUint16)(data, position);
13498 var qcd = {};
13499 j = position + 2;
13500 sqcd = data[j++];
13501
13502 switch (sqcd & 0x1f) {
13503 case 0:
13504 spqcdSize = 8;
13505 scalarExpounded = true;
13506 break;
13507
13508 case 1:
13509 spqcdSize = 16;
13510 scalarExpounded = false;
13511 break;
13512
13513 case 2:
13514 spqcdSize = 16;
13515 scalarExpounded = true;
13516 break;
13517
13518 default:
13519 throw new Error("Invalid SQcd value " + sqcd);
13520 }
13521
13522 qcd.noQuantization = spqcdSize === 8;
13523 qcd.scalarExpounded = scalarExpounded;
13524 qcd.guardBits = sqcd >> 5;
13525 spqcds = [];
13526
13527 while (j < length + position) {
13528 var spqcd = {};
13529
13530 if (spqcdSize === 8) {
13531 spqcd.epsilon = data[j++] >> 3;
13532 spqcd.mu = 0;
13533 } else {
13534 spqcd.epsilon = data[j] >> 3;
13535 spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
13536 j += 2;
13537 }
13538
13539 spqcds.push(spqcd);
13540 }
13541
13542 qcd.SPqcds = spqcds;
13543
13544 if (context.mainHeader) {
13545 context.QCD = qcd;
13546 } else {
13547 context.currentTile.QCD = qcd;
13548 context.currentTile.QCC = [];
13549 }
13550
13551 break;
13552
13553 case 0xff5d:
13554 length = (0, _core_utils.readUint16)(data, position);
13555 var qcc = {};
13556 j = position + 2;
13557 var cqcc;
13558
13559 if (context.SIZ.Csiz < 257) {
13560 cqcc = data[j++];
13561 } else {
13562 cqcc = (0, _core_utils.readUint16)(data, j);
13563 j += 2;
13564 }
13565
13566 sqcd = data[j++];
13567
13568 switch (sqcd & 0x1f) {
13569 case 0:
13570 spqcdSize = 8;
13571 scalarExpounded = true;
13572 break;
13573
13574 case 1:
13575 spqcdSize = 16;
13576 scalarExpounded = false;
13577 break;
13578
13579 case 2:
13580 spqcdSize = 16;
13581 scalarExpounded = true;
13582 break;
13583
13584 default:
13585 throw new Error("Invalid SQcd value " + sqcd);
13586 }
13587
13588 qcc.noQuantization = spqcdSize === 8;
13589 qcc.scalarExpounded = scalarExpounded;
13590 qcc.guardBits = sqcd >> 5;
13591 spqcds = [];
13592
13593 while (j < length + position) {
13594 spqcd = {};
13595
13596 if (spqcdSize === 8) {
13597 spqcd.epsilon = data[j++] >> 3;
13598 spqcd.mu = 0;
13599 } else {
13600 spqcd.epsilon = data[j] >> 3;
13601 spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
13602 j += 2;
13603 }
13604
13605 spqcds.push(spqcd);
13606 }
13607
13608 qcc.SPqcds = spqcds;
13609
13610 if (context.mainHeader) {
13611 context.QCC[cqcc] = qcc;
13612 } else {
13613 context.currentTile.QCC[cqcc] = qcc;
13614 }
13615
13616 break;
13617
13618 case 0xff52:
13619 length = (0, _core_utils.readUint16)(data, position);
13620 var cod = {};
13621 j = position + 2;
13622 var scod = data[j++];
13623 cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
13624 cod.sopMarkerUsed = !!(scod & 2);
13625 cod.ephMarkerUsed = !!(scod & 4);
13626 cod.progressionOrder = data[j++];
13627 cod.layersCount = (0, _core_utils.readUint16)(data, j);
13628 j += 2;
13629 cod.multipleComponentTransform = data[j++];
13630 cod.decompositionLevelsCount = data[j++];
13631 cod.xcb = (data[j++] & 0xf) + 2;
13632 cod.ycb = (data[j++] & 0xf) + 2;
13633 var blockStyle = data[j++];
13634 cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
13635 cod.resetContextProbabilities = !!(blockStyle & 2);
13636 cod.terminationOnEachCodingPass = !!(blockStyle & 4);
13637 cod.verticallyStripe = !!(blockStyle & 8);
13638 cod.predictableTermination = !!(blockStyle & 16);
13639 cod.segmentationSymbolUsed = !!(blockStyle & 32);
13640 cod.reversibleTransformation = data[j++];
13641
13642 if (cod.entropyCoderWithCustomPrecincts) {
13643 var precinctsSizes = [];
13644
13645 while (j < length + position) {
13646 var precinctsSize = data[j++];
13647 precinctsSizes.push({
13648 PPx: precinctsSize & 0xf,
13649 PPy: precinctsSize >> 4
13650 });
13651 }
13652
13653 cod.precinctsSizes = precinctsSizes;
13654 }
13655
13656 var unsupported = [];
13657
13658 if (cod.selectiveArithmeticCodingBypass) {
13659 unsupported.push("selectiveArithmeticCodingBypass");
13660 }
13661
13662 if (cod.resetContextProbabilities) {
13663 unsupported.push("resetContextProbabilities");
13664 }
13665
13666 if (cod.terminationOnEachCodingPass) {
13667 unsupported.push("terminationOnEachCodingPass");
13668 }
13669
13670 if (cod.verticallyStripe) {
13671 unsupported.push("verticallyStripe");
13672 }
13673
13674 if (cod.predictableTermination) {
13675 unsupported.push("predictableTermination");
13676 }
13677
13678 if (unsupported.length > 0) {
13679 doNotRecover = true;
13680 throw new Error("Unsupported COD options (" + unsupported.join(", ") + ")");
13681 }
13682
13683 if (context.mainHeader) {
13684 context.COD = cod;
13685 } else {
13686 context.currentTile.COD = cod;
13687 context.currentTile.COC = [];
13688 }
13689
13690 break;
13691
13692 case 0xff90:
13693 length = (0, _core_utils.readUint16)(data, position);
13694 tile = {};
13695 tile.index = (0, _core_utils.readUint16)(data, position + 2);
13696 tile.length = (0, _core_utils.readUint32)(data, position + 4);
13697 tile.dataEnd = tile.length + position - 2;
13698 tile.partIndex = data[position + 8];
13699 tile.partsCount = data[position + 9];
13700 context.mainHeader = false;
13701
13702 if (tile.partIndex === 0) {
13703 tile.COD = context.COD;
13704 tile.COC = context.COC.slice(0);
13705 tile.QCD = context.QCD;
13706 tile.QCC = context.QCC.slice(0);
13707 }
13708
13709 context.currentTile = tile;
13710 break;
13711
13712 case 0xff93:
13713 tile = context.currentTile;
13714
13715 if (tile.partIndex === 0) {
13716 initializeTile(context, tile.index);
13717 buildPackets(context);
13718 }
13719
13720 length = tile.dataEnd - position;
13721 parseTilePackets(context, data, position, length);
13722 break;
13723
13724 case 0xff55:
13725 case 0xff57:
13726 case 0xff58:
13727 case 0xff64:
13728 length = (0, _core_utils.readUint16)(data, position);
13729 break;
13730
13731 case 0xff53:
13732 throw new Error("Codestream code 0xFF53 (COC) is not implemented");
13733
13734 default:
13735 throw new Error("Unknown codestream code: " + code.toString(16));
13736 }
13737
13738 position += length;
13739 }
13740 } catch (e) {
13741 if (doNotRecover || this.failOnCorruptedImage) {
13742 throw new JpxError(e.message);
13743 } else {
13744 (0, _util.warn)("JPX: Trying to recover from: " + e.message);
13745 }
13746 }
13747
13748 this.tiles = transformComponents(context);
13749 this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
13750 this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
13751 this.componentsCount = context.SIZ.Csiz;
13752 }
13753 };
13754
13755 function calculateComponentDimensions(component, siz) {
13756 component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
13757 component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
13758 component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
13759 component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
13760 component.width = component.x1 - component.x0;
13761 component.height = component.y1 - component.y0;
13762 }
13763
13764 function calculateTileGrids(context, components) {
13765 var siz = context.SIZ;
13766 var tile,
13767 tiles = [];
13768 var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
13769 var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
13770
13771 for (var q = 0; q < numYtiles; q++) {
13772 for (var p = 0; p < numXtiles; p++) {
13773 tile = {};
13774 tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
13775 tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
13776 tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
13777 tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
13778 tile.width = tile.tx1 - tile.tx0;
13779 tile.height = tile.ty1 - tile.ty0;
13780 tile.components = [];
13781 tiles.push(tile);
13782 }
13783 }
13784
13785 context.tiles = tiles;
13786 var componentsCount = siz.Csiz;
13787
13788 for (var i = 0, ii = componentsCount; i < ii; i++) {
13789 var component = components[i];
13790
13791 for (var j = 0, jj = tiles.length; j < jj; j++) {
13792 var tileComponent = {};
13793 tile = tiles[j];
13794 tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
13795 tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
13796 tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
13797 tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
13798 tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
13799 tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
13800 tile.components[i] = tileComponent;
13801 }
13802 }
13803 }
13804
13805 function getBlocksDimensions(context, component, r) {
13806 var codOrCoc = component.codingStyleParameters;
13807 var result = {};
13808
13809 if (!codOrCoc.entropyCoderWithCustomPrecincts) {
13810 result.PPx = 15;
13811 result.PPy = 15;
13812 } else {
13813 result.PPx = codOrCoc.precinctsSizes[r].PPx;
13814 result.PPy = codOrCoc.precinctsSizes[r].PPy;
13815 }
13816
13817 result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
13818 result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
13819 return result;
13820 }
13821
13822 function buildPrecincts(context, resolution, dimensions) {
13823 var precinctWidth = 1 << dimensions.PPx;
13824 var precinctHeight = 1 << dimensions.PPy;
13825 var isZeroRes = resolution.resLevel === 0;
13826 var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
13827 var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
13828 var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
13829 var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
13830 var numprecincts = numprecinctswide * numprecinctshigh;
13831 resolution.precinctParameters = {
13832 precinctWidth,
13833 precinctHeight,
13834 numprecinctswide,
13835 numprecinctshigh,
13836 numprecincts,
13837 precinctWidthInSubband,
13838 precinctHeightInSubband
13839 };
13840 }
13841
13842 function buildCodeblocks(context, subband, dimensions) {
13843 var xcb_ = dimensions.xcb_;
13844 var ycb_ = dimensions.ycb_;
13845 var codeblockWidth = 1 << xcb_;
13846 var codeblockHeight = 1 << ycb_;
13847 var cbx0 = subband.tbx0 >> xcb_;
13848 var cby0 = subband.tby0 >> ycb_;
13849 var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
13850 var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
13851 var precinctParameters = subband.resolution.precinctParameters;
13852 var codeblocks = [];
13853 var precincts = [];
13854 var i, j, codeblock, precinctNumber;
13855
13856 for (j = cby0; j < cby1; j++) {
13857 for (i = cbx0; i < cbx1; i++) {
13858 codeblock = {
13859 cbx: i,
13860 cby: j,
13861 tbx0: codeblockWidth * i,
13862 tby0: codeblockHeight * j,
13863 tbx1: codeblockWidth * (i + 1),
13864 tby1: codeblockHeight * (j + 1)
13865 };
13866 codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
13867 codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
13868 codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
13869 codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
13870 var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
13871 var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
13872 precinctNumber = pi + pj * precinctParameters.numprecinctswide;
13873 codeblock.precinctNumber = precinctNumber;
13874 codeblock.subbandType = subband.type;
13875 codeblock.Lblock = 3;
13876
13877 if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
13878 continue;
13879 }
13880
13881 codeblocks.push(codeblock);
13882 var precinct = precincts[precinctNumber];
13883
13884 if (precinct !== undefined) {
13885 if (i < precinct.cbxMin) {
13886 precinct.cbxMin = i;
13887 } else if (i > precinct.cbxMax) {
13888 precinct.cbxMax = i;
13889 }
13890
13891 if (j < precinct.cbyMin) {
13892 precinct.cbxMin = j;
13893 } else if (j > precinct.cbyMax) {
13894 precinct.cbyMax = j;
13895 }
13896 } else {
13897 precincts[precinctNumber] = precinct = {
13898 cbxMin: i,
13899 cbyMin: j,
13900 cbxMax: i,
13901 cbyMax: j
13902 };
13903 }
13904
13905 codeblock.precinct = precinct;
13906 }
13907 }
13908
13909 subband.codeblockParameters = {
13910 codeblockWidth: xcb_,
13911 codeblockHeight: ycb_,
13912 numcodeblockwide: cbx1 - cbx0 + 1,
13913 numcodeblockhigh: cby1 - cby0 + 1
13914 };
13915 subband.codeblocks = codeblocks;
13916 subband.precincts = precincts;
13917 }
13918
13919 function createPacket(resolution, precinctNumber, layerNumber) {
13920 var precinctCodeblocks = [];
13921 var subbands = resolution.subbands;
13922
13923 for (var i = 0, ii = subbands.length; i < ii; i++) {
13924 var subband = subbands[i];
13925 var codeblocks = subband.codeblocks;
13926
13927 for (var j = 0, jj = codeblocks.length; j < jj; j++) {
13928 var codeblock = codeblocks[j];
13929
13930 if (codeblock.precinctNumber !== precinctNumber) {
13931 continue;
13932 }
13933
13934 precinctCodeblocks.push(codeblock);
13935 }
13936 }
13937
13938 return {
13939 layerNumber,
13940 codeblocks: precinctCodeblocks
13941 };
13942 }
13943
13944 function LayerResolutionComponentPositionIterator(context) {
13945 var siz = context.SIZ;
13946 var tileIndex = context.currentTile.index;
13947 var tile = context.tiles[tileIndex];
13948 var layersCount = tile.codingStyleDefaultParameters.layersCount;
13949 var componentsCount = siz.Csiz;
13950 var maxDecompositionLevelsCount = 0;
13951
13952 for (var q = 0; q < componentsCount; q++) {
13953 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
13954 }
13955
13956 var l = 0,
13957 r = 0,
13958 i = 0,
13959 k = 0;
13960
13961 this.nextPacket = function JpxImage_nextPacket() {
13962 for (; l < layersCount; l++) {
13963 for (; r <= maxDecompositionLevelsCount; r++) {
13964 for (; i < componentsCount; i++) {
13965 var component = tile.components[i];
13966
13967 if (r > component.codingStyleParameters.decompositionLevelsCount) {
13968 continue;
13969 }
13970
13971 var resolution = component.resolutions[r];
13972 var numprecincts = resolution.precinctParameters.numprecincts;
13973
13974 for (; k < numprecincts;) {
13975 var packet = createPacket(resolution, k, l);
13976 k++;
13977 return packet;
13978 }
13979
13980 k = 0;
13981 }
13982
13983 i = 0;
13984 }
13985
13986 r = 0;
13987 }
13988
13989 throw new JpxError("Out of packets");
13990 };
13991 }
13992
13993 function ResolutionLayerComponentPositionIterator(context) {
13994 var siz = context.SIZ;
13995 var tileIndex = context.currentTile.index;
13996 var tile = context.tiles[tileIndex];
13997 var layersCount = tile.codingStyleDefaultParameters.layersCount;
13998 var componentsCount = siz.Csiz;
13999 var maxDecompositionLevelsCount = 0;
14000
14001 for (var q = 0; q < componentsCount; q++) {
14002 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
14003 }
14004
14005 var r = 0,
14006 l = 0,
14007 i = 0,
14008 k = 0;
14009
14010 this.nextPacket = function JpxImage_nextPacket() {
14011 for (; r <= maxDecompositionLevelsCount; r++) {
14012 for (; l < layersCount; l++) {
14013 for (; i < componentsCount; i++) {
14014 var component = tile.components[i];
14015
14016 if (r > component.codingStyleParameters.decompositionLevelsCount) {
14017 continue;
14018 }
14019
14020 var resolution = component.resolutions[r];
14021 var numprecincts = resolution.precinctParameters.numprecincts;
14022
14023 for (; k < numprecincts;) {
14024 var packet = createPacket(resolution, k, l);
14025 k++;
14026 return packet;
14027 }
14028
14029 k = 0;
14030 }
14031
14032 i = 0;
14033 }
14034
14035 l = 0;
14036 }
14037
14038 throw new JpxError("Out of packets");
14039 };
14040 }
14041
14042 function ResolutionPositionComponentLayerIterator(context) {
14043 var siz = context.SIZ;
14044 var tileIndex = context.currentTile.index;
14045 var tile = context.tiles[tileIndex];
14046 var layersCount = tile.codingStyleDefaultParameters.layersCount;
14047 var componentsCount = siz.Csiz;
14048 var l, r, c, p;
14049 var maxDecompositionLevelsCount = 0;
14050
14051 for (c = 0; c < componentsCount; c++) {
14052 const component = tile.components[c];
14053 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
14054 }
14055
14056 var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
14057
14058 for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
14059 var maxNumPrecincts = 0;
14060
14061 for (c = 0; c < componentsCount; ++c) {
14062 var resolutions = tile.components[c].resolutions;
14063
14064 if (r < resolutions.length) {
14065 maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
14066 }
14067 }
14068
14069 maxNumPrecinctsInLevel[r] = maxNumPrecincts;
14070 }
14071
14072 l = 0;
14073 r = 0;
14074 c = 0;
14075 p = 0;
14076
14077 this.nextPacket = function JpxImage_nextPacket() {
14078 for (; r <= maxDecompositionLevelsCount; r++) {
14079 for (; p < maxNumPrecinctsInLevel[r]; p++) {
14080 for (; c < componentsCount; c++) {
14081 const component = tile.components[c];
14082
14083 if (r > component.codingStyleParameters.decompositionLevelsCount) {
14084 continue;
14085 }
14086
14087 var resolution = component.resolutions[r];
14088 var numprecincts = resolution.precinctParameters.numprecincts;
14089
14090 if (p >= numprecincts) {
14091 continue;
14092 }
14093
14094 for (; l < layersCount;) {
14095 var packet = createPacket(resolution, p, l);
14096 l++;
14097 return packet;
14098 }
14099
14100 l = 0;
14101 }
14102
14103 c = 0;
14104 }
14105
14106 p = 0;
14107 }
14108
14109 throw new JpxError("Out of packets");
14110 };
14111 }
14112
14113 function PositionComponentResolutionLayerIterator(context) {
14114 var siz = context.SIZ;
14115 var tileIndex = context.currentTile.index;
14116 var tile = context.tiles[tileIndex];
14117 var layersCount = tile.codingStyleDefaultParameters.layersCount;
14118 var componentsCount = siz.Csiz;
14119 var precinctsSizes = getPrecinctSizesInImageScale(tile);
14120 var precinctsIterationSizes = precinctsSizes;
14121 var l = 0,
14122 r = 0,
14123 c = 0,
14124 px = 0,
14125 py = 0;
14126
14127 this.nextPacket = function JpxImage_nextPacket() {
14128 for (; py < precinctsIterationSizes.maxNumHigh; py++) {
14129 for (; px < precinctsIterationSizes.maxNumWide; px++) {
14130 for (; c < componentsCount; c++) {
14131 var component = tile.components[c];
14132 var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
14133
14134 for (; r <= decompositionLevelsCount; r++) {
14135 var resolution = component.resolutions[r];
14136 var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
14137 var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
14138
14139 if (k === null) {
14140 continue;
14141 }
14142
14143 for (; l < layersCount;) {
14144 var packet = createPacket(resolution, k, l);
14145 l++;
14146 return packet;
14147 }
14148
14149 l = 0;
14150 }
14151
14152 r = 0;
14153 }
14154
14155 c = 0;
14156 }
14157
14158 px = 0;
14159 }
14160
14161 throw new JpxError("Out of packets");
14162 };
14163 }
14164
14165 function ComponentPositionResolutionLayerIterator(context) {
14166 var siz = context.SIZ;
14167 var tileIndex = context.currentTile.index;
14168 var tile = context.tiles[tileIndex];
14169 var layersCount = tile.codingStyleDefaultParameters.layersCount;
14170 var componentsCount = siz.Csiz;
14171 var precinctsSizes = getPrecinctSizesInImageScale(tile);
14172 var l = 0,
14173 r = 0,
14174 c = 0,
14175 px = 0,
14176 py = 0;
14177
14178 this.nextPacket = function JpxImage_nextPacket() {
14179 for (; c < componentsCount; ++c) {
14180 var component = tile.components[c];
14181 var precinctsIterationSizes = precinctsSizes.components[c];
14182 var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
14183
14184 for (; py < precinctsIterationSizes.maxNumHigh; py++) {
14185 for (; px < precinctsIterationSizes.maxNumWide; px++) {
14186 for (; r <= decompositionLevelsCount; r++) {
14187 var resolution = component.resolutions[r];
14188 var sizeInImageScale = precinctsIterationSizes.resolutions[r];
14189 var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
14190
14191 if (k === null) {
14192 continue;
14193 }
14194
14195 for (; l < layersCount;) {
14196 var packet = createPacket(resolution, k, l);
14197 l++;
14198 return packet;
14199 }
14200
14201 l = 0;
14202 }
14203
14204 r = 0;
14205 }
14206
14207 px = 0;
14208 }
14209
14210 py = 0;
14211 }
14212
14213 throw new JpxError("Out of packets");
14214 };
14215 }
14216
14217 function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
14218 var posX = pxIndex * precinctIterationSizes.minWidth;
14219 var posY = pyIndex * precinctIterationSizes.minHeight;
14220
14221 if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
14222 return null;
14223 }
14224
14225 var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
14226 return posX / sizeInImageScale.height + startPrecinctRowIndex;
14227 }
14228
14229 function getPrecinctSizesInImageScale(tile) {
14230 var componentsCount = tile.components.length;
14231 var minWidth = Number.MAX_VALUE;
14232 var minHeight = Number.MAX_VALUE;
14233 var maxNumWide = 0;
14234 var maxNumHigh = 0;
14235 var sizePerComponent = new Array(componentsCount);
14236
14237 for (var c = 0; c < componentsCount; c++) {
14238 var component = tile.components[c];
14239 var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
14240 var sizePerResolution = new Array(decompositionLevelsCount + 1);
14241 var minWidthCurrentComponent = Number.MAX_VALUE;
14242 var minHeightCurrentComponent = Number.MAX_VALUE;
14243 var maxNumWideCurrentComponent = 0;
14244 var maxNumHighCurrentComponent = 0;
14245 var scale = 1;
14246
14247 for (var r = decompositionLevelsCount; r >= 0; --r) {
14248 var resolution = component.resolutions[r];
14249 var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
14250 var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
14251 minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
14252 minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
14253 maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
14254 maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
14255 sizePerResolution[r] = {
14256 width: widthCurrentResolution,
14257 height: heightCurrentResolution
14258 };
14259 scale <<= 1;
14260 }
14261
14262 minWidth = Math.min(minWidth, minWidthCurrentComponent);
14263 minHeight = Math.min(minHeight, minHeightCurrentComponent);
14264 maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
14265 maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
14266 sizePerComponent[c] = {
14267 resolutions: sizePerResolution,
14268 minWidth: minWidthCurrentComponent,
14269 minHeight: minHeightCurrentComponent,
14270 maxNumWide: maxNumWideCurrentComponent,
14271 maxNumHigh: maxNumHighCurrentComponent
14272 };
14273 }
14274
14275 return {
14276 components: sizePerComponent,
14277 minWidth,
14278 minHeight,
14279 maxNumWide,
14280 maxNumHigh
14281 };
14282 }
14283
14284 function buildPackets(context) {
14285 var siz = context.SIZ;
14286 var tileIndex = context.currentTile.index;
14287 var tile = context.tiles[tileIndex];
14288 var componentsCount = siz.Csiz;
14289
14290 for (var c = 0; c < componentsCount; c++) {
14291 var component = tile.components[c];
14292 var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
14293 var resolutions = [];
14294 var subbands = [];
14295
14296 for (var r = 0; r <= decompositionLevelsCount; r++) {
14297 var blocksDimensions = getBlocksDimensions(context, component, r);
14298 var resolution = {};
14299 var scale = 1 << decompositionLevelsCount - r;
14300 resolution.trx0 = Math.ceil(component.tcx0 / scale);
14301 resolution.try0 = Math.ceil(component.tcy0 / scale);
14302 resolution.trx1 = Math.ceil(component.tcx1 / scale);
14303 resolution.try1 = Math.ceil(component.tcy1 / scale);
14304 resolution.resLevel = r;
14305 buildPrecincts(context, resolution, blocksDimensions);
14306 resolutions.push(resolution);
14307 var subband;
14308
14309 if (r === 0) {
14310 subband = {};
14311 subband.type = "LL";
14312 subband.tbx0 = Math.ceil(component.tcx0 / scale);
14313 subband.tby0 = Math.ceil(component.tcy0 / scale);
14314 subband.tbx1 = Math.ceil(component.tcx1 / scale);
14315 subband.tby1 = Math.ceil(component.tcy1 / scale);
14316 subband.resolution = resolution;
14317 buildCodeblocks(context, subband, blocksDimensions);
14318 subbands.push(subband);
14319 resolution.subbands = [subband];
14320 } else {
14321 var bscale = 1 << decompositionLevelsCount - r + 1;
14322 var resolutionSubbands = [];
14323 subband = {};
14324 subband.type = "HL";
14325 subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
14326 subband.tby0 = Math.ceil(component.tcy0 / bscale);
14327 subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
14328 subband.tby1 = Math.ceil(component.tcy1 / bscale);
14329 subband.resolution = resolution;
14330 buildCodeblocks(context, subband, blocksDimensions);
14331 subbands.push(subband);
14332 resolutionSubbands.push(subband);
14333 subband = {};
14334 subband.type = "LH";
14335 subband.tbx0 = Math.ceil(component.tcx0 / bscale);
14336 subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
14337 subband.tbx1 = Math.ceil(component.tcx1 / bscale);
14338 subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
14339 subband.resolution = resolution;
14340 buildCodeblocks(context, subband, blocksDimensions);
14341 subbands.push(subband);
14342 resolutionSubbands.push(subband);
14343 subband = {};
14344 subband.type = "HH";
14345 subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
14346 subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
14347 subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
14348 subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
14349 subband.resolution = resolution;
14350 buildCodeblocks(context, subband, blocksDimensions);
14351 subbands.push(subband);
14352 resolutionSubbands.push(subband);
14353 resolution.subbands = resolutionSubbands;
14354 }
14355 }
14356
14357 component.resolutions = resolutions;
14358 component.subbands = subbands;
14359 }
14360
14361 var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
14362
14363 switch (progressionOrder) {
14364 case 0:
14365 tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
14366 break;
14367
14368 case 1:
14369 tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
14370 break;
14371
14372 case 2:
14373 tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
14374 break;
14375
14376 case 3:
14377 tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
14378 break;
14379
14380 case 4:
14381 tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
14382 break;
14383
14384 default:
14385 throw new JpxError(`Unsupported progression order ${progressionOrder}`);
14386 }
14387 }
14388
14389 function parseTilePackets(context, data, offset, dataLength) {
14390 var position = 0;
14391 var buffer,
14392 bufferSize = 0,
14393 skipNextBit = false;
14394
14395 function readBits(count) {
14396 while (bufferSize < count) {
14397 var b = data[offset + position];
14398 position++;
14399
14400 if (skipNextBit) {
14401 buffer = buffer << 7 | b;
14402 bufferSize += 7;
14403 skipNextBit = false;
14404 } else {
14405 buffer = buffer << 8 | b;
14406 bufferSize += 8;
14407 }
14408
14409 if (b === 0xff) {
14410 skipNextBit = true;
14411 }
14412 }
14413
14414 bufferSize -= count;
14415 return buffer >>> bufferSize & (1 << count) - 1;
14416 }
14417
14418 function skipMarkerIfEqual(value) {
14419 if (data[offset + position - 1] === 0xff && data[offset + position] === value) {
14420 skipBytes(1);
14421 return true;
14422 } else if (data[offset + position] === 0xff && data[offset + position + 1] === value) {
14423 skipBytes(2);
14424 return true;
14425 }
14426
14427 return false;
14428 }
14429
14430 function skipBytes(count) {
14431 position += count;
14432 }
14433
14434 function alignToByte() {
14435 bufferSize = 0;
14436
14437 if (skipNextBit) {
14438 position++;
14439 skipNextBit = false;
14440 }
14441 }
14442
14443 function readCodingpasses() {
14444 if (readBits(1) === 0) {
14445 return 1;
14446 }
14447
14448 if (readBits(1) === 0) {
14449 return 2;
14450 }
14451
14452 var value = readBits(2);
14453
14454 if (value < 3) {
14455 return value + 3;
14456 }
14457
14458 value = readBits(5);
14459
14460 if (value < 31) {
14461 return value + 6;
14462 }
14463
14464 value = readBits(7);
14465 return value + 37;
14466 }
14467
14468 var tileIndex = context.currentTile.index;
14469 var tile = context.tiles[tileIndex];
14470 var sopMarkerUsed = context.COD.sopMarkerUsed;
14471 var ephMarkerUsed = context.COD.ephMarkerUsed;
14472 var packetsIterator = tile.packetsIterator;
14473
14474 while (position < dataLength) {
14475 alignToByte();
14476
14477 if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
14478 skipBytes(4);
14479 }
14480
14481 var packet = packetsIterator.nextPacket();
14482
14483 if (!readBits(1)) {
14484 continue;
14485 }
14486
14487 var layerNumber = packet.layerNumber;
14488 var queue = [],
14489 codeblock;
14490
14491 for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
14492 codeblock = packet.codeblocks[i];
14493 var precinct = codeblock.precinct;
14494 var codeblockColumn = codeblock.cbx - precinct.cbxMin;
14495 var codeblockRow = codeblock.cby - precinct.cbyMin;
14496 var codeblockIncluded = false;
14497 var firstTimeInclusion = false;
14498 var valueReady;
14499
14500 if (codeblock.included !== undefined) {
14501 codeblockIncluded = !!readBits(1);
14502 } else {
14503 precinct = codeblock.precinct;
14504 var inclusionTree, zeroBitPlanesTree;
14505
14506 if (precinct.inclusionTree !== undefined) {
14507 inclusionTree = precinct.inclusionTree;
14508 } else {
14509 var width = precinct.cbxMax - precinct.cbxMin + 1;
14510 var height = precinct.cbyMax - precinct.cbyMin + 1;
14511 inclusionTree = new InclusionTree(width, height, layerNumber);
14512 zeroBitPlanesTree = new TagTree(width, height);
14513 precinct.inclusionTree = inclusionTree;
14514 precinct.zeroBitPlanesTree = zeroBitPlanesTree;
14515 }
14516
14517 if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
14518 while (true) {
14519 if (readBits(1)) {
14520 valueReady = !inclusionTree.nextLevel();
14521
14522 if (valueReady) {
14523 codeblock.included = true;
14524 codeblockIncluded = firstTimeInclusion = true;
14525 break;
14526 }
14527 } else {
14528 inclusionTree.incrementValue(layerNumber);
14529 break;
14530 }
14531 }
14532 }
14533 }
14534
14535 if (!codeblockIncluded) {
14536 continue;
14537 }
14538
14539 if (firstTimeInclusion) {
14540 zeroBitPlanesTree = precinct.zeroBitPlanesTree;
14541 zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
14542
14543 while (true) {
14544 if (readBits(1)) {
14545 valueReady = !zeroBitPlanesTree.nextLevel();
14546
14547 if (valueReady) {
14548 break;
14549 }
14550 } else {
14551 zeroBitPlanesTree.incrementValue();
14552 }
14553 }
14554
14555 codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
14556 }
14557
14558 var codingpasses = readCodingpasses();
14559
14560 while (readBits(1)) {
14561 codeblock.Lblock++;
14562 }
14563
14564 var codingpassesLog2 = (0, _core_utils.log2)(codingpasses);
14565 var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
14566 var codedDataLength = readBits(bits);
14567 queue.push({
14568 codeblock,
14569 codingpasses,
14570 dataLength: codedDataLength
14571 });
14572 }
14573
14574 alignToByte();
14575
14576 if (ephMarkerUsed) {
14577 skipMarkerIfEqual(0x92);
14578 }
14579
14580 while (queue.length > 0) {
14581 var packetItem = queue.shift();
14582 codeblock = packetItem.codeblock;
14583
14584 if (codeblock.data === undefined) {
14585 codeblock.data = [];
14586 }
14587
14588 codeblock.data.push({
14589 data,
14590 start: offset + position,
14591 end: offset + position + packetItem.dataLength,
14592 codingpasses: packetItem.codingpasses
14593 });
14594 position += packetItem.dataLength;
14595 }
14596 }
14597
14598 return position;
14599 }
14600
14601 function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
14602 var x0 = subband.tbx0;
14603 var y0 = subband.tby0;
14604 var width = subband.tbx1 - subband.tbx0;
14605 var codeblocks = subband.codeblocks;
14606 var right = subband.type.charAt(0) === "H" ? 1 : 0;
14607 var bottom = subband.type.charAt(1) === "H" ? levelWidth : 0;
14608
14609 for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
14610 var codeblock = codeblocks[i];
14611 var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
14612 var blockHeight = codeblock.tby1_ - codeblock.tby0_;
14613
14614 if (blockWidth === 0 || blockHeight === 0) {
14615 continue;
14616 }
14617
14618 if (codeblock.data === undefined) {
14619 continue;
14620 }
14621
14622 var bitModel, currentCodingpassType;
14623 bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
14624 currentCodingpassType = 2;
14625 var data = codeblock.data,
14626 totalLength = 0,
14627 codingpasses = 0;
14628 var j, jj, dataItem;
14629
14630 for (j = 0, jj = data.length; j < jj; j++) {
14631 dataItem = data[j];
14632 totalLength += dataItem.end - dataItem.start;
14633 codingpasses += dataItem.codingpasses;
14634 }
14635
14636 var encodedData = new Uint8Array(totalLength);
14637 var position = 0;
14638
14639 for (j = 0, jj = data.length; j < jj; j++) {
14640 dataItem = data[j];
14641 var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
14642 encodedData.set(chunk, position);
14643 position += chunk.length;
14644 }
14645
14646 var decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
14647 bitModel.setDecoder(decoder);
14648
14649 for (j = 0; j < codingpasses; j++) {
14650 switch (currentCodingpassType) {
14651 case 0:
14652 bitModel.runSignificancePropagationPass();
14653 break;
14654
14655 case 1:
14656 bitModel.runMagnitudeRefinementPass();
14657 break;
14658
14659 case 2:
14660 bitModel.runCleanupPass();
14661
14662 if (segmentationSymbolUsed) {
14663 bitModel.checkSegmentationSymbol();
14664 }
14665
14666 break;
14667 }
14668
14669 currentCodingpassType = (currentCodingpassType + 1) % 3;
14670 }
14671
14672 var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
14673 var sign = bitModel.coefficentsSign;
14674 var magnitude = bitModel.coefficentsMagnitude;
14675 var bitsDecoded = bitModel.bitsDecoded;
14676 var magnitudeCorrection = reversible ? 0 : 0.5;
14677 var k, n, nb;
14678 position = 0;
14679 var interleave = subband.type !== "LL";
14680
14681 for (j = 0; j < blockHeight; j++) {
14682 var row = offset / width | 0;
14683 var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
14684
14685 for (k = 0; k < blockWidth; k++) {
14686 n = magnitude[position];
14687
14688 if (n !== 0) {
14689 n = (n + magnitudeCorrection) * delta;
14690
14691 if (sign[position] !== 0) {
14692 n = -n;
14693 }
14694
14695 nb = bitsDecoded[position];
14696 var pos = interleave ? levelOffset + (offset << 1) : offset;
14697
14698 if (reversible && nb >= mb) {
14699 coefficients[pos] = n;
14700 } else {
14701 coefficients[pos] = n * (1 << mb - nb);
14702 }
14703 }
14704
14705 offset++;
14706 position++;
14707 }
14708
14709 offset += width - blockWidth;
14710 }
14711 }
14712 }
14713
14714 function transformTile(context, tile, c) {
14715 var component = tile.components[c];
14716 var codingStyleParameters = component.codingStyleParameters;
14717 var quantizationParameters = component.quantizationParameters;
14718 var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
14719 var spqcds = quantizationParameters.SPqcds;
14720 var scalarExpounded = quantizationParameters.scalarExpounded;
14721 var guardBits = quantizationParameters.guardBits;
14722 var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
14723 var precision = context.components[c].precision;
14724 var reversible = codingStyleParameters.reversibleTransformation;
14725 var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
14726 var subbandCoefficients = [];
14727 var b = 0;
14728
14729 for (var i = 0; i <= decompositionLevelsCount; i++) {
14730 var resolution = component.resolutions[i];
14731 var width = resolution.trx1 - resolution.trx0;
14732 var height = resolution.try1 - resolution.try0;
14733 var coefficients = new Float32Array(width * height);
14734
14735 for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
14736 var mu, epsilon;
14737
14738 if (!scalarExpounded) {
14739 mu = spqcds[0].mu;
14740 epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
14741 } else {
14742 mu = spqcds[b].mu;
14743 epsilon = spqcds[b].epsilon;
14744 b++;
14745 }
14746
14747 var subband = resolution.subbands[j];
14748 var gainLog2 = SubbandsGainLog2[subband.type];
14749 var delta = reversible ? 1 : 2 ** (precision + gainLog2 - epsilon) * (1 + mu / 2048);
14750 var mb = guardBits + epsilon - 1;
14751 copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
14752 }
14753
14754 subbandCoefficients.push({
14755 width,
14756 height,
14757 items: coefficients
14758 });
14759 }
14760
14761 var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
14762 return {
14763 left: component.tcx0,
14764 top: component.tcy0,
14765 width: result.width,
14766 height: result.height,
14767 items: result.items
14768 };
14769 }
14770
14771 function transformComponents(context) {
14772 var siz = context.SIZ;
14773 var components = context.components;
14774 var componentsCount = siz.Csiz;
14775 var resultImages = [];
14776
14777 for (var i = 0, ii = context.tiles.length; i < ii; i++) {
14778 var tile = context.tiles[i];
14779 var transformedTiles = [];
14780 var c;
14781
14782 for (c = 0; c < componentsCount; c++) {
14783 transformedTiles[c] = transformTile(context, tile, c);
14784 }
14785
14786 var tile0 = transformedTiles[0];
14787 var out = new Uint8ClampedArray(tile0.items.length * componentsCount);
14788 var result = {
14789 left: tile0.left,
14790 top: tile0.top,
14791 width: tile0.width,
14792 height: tile0.height,
14793 items: out
14794 };
14795 var shift, offset;
14796 var pos = 0,
14797 j,
14798 jj,
14799 y0,
14800 y1,
14801 y2;
14802
14803 if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
14804 var fourComponents = componentsCount === 4;
14805 var y0items = transformedTiles[0].items;
14806 var y1items = transformedTiles[1].items;
14807 var y2items = transformedTiles[2].items;
14808 var y3items = fourComponents ? transformedTiles[3].items : null;
14809 shift = components[0].precision - 8;
14810 offset = (128 << shift) + 0.5;
14811 var component0 = tile.components[0];
14812 var alpha01 = componentsCount - 3;
14813 jj = y0items.length;
14814
14815 if (!component0.codingStyleParameters.reversibleTransformation) {
14816 for (j = 0; j < jj; j++, pos += alpha01) {
14817 y0 = y0items[j] + offset;
14818 y1 = y1items[j];
14819 y2 = y2items[j];
14820 out[pos++] = y0 + 1.402 * y2 >> shift;
14821 out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
14822 out[pos++] = y0 + 1.772 * y1 >> shift;
14823 }
14824 } else {
14825 for (j = 0; j < jj; j++, pos += alpha01) {
14826 y0 = y0items[j] + offset;
14827 y1 = y1items[j];
14828 y2 = y2items[j];
14829 const g = y0 - (y2 + y1 >> 2);
14830 out[pos++] = g + y2 >> shift;
14831 out[pos++] = g >> shift;
14832 out[pos++] = g + y1 >> shift;
14833 }
14834 }
14835
14836 if (fourComponents) {
14837 for (j = 0, pos = 3; j < jj; j++, pos += 4) {
14838 out[pos] = y3items[j] + offset >> shift;
14839 }
14840 }
14841 } else {
14842 for (c = 0; c < componentsCount; c++) {
14843 var items = transformedTiles[c].items;
14844 shift = components[c].precision - 8;
14845 offset = (128 << shift) + 0.5;
14846
14847 for (pos = c, j = 0, jj = items.length; j < jj; j++) {
14848 out[pos] = items[j] + offset >> shift;
14849 pos += componentsCount;
14850 }
14851 }
14852 }
14853
14854 resultImages.push(result);
14855 }
14856
14857 return resultImages;
14858 }
14859
14860 function initializeTile(context, tileIndex) {
14861 var siz = context.SIZ;
14862 var componentsCount = siz.Csiz;
14863 var tile = context.tiles[tileIndex];
14864
14865 for (var c = 0; c < componentsCount; c++) {
14866 var component = tile.components[c];
14867 var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
14868 component.quantizationParameters = qcdOrQcc;
14869 var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
14870 component.codingStyleParameters = codOrCoc;
14871 }
14872
14873 tile.codingStyleDefaultParameters = context.currentTile.COD;
14874 }
14875
14876 var TagTree = function TagTreeClosure() {
14877 function TagTree(width, height) {
14878 var levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
14879 this.levels = [];
14880
14881 for (var i = 0; i < levelsLength; i++) {
14882 var level = {
14883 width,
14884 height,
14885 items: []
14886 };
14887 this.levels.push(level);
14888 width = Math.ceil(width / 2);
14889 height = Math.ceil(height / 2);
14890 }
14891 }
14892
14893 TagTree.prototype = {
14894 reset: function TagTree_reset(i, j) {
14895 var currentLevel = 0,
14896 value = 0,
14897 level;
14898
14899 while (currentLevel < this.levels.length) {
14900 level = this.levels[currentLevel];
14901 var index = i + j * level.width;
14902
14903 if (level.items[index] !== undefined) {
14904 value = level.items[index];
14905 break;
14906 }
14907
14908 level.index = index;
14909 i >>= 1;
14910 j >>= 1;
14911 currentLevel++;
14912 }
14913
14914 currentLevel--;
14915 level = this.levels[currentLevel];
14916 level.items[level.index] = value;
14917 this.currentLevel = currentLevel;
14918 delete this.value;
14919 },
14920 incrementValue: function TagTree_incrementValue() {
14921 var level = this.levels[this.currentLevel];
14922 level.items[level.index]++;
14923 },
14924 nextLevel: function TagTree_nextLevel() {
14925 var currentLevel = this.currentLevel;
14926 var level = this.levels[currentLevel];
14927 var value = level.items[level.index];
14928 currentLevel--;
14929
14930 if (currentLevel < 0) {
14931 this.value = value;
14932 return false;
14933 }
14934
14935 this.currentLevel = currentLevel;
14936 level = this.levels[currentLevel];
14937 level.items[level.index] = value;
14938 return true;
14939 }
14940 };
14941 return TagTree;
14942 }();
14943
14944 var InclusionTree = function InclusionTreeClosure() {
14945 function InclusionTree(width, height, defaultValue) {
14946 var levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
14947 this.levels = [];
14948
14949 for (var i = 0; i < levelsLength; i++) {
14950 var items = new Uint8Array(width * height);
14951
14952 for (var j = 0, jj = items.length; j < jj; j++) {
14953 items[j] = defaultValue;
14954 }
14955
14956 var level = {
14957 width,
14958 height,
14959 items
14960 };
14961 this.levels.push(level);
14962 width = Math.ceil(width / 2);
14963 height = Math.ceil(height / 2);
14964 }
14965 }
14966
14967 InclusionTree.prototype = {
14968 reset: function InclusionTree_reset(i, j, stopValue) {
14969 var currentLevel = 0;
14970
14971 while (currentLevel < this.levels.length) {
14972 var level = this.levels[currentLevel];
14973 var index = i + j * level.width;
14974 level.index = index;
14975 var value = level.items[index];
14976
14977 if (value === 0xff) {
14978 break;
14979 }
14980
14981 if (value > stopValue) {
14982 this.currentLevel = currentLevel;
14983 this.propagateValues();
14984 return false;
14985 }
14986
14987 i >>= 1;
14988 j >>= 1;
14989 currentLevel++;
14990 }
14991
14992 this.currentLevel = currentLevel - 1;
14993 return true;
14994 },
14995 incrementValue: function InclusionTree_incrementValue(stopValue) {
14996 var level = this.levels[this.currentLevel];
14997 level.items[level.index] = stopValue + 1;
14998 this.propagateValues();
14999 },
15000 propagateValues: function InclusionTree_propagateValues() {
15001 var levelIndex = this.currentLevel;
15002 var level = this.levels[levelIndex];
15003 var currentValue = level.items[level.index];
15004
15005 while (--levelIndex >= 0) {
15006 level = this.levels[levelIndex];
15007 level.items[level.index] = currentValue;
15008 }
15009 },
15010 nextLevel: function InclusionTree_nextLevel() {
15011 var currentLevel = this.currentLevel;
15012 var level = this.levels[currentLevel];
15013 var value = level.items[level.index];
15014 level.items[level.index] = 0xff;
15015 currentLevel--;
15016
15017 if (currentLevel < 0) {
15018 return false;
15019 }
15020
15021 this.currentLevel = currentLevel;
15022 level = this.levels[currentLevel];
15023 level.items[level.index] = value;
15024 return true;
15025 }
15026 };
15027 return InclusionTree;
15028 }();
15029
15030 var BitModel = function BitModelClosure() {
15031 var UNIFORM_CONTEXT = 17;
15032 var RUNLENGTH_CONTEXT = 18;
15033 var LLAndLHContextsLabel = new Uint8Array([0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8]);
15034 var HLContextLabel = new Uint8Array([0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8]);
15035 var HHContextLabel = new Uint8Array([0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5, 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8]);
15036
15037 function BitModel(width, height, subband, zeroBitPlanes, mb) {
15038 this.width = width;
15039 this.height = height;
15040 let contextLabelTable;
15041
15042 if (subband === "HH") {
15043 contextLabelTable = HHContextLabel;
15044 } else if (subband === "HL") {
15045 contextLabelTable = HLContextLabel;
15046 } else {
15047 contextLabelTable = LLAndLHContextsLabel;
15048 }
15049
15050 this.contextLabelTable = contextLabelTable;
15051 var coefficientCount = width * height;
15052 this.neighborsSignificance = new Uint8Array(coefficientCount);
15053 this.coefficentsSign = new Uint8Array(coefficientCount);
15054 let coefficentsMagnitude;
15055
15056 if (mb > 14) {
15057 coefficentsMagnitude = new Uint32Array(coefficientCount);
15058 } else if (mb > 6) {
15059 coefficentsMagnitude = new Uint16Array(coefficientCount);
15060 } else {
15061 coefficentsMagnitude = new Uint8Array(coefficientCount);
15062 }
15063
15064 this.coefficentsMagnitude = coefficentsMagnitude;
15065 this.processingFlags = new Uint8Array(coefficientCount);
15066 var bitsDecoded = new Uint8Array(coefficientCount);
15067
15068 if (zeroBitPlanes !== 0) {
15069 for (var i = 0; i < coefficientCount; i++) {
15070 bitsDecoded[i] = zeroBitPlanes;
15071 }
15072 }
15073
15074 this.bitsDecoded = bitsDecoded;
15075 this.reset();
15076 }
15077
15078 BitModel.prototype = {
15079 setDecoder: function BitModel_setDecoder(decoder) {
15080 this.decoder = decoder;
15081 },
15082 reset: function BitModel_reset() {
15083 this.contexts = new Int8Array(19);
15084 this.contexts[0] = 4 << 1 | 0;
15085 this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
15086 this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
15087 },
15088 setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
15089 var neighborsSignificance = this.neighborsSignificance;
15090 var width = this.width,
15091 height = this.height;
15092 var left = column > 0;
15093 var right = column + 1 < width;
15094 var i;
15095
15096 if (row > 0) {
15097 i = index - width;
15098
15099 if (left) {
15100 neighborsSignificance[i - 1] += 0x10;
15101 }
15102
15103 if (right) {
15104 neighborsSignificance[i + 1] += 0x10;
15105 }
15106
15107 neighborsSignificance[i] += 0x04;
15108 }
15109
15110 if (row + 1 < height) {
15111 i = index + width;
15112
15113 if (left) {
15114 neighborsSignificance[i - 1] += 0x10;
15115 }
15116
15117 if (right) {
15118 neighborsSignificance[i + 1] += 0x10;
15119 }
15120
15121 neighborsSignificance[i] += 0x04;
15122 }
15123
15124 if (left) {
15125 neighborsSignificance[index - 1] += 0x01;
15126 }
15127
15128 if (right) {
15129 neighborsSignificance[index + 1] += 0x01;
15130 }
15131
15132 neighborsSignificance[index] |= 0x80;
15133 },
15134 runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
15135 var decoder = this.decoder;
15136 var width = this.width,
15137 height = this.height;
15138 var coefficentsMagnitude = this.coefficentsMagnitude;
15139 var coefficentsSign = this.coefficentsSign;
15140 var neighborsSignificance = this.neighborsSignificance;
15141 var processingFlags = this.processingFlags;
15142 var contexts = this.contexts;
15143 var labels = this.contextLabelTable;
15144 var bitsDecoded = this.bitsDecoded;
15145 var processedInverseMask = ~1;
15146 var processedMask = 1;
15147 var firstMagnitudeBitMask = 2;
15148
15149 for (var i0 = 0; i0 < height; i0 += 4) {
15150 for (var j = 0; j < width; j++) {
15151 var index = i0 * width + j;
15152
15153 for (var i1 = 0; i1 < 4; i1++, index += width) {
15154 var i = i0 + i1;
15155
15156 if (i >= height) {
15157 break;
15158 }
15159
15160 processingFlags[index] &= processedInverseMask;
15161
15162 if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
15163 continue;
15164 }
15165
15166 var contextLabel = labels[neighborsSignificance[index]];
15167 var decision = decoder.readBit(contexts, contextLabel);
15168
15169 if (decision) {
15170 var sign = this.decodeSignBit(i, j, index);
15171 coefficentsSign[index] = sign;
15172 coefficentsMagnitude[index] = 1;
15173 this.setNeighborsSignificance(i, j, index);
15174 processingFlags[index] |= firstMagnitudeBitMask;
15175 }
15176
15177 bitsDecoded[index]++;
15178 processingFlags[index] |= processedMask;
15179 }
15180 }
15181 }
15182 },
15183 decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
15184 var width = this.width,
15185 height = this.height;
15186 var coefficentsMagnitude = this.coefficentsMagnitude;
15187 var coefficentsSign = this.coefficentsSign;
15188 var contribution, sign0, sign1, significance1;
15189 var contextLabel, decoded;
15190 significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
15191
15192 if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
15193 sign1 = coefficentsSign[index + 1];
15194
15195 if (significance1) {
15196 sign0 = coefficentsSign[index - 1];
15197 contribution = 1 - sign1 - sign0;
15198 } else {
15199 contribution = 1 - sign1 - sign1;
15200 }
15201 } else if (significance1) {
15202 sign0 = coefficentsSign[index - 1];
15203 contribution = 1 - sign0 - sign0;
15204 } else {
15205 contribution = 0;
15206 }
15207
15208 var horizontalContribution = 3 * contribution;
15209 significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
15210
15211 if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
15212 sign1 = coefficentsSign[index + width];
15213
15214 if (significance1) {
15215 sign0 = coefficentsSign[index - width];
15216 contribution = 1 - sign1 - sign0 + horizontalContribution;
15217 } else {
15218 contribution = 1 - sign1 - sign1 + horizontalContribution;
15219 }
15220 } else if (significance1) {
15221 sign0 = coefficentsSign[index - width];
15222 contribution = 1 - sign0 - sign0 + horizontalContribution;
15223 } else {
15224 contribution = horizontalContribution;
15225 }
15226
15227 if (contribution >= 0) {
15228 contextLabel = 9 + contribution;
15229 decoded = this.decoder.readBit(this.contexts, contextLabel);
15230 } else {
15231 contextLabel = 9 - contribution;
15232 decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
15233 }
15234
15235 return decoded;
15236 },
15237 runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
15238 var decoder = this.decoder;
15239 var width = this.width,
15240 height = this.height;
15241 var coefficentsMagnitude = this.coefficentsMagnitude;
15242 var neighborsSignificance = this.neighborsSignificance;
15243 var contexts = this.contexts;
15244 var bitsDecoded = this.bitsDecoded;
15245 var processingFlags = this.processingFlags;
15246 var processedMask = 1;
15247 var firstMagnitudeBitMask = 2;
15248 var length = width * height;
15249 var width4 = width * 4;
15250
15251 for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
15252 indexNext = Math.min(length, index0 + width4);
15253
15254 for (var j = 0; j < width; j++) {
15255 for (var index = index0 + j; index < indexNext; index += width) {
15256 if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
15257 continue;
15258 }
15259
15260 var contextLabel = 16;
15261
15262 if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
15263 processingFlags[index] ^= firstMagnitudeBitMask;
15264 var significance = neighborsSignificance[index] & 127;
15265 contextLabel = significance === 0 ? 15 : 14;
15266 }
15267
15268 var bit = decoder.readBit(contexts, contextLabel);
15269 coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
15270 bitsDecoded[index]++;
15271 processingFlags[index] |= processedMask;
15272 }
15273 }
15274 }
15275 },
15276 runCleanupPass: function BitModel_runCleanupPass() {
15277 var decoder = this.decoder;
15278 var width = this.width,
15279 height = this.height;
15280 var neighborsSignificance = this.neighborsSignificance;
15281 var coefficentsMagnitude = this.coefficentsMagnitude;
15282 var coefficentsSign = this.coefficentsSign;
15283 var contexts = this.contexts;
15284 var labels = this.contextLabelTable;
15285 var bitsDecoded = this.bitsDecoded;
15286 var processingFlags = this.processingFlags;
15287 var processedMask = 1;
15288 var firstMagnitudeBitMask = 2;
15289 var oneRowDown = width;
15290 var twoRowsDown = width * 2;
15291 var threeRowsDown = width * 3;
15292 var iNext;
15293
15294 for (var i0 = 0; i0 < height; i0 = iNext) {
15295 iNext = Math.min(i0 + 4, height);
15296 var indexBase = i0 * width;
15297 var checkAllEmpty = i0 + 3 < height;
15298
15299 for (var j = 0; j < width; j++) {
15300 var index0 = indexBase + j;
15301 var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
15302 var i1 = 0,
15303 index = index0;
15304 var i = i0,
15305 sign;
15306
15307 if (allEmpty) {
15308 var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
15309
15310 if (!hasSignificantCoefficent) {
15311 bitsDecoded[index0]++;
15312 bitsDecoded[index0 + oneRowDown]++;
15313 bitsDecoded[index0 + twoRowsDown]++;
15314 bitsDecoded[index0 + threeRowsDown]++;
15315 continue;
15316 }
15317
15318 i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
15319
15320 if (i1 !== 0) {
15321 i = i0 + i1;
15322 index += i1 * width;
15323 }
15324
15325 sign = this.decodeSignBit(i, j, index);
15326 coefficentsSign[index] = sign;
15327 coefficentsMagnitude[index] = 1;
15328 this.setNeighborsSignificance(i, j, index);
15329 processingFlags[index] |= firstMagnitudeBitMask;
15330 index = index0;
15331
15332 for (var i2 = i0; i2 <= i; i2++, index += width) {
15333 bitsDecoded[index]++;
15334 }
15335
15336 i1++;
15337 }
15338
15339 for (i = i0 + i1; i < iNext; i++, index += width) {
15340 if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
15341 continue;
15342 }
15343
15344 var contextLabel = labels[neighborsSignificance[index]];
15345 var decision = decoder.readBit(contexts, contextLabel);
15346
15347 if (decision === 1) {
15348 sign = this.decodeSignBit(i, j, index);
15349 coefficentsSign[index] = sign;
15350 coefficentsMagnitude[index] = 1;
15351 this.setNeighborsSignificance(i, j, index);
15352 processingFlags[index] |= firstMagnitudeBitMask;
15353 }
15354
15355 bitsDecoded[index]++;
15356 }
15357 }
15358 }
15359 },
15360 checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
15361 var decoder = this.decoder;
15362 var contexts = this.contexts;
15363 var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
15364
15365 if (symbol !== 0xa) {
15366 throw new JpxError("Invalid segmentation symbol");
15367 }
15368 }
15369 };
15370 return BitModel;
15371 }();
15372
15373 var Transform = function TransformClosure() {
15374 function Transform() {}
15375
15376 Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
15377 var ll = subbands[0];
15378
15379 for (var i = 1, ii = subbands.length; i < ii; i++) {
15380 ll = this.iterate(ll, subbands[i], u0, v0);
15381 }
15382
15383 return ll;
15384 };
15385
15386 Transform.prototype.extend = function extend(buffer, offset, size) {
15387 var i1 = offset - 1,
15388 j1 = offset + 1;
15389 var i2 = offset + size - 2,
15390 j2 = offset + size;
15391 buffer[i1--] = buffer[j1++];
15392 buffer[j2++] = buffer[i2--];
15393 buffer[i1--] = buffer[j1++];
15394 buffer[j2++] = buffer[i2--];
15395 buffer[i1--] = buffer[j1++];
15396 buffer[j2++] = buffer[i2--];
15397 buffer[i1] = buffer[j1];
15398 buffer[j2] = buffer[i2];
15399 };
15400
15401 Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
15402 var llWidth = ll.width,
15403 llHeight = ll.height,
15404 llItems = ll.items;
15405 var width = hl_lh_hh.width;
15406 var height = hl_lh_hh.height;
15407 var items = hl_lh_hh.items;
15408 var i, j, k, l, u, v;
15409
15410 for (k = 0, i = 0; i < llHeight; i++) {
15411 l = i * 2 * width;
15412
15413 for (j = 0; j < llWidth; j++, k++, l += 2) {
15414 items[l] = llItems[k];
15415 }
15416 }
15417
15418 llItems = ll.items = null;
15419 var bufferPadding = 4;
15420 var rowBuffer = new Float32Array(width + 2 * bufferPadding);
15421
15422 if (width === 1) {
15423 if ((u0 & 1) !== 0) {
15424 for (v = 0, k = 0; v < height; v++, k += width) {
15425 items[k] *= 0.5;
15426 }
15427 }
15428 } else {
15429 for (v = 0, k = 0; v < height; v++, k += width) {
15430 rowBuffer.set(items.subarray(k, k + width), bufferPadding);
15431 this.extend(rowBuffer, bufferPadding, width);
15432 this.filter(rowBuffer, bufferPadding, width);
15433 items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
15434 }
15435 }
15436
15437 var numBuffers = 16;
15438 var colBuffers = [];
15439
15440 for (i = 0; i < numBuffers; i++) {
15441 colBuffers.push(new Float32Array(height + 2 * bufferPadding));
15442 }
15443
15444 var b,
15445 currentBuffer = 0;
15446 ll = bufferPadding + height;
15447
15448 if (height === 1) {
15449 if ((v0 & 1) !== 0) {
15450 for (u = 0; u < width; u++) {
15451 items[u] *= 0.5;
15452 }
15453 }
15454 } else {
15455 for (u = 0; u < width; u++) {
15456 if (currentBuffer === 0) {
15457 numBuffers = Math.min(width - u, numBuffers);
15458
15459 for (k = u, l = bufferPadding; l < ll; k += width, l++) {
15460 for (b = 0; b < numBuffers; b++) {
15461 colBuffers[b][l] = items[k + b];
15462 }
15463 }
15464
15465 currentBuffer = numBuffers;
15466 }
15467
15468 currentBuffer--;
15469 var buffer = colBuffers[currentBuffer];
15470 this.extend(buffer, bufferPadding, height);
15471 this.filter(buffer, bufferPadding, height);
15472
15473 if (currentBuffer === 0) {
15474 k = u - numBuffers + 1;
15475
15476 for (l = bufferPadding; l < ll; k += width, l++) {
15477 for (b = 0; b < numBuffers; b++) {
15478 items[k + b] = colBuffers[b][l];
15479 }
15480 }
15481 }
15482 }
15483 }
15484
15485 return {
15486 width,
15487 height,
15488 items
15489 };
15490 };
15491
15492 return Transform;
15493 }();
15494
15495 var IrreversibleTransform = function IrreversibleTransformClosure() {
15496 function IrreversibleTransform() {
15497 Transform.call(this);
15498 }
15499
15500 IrreversibleTransform.prototype = Object.create(Transform.prototype);
15501
15502 IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
15503 var len = length >> 1;
15504 offset = offset | 0;
15505 var j, n, current, next;
15506 var alpha = -1.586134342059924;
15507 var beta = -0.052980118572961;
15508 var gamma = 0.882911075530934;
15509 var delta = 0.443506852043971;
15510 var K = 1.230174104914001;
15511 var K_ = 1 / K;
15512 j = offset - 3;
15513
15514 for (n = len + 4; n--; j += 2) {
15515 x[j] *= K_;
15516 }
15517
15518 j = offset - 2;
15519 current = delta * x[j - 1];
15520
15521 for (n = len + 3; n--; j += 2) {
15522 next = delta * x[j + 1];
15523 x[j] = K * x[j] - current - next;
15524
15525 if (n--) {
15526 j += 2;
15527 current = delta * x[j + 1];
15528 x[j] = K * x[j] - current - next;
15529 } else {
15530 break;
15531 }
15532 }
15533
15534 j = offset - 1;
15535 current = gamma * x[j - 1];
15536
15537 for (n = len + 2; n--; j += 2) {
15538 next = gamma * x[j + 1];
15539 x[j] -= current + next;
15540
15541 if (n--) {
15542 j += 2;
15543 current = gamma * x[j + 1];
15544 x[j] -= current + next;
15545 } else {
15546 break;
15547 }
15548 }
15549
15550 j = offset;
15551 current = beta * x[j - 1];
15552
15553 for (n = len + 1; n--; j += 2) {
15554 next = beta * x[j + 1];
15555 x[j] -= current + next;
15556
15557 if (n--) {
15558 j += 2;
15559 current = beta * x[j + 1];
15560 x[j] -= current + next;
15561 } else {
15562 break;
15563 }
15564 }
15565
15566 if (len !== 0) {
15567 j = offset + 1;
15568 current = alpha * x[j - 1];
15569
15570 for (n = len; n--; j += 2) {
15571 next = alpha * x[j + 1];
15572 x[j] -= current + next;
15573
15574 if (n--) {
15575 j += 2;
15576 current = alpha * x[j + 1];
15577 x[j] -= current + next;
15578 } else {
15579 break;
15580 }
15581 }
15582 }
15583 };
15584
15585 return IrreversibleTransform;
15586 }();
15587
15588 var ReversibleTransform = function ReversibleTransformClosure() {
15589 function ReversibleTransform() {
15590 Transform.call(this);
15591 }
15592
15593 ReversibleTransform.prototype = Object.create(Transform.prototype);
15594
15595 ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
15596 var len = length >> 1;
15597 offset = offset | 0;
15598 var j, n;
15599
15600 for (j = offset, n = len + 1; n--; j += 2) {
15601 x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
15602 }
15603
15604 for (j = offset + 1, n = len; n--; j += 2) {
15605 x[j] += x[j - 1] + x[j + 1] >> 1;
15606 }
15607 };
15608
15609 return ReversibleTransform;
15610 }();
15611
15612 return JpxImage;
15613}();
15614
15615exports.JpxImage = JpxImage;
15616
15617/***/ }),
15618/* 22 */
15619/***/ (function(module, exports, __w_pdfjs_require__) {
15620
15621"use strict";
15622
15623
15624Object.defineProperty(exports, "__esModule", {
15625 value: true
15626});
15627exports.calculateSHA512 = exports.calculateSHA384 = exports.calculateSHA256 = exports.calculateMD5 = exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;
15628
15629var _util = __w_pdfjs_require__(2);
15630
15631var _primitives = __w_pdfjs_require__(5);
15632
15633var _stream = __w_pdfjs_require__(12);
15634
15635var ARCFourCipher = function ARCFourCipherClosure() {
15636 function ARCFourCipher(key) {
15637 this.a = 0;
15638 this.b = 0;
15639 var s = new Uint8Array(256);
15640 var i,
15641 j = 0,
15642 tmp,
15643 keyLength = key.length;
15644
15645 for (i = 0; i < 256; ++i) {
15646 s[i] = i;
15647 }
15648
15649 for (i = 0; i < 256; ++i) {
15650 tmp = s[i];
15651 j = j + tmp + key[i % keyLength] & 0xff;
15652 s[i] = s[j];
15653 s[j] = tmp;
15654 }
15655
15656 this.s = s;
15657 }
15658
15659 ARCFourCipher.prototype = {
15660 encryptBlock: function ARCFourCipher_encryptBlock(data) {
15661 var i,
15662 n = data.length,
15663 tmp,
15664 tmp2;
15665 var a = this.a,
15666 b = this.b,
15667 s = this.s;
15668 var output = new Uint8Array(n);
15669
15670 for (i = 0; i < n; ++i) {
15671 a = a + 1 & 0xff;
15672 tmp = s[a];
15673 b = b + tmp & 0xff;
15674 tmp2 = s[b];
15675 s[a] = tmp2;
15676 s[b] = tmp;
15677 output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
15678 }
15679
15680 this.a = a;
15681 this.b = b;
15682 return output;
15683 }
15684 };
15685 ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
15686 return ARCFourCipher;
15687}();
15688
15689exports.ARCFourCipher = ARCFourCipher;
15690
15691var calculateMD5 = function calculateMD5Closure() {
15692 var r = new Uint8Array([7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]);
15693 var k = new Int32Array([-680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426, -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162, 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632, 643717713, -373897302, -701558691, 38016083, -660478335, -405537848, 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784, 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556, -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222, -722521979, 76029189, -640364487, -421815835, 530742520, -995338651, -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606, -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649, -145523070, -1120210379, 718787259, -343485551]);
15694
15695 function hash(data, offset, length) {
15696 var h0 = 1732584193,
15697 h1 = -271733879,
15698 h2 = -1732584194,
15699 h3 = 271733878;
15700 var paddedLength = length + 72 & ~63;
15701 var padded = new Uint8Array(paddedLength);
15702 var i, j, n;
15703
15704 for (i = 0; i < length; ++i) {
15705 padded[i] = data[offset++];
15706 }
15707
15708 padded[i++] = 0x80;
15709 n = paddedLength - 8;
15710
15711 while (i < n) {
15712 padded[i++] = 0;
15713 }
15714
15715 padded[i++] = length << 3 & 0xff;
15716 padded[i++] = length >> 5 & 0xff;
15717 padded[i++] = length >> 13 & 0xff;
15718 padded[i++] = length >> 21 & 0xff;
15719 padded[i++] = length >>> 29 & 0xff;
15720 padded[i++] = 0;
15721 padded[i++] = 0;
15722 padded[i++] = 0;
15723 var w = new Int32Array(16);
15724
15725 for (i = 0; i < paddedLength;) {
15726 for (j = 0; j < 16; ++j, i += 4) {
15727 w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
15728 }
15729
15730 var a = h0,
15731 b = h1,
15732 c = h2,
15733 d = h3,
15734 f,
15735 g;
15736
15737 for (j = 0; j < 64; ++j) {
15738 if (j < 16) {
15739 f = b & c | ~b & d;
15740 g = j;
15741 } else if (j < 32) {
15742 f = d & b | ~d & c;
15743 g = 5 * j + 1 & 15;
15744 } else if (j < 48) {
15745 f = b ^ c ^ d;
15746 g = 3 * j + 5 & 15;
15747 } else {
15748 f = c ^ (b | ~d);
15749 g = 7 * j & 15;
15750 }
15751
15752 var tmp = d,
15753 rotateArg = a + f + k[j] + w[g] | 0,
15754 rotate = r[j];
15755 d = c;
15756 c = b;
15757 b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
15758 a = tmp;
15759 }
15760
15761 h0 = h0 + a | 0;
15762 h1 = h1 + b | 0;
15763 h2 = h2 + c | 0;
15764 h3 = h3 + d | 0;
15765 }
15766
15767 return new Uint8Array([h0 & 0xFF, h0 >> 8 & 0xFF, h0 >> 16 & 0xFF, h0 >>> 24 & 0xFF, h1 & 0xFF, h1 >> 8 & 0xFF, h1 >> 16 & 0xFF, h1 >>> 24 & 0xFF, h2 & 0xFF, h2 >> 8 & 0xFF, h2 >> 16 & 0xFF, h2 >>> 24 & 0xFF, h3 & 0xFF, h3 >> 8 & 0xFF, h3 >> 16 & 0xFF, h3 >>> 24 & 0xFF]);
15768 }
15769
15770 return hash;
15771}();
15772
15773exports.calculateMD5 = calculateMD5;
15774
15775var Word64 = function Word64Closure() {
15776 function Word64(highInteger, lowInteger) {
15777 this.high = highInteger | 0;
15778 this.low = lowInteger | 0;
15779 }
15780
15781 Word64.prototype = {
15782 and: function Word64_and(word) {
15783 this.high &= word.high;
15784 this.low &= word.low;
15785 },
15786 xor: function Word64_xor(word) {
15787 this.high ^= word.high;
15788 this.low ^= word.low;
15789 },
15790 or: function Word64_or(word) {
15791 this.high |= word.high;
15792 this.low |= word.low;
15793 },
15794 shiftRight: function Word64_shiftRight(places) {
15795 if (places >= 32) {
15796 this.low = this.high >>> places - 32 | 0;
15797 this.high = 0;
15798 } else {
15799 this.low = this.low >>> places | this.high << 32 - places;
15800 this.high = this.high >>> places | 0;
15801 }
15802 },
15803 shiftLeft: function Word64_shiftLeft(places) {
15804 if (places >= 32) {
15805 this.high = this.low << places - 32;
15806 this.low = 0;
15807 } else {
15808 this.high = this.high << places | this.low >>> 32 - places;
15809 this.low = this.low << places;
15810 }
15811 },
15812 rotateRight: function Word64_rotateRight(places) {
15813 var low, high;
15814
15815 if (places & 32) {
15816 high = this.low;
15817 low = this.high;
15818 } else {
15819 low = this.low;
15820 high = this.high;
15821 }
15822
15823 places &= 31;
15824 this.low = low >>> places | high << 32 - places;
15825 this.high = high >>> places | low << 32 - places;
15826 },
15827 not: function Word64_not() {
15828 this.high = ~this.high;
15829 this.low = ~this.low;
15830 },
15831 add: function Word64_add(word) {
15832 var lowAdd = (this.low >>> 0) + (word.low >>> 0);
15833 var highAdd = (this.high >>> 0) + (word.high >>> 0);
15834
15835 if (lowAdd > 0xffffffff) {
15836 highAdd += 1;
15837 }
15838
15839 this.low = lowAdd | 0;
15840 this.high = highAdd | 0;
15841 },
15842 copyTo: function Word64_copyTo(bytes, offset) {
15843 bytes[offset] = this.high >>> 24 & 0xff;
15844 bytes[offset + 1] = this.high >> 16 & 0xff;
15845 bytes[offset + 2] = this.high >> 8 & 0xff;
15846 bytes[offset + 3] = this.high & 0xff;
15847 bytes[offset + 4] = this.low >>> 24 & 0xff;
15848 bytes[offset + 5] = this.low >> 16 & 0xff;
15849 bytes[offset + 6] = this.low >> 8 & 0xff;
15850 bytes[offset + 7] = this.low & 0xff;
15851 },
15852 assign: function Word64_assign(word) {
15853 this.high = word.high;
15854 this.low = word.low;
15855 }
15856 };
15857 return Word64;
15858}();
15859
15860var calculateSHA256 = function calculateSHA256Closure() {
15861 function rotr(x, n) {
15862 return x >>> n | x << 32 - n;
15863 }
15864
15865 function ch(x, y, z) {
15866 return x & y ^ ~x & z;
15867 }
15868
15869 function maj(x, y, z) {
15870 return x & y ^ x & z ^ y & z;
15871 }
15872
15873 function sigma(x) {
15874 return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
15875 }
15876
15877 function sigmaPrime(x) {
15878 return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
15879 }
15880
15881 function littleSigma(x) {
15882 return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
15883 }
15884
15885 function littleSigmaPrime(x) {
15886 return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
15887 }
15888
15889 var k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
15890
15891 function hash(data, offset, length) {
15892 var h0 = 0x6a09e667,
15893 h1 = 0xbb67ae85,
15894 h2 = 0x3c6ef372,
15895 h3 = 0xa54ff53a,
15896 h4 = 0x510e527f,
15897 h5 = 0x9b05688c,
15898 h6 = 0x1f83d9ab,
15899 h7 = 0x5be0cd19;
15900 var paddedLength = Math.ceil((length + 9) / 64) * 64;
15901 var padded = new Uint8Array(paddedLength);
15902 var i, j, n;
15903
15904 for (i = 0; i < length; ++i) {
15905 padded[i] = data[offset++];
15906 }
15907
15908 padded[i++] = 0x80;
15909 n = paddedLength - 8;
15910
15911 while (i < n) {
15912 padded[i++] = 0;
15913 }
15914
15915 padded[i++] = 0;
15916 padded[i++] = 0;
15917 padded[i++] = 0;
15918 padded[i++] = length >>> 29 & 0xff;
15919 padded[i++] = length >> 21 & 0xff;
15920 padded[i++] = length >> 13 & 0xff;
15921 padded[i++] = length >> 5 & 0xff;
15922 padded[i++] = length << 3 & 0xff;
15923 var w = new Uint32Array(64);
15924
15925 for (i = 0; i < paddedLength;) {
15926 for (j = 0; j < 16; ++j) {
15927 w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
15928 i += 4;
15929 }
15930
15931 for (j = 16; j < 64; ++j) {
15932 w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
15933 }
15934
15935 var a = h0,
15936 b = h1,
15937 c = h2,
15938 d = h3,
15939 e = h4,
15940 f = h5,
15941 g = h6,
15942 h = h7,
15943 t1,
15944 t2;
15945
15946 for (j = 0; j < 64; ++j) {
15947 t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
15948 t2 = sigma(a) + maj(a, b, c);
15949 h = g;
15950 g = f;
15951 f = e;
15952 e = d + t1 | 0;
15953 d = c;
15954 c = b;
15955 b = a;
15956 a = t1 + t2 | 0;
15957 }
15958
15959 h0 = h0 + a | 0;
15960 h1 = h1 + b | 0;
15961 h2 = h2 + c | 0;
15962 h3 = h3 + d | 0;
15963 h4 = h4 + e | 0;
15964 h5 = h5 + f | 0;
15965 h6 = h6 + g | 0;
15966 h7 = h7 + h | 0;
15967 }
15968
15969 return new Uint8Array([h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF, h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF]);
15970 }
15971
15972 return hash;
15973}();
15974
15975exports.calculateSHA256 = calculateSHA256;
15976
15977var calculateSHA512 = function calculateSHA512Closure() {
15978 function ch(result, x, y, z, tmp) {
15979 result.assign(x);
15980 result.and(y);
15981 tmp.assign(x);
15982 tmp.not();
15983 tmp.and(z);
15984 result.xor(tmp);
15985 }
15986
15987 function maj(result, x, y, z, tmp) {
15988 result.assign(x);
15989 result.and(y);
15990 tmp.assign(x);
15991 tmp.and(z);
15992 result.xor(tmp);
15993 tmp.assign(y);
15994 tmp.and(z);
15995 result.xor(tmp);
15996 }
15997
15998 function sigma(result, x, tmp) {
15999 result.assign(x);
16000 result.rotateRight(28);
16001 tmp.assign(x);
16002 tmp.rotateRight(34);
16003 result.xor(tmp);
16004 tmp.assign(x);
16005 tmp.rotateRight(39);
16006 result.xor(tmp);
16007 }
16008
16009 function sigmaPrime(result, x, tmp) {
16010 result.assign(x);
16011 result.rotateRight(14);
16012 tmp.assign(x);
16013 tmp.rotateRight(18);
16014 result.xor(tmp);
16015 tmp.assign(x);
16016 tmp.rotateRight(41);
16017 result.xor(tmp);
16018 }
16019
16020 function littleSigma(result, x, tmp) {
16021 result.assign(x);
16022 result.rotateRight(1);
16023 tmp.assign(x);
16024 tmp.rotateRight(8);
16025 result.xor(tmp);
16026 tmp.assign(x);
16027 tmp.shiftRight(7);
16028 result.xor(tmp);
16029 }
16030
16031 function littleSigmaPrime(result, x, tmp) {
16032 result.assign(x);
16033 result.rotateRight(19);
16034 tmp.assign(x);
16035 tmp.rotateRight(61);
16036 result.xor(tmp);
16037 tmp.assign(x);
16038 tmp.shiftRight(6);
16039 result.xor(tmp);
16040 }
16041
16042 var k = [new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)];
16043
16044 function hash(data, offset, length, mode384) {
16045 mode384 = !!mode384;
16046 var h0, h1, h2, h3, h4, h5, h6, h7;
16047
16048 if (!mode384) {
16049 h0 = new Word64(0x6a09e667, 0xf3bcc908);
16050 h1 = new Word64(0xbb67ae85, 0x84caa73b);
16051 h2 = new Word64(0x3c6ef372, 0xfe94f82b);
16052 h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
16053 h4 = new Word64(0x510e527f, 0xade682d1);
16054 h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
16055 h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
16056 h7 = new Word64(0x5be0cd19, 0x137e2179);
16057 } else {
16058 h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
16059 h1 = new Word64(0x629a292a, 0x367cd507);
16060 h2 = new Word64(0x9159015a, 0x3070dd17);
16061 h3 = new Word64(0x152fecd8, 0xf70e5939);
16062 h4 = new Word64(0x67332667, 0xffc00b31);
16063 h5 = new Word64(0x8eb44a87, 0x68581511);
16064 h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
16065 h7 = new Word64(0x47b5481d, 0xbefa4fa4);
16066 }
16067
16068 var paddedLength = Math.ceil((length + 17) / 128) * 128;
16069 var padded = new Uint8Array(paddedLength);
16070 var i, j, n;
16071
16072 for (i = 0; i < length; ++i) {
16073 padded[i] = data[offset++];
16074 }
16075
16076 padded[i++] = 0x80;
16077 n = paddedLength - 16;
16078
16079 while (i < n) {
16080 padded[i++] = 0;
16081 }
16082
16083 padded[i++] = 0;
16084 padded[i++] = 0;
16085 padded[i++] = 0;
16086 padded[i++] = 0;
16087 padded[i++] = 0;
16088 padded[i++] = 0;
16089 padded[i++] = 0;
16090 padded[i++] = 0;
16091 padded[i++] = 0;
16092 padded[i++] = 0;
16093 padded[i++] = 0;
16094 padded[i++] = length >>> 29 & 0xff;
16095 padded[i++] = length >> 21 & 0xff;
16096 padded[i++] = length >> 13 & 0xff;
16097 padded[i++] = length >> 5 & 0xff;
16098 padded[i++] = length << 3 & 0xff;
16099 var w = new Array(80);
16100
16101 for (i = 0; i < 80; i++) {
16102 w[i] = new Word64(0, 0);
16103 }
16104
16105 var a = new Word64(0, 0),
16106 b = new Word64(0, 0),
16107 c = new Word64(0, 0);
16108 var d = new Word64(0, 0),
16109 e = new Word64(0, 0),
16110 f = new Word64(0, 0);
16111 var g = new Word64(0, 0),
16112 h = new Word64(0, 0);
16113 var t1 = new Word64(0, 0),
16114 t2 = new Word64(0, 0);
16115 var tmp1 = new Word64(0, 0),
16116 tmp2 = new Word64(0, 0),
16117 tmp3;
16118
16119 for (i = 0; i < paddedLength;) {
16120 for (j = 0; j < 16; ++j) {
16121 w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
16122 w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
16123 i += 8;
16124 }
16125
16126 for (j = 16; j < 80; ++j) {
16127 tmp3 = w[j];
16128 littleSigmaPrime(tmp3, w[j - 2], tmp2);
16129 tmp3.add(w[j - 7]);
16130 littleSigma(tmp1, w[j - 15], tmp2);
16131 tmp3.add(tmp1);
16132 tmp3.add(w[j - 16]);
16133 }
16134
16135 a.assign(h0);
16136 b.assign(h1);
16137 c.assign(h2);
16138 d.assign(h3);
16139 e.assign(h4);
16140 f.assign(h5);
16141 g.assign(h6);
16142 h.assign(h7);
16143
16144 for (j = 0; j < 80; ++j) {
16145 t1.assign(h);
16146 sigmaPrime(tmp1, e, tmp2);
16147 t1.add(tmp1);
16148 ch(tmp1, e, f, g, tmp2);
16149 t1.add(tmp1);
16150 t1.add(k[j]);
16151 t1.add(w[j]);
16152 sigma(t2, a, tmp2);
16153 maj(tmp1, a, b, c, tmp2);
16154 t2.add(tmp1);
16155 tmp3 = h;
16156 h = g;
16157 g = f;
16158 f = e;
16159 d.add(t1);
16160 e = d;
16161 d = c;
16162 c = b;
16163 b = a;
16164 tmp3.assign(t1);
16165 tmp3.add(t2);
16166 a = tmp3;
16167 }
16168
16169 h0.add(a);
16170 h1.add(b);
16171 h2.add(c);
16172 h3.add(d);
16173 h4.add(e);
16174 h5.add(f);
16175 h6.add(g);
16176 h7.add(h);
16177 }
16178
16179 var result;
16180
16181 if (!mode384) {
16182 result = new Uint8Array(64);
16183 h0.copyTo(result, 0);
16184 h1.copyTo(result, 8);
16185 h2.copyTo(result, 16);
16186 h3.copyTo(result, 24);
16187 h4.copyTo(result, 32);
16188 h5.copyTo(result, 40);
16189 h6.copyTo(result, 48);
16190 h7.copyTo(result, 56);
16191 } else {
16192 result = new Uint8Array(48);
16193 h0.copyTo(result, 0);
16194 h1.copyTo(result, 8);
16195 h2.copyTo(result, 16);
16196 h3.copyTo(result, 24);
16197 h4.copyTo(result, 32);
16198 h5.copyTo(result, 40);
16199 }
16200
16201 return result;
16202 }
16203
16204 return hash;
16205}();
16206
16207exports.calculateSHA512 = calculateSHA512;
16208
16209var calculateSHA384 = function calculateSHA384Closure() {
16210 function hash(data, offset, length) {
16211 return calculateSHA512(data, offset, length, true);
16212 }
16213
16214 return hash;
16215}();
16216
16217exports.calculateSHA384 = calculateSHA384;
16218
16219var NullCipher = function NullCipherClosure() {
16220 function NullCipher() {}
16221
16222 NullCipher.prototype = {
16223 decryptBlock: function NullCipher_decryptBlock(data) {
16224 return data;
16225 }
16226 };
16227 return NullCipher;
16228}();
16229
16230class AESBaseCipher {
16231 constructor() {
16232 if (this.constructor === AESBaseCipher) {
16233 (0, _util.unreachable)("Cannot initialize AESBaseCipher.");
16234 }
16235
16236 this._s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
16237 this._inv_s = new Uint8Array([0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]);
16238 this._mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
16239 this._mixCol = new Uint8Array(256);
16240
16241 for (let i = 0; i < 256; i++) {
16242 if (i < 128) {
16243 this._mixCol[i] = i << 1;
16244 } else {
16245 this._mixCol[i] = i << 1 ^ 0x1b;
16246 }
16247 }
16248
16249 this.buffer = new Uint8Array(16);
16250 this.bufferPosition = 0;
16251 }
16252
16253 _expandKey(cipherKey) {
16254 (0, _util.unreachable)("Cannot call `_expandKey` on the base class");
16255 }
16256
16257 _decrypt(input, key) {
16258 let t, u, v;
16259 const state = new Uint8Array(16);
16260 state.set(input);
16261
16262 for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
16263 state[j] ^= key[k];
16264 }
16265
16266 for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
16267 t = state[13];
16268 state[13] = state[9];
16269 state[9] = state[5];
16270 state[5] = state[1];
16271 state[1] = t;
16272 t = state[14];
16273 u = state[10];
16274 state[14] = state[6];
16275 state[10] = state[2];
16276 state[6] = t;
16277 state[2] = u;
16278 t = state[15];
16279 u = state[11];
16280 v = state[7];
16281 state[15] = state[3];
16282 state[11] = t;
16283 state[7] = u;
16284 state[3] = v;
16285
16286 for (let j = 0; j < 16; ++j) {
16287 state[j] = this._inv_s[state[j]];
16288 }
16289
16290 for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
16291 state[j] ^= key[k];
16292 }
16293
16294 for (let j = 0; j < 16; j += 4) {
16295 const s0 = this._mix[state[j]];
16296 const s1 = this._mix[state[j + 1]];
16297 const s2 = this._mix[state[j + 2]];
16298 const s3 = this._mix[state[j + 3]];
16299 t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
16300 state[j] = t >>> 24 & 0xff;
16301 state[j + 1] = t >> 16 & 0xff;
16302 state[j + 2] = t >> 8 & 0xff;
16303 state[j + 3] = t & 0xff;
16304 }
16305 }
16306
16307 t = state[13];
16308 state[13] = state[9];
16309 state[9] = state[5];
16310 state[5] = state[1];
16311 state[1] = t;
16312 t = state[14];
16313 u = state[10];
16314 state[14] = state[6];
16315 state[10] = state[2];
16316 state[6] = t;
16317 state[2] = u;
16318 t = state[15];
16319 u = state[11];
16320 v = state[7];
16321 state[15] = state[3];
16322 state[11] = t;
16323 state[7] = u;
16324 state[3] = v;
16325
16326 for (let j = 0; j < 16; ++j) {
16327 state[j] = this._inv_s[state[j]];
16328 state[j] ^= key[j];
16329 }
16330
16331 return state;
16332 }
16333
16334 _encrypt(input, key) {
16335 const s = this._s;
16336 let t, u, v;
16337 const state = new Uint8Array(16);
16338 state.set(input);
16339
16340 for (let j = 0; j < 16; ++j) {
16341 state[j] ^= key[j];
16342 }
16343
16344 for (let i = 1; i < this._cyclesOfRepetition; i++) {
16345 for (let j = 0; j < 16; ++j) {
16346 state[j] = s[state[j]];
16347 }
16348
16349 v = state[1];
16350 state[1] = state[5];
16351 state[5] = state[9];
16352 state[9] = state[13];
16353 state[13] = v;
16354 v = state[2];
16355 u = state[6];
16356 state[2] = state[10];
16357 state[6] = state[14];
16358 state[10] = v;
16359 state[14] = u;
16360 v = state[3];
16361 u = state[7];
16362 t = state[11];
16363 state[3] = state[15];
16364 state[7] = v;
16365 state[11] = u;
16366 state[15] = t;
16367
16368 for (let j = 0; j < 16; j += 4) {
16369 const s0 = state[j + 0];
16370 const s1 = state[j + 1];
16371 const s2 = state[j + 2];
16372 const s3 = state[j + 3];
16373 t = s0 ^ s1 ^ s2 ^ s3;
16374 state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
16375 state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
16376 state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
16377 state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
16378 }
16379
16380 for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
16381 state[j] ^= key[k];
16382 }
16383 }
16384
16385 for (let j = 0; j < 16; ++j) {
16386 state[j] = s[state[j]];
16387 }
16388
16389 v = state[1];
16390 state[1] = state[5];
16391 state[5] = state[9];
16392 state[9] = state[13];
16393 state[13] = v;
16394 v = state[2];
16395 u = state[6];
16396 state[2] = state[10];
16397 state[6] = state[14];
16398 state[10] = v;
16399 state[14] = u;
16400 v = state[3];
16401 u = state[7];
16402 t = state[11];
16403 state[3] = state[15];
16404 state[7] = v;
16405 state[11] = u;
16406 state[15] = t;
16407
16408 for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
16409 state[j] ^= key[k];
16410 }
16411
16412 return state;
16413 }
16414
16415 _decryptBlock2(data, finalize) {
16416 const sourceLength = data.length;
16417 let buffer = this.buffer,
16418 bufferLength = this.bufferPosition;
16419 const result = [];
16420 let iv = this.iv;
16421
16422 for (let i = 0; i < sourceLength; ++i) {
16423 buffer[bufferLength] = data[i];
16424 ++bufferLength;
16425
16426 if (bufferLength < 16) {
16427 continue;
16428 }
16429
16430 const plain = this._decrypt(buffer, this._key);
16431
16432 for (let j = 0; j < 16; ++j) {
16433 plain[j] ^= iv[j];
16434 }
16435
16436 iv = buffer;
16437 result.push(plain);
16438 buffer = new Uint8Array(16);
16439 bufferLength = 0;
16440 }
16441
16442 this.buffer = buffer;
16443 this.bufferLength = bufferLength;
16444 this.iv = iv;
16445
16446 if (result.length === 0) {
16447 return new Uint8Array(0);
16448 }
16449
16450 let outputLength = 16 * result.length;
16451
16452 if (finalize) {
16453 const lastBlock = result[result.length - 1];
16454 let psLen = lastBlock[15];
16455
16456 if (psLen <= 16) {
16457 for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
16458 if (lastBlock[i] !== psLen) {
16459 psLen = 0;
16460 break;
16461 }
16462 }
16463
16464 outputLength -= psLen;
16465 result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
16466 }
16467 }
16468
16469 const output = new Uint8Array(outputLength);
16470
16471 for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
16472 output.set(result[i], j);
16473 }
16474
16475 return output;
16476 }
16477
16478 decryptBlock(data, finalize, iv = null) {
16479 const sourceLength = data.length;
16480 const buffer = this.buffer;
16481 let bufferLength = this.bufferPosition;
16482
16483 if (iv) {
16484 this.iv = iv;
16485 } else {
16486 for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
16487 buffer[bufferLength] = data[i];
16488 }
16489
16490 if (bufferLength < 16) {
16491 this.bufferLength = bufferLength;
16492 return new Uint8Array(0);
16493 }
16494
16495 this.iv = buffer;
16496 data = data.subarray(16);
16497 }
16498
16499 this.buffer = new Uint8Array(16);
16500 this.bufferLength = 0;
16501 this.decryptBlock = this._decryptBlock2;
16502 return this.decryptBlock(data, finalize);
16503 }
16504
16505 encrypt(data, iv) {
16506 const sourceLength = data.length;
16507 let buffer = this.buffer,
16508 bufferLength = this.bufferPosition;
16509 const result = [];
16510
16511 if (!iv) {
16512 iv = new Uint8Array(16);
16513 }
16514
16515 for (let i = 0; i < sourceLength; ++i) {
16516 buffer[bufferLength] = data[i];
16517 ++bufferLength;
16518
16519 if (bufferLength < 16) {
16520 continue;
16521 }
16522
16523 for (let j = 0; j < 16; ++j) {
16524 buffer[j] ^= iv[j];
16525 }
16526
16527 const cipher = this._encrypt(buffer, this._key);
16528
16529 iv = cipher;
16530 result.push(cipher);
16531 buffer = new Uint8Array(16);
16532 bufferLength = 0;
16533 }
16534
16535 this.buffer = buffer;
16536 this.bufferLength = bufferLength;
16537 this.iv = iv;
16538
16539 if (result.length === 0) {
16540 return new Uint8Array(0);
16541 }
16542
16543 const outputLength = 16 * result.length;
16544 const output = new Uint8Array(outputLength);
16545
16546 for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
16547 output.set(result[i], j);
16548 }
16549
16550 return output;
16551 }
16552
16553}
16554
16555class AES128Cipher extends AESBaseCipher {
16556 constructor(key) {
16557 super();
16558 this._cyclesOfRepetition = 10;
16559 this._keySize = 160;
16560 this._rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
16561 this._key = this._expandKey(key);
16562 }
16563
16564 _expandKey(cipherKey) {
16565 const b = 176;
16566 const s = this._s;
16567 const rcon = this._rcon;
16568 const result = new Uint8Array(b);
16569 result.set(cipherKey);
16570
16571 for (let j = 16, i = 1; j < b; ++i) {
16572 let t1 = result[j - 3];
16573 let t2 = result[j - 2];
16574 let t3 = result[j - 1];
16575 let t4 = result[j - 4];
16576 t1 = s[t1];
16577 t2 = s[t2];
16578 t3 = s[t3];
16579 t4 = s[t4];
16580 t1 = t1 ^ rcon[i];
16581
16582 for (let n = 0; n < 4; ++n) {
16583 result[j] = t1 ^= result[j - 16];
16584 j++;
16585 result[j] = t2 ^= result[j - 16];
16586 j++;
16587 result[j] = t3 ^= result[j - 16];
16588 j++;
16589 result[j] = t4 ^= result[j - 16];
16590 j++;
16591 }
16592 }
16593
16594 return result;
16595 }
16596
16597}
16598
16599exports.AES128Cipher = AES128Cipher;
16600
16601class AES256Cipher extends AESBaseCipher {
16602 constructor(key) {
16603 super();
16604 this._cyclesOfRepetition = 14;
16605 this._keySize = 224;
16606 this._key = this._expandKey(key);
16607 }
16608
16609 _expandKey(cipherKey) {
16610 const b = 240;
16611 const s = this._s;
16612 const result = new Uint8Array(b);
16613 result.set(cipherKey);
16614 let r = 1;
16615 let t1, t2, t3, t4;
16616
16617 for (let j = 32, i = 1; j < b; ++i) {
16618 if (j % 32 === 16) {
16619 t1 = s[t1];
16620 t2 = s[t2];
16621 t3 = s[t3];
16622 t4 = s[t4];
16623 } else if (j % 32 === 0) {
16624 t1 = result[j - 3];
16625 t2 = result[j - 2];
16626 t3 = result[j - 1];
16627 t4 = result[j - 4];
16628 t1 = s[t1];
16629 t2 = s[t2];
16630 t3 = s[t3];
16631 t4 = s[t4];
16632 t1 = t1 ^ r;
16633
16634 if ((r <<= 1) >= 256) {
16635 r = (r ^ 0x1b) & 0xff;
16636 }
16637 }
16638
16639 for (let n = 0; n < 4; ++n) {
16640 result[j] = t1 ^= result[j - 32];
16641 j++;
16642 result[j] = t2 ^= result[j - 32];
16643 j++;
16644 result[j] = t3 ^= result[j - 32];
16645 j++;
16646 result[j] = t4 ^= result[j - 32];
16647 j++;
16648 }
16649 }
16650
16651 return result;
16652 }
16653
16654}
16655
16656exports.AES256Cipher = AES256Cipher;
16657
16658var PDF17 = function PDF17Closure() {
16659 function compareByteArrays(array1, array2) {
16660 if (array1.length !== array2.length) {
16661 return false;
16662 }
16663
16664 for (var i = 0; i < array1.length; i++) {
16665 if (array1[i] !== array2[i]) {
16666 return false;
16667 }
16668 }
16669
16670 return true;
16671 }
16672
16673 function PDF17() {}
16674
16675 PDF17.prototype = {
16676 checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
16677 var hashData = new Uint8Array(password.length + 56);
16678 hashData.set(password, 0);
16679 hashData.set(ownerValidationSalt, password.length);
16680 hashData.set(userBytes, password.length + ownerValidationSalt.length);
16681 var result = calculateSHA256(hashData, 0, hashData.length);
16682 return compareByteArrays(result, ownerPassword);
16683 },
16684 checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
16685 var hashData = new Uint8Array(password.length + 8);
16686 hashData.set(password, 0);
16687 hashData.set(userValidationSalt, password.length);
16688 var result = calculateSHA256(hashData, 0, hashData.length);
16689 return compareByteArrays(result, userPassword);
16690 },
16691 getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
16692 var hashData = new Uint8Array(password.length + 56);
16693 hashData.set(password, 0);
16694 hashData.set(ownerKeySalt, password.length);
16695 hashData.set(userBytes, password.length + ownerKeySalt.length);
16696 var key = calculateSHA256(hashData, 0, hashData.length);
16697 var cipher = new AES256Cipher(key);
16698 return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
16699 },
16700 getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
16701 var hashData = new Uint8Array(password.length + 8);
16702 hashData.set(password, 0);
16703 hashData.set(userKeySalt, password.length);
16704 var key = calculateSHA256(hashData, 0, hashData.length);
16705 var cipher = new AES256Cipher(key);
16706 return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
16707 }
16708 };
16709 return PDF17;
16710}();
16711
16712exports.PDF17 = PDF17;
16713
16714var PDF20 = function PDF20Closure() {
16715 function concatArrays(array1, array2) {
16716 var t = new Uint8Array(array1.length + array2.length);
16717 t.set(array1, 0);
16718 t.set(array2, array1.length);
16719 return t;
16720 }
16721
16722 function calculatePDF20Hash(password, input, userBytes) {
16723 var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
16724 var e = [0];
16725 var i = 0;
16726
16727 while (i < 64 || e[e.length - 1] > i - 32) {
16728 var arrayLength = password.length + k.length + userBytes.length;
16729 var k1 = new Uint8Array(arrayLength * 64);
16730 var array = concatArrays(password, k);
16731 array = concatArrays(array, userBytes);
16732
16733 for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
16734 k1.set(array, pos);
16735 }
16736
16737 var cipher = new AES128Cipher(k.subarray(0, 16));
16738 e = cipher.encrypt(k1, k.subarray(16, 32));
16739 var remainder = 0;
16740
16741 for (var z = 0; z < 16; z++) {
16742 remainder *= 256 % 3;
16743 remainder %= 3;
16744 remainder += (e[z] >>> 0) % 3;
16745 remainder %= 3;
16746 }
16747
16748 if (remainder === 0) {
16749 k = calculateSHA256(e, 0, e.length);
16750 } else if (remainder === 1) {
16751 k = calculateSHA384(e, 0, e.length);
16752 } else if (remainder === 2) {
16753 k = calculateSHA512(e, 0, e.length);
16754 }
16755
16756 i++;
16757 }
16758
16759 return k.subarray(0, 32);
16760 }
16761
16762 function PDF20() {}
16763
16764 function compareByteArrays(array1, array2) {
16765 if (array1.length !== array2.length) {
16766 return false;
16767 }
16768
16769 for (var i = 0; i < array1.length; i++) {
16770 if (array1[i] !== array2[i]) {
16771 return false;
16772 }
16773 }
16774
16775 return true;
16776 }
16777
16778 PDF20.prototype = {
16779 hash: function PDF20_hash(password, concatBytes, userBytes) {
16780 return calculatePDF20Hash(password, concatBytes, userBytes);
16781 },
16782 checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
16783 var hashData = new Uint8Array(password.length + 56);
16784 hashData.set(password, 0);
16785 hashData.set(ownerValidationSalt, password.length);
16786 hashData.set(userBytes, password.length + ownerValidationSalt.length);
16787 var result = calculatePDF20Hash(password, hashData, userBytes);
16788 return compareByteArrays(result, ownerPassword);
16789 },
16790 checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
16791 var hashData = new Uint8Array(password.length + 8);
16792 hashData.set(password, 0);
16793 hashData.set(userValidationSalt, password.length);
16794 var result = calculatePDF20Hash(password, hashData, []);
16795 return compareByteArrays(result, userPassword);
16796 },
16797 getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
16798 var hashData = new Uint8Array(password.length + 56);
16799 hashData.set(password, 0);
16800 hashData.set(ownerKeySalt, password.length);
16801 hashData.set(userBytes, password.length + ownerKeySalt.length);
16802 var key = calculatePDF20Hash(password, hashData, userBytes);
16803 var cipher = new AES256Cipher(key);
16804 return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
16805 },
16806 getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
16807 var hashData = new Uint8Array(password.length + 8);
16808 hashData.set(password, 0);
16809 hashData.set(userKeySalt, password.length);
16810 var key = calculatePDF20Hash(password, hashData, []);
16811 var cipher = new AES256Cipher(key);
16812 return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
16813 }
16814 };
16815 return PDF20;
16816}();
16817
16818exports.PDF20 = PDF20;
16819
16820var CipherTransform = function CipherTransformClosure() {
16821 function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
16822 this.StringCipherConstructor = stringCipherConstructor;
16823 this.StreamCipherConstructor = streamCipherConstructor;
16824 }
16825
16826 CipherTransform.prototype = {
16827 createStream: function CipherTransform_createStream(stream, length) {
16828 var cipher = new this.StreamCipherConstructor();
16829 return new _stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
16830 return cipher.decryptBlock(data, finalize);
16831 });
16832 },
16833 decryptString: function CipherTransform_decryptString(s) {
16834 var cipher = new this.StringCipherConstructor();
16835 var data = (0, _util.stringToBytes)(s);
16836 data = cipher.decryptBlock(data, true);
16837 return (0, _util.bytesToString)(data);
16838 }
16839 };
16840 return CipherTransform;
16841}();
16842
16843var CipherTransformFactory = function CipherTransformFactoryClosure() {
16844 var defaultPasswordBytes = new Uint8Array([0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A]);
16845
16846 function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
16847 if (password) {
16848 var passwordLength = Math.min(127, password.length);
16849 password = password.subarray(0, passwordLength);
16850 } else {
16851 password = [];
16852 }
16853
16854 var pdfAlgorithm;
16855
16856 if (revision === 6) {
16857 pdfAlgorithm = new PDF20();
16858 } else {
16859 pdfAlgorithm = new PDF17();
16860 }
16861
16862 if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
16863 return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
16864 } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
16865 return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
16866 }
16867
16868 return null;
16869 }
16870
16871 function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
16872 var hashDataSize = 40 + ownerPassword.length + fileId.length;
16873 var hashData = new Uint8Array(hashDataSize),
16874 i = 0,
16875 j,
16876 n;
16877
16878 if (password) {
16879 n = Math.min(32, password.length);
16880
16881 for (; i < n; ++i) {
16882 hashData[i] = password[i];
16883 }
16884 }
16885
16886 j = 0;
16887
16888 while (i < 32) {
16889 hashData[i++] = defaultPasswordBytes[j++];
16890 }
16891
16892 for (j = 0, n = ownerPassword.length; j < n; ++j) {
16893 hashData[i++] = ownerPassword[j];
16894 }
16895
16896 hashData[i++] = flags & 0xff;
16897 hashData[i++] = flags >> 8 & 0xff;
16898 hashData[i++] = flags >> 16 & 0xff;
16899 hashData[i++] = flags >>> 24 & 0xff;
16900
16901 for (j = 0, n = fileId.length; j < n; ++j) {
16902 hashData[i++] = fileId[j];
16903 }
16904
16905 if (revision >= 4 && !encryptMetadata) {
16906 hashData[i++] = 0xff;
16907 hashData[i++] = 0xff;
16908 hashData[i++] = 0xff;
16909 hashData[i++] = 0xff;
16910 }
16911
16912 var hash = calculateMD5(hashData, 0, i);
16913 var keyLengthInBytes = keyLength >> 3;
16914
16915 if (revision >= 3) {
16916 for (j = 0; j < 50; ++j) {
16917 hash = calculateMD5(hash, 0, keyLengthInBytes);
16918 }
16919 }
16920
16921 var encryptionKey = hash.subarray(0, keyLengthInBytes);
16922 var cipher, checkData;
16923
16924 if (revision >= 3) {
16925 for (i = 0; i < 32; ++i) {
16926 hashData[i] = defaultPasswordBytes[i];
16927 }
16928
16929 for (j = 0, n = fileId.length; j < n; ++j) {
16930 hashData[i++] = fileId[j];
16931 }
16932
16933 cipher = new ARCFourCipher(encryptionKey);
16934 checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
16935 n = encryptionKey.length;
16936 var derivedKey = new Uint8Array(n),
16937 k;
16938
16939 for (j = 1; j <= 19; ++j) {
16940 for (k = 0; k < n; ++k) {
16941 derivedKey[k] = encryptionKey[k] ^ j;
16942 }
16943
16944 cipher = new ARCFourCipher(derivedKey);
16945 checkData = cipher.encryptBlock(checkData);
16946 }
16947
16948 for (j = 0, n = checkData.length; j < n; ++j) {
16949 if (userPassword[j] !== checkData[j]) {
16950 return null;
16951 }
16952 }
16953 } else {
16954 cipher = new ARCFourCipher(encryptionKey);
16955 checkData = cipher.encryptBlock(defaultPasswordBytes);
16956
16957 for (j = 0, n = checkData.length; j < n; ++j) {
16958 if (userPassword[j] !== checkData[j]) {
16959 return null;
16960 }
16961 }
16962 }
16963
16964 return encryptionKey;
16965 }
16966
16967 function decodeUserPassword(password, ownerPassword, revision, keyLength) {
16968 var hashData = new Uint8Array(32),
16969 i = 0,
16970 j,
16971 n;
16972 n = Math.min(32, password.length);
16973
16974 for (; i < n; ++i) {
16975 hashData[i] = password[i];
16976 }
16977
16978 j = 0;
16979
16980 while (i < 32) {
16981 hashData[i++] = defaultPasswordBytes[j++];
16982 }
16983
16984 var hash = calculateMD5(hashData, 0, i);
16985 var keyLengthInBytes = keyLength >> 3;
16986
16987 if (revision >= 3) {
16988 for (j = 0; j < 50; ++j) {
16989 hash = calculateMD5(hash, 0, hash.length);
16990 }
16991 }
16992
16993 var cipher, userPassword;
16994
16995 if (revision >= 3) {
16996 userPassword = ownerPassword;
16997 var derivedKey = new Uint8Array(keyLengthInBytes),
16998 k;
16999
17000 for (j = 19; j >= 0; j--) {
17001 for (k = 0; k < keyLengthInBytes; ++k) {
17002 derivedKey[k] = hash[k] ^ j;
17003 }
17004
17005 cipher = new ARCFourCipher(derivedKey);
17006 userPassword = cipher.encryptBlock(userPassword);
17007 }
17008 } else {
17009 cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
17010 userPassword = cipher.encryptBlock(ownerPassword);
17011 }
17012
17013 return userPassword;
17014 }
17015
17016 var identityName = _primitives.Name.get("Identity");
17017
17018 function CipherTransformFactory(dict, fileId, password) {
17019 var filter = dict.get("Filter");
17020
17021 if (!(0, _primitives.isName)(filter, "Standard")) {
17022 throw new _util.FormatError("unknown encryption method");
17023 }
17024
17025 this.dict = dict;
17026 var algorithm = dict.get("V");
17027
17028 if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
17029 throw new _util.FormatError("unsupported encryption algorithm");
17030 }
17031
17032 this.algorithm = algorithm;
17033 var keyLength = dict.get("Length");
17034
17035 if (!keyLength) {
17036 if (algorithm <= 3) {
17037 keyLength = 40;
17038 } else {
17039 var cfDict = dict.get("CF");
17040 var streamCryptoName = dict.get("StmF");
17041
17042 if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) {
17043 cfDict.suppressEncryption = true;
17044 var handlerDict = cfDict.get(streamCryptoName.name);
17045 keyLength = handlerDict && handlerDict.get("Length") || 128;
17046
17047 if (keyLength < 40) {
17048 keyLength <<= 3;
17049 }
17050 }
17051 }
17052 }
17053
17054 if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
17055 throw new _util.FormatError("invalid key length");
17056 }
17057
17058 var ownerPassword = (0, _util.stringToBytes)(dict.get("O")).subarray(0, 32);
17059 var userPassword = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 32);
17060 var flags = dict.get("P");
17061 var revision = dict.get("R");
17062 var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
17063 this.encryptMetadata = encryptMetadata;
17064 var fileIdBytes = (0, _util.stringToBytes)(fileId);
17065 var passwordBytes;
17066
17067 if (password) {
17068 if (revision === 6) {
17069 try {
17070 password = (0, _util.utf8StringToString)(password);
17071 } catch (ex) {
17072 (0, _util.warn)("CipherTransformFactory: " + "Unable to convert UTF8 encoded password.");
17073 }
17074 }
17075
17076 passwordBytes = (0, _util.stringToBytes)(password);
17077 }
17078
17079 var encryptionKey;
17080
17081 if (algorithm !== 5) {
17082 encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
17083 } else {
17084 var ownerValidationSalt = (0, _util.stringToBytes)(dict.get("O")).subarray(32, 40);
17085 var ownerKeySalt = (0, _util.stringToBytes)(dict.get("O")).subarray(40, 48);
17086 var uBytes = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 48);
17087 var userValidationSalt = (0, _util.stringToBytes)(dict.get("U")).subarray(32, 40);
17088 var userKeySalt = (0, _util.stringToBytes)(dict.get("U")).subarray(40, 48);
17089 var ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
17090 var userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
17091 var perms = (0, _util.stringToBytes)(dict.get("Perms"));
17092 encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
17093 }
17094
17095 if (!encryptionKey && !password) {
17096 throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
17097 } else if (!encryptionKey && password) {
17098 var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
17099 encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
17100 }
17101
17102 if (!encryptionKey) {
17103 throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
17104 }
17105
17106 this.encryptionKey = encryptionKey;
17107
17108 if (algorithm >= 4) {
17109 var cf = dict.get("CF");
17110
17111 if ((0, _primitives.isDict)(cf)) {
17112 cf.suppressEncryption = true;
17113 }
17114
17115 this.cf = cf;
17116 this.stmf = dict.get("StmF") || identityName;
17117 this.strf = dict.get("StrF") || identityName;
17118 this.eff = dict.get("EFF") || this.stmf;
17119 }
17120 }
17121
17122 function buildObjectKey(num, gen, encryptionKey, isAes) {
17123 var key = new Uint8Array(encryptionKey.length + 9),
17124 i,
17125 n;
17126
17127 for (i = 0, n = encryptionKey.length; i < n; ++i) {
17128 key[i] = encryptionKey[i];
17129 }
17130
17131 key[i++] = num & 0xff;
17132 key[i++] = num >> 8 & 0xff;
17133 key[i++] = num >> 16 & 0xff;
17134 key[i++] = gen & 0xff;
17135 key[i++] = gen >> 8 & 0xff;
17136
17137 if (isAes) {
17138 key[i++] = 0x73;
17139 key[i++] = 0x41;
17140 key[i++] = 0x6c;
17141 key[i++] = 0x54;
17142 }
17143
17144 var hash = calculateMD5(key, 0, i);
17145 return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
17146 }
17147
17148 function buildCipherConstructor(cf, name, num, gen, key) {
17149 if (!(0, _primitives.isName)(name)) {
17150 throw new _util.FormatError("Invalid crypt filter name.");
17151 }
17152
17153 var cryptFilter = cf.get(name.name);
17154 var cfm;
17155
17156 if (cryptFilter !== null && cryptFilter !== undefined) {
17157 cfm = cryptFilter.get("CFM");
17158 }
17159
17160 if (!cfm || cfm.name === "None") {
17161 return function cipherTransformFactoryBuildCipherConstructorNone() {
17162 return new NullCipher();
17163 };
17164 }
17165
17166 if (cfm.name === "V2") {
17167 return function cipherTransformFactoryBuildCipherConstructorV2() {
17168 return new ARCFourCipher(buildObjectKey(num, gen, key, false));
17169 };
17170 }
17171
17172 if (cfm.name === "AESV2") {
17173 return function cipherTransformFactoryBuildCipherConstructorAESV2() {
17174 return new AES128Cipher(buildObjectKey(num, gen, key, true));
17175 };
17176 }
17177
17178 if (cfm.name === "AESV3") {
17179 return function cipherTransformFactoryBuildCipherConstructorAESV3() {
17180 return new AES256Cipher(key);
17181 };
17182 }
17183
17184 throw new _util.FormatError("Unknown crypto method");
17185 }
17186
17187 CipherTransformFactory.prototype = {
17188 createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
17189 if (this.algorithm === 4 || this.algorithm === 5) {
17190 return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
17191 }
17192
17193 var key = buildObjectKey(num, gen, this.encryptionKey, false);
17194
17195 var cipherConstructor = function buildCipherCipherConstructor() {
17196 return new ARCFourCipher(key);
17197 };
17198
17199 return new CipherTransform(cipherConstructor, cipherConstructor);
17200 }
17201 };
17202 return CipherTransformFactory;
17203}();
17204
17205exports.CipherTransformFactory = CipherTransformFactory;
17206
17207/***/ }),
17208/* 23 */
17209/***/ (function(module, exports, __w_pdfjs_require__) {
17210
17211"use strict";
17212
17213
17214Object.defineProperty(exports, "__esModule", {
17215 value: true
17216});
17217exports.ColorSpace = void 0;
17218
17219var _util = __w_pdfjs_require__(2);
17220
17221var _primitives = __w_pdfjs_require__(5);
17222
17223function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
17224 const COMPONENTS = 3;
17225 alpha01 = alpha01 !== 1 ? 0 : alpha01;
17226 const xRatio = w1 / w2;
17227 const yRatio = h1 / h2;
17228 let newIndex = 0,
17229 oldIndex;
17230 const xScaled = new Uint16Array(w2);
17231 const w1Scanline = w1 * COMPONENTS;
17232
17233 for (let i = 0; i < w2; i++) {
17234 xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
17235 }
17236
17237 for (let i = 0; i < h2; i++) {
17238 const py = Math.floor(i * yRatio) * w1Scanline;
17239
17240 for (let j = 0; j < w2; j++) {
17241 oldIndex = py + xScaled[j];
17242 dest[newIndex++] = src[oldIndex++];
17243 dest[newIndex++] = src[oldIndex++];
17244 dest[newIndex++] = src[oldIndex++];
17245 newIndex += alpha01;
17246 }
17247 }
17248}
17249
17250class ColorSpace {
17251 constructor(name, numComps) {
17252 if (this.constructor === ColorSpace) {
17253 (0, _util.unreachable)("Cannot initialize ColorSpace.");
17254 }
17255
17256 this.name = name;
17257 this.numComps = numComps;
17258 }
17259
17260 getRgb(src, srcOffset) {
17261 const rgb = new Uint8ClampedArray(3);
17262 this.getRgbItem(src, srcOffset, rgb, 0);
17263 return rgb;
17264 }
17265
17266 getRgbItem(src, srcOffset, dest, destOffset) {
17267 (0, _util.unreachable)("Should not call ColorSpace.getRgbItem");
17268 }
17269
17270 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17271 (0, _util.unreachable)("Should not call ColorSpace.getRgbBuffer");
17272 }
17273
17274 getOutputLength(inputLength, alpha01) {
17275 (0, _util.unreachable)("Should not call ColorSpace.getOutputLength");
17276 }
17277
17278 isPassthrough(bits) {
17279 return false;
17280 }
17281
17282 isDefaultDecode(decodeMap, bpc) {
17283 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
17284 }
17285
17286 fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
17287 const count = originalWidth * originalHeight;
17288 let rgbBuf = null;
17289 const numComponentColors = 1 << bpc;
17290 const needsResizing = originalHeight !== height || originalWidth !== width;
17291
17292 if (this.isPassthrough(bpc)) {
17293 rgbBuf = comps;
17294 } else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
17295 const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
17296
17297 for (let i = 0; i < numComponentColors; i++) {
17298 allColors[i] = i;
17299 }
17300
17301 const colorMap = new Uint8ClampedArray(numComponentColors * 3);
17302 this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
17303
17304 if (!needsResizing) {
17305 let destPos = 0;
17306
17307 for (let i = 0; i < count; ++i) {
17308 const key = comps[i] * 3;
17309 dest[destPos++] = colorMap[key];
17310 dest[destPos++] = colorMap[key + 1];
17311 dest[destPos++] = colorMap[key + 2];
17312 destPos += alpha01;
17313 }
17314 } else {
17315 rgbBuf = new Uint8Array(count * 3);
17316 let rgbPos = 0;
17317
17318 for (let i = 0; i < count; ++i) {
17319 const key = comps[i] * 3;
17320 rgbBuf[rgbPos++] = colorMap[key];
17321 rgbBuf[rgbPos++] = colorMap[key + 1];
17322 rgbBuf[rgbPos++] = colorMap[key + 2];
17323 }
17324 }
17325 } else {
17326 if (!needsResizing) {
17327 this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
17328 } else {
17329 rgbBuf = new Uint8ClampedArray(count * 3);
17330 this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
17331 }
17332 }
17333
17334 if (rgbBuf) {
17335 if (needsResizing) {
17336 resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
17337 } else {
17338 let destPos = 0,
17339 rgbPos = 0;
17340
17341 for (let i = 0, ii = width * actualHeight; i < ii; i++) {
17342 dest[destPos++] = rgbBuf[rgbPos++];
17343 dest[destPos++] = rgbBuf[rgbPos++];
17344 dest[destPos++] = rgbBuf[rgbPos++];
17345 destPos += alpha01;
17346 }
17347 }
17348 }
17349 }
17350
17351 get usesZeroToOneRange() {
17352 return (0, _util.shadow)(this, "usesZeroToOneRange", true);
17353 }
17354
17355 static parse(cs, xref, res, pdfFunctionFactory) {
17356 const IR = this.parseToIR(cs, xref, res, pdfFunctionFactory);
17357 return this.fromIR(IR);
17358 }
17359
17360 static fromIR(IR) {
17361 const name = Array.isArray(IR) ? IR[0] : IR;
17362 let whitePoint, blackPoint, gamma;
17363
17364 switch (name) {
17365 case "DeviceGrayCS":
17366 return this.singletons.gray;
17367
17368 case "DeviceRgbCS":
17369 return this.singletons.rgb;
17370
17371 case "DeviceCmykCS":
17372 return this.singletons.cmyk;
17373
17374 case "CalGrayCS":
17375 whitePoint = IR[1];
17376 blackPoint = IR[2];
17377 gamma = IR[3];
17378 return new CalGrayCS(whitePoint, blackPoint, gamma);
17379
17380 case "CalRGBCS":
17381 whitePoint = IR[1];
17382 blackPoint = IR[2];
17383 gamma = IR[3];
17384 const matrix = IR[4];
17385 return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
17386
17387 case "PatternCS":
17388 let basePatternCS = IR[1];
17389
17390 if (basePatternCS) {
17391 basePatternCS = this.fromIR(basePatternCS);
17392 }
17393
17394 return new PatternCS(basePatternCS);
17395
17396 case "IndexedCS":
17397 const baseIndexedCS = IR[1];
17398 const hiVal = IR[2];
17399 const lookup = IR[3];
17400 return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);
17401
17402 case "AlternateCS":
17403 const numComps = IR[1];
17404 const alt = IR[2];
17405 const tintFn = IR[3];
17406 return new AlternateCS(numComps, this.fromIR(alt), tintFn);
17407
17408 case "LabCS":
17409 whitePoint = IR[1];
17410 blackPoint = IR[2];
17411 const range = IR[3];
17412 return new LabCS(whitePoint, blackPoint, range);
17413
17414 default:
17415 throw new _util.FormatError(`Unknown colorspace name: ${name}`);
17416 }
17417 }
17418
17419 static parseToIR(cs, xref, res = null, pdfFunctionFactory) {
17420 cs = xref.fetchIfRef(cs);
17421
17422 if ((0, _primitives.isName)(cs)) {
17423 switch (cs.name) {
17424 case "DeviceGray":
17425 case "G":
17426 return "DeviceGrayCS";
17427
17428 case "DeviceRGB":
17429 case "RGB":
17430 return "DeviceRgbCS";
17431
17432 case "DeviceCMYK":
17433 case "CMYK":
17434 return "DeviceCmykCS";
17435
17436 case "Pattern":
17437 return ["PatternCS", null];
17438
17439 default:
17440 if ((0, _primitives.isDict)(res)) {
17441 const colorSpaces = res.get("ColorSpace");
17442
17443 if ((0, _primitives.isDict)(colorSpaces)) {
17444 const resCS = colorSpaces.get(cs.name);
17445
17446 if (resCS) {
17447 if ((0, _primitives.isName)(resCS)) {
17448 return this.parseToIR(resCS, xref, res, pdfFunctionFactory);
17449 }
17450
17451 cs = resCS;
17452 break;
17453 }
17454 }
17455 }
17456
17457 throw new _util.FormatError(`unrecognized colorspace ${cs.name}`);
17458 }
17459 }
17460
17461 if (Array.isArray(cs)) {
17462 const mode = xref.fetchIfRef(cs[0]).name;
17463 let numComps, params, alt, whitePoint, blackPoint, gamma;
17464
17465 switch (mode) {
17466 case "DeviceGray":
17467 case "G":
17468 return "DeviceGrayCS";
17469
17470 case "DeviceRGB":
17471 case "RGB":
17472 return "DeviceRgbCS";
17473
17474 case "DeviceCMYK":
17475 case "CMYK":
17476 return "DeviceCmykCS";
17477
17478 case "CalGray":
17479 params = xref.fetchIfRef(cs[1]);
17480 whitePoint = params.getArray("WhitePoint");
17481 blackPoint = params.getArray("BlackPoint");
17482 gamma = params.get("Gamma");
17483 return ["CalGrayCS", whitePoint, blackPoint, gamma];
17484
17485 case "CalRGB":
17486 params = xref.fetchIfRef(cs[1]);
17487 whitePoint = params.getArray("WhitePoint");
17488 blackPoint = params.getArray("BlackPoint");
17489 gamma = params.getArray("Gamma");
17490 const matrix = params.getArray("Matrix");
17491 return ["CalRGBCS", whitePoint, blackPoint, gamma, matrix];
17492
17493 case "ICCBased":
17494 const stream = xref.fetchIfRef(cs[1]);
17495 const dict = stream.dict;
17496 numComps = dict.get("N");
17497 alt = dict.get("Alternate");
17498
17499 if (alt) {
17500 const altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);
17501 const altCS = this.fromIR(altIR, pdfFunctionFactory);
17502
17503 if (altCS.numComps === numComps) {
17504 return altIR;
17505 }
17506
17507 (0, _util.warn)("ICCBased color space: Ignoring incorrect /Alternate entry.");
17508 }
17509
17510 if (numComps === 1) {
17511 return "DeviceGrayCS";
17512 } else if (numComps === 3) {
17513 return "DeviceRgbCS";
17514 } else if (numComps === 4) {
17515 return "DeviceCmykCS";
17516 }
17517
17518 break;
17519
17520 case "Pattern":
17521 let basePatternCS = cs[1] || null;
17522
17523 if (basePatternCS) {
17524 basePatternCS = this.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);
17525 }
17526
17527 return ["PatternCS", basePatternCS];
17528
17529 case "Indexed":
17530 case "I":
17531 const baseIndexedCS = this.parseToIR(cs[1], xref, res, pdfFunctionFactory);
17532 const hiVal = xref.fetchIfRef(cs[2]) + 1;
17533 let lookup = xref.fetchIfRef(cs[3]);
17534
17535 if ((0, _primitives.isStream)(lookup)) {
17536 lookup = lookup.getBytes();
17537 }
17538
17539 return ["IndexedCS", baseIndexedCS, hiVal, lookup];
17540
17541 case "Separation":
17542 case "DeviceN":
17543 const name = xref.fetchIfRef(cs[1]);
17544 numComps = Array.isArray(name) ? name.length : 1;
17545 alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);
17546 const tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));
17547 return ["AlternateCS", numComps, alt, tintFn];
17548
17549 case "Lab":
17550 params = xref.fetchIfRef(cs[1]);
17551 whitePoint = params.getArray("WhitePoint");
17552 blackPoint = params.getArray("BlackPoint");
17553 const range = params.getArray("Range");
17554 return ["LabCS", whitePoint, blackPoint, range];
17555
17556 default:
17557 throw new _util.FormatError(`unimplemented color space object "${mode}"`);
17558 }
17559 }
17560
17561 throw new _util.FormatError(`unrecognized color space object: "${cs}"`);
17562 }
17563
17564 static isDefaultDecode(decode, numComps) {
17565 if (!Array.isArray(decode)) {
17566 return true;
17567 }
17568
17569 if (numComps * 2 !== decode.length) {
17570 (0, _util.warn)("The decode map is not the correct length");
17571 return true;
17572 }
17573
17574 for (let i = 0, ii = decode.length; i < ii; i += 2) {
17575 if (decode[i] !== 0 || decode[i + 1] !== 1) {
17576 return false;
17577 }
17578 }
17579
17580 return true;
17581 }
17582
17583 static get singletons() {
17584 return (0, _util.shadow)(this, "singletons", {
17585 get gray() {
17586 return (0, _util.shadow)(this, "gray", new DeviceGrayCS());
17587 },
17588
17589 get rgb() {
17590 return (0, _util.shadow)(this, "rgb", new DeviceRgbCS());
17591 },
17592
17593 get cmyk() {
17594 return (0, _util.shadow)(this, "cmyk", new DeviceCmykCS());
17595 }
17596
17597 });
17598 }
17599
17600}
17601
17602exports.ColorSpace = ColorSpace;
17603
17604class AlternateCS extends ColorSpace {
17605 constructor(numComps, base, tintFn) {
17606 super("Alternate", numComps);
17607 this.base = base;
17608 this.tintFn = tintFn;
17609 this.tmpBuf = new Float32Array(base.numComps);
17610 }
17611
17612 getRgbItem(src, srcOffset, dest, destOffset) {
17613 const tmpBuf = this.tmpBuf;
17614 this.tintFn(src, srcOffset, tmpBuf, 0);
17615 this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
17616 }
17617
17618 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17619 const tintFn = this.tintFn;
17620 const base = this.base;
17621 const scale = 1 / ((1 << bits) - 1);
17622 const baseNumComps = base.numComps;
17623 const usesZeroToOneRange = base.usesZeroToOneRange;
17624 const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
17625 let pos = isPassthrough ? destOffset : 0;
17626 const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
17627 const numComps = this.numComps;
17628 const scaled = new Float32Array(numComps);
17629 const tinted = new Float32Array(baseNumComps);
17630 let i, j;
17631
17632 for (i = 0; i < count; i++) {
17633 for (j = 0; j < numComps; j++) {
17634 scaled[j] = src[srcOffset++] * scale;
17635 }
17636
17637 tintFn(scaled, 0, tinted, 0);
17638
17639 if (usesZeroToOneRange) {
17640 for (j = 0; j < baseNumComps; j++) {
17641 baseBuf[pos++] = tinted[j] * 255;
17642 }
17643 } else {
17644 base.getRgbItem(tinted, 0, baseBuf, pos);
17645 pos += baseNumComps;
17646 }
17647 }
17648
17649 if (!isPassthrough) {
17650 base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
17651 }
17652 }
17653
17654 getOutputLength(inputLength, alpha01) {
17655 return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
17656 }
17657
17658}
17659
17660class PatternCS extends ColorSpace {
17661 constructor(baseCS) {
17662 super("Pattern", null);
17663 this.base = baseCS;
17664 }
17665
17666 isDefaultDecode(decodeMap, bpc) {
17667 (0, _util.unreachable)("Should not call PatternCS.isDefaultDecode");
17668 }
17669
17670}
17671
17672class IndexedCS extends ColorSpace {
17673 constructor(base, highVal, lookup) {
17674 super("Indexed", 1);
17675 this.base = base;
17676 this.highVal = highVal;
17677 const baseNumComps = base.numComps;
17678 const length = baseNumComps * highVal;
17679
17680 if ((0, _primitives.isStream)(lookup)) {
17681 this.lookup = new Uint8Array(length);
17682 const bytes = lookup.getBytes(length);
17683 this.lookup.set(bytes);
17684 } else if ((0, _util.isString)(lookup)) {
17685 this.lookup = new Uint8Array(length);
17686
17687 for (let i = 0; i < length; ++i) {
17688 this.lookup[i] = lookup.charCodeAt(i);
17689 }
17690 } else if (lookup instanceof Uint8Array) {
17691 this.lookup = lookup;
17692 } else {
17693 throw new _util.FormatError(`Unrecognized lookup table: ${lookup}`);
17694 }
17695 }
17696
17697 getRgbItem(src, srcOffset, dest, destOffset) {
17698 const numComps = this.base.numComps;
17699 const start = src[srcOffset] * numComps;
17700 this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
17701 }
17702
17703 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17704 const base = this.base;
17705 const numComps = base.numComps;
17706 const outputDelta = base.getOutputLength(numComps, alpha01);
17707 const lookup = this.lookup;
17708
17709 for (let i = 0; i < count; ++i) {
17710 const lookupPos = src[srcOffset++] * numComps;
17711 base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
17712 destOffset += outputDelta;
17713 }
17714 }
17715
17716 getOutputLength(inputLength, alpha01) {
17717 return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
17718 }
17719
17720 isDefaultDecode(decodeMap, bpc) {
17721 if (!Array.isArray(decodeMap)) {
17722 return true;
17723 }
17724
17725 if (decodeMap.length !== 2) {
17726 (0, _util.warn)("Decode map length is not correct");
17727 return true;
17728 }
17729
17730 if (!Number.isInteger(bpc) || bpc < 1) {
17731 (0, _util.warn)("Bits per component is not correct");
17732 return true;
17733 }
17734
17735 return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
17736 }
17737
17738}
17739
17740class DeviceGrayCS extends ColorSpace {
17741 constructor() {
17742 super("DeviceGray", 1);
17743 }
17744
17745 getRgbItem(src, srcOffset, dest, destOffset) {
17746 const c = src[srcOffset] * 255;
17747 dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
17748 }
17749
17750 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17751 const scale = 255 / ((1 << bits) - 1);
17752 let j = srcOffset,
17753 q = destOffset;
17754
17755 for (let i = 0; i < count; ++i) {
17756 const c = scale * src[j++];
17757 dest[q++] = c;
17758 dest[q++] = c;
17759 dest[q++] = c;
17760 q += alpha01;
17761 }
17762 }
17763
17764 getOutputLength(inputLength, alpha01) {
17765 return inputLength * (3 + alpha01);
17766 }
17767
17768}
17769
17770class DeviceRgbCS extends ColorSpace {
17771 constructor() {
17772 super("DeviceRGB", 3);
17773 }
17774
17775 getRgbItem(src, srcOffset, dest, destOffset) {
17776 dest[destOffset] = src[srcOffset] * 255;
17777 dest[destOffset + 1] = src[srcOffset + 1] * 255;
17778 dest[destOffset + 2] = src[srcOffset + 2] * 255;
17779 }
17780
17781 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17782 if (bits === 8 && alpha01 === 0) {
17783 dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
17784 return;
17785 }
17786
17787 const scale = 255 / ((1 << bits) - 1);
17788 let j = srcOffset,
17789 q = destOffset;
17790
17791 for (let i = 0; i < count; ++i) {
17792 dest[q++] = scale * src[j++];
17793 dest[q++] = scale * src[j++];
17794 dest[q++] = scale * src[j++];
17795 q += alpha01;
17796 }
17797 }
17798
17799 getOutputLength(inputLength, alpha01) {
17800 return inputLength * (3 + alpha01) / 3 | 0;
17801 }
17802
17803 isPassthrough(bits) {
17804 return bits === 8;
17805 }
17806
17807}
17808
17809const DeviceCmykCS = function DeviceCmykCSClosure() {
17810 function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
17811 const c = src[srcOffset] * srcScale;
17812 const m = src[srcOffset + 1] * srcScale;
17813 const y = src[srcOffset + 2] * srcScale;
17814 const k = src[srcOffset + 3] * srcScale;
17815 dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
17816 dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
17817 dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
17818 }
17819
17820 class DeviceCmykCS extends ColorSpace {
17821 constructor() {
17822 super("DeviceCMYK", 4);
17823 }
17824
17825 getRgbItem(src, srcOffset, dest, destOffset) {
17826 convertToRgb(src, srcOffset, 1, dest, destOffset);
17827 }
17828
17829 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17830 const scale = 1 / ((1 << bits) - 1);
17831
17832 for (let i = 0; i < count; i++) {
17833 convertToRgb(src, srcOffset, scale, dest, destOffset);
17834 srcOffset += 4;
17835 destOffset += 3 + alpha01;
17836 }
17837 }
17838
17839 getOutputLength(inputLength, alpha01) {
17840 return inputLength / 4 * (3 + alpha01) | 0;
17841 }
17842
17843 }
17844
17845 return DeviceCmykCS;
17846}();
17847
17848const CalGrayCS = function CalGrayCSClosure() {
17849 function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
17850 const A = src[srcOffset] * scale;
17851 const AG = A ** cs.G;
17852 const L = cs.YW * AG;
17853 const val = Math.max(295.8 * L ** 0.333333333333333333 - 40.8, 0);
17854 dest[destOffset] = val;
17855 dest[destOffset + 1] = val;
17856 dest[destOffset + 2] = val;
17857 }
17858
17859 class CalGrayCS extends ColorSpace {
17860 constructor(whitePoint, blackPoint, gamma) {
17861 super("CalGray", 1);
17862
17863 if (!whitePoint) {
17864 throw new _util.FormatError("WhitePoint missing - required for color space CalGray");
17865 }
17866
17867 blackPoint = blackPoint || [0, 0, 0];
17868 gamma = gamma || 1;
17869 this.XW = whitePoint[0];
17870 this.YW = whitePoint[1];
17871 this.ZW = whitePoint[2];
17872 this.XB = blackPoint[0];
17873 this.YB = blackPoint[1];
17874 this.ZB = blackPoint[2];
17875 this.G = gamma;
17876
17877 if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
17878 throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
17879 }
17880
17881 if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
17882 (0, _util.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);
17883 this.XB = this.YB = this.ZB = 0;
17884 }
17885
17886 if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
17887 (0, _util.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
17888 }
17889
17890 if (this.G < 1) {
17891 (0, _util.info)(`Invalid Gamma: ${this.G} for ${this.name}, ` + "falling back to default.");
17892 this.G = 1;
17893 }
17894 }
17895
17896 getRgbItem(src, srcOffset, dest, destOffset) {
17897 convertToRgb(this, src, srcOffset, dest, destOffset, 1);
17898 }
17899
17900 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
17901 const scale = 1 / ((1 << bits) - 1);
17902
17903 for (let i = 0; i < count; ++i) {
17904 convertToRgb(this, src, srcOffset, dest, destOffset, scale);
17905 srcOffset += 1;
17906 destOffset += 3 + alpha01;
17907 }
17908 }
17909
17910 getOutputLength(inputLength, alpha01) {
17911 return inputLength * (3 + alpha01);
17912 }
17913
17914 }
17915
17916 return CalGrayCS;
17917}();
17918
17919const CalRGBCS = function CalRGBCSClosure() {
17920 const BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
17921 const BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
17922 const SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
17923 const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
17924 const tempNormalizeMatrix = new Float32Array(3);
17925 const tempConvertMatrix1 = new Float32Array(3);
17926 const tempConvertMatrix2 = new Float32Array(3);
17927 const DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
17928
17929 function matrixProduct(a, b, result) {
17930 result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
17931 result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
17932 result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
17933 }
17934
17935 function convertToFlat(sourceWhitePoint, LMS, result) {
17936 result[0] = LMS[0] * 1 / sourceWhitePoint[0];
17937 result[1] = LMS[1] * 1 / sourceWhitePoint[1];
17938 result[2] = LMS[2] * 1 / sourceWhitePoint[2];
17939 }
17940
17941 function convertToD65(sourceWhitePoint, LMS, result) {
17942 const D65X = 0.95047;
17943 const D65Y = 1;
17944 const D65Z = 1.08883;
17945 result[0] = LMS[0] * D65X / sourceWhitePoint[0];
17946 result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
17947 result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
17948 }
17949
17950 function sRGBTransferFunction(color) {
17951 if (color <= 0.0031308) {
17952 return adjustToRange(0, 1, 12.92 * color);
17953 }
17954
17955 return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
17956 }
17957
17958 function adjustToRange(min, max, value) {
17959 return Math.max(min, Math.min(max, value));
17960 }
17961
17962 function decodeL(L) {
17963 if (L < 0) {
17964 return -decodeL(-L);
17965 }
17966
17967 if (L > 8.0) {
17968 return ((L + 16) / 116) ** 3;
17969 }
17970
17971 return L * DECODE_L_CONSTANT;
17972 }
17973
17974 function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
17975 if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
17976 result[0] = XYZ_Flat[0];
17977 result[1] = XYZ_Flat[1];
17978 result[2] = XYZ_Flat[2];
17979 return;
17980 }
17981
17982 const zeroDecodeL = decodeL(0);
17983 const X_DST = zeroDecodeL;
17984 const X_SRC = decodeL(sourceBlackPoint[0]);
17985 const Y_DST = zeroDecodeL;
17986 const Y_SRC = decodeL(sourceBlackPoint[1]);
17987 const Z_DST = zeroDecodeL;
17988 const Z_SRC = decodeL(sourceBlackPoint[2]);
17989 const X_Scale = (1 - X_DST) / (1 - X_SRC);
17990 const X_Offset = 1 - X_Scale;
17991 const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
17992 const Y_Offset = 1 - Y_Scale;
17993 const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
17994 const Z_Offset = 1 - Z_Scale;
17995 result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
17996 result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
17997 result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
17998 }
17999
18000 function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
18001 if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
18002 result[0] = XYZ_In[0];
18003 result[1] = XYZ_In[1];
18004 result[2] = XYZ_In[2];
18005 return;
18006 }
18007
18008 const LMS = result;
18009 matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
18010 const LMS_Flat = tempNormalizeMatrix;
18011 convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
18012 matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
18013 }
18014
18015 function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
18016 const LMS = result;
18017 matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
18018 const LMS_D65 = tempNormalizeMatrix;
18019 convertToD65(sourceWhitePoint, LMS, LMS_D65);
18020 matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
18021 }
18022
18023 function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
18024 const A = adjustToRange(0, 1, src[srcOffset] * scale);
18025 const B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
18026 const C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
18027 const AGR = A ** cs.GR;
18028 const BGG = B ** cs.GG;
18029 const CGB = C ** cs.GB;
18030 const X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
18031 const Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
18032 const Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
18033 const XYZ = tempConvertMatrix1;
18034 XYZ[0] = X;
18035 XYZ[1] = Y;
18036 XYZ[2] = Z;
18037 const XYZ_Flat = tempConvertMatrix2;
18038 normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
18039 const XYZ_Black = tempConvertMatrix1;
18040 compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
18041 const XYZ_D65 = tempConvertMatrix2;
18042 normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
18043 const SRGB = tempConvertMatrix1;
18044 matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
18045 dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
18046 dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
18047 dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
18048 }
18049
18050 class CalRGBCS extends ColorSpace {
18051 constructor(whitePoint, blackPoint, gamma, matrix) {
18052 super("CalRGB", 3);
18053
18054 if (!whitePoint) {
18055 throw new _util.FormatError("WhitePoint missing - required for color space CalRGB");
18056 }
18057
18058 blackPoint = blackPoint || new Float32Array(3);
18059 gamma = gamma || new Float32Array([1, 1, 1]);
18060 matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
18061 const XW = whitePoint[0];
18062 const YW = whitePoint[1];
18063 const ZW = whitePoint[2];
18064 this.whitePoint = whitePoint;
18065 const XB = blackPoint[0];
18066 const YB = blackPoint[1];
18067 const ZB = blackPoint[2];
18068 this.blackPoint = blackPoint;
18069 this.GR = gamma[0];
18070 this.GG = gamma[1];
18071 this.GB = gamma[2];
18072 this.MXA = matrix[0];
18073 this.MYA = matrix[1];
18074 this.MZA = matrix[2];
18075 this.MXB = matrix[3];
18076 this.MYB = matrix[4];
18077 this.MZB = matrix[5];
18078 this.MXC = matrix[6];
18079 this.MYC = matrix[7];
18080 this.MZC = matrix[8];
18081
18082 if (XW < 0 || ZW < 0 || YW !== 1) {
18083 throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
18084 }
18085
18086 if (XB < 0 || YB < 0 || ZB < 0) {
18087 (0, _util.info)(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + "falling back to default.");
18088 this.blackPoint = new Float32Array(3);
18089 }
18090
18091 if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
18092 (0, _util.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
18093 this.GR = this.GG = this.GB = 1;
18094 }
18095 }
18096
18097 getRgbItem(src, srcOffset, dest, destOffset) {
18098 convertToRgb(this, src, srcOffset, dest, destOffset, 1);
18099 }
18100
18101 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
18102 const scale = 1 / ((1 << bits) - 1);
18103
18104 for (let i = 0; i < count; ++i) {
18105 convertToRgb(this, src, srcOffset, dest, destOffset, scale);
18106 srcOffset += 3;
18107 destOffset += 3 + alpha01;
18108 }
18109 }
18110
18111 getOutputLength(inputLength, alpha01) {
18112 return inputLength * (3 + alpha01) / 3 | 0;
18113 }
18114
18115 }
18116
18117 return CalRGBCS;
18118}();
18119
18120const LabCS = function LabCSClosure() {
18121 function fn_g(x) {
18122 let result;
18123
18124 if (x >= 6 / 29) {
18125 result = x * x * x;
18126 } else {
18127 result = 108 / 841 * (x - 4 / 29);
18128 }
18129
18130 return result;
18131 }
18132
18133 function decode(value, high1, low2, high2) {
18134 return low2 + value * (high2 - low2) / high1;
18135 }
18136
18137 function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
18138 let Ls = src[srcOffset];
18139 let as = src[srcOffset + 1];
18140 let bs = src[srcOffset + 2];
18141
18142 if (maxVal !== false) {
18143 Ls = decode(Ls, maxVal, 0, 100);
18144 as = decode(as, maxVal, cs.amin, cs.amax);
18145 bs = decode(bs, maxVal, cs.bmin, cs.bmax);
18146 }
18147
18148 if (as > cs.amax) {
18149 as = cs.amax;
18150 } else if (as < cs.amin) {
18151 as = cs.amin;
18152 }
18153
18154 if (bs > cs.bmax) {
18155 bs = cs.bmax;
18156 } else if (bs < cs.bmin) {
18157 bs = cs.bmin;
18158 }
18159
18160 const M = (Ls + 16) / 116;
18161 const L = M + as / 500;
18162 const N = M - bs / 200;
18163 const X = cs.XW * fn_g(L);
18164 const Y = cs.YW * fn_g(M);
18165 const Z = cs.ZW * fn_g(N);
18166 let r, g, b;
18167
18168 if (cs.ZW < 1) {
18169 r = X * 3.1339 + Y * -1.617 + Z * -0.4906;
18170 g = X * -0.9785 + Y * 1.916 + Z * 0.0333;
18171 b = X * 0.072 + Y * -0.229 + Z * 1.4057;
18172 } else {
18173 r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
18174 g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
18175 b = X * 0.0557 + Y * -0.204 + Z * 1.057;
18176 }
18177
18178 dest[destOffset] = Math.sqrt(r) * 255;
18179 dest[destOffset + 1] = Math.sqrt(g) * 255;
18180 dest[destOffset + 2] = Math.sqrt(b) * 255;
18181 }
18182
18183 class LabCS extends ColorSpace {
18184 constructor(whitePoint, blackPoint, range) {
18185 super("Lab", 3);
18186
18187 if (!whitePoint) {
18188 throw new _util.FormatError("WhitePoint missing - required for color space Lab");
18189 }
18190
18191 blackPoint = blackPoint || [0, 0, 0];
18192 range = range || [-100, 100, -100, 100];
18193 this.XW = whitePoint[0];
18194 this.YW = whitePoint[1];
18195 this.ZW = whitePoint[2];
18196 this.amin = range[0];
18197 this.amax = range[1];
18198 this.bmin = range[2];
18199 this.bmax = range[3];
18200 this.XB = blackPoint[0];
18201 this.YB = blackPoint[1];
18202 this.ZB = blackPoint[2];
18203
18204 if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
18205 throw new _util.FormatError("Invalid WhitePoint components, no fallback available");
18206 }
18207
18208 if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
18209 (0, _util.info)("Invalid BlackPoint, falling back to default");
18210 this.XB = this.YB = this.ZB = 0;
18211 }
18212
18213 if (this.amin > this.amax || this.bmin > this.bmax) {
18214 (0, _util.info)("Invalid Range, falling back to defaults");
18215 this.amin = -100;
18216 this.amax = 100;
18217 this.bmin = -100;
18218 this.bmax = 100;
18219 }
18220 }
18221
18222 getRgbItem(src, srcOffset, dest, destOffset) {
18223 convertToRgb(this, src, srcOffset, false, dest, destOffset);
18224 }
18225
18226 getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
18227 const maxVal = (1 << bits) - 1;
18228
18229 for (let i = 0; i < count; i++) {
18230 convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
18231 srcOffset += 3;
18232 destOffset += 3 + alpha01;
18233 }
18234 }
18235
18236 getOutputLength(inputLength, alpha01) {
18237 return inputLength * (3 + alpha01) / 3 | 0;
18238 }
18239
18240 isDefaultDecode(decodeMap, bpc) {
18241 return true;
18242 }
18243
18244 get usesZeroToOneRange() {
18245 return (0, _util.shadow)(this, "usesZeroToOneRange", false);
18246 }
18247
18248 }
18249
18250 return LabCS;
18251}();
18252
18253/***/ }),
18254/* 24 */
18255/***/ (function(module, exports, __w_pdfjs_require__) {
18256
18257"use strict";
18258
18259
18260Object.defineProperty(exports, "__esModule", {
18261 value: true
18262});
18263exports.GlobalImageCache = exports.LocalImageCache = void 0;
18264
18265var _util = __w_pdfjs_require__(2);
18266
18267var _primitives = __w_pdfjs_require__(5);
18268
18269class LocalImageCache {
18270 constructor() {
18271 this._nameRefMap = new Map();
18272 this._imageMap = new Map();
18273 this._imageCache = new _primitives.RefSetCache();
18274 }
18275
18276 getByName(name) {
18277 const ref = this._nameRefMap.get(name);
18278
18279 if (ref) {
18280 return this.getByRef(ref);
18281 }
18282
18283 return this._imageMap.get(name) || null;
18284 }
18285
18286 getByRef(ref) {
18287 return this._imageCache.get(ref) || null;
18288 }
18289
18290 set(name, ref = null, data) {
18291 if (!name) {
18292 throw new Error('LocalImageCache.set - expected "name" argument.');
18293 }
18294
18295 if (ref) {
18296 if (this._imageCache.has(ref)) {
18297 return;
18298 }
18299
18300 this._nameRefMap.set(name, ref);
18301
18302 this._imageCache.put(ref, data);
18303
18304 return;
18305 }
18306
18307 if (this._imageMap.has(name)) {
18308 return;
18309 }
18310
18311 this._imageMap.set(name, data);
18312 }
18313
18314}
18315
18316exports.LocalImageCache = LocalImageCache;
18317
18318class GlobalImageCache {
18319 static get NUM_PAGES_THRESHOLD() {
18320 return (0, _util.shadow)(this, "NUM_PAGES_THRESHOLD", 2);
18321 }
18322
18323 static get MAX_IMAGES_TO_CACHE() {
18324 return (0, _util.shadow)(this, "MAX_IMAGES_TO_CACHE", 10);
18325 }
18326
18327 constructor() {
18328 this._refCache = new _primitives.RefSetCache();
18329 this._imageCache = new _primitives.RefSetCache();
18330 }
18331
18332 shouldCache(ref, pageIndex) {
18333 const pageIndexSet = this._refCache.get(ref);
18334
18335 const numPages = pageIndexSet ? pageIndexSet.size + (pageIndexSet.has(pageIndex) ? 0 : 1) : 1;
18336
18337 if (numPages < GlobalImageCache.NUM_PAGES_THRESHOLD) {
18338 return false;
18339 }
18340
18341 if (!this._imageCache.has(ref) && this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
18342 return false;
18343 }
18344
18345 return true;
18346 }
18347
18348 addPageIndex(ref, pageIndex) {
18349 let pageIndexSet = this._refCache.get(ref);
18350
18351 if (!pageIndexSet) {
18352 pageIndexSet = new Set();
18353
18354 this._refCache.put(ref, pageIndexSet);
18355 }
18356
18357 pageIndexSet.add(pageIndex);
18358 }
18359
18360 getData(ref, pageIndex) {
18361 if (!this._refCache.has(ref)) {
18362 return null;
18363 }
18364
18365 const pageIndexSet = this._refCache.get(ref);
18366
18367 if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
18368 return null;
18369 }
18370
18371 if (!this._imageCache.has(ref)) {
18372 return null;
18373 }
18374
18375 pageIndexSet.add(pageIndex);
18376 return this._imageCache.get(ref);
18377 }
18378
18379 setData(ref, data) {
18380 if (!this._refCache.has(ref)) {
18381 throw new Error('GlobalImageCache.setData - expected "addPageIndex" to have been called.');
18382 }
18383
18384 if (this._imageCache.has(ref)) {
18385 return;
18386 }
18387
18388 if (this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
18389 (0, _util.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE.");
18390 return;
18391 }
18392
18393 this._imageCache.put(ref, data);
18394 }
18395
18396 clear(onlyData = false) {
18397 if (!onlyData) {
18398 this._refCache.clear();
18399 }
18400
18401 this._imageCache.clear();
18402 }
18403
18404}
18405
18406exports.GlobalImageCache = GlobalImageCache;
18407
18408/***/ }),
18409/* 25 */
18410/***/ (function(module, exports, __w_pdfjs_require__) {
18411
18412"use strict";
18413
18414
18415Object.defineProperty(exports, "__esModule", {
18416 value: true
18417});
18418exports.getQuadPoints = getQuadPoints;
18419exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
18420
18421var _util = __w_pdfjs_require__(2);
18422
18423var _obj = __w_pdfjs_require__(10);
18424
18425var _primitives = __w_pdfjs_require__(5);
18426
18427var _colorspace = __w_pdfjs_require__(23);
18428
18429var _core_utils = __w_pdfjs_require__(8);
18430
18431var _operator_list = __w_pdfjs_require__(26);
18432
18433var _stream = __w_pdfjs_require__(12);
18434
18435class AnnotationFactory {
18436 static create(xref, ref, pdfManager, idFactory) {
18437 return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory]);
18438 }
18439
18440 static _create(xref, ref, pdfManager, idFactory) {
18441 const dict = xref.fetchIfRef(ref);
18442
18443 if (!(0, _primitives.isDict)(dict)) {
18444 return undefined;
18445 }
18446
18447 const id = (0, _primitives.isRef)(ref) ? ref.toString() : `annot_${idFactory.createObjId()}`;
18448 let subtype = dict.get("Subtype");
18449 subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
18450 const parameters = {
18451 xref,
18452 dict,
18453 subtype,
18454 id,
18455 pdfManager
18456 };
18457
18458 switch (subtype) {
18459 case "Link":
18460 return new LinkAnnotation(parameters);
18461
18462 case "Text":
18463 return new TextAnnotation(parameters);
18464
18465 case "Widget":
18466 let fieldType = (0, _core_utils.getInheritableProperty)({
18467 dict,
18468 key: "FT"
18469 });
18470 fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
18471
18472 switch (fieldType) {
18473 case "Tx":
18474 return new TextWidgetAnnotation(parameters);
18475
18476 case "Btn":
18477 return new ButtonWidgetAnnotation(parameters);
18478
18479 case "Ch":
18480 return new ChoiceWidgetAnnotation(parameters);
18481 }
18482
18483 (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + "falling back to base field type.");
18484 return new WidgetAnnotation(parameters);
18485
18486 case "Popup":
18487 return new PopupAnnotation(parameters);
18488
18489 case "FreeText":
18490 return new FreeTextAnnotation(parameters);
18491
18492 case "Line":
18493 return new LineAnnotation(parameters);
18494
18495 case "Square":
18496 return new SquareAnnotation(parameters);
18497
18498 case "Circle":
18499 return new CircleAnnotation(parameters);
18500
18501 case "PolyLine":
18502 return new PolylineAnnotation(parameters);
18503
18504 case "Polygon":
18505 return new PolygonAnnotation(parameters);
18506
18507 case "Caret":
18508 return new CaretAnnotation(parameters);
18509
18510 case "Ink":
18511 return new InkAnnotation(parameters);
18512
18513 case "Highlight":
18514 return new HighlightAnnotation(parameters);
18515
18516 case "Underline":
18517 return new UnderlineAnnotation(parameters);
18518
18519 case "Squiggly":
18520 return new SquigglyAnnotation(parameters);
18521
18522 case "StrikeOut":
18523 return new StrikeOutAnnotation(parameters);
18524
18525 case "Stamp":
18526 return new StampAnnotation(parameters);
18527
18528 case "FileAttachment":
18529 return new FileAttachmentAnnotation(parameters);
18530
18531 default:
18532 if (!subtype) {
18533 (0, _util.warn)("Annotation is missing the required /Subtype.");
18534 } else {
18535 (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + "falling back to base annotation.");
18536 }
18537
18538 return new Annotation(parameters);
18539 }
18540 }
18541
18542}
18543
18544exports.AnnotationFactory = AnnotationFactory;
18545
18546function getQuadPoints(dict, rect) {
18547 if (!dict.has("QuadPoints")) {
18548 return null;
18549 }
18550
18551 const quadPoints = dict.getArray("QuadPoints");
18552
18553 if (!Array.isArray(quadPoints) || quadPoints.length % 8 > 0) {
18554 return null;
18555 }
18556
18557 const quadPointsLists = [];
18558
18559 for (let i = 0, ii = quadPoints.length / 8; i < ii; i++) {
18560 quadPointsLists.push([]);
18561
18562 for (let j = i * 8, jj = i * 8 + 8; j < jj; j += 2) {
18563 const x = quadPoints[j];
18564 const y = quadPoints[j + 1];
18565
18566 if (x < rect[0] || x > rect[2] || y < rect[1] || y > rect[3]) {
18567 return null;
18568 }
18569
18570 quadPointsLists[i].push({
18571 x,
18572 y
18573 });
18574 }
18575 }
18576
18577 return quadPointsLists;
18578}
18579
18580function getTransformMatrix(rect, bbox, matrix) {
18581 const [minX, minY, maxX, maxY] = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
18582
18583 if (minX === maxX || minY === maxY) {
18584 return [1, 0, 0, 1, rect[0], rect[1]];
18585 }
18586
18587 const xRatio = (rect[2] - rect[0]) / (maxX - minX);
18588 const yRatio = (rect[3] - rect[1]) / (maxY - minY);
18589 return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
18590}
18591
18592class Annotation {
18593 constructor(params) {
18594 const dict = params.dict;
18595 this.setContents(dict.get("Contents"));
18596 this.setModificationDate(dict.get("M"));
18597 this.setFlags(dict.get("F"));
18598 this.setRectangle(dict.getArray("Rect"));
18599 this.setColor(dict.getArray("C"));
18600 this.setBorderStyle(dict);
18601 this.setAppearance(dict);
18602 this.data = {
18603 annotationFlags: this.flags,
18604 borderStyle: this.borderStyle,
18605 color: this.color,
18606 contents: this.contents,
18607 hasAppearance: !!this.appearance,
18608 id: params.id,
18609 modificationDate: this.modificationDate,
18610 rect: this.rectangle,
18611 subtype: params.subtype
18612 };
18613 }
18614
18615 _hasFlag(flags, flag) {
18616 return !!(flags & flag);
18617 }
18618
18619 _isViewable(flags) {
18620 return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
18621 }
18622
18623 _isPrintable(flags) {
18624 return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
18625 }
18626
18627 get viewable() {
18628 if (this.flags === 0) {
18629 return true;
18630 }
18631
18632 return this._isViewable(this.flags);
18633 }
18634
18635 get printable() {
18636 if (this.flags === 0) {
18637 return false;
18638 }
18639
18640 return this._isPrintable(this.flags);
18641 }
18642
18643 setContents(contents) {
18644 this.contents = (0, _util.stringToPDFString)(contents || "");
18645 }
18646
18647 setModificationDate(modificationDate) {
18648 this.modificationDate = (0, _util.isString)(modificationDate) ? modificationDate : null;
18649 }
18650
18651 setFlags(flags) {
18652 this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
18653 }
18654
18655 hasFlag(flag) {
18656 return this._hasFlag(this.flags, flag);
18657 }
18658
18659 setRectangle(rectangle) {
18660 if (Array.isArray(rectangle) && rectangle.length === 4) {
18661 this.rectangle = _util.Util.normalizeRect(rectangle);
18662 } else {
18663 this.rectangle = [0, 0, 0, 0];
18664 }
18665 }
18666
18667 setColor(color) {
18668 const rgbColor = new Uint8ClampedArray(3);
18669
18670 if (!Array.isArray(color)) {
18671 this.color = rgbColor;
18672 return;
18673 }
18674
18675 switch (color.length) {
18676 case 0:
18677 this.color = null;
18678 break;
18679
18680 case 1:
18681 _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
18682
18683 this.color = rgbColor;
18684 break;
18685
18686 case 3:
18687 _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
18688
18689 this.color = rgbColor;
18690 break;
18691
18692 case 4:
18693 _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
18694
18695 this.color = rgbColor;
18696 break;
18697
18698 default:
18699 this.color = rgbColor;
18700 break;
18701 }
18702 }
18703
18704 setBorderStyle(borderStyle) {
18705 this.borderStyle = new AnnotationBorderStyle();
18706
18707 if (!(0, _primitives.isDict)(borderStyle)) {
18708 return;
18709 }
18710
18711 if (borderStyle.has("BS")) {
18712 const dict = borderStyle.get("BS");
18713 const dictType = dict.get("Type");
18714
18715 if (!dictType || (0, _primitives.isName)(dictType, "Border")) {
18716 this.borderStyle.setWidth(dict.get("W"), this.rectangle);
18717 this.borderStyle.setStyle(dict.get("S"));
18718 this.borderStyle.setDashArray(dict.getArray("D"));
18719 }
18720 } else if (borderStyle.has("Border")) {
18721 const array = borderStyle.getArray("Border");
18722
18723 if (Array.isArray(array) && array.length >= 3) {
18724 this.borderStyle.setHorizontalCornerRadius(array[0]);
18725 this.borderStyle.setVerticalCornerRadius(array[1]);
18726 this.borderStyle.setWidth(array[2], this.rectangle);
18727
18728 if (array.length === 4) {
18729 this.borderStyle.setDashArray(array[3]);
18730 }
18731 }
18732 } else {
18733 this.borderStyle.setWidth(0);
18734 }
18735 }
18736
18737 setAppearance(dict) {
18738 this.appearance = null;
18739 const appearanceStates = dict.get("AP");
18740
18741 if (!(0, _primitives.isDict)(appearanceStates)) {
18742 return;
18743 }
18744
18745 const normalAppearanceState = appearanceStates.get("N");
18746
18747 if ((0, _primitives.isStream)(normalAppearanceState)) {
18748 this.appearance = normalAppearanceState;
18749 return;
18750 }
18751
18752 if (!(0, _primitives.isDict)(normalAppearanceState)) {
18753 return;
18754 }
18755
18756 const as = dict.get("AS");
18757
18758 if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
18759 return;
18760 }
18761
18762 this.appearance = normalAppearanceState.get(as.name);
18763 }
18764
18765 loadResources(keys) {
18766 return this.appearance.dict.getAsync("Resources").then(resources => {
18767 if (!resources) {
18768 return undefined;
18769 }
18770
18771 const objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
18772 return objectLoader.load().then(function () {
18773 return resources;
18774 });
18775 });
18776 }
18777
18778 getOperatorList(evaluator, task, renderForms) {
18779 if (!this.appearance) {
18780 return Promise.resolve(new _operator_list.OperatorList());
18781 }
18782
18783 const data = this.data;
18784 const appearanceDict = this.appearance.dict;
18785 const resourcesPromise = this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"]);
18786 const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
18787 const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
18788 const transform = getTransformMatrix(data.rect, bbox, matrix);
18789 return resourcesPromise.then(resources => {
18790 const opList = new _operator_list.OperatorList();
18791 opList.addOp(_util.OPS.beginAnnotation, [data.rect, transform, matrix]);
18792 return evaluator.getOperatorList({
18793 stream: this.appearance,
18794 task,
18795 resources,
18796 operatorList: opList
18797 }).then(() => {
18798 opList.addOp(_util.OPS.endAnnotation, []);
18799 this.appearance.reset();
18800 return opList;
18801 });
18802 });
18803 }
18804
18805}
18806
18807exports.Annotation = Annotation;
18808
18809class AnnotationBorderStyle {
18810 constructor() {
18811 this.width = 1;
18812 this.style = _util.AnnotationBorderStyleType.SOLID;
18813 this.dashArray = [3];
18814 this.horizontalCornerRadius = 0;
18815 this.verticalCornerRadius = 0;
18816 }
18817
18818 setWidth(width, rect = [0, 0, 0, 0]) {
18819 if ((0, _primitives.isName)(width)) {
18820 this.width = 0;
18821 return;
18822 }
18823
18824 if (Number.isInteger(width)) {
18825 if (width > 0) {
18826 const maxWidth = (rect[2] - rect[0]) / 2;
18827 const maxHeight = (rect[3] - rect[1]) / 2;
18828
18829 if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
18830 (0, _util.warn)(`AnnotationBorderStyle.setWidth - ignoring width: ${width}`);
18831 width = 1;
18832 }
18833 }
18834
18835 this.width = width;
18836 }
18837 }
18838
18839 setStyle(style) {
18840 if (!(0, _primitives.isName)(style)) {
18841 return;
18842 }
18843
18844 switch (style.name) {
18845 case "S":
18846 this.style = _util.AnnotationBorderStyleType.SOLID;
18847 break;
18848
18849 case "D":
18850 this.style = _util.AnnotationBorderStyleType.DASHED;
18851 break;
18852
18853 case "B":
18854 this.style = _util.AnnotationBorderStyleType.BEVELED;
18855 break;
18856
18857 case "I":
18858 this.style = _util.AnnotationBorderStyleType.INSET;
18859 break;
18860
18861 case "U":
18862 this.style = _util.AnnotationBorderStyleType.UNDERLINE;
18863 break;
18864
18865 default:
18866 break;
18867 }
18868 }
18869
18870 setDashArray(dashArray) {
18871 if (Array.isArray(dashArray) && dashArray.length > 0) {
18872 let isValid = true;
18873 let allZeros = true;
18874
18875 for (const element of dashArray) {
18876 const validNumber = +element >= 0;
18877
18878 if (!validNumber) {
18879 isValid = false;
18880 break;
18881 } else if (element > 0) {
18882 allZeros = false;
18883 }
18884 }
18885
18886 if (isValid && !allZeros) {
18887 this.dashArray = dashArray;
18888 } else {
18889 this.width = 0;
18890 }
18891 } else if (dashArray) {
18892 this.width = 0;
18893 }
18894 }
18895
18896 setHorizontalCornerRadius(radius) {
18897 if (Number.isInteger(radius)) {
18898 this.horizontalCornerRadius = radius;
18899 }
18900 }
18901
18902 setVerticalCornerRadius(radius) {
18903 if (Number.isInteger(radius)) {
18904 this.verticalCornerRadius = radius;
18905 }
18906 }
18907
18908}
18909
18910exports.AnnotationBorderStyle = AnnotationBorderStyle;
18911
18912class MarkupAnnotation extends Annotation {
18913 constructor(parameters) {
18914 super(parameters);
18915 const dict = parameters.dict;
18916
18917 if (dict.has("IRT")) {
18918 const rawIRT = dict.getRaw("IRT");
18919 this.data.inReplyTo = (0, _primitives.isRef)(rawIRT) ? rawIRT.toString() : null;
18920 const rt = dict.get("RT");
18921 this.data.replyType = (0, _primitives.isName)(rt) ? rt.name : _util.AnnotationReplyType.REPLY;
18922 }
18923
18924 if (this.data.replyType === _util.AnnotationReplyType.GROUP) {
18925 const parent = dict.get("IRT");
18926 this.data.title = (0, _util.stringToPDFString)(parent.get("T") || "");
18927 this.setContents(parent.get("Contents"));
18928 this.data.contents = this.contents;
18929
18930 if (!parent.has("CreationDate")) {
18931 this.data.creationDate = null;
18932 } else {
18933 this.setCreationDate(parent.get("CreationDate"));
18934 this.data.creationDate = this.creationDate;
18935 }
18936
18937 if (!parent.has("M")) {
18938 this.data.modificationDate = null;
18939 } else {
18940 this.setModificationDate(parent.get("M"));
18941 this.data.modificationDate = this.modificationDate;
18942 }
18943
18944 this.data.hasPopup = parent.has("Popup");
18945
18946 if (!parent.has("C")) {
18947 this.data.color = null;
18948 } else {
18949 this.setColor(parent.getArray("C"));
18950 this.data.color = this.color;
18951 }
18952 } else {
18953 this.data.title = (0, _util.stringToPDFString)(dict.get("T") || "");
18954 this.setCreationDate(dict.get("CreationDate"));
18955 this.data.creationDate = this.creationDate;
18956 this.data.hasPopup = dict.has("Popup");
18957
18958 if (!dict.has("C")) {
18959 this.data.color = null;
18960 }
18961 }
18962 }
18963
18964 setCreationDate(creationDate) {
18965 this.creationDate = (0, _util.isString)(creationDate) ? creationDate : null;
18966 }
18967
18968}
18969
18970exports.MarkupAnnotation = MarkupAnnotation;
18971
18972class WidgetAnnotation extends Annotation {
18973 constructor(params) {
18974 super(params);
18975 const dict = params.dict;
18976 const data = this.data;
18977 data.annotationType = _util.AnnotationType.WIDGET;
18978 data.fieldName = this._constructFieldName(dict);
18979 data.fieldValue = (0, _core_utils.getInheritableProperty)({
18980 dict,
18981 key: "V",
18982 getArray: true
18983 });
18984 data.alternativeText = (0, _util.stringToPDFString)(dict.get("TU") || "");
18985 data.defaultAppearance = (0, _core_utils.getInheritableProperty)({
18986 dict,
18987 key: "DA"
18988 }) || "";
18989 const fieldType = (0, _core_utils.getInheritableProperty)({
18990 dict,
18991 key: "FT"
18992 });
18993 data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
18994 this.fieldResources = (0, _core_utils.getInheritableProperty)({
18995 dict,
18996 key: "DR"
18997 }) || _primitives.Dict.empty;
18998 data.fieldFlags = (0, _core_utils.getInheritableProperty)({
18999 dict,
19000 key: "Ff"
19001 });
19002
19003 if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
19004 data.fieldFlags = 0;
19005 }
19006
19007 data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
19008
19009 if (data.fieldType === "Sig") {
19010 data.fieldValue = null;
19011 this.setFlags(_util.AnnotationFlag.HIDDEN);
19012 }
19013 }
19014
19015 _constructFieldName(dict) {
19016 if (!dict.has("T") && !dict.has("Parent")) {
19017 (0, _util.warn)("Unknown field name, falling back to empty field name.");
19018 return "";
19019 }
19020
19021 if (!dict.has("Parent")) {
19022 return (0, _util.stringToPDFString)(dict.get("T"));
19023 }
19024
19025 const fieldName = [];
19026
19027 if (dict.has("T")) {
19028 fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
19029 }
19030
19031 let loopDict = dict;
19032
19033 while (loopDict.has("Parent")) {
19034 loopDict = loopDict.get("Parent");
19035
19036 if (!(0, _primitives.isDict)(loopDict)) {
19037 break;
19038 }
19039
19040 if (loopDict.has("T")) {
19041 fieldName.unshift((0, _util.stringToPDFString)(loopDict.get("T")));
19042 }
19043 }
19044
19045 return fieldName.join(".");
19046 }
19047
19048 hasFieldFlag(flag) {
19049 return !!(this.data.fieldFlags & flag);
19050 }
19051
19052 getOperatorList(evaluator, task, renderForms) {
19053 if (renderForms) {
19054 return Promise.resolve(new _operator_list.OperatorList());
19055 }
19056
19057 return super.getOperatorList(evaluator, task, renderForms);
19058 }
19059
19060}
19061
19062class TextWidgetAnnotation extends WidgetAnnotation {
19063 constructor(params) {
19064 super(params);
19065 const dict = params.dict;
19066 this.data.fieldValue = (0, _util.stringToPDFString)(this.data.fieldValue || "");
19067 let alignment = (0, _core_utils.getInheritableProperty)({
19068 dict,
19069 key: "Q"
19070 });
19071
19072 if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
19073 alignment = null;
19074 }
19075
19076 this.data.textAlignment = alignment;
19077 let maximumLength = (0, _core_utils.getInheritableProperty)({
19078 dict,
19079 key: "MaxLen"
19080 });
19081
19082 if (!Number.isInteger(maximumLength) || maximumLength < 0) {
19083 maximumLength = null;
19084 }
19085
19086 this.data.maxLen = maximumLength;
19087 this.data.multiLine = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
19088 this.data.comb = this.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
19089 }
19090
19091 getOperatorList(evaluator, task, renderForms) {
19092 if (renderForms || this.appearance) {
19093 return super.getOperatorList(evaluator, task, renderForms);
19094 }
19095
19096 const operatorList = new _operator_list.OperatorList();
19097
19098 if (!this.data.defaultAppearance) {
19099 return Promise.resolve(operatorList);
19100 }
19101
19102 const stream = new _stream.Stream((0, _util.stringToBytes)(this.data.defaultAppearance));
19103 return evaluator.getOperatorList({
19104 stream,
19105 task,
19106 resources: this.fieldResources,
19107 operatorList
19108 }).then(function () {
19109 return operatorList;
19110 });
19111 }
19112
19113}
19114
19115class ButtonWidgetAnnotation extends WidgetAnnotation {
19116 constructor(params) {
19117 super(params);
19118 this.data.checkBox = !this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
19119 this.data.radioButton = this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
19120 this.data.pushButton = this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
19121
19122 if (this.data.checkBox) {
19123 this._processCheckBox(params);
19124 } else if (this.data.radioButton) {
19125 this._processRadioButton(params);
19126 } else if (this.data.pushButton) {
19127 this._processPushButton(params);
19128 } else {
19129 (0, _util.warn)("Invalid field flags for button widget annotation");
19130 }
19131 }
19132
19133 _processCheckBox(params) {
19134 if ((0, _primitives.isName)(this.data.fieldValue)) {
19135 this.data.fieldValue = this.data.fieldValue.name;
19136 }
19137
19138 const customAppearance = params.dict.get("AP");
19139
19140 if (!(0, _primitives.isDict)(customAppearance)) {
19141 return;
19142 }
19143
19144 const exportValueOptionsDict = customAppearance.get("D");
19145
19146 if (!(0, _primitives.isDict)(exportValueOptionsDict)) {
19147 return;
19148 }
19149
19150 const exportValues = exportValueOptionsDict.getKeys();
19151 const hasCorrectOptionCount = exportValues.length === 2;
19152
19153 if (!hasCorrectOptionCount) {
19154 return;
19155 }
19156
19157 this.data.exportValue = exportValues[0] === "Off" ? exportValues[1] : exportValues[0];
19158 }
19159
19160 _processRadioButton(params) {
19161 this.data.fieldValue = this.data.buttonValue = null;
19162 const fieldParent = params.dict.get("Parent");
19163
19164 if ((0, _primitives.isDict)(fieldParent) && fieldParent.has("V")) {
19165 const fieldParentValue = fieldParent.get("V");
19166
19167 if ((0, _primitives.isName)(fieldParentValue)) {
19168 this.data.fieldValue = fieldParentValue.name;
19169 }
19170 }
19171
19172 const appearanceStates = params.dict.get("AP");
19173
19174 if (!(0, _primitives.isDict)(appearanceStates)) {
19175 return;
19176 }
19177
19178 const normalAppearanceState = appearanceStates.get("N");
19179
19180 if (!(0, _primitives.isDict)(normalAppearanceState)) {
19181 return;
19182 }
19183
19184 for (const key of normalAppearanceState.getKeys()) {
19185 if (key !== "Off") {
19186 this.data.buttonValue = key;
19187 break;
19188 }
19189 }
19190 }
19191
19192 _processPushButton(params) {
19193 if (!params.dict.has("A")) {
19194 (0, _util.warn)("Push buttons without action dictionaries are not supported");
19195 return;
19196 }
19197
19198 _obj.Catalog.parseDestDictionary({
19199 destDict: params.dict,
19200 resultObj: this.data,
19201 docBaseUrl: params.pdfManager.docBaseUrl
19202 });
19203 }
19204
19205}
19206
19207class ChoiceWidgetAnnotation extends WidgetAnnotation {
19208 constructor(params) {
19209 super(params);
19210 this.data.options = [];
19211 const options = (0, _core_utils.getInheritableProperty)({
19212 dict: params.dict,
19213 key: "Opt"
19214 });
19215
19216 if (Array.isArray(options)) {
19217 const xref = params.xref;
19218
19219 for (let i = 0, ii = options.length; i < ii; i++) {
19220 const option = xref.fetchIfRef(options[i]);
19221 const isOptionArray = Array.isArray(option);
19222 this.data.options[i] = {
19223 exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
19224 displayValue: (0, _util.stringToPDFString)(isOptionArray ? xref.fetchIfRef(option[1]) : option)
19225 };
19226 }
19227 }
19228
19229 if (!Array.isArray(this.data.fieldValue)) {
19230 this.data.fieldValue = [this.data.fieldValue];
19231 }
19232
19233 this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
19234 this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
19235 }
19236
19237}
19238
19239class TextAnnotation extends MarkupAnnotation {
19240 constructor(parameters) {
19241 const DEFAULT_ICON_SIZE = 22;
19242 super(parameters);
19243 const dict = parameters.dict;
19244 this.data.annotationType = _util.AnnotationType.TEXT;
19245
19246 if (this.data.hasAppearance) {
19247 this.data.name = "NoIcon";
19248 } else {
19249 this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
19250 this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
19251 this.data.name = dict.has("Name") ? dict.get("Name").name : "Note";
19252 }
19253
19254 if (dict.has("State")) {
19255 this.data.state = dict.get("State") || null;
19256 this.data.stateModel = dict.get("StateModel") || null;
19257 } else {
19258 this.data.state = null;
19259 this.data.stateModel = null;
19260 }
19261 }
19262
19263}
19264
19265class LinkAnnotation extends Annotation {
19266 constructor(params) {
19267 super(params);
19268 this.data.annotationType = _util.AnnotationType.LINK;
19269 const quadPoints = getQuadPoints(params.dict, this.rectangle);
19270
19271 if (quadPoints) {
19272 this.data.quadPoints = quadPoints;
19273 }
19274
19275 _obj.Catalog.parseDestDictionary({
19276 destDict: params.dict,
19277 resultObj: this.data,
19278 docBaseUrl: params.pdfManager.docBaseUrl
19279 });
19280 }
19281
19282}
19283
19284class PopupAnnotation extends Annotation {
19285 constructor(parameters) {
19286 super(parameters);
19287 this.data.annotationType = _util.AnnotationType.POPUP;
19288 let parentItem = parameters.dict.get("Parent");
19289
19290 if (!parentItem) {
19291 (0, _util.warn)("Popup annotation has a missing or invalid parent annotation.");
19292 return;
19293 }
19294
19295 const parentSubtype = parentItem.get("Subtype");
19296 this.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
19297 const rawParent = parameters.dict.getRaw("Parent");
19298 this.data.parentId = (0, _primitives.isRef)(rawParent) ? rawParent.toString() : null;
19299 const rt = parentItem.get("RT");
19300
19301 if ((0, _primitives.isName)(rt, _util.AnnotationReplyType.GROUP)) {
19302 parentItem = parentItem.get("IRT");
19303 }
19304
19305 if (!parentItem.has("M")) {
19306 this.data.modificationDate = null;
19307 } else {
19308 this.setModificationDate(parentItem.get("M"));
19309 this.data.modificationDate = this.modificationDate;
19310 }
19311
19312 if (!parentItem.has("C")) {
19313 this.data.color = null;
19314 } else {
19315 this.setColor(parentItem.getArray("C"));
19316 this.data.color = this.color;
19317 }
19318
19319 if (!this.viewable) {
19320 const parentFlags = parentItem.get("F");
19321
19322 if (this._isViewable(parentFlags)) {
19323 this.setFlags(parentFlags);
19324 }
19325 }
19326
19327 this.data.title = (0, _util.stringToPDFString)(parentItem.get("T") || "");
19328 this.data.contents = (0, _util.stringToPDFString)(parentItem.get("Contents") || "");
19329 }
19330
19331}
19332
19333class FreeTextAnnotation extends MarkupAnnotation {
19334 constructor(parameters) {
19335 super(parameters);
19336 this.data.annotationType = _util.AnnotationType.FREETEXT;
19337 }
19338
19339}
19340
19341class LineAnnotation extends MarkupAnnotation {
19342 constructor(parameters) {
19343 super(parameters);
19344 this.data.annotationType = _util.AnnotationType.LINE;
19345 this.data.lineCoordinates = _util.Util.normalizeRect(parameters.dict.getArray("L"));
19346 }
19347
19348}
19349
19350class SquareAnnotation extends MarkupAnnotation {
19351 constructor(parameters) {
19352 super(parameters);
19353 this.data.annotationType = _util.AnnotationType.SQUARE;
19354 }
19355
19356}
19357
19358class CircleAnnotation extends MarkupAnnotation {
19359 constructor(parameters) {
19360 super(parameters);
19361 this.data.annotationType = _util.AnnotationType.CIRCLE;
19362 }
19363
19364}
19365
19366class PolylineAnnotation extends MarkupAnnotation {
19367 constructor(parameters) {
19368 super(parameters);
19369 this.data.annotationType = _util.AnnotationType.POLYLINE;
19370 const rawVertices = parameters.dict.getArray("Vertices");
19371 this.data.vertices = [];
19372
19373 for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
19374 this.data.vertices.push({
19375 x: rawVertices[i],
19376 y: rawVertices[i + 1]
19377 });
19378 }
19379 }
19380
19381}
19382
19383class PolygonAnnotation extends PolylineAnnotation {
19384 constructor(parameters) {
19385 super(parameters);
19386 this.data.annotationType = _util.AnnotationType.POLYGON;
19387 }
19388
19389}
19390
19391class CaretAnnotation extends MarkupAnnotation {
19392 constructor(parameters) {
19393 super(parameters);
19394 this.data.annotationType = _util.AnnotationType.CARET;
19395 }
19396
19397}
19398
19399class InkAnnotation extends MarkupAnnotation {
19400 constructor(parameters) {
19401 super(parameters);
19402 this.data.annotationType = _util.AnnotationType.INK;
19403 const xref = parameters.xref;
19404 const originalInkLists = parameters.dict.getArray("InkList");
19405 this.data.inkLists = [];
19406
19407 for (let i = 0, ii = originalInkLists.length; i < ii; ++i) {
19408 this.data.inkLists.push([]);
19409
19410 for (let j = 0, jj = originalInkLists[i].length; j < jj; j += 2) {
19411 this.data.inkLists[i].push({
19412 x: xref.fetchIfRef(originalInkLists[i][j]),
19413 y: xref.fetchIfRef(originalInkLists[i][j + 1])
19414 });
19415 }
19416 }
19417 }
19418
19419}
19420
19421class HighlightAnnotation extends MarkupAnnotation {
19422 constructor(parameters) {
19423 super(parameters);
19424 this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
19425 const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
19426
19427 if (quadPoints) {
19428 this.data.quadPoints = quadPoints;
19429 }
19430 }
19431
19432}
19433
19434class UnderlineAnnotation extends MarkupAnnotation {
19435 constructor(parameters) {
19436 super(parameters);
19437 this.data.annotationType = _util.AnnotationType.UNDERLINE;
19438 const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
19439
19440 if (quadPoints) {
19441 this.data.quadPoints = quadPoints;
19442 }
19443 }
19444
19445}
19446
19447class SquigglyAnnotation extends MarkupAnnotation {
19448 constructor(parameters) {
19449 super(parameters);
19450 this.data.annotationType = _util.AnnotationType.SQUIGGLY;
19451 const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
19452
19453 if (quadPoints) {
19454 this.data.quadPoints = quadPoints;
19455 }
19456 }
19457
19458}
19459
19460class StrikeOutAnnotation extends MarkupAnnotation {
19461 constructor(parameters) {
19462 super(parameters);
19463 this.data.annotationType = _util.AnnotationType.STRIKEOUT;
19464 const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
19465
19466 if (quadPoints) {
19467 this.data.quadPoints = quadPoints;
19468 }
19469 }
19470
19471}
19472
19473class StampAnnotation extends MarkupAnnotation {
19474 constructor(parameters) {
19475 super(parameters);
19476 this.data.annotationType = _util.AnnotationType.STAMP;
19477 }
19478
19479}
19480
19481class FileAttachmentAnnotation extends MarkupAnnotation {
19482 constructor(parameters) {
19483 super(parameters);
19484 const file = new _obj.FileSpec(parameters.dict.get("FS"), parameters.xref);
19485 this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
19486 this.data.file = file.serializable;
19487 }
19488
19489}
19490
19491/***/ }),
19492/* 26 */
19493/***/ (function(module, exports, __w_pdfjs_require__) {
19494
19495"use strict";
19496
19497
19498Object.defineProperty(exports, "__esModule", {
19499 value: true
19500});
19501exports.OperatorList = void 0;
19502
19503var _util = __w_pdfjs_require__(2);
19504
19505var QueueOptimizer = function QueueOptimizerClosure() {
19506 function addState(parentState, pattern, checkFn, iterateFn, processFn) {
19507 var state = parentState;
19508
19509 for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
19510 var item = pattern[i];
19511 state = state[item] || (state[item] = []);
19512 }
19513
19514 state[pattern[pattern.length - 1]] = {
19515 checkFn,
19516 iterateFn,
19517 processFn
19518 };
19519 }
19520
19521 function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
19522 var iFirstPIMXO = iFirstSave + 2;
19523
19524 for (var i = 0; i < count; i++) {
19525 var arg = argsArray[iFirstPIMXO + 4 * i];
19526 var imageMask = arg.length === 1 && arg[0];
19527
19528 if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
19529 fnArray[iFirstPIMXO + 4 * i] = _util.OPS.paintSolidColorImageMask;
19530 continue;
19531 }
19532
19533 break;
19534 }
19535
19536 return count - i;
19537 }
19538
19539 var InitialState = [];
19540 addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
19541 var fnArray = context.fnArray;
19542 var iFirstSave = context.iCurr - 3;
19543 var pos = (i - iFirstSave) % 4;
19544
19545 switch (pos) {
19546 case 0:
19547 return fnArray[i] === _util.OPS.save;
19548
19549 case 1:
19550 return fnArray[i] === _util.OPS.transform;
19551
19552 case 2:
19553 return fnArray[i] === _util.OPS.paintInlineImageXObject;
19554
19555 case 3:
19556 return fnArray[i] === _util.OPS.restore;
19557 }
19558
19559 throw new Error(`iterateInlineImageGroup - invalid pos: ${pos}`);
19560 }, function foundInlineImageGroup(context, i) {
19561 var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
19562 var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
19563 var MAX_WIDTH = 1000;
19564 var IMAGE_PADDING = 1;
19565 var fnArray = context.fnArray,
19566 argsArray = context.argsArray;
19567 var curr = context.iCurr;
19568 var iFirstSave = curr - 3;
19569 var iFirstTransform = curr - 2;
19570 var iFirstPIIXO = curr - 1;
19571 var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
19572
19573 if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
19574 return i - (i - iFirstSave) % 4;
19575 }
19576
19577 var maxX = 0;
19578 var map = [],
19579 maxLineHeight = 0;
19580 var currentX = IMAGE_PADDING,
19581 currentY = IMAGE_PADDING;
19582 var q;
19583
19584 for (q = 0; q < count; q++) {
19585 var transform = argsArray[iFirstTransform + (q << 2)];
19586 var img = argsArray[iFirstPIIXO + (q << 2)][0];
19587
19588 if (currentX + img.width > MAX_WIDTH) {
19589 maxX = Math.max(maxX, currentX);
19590 currentY += maxLineHeight + 2 * IMAGE_PADDING;
19591 currentX = 0;
19592 maxLineHeight = 0;
19593 }
19594
19595 map.push({
19596 transform,
19597 x: currentX,
19598 y: currentY,
19599 w: img.width,
19600 h: img.height
19601 });
19602 currentX += img.width + 2 * IMAGE_PADDING;
19603 maxLineHeight = Math.max(maxLineHeight, img.height);
19604 }
19605
19606 var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
19607 var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
19608 var imgData = new Uint8ClampedArray(imgWidth * imgHeight * 4);
19609 var imgRowSize = imgWidth << 2;
19610
19611 for (q = 0; q < count; q++) {
19612 var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
19613 var rowSize = map[q].w << 2;
19614 var dataOffset = 0;
19615 var offset = map[q].x + map[q].y * imgWidth << 2;
19616 imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
19617
19618 for (var k = 0, kk = map[q].h; k < kk; k++) {
19619 imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
19620 dataOffset += rowSize;
19621 offset += imgRowSize;
19622 }
19623
19624 imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
19625
19626 while (offset >= 0) {
19627 data[offset - 4] = data[offset];
19628 data[offset - 3] = data[offset + 1];
19629 data[offset - 2] = data[offset + 2];
19630 data[offset - 1] = data[offset + 3];
19631 data[offset + rowSize] = data[offset + rowSize - 4];
19632 data[offset + rowSize + 1] = data[offset + rowSize - 3];
19633 data[offset + rowSize + 2] = data[offset + rowSize - 2];
19634 data[offset + rowSize + 3] = data[offset + rowSize - 1];
19635 offset -= imgRowSize;
19636 }
19637 }
19638
19639 fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
19640 argsArray.splice(iFirstSave, count * 4, [{
19641 width: imgWidth,
19642 height: imgHeight,
19643 kind: _util.ImageKind.RGBA_32BPP,
19644 data: imgData
19645 }, map]);
19646 return iFirstSave + 1;
19647 });
19648 addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
19649 var fnArray = context.fnArray;
19650 var iFirstSave = context.iCurr - 3;
19651 var pos = (i - iFirstSave) % 4;
19652
19653 switch (pos) {
19654 case 0:
19655 return fnArray[i] === _util.OPS.save;
19656
19657 case 1:
19658 return fnArray[i] === _util.OPS.transform;
19659
19660 case 2:
19661 return fnArray[i] === _util.OPS.paintImageMaskXObject;
19662
19663 case 3:
19664 return fnArray[i] === _util.OPS.restore;
19665 }
19666
19667 throw new Error(`iterateImageMaskGroup - invalid pos: ${pos}`);
19668 }, function foundImageMaskGroup(context, i) {
19669 var MIN_IMAGES_IN_MASKS_BLOCK = 10;
19670 var MAX_IMAGES_IN_MASKS_BLOCK = 100;
19671 var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
19672 var fnArray = context.fnArray,
19673 argsArray = context.argsArray;
19674 var curr = context.iCurr;
19675 var iFirstSave = curr - 3;
19676 var iFirstTransform = curr - 2;
19677 var iFirstPIMXO = curr - 1;
19678 var count = Math.floor((i - iFirstSave) / 4);
19679 count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
19680
19681 if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
19682 return i - (i - iFirstSave) % 4;
19683 }
19684
19685 var q;
19686 var isSameImage = false;
19687 var iTransform, transformArgs;
19688 var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
19689
19690 if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
19691 isSameImage = true;
19692 var firstTransformArg0 = argsArray[iFirstTransform][0];
19693 var firstTransformArg3 = argsArray[iFirstTransform][3];
19694 iTransform = iFirstTransform + 4;
19695 var iPIMXO = iFirstPIMXO + 4;
19696
19697 for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
19698 transformArgs = argsArray[iTransform];
19699
19700 if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
19701 if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
19702 isSameImage = false;
19703 } else {
19704 count = q;
19705 }
19706
19707 break;
19708 }
19709 }
19710 }
19711
19712 if (isSameImage) {
19713 count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
19714 var positions = new Float32Array(count * 2);
19715 iTransform = iFirstTransform;
19716
19717 for (q = 0; q < count; q++, iTransform += 4) {
19718 transformArgs = argsArray[iTransform];
19719 positions[q << 1] = transformArgs[4];
19720 positions[(q << 1) + 1] = transformArgs[5];
19721 }
19722
19723 fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
19724 argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg3, positions]);
19725 } else {
19726 count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
19727 var images = [];
19728
19729 for (q = 0; q < count; q++) {
19730 transformArgs = argsArray[iFirstTransform + (q << 2)];
19731 var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
19732 images.push({
19733 data: maskParams.data,
19734 width: maskParams.width,
19735 height: maskParams.height,
19736 transform: transformArgs
19737 });
19738 }
19739
19740 fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
19741 argsArray.splice(iFirstSave, count * 4, [images]);
19742 }
19743
19744 return iFirstSave + 1;
19745 });
19746 addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
19747 var argsArray = context.argsArray;
19748 var iFirstTransform = context.iCurr - 2;
19749 return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
19750 }, function iterateImageGroup(context, i) {
19751 var fnArray = context.fnArray,
19752 argsArray = context.argsArray;
19753 var iFirstSave = context.iCurr - 3;
19754 var pos = (i - iFirstSave) % 4;
19755
19756 switch (pos) {
19757 case 0:
19758 return fnArray[i] === _util.OPS.save;
19759
19760 case 1:
19761 if (fnArray[i] !== _util.OPS.transform) {
19762 return false;
19763 }
19764
19765 var iFirstTransform = context.iCurr - 2;
19766 var firstTransformArg0 = argsArray[iFirstTransform][0];
19767 var firstTransformArg3 = argsArray[iFirstTransform][3];
19768
19769 if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
19770 return false;
19771 }
19772
19773 return true;
19774
19775 case 2:
19776 if (fnArray[i] !== _util.OPS.paintImageXObject) {
19777 return false;
19778 }
19779
19780 var iFirstPIXO = context.iCurr - 1;
19781 var firstPIXOArg0 = argsArray[iFirstPIXO][0];
19782
19783 if (argsArray[i][0] !== firstPIXOArg0) {
19784 return false;
19785 }
19786
19787 return true;
19788
19789 case 3:
19790 return fnArray[i] === _util.OPS.restore;
19791 }
19792
19793 throw new Error(`iterateImageGroup - invalid pos: ${pos}`);
19794 }, function (context, i) {
19795 var MIN_IMAGES_IN_BLOCK = 3;
19796 var MAX_IMAGES_IN_BLOCK = 1000;
19797 var fnArray = context.fnArray,
19798 argsArray = context.argsArray;
19799 var curr = context.iCurr;
19800 var iFirstSave = curr - 3;
19801 var iFirstTransform = curr - 2;
19802 var iFirstPIXO = curr - 1;
19803 var firstPIXOArg0 = argsArray[iFirstPIXO][0];
19804 var firstTransformArg0 = argsArray[iFirstTransform][0];
19805 var firstTransformArg3 = argsArray[iFirstTransform][3];
19806 var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
19807
19808 if (count < MIN_IMAGES_IN_BLOCK) {
19809 return i - (i - iFirstSave) % 4;
19810 }
19811
19812 var positions = new Float32Array(count * 2);
19813 var iTransform = iFirstTransform;
19814
19815 for (var q = 0; q < count; q++, iTransform += 4) {
19816 var transformArgs = argsArray[iTransform];
19817 positions[q << 1] = transformArgs[4];
19818 positions[(q << 1) + 1] = transformArgs[5];
19819 }
19820
19821 var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
19822 fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
19823 argsArray.splice(iFirstSave, count * 4, args);
19824 return iFirstSave + 1;
19825 });
19826 addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function iterateShowTextGroup(context, i) {
19827 var fnArray = context.fnArray,
19828 argsArray = context.argsArray;
19829 var iFirstSave = context.iCurr - 4;
19830 var pos = (i - iFirstSave) % 5;
19831
19832 switch (pos) {
19833 case 0:
19834 return fnArray[i] === _util.OPS.beginText;
19835
19836 case 1:
19837 return fnArray[i] === _util.OPS.setFont;
19838
19839 case 2:
19840 return fnArray[i] === _util.OPS.setTextMatrix;
19841
19842 case 3:
19843 if (fnArray[i] !== _util.OPS.showText) {
19844 return false;
19845 }
19846
19847 var iFirstSetFont = context.iCurr - 3;
19848 var firstSetFontArg0 = argsArray[iFirstSetFont][0];
19849 var firstSetFontArg1 = argsArray[iFirstSetFont][1];
19850
19851 if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
19852 return false;
19853 }
19854
19855 return true;
19856
19857 case 4:
19858 return fnArray[i] === _util.OPS.endText;
19859 }
19860
19861 throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`);
19862 }, function (context, i) {
19863 var MIN_CHARS_IN_BLOCK = 3;
19864 var MAX_CHARS_IN_BLOCK = 1000;
19865 var fnArray = context.fnArray,
19866 argsArray = context.argsArray;
19867 var curr = context.iCurr;
19868 var iFirstBeginText = curr - 4;
19869 var iFirstSetFont = curr - 3;
19870 var iFirstSetTextMatrix = curr - 2;
19871 var iFirstShowText = curr - 1;
19872 var iFirstEndText = curr;
19873 var firstSetFontArg0 = argsArray[iFirstSetFont][0];
19874 var firstSetFontArg1 = argsArray[iFirstSetFont][1];
19875 var count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
19876
19877 if (count < MIN_CHARS_IN_BLOCK) {
19878 return i - (i - iFirstBeginText) % 5;
19879 }
19880
19881 var iFirst = iFirstBeginText;
19882
19883 if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
19884 count++;
19885 iFirst -= 5;
19886 }
19887
19888 var iEndText = iFirst + 4;
19889
19890 for (var q = 1; q < count; q++) {
19891 fnArray.splice(iEndText, 3);
19892 argsArray.splice(iEndText, 3);
19893 iEndText += 2;
19894 }
19895
19896 return iEndText + 1;
19897 });
19898
19899 function QueueOptimizer(queue) {
19900 this.queue = queue;
19901 this.state = null;
19902 this.context = {
19903 iCurr: 0,
19904 fnArray: queue.fnArray,
19905 argsArray: queue.argsArray
19906 };
19907 this.match = null;
19908 this.lastProcessed = 0;
19909 }
19910
19911 QueueOptimizer.prototype = {
19912 _optimize() {
19913 const fnArray = this.queue.fnArray;
19914 let i = this.lastProcessed,
19915 ii = fnArray.length;
19916 let state = this.state;
19917 let match = this.match;
19918
19919 if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
19920 this.lastProcessed = ii;
19921 return;
19922 }
19923
19924 const context = this.context;
19925
19926 while (i < ii) {
19927 if (match) {
19928 const iterate = (0, match.iterateFn)(context, i);
19929
19930 if (iterate) {
19931 i++;
19932 continue;
19933 }
19934
19935 i = (0, match.processFn)(context, i + 1);
19936 ii = fnArray.length;
19937 match = null;
19938 state = null;
19939
19940 if (i >= ii) {
19941 break;
19942 }
19943 }
19944
19945 state = (state || InitialState)[fnArray[i]];
19946
19947 if (!state || Array.isArray(state)) {
19948 i++;
19949 continue;
19950 }
19951
19952 context.iCurr = i;
19953 i++;
19954
19955 if (state.checkFn && !(0, state.checkFn)(context)) {
19956 state = null;
19957 continue;
19958 }
19959
19960 match = state;
19961 state = null;
19962 }
19963
19964 this.state = state;
19965 this.match = match;
19966 this.lastProcessed = i;
19967 },
19968
19969 push(fn, args) {
19970 this.queue.fnArray.push(fn);
19971 this.queue.argsArray.push(args);
19972
19973 this._optimize();
19974 },
19975
19976 flush() {
19977 while (this.match) {
19978 const length = this.queue.fnArray.length;
19979 this.lastProcessed = (0, this.match.processFn)(this.context, length);
19980 this.match = null;
19981 this.state = null;
19982
19983 this._optimize();
19984 }
19985 },
19986
19987 reset() {
19988 this.state = null;
19989 this.match = null;
19990 this.lastProcessed = 0;
19991 }
19992
19993 };
19994 return QueueOptimizer;
19995}();
19996
19997var NullOptimizer = function NullOptimizerClosure() {
19998 function NullOptimizer(queue) {
19999 this.queue = queue;
20000 }
20001
20002 NullOptimizer.prototype = {
20003 push(fn, args) {
20004 this.queue.fnArray.push(fn);
20005 this.queue.argsArray.push(args);
20006 },
20007
20008 flush() {},
20009
20010 reset() {}
20011
20012 };
20013 return NullOptimizer;
20014}();
20015
20016var OperatorList = function OperatorListClosure() {
20017 var CHUNK_SIZE = 1000;
20018 var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
20019
20020 function OperatorList(intent, streamSink, pageIndex) {
20021 this._streamSink = streamSink;
20022 this.fnArray = [];
20023 this.argsArray = [];
20024
20025 if (streamSink && intent !== "oplist") {
20026 this.optimizer = new QueueOptimizer(this);
20027 } else {
20028 this.optimizer = new NullOptimizer(this);
20029 }
20030
20031 this.dependencies = Object.create(null);
20032 this._totalLength = 0;
20033 this.pageIndex = pageIndex;
20034 this.intent = intent;
20035 this.weight = 0;
20036 this._resolved = streamSink ? null : Promise.resolve();
20037 }
20038
20039 OperatorList.prototype = {
20040 get length() {
20041 return this.argsArray.length;
20042 },
20043
20044 get ready() {
20045 return this._resolved || this._streamSink.ready;
20046 },
20047
20048 get totalLength() {
20049 return this._totalLength + this.length;
20050 },
20051
20052 addOp(fn, args) {
20053 this.optimizer.push(fn, args);
20054 this.weight++;
20055
20056 if (this._streamSink) {
20057 if (this.weight >= CHUNK_SIZE) {
20058 this.flush();
20059 } else if (this.weight >= CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
20060 this.flush();
20061 }
20062 }
20063 },
20064
20065 addDependency(dependency) {
20066 if (dependency in this.dependencies) {
20067 return;
20068 }
20069
20070 this.dependencies[dependency] = true;
20071 this.addOp(_util.OPS.dependency, [dependency]);
20072 },
20073
20074 addDependencies(dependencies) {
20075 for (var key in dependencies) {
20076 this.addDependency(key);
20077 }
20078 },
20079
20080 addOpList(opList) {
20081 if (!(opList instanceof OperatorList)) {
20082 (0, _util.warn)('addOpList - ignoring invalid "opList" parameter.');
20083 return;
20084 }
20085
20086 Object.assign(this.dependencies, opList.dependencies);
20087
20088 for (var i = 0, ii = opList.length; i < ii; i++) {
20089 this.addOp(opList.fnArray[i], opList.argsArray[i]);
20090 }
20091 },
20092
20093 getIR() {
20094 return {
20095 fnArray: this.fnArray,
20096 argsArray: this.argsArray,
20097 length: this.length
20098 };
20099 },
20100
20101 get _transfers() {
20102 const transfers = [];
20103 const {
20104 fnArray,
20105 argsArray,
20106 length
20107 } = this;
20108
20109 for (let i = 0; i < length; i++) {
20110 switch (fnArray[i]) {
20111 case _util.OPS.paintInlineImageXObject:
20112 case _util.OPS.paintInlineImageXObjectGroup:
20113 case _util.OPS.paintImageMaskXObject:
20114 const arg = argsArray[i][0];
20115 ;
20116
20117 if (!arg.cached) {
20118 transfers.push(arg.data.buffer);
20119 }
20120
20121 break;
20122 }
20123 }
20124
20125 return transfers;
20126 },
20127
20128 flush(lastChunk = false) {
20129 this.optimizer.flush();
20130 const length = this.length;
20131 this._totalLength += length;
20132
20133 this._streamSink.enqueue({
20134 fnArray: this.fnArray,
20135 argsArray: this.argsArray,
20136 lastChunk,
20137 length
20138 }, 1, this._transfers);
20139
20140 this.dependencies = Object.create(null);
20141 this.fnArray.length = 0;
20142 this.argsArray.length = 0;
20143 this.weight = 0;
20144 this.optimizer.reset();
20145 }
20146
20147 };
20148 return OperatorList;
20149}();
20150
20151exports.OperatorList = OperatorList;
20152
20153/***/ }),
20154/* 27 */
20155/***/ (function(module, exports, __w_pdfjs_require__) {
20156
20157"use strict";
20158
20159
20160Object.defineProperty(exports, "__esModule", {
20161 value: true
20162});
20163exports.PartialEvaluator = void 0;
20164
20165var _util = __w_pdfjs_require__(2);
20166
20167var _cmap = __w_pdfjs_require__(28);
20168
20169var _primitives = __w_pdfjs_require__(5);
20170
20171var _fonts = __w_pdfjs_require__(29);
20172
20173var _encodings = __w_pdfjs_require__(32);
20174
20175var _core_utils = __w_pdfjs_require__(8);
20176
20177var _unicode = __w_pdfjs_require__(35);
20178
20179var _standard_fonts = __w_pdfjs_require__(34);
20180
20181var _pattern = __w_pdfjs_require__(38);
20182
20183var _parser = __w_pdfjs_require__(11);
20184
20185var _bidi = __w_pdfjs_require__(39);
20186
20187var _colorspace = __w_pdfjs_require__(23);
20188
20189var _stream = __w_pdfjs_require__(12);
20190
20191var _glyphlist = __w_pdfjs_require__(33);
20192
20193var _metrics = __w_pdfjs_require__(40);
20194
20195var _function = __w_pdfjs_require__(41);
20196
20197var _image_utils = __w_pdfjs_require__(24);
20198
20199var _murmurhash = __w_pdfjs_require__(43);
20200
20201var _operator_list = __w_pdfjs_require__(26);
20202
20203var _image = __w_pdfjs_require__(44);
20204
20205var PartialEvaluator = function PartialEvaluatorClosure() {
20206 const DefaultPartialEvaluatorOptions = {
20207 maxImageSize: -1,
20208 disableFontFace: false,
20209 ignoreErrors: false,
20210 isEvalSupported: true,
20211 fontExtraProperties: false
20212 };
20213
20214 function PartialEvaluator({
20215 xref,
20216 handler,
20217 pageIndex,
20218 idFactory,
20219 fontCache,
20220 builtInCMapCache,
20221 globalImageCache,
20222 options = null,
20223 pdfFunctionFactory
20224 }) {
20225 this.xref = xref;
20226 this.handler = handler;
20227 this.pageIndex = pageIndex;
20228 this.idFactory = idFactory;
20229 this.fontCache = fontCache;
20230 this.builtInCMapCache = builtInCMapCache;
20231 this.globalImageCache = globalImageCache;
20232 this.options = options || DefaultPartialEvaluatorOptions;
20233 this.pdfFunctionFactory = pdfFunctionFactory;
20234 this.parsingType3Font = false;
20235
20236 this.fetchBuiltInCMap = async name => {
20237 if (this.builtInCMapCache.has(name)) {
20238 return this.builtInCMapCache.get(name);
20239 }
20240
20241 const readableStream = this.handler.sendWithStream("FetchBuiltInCMap", {
20242 name
20243 });
20244 const reader = readableStream.getReader();
20245 const data = await new Promise(function (resolve, reject) {
20246 function pump() {
20247 reader.read().then(function ({
20248 value,
20249 done
20250 }) {
20251 if (done) {
20252 return;
20253 }
20254
20255 resolve(value);
20256 pump();
20257 }, reject);
20258 }
20259
20260 pump();
20261 });
20262
20263 if (data.compressionType !== _util.CMapCompressionType.NONE) {
20264 this.builtInCMapCache.set(name, data);
20265 }
20266
20267 return data;
20268 };
20269 }
20270
20271 var TIME_SLOT_DURATION_MS = 20;
20272 var CHECK_TIME_EVERY = 100;
20273
20274 function TimeSlotManager() {
20275 this.reset();
20276 }
20277
20278 TimeSlotManager.prototype = {
20279 check: function TimeSlotManager_check() {
20280 if (++this.checked < CHECK_TIME_EVERY) {
20281 return false;
20282 }
20283
20284 this.checked = 0;
20285 return this.endTime <= Date.now();
20286 },
20287 reset: function TimeSlotManager_reset() {
20288 this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
20289 this.checked = 0;
20290 }
20291 };
20292
20293 function normalizeBlendMode(value, parsingArray = false) {
20294 if (Array.isArray(value)) {
20295 for (let i = 0, ii = value.length; i < ii; i++) {
20296 const maybeBM = normalizeBlendMode(value[i], true);
20297
20298 if (maybeBM) {
20299 return maybeBM;
20300 }
20301 }
20302
20303 (0, _util.warn)(`Unsupported blend mode Array: ${value}`);
20304 return "source-over";
20305 }
20306
20307 if (!(0, _primitives.isName)(value)) {
20308 if (parsingArray) {
20309 return null;
20310 }
20311
20312 return "source-over";
20313 }
20314
20315 switch (value.name) {
20316 case "Normal":
20317 case "Compatible":
20318 return "source-over";
20319
20320 case "Multiply":
20321 return "multiply";
20322
20323 case "Screen":
20324 return "screen";
20325
20326 case "Overlay":
20327 return "overlay";
20328
20329 case "Darken":
20330 return "darken";
20331
20332 case "Lighten":
20333 return "lighten";
20334
20335 case "ColorDodge":
20336 return "color-dodge";
20337
20338 case "ColorBurn":
20339 return "color-burn";
20340
20341 case "HardLight":
20342 return "hard-light";
20343
20344 case "SoftLight":
20345 return "soft-light";
20346
20347 case "Difference":
20348 return "difference";
20349
20350 case "Exclusion":
20351 return "exclusion";
20352
20353 case "Hue":
20354 return "hue";
20355
20356 case "Saturation":
20357 return "saturation";
20358
20359 case "Color":
20360 return "color";
20361
20362 case "Luminosity":
20363 return "luminosity";
20364 }
20365
20366 if (parsingArray) {
20367 return null;
20368 }
20369
20370 (0, _util.warn)(`Unsupported blend mode: ${value.name}`);
20371 return "source-over";
20372 }
20373
20374 var deferred = Promise.resolve();
20375 var TILING_PATTERN = 1,
20376 SHADING_PATTERN = 2;
20377 PartialEvaluator.prototype = {
20378 clone(newOptions = DefaultPartialEvaluatorOptions) {
20379 var newEvaluator = Object.create(this);
20380 newEvaluator.options = newOptions;
20381 return newEvaluator;
20382 },
20383
20384 hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
20385 if (!(resources instanceof _primitives.Dict)) {
20386 return false;
20387 }
20388
20389 var processed = Object.create(null);
20390
20391 if (resources.objId) {
20392 processed[resources.objId] = true;
20393 }
20394
20395 var nodes = [resources],
20396 xref = this.xref;
20397
20398 while (nodes.length) {
20399 var node = nodes.shift();
20400 var graphicStates = node.get("ExtGState");
20401
20402 if (graphicStates instanceof _primitives.Dict) {
20403 var graphicStatesKeys = graphicStates.getKeys();
20404
20405 for (let i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
20406 const key = graphicStatesKeys[i];
20407 let graphicState = graphicStates.getRaw(key);
20408
20409 if (graphicState instanceof _primitives.Ref) {
20410 if (processed[graphicState.toString()]) {
20411 continue;
20412 }
20413
20414 try {
20415 graphicState = xref.fetch(graphicState);
20416 } catch (ex) {
20417 if (ex instanceof _core_utils.MissingDataException) {
20418 throw ex;
20419 }
20420
20421 if (this.options.ignoreErrors) {
20422 if (graphicState instanceof _primitives.Ref) {
20423 processed[graphicState.toString()] = true;
20424 }
20425
20426 this.handler.send("UnsupportedFeature", {
20427 featureId: _util.UNSUPPORTED_FEATURES.errorExtGState
20428 });
20429 (0, _util.warn)(`hasBlendModes - ignoring ExtGState: "${ex}".`);
20430 continue;
20431 }
20432
20433 throw ex;
20434 }
20435 }
20436
20437 if (!(graphicState instanceof _primitives.Dict)) {
20438 continue;
20439 }
20440
20441 if (graphicState.objId) {
20442 processed[graphicState.objId] = true;
20443 }
20444
20445 const bm = graphicState.get("BM");
20446
20447 if (bm instanceof _primitives.Name) {
20448 if (bm.name !== "Normal") {
20449 return true;
20450 }
20451
20452 continue;
20453 }
20454
20455 if (bm !== undefined && Array.isArray(bm)) {
20456 for (let j = 0, jj = bm.length; j < jj; j++) {
20457 if (bm[j] instanceof _primitives.Name && bm[j].name !== "Normal") {
20458 return true;
20459 }
20460 }
20461 }
20462 }
20463 }
20464
20465 var xObjects = node.get("XObject");
20466
20467 if (!(xObjects instanceof _primitives.Dict)) {
20468 continue;
20469 }
20470
20471 var xObjectsKeys = xObjects.getKeys();
20472
20473 for (let i = 0, ii = xObjectsKeys.length; i < ii; i++) {
20474 const key = xObjectsKeys[i];
20475 var xObject = xObjects.getRaw(key);
20476
20477 if (xObject instanceof _primitives.Ref) {
20478 if (processed[xObject.toString()]) {
20479 continue;
20480 }
20481
20482 try {
20483 xObject = xref.fetch(xObject);
20484 } catch (ex) {
20485 if (ex instanceof _core_utils.MissingDataException) {
20486 throw ex;
20487 }
20488
20489 if (this.options.ignoreErrors) {
20490 if (xObject instanceof _primitives.Ref) {
20491 processed[xObject.toString()] = true;
20492 }
20493
20494 this.handler.send("UnsupportedFeature", {
20495 featureId: _util.UNSUPPORTED_FEATURES.errorXObject
20496 });
20497 (0, _util.warn)(`hasBlendModes - ignoring XObject: "${ex}".`);
20498 continue;
20499 }
20500
20501 throw ex;
20502 }
20503 }
20504
20505 if (!(0, _primitives.isStream)(xObject)) {
20506 continue;
20507 }
20508
20509 if (xObject.dict.objId) {
20510 if (processed[xObject.dict.objId]) {
20511 continue;
20512 }
20513
20514 processed[xObject.dict.objId] = true;
20515 }
20516
20517 var xResources = xObject.dict.get("Resources");
20518
20519 if (xResources instanceof _primitives.Dict && (!xResources.objId || !processed[xResources.objId])) {
20520 nodes.push(xResources);
20521
20522 if (xResources.objId) {
20523 processed[xResources.objId] = true;
20524 }
20525 }
20526 }
20527 }
20528
20529 return false;
20530 },
20531
20532 async buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
20533 var dict = xobj.dict;
20534 var matrix = dict.getArray("Matrix");
20535 var bbox = dict.getArray("BBox");
20536
20537 if (Array.isArray(bbox) && bbox.length === 4) {
20538 bbox = _util.Util.normalizeRect(bbox);
20539 } else {
20540 bbox = null;
20541 }
20542
20543 var group = dict.get("Group");
20544
20545 if (group) {
20546 var groupOptions = {
20547 matrix,
20548 bbox,
20549 smask,
20550 isolated: false,
20551 knockout: false
20552 };
20553 var groupSubtype = group.get("S");
20554 var colorSpace = null;
20555
20556 if ((0, _primitives.isName)(groupSubtype, "Transparency")) {
20557 groupOptions.isolated = group.get("I") || false;
20558 groupOptions.knockout = group.get("K") || false;
20559
20560 if (group.has("CS")) {
20561 colorSpace = await this.parseColorSpace({
20562 cs: group.get("CS"),
20563 resources
20564 });
20565 }
20566 }
20567
20568 if (smask && smask.backdrop) {
20569 colorSpace = colorSpace || _colorspace.ColorSpace.singletons.rgb;
20570 smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
20571 }
20572
20573 operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
20574 }
20575
20576 operatorList.addOp(_util.OPS.paintFormXObjectBegin, [matrix, bbox]);
20577 return this.getOperatorList({
20578 stream: xobj,
20579 task,
20580 resources: dict.get("Resources") || resources,
20581 operatorList,
20582 initialState
20583 }).then(function () {
20584 operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
20585
20586 if (group) {
20587 operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
20588 }
20589 });
20590 },
20591
20592 async buildPaintImageXObject({
20593 resources,
20594 image,
20595 isInline = false,
20596 operatorList,
20597 cacheKey,
20598 localImageCache
20599 }) {
20600 var dict = image.dict;
20601 const imageRef = dict.objId;
20602 var w = dict.get("Width", "W");
20603 var h = dict.get("Height", "H");
20604
20605 if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
20606 (0, _util.warn)("Image dimensions are missing, or not numbers.");
20607 return undefined;
20608 }
20609
20610 var maxImageSize = this.options.maxImageSize;
20611
20612 if (maxImageSize !== -1 && w * h > maxImageSize) {
20613 (0, _util.warn)("Image exceeded maximum allowed size and was removed.");
20614 return undefined;
20615 }
20616
20617 var imageMask = dict.get("ImageMask", "IM") || false;
20618 var imgData, args;
20619
20620 if (imageMask) {
20621 var width = dict.get("Width", "W");
20622 var height = dict.get("Height", "H");
20623 var bitStrideLength = width + 7 >> 3;
20624 var imgArray = image.getBytes(bitStrideLength * height, true);
20625 var decode = dict.getArray("Decode", "D");
20626 imgData = _image.PDFImage.createMask({
20627 imgArray,
20628 width,
20629 height,
20630 imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
20631 inverseDecode: !!decode && decode[0] > 0
20632 });
20633 imgData.cached = !!cacheKey;
20634 args = [imgData];
20635 operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
20636
20637 if (cacheKey) {
20638 localImageCache.set(cacheKey, imageRef, {
20639 fn: _util.OPS.paintImageMaskXObject,
20640 args
20641 });
20642 }
20643
20644 return undefined;
20645 }
20646
20647 var softMask = dict.get("SMask", "SM") || false;
20648 var mask = dict.get("Mask") || false;
20649 var SMALL_IMAGE_DIMENSIONS = 200;
20650
20651 if (isInline && !softMask && !mask && w + h < SMALL_IMAGE_DIMENSIONS) {
20652 const imageObj = new _image.PDFImage({
20653 xref: this.xref,
20654 res: resources,
20655 image,
20656 isInline,
20657 pdfFunctionFactory: this.pdfFunctionFactory
20658 });
20659 imgData = imageObj.createImageData(true);
20660 operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
20661 return undefined;
20662 }
20663
20664 let objId = `img_${this.idFactory.createObjId()}`,
20665 cacheGlobally = false;
20666
20667 if (this.parsingType3Font) {
20668 objId = `${this.idFactory.getDocId()}_type3res_${objId}`;
20669 } else if (imageRef) {
20670 cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex);
20671
20672 if (cacheGlobally) {
20673 objId = `${this.idFactory.getDocId()}_${objId}`;
20674 }
20675 }
20676
20677 operatorList.addDependency(objId);
20678 args = [objId, w, h];
20679
20680 const imgPromise = _image.PDFImage.buildImage({
20681 xref: this.xref,
20682 res: resources,
20683 image,
20684 isInline,
20685 pdfFunctionFactory: this.pdfFunctionFactory
20686 }).then(imageObj => {
20687 imgData = imageObj.createImageData(false);
20688
20689 if (this.parsingType3Font) {
20690 return this.handler.sendWithPromise("commonobj", [objId, "FontType3Res", imgData], [imgData.data.buffer]);
20691 } else if (cacheGlobally) {
20692 this.handler.send("commonobj", [objId, "Image", imgData], [imgData.data.buffer]);
20693 return undefined;
20694 }
20695
20696 this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], [imgData.data.buffer]);
20697 return undefined;
20698 }).catch(reason => {
20699 (0, _util.warn)("Unable to decode image: " + reason);
20700
20701 if (this.parsingType3Font) {
20702 return this.handler.sendWithPromise("commonobj", [objId, "FontType3Res", null]);
20703 } else if (cacheGlobally) {
20704 this.handler.send("commonobj", [objId, "Image", null]);
20705 return undefined;
20706 }
20707
20708 this.handler.send("obj", [objId, this.pageIndex, "Image", null]);
20709 return undefined;
20710 });
20711
20712 if (this.parsingType3Font) {
20713 await imgPromise;
20714 }
20715
20716 operatorList.addOp(_util.OPS.paintImageXObject, args);
20717
20718 if (cacheKey) {
20719 localImageCache.set(cacheKey, imageRef, {
20720 fn: _util.OPS.paintImageXObject,
20721 args
20722 });
20723
20724 if (imageRef) {
20725 (0, _util.assert)(!isInline, "Cannot cache an inline image globally.");
20726 this.globalImageCache.addPageIndex(imageRef, this.pageIndex);
20727
20728 if (cacheGlobally) {
20729 this.globalImageCache.setData(imageRef, {
20730 objId,
20731 fn: _util.OPS.paintImageXObject,
20732 args
20733 });
20734 }
20735 }
20736 }
20737
20738 return undefined;
20739 },
20740
20741 handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
20742 var smaskContent = smask.get("G");
20743 var smaskOptions = {
20744 subtype: smask.get("S").name,
20745 backdrop: smask.get("BC")
20746 };
20747 var transferObj = smask.get("TR");
20748
20749 if ((0, _function.isPDFFunction)(transferObj)) {
20750 const transferFn = this.pdfFunctionFactory.create(transferObj);
20751 var transferMap = new Uint8Array(256);
20752 var tmp = new Float32Array(1);
20753
20754 for (var i = 0; i < 256; i++) {
20755 tmp[0] = i / 255;
20756 transferFn(tmp, 0, tmp, 0);
20757 transferMap[i] = tmp[0] * 255 | 0;
20758 }
20759
20760 smaskOptions.transferMap = transferMap;
20761 }
20762
20763 return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
20764 },
20765
20766 handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
20767 const tilingOpList = new _operator_list.OperatorList();
20768 const resourcesArray = [patternDict.get("Resources"), resources];
20769
20770 const patternResources = _primitives.Dict.merge(this.xref, resourcesArray);
20771
20772 return this.getOperatorList({
20773 stream: pattern,
20774 task,
20775 resources: patternResources,
20776 operatorList: tilingOpList
20777 }).then(function () {
20778 return (0, _pattern.getTilingPatternIR)({
20779 fnArray: tilingOpList.fnArray,
20780 argsArray: tilingOpList.argsArray
20781 }, patternDict, args);
20782 }).then(function (tilingPatternIR) {
20783 operatorList.addDependencies(tilingOpList.dependencies);
20784 operatorList.addOp(fn, tilingPatternIR);
20785 }, reason => {
20786 if (reason instanceof _util.AbortException) {
20787 return;
20788 }
20789
20790 if (this.options.ignoreErrors) {
20791 this.handler.send("UnsupportedFeature", {
20792 featureId: _util.UNSUPPORTED_FEATURES.errorTilingPattern
20793 });
20794 (0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
20795 return;
20796 }
20797
20798 throw reason;
20799 });
20800 },
20801
20802 handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
20803 var fontName;
20804
20805 if (fontArgs) {
20806 fontArgs = fontArgs.slice();
20807 fontName = fontArgs[0].name;
20808 }
20809
20810 return this.loadFont(fontName, fontRef, resources).then(translated => {
20811 if (!translated.font.isType3Font) {
20812 return translated;
20813 }
20814
20815 return translated.loadType3Data(this, resources, operatorList, task).then(function () {
20816 return translated;
20817 }).catch(reason => {
20818 this.handler.send("UnsupportedFeature", {
20819 featureId: _util.UNSUPPORTED_FEATURES.errorFontLoadType3
20820 });
20821 return new TranslatedFont({
20822 loadedName: "g_font_error",
20823 font: new _fonts.ErrorFont(`Type3 font load error: ${reason}`),
20824 dict: translated.font,
20825 extraProperties: this.options.fontExtraProperties
20826 });
20827 });
20828 }).then(translated => {
20829 state.font = translated.font;
20830 translated.send(this.handler);
20831 return translated.loadedName;
20832 });
20833 },
20834
20835 handleText(chars, state) {
20836 const font = state.font;
20837 const glyphs = font.charsToGlyphs(chars);
20838
20839 if (font.data) {
20840 const isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
20841
20842 if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || font.disableFontFace || this.options.disableFontFace) {
20843 PartialEvaluator.buildFontPaths(font, glyphs, this.handler);
20844 }
20845 }
20846
20847 return glyphs;
20848 },
20849
20850 ensureStateFont(state) {
20851 if (state.font) {
20852 return;
20853 }
20854
20855 const reason = new _util.FormatError("Missing setFont (Tf) operator before text rendering operator.");
20856
20857 if (this.options.ignoreErrors) {
20858 this.handler.send("UnsupportedFeature", {
20859 featureId: _util.UNSUPPORTED_FEATURES.errorFontState
20860 });
20861 (0, _util.warn)(`ensureStateFont: "${reason}".`);
20862 return;
20863 }
20864
20865 throw reason;
20866 },
20867
20868 setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
20869 var gStateObj = [];
20870 var gStateKeys = gState.getKeys();
20871 var promise = Promise.resolve();
20872
20873 for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
20874 const key = gStateKeys[i];
20875 const value = gState.get(key);
20876
20877 switch (key) {
20878 case "Type":
20879 break;
20880
20881 case "LW":
20882 case "LC":
20883 case "LJ":
20884 case "ML":
20885 case "D":
20886 case "RI":
20887 case "FL":
20888 case "CA":
20889 case "ca":
20890 gStateObj.push([key, value]);
20891 break;
20892
20893 case "Font":
20894 promise = promise.then(() => {
20895 return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
20896 operatorList.addDependency(loadedName);
20897 gStateObj.push([key, [loadedName, value[1]]]);
20898 });
20899 });
20900 break;
20901
20902 case "BM":
20903 gStateObj.push([key, normalizeBlendMode(value)]);
20904 break;
20905
20906 case "SMask":
20907 if ((0, _primitives.isName)(value, "None")) {
20908 gStateObj.push([key, false]);
20909 break;
20910 }
20911
20912 if ((0, _primitives.isDict)(value)) {
20913 promise = promise.then(() => {
20914 return this.handleSMask(value, resources, operatorList, task, stateManager);
20915 });
20916 gStateObj.push([key, true]);
20917 } else {
20918 (0, _util.warn)("Unsupported SMask type");
20919 }
20920
20921 break;
20922
20923 case "OP":
20924 case "op":
20925 case "OPM":
20926 case "BG":
20927 case "BG2":
20928 case "UCR":
20929 case "UCR2":
20930 case "TR":
20931 case "TR2":
20932 case "HT":
20933 case "SM":
20934 case "SA":
20935 case "AIS":
20936 case "TK":
20937 (0, _util.info)("graphic state operator " + key);
20938 break;
20939
20940 default:
20941 (0, _util.info)("Unknown graphic state operator " + key);
20942 break;
20943 }
20944 }
20945
20946 return promise.then(function () {
20947 if (gStateObj.length > 0) {
20948 operatorList.addOp(_util.OPS.setGState, [gStateObj]);
20949 }
20950 });
20951 },
20952 loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
20953 const errorFont = () => {
20954 return Promise.resolve(new TranslatedFont({
20955 loadedName: "g_font_error",
20956 font: new _fonts.ErrorFont(`Font "${fontName}" is not available.`),
20957 dict: font,
20958 extraProperties: this.options.fontExtraProperties
20959 }));
20960 };
20961
20962 var fontRef,
20963 xref = this.xref;
20964
20965 if (font) {
20966 if (!(0, _primitives.isRef)(font)) {
20967 throw new _util.FormatError('The "font" object should be a reference.');
20968 }
20969
20970 fontRef = font;
20971 } else {
20972 var fontRes = resources.get("Font");
20973
20974 if (fontRes) {
20975 fontRef = fontRes.getRaw(fontName);
20976 }
20977 }
20978
20979 if (!fontRef) {
20980 const partialMsg = `Font "${fontName || font && font.toString()}" is not available`;
20981
20982 if (!this.options.ignoreErrors && !this.parsingType3Font) {
20983 (0, _util.warn)(`${partialMsg}.`);
20984 return errorFont();
20985 }
20986
20987 this.handler.send("UnsupportedFeature", {
20988 featureId: _util.UNSUPPORTED_FEATURES.errorFontMissing
20989 });
20990 (0, _util.warn)(`${partialMsg} -- attempting to fallback to a default font.`);
20991 fontRef = PartialEvaluator.getFallbackFontDict();
20992 }
20993
20994 if (this.fontCache.has(fontRef)) {
20995 return this.fontCache.get(fontRef);
20996 }
20997
20998 font = xref.fetchIfRef(fontRef);
20999
21000 if (!(0, _primitives.isDict)(font)) {
21001 return errorFont();
21002 }
21003
21004 if (font.translated) {
21005 return font.translated;
21006 }
21007
21008 var fontCapability = (0, _util.createPromiseCapability)();
21009 var preEvaluatedFont = this.preEvaluateFont(font);
21010 const {
21011 descriptor,
21012 hash
21013 } = preEvaluatedFont;
21014 var fontRefIsRef = (0, _primitives.isRef)(fontRef),
21015 fontID;
21016
21017 if (fontRefIsRef) {
21018 fontID = fontRef.toString();
21019 }
21020
21021 if (hash && (0, _primitives.isDict)(descriptor)) {
21022 if (!descriptor.fontAliases) {
21023 descriptor.fontAliases = Object.create(null);
21024 }
21025
21026 var fontAliases = descriptor.fontAliases;
21027
21028 if (fontAliases[hash]) {
21029 var aliasFontRef = fontAliases[hash].aliasRef;
21030
21031 if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
21032 this.fontCache.putAlias(fontRef, aliasFontRef);
21033 return this.fontCache.get(fontRef);
21034 }
21035 } else {
21036 fontAliases[hash] = {
21037 fontID: _fonts.Font.getFontID()
21038 };
21039 }
21040
21041 if (fontRefIsRef) {
21042 fontAliases[hash].aliasRef = fontRef;
21043 }
21044
21045 fontID = fontAliases[hash].fontID;
21046 }
21047
21048 if (fontRefIsRef) {
21049 this.fontCache.put(fontRef, fontCapability.promise);
21050 } else {
21051 if (!fontID) {
21052 fontID = this.idFactory.createObjId();
21053 }
21054
21055 this.fontCache.put(`id_${fontID}`, fontCapability.promise);
21056 }
21057
21058 (0, _util.assert)(fontID, 'The "fontID" must be defined.');
21059 font.loadedName = `${this.idFactory.getDocId()}_f${fontID}`;
21060 font.translated = fontCapability.promise;
21061 var translatedPromise;
21062
21063 try {
21064 translatedPromise = this.translateFont(preEvaluatedFont);
21065 } catch (e) {
21066 translatedPromise = Promise.reject(e);
21067 }
21068
21069 translatedPromise.then(translatedFont => {
21070 if (translatedFont.fontType !== undefined) {
21071 var xrefFontStats = xref.stats.fontTypes;
21072 xrefFontStats[translatedFont.fontType] = true;
21073 }
21074
21075 fontCapability.resolve(new TranslatedFont({
21076 loadedName: font.loadedName,
21077 font: translatedFont,
21078 dict: font,
21079 extraProperties: this.options.fontExtraProperties
21080 }));
21081 }).catch(reason => {
21082 this.handler.send("UnsupportedFeature", {
21083 featureId: _util.UNSUPPORTED_FEATURES.errorFontTranslate
21084 });
21085
21086 try {
21087 var fontFile3 = descriptor && descriptor.get("FontFile3");
21088 var subtype = fontFile3 && fontFile3.get("Subtype");
21089 var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
21090 var xrefFontStats = xref.stats.fontTypes;
21091 xrefFontStats[fontType] = true;
21092 } catch (ex) {}
21093
21094 fontCapability.resolve(new TranslatedFont({
21095 loadedName: font.loadedName,
21096 font: new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason),
21097 dict: font,
21098 extraProperties: this.options.fontExtraProperties
21099 }));
21100 });
21101 return fontCapability.promise;
21102 },
21103
21104 buildPath(operatorList, fn, args, parsingText = false) {
21105 var lastIndex = operatorList.length - 1;
21106
21107 if (!args) {
21108 args = [];
21109 }
21110
21111 if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
21112 if (parsingText) {
21113 (0, _util.warn)(`Encountered path operator "${fn}" inside of a text object.`);
21114 operatorList.addOp(_util.OPS.save, null);
21115 }
21116
21117 operatorList.addOp(_util.OPS.constructPath, [[fn], args]);
21118
21119 if (parsingText) {
21120 operatorList.addOp(_util.OPS.restore, null);
21121 }
21122 } else {
21123 var opArgs = operatorList.argsArray[lastIndex];
21124 opArgs[0].push(fn);
21125 Array.prototype.push.apply(opArgs[1], args);
21126 }
21127 },
21128
21129 parseColorSpace({
21130 cs,
21131 resources
21132 }) {
21133 return new Promise(resolve => {
21134 resolve(_colorspace.ColorSpace.parse(cs, this.xref, resources, this.pdfFunctionFactory));
21135 }).catch(reason => {
21136 if (reason instanceof _util.AbortException) {
21137 return null;
21138 }
21139
21140 if (this.options.ignoreErrors) {
21141 this.handler.send("UnsupportedFeature", {
21142 featureId: _util.UNSUPPORTED_FEATURES.errorColorSpace
21143 });
21144 (0, _util.warn)(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
21145 return null;
21146 }
21147
21148 throw reason;
21149 });
21150 },
21151
21152 async handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
21153 var patternName = args[args.length - 1];
21154 var pattern;
21155
21156 if ((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name))) {
21157 var dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
21158 var typeNum = dict.get("PatternType");
21159
21160 if (typeNum === TILING_PATTERN) {
21161 var color = cs.base ? cs.base.getRgb(args, 0) : null;
21162 return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
21163 } else if (typeNum === SHADING_PATTERN) {
21164 var shading = dict.get("Shading");
21165 var matrix = dict.getArray("Matrix");
21166 pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this.pdfFunctionFactory);
21167 operatorList.addOp(fn, pattern.getIR());
21168 return undefined;
21169 }
21170
21171 throw new _util.FormatError(`Unknown PatternType: ${typeNum}`);
21172 }
21173
21174 throw new _util.FormatError(`Unknown PatternName: ${patternName}`);
21175 },
21176
21177 getOperatorList({
21178 stream,
21179 task,
21180 resources,
21181 operatorList,
21182 initialState = null
21183 }) {
21184 resources = resources || _primitives.Dict.empty;
21185 initialState = initialState || new EvalState();
21186
21187 if (!operatorList) {
21188 throw new Error('getOperatorList: missing "operatorList" parameter');
21189 }
21190
21191 var self = this;
21192 var xref = this.xref;
21193 let parsingText = false;
21194 const localImageCache = new _image_utils.LocalImageCache();
21195
21196 var xobjs = resources.get("XObject") || _primitives.Dict.empty;
21197
21198 var patterns = resources.get("Pattern") || _primitives.Dict.empty;
21199
21200 var stateManager = new StateManager(initialState);
21201 var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
21202 var timeSlotManager = new TimeSlotManager();
21203
21204 function closePendingRestoreOPS(argument) {
21205 for (var i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
21206 operatorList.addOp(_util.OPS.restore, []);
21207 }
21208 }
21209
21210 return new Promise(function promiseBody(resolve, reject) {
21211 const next = function (promise) {
21212 Promise.all([promise, operatorList.ready]).then(function () {
21213 try {
21214 promiseBody(resolve, reject);
21215 } catch (ex) {
21216 reject(ex);
21217 }
21218 }, reject);
21219 };
21220
21221 task.ensureNotTerminated();
21222 timeSlotManager.reset();
21223 var stop,
21224 operation = {},
21225 i,
21226 ii,
21227 cs;
21228
21229 while (!(stop = timeSlotManager.check())) {
21230 operation.args = null;
21231
21232 if (!preprocessor.read(operation)) {
21233 break;
21234 }
21235
21236 var args = operation.args;
21237 var fn = operation.fn;
21238
21239 switch (fn | 0) {
21240 case _util.OPS.paintXObject:
21241 var name = args[0].name;
21242
21243 if (name) {
21244 const localImage = localImageCache.getByName(name);
21245
21246 if (localImage) {
21247 operatorList.addOp(localImage.fn, localImage.args);
21248 args = null;
21249 continue;
21250 }
21251 }
21252
21253 next(new Promise(function (resolveXObject, rejectXObject) {
21254 if (!name) {
21255 throw new _util.FormatError("XObject must be referred to by name.");
21256 }
21257
21258 let xobj = xobjs.getRaw(name);
21259
21260 if (xobj instanceof _primitives.Ref) {
21261 const localImage = localImageCache.getByRef(xobj);
21262
21263 if (localImage) {
21264 operatorList.addOp(localImage.fn, localImage.args);
21265 resolveXObject();
21266 return;
21267 }
21268
21269 const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
21270
21271 if (globalImage) {
21272 operatorList.addDependency(globalImage.objId);
21273 operatorList.addOp(globalImage.fn, globalImage.args);
21274 resolveXObject();
21275 return;
21276 }
21277
21278 xobj = xref.fetch(xobj);
21279 }
21280
21281 if (!xobj) {
21282 operatorList.addOp(fn, args);
21283 resolveXObject();
21284 return;
21285 }
21286
21287 if (!(0, _primitives.isStream)(xobj)) {
21288 throw new _util.FormatError("XObject should be a stream");
21289 }
21290
21291 const type = xobj.dict.get("Subtype");
21292
21293 if (!(0, _primitives.isName)(type)) {
21294 throw new _util.FormatError("XObject should have a Name subtype");
21295 }
21296
21297 if (type.name === "Form") {
21298 stateManager.save();
21299 self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
21300 stateManager.restore();
21301 resolveXObject();
21302 }, rejectXObject);
21303 return;
21304 } else if (type.name === "Image") {
21305 self.buildPaintImageXObject({
21306 resources,
21307 image: xobj,
21308 operatorList,
21309 cacheKey: name,
21310 localImageCache
21311 }).then(resolveXObject, rejectXObject);
21312 return;
21313 } else if (type.name === "PS") {
21314 (0, _util.info)("Ignored XObject subtype PS");
21315 } else {
21316 throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
21317 }
21318
21319 resolveXObject();
21320 }).catch(function (reason) {
21321 if (reason instanceof _util.AbortException) {
21322 return;
21323 }
21324
21325 if (self.options.ignoreErrors) {
21326 self.handler.send("UnsupportedFeature", {
21327 featureId: _util.UNSUPPORTED_FEATURES.errorXObject
21328 });
21329 (0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
21330 return;
21331 }
21332
21333 throw reason;
21334 }));
21335 return;
21336
21337 case _util.OPS.setFont:
21338 var fontSize = args[1];
21339 next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
21340 operatorList.addDependency(loadedName);
21341 operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
21342 }));
21343 return;
21344
21345 case _util.OPS.beginText:
21346 parsingText = true;
21347 break;
21348
21349 case _util.OPS.endText:
21350 parsingText = false;
21351 break;
21352
21353 case _util.OPS.endInlineImage:
21354 var cacheKey = args[0].cacheKey;
21355
21356 if (cacheKey) {
21357 const localImage = localImageCache.getByName(cacheKey);
21358
21359 if (localImage) {
21360 operatorList.addOp(localImage.fn, localImage.args);
21361 args = null;
21362 continue;
21363 }
21364 }
21365
21366 next(self.buildPaintImageXObject({
21367 resources,
21368 image: args[0],
21369 isInline: true,
21370 operatorList,
21371 cacheKey,
21372 localImageCache
21373 }));
21374 return;
21375
21376 case _util.OPS.showText:
21377 if (!stateManager.state.font) {
21378 self.ensureStateFont(stateManager.state);
21379 continue;
21380 }
21381
21382 args[0] = self.handleText(args[0], stateManager.state);
21383 break;
21384
21385 case _util.OPS.showSpacedText:
21386 if (!stateManager.state.font) {
21387 self.ensureStateFont(stateManager.state);
21388 continue;
21389 }
21390
21391 var arr = args[0];
21392 var combinedGlyphs = [];
21393 var arrLength = arr.length;
21394 var state = stateManager.state;
21395
21396 for (i = 0; i < arrLength; ++i) {
21397 var arrItem = arr[i];
21398
21399 if ((0, _util.isString)(arrItem)) {
21400 Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
21401 } else if ((0, _util.isNum)(arrItem)) {
21402 combinedGlyphs.push(arrItem);
21403 }
21404 }
21405
21406 args[0] = combinedGlyphs;
21407 fn = _util.OPS.showText;
21408 break;
21409
21410 case _util.OPS.nextLineShowText:
21411 if (!stateManager.state.font) {
21412 self.ensureStateFont(stateManager.state);
21413 continue;
21414 }
21415
21416 operatorList.addOp(_util.OPS.nextLine);
21417 args[0] = self.handleText(args[0], stateManager.state);
21418 fn = _util.OPS.showText;
21419 break;
21420
21421 case _util.OPS.nextLineSetSpacingShowText:
21422 if (!stateManager.state.font) {
21423 self.ensureStateFont(stateManager.state);
21424 continue;
21425 }
21426
21427 operatorList.addOp(_util.OPS.nextLine);
21428 operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
21429 operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
21430 args[0] = self.handleText(args[0], stateManager.state);
21431 fn = _util.OPS.showText;
21432 break;
21433
21434 case _util.OPS.setTextRenderingMode:
21435 stateManager.state.textRenderingMode = args[0];
21436 break;
21437
21438 case _util.OPS.setFillColorSpace:
21439 next(self.parseColorSpace({
21440 cs: args[0],
21441 resources
21442 }).then(function (colorSpace) {
21443 if (colorSpace) {
21444 stateManager.state.fillColorSpace = colorSpace;
21445 }
21446 }));
21447 return;
21448
21449 case _util.OPS.setStrokeColorSpace:
21450 next(self.parseColorSpace({
21451 cs: args[0],
21452 resources
21453 }).then(function (colorSpace) {
21454 if (colorSpace) {
21455 stateManager.state.strokeColorSpace = colorSpace;
21456 }
21457 }));
21458 return;
21459
21460 case _util.OPS.setFillColor:
21461 cs = stateManager.state.fillColorSpace;
21462 args = cs.getRgb(args, 0);
21463 fn = _util.OPS.setFillRGBColor;
21464 break;
21465
21466 case _util.OPS.setStrokeColor:
21467 cs = stateManager.state.strokeColorSpace;
21468 args = cs.getRgb(args, 0);
21469 fn = _util.OPS.setStrokeRGBColor;
21470 break;
21471
21472 case _util.OPS.setFillGray:
21473 stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
21474 args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
21475 fn = _util.OPS.setFillRGBColor;
21476 break;
21477
21478 case _util.OPS.setStrokeGray:
21479 stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
21480 args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
21481 fn = _util.OPS.setStrokeRGBColor;
21482 break;
21483
21484 case _util.OPS.setFillCMYKColor:
21485 stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
21486 args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
21487 fn = _util.OPS.setFillRGBColor;
21488 break;
21489
21490 case _util.OPS.setStrokeCMYKColor:
21491 stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
21492 args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
21493 fn = _util.OPS.setStrokeRGBColor;
21494 break;
21495
21496 case _util.OPS.setFillRGBColor:
21497 stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
21498 args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
21499 break;
21500
21501 case _util.OPS.setStrokeRGBColor:
21502 stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
21503 args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
21504 break;
21505
21506 case _util.OPS.setFillColorN:
21507 cs = stateManager.state.fillColorSpace;
21508
21509 if (cs.name === "Pattern") {
21510 next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task));
21511 return;
21512 }
21513
21514 args = cs.getRgb(args, 0);
21515 fn = _util.OPS.setFillRGBColor;
21516 break;
21517
21518 case _util.OPS.setStrokeColorN:
21519 cs = stateManager.state.strokeColorSpace;
21520
21521 if (cs.name === "Pattern") {
21522 next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task));
21523 return;
21524 }
21525
21526 args = cs.getRgb(args, 0);
21527 fn = _util.OPS.setStrokeRGBColor;
21528 break;
21529
21530 case _util.OPS.shadingFill:
21531 var shadingRes = resources.get("Shading");
21532
21533 if (!shadingRes) {
21534 throw new _util.FormatError("No shading resource found");
21535 }
21536
21537 var shading = shadingRes.get(args[0].name);
21538
21539 if (!shading) {
21540 throw new _util.FormatError("No shading object found");
21541 }
21542
21543 var shadingFill = _pattern.Pattern.parseShading(shading, null, xref, resources, self.handler, self.pdfFunctionFactory);
21544
21545 var patternIR = shadingFill.getIR();
21546 args = [patternIR];
21547 fn = _util.OPS.shadingFill;
21548 break;
21549
21550 case _util.OPS.setGState:
21551 var dictName = args[0];
21552 var extGState = resources.get("ExtGState");
21553
21554 if (!(0, _primitives.isDict)(extGState) || !extGState.has(dictName.name)) {
21555 break;
21556 }
21557
21558 var gState = extGState.get(dictName.name);
21559 next(self.setGState(resources, gState, operatorList, task, stateManager));
21560 return;
21561
21562 case _util.OPS.moveTo:
21563 case _util.OPS.lineTo:
21564 case _util.OPS.curveTo:
21565 case _util.OPS.curveTo2:
21566 case _util.OPS.curveTo3:
21567 case _util.OPS.closePath:
21568 case _util.OPS.rectangle:
21569 self.buildPath(operatorList, fn, args, parsingText);
21570 continue;
21571
21572 case _util.OPS.markPoint:
21573 case _util.OPS.markPointProps:
21574 case _util.OPS.beginMarkedContent:
21575 case _util.OPS.beginMarkedContentProps:
21576 case _util.OPS.endMarkedContent:
21577 case _util.OPS.beginCompat:
21578 case _util.OPS.endCompat:
21579 continue;
21580
21581 default:
21582 if (args !== null) {
21583 for (i = 0, ii = args.length; i < ii; i++) {
21584 if (args[i] instanceof _primitives.Dict) {
21585 break;
21586 }
21587 }
21588
21589 if (i < ii) {
21590 (0, _util.warn)("getOperatorList - ignoring operator: " + fn);
21591 continue;
21592 }
21593 }
21594
21595 }
21596
21597 operatorList.addOp(fn, args);
21598 }
21599
21600 if (stop) {
21601 next(deferred);
21602 return;
21603 }
21604
21605 closePendingRestoreOPS();
21606 resolve();
21607 }).catch(reason => {
21608 if (reason instanceof _util.AbortException) {
21609 return;
21610 }
21611
21612 if (this.options.ignoreErrors) {
21613 this.handler.send("UnsupportedFeature", {
21614 featureId: _util.UNSUPPORTED_FEATURES.errorOperatorList
21615 });
21616 (0, _util.warn)(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
21617 closePendingRestoreOPS();
21618 return;
21619 }
21620
21621 throw reason;
21622 });
21623 },
21624
21625 getTextContent({
21626 stream,
21627 task,
21628 resources,
21629 stateManager = null,
21630 normalizeWhitespace = false,
21631 combineTextItems = false,
21632 sink,
21633 seenStyles = Object.create(null)
21634 }) {
21635 resources = resources || _primitives.Dict.empty;
21636 stateManager = stateManager || new StateManager(new TextState());
21637 var WhitespaceRegexp = /\s/g;
21638 var textContent = {
21639 items: [],
21640 styles: Object.create(null)
21641 };
21642 var textContentItem = {
21643 initialized: false,
21644 str: [],
21645 width: 0,
21646 height: 0,
21647 vertical: false,
21648 lastAdvanceWidth: 0,
21649 lastAdvanceHeight: 0,
21650 textAdvanceScale: 0,
21651 spaceWidth: 0,
21652 fakeSpaceMin: Infinity,
21653 fakeMultiSpaceMin: Infinity,
21654 fakeMultiSpaceMax: -0,
21655 textRunBreakAllowed: false,
21656 transform: null,
21657 fontName: null
21658 };
21659 var SPACE_FACTOR = 0.3;
21660 var MULTI_SPACE_FACTOR = 1.5;
21661 var MULTI_SPACE_FACTOR_MAX = 4;
21662 var self = this;
21663 var xref = this.xref;
21664 var xobjs = null;
21665 const emptyXObjectCache = new _image_utils.LocalImageCache();
21666 var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
21667 var textState;
21668
21669 function ensureTextContentItem() {
21670 if (textContentItem.initialized) {
21671 return textContentItem;
21672 }
21673
21674 var font = textState.font;
21675
21676 if (!(font.loadedName in seenStyles)) {
21677 seenStyles[font.loadedName] = true;
21678 textContent.styles[font.loadedName] = {
21679 fontFamily: font.fallbackName,
21680 ascent: font.ascent,
21681 descent: font.descent,
21682 vertical: font.vertical
21683 };
21684 }
21685
21686 textContentItem.fontName = font.loadedName;
21687 var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
21688
21689 if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
21690 const glyphHeight = font.bbox[3] - font.bbox[1];
21691
21692 if (glyphHeight > 0) {
21693 tsm[3] *= glyphHeight * textState.fontMatrix[3];
21694 }
21695 }
21696
21697 var trm = _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
21698
21699 textContentItem.transform = trm;
21700
21701 if (!font.vertical) {
21702 textContentItem.width = 0;
21703 textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
21704 textContentItem.vertical = false;
21705 } else {
21706 textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
21707 textContentItem.height = 0;
21708 textContentItem.vertical = true;
21709 }
21710
21711 var a = textState.textLineMatrix[0];
21712 var b = textState.textLineMatrix[1];
21713 var scaleLineX = Math.sqrt(a * a + b * b);
21714 a = textState.ctm[0];
21715 b = textState.ctm[1];
21716 var scaleCtmX = Math.sqrt(a * a + b * b);
21717 textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
21718 textContentItem.lastAdvanceWidth = 0;
21719 textContentItem.lastAdvanceHeight = 0;
21720 var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
21721
21722 if (spaceWidth) {
21723 textContentItem.spaceWidth = spaceWidth;
21724 textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
21725 textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
21726 textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
21727 textContentItem.textRunBreakAllowed = !font.isMonospace;
21728 } else {
21729 textContentItem.spaceWidth = 0;
21730 textContentItem.fakeSpaceMin = Infinity;
21731 textContentItem.fakeMultiSpaceMin = Infinity;
21732 textContentItem.fakeMultiSpaceMax = 0;
21733 textContentItem.textRunBreakAllowed = false;
21734 }
21735
21736 textContentItem.initialized = true;
21737 return textContentItem;
21738 }
21739
21740 function replaceWhitespace(str) {
21741 var i = 0,
21742 ii = str.length,
21743 code;
21744
21745 while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
21746 i++;
21747 }
21748
21749 return i < ii ? str.replace(WhitespaceRegexp, " ") : str;
21750 }
21751
21752 function runBidiTransform(textChunk) {
21753 var str = textChunk.str.join("");
21754 var bidiResult = (0, _bidi.bidi)(str, -1, textChunk.vertical);
21755 return {
21756 str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
21757 dir: bidiResult.dir,
21758 width: textChunk.width,
21759 height: textChunk.height,
21760 transform: textChunk.transform,
21761 fontName: textChunk.fontName
21762 };
21763 }
21764
21765 function handleSetFont(fontName, fontRef) {
21766 return self.loadFont(fontName, fontRef, resources).then(function (translated) {
21767 textState.font = translated.font;
21768 textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
21769 });
21770 }
21771
21772 function buildTextContentItem(chars) {
21773 var font = textState.font;
21774 var textChunk = ensureTextContentItem();
21775 var width = 0;
21776 var height = 0;
21777 var glyphs = font.charsToGlyphs(chars);
21778
21779 for (var i = 0; i < glyphs.length; i++) {
21780 var glyph = glyphs[i];
21781 var glyphWidth = null;
21782
21783 if (font.vertical && glyph.vmetric) {
21784 glyphWidth = glyph.vmetric[0];
21785 } else {
21786 glyphWidth = glyph.width;
21787 }
21788
21789 var glyphUnicode = glyph.unicode;
21790 var NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
21791
21792 if (NormalizedUnicodes[glyphUnicode] !== undefined) {
21793 glyphUnicode = NormalizedUnicodes[glyphUnicode];
21794 }
21795
21796 glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
21797 var charSpacing = textState.charSpacing;
21798
21799 if (glyph.isSpace) {
21800 var wordSpacing = textState.wordSpacing;
21801 charSpacing += wordSpacing;
21802
21803 if (wordSpacing > 0) {
21804 addFakeSpaces(wordSpacing, textChunk.str);
21805 }
21806 }
21807
21808 var tx = 0;
21809 var ty = 0;
21810
21811 if (!font.vertical) {
21812 var w0 = glyphWidth * textState.fontMatrix[0];
21813 tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
21814 width += tx;
21815 } else {
21816 var w1 = glyphWidth * textState.fontMatrix[0];
21817 ty = w1 * textState.fontSize + charSpacing;
21818 height += ty;
21819 }
21820
21821 textState.translateTextMatrix(tx, ty);
21822 textChunk.str.push(glyphUnicode);
21823 }
21824
21825 if (!font.vertical) {
21826 textChunk.lastAdvanceWidth = width;
21827 textChunk.width += width;
21828 } else {
21829 textChunk.lastAdvanceHeight = height;
21830 textChunk.height += Math.abs(height);
21831 }
21832
21833 return textChunk;
21834 }
21835
21836 function addFakeSpaces(width, strBuf) {
21837 if (width < textContentItem.fakeSpaceMin) {
21838 return;
21839 }
21840
21841 if (width < textContentItem.fakeMultiSpaceMin) {
21842 strBuf.push(" ");
21843 return;
21844 }
21845
21846 var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
21847
21848 while (fakeSpaces-- > 0) {
21849 strBuf.push(" ");
21850 }
21851 }
21852
21853 function flushTextContentItem() {
21854 if (!textContentItem.initialized) {
21855 return;
21856 }
21857
21858 if (!textContentItem.vertical) {
21859 textContentItem.width *= textContentItem.textAdvanceScale;
21860 } else {
21861 textContentItem.height *= textContentItem.textAdvanceScale;
21862 }
21863
21864 textContent.items.push(runBidiTransform(textContentItem));
21865 textContentItem.initialized = false;
21866 textContentItem.str.length = 0;
21867 }
21868
21869 function enqueueChunk() {
21870 const length = textContent.items.length;
21871
21872 if (length > 0) {
21873 sink.enqueue(textContent, length);
21874 textContent.items = [];
21875 textContent.styles = Object.create(null);
21876 }
21877 }
21878
21879 var timeSlotManager = new TimeSlotManager();
21880 return new Promise(function promiseBody(resolve, reject) {
21881 const next = function (promise) {
21882 enqueueChunk();
21883 Promise.all([promise, sink.ready]).then(function () {
21884 try {
21885 promiseBody(resolve, reject);
21886 } catch (ex) {
21887 reject(ex);
21888 }
21889 }, reject);
21890 };
21891
21892 task.ensureNotTerminated();
21893 timeSlotManager.reset();
21894 var stop,
21895 operation = {},
21896 args = [];
21897
21898 while (!(stop = timeSlotManager.check())) {
21899 args.length = 0;
21900 operation.args = args;
21901
21902 if (!preprocessor.read(operation)) {
21903 break;
21904 }
21905
21906 textState = stateManager.state;
21907 var fn = operation.fn;
21908 args = operation.args;
21909 var advance, diff;
21910
21911 switch (fn | 0) {
21912 case _util.OPS.setFont:
21913 var fontNameArg = args[0].name,
21914 fontSizeArg = args[1];
21915
21916 if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
21917 break;
21918 }
21919
21920 flushTextContentItem();
21921 textState.fontName = fontNameArg;
21922 textState.fontSize = fontSizeArg;
21923 next(handleSetFont(fontNameArg, null));
21924 return;
21925
21926 case _util.OPS.setTextRise:
21927 flushTextContentItem();
21928 textState.textRise = args[0];
21929 break;
21930
21931 case _util.OPS.setHScale:
21932 flushTextContentItem();
21933 textState.textHScale = args[0] / 100;
21934 break;
21935
21936 case _util.OPS.setLeading:
21937 flushTextContentItem();
21938 textState.leading = args[0];
21939 break;
21940
21941 case _util.OPS.moveText:
21942 var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
21943 advance = args[0] - args[1];
21944
21945 if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
21946 textState.translateTextLineMatrix(args[0], args[1]);
21947 textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
21948 textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
21949 diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
21950 addFakeSpaces(diff, textContentItem.str);
21951 break;
21952 }
21953
21954 flushTextContentItem();
21955 textState.translateTextLineMatrix(args[0], args[1]);
21956 textState.textMatrix = textState.textLineMatrix.slice();
21957 break;
21958
21959 case _util.OPS.setLeadingMoveText:
21960 flushTextContentItem();
21961 textState.leading = -args[1];
21962 textState.translateTextLineMatrix(args[0], args[1]);
21963 textState.textMatrix = textState.textLineMatrix.slice();
21964 break;
21965
21966 case _util.OPS.nextLine:
21967 flushTextContentItem();
21968 textState.carriageReturn();
21969 break;
21970
21971 case _util.OPS.setTextMatrix:
21972 advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
21973
21974 if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
21975 textState.translateTextLineMatrix(advance.width, advance.height);
21976 textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
21977 textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
21978 diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
21979 addFakeSpaces(diff, textContentItem.str);
21980 break;
21981 }
21982
21983 flushTextContentItem();
21984 textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
21985 textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
21986 break;
21987
21988 case _util.OPS.setCharSpacing:
21989 textState.charSpacing = args[0];
21990 break;
21991
21992 case _util.OPS.setWordSpacing:
21993 textState.wordSpacing = args[0];
21994 break;
21995
21996 case _util.OPS.beginText:
21997 flushTextContentItem();
21998 textState.textMatrix = _util.IDENTITY_MATRIX.slice();
21999 textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
22000 break;
22001
22002 case _util.OPS.showSpacedText:
22003 if (!stateManager.state.font) {
22004 self.ensureStateFont(stateManager.state);
22005 continue;
22006 }
22007
22008 var items = args[0];
22009 var offset;
22010
22011 for (var j = 0, jj = items.length; j < jj; j++) {
22012 if (typeof items[j] === "string") {
22013 buildTextContentItem(items[j]);
22014 } else if ((0, _util.isNum)(items[j])) {
22015 ensureTextContentItem();
22016 advance = items[j] * textState.fontSize / 1000;
22017 var breakTextRun = false;
22018
22019 if (textState.font.vertical) {
22020 offset = advance;
22021 textState.translateTextMatrix(0, offset);
22022 breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
22023
22024 if (!breakTextRun) {
22025 textContentItem.height += offset;
22026 }
22027 } else {
22028 advance = -advance;
22029 offset = advance * textState.textHScale;
22030 textState.translateTextMatrix(offset, 0);
22031 breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
22032
22033 if (!breakTextRun) {
22034 textContentItem.width += offset;
22035 }
22036 }
22037
22038 if (breakTextRun) {
22039 flushTextContentItem();
22040 } else if (advance > 0) {
22041 addFakeSpaces(advance, textContentItem.str);
22042 }
22043 }
22044 }
22045
22046 break;
22047
22048 case _util.OPS.showText:
22049 if (!stateManager.state.font) {
22050 self.ensureStateFont(stateManager.state);
22051 continue;
22052 }
22053
22054 buildTextContentItem(args[0]);
22055 break;
22056
22057 case _util.OPS.nextLineShowText:
22058 if (!stateManager.state.font) {
22059 self.ensureStateFont(stateManager.state);
22060 continue;
22061 }
22062
22063 flushTextContentItem();
22064 textState.carriageReturn();
22065 buildTextContentItem(args[0]);
22066 break;
22067
22068 case _util.OPS.nextLineSetSpacingShowText:
22069 if (!stateManager.state.font) {
22070 self.ensureStateFont(stateManager.state);
22071 continue;
22072 }
22073
22074 flushTextContentItem();
22075 textState.wordSpacing = args[0];
22076 textState.charSpacing = args[1];
22077 textState.carriageReturn();
22078 buildTextContentItem(args[2]);
22079 break;
22080
22081 case _util.OPS.paintXObject:
22082 flushTextContentItem();
22083
22084 if (!xobjs) {
22085 xobjs = resources.get("XObject") || _primitives.Dict.empty;
22086 }
22087
22088 var name = args[0].name;
22089
22090 if (name && emptyXObjectCache.getByName(name)) {
22091 break;
22092 }
22093
22094 next(new Promise(function (resolveXObject, rejectXObject) {
22095 if (!name) {
22096 throw new _util.FormatError("XObject must be referred to by name.");
22097 }
22098
22099 let xobj = xobjs.getRaw(name);
22100
22101 if (xobj instanceof _primitives.Ref) {
22102 if (emptyXObjectCache.getByRef(xobj)) {
22103 resolveXObject();
22104 return;
22105 }
22106
22107 xobj = xref.fetch(xobj);
22108 }
22109
22110 if (!xobj) {
22111 resolveXObject();
22112 return;
22113 }
22114
22115 if (!(0, _primitives.isStream)(xobj)) {
22116 throw new _util.FormatError("XObject should be a stream");
22117 }
22118
22119 const type = xobj.dict.get("Subtype");
22120
22121 if (!(0, _primitives.isName)(type)) {
22122 throw new _util.FormatError("XObject should have a Name subtype");
22123 }
22124
22125 if (type.name !== "Form") {
22126 emptyXObjectCache.set(name, xobj.dict.objId, true);
22127 resolveXObject();
22128 return;
22129 }
22130
22131 const currentState = stateManager.state.clone();
22132 const xObjStateManager = new StateManager(currentState);
22133 const matrix = xobj.dict.getArray("Matrix");
22134
22135 if (Array.isArray(matrix) && matrix.length === 6) {
22136 xObjStateManager.transform(matrix);
22137 }
22138
22139 enqueueChunk();
22140 const sinkWrapper = {
22141 enqueueInvoked: false,
22142
22143 enqueue(chunk, size) {
22144 this.enqueueInvoked = true;
22145 sink.enqueue(chunk, size);
22146 },
22147
22148 get desiredSize() {
22149 return sink.desiredSize;
22150 },
22151
22152 get ready() {
22153 return sink.ready;
22154 }
22155
22156 };
22157 self.getTextContent({
22158 stream: xobj,
22159 task,
22160 resources: xobj.dict.get("Resources") || resources,
22161 stateManager: xObjStateManager,
22162 normalizeWhitespace,
22163 combineTextItems,
22164 sink: sinkWrapper,
22165 seenStyles
22166 }).then(function () {
22167 if (!sinkWrapper.enqueueInvoked) {
22168 emptyXObjectCache.set(name, xobj.dict.objId, true);
22169 }
22170
22171 resolveXObject();
22172 }, rejectXObject);
22173 }).catch(function (reason) {
22174 if (reason instanceof _util.AbortException) {
22175 return;
22176 }
22177
22178 if (self.options.ignoreErrors) {
22179 (0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
22180 return;
22181 }
22182
22183 throw reason;
22184 }));
22185 return;
22186
22187 case _util.OPS.setGState:
22188 flushTextContentItem();
22189 var dictName = args[0];
22190 var extGState = resources.get("ExtGState");
22191
22192 if (!(0, _primitives.isDict)(extGState) || !(0, _primitives.isName)(dictName)) {
22193 break;
22194 }
22195
22196 var gState = extGState.get(dictName.name);
22197
22198 if (!(0, _primitives.isDict)(gState)) {
22199 break;
22200 }
22201
22202 var gStateFont = gState.get("Font");
22203
22204 if (gStateFont) {
22205 textState.fontName = null;
22206 textState.fontSize = gStateFont[1];
22207 next(handleSetFont(null, gStateFont[0]));
22208 return;
22209 }
22210
22211 break;
22212 }
22213
22214 if (textContent.items.length >= sink.desiredSize) {
22215 stop = true;
22216 break;
22217 }
22218 }
22219
22220 if (stop) {
22221 next(deferred);
22222 return;
22223 }
22224
22225 flushTextContentItem();
22226 enqueueChunk();
22227 resolve();
22228 }).catch(reason => {
22229 if (reason instanceof _util.AbortException) {
22230 return;
22231 }
22232
22233 if (this.options.ignoreErrors) {
22234 (0, _util.warn)(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
22235 flushTextContentItem();
22236 enqueueChunk();
22237 return;
22238 }
22239
22240 throw reason;
22241 });
22242 },
22243
22244 extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
22245 const xref = this.xref;
22246 let cidToGidBytes;
22247 var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
22248 var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
22249
22250 if (properties.composite) {
22251 var cidSystemInfo = dict.get("CIDSystemInfo");
22252
22253 if ((0, _primitives.isDict)(cidSystemInfo)) {
22254 properties.cidSystemInfo = {
22255 registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
22256 ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
22257 supplement: cidSystemInfo.get("Supplement")
22258 };
22259 }
22260
22261 var cidToGidMap = dict.get("CIDToGIDMap");
22262
22263 if ((0, _primitives.isStream)(cidToGidMap)) {
22264 cidToGidBytes = cidToGidMap.getBytes();
22265 }
22266 }
22267
22268 var differences = [];
22269 var baseEncodingName = null;
22270 var encoding;
22271
22272 if (dict.has("Encoding")) {
22273 encoding = dict.get("Encoding");
22274
22275 if ((0, _primitives.isDict)(encoding)) {
22276 baseEncodingName = encoding.get("BaseEncoding");
22277 baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
22278
22279 if (encoding.has("Differences")) {
22280 var diffEncoding = encoding.get("Differences");
22281 var index = 0;
22282
22283 for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
22284 var data = xref.fetchIfRef(diffEncoding[j]);
22285
22286 if ((0, _util.isNum)(data)) {
22287 index = data;
22288 } else if ((0, _primitives.isName)(data)) {
22289 differences[index++] = data.name;
22290 } else {
22291 throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
22292 }
22293 }
22294 }
22295 } else if ((0, _primitives.isName)(encoding)) {
22296 baseEncodingName = encoding.name;
22297 } else {
22298 throw new _util.FormatError("Encoding is not a Name nor a Dict");
22299 }
22300
22301 if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") {
22302 baseEncodingName = null;
22303 }
22304 }
22305
22306 if (baseEncodingName) {
22307 properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName).slice();
22308 } else {
22309 var isSymbolicFont = !!(properties.flags & _fonts.FontFlags.Symbolic);
22310 var isNonsymbolicFont = !!(properties.flags & _fonts.FontFlags.Nonsymbolic);
22311 encoding = _encodings.StandardEncoding;
22312
22313 if (properties.type === "TrueType" && !isNonsymbolicFont) {
22314 encoding = _encodings.WinAnsiEncoding;
22315 }
22316
22317 if (isSymbolicFont) {
22318 encoding = _encodings.MacRomanEncoding;
22319
22320 if (!properties.file) {
22321 if (/Symbol/i.test(properties.name)) {
22322 encoding = _encodings.SymbolSetEncoding;
22323 } else if (/Dingbats|Wingdings/i.test(properties.name)) {
22324 encoding = _encodings.ZapfDingbatsEncoding;
22325 }
22326 }
22327 }
22328
22329 properties.defaultEncoding = encoding;
22330 }
22331
22332 properties.differences = differences;
22333 properties.baseEncodingName = baseEncodingName;
22334 properties.hasEncoding = !!baseEncodingName || differences.length > 0;
22335 properties.dict = dict;
22336 return toUnicodePromise.then(readToUnicode => {
22337 properties.toUnicode = readToUnicode;
22338 return this.buildToUnicode(properties);
22339 }).then(builtToUnicode => {
22340 properties.toUnicode = builtToUnicode;
22341
22342 if (cidToGidBytes) {
22343 properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, builtToUnicode);
22344 }
22345
22346 return properties;
22347 });
22348 },
22349
22350 _buildSimpleFontToUnicode(properties, forceGlyphs = false) {
22351 (0, _util.assert)(!properties.composite, "Must be a simple font.");
22352 const toUnicode = [];
22353 const encoding = properties.defaultEncoding.slice();
22354 const baseEncodingName = properties.baseEncodingName;
22355 const differences = properties.differences;
22356
22357 for (const charcode in differences) {
22358 const glyphName = differences[charcode];
22359
22360 if (glyphName === ".notdef") {
22361 continue;
22362 }
22363
22364 encoding[charcode] = glyphName;
22365 }
22366
22367 const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
22368
22369 for (const charcode in encoding) {
22370 let glyphName = encoding[charcode];
22371
22372 if (glyphName === "") {
22373 continue;
22374 } else if (glyphsUnicodeMap[glyphName] === undefined) {
22375 let code = 0;
22376
22377 switch (glyphName[0]) {
22378 case "G":
22379 if (glyphName.length === 3) {
22380 code = parseInt(glyphName.substring(1), 16);
22381 }
22382
22383 break;
22384
22385 case "g":
22386 if (glyphName.length === 5) {
22387 code = parseInt(glyphName.substring(1), 16);
22388 }
22389
22390 break;
22391
22392 case "C":
22393 case "c":
22394 if (glyphName.length >= 3 && glyphName.length <= 4) {
22395 const codeStr = glyphName.substring(1);
22396
22397 if (forceGlyphs) {
22398 code = parseInt(codeStr, 16);
22399 break;
22400 }
22401
22402 code = +codeStr;
22403
22404 if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) {
22405 return this._buildSimpleFontToUnicode(properties, true);
22406 }
22407 }
22408
22409 break;
22410
22411 default:
22412 const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
22413
22414 if (unicode !== -1) {
22415 code = unicode;
22416 }
22417
22418 }
22419
22420 if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) {
22421 if (baseEncodingName && code === +charcode) {
22422 const baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
22423
22424 if (baseEncoding && (glyphName = baseEncoding[charcode])) {
22425 toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
22426 continue;
22427 }
22428 }
22429
22430 toUnicode[charcode] = String.fromCodePoint(code);
22431 }
22432
22433 continue;
22434 }
22435
22436 toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
22437 }
22438
22439 return new _fonts.ToUnicodeMap(toUnicode);
22440 },
22441
22442 buildToUnicode(properties) {
22443 properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
22444
22445 if (properties.hasIncludedToUnicodeMap) {
22446 if (!properties.composite && properties.hasEncoding) {
22447 properties.fallbackToUnicode = this._buildSimpleFontToUnicode(properties);
22448 }
22449
22450 return Promise.resolve(properties.toUnicode);
22451 }
22452
22453 if (!properties.composite) {
22454 return Promise.resolve(this._buildSimpleFontToUnicode(properties));
22455 }
22456
22457 if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
22458 const registry = properties.cidSystemInfo.registry;
22459 const ordering = properties.cidSystemInfo.ordering;
22460
22461 const ucs2CMapName = _primitives.Name.get(registry + "-" + ordering + "-UCS2");
22462
22463 return _cmap.CMapFactory.create({
22464 encoding: ucs2CMapName,
22465 fetchBuiltInCMap: this.fetchBuiltInCMap,
22466 useCMap: null
22467 }).then(function (ucs2CMap) {
22468 const cMap = properties.cMap;
22469 const toUnicode = [];
22470 cMap.forEach(function (charcode, cid) {
22471 if (cid > 0xffff) {
22472 throw new _util.FormatError("Max size of CID is 65,535");
22473 }
22474
22475 const ucs2 = ucs2CMap.lookup(cid);
22476
22477 if (ucs2) {
22478 toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
22479 }
22480 });
22481 return new _fonts.ToUnicodeMap(toUnicode);
22482 });
22483 }
22484
22485 return Promise.resolve(new _fonts.IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
22486 },
22487
22488 readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
22489 var cmapObj = toUnicode;
22490
22491 if ((0, _primitives.isName)(cmapObj)) {
22492 return _cmap.CMapFactory.create({
22493 encoding: cmapObj,
22494 fetchBuiltInCMap: this.fetchBuiltInCMap,
22495 useCMap: null
22496 }).then(function (cmap) {
22497 if (cmap instanceof _cmap.IdentityCMap) {
22498 return new _fonts.IdentityToUnicodeMap(0, 0xffff);
22499 }
22500
22501 return new _fonts.ToUnicodeMap(cmap.getMap());
22502 });
22503 } else if ((0, _primitives.isStream)(cmapObj)) {
22504 return _cmap.CMapFactory.create({
22505 encoding: cmapObj,
22506 fetchBuiltInCMap: this.fetchBuiltInCMap,
22507 useCMap: null
22508 }).then(function (cmap) {
22509 if (cmap instanceof _cmap.IdentityCMap) {
22510 return new _fonts.IdentityToUnicodeMap(0, 0xffff);
22511 }
22512
22513 var map = new Array(cmap.length);
22514 cmap.forEach(function (charCode, token) {
22515 var str = [];
22516
22517 for (var k = 0; k < token.length; k += 2) {
22518 var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
22519
22520 if ((w1 & 0xf800) !== 0xd800) {
22521 str.push(w1);
22522 continue;
22523 }
22524
22525 k += 2;
22526 var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
22527 str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
22528 }
22529
22530 map[charCode] = String.fromCodePoint.apply(String, str);
22531 });
22532 return new _fonts.ToUnicodeMap(map);
22533 }, reason => {
22534 if (reason instanceof _util.AbortException) {
22535 return null;
22536 }
22537
22538 if (this.options.ignoreErrors) {
22539 this.handler.send("UnsupportedFeature", {
22540 featureId: _util.UNSUPPORTED_FEATURES.errorFontToUnicode
22541 });
22542 (0, _util.warn)(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
22543 return null;
22544 }
22545
22546 throw reason;
22547 });
22548 }
22549
22550 return Promise.resolve(null);
22551 },
22552
22553 readCidToGidMap(glyphsData, toUnicode) {
22554 var result = [];
22555
22556 for (var j = 0, jj = glyphsData.length; j < jj; j++) {
22557 var glyphID = glyphsData[j++] << 8 | glyphsData[j];
22558 const code = j >> 1;
22559
22560 if (glyphID === 0 && !toUnicode.has(code)) {
22561 continue;
22562 }
22563
22564 result[code] = glyphID;
22565 }
22566
22567 return result;
22568 },
22569
22570 extractWidths: function PartialEvaluator_extractWidths(dict, descriptor, properties) {
22571 var xref = this.xref;
22572 var glyphsWidths = [];
22573 var defaultWidth = 0;
22574 var glyphsVMetrics = [];
22575 var defaultVMetrics;
22576 var i, ii, j, jj, start, code, widths;
22577
22578 if (properties.composite) {
22579 defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
22580 widths = dict.get("W");
22581
22582 if (widths) {
22583 for (i = 0, ii = widths.length; i < ii; i++) {
22584 start = xref.fetchIfRef(widths[i++]);
22585 code = xref.fetchIfRef(widths[i]);
22586
22587 if (Array.isArray(code)) {
22588 for (j = 0, jj = code.length; j < jj; j++) {
22589 glyphsWidths[start++] = xref.fetchIfRef(code[j]);
22590 }
22591 } else {
22592 var width = xref.fetchIfRef(widths[++i]);
22593
22594 for (j = start; j <= code; j++) {
22595 glyphsWidths[j] = width;
22596 }
22597 }
22598 }
22599 }
22600
22601 if (properties.vertical) {
22602 var vmetrics = dict.getArray("DW2") || [880, -1000];
22603 defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
22604 vmetrics = dict.get("W2");
22605
22606 if (vmetrics) {
22607 for (i = 0, ii = vmetrics.length; i < ii; i++) {
22608 start = xref.fetchIfRef(vmetrics[i++]);
22609 code = xref.fetchIfRef(vmetrics[i]);
22610
22611 if (Array.isArray(code)) {
22612 for (j = 0, jj = code.length; j < jj; j++) {
22613 glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
22614 }
22615 } else {
22616 var vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
22617
22618 for (j = start; j <= code; j++) {
22619 glyphsVMetrics[j] = vmetric;
22620 }
22621 }
22622 }
22623 }
22624 }
22625 } else {
22626 var firstChar = properties.firstChar;
22627 widths = dict.get("Widths");
22628
22629 if (widths) {
22630 j = firstChar;
22631
22632 for (i = 0, ii = widths.length; i < ii; i++) {
22633 glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
22634 }
22635
22636 defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
22637 } else {
22638 var baseFontName = dict.get("BaseFont");
22639
22640 if ((0, _primitives.isName)(baseFontName)) {
22641 var metrics = this.getBaseFontMetrics(baseFontName.name);
22642 glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
22643 defaultWidth = metrics.defaultWidth;
22644 }
22645 }
22646 }
22647
22648 var isMonospace = true;
22649 var firstWidth = defaultWidth;
22650
22651 for (var glyph in glyphsWidths) {
22652 var glyphWidth = glyphsWidths[glyph];
22653
22654 if (!glyphWidth) {
22655 continue;
22656 }
22657
22658 if (!firstWidth) {
22659 firstWidth = glyphWidth;
22660 continue;
22661 }
22662
22663 if (firstWidth !== glyphWidth) {
22664 isMonospace = false;
22665 break;
22666 }
22667 }
22668
22669 if (isMonospace) {
22670 properties.flags |= _fonts.FontFlags.FixedPitch;
22671 }
22672
22673 properties.defaultWidth = defaultWidth;
22674 properties.widths = glyphsWidths;
22675 properties.defaultVMetrics = defaultVMetrics;
22676 properties.vmetrics = glyphsVMetrics;
22677 },
22678 isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
22679 var fontNameWoStyle = baseFontName.split("-")[0];
22680 return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || fontNameWoStyle.search(/serif/gi) !== -1;
22681 },
22682 getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
22683 var defaultWidth = 0;
22684 var widths = [];
22685 var monospace = false;
22686 var stdFontMap = (0, _standard_fonts.getStdFontMap)();
22687 var lookupName = stdFontMap[name] || name;
22688 var Metrics = (0, _metrics.getMetrics)();
22689
22690 if (!(lookupName in Metrics)) {
22691 if (this.isSerifFont(name)) {
22692 lookupName = "Times-Roman";
22693 } else {
22694 lookupName = "Helvetica";
22695 }
22696 }
22697
22698 var glyphWidths = Metrics[lookupName];
22699
22700 if ((0, _util.isNum)(glyphWidths)) {
22701 defaultWidth = glyphWidths;
22702 monospace = true;
22703 } else {
22704 widths = glyphWidths();
22705 }
22706
22707 return {
22708 defaultWidth,
22709 monospace,
22710 widths
22711 };
22712 },
22713 buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
22714 var widths = Object.create(null);
22715 var differences = properties.differences;
22716 var encoding = properties.defaultEncoding;
22717
22718 for (var charCode = 0; charCode < 256; charCode++) {
22719 if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
22720 widths[charCode] = widthsByGlyphName[differences[charCode]];
22721 continue;
22722 }
22723
22724 if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
22725 widths[charCode] = widthsByGlyphName[encoding[charCode]];
22726 continue;
22727 }
22728 }
22729
22730 return widths;
22731 },
22732 preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
22733 var baseDict = dict;
22734 var type = dict.get("Subtype");
22735
22736 if (!(0, _primitives.isName)(type)) {
22737 throw new _util.FormatError("invalid font Subtype");
22738 }
22739
22740 var composite = false;
22741 var uint8array;
22742
22743 if (type.name === "Type0") {
22744 var df = dict.get("DescendantFonts");
22745
22746 if (!df) {
22747 throw new _util.FormatError("Descendant fonts are not specified");
22748 }
22749
22750 dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
22751 type = dict.get("Subtype");
22752
22753 if (!(0, _primitives.isName)(type)) {
22754 throw new _util.FormatError("invalid font Subtype");
22755 }
22756
22757 composite = true;
22758 }
22759
22760 var descriptor = dict.get("FontDescriptor");
22761
22762 if (descriptor) {
22763 var hash = new _murmurhash.MurmurHash3_64();
22764 var encoding = baseDict.getRaw("Encoding");
22765
22766 if ((0, _primitives.isName)(encoding)) {
22767 hash.update(encoding.name);
22768 } else if ((0, _primitives.isRef)(encoding)) {
22769 hash.update(encoding.toString());
22770 } else if ((0, _primitives.isDict)(encoding)) {
22771 var keys = encoding.getKeys();
22772
22773 for (var i = 0, ii = keys.length; i < ii; i++) {
22774 var entry = encoding.getRaw(keys[i]);
22775
22776 if ((0, _primitives.isName)(entry)) {
22777 hash.update(entry.name);
22778 } else if ((0, _primitives.isRef)(entry)) {
22779 hash.update(entry.toString());
22780 } else if (Array.isArray(entry)) {
22781 var diffLength = entry.length,
22782 diffBuf = new Array(diffLength);
22783
22784 for (var j = 0; j < diffLength; j++) {
22785 var diffEntry = entry[j];
22786
22787 if ((0, _primitives.isName)(diffEntry)) {
22788 diffBuf[j] = diffEntry.name;
22789 } else if ((0, _util.isNum)(diffEntry) || (0, _primitives.isRef)(diffEntry)) {
22790 diffBuf[j] = diffEntry.toString();
22791 }
22792 }
22793
22794 hash.update(diffBuf.join());
22795 }
22796 }
22797 }
22798
22799 const firstChar = dict.get("FirstChar") || 0;
22800 const lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
22801 hash.update(`${firstChar}-${lastChar}`);
22802 var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
22803
22804 if ((0, _primitives.isStream)(toUnicode)) {
22805 var stream = toUnicode.str || toUnicode;
22806 uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
22807 hash.update(uint8array);
22808 } else if ((0, _primitives.isName)(toUnicode)) {
22809 hash.update(toUnicode.name);
22810 }
22811
22812 var widths = dict.get("Widths") || baseDict.get("Widths");
22813
22814 if (widths) {
22815 uint8array = new Uint8Array(new Uint32Array(widths).buffer);
22816 hash.update(uint8array);
22817 }
22818 }
22819
22820 return {
22821 descriptor,
22822 dict,
22823 baseDict,
22824 composite,
22825 type: type.name,
22826 hash: hash ? hash.hexdigest() : ""
22827 };
22828 },
22829 translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
22830 var baseDict = preEvaluatedFont.baseDict;
22831 var dict = preEvaluatedFont.dict;
22832 var composite = preEvaluatedFont.composite;
22833 var descriptor = preEvaluatedFont.descriptor;
22834 var type = preEvaluatedFont.type;
22835 var maxCharIndex = composite ? 0xffff : 0xff;
22836 var properties;
22837 const firstChar = dict.get("FirstChar") || 0;
22838 const lastChar = dict.get("LastChar") || maxCharIndex;
22839
22840 if (!descriptor) {
22841 if (type === "Type3") {
22842 descriptor = new _primitives.Dict(null);
22843 descriptor.set("FontName", _primitives.Name.get(type));
22844 descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0]);
22845 } else {
22846 var baseFontName = dict.get("BaseFont");
22847
22848 if (!(0, _primitives.isName)(baseFontName)) {
22849 throw new _util.FormatError("Base font is not specified");
22850 }
22851
22852 baseFontName = baseFontName.name.replace(/[,_]/g, "-");
22853 var metrics = this.getBaseFontMetrics(baseFontName);
22854 var fontNameWoStyle = baseFontName.split("-")[0];
22855 var flags = (this.isSerifFont(fontNameWoStyle) ? _fonts.FontFlags.Serif : 0) | (metrics.monospace ? _fonts.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts.FontFlags.Symbolic : _fonts.FontFlags.Nonsymbolic);
22856 properties = {
22857 type,
22858 name: baseFontName,
22859 widths: metrics.widths,
22860 defaultWidth: metrics.defaultWidth,
22861 flags,
22862 firstChar,
22863 lastChar
22864 };
22865 const widths = dict.get("Widths");
22866 return this.extractDataStructures(dict, dict, properties).then(newProperties => {
22867 if (widths) {
22868 const glyphWidths = [];
22869 let j = firstChar;
22870
22871 for (let i = 0, ii = widths.length; i < ii; i++) {
22872 glyphWidths[j++] = this.xref.fetchIfRef(widths[i]);
22873 }
22874
22875 newProperties.widths = glyphWidths;
22876 } else {
22877 newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties);
22878 }
22879
22880 return new _fonts.Font(baseFontName, null, newProperties);
22881 });
22882 }
22883 }
22884
22885 var fontName = descriptor.get("FontName");
22886 var baseFont = dict.get("BaseFont");
22887
22888 if ((0, _util.isString)(fontName)) {
22889 fontName = _primitives.Name.get(fontName);
22890 }
22891
22892 if ((0, _util.isString)(baseFont)) {
22893 baseFont = _primitives.Name.get(baseFont);
22894 }
22895
22896 if (type !== "Type3") {
22897 var fontNameStr = fontName && fontName.name;
22898 var baseFontStr = baseFont && baseFont.name;
22899
22900 if (fontNameStr !== baseFontStr) {
22901 (0, _util.info)(`The FontDescriptor\'s FontName is "${fontNameStr}" but ` + `should be the same as the Font\'s BaseFont "${baseFontStr}".`);
22902
22903 if (fontNameStr && baseFontStr && baseFontStr.startsWith(fontNameStr)) {
22904 fontName = baseFont;
22905 }
22906 }
22907 }
22908
22909 fontName = fontName || baseFont;
22910
22911 if (!(0, _primitives.isName)(fontName)) {
22912 throw new _util.FormatError("invalid font name");
22913 }
22914
22915 var fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
22916
22917 if (fontFile) {
22918 if (fontFile.dict) {
22919 var subtype = fontFile.dict.get("Subtype");
22920
22921 if (subtype) {
22922 subtype = subtype.name;
22923 }
22924
22925 var length1 = fontFile.dict.get("Length1");
22926 var length2 = fontFile.dict.get("Length2");
22927 var length3 = fontFile.dict.get("Length3");
22928 }
22929 }
22930
22931 properties = {
22932 type,
22933 name: fontName.name,
22934 subtype,
22935 file: fontFile,
22936 length1,
22937 length2,
22938 length3,
22939 loadedName: baseDict.loadedName,
22940 composite,
22941 fixedPitch: false,
22942 fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX,
22943 firstChar: firstChar || 0,
22944 lastChar: lastChar || maxCharIndex,
22945 bbox: descriptor.getArray("FontBBox"),
22946 ascent: descriptor.get("Ascent"),
22947 descent: descriptor.get("Descent"),
22948 xHeight: descriptor.get("XHeight"),
22949 capHeight: descriptor.get("CapHeight"),
22950 flags: descriptor.get("Flags"),
22951 italicAngle: descriptor.get("ItalicAngle"),
22952 isType3Font: false
22953 };
22954 var cMapPromise;
22955
22956 if (composite) {
22957 var cidEncoding = baseDict.get("Encoding");
22958
22959 if ((0, _primitives.isName)(cidEncoding)) {
22960 properties.cidEncoding = cidEncoding.name;
22961 }
22962
22963 cMapPromise = _cmap.CMapFactory.create({
22964 encoding: cidEncoding,
22965 fetchBuiltInCMap: this.fetchBuiltInCMap,
22966 useCMap: null
22967 }).then(function (cMap) {
22968 properties.cMap = cMap;
22969 properties.vertical = properties.cMap.vertical;
22970 });
22971 } else {
22972 cMapPromise = Promise.resolve(undefined);
22973 }
22974
22975 return cMapPromise.then(() => {
22976 return this.extractDataStructures(dict, baseDict, properties);
22977 }).then(newProperties => {
22978 this.extractWidths(dict, descriptor, newProperties);
22979
22980 if (type === "Type3") {
22981 newProperties.isType3Font = true;
22982 }
22983
22984 return new _fonts.Font(fontName.name, fontFile, newProperties);
22985 });
22986 }
22987 };
22988
22989 PartialEvaluator.buildFontPaths = function (font, glyphs, handler) {
22990 function buildPath(fontChar) {
22991 if (font.renderer.hasBuiltPath(fontChar)) {
22992 return;
22993 }
22994
22995 handler.send("commonobj", [`${font.loadedName}_path_${fontChar}`, "FontPath", font.renderer.getPathJs(fontChar)]);
22996 }
22997
22998 for (const glyph of glyphs) {
22999 buildPath(glyph.fontChar);
23000 const accent = glyph.accent;
23001
23002 if (accent && accent.fontChar) {
23003 buildPath(accent.fontChar);
23004 }
23005 }
23006 };
23007
23008 PartialEvaluator.getFallbackFontDict = function () {
23009 if (this._fallbackFontDict) {
23010 return this._fallbackFontDict;
23011 }
23012
23013 const dict = new _primitives.Dict();
23014 dict.set("BaseFont", _primitives.Name.get("PDFJS-FallbackFont"));
23015 dict.set("Type", _primitives.Name.get("FallbackType"));
23016 dict.set("Subtype", _primitives.Name.get("FallbackType"));
23017 dict.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
23018 return this._fallbackFontDict = dict;
23019 };
23020
23021 return PartialEvaluator;
23022}();
23023
23024exports.PartialEvaluator = PartialEvaluator;
23025
23026class TranslatedFont {
23027 constructor({
23028 loadedName,
23029 font,
23030 dict,
23031 extraProperties = false
23032 }) {
23033 this.loadedName = loadedName;
23034 this.font = font;
23035 this.dict = dict;
23036 this._extraProperties = extraProperties;
23037 this.type3Loaded = null;
23038 this.sent = false;
23039 }
23040
23041 send(handler) {
23042 if (this.sent) {
23043 return;
23044 }
23045
23046 this.sent = true;
23047 handler.send("commonobj", [this.loadedName, "Font", this.font.exportData(this._extraProperties)]);
23048 }
23049
23050 fallback(handler) {
23051 if (!this.font.data) {
23052 return;
23053 }
23054
23055 this.font.disableFontFace = true;
23056 const glyphs = this.font.glyphCacheValues;
23057 PartialEvaluator.buildFontPaths(this.font, glyphs, handler);
23058 }
23059
23060 loadType3Data(evaluator, resources, parentOperatorList, task) {
23061 if (!this.font.isType3Font) {
23062 throw new Error("Must be a Type3 font.");
23063 }
23064
23065 if (this.type3Loaded) {
23066 return this.type3Loaded;
23067 }
23068
23069 var type3Options = Object.create(evaluator.options);
23070 type3Options.ignoreErrors = false;
23071 var type3Evaluator = evaluator.clone(type3Options);
23072 type3Evaluator.parsingType3Font = true;
23073 var translatedFont = this.font;
23074 var loadCharProcsPromise = Promise.resolve();
23075 var charProcs = this.dict.get("CharProcs");
23076 var fontResources = this.dict.get("Resources") || resources;
23077 var charProcKeys = charProcs.getKeys();
23078 var charProcOperatorList = Object.create(null);
23079
23080 for (var i = 0, n = charProcKeys.length; i < n; ++i) {
23081 const key = charProcKeys[i];
23082 loadCharProcsPromise = loadCharProcsPromise.then(function () {
23083 var glyphStream = charProcs.get(key);
23084 var operatorList = new _operator_list.OperatorList();
23085 return type3Evaluator.getOperatorList({
23086 stream: glyphStream,
23087 task,
23088 resources: fontResources,
23089 operatorList
23090 }).then(function () {
23091 charProcOperatorList[key] = operatorList.getIR();
23092 parentOperatorList.addDependencies(operatorList.dependencies);
23093 }).catch(function (reason) {
23094 (0, _util.warn)(`Type3 font resource "${key}" is not available.`);
23095 const dummyOperatorList = new _operator_list.OperatorList();
23096 charProcOperatorList[key] = dummyOperatorList.getIR();
23097 });
23098 });
23099 }
23100
23101 this.type3Loaded = loadCharProcsPromise.then(function () {
23102 translatedFont.charProcOperatorList = charProcOperatorList;
23103 });
23104 return this.type3Loaded;
23105 }
23106
23107}
23108
23109var StateManager = function StateManagerClosure() {
23110 function StateManager(initialState) {
23111 this.state = initialState;
23112 this.stateStack = [];
23113 }
23114
23115 StateManager.prototype = {
23116 save() {
23117 var old = this.state;
23118 this.stateStack.push(this.state);
23119 this.state = old.clone();
23120 },
23121
23122 restore() {
23123 var prev = this.stateStack.pop();
23124
23125 if (prev) {
23126 this.state = prev;
23127 }
23128 },
23129
23130 transform(args) {
23131 this.state.ctm = _util.Util.transform(this.state.ctm, args);
23132 }
23133
23134 };
23135 return StateManager;
23136}();
23137
23138var TextState = function TextStateClosure() {
23139 function TextState() {
23140 this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
23141 this.fontName = null;
23142 this.fontSize = 0;
23143 this.font = null;
23144 this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
23145 this.textMatrix = _util.IDENTITY_MATRIX.slice();
23146 this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
23147 this.charSpacing = 0;
23148 this.wordSpacing = 0;
23149 this.leading = 0;
23150 this.textHScale = 1;
23151 this.textRise = 0;
23152 }
23153
23154 TextState.prototype = {
23155 setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
23156 var m = this.textMatrix;
23157 m[0] = a;
23158 m[1] = b;
23159 m[2] = c;
23160 m[3] = d;
23161 m[4] = e;
23162 m[5] = f;
23163 },
23164 setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
23165 var m = this.textLineMatrix;
23166 m[0] = a;
23167 m[1] = b;
23168 m[2] = c;
23169 m[3] = d;
23170 m[4] = e;
23171 m[5] = f;
23172 },
23173 translateTextMatrix: function TextState_translateTextMatrix(x, y) {
23174 var m = this.textMatrix;
23175 m[4] = m[0] * x + m[2] * y + m[4];
23176 m[5] = m[1] * x + m[3] * y + m[5];
23177 },
23178 translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
23179 var m = this.textLineMatrix;
23180 m[4] = m[0] * x + m[2] * y + m[4];
23181 m[5] = m[1] * x + m[3] * y + m[5];
23182 },
23183 calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
23184 var font = this.font;
23185
23186 if (!font) {
23187 return null;
23188 }
23189
23190 var m = this.textLineMatrix;
23191
23192 if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
23193 return null;
23194 }
23195
23196 var txDiff = e - m[4],
23197 tyDiff = f - m[5];
23198
23199 if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
23200 return null;
23201 }
23202
23203 var tx,
23204 ty,
23205 denominator = a * d - b * c;
23206
23207 if (font.vertical) {
23208 tx = -tyDiff * c / denominator;
23209 ty = tyDiff * a / denominator;
23210 } else {
23211 tx = txDiff * d / denominator;
23212 ty = -txDiff * b / denominator;
23213 }
23214
23215 return {
23216 width: tx,
23217 height: ty,
23218 value: font.vertical ? ty : tx
23219 };
23220 },
23221 calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
23222 var tsm = [this.fontSize * this.textHScale, 0, 0, this.fontSize, 0, this.textRise];
23223 return _util.Util.transform(ctm, _util.Util.transform(this.textMatrix, tsm));
23224 },
23225 carriageReturn: function TextState_carriageReturn() {
23226 this.translateTextLineMatrix(0, -this.leading);
23227 this.textMatrix = this.textLineMatrix.slice();
23228 },
23229 clone: function TextState_clone() {
23230 var clone = Object.create(this);
23231 clone.textMatrix = this.textMatrix.slice();
23232 clone.textLineMatrix = this.textLineMatrix.slice();
23233 clone.fontMatrix = this.fontMatrix.slice();
23234 return clone;
23235 }
23236 };
23237 return TextState;
23238}();
23239
23240var EvalState = function EvalStateClosure() {
23241 function EvalState() {
23242 this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
23243 this.font = null;
23244 this.textRenderingMode = _util.TextRenderingMode.FILL;
23245 this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
23246 this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
23247 }
23248
23249 EvalState.prototype = {
23250 clone: function CanvasExtraState_clone() {
23251 return Object.create(this);
23252 }
23253 };
23254 return EvalState;
23255}();
23256
23257var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
23258 var getOPMap = (0, _core_utils.getLookupTableFactory)(function (t) {
23259 t.w = {
23260 id: _util.OPS.setLineWidth,
23261 numArgs: 1,
23262 variableArgs: false
23263 };
23264 t.J = {
23265 id: _util.OPS.setLineCap,
23266 numArgs: 1,
23267 variableArgs: false
23268 };
23269 t.j = {
23270 id: _util.OPS.setLineJoin,
23271 numArgs: 1,
23272 variableArgs: false
23273 };
23274 t.M = {
23275 id: _util.OPS.setMiterLimit,
23276 numArgs: 1,
23277 variableArgs: false
23278 };
23279 t.d = {
23280 id: _util.OPS.setDash,
23281 numArgs: 2,
23282 variableArgs: false
23283 };
23284 t.ri = {
23285 id: _util.OPS.setRenderingIntent,
23286 numArgs: 1,
23287 variableArgs: false
23288 };
23289 t.i = {
23290 id: _util.OPS.setFlatness,
23291 numArgs: 1,
23292 variableArgs: false
23293 };
23294 t.gs = {
23295 id: _util.OPS.setGState,
23296 numArgs: 1,
23297 variableArgs: false
23298 };
23299 t.q = {
23300 id: _util.OPS.save,
23301 numArgs: 0,
23302 variableArgs: false
23303 };
23304 t.Q = {
23305 id: _util.OPS.restore,
23306 numArgs: 0,
23307 variableArgs: false
23308 };
23309 t.cm = {
23310 id: _util.OPS.transform,
23311 numArgs: 6,
23312 variableArgs: false
23313 };
23314 t.m = {
23315 id: _util.OPS.moveTo,
23316 numArgs: 2,
23317 variableArgs: false
23318 };
23319 t.l = {
23320 id: _util.OPS.lineTo,
23321 numArgs: 2,
23322 variableArgs: false
23323 };
23324 t.c = {
23325 id: _util.OPS.curveTo,
23326 numArgs: 6,
23327 variableArgs: false
23328 };
23329 t.v = {
23330 id: _util.OPS.curveTo2,
23331 numArgs: 4,
23332 variableArgs: false
23333 };
23334 t.y = {
23335 id: _util.OPS.curveTo3,
23336 numArgs: 4,
23337 variableArgs: false
23338 };
23339 t.h = {
23340 id: _util.OPS.closePath,
23341 numArgs: 0,
23342 variableArgs: false
23343 };
23344 t.re = {
23345 id: _util.OPS.rectangle,
23346 numArgs: 4,
23347 variableArgs: false
23348 };
23349 t.S = {
23350 id: _util.OPS.stroke,
23351 numArgs: 0,
23352 variableArgs: false
23353 };
23354 t.s = {
23355 id: _util.OPS.closeStroke,
23356 numArgs: 0,
23357 variableArgs: false
23358 };
23359 t.f = {
23360 id: _util.OPS.fill,
23361 numArgs: 0,
23362 variableArgs: false
23363 };
23364 t.F = {
23365 id: _util.OPS.fill,
23366 numArgs: 0,
23367 variableArgs: false
23368 };
23369 t["f*"] = {
23370 id: _util.OPS.eoFill,
23371 numArgs: 0,
23372 variableArgs: false
23373 };
23374 t.B = {
23375 id: _util.OPS.fillStroke,
23376 numArgs: 0,
23377 variableArgs: false
23378 };
23379 t["B*"] = {
23380 id: _util.OPS.eoFillStroke,
23381 numArgs: 0,
23382 variableArgs: false
23383 };
23384 t.b = {
23385 id: _util.OPS.closeFillStroke,
23386 numArgs: 0,
23387 variableArgs: false
23388 };
23389 t["b*"] = {
23390 id: _util.OPS.closeEOFillStroke,
23391 numArgs: 0,
23392 variableArgs: false
23393 };
23394 t.n = {
23395 id: _util.OPS.endPath,
23396 numArgs: 0,
23397 variableArgs: false
23398 };
23399 t.W = {
23400 id: _util.OPS.clip,
23401 numArgs: 0,
23402 variableArgs: false
23403 };
23404 t["W*"] = {
23405 id: _util.OPS.eoClip,
23406 numArgs: 0,
23407 variableArgs: false
23408 };
23409 t.BT = {
23410 id: _util.OPS.beginText,
23411 numArgs: 0,
23412 variableArgs: false
23413 };
23414 t.ET = {
23415 id: _util.OPS.endText,
23416 numArgs: 0,
23417 variableArgs: false
23418 };
23419 t.Tc = {
23420 id: _util.OPS.setCharSpacing,
23421 numArgs: 1,
23422 variableArgs: false
23423 };
23424 t.Tw = {
23425 id: _util.OPS.setWordSpacing,
23426 numArgs: 1,
23427 variableArgs: false
23428 };
23429 t.Tz = {
23430 id: _util.OPS.setHScale,
23431 numArgs: 1,
23432 variableArgs: false
23433 };
23434 t.TL = {
23435 id: _util.OPS.setLeading,
23436 numArgs: 1,
23437 variableArgs: false
23438 };
23439 t.Tf = {
23440 id: _util.OPS.setFont,
23441 numArgs: 2,
23442 variableArgs: false
23443 };
23444 t.Tr = {
23445 id: _util.OPS.setTextRenderingMode,
23446 numArgs: 1,
23447 variableArgs: false
23448 };
23449 t.Ts = {
23450 id: _util.OPS.setTextRise,
23451 numArgs: 1,
23452 variableArgs: false
23453 };
23454 t.Td = {
23455 id: _util.OPS.moveText,
23456 numArgs: 2,
23457 variableArgs: false
23458 };
23459 t.TD = {
23460 id: _util.OPS.setLeadingMoveText,
23461 numArgs: 2,
23462 variableArgs: false
23463 };
23464 t.Tm = {
23465 id: _util.OPS.setTextMatrix,
23466 numArgs: 6,
23467 variableArgs: false
23468 };
23469 t["T*"] = {
23470 id: _util.OPS.nextLine,
23471 numArgs: 0,
23472 variableArgs: false
23473 };
23474 t.Tj = {
23475 id: _util.OPS.showText,
23476 numArgs: 1,
23477 variableArgs: false
23478 };
23479 t.TJ = {
23480 id: _util.OPS.showSpacedText,
23481 numArgs: 1,
23482 variableArgs: false
23483 };
23484 t["'"] = {
23485 id: _util.OPS.nextLineShowText,
23486 numArgs: 1,
23487 variableArgs: false
23488 };
23489 t['"'] = {
23490 id: _util.OPS.nextLineSetSpacingShowText,
23491 numArgs: 3,
23492 variableArgs: false
23493 };
23494 t.d0 = {
23495 id: _util.OPS.setCharWidth,
23496 numArgs: 2,
23497 variableArgs: false
23498 };
23499 t.d1 = {
23500 id: _util.OPS.setCharWidthAndBounds,
23501 numArgs: 6,
23502 variableArgs: false
23503 };
23504 t.CS = {
23505 id: _util.OPS.setStrokeColorSpace,
23506 numArgs: 1,
23507 variableArgs: false
23508 };
23509 t.cs = {
23510 id: _util.OPS.setFillColorSpace,
23511 numArgs: 1,
23512 variableArgs: false
23513 };
23514 t.SC = {
23515 id: _util.OPS.setStrokeColor,
23516 numArgs: 4,
23517 variableArgs: true
23518 };
23519 t.SCN = {
23520 id: _util.OPS.setStrokeColorN,
23521 numArgs: 33,
23522 variableArgs: true
23523 };
23524 t.sc = {
23525 id: _util.OPS.setFillColor,
23526 numArgs: 4,
23527 variableArgs: true
23528 };
23529 t.scn = {
23530 id: _util.OPS.setFillColorN,
23531 numArgs: 33,
23532 variableArgs: true
23533 };
23534 t.G = {
23535 id: _util.OPS.setStrokeGray,
23536 numArgs: 1,
23537 variableArgs: false
23538 };
23539 t.g = {
23540 id: _util.OPS.setFillGray,
23541 numArgs: 1,
23542 variableArgs: false
23543 };
23544 t.RG = {
23545 id: _util.OPS.setStrokeRGBColor,
23546 numArgs: 3,
23547 variableArgs: false
23548 };
23549 t.rg = {
23550 id: _util.OPS.setFillRGBColor,
23551 numArgs: 3,
23552 variableArgs: false
23553 };
23554 t.K = {
23555 id: _util.OPS.setStrokeCMYKColor,
23556 numArgs: 4,
23557 variableArgs: false
23558 };
23559 t.k = {
23560 id: _util.OPS.setFillCMYKColor,
23561 numArgs: 4,
23562 variableArgs: false
23563 };
23564 t.sh = {
23565 id: _util.OPS.shadingFill,
23566 numArgs: 1,
23567 variableArgs: false
23568 };
23569 t.BI = {
23570 id: _util.OPS.beginInlineImage,
23571 numArgs: 0,
23572 variableArgs: false
23573 };
23574 t.ID = {
23575 id: _util.OPS.beginImageData,
23576 numArgs: 0,
23577 variableArgs: false
23578 };
23579 t.EI = {
23580 id: _util.OPS.endInlineImage,
23581 numArgs: 1,
23582 variableArgs: false
23583 };
23584 t.Do = {
23585 id: _util.OPS.paintXObject,
23586 numArgs: 1,
23587 variableArgs: false
23588 };
23589 t.MP = {
23590 id: _util.OPS.markPoint,
23591 numArgs: 1,
23592 variableArgs: false
23593 };
23594 t.DP = {
23595 id: _util.OPS.markPointProps,
23596 numArgs: 2,
23597 variableArgs: false
23598 };
23599 t.BMC = {
23600 id: _util.OPS.beginMarkedContent,
23601 numArgs: 1,
23602 variableArgs: false
23603 };
23604 t.BDC = {
23605 id: _util.OPS.beginMarkedContentProps,
23606 numArgs: 2,
23607 variableArgs: false
23608 };
23609 t.EMC = {
23610 id: _util.OPS.endMarkedContent,
23611 numArgs: 0,
23612 variableArgs: false
23613 };
23614 t.BX = {
23615 id: _util.OPS.beginCompat,
23616 numArgs: 0,
23617 variableArgs: false
23618 };
23619 t.EX = {
23620 id: _util.OPS.endCompat,
23621 numArgs: 0,
23622 variableArgs: false
23623 };
23624 t.BM = null;
23625 t.BD = null;
23626 t.true = null;
23627 t.fa = null;
23628 t.fal = null;
23629 t.fals = null;
23630 t.false = null;
23631 t.nu = null;
23632 t.nul = null;
23633 t.null = null;
23634 });
23635 const MAX_INVALID_PATH_OPS = 20;
23636
23637 function EvaluatorPreprocessor(stream, xref, stateManager) {
23638 this.opMap = getOPMap();
23639 this.parser = new _parser.Parser({
23640 lexer: new _parser.Lexer(stream, this.opMap),
23641 xref
23642 });
23643 this.stateManager = stateManager;
23644 this.nonProcessedArgs = [];
23645 this._numInvalidPathOPS = 0;
23646 }
23647
23648 EvaluatorPreprocessor.prototype = {
23649 get savedStatesDepth() {
23650 return this.stateManager.stateStack.length;
23651 },
23652
23653 read: function EvaluatorPreprocessor_read(operation) {
23654 var args = operation.args;
23655
23656 while (true) {
23657 var obj = this.parser.getObj();
23658
23659 if (obj instanceof _primitives.Cmd) {
23660 var cmd = obj.cmd;
23661 var opSpec = this.opMap[cmd];
23662
23663 if (!opSpec) {
23664 (0, _util.warn)(`Unknown command "${cmd}".`);
23665 continue;
23666 }
23667
23668 var fn = opSpec.id;
23669 var numArgs = opSpec.numArgs;
23670 var argsLength = args !== null ? args.length : 0;
23671
23672 if (!opSpec.variableArgs) {
23673 if (argsLength !== numArgs) {
23674 var nonProcessedArgs = this.nonProcessedArgs;
23675
23676 while (argsLength > numArgs) {
23677 nonProcessedArgs.push(args.shift());
23678 argsLength--;
23679 }
23680
23681 while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
23682 if (args === null) {
23683 args = [];
23684 }
23685
23686 args.unshift(nonProcessedArgs.pop());
23687 argsLength++;
23688 }
23689 }
23690
23691 if (argsLength < numArgs) {
23692 const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`;
23693
23694 if (fn >= _util.OPS.moveTo && fn <= _util.OPS.endPath && ++this._numInvalidPathOPS > MAX_INVALID_PATH_OPS) {
23695 throw new _util.FormatError(`Invalid ${partialMsg}`);
23696 }
23697
23698 (0, _util.warn)(`Skipping ${partialMsg}`);
23699
23700 if (args !== null) {
23701 args.length = 0;
23702 }
23703
23704 continue;
23705 }
23706 } else if (argsLength > numArgs) {
23707 (0, _util.info)(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`);
23708 }
23709
23710 this.preprocessCommand(fn, args);
23711 operation.fn = fn;
23712 operation.args = args;
23713 return true;
23714 }
23715
23716 if (obj === _primitives.EOF) {
23717 return false;
23718 }
23719
23720 if (obj !== null) {
23721 if (args === null) {
23722 args = [];
23723 }
23724
23725 args.push(obj);
23726
23727 if (args.length > 33) {
23728 throw new _util.FormatError("Too many arguments");
23729 }
23730 }
23731 }
23732 },
23733 preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
23734 switch (fn | 0) {
23735 case _util.OPS.save:
23736 this.stateManager.save();
23737 break;
23738
23739 case _util.OPS.restore:
23740 this.stateManager.restore();
23741 break;
23742
23743 case _util.OPS.transform:
23744 this.stateManager.transform(args);
23745 break;
23746 }
23747 }
23748 };
23749 return EvaluatorPreprocessor;
23750}();
23751
23752/***/ }),
23753/* 28 */
23754/***/ (function(module, exports, __w_pdfjs_require__) {
23755
23756"use strict";
23757
23758
23759Object.defineProperty(exports, "__esModule", {
23760 value: true
23761});
23762exports.CMapFactory = exports.IdentityCMap = exports.CMap = void 0;
23763
23764var _util = __w_pdfjs_require__(2);
23765
23766var _primitives = __w_pdfjs_require__(5);
23767
23768var _parser = __w_pdfjs_require__(11);
23769
23770var _core_utils = __w_pdfjs_require__(8);
23771
23772var _stream = __w_pdfjs_require__(12);
23773
23774var BUILT_IN_CMAPS = ["Adobe-GB1-UCS2", "Adobe-CNS1-UCS2", "Adobe-Japan1-UCS2", "Adobe-Korea1-UCS2", "78-EUC-H", "78-EUC-V", "78-H", "78-RKSJ-H", "78-RKSJ-V", "78-V", "78ms-RKSJ-H", "78ms-RKSJ-V", "83pv-RKSJ-H", "90ms-RKSJ-H", "90ms-RKSJ-V", "90msp-RKSJ-H", "90msp-RKSJ-V", "90pv-RKSJ-H", "90pv-RKSJ-V", "Add-H", "Add-RKSJ-H", "Add-RKSJ-V", "Add-V", "Adobe-CNS1-0", "Adobe-CNS1-1", "Adobe-CNS1-2", "Adobe-CNS1-3", "Adobe-CNS1-4", "Adobe-CNS1-5", "Adobe-CNS1-6", "Adobe-GB1-0", "Adobe-GB1-1", "Adobe-GB1-2", "Adobe-GB1-3", "Adobe-GB1-4", "Adobe-GB1-5", "Adobe-Japan1-0", "Adobe-Japan1-1", "Adobe-Japan1-2", "Adobe-Japan1-3", "Adobe-Japan1-4", "Adobe-Japan1-5", "Adobe-Japan1-6", "Adobe-Korea1-0", "Adobe-Korea1-1", "Adobe-Korea1-2", "B5-H", "B5-V", "B5pc-H", "B5pc-V", "CNS-EUC-H", "CNS-EUC-V", "CNS1-H", "CNS1-V", "CNS2-H", "CNS2-V", "ETHK-B5-H", "ETHK-B5-V", "ETen-B5-H", "ETen-B5-V", "ETenms-B5-H", "ETenms-B5-V", "EUC-H", "EUC-V", "Ext-H", "Ext-RKSJ-H", "Ext-RKSJ-V", "Ext-V", "GB-EUC-H", "GB-EUC-V", "GB-H", "GB-V", "GBK-EUC-H", "GBK-EUC-V", "GBK2K-H", "GBK2K-V", "GBKp-EUC-H", "GBKp-EUC-V", "GBT-EUC-H", "GBT-EUC-V", "GBT-H", "GBT-V", "GBTpc-EUC-H", "GBTpc-EUC-V", "GBpc-EUC-H", "GBpc-EUC-V", "H", "HKdla-B5-H", "HKdla-B5-V", "HKdlb-B5-H", "HKdlb-B5-V", "HKgccs-B5-H", "HKgccs-B5-V", "HKm314-B5-H", "HKm314-B5-V", "HKm471-B5-H", "HKm471-B5-V", "HKscs-B5-H", "HKscs-B5-V", "Hankaku", "Hiragana", "KSC-EUC-H", "KSC-EUC-V", "KSC-H", "KSC-Johab-H", "KSC-Johab-V", "KSC-V", "KSCms-UHC-H", "KSCms-UHC-HW-H", "KSCms-UHC-HW-V", "KSCms-UHC-V", "KSCpc-EUC-H", "KSCpc-EUC-V", "Katakana", "NWP-H", "NWP-V", "RKSJ-H", "RKSJ-V", "Roman", "UniCNS-UCS2-H", "UniCNS-UCS2-V", "UniCNS-UTF16-H", "UniCNS-UTF16-V", "UniCNS-UTF32-H", "UniCNS-UTF32-V", "UniCNS-UTF8-H", "UniCNS-UTF8-V", "UniGB-UCS2-H", "UniGB-UCS2-V", "UniGB-UTF16-H", "UniGB-UTF16-V", "UniGB-UTF32-H", "UniGB-UTF32-V", "UniGB-UTF8-H", "UniGB-UTF8-V", "UniJIS-UCS2-H", "UniJIS-UCS2-HW-H", "UniJIS-UCS2-HW-V", "UniJIS-UCS2-V", "UniJIS-UTF16-H", "UniJIS-UTF16-V", "UniJIS-UTF32-H", "UniJIS-UTF32-V", "UniJIS-UTF8-H", "UniJIS-UTF8-V", "UniJIS2004-UTF16-H", "UniJIS2004-UTF16-V", "UniJIS2004-UTF32-H", "UniJIS2004-UTF32-V", "UniJIS2004-UTF8-H", "UniJIS2004-UTF8-V", "UniJISPro-UCS2-HW-V", "UniJISPro-UCS2-V", "UniJISPro-UTF8-V", "UniJISX0213-UTF32-H", "UniJISX0213-UTF32-V", "UniJISX02132004-UTF32-H", "UniJISX02132004-UTF32-V", "UniKS-UCS2-H", "UniKS-UCS2-V", "UniKS-UTF16-H", "UniKS-UTF16-V", "UniKS-UTF32-H", "UniKS-UTF32-V", "UniKS-UTF8-H", "UniKS-UTF8-V", "V", "WP-Symbol"];
23775const MAX_MAP_RANGE = 2 ** 24 - 1;
23776
23777class CMap {
23778 constructor(builtInCMap = false) {
23779 this.codespaceRanges = [[], [], [], []];
23780 this.numCodespaceRanges = 0;
23781 this._map = [];
23782 this.name = "";
23783 this.vertical = false;
23784 this.useCMap = null;
23785 this.builtInCMap = builtInCMap;
23786 }
23787
23788 addCodespaceRange(n, low, high) {
23789 this.codespaceRanges[n - 1].push(low, high);
23790 this.numCodespaceRanges++;
23791 }
23792
23793 mapCidRange(low, high, dstLow) {
23794 if (high - low > MAX_MAP_RANGE) {
23795 throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
23796 }
23797
23798 while (low <= high) {
23799 this._map[low++] = dstLow++;
23800 }
23801 }
23802
23803 mapBfRange(low, high, dstLow) {
23804 if (high - low > MAX_MAP_RANGE) {
23805 throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
23806 }
23807
23808 var lastByte = dstLow.length - 1;
23809
23810 while (low <= high) {
23811 this._map[low++] = dstLow;
23812 dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
23813 }
23814 }
23815
23816 mapBfRangeToArray(low, high, array) {
23817 if (high - low > MAX_MAP_RANGE) {
23818 throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
23819 }
23820
23821 const ii = array.length;
23822 let i = 0;
23823
23824 while (low <= high && i < ii) {
23825 this._map[low] = array[i++];
23826 ++low;
23827 }
23828 }
23829
23830 mapOne(src, dst) {
23831 this._map[src] = dst;
23832 }
23833
23834 lookup(code) {
23835 return this._map[code];
23836 }
23837
23838 contains(code) {
23839 return this._map[code] !== undefined;
23840 }
23841
23842 forEach(callback) {
23843 const map = this._map;
23844 const length = map.length;
23845
23846 if (length <= 0x10000) {
23847 for (let i = 0; i < length; i++) {
23848 if (map[i] !== undefined) {
23849 callback(i, map[i]);
23850 }
23851 }
23852 } else {
23853 for (const i in map) {
23854 callback(i, map[i]);
23855 }
23856 }
23857 }
23858
23859 charCodeOf(value) {
23860 const map = this._map;
23861
23862 if (map.length <= 0x10000) {
23863 return map.indexOf(value);
23864 }
23865
23866 for (const charCode in map) {
23867 if (map[charCode] === value) {
23868 return charCode | 0;
23869 }
23870 }
23871
23872 return -1;
23873 }
23874
23875 getMap() {
23876 return this._map;
23877 }
23878
23879 readCharCode(str, offset, out) {
23880 let c = 0;
23881 const codespaceRanges = this.codespaceRanges;
23882
23883 for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
23884 c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
23885 const codespaceRange = codespaceRanges[n];
23886
23887 for (let k = 0, kk = codespaceRange.length; k < kk;) {
23888 const low = codespaceRange[k++];
23889 const high = codespaceRange[k++];
23890
23891 if (c >= low && c <= high) {
23892 out.charcode = c;
23893 out.length = n + 1;
23894 return;
23895 }
23896 }
23897 }
23898
23899 out.charcode = 0;
23900 out.length = 1;
23901 }
23902
23903 get length() {
23904 return this._map.length;
23905 }
23906
23907 get isIdentityCMap() {
23908 if (!(this.name === "Identity-H" || this.name === "Identity-V")) {
23909 return false;
23910 }
23911
23912 if (this._map.length !== 0x10000) {
23913 return false;
23914 }
23915
23916 for (let i = 0; i < 0x10000; i++) {
23917 if (this._map[i] !== i) {
23918 return false;
23919 }
23920 }
23921
23922 return true;
23923 }
23924
23925}
23926
23927exports.CMap = CMap;
23928
23929class IdentityCMap extends CMap {
23930 constructor(vertical, n) {
23931 super();
23932 this.vertical = vertical;
23933 this.addCodespaceRange(n, 0, 0xffff);
23934 }
23935
23936 mapCidRange(low, high, dstLow) {
23937 (0, _util.unreachable)("should not call mapCidRange");
23938 }
23939
23940 mapBfRange(low, high, dstLow) {
23941 (0, _util.unreachable)("should not call mapBfRange");
23942 }
23943
23944 mapBfRangeToArray(low, high, array) {
23945 (0, _util.unreachable)("should not call mapBfRangeToArray");
23946 }
23947
23948 mapOne(src, dst) {
23949 (0, _util.unreachable)("should not call mapCidOne");
23950 }
23951
23952 lookup(code) {
23953 return Number.isInteger(code) && code <= 0xffff ? code : undefined;
23954 }
23955
23956 contains(code) {
23957 return Number.isInteger(code) && code <= 0xffff;
23958 }
23959
23960 forEach(callback) {
23961 for (let i = 0; i <= 0xffff; i++) {
23962 callback(i, i);
23963 }
23964 }
23965
23966 charCodeOf(value) {
23967 return Number.isInteger(value) && value <= 0xffff ? value : -1;
23968 }
23969
23970 getMap() {
23971 const map = new Array(0x10000);
23972
23973 for (let i = 0; i <= 0xffff; i++) {
23974 map[i] = i;
23975 }
23976
23977 return map;
23978 }
23979
23980 get length() {
23981 return 0x10000;
23982 }
23983
23984 get isIdentityCMap() {
23985 (0, _util.unreachable)("should not access .isIdentityCMap");
23986 }
23987
23988}
23989
23990exports.IdentityCMap = IdentityCMap;
23991
23992var BinaryCMapReader = function BinaryCMapReaderClosure() {
23993 function hexToInt(a, size) {
23994 var n = 0;
23995
23996 for (var i = 0; i <= size; i++) {
23997 n = n << 8 | a[i];
23998 }
23999
24000 return n >>> 0;
24001 }
24002
24003 function hexToStr(a, size) {
24004 if (size === 1) {
24005 return String.fromCharCode(a[0], a[1]);
24006 }
24007
24008 if (size === 3) {
24009 return String.fromCharCode(a[0], a[1], a[2], a[3]);
24010 }
24011
24012 return String.fromCharCode.apply(null, a.subarray(0, size + 1));
24013 }
24014
24015 function addHex(a, b, size) {
24016 var c = 0;
24017
24018 for (var i = size; i >= 0; i--) {
24019 c += a[i] + b[i];
24020 a[i] = c & 255;
24021 c >>= 8;
24022 }
24023 }
24024
24025 function incHex(a, size) {
24026 var c = 1;
24027
24028 for (var i = size; i >= 0 && c > 0; i--) {
24029 c += a[i];
24030 a[i] = c & 255;
24031 c >>= 8;
24032 }
24033 }
24034
24035 var MAX_NUM_SIZE = 16;
24036 var MAX_ENCODED_NUM_SIZE = 19;
24037
24038 function BinaryCMapStream(data) {
24039 this.buffer = data;
24040 this.pos = 0;
24041 this.end = data.length;
24042 this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
24043 }
24044
24045 BinaryCMapStream.prototype = {
24046 readByte() {
24047 if (this.pos >= this.end) {
24048 return -1;
24049 }
24050
24051 return this.buffer[this.pos++];
24052 },
24053
24054 readNumber() {
24055 var n = 0;
24056 var last;
24057
24058 do {
24059 var b = this.readByte();
24060
24061 if (b < 0) {
24062 throw new _util.FormatError("unexpected EOF in bcmap");
24063 }
24064
24065 last = !(b & 0x80);
24066 n = n << 7 | b & 0x7f;
24067 } while (!last);
24068
24069 return n;
24070 },
24071
24072 readSigned() {
24073 var n = this.readNumber();
24074 return n & 1 ? ~(n >>> 1) : n >>> 1;
24075 },
24076
24077 readHex(num, size) {
24078 num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
24079 this.pos += size + 1;
24080 },
24081
24082 readHexNumber(num, size) {
24083 var last;
24084 var stack = this.tmpBuf,
24085 sp = 0;
24086
24087 do {
24088 var b = this.readByte();
24089
24090 if (b < 0) {
24091 throw new _util.FormatError("unexpected EOF in bcmap");
24092 }
24093
24094 last = !(b & 0x80);
24095 stack[sp++] = b & 0x7f;
24096 } while (!last);
24097
24098 var i = size,
24099 buffer = 0,
24100 bufferSize = 0;
24101
24102 while (i >= 0) {
24103 while (bufferSize < 8 && stack.length > 0) {
24104 buffer = stack[--sp] << bufferSize | buffer;
24105 bufferSize += 7;
24106 }
24107
24108 num[i] = buffer & 255;
24109 i--;
24110 buffer >>= 8;
24111 bufferSize -= 8;
24112 }
24113 },
24114
24115 readHexSigned(num, size) {
24116 this.readHexNumber(num, size);
24117 var sign = num[size] & 1 ? 255 : 0;
24118 var c = 0;
24119
24120 for (var i = 0; i <= size; i++) {
24121 c = (c & 1) << 8 | num[i];
24122 num[i] = c >> 1 ^ sign;
24123 }
24124 },
24125
24126 readString() {
24127 var len = this.readNumber();
24128 var s = "";
24129
24130 for (var i = 0; i < len; i++) {
24131 s += String.fromCharCode(this.readNumber());
24132 }
24133
24134 return s;
24135 }
24136
24137 };
24138
24139 function processBinaryCMap(data, cMap, extend) {
24140 return new Promise(function (resolve, reject) {
24141 var stream = new BinaryCMapStream(data);
24142 var header = stream.readByte();
24143 cMap.vertical = !!(header & 1);
24144 var useCMap = null;
24145 var start = new Uint8Array(MAX_NUM_SIZE);
24146 var end = new Uint8Array(MAX_NUM_SIZE);
24147 var char = new Uint8Array(MAX_NUM_SIZE);
24148 var charCode = new Uint8Array(MAX_NUM_SIZE);
24149 var tmp = new Uint8Array(MAX_NUM_SIZE);
24150 var code;
24151 var b;
24152
24153 while ((b = stream.readByte()) >= 0) {
24154 var type = b >> 5;
24155
24156 if (type === 7) {
24157 switch (b & 0x1f) {
24158 case 0:
24159 stream.readString();
24160 break;
24161
24162 case 1:
24163 useCMap = stream.readString();
24164 break;
24165 }
24166
24167 continue;
24168 }
24169
24170 var sequence = !!(b & 0x10);
24171 var dataSize = b & 15;
24172
24173 if (dataSize + 1 > MAX_NUM_SIZE) {
24174 throw new Error("processBinaryCMap: Invalid dataSize.");
24175 }
24176
24177 var ucs2DataSize = 1;
24178 var subitemsCount = stream.readNumber();
24179 var i;
24180
24181 switch (type) {
24182 case 0:
24183 stream.readHex(start, dataSize);
24184 stream.readHexNumber(end, dataSize);
24185 addHex(end, start, dataSize);
24186 cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
24187
24188 for (i = 1; i < subitemsCount; i++) {
24189 incHex(end, dataSize);
24190 stream.readHexNumber(start, dataSize);
24191 addHex(start, end, dataSize);
24192 stream.readHexNumber(end, dataSize);
24193 addHex(end, start, dataSize);
24194 cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
24195 }
24196
24197 break;
24198
24199 case 1:
24200 stream.readHex(start, dataSize);
24201 stream.readHexNumber(end, dataSize);
24202 addHex(end, start, dataSize);
24203 stream.readNumber();
24204
24205 for (i = 1; i < subitemsCount; i++) {
24206 incHex(end, dataSize);
24207 stream.readHexNumber(start, dataSize);
24208 addHex(start, end, dataSize);
24209 stream.readHexNumber(end, dataSize);
24210 addHex(end, start, dataSize);
24211 stream.readNumber();
24212 }
24213
24214 break;
24215
24216 case 2:
24217 stream.readHex(char, dataSize);
24218 code = stream.readNumber();
24219 cMap.mapOne(hexToInt(char, dataSize), code);
24220
24221 for (i = 1; i < subitemsCount; i++) {
24222 incHex(char, dataSize);
24223
24224 if (!sequence) {
24225 stream.readHexNumber(tmp, dataSize);
24226 addHex(char, tmp, dataSize);
24227 }
24228
24229 code = stream.readSigned() + (code + 1);
24230 cMap.mapOne(hexToInt(char, dataSize), code);
24231 }
24232
24233 break;
24234
24235 case 3:
24236 stream.readHex(start, dataSize);
24237 stream.readHexNumber(end, dataSize);
24238 addHex(end, start, dataSize);
24239 code = stream.readNumber();
24240 cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
24241
24242 for (i = 1; i < subitemsCount; i++) {
24243 incHex(end, dataSize);
24244
24245 if (!sequence) {
24246 stream.readHexNumber(start, dataSize);
24247 addHex(start, end, dataSize);
24248 } else {
24249 start.set(end);
24250 }
24251
24252 stream.readHexNumber(end, dataSize);
24253 addHex(end, start, dataSize);
24254 code = stream.readNumber();
24255 cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
24256 }
24257
24258 break;
24259
24260 case 4:
24261 stream.readHex(char, ucs2DataSize);
24262 stream.readHex(charCode, dataSize);
24263 cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
24264
24265 for (i = 1; i < subitemsCount; i++) {
24266 incHex(char, ucs2DataSize);
24267
24268 if (!sequence) {
24269 stream.readHexNumber(tmp, ucs2DataSize);
24270 addHex(char, tmp, ucs2DataSize);
24271 }
24272
24273 incHex(charCode, dataSize);
24274 stream.readHexSigned(tmp, dataSize);
24275 addHex(charCode, tmp, dataSize);
24276 cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
24277 }
24278
24279 break;
24280
24281 case 5:
24282 stream.readHex(start, ucs2DataSize);
24283 stream.readHexNumber(end, ucs2DataSize);
24284 addHex(end, start, ucs2DataSize);
24285 stream.readHex(charCode, dataSize);
24286 cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
24287
24288 for (i = 1; i < subitemsCount; i++) {
24289 incHex(end, ucs2DataSize);
24290
24291 if (!sequence) {
24292 stream.readHexNumber(start, ucs2DataSize);
24293 addHex(start, end, ucs2DataSize);
24294 } else {
24295 start.set(end);
24296 }
24297
24298 stream.readHexNumber(end, ucs2DataSize);
24299 addHex(end, start, ucs2DataSize);
24300 stream.readHex(charCode, dataSize);
24301 cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
24302 }
24303
24304 break;
24305
24306 default:
24307 reject(new Error("processBinaryCMap: Unknown type: " + type));
24308 return;
24309 }
24310 }
24311
24312 if (useCMap) {
24313 resolve(extend(useCMap));
24314 return;
24315 }
24316
24317 resolve(cMap);
24318 });
24319 }
24320
24321 function BinaryCMapReader() {}
24322
24323 BinaryCMapReader.prototype = {
24324 process: processBinaryCMap
24325 };
24326 return BinaryCMapReader;
24327}();
24328
24329var CMapFactory = function CMapFactoryClosure() {
24330 function strToInt(str) {
24331 var a = 0;
24332
24333 for (var i = 0; i < str.length; i++) {
24334 a = a << 8 | str.charCodeAt(i);
24335 }
24336
24337 return a >>> 0;
24338 }
24339
24340 function expectString(obj) {
24341 if (!(0, _util.isString)(obj)) {
24342 throw new _util.FormatError("Malformed CMap: expected string.");
24343 }
24344 }
24345
24346 function expectInt(obj) {
24347 if (!Number.isInteger(obj)) {
24348 throw new _util.FormatError("Malformed CMap: expected int.");
24349 }
24350 }
24351
24352 function parseBfChar(cMap, lexer) {
24353 while (true) {
24354 var obj = lexer.getObj();
24355
24356 if ((0, _primitives.isEOF)(obj)) {
24357 break;
24358 }
24359
24360 if ((0, _primitives.isCmd)(obj, "endbfchar")) {
24361 return;
24362 }
24363
24364 expectString(obj);
24365 var src = strToInt(obj);
24366 obj = lexer.getObj();
24367 expectString(obj);
24368 var dst = obj;
24369 cMap.mapOne(src, dst);
24370 }
24371 }
24372
24373 function parseBfRange(cMap, lexer) {
24374 while (true) {
24375 var obj = lexer.getObj();
24376
24377 if ((0, _primitives.isEOF)(obj)) {
24378 break;
24379 }
24380
24381 if ((0, _primitives.isCmd)(obj, "endbfrange")) {
24382 return;
24383 }
24384
24385 expectString(obj);
24386 var low = strToInt(obj);
24387 obj = lexer.getObj();
24388 expectString(obj);
24389 var high = strToInt(obj);
24390 obj = lexer.getObj();
24391
24392 if (Number.isInteger(obj) || (0, _util.isString)(obj)) {
24393 var dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
24394 cMap.mapBfRange(low, high, dstLow);
24395 } else if ((0, _primitives.isCmd)(obj, "[")) {
24396 obj = lexer.getObj();
24397 var array = [];
24398
24399 while (!(0, _primitives.isCmd)(obj, "]") && !(0, _primitives.isEOF)(obj)) {
24400 array.push(obj);
24401 obj = lexer.getObj();
24402 }
24403
24404 cMap.mapBfRangeToArray(low, high, array);
24405 } else {
24406 break;
24407 }
24408 }
24409
24410 throw new _util.FormatError("Invalid bf range.");
24411 }
24412
24413 function parseCidChar(cMap, lexer) {
24414 while (true) {
24415 var obj = lexer.getObj();
24416
24417 if ((0, _primitives.isEOF)(obj)) {
24418 break;
24419 }
24420
24421 if ((0, _primitives.isCmd)(obj, "endcidchar")) {
24422 return;
24423 }
24424
24425 expectString(obj);
24426 var src = strToInt(obj);
24427 obj = lexer.getObj();
24428 expectInt(obj);
24429 var dst = obj;
24430 cMap.mapOne(src, dst);
24431 }
24432 }
24433
24434 function parseCidRange(cMap, lexer) {
24435 while (true) {
24436 var obj = lexer.getObj();
24437
24438 if ((0, _primitives.isEOF)(obj)) {
24439 break;
24440 }
24441
24442 if ((0, _primitives.isCmd)(obj, "endcidrange")) {
24443 return;
24444 }
24445
24446 expectString(obj);
24447 var low = strToInt(obj);
24448 obj = lexer.getObj();
24449 expectString(obj);
24450 var high = strToInt(obj);
24451 obj = lexer.getObj();
24452 expectInt(obj);
24453 var dstLow = obj;
24454 cMap.mapCidRange(low, high, dstLow);
24455 }
24456 }
24457
24458 function parseCodespaceRange(cMap, lexer) {
24459 while (true) {
24460 var obj = lexer.getObj();
24461
24462 if ((0, _primitives.isEOF)(obj)) {
24463 break;
24464 }
24465
24466 if ((0, _primitives.isCmd)(obj, "endcodespacerange")) {
24467 return;
24468 }
24469
24470 if (!(0, _util.isString)(obj)) {
24471 break;
24472 }
24473
24474 var low = strToInt(obj);
24475 obj = lexer.getObj();
24476
24477 if (!(0, _util.isString)(obj)) {
24478 break;
24479 }
24480
24481 var high = strToInt(obj);
24482 cMap.addCodespaceRange(obj.length, low, high);
24483 }
24484
24485 throw new _util.FormatError("Invalid codespace range.");
24486 }
24487
24488 function parseWMode(cMap, lexer) {
24489 var obj = lexer.getObj();
24490
24491 if (Number.isInteger(obj)) {
24492 cMap.vertical = !!obj;
24493 }
24494 }
24495
24496 function parseCMapName(cMap, lexer) {
24497 var obj = lexer.getObj();
24498
24499 if ((0, _primitives.isName)(obj) && (0, _util.isString)(obj.name)) {
24500 cMap.name = obj.name;
24501 }
24502 }
24503
24504 function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
24505 var previous;
24506 var embeddedUseCMap;
24507
24508 objLoop: while (true) {
24509 try {
24510 var obj = lexer.getObj();
24511
24512 if ((0, _primitives.isEOF)(obj)) {
24513 break;
24514 } else if ((0, _primitives.isName)(obj)) {
24515 if (obj.name === "WMode") {
24516 parseWMode(cMap, lexer);
24517 } else if (obj.name === "CMapName") {
24518 parseCMapName(cMap, lexer);
24519 }
24520
24521 previous = obj;
24522 } else if ((0, _primitives.isCmd)(obj)) {
24523 switch (obj.cmd) {
24524 case "endcmap":
24525 break objLoop;
24526
24527 case "usecmap":
24528 if ((0, _primitives.isName)(previous)) {
24529 embeddedUseCMap = previous.name;
24530 }
24531
24532 break;
24533
24534 case "begincodespacerange":
24535 parseCodespaceRange(cMap, lexer);
24536 break;
24537
24538 case "beginbfchar":
24539 parseBfChar(cMap, lexer);
24540 break;
24541
24542 case "begincidchar":
24543 parseCidChar(cMap, lexer);
24544 break;
24545
24546 case "beginbfrange":
24547 parseBfRange(cMap, lexer);
24548 break;
24549
24550 case "begincidrange":
24551 parseCidRange(cMap, lexer);
24552 break;
24553 }
24554 }
24555 } catch (ex) {
24556 if (ex instanceof _core_utils.MissingDataException) {
24557 throw ex;
24558 }
24559
24560 (0, _util.warn)("Invalid cMap data: " + ex);
24561 continue;
24562 }
24563 }
24564
24565 if (!useCMap && embeddedUseCMap) {
24566 useCMap = embeddedUseCMap;
24567 }
24568
24569 if (useCMap) {
24570 return extendCMap(cMap, fetchBuiltInCMap, useCMap);
24571 }
24572
24573 return Promise.resolve(cMap);
24574 }
24575
24576 function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
24577 return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
24578 cMap.useCMap = newCMap;
24579
24580 if (cMap.numCodespaceRanges === 0) {
24581 var useCodespaceRanges = cMap.useCMap.codespaceRanges;
24582
24583 for (var i = 0; i < useCodespaceRanges.length; i++) {
24584 cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
24585 }
24586
24587 cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
24588 }
24589
24590 cMap.useCMap.forEach(function (key, value) {
24591 if (!cMap.contains(key)) {
24592 cMap.mapOne(key, cMap.useCMap.lookup(key));
24593 }
24594 });
24595 return cMap;
24596 });
24597 }
24598
24599 function createBuiltInCMap(name, fetchBuiltInCMap) {
24600 if (name === "Identity-H") {
24601 return Promise.resolve(new IdentityCMap(false, 2));
24602 } else if (name === "Identity-V") {
24603 return Promise.resolve(new IdentityCMap(true, 2));
24604 }
24605
24606 if (!BUILT_IN_CMAPS.includes(name)) {
24607 return Promise.reject(new Error("Unknown CMap name: " + name));
24608 }
24609
24610 if (!fetchBuiltInCMap) {
24611 return Promise.reject(new Error("Built-in CMap parameters are not provided."));
24612 }
24613
24614 return fetchBuiltInCMap(name).then(function (data) {
24615 var cMapData = data.cMapData,
24616 compressionType = data.compressionType;
24617 var cMap = new CMap(true);
24618
24619 if (compressionType === _util.CMapCompressionType.BINARY) {
24620 return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
24621 return extendCMap(cMap, fetchBuiltInCMap, useCMap);
24622 });
24623 }
24624
24625 if (compressionType === _util.CMapCompressionType.NONE) {
24626 var lexer = new _parser.Lexer(new _stream.Stream(cMapData));
24627 return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
24628 }
24629
24630 return Promise.reject(new Error("TODO: Only BINARY/NONE CMap compression is currently supported."));
24631 });
24632 }
24633
24634 return {
24635 async create(params) {
24636 var encoding = params.encoding;
24637 var fetchBuiltInCMap = params.fetchBuiltInCMap;
24638 var useCMap = params.useCMap;
24639
24640 if ((0, _primitives.isName)(encoding)) {
24641 return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
24642 } else if ((0, _primitives.isStream)(encoding)) {
24643 var cMap = new CMap();
24644 var lexer = new _parser.Lexer(encoding);
24645 return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
24646 if (parsedCMap.isIdentityCMap) {
24647 return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
24648 }
24649
24650 return parsedCMap;
24651 });
24652 }
24653
24654 throw new Error("Encoding required.");
24655 }
24656
24657 };
24658}();
24659
24660exports.CMapFactory = CMapFactory;
24661
24662/***/ }),
24663/* 29 */
24664/***/ (function(module, exports, __w_pdfjs_require__) {
24665
24666"use strict";
24667
24668
24669Object.defineProperty(exports, "__esModule", {
24670 value: true
24671});
24672exports.getFontType = getFontType;
24673exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.SEAC_ANALYSIS_ENABLED = void 0;
24674
24675var _util = __w_pdfjs_require__(2);
24676
24677var _cff_parser = __w_pdfjs_require__(30);
24678
24679var _glyphlist = __w_pdfjs_require__(33);
24680
24681var _encodings = __w_pdfjs_require__(32);
24682
24683var _standard_fonts = __w_pdfjs_require__(34);
24684
24685var _unicode = __w_pdfjs_require__(35);
24686
24687var _core_utils = __w_pdfjs_require__(8);
24688
24689var _font_renderer = __w_pdfjs_require__(36);
24690
24691var _cmap = __w_pdfjs_require__(28);
24692
24693var _stream = __w_pdfjs_require__(12);
24694
24695var _type1_parser = __w_pdfjs_require__(37);
24696
24697const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
24698var PDF_GLYPH_SPACE_UNITS = 1000;
24699var SEAC_ANALYSIS_ENABLED = true;
24700exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
24701const EXPORT_DATA_PROPERTIES = ["ascent", "bbox", "black", "bold", "charProcOperatorList", "composite", "data", "defaultVMetrics", "defaultWidth", "descent", "fallbackName", "fontMatrix", "fontType", "isMonospace", "isSerifFont", "isType3Font", "italic", "loadedName", "mimetype", "missingFile", "name", "remeasure", "subtype", "type", "vertical"];
24702const EXPORT_DATA_EXTRA_PROPERTIES = ["cMap", "defaultEncoding", "differences", "isSymbolicFont", "seacMap", "toFontChar", "toUnicode", "vmetrics", "widths"];
24703var FontFlags = {
24704 FixedPitch: 1,
24705 Serif: 2,
24706 Symbolic: 4,
24707 Script: 8,
24708 Nonsymbolic: 32,
24709 Italic: 64,
24710 AllCap: 65536,
24711 SmallCap: 131072,
24712 ForceBold: 262144
24713};
24714exports.FontFlags = FontFlags;
24715var MacStandardGlyphOrdering = [".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat"];
24716
24717function adjustWidths(properties) {
24718 if (!properties.fontMatrix) {
24719 return;
24720 }
24721
24722 if (properties.fontMatrix[0] === _util.FONT_IDENTITY_MATRIX[0]) {
24723 return;
24724 }
24725
24726 var scale = 0.001 / properties.fontMatrix[0];
24727 var glyphsWidths = properties.widths;
24728
24729 for (var glyph in glyphsWidths) {
24730 glyphsWidths[glyph] *= scale;
24731 }
24732
24733 properties.defaultWidth *= scale;
24734}
24735
24736function adjustToUnicode(properties, builtInEncoding) {
24737 if (properties.hasIncludedToUnicodeMap) {
24738 return;
24739 }
24740
24741 if (properties.hasEncoding) {
24742 return;
24743 }
24744
24745 if (builtInEncoding === properties.defaultEncoding) {
24746 return;
24747 }
24748
24749 if (properties.toUnicode instanceof IdentityToUnicodeMap) {
24750 return;
24751 }
24752
24753 var toUnicode = [],
24754 glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
24755
24756 for (var charCode in builtInEncoding) {
24757 var glyphName = builtInEncoding[charCode];
24758 var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
24759
24760 if (unicode !== -1) {
24761 toUnicode[charCode] = String.fromCharCode(unicode);
24762 }
24763 }
24764
24765 properties.toUnicode.amend(toUnicode);
24766}
24767
24768function getFontType(type, subtype) {
24769 switch (type) {
24770 case "Type1":
24771 return subtype === "Type1C" ? _util.FontType.TYPE1C : _util.FontType.TYPE1;
24772
24773 case "CIDFontType0":
24774 return subtype === "CIDFontType0C" ? _util.FontType.CIDFONTTYPE0C : _util.FontType.CIDFONTTYPE0;
24775
24776 case "OpenType":
24777 return _util.FontType.OPENTYPE;
24778
24779 case "TrueType":
24780 return _util.FontType.TRUETYPE;
24781
24782 case "CIDFontType2":
24783 return _util.FontType.CIDFONTTYPE2;
24784
24785 case "MMType1":
24786 return _util.FontType.MMTYPE1;
24787
24788 case "Type0":
24789 return _util.FontType.TYPE0;
24790
24791 default:
24792 return _util.FontType.UNKNOWN;
24793 }
24794}
24795
24796function recoverGlyphName(name, glyphsUnicodeMap) {
24797 if (glyphsUnicodeMap[name] !== undefined) {
24798 return name;
24799 }
24800
24801 var unicode = (0, _unicode.getUnicodeForGlyph)(name, glyphsUnicodeMap);
24802
24803 if (unicode !== -1) {
24804 for (var key in glyphsUnicodeMap) {
24805 if (glyphsUnicodeMap[key] === unicode) {
24806 return key;
24807 }
24808 }
24809 }
24810
24811 (0, _util.info)("Unable to recover a standard glyph name for: " + name);
24812 return name;
24813}
24814
24815var Glyph = function GlyphClosure() {
24816 function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
24817 this.fontChar = fontChar;
24818 this.unicode = unicode;
24819 this.accent = accent;
24820 this.width = width;
24821 this.vmetric = vmetric;
24822 this.operatorListId = operatorListId;
24823 this.isSpace = isSpace;
24824 this.isInFont = isInFont;
24825 }
24826
24827 Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
24828 return this.fontChar === fontChar && this.unicode === unicode && this.accent === accent && this.width === width && this.vmetric === vmetric && this.operatorListId === operatorListId && this.isSpace === isSpace && this.isInFont === isInFont;
24829 };
24830
24831 return Glyph;
24832}();
24833
24834var ToUnicodeMap = function ToUnicodeMapClosure() {
24835 function ToUnicodeMap(cmap = []) {
24836 this._map = cmap;
24837 }
24838
24839 ToUnicodeMap.prototype = {
24840 get length() {
24841 return this._map.length;
24842 },
24843
24844 forEach(callback) {
24845 for (var charCode in this._map) {
24846 callback(charCode, this._map[charCode].charCodeAt(0));
24847 }
24848 },
24849
24850 has(i) {
24851 return this._map[i] !== undefined;
24852 },
24853
24854 get(i) {
24855 return this._map[i];
24856 },
24857
24858 charCodeOf(value) {
24859 const map = this._map;
24860
24861 if (map.length <= 0x10000) {
24862 return map.indexOf(value);
24863 }
24864
24865 for (const charCode in map) {
24866 if (map[charCode] === value) {
24867 return charCode | 0;
24868 }
24869 }
24870
24871 return -1;
24872 },
24873
24874 amend(map) {
24875 for (var charCode in map) {
24876 this._map[charCode] = map[charCode];
24877 }
24878 }
24879
24880 };
24881 return ToUnicodeMap;
24882}();
24883
24884exports.ToUnicodeMap = ToUnicodeMap;
24885
24886var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
24887 function IdentityToUnicodeMap(firstChar, lastChar) {
24888 this.firstChar = firstChar;
24889 this.lastChar = lastChar;
24890 }
24891
24892 IdentityToUnicodeMap.prototype = {
24893 get length() {
24894 return this.lastChar + 1 - this.firstChar;
24895 },
24896
24897 forEach(callback) {
24898 for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
24899 callback(i, i);
24900 }
24901 },
24902
24903 has(i) {
24904 return this.firstChar <= i && i <= this.lastChar;
24905 },
24906
24907 get(i) {
24908 if (this.firstChar <= i && i <= this.lastChar) {
24909 return String.fromCharCode(i);
24910 }
24911
24912 return undefined;
24913 },
24914
24915 charCodeOf(v) {
24916 return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
24917 },
24918
24919 amend(map) {
24920 (0, _util.unreachable)("Should not call amend()");
24921 }
24922
24923 };
24924 return IdentityToUnicodeMap;
24925}();
24926
24927exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
24928
24929var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
24930 function writeInt16(dest, offset, num) {
24931 dest[offset] = num >> 8 & 0xff;
24932 dest[offset + 1] = num & 0xff;
24933 }
24934
24935 function writeInt32(dest, offset, num) {
24936 dest[offset] = num >> 24 & 0xff;
24937 dest[offset + 1] = num >> 16 & 0xff;
24938 dest[offset + 2] = num >> 8 & 0xff;
24939 dest[offset + 3] = num & 0xff;
24940 }
24941
24942 function writeData(dest, offset, data) {
24943 var i, ii;
24944
24945 if (data instanceof Uint8Array) {
24946 dest.set(data, offset);
24947 } else if (typeof data === "string") {
24948 for (i = 0, ii = data.length; i < ii; i++) {
24949 dest[offset++] = data.charCodeAt(i) & 0xff;
24950 }
24951 } else {
24952 for (i = 0, ii = data.length; i < ii; i++) {
24953 dest[offset++] = data[i] & 0xff;
24954 }
24955 }
24956 }
24957
24958 function OpenTypeFileBuilder(sfnt) {
24959 this.sfnt = sfnt;
24960 this.tables = Object.create(null);
24961 }
24962
24963 OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
24964 var maxPower2 = 1,
24965 log2 = 0;
24966
24967 while ((maxPower2 ^ entriesCount) > maxPower2) {
24968 maxPower2 <<= 1;
24969 log2++;
24970 }
24971
24972 var searchRange = maxPower2 * entrySize;
24973 return {
24974 range: searchRange,
24975 entry: log2,
24976 rangeShift: entrySize * entriesCount - searchRange
24977 };
24978 };
24979
24980 var OTF_HEADER_SIZE = 12;
24981 var OTF_TABLE_ENTRY_SIZE = 16;
24982 OpenTypeFileBuilder.prototype = {
24983 toArray: function OpenTypeFileBuilder_toArray() {
24984 var sfnt = this.sfnt;
24985 var tables = this.tables;
24986 var tablesNames = Object.keys(tables);
24987 tablesNames.sort();
24988 var numTables = tablesNames.length;
24989 var i, j, jj, table, tableName;
24990 var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
24991 var tableOffsets = [offset];
24992
24993 for (i = 0; i < numTables; i++) {
24994 table = tables[tablesNames[i]];
24995 var paddedLength = (table.length + 3 & ~3) >>> 0;
24996 offset += paddedLength;
24997 tableOffsets.push(offset);
24998 }
24999
25000 var file = new Uint8Array(offset);
25001
25002 for (i = 0; i < numTables; i++) {
25003 table = tables[tablesNames[i]];
25004 writeData(file, tableOffsets[i], table);
25005 }
25006
25007 if (sfnt === "true") {
25008 sfnt = (0, _util.string32)(0x00010000);
25009 }
25010
25011 file[0] = sfnt.charCodeAt(0) & 0xff;
25012 file[1] = sfnt.charCodeAt(1) & 0xff;
25013 file[2] = sfnt.charCodeAt(2) & 0xff;
25014 file[3] = sfnt.charCodeAt(3) & 0xff;
25015 writeInt16(file, 4, numTables);
25016 var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
25017 writeInt16(file, 6, searchParams.range);
25018 writeInt16(file, 8, searchParams.entry);
25019 writeInt16(file, 10, searchParams.rangeShift);
25020 offset = OTF_HEADER_SIZE;
25021
25022 for (i = 0; i < numTables; i++) {
25023 tableName = tablesNames[i];
25024 file[offset] = tableName.charCodeAt(0) & 0xff;
25025 file[offset + 1] = tableName.charCodeAt(1) & 0xff;
25026 file[offset + 2] = tableName.charCodeAt(2) & 0xff;
25027 file[offset + 3] = tableName.charCodeAt(3) & 0xff;
25028 var checksum = 0;
25029
25030 for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
25031 var quad = (0, _core_utils.readUint32)(file, j);
25032 checksum = checksum + quad >>> 0;
25033 }
25034
25035 writeInt32(file, offset + 4, checksum);
25036 writeInt32(file, offset + 8, tableOffsets[i]);
25037 writeInt32(file, offset + 12, tables[tableName].length);
25038 offset += OTF_TABLE_ENTRY_SIZE;
25039 }
25040
25041 return file;
25042 },
25043 addTable: function OpenTypeFileBuilder_addTable(tag, data) {
25044 if (tag in this.tables) {
25045 throw new Error("Table " + tag + " already exists");
25046 }
25047
25048 this.tables[tag] = data;
25049 }
25050 };
25051 return OpenTypeFileBuilder;
25052}();
25053
25054var Font = function FontClosure() {
25055 function Font(name, file, properties) {
25056 var charCode;
25057 this.name = name;
25058 this.loadedName = properties.loadedName;
25059 this.isType3Font = properties.isType3Font;
25060 this.missingFile = false;
25061 this.glyphCache = Object.create(null);
25062 this.isSerifFont = !!(properties.flags & FontFlags.Serif);
25063 this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
25064 this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
25065 var type = properties.type;
25066 var subtype = properties.subtype;
25067 this.type = type;
25068 this.subtype = subtype;
25069 let fallbackName = "sans-serif";
25070
25071 if (this.isMonospace) {
25072 fallbackName = "monospace";
25073 } else if (this.isSerifFont) {
25074 fallbackName = "serif";
25075 }
25076
25077 this.fallbackName = fallbackName;
25078 this.differences = properties.differences;
25079 this.widths = properties.widths;
25080 this.defaultWidth = properties.defaultWidth;
25081 this.composite = properties.composite;
25082 this.cMap = properties.cMap;
25083 this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
25084 this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
25085 this.fontMatrix = properties.fontMatrix;
25086 this.bbox = properties.bbox;
25087 this.defaultEncoding = properties.defaultEncoding;
25088 this.toUnicode = properties.toUnicode;
25089 this.fallbackToUnicode = properties.fallbackToUnicode || new ToUnicodeMap();
25090 this.toFontChar = [];
25091
25092 if (properties.type === "Type3") {
25093 for (charCode = 0; charCode < 256; charCode++) {
25094 this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
25095 }
25096
25097 this.fontType = _util.FontType.TYPE3;
25098 return;
25099 }
25100
25101 this.cidEncoding = properties.cidEncoding;
25102 this.vertical = !!properties.vertical;
25103
25104 if (this.vertical) {
25105 this.vmetrics = properties.vmetrics;
25106 this.defaultVMetrics = properties.defaultVMetrics;
25107 }
25108
25109 if (!file || file.isEmpty) {
25110 if (file) {
25111 (0, _util.warn)('Font file is empty in "' + name + '" (' + this.loadedName + ")");
25112 }
25113
25114 this.fallbackToSystemFont();
25115 return;
25116 }
25117
25118 [type, subtype] = getFontFileType(file, properties);
25119
25120 if (type !== this.type || subtype !== this.subtype) {
25121 (0, _util.info)("Inconsistent font file Type/SubType, expected: " + `${this.type}/${this.subtype} but found: ${type}/${subtype}.`);
25122 }
25123
25124 try {
25125 var data;
25126
25127 switch (type) {
25128 case "MMType1":
25129 (0, _util.info)("MMType1 font (" + name + "), falling back to Type1.");
25130
25131 case "Type1":
25132 case "CIDFontType0":
25133 this.mimetype = "font/opentype";
25134 var cff = subtype === "Type1C" || subtype === "CIDFontType0C" ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
25135 adjustWidths(properties);
25136 data = this.convert(name, cff, properties);
25137 break;
25138
25139 case "OpenType":
25140 case "TrueType":
25141 case "CIDFontType2":
25142 this.mimetype = "font/opentype";
25143 data = this.checkAndRepair(name, file, properties);
25144
25145 if (this.isOpenType) {
25146 adjustWidths(properties);
25147 type = "OpenType";
25148 }
25149
25150 break;
25151
25152 default:
25153 throw new _util.FormatError(`Font ${type} is not supported`);
25154 }
25155 } catch (e) {
25156 (0, _util.warn)(e);
25157 this.fallbackToSystemFont();
25158 return;
25159 }
25160
25161 this.data = data;
25162 this.fontType = getFontType(type, subtype);
25163 this.fontMatrix = properties.fontMatrix;
25164 this.widths = properties.widths;
25165 this.defaultWidth = properties.defaultWidth;
25166 this.toUnicode = properties.toUnicode;
25167 this.seacMap = properties.seacMap;
25168 }
25169
25170 Font.getFontID = function () {
25171 var ID = 1;
25172 return function Font_getFontID() {
25173 return String(ID++);
25174 };
25175 }();
25176
25177 function int16(b0, b1) {
25178 return (b0 << 8) + b1;
25179 }
25180
25181 function writeSignedInt16(bytes, index, value) {
25182 bytes[index + 1] = value;
25183 bytes[index] = value >>> 8;
25184 }
25185
25186 function signedInt16(b0, b1) {
25187 var value = (b0 << 8) + b1;
25188 return value & 1 << 15 ? value - 0x10000 : value;
25189 }
25190
25191 function int32(b0, b1, b2, b3) {
25192 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
25193 }
25194
25195 function string16(value) {
25196 return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
25197 }
25198
25199 function safeString16(value) {
25200 if (value > 0x7fff) {
25201 value = 0x7fff;
25202 } else if (value < -0x8000) {
25203 value = -0x8000;
25204 }
25205
25206 return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
25207 }
25208
25209 function isTrueTypeFile(file) {
25210 var header = file.peekBytes(4);
25211 return (0, _core_utils.readUint32)(header, 0) === 0x00010000 || (0, _util.bytesToString)(header) === "true";
25212 }
25213
25214 function isTrueTypeCollectionFile(file) {
25215 const header = file.peekBytes(4);
25216 return (0, _util.bytesToString)(header) === "ttcf";
25217 }
25218
25219 function isOpenTypeFile(file) {
25220 var header = file.peekBytes(4);
25221 return (0, _util.bytesToString)(header) === "OTTO";
25222 }
25223
25224 function isType1File(file) {
25225 var header = file.peekBytes(2);
25226
25227 if (header[0] === 0x25 && header[1] === 0x21) {
25228 return true;
25229 }
25230
25231 if (header[0] === 0x80 && header[1] === 0x01) {
25232 return true;
25233 }
25234
25235 return false;
25236 }
25237
25238 function isCFFFile(file) {
25239 const header = file.peekBytes(4);
25240
25241 if (header[0] >= 1 && header[3] >= 1 && header[3] <= 4) {
25242 return true;
25243 }
25244
25245 return false;
25246 }
25247
25248 function getFontFileType(file, {
25249 type,
25250 subtype,
25251 composite
25252 }) {
25253 let fileType, fileSubtype;
25254
25255 if (isTrueTypeFile(file) || isTrueTypeCollectionFile(file)) {
25256 if (composite) {
25257 fileType = "CIDFontType2";
25258 } else {
25259 fileType = "TrueType";
25260 }
25261 } else if (isOpenTypeFile(file)) {
25262 if (composite) {
25263 fileType = "CIDFontType2";
25264 } else {
25265 fileType = "OpenType";
25266 }
25267 } else if (isType1File(file)) {
25268 if (composite) {
25269 fileType = "CIDFontType0";
25270 } else {
25271 fileType = type === "MMType1" ? "MMType1" : "Type1";
25272 }
25273 } else if (isCFFFile(file)) {
25274 if (composite) {
25275 fileType = "CIDFontType0";
25276 fileSubtype = "CIDFontType0C";
25277 } else {
25278 fileType = type === "MMType1" ? "MMType1" : "Type1";
25279 fileSubtype = "Type1C";
25280 }
25281 } else {
25282 (0, _util.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");
25283 fileType = type;
25284 fileSubtype = subtype;
25285 }
25286
25287 return [fileType, fileSubtype];
25288 }
25289
25290 function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
25291 var toFontChar = [],
25292 unicode;
25293
25294 for (var i = 0, ii = encoding.length; i < ii; i++) {
25295 unicode = (0, _unicode.getUnicodeForGlyph)(encoding[i], glyphsUnicodeMap);
25296
25297 if (unicode !== -1) {
25298 toFontChar[i] = unicode;
25299 }
25300 }
25301
25302 for (var charCode in differences) {
25303 unicode = (0, _unicode.getUnicodeForGlyph)(differences[charCode], glyphsUnicodeMap);
25304
25305 if (unicode !== -1) {
25306 toFontChar[+charCode] = unicode;
25307 }
25308 }
25309
25310 return toFontChar;
25311 }
25312
25313 function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId) {
25314 var newMap = Object.create(null);
25315 var toFontChar = [];
25316 var privateUseAreaIndex = 0;
25317 var nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
25318 var privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
25319
25320 for (var originalCharCode in charCodeToGlyphId) {
25321 originalCharCode |= 0;
25322 var glyphId = charCodeToGlyphId[originalCharCode];
25323
25324 if (!hasGlyph(glyphId)) {
25325 continue;
25326 }
25327
25328 if (nextAvailableFontCharCode > privateUseOffetEnd) {
25329 privateUseAreaIndex++;
25330
25331 if (privateUseAreaIndex >= PRIVATE_USE_AREAS.length) {
25332 (0, _util.warn)("Ran out of space in font private use area.");
25333 break;
25334 }
25335
25336 nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
25337 privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
25338 }
25339
25340 var fontCharCode = nextAvailableFontCharCode++;
25341
25342 if (glyphId === 0) {
25343 glyphId = newGlyphZeroId;
25344 }
25345
25346 newMap[fontCharCode] = glyphId;
25347 toFontChar[originalCharCode] = fontCharCode;
25348 }
25349
25350 return {
25351 toFontChar,
25352 charCodeToGlyphId: newMap,
25353 nextAvailableFontCharCode
25354 };
25355 }
25356
25357 function getRanges(glyphs, numGlyphs) {
25358 var codes = [];
25359
25360 for (var charCode in glyphs) {
25361 if (glyphs[charCode] >= numGlyphs) {
25362 continue;
25363 }
25364
25365 codes.push({
25366 fontCharCode: charCode | 0,
25367 glyphId: glyphs[charCode]
25368 });
25369 }
25370
25371 if (codes.length === 0) {
25372 codes.push({
25373 fontCharCode: 0,
25374 glyphId: 0
25375 });
25376 }
25377
25378 codes.sort(function fontGetRangesSort(a, b) {
25379 return a.fontCharCode - b.fontCharCode;
25380 });
25381 var ranges = [];
25382 var length = codes.length;
25383
25384 for (var n = 0; n < length;) {
25385 var start = codes[n].fontCharCode;
25386 var codeIndices = [codes[n].glyphId];
25387 ++n;
25388 var end = start;
25389
25390 while (n < length && end + 1 === codes[n].fontCharCode) {
25391 codeIndices.push(codes[n].glyphId);
25392 ++end;
25393 ++n;
25394
25395 if (end === 0xffff) {
25396 break;
25397 }
25398 }
25399
25400 ranges.push([start, end, codeIndices]);
25401 }
25402
25403 return ranges;
25404 }
25405
25406 function createCmapTable(glyphs, numGlyphs) {
25407 var ranges = getRanges(glyphs, numGlyphs);
25408 var numTables = ranges[ranges.length - 1][1] > 0xffff ? 2 : 1;
25409 var cmap = "\x00\x00" + string16(numTables) + "\x00\x03" + "\x00\x01" + (0, _util.string32)(4 + numTables * 8);
25410 var i, ii, j, jj;
25411
25412 for (i = ranges.length - 1; i >= 0; --i) {
25413 if (ranges[i][0] <= 0xffff) {
25414 break;
25415 }
25416 }
25417
25418 var bmpLength = i + 1;
25419
25420 if (ranges[i][0] < 0xffff && ranges[i][1] === 0xffff) {
25421 ranges[i][1] = 0xfffe;
25422 }
25423
25424 var trailingRangesCount = ranges[i][1] < 0xffff ? 1 : 0;
25425 var segCount = bmpLength + trailingRangesCount;
25426 var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
25427 var startCount = "";
25428 var endCount = "";
25429 var idDeltas = "";
25430 var idRangeOffsets = "";
25431 var glyphsIds = "";
25432 var bias = 0;
25433 var range, start, end, codes;
25434
25435 for (i = 0, ii = bmpLength; i < ii; i++) {
25436 range = ranges[i];
25437 start = range[0];
25438 end = range[1];
25439 startCount += string16(start);
25440 endCount += string16(end);
25441 codes = range[2];
25442 var contiguous = true;
25443
25444 for (j = 1, jj = codes.length; j < jj; ++j) {
25445 if (codes[j] !== codes[j - 1] + 1) {
25446 contiguous = false;
25447 break;
25448 }
25449 }
25450
25451 if (!contiguous) {
25452 var offset = (segCount - i) * 2 + bias * 2;
25453 bias += end - start + 1;
25454 idDeltas += string16(0);
25455 idRangeOffsets += string16(offset);
25456
25457 for (j = 0, jj = codes.length; j < jj; ++j) {
25458 glyphsIds += string16(codes[j]);
25459 }
25460 } else {
25461 var startCode = codes[0];
25462 idDeltas += string16(startCode - start & 0xffff);
25463 idRangeOffsets += string16(0);
25464 }
25465 }
25466
25467 if (trailingRangesCount > 0) {
25468 endCount += "\xFF\xFF";
25469 startCount += "\xFF\xFF";
25470 idDeltas += "\x00\x01";
25471 idRangeOffsets += "\x00\x00";
25472 }
25473
25474 var format314 = "\x00\x00" + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + "\x00\x00" + startCount + idDeltas + idRangeOffsets + glyphsIds;
25475 var format31012 = "";
25476 var header31012 = "";
25477
25478 if (numTables > 1) {
25479 cmap += "\x00\x03" + "\x00\x0A" + (0, _util.string32)(4 + numTables * 8 + 4 + format314.length);
25480 format31012 = "";
25481
25482 for (i = 0, ii = ranges.length; i < ii; i++) {
25483 range = ranges[i];
25484 start = range[0];
25485 codes = range[2];
25486 var code = codes[0];
25487
25488 for (j = 1, jj = codes.length; j < jj; ++j) {
25489 if (codes[j] !== codes[j - 1] + 1) {
25490 end = range[0] + j - 1;
25491 format31012 += (0, _util.string32)(start) + (0, _util.string32)(end) + (0, _util.string32)(code);
25492 start = end + 1;
25493 code = codes[j];
25494 }
25495 }
25496
25497 format31012 += (0, _util.string32)(start) + (0, _util.string32)(range[1]) + (0, _util.string32)(code);
25498 }
25499
25500 header31012 = "\x00\x0C" + "\x00\x00" + (0, _util.string32)(format31012.length + 16) + "\x00\x00\x00\x00" + (0, _util.string32)(format31012.length / 12);
25501 }
25502
25503 return cmap + "\x00\x04" + string16(format314.length + 4) + format314 + header31012 + format31012;
25504 }
25505
25506 function validateOS2Table(os2, file) {
25507 file.pos = (file.start || 0) + os2.offset;
25508 var version = file.getUint16();
25509 file.skip(60);
25510 var selection = file.getUint16();
25511
25512 if (version < 4 && selection & 0x0300) {
25513 return false;
25514 }
25515
25516 var firstChar = file.getUint16();
25517 var lastChar = file.getUint16();
25518
25519 if (firstChar > lastChar) {
25520 return false;
25521 }
25522
25523 file.skip(6);
25524 var usWinAscent = file.getUint16();
25525
25526 if (usWinAscent === 0) {
25527 return false;
25528 }
25529
25530 os2.data[8] = os2.data[9] = 0;
25531 return true;
25532 }
25533
25534 function createOS2Table(properties, charstrings, override) {
25535 override = override || {
25536 unitsPerEm: 0,
25537 yMax: 0,
25538 yMin: 0,
25539 ascent: 0,
25540 descent: 0
25541 };
25542 var ulUnicodeRange1 = 0;
25543 var ulUnicodeRange2 = 0;
25544 var ulUnicodeRange3 = 0;
25545 var ulUnicodeRange4 = 0;
25546 var firstCharIndex = null;
25547 var lastCharIndex = 0;
25548
25549 if (charstrings) {
25550 for (var code in charstrings) {
25551 code |= 0;
25552
25553 if (firstCharIndex > code || !firstCharIndex) {
25554 firstCharIndex = code;
25555 }
25556
25557 if (lastCharIndex < code) {
25558 lastCharIndex = code;
25559 }
25560
25561 var position = (0, _unicode.getUnicodeRangeFor)(code);
25562
25563 if (position < 32) {
25564 ulUnicodeRange1 |= 1 << position;
25565 } else if (position < 64) {
25566 ulUnicodeRange2 |= 1 << position - 32;
25567 } else if (position < 96) {
25568 ulUnicodeRange3 |= 1 << position - 64;
25569 } else if (position < 123) {
25570 ulUnicodeRange4 |= 1 << position - 96;
25571 } else {
25572 throw new _util.FormatError("Unicode ranges Bits > 123 are reserved for internal usage");
25573 }
25574 }
25575
25576 if (lastCharIndex > 0xffff) {
25577 lastCharIndex = 0xffff;
25578 }
25579 } else {
25580 firstCharIndex = 0;
25581 lastCharIndex = 255;
25582 }
25583
25584 var bbox = properties.bbox || [0, 0, 0, 0];
25585 var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
25586 var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
25587 var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
25588 var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
25589
25590 if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
25591 typoDescent = -typoDescent;
25592 }
25593
25594 var winAscent = override.yMax || typoAscent;
25595 var winDescent = -override.yMin || -typoDescent;
25596 return "\x00\x03" + "\x02\x24" + "\x01\xF4" + "\x00\x05" + "\x00\x00" + "\x02\x8A" + "\x02\xBB" + "\x00\x00" + "\x00\x8C" + "\x02\x8A" + "\x02\xBB" + "\x00\x00" + "\x01\xDF" + "\x00\x31" + "\x01\x02" + "\x00\x00" + "\x00\x00\x06" + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + "\x00\x00\x00\x00\x00\x00" + (0, _util.string32)(ulUnicodeRange1) + (0, _util.string32)(ulUnicodeRange2) + (0, _util.string32)(ulUnicodeRange3) + (0, _util.string32)(ulUnicodeRange4) + "\x2A\x32\x31\x2A" + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + "\x00\x64" + string16(winAscent) + string16(winDescent) + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + "\x00\x03";
25597 }
25598
25599 function createPostTable(properties) {
25600 var angle = Math.floor(properties.italicAngle * 2 ** 16);
25601 return "\x00\x03\x00\x00" + (0, _util.string32)(angle) + "\x00\x00" + "\x00\x00" + (0, _util.string32)(properties.fixedPitch) + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + "\x00\x00\x00\x00";
25602 }
25603
25604 function createNameTable(name, proto) {
25605 if (!proto) {
25606 proto = [[], []];
25607 }
25608
25609 var strings = [proto[0][0] || "Original licence", proto[0][1] || name, proto[0][2] || "Unknown", proto[0][3] || "uniqueID", proto[0][4] || name, proto[0][5] || "Version 0.11", proto[0][6] || "", proto[0][7] || "Unknown", proto[0][8] || "Unknown", proto[0][9] || "Unknown"];
25610 var stringsUnicode = [];
25611 var i, ii, j, jj, str;
25612
25613 for (i = 0, ii = strings.length; i < ii; i++) {
25614 str = proto[1][i] || strings[i];
25615 var strBufUnicode = [];
25616
25617 for (j = 0, jj = str.length; j < jj; j++) {
25618 strBufUnicode.push(string16(str.charCodeAt(j)));
25619 }
25620
25621 stringsUnicode.push(strBufUnicode.join(""));
25622 }
25623
25624 var names = [strings, stringsUnicode];
25625 var platforms = ["\x00\x01", "\x00\x03"];
25626 var encodings = ["\x00\x00", "\x00\x01"];
25627 var languages = ["\x00\x00", "\x04\x09"];
25628 var namesRecordCount = strings.length * platforms.length;
25629 var nameTable = "\x00\x00" + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
25630 var strOffset = 0;
25631
25632 for (i = 0, ii = platforms.length; i < ii; i++) {
25633 var strs = names[i];
25634
25635 for (j = 0, jj = strs.length; j < jj; j++) {
25636 str = strs[j];
25637 var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
25638 nameTable += nameRecord;
25639 strOffset += str.length;
25640 }
25641 }
25642
25643 nameTable += strings.join("") + stringsUnicode.join("");
25644 return nameTable;
25645 }
25646
25647 Font.prototype = {
25648 name: null,
25649 font: null,
25650 mimetype: null,
25651 disableFontFace: false,
25652
25653 get renderer() {
25654 var renderer = _font_renderer.FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
25655
25656 return (0, _util.shadow)(this, "renderer", renderer);
25657 },
25658
25659 exportData(extraProperties = false) {
25660 const exportDataProperties = extraProperties ? [...EXPORT_DATA_PROPERTIES, ...EXPORT_DATA_EXTRA_PROPERTIES] : EXPORT_DATA_PROPERTIES;
25661 const data = Object.create(null);
25662 let property, value;
25663
25664 for (property of exportDataProperties) {
25665 value = this[property];
25666
25667 if (value !== undefined) {
25668 data[property] = value;
25669 }
25670 }
25671
25672 return data;
25673 },
25674
25675 fallbackToSystemFont: function Font_fallbackToSystemFont() {
25676 this.missingFile = true;
25677 var name = this.name;
25678 var type = this.type;
25679 var subtype = this.subtype;
25680 let fontName = name.replace(/[,_]/g, "-").replace(/\s/g, "");
25681 var stdFontMap = (0, _standard_fonts.getStdFontMap)(),
25682 nonStdFontMap = (0, _standard_fonts.getNonStdFontMap)();
25683 var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
25684 fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
25685 this.bold = fontName.search(/bold/gi) !== -1;
25686 this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
25687 this.black = name.search(/Black/g) !== -1;
25688 this.remeasure = Object.keys(this.widths).length > 0;
25689
25690 if (isStandardFont && type === "CIDFontType2" && this.cidEncoding.startsWith("Identity-")) {
25691 const GlyphMapForStandardFonts = (0, _standard_fonts.getGlyphMapForStandardFonts)();
25692 const map = [];
25693
25694 for (const charCode in GlyphMapForStandardFonts) {
25695 map[+charCode] = GlyphMapForStandardFonts[charCode];
25696 }
25697
25698 if (/Arial-?Black/i.test(name)) {
25699 var SupplementalGlyphMapForArialBlack = (0, _standard_fonts.getSupplementalGlyphMapForArialBlack)();
25700
25701 for (const charCode in SupplementalGlyphMapForArialBlack) {
25702 map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
25703 }
25704 } else if (/Calibri/i.test(name)) {
25705 const SupplementalGlyphMapForCalibri = (0, _standard_fonts.getSupplementalGlyphMapForCalibri)();
25706
25707 for (const charCode in SupplementalGlyphMapForCalibri) {
25708 map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
25709 }
25710 }
25711
25712 var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
25713
25714 if (!isIdentityUnicode) {
25715 this.toUnicode.forEach(function (charCode, unicodeCharCode) {
25716 map[+charCode] = unicodeCharCode;
25717 });
25718 }
25719
25720 this.toFontChar = map;
25721 this.toUnicode = new ToUnicodeMap(map);
25722 } else if (/Symbol/i.test(fontName)) {
25723 this.toFontChar = buildToFontChar(_encodings.SymbolSetEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
25724 } else if (/Dingbats/i.test(fontName)) {
25725 if (/Wingdings/i.test(name)) {
25726 (0, _util.warn)("Non-embedded Wingdings font, falling back to ZapfDingbats.");
25727 }
25728
25729 this.toFontChar = buildToFontChar(_encodings.ZapfDingbatsEncoding, (0, _glyphlist.getDingbatsGlyphsUnicode)(), this.differences);
25730 } else if (isStandardFont) {
25731 this.toFontChar = buildToFontChar(this.defaultEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
25732 } else {
25733 const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
25734 const map = [];
25735 this.toUnicode.forEach((charCode, unicodeCharCode) => {
25736 if (!this.composite) {
25737 var glyphName = this.differences[charCode] || this.defaultEncoding[charCode];
25738 const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
25739
25740 if (unicode !== -1) {
25741 unicodeCharCode = unicode;
25742 }
25743 }
25744
25745 map[+charCode] = unicodeCharCode;
25746 });
25747
25748 if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) {
25749 if (/Verdana/i.test(name)) {
25750 const GlyphMapForStandardFonts = (0, _standard_fonts.getGlyphMapForStandardFonts)();
25751
25752 for (const charCode in GlyphMapForStandardFonts) {
25753 map[+charCode] = GlyphMapForStandardFonts[charCode];
25754 }
25755 }
25756 }
25757
25758 this.toFontChar = map;
25759 }
25760
25761 this.loadedName = fontName.split("-")[0];
25762 this.fontType = getFontType(type, subtype);
25763 },
25764 checkAndRepair: function Font_checkAndRepair(name, font, properties) {
25765 const VALID_TABLES = ["OS/2", "cmap", "head", "hhea", "hmtx", "maxp", "name", "post", "loca", "glyf", "fpgm", "prep", "cvt ", "CFF "];
25766
25767 function readTables(file, numTables) {
25768 const tables = Object.create(null);
25769 tables["OS/2"] = null;
25770 tables.cmap = null;
25771 tables.head = null;
25772 tables.hhea = null;
25773 tables.hmtx = null;
25774 tables.maxp = null;
25775 tables.name = null;
25776 tables.post = null;
25777
25778 for (let i = 0; i < numTables; i++) {
25779 const table = readTableEntry(file);
25780
25781 if (!VALID_TABLES.includes(table.tag)) {
25782 continue;
25783 }
25784
25785 if (table.length === 0) {
25786 continue;
25787 }
25788
25789 tables[table.tag] = table;
25790 }
25791
25792 return tables;
25793 }
25794
25795 function readTableEntry(file) {
25796 var tag = (0, _util.bytesToString)(file.getBytes(4));
25797 var checksum = file.getInt32() >>> 0;
25798 var offset = file.getInt32() >>> 0;
25799 var length = file.getInt32() >>> 0;
25800 var previousPosition = file.pos;
25801 file.pos = file.start ? file.start : 0;
25802 file.skip(offset);
25803 var data = file.getBytes(length);
25804 file.pos = previousPosition;
25805
25806 if (tag === "head") {
25807 data[8] = data[9] = data[10] = data[11] = 0;
25808 data[17] |= 0x20;
25809 }
25810
25811 return {
25812 tag,
25813 checksum,
25814 length,
25815 offset,
25816 data
25817 };
25818 }
25819
25820 function readOpenTypeHeader(ttf) {
25821 return {
25822 version: (0, _util.bytesToString)(ttf.getBytes(4)),
25823 numTables: ttf.getUint16(),
25824 searchRange: ttf.getUint16(),
25825 entrySelector: ttf.getUint16(),
25826 rangeShift: ttf.getUint16()
25827 };
25828 }
25829
25830 function readTrueTypeCollectionHeader(ttc) {
25831 const ttcTag = (0, _util.bytesToString)(ttc.getBytes(4));
25832 (0, _util.assert)(ttcTag === "ttcf", "Must be a TrueType Collection font.");
25833 const majorVersion = ttc.getUint16();
25834 const minorVersion = ttc.getUint16();
25835 const numFonts = ttc.getInt32() >>> 0;
25836 const offsetTable = [];
25837
25838 for (let i = 0; i < numFonts; i++) {
25839 offsetTable.push(ttc.getInt32() >>> 0);
25840 }
25841
25842 const header = {
25843 ttcTag,
25844 majorVersion,
25845 minorVersion,
25846 numFonts,
25847 offsetTable
25848 };
25849
25850 switch (majorVersion) {
25851 case 1:
25852 return header;
25853
25854 case 2:
25855 header.dsigTag = ttc.getInt32() >>> 0;
25856 header.dsigLength = ttc.getInt32() >>> 0;
25857 header.dsigOffset = ttc.getInt32() >>> 0;
25858 return header;
25859 }
25860
25861 throw new _util.FormatError(`Invalid TrueType Collection majorVersion: ${majorVersion}.`);
25862 }
25863
25864 function readTrueTypeCollectionData(ttc, fontName) {
25865 const {
25866 numFonts,
25867 offsetTable
25868 } = readTrueTypeCollectionHeader(ttc);
25869
25870 for (let i = 0; i < numFonts; i++) {
25871 ttc.pos = (ttc.start || 0) + offsetTable[i];
25872 const potentialHeader = readOpenTypeHeader(ttc);
25873 const potentialTables = readTables(ttc, potentialHeader.numTables);
25874
25875 if (!potentialTables.name) {
25876 throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
25877 }
25878
25879 const nameTable = readNameTable(potentialTables.name);
25880
25881 for (let j = 0, jj = nameTable.length; j < jj; j++) {
25882 for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
25883 const nameEntry = nameTable[j][k];
25884
25885 if (nameEntry && nameEntry.replace(/\s/g, "") === fontName) {
25886 return {
25887 header: potentialHeader,
25888 tables: potentialTables
25889 };
25890 }
25891 }
25892 }
25893 }
25894
25895 throw new _util.FormatError(`TrueType Collection does not contain "${fontName}" font.`);
25896 }
25897
25898 function readCmapTable(cmap, file, isSymbolicFont, hasEncoding) {
25899 if (!cmap) {
25900 (0, _util.warn)("No cmap table available.");
25901 return {
25902 platformId: -1,
25903 encodingId: -1,
25904 mappings: [],
25905 hasShortCmap: false
25906 };
25907 }
25908
25909 var segment;
25910 var start = (file.start ? file.start : 0) + cmap.offset;
25911 file.pos = start;
25912 file.skip(2);
25913 var numTables = file.getUint16();
25914 var potentialTable;
25915 var canBreak = false;
25916
25917 for (var i = 0; i < numTables; i++) {
25918 var platformId = file.getUint16();
25919 var encodingId = file.getUint16();
25920 var offset = file.getInt32() >>> 0;
25921 var useTable = false;
25922
25923 if (potentialTable && potentialTable.platformId === platformId && potentialTable.encodingId === encodingId) {
25924 continue;
25925 }
25926
25927 if (platformId === 0 && encodingId === 0) {
25928 useTable = true;
25929 } else if (platformId === 1 && encodingId === 0) {
25930 useTable = true;
25931 } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
25932 useTable = true;
25933
25934 if (!isSymbolicFont) {
25935 canBreak = true;
25936 }
25937 } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
25938 useTable = true;
25939 canBreak = true;
25940 }
25941
25942 if (useTable) {
25943 potentialTable = {
25944 platformId,
25945 encodingId,
25946 offset
25947 };
25948 }
25949
25950 if (canBreak) {
25951 break;
25952 }
25953 }
25954
25955 if (potentialTable) {
25956 file.pos = start + potentialTable.offset;
25957 }
25958
25959 if (!potentialTable || file.peekByte() === -1) {
25960 (0, _util.warn)("Could not find a preferred cmap table.");
25961 return {
25962 platformId: -1,
25963 encodingId: -1,
25964 mappings: [],
25965 hasShortCmap: false
25966 };
25967 }
25968
25969 var format = file.getUint16();
25970 file.skip(2 + 2);
25971 var hasShortCmap = false;
25972 var mappings = [];
25973 var j, glyphId;
25974
25975 if (format === 0) {
25976 for (j = 0; j < 256; j++) {
25977 var index = file.getByte();
25978
25979 if (!index) {
25980 continue;
25981 }
25982
25983 mappings.push({
25984 charCode: j,
25985 glyphId: index
25986 });
25987 }
25988
25989 hasShortCmap = true;
25990 } else if (format === 4) {
25991 var segCount = file.getUint16() >> 1;
25992 file.skip(6);
25993 var segIndex,
25994 segments = [];
25995
25996 for (segIndex = 0; segIndex < segCount; segIndex++) {
25997 segments.push({
25998 end: file.getUint16()
25999 });
26000 }
26001
26002 file.skip(2);
26003
26004 for (segIndex = 0; segIndex < segCount; segIndex++) {
26005 segments[segIndex].start = file.getUint16();
26006 }
26007
26008 for (segIndex = 0; segIndex < segCount; segIndex++) {
26009 segments[segIndex].delta = file.getUint16();
26010 }
26011
26012 var offsetsCount = 0;
26013
26014 for (segIndex = 0; segIndex < segCount; segIndex++) {
26015 segment = segments[segIndex];
26016 var rangeOffset = file.getUint16();
26017
26018 if (!rangeOffset) {
26019 segment.offsetIndex = -1;
26020 continue;
26021 }
26022
26023 var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
26024 segment.offsetIndex = offsetIndex;
26025 offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
26026 }
26027
26028 var offsets = [];
26029
26030 for (j = 0; j < offsetsCount; j++) {
26031 offsets.push(file.getUint16());
26032 }
26033
26034 for (segIndex = 0; segIndex < segCount; segIndex++) {
26035 segment = segments[segIndex];
26036 start = segment.start;
26037 var end = segment.end;
26038 var delta = segment.delta;
26039 offsetIndex = segment.offsetIndex;
26040
26041 for (j = start; j <= end; j++) {
26042 if (j === 0xffff) {
26043 continue;
26044 }
26045
26046 glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
26047 glyphId = glyphId + delta & 0xffff;
26048 mappings.push({
26049 charCode: j,
26050 glyphId
26051 });
26052 }
26053 }
26054 } else if (format === 6) {
26055 var firstCode = file.getUint16();
26056 var entryCount = file.getUint16();
26057
26058 for (j = 0; j < entryCount; j++) {
26059 glyphId = file.getUint16();
26060 var charCode = firstCode + j;
26061 mappings.push({
26062 charCode,
26063 glyphId
26064 });
26065 }
26066 } else {
26067 (0, _util.warn)("cmap table has unsupported format: " + format);
26068 return {
26069 platformId: -1,
26070 encodingId: -1,
26071 mappings: [],
26072 hasShortCmap: false
26073 };
26074 }
26075
26076 mappings.sort(function (a, b) {
26077 return a.charCode - b.charCode;
26078 });
26079
26080 for (i = 1; i < mappings.length; i++) {
26081 if (mappings[i - 1].charCode === mappings[i].charCode) {
26082 mappings.splice(i, 1);
26083 i--;
26084 }
26085 }
26086
26087 return {
26088 platformId: potentialTable.platformId,
26089 encodingId: potentialTable.encodingId,
26090 mappings,
26091 hasShortCmap
26092 };
26093 }
26094
26095 function sanitizeMetrics(file, header, metrics, numGlyphs, dupFirstEntry) {
26096 if (!header) {
26097 if (metrics) {
26098 metrics.data = null;
26099 }
26100
26101 return;
26102 }
26103
26104 file.pos = (file.start ? file.start : 0) + header.offset;
26105 file.pos += 4;
26106 file.pos += 2;
26107 file.pos += 2;
26108 file.pos += 2;
26109 file.pos += 2;
26110 file.pos += 2;
26111 file.pos += 2;
26112 file.pos += 2;
26113 file.pos += 2;
26114 file.pos += 2;
26115 file.pos += 2;
26116 file.pos += 8;
26117 file.pos += 2;
26118 var numOfMetrics = file.getUint16();
26119
26120 if (numOfMetrics > numGlyphs) {
26121 (0, _util.info)("The numOfMetrics (" + numOfMetrics + ") should not be " + "greater than the numGlyphs (" + numGlyphs + ")");
26122 numOfMetrics = numGlyphs;
26123 header.data[34] = (numOfMetrics & 0xff00) >> 8;
26124 header.data[35] = numOfMetrics & 0x00ff;
26125 }
26126
26127 var numOfSidebearings = numGlyphs - numOfMetrics;
26128 var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
26129
26130 if (numMissing > 0) {
26131 var entries = new Uint8Array(metrics.length + numMissing * 2);
26132 entries.set(metrics.data);
26133
26134 if (dupFirstEntry) {
26135 entries[metrics.length] = metrics.data[2];
26136 entries[metrics.length + 1] = metrics.data[3];
26137 }
26138
26139 metrics.data = entries;
26140 }
26141 }
26142
26143 function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
26144 var glyphProfile = {
26145 length: 0,
26146 sizeOfInstructions: 0
26147 };
26148
26149 if (sourceEnd - sourceStart <= 12) {
26150 return glyphProfile;
26151 }
26152
26153 var glyf = source.subarray(sourceStart, sourceEnd);
26154 var contoursCount = signedInt16(glyf[0], glyf[1]);
26155
26156 if (contoursCount < 0) {
26157 contoursCount = -1;
26158 writeSignedInt16(glyf, 0, contoursCount);
26159 dest.set(glyf, destStart);
26160 glyphProfile.length = glyf.length;
26161 return glyphProfile;
26162 }
26163
26164 var i,
26165 j = 10,
26166 flagsCount = 0;
26167
26168 for (i = 0; i < contoursCount; i++) {
26169 var endPoint = glyf[j] << 8 | glyf[j + 1];
26170 flagsCount = endPoint + 1;
26171 j += 2;
26172 }
26173
26174 var instructionsStart = j;
26175 var instructionsLength = glyf[j] << 8 | glyf[j + 1];
26176 glyphProfile.sizeOfInstructions = instructionsLength;
26177 j += 2 + instructionsLength;
26178 var instructionsEnd = j;
26179 var coordinatesLength = 0;
26180
26181 for (i = 0; i < flagsCount; i++) {
26182 var flag = glyf[j++];
26183
26184 if (flag & 0xc0) {
26185 glyf[j - 1] = flag & 0x3f;
26186 }
26187
26188 let xLength = 2;
26189
26190 if (flag & 2) {
26191 xLength = 1;
26192 } else if (flag & 16) {
26193 xLength = 0;
26194 }
26195
26196 let yLength = 2;
26197
26198 if (flag & 4) {
26199 yLength = 1;
26200 } else if (flag & 32) {
26201 yLength = 0;
26202 }
26203
26204 const xyLength = xLength + yLength;
26205 coordinatesLength += xyLength;
26206
26207 if (flag & 8) {
26208 var repeat = glyf[j++];
26209 i += repeat;
26210 coordinatesLength += repeat * xyLength;
26211 }
26212 }
26213
26214 if (coordinatesLength === 0) {
26215 return glyphProfile;
26216 }
26217
26218 var glyphDataLength = j + coordinatesLength;
26219
26220 if (glyphDataLength > glyf.length) {
26221 return glyphProfile;
26222 }
26223
26224 if (!hintsValid && instructionsLength > 0) {
26225 dest.set(glyf.subarray(0, instructionsStart), destStart);
26226 dest.set([0, 0], destStart + instructionsStart);
26227 dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
26228 glyphDataLength -= instructionsLength;
26229
26230 if (glyf.length - glyphDataLength > 3) {
26231 glyphDataLength = glyphDataLength + 3 & ~3;
26232 }
26233
26234 glyphProfile.length = glyphDataLength;
26235 return glyphProfile;
26236 }
26237
26238 if (glyf.length - glyphDataLength > 3) {
26239 glyphDataLength = glyphDataLength + 3 & ~3;
26240 dest.set(glyf.subarray(0, glyphDataLength), destStart);
26241 glyphProfile.length = glyphDataLength;
26242 return glyphProfile;
26243 }
26244
26245 dest.set(glyf, destStart);
26246 glyphProfile.length = glyf.length;
26247 return glyphProfile;
26248 }
26249
26250 function sanitizeHead(head, numGlyphs, locaLength) {
26251 var data = head.data;
26252 var version = int32(data[0], data[1], data[2], data[3]);
26253
26254 if (version >> 16 !== 1) {
26255 (0, _util.info)("Attempting to fix invalid version in head table: " + version);
26256 data[0] = 0;
26257 data[1] = 1;
26258 data[2] = 0;
26259 data[3] = 0;
26260 }
26261
26262 var indexToLocFormat = int16(data[50], data[51]);
26263
26264 if (indexToLocFormat < 0 || indexToLocFormat > 1) {
26265 (0, _util.info)("Attempting to fix invalid indexToLocFormat in head table: " + indexToLocFormat);
26266 var numGlyphsPlusOne = numGlyphs + 1;
26267
26268 if (locaLength === numGlyphsPlusOne << 1) {
26269 data[50] = 0;
26270 data[51] = 0;
26271 } else if (locaLength === numGlyphsPlusOne << 2) {
26272 data[50] = 0;
26273 data[51] = 1;
26274 } else {
26275 throw new _util.FormatError("Could not fix indexToLocFormat: " + indexToLocFormat);
26276 }
26277 }
26278 }
26279
26280 function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions) {
26281 var itemSize, itemDecode, itemEncode;
26282
26283 if (isGlyphLocationsLong) {
26284 itemSize = 4;
26285
26286 itemDecode = function fontItemDecodeLong(data, offset) {
26287 return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
26288 };
26289
26290 itemEncode = function fontItemEncodeLong(data, offset, value) {
26291 data[offset] = value >>> 24 & 0xff;
26292 data[offset + 1] = value >> 16 & 0xff;
26293 data[offset + 2] = value >> 8 & 0xff;
26294 data[offset + 3] = value & 0xff;
26295 };
26296 } else {
26297 itemSize = 2;
26298
26299 itemDecode = function fontItemDecode(data, offset) {
26300 return data[offset] << 9 | data[offset + 1] << 1;
26301 };
26302
26303 itemEncode = function fontItemEncode(data, offset, value) {
26304 data[offset] = value >> 9 & 0xff;
26305 data[offset + 1] = value >> 1 & 0xff;
26306 };
26307 }
26308
26309 var numGlyphsOut = dupFirstEntry ? numGlyphs + 1 : numGlyphs;
26310 var locaDataSize = itemSize * (1 + numGlyphsOut);
26311 var locaData = new Uint8Array(locaDataSize);
26312 locaData.set(loca.data.subarray(0, locaDataSize));
26313 loca.data = locaData;
26314 var oldGlyfData = glyf.data;
26315 var oldGlyfDataLength = oldGlyfData.length;
26316 var newGlyfData = new Uint8Array(oldGlyfDataLength);
26317 var startOffset = itemDecode(locaData, 0);
26318 var writeOffset = 0;
26319 var missingGlyphs = Object.create(null);
26320 itemEncode(locaData, 0, writeOffset);
26321 var i, j;
26322
26323 for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
26324 var endOffset = itemDecode(locaData, j);
26325
26326 if (endOffset === 0) {
26327 endOffset = startOffset;
26328 }
26329
26330 if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
26331 endOffset = oldGlyfDataLength;
26332 }
26333
26334 if (endOffset > oldGlyfDataLength) {
26335 startOffset = endOffset;
26336 }
26337
26338 var glyphProfile = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
26339 var newLength = glyphProfile.length;
26340
26341 if (newLength === 0) {
26342 missingGlyphs[i] = true;
26343 }
26344
26345 if (glyphProfile.sizeOfInstructions > maxSizeOfInstructions) {
26346 maxSizeOfInstructions = glyphProfile.sizeOfInstructions;
26347 }
26348
26349 writeOffset += newLength;
26350 itemEncode(locaData, j, writeOffset);
26351 startOffset = endOffset;
26352 }
26353
26354 if (writeOffset === 0) {
26355 var simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
26356
26357 for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
26358 itemEncode(locaData, j, simpleGlyph.length);
26359 }
26360
26361 glyf.data = simpleGlyph;
26362 } else if (dupFirstEntry) {
26363 var firstEntryLength = itemDecode(locaData, itemSize);
26364
26365 if (newGlyfData.length > firstEntryLength + writeOffset) {
26366 glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
26367 } else {
26368 glyf.data = new Uint8Array(firstEntryLength + writeOffset);
26369 glyf.data.set(newGlyfData.subarray(0, writeOffset));
26370 }
26371
26372 glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
26373 itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
26374 } else {
26375 glyf.data = newGlyfData.subarray(0, writeOffset);
26376 }
26377
26378 return {
26379 missingGlyphs,
26380 maxSizeOfInstructions
26381 };
26382 }
26383
26384 function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) {
26385 var start = (font.start ? font.start : 0) + post.offset;
26386 font.pos = start;
26387 var length = post.length,
26388 end = start + length;
26389 var version = font.getInt32();
26390 font.skip(28);
26391 var glyphNames;
26392 var valid = true;
26393 var i;
26394
26395 switch (version) {
26396 case 0x00010000:
26397 glyphNames = MacStandardGlyphOrdering;
26398 break;
26399
26400 case 0x00020000:
26401 var numGlyphs = font.getUint16();
26402
26403 if (numGlyphs !== maxpNumGlyphs) {
26404 valid = false;
26405 break;
26406 }
26407
26408 var glyphNameIndexes = [];
26409
26410 for (i = 0; i < numGlyphs; ++i) {
26411 var index = font.getUint16();
26412
26413 if (index >= 32768) {
26414 valid = false;
26415 break;
26416 }
26417
26418 glyphNameIndexes.push(index);
26419 }
26420
26421 if (!valid) {
26422 break;
26423 }
26424
26425 var customNames = [];
26426 var strBuf = [];
26427
26428 while (font.pos < end) {
26429 var stringLength = font.getByte();
26430 strBuf.length = stringLength;
26431
26432 for (i = 0; i < stringLength; ++i) {
26433 strBuf[i] = String.fromCharCode(font.getByte());
26434 }
26435
26436 customNames.push(strBuf.join(""));
26437 }
26438
26439 glyphNames = [];
26440
26441 for (i = 0; i < numGlyphs; ++i) {
26442 var j = glyphNameIndexes[i];
26443
26444 if (j < 258) {
26445 glyphNames.push(MacStandardGlyphOrdering[j]);
26446 continue;
26447 }
26448
26449 glyphNames.push(customNames[j - 258]);
26450 }
26451
26452 break;
26453
26454 case 0x00030000:
26455 break;
26456
26457 default:
26458 (0, _util.warn)("Unknown/unsupported post table version " + version);
26459 valid = false;
26460
26461 if (propertiesObj.defaultEncoding) {
26462 glyphNames = propertiesObj.defaultEncoding;
26463 }
26464
26465 break;
26466 }
26467
26468 propertiesObj.glyphNames = glyphNames;
26469 return valid;
26470 }
26471
26472 function readNameTable(nameTable) {
26473 var start = (font.start ? font.start : 0) + nameTable.offset;
26474 font.pos = start;
26475 var names = [[], []];
26476 var length = nameTable.length,
26477 end = start + length;
26478 var format = font.getUint16();
26479 var FORMAT_0_HEADER_LENGTH = 6;
26480
26481 if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
26482 return names;
26483 }
26484
26485 var numRecords = font.getUint16();
26486 var stringsStart = font.getUint16();
26487 var records = [];
26488 var NAME_RECORD_LENGTH = 12;
26489 var i, ii;
26490
26491 for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
26492 var r = {
26493 platform: font.getUint16(),
26494 encoding: font.getUint16(),
26495 language: font.getUint16(),
26496 name: font.getUint16(),
26497 length: font.getUint16(),
26498 offset: font.getUint16()
26499 };
26500
26501 if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
26502 records.push(r);
26503 }
26504 }
26505
26506 for (i = 0, ii = records.length; i < ii; i++) {
26507 var record = records[i];
26508
26509 if (record.length <= 0) {
26510 continue;
26511 }
26512
26513 var pos = start + stringsStart + record.offset;
26514
26515 if (pos + record.length > end) {
26516 continue;
26517 }
26518
26519 font.pos = pos;
26520 var nameIndex = record.name;
26521
26522 if (record.encoding) {
26523 var str = "";
26524
26525 for (var j = 0, jj = record.length; j < jj; j += 2) {
26526 str += String.fromCharCode(font.getUint16());
26527 }
26528
26529 names[1][nameIndex] = str;
26530 } else {
26531 names[0][nameIndex] = (0, _util.bytesToString)(font.getBytes(record.length));
26532 }
26533 }
26534
26535 return names;
26536 }
26537
26538 var TTOpsStackDeltas = [0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1, 1, -1, -999, 0, 1, 0, -1, -2, 0, -1, -2, -1, -1, 0, -1, -1, 0, 0, -999, -999, -1, -1, -1, -1, -2, -999, -2, -2, -999, 0, -2, -2, 0, 0, -2, 0, -2, 0, 0, 0, -2, -1, -1, 1, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -999, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -999, -999, -999, -999, -999, -1, -1, -2, -2, 0, 0, 0, 0, -1, -1, -999, -2, -2, 0, 0, -1, -2, -2, 0, 0, 0, -1, -1, -1, -2];
26539
26540 function sanitizeTTProgram(table, ttContext) {
26541 var data = table.data;
26542 var i = 0,
26543 j,
26544 n,
26545 b,
26546 funcId,
26547 pc,
26548 lastEndf = 0,
26549 lastDeff = 0;
26550 var stack = [];
26551 var callstack = [];
26552 var functionsCalled = [];
26553 var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
26554 var inFDEF = false,
26555 ifLevel = 0,
26556 inELSE = 0;
26557
26558 for (var ii = data.length; i < ii;) {
26559 var op = data[i++];
26560
26561 if (op === 0x40) {
26562 n = data[i++];
26563
26564 if (inFDEF || inELSE) {
26565 i += n;
26566 } else {
26567 for (j = 0; j < n; j++) {
26568 stack.push(data[i++]);
26569 }
26570 }
26571 } else if (op === 0x41) {
26572 n = data[i++];
26573
26574 if (inFDEF || inELSE) {
26575 i += n * 2;
26576 } else {
26577 for (j = 0; j < n; j++) {
26578 b = data[i++];
26579 stack.push(b << 8 | data[i++]);
26580 }
26581 }
26582 } else if ((op & 0xf8) === 0xb0) {
26583 n = op - 0xb0 + 1;
26584
26585 if (inFDEF || inELSE) {
26586 i += n;
26587 } else {
26588 for (j = 0; j < n; j++) {
26589 stack.push(data[i++]);
26590 }
26591 }
26592 } else if ((op & 0xf8) === 0xb8) {
26593 n = op - 0xb8 + 1;
26594
26595 if (inFDEF || inELSE) {
26596 i += n * 2;
26597 } else {
26598 for (j = 0; j < n; j++) {
26599 b = data[i++];
26600 stack.push(b << 8 | data[i++]);
26601 }
26602 }
26603 } else if (op === 0x2b && !tooComplexToFollowFunctions) {
26604 if (!inFDEF && !inELSE) {
26605 funcId = stack[stack.length - 1];
26606
26607 if (isNaN(funcId)) {
26608 (0, _util.info)("TT: CALL empty stack (or invalid entry).");
26609 } else {
26610 ttContext.functionsUsed[funcId] = true;
26611
26612 if (funcId in ttContext.functionsStackDeltas) {
26613 const newStackLength = stack.length + ttContext.functionsStackDeltas[funcId];
26614
26615 if (newStackLength < 0) {
26616 (0, _util.warn)("TT: CALL invalid functions stack delta.");
26617 ttContext.hintsValid = false;
26618 return;
26619 }
26620
26621 stack.length = newStackLength;
26622 } else if (funcId in ttContext.functionsDefined && !functionsCalled.includes(funcId)) {
26623 callstack.push({
26624 data,
26625 i,
26626 stackTop: stack.length - 1
26627 });
26628 functionsCalled.push(funcId);
26629 pc = ttContext.functionsDefined[funcId];
26630
26631 if (!pc) {
26632 (0, _util.warn)("TT: CALL non-existent function");
26633 ttContext.hintsValid = false;
26634 return;
26635 }
26636
26637 data = pc.data;
26638 i = pc.i;
26639 }
26640 }
26641 }
26642 } else if (op === 0x2c && !tooComplexToFollowFunctions) {
26643 if (inFDEF || inELSE) {
26644 (0, _util.warn)("TT: nested FDEFs not allowed");
26645 tooComplexToFollowFunctions = true;
26646 }
26647
26648 inFDEF = true;
26649 lastDeff = i;
26650 funcId = stack.pop();
26651 ttContext.functionsDefined[funcId] = {
26652 data,
26653 i
26654 };
26655 } else if (op === 0x2d) {
26656 if (inFDEF) {
26657 inFDEF = false;
26658 lastEndf = i;
26659 } else {
26660 pc = callstack.pop();
26661
26662 if (!pc) {
26663 (0, _util.warn)("TT: ENDF bad stack");
26664 ttContext.hintsValid = false;
26665 return;
26666 }
26667
26668 funcId = functionsCalled.pop();
26669 data = pc.data;
26670 i = pc.i;
26671 ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
26672 }
26673 } else if (op === 0x89) {
26674 if (inFDEF || inELSE) {
26675 (0, _util.warn)("TT: nested IDEFs not allowed");
26676 tooComplexToFollowFunctions = true;
26677 }
26678
26679 inFDEF = true;
26680 lastDeff = i;
26681 } else if (op === 0x58) {
26682 ++ifLevel;
26683 } else if (op === 0x1b) {
26684 inELSE = ifLevel;
26685 } else if (op === 0x59) {
26686 if (inELSE === ifLevel) {
26687 inELSE = 0;
26688 }
26689
26690 --ifLevel;
26691 } else if (op === 0x1c) {
26692 if (!inFDEF && !inELSE) {
26693 var offset = stack[stack.length - 1];
26694
26695 if (offset > 0) {
26696 i += offset - 1;
26697 }
26698 }
26699 }
26700
26701 if (!inFDEF && !inELSE) {
26702 let stackDelta = 0;
26703
26704 if (op <= 0x8e) {
26705 stackDelta = TTOpsStackDeltas[op];
26706 } else if (op >= 0xc0 && op <= 0xdf) {
26707 stackDelta = -1;
26708 } else if (op >= 0xe0) {
26709 stackDelta = -2;
26710 }
26711
26712 if (op >= 0x71 && op <= 0x75) {
26713 n = stack.pop();
26714
26715 if (!isNaN(n)) {
26716 stackDelta = -n * 2;
26717 }
26718 }
26719
26720 while (stackDelta < 0 && stack.length > 0) {
26721 stack.pop();
26722 stackDelta++;
26723 }
26724
26725 while (stackDelta > 0) {
26726 stack.push(NaN);
26727 stackDelta--;
26728 }
26729 }
26730 }
26731
26732 ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
26733 var content = [data];
26734
26735 if (i > data.length) {
26736 content.push(new Uint8Array(i - data.length));
26737 }
26738
26739 if (lastDeff > lastEndf) {
26740 (0, _util.warn)("TT: complementing a missing function tail");
26741 content.push(new Uint8Array([0x22, 0x2d]));
26742 }
26743
26744 foldTTTable(table, content);
26745 }
26746
26747 function checkInvalidFunctions(ttContext, maxFunctionDefs) {
26748 if (ttContext.tooComplexToFollowFunctions) {
26749 return;
26750 }
26751
26752 if (ttContext.functionsDefined.length > maxFunctionDefs) {
26753 (0, _util.warn)("TT: more functions defined than expected");
26754 ttContext.hintsValid = false;
26755 return;
26756 }
26757
26758 for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
26759 if (j > maxFunctionDefs) {
26760 (0, _util.warn)("TT: invalid function id: " + j);
26761 ttContext.hintsValid = false;
26762 return;
26763 }
26764
26765 if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
26766 (0, _util.warn)("TT: undefined function: " + j);
26767 ttContext.hintsValid = false;
26768 return;
26769 }
26770 }
26771 }
26772
26773 function foldTTTable(table, content) {
26774 if (content.length > 1) {
26775 var newLength = 0;
26776 var j, jj;
26777
26778 for (j = 0, jj = content.length; j < jj; j++) {
26779 newLength += content[j].length;
26780 }
26781
26782 newLength = newLength + 3 & ~3;
26783 var result = new Uint8Array(newLength);
26784 var pos = 0;
26785
26786 for (j = 0, jj = content.length; j < jj; j++) {
26787 result.set(content[j], pos);
26788 pos += content[j].length;
26789 }
26790
26791 table.data = result;
26792 table.length = newLength;
26793 }
26794 }
26795
26796 function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
26797 var ttContext = {
26798 functionsDefined: [],
26799 functionsUsed: [],
26800 functionsStackDeltas: [],
26801 tooComplexToFollowFunctions: false,
26802 hintsValid: true
26803 };
26804
26805 if (fpgm) {
26806 sanitizeTTProgram(fpgm, ttContext);
26807 }
26808
26809 if (prep) {
26810 sanitizeTTProgram(prep, ttContext);
26811 }
26812
26813 if (fpgm) {
26814 checkInvalidFunctions(ttContext, maxFunctionDefs);
26815 }
26816
26817 if (cvt && cvt.length & 1) {
26818 var cvtData = new Uint8Array(cvt.length + 1);
26819 cvtData.set(cvt.data);
26820 cvt.data = cvtData;
26821 }
26822
26823 return ttContext.hintsValid;
26824 }
26825
26826 font = new _stream.Stream(new Uint8Array(font.getBytes()));
26827 let header, tables;
26828
26829 if (isTrueTypeCollectionFile(font)) {
26830 const ttcData = readTrueTypeCollectionData(font, this.name);
26831 header = ttcData.header;
26832 tables = ttcData.tables;
26833 } else {
26834 header = readOpenTypeHeader(font);
26835 tables = readTables(font, header.numTables);
26836 }
26837
26838 let cff, cffFile;
26839 var isTrueType = !tables["CFF "];
26840
26841 if (!isTrueType) {
26842 const isComposite = properties.composite && ((properties.cidToGidMap || []).length > 0 || !(properties.cMap instanceof _cmap.IdentityCMap));
26843
26844 if (header.version === "OTTO" && !isComposite || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
26845 cffFile = new _stream.Stream(tables["CFF "].data);
26846 cff = new CFFFont(cffFile, properties);
26847 adjustWidths(properties);
26848 return this.convert(name, cff, properties);
26849 }
26850
26851 delete tables.glyf;
26852 delete tables.loca;
26853 delete tables.fpgm;
26854 delete tables.prep;
26855 delete tables["cvt "];
26856 this.isOpenType = true;
26857 } else {
26858 if (!tables.loca) {
26859 throw new _util.FormatError('Required "loca" table is not found');
26860 }
26861
26862 if (!tables.glyf) {
26863 (0, _util.warn)('Required "glyf" table is not found -- trying to recover.');
26864 tables.glyf = {
26865 tag: "glyf",
26866 data: new Uint8Array(0)
26867 };
26868 }
26869
26870 this.isOpenType = false;
26871 }
26872
26873 if (!tables.maxp) {
26874 throw new _util.FormatError('Required "maxp" table is not found');
26875 }
26876
26877 font.pos = (font.start || 0) + tables.maxp.offset;
26878 var version = font.getInt32();
26879 const numGlyphs = font.getUint16();
26880 let numGlyphsOut = numGlyphs + 1;
26881 let dupFirstEntry = true;
26882
26883 if (numGlyphsOut > 0xffff) {
26884 dupFirstEntry = false;
26885 numGlyphsOut = numGlyphs;
26886 (0, _util.warn)("Not enough space in glyfs to duplicate first glyph.");
26887 }
26888
26889 var maxFunctionDefs = 0;
26890 var maxSizeOfInstructions = 0;
26891
26892 if (version >= 0x00010000 && tables.maxp.length >= 22) {
26893 font.pos += 8;
26894 var maxZones = font.getUint16();
26895
26896 if (maxZones > 2) {
26897 tables.maxp.data[14] = 0;
26898 tables.maxp.data[15] = 2;
26899 }
26900
26901 font.pos += 4;
26902 maxFunctionDefs = font.getUint16();
26903 font.pos += 4;
26904 maxSizeOfInstructions = font.getUint16();
26905 }
26906
26907 tables.maxp.data[4] = numGlyphsOut >> 8;
26908 tables.maxp.data[5] = numGlyphsOut & 255;
26909 var hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, tables["cvt "], maxFunctionDefs);
26910
26911 if (!hintsValid) {
26912 delete tables.fpgm;
26913 delete tables.prep;
26914 delete tables["cvt "];
26915 }
26916
26917 sanitizeMetrics(font, tables.hhea, tables.hmtx, numGlyphsOut, dupFirstEntry);
26918
26919 if (!tables.head) {
26920 throw new _util.FormatError('Required "head" table is not found');
26921 }
26922
26923 sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
26924 var missingGlyphs = Object.create(null);
26925
26926 if (isTrueType) {
26927 var isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
26928 var glyphsInfo = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
26929 missingGlyphs = glyphsInfo.missingGlyphs;
26930
26931 if (version >= 0x00010000 && tables.maxp.length >= 22) {
26932 tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
26933 tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
26934 }
26935 }
26936
26937 if (!tables.hhea) {
26938 throw new _util.FormatError('Required "hhea" table is not found');
26939 }
26940
26941 if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
26942 tables.hhea.data[10] = 0xff;
26943 tables.hhea.data[11] = 0xff;
26944 }
26945
26946 var metricsOverride = {
26947 unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
26948 yMax: int16(tables.head.data[42], tables.head.data[43]),
26949 yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
26950 ascent: int16(tables.hhea.data[4], tables.hhea.data[5]),
26951 descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7])
26952 };
26953 this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
26954 this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
26955
26956 if (tables.post) {
26957 readPostScriptTable(tables.post, properties, numGlyphs);
26958 }
26959
26960 tables.post = {
26961 tag: "post",
26962 data: createPostTable(properties)
26963 };
26964 const charCodeToGlyphId = [];
26965
26966 function hasGlyph(glyphId) {
26967 return !missingGlyphs[glyphId];
26968 }
26969
26970 if (properties.composite) {
26971 var cidToGidMap = properties.cidToGidMap || [];
26972 var isCidToGidMapEmpty = cidToGidMap.length === 0;
26973 properties.cMap.forEach(function (charCode, cid) {
26974 if (cid > 0xffff) {
26975 throw new _util.FormatError("Max size of CID is 65,535");
26976 }
26977
26978 var glyphId = -1;
26979
26980 if (isCidToGidMapEmpty) {
26981 glyphId = cid;
26982 } else if (cidToGidMap[cid] !== undefined) {
26983 glyphId = cidToGidMap[cid];
26984 }
26985
26986 if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
26987 charCodeToGlyphId[charCode] = glyphId;
26988 }
26989 });
26990 } else {
26991 var cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont, properties.hasEncoding);
26992 var cmapPlatformId = cmapTable.platformId;
26993 var cmapEncodingId = cmapTable.encodingId;
26994 var cmapMappings = cmapTable.mappings;
26995 var cmapMappingsLength = cmapMappings.length;
26996
26997 if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!(0, _encodings.getEncoding)(properties.baseEncodingName)) {
26998 var baseEncoding = [];
26999
27000 if (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding") {
27001 baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
27002 }
27003
27004 var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
27005
27006 for (let charCode = 0; charCode < 256; charCode++) {
27007 var glyphName, standardGlyphName;
27008
27009 if (this.differences && charCode in this.differences) {
27010 glyphName = this.differences[charCode];
27011 } else if (charCode in baseEncoding && baseEncoding[charCode] !== "") {
27012 glyphName = baseEncoding[charCode];
27013 } else {
27014 glyphName = _encodings.StandardEncoding[charCode];
27015 }
27016
27017 if (!glyphName) {
27018 continue;
27019 }
27020
27021 standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
27022 var unicodeOrCharCode;
27023
27024 if (cmapPlatformId === 3 && cmapEncodingId === 1) {
27025 unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
27026 } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
27027 unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
27028 }
27029
27030 var found = false;
27031
27032 for (let i = 0; i < cmapMappingsLength; ++i) {
27033 if (cmapMappings[i].charCode !== unicodeOrCharCode) {
27034 continue;
27035 }
27036
27037 charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
27038 found = true;
27039 break;
27040 }
27041
27042 if (!found && properties.glyphNames) {
27043 var glyphId = properties.glyphNames.indexOf(glyphName);
27044
27045 if (glyphId === -1 && standardGlyphName !== glyphName) {
27046 glyphId = properties.glyphNames.indexOf(standardGlyphName);
27047 }
27048
27049 if (glyphId > 0 && hasGlyph(glyphId)) {
27050 charCodeToGlyphId[charCode] = glyphId;
27051 }
27052 }
27053 }
27054 } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
27055 for (let i = 0; i < cmapMappingsLength; ++i) {
27056 charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
27057 }
27058 } else {
27059 for (let i = 0; i < cmapMappingsLength; ++i) {
27060 let charCode = cmapMappings[i].charCode;
27061
27062 if (cmapPlatformId === 3 && charCode >= 0xf000 && charCode <= 0xf0ff) {
27063 charCode &= 0xff;
27064 }
27065
27066 charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
27067 }
27068 }
27069 }
27070
27071 if (charCodeToGlyphId.length === 0) {
27072 charCodeToGlyphId[0] = 0;
27073 }
27074
27075 let glyphZeroId = numGlyphsOut - 1;
27076
27077 if (!dupFirstEntry) {
27078 glyphZeroId = 0;
27079 }
27080
27081 var newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId);
27082 this.toFontChar = newMapping.toFontChar;
27083 tables.cmap = {
27084 tag: "cmap",
27085 data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphsOut)
27086 };
27087
27088 if (!tables["OS/2"] || !validateOS2Table(tables["OS/2"], font)) {
27089 tables["OS/2"] = {
27090 tag: "OS/2",
27091 data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
27092 };
27093 }
27094
27095 if (!isTrueType) {
27096 try {
27097 cffFile = new _stream.Stream(tables["CFF "].data);
27098 var parser = new _cff_parser.CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
27099 cff = parser.parse();
27100 cff.duplicateFirstGlyph();
27101 var compiler = new _cff_parser.CFFCompiler(cff);
27102 tables["CFF "].data = compiler.compile();
27103 } catch (e) {
27104 (0, _util.warn)("Failed to compile font " + properties.loadedName);
27105 }
27106 }
27107
27108 if (!tables.name) {
27109 tables.name = {
27110 tag: "name",
27111 data: createNameTable(this.name)
27112 };
27113 } else {
27114 var namePrototype = readNameTable(tables.name);
27115 tables.name.data = createNameTable(name, namePrototype);
27116 }
27117
27118 var builder = new OpenTypeFileBuilder(header.version);
27119
27120 for (var tableTag in tables) {
27121 builder.addTable(tableTag, tables[tableTag].data);
27122 }
27123
27124 return builder.toArray();
27125 },
27126 convert: function Font_convert(fontName, font, properties) {
27127 properties.fixedPitch = false;
27128
27129 if (properties.builtInEncoding) {
27130 adjustToUnicode(properties, properties.builtInEncoding);
27131 }
27132
27133 let glyphZeroId = 1;
27134
27135 if (font instanceof CFFFont) {
27136 glyphZeroId = font.numGlyphs - 1;
27137 }
27138
27139 var mapping = font.getGlyphMapping(properties);
27140 var newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId);
27141 this.toFontChar = newMapping.toFontChar;
27142 var numGlyphs = font.numGlyphs;
27143
27144 function getCharCodes(charCodeToGlyphId, glyphId) {
27145 var charCodes = null;
27146
27147 for (var charCode in charCodeToGlyphId) {
27148 if (glyphId === charCodeToGlyphId[charCode]) {
27149 if (!charCodes) {
27150 charCodes = [];
27151 }
27152
27153 charCodes.push(charCode | 0);
27154 }
27155 }
27156
27157 return charCodes;
27158 }
27159
27160 function createCharCode(charCodeToGlyphId, glyphId) {
27161 for (var charCode in charCodeToGlyphId) {
27162 if (glyphId === charCodeToGlyphId[charCode]) {
27163 return charCode | 0;
27164 }
27165 }
27166
27167 newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
27168 return newMapping.nextAvailableFontCharCode++;
27169 }
27170
27171 var seacs = font.seacs;
27172
27173 if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
27174 var matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;
27175 var charset = font.getCharset();
27176 var seacMap = Object.create(null);
27177
27178 for (var glyphId in seacs) {
27179 glyphId |= 0;
27180 var seac = seacs[glyphId];
27181 var baseGlyphName = _encodings.StandardEncoding[seac[2]];
27182 var accentGlyphName = _encodings.StandardEncoding[seac[3]];
27183 var baseGlyphId = charset.indexOf(baseGlyphName);
27184 var accentGlyphId = charset.indexOf(accentGlyphName);
27185
27186 if (baseGlyphId < 0 || accentGlyphId < 0) {
27187 continue;
27188 }
27189
27190 var accentOffset = {
27191 x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
27192 y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
27193 };
27194 var charCodes = getCharCodes(mapping, glyphId);
27195
27196 if (!charCodes) {
27197 continue;
27198 }
27199
27200 for (let i = 0, ii = charCodes.length; i < ii; i++) {
27201 var charCode = charCodes[i];
27202 var charCodeToGlyphId = newMapping.charCodeToGlyphId;
27203 var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
27204 var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
27205 seacMap[charCode] = {
27206 baseFontCharCode,
27207 accentFontCharCode,
27208 accentOffset
27209 };
27210 }
27211 }
27212
27213 properties.seacMap = seacMap;
27214 }
27215
27216 var unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
27217 var builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F");
27218 builder.addTable("CFF ", font.data);
27219 builder.addTable("OS/2", createOS2Table(properties, newMapping.charCodeToGlyphId));
27220 builder.addTable("cmap", createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
27221 builder.addTable("head", "\x00\x01\x00\x00" + "\x00\x00\x10\x00" + "\x00\x00\x00\x00" + "\x5F\x0F\x3C\xF5" + "\x00\x00" + safeString16(unitsPerEm) + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00" + safeString16(properties.descent) + "\x0F\xFF" + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + "\x00\x11" + "\x00\x00" + "\x00\x00" + "\x00\x00");
27222 builder.addTable("hhea", "\x00\x01\x00\x00" + safeString16(properties.ascent) + safeString16(properties.descent) + "\x00\x00" + "\xFF\xFF" + "\x00\x00" + "\x00\x00" + "\x00\x00" + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + string16(numGlyphs));
27223 builder.addTable("hmtx", function fontFieldsHmtx() {
27224 var charstrings = font.charstrings;
27225 var cffWidths = font.cff ? font.cff.widths : null;
27226 var hmtx = "\x00\x00\x00\x00";
27227
27228 for (let i = 1, ii = numGlyphs; i < ii; i++) {
27229 var width = 0;
27230
27231 if (charstrings) {
27232 var charstring = charstrings[i - 1];
27233 width = "width" in charstring ? charstring.width : 0;
27234 } else if (cffWidths) {
27235 width = Math.ceil(cffWidths[i] || 0);
27236 }
27237
27238 hmtx += string16(width) + string16(0);
27239 }
27240
27241 return hmtx;
27242 }());
27243 builder.addTable("maxp", "\x00\x00\x50\x00" + string16(numGlyphs));
27244 builder.addTable("name", createNameTable(fontName));
27245 builder.addTable("post", createPostTable(properties));
27246 return builder.toArray();
27247 },
27248
27249 get spaceWidth() {
27250 var possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
27251 var width;
27252
27253 for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
27254 var glyphName = possibleSpaceReplacements[i];
27255
27256 if (glyphName in this.widths) {
27257 width = this.widths[glyphName];
27258 break;
27259 }
27260
27261 var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
27262 var glyphUnicode = glyphsUnicodeMap[glyphName];
27263 var charcode = 0;
27264
27265 if (this.composite && this.cMap.contains(glyphUnicode)) {
27266 charcode = this.cMap.lookup(glyphUnicode);
27267 }
27268
27269 if (!charcode && this.toUnicode) {
27270 charcode = this.toUnicode.charCodeOf(glyphUnicode);
27271 }
27272
27273 if (charcode <= 0) {
27274 charcode = glyphUnicode;
27275 }
27276
27277 width = this.widths[charcode];
27278
27279 if (width) {
27280 break;
27281 }
27282 }
27283
27284 width = width || this.defaultWidth;
27285 return (0, _util.shadow)(this, "spaceWidth", width);
27286 },
27287
27288 charToGlyph: function Font_charToGlyph(charcode, isSpace) {
27289 var fontCharCode, width, operatorListId;
27290 var widthCode = charcode;
27291
27292 if (this.cMap && this.cMap.contains(charcode)) {
27293 widthCode = this.cMap.lookup(charcode);
27294 }
27295
27296 width = this.widths[widthCode];
27297 width = (0, _util.isNum)(width) ? width : this.defaultWidth;
27298 var vmetric = this.vmetrics && this.vmetrics[widthCode];
27299 let unicode = this.toUnicode.get(charcode) || this.fallbackToUnicode.get(charcode) || charcode;
27300
27301 if (typeof unicode === "number") {
27302 unicode = String.fromCharCode(unicode);
27303 }
27304
27305 var isInFont = (charcode in this.toFontChar);
27306 fontCharCode = this.toFontChar[charcode] || charcode;
27307
27308 if (this.missingFile) {
27309 const glyphName = this.differences[charcode] || this.defaultEncoding[charcode];
27310
27311 if ((glyphName === ".notdef" || glyphName === "") && this.type === "Type1") {
27312 fontCharCode = 0x20;
27313 }
27314
27315 fontCharCode = (0, _unicode.mapSpecialUnicodeValues)(fontCharCode);
27316 }
27317
27318 if (this.isType3Font) {
27319 operatorListId = fontCharCode;
27320 }
27321
27322 var accent = null;
27323
27324 if (this.seacMap && this.seacMap[charcode]) {
27325 isInFont = true;
27326 var seac = this.seacMap[charcode];
27327 fontCharCode = seac.baseFontCharCode;
27328 accent = {
27329 fontChar: String.fromCodePoint(seac.accentFontCharCode),
27330 offset: seac.accentOffset
27331 };
27332 }
27333
27334 let fontChar = "";
27335
27336 if (typeof fontCharCode === "number") {
27337 if (fontCharCode <= 0x10ffff) {
27338 fontChar = String.fromCodePoint(fontCharCode);
27339 } else {
27340 (0, _util.warn)(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
27341 }
27342 }
27343
27344 var glyph = this.glyphCache[charcode];
27345
27346 if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
27347 glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
27348 this.glyphCache[charcode] = glyph;
27349 }
27350
27351 return glyph;
27352 },
27353 charsToGlyphs: function Font_charsToGlyphs(chars) {
27354 var charsCache = this.charsCache;
27355 var glyphs, glyph, charcode;
27356
27357 if (charsCache) {
27358 glyphs = charsCache[chars];
27359
27360 if (glyphs) {
27361 return glyphs;
27362 }
27363 }
27364
27365 if (!charsCache) {
27366 charsCache = this.charsCache = Object.create(null);
27367 }
27368
27369 glyphs = [];
27370 var charsCacheKey = chars;
27371 var i = 0,
27372 ii;
27373
27374 if (this.cMap) {
27375 var c = Object.create(null);
27376
27377 while (i < chars.length) {
27378 this.cMap.readCharCode(chars, i, c);
27379 charcode = c.charcode;
27380 var length = c.length;
27381 i += length;
27382 var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
27383 glyph = this.charToGlyph(charcode, isSpace);
27384 glyphs.push(glyph);
27385 }
27386 } else {
27387 for (i = 0, ii = chars.length; i < ii; ++i) {
27388 charcode = chars.charCodeAt(i);
27389 glyph = this.charToGlyph(charcode, charcode === 0x20);
27390 glyphs.push(glyph);
27391 }
27392 }
27393
27394 return charsCache[charsCacheKey] = glyphs;
27395 },
27396
27397 get glyphCacheValues() {
27398 return Object.values(this.glyphCache);
27399 }
27400
27401 };
27402 return Font;
27403}();
27404
27405exports.Font = Font;
27406
27407var ErrorFont = function ErrorFontClosure() {
27408 function ErrorFont(error) {
27409 this.error = error;
27410 this.loadedName = "g_font_error";
27411 this.missingFile = true;
27412 }
27413
27414 ErrorFont.prototype = {
27415 charsToGlyphs: function ErrorFont_charsToGlyphs() {
27416 return [];
27417 },
27418
27419 exportData(extraProperties = false) {
27420 return {
27421 error: this.error
27422 };
27423 }
27424
27425 };
27426 return ErrorFont;
27427}();
27428
27429exports.ErrorFont = ErrorFont;
27430
27431function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
27432 var charCodeToGlyphId = Object.create(null);
27433 var glyphId, charCode, baseEncoding;
27434 var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
27435
27436 if (properties.baseEncodingName) {
27437 baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
27438
27439 for (charCode = 0; charCode < baseEncoding.length; charCode++) {
27440 glyphId = glyphNames.indexOf(baseEncoding[charCode]);
27441
27442 if (glyphId >= 0) {
27443 charCodeToGlyphId[charCode] = glyphId;
27444 } else {
27445 charCodeToGlyphId[charCode] = 0;
27446 }
27447 }
27448 } else if (isSymbolicFont) {
27449 for (charCode in builtInEncoding) {
27450 charCodeToGlyphId[charCode] = builtInEncoding[charCode];
27451 }
27452 } else {
27453 baseEncoding = _encodings.StandardEncoding;
27454
27455 for (charCode = 0; charCode < baseEncoding.length; charCode++) {
27456 glyphId = glyphNames.indexOf(baseEncoding[charCode]);
27457
27458 if (glyphId >= 0) {
27459 charCodeToGlyphId[charCode] = glyphId;
27460 } else {
27461 charCodeToGlyphId[charCode] = 0;
27462 }
27463 }
27464 }
27465
27466 var differences = properties.differences,
27467 glyphsUnicodeMap;
27468
27469 if (differences) {
27470 for (charCode in differences) {
27471 var glyphName = differences[charCode];
27472 glyphId = glyphNames.indexOf(glyphName);
27473
27474 if (glyphId === -1) {
27475 if (!glyphsUnicodeMap) {
27476 glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
27477 }
27478
27479 var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
27480
27481 if (standardGlyphName !== glyphName) {
27482 glyphId = glyphNames.indexOf(standardGlyphName);
27483 }
27484 }
27485
27486 if (glyphId >= 0) {
27487 charCodeToGlyphId[charCode] = glyphId;
27488 } else {
27489 charCodeToGlyphId[charCode] = 0;
27490 }
27491 }
27492 }
27493
27494 return charCodeToGlyphId;
27495}
27496
27497var Type1Font = function Type1FontClosure() {
27498 function findBlock(streamBytes, signature, startIndex) {
27499 var streamBytesLength = streamBytes.length;
27500 var signatureLength = signature.length;
27501 var scanLength = streamBytesLength - signatureLength;
27502 var i = startIndex,
27503 j,
27504 found = false;
27505
27506 while (i < scanLength) {
27507 j = 0;
27508
27509 while (j < signatureLength && streamBytes[i + j] === signature[j]) {
27510 j++;
27511 }
27512
27513 if (j >= signatureLength) {
27514 i += j;
27515
27516 while (i < streamBytesLength && (0, _core_utils.isWhiteSpace)(streamBytes[i])) {
27517 i++;
27518 }
27519
27520 found = true;
27521 break;
27522 }
27523
27524 i++;
27525 }
27526
27527 return {
27528 found,
27529 length: i
27530 };
27531 }
27532
27533 function getHeaderBlock(stream, suggestedLength) {
27534 var EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
27535 var streamStartPos = stream.pos;
27536 var headerBytes, headerBytesLength, block;
27537
27538 try {
27539 headerBytes = stream.getBytes(suggestedLength);
27540 headerBytesLength = headerBytes.length;
27541 } catch (ex) {
27542 if (ex instanceof _core_utils.MissingDataException) {
27543 throw ex;
27544 }
27545 }
27546
27547 if (headerBytesLength === suggestedLength) {
27548 block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
27549
27550 if (block.found && block.length === suggestedLength) {
27551 return {
27552 stream: new _stream.Stream(headerBytes),
27553 length: suggestedLength
27554 };
27555 }
27556 }
27557
27558 (0, _util.warn)('Invalid "Length1" property in Type1 font -- trying to recover.');
27559 stream.pos = streamStartPos;
27560 var SCAN_BLOCK_LENGTH = 2048;
27561 var actualLength;
27562
27563 while (true) {
27564 var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
27565 block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
27566
27567 if (block.length === 0) {
27568 break;
27569 }
27570
27571 stream.pos += block.length;
27572
27573 if (block.found) {
27574 actualLength = stream.pos - streamStartPos;
27575 break;
27576 }
27577 }
27578
27579 stream.pos = streamStartPos;
27580
27581 if (actualLength) {
27582 return {
27583 stream: new _stream.Stream(stream.getBytes(actualLength)),
27584 length: actualLength
27585 };
27586 }
27587
27588 (0, _util.warn)('Unable to recover "Length1" property in Type1 font -- using as is.');
27589 return {
27590 stream: new _stream.Stream(stream.getBytes(suggestedLength)),
27591 length: suggestedLength
27592 };
27593 }
27594
27595 function getEexecBlock(stream, suggestedLength) {
27596 var eexecBytes = stream.getBytes();
27597 return {
27598 stream: new _stream.Stream(eexecBytes),
27599 length: eexecBytes.length
27600 };
27601 }
27602
27603 function Type1Font(name, file, properties) {
27604 var PFB_HEADER_SIZE = 6;
27605 var headerBlockLength = properties.length1;
27606 var eexecBlockLength = properties.length2;
27607 var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
27608 var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
27609
27610 if (pfbHeaderPresent) {
27611 file.skip(PFB_HEADER_SIZE);
27612 headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
27613 }
27614
27615 var headerBlock = getHeaderBlock(file, headerBlockLength);
27616 var headerBlockParser = new _type1_parser.Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
27617 headerBlockParser.extractFontHeader(properties);
27618
27619 if (pfbHeaderPresent) {
27620 pfbHeader = file.getBytes(PFB_HEADER_SIZE);
27621 eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
27622 }
27623
27624 var eexecBlock = getEexecBlock(file, eexecBlockLength);
27625 var eexecBlockParser = new _type1_parser.Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
27626 var data = eexecBlockParser.extractFontProgram(properties);
27627
27628 for (const key in data.properties) {
27629 properties[key] = data.properties[key];
27630 }
27631
27632 var charstrings = data.charstrings;
27633 var type2Charstrings = this.getType2Charstrings(charstrings);
27634 var subrs = this.getType2Subrs(data.subrs);
27635 this.charstrings = charstrings;
27636 this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
27637 this.seacs = this.getSeacs(data.charstrings);
27638 }
27639
27640 Type1Font.prototype = {
27641 get numGlyphs() {
27642 return this.charstrings.length + 1;
27643 },
27644
27645 getCharset: function Type1Font_getCharset() {
27646 var charset = [".notdef"];
27647 var charstrings = this.charstrings;
27648
27649 for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
27650 charset.push(charstrings[glyphId].glyphName);
27651 }
27652
27653 return charset;
27654 },
27655 getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
27656 var charstrings = this.charstrings;
27657
27658 if (properties.composite) {
27659 const charCodeToGlyphId = Object.create(null);
27660
27661 for (let glyphId = 0, charstringsLen = charstrings.length; glyphId < charstringsLen; glyphId++) {
27662 const charCode = properties.cMap.charCodeOf(glyphId);
27663 charCodeToGlyphId[charCode] = glyphId + 1;
27664 }
27665
27666 return charCodeToGlyphId;
27667 }
27668
27669 var glyphNames = [".notdef"],
27670 glyphId;
27671
27672 for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
27673 glyphNames.push(charstrings[glyphId].glyphName);
27674 }
27675
27676 var encoding = properties.builtInEncoding;
27677
27678 if (encoding) {
27679 var builtInEncoding = Object.create(null);
27680
27681 for (var charCode in encoding) {
27682 glyphId = glyphNames.indexOf(encoding[charCode]);
27683
27684 if (glyphId >= 0) {
27685 builtInEncoding[charCode] = glyphId;
27686 }
27687 }
27688 }
27689
27690 return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
27691 },
27692 hasGlyphId: function Type1Font_hasGlyphID(id) {
27693 if (id < 0 || id >= this.numGlyphs) {
27694 return false;
27695 }
27696
27697 if (id === 0) {
27698 return true;
27699 }
27700
27701 var glyph = this.charstrings[id - 1];
27702 return glyph.charstring.length > 0;
27703 },
27704 getSeacs: function Type1Font_getSeacs(charstrings) {
27705 var i, ii;
27706 var seacMap = [];
27707
27708 for (i = 0, ii = charstrings.length; i < ii; i++) {
27709 var charstring = charstrings[i];
27710
27711 if (charstring.seac) {
27712 seacMap[i + 1] = charstring.seac;
27713 }
27714 }
27715
27716 return seacMap;
27717 },
27718 getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
27719 var type2Charstrings = [];
27720
27721 for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
27722 type2Charstrings.push(type1Charstrings[i].charstring);
27723 }
27724
27725 return type2Charstrings;
27726 },
27727 getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
27728 var bias = 0;
27729 var count = type1Subrs.length;
27730
27731 if (count < 1133) {
27732 bias = 107;
27733 } else if (count < 33769) {
27734 bias = 1131;
27735 } else {
27736 bias = 32768;
27737 }
27738
27739 var type2Subrs = [];
27740 var i;
27741
27742 for (i = 0; i < bias; i++) {
27743 type2Subrs.push([0x0b]);
27744 }
27745
27746 for (i = 0; i < count; i++) {
27747 type2Subrs.push(type1Subrs[i]);
27748 }
27749
27750 return type2Subrs;
27751 },
27752 wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
27753 var cff = new _cff_parser.CFF();
27754 cff.header = new _cff_parser.CFFHeader(1, 0, 4, 4);
27755 cff.names = [name];
27756 var topDict = new _cff_parser.CFFTopDict();
27757 topDict.setByName("version", 391);
27758 topDict.setByName("Notice", 392);
27759 topDict.setByName("FullName", 393);
27760 topDict.setByName("FamilyName", 394);
27761 topDict.setByName("Weight", 395);
27762 topDict.setByName("Encoding", null);
27763 topDict.setByName("FontMatrix", properties.fontMatrix);
27764 topDict.setByName("FontBBox", properties.bbox);
27765 topDict.setByName("charset", null);
27766 topDict.setByName("CharStrings", null);
27767 topDict.setByName("Private", null);
27768 cff.topDict = topDict;
27769 var strings = new _cff_parser.CFFStrings();
27770 strings.add("Version 0.11");
27771 strings.add("See original notice");
27772 strings.add(name);
27773 strings.add(name);
27774 strings.add("Medium");
27775 cff.strings = strings;
27776 cff.globalSubrIndex = new _cff_parser.CFFIndex();
27777 var count = glyphs.length;
27778 var charsetArray = [".notdef"];
27779 var i, ii;
27780
27781 for (i = 0; i < count; i++) {
27782 const glyphName = charstrings[i].glyphName;
27783
27784 const index = _cff_parser.CFFStandardStrings.indexOf(glyphName);
27785
27786 if (index === -1) {
27787 strings.add(glyphName);
27788 }
27789
27790 charsetArray.push(glyphName);
27791 }
27792
27793 cff.charset = new _cff_parser.CFFCharset(false, 0, charsetArray);
27794 var charStringsIndex = new _cff_parser.CFFIndex();
27795 charStringsIndex.add([0x8b, 0x0e]);
27796
27797 for (i = 0; i < count; i++) {
27798 charStringsIndex.add(glyphs[i]);
27799 }
27800
27801 cff.charStrings = charStringsIndex;
27802 var privateDict = new _cff_parser.CFFPrivateDict();
27803 privateDict.setByName("Subrs", null);
27804 var fields = ["BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues", "StemSnapH", "StemSnapV", "BlueShift", "BlueFuzz", "BlueScale", "LanguageGroup", "ExpansionFactor", "ForceBold", "StdHW", "StdVW"];
27805
27806 for (i = 0, ii = fields.length; i < ii; i++) {
27807 var field = fields[i];
27808
27809 if (!(field in properties.privateData)) {
27810 continue;
27811 }
27812
27813 var value = properties.privateData[field];
27814
27815 if (Array.isArray(value)) {
27816 for (var j = value.length - 1; j > 0; j--) {
27817 value[j] -= value[j - 1];
27818 }
27819 }
27820
27821 privateDict.setByName(field, value);
27822 }
27823
27824 cff.topDict.privateDict = privateDict;
27825 var subrIndex = new _cff_parser.CFFIndex();
27826
27827 for (i = 0, ii = subrs.length; i < ii; i++) {
27828 subrIndex.add(subrs[i]);
27829 }
27830
27831 privateDict.subrsIndex = subrIndex;
27832 var compiler = new _cff_parser.CFFCompiler(cff);
27833 return compiler.compile();
27834 }
27835 };
27836 return Type1Font;
27837}();
27838
27839var CFFFont = function CFFFontClosure() {
27840 function CFFFont(file, properties) {
27841 this.properties = properties;
27842 var parser = new _cff_parser.CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
27843 this.cff = parser.parse();
27844 this.cff.duplicateFirstGlyph();
27845 var compiler = new _cff_parser.CFFCompiler(this.cff);
27846 this.seacs = this.cff.seacs;
27847
27848 try {
27849 this.data = compiler.compile();
27850 } catch (e) {
27851 (0, _util.warn)("Failed to compile font " + properties.loadedName);
27852 this.data = file;
27853 }
27854 }
27855
27856 CFFFont.prototype = {
27857 get numGlyphs() {
27858 return this.cff.charStrings.count;
27859 },
27860
27861 getCharset: function CFFFont_getCharset() {
27862 return this.cff.charset.charset;
27863 },
27864 getGlyphMapping: function CFFFont_getGlyphMapping() {
27865 var cff = this.cff;
27866 var properties = this.properties;
27867 var charsets = cff.charset.charset;
27868 var charCodeToGlyphId;
27869 var glyphId;
27870
27871 if (properties.composite) {
27872 charCodeToGlyphId = Object.create(null);
27873 let charCode;
27874
27875 if (cff.isCIDFont) {
27876 for (glyphId = 0; glyphId < charsets.length; glyphId++) {
27877 var cid = charsets[glyphId];
27878 charCode = properties.cMap.charCodeOf(cid);
27879 charCodeToGlyphId[charCode] = glyphId;
27880 }
27881 } else {
27882 for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
27883 charCode = properties.cMap.charCodeOf(glyphId);
27884 charCodeToGlyphId[charCode] = glyphId;
27885 }
27886 }
27887
27888 return charCodeToGlyphId;
27889 }
27890
27891 var encoding = cff.encoding ? cff.encoding.encoding : null;
27892 charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
27893 return charCodeToGlyphId;
27894 },
27895 hasGlyphId: function CFFFont_hasGlyphID(id) {
27896 return this.cff.hasGlyphId(id);
27897 }
27898 };
27899 return CFFFont;
27900}();
27901
27902/***/ }),
27903/* 30 */
27904/***/ (function(module, exports, __w_pdfjs_require__) {
27905
27906"use strict";
27907
27908
27909Object.defineProperty(exports, "__esModule", {
27910 value: true
27911});
27912exports.CFFFDSelect = exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = void 0;
27913
27914var _util = __w_pdfjs_require__(2);
27915
27916var _charsets = __w_pdfjs_require__(31);
27917
27918var _encodings = __w_pdfjs_require__(32);
27919
27920var MAX_SUBR_NESTING = 10;
27921var CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
27922exports.CFFStandardStrings = CFFStandardStrings;
27923const NUM_STANDARD_CFF_STRINGS = 391;
27924
27925var CFFParser = function CFFParserClosure() {
27926 var CharstringValidationData = [null, {
27927 id: "hstem",
27928 min: 2,
27929 stackClearing: true,
27930 stem: true
27931 }, null, {
27932 id: "vstem",
27933 min: 2,
27934 stackClearing: true,
27935 stem: true
27936 }, {
27937 id: "vmoveto",
27938 min: 1,
27939 stackClearing: true
27940 }, {
27941 id: "rlineto",
27942 min: 2,
27943 resetStack: true
27944 }, {
27945 id: "hlineto",
27946 min: 1,
27947 resetStack: true
27948 }, {
27949 id: "vlineto",
27950 min: 1,
27951 resetStack: true
27952 }, {
27953 id: "rrcurveto",
27954 min: 6,
27955 resetStack: true
27956 }, null, {
27957 id: "callsubr",
27958 min: 1,
27959 undefStack: true
27960 }, {
27961 id: "return",
27962 min: 0,
27963 undefStack: true
27964 }, null, null, {
27965 id: "endchar",
27966 min: 0,
27967 stackClearing: true
27968 }, null, null, null, {
27969 id: "hstemhm",
27970 min: 2,
27971 stackClearing: true,
27972 stem: true
27973 }, {
27974 id: "hintmask",
27975 min: 0,
27976 stackClearing: true
27977 }, {
27978 id: "cntrmask",
27979 min: 0,
27980 stackClearing: true
27981 }, {
27982 id: "rmoveto",
27983 min: 2,
27984 stackClearing: true
27985 }, {
27986 id: "hmoveto",
27987 min: 1,
27988 stackClearing: true
27989 }, {
27990 id: "vstemhm",
27991 min: 2,
27992 stackClearing: true,
27993 stem: true
27994 }, {
27995 id: "rcurveline",
27996 min: 8,
27997 resetStack: true
27998 }, {
27999 id: "rlinecurve",
28000 min: 8,
28001 resetStack: true
28002 }, {
28003 id: "vvcurveto",
28004 min: 4,
28005 resetStack: true
28006 }, {
28007 id: "hhcurveto",
28008 min: 4,
28009 resetStack: true
28010 }, null, {
28011 id: "callgsubr",
28012 min: 1,
28013 undefStack: true
28014 }, {
28015 id: "vhcurveto",
28016 min: 4,
28017 resetStack: true
28018 }, {
28019 id: "hvcurveto",
28020 min: 4,
28021 resetStack: true
28022 }];
28023 var CharstringValidationData12 = [null, null, null, {
28024 id: "and",
28025 min: 2,
28026 stackDelta: -1
28027 }, {
28028 id: "or",
28029 min: 2,
28030 stackDelta: -1
28031 }, {
28032 id: "not",
28033 min: 1,
28034 stackDelta: 0
28035 }, null, null, null, {
28036 id: "abs",
28037 min: 1,
28038 stackDelta: 0
28039 }, {
28040 id: "add",
28041 min: 2,
28042 stackDelta: -1,
28043 stackFn: function stack_div(stack, index) {
28044 stack[index - 2] = stack[index - 2] + stack[index - 1];
28045 }
28046 }, {
28047 id: "sub",
28048 min: 2,
28049 stackDelta: -1,
28050 stackFn: function stack_div(stack, index) {
28051 stack[index - 2] = stack[index - 2] - stack[index - 1];
28052 }
28053 }, {
28054 id: "div",
28055 min: 2,
28056 stackDelta: -1,
28057 stackFn: function stack_div(stack, index) {
28058 stack[index - 2] = stack[index - 2] / stack[index - 1];
28059 }
28060 }, null, {
28061 id: "neg",
28062 min: 1,
28063 stackDelta: 0,
28064 stackFn: function stack_div(stack, index) {
28065 stack[index - 1] = -stack[index - 1];
28066 }
28067 }, {
28068 id: "eq",
28069 min: 2,
28070 stackDelta: -1
28071 }, null, null, {
28072 id: "drop",
28073 min: 1,
28074 stackDelta: -1
28075 }, null, {
28076 id: "put",
28077 min: 2,
28078 stackDelta: -2
28079 }, {
28080 id: "get",
28081 min: 1,
28082 stackDelta: 0
28083 }, {
28084 id: "ifelse",
28085 min: 4,
28086 stackDelta: -3
28087 }, {
28088 id: "random",
28089 min: 0,
28090 stackDelta: 1
28091 }, {
28092 id: "mul",
28093 min: 2,
28094 stackDelta: -1,
28095 stackFn: function stack_div(stack, index) {
28096 stack[index - 2] = stack[index - 2] * stack[index - 1];
28097 }
28098 }, null, {
28099 id: "sqrt",
28100 min: 1,
28101 stackDelta: 0
28102 }, {
28103 id: "dup",
28104 min: 1,
28105 stackDelta: 1
28106 }, {
28107 id: "exch",
28108 min: 2,
28109 stackDelta: 0
28110 }, {
28111 id: "index",
28112 min: 2,
28113 stackDelta: 0
28114 }, {
28115 id: "roll",
28116 min: 3,
28117 stackDelta: -2
28118 }, null, null, null, {
28119 id: "hflex",
28120 min: 7,
28121 resetStack: true
28122 }, {
28123 id: "flex",
28124 min: 13,
28125 resetStack: true
28126 }, {
28127 id: "hflex1",
28128 min: 9,
28129 resetStack: true
28130 }, {
28131 id: "flex1",
28132 min: 11,
28133 resetStack: true
28134 }];
28135
28136 function CFFParser(file, properties, seacAnalysisEnabled) {
28137 this.bytes = file.getBytes();
28138 this.properties = properties;
28139 this.seacAnalysisEnabled = !!seacAnalysisEnabled;
28140 }
28141
28142 CFFParser.prototype = {
28143 parse: function CFFParser_parse() {
28144 var properties = this.properties;
28145 var cff = new CFF();
28146 this.cff = cff;
28147 var header = this.parseHeader();
28148 var nameIndex = this.parseIndex(header.endPos);
28149 var topDictIndex = this.parseIndex(nameIndex.endPos);
28150 var stringIndex = this.parseIndex(topDictIndex.endPos);
28151 var globalSubrIndex = this.parseIndex(stringIndex.endPos);
28152 var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
28153 var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
28154 cff.header = header.obj;
28155 cff.names = this.parseNameIndex(nameIndex.obj);
28156 cff.strings = this.parseStringIndex(stringIndex.obj);
28157 cff.topDict = topDict;
28158 cff.globalSubrIndex = globalSubrIndex.obj;
28159 this.parsePrivateDict(cff.topDict);
28160 cff.isCIDFont = topDict.hasName("ROS");
28161 var charStringOffset = topDict.getByName("CharStrings");
28162 var charStringIndex = this.parseIndex(charStringOffset).obj;
28163 var fontMatrix = topDict.getByName("FontMatrix");
28164
28165 if (fontMatrix) {
28166 properties.fontMatrix = fontMatrix;
28167 }
28168
28169 var fontBBox = topDict.getByName("FontBBox");
28170
28171 if (fontBBox) {
28172 properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
28173 properties.descent = Math.min(fontBBox[1], fontBBox[3]);
28174 properties.ascentScaled = true;
28175 }
28176
28177 var charset, encoding;
28178
28179 if (cff.isCIDFont) {
28180 var fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
28181
28182 for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
28183 var dictRaw = fdArrayIndex.get(i);
28184 var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
28185 this.parsePrivateDict(fontDict);
28186 cff.fdArray.push(fontDict);
28187 }
28188
28189 encoding = null;
28190 charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, true);
28191 cff.fdSelect = this.parseFDSelect(topDict.getByName("FDSelect"), charStringIndex.count);
28192 } else {
28193 charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, false);
28194 encoding = this.parseEncoding(topDict.getByName("Encoding"), properties, cff.strings, charset.charset);
28195 }
28196
28197 cff.charset = charset;
28198 cff.encoding = encoding;
28199 var charStringsAndSeacs = this.parseCharStrings({
28200 charStrings: charStringIndex,
28201 localSubrIndex: topDict.privateDict.subrsIndex,
28202 globalSubrIndex: globalSubrIndex.obj,
28203 fdSelect: cff.fdSelect,
28204 fdArray: cff.fdArray,
28205 privateDict: topDict.privateDict
28206 });
28207 cff.charStrings = charStringsAndSeacs.charStrings;
28208 cff.seacs = charStringsAndSeacs.seacs;
28209 cff.widths = charStringsAndSeacs.widths;
28210 return cff;
28211 },
28212 parseHeader: function CFFParser_parseHeader() {
28213 var bytes = this.bytes;
28214 var bytesLength = bytes.length;
28215 var offset = 0;
28216
28217 while (offset < bytesLength && bytes[offset] !== 1) {
28218 ++offset;
28219 }
28220
28221 if (offset >= bytesLength) {
28222 throw new _util.FormatError("Invalid CFF header");
28223 }
28224
28225 if (offset !== 0) {
28226 (0, _util.info)("cff data is shifted");
28227 bytes = bytes.subarray(offset);
28228 this.bytes = bytes;
28229 }
28230
28231 var major = bytes[0];
28232 var minor = bytes[1];
28233 var hdrSize = bytes[2];
28234 var offSize = bytes[3];
28235 var header = new CFFHeader(major, minor, hdrSize, offSize);
28236 return {
28237 obj: header,
28238 endPos: hdrSize
28239 };
28240 },
28241 parseDict: function CFFParser_parseDict(dict) {
28242 var pos = 0;
28243
28244 function parseOperand() {
28245 var value = dict[pos++];
28246
28247 if (value === 30) {
28248 return parseFloatOperand();
28249 } else if (value === 28) {
28250 value = dict[pos++];
28251 value = (value << 24 | dict[pos++] << 16) >> 16;
28252 return value;
28253 } else if (value === 29) {
28254 value = dict[pos++];
28255 value = value << 8 | dict[pos++];
28256 value = value << 8 | dict[pos++];
28257 value = value << 8 | dict[pos++];
28258 return value;
28259 } else if (value >= 32 && value <= 246) {
28260 return value - 139;
28261 } else if (value >= 247 && value <= 250) {
28262 return (value - 247) * 256 + dict[pos++] + 108;
28263 } else if (value >= 251 && value <= 254) {
28264 return -((value - 251) * 256) - dict[pos++] - 108;
28265 }
28266
28267 (0, _util.warn)('CFFParser_parseDict: "' + value + '" is a reserved command.');
28268 return NaN;
28269 }
28270
28271 function parseFloatOperand() {
28272 var str = "";
28273 var eof = 15;
28274 const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
28275 var length = dict.length;
28276
28277 while (pos < length) {
28278 var b = dict[pos++];
28279 var b1 = b >> 4;
28280 var b2 = b & 15;
28281
28282 if (b1 === eof) {
28283 break;
28284 }
28285
28286 str += lookup[b1];
28287
28288 if (b2 === eof) {
28289 break;
28290 }
28291
28292 str += lookup[b2];
28293 }
28294
28295 return parseFloat(str);
28296 }
28297
28298 var operands = [];
28299 var entries = [];
28300 pos = 0;
28301 var end = dict.length;
28302
28303 while (pos < end) {
28304 var b = dict[pos];
28305
28306 if (b <= 21) {
28307 if (b === 12) {
28308 b = b << 8 | dict[++pos];
28309 }
28310
28311 entries.push([b, operands]);
28312 operands = [];
28313 ++pos;
28314 } else {
28315 operands.push(parseOperand());
28316 }
28317 }
28318
28319 return entries;
28320 },
28321 parseIndex: function CFFParser_parseIndex(pos) {
28322 var cffIndex = new CFFIndex();
28323 var bytes = this.bytes;
28324 var count = bytes[pos++] << 8 | bytes[pos++];
28325 var offsets = [];
28326 var end = pos;
28327 var i, ii;
28328
28329 if (count !== 0) {
28330 var offsetSize = bytes[pos++];
28331 var startPos = pos + (count + 1) * offsetSize - 1;
28332
28333 for (i = 0, ii = count + 1; i < ii; ++i) {
28334 var offset = 0;
28335
28336 for (var j = 0; j < offsetSize; ++j) {
28337 offset <<= 8;
28338 offset += bytes[pos++];
28339 }
28340
28341 offsets.push(startPos + offset);
28342 }
28343
28344 end = offsets[count];
28345 }
28346
28347 for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
28348 var offsetStart = offsets[i];
28349 var offsetEnd = offsets[i + 1];
28350 cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
28351 }
28352
28353 return {
28354 obj: cffIndex,
28355 endPos: end
28356 };
28357 },
28358 parseNameIndex: function CFFParser_parseNameIndex(index) {
28359 var names = [];
28360
28361 for (var i = 0, ii = index.count; i < ii; ++i) {
28362 var name = index.get(i);
28363 names.push((0, _util.bytesToString)(name));
28364 }
28365
28366 return names;
28367 },
28368 parseStringIndex: function CFFParser_parseStringIndex(index) {
28369 var strings = new CFFStrings();
28370
28371 for (var i = 0, ii = index.count; i < ii; ++i) {
28372 var data = index.get(i);
28373 strings.add((0, _util.bytesToString)(data));
28374 }
28375
28376 return strings;
28377 },
28378 createDict: function CFFParser_createDict(Type, dict, strings) {
28379 var cffDict = new Type(strings);
28380
28381 for (var i = 0, ii = dict.length; i < ii; ++i) {
28382 var pair = dict[i];
28383 var key = pair[0];
28384 var value = pair[1];
28385 cffDict.setByKey(key, value);
28386 }
28387
28388 return cffDict;
28389 },
28390 parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
28391 if (!data || state.callDepth > MAX_SUBR_NESTING) {
28392 return false;
28393 }
28394
28395 var stackSize = state.stackSize;
28396 var stack = state.stack;
28397 var length = data.length;
28398
28399 for (var j = 0; j < length;) {
28400 var value = data[j++];
28401 var validationCommand = null;
28402
28403 if (value === 12) {
28404 var q = data[j++];
28405
28406 if (q === 0) {
28407 data[j - 2] = 139;
28408 data[j - 1] = 22;
28409 stackSize = 0;
28410 } else {
28411 validationCommand = CharstringValidationData12[q];
28412 }
28413 } else if (value === 28) {
28414 stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
28415 j += 2;
28416 stackSize++;
28417 } else if (value === 14) {
28418 if (stackSize >= 4) {
28419 stackSize -= 4;
28420
28421 if (this.seacAnalysisEnabled) {
28422 state.seac = stack.slice(stackSize, stackSize + 4);
28423 return false;
28424 }
28425 }
28426
28427 validationCommand = CharstringValidationData[value];
28428 } else if (value >= 32 && value <= 246) {
28429 stack[stackSize] = value - 139;
28430 stackSize++;
28431 } else if (value >= 247 && value <= 254) {
28432 stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
28433 j++;
28434 stackSize++;
28435 } else if (value === 255) {
28436 stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
28437 j += 4;
28438 stackSize++;
28439 } else if (value === 19 || value === 20) {
28440 state.hints += stackSize >> 1;
28441 j += state.hints + 7 >> 3;
28442 stackSize %= 2;
28443 validationCommand = CharstringValidationData[value];
28444 } else if (value === 10 || value === 29) {
28445 var subrsIndex;
28446
28447 if (value === 10) {
28448 subrsIndex = localSubrIndex;
28449 } else {
28450 subrsIndex = globalSubrIndex;
28451 }
28452
28453 if (!subrsIndex) {
28454 validationCommand = CharstringValidationData[value];
28455 (0, _util.warn)("Missing subrsIndex for " + validationCommand.id);
28456 return false;
28457 }
28458
28459 var bias = 32768;
28460
28461 if (subrsIndex.count < 1240) {
28462 bias = 107;
28463 } else if (subrsIndex.count < 33900) {
28464 bias = 1131;
28465 }
28466
28467 var subrNumber = stack[--stackSize] + bias;
28468
28469 if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
28470 validationCommand = CharstringValidationData[value];
28471 (0, _util.warn)("Out of bounds subrIndex for " + validationCommand.id);
28472 return false;
28473 }
28474
28475 state.stackSize = stackSize;
28476 state.callDepth++;
28477 var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
28478
28479 if (!valid) {
28480 return false;
28481 }
28482
28483 state.callDepth--;
28484 stackSize = state.stackSize;
28485 continue;
28486 } else if (value === 11) {
28487 state.stackSize = stackSize;
28488 return true;
28489 } else {
28490 validationCommand = CharstringValidationData[value];
28491 }
28492
28493 if (validationCommand) {
28494 if (validationCommand.stem) {
28495 state.hints += stackSize >> 1;
28496
28497 if (value === 3 || value === 23) {
28498 state.hasVStems = true;
28499 } else if (state.hasVStems && (value === 1 || value === 18)) {
28500 (0, _util.warn)("CFF stem hints are in wrong order");
28501 data[j - 1] = value === 1 ? 3 : 23;
28502 }
28503 }
28504
28505 if ("min" in validationCommand) {
28506 if (!state.undefStack && stackSize < validationCommand.min) {
28507 (0, _util.warn)("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
28508 return false;
28509 }
28510 }
28511
28512 if (state.firstStackClearing && validationCommand.stackClearing) {
28513 state.firstStackClearing = false;
28514 stackSize -= validationCommand.min;
28515
28516 if (stackSize >= 2 && validationCommand.stem) {
28517 stackSize %= 2;
28518 } else if (stackSize > 1) {
28519 (0, _util.warn)("Found too many parameters for stack-clearing command");
28520 }
28521
28522 if (stackSize > 0 && stack[stackSize - 1] >= 0) {
28523 state.width = stack[stackSize - 1];
28524 }
28525 }
28526
28527 if ("stackDelta" in validationCommand) {
28528 if ("stackFn" in validationCommand) {
28529 validationCommand.stackFn(stack, stackSize);
28530 }
28531
28532 stackSize += validationCommand.stackDelta;
28533 } else if (validationCommand.stackClearing) {
28534 stackSize = 0;
28535 } else if (validationCommand.resetStack) {
28536 stackSize = 0;
28537 state.undefStack = false;
28538 } else if (validationCommand.undefStack) {
28539 stackSize = 0;
28540 state.undefStack = true;
28541 state.firstStackClearing = false;
28542 }
28543 }
28544 }
28545
28546 state.stackSize = stackSize;
28547 return true;
28548 },
28549
28550 parseCharStrings({
28551 charStrings,
28552 localSubrIndex,
28553 globalSubrIndex,
28554 fdSelect,
28555 fdArray,
28556 privateDict
28557 }) {
28558 var seacs = [];
28559 var widths = [];
28560 var count = charStrings.count;
28561
28562 for (var i = 0; i < count; i++) {
28563 var charstring = charStrings.get(i);
28564 var state = {
28565 callDepth: 0,
28566 stackSize: 0,
28567 stack: [],
28568 undefStack: true,
28569 hints: 0,
28570 firstStackClearing: true,
28571 seac: null,
28572 width: null,
28573 hasVStems: false
28574 };
28575 var valid = true;
28576 var localSubrToUse = null;
28577 var privateDictToUse = privateDict;
28578
28579 if (fdSelect && fdArray.length) {
28580 var fdIndex = fdSelect.getFDIndex(i);
28581
28582 if (fdIndex === -1) {
28583 (0, _util.warn)("Glyph index is not in fd select.");
28584 valid = false;
28585 }
28586
28587 if (fdIndex >= fdArray.length) {
28588 (0, _util.warn)("Invalid fd index for glyph index.");
28589 valid = false;
28590 }
28591
28592 if (valid) {
28593 privateDictToUse = fdArray[fdIndex].privateDict;
28594 localSubrToUse = privateDictToUse.subrsIndex;
28595 }
28596 } else if (localSubrIndex) {
28597 localSubrToUse = localSubrIndex;
28598 }
28599
28600 if (valid) {
28601 valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
28602 }
28603
28604 if (state.width !== null) {
28605 const nominalWidth = privateDictToUse.getByName("nominalWidthX");
28606 widths[i] = nominalWidth + state.width;
28607 } else {
28608 const defaultWidth = privateDictToUse.getByName("defaultWidthX");
28609 widths[i] = defaultWidth;
28610 }
28611
28612 if (state.seac !== null) {
28613 seacs[i] = state.seac;
28614 }
28615
28616 if (!valid) {
28617 charStrings.set(i, new Uint8Array([14]));
28618 }
28619 }
28620
28621 return {
28622 charStrings,
28623 seacs,
28624 widths
28625 };
28626 },
28627
28628 emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
28629 var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
28630 parentDict.setByKey(18, [0, 0]);
28631 parentDict.privateDict = privateDict;
28632 },
28633 parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
28634 if (!parentDict.hasName("Private")) {
28635 this.emptyPrivateDictionary(parentDict);
28636 return;
28637 }
28638
28639 var privateOffset = parentDict.getByName("Private");
28640
28641 if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
28642 parentDict.removeByName("Private");
28643 return;
28644 }
28645
28646 var size = privateOffset[0];
28647 var offset = privateOffset[1];
28648
28649 if (size === 0 || offset >= this.bytes.length) {
28650 this.emptyPrivateDictionary(parentDict);
28651 return;
28652 }
28653
28654 var privateDictEnd = offset + size;
28655 var dictData = this.bytes.subarray(offset, privateDictEnd);
28656 var dict = this.parseDict(dictData);
28657 var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
28658 parentDict.privateDict = privateDict;
28659
28660 if (!privateDict.getByName("Subrs")) {
28661 return;
28662 }
28663
28664 var subrsOffset = privateDict.getByName("Subrs");
28665 var relativeOffset = offset + subrsOffset;
28666
28667 if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
28668 this.emptyPrivateDictionary(parentDict);
28669 return;
28670 }
28671
28672 var subrsIndex = this.parseIndex(relativeOffset);
28673 privateDict.subrsIndex = subrsIndex.obj;
28674 },
28675 parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
28676 if (pos === 0) {
28677 return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);
28678 } else if (pos === 1) {
28679 return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, _charsets.ExpertCharset);
28680 } else if (pos === 2) {
28681 return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);
28682 }
28683
28684 var bytes = this.bytes;
28685 var start = pos;
28686 var format = bytes[pos++];
28687 const charset = [cid ? 0 : ".notdef"];
28688 var id, count, i;
28689 length -= 1;
28690
28691 switch (format) {
28692 case 0:
28693 for (i = 0; i < length; i++) {
28694 id = bytes[pos++] << 8 | bytes[pos++];
28695 charset.push(cid ? id : strings.get(id));
28696 }
28697
28698 break;
28699
28700 case 1:
28701 while (charset.length <= length) {
28702 id = bytes[pos++] << 8 | bytes[pos++];
28703 count = bytes[pos++];
28704
28705 for (i = 0; i <= count; i++) {
28706 charset.push(cid ? id++ : strings.get(id++));
28707 }
28708 }
28709
28710 break;
28711
28712 case 2:
28713 while (charset.length <= length) {
28714 id = bytes[pos++] << 8 | bytes[pos++];
28715 count = bytes[pos++] << 8 | bytes[pos++];
28716
28717 for (i = 0; i <= count; i++) {
28718 charset.push(cid ? id++ : strings.get(id++));
28719 }
28720 }
28721
28722 break;
28723
28724 default:
28725 throw new _util.FormatError("Unknown charset format");
28726 }
28727
28728 var end = pos;
28729 var raw = bytes.subarray(start, end);
28730 return new CFFCharset(false, format, charset, raw);
28731 },
28732 parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
28733 var encoding = Object.create(null);
28734 var bytes = this.bytes;
28735 var predefined = false;
28736 var format, i, ii;
28737 var raw = null;
28738
28739 function readSupplement() {
28740 var supplementsCount = bytes[pos++];
28741
28742 for (i = 0; i < supplementsCount; i++) {
28743 var code = bytes[pos++];
28744 var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
28745 encoding[code] = charset.indexOf(strings.get(sid));
28746 }
28747 }
28748
28749 if (pos === 0 || pos === 1) {
28750 predefined = true;
28751 format = pos;
28752 var baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
28753
28754 for (i = 0, ii = charset.length; i < ii; i++) {
28755 var index = baseEncoding.indexOf(charset[i]);
28756
28757 if (index !== -1) {
28758 encoding[index] = i;
28759 }
28760 }
28761 } else {
28762 var dataStart = pos;
28763 format = bytes[pos++];
28764
28765 switch (format & 0x7f) {
28766 case 0:
28767 var glyphsCount = bytes[pos++];
28768
28769 for (i = 1; i <= glyphsCount; i++) {
28770 encoding[bytes[pos++]] = i;
28771 }
28772
28773 break;
28774
28775 case 1:
28776 var rangesCount = bytes[pos++];
28777 var gid = 1;
28778
28779 for (i = 0; i < rangesCount; i++) {
28780 var start = bytes[pos++];
28781 var left = bytes[pos++];
28782
28783 for (var j = start; j <= start + left; j++) {
28784 encoding[j] = gid++;
28785 }
28786 }
28787
28788 break;
28789
28790 default:
28791 throw new _util.FormatError(`Unknown encoding format: ${format} in CFF`);
28792 }
28793
28794 var dataEnd = pos;
28795
28796 if (format & 0x80) {
28797 bytes[dataStart] &= 0x7f;
28798 readSupplement();
28799 }
28800
28801 raw = bytes.subarray(dataStart, dataEnd);
28802 }
28803
28804 format = format & 0x7f;
28805 return new CFFEncoding(predefined, format, encoding, raw);
28806 },
28807 parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
28808 var bytes = this.bytes;
28809 var format = bytes[pos++];
28810 var fdSelect = [];
28811 var i;
28812
28813 switch (format) {
28814 case 0:
28815 for (i = 0; i < length; ++i) {
28816 var id = bytes[pos++];
28817 fdSelect.push(id);
28818 }
28819
28820 break;
28821
28822 case 3:
28823 var rangesCount = bytes[pos++] << 8 | bytes[pos++];
28824
28825 for (i = 0; i < rangesCount; ++i) {
28826 var first = bytes[pos++] << 8 | bytes[pos++];
28827
28828 if (i === 0 && first !== 0) {
28829 (0, _util.warn)("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
28830 first = 0;
28831 }
28832
28833 var fdIndex = bytes[pos++];
28834 var next = bytes[pos] << 8 | bytes[pos + 1];
28835
28836 for (var j = first; j < next; ++j) {
28837 fdSelect.push(fdIndex);
28838 }
28839 }
28840
28841 pos += 2;
28842 break;
28843
28844 default:
28845 throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`);
28846 }
28847
28848 if (fdSelect.length !== length) {
28849 throw new _util.FormatError("parseFDSelect: Invalid font data.");
28850 }
28851
28852 return new CFFFDSelect(format, fdSelect);
28853 }
28854 };
28855 return CFFParser;
28856}();
28857
28858exports.CFFParser = CFFParser;
28859
28860var CFF = function CFFClosure() {
28861 function CFF() {
28862 this.header = null;
28863 this.names = [];
28864 this.topDict = null;
28865 this.strings = new CFFStrings();
28866 this.globalSubrIndex = null;
28867 this.encoding = null;
28868 this.charset = null;
28869 this.charStrings = null;
28870 this.fdArray = [];
28871 this.fdSelect = null;
28872 this.isCIDFont = false;
28873 }
28874
28875 CFF.prototype = {
28876 duplicateFirstGlyph: function CFF_duplicateFirstGlyph() {
28877 if (this.charStrings.count >= 65535) {
28878 (0, _util.warn)("Not enough space in charstrings to duplicate first glyph.");
28879 return;
28880 }
28881
28882 var glyphZero = this.charStrings.get(0);
28883 this.charStrings.add(glyphZero);
28884
28885 if (this.isCIDFont) {
28886 this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
28887 }
28888 },
28889 hasGlyphId: function CFF_hasGlyphID(id) {
28890 if (id < 0 || id >= this.charStrings.count) {
28891 return false;
28892 }
28893
28894 var glyph = this.charStrings.get(id);
28895 return glyph.length > 0;
28896 }
28897 };
28898 return CFF;
28899}();
28900
28901exports.CFF = CFF;
28902
28903var CFFHeader = function CFFHeaderClosure() {
28904 function CFFHeader(major, minor, hdrSize, offSize) {
28905 this.major = major;
28906 this.minor = minor;
28907 this.hdrSize = hdrSize;
28908 this.offSize = offSize;
28909 }
28910
28911 return CFFHeader;
28912}();
28913
28914exports.CFFHeader = CFFHeader;
28915
28916var CFFStrings = function CFFStringsClosure() {
28917 function CFFStrings() {
28918 this.strings = [];
28919 }
28920
28921 CFFStrings.prototype = {
28922 get: function CFFStrings_get(index) {
28923 if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
28924 return CFFStandardStrings[index];
28925 }
28926
28927 if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
28928 return this.strings[index - NUM_STANDARD_CFF_STRINGS];
28929 }
28930
28931 return CFFStandardStrings[0];
28932 },
28933 getSID: function CFFStrings_getSID(str) {
28934 let index = CFFStandardStrings.indexOf(str);
28935
28936 if (index !== -1) {
28937 return index;
28938 }
28939
28940 index = this.strings.indexOf(str);
28941
28942 if (index !== -1) {
28943 return index + NUM_STANDARD_CFF_STRINGS;
28944 }
28945
28946 return -1;
28947 },
28948 add: function CFFStrings_add(value) {
28949 this.strings.push(value);
28950 },
28951
28952 get count() {
28953 return this.strings.length;
28954 }
28955
28956 };
28957 return CFFStrings;
28958}();
28959
28960exports.CFFStrings = CFFStrings;
28961
28962var CFFIndex = function CFFIndexClosure() {
28963 function CFFIndex() {
28964 this.objects = [];
28965 this.length = 0;
28966 }
28967
28968 CFFIndex.prototype = {
28969 add: function CFFIndex_add(data) {
28970 this.length += data.length;
28971 this.objects.push(data);
28972 },
28973 set: function CFFIndex_set(index, data) {
28974 this.length += data.length - this.objects[index].length;
28975 this.objects[index] = data;
28976 },
28977 get: function CFFIndex_get(index) {
28978 return this.objects[index];
28979 },
28980
28981 get count() {
28982 return this.objects.length;
28983 }
28984
28985 };
28986 return CFFIndex;
28987}();
28988
28989exports.CFFIndex = CFFIndex;
28990
28991var CFFDict = function CFFDictClosure() {
28992 function CFFDict(tables, strings) {
28993 this.keyToNameMap = tables.keyToNameMap;
28994 this.nameToKeyMap = tables.nameToKeyMap;
28995 this.defaults = tables.defaults;
28996 this.types = tables.types;
28997 this.opcodes = tables.opcodes;
28998 this.order = tables.order;
28999 this.strings = strings;
29000 this.values = Object.create(null);
29001 }
29002
29003 CFFDict.prototype = {
29004 setByKey: function CFFDict_setByKey(key, value) {
29005 if (!(key in this.keyToNameMap)) {
29006 return false;
29007 }
29008
29009 var valueLength = value.length;
29010
29011 if (valueLength === 0) {
29012 return true;
29013 }
29014
29015 for (var i = 0; i < valueLength; i++) {
29016 if (isNaN(value[i])) {
29017 (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
29018 return true;
29019 }
29020 }
29021
29022 var type = this.types[key];
29023
29024 if (type === "num" || type === "sid" || type === "offset") {
29025 value = value[0];
29026 }
29027
29028 this.values[key] = value;
29029 return true;
29030 },
29031 setByName: function CFFDict_setByName(name, value) {
29032 if (!(name in this.nameToKeyMap)) {
29033 throw new _util.FormatError(`Invalid dictionary name "${name}"`);
29034 }
29035
29036 this.values[this.nameToKeyMap[name]] = value;
29037 },
29038 hasName: function CFFDict_hasName(name) {
29039 return this.nameToKeyMap[name] in this.values;
29040 },
29041 getByName: function CFFDict_getByName(name) {
29042 if (!(name in this.nameToKeyMap)) {
29043 throw new _util.FormatError(`Invalid dictionary name ${name}"`);
29044 }
29045
29046 var key = this.nameToKeyMap[name];
29047
29048 if (!(key in this.values)) {
29049 return this.defaults[key];
29050 }
29051
29052 return this.values[key];
29053 },
29054 removeByName: function CFFDict_removeByName(name) {
29055 delete this.values[this.nameToKeyMap[name]];
29056 }
29057 };
29058
29059 CFFDict.createTables = function CFFDict_createTables(layout) {
29060 var tables = {
29061 keyToNameMap: {},
29062 nameToKeyMap: {},
29063 defaults: {},
29064 types: {},
29065 opcodes: {},
29066 order: []
29067 };
29068
29069 for (var i = 0, ii = layout.length; i < ii; ++i) {
29070 var entry = layout[i];
29071 var key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
29072 tables.keyToNameMap[key] = entry[1];
29073 tables.nameToKeyMap[entry[1]] = key;
29074 tables.types[key] = entry[2];
29075 tables.defaults[key] = entry[3];
29076 tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
29077 tables.order.push(key);
29078 }
29079
29080 return tables;
29081 };
29082
29083 return CFFDict;
29084}();
29085
29086var CFFTopDict = function CFFTopDictClosure() {
29087 var layout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
29088 var tables = null;
29089
29090 function CFFTopDict(strings) {
29091 if (tables === null) {
29092 tables = CFFDict.createTables(layout);
29093 }
29094
29095 CFFDict.call(this, tables, strings);
29096 this.privateDict = null;
29097 }
29098
29099 CFFTopDict.prototype = Object.create(CFFDict.prototype);
29100 return CFFTopDict;
29101}();
29102
29103exports.CFFTopDict = CFFTopDict;
29104
29105var CFFPrivateDict = function CFFPrivateDictClosure() {
29106 var layout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", 0.039625], [[12, 10], "BlueShift", "num", 7], [[12, 11], "BlueFuzz", "num", 1], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", 0.06], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
29107 var tables = null;
29108
29109 function CFFPrivateDict(strings) {
29110 if (tables === null) {
29111 tables = CFFDict.createTables(layout);
29112 }
29113
29114 CFFDict.call(this, tables, strings);
29115 this.subrsIndex = null;
29116 }
29117
29118 CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
29119 return CFFPrivateDict;
29120}();
29121
29122exports.CFFPrivateDict = CFFPrivateDict;
29123var CFFCharsetPredefinedTypes = {
29124 ISO_ADOBE: 0,
29125 EXPERT: 1,
29126 EXPERT_SUBSET: 2
29127};
29128
29129var CFFCharset = function CFFCharsetClosure() {
29130 function CFFCharset(predefined, format, charset, raw) {
29131 this.predefined = predefined;
29132 this.format = format;
29133 this.charset = charset;
29134 this.raw = raw;
29135 }
29136
29137 return CFFCharset;
29138}();
29139
29140exports.CFFCharset = CFFCharset;
29141
29142var CFFEncoding = function CFFEncodingClosure() {
29143 function CFFEncoding(predefined, format, encoding, raw) {
29144 this.predefined = predefined;
29145 this.format = format;
29146 this.encoding = encoding;
29147 this.raw = raw;
29148 }
29149
29150 return CFFEncoding;
29151}();
29152
29153var CFFFDSelect = function CFFFDSelectClosure() {
29154 function CFFFDSelect(format, fdSelect) {
29155 this.format = format;
29156 this.fdSelect = fdSelect;
29157 }
29158
29159 CFFFDSelect.prototype = {
29160 getFDIndex: function CFFFDSelect_get(glyphIndex) {
29161 if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
29162 return -1;
29163 }
29164
29165 return this.fdSelect[glyphIndex];
29166 }
29167 };
29168 return CFFFDSelect;
29169}();
29170
29171exports.CFFFDSelect = CFFFDSelect;
29172
29173var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
29174 function CFFOffsetTracker() {
29175 this.offsets = Object.create(null);
29176 }
29177
29178 CFFOffsetTracker.prototype = {
29179 isTracking: function CFFOffsetTracker_isTracking(key) {
29180 return key in this.offsets;
29181 },
29182 track: function CFFOffsetTracker_track(key, location) {
29183 if (key in this.offsets) {
29184 throw new _util.FormatError(`Already tracking location of ${key}`);
29185 }
29186
29187 this.offsets[key] = location;
29188 },
29189 offset: function CFFOffsetTracker_offset(value) {
29190 for (var key in this.offsets) {
29191 this.offsets[key] += value;
29192 }
29193 },
29194 setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
29195 if (!(key in this.offsets)) {
29196 throw new _util.FormatError(`Not tracking location of ${key}`);
29197 }
29198
29199 var data = output.data;
29200 var dataOffset = this.offsets[key];
29201 var size = 5;
29202
29203 for (var i = 0, ii = values.length; i < ii; ++i) {
29204 var offset0 = i * size + dataOffset;
29205 var offset1 = offset0 + 1;
29206 var offset2 = offset0 + 2;
29207 var offset3 = offset0 + 3;
29208 var offset4 = offset0 + 4;
29209
29210 if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
29211 throw new _util.FormatError("writing to an offset that is not empty");
29212 }
29213
29214 var value = values[i];
29215 data[offset0] = 0x1d;
29216 data[offset1] = value >> 24 & 0xff;
29217 data[offset2] = value >> 16 & 0xff;
29218 data[offset3] = value >> 8 & 0xff;
29219 data[offset4] = value & 0xff;
29220 }
29221 }
29222 };
29223 return CFFOffsetTracker;
29224}();
29225
29226var CFFCompiler = function CFFCompilerClosure() {
29227 function CFFCompiler(cff) {
29228 this.cff = cff;
29229 }
29230
29231 CFFCompiler.prototype = {
29232 compile: function CFFCompiler_compile() {
29233 var cff = this.cff;
29234 var output = {
29235 data: [],
29236 length: 0,
29237 add: function CFFCompiler_add(data) {
29238 this.data = this.data.concat(data);
29239 this.length = this.data.length;
29240 }
29241 };
29242 var header = this.compileHeader(cff.header);
29243 output.add(header);
29244 var nameIndex = this.compileNameIndex(cff.names);
29245 output.add(nameIndex);
29246
29247 if (cff.isCIDFont) {
29248 if (cff.topDict.hasName("FontMatrix")) {
29249 var base = cff.topDict.getByName("FontMatrix");
29250 cff.topDict.removeByName("FontMatrix");
29251
29252 for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
29253 var subDict = cff.fdArray[i];
29254 var matrix = base.slice(0);
29255
29256 if (subDict.hasName("FontMatrix")) {
29257 matrix = _util.Util.transform(matrix, subDict.getByName("FontMatrix"));
29258 }
29259
29260 subDict.setByName("FontMatrix", matrix);
29261 }
29262 }
29263 }
29264
29265 cff.topDict.setByName("charset", 0);
29266 var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
29267 output.add(compiled.output);
29268 var topDictTracker = compiled.trackers[0];
29269 var stringIndex = this.compileStringIndex(cff.strings.strings);
29270 output.add(stringIndex);
29271 var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
29272 output.add(globalSubrIndex);
29273
29274 if (cff.encoding && cff.topDict.hasName("Encoding")) {
29275 if (cff.encoding.predefined) {
29276 topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
29277 } else {
29278 var encoding = this.compileEncoding(cff.encoding);
29279 topDictTracker.setEntryLocation("Encoding", [output.length], output);
29280 output.add(encoding);
29281 }
29282 }
29283
29284 var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
29285 topDictTracker.setEntryLocation("charset", [output.length], output);
29286 output.add(charset);
29287 var charStrings = this.compileCharStrings(cff.charStrings);
29288 topDictTracker.setEntryLocation("CharStrings", [output.length], output);
29289 output.add(charStrings);
29290
29291 if (cff.isCIDFont) {
29292 topDictTracker.setEntryLocation("FDSelect", [output.length], output);
29293 var fdSelect = this.compileFDSelect(cff.fdSelect);
29294 output.add(fdSelect);
29295 compiled = this.compileTopDicts(cff.fdArray, output.length, true);
29296 topDictTracker.setEntryLocation("FDArray", [output.length], output);
29297 output.add(compiled.output);
29298 var fontDictTrackers = compiled.trackers;
29299 this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
29300 }
29301
29302 this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
29303 output.add([0]);
29304 return output.data;
29305 },
29306 encodeNumber: function CFFCompiler_encodeNumber(value) {
29307 if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
29308 return this.encodeInteger(value);
29309 }
29310
29311 return this.encodeFloat(value);
29312 },
29313 encodeFloat: function CFFCompiler_encodeFloat(num) {
29314 var value = num.toString();
29315 var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
29316
29317 if (m) {
29318 var epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
29319 value = (Math.round(num * epsilon) / epsilon).toString();
29320 }
29321
29322 var nibbles = "";
29323 var i, ii;
29324
29325 for (i = 0, ii = value.length; i < ii; ++i) {
29326 var a = value[i];
29327
29328 if (a === "e") {
29329 nibbles += value[++i] === "-" ? "c" : "b";
29330 } else if (a === ".") {
29331 nibbles += "a";
29332 } else if (a === "-") {
29333 nibbles += "e";
29334 } else {
29335 nibbles += a;
29336 }
29337 }
29338
29339 nibbles += nibbles.length & 1 ? "f" : "ff";
29340 var out = [30];
29341
29342 for (i = 0, ii = nibbles.length; i < ii; i += 2) {
29343 out.push(parseInt(nibbles.substring(i, i + 2), 16));
29344 }
29345
29346 return out;
29347 },
29348 encodeInteger: function CFFCompiler_encodeInteger(value) {
29349 var code;
29350
29351 if (value >= -107 && value <= 107) {
29352 code = [value + 139];
29353 } else if (value >= 108 && value <= 1131) {
29354 value = value - 108;
29355 code = [(value >> 8) + 247, value & 0xff];
29356 } else if (value >= -1131 && value <= -108) {
29357 value = -value - 108;
29358 code = [(value >> 8) + 251, value & 0xff];
29359 } else if (value >= -32768 && value <= 32767) {
29360 code = [0x1c, value >> 8 & 0xff, value & 0xff];
29361 } else {
29362 code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
29363 }
29364
29365 return code;
29366 },
29367 compileHeader: function CFFCompiler_compileHeader(header) {
29368 return [header.major, header.minor, header.hdrSize, header.offSize];
29369 },
29370 compileNameIndex: function CFFCompiler_compileNameIndex(names) {
29371 var nameIndex = new CFFIndex();
29372
29373 for (var i = 0, ii = names.length; i < ii; ++i) {
29374 var name = names[i];
29375 var length = Math.min(name.length, 127);
29376 var sanitizedName = new Array(length);
29377
29378 for (var j = 0; j < length; j++) {
29379 var char = name[j];
29380
29381 if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
29382 char = "_";
29383 }
29384
29385 sanitizedName[j] = char;
29386 }
29387
29388 sanitizedName = sanitizedName.join("");
29389
29390 if (sanitizedName === "") {
29391 sanitizedName = "Bad_Font_Name";
29392 }
29393
29394 nameIndex.add((0, _util.stringToBytes)(sanitizedName));
29395 }
29396
29397 return this.compileIndex(nameIndex);
29398 },
29399 compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
29400 var fontDictTrackers = [];
29401 var fdArrayIndex = new CFFIndex();
29402
29403 for (var i = 0, ii = dicts.length; i < ii; ++i) {
29404 var fontDict = dicts[i];
29405
29406 if (removeCidKeys) {
29407 fontDict.removeByName("CIDFontVersion");
29408 fontDict.removeByName("CIDFontRevision");
29409 fontDict.removeByName("CIDFontType");
29410 fontDict.removeByName("CIDCount");
29411 fontDict.removeByName("UIDBase");
29412 }
29413
29414 var fontDictTracker = new CFFOffsetTracker();
29415 var fontDictData = this.compileDict(fontDict, fontDictTracker);
29416 fontDictTrackers.push(fontDictTracker);
29417 fdArrayIndex.add(fontDictData);
29418 fontDictTracker.offset(length);
29419 }
29420
29421 fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
29422 return {
29423 trackers: fontDictTrackers,
29424 output: fdArrayIndex
29425 };
29426 },
29427 compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
29428 for (var i = 0, ii = dicts.length; i < ii; ++i) {
29429 var fontDict = dicts[i];
29430 var privateDict = fontDict.privateDict;
29431
29432 if (!privateDict || !fontDict.hasName("Private")) {
29433 throw new _util.FormatError("There must be a private dictionary.");
29434 }
29435
29436 var privateDictTracker = new CFFOffsetTracker();
29437 var privateDictData = this.compileDict(privateDict, privateDictTracker);
29438 var outputLength = output.length;
29439 privateDictTracker.offset(outputLength);
29440
29441 if (!privateDictData.length) {
29442 outputLength = 0;
29443 }
29444
29445 trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
29446 output.add(privateDictData);
29447
29448 if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
29449 var subrs = this.compileIndex(privateDict.subrsIndex);
29450 privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
29451 output.add(subrs);
29452 }
29453 }
29454 },
29455 compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
29456 var out = [];
29457 var order = dict.order;
29458
29459 for (var i = 0; i < order.length; ++i) {
29460 var key = order[i];
29461
29462 if (!(key in dict.values)) {
29463 continue;
29464 }
29465
29466 var values = dict.values[key];
29467 var types = dict.types[key];
29468
29469 if (!Array.isArray(types)) {
29470 types = [types];
29471 }
29472
29473 if (!Array.isArray(values)) {
29474 values = [values];
29475 }
29476
29477 if (values.length === 0) {
29478 continue;
29479 }
29480
29481 for (var j = 0, jj = types.length; j < jj; ++j) {
29482 var type = types[j];
29483 var value = values[j];
29484
29485 switch (type) {
29486 case "num":
29487 case "sid":
29488 out = out.concat(this.encodeNumber(value));
29489 break;
29490
29491 case "offset":
29492 var name = dict.keyToNameMap[key];
29493
29494 if (!offsetTracker.isTracking(name)) {
29495 offsetTracker.track(name, out.length);
29496 }
29497
29498 out = out.concat([0x1d, 0, 0, 0, 0]);
29499 break;
29500
29501 case "array":
29502 case "delta":
29503 out = out.concat(this.encodeNumber(value));
29504
29505 for (var k = 1, kk = values.length; k < kk; ++k) {
29506 out = out.concat(this.encodeNumber(values[k]));
29507 }
29508
29509 break;
29510
29511 default:
29512 throw new _util.FormatError(`Unknown data type of ${type}`);
29513 }
29514 }
29515
29516 out = out.concat(dict.opcodes[key]);
29517 }
29518
29519 return out;
29520 },
29521 compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
29522 var stringIndex = new CFFIndex();
29523
29524 for (var i = 0, ii = strings.length; i < ii; ++i) {
29525 stringIndex.add((0, _util.stringToBytes)(strings[i]));
29526 }
29527
29528 return this.compileIndex(stringIndex);
29529 },
29530 compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
29531 var globalSubrIndex = this.cff.globalSubrIndex;
29532 this.out.writeByteArray(this.compileIndex(globalSubrIndex));
29533 },
29534 compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
29535 var charStringsIndex = new CFFIndex();
29536
29537 for (var i = 0; i < charStrings.count; i++) {
29538 var glyph = charStrings.get(i);
29539
29540 if (glyph.length === 0) {
29541 charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
29542 continue;
29543 }
29544
29545 charStringsIndex.add(glyph);
29546 }
29547
29548 return this.compileIndex(charStringsIndex);
29549 },
29550 compileCharset: function CFFCompiler_compileCharset(charset, numGlyphs, strings, isCIDFont) {
29551 let out;
29552 const numGlyphsLessNotDef = numGlyphs - 1;
29553
29554 if (isCIDFont) {
29555 out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xff, numGlyphsLessNotDef & 0xff]);
29556 } else {
29557 const length = 1 + numGlyphsLessNotDef * 2;
29558 out = new Uint8Array(length);
29559 out[0] = 0;
29560 let charsetIndex = 0;
29561 const numCharsets = charset.charset.length;
29562 let warned = false;
29563
29564 for (let i = 1; i < out.length; i += 2) {
29565 let sid = 0;
29566
29567 if (charsetIndex < numCharsets) {
29568 const name = charset.charset[charsetIndex++];
29569 sid = strings.getSID(name);
29570
29571 if (sid === -1) {
29572 sid = 0;
29573
29574 if (!warned) {
29575 warned = true;
29576 (0, _util.warn)(`Couldn't find ${name} in CFF strings`);
29577 }
29578 }
29579 }
29580
29581 out[i] = sid >> 8 & 0xff;
29582 out[i + 1] = sid & 0xff;
29583 }
29584 }
29585
29586 return this.compileTypedArray(out);
29587 },
29588 compileEncoding: function CFFCompiler_compileEncoding(encoding) {
29589 return this.compileTypedArray(encoding.raw);
29590 },
29591 compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
29592 const format = fdSelect.format;
29593 let out, i;
29594
29595 switch (format) {
29596 case 0:
29597 out = new Uint8Array(1 + fdSelect.fdSelect.length);
29598 out[0] = format;
29599
29600 for (i = 0; i < fdSelect.fdSelect.length; i++) {
29601 out[i + 1] = fdSelect.fdSelect[i];
29602 }
29603
29604 break;
29605
29606 case 3:
29607 const start = 0;
29608 let lastFD = fdSelect.fdSelect[0];
29609 const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
29610
29611 for (i = 1; i < fdSelect.fdSelect.length; i++) {
29612 const currentFD = fdSelect.fdSelect[i];
29613
29614 if (currentFD !== lastFD) {
29615 ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
29616 lastFD = currentFD;
29617 }
29618 }
29619
29620 const numRanges = (ranges.length - 3) / 3;
29621 ranges[1] = numRanges >> 8 & 0xff;
29622 ranges[2] = numRanges & 0xff;
29623 ranges.push(i >> 8 & 0xff, i & 0xff);
29624 out = new Uint8Array(ranges);
29625 break;
29626 }
29627
29628 return this.compileTypedArray(out);
29629 },
29630 compileTypedArray: function CFFCompiler_compileTypedArray(data) {
29631 var out = [];
29632
29633 for (var i = 0, ii = data.length; i < ii; ++i) {
29634 out[i] = data[i];
29635 }
29636
29637 return out;
29638 },
29639 compileIndex: function CFFCompiler_compileIndex(index, trackers) {
29640 trackers = trackers || [];
29641 var objects = index.objects;
29642 var count = objects.length;
29643
29644 if (count === 0) {
29645 return [0, 0, 0];
29646 }
29647
29648 var data = [count >> 8 & 0xff, count & 0xff];
29649 var lastOffset = 1,
29650 i;
29651
29652 for (i = 0; i < count; ++i) {
29653 lastOffset += objects[i].length;
29654 }
29655
29656 var offsetSize;
29657
29658 if (lastOffset < 0x100) {
29659 offsetSize = 1;
29660 } else if (lastOffset < 0x10000) {
29661 offsetSize = 2;
29662 } else if (lastOffset < 0x1000000) {
29663 offsetSize = 3;
29664 } else {
29665 offsetSize = 4;
29666 }
29667
29668 data.push(offsetSize);
29669 var relativeOffset = 1;
29670
29671 for (i = 0; i < count + 1; i++) {
29672 if (offsetSize === 1) {
29673 data.push(relativeOffset & 0xff);
29674 } else if (offsetSize === 2) {
29675 data.push(relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
29676 } else if (offsetSize === 3) {
29677 data.push(relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
29678 } else {
29679 data.push(relativeOffset >>> 24 & 0xff, relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
29680 }
29681
29682 if (objects[i]) {
29683 relativeOffset += objects[i].length;
29684 }
29685 }
29686
29687 for (i = 0; i < count; i++) {
29688 if (trackers[i]) {
29689 trackers[i].offset(data.length);
29690 }
29691
29692 for (var j = 0, jj = objects[i].length; j < jj; j++) {
29693 data.push(objects[i][j]);
29694 }
29695 }
29696
29697 return data;
29698 }
29699 };
29700 return CFFCompiler;
29701}();
29702
29703exports.CFFCompiler = CFFCompiler;
29704
29705/***/ }),
29706/* 31 */
29707/***/ (function(module, exports, __w_pdfjs_require__) {
29708
29709"use strict";
29710
29711
29712Object.defineProperty(exports, "__esModule", {
29713 value: true
29714});
29715exports.ExpertSubsetCharset = exports.ExpertCharset = exports.ISOAdobeCharset = void 0;
29716const ISOAdobeCharset = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron"];
29717exports.ISOAdobeCharset = ISOAdobeCharset;
29718const ExpertCharset = [".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
29719exports.ExpertCharset = ExpertCharset;
29720const ExpertSubsetCharset = [".notdef", "space", "dollaroldstyle", "dollarsuperior", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior"];
29721exports.ExpertSubsetCharset = ExpertSubsetCharset;
29722
29723/***/ }),
29724/* 32 */
29725/***/ (function(module, exports, __w_pdfjs_require__) {
29726
29727"use strict";
29728
29729
29730Object.defineProperty(exports, "__esModule", {
29731 value: true
29732});
29733exports.getEncoding = getEncoding;
29734exports.ExpertEncoding = exports.ZapfDingbatsEncoding = exports.SymbolSetEncoding = exports.MacRomanEncoding = exports.StandardEncoding = exports.WinAnsiEncoding = void 0;
29735const ExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "", "", "", "isuperior", "", "", "lsuperior", "msuperior", "nsuperior", "osuperior", "", "", "rsuperior", "ssuperior", "tsuperior", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdownsmall", "centoldstyle", "Lslashsmall", "", "", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "", "Dotaccentsmall", "", "", "Macronsmall", "", "", "figuredash", "hypheninferior", "", "", "Ogoneksmall", "Ringsmall", "Cedillasmall", "", "", "", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
29736exports.ExpertEncoding = ExpertEncoding;
29737const MacExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "centoldstyle", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "", "threequartersemdash", "", "questionsmall", "", "", "", "", "Ethsmall", "", "", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "", "", "", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hypheninferior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "asuperior", "centsuperior", "", "", "", "", "Aacutesmall", "Agravesmall", "Acircumflexsmall", "Adieresissmall", "Atildesmall", "Aringsmall", "Ccedillasmall", "Eacutesmall", "Egravesmall", "Ecircumflexsmall", "Edieresissmall", "Iacutesmall", "Igravesmall", "Icircumflexsmall", "Idieresissmall", "Ntildesmall", "Oacutesmall", "Ogravesmall", "Ocircumflexsmall", "Odieresissmall", "Otildesmall", "Uacutesmall", "Ugravesmall", "Ucircumflexsmall", "Udieresissmall", "", "eightsuperior", "fourinferior", "threeinferior", "sixinferior", "eightinferior", "seveninferior", "Scaronsmall", "", "centinferior", "twoinferior", "", "Dieresissmall", "", "Caronsmall", "osuperior", "fiveinferior", "", "commainferior", "periodinferior", "Yacutesmall", "", "dollarinferior", "", "", "Thornsmall", "", "nineinferior", "zeroinferior", "Zcaronsmall", "AEsmall", "Oslashsmall", "questiondownsmall", "oneinferior", "Lslashsmall", "", "", "", "", "", "", "Cedillasmall", "", "", "", "", "", "OEsmall", "figuredash", "hyphensuperior", "", "", "", "", "exclamdownsmall", "", "Ydieresissmall", "", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "ninesuperior", "zerosuperior", "", "esuperior", "rsuperior", "tsuperior", "", "", "isuperior", "ssuperior", "dsuperior", "", "", "", "", "", "lsuperior", "Ogoneksmall", "Brevesmall", "Macronsmall", "bsuperior", "nsuperior", "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", "", "", "", ""];
29738const MacRomanEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "space", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron"];
29739exports.MacRomanEncoding = MacRomanEncoding;
29740const StandardEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "", "endash", "dagger", "daggerdbl", "periodcentered", "", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "", "questiondown", "", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "", "ring", "cedilla", "", "hungarumlaut", "ogonek", "caron", "emdash", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "AE", "", "ordfeminine", "", "", "", "", "Lslash", "Oslash", "OE", "ordmasculine", "", "", "", "", "", "ae", "", "", "", "dotlessi", "", "", "lslash", "oslash", "oe", "germandbls", "", "", "", ""];
29741exports.StandardEncoding = StandardEncoding;
29742const WinAnsiEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "bullet", "Euro", "bullet", "quotesinglbase", "florin", "quotedblbase", "ellipsis", "dagger", "daggerdbl", "circumflex", "perthousand", "Scaron", "guilsinglleft", "OE", "bullet", "Zcaron", "bullet", "bullet", "quoteleft", "quoteright", "quotedblleft", "quotedblright", "bullet", "endash", "emdash", "tilde", "trademark", "scaron", "guilsinglright", "oe", "bullet", "zcaron", "Ydieresis", "space", "exclamdown", "cent", "sterling", "currency", "yen", "brokenbar", "section", "dieresis", "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", "registered", "macron", "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu", "paragraph", "periodcentered", "cedilla", "onesuperior", "ordmasculine", "guillemotright", "onequarter", "onehalf", "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex", "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave", "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae", "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave", "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis"];
29743exports.WinAnsiEncoding = WinAnsiEncoding;
29744const SymbolSetEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "universal", "numbersign", "existential", "percent", "ampersand", "suchthat", "parenleft", "parenright", "asteriskmath", "plus", "comma", "minus", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "congruent", "Alpha", "Beta", "Chi", "Delta", "Epsilon", "Phi", "Gamma", "Eta", "Iota", "theta1", "Kappa", "Lambda", "Mu", "Nu", "Omicron", "Pi", "Theta", "Rho", "Sigma", "Tau", "Upsilon", "sigma1", "Omega", "Xi", "Psi", "Zeta", "bracketleft", "therefore", "bracketright", "perpendicular", "underscore", "radicalex", "alpha", "beta", "chi", "delta", "epsilon", "phi", "gamma", "eta", "iota", "phi1", "kappa", "lambda", "mu", "nu", "omicron", "pi", "theta", "rho", "sigma", "tau", "upsilon", "omega1", "omega", "xi", "psi", "zeta", "braceleft", "bar", "braceright", "similar", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Euro", "Upsilon1", "minute", "lessequal", "fraction", "infinity", "florin", "club", "diamond", "heart", "spade", "arrowboth", "arrowleft", "arrowup", "arrowright", "arrowdown", "degree", "plusminus", "second", "greaterequal", "multiply", "proportional", "partialdiff", "bullet", "divide", "notequal", "equivalence", "approxequal", "ellipsis", "arrowvertex", "arrowhorizex", "carriagereturn", "aleph", "Ifraktur", "Rfraktur", "weierstrass", "circlemultiply", "circleplus", "emptyset", "intersection", "union", "propersuperset", "reflexsuperset", "notsubset", "propersubset", "reflexsubset", "element", "notelement", "angle", "gradient", "registerserif", "copyrightserif", "trademarkserif", "product", "radical", "dotmath", "logicalnot", "logicaland", "logicalor", "arrowdblboth", "arrowdblleft", "arrowdblup", "arrowdblright", "arrowdbldown", "lozenge", "angleleft", "registersans", "copyrightsans", "trademarksans", "summation", "parenlefttp", "parenleftex", "parenleftbt", "bracketlefttp", "bracketleftex", "bracketleftbt", "bracelefttp", "braceleftmid", "braceleftbt", "braceex", "", "angleright", "integral", "integraltp", "integralex", "integralbt", "parenrighttp", "parenrightex", "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt", ""];
29745exports.SymbolSetEncoding = SymbolSetEncoding;
29746const ZapfDingbatsEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26", "a27", "a28", "a6", "a7", "a8", "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34", "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44", "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74", "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81", "a82", "a83", "a84", "a97", "a98", "a99", "a100", "", "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85", "a206", "a86", "a87", "a88", "a95", "a96", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a101", "a102", "a103", "a104", "a106", "a107", "a108", "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123", "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", "a132", "a133", "a134", "a135", "a136", "a137", "a138", "a139", "a140", "a141", "a142", "a143", "a144", "a145", "a146", "a147", "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155", "a156", "a157", "a158", "a159", "a160", "a161", "a163", "a164", "a196", "a165", "a192", "a166", "a167", "a168", "a169", "a170", "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177", "a178", "a179", "a193", "a180", "a199", "a181", "a200", "a182", "", "a201", "a183", "a184", "a197", "a185", "a194", "a198", "a186", "a195", "a187", "a188", "a189", "a190", "a191", ""];
29747exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
29748
29749function getEncoding(encodingName) {
29750 switch (encodingName) {
29751 case "WinAnsiEncoding":
29752 return WinAnsiEncoding;
29753
29754 case "StandardEncoding":
29755 return StandardEncoding;
29756
29757 case "MacRomanEncoding":
29758 return MacRomanEncoding;
29759
29760 case "SymbolSetEncoding":
29761 return SymbolSetEncoding;
29762
29763 case "ZapfDingbatsEncoding":
29764 return ZapfDingbatsEncoding;
29765
29766 case "ExpertEncoding":
29767 return ExpertEncoding;
29768
29769 case "MacExpertEncoding":
29770 return MacExpertEncoding;
29771
29772 default:
29773 return null;
29774 }
29775}
29776
29777/***/ }),
29778/* 33 */
29779/***/ (function(module, exports, __w_pdfjs_require__) {
29780
29781var getLookupTableFactory = __w_pdfjs_require__(8).getLookupTableFactory;
29782var getGlyphsUnicode = getLookupTableFactory(function (t) {
29783 t.A = 0x0041;
29784 t.AE = 0x00c6;
29785 t.AEacute = 0x01fc;
29786 t.AEmacron = 0x01e2;
29787 t.AEsmall = 0xf7e6;
29788 t.Aacute = 0x00c1;
29789 t.Aacutesmall = 0xf7e1;
29790 t.Abreve = 0x0102;
29791 t.Abreveacute = 0x1eae;
29792 t.Abrevecyrillic = 0x04d0;
29793 t.Abrevedotbelow = 0x1eb6;
29794 t.Abrevegrave = 0x1eb0;
29795 t.Abrevehookabove = 0x1eb2;
29796 t.Abrevetilde = 0x1eb4;
29797 t.Acaron = 0x01cd;
29798 t.Acircle = 0x24b6;
29799 t.Acircumflex = 0x00c2;
29800 t.Acircumflexacute = 0x1ea4;
29801 t.Acircumflexdotbelow = 0x1eac;
29802 t.Acircumflexgrave = 0x1ea6;
29803 t.Acircumflexhookabove = 0x1ea8;
29804 t.Acircumflexsmall = 0xf7e2;
29805 t.Acircumflextilde = 0x1eaa;
29806 t.Acute = 0xf6c9;
29807 t.Acutesmall = 0xf7b4;
29808 t.Acyrillic = 0x0410;
29809 t.Adblgrave = 0x0200;
29810 t.Adieresis = 0x00c4;
29811 t.Adieresiscyrillic = 0x04d2;
29812 t.Adieresismacron = 0x01de;
29813 t.Adieresissmall = 0xf7e4;
29814 t.Adotbelow = 0x1ea0;
29815 t.Adotmacron = 0x01e0;
29816 t.Agrave = 0x00c0;
29817 t.Agravesmall = 0xf7e0;
29818 t.Ahookabove = 0x1ea2;
29819 t.Aiecyrillic = 0x04d4;
29820 t.Ainvertedbreve = 0x0202;
29821 t.Alpha = 0x0391;
29822 t.Alphatonos = 0x0386;
29823 t.Amacron = 0x0100;
29824 t.Amonospace = 0xff21;
29825 t.Aogonek = 0x0104;
29826 t.Aring = 0x00c5;
29827 t.Aringacute = 0x01fa;
29828 t.Aringbelow = 0x1e00;
29829 t.Aringsmall = 0xf7e5;
29830 t.Asmall = 0xf761;
29831 t.Atilde = 0x00c3;
29832 t.Atildesmall = 0xf7e3;
29833 t.Aybarmenian = 0x0531;
29834 t.B = 0x0042;
29835 t.Bcircle = 0x24b7;
29836 t.Bdotaccent = 0x1e02;
29837 t.Bdotbelow = 0x1e04;
29838 t.Becyrillic = 0x0411;
29839 t.Benarmenian = 0x0532;
29840 t.Beta = 0x0392;
29841 t.Bhook = 0x0181;
29842 t.Blinebelow = 0x1e06;
29843 t.Bmonospace = 0xff22;
29844 t.Brevesmall = 0xf6f4;
29845 t.Bsmall = 0xf762;
29846 t.Btopbar = 0x0182;
29847 t.C = 0x0043;
29848 t.Caarmenian = 0x053e;
29849 t.Cacute = 0x0106;
29850 t.Caron = 0xf6ca;
29851 t.Caronsmall = 0xf6f5;
29852 t.Ccaron = 0x010c;
29853 t.Ccedilla = 0x00c7;
29854 t.Ccedillaacute = 0x1e08;
29855 t.Ccedillasmall = 0xf7e7;
29856 t.Ccircle = 0x24b8;
29857 t.Ccircumflex = 0x0108;
29858 t.Cdot = 0x010a;
29859 t.Cdotaccent = 0x010a;
29860 t.Cedillasmall = 0xf7b8;
29861 t.Chaarmenian = 0x0549;
29862 t.Cheabkhasiancyrillic = 0x04bc;
29863 t.Checyrillic = 0x0427;
29864 t.Chedescenderabkhasiancyrillic = 0x04be;
29865 t.Chedescendercyrillic = 0x04b6;
29866 t.Chedieresiscyrillic = 0x04f4;
29867 t.Cheharmenian = 0x0543;
29868 t.Chekhakassiancyrillic = 0x04cb;
29869 t.Cheverticalstrokecyrillic = 0x04b8;
29870 t.Chi = 0x03a7;
29871 t.Chook = 0x0187;
29872 t.Circumflexsmall = 0xf6f6;
29873 t.Cmonospace = 0xff23;
29874 t.Coarmenian = 0x0551;
29875 t.Csmall = 0xf763;
29876 t.D = 0x0044;
29877 t.DZ = 0x01f1;
29878 t.DZcaron = 0x01c4;
29879 t.Daarmenian = 0x0534;
29880 t.Dafrican = 0x0189;
29881 t.Dcaron = 0x010e;
29882 t.Dcedilla = 0x1e10;
29883 t.Dcircle = 0x24b9;
29884 t.Dcircumflexbelow = 0x1e12;
29885 t.Dcroat = 0x0110;
29886 t.Ddotaccent = 0x1e0a;
29887 t.Ddotbelow = 0x1e0c;
29888 t.Decyrillic = 0x0414;
29889 t.Deicoptic = 0x03ee;
29890 t.Delta = 0x2206;
29891 t.Deltagreek = 0x0394;
29892 t.Dhook = 0x018a;
29893 t.Dieresis = 0xf6cb;
29894 t.DieresisAcute = 0xf6cc;
29895 t.DieresisGrave = 0xf6cd;
29896 t.Dieresissmall = 0xf7a8;
29897 t.Digammagreek = 0x03dc;
29898 t.Djecyrillic = 0x0402;
29899 t.Dlinebelow = 0x1e0e;
29900 t.Dmonospace = 0xff24;
29901 t.Dotaccentsmall = 0xf6f7;
29902 t.Dslash = 0x0110;
29903 t.Dsmall = 0xf764;
29904 t.Dtopbar = 0x018b;
29905 t.Dz = 0x01f2;
29906 t.Dzcaron = 0x01c5;
29907 t.Dzeabkhasiancyrillic = 0x04e0;
29908 t.Dzecyrillic = 0x0405;
29909 t.Dzhecyrillic = 0x040f;
29910 t.E = 0x0045;
29911 t.Eacute = 0x00c9;
29912 t.Eacutesmall = 0xf7e9;
29913 t.Ebreve = 0x0114;
29914 t.Ecaron = 0x011a;
29915 t.Ecedillabreve = 0x1e1c;
29916 t.Echarmenian = 0x0535;
29917 t.Ecircle = 0x24ba;
29918 t.Ecircumflex = 0x00ca;
29919 t.Ecircumflexacute = 0x1ebe;
29920 t.Ecircumflexbelow = 0x1e18;
29921 t.Ecircumflexdotbelow = 0x1ec6;
29922 t.Ecircumflexgrave = 0x1ec0;
29923 t.Ecircumflexhookabove = 0x1ec2;
29924 t.Ecircumflexsmall = 0xf7ea;
29925 t.Ecircumflextilde = 0x1ec4;
29926 t.Ecyrillic = 0x0404;
29927 t.Edblgrave = 0x0204;
29928 t.Edieresis = 0x00cb;
29929 t.Edieresissmall = 0xf7eb;
29930 t.Edot = 0x0116;
29931 t.Edotaccent = 0x0116;
29932 t.Edotbelow = 0x1eb8;
29933 t.Efcyrillic = 0x0424;
29934 t.Egrave = 0x00c8;
29935 t.Egravesmall = 0xf7e8;
29936 t.Eharmenian = 0x0537;
29937 t.Ehookabove = 0x1eba;
29938 t.Eightroman = 0x2167;
29939 t.Einvertedbreve = 0x0206;
29940 t.Eiotifiedcyrillic = 0x0464;
29941 t.Elcyrillic = 0x041b;
29942 t.Elevenroman = 0x216a;
29943 t.Emacron = 0x0112;
29944 t.Emacronacute = 0x1e16;
29945 t.Emacrongrave = 0x1e14;
29946 t.Emcyrillic = 0x041c;
29947 t.Emonospace = 0xff25;
29948 t.Encyrillic = 0x041d;
29949 t.Endescendercyrillic = 0x04a2;
29950 t.Eng = 0x014a;
29951 t.Enghecyrillic = 0x04a4;
29952 t.Enhookcyrillic = 0x04c7;
29953 t.Eogonek = 0x0118;
29954 t.Eopen = 0x0190;
29955 t.Epsilon = 0x0395;
29956 t.Epsilontonos = 0x0388;
29957 t.Ercyrillic = 0x0420;
29958 t.Ereversed = 0x018e;
29959 t.Ereversedcyrillic = 0x042d;
29960 t.Escyrillic = 0x0421;
29961 t.Esdescendercyrillic = 0x04aa;
29962 t.Esh = 0x01a9;
29963 t.Esmall = 0xf765;
29964 t.Eta = 0x0397;
29965 t.Etarmenian = 0x0538;
29966 t.Etatonos = 0x0389;
29967 t.Eth = 0x00d0;
29968 t.Ethsmall = 0xf7f0;
29969 t.Etilde = 0x1ebc;
29970 t.Etildebelow = 0x1e1a;
29971 t.Euro = 0x20ac;
29972 t.Ezh = 0x01b7;
29973 t.Ezhcaron = 0x01ee;
29974 t.Ezhreversed = 0x01b8;
29975 t.F = 0x0046;
29976 t.Fcircle = 0x24bb;
29977 t.Fdotaccent = 0x1e1e;
29978 t.Feharmenian = 0x0556;
29979 t.Feicoptic = 0x03e4;
29980 t.Fhook = 0x0191;
29981 t.Fitacyrillic = 0x0472;
29982 t.Fiveroman = 0x2164;
29983 t.Fmonospace = 0xff26;
29984 t.Fourroman = 0x2163;
29985 t.Fsmall = 0xf766;
29986 t.G = 0x0047;
29987 t.GBsquare = 0x3387;
29988 t.Gacute = 0x01f4;
29989 t.Gamma = 0x0393;
29990 t.Gammaafrican = 0x0194;
29991 t.Gangiacoptic = 0x03ea;
29992 t.Gbreve = 0x011e;
29993 t.Gcaron = 0x01e6;
29994 t.Gcedilla = 0x0122;
29995 t.Gcircle = 0x24bc;
29996 t.Gcircumflex = 0x011c;
29997 t.Gcommaaccent = 0x0122;
29998 t.Gdot = 0x0120;
29999 t.Gdotaccent = 0x0120;
30000 t.Gecyrillic = 0x0413;
30001 t.Ghadarmenian = 0x0542;
30002 t.Ghemiddlehookcyrillic = 0x0494;
30003 t.Ghestrokecyrillic = 0x0492;
30004 t.Gheupturncyrillic = 0x0490;
30005 t.Ghook = 0x0193;
30006 t.Gimarmenian = 0x0533;
30007 t.Gjecyrillic = 0x0403;
30008 t.Gmacron = 0x1e20;
30009 t.Gmonospace = 0xff27;
30010 t.Grave = 0xf6ce;
30011 t.Gravesmall = 0xf760;
30012 t.Gsmall = 0xf767;
30013 t.Gsmallhook = 0x029b;
30014 t.Gstroke = 0x01e4;
30015 t.H = 0x0048;
30016 t.H18533 = 0x25cf;
30017 t.H18543 = 0x25aa;
30018 t.H18551 = 0x25ab;
30019 t.H22073 = 0x25a1;
30020 t.HPsquare = 0x33cb;
30021 t.Haabkhasiancyrillic = 0x04a8;
30022 t.Hadescendercyrillic = 0x04b2;
30023 t.Hardsigncyrillic = 0x042a;
30024 t.Hbar = 0x0126;
30025 t.Hbrevebelow = 0x1e2a;
30026 t.Hcedilla = 0x1e28;
30027 t.Hcircle = 0x24bd;
30028 t.Hcircumflex = 0x0124;
30029 t.Hdieresis = 0x1e26;
30030 t.Hdotaccent = 0x1e22;
30031 t.Hdotbelow = 0x1e24;
30032 t.Hmonospace = 0xff28;
30033 t.Hoarmenian = 0x0540;
30034 t.Horicoptic = 0x03e8;
30035 t.Hsmall = 0xf768;
30036 t.Hungarumlaut = 0xf6cf;
30037 t.Hungarumlautsmall = 0xf6f8;
30038 t.Hzsquare = 0x3390;
30039 t.I = 0x0049;
30040 t.IAcyrillic = 0x042f;
30041 t.IJ = 0x0132;
30042 t.IUcyrillic = 0x042e;
30043 t.Iacute = 0x00cd;
30044 t.Iacutesmall = 0xf7ed;
30045 t.Ibreve = 0x012c;
30046 t.Icaron = 0x01cf;
30047 t.Icircle = 0x24be;
30048 t.Icircumflex = 0x00ce;
30049 t.Icircumflexsmall = 0xf7ee;
30050 t.Icyrillic = 0x0406;
30051 t.Idblgrave = 0x0208;
30052 t.Idieresis = 0x00cf;
30053 t.Idieresisacute = 0x1e2e;
30054 t.Idieresiscyrillic = 0x04e4;
30055 t.Idieresissmall = 0xf7ef;
30056 t.Idot = 0x0130;
30057 t.Idotaccent = 0x0130;
30058 t.Idotbelow = 0x1eca;
30059 t.Iebrevecyrillic = 0x04d6;
30060 t.Iecyrillic = 0x0415;
30061 t.Ifraktur = 0x2111;
30062 t.Igrave = 0x00cc;
30063 t.Igravesmall = 0xf7ec;
30064 t.Ihookabove = 0x1ec8;
30065 t.Iicyrillic = 0x0418;
30066 t.Iinvertedbreve = 0x020a;
30067 t.Iishortcyrillic = 0x0419;
30068 t.Imacron = 0x012a;
30069 t.Imacroncyrillic = 0x04e2;
30070 t.Imonospace = 0xff29;
30071 t.Iniarmenian = 0x053b;
30072 t.Iocyrillic = 0x0401;
30073 t.Iogonek = 0x012e;
30074 t.Iota = 0x0399;
30075 t.Iotaafrican = 0x0196;
30076 t.Iotadieresis = 0x03aa;
30077 t.Iotatonos = 0x038a;
30078 t.Ismall = 0xf769;
30079 t.Istroke = 0x0197;
30080 t.Itilde = 0x0128;
30081 t.Itildebelow = 0x1e2c;
30082 t.Izhitsacyrillic = 0x0474;
30083 t.Izhitsadblgravecyrillic = 0x0476;
30084 t.J = 0x004a;
30085 t.Jaarmenian = 0x0541;
30086 t.Jcircle = 0x24bf;
30087 t.Jcircumflex = 0x0134;
30088 t.Jecyrillic = 0x0408;
30089 t.Jheharmenian = 0x054b;
30090 t.Jmonospace = 0xff2a;
30091 t.Jsmall = 0xf76a;
30092 t.K = 0x004b;
30093 t.KBsquare = 0x3385;
30094 t.KKsquare = 0x33cd;
30095 t.Kabashkircyrillic = 0x04a0;
30096 t.Kacute = 0x1e30;
30097 t.Kacyrillic = 0x041a;
30098 t.Kadescendercyrillic = 0x049a;
30099 t.Kahookcyrillic = 0x04c3;
30100 t.Kappa = 0x039a;
30101 t.Kastrokecyrillic = 0x049e;
30102 t.Kaverticalstrokecyrillic = 0x049c;
30103 t.Kcaron = 0x01e8;
30104 t.Kcedilla = 0x0136;
30105 t.Kcircle = 0x24c0;
30106 t.Kcommaaccent = 0x0136;
30107 t.Kdotbelow = 0x1e32;
30108 t.Keharmenian = 0x0554;
30109 t.Kenarmenian = 0x053f;
30110 t.Khacyrillic = 0x0425;
30111 t.Kheicoptic = 0x03e6;
30112 t.Khook = 0x0198;
30113 t.Kjecyrillic = 0x040c;
30114 t.Klinebelow = 0x1e34;
30115 t.Kmonospace = 0xff2b;
30116 t.Koppacyrillic = 0x0480;
30117 t.Koppagreek = 0x03de;
30118 t.Ksicyrillic = 0x046e;
30119 t.Ksmall = 0xf76b;
30120 t.L = 0x004c;
30121 t.LJ = 0x01c7;
30122 t.LL = 0xf6bf;
30123 t.Lacute = 0x0139;
30124 t.Lambda = 0x039b;
30125 t.Lcaron = 0x013d;
30126 t.Lcedilla = 0x013b;
30127 t.Lcircle = 0x24c1;
30128 t.Lcircumflexbelow = 0x1e3c;
30129 t.Lcommaaccent = 0x013b;
30130 t.Ldot = 0x013f;
30131 t.Ldotaccent = 0x013f;
30132 t.Ldotbelow = 0x1e36;
30133 t.Ldotbelowmacron = 0x1e38;
30134 t.Liwnarmenian = 0x053c;
30135 t.Lj = 0x01c8;
30136 t.Ljecyrillic = 0x0409;
30137 t.Llinebelow = 0x1e3a;
30138 t.Lmonospace = 0xff2c;
30139 t.Lslash = 0x0141;
30140 t.Lslashsmall = 0xf6f9;
30141 t.Lsmall = 0xf76c;
30142 t.M = 0x004d;
30143 t.MBsquare = 0x3386;
30144 t.Macron = 0xf6d0;
30145 t.Macronsmall = 0xf7af;
30146 t.Macute = 0x1e3e;
30147 t.Mcircle = 0x24c2;
30148 t.Mdotaccent = 0x1e40;
30149 t.Mdotbelow = 0x1e42;
30150 t.Menarmenian = 0x0544;
30151 t.Mmonospace = 0xff2d;
30152 t.Msmall = 0xf76d;
30153 t.Mturned = 0x019c;
30154 t.Mu = 0x039c;
30155 t.N = 0x004e;
30156 t.NJ = 0x01ca;
30157 t.Nacute = 0x0143;
30158 t.Ncaron = 0x0147;
30159 t.Ncedilla = 0x0145;
30160 t.Ncircle = 0x24c3;
30161 t.Ncircumflexbelow = 0x1e4a;
30162 t.Ncommaaccent = 0x0145;
30163 t.Ndotaccent = 0x1e44;
30164 t.Ndotbelow = 0x1e46;
30165 t.Nhookleft = 0x019d;
30166 t.Nineroman = 0x2168;
30167 t.Nj = 0x01cb;
30168 t.Njecyrillic = 0x040a;
30169 t.Nlinebelow = 0x1e48;
30170 t.Nmonospace = 0xff2e;
30171 t.Nowarmenian = 0x0546;
30172 t.Nsmall = 0xf76e;
30173 t.Ntilde = 0x00d1;
30174 t.Ntildesmall = 0xf7f1;
30175 t.Nu = 0x039d;
30176 t.O = 0x004f;
30177 t.OE = 0x0152;
30178 t.OEsmall = 0xf6fa;
30179 t.Oacute = 0x00d3;
30180 t.Oacutesmall = 0xf7f3;
30181 t.Obarredcyrillic = 0x04e8;
30182 t.Obarreddieresiscyrillic = 0x04ea;
30183 t.Obreve = 0x014e;
30184 t.Ocaron = 0x01d1;
30185 t.Ocenteredtilde = 0x019f;
30186 t.Ocircle = 0x24c4;
30187 t.Ocircumflex = 0x00d4;
30188 t.Ocircumflexacute = 0x1ed0;
30189 t.Ocircumflexdotbelow = 0x1ed8;
30190 t.Ocircumflexgrave = 0x1ed2;
30191 t.Ocircumflexhookabove = 0x1ed4;
30192 t.Ocircumflexsmall = 0xf7f4;
30193 t.Ocircumflextilde = 0x1ed6;
30194 t.Ocyrillic = 0x041e;
30195 t.Odblacute = 0x0150;
30196 t.Odblgrave = 0x020c;
30197 t.Odieresis = 0x00d6;
30198 t.Odieresiscyrillic = 0x04e6;
30199 t.Odieresissmall = 0xf7f6;
30200 t.Odotbelow = 0x1ecc;
30201 t.Ogoneksmall = 0xf6fb;
30202 t.Ograve = 0x00d2;
30203 t.Ogravesmall = 0xf7f2;
30204 t.Oharmenian = 0x0555;
30205 t.Ohm = 0x2126;
30206 t.Ohookabove = 0x1ece;
30207 t.Ohorn = 0x01a0;
30208 t.Ohornacute = 0x1eda;
30209 t.Ohorndotbelow = 0x1ee2;
30210 t.Ohorngrave = 0x1edc;
30211 t.Ohornhookabove = 0x1ede;
30212 t.Ohorntilde = 0x1ee0;
30213 t.Ohungarumlaut = 0x0150;
30214 t.Oi = 0x01a2;
30215 t.Oinvertedbreve = 0x020e;
30216 t.Omacron = 0x014c;
30217 t.Omacronacute = 0x1e52;
30218 t.Omacrongrave = 0x1e50;
30219 t.Omega = 0x2126;
30220 t.Omegacyrillic = 0x0460;
30221 t.Omegagreek = 0x03a9;
30222 t.Omegaroundcyrillic = 0x047a;
30223 t.Omegatitlocyrillic = 0x047c;
30224 t.Omegatonos = 0x038f;
30225 t.Omicron = 0x039f;
30226 t.Omicrontonos = 0x038c;
30227 t.Omonospace = 0xff2f;
30228 t.Oneroman = 0x2160;
30229 t.Oogonek = 0x01ea;
30230 t.Oogonekmacron = 0x01ec;
30231 t.Oopen = 0x0186;
30232 t.Oslash = 0x00d8;
30233 t.Oslashacute = 0x01fe;
30234 t.Oslashsmall = 0xf7f8;
30235 t.Osmall = 0xf76f;
30236 t.Ostrokeacute = 0x01fe;
30237 t.Otcyrillic = 0x047e;
30238 t.Otilde = 0x00d5;
30239 t.Otildeacute = 0x1e4c;
30240 t.Otildedieresis = 0x1e4e;
30241 t.Otildesmall = 0xf7f5;
30242 t.P = 0x0050;
30243 t.Pacute = 0x1e54;
30244 t.Pcircle = 0x24c5;
30245 t.Pdotaccent = 0x1e56;
30246 t.Pecyrillic = 0x041f;
30247 t.Peharmenian = 0x054a;
30248 t.Pemiddlehookcyrillic = 0x04a6;
30249 t.Phi = 0x03a6;
30250 t.Phook = 0x01a4;
30251 t.Pi = 0x03a0;
30252 t.Piwrarmenian = 0x0553;
30253 t.Pmonospace = 0xff30;
30254 t.Psi = 0x03a8;
30255 t.Psicyrillic = 0x0470;
30256 t.Psmall = 0xf770;
30257 t.Q = 0x0051;
30258 t.Qcircle = 0x24c6;
30259 t.Qmonospace = 0xff31;
30260 t.Qsmall = 0xf771;
30261 t.R = 0x0052;
30262 t.Raarmenian = 0x054c;
30263 t.Racute = 0x0154;
30264 t.Rcaron = 0x0158;
30265 t.Rcedilla = 0x0156;
30266 t.Rcircle = 0x24c7;
30267 t.Rcommaaccent = 0x0156;
30268 t.Rdblgrave = 0x0210;
30269 t.Rdotaccent = 0x1e58;
30270 t.Rdotbelow = 0x1e5a;
30271 t.Rdotbelowmacron = 0x1e5c;
30272 t.Reharmenian = 0x0550;
30273 t.Rfraktur = 0x211c;
30274 t.Rho = 0x03a1;
30275 t.Ringsmall = 0xf6fc;
30276 t.Rinvertedbreve = 0x0212;
30277 t.Rlinebelow = 0x1e5e;
30278 t.Rmonospace = 0xff32;
30279 t.Rsmall = 0xf772;
30280 t.Rsmallinverted = 0x0281;
30281 t.Rsmallinvertedsuperior = 0x02b6;
30282 t.S = 0x0053;
30283 t.SF010000 = 0x250c;
30284 t.SF020000 = 0x2514;
30285 t.SF030000 = 0x2510;
30286 t.SF040000 = 0x2518;
30287 t.SF050000 = 0x253c;
30288 t.SF060000 = 0x252c;
30289 t.SF070000 = 0x2534;
30290 t.SF080000 = 0x251c;
30291 t.SF090000 = 0x2524;
30292 t.SF100000 = 0x2500;
30293 t.SF110000 = 0x2502;
30294 t.SF190000 = 0x2561;
30295 t.SF200000 = 0x2562;
30296 t.SF210000 = 0x2556;
30297 t.SF220000 = 0x2555;
30298 t.SF230000 = 0x2563;
30299 t.SF240000 = 0x2551;
30300 t.SF250000 = 0x2557;
30301 t.SF260000 = 0x255d;
30302 t.SF270000 = 0x255c;
30303 t.SF280000 = 0x255b;
30304 t.SF360000 = 0x255e;
30305 t.SF370000 = 0x255f;
30306 t.SF380000 = 0x255a;
30307 t.SF390000 = 0x2554;
30308 t.SF400000 = 0x2569;
30309 t.SF410000 = 0x2566;
30310 t.SF420000 = 0x2560;
30311 t.SF430000 = 0x2550;
30312 t.SF440000 = 0x256c;
30313 t.SF450000 = 0x2567;
30314 t.SF460000 = 0x2568;
30315 t.SF470000 = 0x2564;
30316 t.SF480000 = 0x2565;
30317 t.SF490000 = 0x2559;
30318 t.SF500000 = 0x2558;
30319 t.SF510000 = 0x2552;
30320 t.SF520000 = 0x2553;
30321 t.SF530000 = 0x256b;
30322 t.SF540000 = 0x256a;
30323 t.Sacute = 0x015a;
30324 t.Sacutedotaccent = 0x1e64;
30325 t.Sampigreek = 0x03e0;
30326 t.Scaron = 0x0160;
30327 t.Scarondotaccent = 0x1e66;
30328 t.Scaronsmall = 0xf6fd;
30329 t.Scedilla = 0x015e;
30330 t.Schwa = 0x018f;
30331 t.Schwacyrillic = 0x04d8;
30332 t.Schwadieresiscyrillic = 0x04da;
30333 t.Scircle = 0x24c8;
30334 t.Scircumflex = 0x015c;
30335 t.Scommaaccent = 0x0218;
30336 t.Sdotaccent = 0x1e60;
30337 t.Sdotbelow = 0x1e62;
30338 t.Sdotbelowdotaccent = 0x1e68;
30339 t.Seharmenian = 0x054d;
30340 t.Sevenroman = 0x2166;
30341 t.Shaarmenian = 0x0547;
30342 t.Shacyrillic = 0x0428;
30343 t.Shchacyrillic = 0x0429;
30344 t.Sheicoptic = 0x03e2;
30345 t.Shhacyrillic = 0x04ba;
30346 t.Shimacoptic = 0x03ec;
30347 t.Sigma = 0x03a3;
30348 t.Sixroman = 0x2165;
30349 t.Smonospace = 0xff33;
30350 t.Softsigncyrillic = 0x042c;
30351 t.Ssmall = 0xf773;
30352 t.Stigmagreek = 0x03da;
30353 t.T = 0x0054;
30354 t.Tau = 0x03a4;
30355 t.Tbar = 0x0166;
30356 t.Tcaron = 0x0164;
30357 t.Tcedilla = 0x0162;
30358 t.Tcircle = 0x24c9;
30359 t.Tcircumflexbelow = 0x1e70;
30360 t.Tcommaaccent = 0x0162;
30361 t.Tdotaccent = 0x1e6a;
30362 t.Tdotbelow = 0x1e6c;
30363 t.Tecyrillic = 0x0422;
30364 t.Tedescendercyrillic = 0x04ac;
30365 t.Tenroman = 0x2169;
30366 t.Tetsecyrillic = 0x04b4;
30367 t.Theta = 0x0398;
30368 t.Thook = 0x01ac;
30369 t.Thorn = 0x00de;
30370 t.Thornsmall = 0xf7fe;
30371 t.Threeroman = 0x2162;
30372 t.Tildesmall = 0xf6fe;
30373 t.Tiwnarmenian = 0x054f;
30374 t.Tlinebelow = 0x1e6e;
30375 t.Tmonospace = 0xff34;
30376 t.Toarmenian = 0x0539;
30377 t.Tonefive = 0x01bc;
30378 t.Tonesix = 0x0184;
30379 t.Tonetwo = 0x01a7;
30380 t.Tretroflexhook = 0x01ae;
30381 t.Tsecyrillic = 0x0426;
30382 t.Tshecyrillic = 0x040b;
30383 t.Tsmall = 0xf774;
30384 t.Twelveroman = 0x216b;
30385 t.Tworoman = 0x2161;
30386 t.U = 0x0055;
30387 t.Uacute = 0x00da;
30388 t.Uacutesmall = 0xf7fa;
30389 t.Ubreve = 0x016c;
30390 t.Ucaron = 0x01d3;
30391 t.Ucircle = 0x24ca;
30392 t.Ucircumflex = 0x00db;
30393 t.Ucircumflexbelow = 0x1e76;
30394 t.Ucircumflexsmall = 0xf7fb;
30395 t.Ucyrillic = 0x0423;
30396 t.Udblacute = 0x0170;
30397 t.Udblgrave = 0x0214;
30398 t.Udieresis = 0x00dc;
30399 t.Udieresisacute = 0x01d7;
30400 t.Udieresisbelow = 0x1e72;
30401 t.Udieresiscaron = 0x01d9;
30402 t.Udieresiscyrillic = 0x04f0;
30403 t.Udieresisgrave = 0x01db;
30404 t.Udieresismacron = 0x01d5;
30405 t.Udieresissmall = 0xf7fc;
30406 t.Udotbelow = 0x1ee4;
30407 t.Ugrave = 0x00d9;
30408 t.Ugravesmall = 0xf7f9;
30409 t.Uhookabove = 0x1ee6;
30410 t.Uhorn = 0x01af;
30411 t.Uhornacute = 0x1ee8;
30412 t.Uhorndotbelow = 0x1ef0;
30413 t.Uhorngrave = 0x1eea;
30414 t.Uhornhookabove = 0x1eec;
30415 t.Uhorntilde = 0x1eee;
30416 t.Uhungarumlaut = 0x0170;
30417 t.Uhungarumlautcyrillic = 0x04f2;
30418 t.Uinvertedbreve = 0x0216;
30419 t.Ukcyrillic = 0x0478;
30420 t.Umacron = 0x016a;
30421 t.Umacroncyrillic = 0x04ee;
30422 t.Umacrondieresis = 0x1e7a;
30423 t.Umonospace = 0xff35;
30424 t.Uogonek = 0x0172;
30425 t.Upsilon = 0x03a5;
30426 t.Upsilon1 = 0x03d2;
30427 t.Upsilonacutehooksymbolgreek = 0x03d3;
30428 t.Upsilonafrican = 0x01b1;
30429 t.Upsilondieresis = 0x03ab;
30430 t.Upsilondieresishooksymbolgreek = 0x03d4;
30431 t.Upsilonhooksymbol = 0x03d2;
30432 t.Upsilontonos = 0x038e;
30433 t.Uring = 0x016e;
30434 t.Ushortcyrillic = 0x040e;
30435 t.Usmall = 0xf775;
30436 t.Ustraightcyrillic = 0x04ae;
30437 t.Ustraightstrokecyrillic = 0x04b0;
30438 t.Utilde = 0x0168;
30439 t.Utildeacute = 0x1e78;
30440 t.Utildebelow = 0x1e74;
30441 t.V = 0x0056;
30442 t.Vcircle = 0x24cb;
30443 t.Vdotbelow = 0x1e7e;
30444 t.Vecyrillic = 0x0412;
30445 t.Vewarmenian = 0x054e;
30446 t.Vhook = 0x01b2;
30447 t.Vmonospace = 0xff36;
30448 t.Voarmenian = 0x0548;
30449 t.Vsmall = 0xf776;
30450 t.Vtilde = 0x1e7c;
30451 t.W = 0x0057;
30452 t.Wacute = 0x1e82;
30453 t.Wcircle = 0x24cc;
30454 t.Wcircumflex = 0x0174;
30455 t.Wdieresis = 0x1e84;
30456 t.Wdotaccent = 0x1e86;
30457 t.Wdotbelow = 0x1e88;
30458 t.Wgrave = 0x1e80;
30459 t.Wmonospace = 0xff37;
30460 t.Wsmall = 0xf777;
30461 t.X = 0x0058;
30462 t.Xcircle = 0x24cd;
30463 t.Xdieresis = 0x1e8c;
30464 t.Xdotaccent = 0x1e8a;
30465 t.Xeharmenian = 0x053d;
30466 t.Xi = 0x039e;
30467 t.Xmonospace = 0xff38;
30468 t.Xsmall = 0xf778;
30469 t.Y = 0x0059;
30470 t.Yacute = 0x00dd;
30471 t.Yacutesmall = 0xf7fd;
30472 t.Yatcyrillic = 0x0462;
30473 t.Ycircle = 0x24ce;
30474 t.Ycircumflex = 0x0176;
30475 t.Ydieresis = 0x0178;
30476 t.Ydieresissmall = 0xf7ff;
30477 t.Ydotaccent = 0x1e8e;
30478 t.Ydotbelow = 0x1ef4;
30479 t.Yericyrillic = 0x042b;
30480 t.Yerudieresiscyrillic = 0x04f8;
30481 t.Ygrave = 0x1ef2;
30482 t.Yhook = 0x01b3;
30483 t.Yhookabove = 0x1ef6;
30484 t.Yiarmenian = 0x0545;
30485 t.Yicyrillic = 0x0407;
30486 t.Yiwnarmenian = 0x0552;
30487 t.Ymonospace = 0xff39;
30488 t.Ysmall = 0xf779;
30489 t.Ytilde = 0x1ef8;
30490 t.Yusbigcyrillic = 0x046a;
30491 t.Yusbigiotifiedcyrillic = 0x046c;
30492 t.Yuslittlecyrillic = 0x0466;
30493 t.Yuslittleiotifiedcyrillic = 0x0468;
30494 t.Z = 0x005a;
30495 t.Zaarmenian = 0x0536;
30496 t.Zacute = 0x0179;
30497 t.Zcaron = 0x017d;
30498 t.Zcaronsmall = 0xf6ff;
30499 t.Zcircle = 0x24cf;
30500 t.Zcircumflex = 0x1e90;
30501 t.Zdot = 0x017b;
30502 t.Zdotaccent = 0x017b;
30503 t.Zdotbelow = 0x1e92;
30504 t.Zecyrillic = 0x0417;
30505 t.Zedescendercyrillic = 0x0498;
30506 t.Zedieresiscyrillic = 0x04de;
30507 t.Zeta = 0x0396;
30508 t.Zhearmenian = 0x053a;
30509 t.Zhebrevecyrillic = 0x04c1;
30510 t.Zhecyrillic = 0x0416;
30511 t.Zhedescendercyrillic = 0x0496;
30512 t.Zhedieresiscyrillic = 0x04dc;
30513 t.Zlinebelow = 0x1e94;
30514 t.Zmonospace = 0xff3a;
30515 t.Zsmall = 0xf77a;
30516 t.Zstroke = 0x01b5;
30517 t.a = 0x0061;
30518 t.aabengali = 0x0986;
30519 t.aacute = 0x00e1;
30520 t.aadeva = 0x0906;
30521 t.aagujarati = 0x0a86;
30522 t.aagurmukhi = 0x0a06;
30523 t.aamatragurmukhi = 0x0a3e;
30524 t.aarusquare = 0x3303;
30525 t.aavowelsignbengali = 0x09be;
30526 t.aavowelsigndeva = 0x093e;
30527 t.aavowelsigngujarati = 0x0abe;
30528 t.abbreviationmarkarmenian = 0x055f;
30529 t.abbreviationsigndeva = 0x0970;
30530 t.abengali = 0x0985;
30531 t.abopomofo = 0x311a;
30532 t.abreve = 0x0103;
30533 t.abreveacute = 0x1eaf;
30534 t.abrevecyrillic = 0x04d1;
30535 t.abrevedotbelow = 0x1eb7;
30536 t.abrevegrave = 0x1eb1;
30537 t.abrevehookabove = 0x1eb3;
30538 t.abrevetilde = 0x1eb5;
30539 t.acaron = 0x01ce;
30540 t.acircle = 0x24d0;
30541 t.acircumflex = 0x00e2;
30542 t.acircumflexacute = 0x1ea5;
30543 t.acircumflexdotbelow = 0x1ead;
30544 t.acircumflexgrave = 0x1ea7;
30545 t.acircumflexhookabove = 0x1ea9;
30546 t.acircumflextilde = 0x1eab;
30547 t.acute = 0x00b4;
30548 t.acutebelowcmb = 0x0317;
30549 t.acutecmb = 0x0301;
30550 t.acutecomb = 0x0301;
30551 t.acutedeva = 0x0954;
30552 t.acutelowmod = 0x02cf;
30553 t.acutetonecmb = 0x0341;
30554 t.acyrillic = 0x0430;
30555 t.adblgrave = 0x0201;
30556 t.addakgurmukhi = 0x0a71;
30557 t.adeva = 0x0905;
30558 t.adieresis = 0x00e4;
30559 t.adieresiscyrillic = 0x04d3;
30560 t.adieresismacron = 0x01df;
30561 t.adotbelow = 0x1ea1;
30562 t.adotmacron = 0x01e1;
30563 t.ae = 0x00e6;
30564 t.aeacute = 0x01fd;
30565 t.aekorean = 0x3150;
30566 t.aemacron = 0x01e3;
30567 t.afii00208 = 0x2015;
30568 t.afii08941 = 0x20a4;
30569 t.afii10017 = 0x0410;
30570 t.afii10018 = 0x0411;
30571 t.afii10019 = 0x0412;
30572 t.afii10020 = 0x0413;
30573 t.afii10021 = 0x0414;
30574 t.afii10022 = 0x0415;
30575 t.afii10023 = 0x0401;
30576 t.afii10024 = 0x0416;
30577 t.afii10025 = 0x0417;
30578 t.afii10026 = 0x0418;
30579 t.afii10027 = 0x0419;
30580 t.afii10028 = 0x041a;
30581 t.afii10029 = 0x041b;
30582 t.afii10030 = 0x041c;
30583 t.afii10031 = 0x041d;
30584 t.afii10032 = 0x041e;
30585 t.afii10033 = 0x041f;
30586 t.afii10034 = 0x0420;
30587 t.afii10035 = 0x0421;
30588 t.afii10036 = 0x0422;
30589 t.afii10037 = 0x0423;
30590 t.afii10038 = 0x0424;
30591 t.afii10039 = 0x0425;
30592 t.afii10040 = 0x0426;
30593 t.afii10041 = 0x0427;
30594 t.afii10042 = 0x0428;
30595 t.afii10043 = 0x0429;
30596 t.afii10044 = 0x042a;
30597 t.afii10045 = 0x042b;
30598 t.afii10046 = 0x042c;
30599 t.afii10047 = 0x042d;
30600 t.afii10048 = 0x042e;
30601 t.afii10049 = 0x042f;
30602 t.afii10050 = 0x0490;
30603 t.afii10051 = 0x0402;
30604 t.afii10052 = 0x0403;
30605 t.afii10053 = 0x0404;
30606 t.afii10054 = 0x0405;
30607 t.afii10055 = 0x0406;
30608 t.afii10056 = 0x0407;
30609 t.afii10057 = 0x0408;
30610 t.afii10058 = 0x0409;
30611 t.afii10059 = 0x040a;
30612 t.afii10060 = 0x040b;
30613 t.afii10061 = 0x040c;
30614 t.afii10062 = 0x040e;
30615 t.afii10063 = 0xf6c4;
30616 t.afii10064 = 0xf6c5;
30617 t.afii10065 = 0x0430;
30618 t.afii10066 = 0x0431;
30619 t.afii10067 = 0x0432;
30620 t.afii10068 = 0x0433;
30621 t.afii10069 = 0x0434;
30622 t.afii10070 = 0x0435;
30623 t.afii10071 = 0x0451;
30624 t.afii10072 = 0x0436;
30625 t.afii10073 = 0x0437;
30626 t.afii10074 = 0x0438;
30627 t.afii10075 = 0x0439;
30628 t.afii10076 = 0x043a;
30629 t.afii10077 = 0x043b;
30630 t.afii10078 = 0x043c;
30631 t.afii10079 = 0x043d;
30632 t.afii10080 = 0x043e;
30633 t.afii10081 = 0x043f;
30634 t.afii10082 = 0x0440;
30635 t.afii10083 = 0x0441;
30636 t.afii10084 = 0x0442;
30637 t.afii10085 = 0x0443;
30638 t.afii10086 = 0x0444;
30639 t.afii10087 = 0x0445;
30640 t.afii10088 = 0x0446;
30641 t.afii10089 = 0x0447;
30642 t.afii10090 = 0x0448;
30643 t.afii10091 = 0x0449;
30644 t.afii10092 = 0x044a;
30645 t.afii10093 = 0x044b;
30646 t.afii10094 = 0x044c;
30647 t.afii10095 = 0x044d;
30648 t.afii10096 = 0x044e;
30649 t.afii10097 = 0x044f;
30650 t.afii10098 = 0x0491;
30651 t.afii10099 = 0x0452;
30652 t.afii10100 = 0x0453;
30653 t.afii10101 = 0x0454;
30654 t.afii10102 = 0x0455;
30655 t.afii10103 = 0x0456;
30656 t.afii10104 = 0x0457;
30657 t.afii10105 = 0x0458;
30658 t.afii10106 = 0x0459;
30659 t.afii10107 = 0x045a;
30660 t.afii10108 = 0x045b;
30661 t.afii10109 = 0x045c;
30662 t.afii10110 = 0x045e;
30663 t.afii10145 = 0x040f;
30664 t.afii10146 = 0x0462;
30665 t.afii10147 = 0x0472;
30666 t.afii10148 = 0x0474;
30667 t.afii10192 = 0xf6c6;
30668 t.afii10193 = 0x045f;
30669 t.afii10194 = 0x0463;
30670 t.afii10195 = 0x0473;
30671 t.afii10196 = 0x0475;
30672 t.afii10831 = 0xf6c7;
30673 t.afii10832 = 0xf6c8;
30674 t.afii10846 = 0x04d9;
30675 t.afii299 = 0x200e;
30676 t.afii300 = 0x200f;
30677 t.afii301 = 0x200d;
30678 t.afii57381 = 0x066a;
30679 t.afii57388 = 0x060c;
30680 t.afii57392 = 0x0660;
30681 t.afii57393 = 0x0661;
30682 t.afii57394 = 0x0662;
30683 t.afii57395 = 0x0663;
30684 t.afii57396 = 0x0664;
30685 t.afii57397 = 0x0665;
30686 t.afii57398 = 0x0666;
30687 t.afii57399 = 0x0667;
30688 t.afii57400 = 0x0668;
30689 t.afii57401 = 0x0669;
30690 t.afii57403 = 0x061b;
30691 t.afii57407 = 0x061f;
30692 t.afii57409 = 0x0621;
30693 t.afii57410 = 0x0622;
30694 t.afii57411 = 0x0623;
30695 t.afii57412 = 0x0624;
30696 t.afii57413 = 0x0625;
30697 t.afii57414 = 0x0626;
30698 t.afii57415 = 0x0627;
30699 t.afii57416 = 0x0628;
30700 t.afii57417 = 0x0629;
30701 t.afii57418 = 0x062a;
30702 t.afii57419 = 0x062b;
30703 t.afii57420 = 0x062c;
30704 t.afii57421 = 0x062d;
30705 t.afii57422 = 0x062e;
30706 t.afii57423 = 0x062f;
30707 t.afii57424 = 0x0630;
30708 t.afii57425 = 0x0631;
30709 t.afii57426 = 0x0632;
30710 t.afii57427 = 0x0633;
30711 t.afii57428 = 0x0634;
30712 t.afii57429 = 0x0635;
30713 t.afii57430 = 0x0636;
30714 t.afii57431 = 0x0637;
30715 t.afii57432 = 0x0638;
30716 t.afii57433 = 0x0639;
30717 t.afii57434 = 0x063a;
30718 t.afii57440 = 0x0640;
30719 t.afii57441 = 0x0641;
30720 t.afii57442 = 0x0642;
30721 t.afii57443 = 0x0643;
30722 t.afii57444 = 0x0644;
30723 t.afii57445 = 0x0645;
30724 t.afii57446 = 0x0646;
30725 t.afii57448 = 0x0648;
30726 t.afii57449 = 0x0649;
30727 t.afii57450 = 0x064a;
30728 t.afii57451 = 0x064b;
30729 t.afii57452 = 0x064c;
30730 t.afii57453 = 0x064d;
30731 t.afii57454 = 0x064e;
30732 t.afii57455 = 0x064f;
30733 t.afii57456 = 0x0650;
30734 t.afii57457 = 0x0651;
30735 t.afii57458 = 0x0652;
30736 t.afii57470 = 0x0647;
30737 t.afii57505 = 0x06a4;
30738 t.afii57506 = 0x067e;
30739 t.afii57507 = 0x0686;
30740 t.afii57508 = 0x0698;
30741 t.afii57509 = 0x06af;
30742 t.afii57511 = 0x0679;
30743 t.afii57512 = 0x0688;
30744 t.afii57513 = 0x0691;
30745 t.afii57514 = 0x06ba;
30746 t.afii57519 = 0x06d2;
30747 t.afii57534 = 0x06d5;
30748 t.afii57636 = 0x20aa;
30749 t.afii57645 = 0x05be;
30750 t.afii57658 = 0x05c3;
30751 t.afii57664 = 0x05d0;
30752 t.afii57665 = 0x05d1;
30753 t.afii57666 = 0x05d2;
30754 t.afii57667 = 0x05d3;
30755 t.afii57668 = 0x05d4;
30756 t.afii57669 = 0x05d5;
30757 t.afii57670 = 0x05d6;
30758 t.afii57671 = 0x05d7;
30759 t.afii57672 = 0x05d8;
30760 t.afii57673 = 0x05d9;
30761 t.afii57674 = 0x05da;
30762 t.afii57675 = 0x05db;
30763 t.afii57676 = 0x05dc;
30764 t.afii57677 = 0x05dd;
30765 t.afii57678 = 0x05de;
30766 t.afii57679 = 0x05df;
30767 t.afii57680 = 0x05e0;
30768 t.afii57681 = 0x05e1;
30769 t.afii57682 = 0x05e2;
30770 t.afii57683 = 0x05e3;
30771 t.afii57684 = 0x05e4;
30772 t.afii57685 = 0x05e5;
30773 t.afii57686 = 0x05e6;
30774 t.afii57687 = 0x05e7;
30775 t.afii57688 = 0x05e8;
30776 t.afii57689 = 0x05e9;
30777 t.afii57690 = 0x05ea;
30778 t.afii57694 = 0xfb2a;
30779 t.afii57695 = 0xfb2b;
30780 t.afii57700 = 0xfb4b;
30781 t.afii57705 = 0xfb1f;
30782 t.afii57716 = 0x05f0;
30783 t.afii57717 = 0x05f1;
30784 t.afii57718 = 0x05f2;
30785 t.afii57723 = 0xfb35;
30786 t.afii57793 = 0x05b4;
30787 t.afii57794 = 0x05b5;
30788 t.afii57795 = 0x05b6;
30789 t.afii57796 = 0x05bb;
30790 t.afii57797 = 0x05b8;
30791 t.afii57798 = 0x05b7;
30792 t.afii57799 = 0x05b0;
30793 t.afii57800 = 0x05b2;
30794 t.afii57801 = 0x05b1;
30795 t.afii57802 = 0x05b3;
30796 t.afii57803 = 0x05c2;
30797 t.afii57804 = 0x05c1;
30798 t.afii57806 = 0x05b9;
30799 t.afii57807 = 0x05bc;
30800 t.afii57839 = 0x05bd;
30801 t.afii57841 = 0x05bf;
30802 t.afii57842 = 0x05c0;
30803 t.afii57929 = 0x02bc;
30804 t.afii61248 = 0x2105;
30805 t.afii61289 = 0x2113;
30806 t.afii61352 = 0x2116;
30807 t.afii61573 = 0x202c;
30808 t.afii61574 = 0x202d;
30809 t.afii61575 = 0x202e;
30810 t.afii61664 = 0x200c;
30811 t.afii63167 = 0x066d;
30812 t.afii64937 = 0x02bd;
30813 t.agrave = 0x00e0;
30814 t.agujarati = 0x0a85;
30815 t.agurmukhi = 0x0a05;
30816 t.ahiragana = 0x3042;
30817 t.ahookabove = 0x1ea3;
30818 t.aibengali = 0x0990;
30819 t.aibopomofo = 0x311e;
30820 t.aideva = 0x0910;
30821 t.aiecyrillic = 0x04d5;
30822 t.aigujarati = 0x0a90;
30823 t.aigurmukhi = 0x0a10;
30824 t.aimatragurmukhi = 0x0a48;
30825 t.ainarabic = 0x0639;
30826 t.ainfinalarabic = 0xfeca;
30827 t.aininitialarabic = 0xfecb;
30828 t.ainmedialarabic = 0xfecc;
30829 t.ainvertedbreve = 0x0203;
30830 t.aivowelsignbengali = 0x09c8;
30831 t.aivowelsigndeva = 0x0948;
30832 t.aivowelsigngujarati = 0x0ac8;
30833 t.akatakana = 0x30a2;
30834 t.akatakanahalfwidth = 0xff71;
30835 t.akorean = 0x314f;
30836 t.alef = 0x05d0;
30837 t.alefarabic = 0x0627;
30838 t.alefdageshhebrew = 0xfb30;
30839 t.aleffinalarabic = 0xfe8e;
30840 t.alefhamzaabovearabic = 0x0623;
30841 t.alefhamzaabovefinalarabic = 0xfe84;
30842 t.alefhamzabelowarabic = 0x0625;
30843 t.alefhamzabelowfinalarabic = 0xfe88;
30844 t.alefhebrew = 0x05d0;
30845 t.aleflamedhebrew = 0xfb4f;
30846 t.alefmaddaabovearabic = 0x0622;
30847 t.alefmaddaabovefinalarabic = 0xfe82;
30848 t.alefmaksuraarabic = 0x0649;
30849 t.alefmaksurafinalarabic = 0xfef0;
30850 t.alefmaksurainitialarabic = 0xfef3;
30851 t.alefmaksuramedialarabic = 0xfef4;
30852 t.alefpatahhebrew = 0xfb2e;
30853 t.alefqamatshebrew = 0xfb2f;
30854 t.aleph = 0x2135;
30855 t.allequal = 0x224c;
30856 t.alpha = 0x03b1;
30857 t.alphatonos = 0x03ac;
30858 t.amacron = 0x0101;
30859 t.amonospace = 0xff41;
30860 t.ampersand = 0x0026;
30861 t.ampersandmonospace = 0xff06;
30862 t.ampersandsmall = 0xf726;
30863 t.amsquare = 0x33c2;
30864 t.anbopomofo = 0x3122;
30865 t.angbopomofo = 0x3124;
30866 t.angbracketleft = 0x3008;
30867 t.angbracketright = 0x3009;
30868 t.angkhankhuthai = 0x0e5a;
30869 t.angle = 0x2220;
30870 t.anglebracketleft = 0x3008;
30871 t.anglebracketleftvertical = 0xfe3f;
30872 t.anglebracketright = 0x3009;
30873 t.anglebracketrightvertical = 0xfe40;
30874 t.angleleft = 0x2329;
30875 t.angleright = 0x232a;
30876 t.angstrom = 0x212b;
30877 t.anoteleia = 0x0387;
30878 t.anudattadeva = 0x0952;
30879 t.anusvarabengali = 0x0982;
30880 t.anusvaradeva = 0x0902;
30881 t.anusvaragujarati = 0x0a82;
30882 t.aogonek = 0x0105;
30883 t.apaatosquare = 0x3300;
30884 t.aparen = 0x249c;
30885 t.apostrophearmenian = 0x055a;
30886 t.apostrophemod = 0x02bc;
30887 t.apple = 0xf8ff;
30888 t.approaches = 0x2250;
30889 t.approxequal = 0x2248;
30890 t.approxequalorimage = 0x2252;
30891 t.approximatelyequal = 0x2245;
30892 t.araeaekorean = 0x318e;
30893 t.araeakorean = 0x318d;
30894 t.arc = 0x2312;
30895 t.arighthalfring = 0x1e9a;
30896 t.aring = 0x00e5;
30897 t.aringacute = 0x01fb;
30898 t.aringbelow = 0x1e01;
30899 t.arrowboth = 0x2194;
30900 t.arrowdashdown = 0x21e3;
30901 t.arrowdashleft = 0x21e0;
30902 t.arrowdashright = 0x21e2;
30903 t.arrowdashup = 0x21e1;
30904 t.arrowdblboth = 0x21d4;
30905 t.arrowdbldown = 0x21d3;
30906 t.arrowdblleft = 0x21d0;
30907 t.arrowdblright = 0x21d2;
30908 t.arrowdblup = 0x21d1;
30909 t.arrowdown = 0x2193;
30910 t.arrowdownleft = 0x2199;
30911 t.arrowdownright = 0x2198;
30912 t.arrowdownwhite = 0x21e9;
30913 t.arrowheaddownmod = 0x02c5;
30914 t.arrowheadleftmod = 0x02c2;
30915 t.arrowheadrightmod = 0x02c3;
30916 t.arrowheadupmod = 0x02c4;
30917 t.arrowhorizex = 0xf8e7;
30918 t.arrowleft = 0x2190;
30919 t.arrowleftdbl = 0x21d0;
30920 t.arrowleftdblstroke = 0x21cd;
30921 t.arrowleftoverright = 0x21c6;
30922 t.arrowleftwhite = 0x21e6;
30923 t.arrowright = 0x2192;
30924 t.arrowrightdblstroke = 0x21cf;
30925 t.arrowrightheavy = 0x279e;
30926 t.arrowrightoverleft = 0x21c4;
30927 t.arrowrightwhite = 0x21e8;
30928 t.arrowtableft = 0x21e4;
30929 t.arrowtabright = 0x21e5;
30930 t.arrowup = 0x2191;
30931 t.arrowupdn = 0x2195;
30932 t.arrowupdnbse = 0x21a8;
30933 t.arrowupdownbase = 0x21a8;
30934 t.arrowupleft = 0x2196;
30935 t.arrowupleftofdown = 0x21c5;
30936 t.arrowupright = 0x2197;
30937 t.arrowupwhite = 0x21e7;
30938 t.arrowvertex = 0xf8e6;
30939 t.asciicircum = 0x005e;
30940 t.asciicircummonospace = 0xff3e;
30941 t.asciitilde = 0x007e;
30942 t.asciitildemonospace = 0xff5e;
30943 t.ascript = 0x0251;
30944 t.ascriptturned = 0x0252;
30945 t.asmallhiragana = 0x3041;
30946 t.asmallkatakana = 0x30a1;
30947 t.asmallkatakanahalfwidth = 0xff67;
30948 t.asterisk = 0x002a;
30949 t.asteriskaltonearabic = 0x066d;
30950 t.asteriskarabic = 0x066d;
30951 t.asteriskmath = 0x2217;
30952 t.asteriskmonospace = 0xff0a;
30953 t.asterisksmall = 0xfe61;
30954 t.asterism = 0x2042;
30955 t.asuperior = 0xf6e9;
30956 t.asymptoticallyequal = 0x2243;
30957 t.at = 0x0040;
30958 t.atilde = 0x00e3;
30959 t.atmonospace = 0xff20;
30960 t.atsmall = 0xfe6b;
30961 t.aturned = 0x0250;
30962 t.aubengali = 0x0994;
30963 t.aubopomofo = 0x3120;
30964 t.audeva = 0x0914;
30965 t.augujarati = 0x0a94;
30966 t.augurmukhi = 0x0a14;
30967 t.aulengthmarkbengali = 0x09d7;
30968 t.aumatragurmukhi = 0x0a4c;
30969 t.auvowelsignbengali = 0x09cc;
30970 t.auvowelsigndeva = 0x094c;
30971 t.auvowelsigngujarati = 0x0acc;
30972 t.avagrahadeva = 0x093d;
30973 t.aybarmenian = 0x0561;
30974 t.ayin = 0x05e2;
30975 t.ayinaltonehebrew = 0xfb20;
30976 t.ayinhebrew = 0x05e2;
30977 t.b = 0x0062;
30978 t.babengali = 0x09ac;
30979 t.backslash = 0x005c;
30980 t.backslashmonospace = 0xff3c;
30981 t.badeva = 0x092c;
30982 t.bagujarati = 0x0aac;
30983 t.bagurmukhi = 0x0a2c;
30984 t.bahiragana = 0x3070;
30985 t.bahtthai = 0x0e3f;
30986 t.bakatakana = 0x30d0;
30987 t.bar = 0x007c;
30988 t.barmonospace = 0xff5c;
30989 t.bbopomofo = 0x3105;
30990 t.bcircle = 0x24d1;
30991 t.bdotaccent = 0x1e03;
30992 t.bdotbelow = 0x1e05;
30993 t.beamedsixteenthnotes = 0x266c;
30994 t.because = 0x2235;
30995 t.becyrillic = 0x0431;
30996 t.beharabic = 0x0628;
30997 t.behfinalarabic = 0xfe90;
30998 t.behinitialarabic = 0xfe91;
30999 t.behiragana = 0x3079;
31000 t.behmedialarabic = 0xfe92;
31001 t.behmeeminitialarabic = 0xfc9f;
31002 t.behmeemisolatedarabic = 0xfc08;
31003 t.behnoonfinalarabic = 0xfc6d;
31004 t.bekatakana = 0x30d9;
31005 t.benarmenian = 0x0562;
31006 t.bet = 0x05d1;
31007 t.beta = 0x03b2;
31008 t.betasymbolgreek = 0x03d0;
31009 t.betdagesh = 0xfb31;
31010 t.betdageshhebrew = 0xfb31;
31011 t.bethebrew = 0x05d1;
31012 t.betrafehebrew = 0xfb4c;
31013 t.bhabengali = 0x09ad;
31014 t.bhadeva = 0x092d;
31015 t.bhagujarati = 0x0aad;
31016 t.bhagurmukhi = 0x0a2d;
31017 t.bhook = 0x0253;
31018 t.bihiragana = 0x3073;
31019 t.bikatakana = 0x30d3;
31020 t.bilabialclick = 0x0298;
31021 t.bindigurmukhi = 0x0a02;
31022 t.birusquare = 0x3331;
31023 t.blackcircle = 0x25cf;
31024 t.blackdiamond = 0x25c6;
31025 t.blackdownpointingtriangle = 0x25bc;
31026 t.blackleftpointingpointer = 0x25c4;
31027 t.blackleftpointingtriangle = 0x25c0;
31028 t.blacklenticularbracketleft = 0x3010;
31029 t.blacklenticularbracketleftvertical = 0xfe3b;
31030 t.blacklenticularbracketright = 0x3011;
31031 t.blacklenticularbracketrightvertical = 0xfe3c;
31032 t.blacklowerlefttriangle = 0x25e3;
31033 t.blacklowerrighttriangle = 0x25e2;
31034 t.blackrectangle = 0x25ac;
31035 t.blackrightpointingpointer = 0x25ba;
31036 t.blackrightpointingtriangle = 0x25b6;
31037 t.blacksmallsquare = 0x25aa;
31038 t.blacksmilingface = 0x263b;
31039 t.blacksquare = 0x25a0;
31040 t.blackstar = 0x2605;
31041 t.blackupperlefttriangle = 0x25e4;
31042 t.blackupperrighttriangle = 0x25e5;
31043 t.blackuppointingsmalltriangle = 0x25b4;
31044 t.blackuppointingtriangle = 0x25b2;
31045 t.blank = 0x2423;
31046 t.blinebelow = 0x1e07;
31047 t.block = 0x2588;
31048 t.bmonospace = 0xff42;
31049 t.bobaimaithai = 0x0e1a;
31050 t.bohiragana = 0x307c;
31051 t.bokatakana = 0x30dc;
31052 t.bparen = 0x249d;
31053 t.bqsquare = 0x33c3;
31054 t.braceex = 0xf8f4;
31055 t.braceleft = 0x007b;
31056 t.braceleftbt = 0xf8f3;
31057 t.braceleftmid = 0xf8f2;
31058 t.braceleftmonospace = 0xff5b;
31059 t.braceleftsmall = 0xfe5b;
31060 t.bracelefttp = 0xf8f1;
31061 t.braceleftvertical = 0xfe37;
31062 t.braceright = 0x007d;
31063 t.bracerightbt = 0xf8fe;
31064 t.bracerightmid = 0xf8fd;
31065 t.bracerightmonospace = 0xff5d;
31066 t.bracerightsmall = 0xfe5c;
31067 t.bracerighttp = 0xf8fc;
31068 t.bracerightvertical = 0xfe38;
31069 t.bracketleft = 0x005b;
31070 t.bracketleftbt = 0xf8f0;
31071 t.bracketleftex = 0xf8ef;
31072 t.bracketleftmonospace = 0xff3b;
31073 t.bracketlefttp = 0xf8ee;
31074 t.bracketright = 0x005d;
31075 t.bracketrightbt = 0xf8fb;
31076 t.bracketrightex = 0xf8fa;
31077 t.bracketrightmonospace = 0xff3d;
31078 t.bracketrighttp = 0xf8f9;
31079 t.breve = 0x02d8;
31080 t.brevebelowcmb = 0x032e;
31081 t.brevecmb = 0x0306;
31082 t.breveinvertedbelowcmb = 0x032f;
31083 t.breveinvertedcmb = 0x0311;
31084 t.breveinverteddoublecmb = 0x0361;
31085 t.bridgebelowcmb = 0x032a;
31086 t.bridgeinvertedbelowcmb = 0x033a;
31087 t.brokenbar = 0x00a6;
31088 t.bstroke = 0x0180;
31089 t.bsuperior = 0xf6ea;
31090 t.btopbar = 0x0183;
31091 t.buhiragana = 0x3076;
31092 t.bukatakana = 0x30d6;
31093 t.bullet = 0x2022;
31094 t.bulletinverse = 0x25d8;
31095 t.bulletoperator = 0x2219;
31096 t.bullseye = 0x25ce;
31097 t.c = 0x0063;
31098 t.caarmenian = 0x056e;
31099 t.cabengali = 0x099a;
31100 t.cacute = 0x0107;
31101 t.cadeva = 0x091a;
31102 t.cagujarati = 0x0a9a;
31103 t.cagurmukhi = 0x0a1a;
31104 t.calsquare = 0x3388;
31105 t.candrabindubengali = 0x0981;
31106 t.candrabinducmb = 0x0310;
31107 t.candrabindudeva = 0x0901;
31108 t.candrabindugujarati = 0x0a81;
31109 t.capslock = 0x21ea;
31110 t.careof = 0x2105;
31111 t.caron = 0x02c7;
31112 t.caronbelowcmb = 0x032c;
31113 t.caroncmb = 0x030c;
31114 t.carriagereturn = 0x21b5;
31115 t.cbopomofo = 0x3118;
31116 t.ccaron = 0x010d;
31117 t.ccedilla = 0x00e7;
31118 t.ccedillaacute = 0x1e09;
31119 t.ccircle = 0x24d2;
31120 t.ccircumflex = 0x0109;
31121 t.ccurl = 0x0255;
31122 t.cdot = 0x010b;
31123 t.cdotaccent = 0x010b;
31124 t.cdsquare = 0x33c5;
31125 t.cedilla = 0x00b8;
31126 t.cedillacmb = 0x0327;
31127 t.cent = 0x00a2;
31128 t.centigrade = 0x2103;
31129 t.centinferior = 0xf6df;
31130 t.centmonospace = 0xffe0;
31131 t.centoldstyle = 0xf7a2;
31132 t.centsuperior = 0xf6e0;
31133 t.chaarmenian = 0x0579;
31134 t.chabengali = 0x099b;
31135 t.chadeva = 0x091b;
31136 t.chagujarati = 0x0a9b;
31137 t.chagurmukhi = 0x0a1b;
31138 t.chbopomofo = 0x3114;
31139 t.cheabkhasiancyrillic = 0x04bd;
31140 t.checkmark = 0x2713;
31141 t.checyrillic = 0x0447;
31142 t.chedescenderabkhasiancyrillic = 0x04bf;
31143 t.chedescendercyrillic = 0x04b7;
31144 t.chedieresiscyrillic = 0x04f5;
31145 t.cheharmenian = 0x0573;
31146 t.chekhakassiancyrillic = 0x04cc;
31147 t.cheverticalstrokecyrillic = 0x04b9;
31148 t.chi = 0x03c7;
31149 t.chieuchacirclekorean = 0x3277;
31150 t.chieuchaparenkorean = 0x3217;
31151 t.chieuchcirclekorean = 0x3269;
31152 t.chieuchkorean = 0x314a;
31153 t.chieuchparenkorean = 0x3209;
31154 t.chochangthai = 0x0e0a;
31155 t.chochanthai = 0x0e08;
31156 t.chochingthai = 0x0e09;
31157 t.chochoethai = 0x0e0c;
31158 t.chook = 0x0188;
31159 t.cieucacirclekorean = 0x3276;
31160 t.cieucaparenkorean = 0x3216;
31161 t.cieuccirclekorean = 0x3268;
31162 t.cieuckorean = 0x3148;
31163 t.cieucparenkorean = 0x3208;
31164 t.cieucuparenkorean = 0x321c;
31165 t.circle = 0x25cb;
31166 t.circlecopyrt = 0x00a9;
31167 t.circlemultiply = 0x2297;
31168 t.circleot = 0x2299;
31169 t.circleplus = 0x2295;
31170 t.circlepostalmark = 0x3036;
31171 t.circlewithlefthalfblack = 0x25d0;
31172 t.circlewithrighthalfblack = 0x25d1;
31173 t.circumflex = 0x02c6;
31174 t.circumflexbelowcmb = 0x032d;
31175 t.circumflexcmb = 0x0302;
31176 t.clear = 0x2327;
31177 t.clickalveolar = 0x01c2;
31178 t.clickdental = 0x01c0;
31179 t.clicklateral = 0x01c1;
31180 t.clickretroflex = 0x01c3;
31181 t.club = 0x2663;
31182 t.clubsuitblack = 0x2663;
31183 t.clubsuitwhite = 0x2667;
31184 t.cmcubedsquare = 0x33a4;
31185 t.cmonospace = 0xff43;
31186 t.cmsquaredsquare = 0x33a0;
31187 t.coarmenian = 0x0581;
31188 t.colon = 0x003a;
31189 t.colonmonetary = 0x20a1;
31190 t.colonmonospace = 0xff1a;
31191 t.colonsign = 0x20a1;
31192 t.colonsmall = 0xfe55;
31193 t.colontriangularhalfmod = 0x02d1;
31194 t.colontriangularmod = 0x02d0;
31195 t.comma = 0x002c;
31196 t.commaabovecmb = 0x0313;
31197 t.commaaboverightcmb = 0x0315;
31198 t.commaaccent = 0xf6c3;
31199 t.commaarabic = 0x060c;
31200 t.commaarmenian = 0x055d;
31201 t.commainferior = 0xf6e1;
31202 t.commamonospace = 0xff0c;
31203 t.commareversedabovecmb = 0x0314;
31204 t.commareversedmod = 0x02bd;
31205 t.commasmall = 0xfe50;
31206 t.commasuperior = 0xf6e2;
31207 t.commaturnedabovecmb = 0x0312;
31208 t.commaturnedmod = 0x02bb;
31209 t.compass = 0x263c;
31210 t.congruent = 0x2245;
31211 t.contourintegral = 0x222e;
31212 t.control = 0x2303;
31213 t.controlACK = 0x0006;
31214 t.controlBEL = 0x0007;
31215 t.controlBS = 0x0008;
31216 t.controlCAN = 0x0018;
31217 t.controlCR = 0x000d;
31218 t.controlDC1 = 0x0011;
31219 t.controlDC2 = 0x0012;
31220 t.controlDC3 = 0x0013;
31221 t.controlDC4 = 0x0014;
31222 t.controlDEL = 0x007f;
31223 t.controlDLE = 0x0010;
31224 t.controlEM = 0x0019;
31225 t.controlENQ = 0x0005;
31226 t.controlEOT = 0x0004;
31227 t.controlESC = 0x001b;
31228 t.controlETB = 0x0017;
31229 t.controlETX = 0x0003;
31230 t.controlFF = 0x000c;
31231 t.controlFS = 0x001c;
31232 t.controlGS = 0x001d;
31233 t.controlHT = 0x0009;
31234 t.controlLF = 0x000a;
31235 t.controlNAK = 0x0015;
31236 t.controlNULL = 0x0000;
31237 t.controlRS = 0x001e;
31238 t.controlSI = 0x000f;
31239 t.controlSO = 0x000e;
31240 t.controlSOT = 0x0002;
31241 t.controlSTX = 0x0001;
31242 t.controlSUB = 0x001a;
31243 t.controlSYN = 0x0016;
31244 t.controlUS = 0x001f;
31245 t.controlVT = 0x000b;
31246 t.copyright = 0x00a9;
31247 t.copyrightsans = 0xf8e9;
31248 t.copyrightserif = 0xf6d9;
31249 t.cornerbracketleft = 0x300c;
31250 t.cornerbracketlefthalfwidth = 0xff62;
31251 t.cornerbracketleftvertical = 0xfe41;
31252 t.cornerbracketright = 0x300d;
31253 t.cornerbracketrighthalfwidth = 0xff63;
31254 t.cornerbracketrightvertical = 0xfe42;
31255 t.corporationsquare = 0x337f;
31256 t.cosquare = 0x33c7;
31257 t.coverkgsquare = 0x33c6;
31258 t.cparen = 0x249e;
31259 t.cruzeiro = 0x20a2;
31260 t.cstretched = 0x0297;
31261 t.curlyand = 0x22cf;
31262 t.curlyor = 0x22ce;
31263 t.currency = 0x00a4;
31264 t.cyrBreve = 0xf6d1;
31265 t.cyrFlex = 0xf6d2;
31266 t.cyrbreve = 0xf6d4;
31267 t.cyrflex = 0xf6d5;
31268 t.d = 0x0064;
31269 t.daarmenian = 0x0564;
31270 t.dabengali = 0x09a6;
31271 t.dadarabic = 0x0636;
31272 t.dadeva = 0x0926;
31273 t.dadfinalarabic = 0xfebe;
31274 t.dadinitialarabic = 0xfebf;
31275 t.dadmedialarabic = 0xfec0;
31276 t.dagesh = 0x05bc;
31277 t.dageshhebrew = 0x05bc;
31278 t.dagger = 0x2020;
31279 t.daggerdbl = 0x2021;
31280 t.dagujarati = 0x0aa6;
31281 t.dagurmukhi = 0x0a26;
31282 t.dahiragana = 0x3060;
31283 t.dakatakana = 0x30c0;
31284 t.dalarabic = 0x062f;
31285 t.dalet = 0x05d3;
31286 t.daletdagesh = 0xfb33;
31287 t.daletdageshhebrew = 0xfb33;
31288 t.dalethebrew = 0x05d3;
31289 t.dalfinalarabic = 0xfeaa;
31290 t.dammaarabic = 0x064f;
31291 t.dammalowarabic = 0x064f;
31292 t.dammatanaltonearabic = 0x064c;
31293 t.dammatanarabic = 0x064c;
31294 t.danda = 0x0964;
31295 t.dargahebrew = 0x05a7;
31296 t.dargalefthebrew = 0x05a7;
31297 t.dasiapneumatacyrilliccmb = 0x0485;
31298 t.dblGrave = 0xf6d3;
31299 t.dblanglebracketleft = 0x300a;
31300 t.dblanglebracketleftvertical = 0xfe3d;
31301 t.dblanglebracketright = 0x300b;
31302 t.dblanglebracketrightvertical = 0xfe3e;
31303 t.dblarchinvertedbelowcmb = 0x032b;
31304 t.dblarrowleft = 0x21d4;
31305 t.dblarrowright = 0x21d2;
31306 t.dbldanda = 0x0965;
31307 t.dblgrave = 0xf6d6;
31308 t.dblgravecmb = 0x030f;
31309 t.dblintegral = 0x222c;
31310 t.dbllowline = 0x2017;
31311 t.dbllowlinecmb = 0x0333;
31312 t.dbloverlinecmb = 0x033f;
31313 t.dblprimemod = 0x02ba;
31314 t.dblverticalbar = 0x2016;
31315 t.dblverticallineabovecmb = 0x030e;
31316 t.dbopomofo = 0x3109;
31317 t.dbsquare = 0x33c8;
31318 t.dcaron = 0x010f;
31319 t.dcedilla = 0x1e11;
31320 t.dcircle = 0x24d3;
31321 t.dcircumflexbelow = 0x1e13;
31322 t.dcroat = 0x0111;
31323 t.ddabengali = 0x09a1;
31324 t.ddadeva = 0x0921;
31325 t.ddagujarati = 0x0aa1;
31326 t.ddagurmukhi = 0x0a21;
31327 t.ddalarabic = 0x0688;
31328 t.ddalfinalarabic = 0xfb89;
31329 t.dddhadeva = 0x095c;
31330 t.ddhabengali = 0x09a2;
31331 t.ddhadeva = 0x0922;
31332 t.ddhagujarati = 0x0aa2;
31333 t.ddhagurmukhi = 0x0a22;
31334 t.ddotaccent = 0x1e0b;
31335 t.ddotbelow = 0x1e0d;
31336 t.decimalseparatorarabic = 0x066b;
31337 t.decimalseparatorpersian = 0x066b;
31338 t.decyrillic = 0x0434;
31339 t.degree = 0x00b0;
31340 t.dehihebrew = 0x05ad;
31341 t.dehiragana = 0x3067;
31342 t.deicoptic = 0x03ef;
31343 t.dekatakana = 0x30c7;
31344 t.deleteleft = 0x232b;
31345 t.deleteright = 0x2326;
31346 t.delta = 0x03b4;
31347 t.deltaturned = 0x018d;
31348 t.denominatorminusonenumeratorbengali = 0x09f8;
31349 t.dezh = 0x02a4;
31350 t.dhabengali = 0x09a7;
31351 t.dhadeva = 0x0927;
31352 t.dhagujarati = 0x0aa7;
31353 t.dhagurmukhi = 0x0a27;
31354 t.dhook = 0x0257;
31355 t.dialytikatonos = 0x0385;
31356 t.dialytikatonoscmb = 0x0344;
31357 t.diamond = 0x2666;
31358 t.diamondsuitwhite = 0x2662;
31359 t.dieresis = 0x00a8;
31360 t.dieresisacute = 0xf6d7;
31361 t.dieresisbelowcmb = 0x0324;
31362 t.dieresiscmb = 0x0308;
31363 t.dieresisgrave = 0xf6d8;
31364 t.dieresistonos = 0x0385;
31365 t.dihiragana = 0x3062;
31366 t.dikatakana = 0x30c2;
31367 t.dittomark = 0x3003;
31368 t.divide = 0x00f7;
31369 t.divides = 0x2223;
31370 t.divisionslash = 0x2215;
31371 t.djecyrillic = 0x0452;
31372 t.dkshade = 0x2593;
31373 t.dlinebelow = 0x1e0f;
31374 t.dlsquare = 0x3397;
31375 t.dmacron = 0x0111;
31376 t.dmonospace = 0xff44;
31377 t.dnblock = 0x2584;
31378 t.dochadathai = 0x0e0e;
31379 t.dodekthai = 0x0e14;
31380 t.dohiragana = 0x3069;
31381 t.dokatakana = 0x30c9;
31382 t.dollar = 0x0024;
31383 t.dollarinferior = 0xf6e3;
31384 t.dollarmonospace = 0xff04;
31385 t.dollaroldstyle = 0xf724;
31386 t.dollarsmall = 0xfe69;
31387 t.dollarsuperior = 0xf6e4;
31388 t.dong = 0x20ab;
31389 t.dorusquare = 0x3326;
31390 t.dotaccent = 0x02d9;
31391 t.dotaccentcmb = 0x0307;
31392 t.dotbelowcmb = 0x0323;
31393 t.dotbelowcomb = 0x0323;
31394 t.dotkatakana = 0x30fb;
31395 t.dotlessi = 0x0131;
31396 t.dotlessj = 0xf6be;
31397 t.dotlessjstrokehook = 0x0284;
31398 t.dotmath = 0x22c5;
31399 t.dottedcircle = 0x25cc;
31400 t.doubleyodpatah = 0xfb1f;
31401 t.doubleyodpatahhebrew = 0xfb1f;
31402 t.downtackbelowcmb = 0x031e;
31403 t.downtackmod = 0x02d5;
31404 t.dparen = 0x249f;
31405 t.dsuperior = 0xf6eb;
31406 t.dtail = 0x0256;
31407 t.dtopbar = 0x018c;
31408 t.duhiragana = 0x3065;
31409 t.dukatakana = 0x30c5;
31410 t.dz = 0x01f3;
31411 t.dzaltone = 0x02a3;
31412 t.dzcaron = 0x01c6;
31413 t.dzcurl = 0x02a5;
31414 t.dzeabkhasiancyrillic = 0x04e1;
31415 t.dzecyrillic = 0x0455;
31416 t.dzhecyrillic = 0x045f;
31417 t.e = 0x0065;
31418 t.eacute = 0x00e9;
31419 t.earth = 0x2641;
31420 t.ebengali = 0x098f;
31421 t.ebopomofo = 0x311c;
31422 t.ebreve = 0x0115;
31423 t.ecandradeva = 0x090d;
31424 t.ecandragujarati = 0x0a8d;
31425 t.ecandravowelsigndeva = 0x0945;
31426 t.ecandravowelsigngujarati = 0x0ac5;
31427 t.ecaron = 0x011b;
31428 t.ecedillabreve = 0x1e1d;
31429 t.echarmenian = 0x0565;
31430 t.echyiwnarmenian = 0x0587;
31431 t.ecircle = 0x24d4;
31432 t.ecircumflex = 0x00ea;
31433 t.ecircumflexacute = 0x1ebf;
31434 t.ecircumflexbelow = 0x1e19;
31435 t.ecircumflexdotbelow = 0x1ec7;
31436 t.ecircumflexgrave = 0x1ec1;
31437 t.ecircumflexhookabove = 0x1ec3;
31438 t.ecircumflextilde = 0x1ec5;
31439 t.ecyrillic = 0x0454;
31440 t.edblgrave = 0x0205;
31441 t.edeva = 0x090f;
31442 t.edieresis = 0x00eb;
31443 t.edot = 0x0117;
31444 t.edotaccent = 0x0117;
31445 t.edotbelow = 0x1eb9;
31446 t.eegurmukhi = 0x0a0f;
31447 t.eematragurmukhi = 0x0a47;
31448 t.efcyrillic = 0x0444;
31449 t.egrave = 0x00e8;
31450 t.egujarati = 0x0a8f;
31451 t.eharmenian = 0x0567;
31452 t.ehbopomofo = 0x311d;
31453 t.ehiragana = 0x3048;
31454 t.ehookabove = 0x1ebb;
31455 t.eibopomofo = 0x311f;
31456 t.eight = 0x0038;
31457 t.eightarabic = 0x0668;
31458 t.eightbengali = 0x09ee;
31459 t.eightcircle = 0x2467;
31460 t.eightcircleinversesansserif = 0x2791;
31461 t.eightdeva = 0x096e;
31462 t.eighteencircle = 0x2471;
31463 t.eighteenparen = 0x2485;
31464 t.eighteenperiod = 0x2499;
31465 t.eightgujarati = 0x0aee;
31466 t.eightgurmukhi = 0x0a6e;
31467 t.eighthackarabic = 0x0668;
31468 t.eighthangzhou = 0x3028;
31469 t.eighthnotebeamed = 0x266b;
31470 t.eightideographicparen = 0x3227;
31471 t.eightinferior = 0x2088;
31472 t.eightmonospace = 0xff18;
31473 t.eightoldstyle = 0xf738;
31474 t.eightparen = 0x247b;
31475 t.eightperiod = 0x248f;
31476 t.eightpersian = 0x06f8;
31477 t.eightroman = 0x2177;
31478 t.eightsuperior = 0x2078;
31479 t.eightthai = 0x0e58;
31480 t.einvertedbreve = 0x0207;
31481 t.eiotifiedcyrillic = 0x0465;
31482 t.ekatakana = 0x30a8;
31483 t.ekatakanahalfwidth = 0xff74;
31484 t.ekonkargurmukhi = 0x0a74;
31485 t.ekorean = 0x3154;
31486 t.elcyrillic = 0x043b;
31487 t.element = 0x2208;
31488 t.elevencircle = 0x246a;
31489 t.elevenparen = 0x247e;
31490 t.elevenperiod = 0x2492;
31491 t.elevenroman = 0x217a;
31492 t.ellipsis = 0x2026;
31493 t.ellipsisvertical = 0x22ee;
31494 t.emacron = 0x0113;
31495 t.emacronacute = 0x1e17;
31496 t.emacrongrave = 0x1e15;
31497 t.emcyrillic = 0x043c;
31498 t.emdash = 0x2014;
31499 t.emdashvertical = 0xfe31;
31500 t.emonospace = 0xff45;
31501 t.emphasismarkarmenian = 0x055b;
31502 t.emptyset = 0x2205;
31503 t.enbopomofo = 0x3123;
31504 t.encyrillic = 0x043d;
31505 t.endash = 0x2013;
31506 t.endashvertical = 0xfe32;
31507 t.endescendercyrillic = 0x04a3;
31508 t.eng = 0x014b;
31509 t.engbopomofo = 0x3125;
31510 t.enghecyrillic = 0x04a5;
31511 t.enhookcyrillic = 0x04c8;
31512 t.enspace = 0x2002;
31513 t.eogonek = 0x0119;
31514 t.eokorean = 0x3153;
31515 t.eopen = 0x025b;
31516 t.eopenclosed = 0x029a;
31517 t.eopenreversed = 0x025c;
31518 t.eopenreversedclosed = 0x025e;
31519 t.eopenreversedhook = 0x025d;
31520 t.eparen = 0x24a0;
31521 t.epsilon = 0x03b5;
31522 t.epsilontonos = 0x03ad;
31523 t.equal = 0x003d;
31524 t.equalmonospace = 0xff1d;
31525 t.equalsmall = 0xfe66;
31526 t.equalsuperior = 0x207c;
31527 t.equivalence = 0x2261;
31528 t.erbopomofo = 0x3126;
31529 t.ercyrillic = 0x0440;
31530 t.ereversed = 0x0258;
31531 t.ereversedcyrillic = 0x044d;
31532 t.escyrillic = 0x0441;
31533 t.esdescendercyrillic = 0x04ab;
31534 t.esh = 0x0283;
31535 t.eshcurl = 0x0286;
31536 t.eshortdeva = 0x090e;
31537 t.eshortvowelsigndeva = 0x0946;
31538 t.eshreversedloop = 0x01aa;
31539 t.eshsquatreversed = 0x0285;
31540 t.esmallhiragana = 0x3047;
31541 t.esmallkatakana = 0x30a7;
31542 t.esmallkatakanahalfwidth = 0xff6a;
31543 t.estimated = 0x212e;
31544 t.esuperior = 0xf6ec;
31545 t.eta = 0x03b7;
31546 t.etarmenian = 0x0568;
31547 t.etatonos = 0x03ae;
31548 t.eth = 0x00f0;
31549 t.etilde = 0x1ebd;
31550 t.etildebelow = 0x1e1b;
31551 t.etnahtafoukhhebrew = 0x0591;
31552 t.etnahtafoukhlefthebrew = 0x0591;
31553 t.etnahtahebrew = 0x0591;
31554 t.etnahtalefthebrew = 0x0591;
31555 t.eturned = 0x01dd;
31556 t.eukorean = 0x3161;
31557 t.euro = 0x20ac;
31558 t.evowelsignbengali = 0x09c7;
31559 t.evowelsigndeva = 0x0947;
31560 t.evowelsigngujarati = 0x0ac7;
31561 t.exclam = 0x0021;
31562 t.exclamarmenian = 0x055c;
31563 t.exclamdbl = 0x203c;
31564 t.exclamdown = 0x00a1;
31565 t.exclamdownsmall = 0xf7a1;
31566 t.exclammonospace = 0xff01;
31567 t.exclamsmall = 0xf721;
31568 t.existential = 0x2203;
31569 t.ezh = 0x0292;
31570 t.ezhcaron = 0x01ef;
31571 t.ezhcurl = 0x0293;
31572 t.ezhreversed = 0x01b9;
31573 t.ezhtail = 0x01ba;
31574 t.f = 0x0066;
31575 t.fadeva = 0x095e;
31576 t.fagurmukhi = 0x0a5e;
31577 t.fahrenheit = 0x2109;
31578 t.fathaarabic = 0x064e;
31579 t.fathalowarabic = 0x064e;
31580 t.fathatanarabic = 0x064b;
31581 t.fbopomofo = 0x3108;
31582 t.fcircle = 0x24d5;
31583 t.fdotaccent = 0x1e1f;
31584 t.feharabic = 0x0641;
31585 t.feharmenian = 0x0586;
31586 t.fehfinalarabic = 0xfed2;
31587 t.fehinitialarabic = 0xfed3;
31588 t.fehmedialarabic = 0xfed4;
31589 t.feicoptic = 0x03e5;
31590 t.female = 0x2640;
31591 t.ff = 0xfb00;
31592 t.f_f = 0xfb00;
31593 t.ffi = 0xfb03;
31594 t.ffl = 0xfb04;
31595 t.fi = 0xfb01;
31596 t.fifteencircle = 0x246e;
31597 t.fifteenparen = 0x2482;
31598 t.fifteenperiod = 0x2496;
31599 t.figuredash = 0x2012;
31600 t.filledbox = 0x25a0;
31601 t.filledrect = 0x25ac;
31602 t.finalkaf = 0x05da;
31603 t.finalkafdagesh = 0xfb3a;
31604 t.finalkafdageshhebrew = 0xfb3a;
31605 t.finalkafhebrew = 0x05da;
31606 t.finalmem = 0x05dd;
31607 t.finalmemhebrew = 0x05dd;
31608 t.finalnun = 0x05df;
31609 t.finalnunhebrew = 0x05df;
31610 t.finalpe = 0x05e3;
31611 t.finalpehebrew = 0x05e3;
31612 t.finaltsadi = 0x05e5;
31613 t.finaltsadihebrew = 0x05e5;
31614 t.firsttonechinese = 0x02c9;
31615 t.fisheye = 0x25c9;
31616 t.fitacyrillic = 0x0473;
31617 t.five = 0x0035;
31618 t.fivearabic = 0x0665;
31619 t.fivebengali = 0x09eb;
31620 t.fivecircle = 0x2464;
31621 t.fivecircleinversesansserif = 0x278e;
31622 t.fivedeva = 0x096b;
31623 t.fiveeighths = 0x215d;
31624 t.fivegujarati = 0x0aeb;
31625 t.fivegurmukhi = 0x0a6b;
31626 t.fivehackarabic = 0x0665;
31627 t.fivehangzhou = 0x3025;
31628 t.fiveideographicparen = 0x3224;
31629 t.fiveinferior = 0x2085;
31630 t.fivemonospace = 0xff15;
31631 t.fiveoldstyle = 0xf735;
31632 t.fiveparen = 0x2478;
31633 t.fiveperiod = 0x248c;
31634 t.fivepersian = 0x06f5;
31635 t.fiveroman = 0x2174;
31636 t.fivesuperior = 0x2075;
31637 t.fivethai = 0x0e55;
31638 t.fl = 0xfb02;
31639 t.florin = 0x0192;
31640 t.fmonospace = 0xff46;
31641 t.fmsquare = 0x3399;
31642 t.fofanthai = 0x0e1f;
31643 t.fofathai = 0x0e1d;
31644 t.fongmanthai = 0x0e4f;
31645 t.forall = 0x2200;
31646 t.four = 0x0034;
31647 t.fourarabic = 0x0664;
31648 t.fourbengali = 0x09ea;
31649 t.fourcircle = 0x2463;
31650 t.fourcircleinversesansserif = 0x278d;
31651 t.fourdeva = 0x096a;
31652 t.fourgujarati = 0x0aea;
31653 t.fourgurmukhi = 0x0a6a;
31654 t.fourhackarabic = 0x0664;
31655 t.fourhangzhou = 0x3024;
31656 t.fourideographicparen = 0x3223;
31657 t.fourinferior = 0x2084;
31658 t.fourmonospace = 0xff14;
31659 t.fournumeratorbengali = 0x09f7;
31660 t.fouroldstyle = 0xf734;
31661 t.fourparen = 0x2477;
31662 t.fourperiod = 0x248b;
31663 t.fourpersian = 0x06f4;
31664 t.fourroman = 0x2173;
31665 t.foursuperior = 0x2074;
31666 t.fourteencircle = 0x246d;
31667 t.fourteenparen = 0x2481;
31668 t.fourteenperiod = 0x2495;
31669 t.fourthai = 0x0e54;
31670 t.fourthtonechinese = 0x02cb;
31671 t.fparen = 0x24a1;
31672 t.fraction = 0x2044;
31673 t.franc = 0x20a3;
31674 t.g = 0x0067;
31675 t.gabengali = 0x0997;
31676 t.gacute = 0x01f5;
31677 t.gadeva = 0x0917;
31678 t.gafarabic = 0x06af;
31679 t.gaffinalarabic = 0xfb93;
31680 t.gafinitialarabic = 0xfb94;
31681 t.gafmedialarabic = 0xfb95;
31682 t.gagujarati = 0x0a97;
31683 t.gagurmukhi = 0x0a17;
31684 t.gahiragana = 0x304c;
31685 t.gakatakana = 0x30ac;
31686 t.gamma = 0x03b3;
31687 t.gammalatinsmall = 0x0263;
31688 t.gammasuperior = 0x02e0;
31689 t.gangiacoptic = 0x03eb;
31690 t.gbopomofo = 0x310d;
31691 t.gbreve = 0x011f;
31692 t.gcaron = 0x01e7;
31693 t.gcedilla = 0x0123;
31694 t.gcircle = 0x24d6;
31695 t.gcircumflex = 0x011d;
31696 t.gcommaaccent = 0x0123;
31697 t.gdot = 0x0121;
31698 t.gdotaccent = 0x0121;
31699 t.gecyrillic = 0x0433;
31700 t.gehiragana = 0x3052;
31701 t.gekatakana = 0x30b2;
31702 t.geometricallyequal = 0x2251;
31703 t.gereshaccenthebrew = 0x059c;
31704 t.gereshhebrew = 0x05f3;
31705 t.gereshmuqdamhebrew = 0x059d;
31706 t.germandbls = 0x00df;
31707 t.gershayimaccenthebrew = 0x059e;
31708 t.gershayimhebrew = 0x05f4;
31709 t.getamark = 0x3013;
31710 t.ghabengali = 0x0998;
31711 t.ghadarmenian = 0x0572;
31712 t.ghadeva = 0x0918;
31713 t.ghagujarati = 0x0a98;
31714 t.ghagurmukhi = 0x0a18;
31715 t.ghainarabic = 0x063a;
31716 t.ghainfinalarabic = 0xfece;
31717 t.ghaininitialarabic = 0xfecf;
31718 t.ghainmedialarabic = 0xfed0;
31719 t.ghemiddlehookcyrillic = 0x0495;
31720 t.ghestrokecyrillic = 0x0493;
31721 t.gheupturncyrillic = 0x0491;
31722 t.ghhadeva = 0x095a;
31723 t.ghhagurmukhi = 0x0a5a;
31724 t.ghook = 0x0260;
31725 t.ghzsquare = 0x3393;
31726 t.gihiragana = 0x304e;
31727 t.gikatakana = 0x30ae;
31728 t.gimarmenian = 0x0563;
31729 t.gimel = 0x05d2;
31730 t.gimeldagesh = 0xfb32;
31731 t.gimeldageshhebrew = 0xfb32;
31732 t.gimelhebrew = 0x05d2;
31733 t.gjecyrillic = 0x0453;
31734 t.glottalinvertedstroke = 0x01be;
31735 t.glottalstop = 0x0294;
31736 t.glottalstopinverted = 0x0296;
31737 t.glottalstopmod = 0x02c0;
31738 t.glottalstopreversed = 0x0295;
31739 t.glottalstopreversedmod = 0x02c1;
31740 t.glottalstopreversedsuperior = 0x02e4;
31741 t.glottalstopstroke = 0x02a1;
31742 t.glottalstopstrokereversed = 0x02a2;
31743 t.gmacron = 0x1e21;
31744 t.gmonospace = 0xff47;
31745 t.gohiragana = 0x3054;
31746 t.gokatakana = 0x30b4;
31747 t.gparen = 0x24a2;
31748 t.gpasquare = 0x33ac;
31749 t.gradient = 0x2207;
31750 t.grave = 0x0060;
31751 t.gravebelowcmb = 0x0316;
31752 t.gravecmb = 0x0300;
31753 t.gravecomb = 0x0300;
31754 t.gravedeva = 0x0953;
31755 t.gravelowmod = 0x02ce;
31756 t.gravemonospace = 0xff40;
31757 t.gravetonecmb = 0x0340;
31758 t.greater = 0x003e;
31759 t.greaterequal = 0x2265;
31760 t.greaterequalorless = 0x22db;
31761 t.greatermonospace = 0xff1e;
31762 t.greaterorequivalent = 0x2273;
31763 t.greaterorless = 0x2277;
31764 t.greateroverequal = 0x2267;
31765 t.greatersmall = 0xfe65;
31766 t.gscript = 0x0261;
31767 t.gstroke = 0x01e5;
31768 t.guhiragana = 0x3050;
31769 t.guillemotleft = 0x00ab;
31770 t.guillemotright = 0x00bb;
31771 t.guilsinglleft = 0x2039;
31772 t.guilsinglright = 0x203a;
31773 t.gukatakana = 0x30b0;
31774 t.guramusquare = 0x3318;
31775 t.gysquare = 0x33c9;
31776 t.h = 0x0068;
31777 t.haabkhasiancyrillic = 0x04a9;
31778 t.haaltonearabic = 0x06c1;
31779 t.habengali = 0x09b9;
31780 t.hadescendercyrillic = 0x04b3;
31781 t.hadeva = 0x0939;
31782 t.hagujarati = 0x0ab9;
31783 t.hagurmukhi = 0x0a39;
31784 t.haharabic = 0x062d;
31785 t.hahfinalarabic = 0xfea2;
31786 t.hahinitialarabic = 0xfea3;
31787 t.hahiragana = 0x306f;
31788 t.hahmedialarabic = 0xfea4;
31789 t.haitusquare = 0x332a;
31790 t.hakatakana = 0x30cf;
31791 t.hakatakanahalfwidth = 0xff8a;
31792 t.halantgurmukhi = 0x0a4d;
31793 t.hamzaarabic = 0x0621;
31794 t.hamzalowarabic = 0x0621;
31795 t.hangulfiller = 0x3164;
31796 t.hardsigncyrillic = 0x044a;
31797 t.harpoonleftbarbup = 0x21bc;
31798 t.harpoonrightbarbup = 0x21c0;
31799 t.hasquare = 0x33ca;
31800 t.hatafpatah = 0x05b2;
31801 t.hatafpatah16 = 0x05b2;
31802 t.hatafpatah23 = 0x05b2;
31803 t.hatafpatah2f = 0x05b2;
31804 t.hatafpatahhebrew = 0x05b2;
31805 t.hatafpatahnarrowhebrew = 0x05b2;
31806 t.hatafpatahquarterhebrew = 0x05b2;
31807 t.hatafpatahwidehebrew = 0x05b2;
31808 t.hatafqamats = 0x05b3;
31809 t.hatafqamats1b = 0x05b3;
31810 t.hatafqamats28 = 0x05b3;
31811 t.hatafqamats34 = 0x05b3;
31812 t.hatafqamatshebrew = 0x05b3;
31813 t.hatafqamatsnarrowhebrew = 0x05b3;
31814 t.hatafqamatsquarterhebrew = 0x05b3;
31815 t.hatafqamatswidehebrew = 0x05b3;
31816 t.hatafsegol = 0x05b1;
31817 t.hatafsegol17 = 0x05b1;
31818 t.hatafsegol24 = 0x05b1;
31819 t.hatafsegol30 = 0x05b1;
31820 t.hatafsegolhebrew = 0x05b1;
31821 t.hatafsegolnarrowhebrew = 0x05b1;
31822 t.hatafsegolquarterhebrew = 0x05b1;
31823 t.hatafsegolwidehebrew = 0x05b1;
31824 t.hbar = 0x0127;
31825 t.hbopomofo = 0x310f;
31826 t.hbrevebelow = 0x1e2b;
31827 t.hcedilla = 0x1e29;
31828 t.hcircle = 0x24d7;
31829 t.hcircumflex = 0x0125;
31830 t.hdieresis = 0x1e27;
31831 t.hdotaccent = 0x1e23;
31832 t.hdotbelow = 0x1e25;
31833 t.he = 0x05d4;
31834 t.heart = 0x2665;
31835 t.heartsuitblack = 0x2665;
31836 t.heartsuitwhite = 0x2661;
31837 t.hedagesh = 0xfb34;
31838 t.hedageshhebrew = 0xfb34;
31839 t.hehaltonearabic = 0x06c1;
31840 t.heharabic = 0x0647;
31841 t.hehebrew = 0x05d4;
31842 t.hehfinalaltonearabic = 0xfba7;
31843 t.hehfinalalttwoarabic = 0xfeea;
31844 t.hehfinalarabic = 0xfeea;
31845 t.hehhamzaabovefinalarabic = 0xfba5;
31846 t.hehhamzaaboveisolatedarabic = 0xfba4;
31847 t.hehinitialaltonearabic = 0xfba8;
31848 t.hehinitialarabic = 0xfeeb;
31849 t.hehiragana = 0x3078;
31850 t.hehmedialaltonearabic = 0xfba9;
31851 t.hehmedialarabic = 0xfeec;
31852 t.heiseierasquare = 0x337b;
31853 t.hekatakana = 0x30d8;
31854 t.hekatakanahalfwidth = 0xff8d;
31855 t.hekutaarusquare = 0x3336;
31856 t.henghook = 0x0267;
31857 t.herutusquare = 0x3339;
31858 t.het = 0x05d7;
31859 t.hethebrew = 0x05d7;
31860 t.hhook = 0x0266;
31861 t.hhooksuperior = 0x02b1;
31862 t.hieuhacirclekorean = 0x327b;
31863 t.hieuhaparenkorean = 0x321b;
31864 t.hieuhcirclekorean = 0x326d;
31865 t.hieuhkorean = 0x314e;
31866 t.hieuhparenkorean = 0x320d;
31867 t.hihiragana = 0x3072;
31868 t.hikatakana = 0x30d2;
31869 t.hikatakanahalfwidth = 0xff8b;
31870 t.hiriq = 0x05b4;
31871 t.hiriq14 = 0x05b4;
31872 t.hiriq21 = 0x05b4;
31873 t.hiriq2d = 0x05b4;
31874 t.hiriqhebrew = 0x05b4;
31875 t.hiriqnarrowhebrew = 0x05b4;
31876 t.hiriqquarterhebrew = 0x05b4;
31877 t.hiriqwidehebrew = 0x05b4;
31878 t.hlinebelow = 0x1e96;
31879 t.hmonospace = 0xff48;
31880 t.hoarmenian = 0x0570;
31881 t.hohipthai = 0x0e2b;
31882 t.hohiragana = 0x307b;
31883 t.hokatakana = 0x30db;
31884 t.hokatakanahalfwidth = 0xff8e;
31885 t.holam = 0x05b9;
31886 t.holam19 = 0x05b9;
31887 t.holam26 = 0x05b9;
31888 t.holam32 = 0x05b9;
31889 t.holamhebrew = 0x05b9;
31890 t.holamnarrowhebrew = 0x05b9;
31891 t.holamquarterhebrew = 0x05b9;
31892 t.holamwidehebrew = 0x05b9;
31893 t.honokhukthai = 0x0e2e;
31894 t.hookabovecomb = 0x0309;
31895 t.hookcmb = 0x0309;
31896 t.hookpalatalizedbelowcmb = 0x0321;
31897 t.hookretroflexbelowcmb = 0x0322;
31898 t.hoonsquare = 0x3342;
31899 t.horicoptic = 0x03e9;
31900 t.horizontalbar = 0x2015;
31901 t.horncmb = 0x031b;
31902 t.hotsprings = 0x2668;
31903 t.house = 0x2302;
31904 t.hparen = 0x24a3;
31905 t.hsuperior = 0x02b0;
31906 t.hturned = 0x0265;
31907 t.huhiragana = 0x3075;
31908 t.huiitosquare = 0x3333;
31909 t.hukatakana = 0x30d5;
31910 t.hukatakanahalfwidth = 0xff8c;
31911 t.hungarumlaut = 0x02dd;
31912 t.hungarumlautcmb = 0x030b;
31913 t.hv = 0x0195;
31914 t.hyphen = 0x002d;
31915 t.hypheninferior = 0xf6e5;
31916 t.hyphenmonospace = 0xff0d;
31917 t.hyphensmall = 0xfe63;
31918 t.hyphensuperior = 0xf6e6;
31919 t.hyphentwo = 0x2010;
31920 t.i = 0x0069;
31921 t.iacute = 0x00ed;
31922 t.iacyrillic = 0x044f;
31923 t.ibengali = 0x0987;
31924 t.ibopomofo = 0x3127;
31925 t.ibreve = 0x012d;
31926 t.icaron = 0x01d0;
31927 t.icircle = 0x24d8;
31928 t.icircumflex = 0x00ee;
31929 t.icyrillic = 0x0456;
31930 t.idblgrave = 0x0209;
31931 t.ideographearthcircle = 0x328f;
31932 t.ideographfirecircle = 0x328b;
31933 t.ideographicallianceparen = 0x323f;
31934 t.ideographiccallparen = 0x323a;
31935 t.ideographiccentrecircle = 0x32a5;
31936 t.ideographicclose = 0x3006;
31937 t.ideographiccomma = 0x3001;
31938 t.ideographiccommaleft = 0xff64;
31939 t.ideographiccongratulationparen = 0x3237;
31940 t.ideographiccorrectcircle = 0x32a3;
31941 t.ideographicearthparen = 0x322f;
31942 t.ideographicenterpriseparen = 0x323d;
31943 t.ideographicexcellentcircle = 0x329d;
31944 t.ideographicfestivalparen = 0x3240;
31945 t.ideographicfinancialcircle = 0x3296;
31946 t.ideographicfinancialparen = 0x3236;
31947 t.ideographicfireparen = 0x322b;
31948 t.ideographichaveparen = 0x3232;
31949 t.ideographichighcircle = 0x32a4;
31950 t.ideographiciterationmark = 0x3005;
31951 t.ideographiclaborcircle = 0x3298;
31952 t.ideographiclaborparen = 0x3238;
31953 t.ideographicleftcircle = 0x32a7;
31954 t.ideographiclowcircle = 0x32a6;
31955 t.ideographicmedicinecircle = 0x32a9;
31956 t.ideographicmetalparen = 0x322e;
31957 t.ideographicmoonparen = 0x322a;
31958 t.ideographicnameparen = 0x3234;
31959 t.ideographicperiod = 0x3002;
31960 t.ideographicprintcircle = 0x329e;
31961 t.ideographicreachparen = 0x3243;
31962 t.ideographicrepresentparen = 0x3239;
31963 t.ideographicresourceparen = 0x323e;
31964 t.ideographicrightcircle = 0x32a8;
31965 t.ideographicsecretcircle = 0x3299;
31966 t.ideographicselfparen = 0x3242;
31967 t.ideographicsocietyparen = 0x3233;
31968 t.ideographicspace = 0x3000;
31969 t.ideographicspecialparen = 0x3235;
31970 t.ideographicstockparen = 0x3231;
31971 t.ideographicstudyparen = 0x323b;
31972 t.ideographicsunparen = 0x3230;
31973 t.ideographicsuperviseparen = 0x323c;
31974 t.ideographicwaterparen = 0x322c;
31975 t.ideographicwoodparen = 0x322d;
31976 t.ideographiczero = 0x3007;
31977 t.ideographmetalcircle = 0x328e;
31978 t.ideographmooncircle = 0x328a;
31979 t.ideographnamecircle = 0x3294;
31980 t.ideographsuncircle = 0x3290;
31981 t.ideographwatercircle = 0x328c;
31982 t.ideographwoodcircle = 0x328d;
31983 t.ideva = 0x0907;
31984 t.idieresis = 0x00ef;
31985 t.idieresisacute = 0x1e2f;
31986 t.idieresiscyrillic = 0x04e5;
31987 t.idotbelow = 0x1ecb;
31988 t.iebrevecyrillic = 0x04d7;
31989 t.iecyrillic = 0x0435;
31990 t.ieungacirclekorean = 0x3275;
31991 t.ieungaparenkorean = 0x3215;
31992 t.ieungcirclekorean = 0x3267;
31993 t.ieungkorean = 0x3147;
31994 t.ieungparenkorean = 0x3207;
31995 t.igrave = 0x00ec;
31996 t.igujarati = 0x0a87;
31997 t.igurmukhi = 0x0a07;
31998 t.ihiragana = 0x3044;
31999 t.ihookabove = 0x1ec9;
32000 t.iibengali = 0x0988;
32001 t.iicyrillic = 0x0438;
32002 t.iideva = 0x0908;
32003 t.iigujarati = 0x0a88;
32004 t.iigurmukhi = 0x0a08;
32005 t.iimatragurmukhi = 0x0a40;
32006 t.iinvertedbreve = 0x020b;
32007 t.iishortcyrillic = 0x0439;
32008 t.iivowelsignbengali = 0x09c0;
32009 t.iivowelsigndeva = 0x0940;
32010 t.iivowelsigngujarati = 0x0ac0;
32011 t.ij = 0x0133;
32012 t.ikatakana = 0x30a4;
32013 t.ikatakanahalfwidth = 0xff72;
32014 t.ikorean = 0x3163;
32015 t.ilde = 0x02dc;
32016 t.iluyhebrew = 0x05ac;
32017 t.imacron = 0x012b;
32018 t.imacroncyrillic = 0x04e3;
32019 t.imageorapproximatelyequal = 0x2253;
32020 t.imatragurmukhi = 0x0a3f;
32021 t.imonospace = 0xff49;
32022 t.increment = 0x2206;
32023 t.infinity = 0x221e;
32024 t.iniarmenian = 0x056b;
32025 t.integral = 0x222b;
32026 t.integralbottom = 0x2321;
32027 t.integralbt = 0x2321;
32028 t.integralex = 0xf8f5;
32029 t.integraltop = 0x2320;
32030 t.integraltp = 0x2320;
32031 t.intersection = 0x2229;
32032 t.intisquare = 0x3305;
32033 t.invbullet = 0x25d8;
32034 t.invcircle = 0x25d9;
32035 t.invsmileface = 0x263b;
32036 t.iocyrillic = 0x0451;
32037 t.iogonek = 0x012f;
32038 t.iota = 0x03b9;
32039 t.iotadieresis = 0x03ca;
32040 t.iotadieresistonos = 0x0390;
32041 t.iotalatin = 0x0269;
32042 t.iotatonos = 0x03af;
32043 t.iparen = 0x24a4;
32044 t.irigurmukhi = 0x0a72;
32045 t.ismallhiragana = 0x3043;
32046 t.ismallkatakana = 0x30a3;
32047 t.ismallkatakanahalfwidth = 0xff68;
32048 t.issharbengali = 0x09fa;
32049 t.istroke = 0x0268;
32050 t.isuperior = 0xf6ed;
32051 t.iterationhiragana = 0x309d;
32052 t.iterationkatakana = 0x30fd;
32053 t.itilde = 0x0129;
32054 t.itildebelow = 0x1e2d;
32055 t.iubopomofo = 0x3129;
32056 t.iucyrillic = 0x044e;
32057 t.ivowelsignbengali = 0x09bf;
32058 t.ivowelsigndeva = 0x093f;
32059 t.ivowelsigngujarati = 0x0abf;
32060 t.izhitsacyrillic = 0x0475;
32061 t.izhitsadblgravecyrillic = 0x0477;
32062 t.j = 0x006a;
32063 t.jaarmenian = 0x0571;
32064 t.jabengali = 0x099c;
32065 t.jadeva = 0x091c;
32066 t.jagujarati = 0x0a9c;
32067 t.jagurmukhi = 0x0a1c;
32068 t.jbopomofo = 0x3110;
32069 t.jcaron = 0x01f0;
32070 t.jcircle = 0x24d9;
32071 t.jcircumflex = 0x0135;
32072 t.jcrossedtail = 0x029d;
32073 t.jdotlessstroke = 0x025f;
32074 t.jecyrillic = 0x0458;
32075 t.jeemarabic = 0x062c;
32076 t.jeemfinalarabic = 0xfe9e;
32077 t.jeeminitialarabic = 0xfe9f;
32078 t.jeemmedialarabic = 0xfea0;
32079 t.jeharabic = 0x0698;
32080 t.jehfinalarabic = 0xfb8b;
32081 t.jhabengali = 0x099d;
32082 t.jhadeva = 0x091d;
32083 t.jhagujarati = 0x0a9d;
32084 t.jhagurmukhi = 0x0a1d;
32085 t.jheharmenian = 0x057b;
32086 t.jis = 0x3004;
32087 t.jmonospace = 0xff4a;
32088 t.jparen = 0x24a5;
32089 t.jsuperior = 0x02b2;
32090 t.k = 0x006b;
32091 t.kabashkircyrillic = 0x04a1;
32092 t.kabengali = 0x0995;
32093 t.kacute = 0x1e31;
32094 t.kacyrillic = 0x043a;
32095 t.kadescendercyrillic = 0x049b;
32096 t.kadeva = 0x0915;
32097 t.kaf = 0x05db;
32098 t.kafarabic = 0x0643;
32099 t.kafdagesh = 0xfb3b;
32100 t.kafdageshhebrew = 0xfb3b;
32101 t.kaffinalarabic = 0xfeda;
32102 t.kafhebrew = 0x05db;
32103 t.kafinitialarabic = 0xfedb;
32104 t.kafmedialarabic = 0xfedc;
32105 t.kafrafehebrew = 0xfb4d;
32106 t.kagujarati = 0x0a95;
32107 t.kagurmukhi = 0x0a15;
32108 t.kahiragana = 0x304b;
32109 t.kahookcyrillic = 0x04c4;
32110 t.kakatakana = 0x30ab;
32111 t.kakatakanahalfwidth = 0xff76;
32112 t.kappa = 0x03ba;
32113 t.kappasymbolgreek = 0x03f0;
32114 t.kapyeounmieumkorean = 0x3171;
32115 t.kapyeounphieuphkorean = 0x3184;
32116 t.kapyeounpieupkorean = 0x3178;
32117 t.kapyeounssangpieupkorean = 0x3179;
32118 t.karoriisquare = 0x330d;
32119 t.kashidaautoarabic = 0x0640;
32120 t.kashidaautonosidebearingarabic = 0x0640;
32121 t.kasmallkatakana = 0x30f5;
32122 t.kasquare = 0x3384;
32123 t.kasraarabic = 0x0650;
32124 t.kasratanarabic = 0x064d;
32125 t.kastrokecyrillic = 0x049f;
32126 t.katahiraprolongmarkhalfwidth = 0xff70;
32127 t.kaverticalstrokecyrillic = 0x049d;
32128 t.kbopomofo = 0x310e;
32129 t.kcalsquare = 0x3389;
32130 t.kcaron = 0x01e9;
32131 t.kcedilla = 0x0137;
32132 t.kcircle = 0x24da;
32133 t.kcommaaccent = 0x0137;
32134 t.kdotbelow = 0x1e33;
32135 t.keharmenian = 0x0584;
32136 t.kehiragana = 0x3051;
32137 t.kekatakana = 0x30b1;
32138 t.kekatakanahalfwidth = 0xff79;
32139 t.kenarmenian = 0x056f;
32140 t.kesmallkatakana = 0x30f6;
32141 t.kgreenlandic = 0x0138;
32142 t.khabengali = 0x0996;
32143 t.khacyrillic = 0x0445;
32144 t.khadeva = 0x0916;
32145 t.khagujarati = 0x0a96;
32146 t.khagurmukhi = 0x0a16;
32147 t.khaharabic = 0x062e;
32148 t.khahfinalarabic = 0xfea6;
32149 t.khahinitialarabic = 0xfea7;
32150 t.khahmedialarabic = 0xfea8;
32151 t.kheicoptic = 0x03e7;
32152 t.khhadeva = 0x0959;
32153 t.khhagurmukhi = 0x0a59;
32154 t.khieukhacirclekorean = 0x3278;
32155 t.khieukhaparenkorean = 0x3218;
32156 t.khieukhcirclekorean = 0x326a;
32157 t.khieukhkorean = 0x314b;
32158 t.khieukhparenkorean = 0x320a;
32159 t.khokhaithai = 0x0e02;
32160 t.khokhonthai = 0x0e05;
32161 t.khokhuatthai = 0x0e03;
32162 t.khokhwaithai = 0x0e04;
32163 t.khomutthai = 0x0e5b;
32164 t.khook = 0x0199;
32165 t.khorakhangthai = 0x0e06;
32166 t.khzsquare = 0x3391;
32167 t.kihiragana = 0x304d;
32168 t.kikatakana = 0x30ad;
32169 t.kikatakanahalfwidth = 0xff77;
32170 t.kiroguramusquare = 0x3315;
32171 t.kiromeetorusquare = 0x3316;
32172 t.kirosquare = 0x3314;
32173 t.kiyeokacirclekorean = 0x326e;
32174 t.kiyeokaparenkorean = 0x320e;
32175 t.kiyeokcirclekorean = 0x3260;
32176 t.kiyeokkorean = 0x3131;
32177 t.kiyeokparenkorean = 0x3200;
32178 t.kiyeoksioskorean = 0x3133;
32179 t.kjecyrillic = 0x045c;
32180 t.klinebelow = 0x1e35;
32181 t.klsquare = 0x3398;
32182 t.kmcubedsquare = 0x33a6;
32183 t.kmonospace = 0xff4b;
32184 t.kmsquaredsquare = 0x33a2;
32185 t.kohiragana = 0x3053;
32186 t.kohmsquare = 0x33c0;
32187 t.kokaithai = 0x0e01;
32188 t.kokatakana = 0x30b3;
32189 t.kokatakanahalfwidth = 0xff7a;
32190 t.kooposquare = 0x331e;
32191 t.koppacyrillic = 0x0481;
32192 t.koreanstandardsymbol = 0x327f;
32193 t.koroniscmb = 0x0343;
32194 t.kparen = 0x24a6;
32195 t.kpasquare = 0x33aa;
32196 t.ksicyrillic = 0x046f;
32197 t.ktsquare = 0x33cf;
32198 t.kturned = 0x029e;
32199 t.kuhiragana = 0x304f;
32200 t.kukatakana = 0x30af;
32201 t.kukatakanahalfwidth = 0xff78;
32202 t.kvsquare = 0x33b8;
32203 t.kwsquare = 0x33be;
32204 t.l = 0x006c;
32205 t.labengali = 0x09b2;
32206 t.lacute = 0x013a;
32207 t.ladeva = 0x0932;
32208 t.lagujarati = 0x0ab2;
32209 t.lagurmukhi = 0x0a32;
32210 t.lakkhangyaothai = 0x0e45;
32211 t.lamaleffinalarabic = 0xfefc;
32212 t.lamalefhamzaabovefinalarabic = 0xfef8;
32213 t.lamalefhamzaaboveisolatedarabic = 0xfef7;
32214 t.lamalefhamzabelowfinalarabic = 0xfefa;
32215 t.lamalefhamzabelowisolatedarabic = 0xfef9;
32216 t.lamalefisolatedarabic = 0xfefb;
32217 t.lamalefmaddaabovefinalarabic = 0xfef6;
32218 t.lamalefmaddaaboveisolatedarabic = 0xfef5;
32219 t.lamarabic = 0x0644;
32220 t.lambda = 0x03bb;
32221 t.lambdastroke = 0x019b;
32222 t.lamed = 0x05dc;
32223 t.lameddagesh = 0xfb3c;
32224 t.lameddageshhebrew = 0xfb3c;
32225 t.lamedhebrew = 0x05dc;
32226 t.lamfinalarabic = 0xfede;
32227 t.lamhahinitialarabic = 0xfcca;
32228 t.laminitialarabic = 0xfedf;
32229 t.lamjeeminitialarabic = 0xfcc9;
32230 t.lamkhahinitialarabic = 0xfccb;
32231 t.lamlamhehisolatedarabic = 0xfdf2;
32232 t.lammedialarabic = 0xfee0;
32233 t.lammeemhahinitialarabic = 0xfd88;
32234 t.lammeeminitialarabic = 0xfccc;
32235 t.largecircle = 0x25ef;
32236 t.lbar = 0x019a;
32237 t.lbelt = 0x026c;
32238 t.lbopomofo = 0x310c;
32239 t.lcaron = 0x013e;
32240 t.lcedilla = 0x013c;
32241 t.lcircle = 0x24db;
32242 t.lcircumflexbelow = 0x1e3d;
32243 t.lcommaaccent = 0x013c;
32244 t.ldot = 0x0140;
32245 t.ldotaccent = 0x0140;
32246 t.ldotbelow = 0x1e37;
32247 t.ldotbelowmacron = 0x1e39;
32248 t.leftangleabovecmb = 0x031a;
32249 t.lefttackbelowcmb = 0x0318;
32250 t.less = 0x003c;
32251 t.lessequal = 0x2264;
32252 t.lessequalorgreater = 0x22da;
32253 t.lessmonospace = 0xff1c;
32254 t.lessorequivalent = 0x2272;
32255 t.lessorgreater = 0x2276;
32256 t.lessoverequal = 0x2266;
32257 t.lesssmall = 0xfe64;
32258 t.lezh = 0x026e;
32259 t.lfblock = 0x258c;
32260 t.lhookretroflex = 0x026d;
32261 t.lira = 0x20a4;
32262 t.liwnarmenian = 0x056c;
32263 t.lj = 0x01c9;
32264 t.ljecyrillic = 0x0459;
32265 t.ll = 0xf6c0;
32266 t.lladeva = 0x0933;
32267 t.llagujarati = 0x0ab3;
32268 t.llinebelow = 0x1e3b;
32269 t.llladeva = 0x0934;
32270 t.llvocalicbengali = 0x09e1;
32271 t.llvocalicdeva = 0x0961;
32272 t.llvocalicvowelsignbengali = 0x09e3;
32273 t.llvocalicvowelsigndeva = 0x0963;
32274 t.lmiddletilde = 0x026b;
32275 t.lmonospace = 0xff4c;
32276 t.lmsquare = 0x33d0;
32277 t.lochulathai = 0x0e2c;
32278 t.logicaland = 0x2227;
32279 t.logicalnot = 0x00ac;
32280 t.logicalnotreversed = 0x2310;
32281 t.logicalor = 0x2228;
32282 t.lolingthai = 0x0e25;
32283 t.longs = 0x017f;
32284 t.lowlinecenterline = 0xfe4e;
32285 t.lowlinecmb = 0x0332;
32286 t.lowlinedashed = 0xfe4d;
32287 t.lozenge = 0x25ca;
32288 t.lparen = 0x24a7;
32289 t.lslash = 0x0142;
32290 t.lsquare = 0x2113;
32291 t.lsuperior = 0xf6ee;
32292 t.ltshade = 0x2591;
32293 t.luthai = 0x0e26;
32294 t.lvocalicbengali = 0x098c;
32295 t.lvocalicdeva = 0x090c;
32296 t.lvocalicvowelsignbengali = 0x09e2;
32297 t.lvocalicvowelsigndeva = 0x0962;
32298 t.lxsquare = 0x33d3;
32299 t.m = 0x006d;
32300 t.mabengali = 0x09ae;
32301 t.macron = 0x00af;
32302 t.macronbelowcmb = 0x0331;
32303 t.macroncmb = 0x0304;
32304 t.macronlowmod = 0x02cd;
32305 t.macronmonospace = 0xffe3;
32306 t.macute = 0x1e3f;
32307 t.madeva = 0x092e;
32308 t.magujarati = 0x0aae;
32309 t.magurmukhi = 0x0a2e;
32310 t.mahapakhhebrew = 0x05a4;
32311 t.mahapakhlefthebrew = 0x05a4;
32312 t.mahiragana = 0x307e;
32313 t.maichattawalowleftthai = 0xf895;
32314 t.maichattawalowrightthai = 0xf894;
32315 t.maichattawathai = 0x0e4b;
32316 t.maichattawaupperleftthai = 0xf893;
32317 t.maieklowleftthai = 0xf88c;
32318 t.maieklowrightthai = 0xf88b;
32319 t.maiekthai = 0x0e48;
32320 t.maiekupperleftthai = 0xf88a;
32321 t.maihanakatleftthai = 0xf884;
32322 t.maihanakatthai = 0x0e31;
32323 t.maitaikhuleftthai = 0xf889;
32324 t.maitaikhuthai = 0x0e47;
32325 t.maitholowleftthai = 0xf88f;
32326 t.maitholowrightthai = 0xf88e;
32327 t.maithothai = 0x0e49;
32328 t.maithoupperleftthai = 0xf88d;
32329 t.maitrilowleftthai = 0xf892;
32330 t.maitrilowrightthai = 0xf891;
32331 t.maitrithai = 0x0e4a;
32332 t.maitriupperleftthai = 0xf890;
32333 t.maiyamokthai = 0x0e46;
32334 t.makatakana = 0x30de;
32335 t.makatakanahalfwidth = 0xff8f;
32336 t.male = 0x2642;
32337 t.mansyonsquare = 0x3347;
32338 t.maqafhebrew = 0x05be;
32339 t.mars = 0x2642;
32340 t.masoracirclehebrew = 0x05af;
32341 t.masquare = 0x3383;
32342 t.mbopomofo = 0x3107;
32343 t.mbsquare = 0x33d4;
32344 t.mcircle = 0x24dc;
32345 t.mcubedsquare = 0x33a5;
32346 t.mdotaccent = 0x1e41;
32347 t.mdotbelow = 0x1e43;
32348 t.meemarabic = 0x0645;
32349 t.meemfinalarabic = 0xfee2;
32350 t.meeminitialarabic = 0xfee3;
32351 t.meemmedialarabic = 0xfee4;
32352 t.meemmeeminitialarabic = 0xfcd1;
32353 t.meemmeemisolatedarabic = 0xfc48;
32354 t.meetorusquare = 0x334d;
32355 t.mehiragana = 0x3081;
32356 t.meizierasquare = 0x337e;
32357 t.mekatakana = 0x30e1;
32358 t.mekatakanahalfwidth = 0xff92;
32359 t.mem = 0x05de;
32360 t.memdagesh = 0xfb3e;
32361 t.memdageshhebrew = 0xfb3e;
32362 t.memhebrew = 0x05de;
32363 t.menarmenian = 0x0574;
32364 t.merkhahebrew = 0x05a5;
32365 t.merkhakefulahebrew = 0x05a6;
32366 t.merkhakefulalefthebrew = 0x05a6;
32367 t.merkhalefthebrew = 0x05a5;
32368 t.mhook = 0x0271;
32369 t.mhzsquare = 0x3392;
32370 t.middledotkatakanahalfwidth = 0xff65;
32371 t.middot = 0x00b7;
32372 t.mieumacirclekorean = 0x3272;
32373 t.mieumaparenkorean = 0x3212;
32374 t.mieumcirclekorean = 0x3264;
32375 t.mieumkorean = 0x3141;
32376 t.mieumpansioskorean = 0x3170;
32377 t.mieumparenkorean = 0x3204;
32378 t.mieumpieupkorean = 0x316e;
32379 t.mieumsioskorean = 0x316f;
32380 t.mihiragana = 0x307f;
32381 t.mikatakana = 0x30df;
32382 t.mikatakanahalfwidth = 0xff90;
32383 t.minus = 0x2212;
32384 t.minusbelowcmb = 0x0320;
32385 t.minuscircle = 0x2296;
32386 t.minusmod = 0x02d7;
32387 t.minusplus = 0x2213;
32388 t.minute = 0x2032;
32389 t.miribaarusquare = 0x334a;
32390 t.mirisquare = 0x3349;
32391 t.mlonglegturned = 0x0270;
32392 t.mlsquare = 0x3396;
32393 t.mmcubedsquare = 0x33a3;
32394 t.mmonospace = 0xff4d;
32395 t.mmsquaredsquare = 0x339f;
32396 t.mohiragana = 0x3082;
32397 t.mohmsquare = 0x33c1;
32398 t.mokatakana = 0x30e2;
32399 t.mokatakanahalfwidth = 0xff93;
32400 t.molsquare = 0x33d6;
32401 t.momathai = 0x0e21;
32402 t.moverssquare = 0x33a7;
32403 t.moverssquaredsquare = 0x33a8;
32404 t.mparen = 0x24a8;
32405 t.mpasquare = 0x33ab;
32406 t.mssquare = 0x33b3;
32407 t.msuperior = 0xf6ef;
32408 t.mturned = 0x026f;
32409 t.mu = 0x00b5;
32410 t.mu1 = 0x00b5;
32411 t.muasquare = 0x3382;
32412 t.muchgreater = 0x226b;
32413 t.muchless = 0x226a;
32414 t.mufsquare = 0x338c;
32415 t.mugreek = 0x03bc;
32416 t.mugsquare = 0x338d;
32417 t.muhiragana = 0x3080;
32418 t.mukatakana = 0x30e0;
32419 t.mukatakanahalfwidth = 0xff91;
32420 t.mulsquare = 0x3395;
32421 t.multiply = 0x00d7;
32422 t.mumsquare = 0x339b;
32423 t.munahhebrew = 0x05a3;
32424 t.munahlefthebrew = 0x05a3;
32425 t.musicalnote = 0x266a;
32426 t.musicalnotedbl = 0x266b;
32427 t.musicflatsign = 0x266d;
32428 t.musicsharpsign = 0x266f;
32429 t.mussquare = 0x33b2;
32430 t.muvsquare = 0x33b6;
32431 t.muwsquare = 0x33bc;
32432 t.mvmegasquare = 0x33b9;
32433 t.mvsquare = 0x33b7;
32434 t.mwmegasquare = 0x33bf;
32435 t.mwsquare = 0x33bd;
32436 t.n = 0x006e;
32437 t.nabengali = 0x09a8;
32438 t.nabla = 0x2207;
32439 t.nacute = 0x0144;
32440 t.nadeva = 0x0928;
32441 t.nagujarati = 0x0aa8;
32442 t.nagurmukhi = 0x0a28;
32443 t.nahiragana = 0x306a;
32444 t.nakatakana = 0x30ca;
32445 t.nakatakanahalfwidth = 0xff85;
32446 t.napostrophe = 0x0149;
32447 t.nasquare = 0x3381;
32448 t.nbopomofo = 0x310b;
32449 t.nbspace = 0x00a0;
32450 t.ncaron = 0x0148;
32451 t.ncedilla = 0x0146;
32452 t.ncircle = 0x24dd;
32453 t.ncircumflexbelow = 0x1e4b;
32454 t.ncommaaccent = 0x0146;
32455 t.ndotaccent = 0x1e45;
32456 t.ndotbelow = 0x1e47;
32457 t.nehiragana = 0x306d;
32458 t.nekatakana = 0x30cd;
32459 t.nekatakanahalfwidth = 0xff88;
32460 t.newsheqelsign = 0x20aa;
32461 t.nfsquare = 0x338b;
32462 t.ngabengali = 0x0999;
32463 t.ngadeva = 0x0919;
32464 t.ngagujarati = 0x0a99;
32465 t.ngagurmukhi = 0x0a19;
32466 t.ngonguthai = 0x0e07;
32467 t.nhiragana = 0x3093;
32468 t.nhookleft = 0x0272;
32469 t.nhookretroflex = 0x0273;
32470 t.nieunacirclekorean = 0x326f;
32471 t.nieunaparenkorean = 0x320f;
32472 t.nieuncieuckorean = 0x3135;
32473 t.nieuncirclekorean = 0x3261;
32474 t.nieunhieuhkorean = 0x3136;
32475 t.nieunkorean = 0x3134;
32476 t.nieunpansioskorean = 0x3168;
32477 t.nieunparenkorean = 0x3201;
32478 t.nieunsioskorean = 0x3167;
32479 t.nieuntikeutkorean = 0x3166;
32480 t.nihiragana = 0x306b;
32481 t.nikatakana = 0x30cb;
32482 t.nikatakanahalfwidth = 0xff86;
32483 t.nikhahitleftthai = 0xf899;
32484 t.nikhahitthai = 0x0e4d;
32485 t.nine = 0x0039;
32486 t.ninearabic = 0x0669;
32487 t.ninebengali = 0x09ef;
32488 t.ninecircle = 0x2468;
32489 t.ninecircleinversesansserif = 0x2792;
32490 t.ninedeva = 0x096f;
32491 t.ninegujarati = 0x0aef;
32492 t.ninegurmukhi = 0x0a6f;
32493 t.ninehackarabic = 0x0669;
32494 t.ninehangzhou = 0x3029;
32495 t.nineideographicparen = 0x3228;
32496 t.nineinferior = 0x2089;
32497 t.ninemonospace = 0xff19;
32498 t.nineoldstyle = 0xf739;
32499 t.nineparen = 0x247c;
32500 t.nineperiod = 0x2490;
32501 t.ninepersian = 0x06f9;
32502 t.nineroman = 0x2178;
32503 t.ninesuperior = 0x2079;
32504 t.nineteencircle = 0x2472;
32505 t.nineteenparen = 0x2486;
32506 t.nineteenperiod = 0x249a;
32507 t.ninethai = 0x0e59;
32508 t.nj = 0x01cc;
32509 t.njecyrillic = 0x045a;
32510 t.nkatakana = 0x30f3;
32511 t.nkatakanahalfwidth = 0xff9d;
32512 t.nlegrightlong = 0x019e;
32513 t.nlinebelow = 0x1e49;
32514 t.nmonospace = 0xff4e;
32515 t.nmsquare = 0x339a;
32516 t.nnabengali = 0x09a3;
32517 t.nnadeva = 0x0923;
32518 t.nnagujarati = 0x0aa3;
32519 t.nnagurmukhi = 0x0a23;
32520 t.nnnadeva = 0x0929;
32521 t.nohiragana = 0x306e;
32522 t.nokatakana = 0x30ce;
32523 t.nokatakanahalfwidth = 0xff89;
32524 t.nonbreakingspace = 0x00a0;
32525 t.nonenthai = 0x0e13;
32526 t.nonuthai = 0x0e19;
32527 t.noonarabic = 0x0646;
32528 t.noonfinalarabic = 0xfee6;
32529 t.noonghunnaarabic = 0x06ba;
32530 t.noonghunnafinalarabic = 0xfb9f;
32531 t.nooninitialarabic = 0xfee7;
32532 t.noonjeeminitialarabic = 0xfcd2;
32533 t.noonjeemisolatedarabic = 0xfc4b;
32534 t.noonmedialarabic = 0xfee8;
32535 t.noonmeeminitialarabic = 0xfcd5;
32536 t.noonmeemisolatedarabic = 0xfc4e;
32537 t.noonnoonfinalarabic = 0xfc8d;
32538 t.notcontains = 0x220c;
32539 t.notelement = 0x2209;
32540 t.notelementof = 0x2209;
32541 t.notequal = 0x2260;
32542 t.notgreater = 0x226f;
32543 t.notgreaternorequal = 0x2271;
32544 t.notgreaternorless = 0x2279;
32545 t.notidentical = 0x2262;
32546 t.notless = 0x226e;
32547 t.notlessnorequal = 0x2270;
32548 t.notparallel = 0x2226;
32549 t.notprecedes = 0x2280;
32550 t.notsubset = 0x2284;
32551 t.notsucceeds = 0x2281;
32552 t.notsuperset = 0x2285;
32553 t.nowarmenian = 0x0576;
32554 t.nparen = 0x24a9;
32555 t.nssquare = 0x33b1;
32556 t.nsuperior = 0x207f;
32557 t.ntilde = 0x00f1;
32558 t.nu = 0x03bd;
32559 t.nuhiragana = 0x306c;
32560 t.nukatakana = 0x30cc;
32561 t.nukatakanahalfwidth = 0xff87;
32562 t.nuktabengali = 0x09bc;
32563 t.nuktadeva = 0x093c;
32564 t.nuktagujarati = 0x0abc;
32565 t.nuktagurmukhi = 0x0a3c;
32566 t.numbersign = 0x0023;
32567 t.numbersignmonospace = 0xff03;
32568 t.numbersignsmall = 0xfe5f;
32569 t.numeralsigngreek = 0x0374;
32570 t.numeralsignlowergreek = 0x0375;
32571 t.numero = 0x2116;
32572 t.nun = 0x05e0;
32573 t.nundagesh = 0xfb40;
32574 t.nundageshhebrew = 0xfb40;
32575 t.nunhebrew = 0x05e0;
32576 t.nvsquare = 0x33b5;
32577 t.nwsquare = 0x33bb;
32578 t.nyabengali = 0x099e;
32579 t.nyadeva = 0x091e;
32580 t.nyagujarati = 0x0a9e;
32581 t.nyagurmukhi = 0x0a1e;
32582 t.o = 0x006f;
32583 t.oacute = 0x00f3;
32584 t.oangthai = 0x0e2d;
32585 t.obarred = 0x0275;
32586 t.obarredcyrillic = 0x04e9;
32587 t.obarreddieresiscyrillic = 0x04eb;
32588 t.obengali = 0x0993;
32589 t.obopomofo = 0x311b;
32590 t.obreve = 0x014f;
32591 t.ocandradeva = 0x0911;
32592 t.ocandragujarati = 0x0a91;
32593 t.ocandravowelsigndeva = 0x0949;
32594 t.ocandravowelsigngujarati = 0x0ac9;
32595 t.ocaron = 0x01d2;
32596 t.ocircle = 0x24de;
32597 t.ocircumflex = 0x00f4;
32598 t.ocircumflexacute = 0x1ed1;
32599 t.ocircumflexdotbelow = 0x1ed9;
32600 t.ocircumflexgrave = 0x1ed3;
32601 t.ocircumflexhookabove = 0x1ed5;
32602 t.ocircumflextilde = 0x1ed7;
32603 t.ocyrillic = 0x043e;
32604 t.odblacute = 0x0151;
32605 t.odblgrave = 0x020d;
32606 t.odeva = 0x0913;
32607 t.odieresis = 0x00f6;
32608 t.odieresiscyrillic = 0x04e7;
32609 t.odotbelow = 0x1ecd;
32610 t.oe = 0x0153;
32611 t.oekorean = 0x315a;
32612 t.ogonek = 0x02db;
32613 t.ogonekcmb = 0x0328;
32614 t.ograve = 0x00f2;
32615 t.ogujarati = 0x0a93;
32616 t.oharmenian = 0x0585;
32617 t.ohiragana = 0x304a;
32618 t.ohookabove = 0x1ecf;
32619 t.ohorn = 0x01a1;
32620 t.ohornacute = 0x1edb;
32621 t.ohorndotbelow = 0x1ee3;
32622 t.ohorngrave = 0x1edd;
32623 t.ohornhookabove = 0x1edf;
32624 t.ohorntilde = 0x1ee1;
32625 t.ohungarumlaut = 0x0151;
32626 t.oi = 0x01a3;
32627 t.oinvertedbreve = 0x020f;
32628 t.okatakana = 0x30aa;
32629 t.okatakanahalfwidth = 0xff75;
32630 t.okorean = 0x3157;
32631 t.olehebrew = 0x05ab;
32632 t.omacron = 0x014d;
32633 t.omacronacute = 0x1e53;
32634 t.omacrongrave = 0x1e51;
32635 t.omdeva = 0x0950;
32636 t.omega = 0x03c9;
32637 t.omega1 = 0x03d6;
32638 t.omegacyrillic = 0x0461;
32639 t.omegalatinclosed = 0x0277;
32640 t.omegaroundcyrillic = 0x047b;
32641 t.omegatitlocyrillic = 0x047d;
32642 t.omegatonos = 0x03ce;
32643 t.omgujarati = 0x0ad0;
32644 t.omicron = 0x03bf;
32645 t.omicrontonos = 0x03cc;
32646 t.omonospace = 0xff4f;
32647 t.one = 0x0031;
32648 t.onearabic = 0x0661;
32649 t.onebengali = 0x09e7;
32650 t.onecircle = 0x2460;
32651 t.onecircleinversesansserif = 0x278a;
32652 t.onedeva = 0x0967;
32653 t.onedotenleader = 0x2024;
32654 t.oneeighth = 0x215b;
32655 t.onefitted = 0xf6dc;
32656 t.onegujarati = 0x0ae7;
32657 t.onegurmukhi = 0x0a67;
32658 t.onehackarabic = 0x0661;
32659 t.onehalf = 0x00bd;
32660 t.onehangzhou = 0x3021;
32661 t.oneideographicparen = 0x3220;
32662 t.oneinferior = 0x2081;
32663 t.onemonospace = 0xff11;
32664 t.onenumeratorbengali = 0x09f4;
32665 t.oneoldstyle = 0xf731;
32666 t.oneparen = 0x2474;
32667 t.oneperiod = 0x2488;
32668 t.onepersian = 0x06f1;
32669 t.onequarter = 0x00bc;
32670 t.oneroman = 0x2170;
32671 t.onesuperior = 0x00b9;
32672 t.onethai = 0x0e51;
32673 t.onethird = 0x2153;
32674 t.oogonek = 0x01eb;
32675 t.oogonekmacron = 0x01ed;
32676 t.oogurmukhi = 0x0a13;
32677 t.oomatragurmukhi = 0x0a4b;
32678 t.oopen = 0x0254;
32679 t.oparen = 0x24aa;
32680 t.openbullet = 0x25e6;
32681 t.option = 0x2325;
32682 t.ordfeminine = 0x00aa;
32683 t.ordmasculine = 0x00ba;
32684 t.orthogonal = 0x221f;
32685 t.oshortdeva = 0x0912;
32686 t.oshortvowelsigndeva = 0x094a;
32687 t.oslash = 0x00f8;
32688 t.oslashacute = 0x01ff;
32689 t.osmallhiragana = 0x3049;
32690 t.osmallkatakana = 0x30a9;
32691 t.osmallkatakanahalfwidth = 0xff6b;
32692 t.ostrokeacute = 0x01ff;
32693 t.osuperior = 0xf6f0;
32694 t.otcyrillic = 0x047f;
32695 t.otilde = 0x00f5;
32696 t.otildeacute = 0x1e4d;
32697 t.otildedieresis = 0x1e4f;
32698 t.oubopomofo = 0x3121;
32699 t.overline = 0x203e;
32700 t.overlinecenterline = 0xfe4a;
32701 t.overlinecmb = 0x0305;
32702 t.overlinedashed = 0xfe49;
32703 t.overlinedblwavy = 0xfe4c;
32704 t.overlinewavy = 0xfe4b;
32705 t.overscore = 0x00af;
32706 t.ovowelsignbengali = 0x09cb;
32707 t.ovowelsigndeva = 0x094b;
32708 t.ovowelsigngujarati = 0x0acb;
32709 t.p = 0x0070;
32710 t.paampssquare = 0x3380;
32711 t.paasentosquare = 0x332b;
32712 t.pabengali = 0x09aa;
32713 t.pacute = 0x1e55;
32714 t.padeva = 0x092a;
32715 t.pagedown = 0x21df;
32716 t.pageup = 0x21de;
32717 t.pagujarati = 0x0aaa;
32718 t.pagurmukhi = 0x0a2a;
32719 t.pahiragana = 0x3071;
32720 t.paiyannoithai = 0x0e2f;
32721 t.pakatakana = 0x30d1;
32722 t.palatalizationcyrilliccmb = 0x0484;
32723 t.palochkacyrillic = 0x04c0;
32724 t.pansioskorean = 0x317f;
32725 t.paragraph = 0x00b6;
32726 t.parallel = 0x2225;
32727 t.parenleft = 0x0028;
32728 t.parenleftaltonearabic = 0xfd3e;
32729 t.parenleftbt = 0xf8ed;
32730 t.parenleftex = 0xf8ec;
32731 t.parenleftinferior = 0x208d;
32732 t.parenleftmonospace = 0xff08;
32733 t.parenleftsmall = 0xfe59;
32734 t.parenleftsuperior = 0x207d;
32735 t.parenlefttp = 0xf8eb;
32736 t.parenleftvertical = 0xfe35;
32737 t.parenright = 0x0029;
32738 t.parenrightaltonearabic = 0xfd3f;
32739 t.parenrightbt = 0xf8f8;
32740 t.parenrightex = 0xf8f7;
32741 t.parenrightinferior = 0x208e;
32742 t.parenrightmonospace = 0xff09;
32743 t.parenrightsmall = 0xfe5a;
32744 t.parenrightsuperior = 0x207e;
32745 t.parenrighttp = 0xf8f6;
32746 t.parenrightvertical = 0xfe36;
32747 t.partialdiff = 0x2202;
32748 t.paseqhebrew = 0x05c0;
32749 t.pashtahebrew = 0x0599;
32750 t.pasquare = 0x33a9;
32751 t.patah = 0x05b7;
32752 t.patah11 = 0x05b7;
32753 t.patah1d = 0x05b7;
32754 t.patah2a = 0x05b7;
32755 t.patahhebrew = 0x05b7;
32756 t.patahnarrowhebrew = 0x05b7;
32757 t.patahquarterhebrew = 0x05b7;
32758 t.patahwidehebrew = 0x05b7;
32759 t.pazerhebrew = 0x05a1;
32760 t.pbopomofo = 0x3106;
32761 t.pcircle = 0x24df;
32762 t.pdotaccent = 0x1e57;
32763 t.pe = 0x05e4;
32764 t.pecyrillic = 0x043f;
32765 t.pedagesh = 0xfb44;
32766 t.pedageshhebrew = 0xfb44;
32767 t.peezisquare = 0x333b;
32768 t.pefinaldageshhebrew = 0xfb43;
32769 t.peharabic = 0x067e;
32770 t.peharmenian = 0x057a;
32771 t.pehebrew = 0x05e4;
32772 t.pehfinalarabic = 0xfb57;
32773 t.pehinitialarabic = 0xfb58;
32774 t.pehiragana = 0x307a;
32775 t.pehmedialarabic = 0xfb59;
32776 t.pekatakana = 0x30da;
32777 t.pemiddlehookcyrillic = 0x04a7;
32778 t.perafehebrew = 0xfb4e;
32779 t.percent = 0x0025;
32780 t.percentarabic = 0x066a;
32781 t.percentmonospace = 0xff05;
32782 t.percentsmall = 0xfe6a;
32783 t.period = 0x002e;
32784 t.periodarmenian = 0x0589;
32785 t.periodcentered = 0x00b7;
32786 t.periodhalfwidth = 0xff61;
32787 t.periodinferior = 0xf6e7;
32788 t.periodmonospace = 0xff0e;
32789 t.periodsmall = 0xfe52;
32790 t.periodsuperior = 0xf6e8;
32791 t.perispomenigreekcmb = 0x0342;
32792 t.perpendicular = 0x22a5;
32793 t.perthousand = 0x2030;
32794 t.peseta = 0x20a7;
32795 t.pfsquare = 0x338a;
32796 t.phabengali = 0x09ab;
32797 t.phadeva = 0x092b;
32798 t.phagujarati = 0x0aab;
32799 t.phagurmukhi = 0x0a2b;
32800 t.phi = 0x03c6;
32801 t.phi1 = 0x03d5;
32802 t.phieuphacirclekorean = 0x327a;
32803 t.phieuphaparenkorean = 0x321a;
32804 t.phieuphcirclekorean = 0x326c;
32805 t.phieuphkorean = 0x314d;
32806 t.phieuphparenkorean = 0x320c;
32807 t.philatin = 0x0278;
32808 t.phinthuthai = 0x0e3a;
32809 t.phisymbolgreek = 0x03d5;
32810 t.phook = 0x01a5;
32811 t.phophanthai = 0x0e1e;
32812 t.phophungthai = 0x0e1c;
32813 t.phosamphaothai = 0x0e20;
32814 t.pi = 0x03c0;
32815 t.pieupacirclekorean = 0x3273;
32816 t.pieupaparenkorean = 0x3213;
32817 t.pieupcieuckorean = 0x3176;
32818 t.pieupcirclekorean = 0x3265;
32819 t.pieupkiyeokkorean = 0x3172;
32820 t.pieupkorean = 0x3142;
32821 t.pieupparenkorean = 0x3205;
32822 t.pieupsioskiyeokkorean = 0x3174;
32823 t.pieupsioskorean = 0x3144;
32824 t.pieupsiostikeutkorean = 0x3175;
32825 t.pieupthieuthkorean = 0x3177;
32826 t.pieuptikeutkorean = 0x3173;
32827 t.pihiragana = 0x3074;
32828 t.pikatakana = 0x30d4;
32829 t.pisymbolgreek = 0x03d6;
32830 t.piwrarmenian = 0x0583;
32831 t.plus = 0x002b;
32832 t.plusbelowcmb = 0x031f;
32833 t.pluscircle = 0x2295;
32834 t.plusminus = 0x00b1;
32835 t.plusmod = 0x02d6;
32836 t.plusmonospace = 0xff0b;
32837 t.plussmall = 0xfe62;
32838 t.plussuperior = 0x207a;
32839 t.pmonospace = 0xff50;
32840 t.pmsquare = 0x33d8;
32841 t.pohiragana = 0x307d;
32842 t.pointingindexdownwhite = 0x261f;
32843 t.pointingindexleftwhite = 0x261c;
32844 t.pointingindexrightwhite = 0x261e;
32845 t.pointingindexupwhite = 0x261d;
32846 t.pokatakana = 0x30dd;
32847 t.poplathai = 0x0e1b;
32848 t.postalmark = 0x3012;
32849 t.postalmarkface = 0x3020;
32850 t.pparen = 0x24ab;
32851 t.precedes = 0x227a;
32852 t.prescription = 0x211e;
32853 t.primemod = 0x02b9;
32854 t.primereversed = 0x2035;
32855 t.product = 0x220f;
32856 t.projective = 0x2305;
32857 t.prolongedkana = 0x30fc;
32858 t.propellor = 0x2318;
32859 t.propersubset = 0x2282;
32860 t.propersuperset = 0x2283;
32861 t.proportion = 0x2237;
32862 t.proportional = 0x221d;
32863 t.psi = 0x03c8;
32864 t.psicyrillic = 0x0471;
32865 t.psilipneumatacyrilliccmb = 0x0486;
32866 t.pssquare = 0x33b0;
32867 t.puhiragana = 0x3077;
32868 t.pukatakana = 0x30d7;
32869 t.pvsquare = 0x33b4;
32870 t.pwsquare = 0x33ba;
32871 t.q = 0x0071;
32872 t.qadeva = 0x0958;
32873 t.qadmahebrew = 0x05a8;
32874 t.qafarabic = 0x0642;
32875 t.qaffinalarabic = 0xfed6;
32876 t.qafinitialarabic = 0xfed7;
32877 t.qafmedialarabic = 0xfed8;
32878 t.qamats = 0x05b8;
32879 t.qamats10 = 0x05b8;
32880 t.qamats1a = 0x05b8;
32881 t.qamats1c = 0x05b8;
32882 t.qamats27 = 0x05b8;
32883 t.qamats29 = 0x05b8;
32884 t.qamats33 = 0x05b8;
32885 t.qamatsde = 0x05b8;
32886 t.qamatshebrew = 0x05b8;
32887 t.qamatsnarrowhebrew = 0x05b8;
32888 t.qamatsqatanhebrew = 0x05b8;
32889 t.qamatsqatannarrowhebrew = 0x05b8;
32890 t.qamatsqatanquarterhebrew = 0x05b8;
32891 t.qamatsqatanwidehebrew = 0x05b8;
32892 t.qamatsquarterhebrew = 0x05b8;
32893 t.qamatswidehebrew = 0x05b8;
32894 t.qarneyparahebrew = 0x059f;
32895 t.qbopomofo = 0x3111;
32896 t.qcircle = 0x24e0;
32897 t.qhook = 0x02a0;
32898 t.qmonospace = 0xff51;
32899 t.qof = 0x05e7;
32900 t.qofdagesh = 0xfb47;
32901 t.qofdageshhebrew = 0xfb47;
32902 t.qofhebrew = 0x05e7;
32903 t.qparen = 0x24ac;
32904 t.quarternote = 0x2669;
32905 t.qubuts = 0x05bb;
32906 t.qubuts18 = 0x05bb;
32907 t.qubuts25 = 0x05bb;
32908 t.qubuts31 = 0x05bb;
32909 t.qubutshebrew = 0x05bb;
32910 t.qubutsnarrowhebrew = 0x05bb;
32911 t.qubutsquarterhebrew = 0x05bb;
32912 t.qubutswidehebrew = 0x05bb;
32913 t.question = 0x003f;
32914 t.questionarabic = 0x061f;
32915 t.questionarmenian = 0x055e;
32916 t.questiondown = 0x00bf;
32917 t.questiondownsmall = 0xf7bf;
32918 t.questiongreek = 0x037e;
32919 t.questionmonospace = 0xff1f;
32920 t.questionsmall = 0xf73f;
32921 t.quotedbl = 0x0022;
32922 t.quotedblbase = 0x201e;
32923 t.quotedblleft = 0x201c;
32924 t.quotedblmonospace = 0xff02;
32925 t.quotedblprime = 0x301e;
32926 t.quotedblprimereversed = 0x301d;
32927 t.quotedblright = 0x201d;
32928 t.quoteleft = 0x2018;
32929 t.quoteleftreversed = 0x201b;
32930 t.quotereversed = 0x201b;
32931 t.quoteright = 0x2019;
32932 t.quoterightn = 0x0149;
32933 t.quotesinglbase = 0x201a;
32934 t.quotesingle = 0x0027;
32935 t.quotesinglemonospace = 0xff07;
32936 t.r = 0x0072;
32937 t.raarmenian = 0x057c;
32938 t.rabengali = 0x09b0;
32939 t.racute = 0x0155;
32940 t.radeva = 0x0930;
32941 t.radical = 0x221a;
32942 t.radicalex = 0xf8e5;
32943 t.radoverssquare = 0x33ae;
32944 t.radoverssquaredsquare = 0x33af;
32945 t.radsquare = 0x33ad;
32946 t.rafe = 0x05bf;
32947 t.rafehebrew = 0x05bf;
32948 t.ragujarati = 0x0ab0;
32949 t.ragurmukhi = 0x0a30;
32950 t.rahiragana = 0x3089;
32951 t.rakatakana = 0x30e9;
32952 t.rakatakanahalfwidth = 0xff97;
32953 t.ralowerdiagonalbengali = 0x09f1;
32954 t.ramiddlediagonalbengali = 0x09f0;
32955 t.ramshorn = 0x0264;
32956 t.ratio = 0x2236;
32957 t.rbopomofo = 0x3116;
32958 t.rcaron = 0x0159;
32959 t.rcedilla = 0x0157;
32960 t.rcircle = 0x24e1;
32961 t.rcommaaccent = 0x0157;
32962 t.rdblgrave = 0x0211;
32963 t.rdotaccent = 0x1e59;
32964 t.rdotbelow = 0x1e5b;
32965 t.rdotbelowmacron = 0x1e5d;
32966 t.referencemark = 0x203b;
32967 t.reflexsubset = 0x2286;
32968 t.reflexsuperset = 0x2287;
32969 t.registered = 0x00ae;
32970 t.registersans = 0xf8e8;
32971 t.registerserif = 0xf6da;
32972 t.reharabic = 0x0631;
32973 t.reharmenian = 0x0580;
32974 t.rehfinalarabic = 0xfeae;
32975 t.rehiragana = 0x308c;
32976 t.rekatakana = 0x30ec;
32977 t.rekatakanahalfwidth = 0xff9a;
32978 t.resh = 0x05e8;
32979 t.reshdageshhebrew = 0xfb48;
32980 t.reshhebrew = 0x05e8;
32981 t.reversedtilde = 0x223d;
32982 t.reviahebrew = 0x0597;
32983 t.reviamugrashhebrew = 0x0597;
32984 t.revlogicalnot = 0x2310;
32985 t.rfishhook = 0x027e;
32986 t.rfishhookreversed = 0x027f;
32987 t.rhabengali = 0x09dd;
32988 t.rhadeva = 0x095d;
32989 t.rho = 0x03c1;
32990 t.rhook = 0x027d;
32991 t.rhookturned = 0x027b;
32992 t.rhookturnedsuperior = 0x02b5;
32993 t.rhosymbolgreek = 0x03f1;
32994 t.rhotichookmod = 0x02de;
32995 t.rieulacirclekorean = 0x3271;
32996 t.rieulaparenkorean = 0x3211;
32997 t.rieulcirclekorean = 0x3263;
32998 t.rieulhieuhkorean = 0x3140;
32999 t.rieulkiyeokkorean = 0x313a;
33000 t.rieulkiyeoksioskorean = 0x3169;
33001 t.rieulkorean = 0x3139;
33002 t.rieulmieumkorean = 0x313b;
33003 t.rieulpansioskorean = 0x316c;
33004 t.rieulparenkorean = 0x3203;
33005 t.rieulphieuphkorean = 0x313f;
33006 t.rieulpieupkorean = 0x313c;
33007 t.rieulpieupsioskorean = 0x316b;
33008 t.rieulsioskorean = 0x313d;
33009 t.rieulthieuthkorean = 0x313e;
33010 t.rieultikeutkorean = 0x316a;
33011 t.rieulyeorinhieuhkorean = 0x316d;
33012 t.rightangle = 0x221f;
33013 t.righttackbelowcmb = 0x0319;
33014 t.righttriangle = 0x22bf;
33015 t.rihiragana = 0x308a;
33016 t.rikatakana = 0x30ea;
33017 t.rikatakanahalfwidth = 0xff98;
33018 t.ring = 0x02da;
33019 t.ringbelowcmb = 0x0325;
33020 t.ringcmb = 0x030a;
33021 t.ringhalfleft = 0x02bf;
33022 t.ringhalfleftarmenian = 0x0559;
33023 t.ringhalfleftbelowcmb = 0x031c;
33024 t.ringhalfleftcentered = 0x02d3;
33025 t.ringhalfright = 0x02be;
33026 t.ringhalfrightbelowcmb = 0x0339;
33027 t.ringhalfrightcentered = 0x02d2;
33028 t.rinvertedbreve = 0x0213;
33029 t.rittorusquare = 0x3351;
33030 t.rlinebelow = 0x1e5f;
33031 t.rlongleg = 0x027c;
33032 t.rlonglegturned = 0x027a;
33033 t.rmonospace = 0xff52;
33034 t.rohiragana = 0x308d;
33035 t.rokatakana = 0x30ed;
33036 t.rokatakanahalfwidth = 0xff9b;
33037 t.roruathai = 0x0e23;
33038 t.rparen = 0x24ad;
33039 t.rrabengali = 0x09dc;
33040 t.rradeva = 0x0931;
33041 t.rragurmukhi = 0x0a5c;
33042 t.rreharabic = 0x0691;
33043 t.rrehfinalarabic = 0xfb8d;
33044 t.rrvocalicbengali = 0x09e0;
33045 t.rrvocalicdeva = 0x0960;
33046 t.rrvocalicgujarati = 0x0ae0;
33047 t.rrvocalicvowelsignbengali = 0x09c4;
33048 t.rrvocalicvowelsigndeva = 0x0944;
33049 t.rrvocalicvowelsigngujarati = 0x0ac4;
33050 t.rsuperior = 0xf6f1;
33051 t.rtblock = 0x2590;
33052 t.rturned = 0x0279;
33053 t.rturnedsuperior = 0x02b4;
33054 t.ruhiragana = 0x308b;
33055 t.rukatakana = 0x30eb;
33056 t.rukatakanahalfwidth = 0xff99;
33057 t.rupeemarkbengali = 0x09f2;
33058 t.rupeesignbengali = 0x09f3;
33059 t.rupiah = 0xf6dd;
33060 t.ruthai = 0x0e24;
33061 t.rvocalicbengali = 0x098b;
33062 t.rvocalicdeva = 0x090b;
33063 t.rvocalicgujarati = 0x0a8b;
33064 t.rvocalicvowelsignbengali = 0x09c3;
33065 t.rvocalicvowelsigndeva = 0x0943;
33066 t.rvocalicvowelsigngujarati = 0x0ac3;
33067 t.s = 0x0073;
33068 t.sabengali = 0x09b8;
33069 t.sacute = 0x015b;
33070 t.sacutedotaccent = 0x1e65;
33071 t.sadarabic = 0x0635;
33072 t.sadeva = 0x0938;
33073 t.sadfinalarabic = 0xfeba;
33074 t.sadinitialarabic = 0xfebb;
33075 t.sadmedialarabic = 0xfebc;
33076 t.sagujarati = 0x0ab8;
33077 t.sagurmukhi = 0x0a38;
33078 t.sahiragana = 0x3055;
33079 t.sakatakana = 0x30b5;
33080 t.sakatakanahalfwidth = 0xff7b;
33081 t.sallallahoualayhewasallamarabic = 0xfdfa;
33082 t.samekh = 0x05e1;
33083 t.samekhdagesh = 0xfb41;
33084 t.samekhdageshhebrew = 0xfb41;
33085 t.samekhhebrew = 0x05e1;
33086 t.saraaathai = 0x0e32;
33087 t.saraaethai = 0x0e41;
33088 t.saraaimaimalaithai = 0x0e44;
33089 t.saraaimaimuanthai = 0x0e43;
33090 t.saraamthai = 0x0e33;
33091 t.saraathai = 0x0e30;
33092 t.saraethai = 0x0e40;
33093 t.saraiileftthai = 0xf886;
33094 t.saraiithai = 0x0e35;
33095 t.saraileftthai = 0xf885;
33096 t.saraithai = 0x0e34;
33097 t.saraothai = 0x0e42;
33098 t.saraueeleftthai = 0xf888;
33099 t.saraueethai = 0x0e37;
33100 t.saraueleftthai = 0xf887;
33101 t.sarauethai = 0x0e36;
33102 t.sarauthai = 0x0e38;
33103 t.sarauuthai = 0x0e39;
33104 t.sbopomofo = 0x3119;
33105 t.scaron = 0x0161;
33106 t.scarondotaccent = 0x1e67;
33107 t.scedilla = 0x015f;
33108 t.schwa = 0x0259;
33109 t.schwacyrillic = 0x04d9;
33110 t.schwadieresiscyrillic = 0x04db;
33111 t.schwahook = 0x025a;
33112 t.scircle = 0x24e2;
33113 t.scircumflex = 0x015d;
33114 t.scommaaccent = 0x0219;
33115 t.sdotaccent = 0x1e61;
33116 t.sdotbelow = 0x1e63;
33117 t.sdotbelowdotaccent = 0x1e69;
33118 t.seagullbelowcmb = 0x033c;
33119 t.second = 0x2033;
33120 t.secondtonechinese = 0x02ca;
33121 t.section = 0x00a7;
33122 t.seenarabic = 0x0633;
33123 t.seenfinalarabic = 0xfeb2;
33124 t.seeninitialarabic = 0xfeb3;
33125 t.seenmedialarabic = 0xfeb4;
33126 t.segol = 0x05b6;
33127 t.segol13 = 0x05b6;
33128 t.segol1f = 0x05b6;
33129 t.segol2c = 0x05b6;
33130 t.segolhebrew = 0x05b6;
33131 t.segolnarrowhebrew = 0x05b6;
33132 t.segolquarterhebrew = 0x05b6;
33133 t.segoltahebrew = 0x0592;
33134 t.segolwidehebrew = 0x05b6;
33135 t.seharmenian = 0x057d;
33136 t.sehiragana = 0x305b;
33137 t.sekatakana = 0x30bb;
33138 t.sekatakanahalfwidth = 0xff7e;
33139 t.semicolon = 0x003b;
33140 t.semicolonarabic = 0x061b;
33141 t.semicolonmonospace = 0xff1b;
33142 t.semicolonsmall = 0xfe54;
33143 t.semivoicedmarkkana = 0x309c;
33144 t.semivoicedmarkkanahalfwidth = 0xff9f;
33145 t.sentisquare = 0x3322;
33146 t.sentosquare = 0x3323;
33147 t.seven = 0x0037;
33148 t.sevenarabic = 0x0667;
33149 t.sevenbengali = 0x09ed;
33150 t.sevencircle = 0x2466;
33151 t.sevencircleinversesansserif = 0x2790;
33152 t.sevendeva = 0x096d;
33153 t.seveneighths = 0x215e;
33154 t.sevengujarati = 0x0aed;
33155 t.sevengurmukhi = 0x0a6d;
33156 t.sevenhackarabic = 0x0667;
33157 t.sevenhangzhou = 0x3027;
33158 t.sevenideographicparen = 0x3226;
33159 t.seveninferior = 0x2087;
33160 t.sevenmonospace = 0xff17;
33161 t.sevenoldstyle = 0xf737;
33162 t.sevenparen = 0x247a;
33163 t.sevenperiod = 0x248e;
33164 t.sevenpersian = 0x06f7;
33165 t.sevenroman = 0x2176;
33166 t.sevensuperior = 0x2077;
33167 t.seventeencircle = 0x2470;
33168 t.seventeenparen = 0x2484;
33169 t.seventeenperiod = 0x2498;
33170 t.seventhai = 0x0e57;
33171 t.sfthyphen = 0x00ad;
33172 t.shaarmenian = 0x0577;
33173 t.shabengali = 0x09b6;
33174 t.shacyrillic = 0x0448;
33175 t.shaddaarabic = 0x0651;
33176 t.shaddadammaarabic = 0xfc61;
33177 t.shaddadammatanarabic = 0xfc5e;
33178 t.shaddafathaarabic = 0xfc60;
33179 t.shaddakasraarabic = 0xfc62;
33180 t.shaddakasratanarabic = 0xfc5f;
33181 t.shade = 0x2592;
33182 t.shadedark = 0x2593;
33183 t.shadelight = 0x2591;
33184 t.shademedium = 0x2592;
33185 t.shadeva = 0x0936;
33186 t.shagujarati = 0x0ab6;
33187 t.shagurmukhi = 0x0a36;
33188 t.shalshelethebrew = 0x0593;
33189 t.shbopomofo = 0x3115;
33190 t.shchacyrillic = 0x0449;
33191 t.sheenarabic = 0x0634;
33192 t.sheenfinalarabic = 0xfeb6;
33193 t.sheeninitialarabic = 0xfeb7;
33194 t.sheenmedialarabic = 0xfeb8;
33195 t.sheicoptic = 0x03e3;
33196 t.sheqel = 0x20aa;
33197 t.sheqelhebrew = 0x20aa;
33198 t.sheva = 0x05b0;
33199 t.sheva115 = 0x05b0;
33200 t.sheva15 = 0x05b0;
33201 t.sheva22 = 0x05b0;
33202 t.sheva2e = 0x05b0;
33203 t.shevahebrew = 0x05b0;
33204 t.shevanarrowhebrew = 0x05b0;
33205 t.shevaquarterhebrew = 0x05b0;
33206 t.shevawidehebrew = 0x05b0;
33207 t.shhacyrillic = 0x04bb;
33208 t.shimacoptic = 0x03ed;
33209 t.shin = 0x05e9;
33210 t.shindagesh = 0xfb49;
33211 t.shindageshhebrew = 0xfb49;
33212 t.shindageshshindot = 0xfb2c;
33213 t.shindageshshindothebrew = 0xfb2c;
33214 t.shindageshsindot = 0xfb2d;
33215 t.shindageshsindothebrew = 0xfb2d;
33216 t.shindothebrew = 0x05c1;
33217 t.shinhebrew = 0x05e9;
33218 t.shinshindot = 0xfb2a;
33219 t.shinshindothebrew = 0xfb2a;
33220 t.shinsindot = 0xfb2b;
33221 t.shinsindothebrew = 0xfb2b;
33222 t.shook = 0x0282;
33223 t.sigma = 0x03c3;
33224 t.sigma1 = 0x03c2;
33225 t.sigmafinal = 0x03c2;
33226 t.sigmalunatesymbolgreek = 0x03f2;
33227 t.sihiragana = 0x3057;
33228 t.sikatakana = 0x30b7;
33229 t.sikatakanahalfwidth = 0xff7c;
33230 t.siluqhebrew = 0x05bd;
33231 t.siluqlefthebrew = 0x05bd;
33232 t.similar = 0x223c;
33233 t.sindothebrew = 0x05c2;
33234 t.siosacirclekorean = 0x3274;
33235 t.siosaparenkorean = 0x3214;
33236 t.sioscieuckorean = 0x317e;
33237 t.sioscirclekorean = 0x3266;
33238 t.sioskiyeokkorean = 0x317a;
33239 t.sioskorean = 0x3145;
33240 t.siosnieunkorean = 0x317b;
33241 t.siosparenkorean = 0x3206;
33242 t.siospieupkorean = 0x317d;
33243 t.siostikeutkorean = 0x317c;
33244 t.six = 0x0036;
33245 t.sixarabic = 0x0666;
33246 t.sixbengali = 0x09ec;
33247 t.sixcircle = 0x2465;
33248 t.sixcircleinversesansserif = 0x278f;
33249 t.sixdeva = 0x096c;
33250 t.sixgujarati = 0x0aec;
33251 t.sixgurmukhi = 0x0a6c;
33252 t.sixhackarabic = 0x0666;
33253 t.sixhangzhou = 0x3026;
33254 t.sixideographicparen = 0x3225;
33255 t.sixinferior = 0x2086;
33256 t.sixmonospace = 0xff16;
33257 t.sixoldstyle = 0xf736;
33258 t.sixparen = 0x2479;
33259 t.sixperiod = 0x248d;
33260 t.sixpersian = 0x06f6;
33261 t.sixroman = 0x2175;
33262 t.sixsuperior = 0x2076;
33263 t.sixteencircle = 0x246f;
33264 t.sixteencurrencydenominatorbengali = 0x09f9;
33265 t.sixteenparen = 0x2483;
33266 t.sixteenperiod = 0x2497;
33267 t.sixthai = 0x0e56;
33268 t.slash = 0x002f;
33269 t.slashmonospace = 0xff0f;
33270 t.slong = 0x017f;
33271 t.slongdotaccent = 0x1e9b;
33272 t.smileface = 0x263a;
33273 t.smonospace = 0xff53;
33274 t.sofpasuqhebrew = 0x05c3;
33275 t.softhyphen = 0x00ad;
33276 t.softsigncyrillic = 0x044c;
33277 t.sohiragana = 0x305d;
33278 t.sokatakana = 0x30bd;
33279 t.sokatakanahalfwidth = 0xff7f;
33280 t.soliduslongoverlaycmb = 0x0338;
33281 t.solidusshortoverlaycmb = 0x0337;
33282 t.sorusithai = 0x0e29;
33283 t.sosalathai = 0x0e28;
33284 t.sosothai = 0x0e0b;
33285 t.sosuathai = 0x0e2a;
33286 t.space = 0x0020;
33287 t.spacehackarabic = 0x0020;
33288 t.spade = 0x2660;
33289 t.spadesuitblack = 0x2660;
33290 t.spadesuitwhite = 0x2664;
33291 t.sparen = 0x24ae;
33292 t.squarebelowcmb = 0x033b;
33293 t.squarecc = 0x33c4;
33294 t.squarecm = 0x339d;
33295 t.squarediagonalcrosshatchfill = 0x25a9;
33296 t.squarehorizontalfill = 0x25a4;
33297 t.squarekg = 0x338f;
33298 t.squarekm = 0x339e;
33299 t.squarekmcapital = 0x33ce;
33300 t.squareln = 0x33d1;
33301 t.squarelog = 0x33d2;
33302 t.squaremg = 0x338e;
33303 t.squaremil = 0x33d5;
33304 t.squaremm = 0x339c;
33305 t.squaremsquared = 0x33a1;
33306 t.squareorthogonalcrosshatchfill = 0x25a6;
33307 t.squareupperlefttolowerrightfill = 0x25a7;
33308 t.squareupperrighttolowerleftfill = 0x25a8;
33309 t.squareverticalfill = 0x25a5;
33310 t.squarewhitewithsmallblack = 0x25a3;
33311 t.srsquare = 0x33db;
33312 t.ssabengali = 0x09b7;
33313 t.ssadeva = 0x0937;
33314 t.ssagujarati = 0x0ab7;
33315 t.ssangcieuckorean = 0x3149;
33316 t.ssanghieuhkorean = 0x3185;
33317 t.ssangieungkorean = 0x3180;
33318 t.ssangkiyeokkorean = 0x3132;
33319 t.ssangnieunkorean = 0x3165;
33320 t.ssangpieupkorean = 0x3143;
33321 t.ssangsioskorean = 0x3146;
33322 t.ssangtikeutkorean = 0x3138;
33323 t.ssuperior = 0xf6f2;
33324 t.sterling = 0x00a3;
33325 t.sterlingmonospace = 0xffe1;
33326 t.strokelongoverlaycmb = 0x0336;
33327 t.strokeshortoverlaycmb = 0x0335;
33328 t.subset = 0x2282;
33329 t.subsetnotequal = 0x228a;
33330 t.subsetorequal = 0x2286;
33331 t.succeeds = 0x227b;
33332 t.suchthat = 0x220b;
33333 t.suhiragana = 0x3059;
33334 t.sukatakana = 0x30b9;
33335 t.sukatakanahalfwidth = 0xff7d;
33336 t.sukunarabic = 0x0652;
33337 t.summation = 0x2211;
33338 t.sun = 0x263c;
33339 t.superset = 0x2283;
33340 t.supersetnotequal = 0x228b;
33341 t.supersetorequal = 0x2287;
33342 t.svsquare = 0x33dc;
33343 t.syouwaerasquare = 0x337c;
33344 t.t = 0x0074;
33345 t.tabengali = 0x09a4;
33346 t.tackdown = 0x22a4;
33347 t.tackleft = 0x22a3;
33348 t.tadeva = 0x0924;
33349 t.tagujarati = 0x0aa4;
33350 t.tagurmukhi = 0x0a24;
33351 t.taharabic = 0x0637;
33352 t.tahfinalarabic = 0xfec2;
33353 t.tahinitialarabic = 0xfec3;
33354 t.tahiragana = 0x305f;
33355 t.tahmedialarabic = 0xfec4;
33356 t.taisyouerasquare = 0x337d;
33357 t.takatakana = 0x30bf;
33358 t.takatakanahalfwidth = 0xff80;
33359 t.tatweelarabic = 0x0640;
33360 t.tau = 0x03c4;
33361 t.tav = 0x05ea;
33362 t.tavdages = 0xfb4a;
33363 t.tavdagesh = 0xfb4a;
33364 t.tavdageshhebrew = 0xfb4a;
33365 t.tavhebrew = 0x05ea;
33366 t.tbar = 0x0167;
33367 t.tbopomofo = 0x310a;
33368 t.tcaron = 0x0165;
33369 t.tccurl = 0x02a8;
33370 t.tcedilla = 0x0163;
33371 t.tcheharabic = 0x0686;
33372 t.tchehfinalarabic = 0xfb7b;
33373 t.tchehinitialarabic = 0xfb7c;
33374 t.tchehmedialarabic = 0xfb7d;
33375 t.tcircle = 0x24e3;
33376 t.tcircumflexbelow = 0x1e71;
33377 t.tcommaaccent = 0x0163;
33378 t.tdieresis = 0x1e97;
33379 t.tdotaccent = 0x1e6b;
33380 t.tdotbelow = 0x1e6d;
33381 t.tecyrillic = 0x0442;
33382 t.tedescendercyrillic = 0x04ad;
33383 t.teharabic = 0x062a;
33384 t.tehfinalarabic = 0xfe96;
33385 t.tehhahinitialarabic = 0xfca2;
33386 t.tehhahisolatedarabic = 0xfc0c;
33387 t.tehinitialarabic = 0xfe97;
33388 t.tehiragana = 0x3066;
33389 t.tehjeeminitialarabic = 0xfca1;
33390 t.tehjeemisolatedarabic = 0xfc0b;
33391 t.tehmarbutaarabic = 0x0629;
33392 t.tehmarbutafinalarabic = 0xfe94;
33393 t.tehmedialarabic = 0xfe98;
33394 t.tehmeeminitialarabic = 0xfca4;
33395 t.tehmeemisolatedarabic = 0xfc0e;
33396 t.tehnoonfinalarabic = 0xfc73;
33397 t.tekatakana = 0x30c6;
33398 t.tekatakanahalfwidth = 0xff83;
33399 t.telephone = 0x2121;
33400 t.telephoneblack = 0x260e;
33401 t.telishagedolahebrew = 0x05a0;
33402 t.telishaqetanahebrew = 0x05a9;
33403 t.tencircle = 0x2469;
33404 t.tenideographicparen = 0x3229;
33405 t.tenparen = 0x247d;
33406 t.tenperiod = 0x2491;
33407 t.tenroman = 0x2179;
33408 t.tesh = 0x02a7;
33409 t.tet = 0x05d8;
33410 t.tetdagesh = 0xfb38;
33411 t.tetdageshhebrew = 0xfb38;
33412 t.tethebrew = 0x05d8;
33413 t.tetsecyrillic = 0x04b5;
33414 t.tevirhebrew = 0x059b;
33415 t.tevirlefthebrew = 0x059b;
33416 t.thabengali = 0x09a5;
33417 t.thadeva = 0x0925;
33418 t.thagujarati = 0x0aa5;
33419 t.thagurmukhi = 0x0a25;
33420 t.thalarabic = 0x0630;
33421 t.thalfinalarabic = 0xfeac;
33422 t.thanthakhatlowleftthai = 0xf898;
33423 t.thanthakhatlowrightthai = 0xf897;
33424 t.thanthakhatthai = 0x0e4c;
33425 t.thanthakhatupperleftthai = 0xf896;
33426 t.theharabic = 0x062b;
33427 t.thehfinalarabic = 0xfe9a;
33428 t.thehinitialarabic = 0xfe9b;
33429 t.thehmedialarabic = 0xfe9c;
33430 t.thereexists = 0x2203;
33431 t.therefore = 0x2234;
33432 t.theta = 0x03b8;
33433 t.theta1 = 0x03d1;
33434 t.thetasymbolgreek = 0x03d1;
33435 t.thieuthacirclekorean = 0x3279;
33436 t.thieuthaparenkorean = 0x3219;
33437 t.thieuthcirclekorean = 0x326b;
33438 t.thieuthkorean = 0x314c;
33439 t.thieuthparenkorean = 0x320b;
33440 t.thirteencircle = 0x246c;
33441 t.thirteenparen = 0x2480;
33442 t.thirteenperiod = 0x2494;
33443 t.thonangmonthothai = 0x0e11;
33444 t.thook = 0x01ad;
33445 t.thophuthaothai = 0x0e12;
33446 t.thorn = 0x00fe;
33447 t.thothahanthai = 0x0e17;
33448 t.thothanthai = 0x0e10;
33449 t.thothongthai = 0x0e18;
33450 t.thothungthai = 0x0e16;
33451 t.thousandcyrillic = 0x0482;
33452 t.thousandsseparatorarabic = 0x066c;
33453 t.thousandsseparatorpersian = 0x066c;
33454 t.three = 0x0033;
33455 t.threearabic = 0x0663;
33456 t.threebengali = 0x09e9;
33457 t.threecircle = 0x2462;
33458 t.threecircleinversesansserif = 0x278c;
33459 t.threedeva = 0x0969;
33460 t.threeeighths = 0x215c;
33461 t.threegujarati = 0x0ae9;
33462 t.threegurmukhi = 0x0a69;
33463 t.threehackarabic = 0x0663;
33464 t.threehangzhou = 0x3023;
33465 t.threeideographicparen = 0x3222;
33466 t.threeinferior = 0x2083;
33467 t.threemonospace = 0xff13;
33468 t.threenumeratorbengali = 0x09f6;
33469 t.threeoldstyle = 0xf733;
33470 t.threeparen = 0x2476;
33471 t.threeperiod = 0x248a;
33472 t.threepersian = 0x06f3;
33473 t.threequarters = 0x00be;
33474 t.threequartersemdash = 0xf6de;
33475 t.threeroman = 0x2172;
33476 t.threesuperior = 0x00b3;
33477 t.threethai = 0x0e53;
33478 t.thzsquare = 0x3394;
33479 t.tihiragana = 0x3061;
33480 t.tikatakana = 0x30c1;
33481 t.tikatakanahalfwidth = 0xff81;
33482 t.tikeutacirclekorean = 0x3270;
33483 t.tikeutaparenkorean = 0x3210;
33484 t.tikeutcirclekorean = 0x3262;
33485 t.tikeutkorean = 0x3137;
33486 t.tikeutparenkorean = 0x3202;
33487 t.tilde = 0x02dc;
33488 t.tildebelowcmb = 0x0330;
33489 t.tildecmb = 0x0303;
33490 t.tildecomb = 0x0303;
33491 t.tildedoublecmb = 0x0360;
33492 t.tildeoperator = 0x223c;
33493 t.tildeoverlaycmb = 0x0334;
33494 t.tildeverticalcmb = 0x033e;
33495 t.timescircle = 0x2297;
33496 t.tipehahebrew = 0x0596;
33497 t.tipehalefthebrew = 0x0596;
33498 t.tippigurmukhi = 0x0a70;
33499 t.titlocyrilliccmb = 0x0483;
33500 t.tiwnarmenian = 0x057f;
33501 t.tlinebelow = 0x1e6f;
33502 t.tmonospace = 0xff54;
33503 t.toarmenian = 0x0569;
33504 t.tohiragana = 0x3068;
33505 t.tokatakana = 0x30c8;
33506 t.tokatakanahalfwidth = 0xff84;
33507 t.tonebarextrahighmod = 0x02e5;
33508 t.tonebarextralowmod = 0x02e9;
33509 t.tonebarhighmod = 0x02e6;
33510 t.tonebarlowmod = 0x02e8;
33511 t.tonebarmidmod = 0x02e7;
33512 t.tonefive = 0x01bd;
33513 t.tonesix = 0x0185;
33514 t.tonetwo = 0x01a8;
33515 t.tonos = 0x0384;
33516 t.tonsquare = 0x3327;
33517 t.topatakthai = 0x0e0f;
33518 t.tortoiseshellbracketleft = 0x3014;
33519 t.tortoiseshellbracketleftsmall = 0xfe5d;
33520 t.tortoiseshellbracketleftvertical = 0xfe39;
33521 t.tortoiseshellbracketright = 0x3015;
33522 t.tortoiseshellbracketrightsmall = 0xfe5e;
33523 t.tortoiseshellbracketrightvertical = 0xfe3a;
33524 t.totaothai = 0x0e15;
33525 t.tpalatalhook = 0x01ab;
33526 t.tparen = 0x24af;
33527 t.trademark = 0x2122;
33528 t.trademarksans = 0xf8ea;
33529 t.trademarkserif = 0xf6db;
33530 t.tretroflexhook = 0x0288;
33531 t.triagdn = 0x25bc;
33532 t.triaglf = 0x25c4;
33533 t.triagrt = 0x25ba;
33534 t.triagup = 0x25b2;
33535 t.ts = 0x02a6;
33536 t.tsadi = 0x05e6;
33537 t.tsadidagesh = 0xfb46;
33538 t.tsadidageshhebrew = 0xfb46;
33539 t.tsadihebrew = 0x05e6;
33540 t.tsecyrillic = 0x0446;
33541 t.tsere = 0x05b5;
33542 t.tsere12 = 0x05b5;
33543 t.tsere1e = 0x05b5;
33544 t.tsere2b = 0x05b5;
33545 t.tserehebrew = 0x05b5;
33546 t.tserenarrowhebrew = 0x05b5;
33547 t.tserequarterhebrew = 0x05b5;
33548 t.tserewidehebrew = 0x05b5;
33549 t.tshecyrillic = 0x045b;
33550 t.tsuperior = 0xf6f3;
33551 t.ttabengali = 0x099f;
33552 t.ttadeva = 0x091f;
33553 t.ttagujarati = 0x0a9f;
33554 t.ttagurmukhi = 0x0a1f;
33555 t.tteharabic = 0x0679;
33556 t.ttehfinalarabic = 0xfb67;
33557 t.ttehinitialarabic = 0xfb68;
33558 t.ttehmedialarabic = 0xfb69;
33559 t.tthabengali = 0x09a0;
33560 t.tthadeva = 0x0920;
33561 t.tthagujarati = 0x0aa0;
33562 t.tthagurmukhi = 0x0a20;
33563 t.tturned = 0x0287;
33564 t.tuhiragana = 0x3064;
33565 t.tukatakana = 0x30c4;
33566 t.tukatakanahalfwidth = 0xff82;
33567 t.tusmallhiragana = 0x3063;
33568 t.tusmallkatakana = 0x30c3;
33569 t.tusmallkatakanahalfwidth = 0xff6f;
33570 t.twelvecircle = 0x246b;
33571 t.twelveparen = 0x247f;
33572 t.twelveperiod = 0x2493;
33573 t.twelveroman = 0x217b;
33574 t.twentycircle = 0x2473;
33575 t.twentyhangzhou = 0x5344;
33576 t.twentyparen = 0x2487;
33577 t.twentyperiod = 0x249b;
33578 t.two = 0x0032;
33579 t.twoarabic = 0x0662;
33580 t.twobengali = 0x09e8;
33581 t.twocircle = 0x2461;
33582 t.twocircleinversesansserif = 0x278b;
33583 t.twodeva = 0x0968;
33584 t.twodotenleader = 0x2025;
33585 t.twodotleader = 0x2025;
33586 t.twodotleadervertical = 0xfe30;
33587 t.twogujarati = 0x0ae8;
33588 t.twogurmukhi = 0x0a68;
33589 t.twohackarabic = 0x0662;
33590 t.twohangzhou = 0x3022;
33591 t.twoideographicparen = 0x3221;
33592 t.twoinferior = 0x2082;
33593 t.twomonospace = 0xff12;
33594 t.twonumeratorbengali = 0x09f5;
33595 t.twooldstyle = 0xf732;
33596 t.twoparen = 0x2475;
33597 t.twoperiod = 0x2489;
33598 t.twopersian = 0x06f2;
33599 t.tworoman = 0x2171;
33600 t.twostroke = 0x01bb;
33601 t.twosuperior = 0x00b2;
33602 t.twothai = 0x0e52;
33603 t.twothirds = 0x2154;
33604 t.u = 0x0075;
33605 t.uacute = 0x00fa;
33606 t.ubar = 0x0289;
33607 t.ubengali = 0x0989;
33608 t.ubopomofo = 0x3128;
33609 t.ubreve = 0x016d;
33610 t.ucaron = 0x01d4;
33611 t.ucircle = 0x24e4;
33612 t.ucircumflex = 0x00fb;
33613 t.ucircumflexbelow = 0x1e77;
33614 t.ucyrillic = 0x0443;
33615 t.udattadeva = 0x0951;
33616 t.udblacute = 0x0171;
33617 t.udblgrave = 0x0215;
33618 t.udeva = 0x0909;
33619 t.udieresis = 0x00fc;
33620 t.udieresisacute = 0x01d8;
33621 t.udieresisbelow = 0x1e73;
33622 t.udieresiscaron = 0x01da;
33623 t.udieresiscyrillic = 0x04f1;
33624 t.udieresisgrave = 0x01dc;
33625 t.udieresismacron = 0x01d6;
33626 t.udotbelow = 0x1ee5;
33627 t.ugrave = 0x00f9;
33628 t.ugujarati = 0x0a89;
33629 t.ugurmukhi = 0x0a09;
33630 t.uhiragana = 0x3046;
33631 t.uhookabove = 0x1ee7;
33632 t.uhorn = 0x01b0;
33633 t.uhornacute = 0x1ee9;
33634 t.uhorndotbelow = 0x1ef1;
33635 t.uhorngrave = 0x1eeb;
33636 t.uhornhookabove = 0x1eed;
33637 t.uhorntilde = 0x1eef;
33638 t.uhungarumlaut = 0x0171;
33639 t.uhungarumlautcyrillic = 0x04f3;
33640 t.uinvertedbreve = 0x0217;
33641 t.ukatakana = 0x30a6;
33642 t.ukatakanahalfwidth = 0xff73;
33643 t.ukcyrillic = 0x0479;
33644 t.ukorean = 0x315c;
33645 t.umacron = 0x016b;
33646 t.umacroncyrillic = 0x04ef;
33647 t.umacrondieresis = 0x1e7b;
33648 t.umatragurmukhi = 0x0a41;
33649 t.umonospace = 0xff55;
33650 t.underscore = 0x005f;
33651 t.underscoredbl = 0x2017;
33652 t.underscoremonospace = 0xff3f;
33653 t.underscorevertical = 0xfe33;
33654 t.underscorewavy = 0xfe4f;
33655 t.union = 0x222a;
33656 t.universal = 0x2200;
33657 t.uogonek = 0x0173;
33658 t.uparen = 0x24b0;
33659 t.upblock = 0x2580;
33660 t.upperdothebrew = 0x05c4;
33661 t.upsilon = 0x03c5;
33662 t.upsilondieresis = 0x03cb;
33663 t.upsilondieresistonos = 0x03b0;
33664 t.upsilonlatin = 0x028a;
33665 t.upsilontonos = 0x03cd;
33666 t.uptackbelowcmb = 0x031d;
33667 t.uptackmod = 0x02d4;
33668 t.uragurmukhi = 0x0a73;
33669 t.uring = 0x016f;
33670 t.ushortcyrillic = 0x045e;
33671 t.usmallhiragana = 0x3045;
33672 t.usmallkatakana = 0x30a5;
33673 t.usmallkatakanahalfwidth = 0xff69;
33674 t.ustraightcyrillic = 0x04af;
33675 t.ustraightstrokecyrillic = 0x04b1;
33676 t.utilde = 0x0169;
33677 t.utildeacute = 0x1e79;
33678 t.utildebelow = 0x1e75;
33679 t.uubengali = 0x098a;
33680 t.uudeva = 0x090a;
33681 t.uugujarati = 0x0a8a;
33682 t.uugurmukhi = 0x0a0a;
33683 t.uumatragurmukhi = 0x0a42;
33684 t.uuvowelsignbengali = 0x09c2;
33685 t.uuvowelsigndeva = 0x0942;
33686 t.uuvowelsigngujarati = 0x0ac2;
33687 t.uvowelsignbengali = 0x09c1;
33688 t.uvowelsigndeva = 0x0941;
33689 t.uvowelsigngujarati = 0x0ac1;
33690 t.v = 0x0076;
33691 t.vadeva = 0x0935;
33692 t.vagujarati = 0x0ab5;
33693 t.vagurmukhi = 0x0a35;
33694 t.vakatakana = 0x30f7;
33695 t.vav = 0x05d5;
33696 t.vavdagesh = 0xfb35;
33697 t.vavdagesh65 = 0xfb35;
33698 t.vavdageshhebrew = 0xfb35;
33699 t.vavhebrew = 0x05d5;
33700 t.vavholam = 0xfb4b;
33701 t.vavholamhebrew = 0xfb4b;
33702 t.vavvavhebrew = 0x05f0;
33703 t.vavyodhebrew = 0x05f1;
33704 t.vcircle = 0x24e5;
33705 t.vdotbelow = 0x1e7f;
33706 t.vecyrillic = 0x0432;
33707 t.veharabic = 0x06a4;
33708 t.vehfinalarabic = 0xfb6b;
33709 t.vehinitialarabic = 0xfb6c;
33710 t.vehmedialarabic = 0xfb6d;
33711 t.vekatakana = 0x30f9;
33712 t.venus = 0x2640;
33713 t.verticalbar = 0x007c;
33714 t.verticallineabovecmb = 0x030d;
33715 t.verticallinebelowcmb = 0x0329;
33716 t.verticallinelowmod = 0x02cc;
33717 t.verticallinemod = 0x02c8;
33718 t.vewarmenian = 0x057e;
33719 t.vhook = 0x028b;
33720 t.vikatakana = 0x30f8;
33721 t.viramabengali = 0x09cd;
33722 t.viramadeva = 0x094d;
33723 t.viramagujarati = 0x0acd;
33724 t.visargabengali = 0x0983;
33725 t.visargadeva = 0x0903;
33726 t.visargagujarati = 0x0a83;
33727 t.vmonospace = 0xff56;
33728 t.voarmenian = 0x0578;
33729 t.voicediterationhiragana = 0x309e;
33730 t.voicediterationkatakana = 0x30fe;
33731 t.voicedmarkkana = 0x309b;
33732 t.voicedmarkkanahalfwidth = 0xff9e;
33733 t.vokatakana = 0x30fa;
33734 t.vparen = 0x24b1;
33735 t.vtilde = 0x1e7d;
33736 t.vturned = 0x028c;
33737 t.vuhiragana = 0x3094;
33738 t.vukatakana = 0x30f4;
33739 t.w = 0x0077;
33740 t.wacute = 0x1e83;
33741 t.waekorean = 0x3159;
33742 t.wahiragana = 0x308f;
33743 t.wakatakana = 0x30ef;
33744 t.wakatakanahalfwidth = 0xff9c;
33745 t.wakorean = 0x3158;
33746 t.wasmallhiragana = 0x308e;
33747 t.wasmallkatakana = 0x30ee;
33748 t.wattosquare = 0x3357;
33749 t.wavedash = 0x301c;
33750 t.wavyunderscorevertical = 0xfe34;
33751 t.wawarabic = 0x0648;
33752 t.wawfinalarabic = 0xfeee;
33753 t.wawhamzaabovearabic = 0x0624;
33754 t.wawhamzaabovefinalarabic = 0xfe86;
33755 t.wbsquare = 0x33dd;
33756 t.wcircle = 0x24e6;
33757 t.wcircumflex = 0x0175;
33758 t.wdieresis = 0x1e85;
33759 t.wdotaccent = 0x1e87;
33760 t.wdotbelow = 0x1e89;
33761 t.wehiragana = 0x3091;
33762 t.weierstrass = 0x2118;
33763 t.wekatakana = 0x30f1;
33764 t.wekorean = 0x315e;
33765 t.weokorean = 0x315d;
33766 t.wgrave = 0x1e81;
33767 t.whitebullet = 0x25e6;
33768 t.whitecircle = 0x25cb;
33769 t.whitecircleinverse = 0x25d9;
33770 t.whitecornerbracketleft = 0x300e;
33771 t.whitecornerbracketleftvertical = 0xfe43;
33772 t.whitecornerbracketright = 0x300f;
33773 t.whitecornerbracketrightvertical = 0xfe44;
33774 t.whitediamond = 0x25c7;
33775 t.whitediamondcontainingblacksmalldiamond = 0x25c8;
33776 t.whitedownpointingsmalltriangle = 0x25bf;
33777 t.whitedownpointingtriangle = 0x25bd;
33778 t.whiteleftpointingsmalltriangle = 0x25c3;
33779 t.whiteleftpointingtriangle = 0x25c1;
33780 t.whitelenticularbracketleft = 0x3016;
33781 t.whitelenticularbracketright = 0x3017;
33782 t.whiterightpointingsmalltriangle = 0x25b9;
33783 t.whiterightpointingtriangle = 0x25b7;
33784 t.whitesmallsquare = 0x25ab;
33785 t.whitesmilingface = 0x263a;
33786 t.whitesquare = 0x25a1;
33787 t.whitestar = 0x2606;
33788 t.whitetelephone = 0x260f;
33789 t.whitetortoiseshellbracketleft = 0x3018;
33790 t.whitetortoiseshellbracketright = 0x3019;
33791 t.whiteuppointingsmalltriangle = 0x25b5;
33792 t.whiteuppointingtriangle = 0x25b3;
33793 t.wihiragana = 0x3090;
33794 t.wikatakana = 0x30f0;
33795 t.wikorean = 0x315f;
33796 t.wmonospace = 0xff57;
33797 t.wohiragana = 0x3092;
33798 t.wokatakana = 0x30f2;
33799 t.wokatakanahalfwidth = 0xff66;
33800 t.won = 0x20a9;
33801 t.wonmonospace = 0xffe6;
33802 t.wowaenthai = 0x0e27;
33803 t.wparen = 0x24b2;
33804 t.wring = 0x1e98;
33805 t.wsuperior = 0x02b7;
33806 t.wturned = 0x028d;
33807 t.wynn = 0x01bf;
33808 t.x = 0x0078;
33809 t.xabovecmb = 0x033d;
33810 t.xbopomofo = 0x3112;
33811 t.xcircle = 0x24e7;
33812 t.xdieresis = 0x1e8d;
33813 t.xdotaccent = 0x1e8b;
33814 t.xeharmenian = 0x056d;
33815 t.xi = 0x03be;
33816 t.xmonospace = 0xff58;
33817 t.xparen = 0x24b3;
33818 t.xsuperior = 0x02e3;
33819 t.y = 0x0079;
33820 t.yaadosquare = 0x334e;
33821 t.yabengali = 0x09af;
33822 t.yacute = 0x00fd;
33823 t.yadeva = 0x092f;
33824 t.yaekorean = 0x3152;
33825 t.yagujarati = 0x0aaf;
33826 t.yagurmukhi = 0x0a2f;
33827 t.yahiragana = 0x3084;
33828 t.yakatakana = 0x30e4;
33829 t.yakatakanahalfwidth = 0xff94;
33830 t.yakorean = 0x3151;
33831 t.yamakkanthai = 0x0e4e;
33832 t.yasmallhiragana = 0x3083;
33833 t.yasmallkatakana = 0x30e3;
33834 t.yasmallkatakanahalfwidth = 0xff6c;
33835 t.yatcyrillic = 0x0463;
33836 t.ycircle = 0x24e8;
33837 t.ycircumflex = 0x0177;
33838 t.ydieresis = 0x00ff;
33839 t.ydotaccent = 0x1e8f;
33840 t.ydotbelow = 0x1ef5;
33841 t.yeharabic = 0x064a;
33842 t.yehbarreearabic = 0x06d2;
33843 t.yehbarreefinalarabic = 0xfbaf;
33844 t.yehfinalarabic = 0xfef2;
33845 t.yehhamzaabovearabic = 0x0626;
33846 t.yehhamzaabovefinalarabic = 0xfe8a;
33847 t.yehhamzaaboveinitialarabic = 0xfe8b;
33848 t.yehhamzaabovemedialarabic = 0xfe8c;
33849 t.yehinitialarabic = 0xfef3;
33850 t.yehmedialarabic = 0xfef4;
33851 t.yehmeeminitialarabic = 0xfcdd;
33852 t.yehmeemisolatedarabic = 0xfc58;
33853 t.yehnoonfinalarabic = 0xfc94;
33854 t.yehthreedotsbelowarabic = 0x06d1;
33855 t.yekorean = 0x3156;
33856 t.yen = 0x00a5;
33857 t.yenmonospace = 0xffe5;
33858 t.yeokorean = 0x3155;
33859 t.yeorinhieuhkorean = 0x3186;
33860 t.yerahbenyomohebrew = 0x05aa;
33861 t.yerahbenyomolefthebrew = 0x05aa;
33862 t.yericyrillic = 0x044b;
33863 t.yerudieresiscyrillic = 0x04f9;
33864 t.yesieungkorean = 0x3181;
33865 t.yesieungpansioskorean = 0x3183;
33866 t.yesieungsioskorean = 0x3182;
33867 t.yetivhebrew = 0x059a;
33868 t.ygrave = 0x1ef3;
33869 t.yhook = 0x01b4;
33870 t.yhookabove = 0x1ef7;
33871 t.yiarmenian = 0x0575;
33872 t.yicyrillic = 0x0457;
33873 t.yikorean = 0x3162;
33874 t.yinyang = 0x262f;
33875 t.yiwnarmenian = 0x0582;
33876 t.ymonospace = 0xff59;
33877 t.yod = 0x05d9;
33878 t.yoddagesh = 0xfb39;
33879 t.yoddageshhebrew = 0xfb39;
33880 t.yodhebrew = 0x05d9;
33881 t.yodyodhebrew = 0x05f2;
33882 t.yodyodpatahhebrew = 0xfb1f;
33883 t.yohiragana = 0x3088;
33884 t.yoikorean = 0x3189;
33885 t.yokatakana = 0x30e8;
33886 t.yokatakanahalfwidth = 0xff96;
33887 t.yokorean = 0x315b;
33888 t.yosmallhiragana = 0x3087;
33889 t.yosmallkatakana = 0x30e7;
33890 t.yosmallkatakanahalfwidth = 0xff6e;
33891 t.yotgreek = 0x03f3;
33892 t.yoyaekorean = 0x3188;
33893 t.yoyakorean = 0x3187;
33894 t.yoyakthai = 0x0e22;
33895 t.yoyingthai = 0x0e0d;
33896 t.yparen = 0x24b4;
33897 t.ypogegrammeni = 0x037a;
33898 t.ypogegrammenigreekcmb = 0x0345;
33899 t.yr = 0x01a6;
33900 t.yring = 0x1e99;
33901 t.ysuperior = 0x02b8;
33902 t.ytilde = 0x1ef9;
33903 t.yturned = 0x028e;
33904 t.yuhiragana = 0x3086;
33905 t.yuikorean = 0x318c;
33906 t.yukatakana = 0x30e6;
33907 t.yukatakanahalfwidth = 0xff95;
33908 t.yukorean = 0x3160;
33909 t.yusbigcyrillic = 0x046b;
33910 t.yusbigiotifiedcyrillic = 0x046d;
33911 t.yuslittlecyrillic = 0x0467;
33912 t.yuslittleiotifiedcyrillic = 0x0469;
33913 t.yusmallhiragana = 0x3085;
33914 t.yusmallkatakana = 0x30e5;
33915 t.yusmallkatakanahalfwidth = 0xff6d;
33916 t.yuyekorean = 0x318b;
33917 t.yuyeokorean = 0x318a;
33918 t.yyabengali = 0x09df;
33919 t.yyadeva = 0x095f;
33920 t.z = 0x007a;
33921 t.zaarmenian = 0x0566;
33922 t.zacute = 0x017a;
33923 t.zadeva = 0x095b;
33924 t.zagurmukhi = 0x0a5b;
33925 t.zaharabic = 0x0638;
33926 t.zahfinalarabic = 0xfec6;
33927 t.zahinitialarabic = 0xfec7;
33928 t.zahiragana = 0x3056;
33929 t.zahmedialarabic = 0xfec8;
33930 t.zainarabic = 0x0632;
33931 t.zainfinalarabic = 0xfeb0;
33932 t.zakatakana = 0x30b6;
33933 t.zaqefgadolhebrew = 0x0595;
33934 t.zaqefqatanhebrew = 0x0594;
33935 t.zarqahebrew = 0x0598;
33936 t.zayin = 0x05d6;
33937 t.zayindagesh = 0xfb36;
33938 t.zayindageshhebrew = 0xfb36;
33939 t.zayinhebrew = 0x05d6;
33940 t.zbopomofo = 0x3117;
33941 t.zcaron = 0x017e;
33942 t.zcircle = 0x24e9;
33943 t.zcircumflex = 0x1e91;
33944 t.zcurl = 0x0291;
33945 t.zdot = 0x017c;
33946 t.zdotaccent = 0x017c;
33947 t.zdotbelow = 0x1e93;
33948 t.zecyrillic = 0x0437;
33949 t.zedescendercyrillic = 0x0499;
33950 t.zedieresiscyrillic = 0x04df;
33951 t.zehiragana = 0x305c;
33952 t.zekatakana = 0x30bc;
33953 t.zero = 0x0030;
33954 t.zeroarabic = 0x0660;
33955 t.zerobengali = 0x09e6;
33956 t.zerodeva = 0x0966;
33957 t.zerogujarati = 0x0ae6;
33958 t.zerogurmukhi = 0x0a66;
33959 t.zerohackarabic = 0x0660;
33960 t.zeroinferior = 0x2080;
33961 t.zeromonospace = 0xff10;
33962 t.zerooldstyle = 0xf730;
33963 t.zeropersian = 0x06f0;
33964 t.zerosuperior = 0x2070;
33965 t.zerothai = 0x0e50;
33966 t.zerowidthjoiner = 0xfeff;
33967 t.zerowidthnonjoiner = 0x200c;
33968 t.zerowidthspace = 0x200b;
33969 t.zeta = 0x03b6;
33970 t.zhbopomofo = 0x3113;
33971 t.zhearmenian = 0x056a;
33972 t.zhebrevecyrillic = 0x04c2;
33973 t.zhecyrillic = 0x0436;
33974 t.zhedescendercyrillic = 0x0497;
33975 t.zhedieresiscyrillic = 0x04dd;
33976 t.zihiragana = 0x3058;
33977 t.zikatakana = 0x30b8;
33978 t.zinorhebrew = 0x05ae;
33979 t.zlinebelow = 0x1e95;
33980 t.zmonospace = 0xff5a;
33981 t.zohiragana = 0x305e;
33982 t.zokatakana = 0x30be;
33983 t.zparen = 0x24b5;
33984 t.zretroflexhook = 0x0290;
33985 t.zstroke = 0x01b6;
33986 t.zuhiragana = 0x305a;
33987 t.zukatakana = 0x30ba;
33988 t[".notdef"] = 0x0000;
33989 t.angbracketleftbig = 0x2329;
33990 t.angbracketleftBig = 0x2329;
33991 t.angbracketleftbigg = 0x2329;
33992 t.angbracketleftBigg = 0x2329;
33993 t.angbracketrightBig = 0x232a;
33994 t.angbracketrightbig = 0x232a;
33995 t.angbracketrightBigg = 0x232a;
33996 t.angbracketrightbigg = 0x232a;
33997 t.arrowhookleft = 0x21aa;
33998 t.arrowhookright = 0x21a9;
33999 t.arrowlefttophalf = 0x21bc;
34000 t.arrowleftbothalf = 0x21bd;
34001 t.arrownortheast = 0x2197;
34002 t.arrownorthwest = 0x2196;
34003 t.arrowrighttophalf = 0x21c0;
34004 t.arrowrightbothalf = 0x21c1;
34005 t.arrowsoutheast = 0x2198;
34006 t.arrowsouthwest = 0x2199;
34007 t.backslashbig = 0x2216;
34008 t.backslashBig = 0x2216;
34009 t.backslashBigg = 0x2216;
34010 t.backslashbigg = 0x2216;
34011 t.bardbl = 0x2016;
34012 t.bracehtipdownleft = 0xfe37;
34013 t.bracehtipdownright = 0xfe37;
34014 t.bracehtipupleft = 0xfe38;
34015 t.bracehtipupright = 0xfe38;
34016 t.braceleftBig = 0x007b;
34017 t.braceleftbig = 0x007b;
34018 t.braceleftbigg = 0x007b;
34019 t.braceleftBigg = 0x007b;
34020 t.bracerightBig = 0x007d;
34021 t.bracerightbig = 0x007d;
34022 t.bracerightbigg = 0x007d;
34023 t.bracerightBigg = 0x007d;
34024 t.bracketleftbig = 0x005b;
34025 t.bracketleftBig = 0x005b;
34026 t.bracketleftbigg = 0x005b;
34027 t.bracketleftBigg = 0x005b;
34028 t.bracketrightBig = 0x005d;
34029 t.bracketrightbig = 0x005d;
34030 t.bracketrightbigg = 0x005d;
34031 t.bracketrightBigg = 0x005d;
34032 t.ceilingleftbig = 0x2308;
34033 t.ceilingleftBig = 0x2308;
34034 t.ceilingleftBigg = 0x2308;
34035 t.ceilingleftbigg = 0x2308;
34036 t.ceilingrightbig = 0x2309;
34037 t.ceilingrightBig = 0x2309;
34038 t.ceilingrightbigg = 0x2309;
34039 t.ceilingrightBigg = 0x2309;
34040 t.circledotdisplay = 0x2299;
34041 t.circledottext = 0x2299;
34042 t.circlemultiplydisplay = 0x2297;
34043 t.circlemultiplytext = 0x2297;
34044 t.circleplusdisplay = 0x2295;
34045 t.circleplustext = 0x2295;
34046 t.contintegraldisplay = 0x222e;
34047 t.contintegraltext = 0x222e;
34048 t.coproductdisplay = 0x2210;
34049 t.coproducttext = 0x2210;
34050 t.floorleftBig = 0x230a;
34051 t.floorleftbig = 0x230a;
34052 t.floorleftbigg = 0x230a;
34053 t.floorleftBigg = 0x230a;
34054 t.floorrightbig = 0x230b;
34055 t.floorrightBig = 0x230b;
34056 t.floorrightBigg = 0x230b;
34057 t.floorrightbigg = 0x230b;
34058 t.hatwide = 0x0302;
34059 t.hatwider = 0x0302;
34060 t.hatwidest = 0x0302;
34061 t.intercal = 0x1d40;
34062 t.integraldisplay = 0x222b;
34063 t.integraltext = 0x222b;
34064 t.intersectiondisplay = 0x22c2;
34065 t.intersectiontext = 0x22c2;
34066 t.logicalanddisplay = 0x2227;
34067 t.logicalandtext = 0x2227;
34068 t.logicalordisplay = 0x2228;
34069 t.logicalortext = 0x2228;
34070 t.parenleftBig = 0x0028;
34071 t.parenleftbig = 0x0028;
34072 t.parenleftBigg = 0x0028;
34073 t.parenleftbigg = 0x0028;
34074 t.parenrightBig = 0x0029;
34075 t.parenrightbig = 0x0029;
34076 t.parenrightBigg = 0x0029;
34077 t.parenrightbigg = 0x0029;
34078 t.prime = 0x2032;
34079 t.productdisplay = 0x220f;
34080 t.producttext = 0x220f;
34081 t.radicalbig = 0x221a;
34082 t.radicalBig = 0x221a;
34083 t.radicalBigg = 0x221a;
34084 t.radicalbigg = 0x221a;
34085 t.radicalbt = 0x221a;
34086 t.radicaltp = 0x221a;
34087 t.radicalvertex = 0x221a;
34088 t.slashbig = 0x002f;
34089 t.slashBig = 0x002f;
34090 t.slashBigg = 0x002f;
34091 t.slashbigg = 0x002f;
34092 t.summationdisplay = 0x2211;
34093 t.summationtext = 0x2211;
34094 t.tildewide = 0x02dc;
34095 t.tildewider = 0x02dc;
34096 t.tildewidest = 0x02dc;
34097 t.uniondisplay = 0x22c3;
34098 t.unionmultidisplay = 0x228e;
34099 t.unionmultitext = 0x228e;
34100 t.unionsqdisplay = 0x2294;
34101 t.unionsqtext = 0x2294;
34102 t.uniontext = 0x22c3;
34103 t.vextenddouble = 0x2225;
34104 t.vextendsingle = 0x2223;
34105});
34106var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
34107 t.space = 0x0020;
34108 t.a1 = 0x2701;
34109 t.a2 = 0x2702;
34110 t.a202 = 0x2703;
34111 t.a3 = 0x2704;
34112 t.a4 = 0x260e;
34113 t.a5 = 0x2706;
34114 t.a119 = 0x2707;
34115 t.a118 = 0x2708;
34116 t.a117 = 0x2709;
34117 t.a11 = 0x261b;
34118 t.a12 = 0x261e;
34119 t.a13 = 0x270c;
34120 t.a14 = 0x270d;
34121 t.a15 = 0x270e;
34122 t.a16 = 0x270f;
34123 t.a105 = 0x2710;
34124 t.a17 = 0x2711;
34125 t.a18 = 0x2712;
34126 t.a19 = 0x2713;
34127 t.a20 = 0x2714;
34128 t.a21 = 0x2715;
34129 t.a22 = 0x2716;
34130 t.a23 = 0x2717;
34131 t.a24 = 0x2718;
34132 t.a25 = 0x2719;
34133 t.a26 = 0x271a;
34134 t.a27 = 0x271b;
34135 t.a28 = 0x271c;
34136 t.a6 = 0x271d;
34137 t.a7 = 0x271e;
34138 t.a8 = 0x271f;
34139 t.a9 = 0x2720;
34140 t.a10 = 0x2721;
34141 t.a29 = 0x2722;
34142 t.a30 = 0x2723;
34143 t.a31 = 0x2724;
34144 t.a32 = 0x2725;
34145 t.a33 = 0x2726;
34146 t.a34 = 0x2727;
34147 t.a35 = 0x2605;
34148 t.a36 = 0x2729;
34149 t.a37 = 0x272a;
34150 t.a38 = 0x272b;
34151 t.a39 = 0x272c;
34152 t.a40 = 0x272d;
34153 t.a41 = 0x272e;
34154 t.a42 = 0x272f;
34155 t.a43 = 0x2730;
34156 t.a44 = 0x2731;
34157 t.a45 = 0x2732;
34158 t.a46 = 0x2733;
34159 t.a47 = 0x2734;
34160 t.a48 = 0x2735;
34161 t.a49 = 0x2736;
34162 t.a50 = 0x2737;
34163 t.a51 = 0x2738;
34164 t.a52 = 0x2739;
34165 t.a53 = 0x273a;
34166 t.a54 = 0x273b;
34167 t.a55 = 0x273c;
34168 t.a56 = 0x273d;
34169 t.a57 = 0x273e;
34170 t.a58 = 0x273f;
34171 t.a59 = 0x2740;
34172 t.a60 = 0x2741;
34173 t.a61 = 0x2742;
34174 t.a62 = 0x2743;
34175 t.a63 = 0x2744;
34176 t.a64 = 0x2745;
34177 t.a65 = 0x2746;
34178 t.a66 = 0x2747;
34179 t.a67 = 0x2748;
34180 t.a68 = 0x2749;
34181 t.a69 = 0x274a;
34182 t.a70 = 0x274b;
34183 t.a71 = 0x25cf;
34184 t.a72 = 0x274d;
34185 t.a73 = 0x25a0;
34186 t.a74 = 0x274f;
34187 t.a203 = 0x2750;
34188 t.a75 = 0x2751;
34189 t.a204 = 0x2752;
34190 t.a76 = 0x25b2;
34191 t.a77 = 0x25bc;
34192 t.a78 = 0x25c6;
34193 t.a79 = 0x2756;
34194 t.a81 = 0x25d7;
34195 t.a82 = 0x2758;
34196 t.a83 = 0x2759;
34197 t.a84 = 0x275a;
34198 t.a97 = 0x275b;
34199 t.a98 = 0x275c;
34200 t.a99 = 0x275d;
34201 t.a100 = 0x275e;
34202 t.a101 = 0x2761;
34203 t.a102 = 0x2762;
34204 t.a103 = 0x2763;
34205 t.a104 = 0x2764;
34206 t.a106 = 0x2765;
34207 t.a107 = 0x2766;
34208 t.a108 = 0x2767;
34209 t.a112 = 0x2663;
34210 t.a111 = 0x2666;
34211 t.a110 = 0x2665;
34212 t.a109 = 0x2660;
34213 t.a120 = 0x2460;
34214 t.a121 = 0x2461;
34215 t.a122 = 0x2462;
34216 t.a123 = 0x2463;
34217 t.a124 = 0x2464;
34218 t.a125 = 0x2465;
34219 t.a126 = 0x2466;
34220 t.a127 = 0x2467;
34221 t.a128 = 0x2468;
34222 t.a129 = 0x2469;
34223 t.a130 = 0x2776;
34224 t.a131 = 0x2777;
34225 t.a132 = 0x2778;
34226 t.a133 = 0x2779;
34227 t.a134 = 0x277a;
34228 t.a135 = 0x277b;
34229 t.a136 = 0x277c;
34230 t.a137 = 0x277d;
34231 t.a138 = 0x277e;
34232 t.a139 = 0x277f;
34233 t.a140 = 0x2780;
34234 t.a141 = 0x2781;
34235 t.a142 = 0x2782;
34236 t.a143 = 0x2783;
34237 t.a144 = 0x2784;
34238 t.a145 = 0x2785;
34239 t.a146 = 0x2786;
34240 t.a147 = 0x2787;
34241 t.a148 = 0x2788;
34242 t.a149 = 0x2789;
34243 t.a150 = 0x278a;
34244 t.a151 = 0x278b;
34245 t.a152 = 0x278c;
34246 t.a153 = 0x278d;
34247 t.a154 = 0x278e;
34248 t.a155 = 0x278f;
34249 t.a156 = 0x2790;
34250 t.a157 = 0x2791;
34251 t.a158 = 0x2792;
34252 t.a159 = 0x2793;
34253 t.a160 = 0x2794;
34254 t.a161 = 0x2192;
34255 t.a163 = 0x2194;
34256 t.a164 = 0x2195;
34257 t.a196 = 0x2798;
34258 t.a165 = 0x2799;
34259 t.a192 = 0x279a;
34260 t.a166 = 0x279b;
34261 t.a167 = 0x279c;
34262 t.a168 = 0x279d;
34263 t.a169 = 0x279e;
34264 t.a170 = 0x279f;
34265 t.a171 = 0x27a0;
34266 t.a172 = 0x27a1;
34267 t.a173 = 0x27a2;
34268 t.a162 = 0x27a3;
34269 t.a174 = 0x27a4;
34270 t.a175 = 0x27a5;
34271 t.a176 = 0x27a6;
34272 t.a177 = 0x27a7;
34273 t.a178 = 0x27a8;
34274 t.a179 = 0x27a9;
34275 t.a193 = 0x27aa;
34276 t.a180 = 0x27ab;
34277 t.a199 = 0x27ac;
34278 t.a181 = 0x27ad;
34279 t.a200 = 0x27ae;
34280 t.a182 = 0x27af;
34281 t.a201 = 0x27b1;
34282 t.a183 = 0x27b2;
34283 t.a184 = 0x27b3;
34284 t.a197 = 0x27b4;
34285 t.a185 = 0x27b5;
34286 t.a194 = 0x27b6;
34287 t.a198 = 0x27b7;
34288 t.a186 = 0x27b8;
34289 t.a195 = 0x27b9;
34290 t.a187 = 0x27ba;
34291 t.a188 = 0x27bb;
34292 t.a189 = 0x27bc;
34293 t.a190 = 0x27bd;
34294 t.a191 = 0x27be;
34295 t.a89 = 0x2768;
34296 t.a90 = 0x2769;
34297 t.a93 = 0x276a;
34298 t.a94 = 0x276b;
34299 t.a91 = 0x276c;
34300 t.a92 = 0x276d;
34301 t.a205 = 0x276e;
34302 t.a85 = 0x276f;
34303 t.a206 = 0x2770;
34304 t.a86 = 0x2771;
34305 t.a87 = 0x2772;
34306 t.a88 = 0x2773;
34307 t.a95 = 0x2774;
34308 t.a96 = 0x2775;
34309 t[".notdef"] = 0x0000;
34310});
34311exports.getGlyphsUnicode = getGlyphsUnicode;
34312exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
34313
34314/***/ }),
34315/* 34 */
34316/***/ (function(module, exports, __w_pdfjs_require__) {
34317
34318"use strict";
34319
34320
34321Object.defineProperty(exports, "__esModule", {
34322 value: true
34323});
34324exports.getSupplementalGlyphMapForCalibri = exports.getSupplementalGlyphMapForArialBlack = exports.getGlyphMapForStandardFonts = exports.getSymbolsFonts = exports.getSerifFonts = exports.getNonStdFontMap = exports.getStdFontMap = void 0;
34325
34326var _core_utils = __w_pdfjs_require__(8);
34327
34328const getStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
34329 t.ArialNarrow = "Helvetica";
34330 t["ArialNarrow-Bold"] = "Helvetica-Bold";
34331 t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
34332 t["ArialNarrow-Italic"] = "Helvetica-Oblique";
34333 t.ArialBlack = "Helvetica";
34334 t["ArialBlack-Bold"] = "Helvetica-Bold";
34335 t["ArialBlack-BoldItalic"] = "Helvetica-BoldOblique";
34336 t["ArialBlack-Italic"] = "Helvetica-Oblique";
34337 t["Arial-Black"] = "Helvetica";
34338 t["Arial-Black-Bold"] = "Helvetica-Bold";
34339 t["Arial-Black-BoldItalic"] = "Helvetica-BoldOblique";
34340 t["Arial-Black-Italic"] = "Helvetica-Oblique";
34341 t.Arial = "Helvetica";
34342 t["Arial-Bold"] = "Helvetica-Bold";
34343 t["Arial-BoldItalic"] = "Helvetica-BoldOblique";
34344 t["Arial-Italic"] = "Helvetica-Oblique";
34345 t["Arial-BoldItalicMT"] = "Helvetica-BoldOblique";
34346 t["Arial-BoldMT"] = "Helvetica-Bold";
34347 t["Arial-ItalicMT"] = "Helvetica-Oblique";
34348 t.ArialMT = "Helvetica";
34349 t["Courier-Bold"] = "Courier-Bold";
34350 t["Courier-BoldItalic"] = "Courier-BoldOblique";
34351 t["Courier-Italic"] = "Courier-Oblique";
34352 t.CourierNew = "Courier";
34353 t["CourierNew-Bold"] = "Courier-Bold";
34354 t["CourierNew-BoldItalic"] = "Courier-BoldOblique";
34355 t["CourierNew-Italic"] = "Courier-Oblique";
34356 t["CourierNewPS-BoldItalicMT"] = "Courier-BoldOblique";
34357 t["CourierNewPS-BoldMT"] = "Courier-Bold";
34358 t["CourierNewPS-ItalicMT"] = "Courier-Oblique";
34359 t.CourierNewPSMT = "Courier";
34360 t.Helvetica = "Helvetica";
34361 t["Helvetica-Bold"] = "Helvetica-Bold";
34362 t["Helvetica-BoldItalic"] = "Helvetica-BoldOblique";
34363 t["Helvetica-BoldOblique"] = "Helvetica-BoldOblique";
34364 t["Helvetica-Italic"] = "Helvetica-Oblique";
34365 t["Helvetica-Oblique"] = "Helvetica-Oblique";
34366 t["Symbol-Bold"] = "Symbol";
34367 t["Symbol-BoldItalic"] = "Symbol";
34368 t["Symbol-Italic"] = "Symbol";
34369 t.TimesNewRoman = "Times-Roman";
34370 t["TimesNewRoman-Bold"] = "Times-Bold";
34371 t["TimesNewRoman-BoldItalic"] = "Times-BoldItalic";
34372 t["TimesNewRoman-Italic"] = "Times-Italic";
34373 t.TimesNewRomanPS = "Times-Roman";
34374 t["TimesNewRomanPS-Bold"] = "Times-Bold";
34375 t["TimesNewRomanPS-BoldItalic"] = "Times-BoldItalic";
34376 t["TimesNewRomanPS-BoldItalicMT"] = "Times-BoldItalic";
34377 t["TimesNewRomanPS-BoldMT"] = "Times-Bold";
34378 t["TimesNewRomanPS-Italic"] = "Times-Italic";
34379 t["TimesNewRomanPS-ItalicMT"] = "Times-Italic";
34380 t.TimesNewRomanPSMT = "Times-Roman";
34381 t["TimesNewRomanPSMT-Bold"] = "Times-Bold";
34382 t["TimesNewRomanPSMT-BoldItalic"] = "Times-BoldItalic";
34383 t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
34384});
34385exports.getStdFontMap = getStdFontMap;
34386const getNonStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
34387 t.Calibri = "Helvetica";
34388 t["Calibri-Bold"] = "Helvetica-Bold";
34389 t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
34390 t["Calibri-Italic"] = "Helvetica-Oblique";
34391 t.CenturyGothic = "Helvetica";
34392 t["CenturyGothic-Bold"] = "Helvetica-Bold";
34393 t["CenturyGothic-BoldItalic"] = "Helvetica-BoldOblique";
34394 t["CenturyGothic-Italic"] = "Helvetica-Oblique";
34395 t.ComicSansMS = "Comic Sans MS";
34396 t["ComicSansMS-Bold"] = "Comic Sans MS-Bold";
34397 t["ComicSansMS-BoldItalic"] = "Comic Sans MS-BoldItalic";
34398 t["ComicSansMS-Italic"] = "Comic Sans MS-Italic";
34399 t.LucidaConsole = "Courier";
34400 t["LucidaConsole-Bold"] = "Courier-Bold";
34401 t["LucidaConsole-BoldItalic"] = "Courier-BoldOblique";
34402 t["LucidaConsole-Italic"] = "Courier-Oblique";
34403 t["LucidaSans-Demi"] = "Helvetica-Bold";
34404 t["MS-Gothic"] = "MS Gothic";
34405 t["MS-Gothic-Bold"] = "MS Gothic-Bold";
34406 t["MS-Gothic-BoldItalic"] = "MS Gothic-BoldItalic";
34407 t["MS-Gothic-Italic"] = "MS Gothic-Italic";
34408 t["MS-Mincho"] = "MS Mincho";
34409 t["MS-Mincho-Bold"] = "MS Mincho-Bold";
34410 t["MS-Mincho-BoldItalic"] = "MS Mincho-BoldItalic";
34411 t["MS-Mincho-Italic"] = "MS Mincho-Italic";
34412 t["MS-PGothic"] = "MS PGothic";
34413 t["MS-PGothic-Bold"] = "MS PGothic-Bold";
34414 t["MS-PGothic-BoldItalic"] = "MS PGothic-BoldItalic";
34415 t["MS-PGothic-Italic"] = "MS PGothic-Italic";
34416 t["MS-PMincho"] = "MS PMincho";
34417 t["MS-PMincho-Bold"] = "MS PMincho-Bold";
34418 t["MS-PMincho-BoldItalic"] = "MS PMincho-BoldItalic";
34419 t["MS-PMincho-Italic"] = "MS PMincho-Italic";
34420 t.NuptialScript = "Times-Italic";
34421 t.SegoeUISymbol = "Helvetica";
34422 t.Wingdings = "ZapfDingbats";
34423 t["Wingdings-Regular"] = "ZapfDingbats";
34424});
34425exports.getNonStdFontMap = getNonStdFontMap;
34426const getSerifFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
34427 t["Adobe Jenson"] = true;
34428 t["Adobe Text"] = true;
34429 t.Albertus = true;
34430 t.Aldus = true;
34431 t.Alexandria = true;
34432 t.Algerian = true;
34433 t["American Typewriter"] = true;
34434 t.Antiqua = true;
34435 t.Apex = true;
34436 t.Arno = true;
34437 t.Aster = true;
34438 t.Aurora = true;
34439 t.Baskerville = true;
34440 t.Bell = true;
34441 t.Bembo = true;
34442 t["Bembo Schoolbook"] = true;
34443 t.Benguiat = true;
34444 t["Berkeley Old Style"] = true;
34445 t["Bernhard Modern"] = true;
34446 t["Berthold City"] = true;
34447 t.Bodoni = true;
34448 t["Bauer Bodoni"] = true;
34449 t["Book Antiqua"] = true;
34450 t.Bookman = true;
34451 t["Bordeaux Roman"] = true;
34452 t["Californian FB"] = true;
34453 t.Calisto = true;
34454 t.Calvert = true;
34455 t.Capitals = true;
34456 t.Cambria = true;
34457 t.Cartier = true;
34458 t.Caslon = true;
34459 t.Catull = true;
34460 t.Centaur = true;
34461 t["Century Old Style"] = true;
34462 t["Century Schoolbook"] = true;
34463 t.Chaparral = true;
34464 t["Charis SIL"] = true;
34465 t.Cheltenham = true;
34466 t["Cholla Slab"] = true;
34467 t.Clarendon = true;
34468 t.Clearface = true;
34469 t.Cochin = true;
34470 t.Colonna = true;
34471 t["Computer Modern"] = true;
34472 t["Concrete Roman"] = true;
34473 t.Constantia = true;
34474 t["Cooper Black"] = true;
34475 t.Corona = true;
34476 t.Ecotype = true;
34477 t.Egyptienne = true;
34478 t.Elephant = true;
34479 t.Excelsior = true;
34480 t.Fairfield = true;
34481 t["FF Scala"] = true;
34482 t.Folkard = true;
34483 t.Footlight = true;
34484 t.FreeSerif = true;
34485 t["Friz Quadrata"] = true;
34486 t.Garamond = true;
34487 t.Gentium = true;
34488 t.Georgia = true;
34489 t.Gloucester = true;
34490 t["Goudy Old Style"] = true;
34491 t["Goudy Schoolbook"] = true;
34492 t["Goudy Pro Font"] = true;
34493 t.Granjon = true;
34494 t["Guardian Egyptian"] = true;
34495 t.Heather = true;
34496 t.Hercules = true;
34497 t["High Tower Text"] = true;
34498 t.Hiroshige = true;
34499 t["Hoefler Text"] = true;
34500 t["Humana Serif"] = true;
34501 t.Imprint = true;
34502 t["Ionic No. 5"] = true;
34503 t.Janson = true;
34504 t.Joanna = true;
34505 t.Korinna = true;
34506 t.Lexicon = true;
34507 t["Liberation Serif"] = true;
34508 t["Linux Libertine"] = true;
34509 t.Literaturnaya = true;
34510 t.Lucida = true;
34511 t["Lucida Bright"] = true;
34512 t.Melior = true;
34513 t.Memphis = true;
34514 t.Miller = true;
34515 t.Minion = true;
34516 t.Modern = true;
34517 t["Mona Lisa"] = true;
34518 t["Mrs Eaves"] = true;
34519 t["MS Serif"] = true;
34520 t["Museo Slab"] = true;
34521 t["New York"] = true;
34522 t["Nimbus Roman"] = true;
34523 t["NPS Rawlinson Roadway"] = true;
34524 t.NuptialScript = true;
34525 t.Palatino = true;
34526 t.Perpetua = true;
34527 t.Plantin = true;
34528 t["Plantin Schoolbook"] = true;
34529 t.Playbill = true;
34530 t["Poor Richard"] = true;
34531 t["Rawlinson Roadway"] = true;
34532 t.Renault = true;
34533 t.Requiem = true;
34534 t.Rockwell = true;
34535 t.Roman = true;
34536 t["Rotis Serif"] = true;
34537 t.Sabon = true;
34538 t.Scala = true;
34539 t.Seagull = true;
34540 t.Sistina = true;
34541 t.Souvenir = true;
34542 t.STIX = true;
34543 t["Stone Informal"] = true;
34544 t["Stone Serif"] = true;
34545 t.Sylfaen = true;
34546 t.Times = true;
34547 t.Trajan = true;
34548 t["Trinité"] = true;
34549 t["Trump Mediaeval"] = true;
34550 t.Utopia = true;
34551 t["Vale Type"] = true;
34552 t["Bitstream Vera"] = true;
34553 t["Vera Serif"] = true;
34554 t.Versailles = true;
34555 t.Wanted = true;
34556 t.Weiss = true;
34557 t["Wide Latin"] = true;
34558 t.Windsor = true;
34559 t.XITS = true;
34560});
34561exports.getSerifFonts = getSerifFonts;
34562const getSymbolsFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
34563 t.Dingbats = true;
34564 t.Symbol = true;
34565 t.ZapfDingbats = true;
34566});
34567exports.getSymbolsFonts = getSymbolsFonts;
34568const getGlyphMapForStandardFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
34569 t[2] = 10;
34570 t[3] = 32;
34571 t[4] = 33;
34572 t[5] = 34;
34573 t[6] = 35;
34574 t[7] = 36;
34575 t[8] = 37;
34576 t[9] = 38;
34577 t[10] = 39;
34578 t[11] = 40;
34579 t[12] = 41;
34580 t[13] = 42;
34581 t[14] = 43;
34582 t[15] = 44;
34583 t[16] = 45;
34584 t[17] = 46;
34585 t[18] = 47;
34586 t[19] = 48;
34587 t[20] = 49;
34588 t[21] = 50;
34589 t[22] = 51;
34590 t[23] = 52;
34591 t[24] = 53;
34592 t[25] = 54;
34593 t[26] = 55;
34594 t[27] = 56;
34595 t[28] = 57;
34596 t[29] = 58;
34597 t[30] = 894;
34598 t[31] = 60;
34599 t[32] = 61;
34600 t[33] = 62;
34601 t[34] = 63;
34602 t[35] = 64;
34603 t[36] = 65;
34604 t[37] = 66;
34605 t[38] = 67;
34606 t[39] = 68;
34607 t[40] = 69;
34608 t[41] = 70;
34609 t[42] = 71;
34610 t[43] = 72;
34611 t[44] = 73;
34612 t[45] = 74;
34613 t[46] = 75;
34614 t[47] = 76;
34615 t[48] = 77;
34616 t[49] = 78;
34617 t[50] = 79;
34618 t[51] = 80;
34619 t[52] = 81;
34620 t[53] = 82;
34621 t[54] = 83;
34622 t[55] = 84;
34623 t[56] = 85;
34624 t[57] = 86;
34625 t[58] = 87;
34626 t[59] = 88;
34627 t[60] = 89;
34628 t[61] = 90;
34629 t[62] = 91;
34630 t[63] = 92;
34631 t[64] = 93;
34632 t[65] = 94;
34633 t[66] = 95;
34634 t[67] = 96;
34635 t[68] = 97;
34636 t[69] = 98;
34637 t[70] = 99;
34638 t[71] = 100;
34639 t[72] = 101;
34640 t[73] = 102;
34641 t[74] = 103;
34642 t[75] = 104;
34643 t[76] = 105;
34644 t[77] = 106;
34645 t[78] = 107;
34646 t[79] = 108;
34647 t[80] = 109;
34648 t[81] = 110;
34649 t[82] = 111;
34650 t[83] = 112;
34651 t[84] = 113;
34652 t[85] = 114;
34653 t[86] = 115;
34654 t[87] = 116;
34655 t[88] = 117;
34656 t[89] = 118;
34657 t[90] = 119;
34658 t[91] = 120;
34659 t[92] = 121;
34660 t[93] = 122;
34661 t[94] = 123;
34662 t[95] = 124;
34663 t[96] = 125;
34664 t[97] = 126;
34665 t[98] = 196;
34666 t[99] = 197;
34667 t[100] = 199;
34668 t[101] = 201;
34669 t[102] = 209;
34670 t[103] = 214;
34671 t[104] = 220;
34672 t[105] = 225;
34673 t[106] = 224;
34674 t[107] = 226;
34675 t[108] = 228;
34676 t[109] = 227;
34677 t[110] = 229;
34678 t[111] = 231;
34679 t[112] = 233;
34680 t[113] = 232;
34681 t[114] = 234;
34682 t[115] = 235;
34683 t[116] = 237;
34684 t[117] = 236;
34685 t[118] = 238;
34686 t[119] = 239;
34687 t[120] = 241;
34688 t[121] = 243;
34689 t[122] = 242;
34690 t[123] = 244;
34691 t[124] = 246;
34692 t[125] = 245;
34693 t[126] = 250;
34694 t[127] = 249;
34695 t[128] = 251;
34696 t[129] = 252;
34697 t[130] = 8224;
34698 t[131] = 176;
34699 t[132] = 162;
34700 t[133] = 163;
34701 t[134] = 167;
34702 t[135] = 8226;
34703 t[136] = 182;
34704 t[137] = 223;
34705 t[138] = 174;
34706 t[139] = 169;
34707 t[140] = 8482;
34708 t[141] = 180;
34709 t[142] = 168;
34710 t[143] = 8800;
34711 t[144] = 198;
34712 t[145] = 216;
34713 t[146] = 8734;
34714 t[147] = 177;
34715 t[148] = 8804;
34716 t[149] = 8805;
34717 t[150] = 165;
34718 t[151] = 181;
34719 t[152] = 8706;
34720 t[153] = 8721;
34721 t[154] = 8719;
34722 t[156] = 8747;
34723 t[157] = 170;
34724 t[158] = 186;
34725 t[159] = 8486;
34726 t[160] = 230;
34727 t[161] = 248;
34728 t[162] = 191;
34729 t[163] = 161;
34730 t[164] = 172;
34731 t[165] = 8730;
34732 t[166] = 402;
34733 t[167] = 8776;
34734 t[168] = 8710;
34735 t[169] = 171;
34736 t[170] = 187;
34737 t[171] = 8230;
34738 t[210] = 218;
34739 t[223] = 711;
34740 t[224] = 321;
34741 t[225] = 322;
34742 t[227] = 353;
34743 t[229] = 382;
34744 t[234] = 253;
34745 t[252] = 263;
34746 t[253] = 268;
34747 t[254] = 269;
34748 t[258] = 258;
34749 t[260] = 260;
34750 t[261] = 261;
34751 t[265] = 280;
34752 t[266] = 281;
34753 t[268] = 283;
34754 t[269] = 313;
34755 t[275] = 323;
34756 t[276] = 324;
34757 t[278] = 328;
34758 t[284] = 345;
34759 t[285] = 346;
34760 t[286] = 347;
34761 t[292] = 367;
34762 t[295] = 377;
34763 t[296] = 378;
34764 t[298] = 380;
34765 t[305] = 963;
34766 t[306] = 964;
34767 t[307] = 966;
34768 t[308] = 8215;
34769 t[309] = 8252;
34770 t[310] = 8319;
34771 t[311] = 8359;
34772 t[312] = 8592;
34773 t[313] = 8593;
34774 t[337] = 9552;
34775 t[493] = 1039;
34776 t[494] = 1040;
34777 t[705] = 1524;
34778 t[706] = 8362;
34779 t[710] = 64288;
34780 t[711] = 64298;
34781 t[759] = 1617;
34782 t[761] = 1776;
34783 t[763] = 1778;
34784 t[775] = 1652;
34785 t[777] = 1764;
34786 t[778] = 1780;
34787 t[779] = 1781;
34788 t[780] = 1782;
34789 t[782] = 771;
34790 t[783] = 64726;
34791 t[786] = 8363;
34792 t[788] = 8532;
34793 t[790] = 768;
34794 t[791] = 769;
34795 t[792] = 768;
34796 t[795] = 803;
34797 t[797] = 64336;
34798 t[798] = 64337;
34799 t[799] = 64342;
34800 t[800] = 64343;
34801 t[801] = 64344;
34802 t[802] = 64345;
34803 t[803] = 64362;
34804 t[804] = 64363;
34805 t[805] = 64364;
34806 t[2424] = 7821;
34807 t[2425] = 7822;
34808 t[2426] = 7823;
34809 t[2427] = 7824;
34810 t[2428] = 7825;
34811 t[2429] = 7826;
34812 t[2430] = 7827;
34813 t[2433] = 7682;
34814 t[2678] = 8045;
34815 t[2679] = 8046;
34816 t[2830] = 1552;
34817 t[2838] = 686;
34818 t[2840] = 751;
34819 t[2842] = 753;
34820 t[2843] = 754;
34821 t[2844] = 755;
34822 t[2846] = 757;
34823 t[2856] = 767;
34824 t[2857] = 848;
34825 t[2858] = 849;
34826 t[2862] = 853;
34827 t[2863] = 854;
34828 t[2864] = 855;
34829 t[2865] = 861;
34830 t[2866] = 862;
34831 t[2906] = 7460;
34832 t[2908] = 7462;
34833 t[2909] = 7463;
34834 t[2910] = 7464;
34835 t[2912] = 7466;
34836 t[2913] = 7467;
34837 t[2914] = 7468;
34838 t[2916] = 7470;
34839 t[2917] = 7471;
34840 t[2918] = 7472;
34841 t[2920] = 7474;
34842 t[2921] = 7475;
34843 t[2922] = 7476;
34844 t[2924] = 7478;
34845 t[2925] = 7479;
34846 t[2926] = 7480;
34847 t[2928] = 7482;
34848 t[2929] = 7483;
34849 t[2930] = 7484;
34850 t[2932] = 7486;
34851 t[2933] = 7487;
34852 t[2934] = 7488;
34853 t[2936] = 7490;
34854 t[2937] = 7491;
34855 t[2938] = 7492;
34856 t[2940] = 7494;
34857 t[2941] = 7495;
34858 t[2942] = 7496;
34859 t[2944] = 7498;
34860 t[2946] = 7500;
34861 t[2948] = 7502;
34862 t[2950] = 7504;
34863 t[2951] = 7505;
34864 t[2952] = 7506;
34865 t[2954] = 7508;
34866 t[2955] = 7509;
34867 t[2956] = 7510;
34868 t[2958] = 7512;
34869 t[2959] = 7513;
34870 t[2960] = 7514;
34871 t[2962] = 7516;
34872 t[2963] = 7517;
34873 t[2964] = 7518;
34874 t[2966] = 7520;
34875 t[2967] = 7521;
34876 t[2968] = 7522;
34877 t[2970] = 7524;
34878 t[2971] = 7525;
34879 t[2972] = 7526;
34880 t[2974] = 7528;
34881 t[2975] = 7529;
34882 t[2976] = 7530;
34883 t[2978] = 1537;
34884 t[2979] = 1538;
34885 t[2980] = 1539;
34886 t[2982] = 1549;
34887 t[2983] = 1551;
34888 t[2984] = 1552;
34889 t[2986] = 1554;
34890 t[2987] = 1555;
34891 t[2988] = 1556;
34892 t[2990] = 1623;
34893 t[2991] = 1624;
34894 t[2995] = 1775;
34895 t[2999] = 1791;
34896 t[3002] = 64290;
34897 t[3003] = 64291;
34898 t[3004] = 64292;
34899 t[3006] = 64294;
34900 t[3007] = 64295;
34901 t[3008] = 64296;
34902 t[3011] = 1900;
34903 t[3014] = 8223;
34904 t[3015] = 8244;
34905 t[3017] = 7532;
34906 t[3018] = 7533;
34907 t[3019] = 7534;
34908 t[3075] = 7590;
34909 t[3076] = 7591;
34910 t[3079] = 7594;
34911 t[3080] = 7595;
34912 t[3083] = 7598;
34913 t[3084] = 7599;
34914 t[3087] = 7602;
34915 t[3088] = 7603;
34916 t[3091] = 7606;
34917 t[3092] = 7607;
34918 t[3095] = 7610;
34919 t[3096] = 7611;
34920 t[3099] = 7614;
34921 t[3100] = 7615;
34922 t[3103] = 7618;
34923 t[3104] = 7619;
34924 t[3107] = 8337;
34925 t[3108] = 8338;
34926 t[3116] = 1884;
34927 t[3119] = 1885;
34928 t[3120] = 1885;
34929 t[3123] = 1886;
34930 t[3124] = 1886;
34931 t[3127] = 1887;
34932 t[3128] = 1887;
34933 t[3131] = 1888;
34934 t[3132] = 1888;
34935 t[3135] = 1889;
34936 t[3136] = 1889;
34937 t[3139] = 1890;
34938 t[3140] = 1890;
34939 t[3143] = 1891;
34940 t[3144] = 1891;
34941 t[3147] = 1892;
34942 t[3148] = 1892;
34943 t[3153] = 580;
34944 t[3154] = 581;
34945 t[3157] = 584;
34946 t[3158] = 585;
34947 t[3161] = 588;
34948 t[3162] = 589;
34949 t[3165] = 891;
34950 t[3166] = 892;
34951 t[3169] = 1274;
34952 t[3170] = 1275;
34953 t[3173] = 1278;
34954 t[3174] = 1279;
34955 t[3181] = 7622;
34956 t[3182] = 7623;
34957 t[3282] = 11799;
34958 t[3316] = 578;
34959 t[3379] = 42785;
34960 t[3393] = 1159;
34961 t[3416] = 8377;
34962});
34963exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
34964const getSupplementalGlyphMapForArialBlack = (0, _core_utils.getLookupTableFactory)(function (t) {
34965 t[227] = 322;
34966 t[264] = 261;
34967 t[291] = 346;
34968});
34969exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
34970const getSupplementalGlyphMapForCalibri = (0, _core_utils.getLookupTableFactory)(function (t) {
34971 t[1] = 32;
34972 t[4] = 65;
34973 t[17] = 66;
34974 t[18] = 67;
34975 t[24] = 68;
34976 t[28] = 69;
34977 t[38] = 70;
34978 t[39] = 71;
34979 t[44] = 72;
34980 t[47] = 73;
34981 t[58] = 74;
34982 t[60] = 75;
34983 t[62] = 76;
34984 t[68] = 77;
34985 t[69] = 78;
34986 t[75] = 79;
34987 t[87] = 80;
34988 t[89] = 81;
34989 t[90] = 82;
34990 t[94] = 83;
34991 t[100] = 84;
34992 t[104] = 85;
34993 t[115] = 86;
34994 t[116] = 87;
34995 t[121] = 88;
34996 t[122] = 89;
34997 t[127] = 90;
34998 t[258] = 97;
34999 t[268] = 261;
35000 t[271] = 98;
35001 t[272] = 99;
35002 t[273] = 263;
35003 t[282] = 100;
35004 t[286] = 101;
35005 t[295] = 281;
35006 t[296] = 102;
35007 t[336] = 103;
35008 t[346] = 104;
35009 t[349] = 105;
35010 t[361] = 106;
35011 t[364] = 107;
35012 t[367] = 108;
35013 t[371] = 322;
35014 t[373] = 109;
35015 t[374] = 110;
35016 t[381] = 111;
35017 t[383] = 243;
35018 t[393] = 112;
35019 t[395] = 113;
35020 t[396] = 114;
35021 t[400] = 115;
35022 t[401] = 347;
35023 t[410] = 116;
35024 t[437] = 117;
35025 t[448] = 118;
35026 t[449] = 119;
35027 t[454] = 120;
35028 t[455] = 121;
35029 t[460] = 122;
35030 t[463] = 380;
35031 t[853] = 44;
35032 t[855] = 58;
35033 t[856] = 46;
35034 t[876] = 47;
35035 t[878] = 45;
35036 t[882] = 45;
35037 t[894] = 40;
35038 t[895] = 41;
35039 t[896] = 91;
35040 t[897] = 93;
35041 t[923] = 64;
35042 t[1004] = 48;
35043 t[1005] = 49;
35044 t[1006] = 50;
35045 t[1007] = 51;
35046 t[1008] = 52;
35047 t[1009] = 53;
35048 t[1010] = 54;
35049 t[1011] = 55;
35050 t[1012] = 56;
35051 t[1013] = 57;
35052 t[1081] = 37;
35053 t[1085] = 43;
35054 t[1086] = 45;
35055});
35056exports.getSupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri;
35057
35058/***/ }),
35059/* 35 */
35060/***/ (function(module, exports, __w_pdfjs_require__) {
35061
35062var getLookupTableFactory = __w_pdfjs_require__(8).getLookupTableFactory;
35063var getSpecialPUASymbols = getLookupTableFactory(function (t) {
35064 t[63721] = 0x00a9;
35065 t[63193] = 0x00a9;
35066 t[63720] = 0x00ae;
35067 t[63194] = 0x00ae;
35068 t[63722] = 0x2122;
35069 t[63195] = 0x2122;
35070 t[63729] = 0x23a7;
35071 t[63730] = 0x23a8;
35072 t[63731] = 0x23a9;
35073 t[63740] = 0x23ab;
35074 t[63741] = 0x23ac;
35075 t[63742] = 0x23ad;
35076 t[63726] = 0x23a1;
35077 t[63727] = 0x23a2;
35078 t[63728] = 0x23a3;
35079 t[63737] = 0x23a4;
35080 t[63738] = 0x23a5;
35081 t[63739] = 0x23a6;
35082 t[63723] = 0x239b;
35083 t[63724] = 0x239c;
35084 t[63725] = 0x239d;
35085 t[63734] = 0x239e;
35086 t[63735] = 0x239f;
35087 t[63736] = 0x23a0;
35088});
35089function mapSpecialUnicodeValues(code) {
35090 if (code >= 0xfff0 && code <= 0xffff) {
35091 return 0;
35092 } else if (code >= 0xf600 && code <= 0xf8ff) {
35093 return getSpecialPUASymbols()[code] || code;
35094 } else if (code === 0x00ad) {
35095 return 0x002d;
35096 }
35097 return code;
35098}
35099function getUnicodeForGlyph(name, glyphsUnicodeMap) {
35100 var unicode = glyphsUnicodeMap[name];
35101 if (unicode !== undefined) {
35102 return unicode;
35103 }
35104 if (!name) {
35105 return -1;
35106 }
35107 if (name[0] === "u") {
35108 var nameLen = name.length, hexStr;
35109 if (nameLen === 7 && name[1] === "n" && name[2] === "i") {
35110 hexStr = name.substring(3);
35111 } else if (nameLen >= 5 && nameLen <= 7) {
35112 hexStr = name.substring(1);
35113 } else {
35114 return -1;
35115 }
35116 if (hexStr === hexStr.toUpperCase()) {
35117 unicode = parseInt(hexStr, 16);
35118 if (unicode >= 0) {
35119 return unicode;
35120 }
35121 }
35122 }
35123 return -1;
35124}
35125var UnicodeRanges = [
35126 {
35127 begin: 0x0000,
35128 end: 0x007f
35129 },
35130 {
35131 begin: 0x0080,
35132 end: 0x00ff
35133 },
35134 {
35135 begin: 0x0100,
35136 end: 0x017f
35137 },
35138 {
35139 begin: 0x0180,
35140 end: 0x024f
35141 },
35142 {
35143 begin: 0x0250,
35144 end: 0x02af
35145 },
35146 {
35147 begin: 0x02b0,
35148 end: 0x02ff
35149 },
35150 {
35151 begin: 0x0300,
35152 end: 0x036f
35153 },
35154 {
35155 begin: 0x0370,
35156 end: 0x03ff
35157 },
35158 {
35159 begin: 0x2c80,
35160 end: 0x2cff
35161 },
35162 {
35163 begin: 0x0400,
35164 end: 0x04ff
35165 },
35166 {
35167 begin: 0x0530,
35168 end: 0x058f
35169 },
35170 {
35171 begin: 0x0590,
35172 end: 0x05ff
35173 },
35174 {
35175 begin: 0xa500,
35176 end: 0xa63f
35177 },
35178 {
35179 begin: 0x0600,
35180 end: 0x06ff
35181 },
35182 {
35183 begin: 0x07c0,
35184 end: 0x07ff
35185 },
35186 {
35187 begin: 0x0900,
35188 end: 0x097f
35189 },
35190 {
35191 begin: 0x0980,
35192 end: 0x09ff
35193 },
35194 {
35195 begin: 0x0a00,
35196 end: 0x0a7f
35197 },
35198 {
35199 begin: 0x0a80,
35200 end: 0x0aff
35201 },
35202 {
35203 begin: 0x0b00,
35204 end: 0x0b7f
35205 },
35206 {
35207 begin: 0x0b80,
35208 end: 0x0bff
35209 },
35210 {
35211 begin: 0x0c00,
35212 end: 0x0c7f
35213 },
35214 {
35215 begin: 0x0c80,
35216 end: 0x0cff
35217 },
35218 {
35219 begin: 0x0d00,
35220 end: 0x0d7f
35221 },
35222 {
35223 begin: 0x0e00,
35224 end: 0x0e7f
35225 },
35226 {
35227 begin: 0x0e80,
35228 end: 0x0eff
35229 },
35230 {
35231 begin: 0x10a0,
35232 end: 0x10ff
35233 },
35234 {
35235 begin: 0x1b00,
35236 end: 0x1b7f
35237 },
35238 {
35239 begin: 0x1100,
35240 end: 0x11ff
35241 },
35242 {
35243 begin: 0x1e00,
35244 end: 0x1eff
35245 },
35246 {
35247 begin: 0x1f00,
35248 end: 0x1fff
35249 },
35250 {
35251 begin: 0x2000,
35252 end: 0x206f
35253 },
35254 {
35255 begin: 0x2070,
35256 end: 0x209f
35257 },
35258 {
35259 begin: 0x20a0,
35260 end: 0x20cf
35261 },
35262 {
35263 begin: 0x20d0,
35264 end: 0x20ff
35265 },
35266 {
35267 begin: 0x2100,
35268 end: 0x214f
35269 },
35270 {
35271 begin: 0x2150,
35272 end: 0x218f
35273 },
35274 {
35275 begin: 0x2190,
35276 end: 0x21ff
35277 },
35278 {
35279 begin: 0x2200,
35280 end: 0x22ff
35281 },
35282 {
35283 begin: 0x2300,
35284 end: 0x23ff
35285 },
35286 {
35287 begin: 0x2400,
35288 end: 0x243f
35289 },
35290 {
35291 begin: 0x2440,
35292 end: 0x245f
35293 },
35294 {
35295 begin: 0x2460,
35296 end: 0x24ff
35297 },
35298 {
35299 begin: 0x2500,
35300 end: 0x257f
35301 },
35302 {
35303 begin: 0x2580,
35304 end: 0x259f
35305 },
35306 {
35307 begin: 0x25a0,
35308 end: 0x25ff
35309 },
35310 {
35311 begin: 0x2600,
35312 end: 0x26ff
35313 },
35314 {
35315 begin: 0x2700,
35316 end: 0x27bf
35317 },
35318 {
35319 begin: 0x3000,
35320 end: 0x303f
35321 },
35322 {
35323 begin: 0x3040,
35324 end: 0x309f
35325 },
35326 {
35327 begin: 0x30a0,
35328 end: 0x30ff
35329 },
35330 {
35331 begin: 0x3100,
35332 end: 0x312f
35333 },
35334 {
35335 begin: 0x3130,
35336 end: 0x318f
35337 },
35338 {
35339 begin: 0xa840,
35340 end: 0xa87f
35341 },
35342 {
35343 begin: 0x3200,
35344 end: 0x32ff
35345 },
35346 {
35347 begin: 0x3300,
35348 end: 0x33ff
35349 },
35350 {
35351 begin: 0xac00,
35352 end: 0xd7af
35353 },
35354 {
35355 begin: 0xd800,
35356 end: 0xdfff
35357 },
35358 {
35359 begin: 0x10900,
35360 end: 0x1091f
35361 },
35362 {
35363 begin: 0x4e00,
35364 end: 0x9fff
35365 },
35366 {
35367 begin: 0xe000,
35368 end: 0xf8ff
35369 },
35370 {
35371 begin: 0x31c0,
35372 end: 0x31ef
35373 },
35374 {
35375 begin: 0xfb00,
35376 end: 0xfb4f
35377 },
35378 {
35379 begin: 0xfb50,
35380 end: 0xfdff
35381 },
35382 {
35383 begin: 0xfe20,
35384 end: 0xfe2f
35385 },
35386 {
35387 begin: 0xfe10,
35388 end: 0xfe1f
35389 },
35390 {
35391 begin: 0xfe50,
35392 end: 0xfe6f
35393 },
35394 {
35395 begin: 0xfe70,
35396 end: 0xfeff
35397 },
35398 {
35399 begin: 0xff00,
35400 end: 0xffef
35401 },
35402 {
35403 begin: 0xfff0,
35404 end: 0xffff
35405 },
35406 {
35407 begin: 0x0f00,
35408 end: 0x0fff
35409 },
35410 {
35411 begin: 0x0700,
35412 end: 0x074f
35413 },
35414 {
35415 begin: 0x0780,
35416 end: 0x07bf
35417 },
35418 {
35419 begin: 0x0d80,
35420 end: 0x0dff
35421 },
35422 {
35423 begin: 0x1000,
35424 end: 0x109f
35425 },
35426 {
35427 begin: 0x1200,
35428 end: 0x137f
35429 },
35430 {
35431 begin: 0x13a0,
35432 end: 0x13ff
35433 },
35434 {
35435 begin: 0x1400,
35436 end: 0x167f
35437 },
35438 {
35439 begin: 0x1680,
35440 end: 0x169f
35441 },
35442 {
35443 begin: 0x16a0,
35444 end: 0x16ff
35445 },
35446 {
35447 begin: 0x1780,
35448 end: 0x17ff
35449 },
35450 {
35451 begin: 0x1800,
35452 end: 0x18af
35453 },
35454 {
35455 begin: 0x2800,
35456 end: 0x28ff
35457 },
35458 {
35459 begin: 0xa000,
35460 end: 0xa48f
35461 },
35462 {
35463 begin: 0x1700,
35464 end: 0x171f
35465 },
35466 {
35467 begin: 0x10300,
35468 end: 0x1032f
35469 },
35470 {
35471 begin: 0x10330,
35472 end: 0x1034f
35473 },
35474 {
35475 begin: 0x10400,
35476 end: 0x1044f
35477 },
35478 {
35479 begin: 0x1d000,
35480 end: 0x1d0ff
35481 },
35482 {
35483 begin: 0x1d400,
35484 end: 0x1d7ff
35485 },
35486 {
35487 begin: 0xff000,
35488 end: 0xffffd
35489 },
35490 {
35491 begin: 0xfe00,
35492 end: 0xfe0f
35493 },
35494 {
35495 begin: 0xe0000,
35496 end: 0xe007f
35497 },
35498 {
35499 begin: 0x1900,
35500 end: 0x194f
35501 },
35502 {
35503 begin: 0x1950,
35504 end: 0x197f
35505 },
35506 {
35507 begin: 0x1980,
35508 end: 0x19df
35509 },
35510 {
35511 begin: 0x1a00,
35512 end: 0x1a1f
35513 },
35514 {
35515 begin: 0x2c00,
35516 end: 0x2c5f
35517 },
35518 {
35519 begin: 0x2d30,
35520 end: 0x2d7f
35521 },
35522 {
35523 begin: 0x4dc0,
35524 end: 0x4dff
35525 },
35526 {
35527 begin: 0xa800,
35528 end: 0xa82f
35529 },
35530 {
35531 begin: 0x10000,
35532 end: 0x1007f
35533 },
35534 {
35535 begin: 0x10140,
35536 end: 0x1018f
35537 },
35538 {
35539 begin: 0x10380,
35540 end: 0x1039f
35541 },
35542 {
35543 begin: 0x103a0,
35544 end: 0x103df
35545 },
35546 {
35547 begin: 0x10450,
35548 end: 0x1047f
35549 },
35550 {
35551 begin: 0x10480,
35552 end: 0x104af
35553 },
35554 {
35555 begin: 0x10800,
35556 end: 0x1083f
35557 },
35558 {
35559 begin: 0x10a00,
35560 end: 0x10a5f
35561 },
35562 {
35563 begin: 0x1d300,
35564 end: 0x1d35f
35565 },
35566 {
35567 begin: 0x12000,
35568 end: 0x123ff
35569 },
35570 {
35571 begin: 0x1d360,
35572 end: 0x1d37f
35573 },
35574 {
35575 begin: 0x1b80,
35576 end: 0x1bbf
35577 },
35578 {
35579 begin: 0x1c00,
35580 end: 0x1c4f
35581 },
35582 {
35583 begin: 0x1c50,
35584 end: 0x1c7f
35585 },
35586 {
35587 begin: 0xa880,
35588 end: 0xa8df
35589 },
35590 {
35591 begin: 0xa900,
35592 end: 0xa92f
35593 },
35594 {
35595 begin: 0xa930,
35596 end: 0xa95f
35597 },
35598 {
35599 begin: 0xaa00,
35600 end: 0xaa5f
35601 },
35602 {
35603 begin: 0x10190,
35604 end: 0x101cf
35605 },
35606 {
35607 begin: 0x101d0,
35608 end: 0x101ff
35609 },
35610 {
35611 begin: 0x102a0,
35612 end: 0x102df
35613 },
35614 {
35615 begin: 0x1f030,
35616 end: 0x1f09f
35617 }
35618];
35619function getUnicodeRangeFor(value) {
35620 for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
35621 var range = UnicodeRanges[i];
35622 if (value >= range.begin && value < range.end) {
35623 return i;
35624 }
35625 }
35626 return -1;
35627}
35628function isRTLRangeFor(value) {
35629 var range = UnicodeRanges[13];
35630 if (value >= range.begin && value < range.end) {
35631 return true;
35632 }
35633 range = UnicodeRanges[11];
35634 if (value >= range.begin && value < range.end) {
35635 return true;
35636 }
35637 return false;
35638}
35639var getNormalizedUnicodes = getLookupTableFactory(function (t) {
35640 t["\u00A8"] = "\u0020\u0308";
35641 t["\u00AF"] = "\u0020\u0304";
35642 t["\u00B4"] = "\u0020\u0301";
35643 t["\u00B5"] = "\u03BC";
35644 t["\u00B8"] = "\u0020\u0327";
35645 t["\u0132"] = "\u0049\u004A";
35646 t["\u0133"] = "\u0069\u006A";
35647 t["\u013F"] = "\u004C\u00B7";
35648 t["\u0140"] = "\u006C\u00B7";
35649 t["\u0149"] = "\u02BC\u006E";
35650 t["\u017F"] = "\u0073";
35651 t["\u01C4"] = "\u0044\u017D";
35652 t["\u01C5"] = "\u0044\u017E";
35653 t["\u01C6"] = "\u0064\u017E";
35654 t["\u01C7"] = "\u004C\u004A";
35655 t["\u01C8"] = "\u004C\u006A";
35656 t["\u01C9"] = "\u006C\u006A";
35657 t["\u01CA"] = "\u004E\u004A";
35658 t["\u01CB"] = "\u004E\u006A";
35659 t["\u01CC"] = "\u006E\u006A";
35660 t["\u01F1"] = "\u0044\u005A";
35661 t["\u01F2"] = "\u0044\u007A";
35662 t["\u01F3"] = "\u0064\u007A";
35663 t["\u02D8"] = "\u0020\u0306";
35664 t["\u02D9"] = "\u0020\u0307";
35665 t["\u02DA"] = "\u0020\u030A";
35666 t["\u02DB"] = "\u0020\u0328";
35667 t["\u02DC"] = "\u0020\u0303";
35668 t["\u02DD"] = "\u0020\u030B";
35669 t["\u037A"] = "\u0020\u0345";
35670 t["\u0384"] = "\u0020\u0301";
35671 t["\u03D0"] = "\u03B2";
35672 t["\u03D1"] = "\u03B8";
35673 t["\u03D2"] = "\u03A5";
35674 t["\u03D5"] = "\u03C6";
35675 t["\u03D6"] = "\u03C0";
35676 t["\u03F0"] = "\u03BA";
35677 t["\u03F1"] = "\u03C1";
35678 t["\u03F2"] = "\u03C2";
35679 t["\u03F4"] = "\u0398";
35680 t["\u03F5"] = "\u03B5";
35681 t["\u03F9"] = "\u03A3";
35682 t["\u0587"] = "\u0565\u0582";
35683 t["\u0675"] = "\u0627\u0674";
35684 t["\u0676"] = "\u0648\u0674";
35685 t["\u0677"] = "\u06C7\u0674";
35686 t["\u0678"] = "\u064A\u0674";
35687 t["\u0E33"] = "\u0E4D\u0E32";
35688 t["\u0EB3"] = "\u0ECD\u0EB2";
35689 t["\u0EDC"] = "\u0EAB\u0E99";
35690 t["\u0EDD"] = "\u0EAB\u0EA1";
35691 t["\u0F77"] = "\u0FB2\u0F81";
35692 t["\u0F79"] = "\u0FB3\u0F81";
35693 t["\u1E9A"] = "\u0061\u02BE";
35694 t["\u1FBD"] = "\u0020\u0313";
35695 t["\u1FBF"] = "\u0020\u0313";
35696 t["\u1FC0"] = "\u0020\u0342";
35697 t["\u1FFE"] = "\u0020\u0314";
35698 t["\u2002"] = "\u0020";
35699 t["\u2003"] = "\u0020";
35700 t["\u2004"] = "\u0020";
35701 t["\u2005"] = "\u0020";
35702 t["\u2006"] = "\u0020";
35703 t["\u2008"] = "\u0020";
35704 t["\u2009"] = "\u0020";
35705 t["\u200A"] = "\u0020";
35706 t["\u2017"] = "\u0020\u0333";
35707 t["\u2024"] = "\u002E";
35708 t["\u2025"] = "\u002E\u002E";
35709 t["\u2026"] = "\u002E\u002E\u002E";
35710 t["\u2033"] = "\u2032\u2032";
35711 t["\u2034"] = "\u2032\u2032\u2032";
35712 t["\u2036"] = "\u2035\u2035";
35713 t["\u2037"] = "\u2035\u2035\u2035";
35714 t["\u203C"] = "\u0021\u0021";
35715 t["\u203E"] = "\u0020\u0305";
35716 t["\u2047"] = "\u003F\u003F";
35717 t["\u2048"] = "\u003F\u0021";
35718 t["\u2049"] = "\u0021\u003F";
35719 t["\u2057"] = "\u2032\u2032\u2032\u2032";
35720 t["\u205F"] = "\u0020";
35721 t["\u20A8"] = "\u0052\u0073";
35722 t["\u2100"] = "\u0061\u002F\u0063";
35723 t["\u2101"] = "\u0061\u002F\u0073";
35724 t["\u2103"] = "\u00B0\u0043";
35725 t["\u2105"] = "\u0063\u002F\u006F";
35726 t["\u2106"] = "\u0063\u002F\u0075";
35727 t["\u2107"] = "\u0190";
35728 t["\u2109"] = "\u00B0\u0046";
35729 t["\u2116"] = "\u004E\u006F";
35730 t["\u2121"] = "\u0054\u0045\u004C";
35731 t["\u2135"] = "\u05D0";
35732 t["\u2136"] = "\u05D1";
35733 t["\u2137"] = "\u05D2";
35734 t["\u2138"] = "\u05D3";
35735 t["\u213B"] = "\u0046\u0041\u0058";
35736 t["\u2160"] = "\u0049";
35737 t["\u2161"] = "\u0049\u0049";
35738 t["\u2162"] = "\u0049\u0049\u0049";
35739 t["\u2163"] = "\u0049\u0056";
35740 t["\u2164"] = "\u0056";
35741 t["\u2165"] = "\u0056\u0049";
35742 t["\u2166"] = "\u0056\u0049\u0049";
35743 t["\u2167"] = "\u0056\u0049\u0049\u0049";
35744 t["\u2168"] = "\u0049\u0058";
35745 t["\u2169"] = "\u0058";
35746 t["\u216A"] = "\u0058\u0049";
35747 t["\u216B"] = "\u0058\u0049\u0049";
35748 t["\u216C"] = "\u004C";
35749 t["\u216D"] = "\u0043";
35750 t["\u216E"] = "\u0044";
35751 t["\u216F"] = "\u004D";
35752 t["\u2170"] = "\u0069";
35753 t["\u2171"] = "\u0069\u0069";
35754 t["\u2172"] = "\u0069\u0069\u0069";
35755 t["\u2173"] = "\u0069\u0076";
35756 t["\u2174"] = "\u0076";
35757 t["\u2175"] = "\u0076\u0069";
35758 t["\u2176"] = "\u0076\u0069\u0069";
35759 t["\u2177"] = "\u0076\u0069\u0069\u0069";
35760 t["\u2178"] = "\u0069\u0078";
35761 t["\u2179"] = "\u0078";
35762 t["\u217A"] = "\u0078\u0069";
35763 t["\u217B"] = "\u0078\u0069\u0069";
35764 t["\u217C"] = "\u006C";
35765 t["\u217D"] = "\u0063";
35766 t["\u217E"] = "\u0064";
35767 t["\u217F"] = "\u006D";
35768 t["\u222C"] = "\u222B\u222B";
35769 t["\u222D"] = "\u222B\u222B\u222B";
35770 t["\u222F"] = "\u222E\u222E";
35771 t["\u2230"] = "\u222E\u222E\u222E";
35772 t["\u2474"] = "\u0028\u0031\u0029";
35773 t["\u2475"] = "\u0028\u0032\u0029";
35774 t["\u2476"] = "\u0028\u0033\u0029";
35775 t["\u2477"] = "\u0028\u0034\u0029";
35776 t["\u2478"] = "\u0028\u0035\u0029";
35777 t["\u2479"] = "\u0028\u0036\u0029";
35778 t["\u247A"] = "\u0028\u0037\u0029";
35779 t["\u247B"] = "\u0028\u0038\u0029";
35780 t["\u247C"] = "\u0028\u0039\u0029";
35781 t["\u247D"] = "\u0028\u0031\u0030\u0029";
35782 t["\u247E"] = "\u0028\u0031\u0031\u0029";
35783 t["\u247F"] = "\u0028\u0031\u0032\u0029";
35784 t["\u2480"] = "\u0028\u0031\u0033\u0029";
35785 t["\u2481"] = "\u0028\u0031\u0034\u0029";
35786 t["\u2482"] = "\u0028\u0031\u0035\u0029";
35787 t["\u2483"] = "\u0028\u0031\u0036\u0029";
35788 t["\u2484"] = "\u0028\u0031\u0037\u0029";
35789 t["\u2485"] = "\u0028\u0031\u0038\u0029";
35790 t["\u2486"] = "\u0028\u0031\u0039\u0029";
35791 t["\u2487"] = "\u0028\u0032\u0030\u0029";
35792 t["\u2488"] = "\u0031\u002E";
35793 t["\u2489"] = "\u0032\u002E";
35794 t["\u248A"] = "\u0033\u002E";
35795 t["\u248B"] = "\u0034\u002E";
35796 t["\u248C"] = "\u0035\u002E";
35797 t["\u248D"] = "\u0036\u002E";
35798 t["\u248E"] = "\u0037\u002E";
35799 t["\u248F"] = "\u0038\u002E";
35800 t["\u2490"] = "\u0039\u002E";
35801 t["\u2491"] = "\u0031\u0030\u002E";
35802 t["\u2492"] = "\u0031\u0031\u002E";
35803 t["\u2493"] = "\u0031\u0032\u002E";
35804 t["\u2494"] = "\u0031\u0033\u002E";
35805 t["\u2495"] = "\u0031\u0034\u002E";
35806 t["\u2496"] = "\u0031\u0035\u002E";
35807 t["\u2497"] = "\u0031\u0036\u002E";
35808 t["\u2498"] = "\u0031\u0037\u002E";
35809 t["\u2499"] = "\u0031\u0038\u002E";
35810 t["\u249A"] = "\u0031\u0039\u002E";
35811 t["\u249B"] = "\u0032\u0030\u002E";
35812 t["\u249C"] = "\u0028\u0061\u0029";
35813 t["\u249D"] = "\u0028\u0062\u0029";
35814 t["\u249E"] = "\u0028\u0063\u0029";
35815 t["\u249F"] = "\u0028\u0064\u0029";
35816 t["\u24A0"] = "\u0028\u0065\u0029";
35817 t["\u24A1"] = "\u0028\u0066\u0029";
35818 t["\u24A2"] = "\u0028\u0067\u0029";
35819 t["\u24A3"] = "\u0028\u0068\u0029";
35820 t["\u24A4"] = "\u0028\u0069\u0029";
35821 t["\u24A5"] = "\u0028\u006A\u0029";
35822 t["\u24A6"] = "\u0028\u006B\u0029";
35823 t["\u24A7"] = "\u0028\u006C\u0029";
35824 t["\u24A8"] = "\u0028\u006D\u0029";
35825 t["\u24A9"] = "\u0028\u006E\u0029";
35826 t["\u24AA"] = "\u0028\u006F\u0029";
35827 t["\u24AB"] = "\u0028\u0070\u0029";
35828 t["\u24AC"] = "\u0028\u0071\u0029";
35829 t["\u24AD"] = "\u0028\u0072\u0029";
35830 t["\u24AE"] = "\u0028\u0073\u0029";
35831 t["\u24AF"] = "\u0028\u0074\u0029";
35832 t["\u24B0"] = "\u0028\u0075\u0029";
35833 t["\u24B1"] = "\u0028\u0076\u0029";
35834 t["\u24B2"] = "\u0028\u0077\u0029";
35835 t["\u24B3"] = "\u0028\u0078\u0029";
35836 t["\u24B4"] = "\u0028\u0079\u0029";
35837 t["\u24B5"] = "\u0028\u007A\u0029";
35838 t["\u2A0C"] = "\u222B\u222B\u222B\u222B";
35839 t["\u2A74"] = "\u003A\u003A\u003D";
35840 t["\u2A75"] = "\u003D\u003D";
35841 t["\u2A76"] = "\u003D\u003D\u003D";
35842 t["\u2E9F"] = "\u6BCD";
35843 t["\u2EF3"] = "\u9F9F";
35844 t["\u2F00"] = "\u4E00";
35845 t["\u2F01"] = "\u4E28";
35846 t["\u2F02"] = "\u4E36";
35847 t["\u2F03"] = "\u4E3F";
35848 t["\u2F04"] = "\u4E59";
35849 t["\u2F05"] = "\u4E85";
35850 t["\u2F06"] = "\u4E8C";
35851 t["\u2F07"] = "\u4EA0";
35852 t["\u2F08"] = "\u4EBA";
35853 t["\u2F09"] = "\u513F";
35854 t["\u2F0A"] = "\u5165";
35855 t["\u2F0B"] = "\u516B";
35856 t["\u2F0C"] = "\u5182";
35857 t["\u2F0D"] = "\u5196";
35858 t["\u2F0E"] = "\u51AB";
35859 t["\u2F0F"] = "\u51E0";
35860 t["\u2F10"] = "\u51F5";
35861 t["\u2F11"] = "\u5200";
35862 t["\u2F12"] = "\u529B";
35863 t["\u2F13"] = "\u52F9";
35864 t["\u2F14"] = "\u5315";
35865 t["\u2F15"] = "\u531A";
35866 t["\u2F16"] = "\u5338";
35867 t["\u2F17"] = "\u5341";
35868 t["\u2F18"] = "\u535C";
35869 t["\u2F19"] = "\u5369";
35870 t["\u2F1A"] = "\u5382";
35871 t["\u2F1B"] = "\u53B6";
35872 t["\u2F1C"] = "\u53C8";
35873 t["\u2F1D"] = "\u53E3";
35874 t["\u2F1E"] = "\u56D7";
35875 t["\u2F1F"] = "\u571F";
35876 t["\u2F20"] = "\u58EB";
35877 t["\u2F21"] = "\u5902";
35878 t["\u2F22"] = "\u590A";
35879 t["\u2F23"] = "\u5915";
35880 t["\u2F24"] = "\u5927";
35881 t["\u2F25"] = "\u5973";
35882 t["\u2F26"] = "\u5B50";
35883 t["\u2F27"] = "\u5B80";
35884 t["\u2F28"] = "\u5BF8";
35885 t["\u2F29"] = "\u5C0F";
35886 t["\u2F2A"] = "\u5C22";
35887 t["\u2F2B"] = "\u5C38";
35888 t["\u2F2C"] = "\u5C6E";
35889 t["\u2F2D"] = "\u5C71";
35890 t["\u2F2E"] = "\u5DDB";
35891 t["\u2F2F"] = "\u5DE5";
35892 t["\u2F30"] = "\u5DF1";
35893 t["\u2F31"] = "\u5DFE";
35894 t["\u2F32"] = "\u5E72";
35895 t["\u2F33"] = "\u5E7A";
35896 t["\u2F34"] = "\u5E7F";
35897 t["\u2F35"] = "\u5EF4";
35898 t["\u2F36"] = "\u5EFE";
35899 t["\u2F37"] = "\u5F0B";
35900 t["\u2F38"] = "\u5F13";
35901 t["\u2F39"] = "\u5F50";
35902 t["\u2F3A"] = "\u5F61";
35903 t["\u2F3B"] = "\u5F73";
35904 t["\u2F3C"] = "\u5FC3";
35905 t["\u2F3D"] = "\u6208";
35906 t["\u2F3E"] = "\u6236";
35907 t["\u2F3F"] = "\u624B";
35908 t["\u2F40"] = "\u652F";
35909 t["\u2F41"] = "\u6534";
35910 t["\u2F42"] = "\u6587";
35911 t["\u2F43"] = "\u6597";
35912 t["\u2F44"] = "\u65A4";
35913 t["\u2F45"] = "\u65B9";
35914 t["\u2F46"] = "\u65E0";
35915 t["\u2F47"] = "\u65E5";
35916 t["\u2F48"] = "\u66F0";
35917 t["\u2F49"] = "\u6708";
35918 t["\u2F4A"] = "\u6728";
35919 t["\u2F4B"] = "\u6B20";
35920 t["\u2F4C"] = "\u6B62";
35921 t["\u2F4D"] = "\u6B79";
35922 t["\u2F4E"] = "\u6BB3";
35923 t["\u2F4F"] = "\u6BCB";
35924 t["\u2F50"] = "\u6BD4";
35925 t["\u2F51"] = "\u6BDB";
35926 t["\u2F52"] = "\u6C0F";
35927 t["\u2F53"] = "\u6C14";
35928 t["\u2F54"] = "\u6C34";
35929 t["\u2F55"] = "\u706B";
35930 t["\u2F56"] = "\u722A";
35931 t["\u2F57"] = "\u7236";
35932 t["\u2F58"] = "\u723B";
35933 t["\u2F59"] = "\u723F";
35934 t["\u2F5A"] = "\u7247";
35935 t["\u2F5B"] = "\u7259";
35936 t["\u2F5C"] = "\u725B";
35937 t["\u2F5D"] = "\u72AC";
35938 t["\u2F5E"] = "\u7384";
35939 t["\u2F5F"] = "\u7389";
35940 t["\u2F60"] = "\u74DC";
35941 t["\u2F61"] = "\u74E6";
35942 t["\u2F62"] = "\u7518";
35943 t["\u2F63"] = "\u751F";
35944 t["\u2F64"] = "\u7528";
35945 t["\u2F65"] = "\u7530";
35946 t["\u2F66"] = "\u758B";
35947 t["\u2F67"] = "\u7592";
35948 t["\u2F68"] = "\u7676";
35949 t["\u2F69"] = "\u767D";
35950 t["\u2F6A"] = "\u76AE";
35951 t["\u2F6B"] = "\u76BF";
35952 t["\u2F6C"] = "\u76EE";
35953 t["\u2F6D"] = "\u77DB";
35954 t["\u2F6E"] = "\u77E2";
35955 t["\u2F6F"] = "\u77F3";
35956 t["\u2F70"] = "\u793A";
35957 t["\u2F71"] = "\u79B8";
35958 t["\u2F72"] = "\u79BE";
35959 t["\u2F73"] = "\u7A74";
35960 t["\u2F74"] = "\u7ACB";
35961 t["\u2F75"] = "\u7AF9";
35962 t["\u2F76"] = "\u7C73";
35963 t["\u2F77"] = "\u7CF8";
35964 t["\u2F78"] = "\u7F36";
35965 t["\u2F79"] = "\u7F51";
35966 t["\u2F7A"] = "\u7F8A";
35967 t["\u2F7B"] = "\u7FBD";
35968 t["\u2F7C"] = "\u8001";
35969 t["\u2F7D"] = "\u800C";
35970 t["\u2F7E"] = "\u8012";
35971 t["\u2F7F"] = "\u8033";
35972 t["\u2F80"] = "\u807F";
35973 t["\u2F81"] = "\u8089";
35974 t["\u2F82"] = "\u81E3";
35975 t["\u2F83"] = "\u81EA";
35976 t["\u2F84"] = "\u81F3";
35977 t["\u2F85"] = "\u81FC";
35978 t["\u2F86"] = "\u820C";
35979 t["\u2F87"] = "\u821B";
35980 t["\u2F88"] = "\u821F";
35981 t["\u2F89"] = "\u826E";
35982 t["\u2F8A"] = "\u8272";
35983 t["\u2F8B"] = "\u8278";
35984 t["\u2F8C"] = "\u864D";
35985 t["\u2F8D"] = "\u866B";
35986 t["\u2F8E"] = "\u8840";
35987 t["\u2F8F"] = "\u884C";
35988 t["\u2F90"] = "\u8863";
35989 t["\u2F91"] = "\u897E";
35990 t["\u2F92"] = "\u898B";
35991 t["\u2F93"] = "\u89D2";
35992 t["\u2F94"] = "\u8A00";
35993 t["\u2F95"] = "\u8C37";
35994 t["\u2F96"] = "\u8C46";
35995 t["\u2F97"] = "\u8C55";
35996 t["\u2F98"] = "\u8C78";
35997 t["\u2F99"] = "\u8C9D";
35998 t["\u2F9A"] = "\u8D64";
35999 t["\u2F9B"] = "\u8D70";
36000 t["\u2F9C"] = "\u8DB3";
36001 t["\u2F9D"] = "\u8EAB";
36002 t["\u2F9E"] = "\u8ECA";
36003 t["\u2F9F"] = "\u8F9B";
36004 t["\u2FA0"] = "\u8FB0";
36005 t["\u2FA1"] = "\u8FB5";
36006 t["\u2FA2"] = "\u9091";
36007 t["\u2FA3"] = "\u9149";
36008 t["\u2FA4"] = "\u91C6";
36009 t["\u2FA5"] = "\u91CC";
36010 t["\u2FA6"] = "\u91D1";
36011 t["\u2FA7"] = "\u9577";
36012 t["\u2FA8"] = "\u9580";
36013 t["\u2FA9"] = "\u961C";
36014 t["\u2FAA"] = "\u96B6";
36015 t["\u2FAB"] = "\u96B9";
36016 t["\u2FAC"] = "\u96E8";
36017 t["\u2FAD"] = "\u9751";
36018 t["\u2FAE"] = "\u975E";
36019 t["\u2FAF"] = "\u9762";
36020 t["\u2FB0"] = "\u9769";
36021 t["\u2FB1"] = "\u97CB";
36022 t["\u2FB2"] = "\u97ED";
36023 t["\u2FB3"] = "\u97F3";
36024 t["\u2FB4"] = "\u9801";
36025 t["\u2FB5"] = "\u98A8";
36026 t["\u2FB6"] = "\u98DB";
36027 t["\u2FB7"] = "\u98DF";
36028 t["\u2FB8"] = "\u9996";
36029 t["\u2FB9"] = "\u9999";
36030 t["\u2FBA"] = "\u99AC";
36031 t["\u2FBB"] = "\u9AA8";
36032 t["\u2FBC"] = "\u9AD8";
36033 t["\u2FBD"] = "\u9ADF";
36034 t["\u2FBE"] = "\u9B25";
36035 t["\u2FBF"] = "\u9B2F";
36036 t["\u2FC0"] = "\u9B32";
36037 t["\u2FC1"] = "\u9B3C";
36038 t["\u2FC2"] = "\u9B5A";
36039 t["\u2FC3"] = "\u9CE5";
36040 t["\u2FC4"] = "\u9E75";
36041 t["\u2FC5"] = "\u9E7F";
36042 t["\u2FC6"] = "\u9EA5";
36043 t["\u2FC7"] = "\u9EBB";
36044 t["\u2FC8"] = "\u9EC3";
36045 t["\u2FC9"] = "\u9ECD";
36046 t["\u2FCA"] = "\u9ED1";
36047 t["\u2FCB"] = "\u9EF9";
36048 t["\u2FCC"] = "\u9EFD";
36049 t["\u2FCD"] = "\u9F0E";
36050 t["\u2FCE"] = "\u9F13";
36051 t["\u2FCF"] = "\u9F20";
36052 t["\u2FD0"] = "\u9F3B";
36053 t["\u2FD1"] = "\u9F4A";
36054 t["\u2FD2"] = "\u9F52";
36055 t["\u2FD3"] = "\u9F8D";
36056 t["\u2FD4"] = "\u9F9C";
36057 t["\u2FD5"] = "\u9FA0";
36058 t["\u3036"] = "\u3012";
36059 t["\u3038"] = "\u5341";
36060 t["\u3039"] = "\u5344";
36061 t["\u303A"] = "\u5345";
36062 t["\u309B"] = "\u0020\u3099";
36063 t["\u309C"] = "\u0020\u309A";
36064 t["\u3131"] = "\u1100";
36065 t["\u3132"] = "\u1101";
36066 t["\u3133"] = "\u11AA";
36067 t["\u3134"] = "\u1102";
36068 t["\u3135"] = "\u11AC";
36069 t["\u3136"] = "\u11AD";
36070 t["\u3137"] = "\u1103";
36071 t["\u3138"] = "\u1104";
36072 t["\u3139"] = "\u1105";
36073 t["\u313A"] = "\u11B0";
36074 t["\u313B"] = "\u11B1";
36075 t["\u313C"] = "\u11B2";
36076 t["\u313D"] = "\u11B3";
36077 t["\u313E"] = "\u11B4";
36078 t["\u313F"] = "\u11B5";
36079 t["\u3140"] = "\u111A";
36080 t["\u3141"] = "\u1106";
36081 t["\u3142"] = "\u1107";
36082 t["\u3143"] = "\u1108";
36083 t["\u3144"] = "\u1121";
36084 t["\u3145"] = "\u1109";
36085 t["\u3146"] = "\u110A";
36086 t["\u3147"] = "\u110B";
36087 t["\u3148"] = "\u110C";
36088 t["\u3149"] = "\u110D";
36089 t["\u314A"] = "\u110E";
36090 t["\u314B"] = "\u110F";
36091 t["\u314C"] = "\u1110";
36092 t["\u314D"] = "\u1111";
36093 t["\u314E"] = "\u1112";
36094 t["\u314F"] = "\u1161";
36095 t["\u3150"] = "\u1162";
36096 t["\u3151"] = "\u1163";
36097 t["\u3152"] = "\u1164";
36098 t["\u3153"] = "\u1165";
36099 t["\u3154"] = "\u1166";
36100 t["\u3155"] = "\u1167";
36101 t["\u3156"] = "\u1168";
36102 t["\u3157"] = "\u1169";
36103 t["\u3158"] = "\u116A";
36104 t["\u3159"] = "\u116B";
36105 t["\u315A"] = "\u116C";
36106 t["\u315B"] = "\u116D";
36107 t["\u315C"] = "\u116E";
36108 t["\u315D"] = "\u116F";
36109 t["\u315E"] = "\u1170";
36110 t["\u315F"] = "\u1171";
36111 t["\u3160"] = "\u1172";
36112 t["\u3161"] = "\u1173";
36113 t["\u3162"] = "\u1174";
36114 t["\u3163"] = "\u1175";
36115 t["\u3164"] = "\u1160";
36116 t["\u3165"] = "\u1114";
36117 t["\u3166"] = "\u1115";
36118 t["\u3167"] = "\u11C7";
36119 t["\u3168"] = "\u11C8";
36120 t["\u3169"] = "\u11CC";
36121 t["\u316A"] = "\u11CE";
36122 t["\u316B"] = "\u11D3";
36123 t["\u316C"] = "\u11D7";
36124 t["\u316D"] = "\u11D9";
36125 t["\u316E"] = "\u111C";
36126 t["\u316F"] = "\u11DD";
36127 t["\u3170"] = "\u11DF";
36128 t["\u3171"] = "\u111D";
36129 t["\u3172"] = "\u111E";
36130 t["\u3173"] = "\u1120";
36131 t["\u3174"] = "\u1122";
36132 t["\u3175"] = "\u1123";
36133 t["\u3176"] = "\u1127";
36134 t["\u3177"] = "\u1129";
36135 t["\u3178"] = "\u112B";
36136 t["\u3179"] = "\u112C";
36137 t["\u317A"] = "\u112D";
36138 t["\u317B"] = "\u112E";
36139 t["\u317C"] = "\u112F";
36140 t["\u317D"] = "\u1132";
36141 t["\u317E"] = "\u1136";
36142 t["\u317F"] = "\u1140";
36143 t["\u3180"] = "\u1147";
36144 t["\u3181"] = "\u114C";
36145 t["\u3182"] = "\u11F1";
36146 t["\u3183"] = "\u11F2";
36147 t["\u3184"] = "\u1157";
36148 t["\u3185"] = "\u1158";
36149 t["\u3186"] = "\u1159";
36150 t["\u3187"] = "\u1184";
36151 t["\u3188"] = "\u1185";
36152 t["\u3189"] = "\u1188";
36153 t["\u318A"] = "\u1191";
36154 t["\u318B"] = "\u1192";
36155 t["\u318C"] = "\u1194";
36156 t["\u318D"] = "\u119E";
36157 t["\u318E"] = "\u11A1";
36158 t["\u3200"] = "\u0028\u1100\u0029";
36159 t["\u3201"] = "\u0028\u1102\u0029";
36160 t["\u3202"] = "\u0028\u1103\u0029";
36161 t["\u3203"] = "\u0028\u1105\u0029";
36162 t["\u3204"] = "\u0028\u1106\u0029";
36163 t["\u3205"] = "\u0028\u1107\u0029";
36164 t["\u3206"] = "\u0028\u1109\u0029";
36165 t["\u3207"] = "\u0028\u110B\u0029";
36166 t["\u3208"] = "\u0028\u110C\u0029";
36167 t["\u3209"] = "\u0028\u110E\u0029";
36168 t["\u320A"] = "\u0028\u110F\u0029";
36169 t["\u320B"] = "\u0028\u1110\u0029";
36170 t["\u320C"] = "\u0028\u1111\u0029";
36171 t["\u320D"] = "\u0028\u1112\u0029";
36172 t["\u320E"] = "\u0028\u1100\u1161\u0029";
36173 t["\u320F"] = "\u0028\u1102\u1161\u0029";
36174 t["\u3210"] = "\u0028\u1103\u1161\u0029";
36175 t["\u3211"] = "\u0028\u1105\u1161\u0029";
36176 t["\u3212"] = "\u0028\u1106\u1161\u0029";
36177 t["\u3213"] = "\u0028\u1107\u1161\u0029";
36178 t["\u3214"] = "\u0028\u1109\u1161\u0029";
36179 t["\u3215"] = "\u0028\u110B\u1161\u0029";
36180 t["\u3216"] = "\u0028\u110C\u1161\u0029";
36181 t["\u3217"] = "\u0028\u110E\u1161\u0029";
36182 t["\u3218"] = "\u0028\u110F\u1161\u0029";
36183 t["\u3219"] = "\u0028\u1110\u1161\u0029";
36184 t["\u321A"] = "\u0028\u1111\u1161\u0029";
36185 t["\u321B"] = "\u0028\u1112\u1161\u0029";
36186 t["\u321C"] = "\u0028\u110C\u116E\u0029";
36187 t["\u321D"] = "\u0028\u110B\u1169\u110C\u1165\u11AB\u0029";
36188 t["\u321E"] = "\u0028\u110B\u1169\u1112\u116E\u0029";
36189 t["\u3220"] = "\u0028\u4E00\u0029";
36190 t["\u3221"] = "\u0028\u4E8C\u0029";
36191 t["\u3222"] = "\u0028\u4E09\u0029";
36192 t["\u3223"] = "\u0028\u56DB\u0029";
36193 t["\u3224"] = "\u0028\u4E94\u0029";
36194 t["\u3225"] = "\u0028\u516D\u0029";
36195 t["\u3226"] = "\u0028\u4E03\u0029";
36196 t["\u3227"] = "\u0028\u516B\u0029";
36197 t["\u3228"] = "\u0028\u4E5D\u0029";
36198 t["\u3229"] = "\u0028\u5341\u0029";
36199 t["\u322A"] = "\u0028\u6708\u0029";
36200 t["\u322B"] = "\u0028\u706B\u0029";
36201 t["\u322C"] = "\u0028\u6C34\u0029";
36202 t["\u322D"] = "\u0028\u6728\u0029";
36203 t["\u322E"] = "\u0028\u91D1\u0029";
36204 t["\u322F"] = "\u0028\u571F\u0029";
36205 t["\u3230"] = "\u0028\u65E5\u0029";
36206 t["\u3231"] = "\u0028\u682A\u0029";
36207 t["\u3232"] = "\u0028\u6709\u0029";
36208 t["\u3233"] = "\u0028\u793E\u0029";
36209 t["\u3234"] = "\u0028\u540D\u0029";
36210 t["\u3235"] = "\u0028\u7279\u0029";
36211 t["\u3236"] = "\u0028\u8CA1\u0029";
36212 t["\u3237"] = "\u0028\u795D\u0029";
36213 t["\u3238"] = "\u0028\u52B4\u0029";
36214 t["\u3239"] = "\u0028\u4EE3\u0029";
36215 t["\u323A"] = "\u0028\u547C\u0029";
36216 t["\u323B"] = "\u0028\u5B66\u0029";
36217 t["\u323C"] = "\u0028\u76E3\u0029";
36218 t["\u323D"] = "\u0028\u4F01\u0029";
36219 t["\u323E"] = "\u0028\u8CC7\u0029";
36220 t["\u323F"] = "\u0028\u5354\u0029";
36221 t["\u3240"] = "\u0028\u796D\u0029";
36222 t["\u3241"] = "\u0028\u4F11\u0029";
36223 t["\u3242"] = "\u0028\u81EA\u0029";
36224 t["\u3243"] = "\u0028\u81F3\u0029";
36225 t["\u32C0"] = "\u0031\u6708";
36226 t["\u32C1"] = "\u0032\u6708";
36227 t["\u32C2"] = "\u0033\u6708";
36228 t["\u32C3"] = "\u0034\u6708";
36229 t["\u32C4"] = "\u0035\u6708";
36230 t["\u32C5"] = "\u0036\u6708";
36231 t["\u32C6"] = "\u0037\u6708";
36232 t["\u32C7"] = "\u0038\u6708";
36233 t["\u32C8"] = "\u0039\u6708";
36234 t["\u32C9"] = "\u0031\u0030\u6708";
36235 t["\u32CA"] = "\u0031\u0031\u6708";
36236 t["\u32CB"] = "\u0031\u0032\u6708";
36237 t["\u3358"] = "\u0030\u70B9";
36238 t["\u3359"] = "\u0031\u70B9";
36239 t["\u335A"] = "\u0032\u70B9";
36240 t["\u335B"] = "\u0033\u70B9";
36241 t["\u335C"] = "\u0034\u70B9";
36242 t["\u335D"] = "\u0035\u70B9";
36243 t["\u335E"] = "\u0036\u70B9";
36244 t["\u335F"] = "\u0037\u70B9";
36245 t["\u3360"] = "\u0038\u70B9";
36246 t["\u3361"] = "\u0039\u70B9";
36247 t["\u3362"] = "\u0031\u0030\u70B9";
36248 t["\u3363"] = "\u0031\u0031\u70B9";
36249 t["\u3364"] = "\u0031\u0032\u70B9";
36250 t["\u3365"] = "\u0031\u0033\u70B9";
36251 t["\u3366"] = "\u0031\u0034\u70B9";
36252 t["\u3367"] = "\u0031\u0035\u70B9";
36253 t["\u3368"] = "\u0031\u0036\u70B9";
36254 t["\u3369"] = "\u0031\u0037\u70B9";
36255 t["\u336A"] = "\u0031\u0038\u70B9";
36256 t["\u336B"] = "\u0031\u0039\u70B9";
36257 t["\u336C"] = "\u0032\u0030\u70B9";
36258 t["\u336D"] = "\u0032\u0031\u70B9";
36259 t["\u336E"] = "\u0032\u0032\u70B9";
36260 t["\u336F"] = "\u0032\u0033\u70B9";
36261 t["\u3370"] = "\u0032\u0034\u70B9";
36262 t["\u33E0"] = "\u0031\u65E5";
36263 t["\u33E1"] = "\u0032\u65E5";
36264 t["\u33E2"] = "\u0033\u65E5";
36265 t["\u33E3"] = "\u0034\u65E5";
36266 t["\u33E4"] = "\u0035\u65E5";
36267 t["\u33E5"] = "\u0036\u65E5";
36268 t["\u33E6"] = "\u0037\u65E5";
36269 t["\u33E7"] = "\u0038\u65E5";
36270 t["\u33E8"] = "\u0039\u65E5";
36271 t["\u33E9"] = "\u0031\u0030\u65E5";
36272 t["\u33EA"] = "\u0031\u0031\u65E5";
36273 t["\u33EB"] = "\u0031\u0032\u65E5";
36274 t["\u33EC"] = "\u0031\u0033\u65E5";
36275 t["\u33ED"] = "\u0031\u0034\u65E5";
36276 t["\u33EE"] = "\u0031\u0035\u65E5";
36277 t["\u33EF"] = "\u0031\u0036\u65E5";
36278 t["\u33F0"] = "\u0031\u0037\u65E5";
36279 t["\u33F1"] = "\u0031\u0038\u65E5";
36280 t["\u33F2"] = "\u0031\u0039\u65E5";
36281 t["\u33F3"] = "\u0032\u0030\u65E5";
36282 t["\u33F4"] = "\u0032\u0031\u65E5";
36283 t["\u33F5"] = "\u0032\u0032\u65E5";
36284 t["\u33F6"] = "\u0032\u0033\u65E5";
36285 t["\u33F7"] = "\u0032\u0034\u65E5";
36286 t["\u33F8"] = "\u0032\u0035\u65E5";
36287 t["\u33F9"] = "\u0032\u0036\u65E5";
36288 t["\u33FA"] = "\u0032\u0037\u65E5";
36289 t["\u33FB"] = "\u0032\u0038\u65E5";
36290 t["\u33FC"] = "\u0032\u0039\u65E5";
36291 t["\u33FD"] = "\u0033\u0030\u65E5";
36292 t["\u33FE"] = "\u0033\u0031\u65E5";
36293 t["\uFB00"] = "\u0066\u0066";
36294 t["\uFB01"] = "\u0066\u0069";
36295 t["\uFB02"] = "\u0066\u006C";
36296 t["\uFB03"] = "\u0066\u0066\u0069";
36297 t["\uFB04"] = "\u0066\u0066\u006C";
36298 t["\uFB05"] = "\u017F\u0074";
36299 t["\uFB06"] = "\u0073\u0074";
36300 t["\uFB13"] = "\u0574\u0576";
36301 t["\uFB14"] = "\u0574\u0565";
36302 t["\uFB15"] = "\u0574\u056B";
36303 t["\uFB16"] = "\u057E\u0576";
36304 t["\uFB17"] = "\u0574\u056D";
36305 t["\uFB4F"] = "\u05D0\u05DC";
36306 t["\uFB50"] = "\u0671";
36307 t["\uFB51"] = "\u0671";
36308 t["\uFB52"] = "\u067B";
36309 t["\uFB53"] = "\u067B";
36310 t["\uFB54"] = "\u067B";
36311 t["\uFB55"] = "\u067B";
36312 t["\uFB56"] = "\u067E";
36313 t["\uFB57"] = "\u067E";
36314 t["\uFB58"] = "\u067E";
36315 t["\uFB59"] = "\u067E";
36316 t["\uFB5A"] = "\u0680";
36317 t["\uFB5B"] = "\u0680";
36318 t["\uFB5C"] = "\u0680";
36319 t["\uFB5D"] = "\u0680";
36320 t["\uFB5E"] = "\u067A";
36321 t["\uFB5F"] = "\u067A";
36322 t["\uFB60"] = "\u067A";
36323 t["\uFB61"] = "\u067A";
36324 t["\uFB62"] = "\u067F";
36325 t["\uFB63"] = "\u067F";
36326 t["\uFB64"] = "\u067F";
36327 t["\uFB65"] = "\u067F";
36328 t["\uFB66"] = "\u0679";
36329 t["\uFB67"] = "\u0679";
36330 t["\uFB68"] = "\u0679";
36331 t["\uFB69"] = "\u0679";
36332 t["\uFB6A"] = "\u06A4";
36333 t["\uFB6B"] = "\u06A4";
36334 t["\uFB6C"] = "\u06A4";
36335 t["\uFB6D"] = "\u06A4";
36336 t["\uFB6E"] = "\u06A6";
36337 t["\uFB6F"] = "\u06A6";
36338 t["\uFB70"] = "\u06A6";
36339 t["\uFB71"] = "\u06A6";
36340 t["\uFB72"] = "\u0684";
36341 t["\uFB73"] = "\u0684";
36342 t["\uFB74"] = "\u0684";
36343 t["\uFB75"] = "\u0684";
36344 t["\uFB76"] = "\u0683";
36345 t["\uFB77"] = "\u0683";
36346 t["\uFB78"] = "\u0683";
36347 t["\uFB79"] = "\u0683";
36348 t["\uFB7A"] = "\u0686";
36349 t["\uFB7B"] = "\u0686";
36350 t["\uFB7C"] = "\u0686";
36351 t["\uFB7D"] = "\u0686";
36352 t["\uFB7E"] = "\u0687";
36353 t["\uFB7F"] = "\u0687";
36354 t["\uFB80"] = "\u0687";
36355 t["\uFB81"] = "\u0687";
36356 t["\uFB82"] = "\u068D";
36357 t["\uFB83"] = "\u068D";
36358 t["\uFB84"] = "\u068C";
36359 t["\uFB85"] = "\u068C";
36360 t["\uFB86"] = "\u068E";
36361 t["\uFB87"] = "\u068E";
36362 t["\uFB88"] = "\u0688";
36363 t["\uFB89"] = "\u0688";
36364 t["\uFB8A"] = "\u0698";
36365 t["\uFB8B"] = "\u0698";
36366 t["\uFB8C"] = "\u0691";
36367 t["\uFB8D"] = "\u0691";
36368 t["\uFB8E"] = "\u06A9";
36369 t["\uFB8F"] = "\u06A9";
36370 t["\uFB90"] = "\u06A9";
36371 t["\uFB91"] = "\u06A9";
36372 t["\uFB92"] = "\u06AF";
36373 t["\uFB93"] = "\u06AF";
36374 t["\uFB94"] = "\u06AF";
36375 t["\uFB95"] = "\u06AF";
36376 t["\uFB96"] = "\u06B3";
36377 t["\uFB97"] = "\u06B3";
36378 t["\uFB98"] = "\u06B3";
36379 t["\uFB99"] = "\u06B3";
36380 t["\uFB9A"] = "\u06B1";
36381 t["\uFB9B"] = "\u06B1";
36382 t["\uFB9C"] = "\u06B1";
36383 t["\uFB9D"] = "\u06B1";
36384 t["\uFB9E"] = "\u06BA";
36385 t["\uFB9F"] = "\u06BA";
36386 t["\uFBA0"] = "\u06BB";
36387 t["\uFBA1"] = "\u06BB";
36388 t["\uFBA2"] = "\u06BB";
36389 t["\uFBA3"] = "\u06BB";
36390 t["\uFBA4"] = "\u06C0";
36391 t["\uFBA5"] = "\u06C0";
36392 t["\uFBA6"] = "\u06C1";
36393 t["\uFBA7"] = "\u06C1";
36394 t["\uFBA8"] = "\u06C1";
36395 t["\uFBA9"] = "\u06C1";
36396 t["\uFBAA"] = "\u06BE";
36397 t["\uFBAB"] = "\u06BE";
36398 t["\uFBAC"] = "\u06BE";
36399 t["\uFBAD"] = "\u06BE";
36400 t["\uFBAE"] = "\u06D2";
36401 t["\uFBAF"] = "\u06D2";
36402 t["\uFBB0"] = "\u06D3";
36403 t["\uFBB1"] = "\u06D3";
36404 t["\uFBD3"] = "\u06AD";
36405 t["\uFBD4"] = "\u06AD";
36406 t["\uFBD5"] = "\u06AD";
36407 t["\uFBD6"] = "\u06AD";
36408 t["\uFBD7"] = "\u06C7";
36409 t["\uFBD8"] = "\u06C7";
36410 t["\uFBD9"] = "\u06C6";
36411 t["\uFBDA"] = "\u06C6";
36412 t["\uFBDB"] = "\u06C8";
36413 t["\uFBDC"] = "\u06C8";
36414 t["\uFBDD"] = "\u0677";
36415 t["\uFBDE"] = "\u06CB";
36416 t["\uFBDF"] = "\u06CB";
36417 t["\uFBE0"] = "\u06C5";
36418 t["\uFBE1"] = "\u06C5";
36419 t["\uFBE2"] = "\u06C9";
36420 t["\uFBE3"] = "\u06C9";
36421 t["\uFBE4"] = "\u06D0";
36422 t["\uFBE5"] = "\u06D0";
36423 t["\uFBE6"] = "\u06D0";
36424 t["\uFBE7"] = "\u06D0";
36425 t["\uFBE8"] = "\u0649";
36426 t["\uFBE9"] = "\u0649";
36427 t["\uFBEA"] = "\u0626\u0627";
36428 t["\uFBEB"] = "\u0626\u0627";
36429 t["\uFBEC"] = "\u0626\u06D5";
36430 t["\uFBED"] = "\u0626\u06D5";
36431 t["\uFBEE"] = "\u0626\u0648";
36432 t["\uFBEF"] = "\u0626\u0648";
36433 t["\uFBF0"] = "\u0626\u06C7";
36434 t["\uFBF1"] = "\u0626\u06C7";
36435 t["\uFBF2"] = "\u0626\u06C6";
36436 t["\uFBF3"] = "\u0626\u06C6";
36437 t["\uFBF4"] = "\u0626\u06C8";
36438 t["\uFBF5"] = "\u0626\u06C8";
36439 t["\uFBF6"] = "\u0626\u06D0";
36440 t["\uFBF7"] = "\u0626\u06D0";
36441 t["\uFBF8"] = "\u0626\u06D0";
36442 t["\uFBF9"] = "\u0626\u0649";
36443 t["\uFBFA"] = "\u0626\u0649";
36444 t["\uFBFB"] = "\u0626\u0649";
36445 t["\uFBFC"] = "\u06CC";
36446 t["\uFBFD"] = "\u06CC";
36447 t["\uFBFE"] = "\u06CC";
36448 t["\uFBFF"] = "\u06CC";
36449 t["\uFC00"] = "\u0626\u062C";
36450 t["\uFC01"] = "\u0626\u062D";
36451 t["\uFC02"] = "\u0626\u0645";
36452 t["\uFC03"] = "\u0626\u0649";
36453 t["\uFC04"] = "\u0626\u064A";
36454 t["\uFC05"] = "\u0628\u062C";
36455 t["\uFC06"] = "\u0628\u062D";
36456 t["\uFC07"] = "\u0628\u062E";
36457 t["\uFC08"] = "\u0628\u0645";
36458 t["\uFC09"] = "\u0628\u0649";
36459 t["\uFC0A"] = "\u0628\u064A";
36460 t["\uFC0B"] = "\u062A\u062C";
36461 t["\uFC0C"] = "\u062A\u062D";
36462 t["\uFC0D"] = "\u062A\u062E";
36463 t["\uFC0E"] = "\u062A\u0645";
36464 t["\uFC0F"] = "\u062A\u0649";
36465 t["\uFC10"] = "\u062A\u064A";
36466 t["\uFC11"] = "\u062B\u062C";
36467 t["\uFC12"] = "\u062B\u0645";
36468 t["\uFC13"] = "\u062B\u0649";
36469 t["\uFC14"] = "\u062B\u064A";
36470 t["\uFC15"] = "\u062C\u062D";
36471 t["\uFC16"] = "\u062C\u0645";
36472 t["\uFC17"] = "\u062D\u062C";
36473 t["\uFC18"] = "\u062D\u0645";
36474 t["\uFC19"] = "\u062E\u062C";
36475 t["\uFC1A"] = "\u062E\u062D";
36476 t["\uFC1B"] = "\u062E\u0645";
36477 t["\uFC1C"] = "\u0633\u062C";
36478 t["\uFC1D"] = "\u0633\u062D";
36479 t["\uFC1E"] = "\u0633\u062E";
36480 t["\uFC1F"] = "\u0633\u0645";
36481 t["\uFC20"] = "\u0635\u062D";
36482 t["\uFC21"] = "\u0635\u0645";
36483 t["\uFC22"] = "\u0636\u062C";
36484 t["\uFC23"] = "\u0636\u062D";
36485 t["\uFC24"] = "\u0636\u062E";
36486 t["\uFC25"] = "\u0636\u0645";
36487 t["\uFC26"] = "\u0637\u062D";
36488 t["\uFC27"] = "\u0637\u0645";
36489 t["\uFC28"] = "\u0638\u0645";
36490 t["\uFC29"] = "\u0639\u062C";
36491 t["\uFC2A"] = "\u0639\u0645";
36492 t["\uFC2B"] = "\u063A\u062C";
36493 t["\uFC2C"] = "\u063A\u0645";
36494 t["\uFC2D"] = "\u0641\u062C";
36495 t["\uFC2E"] = "\u0641\u062D";
36496 t["\uFC2F"] = "\u0641\u062E";
36497 t["\uFC30"] = "\u0641\u0645";
36498 t["\uFC31"] = "\u0641\u0649";
36499 t["\uFC32"] = "\u0641\u064A";
36500 t["\uFC33"] = "\u0642\u062D";
36501 t["\uFC34"] = "\u0642\u0645";
36502 t["\uFC35"] = "\u0642\u0649";
36503 t["\uFC36"] = "\u0642\u064A";
36504 t["\uFC37"] = "\u0643\u0627";
36505 t["\uFC38"] = "\u0643\u062C";
36506 t["\uFC39"] = "\u0643\u062D";
36507 t["\uFC3A"] = "\u0643\u062E";
36508 t["\uFC3B"] = "\u0643\u0644";
36509 t["\uFC3C"] = "\u0643\u0645";
36510 t["\uFC3D"] = "\u0643\u0649";
36511 t["\uFC3E"] = "\u0643\u064A";
36512 t["\uFC3F"] = "\u0644\u062C";
36513 t["\uFC40"] = "\u0644\u062D";
36514 t["\uFC41"] = "\u0644\u062E";
36515 t["\uFC42"] = "\u0644\u0645";
36516 t["\uFC43"] = "\u0644\u0649";
36517 t["\uFC44"] = "\u0644\u064A";
36518 t["\uFC45"] = "\u0645\u062C";
36519 t["\uFC46"] = "\u0645\u062D";
36520 t["\uFC47"] = "\u0645\u062E";
36521 t["\uFC48"] = "\u0645\u0645";
36522 t["\uFC49"] = "\u0645\u0649";
36523 t["\uFC4A"] = "\u0645\u064A";
36524 t["\uFC4B"] = "\u0646\u062C";
36525 t["\uFC4C"] = "\u0646\u062D";
36526 t["\uFC4D"] = "\u0646\u062E";
36527 t["\uFC4E"] = "\u0646\u0645";
36528 t["\uFC4F"] = "\u0646\u0649";
36529 t["\uFC50"] = "\u0646\u064A";
36530 t["\uFC51"] = "\u0647\u062C";
36531 t["\uFC52"] = "\u0647\u0645";
36532 t["\uFC53"] = "\u0647\u0649";
36533 t["\uFC54"] = "\u0647\u064A";
36534 t["\uFC55"] = "\u064A\u062C";
36535 t["\uFC56"] = "\u064A\u062D";
36536 t["\uFC57"] = "\u064A\u062E";
36537 t["\uFC58"] = "\u064A\u0645";
36538 t["\uFC59"] = "\u064A\u0649";
36539 t["\uFC5A"] = "\u064A\u064A";
36540 t["\uFC5B"] = "\u0630\u0670";
36541 t["\uFC5C"] = "\u0631\u0670";
36542 t["\uFC5D"] = "\u0649\u0670";
36543 t["\uFC5E"] = "\u0020\u064C\u0651";
36544 t["\uFC5F"] = "\u0020\u064D\u0651";
36545 t["\uFC60"] = "\u0020\u064E\u0651";
36546 t["\uFC61"] = "\u0020\u064F\u0651";
36547 t["\uFC62"] = "\u0020\u0650\u0651";
36548 t["\uFC63"] = "\u0020\u0651\u0670";
36549 t["\uFC64"] = "\u0626\u0631";
36550 t["\uFC65"] = "\u0626\u0632";
36551 t["\uFC66"] = "\u0626\u0645";
36552 t["\uFC67"] = "\u0626\u0646";
36553 t["\uFC68"] = "\u0626\u0649";
36554 t["\uFC69"] = "\u0626\u064A";
36555 t["\uFC6A"] = "\u0628\u0631";
36556 t["\uFC6B"] = "\u0628\u0632";
36557 t["\uFC6C"] = "\u0628\u0645";
36558 t["\uFC6D"] = "\u0628\u0646";
36559 t["\uFC6E"] = "\u0628\u0649";
36560 t["\uFC6F"] = "\u0628\u064A";
36561 t["\uFC70"] = "\u062A\u0631";
36562 t["\uFC71"] = "\u062A\u0632";
36563 t["\uFC72"] = "\u062A\u0645";
36564 t["\uFC73"] = "\u062A\u0646";
36565 t["\uFC74"] = "\u062A\u0649";
36566 t["\uFC75"] = "\u062A\u064A";
36567 t["\uFC76"] = "\u062B\u0631";
36568 t["\uFC77"] = "\u062B\u0632";
36569 t["\uFC78"] = "\u062B\u0645";
36570 t["\uFC79"] = "\u062B\u0646";
36571 t["\uFC7A"] = "\u062B\u0649";
36572 t["\uFC7B"] = "\u062B\u064A";
36573 t["\uFC7C"] = "\u0641\u0649";
36574 t["\uFC7D"] = "\u0641\u064A";
36575 t["\uFC7E"] = "\u0642\u0649";
36576 t["\uFC7F"] = "\u0642\u064A";
36577 t["\uFC80"] = "\u0643\u0627";
36578 t["\uFC81"] = "\u0643\u0644";
36579 t["\uFC82"] = "\u0643\u0645";
36580 t["\uFC83"] = "\u0643\u0649";
36581 t["\uFC84"] = "\u0643\u064A";
36582 t["\uFC85"] = "\u0644\u0645";
36583 t["\uFC86"] = "\u0644\u0649";
36584 t["\uFC87"] = "\u0644\u064A";
36585 t["\uFC88"] = "\u0645\u0627";
36586 t["\uFC89"] = "\u0645\u0645";
36587 t["\uFC8A"] = "\u0646\u0631";
36588 t["\uFC8B"] = "\u0646\u0632";
36589 t["\uFC8C"] = "\u0646\u0645";
36590 t["\uFC8D"] = "\u0646\u0646";
36591 t["\uFC8E"] = "\u0646\u0649";
36592 t["\uFC8F"] = "\u0646\u064A";
36593 t["\uFC90"] = "\u0649\u0670";
36594 t["\uFC91"] = "\u064A\u0631";
36595 t["\uFC92"] = "\u064A\u0632";
36596 t["\uFC93"] = "\u064A\u0645";
36597 t["\uFC94"] = "\u064A\u0646";
36598 t["\uFC95"] = "\u064A\u0649";
36599 t["\uFC96"] = "\u064A\u064A";
36600 t["\uFC97"] = "\u0626\u062C";
36601 t["\uFC98"] = "\u0626\u062D";
36602 t["\uFC99"] = "\u0626\u062E";
36603 t["\uFC9A"] = "\u0626\u0645";
36604 t["\uFC9B"] = "\u0626\u0647";
36605 t["\uFC9C"] = "\u0628\u062C";
36606 t["\uFC9D"] = "\u0628\u062D";
36607 t["\uFC9E"] = "\u0628\u062E";
36608 t["\uFC9F"] = "\u0628\u0645";
36609 t["\uFCA0"] = "\u0628\u0647";
36610 t["\uFCA1"] = "\u062A\u062C";
36611 t["\uFCA2"] = "\u062A\u062D";
36612 t["\uFCA3"] = "\u062A\u062E";
36613 t["\uFCA4"] = "\u062A\u0645";
36614 t["\uFCA5"] = "\u062A\u0647";
36615 t["\uFCA6"] = "\u062B\u0645";
36616 t["\uFCA7"] = "\u062C\u062D";
36617 t["\uFCA8"] = "\u062C\u0645";
36618 t["\uFCA9"] = "\u062D\u062C";
36619 t["\uFCAA"] = "\u062D\u0645";
36620 t["\uFCAB"] = "\u062E\u062C";
36621 t["\uFCAC"] = "\u062E\u0645";
36622 t["\uFCAD"] = "\u0633\u062C";
36623 t["\uFCAE"] = "\u0633\u062D";
36624 t["\uFCAF"] = "\u0633\u062E";
36625 t["\uFCB0"] = "\u0633\u0645";
36626 t["\uFCB1"] = "\u0635\u062D";
36627 t["\uFCB2"] = "\u0635\u062E";
36628 t["\uFCB3"] = "\u0635\u0645";
36629 t["\uFCB4"] = "\u0636\u062C";
36630 t["\uFCB5"] = "\u0636\u062D";
36631 t["\uFCB6"] = "\u0636\u062E";
36632 t["\uFCB7"] = "\u0636\u0645";
36633 t["\uFCB8"] = "\u0637\u062D";
36634 t["\uFCB9"] = "\u0638\u0645";
36635 t["\uFCBA"] = "\u0639\u062C";
36636 t["\uFCBB"] = "\u0639\u0645";
36637 t["\uFCBC"] = "\u063A\u062C";
36638 t["\uFCBD"] = "\u063A\u0645";
36639 t["\uFCBE"] = "\u0641\u062C";
36640 t["\uFCBF"] = "\u0641\u062D";
36641 t["\uFCC0"] = "\u0641\u062E";
36642 t["\uFCC1"] = "\u0641\u0645";
36643 t["\uFCC2"] = "\u0642\u062D";
36644 t["\uFCC3"] = "\u0642\u0645";
36645 t["\uFCC4"] = "\u0643\u062C";
36646 t["\uFCC5"] = "\u0643\u062D";
36647 t["\uFCC6"] = "\u0643\u062E";
36648 t["\uFCC7"] = "\u0643\u0644";
36649 t["\uFCC8"] = "\u0643\u0645";
36650 t["\uFCC9"] = "\u0644\u062C";
36651 t["\uFCCA"] = "\u0644\u062D";
36652 t["\uFCCB"] = "\u0644\u062E";
36653 t["\uFCCC"] = "\u0644\u0645";
36654 t["\uFCCD"] = "\u0644\u0647";
36655 t["\uFCCE"] = "\u0645\u062C";
36656 t["\uFCCF"] = "\u0645\u062D";
36657 t["\uFCD0"] = "\u0645\u062E";
36658 t["\uFCD1"] = "\u0645\u0645";
36659 t["\uFCD2"] = "\u0646\u062C";
36660 t["\uFCD3"] = "\u0646\u062D";
36661 t["\uFCD4"] = "\u0646\u062E";
36662 t["\uFCD5"] = "\u0646\u0645";
36663 t["\uFCD6"] = "\u0646\u0647";
36664 t["\uFCD7"] = "\u0647\u062C";
36665 t["\uFCD8"] = "\u0647\u0645";
36666 t["\uFCD9"] = "\u0647\u0670";
36667 t["\uFCDA"] = "\u064A\u062C";
36668 t["\uFCDB"] = "\u064A\u062D";
36669 t["\uFCDC"] = "\u064A\u062E";
36670 t["\uFCDD"] = "\u064A\u0645";
36671 t["\uFCDE"] = "\u064A\u0647";
36672 t["\uFCDF"] = "\u0626\u0645";
36673 t["\uFCE0"] = "\u0626\u0647";
36674 t["\uFCE1"] = "\u0628\u0645";
36675 t["\uFCE2"] = "\u0628\u0647";
36676 t["\uFCE3"] = "\u062A\u0645";
36677 t["\uFCE4"] = "\u062A\u0647";
36678 t["\uFCE5"] = "\u062B\u0645";
36679 t["\uFCE6"] = "\u062B\u0647";
36680 t["\uFCE7"] = "\u0633\u0645";
36681 t["\uFCE8"] = "\u0633\u0647";
36682 t["\uFCE9"] = "\u0634\u0645";
36683 t["\uFCEA"] = "\u0634\u0647";
36684 t["\uFCEB"] = "\u0643\u0644";
36685 t["\uFCEC"] = "\u0643\u0645";
36686 t["\uFCED"] = "\u0644\u0645";
36687 t["\uFCEE"] = "\u0646\u0645";
36688 t["\uFCEF"] = "\u0646\u0647";
36689 t["\uFCF0"] = "\u064A\u0645";
36690 t["\uFCF1"] = "\u064A\u0647";
36691 t["\uFCF2"] = "\u0640\u064E\u0651";
36692 t["\uFCF3"] = "\u0640\u064F\u0651";
36693 t["\uFCF4"] = "\u0640\u0650\u0651";
36694 t["\uFCF5"] = "\u0637\u0649";
36695 t["\uFCF6"] = "\u0637\u064A";
36696 t["\uFCF7"] = "\u0639\u0649";
36697 t["\uFCF8"] = "\u0639\u064A";
36698 t["\uFCF9"] = "\u063A\u0649";
36699 t["\uFCFA"] = "\u063A\u064A";
36700 t["\uFCFB"] = "\u0633\u0649";
36701 t["\uFCFC"] = "\u0633\u064A";
36702 t["\uFCFD"] = "\u0634\u0649";
36703 t["\uFCFE"] = "\u0634\u064A";
36704 t["\uFCFF"] = "\u062D\u0649";
36705 t["\uFD00"] = "\u062D\u064A";
36706 t["\uFD01"] = "\u062C\u0649";
36707 t["\uFD02"] = "\u062C\u064A";
36708 t["\uFD03"] = "\u062E\u0649";
36709 t["\uFD04"] = "\u062E\u064A";
36710 t["\uFD05"] = "\u0635\u0649";
36711 t["\uFD06"] = "\u0635\u064A";
36712 t["\uFD07"] = "\u0636\u0649";
36713 t["\uFD08"] = "\u0636\u064A";
36714 t["\uFD09"] = "\u0634\u062C";
36715 t["\uFD0A"] = "\u0634\u062D";
36716 t["\uFD0B"] = "\u0634\u062E";
36717 t["\uFD0C"] = "\u0634\u0645";
36718 t["\uFD0D"] = "\u0634\u0631";
36719 t["\uFD0E"] = "\u0633\u0631";
36720 t["\uFD0F"] = "\u0635\u0631";
36721 t["\uFD10"] = "\u0636\u0631";
36722 t["\uFD11"] = "\u0637\u0649";
36723 t["\uFD12"] = "\u0637\u064A";
36724 t["\uFD13"] = "\u0639\u0649";
36725 t["\uFD14"] = "\u0639\u064A";
36726 t["\uFD15"] = "\u063A\u0649";
36727 t["\uFD16"] = "\u063A\u064A";
36728 t["\uFD17"] = "\u0633\u0649";
36729 t["\uFD18"] = "\u0633\u064A";
36730 t["\uFD19"] = "\u0634\u0649";
36731 t["\uFD1A"] = "\u0634\u064A";
36732 t["\uFD1B"] = "\u062D\u0649";
36733 t["\uFD1C"] = "\u062D\u064A";
36734 t["\uFD1D"] = "\u062C\u0649";
36735 t["\uFD1E"] = "\u062C\u064A";
36736 t["\uFD1F"] = "\u062E\u0649";
36737 t["\uFD20"] = "\u062E\u064A";
36738 t["\uFD21"] = "\u0635\u0649";
36739 t["\uFD22"] = "\u0635\u064A";
36740 t["\uFD23"] = "\u0636\u0649";
36741 t["\uFD24"] = "\u0636\u064A";
36742 t["\uFD25"] = "\u0634\u062C";
36743 t["\uFD26"] = "\u0634\u062D";
36744 t["\uFD27"] = "\u0634\u062E";
36745 t["\uFD28"] = "\u0634\u0645";
36746 t["\uFD29"] = "\u0634\u0631";
36747 t["\uFD2A"] = "\u0633\u0631";
36748 t["\uFD2B"] = "\u0635\u0631";
36749 t["\uFD2C"] = "\u0636\u0631";
36750 t["\uFD2D"] = "\u0634\u062C";
36751 t["\uFD2E"] = "\u0634\u062D";
36752 t["\uFD2F"] = "\u0634\u062E";
36753 t["\uFD30"] = "\u0634\u0645";
36754 t["\uFD31"] = "\u0633\u0647";
36755 t["\uFD32"] = "\u0634\u0647";
36756 t["\uFD33"] = "\u0637\u0645";
36757 t["\uFD34"] = "\u0633\u062C";
36758 t["\uFD35"] = "\u0633\u062D";
36759 t["\uFD36"] = "\u0633\u062E";
36760 t["\uFD37"] = "\u0634\u062C";
36761 t["\uFD38"] = "\u0634\u062D";
36762 t["\uFD39"] = "\u0634\u062E";
36763 t["\uFD3A"] = "\u0637\u0645";
36764 t["\uFD3B"] = "\u0638\u0645";
36765 t["\uFD3C"] = "\u0627\u064B";
36766 t["\uFD3D"] = "\u0627\u064B";
36767 t["\uFD50"] = "\u062A\u062C\u0645";
36768 t["\uFD51"] = "\u062A\u062D\u062C";
36769 t["\uFD52"] = "\u062A\u062D\u062C";
36770 t["\uFD53"] = "\u062A\u062D\u0645";
36771 t["\uFD54"] = "\u062A\u062E\u0645";
36772 t["\uFD55"] = "\u062A\u0645\u062C";
36773 t["\uFD56"] = "\u062A\u0645\u062D";
36774 t["\uFD57"] = "\u062A\u0645\u062E";
36775 t["\uFD58"] = "\u062C\u0645\u062D";
36776 t["\uFD59"] = "\u062C\u0645\u062D";
36777 t["\uFD5A"] = "\u062D\u0645\u064A";
36778 t["\uFD5B"] = "\u062D\u0645\u0649";
36779 t["\uFD5C"] = "\u0633\u062D\u062C";
36780 t["\uFD5D"] = "\u0633\u062C\u062D";
36781 t["\uFD5E"] = "\u0633\u062C\u0649";
36782 t["\uFD5F"] = "\u0633\u0645\u062D";
36783 t["\uFD60"] = "\u0633\u0645\u062D";
36784 t["\uFD61"] = "\u0633\u0645\u062C";
36785 t["\uFD62"] = "\u0633\u0645\u0645";
36786 t["\uFD63"] = "\u0633\u0645\u0645";
36787 t["\uFD64"] = "\u0635\u062D\u062D";
36788 t["\uFD65"] = "\u0635\u062D\u062D";
36789 t["\uFD66"] = "\u0635\u0645\u0645";
36790 t["\uFD67"] = "\u0634\u062D\u0645";
36791 t["\uFD68"] = "\u0634\u062D\u0645";
36792 t["\uFD69"] = "\u0634\u062C\u064A";
36793 t["\uFD6A"] = "\u0634\u0645\u062E";
36794 t["\uFD6B"] = "\u0634\u0645\u062E";
36795 t["\uFD6C"] = "\u0634\u0645\u0645";
36796 t["\uFD6D"] = "\u0634\u0645\u0645";
36797 t["\uFD6E"] = "\u0636\u062D\u0649";
36798 t["\uFD6F"] = "\u0636\u062E\u0645";
36799 t["\uFD70"] = "\u0636\u062E\u0645";
36800 t["\uFD71"] = "\u0637\u0645\u062D";
36801 t["\uFD72"] = "\u0637\u0645\u062D";
36802 t["\uFD73"] = "\u0637\u0645\u0645";
36803 t["\uFD74"] = "\u0637\u0645\u064A";
36804 t["\uFD75"] = "\u0639\u062C\u0645";
36805 t["\uFD76"] = "\u0639\u0645\u0645";
36806 t["\uFD77"] = "\u0639\u0645\u0645";
36807 t["\uFD78"] = "\u0639\u0645\u0649";
36808 t["\uFD79"] = "\u063A\u0645\u0645";
36809 t["\uFD7A"] = "\u063A\u0645\u064A";
36810 t["\uFD7B"] = "\u063A\u0645\u0649";
36811 t["\uFD7C"] = "\u0641\u062E\u0645";
36812 t["\uFD7D"] = "\u0641\u062E\u0645";
36813 t["\uFD7E"] = "\u0642\u0645\u062D";
36814 t["\uFD7F"] = "\u0642\u0645\u0645";
36815 t["\uFD80"] = "\u0644\u062D\u0645";
36816 t["\uFD81"] = "\u0644\u062D\u064A";
36817 t["\uFD82"] = "\u0644\u062D\u0649";
36818 t["\uFD83"] = "\u0644\u062C\u062C";
36819 t["\uFD84"] = "\u0644\u062C\u062C";
36820 t["\uFD85"] = "\u0644\u062E\u0645";
36821 t["\uFD86"] = "\u0644\u062E\u0645";
36822 t["\uFD87"] = "\u0644\u0645\u062D";
36823 t["\uFD88"] = "\u0644\u0645\u062D";
36824 t["\uFD89"] = "\u0645\u062D\u062C";
36825 t["\uFD8A"] = "\u0645\u062D\u0645";
36826 t["\uFD8B"] = "\u0645\u062D\u064A";
36827 t["\uFD8C"] = "\u0645\u062C\u062D";
36828 t["\uFD8D"] = "\u0645\u062C\u0645";
36829 t["\uFD8E"] = "\u0645\u062E\u062C";
36830 t["\uFD8F"] = "\u0645\u062E\u0645";
36831 t["\uFD92"] = "\u0645\u062C\u062E";
36832 t["\uFD93"] = "\u0647\u0645\u062C";
36833 t["\uFD94"] = "\u0647\u0645\u0645";
36834 t["\uFD95"] = "\u0646\u062D\u0645";
36835 t["\uFD96"] = "\u0646\u062D\u0649";
36836 t["\uFD97"] = "\u0646\u062C\u0645";
36837 t["\uFD98"] = "\u0646\u062C\u0645";
36838 t["\uFD99"] = "\u0646\u062C\u0649";
36839 t["\uFD9A"] = "\u0646\u0645\u064A";
36840 t["\uFD9B"] = "\u0646\u0645\u0649";
36841 t["\uFD9C"] = "\u064A\u0645\u0645";
36842 t["\uFD9D"] = "\u064A\u0645\u0645";
36843 t["\uFD9E"] = "\u0628\u062E\u064A";
36844 t["\uFD9F"] = "\u062A\u062C\u064A";
36845 t["\uFDA0"] = "\u062A\u062C\u0649";
36846 t["\uFDA1"] = "\u062A\u062E\u064A";
36847 t["\uFDA2"] = "\u062A\u062E\u0649";
36848 t["\uFDA3"] = "\u062A\u0645\u064A";
36849 t["\uFDA4"] = "\u062A\u0645\u0649";
36850 t["\uFDA5"] = "\u062C\u0645\u064A";
36851 t["\uFDA6"] = "\u062C\u062D\u0649";
36852 t["\uFDA7"] = "\u062C\u0645\u0649";
36853 t["\uFDA8"] = "\u0633\u062E\u0649";
36854 t["\uFDA9"] = "\u0635\u062D\u064A";
36855 t["\uFDAA"] = "\u0634\u062D\u064A";
36856 t["\uFDAB"] = "\u0636\u062D\u064A";
36857 t["\uFDAC"] = "\u0644\u062C\u064A";
36858 t["\uFDAD"] = "\u0644\u0645\u064A";
36859 t["\uFDAE"] = "\u064A\u062D\u064A";
36860 t["\uFDAF"] = "\u064A\u062C\u064A";
36861 t["\uFDB0"] = "\u064A\u0645\u064A";
36862 t["\uFDB1"] = "\u0645\u0645\u064A";
36863 t["\uFDB2"] = "\u0642\u0645\u064A";
36864 t["\uFDB3"] = "\u0646\u062D\u064A";
36865 t["\uFDB4"] = "\u0642\u0645\u062D";
36866 t["\uFDB5"] = "\u0644\u062D\u0645";
36867 t["\uFDB6"] = "\u0639\u0645\u064A";
36868 t["\uFDB7"] = "\u0643\u0645\u064A";
36869 t["\uFDB8"] = "\u0646\u062C\u062D";
36870 t["\uFDB9"] = "\u0645\u062E\u064A";
36871 t["\uFDBA"] = "\u0644\u062C\u0645";
36872 t["\uFDBB"] = "\u0643\u0645\u0645";
36873 t["\uFDBC"] = "\u0644\u062C\u0645";
36874 t["\uFDBD"] = "\u0646\u062C\u062D";
36875 t["\uFDBE"] = "\u062C\u062D\u064A";
36876 t["\uFDBF"] = "\u062D\u062C\u064A";
36877 t["\uFDC0"] = "\u0645\u062C\u064A";
36878 t["\uFDC1"] = "\u0641\u0645\u064A";
36879 t["\uFDC2"] = "\u0628\u062D\u064A";
36880 t["\uFDC3"] = "\u0643\u0645\u0645";
36881 t["\uFDC4"] = "\u0639\u062C\u0645";
36882 t["\uFDC5"] = "\u0635\u0645\u0645";
36883 t["\uFDC6"] = "\u0633\u062E\u064A";
36884 t["\uFDC7"] = "\u0646\u062C\u064A";
36885 t["\uFE49"] = "\u203E";
36886 t["\uFE4A"] = "\u203E";
36887 t["\uFE4B"] = "\u203E";
36888 t["\uFE4C"] = "\u203E";
36889 t["\uFE4D"] = "\u005F";
36890 t["\uFE4E"] = "\u005F";
36891 t["\uFE4F"] = "\u005F";
36892 t["\uFE80"] = "\u0621";
36893 t["\uFE81"] = "\u0622";
36894 t["\uFE82"] = "\u0622";
36895 t["\uFE83"] = "\u0623";
36896 t["\uFE84"] = "\u0623";
36897 t["\uFE85"] = "\u0624";
36898 t["\uFE86"] = "\u0624";
36899 t["\uFE87"] = "\u0625";
36900 t["\uFE88"] = "\u0625";
36901 t["\uFE89"] = "\u0626";
36902 t["\uFE8A"] = "\u0626";
36903 t["\uFE8B"] = "\u0626";
36904 t["\uFE8C"] = "\u0626";
36905 t["\uFE8D"] = "\u0627";
36906 t["\uFE8E"] = "\u0627";
36907 t["\uFE8F"] = "\u0628";
36908 t["\uFE90"] = "\u0628";
36909 t["\uFE91"] = "\u0628";
36910 t["\uFE92"] = "\u0628";
36911 t["\uFE93"] = "\u0629";
36912 t["\uFE94"] = "\u0629";
36913 t["\uFE95"] = "\u062A";
36914 t["\uFE96"] = "\u062A";
36915 t["\uFE97"] = "\u062A";
36916 t["\uFE98"] = "\u062A";
36917 t["\uFE99"] = "\u062B";
36918 t["\uFE9A"] = "\u062B";
36919 t["\uFE9B"] = "\u062B";
36920 t["\uFE9C"] = "\u062B";
36921 t["\uFE9D"] = "\u062C";
36922 t["\uFE9E"] = "\u062C";
36923 t["\uFE9F"] = "\u062C";
36924 t["\uFEA0"] = "\u062C";
36925 t["\uFEA1"] = "\u062D";
36926 t["\uFEA2"] = "\u062D";
36927 t["\uFEA3"] = "\u062D";
36928 t["\uFEA4"] = "\u062D";
36929 t["\uFEA5"] = "\u062E";
36930 t["\uFEA6"] = "\u062E";
36931 t["\uFEA7"] = "\u062E";
36932 t["\uFEA8"] = "\u062E";
36933 t["\uFEA9"] = "\u062F";
36934 t["\uFEAA"] = "\u062F";
36935 t["\uFEAB"] = "\u0630";
36936 t["\uFEAC"] = "\u0630";
36937 t["\uFEAD"] = "\u0631";
36938 t["\uFEAE"] = "\u0631";
36939 t["\uFEAF"] = "\u0632";
36940 t["\uFEB0"] = "\u0632";
36941 t["\uFEB1"] = "\u0633";
36942 t["\uFEB2"] = "\u0633";
36943 t["\uFEB3"] = "\u0633";
36944 t["\uFEB4"] = "\u0633";
36945 t["\uFEB5"] = "\u0634";
36946 t["\uFEB6"] = "\u0634";
36947 t["\uFEB7"] = "\u0634";
36948 t["\uFEB8"] = "\u0634";
36949 t["\uFEB9"] = "\u0635";
36950 t["\uFEBA"] = "\u0635";
36951 t["\uFEBB"] = "\u0635";
36952 t["\uFEBC"] = "\u0635";
36953 t["\uFEBD"] = "\u0636";
36954 t["\uFEBE"] = "\u0636";
36955 t["\uFEBF"] = "\u0636";
36956 t["\uFEC0"] = "\u0636";
36957 t["\uFEC1"] = "\u0637";
36958 t["\uFEC2"] = "\u0637";
36959 t["\uFEC3"] = "\u0637";
36960 t["\uFEC4"] = "\u0637";
36961 t["\uFEC5"] = "\u0638";
36962 t["\uFEC6"] = "\u0638";
36963 t["\uFEC7"] = "\u0638";
36964 t["\uFEC8"] = "\u0638";
36965 t["\uFEC9"] = "\u0639";
36966 t["\uFECA"] = "\u0639";
36967 t["\uFECB"] = "\u0639";
36968 t["\uFECC"] = "\u0639";
36969 t["\uFECD"] = "\u063A";
36970 t["\uFECE"] = "\u063A";
36971 t["\uFECF"] = "\u063A";
36972 t["\uFED0"] = "\u063A";
36973 t["\uFED1"] = "\u0641";
36974 t["\uFED2"] = "\u0641";
36975 t["\uFED3"] = "\u0641";
36976 t["\uFED4"] = "\u0641";
36977 t["\uFED5"] = "\u0642";
36978 t["\uFED6"] = "\u0642";
36979 t["\uFED7"] = "\u0642";
36980 t["\uFED8"] = "\u0642";
36981 t["\uFED9"] = "\u0643";
36982 t["\uFEDA"] = "\u0643";
36983 t["\uFEDB"] = "\u0643";
36984 t["\uFEDC"] = "\u0643";
36985 t["\uFEDD"] = "\u0644";
36986 t["\uFEDE"] = "\u0644";
36987 t["\uFEDF"] = "\u0644";
36988 t["\uFEE0"] = "\u0644";
36989 t["\uFEE1"] = "\u0645";
36990 t["\uFEE2"] = "\u0645";
36991 t["\uFEE3"] = "\u0645";
36992 t["\uFEE4"] = "\u0645";
36993 t["\uFEE5"] = "\u0646";
36994 t["\uFEE6"] = "\u0646";
36995 t["\uFEE7"] = "\u0646";
36996 t["\uFEE8"] = "\u0646";
36997 t["\uFEE9"] = "\u0647";
36998 t["\uFEEA"] = "\u0647";
36999 t["\uFEEB"] = "\u0647";
37000 t["\uFEEC"] = "\u0647";
37001 t["\uFEED"] = "\u0648";
37002 t["\uFEEE"] = "\u0648";
37003 t["\uFEEF"] = "\u0649";
37004 t["\uFEF0"] = "\u0649";
37005 t["\uFEF1"] = "\u064A";
37006 t["\uFEF2"] = "\u064A";
37007 t["\uFEF3"] = "\u064A";
37008 t["\uFEF4"] = "\u064A";
37009 t["\uFEF5"] = "\u0644\u0622";
37010 t["\uFEF6"] = "\u0644\u0622";
37011 t["\uFEF7"] = "\u0644\u0623";
37012 t["\uFEF8"] = "\u0644\u0623";
37013 t["\uFEF9"] = "\u0644\u0625";
37014 t["\uFEFA"] = "\u0644\u0625";
37015 t["\uFEFB"] = "\u0644\u0627";
37016 t["\uFEFC"] = "\u0644\u0627";
37017});
37018function reverseIfRtl(chars) {
37019 var charsLength = chars.length;
37020 if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
37021 return chars;
37022 }
37023 var s = "";
37024 for (var ii = charsLength - 1; ii >= 0; ii--) {
37025 s += chars[ii];
37026 }
37027 return s;
37028}
37029exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
37030exports.reverseIfRtl = reverseIfRtl;
37031exports.getUnicodeRangeFor = getUnicodeRangeFor;
37032exports.getNormalizedUnicodes = getNormalizedUnicodes;
37033exports.getUnicodeForGlyph = getUnicodeForGlyph;
37034
37035/***/ }),
37036/* 36 */
37037/***/ (function(module, exports, __w_pdfjs_require__) {
37038
37039"use strict";
37040
37041
37042Object.defineProperty(exports, "__esModule", {
37043 value: true
37044});
37045exports.FontRendererFactory = void 0;
37046
37047var _util = __w_pdfjs_require__(2);
37048
37049var _cff_parser = __w_pdfjs_require__(30);
37050
37051var _glyphlist = __w_pdfjs_require__(33);
37052
37053var _encodings = __w_pdfjs_require__(32);
37054
37055var _stream = __w_pdfjs_require__(12);
37056
37057var FontRendererFactory = function FontRendererFactoryClosure() {
37058 function getLong(data, offset) {
37059 return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
37060 }
37061
37062 function getUshort(data, offset) {
37063 return data[offset] << 8 | data[offset + 1];
37064 }
37065
37066 function getSubroutineBias(subrs) {
37067 const numSubrs = subrs.length;
37068 let bias = 32768;
37069
37070 if (numSubrs < 1240) {
37071 bias = 107;
37072 } else if (numSubrs < 33900) {
37073 bias = 1131;
37074 }
37075
37076 return bias;
37077 }
37078
37079 function parseCmap(data, start, end) {
37080 var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
37081 var format = getUshort(data, start + offset);
37082 var ranges, p, i;
37083
37084 if (format === 4) {
37085 getUshort(data, start + offset + 2);
37086 var segCount = getUshort(data, start + offset + 6) >> 1;
37087 p = start + offset + 14;
37088 ranges = [];
37089
37090 for (i = 0; i < segCount; i++, p += 2) {
37091 ranges[i] = {
37092 end: getUshort(data, p)
37093 };
37094 }
37095
37096 p += 2;
37097
37098 for (i = 0; i < segCount; i++, p += 2) {
37099 ranges[i].start = getUshort(data, p);
37100 }
37101
37102 for (i = 0; i < segCount; i++, p += 2) {
37103 ranges[i].idDelta = getUshort(data, p);
37104 }
37105
37106 for (i = 0; i < segCount; i++, p += 2) {
37107 var idOffset = getUshort(data, p);
37108
37109 if (idOffset === 0) {
37110 continue;
37111 }
37112
37113 ranges[i].ids = [];
37114
37115 for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
37116 ranges[i].ids[j] = getUshort(data, p + idOffset);
37117 idOffset += 2;
37118 }
37119 }
37120
37121 return ranges;
37122 } else if (format === 12) {
37123 getLong(data, start + offset + 4);
37124 var groups = getLong(data, start + offset + 12);
37125 p = start + offset + 16;
37126 ranges = [];
37127
37128 for (i = 0; i < groups; i++) {
37129 ranges.push({
37130 start: getLong(data, p),
37131 end: getLong(data, p + 4),
37132 idDelta: getLong(data, p + 8) - getLong(data, p)
37133 });
37134 p += 12;
37135 }
37136
37137 return ranges;
37138 }
37139
37140 throw new _util.FormatError(`unsupported cmap: ${format}`);
37141 }
37142
37143 function parseCff(data, start, end, seacAnalysisEnabled) {
37144 var properties = {};
37145 var parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
37146 var cff = parser.parse();
37147 return {
37148 glyphs: cff.charStrings.objects,
37149 subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
37150 gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects,
37151 isCFFCIDFont: cff.isCIDFont,
37152 fdSelect: cff.fdSelect,
37153 fdArray: cff.fdArray
37154 };
37155 }
37156
37157 function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
37158 var itemSize, itemDecode;
37159
37160 if (isGlyphLocationsLong) {
37161 itemSize = 4;
37162
37163 itemDecode = function fontItemDecodeLong(data, offset) {
37164 return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
37165 };
37166 } else {
37167 itemSize = 2;
37168
37169 itemDecode = function fontItemDecode(data, offset) {
37170 return data[offset] << 9 | data[offset + 1] << 1;
37171 };
37172 }
37173
37174 var glyphs = [];
37175 var startOffset = itemDecode(loca, 0);
37176
37177 for (var j = itemSize; j < loca.length; j += itemSize) {
37178 var endOffset = itemDecode(loca, j);
37179 glyphs.push(glyf.subarray(startOffset, endOffset));
37180 startOffset = endOffset;
37181 }
37182
37183 return glyphs;
37184 }
37185
37186 function lookupCmap(ranges, unicode) {
37187 var code = unicode.codePointAt(0),
37188 gid = 0;
37189 var l = 0,
37190 r = ranges.length - 1;
37191
37192 while (l < r) {
37193 var c = l + r + 1 >> 1;
37194
37195 if (code < ranges[c].start) {
37196 r = c - 1;
37197 } else {
37198 l = c;
37199 }
37200 }
37201
37202 if (ranges[l].start <= code && code <= ranges[l].end) {
37203 gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xffff;
37204 }
37205
37206 return {
37207 charCode: code,
37208 glyphId: gid
37209 };
37210 }
37211
37212 function compileGlyf(code, cmds, font) {
37213 function moveTo(x, y) {
37214 cmds.push({
37215 cmd: "moveTo",
37216 args: [x, y]
37217 });
37218 }
37219
37220 function lineTo(x, y) {
37221 cmds.push({
37222 cmd: "lineTo",
37223 args: [x, y]
37224 });
37225 }
37226
37227 function quadraticCurveTo(xa, ya, x, y) {
37228 cmds.push({
37229 cmd: "quadraticCurveTo",
37230 args: [xa, ya, x, y]
37231 });
37232 }
37233
37234 var i = 0;
37235 var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
37236 var flags;
37237 var x = 0,
37238 y = 0;
37239 i += 10;
37240
37241 if (numberOfContours < 0) {
37242 do {
37243 flags = code[i] << 8 | code[i + 1];
37244 var glyphIndex = code[i + 2] << 8 | code[i + 3];
37245 i += 4;
37246 var arg1, arg2;
37247
37248 if (flags & 0x01) {
37249 arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
37250 arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
37251 i += 4;
37252 } else {
37253 arg1 = code[i++];
37254 arg2 = code[i++];
37255 }
37256
37257 if (flags & 0x02) {
37258 x = arg1;
37259 y = arg2;
37260 } else {
37261 x = 0;
37262 y = 0;
37263 }
37264
37265 var scaleX = 1,
37266 scaleY = 1,
37267 scale01 = 0,
37268 scale10 = 0;
37269
37270 if (flags & 0x08) {
37271 scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
37272 i += 2;
37273 } else if (flags & 0x40) {
37274 scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
37275 scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
37276 i += 4;
37277 } else if (flags & 0x80) {
37278 scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
37279 scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
37280 scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
37281 scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
37282 i += 8;
37283 }
37284
37285 var subglyph = font.glyphs[glyphIndex];
37286
37287 if (subglyph) {
37288 cmds.push({
37289 cmd: "save"
37290 });
37291 cmds.push({
37292 cmd: "transform",
37293 args: [scaleX, scale01, scale10, scaleY, x, y]
37294 });
37295 compileGlyf(subglyph, cmds, font);
37296 cmds.push({
37297 cmd: "restore"
37298 });
37299 }
37300 } while (flags & 0x20);
37301 } else {
37302 var endPtsOfContours = [];
37303 var j, jj;
37304
37305 for (j = 0; j < numberOfContours; j++) {
37306 endPtsOfContours.push(code[i] << 8 | code[i + 1]);
37307 i += 2;
37308 }
37309
37310 var instructionLength = code[i] << 8 | code[i + 1];
37311 i += 2 + instructionLength;
37312 var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
37313 var points = [];
37314
37315 while (points.length < numberOfPoints) {
37316 flags = code[i++];
37317 var repeat = 1;
37318
37319 if (flags & 0x08) {
37320 repeat += code[i++];
37321 }
37322
37323 while (repeat-- > 0) {
37324 points.push({
37325 flags
37326 });
37327 }
37328 }
37329
37330 for (j = 0; j < numberOfPoints; j++) {
37331 switch (points[j].flags & 0x12) {
37332 case 0x00:
37333 x += (code[i] << 24 | code[i + 1] << 16) >> 16;
37334 i += 2;
37335 break;
37336
37337 case 0x02:
37338 x -= code[i++];
37339 break;
37340
37341 case 0x12:
37342 x += code[i++];
37343 break;
37344 }
37345
37346 points[j].x = x;
37347 }
37348
37349 for (j = 0; j < numberOfPoints; j++) {
37350 switch (points[j].flags & 0x24) {
37351 case 0x00:
37352 y += (code[i] << 24 | code[i + 1] << 16) >> 16;
37353 i += 2;
37354 break;
37355
37356 case 0x04:
37357 y -= code[i++];
37358 break;
37359
37360 case 0x24:
37361 y += code[i++];
37362 break;
37363 }
37364
37365 points[j].y = y;
37366 }
37367
37368 var startPoint = 0;
37369
37370 for (i = 0; i < numberOfContours; i++) {
37371 var endPoint = endPtsOfContours[i];
37372 var contour = points.slice(startPoint, endPoint + 1);
37373
37374 if (contour[0].flags & 1) {
37375 contour.push(contour[0]);
37376 } else if (contour[contour.length - 1].flags & 1) {
37377 contour.unshift(contour[contour.length - 1]);
37378 } else {
37379 var p = {
37380 flags: 1,
37381 x: (contour[0].x + contour[contour.length - 1].x) / 2,
37382 y: (contour[0].y + contour[contour.length - 1].y) / 2
37383 };
37384 contour.unshift(p);
37385 contour.push(p);
37386 }
37387
37388 moveTo(contour[0].x, contour[0].y);
37389
37390 for (j = 1, jj = contour.length; j < jj; j++) {
37391 if (contour[j].flags & 1) {
37392 lineTo(contour[j].x, contour[j].y);
37393 } else if (contour[j + 1].flags & 1) {
37394 quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
37395 j++;
37396 } else {
37397 quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
37398 }
37399 }
37400
37401 startPoint = endPoint + 1;
37402 }
37403 }
37404 }
37405
37406 function compileCharString(charStringCode, cmds, font, glyphId) {
37407 function moveTo(x, y) {
37408 cmds.push({
37409 cmd: "moveTo",
37410 args: [x, y]
37411 });
37412 }
37413
37414 function lineTo(x, y) {
37415 cmds.push({
37416 cmd: "lineTo",
37417 args: [x, y]
37418 });
37419 }
37420
37421 function bezierCurveTo(x1, y1, x2, y2, x, y) {
37422 cmds.push({
37423 cmd: "bezierCurveTo",
37424 args: [x1, y1, x2, y2, x, y]
37425 });
37426 }
37427
37428 var stack = [];
37429 var x = 0,
37430 y = 0;
37431 var stems = 0;
37432
37433 function parse(code) {
37434 var i = 0;
37435
37436 while (i < code.length) {
37437 var stackClean = false;
37438 var v = code[i++];
37439 var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
37440
37441 switch (v) {
37442 case 1:
37443 stems += stack.length >> 1;
37444 stackClean = true;
37445 break;
37446
37447 case 3:
37448 stems += stack.length >> 1;
37449 stackClean = true;
37450 break;
37451
37452 case 4:
37453 y += stack.pop();
37454 moveTo(x, y);
37455 stackClean = true;
37456 break;
37457
37458 case 5:
37459 while (stack.length > 0) {
37460 x += stack.shift();
37461 y += stack.shift();
37462 lineTo(x, y);
37463 }
37464
37465 break;
37466
37467 case 6:
37468 while (stack.length > 0) {
37469 x += stack.shift();
37470 lineTo(x, y);
37471
37472 if (stack.length === 0) {
37473 break;
37474 }
37475
37476 y += stack.shift();
37477 lineTo(x, y);
37478 }
37479
37480 break;
37481
37482 case 7:
37483 while (stack.length > 0) {
37484 y += stack.shift();
37485 lineTo(x, y);
37486
37487 if (stack.length === 0) {
37488 break;
37489 }
37490
37491 x += stack.shift();
37492 lineTo(x, y);
37493 }
37494
37495 break;
37496
37497 case 8:
37498 while (stack.length > 0) {
37499 xa = x + stack.shift();
37500 ya = y + stack.shift();
37501 xb = xa + stack.shift();
37502 yb = ya + stack.shift();
37503 x = xb + stack.shift();
37504 y = yb + stack.shift();
37505 bezierCurveTo(xa, ya, xb, yb, x, y);
37506 }
37507
37508 break;
37509
37510 case 10:
37511 n = stack.pop();
37512 subrCode = null;
37513
37514 if (font.isCFFCIDFont) {
37515 const fdIndex = font.fdSelect.getFDIndex(glyphId);
37516
37517 if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
37518 const fontDict = font.fdArray[fdIndex];
37519 let subrs;
37520
37521 if (fontDict.privateDict && fontDict.privateDict.subrsIndex) {
37522 subrs = fontDict.privateDict.subrsIndex.objects;
37523 }
37524
37525 if (subrs) {
37526 n += getSubroutineBias(subrs);
37527 subrCode = subrs[n];
37528 }
37529 } else {
37530 (0, _util.warn)("Invalid fd index for glyph index.");
37531 }
37532 } else {
37533 subrCode = font.subrs[n + font.subrsBias];
37534 }
37535
37536 if (subrCode) {
37537 parse(subrCode);
37538 }
37539
37540 break;
37541
37542 case 11:
37543 return;
37544
37545 case 12:
37546 v = code[i++];
37547
37548 switch (v) {
37549 case 34:
37550 xa = x + stack.shift();
37551 xb = xa + stack.shift();
37552 y1 = y + stack.shift();
37553 x = xb + stack.shift();
37554 bezierCurveTo(xa, y, xb, y1, x, y1);
37555 xa = x + stack.shift();
37556 xb = xa + stack.shift();
37557 x = xb + stack.shift();
37558 bezierCurveTo(xa, y1, xb, y, x, y);
37559 break;
37560
37561 case 35:
37562 xa = x + stack.shift();
37563 ya = y + stack.shift();
37564 xb = xa + stack.shift();
37565 yb = ya + stack.shift();
37566 x = xb + stack.shift();
37567 y = yb + stack.shift();
37568 bezierCurveTo(xa, ya, xb, yb, x, y);
37569 xa = x + stack.shift();
37570 ya = y + stack.shift();
37571 xb = xa + stack.shift();
37572 yb = ya + stack.shift();
37573 x = xb + stack.shift();
37574 y = yb + stack.shift();
37575 bezierCurveTo(xa, ya, xb, yb, x, y);
37576 stack.pop();
37577 break;
37578
37579 case 36:
37580 xa = x + stack.shift();
37581 y1 = y + stack.shift();
37582 xb = xa + stack.shift();
37583 y2 = y1 + stack.shift();
37584 x = xb + stack.shift();
37585 bezierCurveTo(xa, y1, xb, y2, x, y2);
37586 xa = x + stack.shift();
37587 xb = xa + stack.shift();
37588 y3 = y2 + stack.shift();
37589 x = xb + stack.shift();
37590 bezierCurveTo(xa, y2, xb, y3, x, y);
37591 break;
37592
37593 case 37:
37594 var x0 = x,
37595 y0 = y;
37596 xa = x + stack.shift();
37597 ya = y + stack.shift();
37598 xb = xa + stack.shift();
37599 yb = ya + stack.shift();
37600 x = xb + stack.shift();
37601 y = yb + stack.shift();
37602 bezierCurveTo(xa, ya, xb, yb, x, y);
37603 xa = x + stack.shift();
37604 ya = y + stack.shift();
37605 xb = xa + stack.shift();
37606 yb = ya + stack.shift();
37607 x = xb;
37608 y = yb;
37609
37610 if (Math.abs(x - x0) > Math.abs(y - y0)) {
37611 x += stack.shift();
37612 } else {
37613 y += stack.shift();
37614 }
37615
37616 bezierCurveTo(xa, ya, xb, yb, x, y);
37617 break;
37618
37619 default:
37620 throw new _util.FormatError(`unknown operator: 12 ${v}`);
37621 }
37622
37623 break;
37624
37625 case 14:
37626 if (stack.length >= 4) {
37627 var achar = stack.pop();
37628 var bchar = stack.pop();
37629 y = stack.pop();
37630 x = stack.pop();
37631 cmds.push({
37632 cmd: "save"
37633 });
37634 cmds.push({
37635 cmd: "translate",
37636 args: [x, y]
37637 });
37638 var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
37639 compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
37640 cmds.push({
37641 cmd: "restore"
37642 });
37643 cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
37644 compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
37645 }
37646
37647 return;
37648
37649 case 18:
37650 stems += stack.length >> 1;
37651 stackClean = true;
37652 break;
37653
37654 case 19:
37655 stems += stack.length >> 1;
37656 i += stems + 7 >> 3;
37657 stackClean = true;
37658 break;
37659
37660 case 20:
37661 stems += stack.length >> 1;
37662 i += stems + 7 >> 3;
37663 stackClean = true;
37664 break;
37665
37666 case 21:
37667 y += stack.pop();
37668 x += stack.pop();
37669 moveTo(x, y);
37670 stackClean = true;
37671 break;
37672
37673 case 22:
37674 x += stack.pop();
37675 moveTo(x, y);
37676 stackClean = true;
37677 break;
37678
37679 case 23:
37680 stems += stack.length >> 1;
37681 stackClean = true;
37682 break;
37683
37684 case 24:
37685 while (stack.length > 2) {
37686 xa = x + stack.shift();
37687 ya = y + stack.shift();
37688 xb = xa + stack.shift();
37689 yb = ya + stack.shift();
37690 x = xb + stack.shift();
37691 y = yb + stack.shift();
37692 bezierCurveTo(xa, ya, xb, yb, x, y);
37693 }
37694
37695 x += stack.shift();
37696 y += stack.shift();
37697 lineTo(x, y);
37698 break;
37699
37700 case 25:
37701 while (stack.length > 6) {
37702 x += stack.shift();
37703 y += stack.shift();
37704 lineTo(x, y);
37705 }
37706
37707 xa = x + stack.shift();
37708 ya = y + stack.shift();
37709 xb = xa + stack.shift();
37710 yb = ya + stack.shift();
37711 x = xb + stack.shift();
37712 y = yb + stack.shift();
37713 bezierCurveTo(xa, ya, xb, yb, x, y);
37714 break;
37715
37716 case 26:
37717 if (stack.length % 2) {
37718 x += stack.shift();
37719 }
37720
37721 while (stack.length > 0) {
37722 xa = x;
37723 ya = y + stack.shift();
37724 xb = xa + stack.shift();
37725 yb = ya + stack.shift();
37726 x = xb;
37727 y = yb + stack.shift();
37728 bezierCurveTo(xa, ya, xb, yb, x, y);
37729 }
37730
37731 break;
37732
37733 case 27:
37734 if (stack.length % 2) {
37735 y += stack.shift();
37736 }
37737
37738 while (stack.length > 0) {
37739 xa = x + stack.shift();
37740 ya = y;
37741 xb = xa + stack.shift();
37742 yb = ya + stack.shift();
37743 x = xb + stack.shift();
37744 y = yb;
37745 bezierCurveTo(xa, ya, xb, yb, x, y);
37746 }
37747
37748 break;
37749
37750 case 28:
37751 stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
37752 i += 2;
37753 break;
37754
37755 case 29:
37756 n = stack.pop() + font.gsubrsBias;
37757 subrCode = font.gsubrs[n];
37758
37759 if (subrCode) {
37760 parse(subrCode);
37761 }
37762
37763 break;
37764
37765 case 30:
37766 while (stack.length > 0) {
37767 xa = x;
37768 ya = y + stack.shift();
37769 xb = xa + stack.shift();
37770 yb = ya + stack.shift();
37771 x = xb + stack.shift();
37772 y = yb + (stack.length === 1 ? stack.shift() : 0);
37773 bezierCurveTo(xa, ya, xb, yb, x, y);
37774
37775 if (stack.length === 0) {
37776 break;
37777 }
37778
37779 xa = x + stack.shift();
37780 ya = y;
37781 xb = xa + stack.shift();
37782 yb = ya + stack.shift();
37783 y = yb + stack.shift();
37784 x = xb + (stack.length === 1 ? stack.shift() : 0);
37785 bezierCurveTo(xa, ya, xb, yb, x, y);
37786 }
37787
37788 break;
37789
37790 case 31:
37791 while (stack.length > 0) {
37792 xa = x + stack.shift();
37793 ya = y;
37794 xb = xa + stack.shift();
37795 yb = ya + stack.shift();
37796 y = yb + stack.shift();
37797 x = xb + (stack.length === 1 ? stack.shift() : 0);
37798 bezierCurveTo(xa, ya, xb, yb, x, y);
37799
37800 if (stack.length === 0) {
37801 break;
37802 }
37803
37804 xa = x;
37805 ya = y + stack.shift();
37806 xb = xa + stack.shift();
37807 yb = ya + stack.shift();
37808 x = xb + stack.shift();
37809 y = yb + (stack.length === 1 ? stack.shift() : 0);
37810 bezierCurveTo(xa, ya, xb, yb, x, y);
37811 }
37812
37813 break;
37814
37815 default:
37816 if (v < 32) {
37817 throw new _util.FormatError(`unknown operator: ${v}`);
37818 }
37819
37820 if (v < 247) {
37821 stack.push(v - 139);
37822 } else if (v < 251) {
37823 stack.push((v - 247) * 256 + code[i++] + 108);
37824 } else if (v < 255) {
37825 stack.push(-(v - 251) * 256 - code[i++] - 108);
37826 } else {
37827 stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
37828 i += 4;
37829 }
37830
37831 break;
37832 }
37833
37834 if (stackClean) {
37835 stack.length = 0;
37836 }
37837 }
37838 }
37839
37840 parse(charStringCode);
37841 }
37842
37843 const NOOP = [];
37844
37845 class CompiledFont {
37846 constructor(fontMatrix) {
37847 if (this.constructor === CompiledFont) {
37848 (0, _util.unreachable)("Cannot initialize CompiledFont.");
37849 }
37850
37851 this.fontMatrix = fontMatrix;
37852 this.compiledGlyphs = Object.create(null);
37853 this.compiledCharCodeToGlyphId = Object.create(null);
37854 }
37855
37856 getPathJs(unicode) {
37857 const cmap = lookupCmap(this.cmap, unicode);
37858 let fn = this.compiledGlyphs[cmap.glyphId];
37859
37860 if (!fn) {
37861 fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
37862 this.compiledGlyphs[cmap.glyphId] = fn;
37863 }
37864
37865 if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
37866 this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
37867 }
37868
37869 return fn;
37870 }
37871
37872 compileGlyph(code, glyphId) {
37873 if (!code || code.length === 0 || code[0] === 14) {
37874 return NOOP;
37875 }
37876
37877 let fontMatrix = this.fontMatrix;
37878
37879 if (this.isCFFCIDFont) {
37880 const fdIndex = this.fdSelect.getFDIndex(glyphId);
37881
37882 if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
37883 const fontDict = this.fdArray[fdIndex];
37884 fontMatrix = fontDict.getByName("FontMatrix") || _util.FONT_IDENTITY_MATRIX;
37885 } else {
37886 (0, _util.warn)("Invalid fd index for glyph index.");
37887 }
37888 }
37889
37890 const cmds = [];
37891 cmds.push({
37892 cmd: "save"
37893 });
37894 cmds.push({
37895 cmd: "transform",
37896 args: fontMatrix.slice()
37897 });
37898 cmds.push({
37899 cmd: "scale",
37900 args: ["size", "-size"]
37901 });
37902 this.compileGlyphImpl(code, cmds, glyphId);
37903 cmds.push({
37904 cmd: "restore"
37905 });
37906 return cmds;
37907 }
37908
37909 compileGlyphImpl() {
37910 (0, _util.unreachable)("Children classes should implement this.");
37911 }
37912
37913 hasBuiltPath(unicode) {
37914 const cmap = lookupCmap(this.cmap, unicode);
37915 return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
37916 }
37917
37918 }
37919
37920 class TrueTypeCompiled extends CompiledFont {
37921 constructor(glyphs, cmap, fontMatrix) {
37922 super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
37923 this.glyphs = glyphs;
37924 this.cmap = cmap;
37925 }
37926
37927 compileGlyphImpl(code, cmds) {
37928 compileGlyf(code, cmds, this);
37929 }
37930
37931 }
37932
37933 class Type2Compiled extends CompiledFont {
37934 constructor(cffInfo, cmap, fontMatrix, glyphNameMap) {
37935 super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
37936 this.glyphs = cffInfo.glyphs;
37937 this.gsubrs = cffInfo.gsubrs || [];
37938 this.subrs = cffInfo.subrs || [];
37939 this.cmap = cmap;
37940 this.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
37941 this.gsubrsBias = getSubroutineBias(this.gsubrs);
37942 this.subrsBias = getSubroutineBias(this.subrs);
37943 this.isCFFCIDFont = cffInfo.isCFFCIDFont;
37944 this.fdSelect = cffInfo.fdSelect;
37945 this.fdArray = cffInfo.fdArray;
37946 }
37947
37948 compileGlyphImpl(code, cmds, glyphId) {
37949 compileCharString(code, cmds, this, glyphId);
37950 }
37951
37952 }
37953
37954 return {
37955 create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
37956 var data = new Uint8Array(font.data);
37957 var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
37958 var numTables = getUshort(data, 4);
37959
37960 for (var i = 0, p = 12; i < numTables; i++, p += 16) {
37961 var tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
37962 var offset = getLong(data, p + 8);
37963 var length = getLong(data, p + 12);
37964
37965 switch (tag) {
37966 case "cmap":
37967 cmap = parseCmap(data, offset, offset + length);
37968 break;
37969
37970 case "glyf":
37971 glyf = data.subarray(offset, offset + length);
37972 break;
37973
37974 case "loca":
37975 loca = data.subarray(offset, offset + length);
37976 break;
37977
37978 case "head":
37979 unitsPerEm = getUshort(data, offset + 18);
37980 indexToLocFormat = getUshort(data, offset + 50);
37981 break;
37982
37983 case "CFF ":
37984 cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
37985 break;
37986 }
37987 }
37988
37989 if (glyf) {
37990 var fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
37991 return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
37992 }
37993
37994 return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
37995 }
37996 };
37997}();
37998
37999exports.FontRendererFactory = FontRendererFactory;
38000
38001/***/ }),
38002/* 37 */
38003/***/ (function(module, exports, __w_pdfjs_require__) {
38004
38005"use strict";
38006
38007
38008Object.defineProperty(exports, "__esModule", {
38009 value: true
38010});
38011exports.Type1Parser = void 0;
38012
38013var _encodings = __w_pdfjs_require__(32);
38014
38015var _core_utils = __w_pdfjs_require__(8);
38016
38017var _stream = __w_pdfjs_require__(12);
38018
38019var _util = __w_pdfjs_require__(2);
38020
38021var HINTING_ENABLED = false;
38022
38023var Type1CharString = function Type1CharStringClosure() {
38024 var COMMAND_MAP = {
38025 hstem: [1],
38026 vstem: [3],
38027 vmoveto: [4],
38028 rlineto: [5],
38029 hlineto: [6],
38030 vlineto: [7],
38031 rrcurveto: [8],
38032 callsubr: [10],
38033 flex: [12, 35],
38034 drop: [12, 18],
38035 endchar: [14],
38036 rmoveto: [21],
38037 hmoveto: [22],
38038 vhcurveto: [30],
38039 hvcurveto: [31]
38040 };
38041
38042 function Type1CharString() {
38043 this.width = 0;
38044 this.lsb = 0;
38045 this.flexing = false;
38046 this.output = [];
38047 this.stack = [];
38048 }
38049
38050 Type1CharString.prototype = {
38051 convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
38052 var count = encoded.length;
38053 var error = false;
38054 var wx, sbx, subrNumber;
38055
38056 for (var i = 0; i < count; i++) {
38057 var value = encoded[i];
38058
38059 if (value < 32) {
38060 if (value === 12) {
38061 value = (value << 8) + encoded[++i];
38062 }
38063
38064 switch (value) {
38065 case 1:
38066 if (!HINTING_ENABLED) {
38067 this.stack = [];
38068 break;
38069 }
38070
38071 error = this.executeCommand(2, COMMAND_MAP.hstem);
38072 break;
38073
38074 case 3:
38075 if (!HINTING_ENABLED) {
38076 this.stack = [];
38077 break;
38078 }
38079
38080 error = this.executeCommand(2, COMMAND_MAP.vstem);
38081 break;
38082
38083 case 4:
38084 if (this.flexing) {
38085 if (this.stack.length < 1) {
38086 error = true;
38087 break;
38088 }
38089
38090 var dy = this.stack.pop();
38091 this.stack.push(0, dy);
38092 break;
38093 }
38094
38095 error = this.executeCommand(1, COMMAND_MAP.vmoveto);
38096 break;
38097
38098 case 5:
38099 error = this.executeCommand(2, COMMAND_MAP.rlineto);
38100 break;
38101
38102 case 6:
38103 error = this.executeCommand(1, COMMAND_MAP.hlineto);
38104 break;
38105
38106 case 7:
38107 error = this.executeCommand(1, COMMAND_MAP.vlineto);
38108 break;
38109
38110 case 8:
38111 error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
38112 break;
38113
38114 case 9:
38115 this.stack = [];
38116 break;
38117
38118 case 10:
38119 if (this.stack.length < 1) {
38120 error = true;
38121 break;
38122 }
38123
38124 subrNumber = this.stack.pop();
38125
38126 if (!subrs[subrNumber]) {
38127 error = true;
38128 break;
38129 }
38130
38131 error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
38132 break;
38133
38134 case 11:
38135 return error;
38136
38137 case 13:
38138 if (this.stack.length < 2) {
38139 error = true;
38140 break;
38141 }
38142
38143 wx = this.stack.pop();
38144 sbx = this.stack.pop();
38145 this.lsb = sbx;
38146 this.width = wx;
38147 this.stack.push(wx, sbx);
38148 error = this.executeCommand(2, COMMAND_MAP.hmoveto);
38149 break;
38150
38151 case 14:
38152 this.output.push(COMMAND_MAP.endchar[0]);
38153 break;
38154
38155 case 21:
38156 if (this.flexing) {
38157 break;
38158 }
38159
38160 error = this.executeCommand(2, COMMAND_MAP.rmoveto);
38161 break;
38162
38163 case 22:
38164 if (this.flexing) {
38165 this.stack.push(0);
38166 break;
38167 }
38168
38169 error = this.executeCommand(1, COMMAND_MAP.hmoveto);
38170 break;
38171
38172 case 30:
38173 error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
38174 break;
38175
38176 case 31:
38177 error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
38178 break;
38179
38180 case (12 << 8) + 0:
38181 this.stack = [];
38182 break;
38183
38184 case (12 << 8) + 1:
38185 if (!HINTING_ENABLED) {
38186 this.stack = [];
38187 break;
38188 }
38189
38190 error = this.executeCommand(2, COMMAND_MAP.vstem);
38191 break;
38192
38193 case (12 << 8) + 2:
38194 if (!HINTING_ENABLED) {
38195 this.stack = [];
38196 break;
38197 }
38198
38199 error = this.executeCommand(2, COMMAND_MAP.hstem);
38200 break;
38201
38202 case (12 << 8) + 6:
38203 if (seacAnalysisEnabled) {
38204 this.seac = this.stack.splice(-4, 4);
38205 error = this.executeCommand(0, COMMAND_MAP.endchar);
38206 } else {
38207 error = this.executeCommand(4, COMMAND_MAP.endchar);
38208 }
38209
38210 break;
38211
38212 case (12 << 8) + 7:
38213 if (this.stack.length < 4) {
38214 error = true;
38215 break;
38216 }
38217
38218 this.stack.pop();
38219 wx = this.stack.pop();
38220 var sby = this.stack.pop();
38221 sbx = this.stack.pop();
38222 this.lsb = sbx;
38223 this.width = wx;
38224 this.stack.push(wx, sbx, sby);
38225 error = this.executeCommand(3, COMMAND_MAP.rmoveto);
38226 break;
38227
38228 case (12 << 8) + 12:
38229 if (this.stack.length < 2) {
38230 error = true;
38231 break;
38232 }
38233
38234 var num2 = this.stack.pop();
38235 var num1 = this.stack.pop();
38236 this.stack.push(num1 / num2);
38237 break;
38238
38239 case (12 << 8) + 16:
38240 if (this.stack.length < 2) {
38241 error = true;
38242 break;
38243 }
38244
38245 subrNumber = this.stack.pop();
38246 var numArgs = this.stack.pop();
38247
38248 if (subrNumber === 0 && numArgs === 3) {
38249 var flexArgs = this.stack.splice(this.stack.length - 17, 17);
38250 this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);
38251 error = this.executeCommand(13, COMMAND_MAP.flex, true);
38252 this.flexing = false;
38253 this.stack.push(flexArgs[15], flexArgs[16]);
38254 } else if (subrNumber === 1 && numArgs === 0) {
38255 this.flexing = true;
38256 }
38257
38258 break;
38259
38260 case (12 << 8) + 17:
38261 break;
38262
38263 case (12 << 8) + 33:
38264 this.stack = [];
38265 break;
38266
38267 default:
38268 (0, _util.warn)('Unknown type 1 charstring command of "' + value + '"');
38269 break;
38270 }
38271
38272 if (error) {
38273 break;
38274 }
38275
38276 continue;
38277 } else if (value <= 246) {
38278 value = value - 139;
38279 } else if (value <= 250) {
38280 value = (value - 247) * 256 + encoded[++i] + 108;
38281 } else if (value <= 254) {
38282 value = -((value - 251) * 256) - encoded[++i] - 108;
38283 } else {
38284 value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
38285 }
38286
38287 this.stack.push(value);
38288 }
38289
38290 return error;
38291 },
38292
38293 executeCommand(howManyArgs, command, keepStack) {
38294 var stackLength = this.stack.length;
38295
38296 if (howManyArgs > stackLength) {
38297 return true;
38298 }
38299
38300 var start = stackLength - howManyArgs;
38301
38302 for (var i = start; i < stackLength; i++) {
38303 var value = this.stack[i];
38304
38305 if (Number.isInteger(value)) {
38306 this.output.push(28, value >> 8 & 0xff, value & 0xff);
38307 } else {
38308 value = 65536 * value | 0;
38309 this.output.push(255, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
38310 }
38311 }
38312
38313 this.output.push.apply(this.output, command);
38314
38315 if (keepStack) {
38316 this.stack.splice(start, howManyArgs);
38317 } else {
38318 this.stack.length = 0;
38319 }
38320
38321 return false;
38322 }
38323
38324 };
38325 return Type1CharString;
38326}();
38327
38328var Type1Parser = function Type1ParserClosure() {
38329 var EEXEC_ENCRYPT_KEY = 55665;
38330 var CHAR_STRS_ENCRYPT_KEY = 4330;
38331
38332 function isHexDigit(code) {
38333 return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
38334 }
38335
38336 function decrypt(data, key, discardNumber) {
38337 if (discardNumber >= data.length) {
38338 return new Uint8Array(0);
38339 }
38340
38341 var r = key | 0,
38342 c1 = 52845,
38343 c2 = 22719,
38344 i,
38345 j;
38346
38347 for (i = 0; i < discardNumber; i++) {
38348 r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
38349 }
38350
38351 var count = data.length - discardNumber;
38352 var decrypted = new Uint8Array(count);
38353
38354 for (i = discardNumber, j = 0; j < count; i++, j++) {
38355 var value = data[i];
38356 decrypted[j] = value ^ r >> 8;
38357 r = (value + r) * c1 + c2 & (1 << 16) - 1;
38358 }
38359
38360 return decrypted;
38361 }
38362
38363 function decryptAscii(data, key, discardNumber) {
38364 var r = key | 0,
38365 c1 = 52845,
38366 c2 = 22719;
38367 var count = data.length,
38368 maybeLength = count >>> 1;
38369 var decrypted = new Uint8Array(maybeLength);
38370 var i, j;
38371
38372 for (i = 0, j = 0; i < count; i++) {
38373 var digit1 = data[i];
38374
38375 if (!isHexDigit(digit1)) {
38376 continue;
38377 }
38378
38379 i++;
38380 var digit2;
38381
38382 while (i < count && !isHexDigit(digit2 = data[i])) {
38383 i++;
38384 }
38385
38386 if (i < count) {
38387 var value = parseInt(String.fromCharCode(digit1, digit2), 16);
38388 decrypted[j++] = value ^ r >> 8;
38389 r = (value + r) * c1 + c2 & (1 << 16) - 1;
38390 }
38391 }
38392
38393 return decrypted.slice(discardNumber, j);
38394 }
38395
38396 function isSpecial(c) {
38397 return c === 0x2f || c === 0x5b || c === 0x5d || c === 0x7b || c === 0x7d || c === 0x28 || c === 0x29;
38398 }
38399
38400 function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
38401 if (encrypted) {
38402 var data = stream.getBytes();
38403 var isBinary = !((isHexDigit(data[0]) || (0, _core_utils.isWhiteSpace)(data[0])) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]) && isHexDigit(data[4]) && isHexDigit(data[5]) && isHexDigit(data[6]) && isHexDigit(data[7]));
38404 stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
38405 }
38406
38407 this.seacAnalysisEnabled = !!seacAnalysisEnabled;
38408 this.stream = stream;
38409 this.nextChar();
38410 }
38411
38412 Type1Parser.prototype = {
38413 readNumberArray: function Type1Parser_readNumberArray() {
38414 this.getToken();
38415 var array = [];
38416
38417 while (true) {
38418 var token = this.getToken();
38419
38420 if (token === null || token === "]" || token === "}") {
38421 break;
38422 }
38423
38424 array.push(parseFloat(token || 0));
38425 }
38426
38427 return array;
38428 },
38429 readNumber: function Type1Parser_readNumber() {
38430 var token = this.getToken();
38431 return parseFloat(token || 0);
38432 },
38433 readInt: function Type1Parser_readInt() {
38434 var token = this.getToken();
38435 return parseInt(token || 0, 10) | 0;
38436 },
38437 readBoolean: function Type1Parser_readBoolean() {
38438 var token = this.getToken();
38439 return token === "true" ? 1 : 0;
38440 },
38441 nextChar: function Type1_nextChar() {
38442 return this.currentChar = this.stream.getByte();
38443 },
38444 getToken: function Type1Parser_getToken() {
38445 var comment = false;
38446 var ch = this.currentChar;
38447
38448 while (true) {
38449 if (ch === -1) {
38450 return null;
38451 }
38452
38453 if (comment) {
38454 if (ch === 0x0a || ch === 0x0d) {
38455 comment = false;
38456 }
38457 } else if (ch === 0x25) {
38458 comment = true;
38459 } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
38460 break;
38461 }
38462
38463 ch = this.nextChar();
38464 }
38465
38466 if (isSpecial(ch)) {
38467 this.nextChar();
38468 return String.fromCharCode(ch);
38469 }
38470
38471 var token = "";
38472
38473 do {
38474 token += String.fromCharCode(ch);
38475 ch = this.nextChar();
38476 } while (ch >= 0 && !(0, _core_utils.isWhiteSpace)(ch) && !isSpecial(ch));
38477
38478 return token;
38479 },
38480 readCharStrings: function Type1Parser_readCharStrings(bytes, lenIV) {
38481 if (lenIV === -1) {
38482 return bytes;
38483 }
38484
38485 return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
38486 },
38487 extractFontProgram: function Type1Parser_extractFontProgram(properties) {
38488 var stream = this.stream;
38489 var subrs = [],
38490 charstrings = [];
38491 var privateData = Object.create(null);
38492 privateData.lenIV = 4;
38493 var program = {
38494 subrs: [],
38495 charstrings: [],
38496 properties: {
38497 privateData
38498 }
38499 };
38500 var token, length, data, lenIV, encoded;
38501
38502 while ((token = this.getToken()) !== null) {
38503 if (token !== "/") {
38504 continue;
38505 }
38506
38507 token = this.getToken();
38508
38509 switch (token) {
38510 case "CharStrings":
38511 this.getToken();
38512 this.getToken();
38513 this.getToken();
38514 this.getToken();
38515
38516 while (true) {
38517 token = this.getToken();
38518
38519 if (token === null || token === "end") {
38520 break;
38521 }
38522
38523 if (token !== "/") {
38524 continue;
38525 }
38526
38527 var glyph = this.getToken();
38528 length = this.readInt();
38529 this.getToken();
38530 data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
38531 lenIV = program.properties.privateData.lenIV;
38532 encoded = this.readCharStrings(data, lenIV);
38533 this.nextChar();
38534 token = this.getToken();
38535
38536 if (token === "noaccess") {
38537 this.getToken();
38538 }
38539
38540 charstrings.push({
38541 glyph,
38542 encoded
38543 });
38544 }
38545
38546 break;
38547
38548 case "Subrs":
38549 this.readInt();
38550 this.getToken();
38551
38552 while (this.getToken() === "dup") {
38553 const index = this.readInt();
38554 length = this.readInt();
38555 this.getToken();
38556 data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
38557 lenIV = program.properties.privateData.lenIV;
38558 encoded = this.readCharStrings(data, lenIV);
38559 this.nextChar();
38560 token = this.getToken();
38561
38562 if (token === "noaccess") {
38563 this.getToken();
38564 }
38565
38566 subrs[index] = encoded;
38567 }
38568
38569 break;
38570
38571 case "BlueValues":
38572 case "OtherBlues":
38573 case "FamilyBlues":
38574 case "FamilyOtherBlues":
38575 var blueArray = this.readNumberArray();
38576
38577 if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
38578 program.properties.privateData[token] = blueArray;
38579 }
38580
38581 break;
38582
38583 case "StemSnapH":
38584 case "StemSnapV":
38585 program.properties.privateData[token] = this.readNumberArray();
38586 break;
38587
38588 case "StdHW":
38589 case "StdVW":
38590 program.properties.privateData[token] = this.readNumberArray()[0];
38591 break;
38592
38593 case "BlueShift":
38594 case "lenIV":
38595 case "BlueFuzz":
38596 case "BlueScale":
38597 case "LanguageGroup":
38598 case "ExpansionFactor":
38599 program.properties.privateData[token] = this.readNumber();
38600 break;
38601
38602 case "ForceBold":
38603 program.properties.privateData[token] = this.readBoolean();
38604 break;
38605 }
38606 }
38607
38608 for (var i = 0; i < charstrings.length; i++) {
38609 glyph = charstrings[i].glyph;
38610 encoded = charstrings[i].encoded;
38611 var charString = new Type1CharString();
38612 var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
38613 var output = charString.output;
38614
38615 if (error) {
38616 output = [14];
38617 }
38618
38619 const charStringObject = {
38620 glyphName: glyph,
38621 charstring: output,
38622 width: charString.width,
38623 lsb: charString.lsb,
38624 seac: charString.seac
38625 };
38626
38627 if (glyph === ".notdef") {
38628 program.charstrings.unshift(charStringObject);
38629 } else {
38630 program.charstrings.push(charStringObject);
38631 }
38632
38633 if (properties.builtInEncoding) {
38634 const index = properties.builtInEncoding.indexOf(glyph);
38635
38636 if (index > -1 && properties.widths[index] === undefined && index >= properties.firstChar && index <= properties.lastChar) {
38637 properties.widths[index] = charString.width;
38638 }
38639 }
38640 }
38641
38642 return program;
38643 },
38644 extractFontHeader: function Type1Parser_extractFontHeader(properties) {
38645 var token;
38646
38647 while ((token = this.getToken()) !== null) {
38648 if (token !== "/") {
38649 continue;
38650 }
38651
38652 token = this.getToken();
38653
38654 switch (token) {
38655 case "FontMatrix":
38656 var matrix = this.readNumberArray();
38657 properties.fontMatrix = matrix;
38658 break;
38659
38660 case "Encoding":
38661 var encodingArg = this.getToken();
38662 var encoding;
38663
38664 if (!/^\d+$/.test(encodingArg)) {
38665 encoding = (0, _encodings.getEncoding)(encodingArg);
38666 } else {
38667 encoding = [];
38668 var size = parseInt(encodingArg, 10) | 0;
38669 this.getToken();
38670
38671 for (var j = 0; j < size; j++) {
38672 token = this.getToken();
38673
38674 while (token !== "dup" && token !== "def") {
38675 token = this.getToken();
38676
38677 if (token === null) {
38678 return;
38679 }
38680 }
38681
38682 if (token === "def") {
38683 break;
38684 }
38685
38686 var index = this.readInt();
38687 this.getToken();
38688 var glyph = this.getToken();
38689 encoding[index] = glyph;
38690 this.getToken();
38691 }
38692 }
38693
38694 properties.builtInEncoding = encoding;
38695 break;
38696
38697 case "FontBBox":
38698 var fontBBox = this.readNumberArray();
38699 properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
38700 properties.descent = Math.min(fontBBox[1], fontBBox[3]);
38701 properties.ascentScaled = true;
38702 break;
38703 }
38704 }
38705 }
38706 };
38707 return Type1Parser;
38708}();
38709
38710exports.Type1Parser = Type1Parser;
38711
38712/***/ }),
38713/* 38 */
38714/***/ (function(module, exports, __w_pdfjs_require__) {
38715
38716"use strict";
38717
38718
38719Object.defineProperty(exports, "__esModule", {
38720 value: true
38721});
38722exports.getTilingPatternIR = getTilingPatternIR;
38723exports.Pattern = void 0;
38724
38725var _util = __w_pdfjs_require__(2);
38726
38727var _colorspace = __w_pdfjs_require__(23);
38728
38729var _primitives = __w_pdfjs_require__(5);
38730
38731var _core_utils = __w_pdfjs_require__(8);
38732
38733var ShadingType = {
38734 FUNCTION_BASED: 1,
38735 AXIAL: 2,
38736 RADIAL: 3,
38737 FREE_FORM_MESH: 4,
38738 LATTICE_FORM_MESH: 5,
38739 COONS_PATCH_MESH: 6,
38740 TENSOR_PATCH_MESH: 7
38741};
38742
38743var Pattern = function PatternClosure() {
38744 function Pattern() {
38745 (0, _util.unreachable)("should not call Pattern constructor");
38746 }
38747
38748 Pattern.prototype = {
38749 getPattern: function Pattern_getPattern(ctx) {
38750 (0, _util.unreachable)(`Should not call Pattern.getStyle: ${ctx}`);
38751 }
38752 };
38753
38754 Pattern.parseShading = function (shading, matrix, xref, res, handler, pdfFunctionFactory) {
38755 var dict = (0, _primitives.isStream)(shading) ? shading.dict : shading;
38756 var type = dict.get("ShadingType");
38757
38758 try {
38759 switch (type) {
38760 case ShadingType.AXIAL:
38761 case ShadingType.RADIAL:
38762 return new Shadings.RadialAxial(dict, matrix, xref, res, pdfFunctionFactory);
38763
38764 case ShadingType.FREE_FORM_MESH:
38765 case ShadingType.LATTICE_FORM_MESH:
38766 case ShadingType.COONS_PATCH_MESH:
38767 case ShadingType.TENSOR_PATCH_MESH:
38768 return new Shadings.Mesh(shading, matrix, xref, res, pdfFunctionFactory);
38769
38770 default:
38771 throw new _util.FormatError("Unsupported ShadingType: " + type);
38772 }
38773 } catch (ex) {
38774 if (ex instanceof _core_utils.MissingDataException) {
38775 throw ex;
38776 }
38777
38778 handler.send("UnsupportedFeature", {
38779 featureId: _util.UNSUPPORTED_FEATURES.shadingPattern
38780 });
38781 (0, _util.warn)(ex);
38782 return new Shadings.Dummy();
38783 }
38784 };
38785
38786 return Pattern;
38787}();
38788
38789exports.Pattern = Pattern;
38790var Shadings = {};
38791Shadings.SMALL_NUMBER = 1e-6;
38792
38793Shadings.RadialAxial = function RadialAxialClosure() {
38794 function RadialAxial(dict, matrix, xref, res, pdfFunctionFactory) {
38795 this.matrix = matrix;
38796 this.coordsArr = dict.getArray("Coords");
38797 this.shadingType = dict.get("ShadingType");
38798 this.type = "Pattern";
38799 var cs = dict.get("ColorSpace", "CS");
38800 cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
38801 this.cs = cs;
38802 const bbox = dict.getArray("BBox");
38803
38804 if (Array.isArray(bbox) && bbox.length === 4) {
38805 this.bbox = _util.Util.normalizeRect(bbox);
38806 } else {
38807 this.bbox = null;
38808 }
38809
38810 var t0 = 0.0,
38811 t1 = 1.0;
38812
38813 if (dict.has("Domain")) {
38814 var domainArr = dict.getArray("Domain");
38815 t0 = domainArr[0];
38816 t1 = domainArr[1];
38817 }
38818
38819 var extendStart = false,
38820 extendEnd = false;
38821
38822 if (dict.has("Extend")) {
38823 var extendArr = dict.getArray("Extend");
38824 extendStart = extendArr[0];
38825 extendEnd = extendArr[1];
38826 }
38827
38828 if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
38829 var x1 = this.coordsArr[0];
38830 var y1 = this.coordsArr[1];
38831 var r1 = this.coordsArr[2];
38832 var x2 = this.coordsArr[3];
38833 var y2 = this.coordsArr[4];
38834 var r2 = this.coordsArr[5];
38835 var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
38836
38837 if (r1 <= r2 + distance && r2 <= r1 + distance) {
38838 (0, _util.warn)("Unsupported radial gradient.");
38839 }
38840 }
38841
38842 this.extendStart = extendStart;
38843 this.extendEnd = extendEnd;
38844 var fnObj = dict.get("Function");
38845 var fn = pdfFunctionFactory.createFromArray(fnObj);
38846 const NUMBER_OF_SAMPLES = 10;
38847 const step = (t1 - t0) / NUMBER_OF_SAMPLES;
38848 var colorStops = this.colorStops = [];
38849
38850 if (t0 >= t1 || step <= 0) {
38851 (0, _util.info)("Bad shading domain.");
38852 return;
38853 }
38854
38855 var color = new Float32Array(cs.numComps),
38856 ratio = new Float32Array(1);
38857 var rgbColor;
38858
38859 for (let i = 0; i <= NUMBER_OF_SAMPLES; i++) {
38860 ratio[0] = t0 + i * step;
38861 fn(ratio, 0, color, 0);
38862 rgbColor = cs.getRgb(color, 0);
38863
38864 var cssColor = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
38865
38866 colorStops.push([i / NUMBER_OF_SAMPLES, cssColor]);
38867 }
38868
38869 var background = "transparent";
38870
38871 if (dict.has("Background")) {
38872 rgbColor = cs.getRgb(dict.get("Background"), 0);
38873 background = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
38874 }
38875
38876 if (!extendStart) {
38877 colorStops.unshift([0, background]);
38878 colorStops[1][0] += Shadings.SMALL_NUMBER;
38879 }
38880
38881 if (!extendEnd) {
38882 colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
38883 colorStops.push([1, background]);
38884 }
38885
38886 this.colorStops = colorStops;
38887 }
38888
38889 RadialAxial.prototype = {
38890 getIR: function RadialAxial_getIR() {
38891 var coordsArr = this.coordsArr;
38892 var shadingType = this.shadingType;
38893 var type, p0, p1, r0, r1;
38894
38895 if (shadingType === ShadingType.AXIAL) {
38896 p0 = [coordsArr[0], coordsArr[1]];
38897 p1 = [coordsArr[2], coordsArr[3]];
38898 r0 = null;
38899 r1 = null;
38900 type = "axial";
38901 } else if (shadingType === ShadingType.RADIAL) {
38902 p0 = [coordsArr[0], coordsArr[1]];
38903 p1 = [coordsArr[3], coordsArr[4]];
38904 r0 = coordsArr[2];
38905 r1 = coordsArr[5];
38906 type = "radial";
38907 } else {
38908 (0, _util.unreachable)(`getPattern type unknown: ${shadingType}`);
38909 }
38910
38911 var matrix = this.matrix;
38912
38913 if (matrix) {
38914 p0 = _util.Util.applyTransform(p0, matrix);
38915 p1 = _util.Util.applyTransform(p1, matrix);
38916
38917 if (shadingType === ShadingType.RADIAL) {
38918 var scale = _util.Util.singularValueDecompose2dScale(matrix);
38919
38920 r0 *= scale[0];
38921 r1 *= scale[1];
38922 }
38923 }
38924
38925 return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
38926 }
38927 };
38928 return RadialAxial;
38929}();
38930
38931Shadings.Mesh = function MeshClosure() {
38932 function MeshStreamReader(stream, context) {
38933 this.stream = stream;
38934 this.context = context;
38935 this.buffer = 0;
38936 this.bufferLength = 0;
38937 var numComps = context.numComps;
38938 this.tmpCompsBuf = new Float32Array(numComps);
38939 var csNumComps = context.colorSpace.numComps;
38940 this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
38941 }
38942
38943 MeshStreamReader.prototype = {
38944 get hasData() {
38945 if (this.stream.end) {
38946 return this.stream.pos < this.stream.end;
38947 }
38948
38949 if (this.bufferLength > 0) {
38950 return true;
38951 }
38952
38953 var nextByte = this.stream.getByte();
38954
38955 if (nextByte < 0) {
38956 return false;
38957 }
38958
38959 this.buffer = nextByte;
38960 this.bufferLength = 8;
38961 return true;
38962 },
38963
38964 readBits: function MeshStreamReader_readBits(n) {
38965 var buffer = this.buffer;
38966 var bufferLength = this.bufferLength;
38967
38968 if (n === 32) {
38969 if (bufferLength === 0) {
38970 return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
38971 }
38972
38973 buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
38974 var nextByte = this.stream.getByte();
38975 this.buffer = nextByte & (1 << bufferLength) - 1;
38976 return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;
38977 }
38978
38979 if (n === 8 && bufferLength === 0) {
38980 return this.stream.getByte();
38981 }
38982
38983 while (bufferLength < n) {
38984 buffer = buffer << 8 | this.stream.getByte();
38985 bufferLength += 8;
38986 }
38987
38988 bufferLength -= n;
38989 this.bufferLength = bufferLength;
38990 this.buffer = buffer & (1 << bufferLength) - 1;
38991 return buffer >> bufferLength;
38992 },
38993 align: function MeshStreamReader_align() {
38994 this.buffer = 0;
38995 this.bufferLength = 0;
38996 },
38997 readFlag: function MeshStreamReader_readFlag() {
38998 return this.readBits(this.context.bitsPerFlag);
38999 },
39000 readCoordinate: function MeshStreamReader_readCoordinate() {
39001 var bitsPerCoordinate = this.context.bitsPerCoordinate;
39002 var xi = this.readBits(bitsPerCoordinate);
39003 var yi = this.readBits(bitsPerCoordinate);
39004 var decode = this.context.decode;
39005 var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
39006 return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
39007 },
39008 readComponents: function MeshStreamReader_readComponents() {
39009 var numComps = this.context.numComps;
39010 var bitsPerComponent = this.context.bitsPerComponent;
39011 var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
39012 var decode = this.context.decode;
39013 var components = this.tmpCompsBuf;
39014
39015 for (var i = 0, j = 4; i < numComps; i++, j += 2) {
39016 var ci = this.readBits(bitsPerComponent);
39017 components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
39018 }
39019
39020 var color = this.tmpCsCompsBuf;
39021
39022 if (this.context.colorFn) {
39023 this.context.colorFn(components, 0, color, 0);
39024 }
39025
39026 return this.context.colorSpace.getRgb(color, 0);
39027 }
39028 };
39029
39030 function decodeType4Shading(mesh, reader) {
39031 var coords = mesh.coords;
39032 var colors = mesh.colors;
39033 var operators = [];
39034 var ps = [];
39035 var verticesLeft = 0;
39036
39037 while (reader.hasData) {
39038 var f = reader.readFlag();
39039 var coord = reader.readCoordinate();
39040 var color = reader.readComponents();
39041
39042 if (verticesLeft === 0) {
39043 if (!(0 <= f && f <= 2)) {
39044 throw new _util.FormatError("Unknown type4 flag");
39045 }
39046
39047 switch (f) {
39048 case 0:
39049 verticesLeft = 3;
39050 break;
39051
39052 case 1:
39053 ps.push(ps[ps.length - 2], ps[ps.length - 1]);
39054 verticesLeft = 1;
39055 break;
39056
39057 case 2:
39058 ps.push(ps[ps.length - 3], ps[ps.length - 1]);
39059 verticesLeft = 1;
39060 break;
39061 }
39062
39063 operators.push(f);
39064 }
39065
39066 ps.push(coords.length);
39067 coords.push(coord);
39068 colors.push(color);
39069 verticesLeft--;
39070 reader.align();
39071 }
39072
39073 mesh.figures.push({
39074 type: "triangles",
39075 coords: new Int32Array(ps),
39076 colors: new Int32Array(ps)
39077 });
39078 }
39079
39080 function decodeType5Shading(mesh, reader, verticesPerRow) {
39081 var coords = mesh.coords;
39082 var colors = mesh.colors;
39083 var ps = [];
39084
39085 while (reader.hasData) {
39086 var coord = reader.readCoordinate();
39087 var color = reader.readComponents();
39088 ps.push(coords.length);
39089 coords.push(coord);
39090 colors.push(color);
39091 }
39092
39093 mesh.figures.push({
39094 type: "lattice",
39095 coords: new Int32Array(ps),
39096 colors: new Int32Array(ps),
39097 verticesPerRow
39098 });
39099 }
39100
39101 var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
39102 var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
39103 var TRIANGLE_DENSITY = 20;
39104
39105 var getB = function getBClosure() {
39106 function buildB(count) {
39107 var lut = [];
39108
39109 for (var i = 0; i <= count; i++) {
39110 var t = i / count,
39111 t_ = 1 - t;
39112 lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t]));
39113 }
39114
39115 return lut;
39116 }
39117
39118 var cache = [];
39119 return function getB(count) {
39120 if (!cache[count]) {
39121 cache[count] = buildB(count);
39122 }
39123
39124 return cache[count];
39125 };
39126 }();
39127
39128 function buildFigureFromPatch(mesh, index) {
39129 var figure = mesh.figures[index];
39130 (0, _util.assert)(figure.type === "patch", "Unexpected patch mesh figure");
39131 var coords = mesh.coords,
39132 colors = mesh.colors;
39133 var pi = figure.coords;
39134 var ci = figure.colors;
39135 var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
39136 var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
39137 var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
39138 var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
39139 var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
39140 splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
39141 var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
39142 splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
39143 var verticesPerRow = splitXBy + 1;
39144 var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
39145 var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
39146 var k = 0;
39147 var cl = new Uint8Array(3),
39148 cr = new Uint8Array(3);
39149 var c0 = colors[ci[0]],
39150 c1 = colors[ci[1]],
39151 c2 = colors[ci[2]],
39152 c3 = colors[ci[3]];
39153 var bRow = getB(splitYBy),
39154 bCol = getB(splitXBy);
39155
39156 for (var row = 0; row <= splitYBy; row++) {
39157 cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
39158 cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
39159 cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
39160 cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
39161 cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
39162 cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
39163
39164 for (var col = 0; col <= splitXBy; col++, k++) {
39165 if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
39166 continue;
39167 }
39168
39169 var x = 0,
39170 y = 0;
39171 var q = 0;
39172
39173 for (var i = 0; i <= 3; i++) {
39174 for (var j = 0; j <= 3; j++, q++) {
39175 var m = bRow[row][i] * bCol[col][j];
39176 x += coords[pi[q]][0] * m;
39177 y += coords[pi[q]][1] * m;
39178 }
39179 }
39180
39181 figureCoords[k] = coords.length;
39182 coords.push([x, y]);
39183 figureColors[k] = colors.length;
39184 var newColor = new Uint8Array(3);
39185 newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
39186 newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
39187 newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
39188 colors.push(newColor);
39189 }
39190 }
39191
39192 figureCoords[0] = pi[0];
39193 figureColors[0] = ci[0];
39194 figureCoords[splitXBy] = pi[3];
39195 figureColors[splitXBy] = ci[1];
39196 figureCoords[verticesPerRow * splitYBy] = pi[12];
39197 figureColors[verticesPerRow * splitYBy] = ci[2];
39198 figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
39199 figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
39200 mesh.figures[index] = {
39201 type: "lattice",
39202 coords: figureCoords,
39203 colors: figureColors,
39204 verticesPerRow
39205 };
39206 }
39207
39208 function decodeType6Shading(mesh, reader) {
39209 var coords = mesh.coords;
39210 var colors = mesh.colors;
39211 var ps = new Int32Array(16);
39212 var cs = new Int32Array(4);
39213
39214 while (reader.hasData) {
39215 var f = reader.readFlag();
39216
39217 if (!(0 <= f && f <= 3)) {
39218 throw new _util.FormatError("Unknown type6 flag");
39219 }
39220
39221 var i, ii;
39222 var pi = coords.length;
39223
39224 for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
39225 coords.push(reader.readCoordinate());
39226 }
39227
39228 var ci = colors.length;
39229
39230 for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
39231 colors.push(reader.readComponents());
39232 }
39233
39234 var tmp1, tmp2, tmp3, tmp4;
39235
39236 switch (f) {
39237 case 0:
39238 ps[12] = pi + 3;
39239 ps[13] = pi + 4;
39240 ps[14] = pi + 5;
39241 ps[15] = pi + 6;
39242 ps[8] = pi + 2;
39243 ps[11] = pi + 7;
39244 ps[4] = pi + 1;
39245 ps[7] = pi + 8;
39246 ps[0] = pi;
39247 ps[1] = pi + 11;
39248 ps[2] = pi + 10;
39249 ps[3] = pi + 9;
39250 cs[2] = ci + 1;
39251 cs[3] = ci + 2;
39252 cs[0] = ci;
39253 cs[1] = ci + 3;
39254 break;
39255
39256 case 1:
39257 tmp1 = ps[12];
39258 tmp2 = ps[13];
39259 tmp3 = ps[14];
39260 tmp4 = ps[15];
39261 ps[12] = tmp4;
39262 ps[13] = pi + 0;
39263 ps[14] = pi + 1;
39264 ps[15] = pi + 2;
39265 ps[8] = tmp3;
39266 ps[11] = pi + 3;
39267 ps[4] = tmp2;
39268 ps[7] = pi + 4;
39269 ps[0] = tmp1;
39270 ps[1] = pi + 7;
39271 ps[2] = pi + 6;
39272 ps[3] = pi + 5;
39273 tmp1 = cs[2];
39274 tmp2 = cs[3];
39275 cs[2] = tmp2;
39276 cs[3] = ci;
39277 cs[0] = tmp1;
39278 cs[1] = ci + 1;
39279 break;
39280
39281 case 2:
39282 tmp1 = ps[15];
39283 tmp2 = ps[11];
39284 ps[12] = ps[3];
39285 ps[13] = pi + 0;
39286 ps[14] = pi + 1;
39287 ps[15] = pi + 2;
39288 ps[8] = ps[7];
39289 ps[11] = pi + 3;
39290 ps[4] = tmp2;
39291 ps[7] = pi + 4;
39292 ps[0] = tmp1;
39293 ps[1] = pi + 7;
39294 ps[2] = pi + 6;
39295 ps[3] = pi + 5;
39296 tmp1 = cs[3];
39297 cs[2] = cs[1];
39298 cs[3] = ci;
39299 cs[0] = tmp1;
39300 cs[1] = ci + 1;
39301 break;
39302
39303 case 3:
39304 ps[12] = ps[0];
39305 ps[13] = pi + 0;
39306 ps[14] = pi + 1;
39307 ps[15] = pi + 2;
39308 ps[8] = ps[1];
39309 ps[11] = pi + 3;
39310 ps[4] = ps[2];
39311 ps[7] = pi + 4;
39312 ps[0] = ps[3];
39313 ps[1] = pi + 7;
39314 ps[2] = pi + 6;
39315 ps[3] = pi + 5;
39316 cs[2] = cs[0];
39317 cs[3] = ci;
39318 cs[0] = cs[1];
39319 cs[1] = ci + 1;
39320 break;
39321 }
39322
39323 ps[5] = coords.length;
39324 coords.push([(-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9, (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9]);
39325 ps[6] = coords.length;
39326 coords.push([(-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9, (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9]);
39327 ps[9] = coords.length;
39328 coords.push([(-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9, (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9]);
39329 ps[10] = coords.length;
39330 coords.push([(-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9]);
39331 mesh.figures.push({
39332 type: "patch",
39333 coords: new Int32Array(ps),
39334 colors: new Int32Array(cs)
39335 });
39336 }
39337 }
39338
39339 function decodeType7Shading(mesh, reader) {
39340 var coords = mesh.coords;
39341 var colors = mesh.colors;
39342 var ps = new Int32Array(16);
39343 var cs = new Int32Array(4);
39344
39345 while (reader.hasData) {
39346 var f = reader.readFlag();
39347
39348 if (!(0 <= f && f <= 3)) {
39349 throw new _util.FormatError("Unknown type7 flag");
39350 }
39351
39352 var i, ii;
39353 var pi = coords.length;
39354
39355 for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
39356 coords.push(reader.readCoordinate());
39357 }
39358
39359 var ci = colors.length;
39360
39361 for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
39362 colors.push(reader.readComponents());
39363 }
39364
39365 var tmp1, tmp2, tmp3, tmp4;
39366
39367 switch (f) {
39368 case 0:
39369 ps[12] = pi + 3;
39370 ps[13] = pi + 4;
39371 ps[14] = pi + 5;
39372 ps[15] = pi + 6;
39373 ps[8] = pi + 2;
39374 ps[9] = pi + 13;
39375 ps[10] = pi + 14;
39376 ps[11] = pi + 7;
39377 ps[4] = pi + 1;
39378 ps[5] = pi + 12;
39379 ps[6] = pi + 15;
39380 ps[7] = pi + 8;
39381 ps[0] = pi;
39382 ps[1] = pi + 11;
39383 ps[2] = pi + 10;
39384 ps[3] = pi + 9;
39385 cs[2] = ci + 1;
39386 cs[3] = ci + 2;
39387 cs[0] = ci;
39388 cs[1] = ci + 3;
39389 break;
39390
39391 case 1:
39392 tmp1 = ps[12];
39393 tmp2 = ps[13];
39394 tmp3 = ps[14];
39395 tmp4 = ps[15];
39396 ps[12] = tmp4;
39397 ps[13] = pi + 0;
39398 ps[14] = pi + 1;
39399 ps[15] = pi + 2;
39400 ps[8] = tmp3;
39401 ps[9] = pi + 9;
39402 ps[10] = pi + 10;
39403 ps[11] = pi + 3;
39404 ps[4] = tmp2;
39405 ps[5] = pi + 8;
39406 ps[6] = pi + 11;
39407 ps[7] = pi + 4;
39408 ps[0] = tmp1;
39409 ps[1] = pi + 7;
39410 ps[2] = pi + 6;
39411 ps[3] = pi + 5;
39412 tmp1 = cs[2];
39413 tmp2 = cs[3];
39414 cs[2] = tmp2;
39415 cs[3] = ci;
39416 cs[0] = tmp1;
39417 cs[1] = ci + 1;
39418 break;
39419
39420 case 2:
39421 tmp1 = ps[15];
39422 tmp2 = ps[11];
39423 ps[12] = ps[3];
39424 ps[13] = pi + 0;
39425 ps[14] = pi + 1;
39426 ps[15] = pi + 2;
39427 ps[8] = ps[7];
39428 ps[9] = pi + 9;
39429 ps[10] = pi + 10;
39430 ps[11] = pi + 3;
39431 ps[4] = tmp2;
39432 ps[5] = pi + 8;
39433 ps[6] = pi + 11;
39434 ps[7] = pi + 4;
39435 ps[0] = tmp1;
39436 ps[1] = pi + 7;
39437 ps[2] = pi + 6;
39438 ps[3] = pi + 5;
39439 tmp1 = cs[3];
39440 cs[2] = cs[1];
39441 cs[3] = ci;
39442 cs[0] = tmp1;
39443 cs[1] = ci + 1;
39444 break;
39445
39446 case 3:
39447 ps[12] = ps[0];
39448 ps[13] = pi + 0;
39449 ps[14] = pi + 1;
39450 ps[15] = pi + 2;
39451 ps[8] = ps[1];
39452 ps[9] = pi + 9;
39453 ps[10] = pi + 10;
39454 ps[11] = pi + 3;
39455 ps[4] = ps[2];
39456 ps[5] = pi + 8;
39457 ps[6] = pi + 11;
39458 ps[7] = pi + 4;
39459 ps[0] = ps[3];
39460 ps[1] = pi + 7;
39461 ps[2] = pi + 6;
39462 ps[3] = pi + 5;
39463 cs[2] = cs[0];
39464 cs[3] = ci;
39465 cs[0] = cs[1];
39466 cs[1] = ci + 1;
39467 break;
39468 }
39469
39470 mesh.figures.push({
39471 type: "patch",
39472 coords: new Int32Array(ps),
39473 colors: new Int32Array(cs)
39474 });
39475 }
39476 }
39477
39478 function updateBounds(mesh) {
39479 var minX = mesh.coords[0][0],
39480 minY = mesh.coords[0][1],
39481 maxX = minX,
39482 maxY = minY;
39483
39484 for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
39485 var x = mesh.coords[i][0],
39486 y = mesh.coords[i][1];
39487 minX = minX > x ? x : minX;
39488 minY = minY > y ? y : minY;
39489 maxX = maxX < x ? x : maxX;
39490 maxY = maxY < y ? y : maxY;
39491 }
39492
39493 mesh.bounds = [minX, minY, maxX, maxY];
39494 }
39495
39496 function packData(mesh) {
39497 var i, ii, j, jj;
39498 var coords = mesh.coords;
39499 var coordsPacked = new Float32Array(coords.length * 2);
39500
39501 for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
39502 var xy = coords[i];
39503 coordsPacked[j++] = xy[0];
39504 coordsPacked[j++] = xy[1];
39505 }
39506
39507 mesh.coords = coordsPacked;
39508 var colors = mesh.colors;
39509 var colorsPacked = new Uint8Array(colors.length * 3);
39510
39511 for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
39512 var c = colors[i];
39513 colorsPacked[j++] = c[0];
39514 colorsPacked[j++] = c[1];
39515 colorsPacked[j++] = c[2];
39516 }
39517
39518 mesh.colors = colorsPacked;
39519 var figures = mesh.figures;
39520
39521 for (i = 0, ii = figures.length; i < ii; i++) {
39522 var figure = figures[i],
39523 ps = figure.coords,
39524 cs = figure.colors;
39525
39526 for (j = 0, jj = ps.length; j < jj; j++) {
39527 ps[j] *= 2;
39528 cs[j] *= 3;
39529 }
39530 }
39531 }
39532
39533 function Mesh(stream, matrix, xref, res, pdfFunctionFactory) {
39534 if (!(0, _primitives.isStream)(stream)) {
39535 throw new _util.FormatError("Mesh data is not a stream");
39536 }
39537
39538 var dict = stream.dict;
39539 this.matrix = matrix;
39540 this.shadingType = dict.get("ShadingType");
39541 this.type = "Pattern";
39542 const bbox = dict.getArray("BBox");
39543
39544 if (Array.isArray(bbox) && bbox.length === 4) {
39545 this.bbox = _util.Util.normalizeRect(bbox);
39546 } else {
39547 this.bbox = null;
39548 }
39549
39550 var cs = dict.get("ColorSpace", "CS");
39551 cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
39552 this.cs = cs;
39553 this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
39554 var fnObj = dict.get("Function");
39555 var fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
39556 this.coords = [];
39557 this.colors = [];
39558 this.figures = [];
39559 var decodeContext = {
39560 bitsPerCoordinate: dict.get("BitsPerCoordinate"),
39561 bitsPerComponent: dict.get("BitsPerComponent"),
39562 bitsPerFlag: dict.get("BitsPerFlag"),
39563 decode: dict.getArray("Decode"),
39564 colorFn: fn,
39565 colorSpace: cs,
39566 numComps: fn ? 1 : cs.numComps
39567 };
39568 var reader = new MeshStreamReader(stream, decodeContext);
39569 var patchMesh = false;
39570
39571 switch (this.shadingType) {
39572 case ShadingType.FREE_FORM_MESH:
39573 decodeType4Shading(this, reader);
39574 break;
39575
39576 case ShadingType.LATTICE_FORM_MESH:
39577 var verticesPerRow = dict.get("VerticesPerRow") | 0;
39578
39579 if (verticesPerRow < 2) {
39580 throw new _util.FormatError("Invalid VerticesPerRow");
39581 }
39582
39583 decodeType5Shading(this, reader, verticesPerRow);
39584 break;
39585
39586 case ShadingType.COONS_PATCH_MESH:
39587 decodeType6Shading(this, reader);
39588 patchMesh = true;
39589 break;
39590
39591 case ShadingType.TENSOR_PATCH_MESH:
39592 decodeType7Shading(this, reader);
39593 patchMesh = true;
39594 break;
39595
39596 default:
39597 (0, _util.unreachable)("Unsupported mesh type.");
39598 break;
39599 }
39600
39601 if (patchMesh) {
39602 updateBounds(this);
39603
39604 for (var i = 0, ii = this.figures.length; i < ii; i++) {
39605 buildFigureFromPatch(this, i);
39606 }
39607 }
39608
39609 updateBounds(this);
39610 packData(this);
39611 }
39612
39613 Mesh.prototype = {
39614 getIR: function Mesh_getIR() {
39615 return ["Mesh", this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.matrix, this.bbox, this.background];
39616 }
39617 };
39618 return Mesh;
39619}();
39620
39621Shadings.Dummy = function DummyClosure() {
39622 function Dummy() {
39623 this.type = "Pattern";
39624 }
39625
39626 Dummy.prototype = {
39627 getIR: function Dummy_getIR() {
39628 return ["Dummy"];
39629 }
39630 };
39631 return Dummy;
39632}();
39633
39634function getTilingPatternIR(operatorList, dict, args) {
39635 const matrix = dict.getArray("Matrix");
39636
39637 const bbox = _util.Util.normalizeRect(dict.getArray("BBox"));
39638
39639 const xstep = dict.get("XStep");
39640 const ystep = dict.get("YStep");
39641 const paintType = dict.get("PaintType");
39642 const tilingType = dict.get("TilingType");
39643
39644 if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
39645 throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
39646 }
39647
39648 return ["TilingPattern", args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
39649}
39650
39651/***/ }),
39652/* 39 */
39653/***/ (function(module, exports, __w_pdfjs_require__) {
39654
39655"use strict";
39656
39657
39658Object.defineProperty(exports, "__esModule", {
39659 value: true
39660});
39661exports.bidi = bidi;
39662
39663var _util = __w_pdfjs_require__(2);
39664
39665var baseTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON", "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"];
39666var arabicTypes = ["AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL", "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"];
39667
39668function isOdd(i) {
39669 return (i & 1) !== 0;
39670}
39671
39672function isEven(i) {
39673 return (i & 1) === 0;
39674}
39675
39676function findUnequal(arr, start, value) {
39677 for (var j = start, jj = arr.length; j < jj; ++j) {
39678 if (arr[j] !== value) {
39679 return j;
39680 }
39681 }
39682
39683 return j;
39684}
39685
39686function setValues(arr, start, end, value) {
39687 for (var j = start; j < end; ++j) {
39688 arr[j] = value;
39689 }
39690}
39691
39692function reverseValues(arr, start, end) {
39693 for (var i = start, j = end - 1; i < j; ++i, --j) {
39694 var temp = arr[i];
39695 arr[i] = arr[j];
39696 arr[j] = temp;
39697 }
39698}
39699
39700function createBidiText(str, isLTR, vertical = false) {
39701 let dir = "ltr";
39702
39703 if (vertical) {
39704 dir = "ttb";
39705 } else if (!isLTR) {
39706 dir = "rtl";
39707 }
39708
39709 return {
39710 str,
39711 dir
39712 };
39713}
39714
39715var chars = [];
39716var types = [];
39717
39718function bidi(str, startLevel, vertical) {
39719 var isLTR = true;
39720 var strLength = str.length;
39721
39722 if (strLength === 0 || vertical) {
39723 return createBidiText(str, isLTR, vertical);
39724 }
39725
39726 chars.length = strLength;
39727 types.length = strLength;
39728 var numBidi = 0;
39729 var i, ii;
39730
39731 for (i = 0; i < strLength; ++i) {
39732 chars[i] = str.charAt(i);
39733 var charCode = str.charCodeAt(i);
39734 var charType = "L";
39735
39736 if (charCode <= 0x00ff) {
39737 charType = baseTypes[charCode];
39738 } else if (0x0590 <= charCode && charCode <= 0x05f4) {
39739 charType = "R";
39740 } else if (0x0600 <= charCode && charCode <= 0x06ff) {
39741 charType = arabicTypes[charCode & 0xff];
39742
39743 if (!charType) {
39744 (0, _util.warn)("Bidi: invalid Unicode character " + charCode.toString(16));
39745 }
39746 } else if (0x0700 <= charCode && charCode <= 0x08ac) {
39747 charType = "AL";
39748 }
39749
39750 if (charType === "R" || charType === "AL" || charType === "AN") {
39751 numBidi++;
39752 }
39753
39754 types[i] = charType;
39755 }
39756
39757 if (numBidi === 0) {
39758 isLTR = true;
39759 return createBidiText(str, isLTR);
39760 }
39761
39762 if (startLevel === -1) {
39763 if (numBidi / strLength < 0.3) {
39764 isLTR = true;
39765 startLevel = 0;
39766 } else {
39767 isLTR = false;
39768 startLevel = 1;
39769 }
39770 }
39771
39772 var levels = [];
39773
39774 for (i = 0; i < strLength; ++i) {
39775 levels[i] = startLevel;
39776 }
39777
39778 var e = isOdd(startLevel) ? "R" : "L";
39779 var sor = e;
39780 var eor = sor;
39781 var lastType = sor;
39782
39783 for (i = 0; i < strLength; ++i) {
39784 if (types[i] === "NSM") {
39785 types[i] = lastType;
39786 } else {
39787 lastType = types[i];
39788 }
39789 }
39790
39791 lastType = sor;
39792 var t;
39793
39794 for (i = 0; i < strLength; ++i) {
39795 t = types[i];
39796
39797 if (t === "EN") {
39798 types[i] = lastType === "AL" ? "AN" : "EN";
39799 } else if (t === "R" || t === "L" || t === "AL") {
39800 lastType = t;
39801 }
39802 }
39803
39804 for (i = 0; i < strLength; ++i) {
39805 t = types[i];
39806
39807 if (t === "AL") {
39808 types[i] = "R";
39809 }
39810 }
39811
39812 for (i = 1; i < strLength - 1; ++i) {
39813 if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
39814 types[i] = "EN";
39815 }
39816
39817 if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
39818 types[i] = types[i - 1];
39819 }
39820 }
39821
39822 for (i = 0; i < strLength; ++i) {
39823 if (types[i] === "EN") {
39824 var j;
39825
39826 for (j = i - 1; j >= 0; --j) {
39827 if (types[j] !== "ET") {
39828 break;
39829 }
39830
39831 types[j] = "EN";
39832 }
39833
39834 for (j = i + 1; j < strLength; ++j) {
39835 if (types[j] !== "ET") {
39836 break;
39837 }
39838
39839 types[j] = "EN";
39840 }
39841 }
39842 }
39843
39844 for (i = 0; i < strLength; ++i) {
39845 t = types[i];
39846
39847 if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
39848 types[i] = "ON";
39849 }
39850 }
39851
39852 lastType = sor;
39853
39854 for (i = 0; i < strLength; ++i) {
39855 t = types[i];
39856
39857 if (t === "EN") {
39858 types[i] = lastType === "L" ? "L" : "EN";
39859 } else if (t === "R" || t === "L") {
39860 lastType = t;
39861 }
39862 }
39863
39864 for (i = 0; i < strLength; ++i) {
39865 if (types[i] === "ON") {
39866 var end = findUnequal(types, i + 1, "ON");
39867 var before = sor;
39868
39869 if (i > 0) {
39870 before = types[i - 1];
39871 }
39872
39873 var after = eor;
39874
39875 if (end + 1 < strLength) {
39876 after = types[end + 1];
39877 }
39878
39879 if (before !== "L") {
39880 before = "R";
39881 }
39882
39883 if (after !== "L") {
39884 after = "R";
39885 }
39886
39887 if (before === after) {
39888 setValues(types, i, end, before);
39889 }
39890
39891 i = end - 1;
39892 }
39893 }
39894
39895 for (i = 0; i < strLength; ++i) {
39896 if (types[i] === "ON") {
39897 types[i] = e;
39898 }
39899 }
39900
39901 for (i = 0; i < strLength; ++i) {
39902 t = types[i];
39903
39904 if (isEven(levels[i])) {
39905 if (t === "R") {
39906 levels[i] += 1;
39907 } else if (t === "AN" || t === "EN") {
39908 levels[i] += 2;
39909 }
39910 } else {
39911 if (t === "L" || t === "AN" || t === "EN") {
39912 levels[i] += 1;
39913 }
39914 }
39915 }
39916
39917 var highestLevel = -1;
39918 var lowestOddLevel = 99;
39919 var level;
39920
39921 for (i = 0, ii = levels.length; i < ii; ++i) {
39922 level = levels[i];
39923
39924 if (highestLevel < level) {
39925 highestLevel = level;
39926 }
39927
39928 if (lowestOddLevel > level && isOdd(level)) {
39929 lowestOddLevel = level;
39930 }
39931 }
39932
39933 for (level = highestLevel; level >= lowestOddLevel; --level) {
39934 var start = -1;
39935
39936 for (i = 0, ii = levels.length; i < ii; ++i) {
39937 if (levels[i] < level) {
39938 if (start >= 0) {
39939 reverseValues(chars, start, i);
39940 start = -1;
39941 }
39942 } else if (start < 0) {
39943 start = i;
39944 }
39945 }
39946
39947 if (start >= 0) {
39948 reverseValues(chars, start, levels.length);
39949 }
39950 }
39951
39952 for (i = 0, ii = chars.length; i < ii; ++i) {
39953 var ch = chars[i];
39954
39955 if (ch === "<" || ch === ">") {
39956 chars[i] = "";
39957 }
39958 }
39959
39960 return createBidiText(chars.join(""), isLTR);
39961}
39962
39963/***/ }),
39964/* 40 */
39965/***/ (function(module, exports, __w_pdfjs_require__) {
39966
39967"use strict";
39968
39969
39970Object.defineProperty(exports, "__esModule", {
39971 value: true
39972});
39973exports.getMetrics = void 0;
39974
39975var _core_utils = __w_pdfjs_require__(8);
39976
39977var getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
39978 t.Courier = 600;
39979 t["Courier-Bold"] = 600;
39980 t["Courier-BoldOblique"] = 600;
39981 t["Courier-Oblique"] = 600;
39982 t.Helvetica = (0, _core_utils.getLookupTableFactory)(function (t) {
39983 t.space = 278;
39984 t.exclam = 278;
39985 t.quotedbl = 355;
39986 t.numbersign = 556;
39987 t.dollar = 556;
39988 t.percent = 889;
39989 t.ampersand = 667;
39990 t.quoteright = 222;
39991 t.parenleft = 333;
39992 t.parenright = 333;
39993 t.asterisk = 389;
39994 t.plus = 584;
39995 t.comma = 278;
39996 t.hyphen = 333;
39997 t.period = 278;
39998 t.slash = 278;
39999 t.zero = 556;
40000 t.one = 556;
40001 t.two = 556;
40002 t.three = 556;
40003 t.four = 556;
40004 t.five = 556;
40005 t.six = 556;
40006 t.seven = 556;
40007 t.eight = 556;
40008 t.nine = 556;
40009 t.colon = 278;
40010 t.semicolon = 278;
40011 t.less = 584;
40012 t.equal = 584;
40013 t.greater = 584;
40014 t.question = 556;
40015 t.at = 1015;
40016 t.A = 667;
40017 t.B = 667;
40018 t.C = 722;
40019 t.D = 722;
40020 t.E = 667;
40021 t.F = 611;
40022 t.G = 778;
40023 t.H = 722;
40024 t.I = 278;
40025 t.J = 500;
40026 t.K = 667;
40027 t.L = 556;
40028 t.M = 833;
40029 t.N = 722;
40030 t.O = 778;
40031 t.P = 667;
40032 t.Q = 778;
40033 t.R = 722;
40034 t.S = 667;
40035 t.T = 611;
40036 t.U = 722;
40037 t.V = 667;
40038 t.W = 944;
40039 t.X = 667;
40040 t.Y = 667;
40041 t.Z = 611;
40042 t.bracketleft = 278;
40043 t.backslash = 278;
40044 t.bracketright = 278;
40045 t.asciicircum = 469;
40046 t.underscore = 556;
40047 t.quoteleft = 222;
40048 t.a = 556;
40049 t.b = 556;
40050 t.c = 500;
40051 t.d = 556;
40052 t.e = 556;
40053 t.f = 278;
40054 t.g = 556;
40055 t.h = 556;
40056 t.i = 222;
40057 t.j = 222;
40058 t.k = 500;
40059 t.l = 222;
40060 t.m = 833;
40061 t.n = 556;
40062 t.o = 556;
40063 t.p = 556;
40064 t.q = 556;
40065 t.r = 333;
40066 t.s = 500;
40067 t.t = 278;
40068 t.u = 556;
40069 t.v = 500;
40070 t.w = 722;
40071 t.x = 500;
40072 t.y = 500;
40073 t.z = 500;
40074 t.braceleft = 334;
40075 t.bar = 260;
40076 t.braceright = 334;
40077 t.asciitilde = 584;
40078 t.exclamdown = 333;
40079 t.cent = 556;
40080 t.sterling = 556;
40081 t.fraction = 167;
40082 t.yen = 556;
40083 t.florin = 556;
40084 t.section = 556;
40085 t.currency = 556;
40086 t.quotesingle = 191;
40087 t.quotedblleft = 333;
40088 t.guillemotleft = 556;
40089 t.guilsinglleft = 333;
40090 t.guilsinglright = 333;
40091 t.fi = 500;
40092 t.fl = 500;
40093 t.endash = 556;
40094 t.dagger = 556;
40095 t.daggerdbl = 556;
40096 t.periodcentered = 278;
40097 t.paragraph = 537;
40098 t.bullet = 350;
40099 t.quotesinglbase = 222;
40100 t.quotedblbase = 333;
40101 t.quotedblright = 333;
40102 t.guillemotright = 556;
40103 t.ellipsis = 1000;
40104 t.perthousand = 1000;
40105 t.questiondown = 611;
40106 t.grave = 333;
40107 t.acute = 333;
40108 t.circumflex = 333;
40109 t.tilde = 333;
40110 t.macron = 333;
40111 t.breve = 333;
40112 t.dotaccent = 333;
40113 t.dieresis = 333;
40114 t.ring = 333;
40115 t.cedilla = 333;
40116 t.hungarumlaut = 333;
40117 t.ogonek = 333;
40118 t.caron = 333;
40119 t.emdash = 1000;
40120 t.AE = 1000;
40121 t.ordfeminine = 370;
40122 t.Lslash = 556;
40123 t.Oslash = 778;
40124 t.OE = 1000;
40125 t.ordmasculine = 365;
40126 t.ae = 889;
40127 t.dotlessi = 278;
40128 t.lslash = 222;
40129 t.oslash = 611;
40130 t.oe = 944;
40131 t.germandbls = 611;
40132 t.Idieresis = 278;
40133 t.eacute = 556;
40134 t.abreve = 556;
40135 t.uhungarumlaut = 556;
40136 t.ecaron = 556;
40137 t.Ydieresis = 667;
40138 t.divide = 584;
40139 t.Yacute = 667;
40140 t.Acircumflex = 667;
40141 t.aacute = 556;
40142 t.Ucircumflex = 722;
40143 t.yacute = 500;
40144 t.scommaaccent = 500;
40145 t.ecircumflex = 556;
40146 t.Uring = 722;
40147 t.Udieresis = 722;
40148 t.aogonek = 556;
40149 t.Uacute = 722;
40150 t.uogonek = 556;
40151 t.Edieresis = 667;
40152 t.Dcroat = 722;
40153 t.commaaccent = 250;
40154 t.copyright = 737;
40155 t.Emacron = 667;
40156 t.ccaron = 500;
40157 t.aring = 556;
40158 t.Ncommaaccent = 722;
40159 t.lacute = 222;
40160 t.agrave = 556;
40161 t.Tcommaaccent = 611;
40162 t.Cacute = 722;
40163 t.atilde = 556;
40164 t.Edotaccent = 667;
40165 t.scaron = 500;
40166 t.scedilla = 500;
40167 t.iacute = 278;
40168 t.lozenge = 471;
40169 t.Rcaron = 722;
40170 t.Gcommaaccent = 778;
40171 t.ucircumflex = 556;
40172 t.acircumflex = 556;
40173 t.Amacron = 667;
40174 t.rcaron = 333;
40175 t.ccedilla = 500;
40176 t.Zdotaccent = 611;
40177 t.Thorn = 667;
40178 t.Omacron = 778;
40179 t.Racute = 722;
40180 t.Sacute = 667;
40181 t.dcaron = 643;
40182 t.Umacron = 722;
40183 t.uring = 556;
40184 t.threesuperior = 333;
40185 t.Ograve = 778;
40186 t.Agrave = 667;
40187 t.Abreve = 667;
40188 t.multiply = 584;
40189 t.uacute = 556;
40190 t.Tcaron = 611;
40191 t.partialdiff = 476;
40192 t.ydieresis = 500;
40193 t.Nacute = 722;
40194 t.icircumflex = 278;
40195 t.Ecircumflex = 667;
40196 t.adieresis = 556;
40197 t.edieresis = 556;
40198 t.cacute = 500;
40199 t.nacute = 556;
40200 t.umacron = 556;
40201 t.Ncaron = 722;
40202 t.Iacute = 278;
40203 t.plusminus = 584;
40204 t.brokenbar = 260;
40205 t.registered = 737;
40206 t.Gbreve = 778;
40207 t.Idotaccent = 278;
40208 t.summation = 600;
40209 t.Egrave = 667;
40210 t.racute = 333;
40211 t.omacron = 556;
40212 t.Zacute = 611;
40213 t.Zcaron = 611;
40214 t.greaterequal = 549;
40215 t.Eth = 722;
40216 t.Ccedilla = 722;
40217 t.lcommaaccent = 222;
40218 t.tcaron = 317;
40219 t.eogonek = 556;
40220 t.Uogonek = 722;
40221 t.Aacute = 667;
40222 t.Adieresis = 667;
40223 t.egrave = 556;
40224 t.zacute = 500;
40225 t.iogonek = 222;
40226 t.Oacute = 778;
40227 t.oacute = 556;
40228 t.amacron = 556;
40229 t.sacute = 500;
40230 t.idieresis = 278;
40231 t.Ocircumflex = 778;
40232 t.Ugrave = 722;
40233 t.Delta = 612;
40234 t.thorn = 556;
40235 t.twosuperior = 333;
40236 t.Odieresis = 778;
40237 t.mu = 556;
40238 t.igrave = 278;
40239 t.ohungarumlaut = 556;
40240 t.Eogonek = 667;
40241 t.dcroat = 556;
40242 t.threequarters = 834;
40243 t.Scedilla = 667;
40244 t.lcaron = 299;
40245 t.Kcommaaccent = 667;
40246 t.Lacute = 556;
40247 t.trademark = 1000;
40248 t.edotaccent = 556;
40249 t.Igrave = 278;
40250 t.Imacron = 278;
40251 t.Lcaron = 556;
40252 t.onehalf = 834;
40253 t.lessequal = 549;
40254 t.ocircumflex = 556;
40255 t.ntilde = 556;
40256 t.Uhungarumlaut = 722;
40257 t.Eacute = 667;
40258 t.emacron = 556;
40259 t.gbreve = 556;
40260 t.onequarter = 834;
40261 t.Scaron = 667;
40262 t.Scommaaccent = 667;
40263 t.Ohungarumlaut = 778;
40264 t.degree = 400;
40265 t.ograve = 556;
40266 t.Ccaron = 722;
40267 t.ugrave = 556;
40268 t.radical = 453;
40269 t.Dcaron = 722;
40270 t.rcommaaccent = 333;
40271 t.Ntilde = 722;
40272 t.otilde = 556;
40273 t.Rcommaaccent = 722;
40274 t.Lcommaaccent = 556;
40275 t.Atilde = 667;
40276 t.Aogonek = 667;
40277 t.Aring = 667;
40278 t.Otilde = 778;
40279 t.zdotaccent = 500;
40280 t.Ecaron = 667;
40281 t.Iogonek = 278;
40282 t.kcommaaccent = 500;
40283 t.minus = 584;
40284 t.Icircumflex = 278;
40285 t.ncaron = 556;
40286 t.tcommaaccent = 278;
40287 t.logicalnot = 584;
40288 t.odieresis = 556;
40289 t.udieresis = 556;
40290 t.notequal = 549;
40291 t.gcommaaccent = 556;
40292 t.eth = 556;
40293 t.zcaron = 500;
40294 t.ncommaaccent = 556;
40295 t.onesuperior = 333;
40296 t.imacron = 278;
40297 t.Euro = 556;
40298 });
40299 t["Helvetica-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
40300 t.space = 278;
40301 t.exclam = 333;
40302 t.quotedbl = 474;
40303 t.numbersign = 556;
40304 t.dollar = 556;
40305 t.percent = 889;
40306 t.ampersand = 722;
40307 t.quoteright = 278;
40308 t.parenleft = 333;
40309 t.parenright = 333;
40310 t.asterisk = 389;
40311 t.plus = 584;
40312 t.comma = 278;
40313 t.hyphen = 333;
40314 t.period = 278;
40315 t.slash = 278;
40316 t.zero = 556;
40317 t.one = 556;
40318 t.two = 556;
40319 t.three = 556;
40320 t.four = 556;
40321 t.five = 556;
40322 t.six = 556;
40323 t.seven = 556;
40324 t.eight = 556;
40325 t.nine = 556;
40326 t.colon = 333;
40327 t.semicolon = 333;
40328 t.less = 584;
40329 t.equal = 584;
40330 t.greater = 584;
40331 t.question = 611;
40332 t.at = 975;
40333 t.A = 722;
40334 t.B = 722;
40335 t.C = 722;
40336 t.D = 722;
40337 t.E = 667;
40338 t.F = 611;
40339 t.G = 778;
40340 t.H = 722;
40341 t.I = 278;
40342 t.J = 556;
40343 t.K = 722;
40344 t.L = 611;
40345 t.M = 833;
40346 t.N = 722;
40347 t.O = 778;
40348 t.P = 667;
40349 t.Q = 778;
40350 t.R = 722;
40351 t.S = 667;
40352 t.T = 611;
40353 t.U = 722;
40354 t.V = 667;
40355 t.W = 944;
40356 t.X = 667;
40357 t.Y = 667;
40358 t.Z = 611;
40359 t.bracketleft = 333;
40360 t.backslash = 278;
40361 t.bracketright = 333;
40362 t.asciicircum = 584;
40363 t.underscore = 556;
40364 t.quoteleft = 278;
40365 t.a = 556;
40366 t.b = 611;
40367 t.c = 556;
40368 t.d = 611;
40369 t.e = 556;
40370 t.f = 333;
40371 t.g = 611;
40372 t.h = 611;
40373 t.i = 278;
40374 t.j = 278;
40375 t.k = 556;
40376 t.l = 278;
40377 t.m = 889;
40378 t.n = 611;
40379 t.o = 611;
40380 t.p = 611;
40381 t.q = 611;
40382 t.r = 389;
40383 t.s = 556;
40384 t.t = 333;
40385 t.u = 611;
40386 t.v = 556;
40387 t.w = 778;
40388 t.x = 556;
40389 t.y = 556;
40390 t.z = 500;
40391 t.braceleft = 389;
40392 t.bar = 280;
40393 t.braceright = 389;
40394 t.asciitilde = 584;
40395 t.exclamdown = 333;
40396 t.cent = 556;
40397 t.sterling = 556;
40398 t.fraction = 167;
40399 t.yen = 556;
40400 t.florin = 556;
40401 t.section = 556;
40402 t.currency = 556;
40403 t.quotesingle = 238;
40404 t.quotedblleft = 500;
40405 t.guillemotleft = 556;
40406 t.guilsinglleft = 333;
40407 t.guilsinglright = 333;
40408 t.fi = 611;
40409 t.fl = 611;
40410 t.endash = 556;
40411 t.dagger = 556;
40412 t.daggerdbl = 556;
40413 t.periodcentered = 278;
40414 t.paragraph = 556;
40415 t.bullet = 350;
40416 t.quotesinglbase = 278;
40417 t.quotedblbase = 500;
40418 t.quotedblright = 500;
40419 t.guillemotright = 556;
40420 t.ellipsis = 1000;
40421 t.perthousand = 1000;
40422 t.questiondown = 611;
40423 t.grave = 333;
40424 t.acute = 333;
40425 t.circumflex = 333;
40426 t.tilde = 333;
40427 t.macron = 333;
40428 t.breve = 333;
40429 t.dotaccent = 333;
40430 t.dieresis = 333;
40431 t.ring = 333;
40432 t.cedilla = 333;
40433 t.hungarumlaut = 333;
40434 t.ogonek = 333;
40435 t.caron = 333;
40436 t.emdash = 1000;
40437 t.AE = 1000;
40438 t.ordfeminine = 370;
40439 t.Lslash = 611;
40440 t.Oslash = 778;
40441 t.OE = 1000;
40442 t.ordmasculine = 365;
40443 t.ae = 889;
40444 t.dotlessi = 278;
40445 t.lslash = 278;
40446 t.oslash = 611;
40447 t.oe = 944;
40448 t.germandbls = 611;
40449 t.Idieresis = 278;
40450 t.eacute = 556;
40451 t.abreve = 556;
40452 t.uhungarumlaut = 611;
40453 t.ecaron = 556;
40454 t.Ydieresis = 667;
40455 t.divide = 584;
40456 t.Yacute = 667;
40457 t.Acircumflex = 722;
40458 t.aacute = 556;
40459 t.Ucircumflex = 722;
40460 t.yacute = 556;
40461 t.scommaaccent = 556;
40462 t.ecircumflex = 556;
40463 t.Uring = 722;
40464 t.Udieresis = 722;
40465 t.aogonek = 556;
40466 t.Uacute = 722;
40467 t.uogonek = 611;
40468 t.Edieresis = 667;
40469 t.Dcroat = 722;
40470 t.commaaccent = 250;
40471 t.copyright = 737;
40472 t.Emacron = 667;
40473 t.ccaron = 556;
40474 t.aring = 556;
40475 t.Ncommaaccent = 722;
40476 t.lacute = 278;
40477 t.agrave = 556;
40478 t.Tcommaaccent = 611;
40479 t.Cacute = 722;
40480 t.atilde = 556;
40481 t.Edotaccent = 667;
40482 t.scaron = 556;
40483 t.scedilla = 556;
40484 t.iacute = 278;
40485 t.lozenge = 494;
40486 t.Rcaron = 722;
40487 t.Gcommaaccent = 778;
40488 t.ucircumflex = 611;
40489 t.acircumflex = 556;
40490 t.Amacron = 722;
40491 t.rcaron = 389;
40492 t.ccedilla = 556;
40493 t.Zdotaccent = 611;
40494 t.Thorn = 667;
40495 t.Omacron = 778;
40496 t.Racute = 722;
40497 t.Sacute = 667;
40498 t.dcaron = 743;
40499 t.Umacron = 722;
40500 t.uring = 611;
40501 t.threesuperior = 333;
40502 t.Ograve = 778;
40503 t.Agrave = 722;
40504 t.Abreve = 722;
40505 t.multiply = 584;
40506 t.uacute = 611;
40507 t.Tcaron = 611;
40508 t.partialdiff = 494;
40509 t.ydieresis = 556;
40510 t.Nacute = 722;
40511 t.icircumflex = 278;
40512 t.Ecircumflex = 667;
40513 t.adieresis = 556;
40514 t.edieresis = 556;
40515 t.cacute = 556;
40516 t.nacute = 611;
40517 t.umacron = 611;
40518 t.Ncaron = 722;
40519 t.Iacute = 278;
40520 t.plusminus = 584;
40521 t.brokenbar = 280;
40522 t.registered = 737;
40523 t.Gbreve = 778;
40524 t.Idotaccent = 278;
40525 t.summation = 600;
40526 t.Egrave = 667;
40527 t.racute = 389;
40528 t.omacron = 611;
40529 t.Zacute = 611;
40530 t.Zcaron = 611;
40531 t.greaterequal = 549;
40532 t.Eth = 722;
40533 t.Ccedilla = 722;
40534 t.lcommaaccent = 278;
40535 t.tcaron = 389;
40536 t.eogonek = 556;
40537 t.Uogonek = 722;
40538 t.Aacute = 722;
40539 t.Adieresis = 722;
40540 t.egrave = 556;
40541 t.zacute = 500;
40542 t.iogonek = 278;
40543 t.Oacute = 778;
40544 t.oacute = 611;
40545 t.amacron = 556;
40546 t.sacute = 556;
40547 t.idieresis = 278;
40548 t.Ocircumflex = 778;
40549 t.Ugrave = 722;
40550 t.Delta = 612;
40551 t.thorn = 611;
40552 t.twosuperior = 333;
40553 t.Odieresis = 778;
40554 t.mu = 611;
40555 t.igrave = 278;
40556 t.ohungarumlaut = 611;
40557 t.Eogonek = 667;
40558 t.dcroat = 611;
40559 t.threequarters = 834;
40560 t.Scedilla = 667;
40561 t.lcaron = 400;
40562 t.Kcommaaccent = 722;
40563 t.Lacute = 611;
40564 t.trademark = 1000;
40565 t.edotaccent = 556;
40566 t.Igrave = 278;
40567 t.Imacron = 278;
40568 t.Lcaron = 611;
40569 t.onehalf = 834;
40570 t.lessequal = 549;
40571 t.ocircumflex = 611;
40572 t.ntilde = 611;
40573 t.Uhungarumlaut = 722;
40574 t.Eacute = 667;
40575 t.emacron = 556;
40576 t.gbreve = 611;
40577 t.onequarter = 834;
40578 t.Scaron = 667;
40579 t.Scommaaccent = 667;
40580 t.Ohungarumlaut = 778;
40581 t.degree = 400;
40582 t.ograve = 611;
40583 t.Ccaron = 722;
40584 t.ugrave = 611;
40585 t.radical = 549;
40586 t.Dcaron = 722;
40587 t.rcommaaccent = 389;
40588 t.Ntilde = 722;
40589 t.otilde = 611;
40590 t.Rcommaaccent = 722;
40591 t.Lcommaaccent = 611;
40592 t.Atilde = 722;
40593 t.Aogonek = 722;
40594 t.Aring = 722;
40595 t.Otilde = 778;
40596 t.zdotaccent = 500;
40597 t.Ecaron = 667;
40598 t.Iogonek = 278;
40599 t.kcommaaccent = 556;
40600 t.minus = 584;
40601 t.Icircumflex = 278;
40602 t.ncaron = 611;
40603 t.tcommaaccent = 333;
40604 t.logicalnot = 584;
40605 t.odieresis = 611;
40606 t.udieresis = 611;
40607 t.notequal = 549;
40608 t.gcommaaccent = 611;
40609 t.eth = 611;
40610 t.zcaron = 500;
40611 t.ncommaaccent = 611;
40612 t.onesuperior = 333;
40613 t.imacron = 278;
40614 t.Euro = 556;
40615 });
40616 t["Helvetica-BoldOblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
40617 t.space = 278;
40618 t.exclam = 333;
40619 t.quotedbl = 474;
40620 t.numbersign = 556;
40621 t.dollar = 556;
40622 t.percent = 889;
40623 t.ampersand = 722;
40624 t.quoteright = 278;
40625 t.parenleft = 333;
40626 t.parenright = 333;
40627 t.asterisk = 389;
40628 t.plus = 584;
40629 t.comma = 278;
40630 t.hyphen = 333;
40631 t.period = 278;
40632 t.slash = 278;
40633 t.zero = 556;
40634 t.one = 556;
40635 t.two = 556;
40636 t.three = 556;
40637 t.four = 556;
40638 t.five = 556;
40639 t.six = 556;
40640 t.seven = 556;
40641 t.eight = 556;
40642 t.nine = 556;
40643 t.colon = 333;
40644 t.semicolon = 333;
40645 t.less = 584;
40646 t.equal = 584;
40647 t.greater = 584;
40648 t.question = 611;
40649 t.at = 975;
40650 t.A = 722;
40651 t.B = 722;
40652 t.C = 722;
40653 t.D = 722;
40654 t.E = 667;
40655 t.F = 611;
40656 t.G = 778;
40657 t.H = 722;
40658 t.I = 278;
40659 t.J = 556;
40660 t.K = 722;
40661 t.L = 611;
40662 t.M = 833;
40663 t.N = 722;
40664 t.O = 778;
40665 t.P = 667;
40666 t.Q = 778;
40667 t.R = 722;
40668 t.S = 667;
40669 t.T = 611;
40670 t.U = 722;
40671 t.V = 667;
40672 t.W = 944;
40673 t.X = 667;
40674 t.Y = 667;
40675 t.Z = 611;
40676 t.bracketleft = 333;
40677 t.backslash = 278;
40678 t.bracketright = 333;
40679 t.asciicircum = 584;
40680 t.underscore = 556;
40681 t.quoteleft = 278;
40682 t.a = 556;
40683 t.b = 611;
40684 t.c = 556;
40685 t.d = 611;
40686 t.e = 556;
40687 t.f = 333;
40688 t.g = 611;
40689 t.h = 611;
40690 t.i = 278;
40691 t.j = 278;
40692 t.k = 556;
40693 t.l = 278;
40694 t.m = 889;
40695 t.n = 611;
40696 t.o = 611;
40697 t.p = 611;
40698 t.q = 611;
40699 t.r = 389;
40700 t.s = 556;
40701 t.t = 333;
40702 t.u = 611;
40703 t.v = 556;
40704 t.w = 778;
40705 t.x = 556;
40706 t.y = 556;
40707 t.z = 500;
40708 t.braceleft = 389;
40709 t.bar = 280;
40710 t.braceright = 389;
40711 t.asciitilde = 584;
40712 t.exclamdown = 333;
40713 t.cent = 556;
40714 t.sterling = 556;
40715 t.fraction = 167;
40716 t.yen = 556;
40717 t.florin = 556;
40718 t.section = 556;
40719 t.currency = 556;
40720 t.quotesingle = 238;
40721 t.quotedblleft = 500;
40722 t.guillemotleft = 556;
40723 t.guilsinglleft = 333;
40724 t.guilsinglright = 333;
40725 t.fi = 611;
40726 t.fl = 611;
40727 t.endash = 556;
40728 t.dagger = 556;
40729 t.daggerdbl = 556;
40730 t.periodcentered = 278;
40731 t.paragraph = 556;
40732 t.bullet = 350;
40733 t.quotesinglbase = 278;
40734 t.quotedblbase = 500;
40735 t.quotedblright = 500;
40736 t.guillemotright = 556;
40737 t.ellipsis = 1000;
40738 t.perthousand = 1000;
40739 t.questiondown = 611;
40740 t.grave = 333;
40741 t.acute = 333;
40742 t.circumflex = 333;
40743 t.tilde = 333;
40744 t.macron = 333;
40745 t.breve = 333;
40746 t.dotaccent = 333;
40747 t.dieresis = 333;
40748 t.ring = 333;
40749 t.cedilla = 333;
40750 t.hungarumlaut = 333;
40751 t.ogonek = 333;
40752 t.caron = 333;
40753 t.emdash = 1000;
40754 t.AE = 1000;
40755 t.ordfeminine = 370;
40756 t.Lslash = 611;
40757 t.Oslash = 778;
40758 t.OE = 1000;
40759 t.ordmasculine = 365;
40760 t.ae = 889;
40761 t.dotlessi = 278;
40762 t.lslash = 278;
40763 t.oslash = 611;
40764 t.oe = 944;
40765 t.germandbls = 611;
40766 t.Idieresis = 278;
40767 t.eacute = 556;
40768 t.abreve = 556;
40769 t.uhungarumlaut = 611;
40770 t.ecaron = 556;
40771 t.Ydieresis = 667;
40772 t.divide = 584;
40773 t.Yacute = 667;
40774 t.Acircumflex = 722;
40775 t.aacute = 556;
40776 t.Ucircumflex = 722;
40777 t.yacute = 556;
40778 t.scommaaccent = 556;
40779 t.ecircumflex = 556;
40780 t.Uring = 722;
40781 t.Udieresis = 722;
40782 t.aogonek = 556;
40783 t.Uacute = 722;
40784 t.uogonek = 611;
40785 t.Edieresis = 667;
40786 t.Dcroat = 722;
40787 t.commaaccent = 250;
40788 t.copyright = 737;
40789 t.Emacron = 667;
40790 t.ccaron = 556;
40791 t.aring = 556;
40792 t.Ncommaaccent = 722;
40793 t.lacute = 278;
40794 t.agrave = 556;
40795 t.Tcommaaccent = 611;
40796 t.Cacute = 722;
40797 t.atilde = 556;
40798 t.Edotaccent = 667;
40799 t.scaron = 556;
40800 t.scedilla = 556;
40801 t.iacute = 278;
40802 t.lozenge = 494;
40803 t.Rcaron = 722;
40804 t.Gcommaaccent = 778;
40805 t.ucircumflex = 611;
40806 t.acircumflex = 556;
40807 t.Amacron = 722;
40808 t.rcaron = 389;
40809 t.ccedilla = 556;
40810 t.Zdotaccent = 611;
40811 t.Thorn = 667;
40812 t.Omacron = 778;
40813 t.Racute = 722;
40814 t.Sacute = 667;
40815 t.dcaron = 743;
40816 t.Umacron = 722;
40817 t.uring = 611;
40818 t.threesuperior = 333;
40819 t.Ograve = 778;
40820 t.Agrave = 722;
40821 t.Abreve = 722;
40822 t.multiply = 584;
40823 t.uacute = 611;
40824 t.Tcaron = 611;
40825 t.partialdiff = 494;
40826 t.ydieresis = 556;
40827 t.Nacute = 722;
40828 t.icircumflex = 278;
40829 t.Ecircumflex = 667;
40830 t.adieresis = 556;
40831 t.edieresis = 556;
40832 t.cacute = 556;
40833 t.nacute = 611;
40834 t.umacron = 611;
40835 t.Ncaron = 722;
40836 t.Iacute = 278;
40837 t.plusminus = 584;
40838 t.brokenbar = 280;
40839 t.registered = 737;
40840 t.Gbreve = 778;
40841 t.Idotaccent = 278;
40842 t.summation = 600;
40843 t.Egrave = 667;
40844 t.racute = 389;
40845 t.omacron = 611;
40846 t.Zacute = 611;
40847 t.Zcaron = 611;
40848 t.greaterequal = 549;
40849 t.Eth = 722;
40850 t.Ccedilla = 722;
40851 t.lcommaaccent = 278;
40852 t.tcaron = 389;
40853 t.eogonek = 556;
40854 t.Uogonek = 722;
40855 t.Aacute = 722;
40856 t.Adieresis = 722;
40857 t.egrave = 556;
40858 t.zacute = 500;
40859 t.iogonek = 278;
40860 t.Oacute = 778;
40861 t.oacute = 611;
40862 t.amacron = 556;
40863 t.sacute = 556;
40864 t.idieresis = 278;
40865 t.Ocircumflex = 778;
40866 t.Ugrave = 722;
40867 t.Delta = 612;
40868 t.thorn = 611;
40869 t.twosuperior = 333;
40870 t.Odieresis = 778;
40871 t.mu = 611;
40872 t.igrave = 278;
40873 t.ohungarumlaut = 611;
40874 t.Eogonek = 667;
40875 t.dcroat = 611;
40876 t.threequarters = 834;
40877 t.Scedilla = 667;
40878 t.lcaron = 400;
40879 t.Kcommaaccent = 722;
40880 t.Lacute = 611;
40881 t.trademark = 1000;
40882 t.edotaccent = 556;
40883 t.Igrave = 278;
40884 t.Imacron = 278;
40885 t.Lcaron = 611;
40886 t.onehalf = 834;
40887 t.lessequal = 549;
40888 t.ocircumflex = 611;
40889 t.ntilde = 611;
40890 t.Uhungarumlaut = 722;
40891 t.Eacute = 667;
40892 t.emacron = 556;
40893 t.gbreve = 611;
40894 t.onequarter = 834;
40895 t.Scaron = 667;
40896 t.Scommaaccent = 667;
40897 t.Ohungarumlaut = 778;
40898 t.degree = 400;
40899 t.ograve = 611;
40900 t.Ccaron = 722;
40901 t.ugrave = 611;
40902 t.radical = 549;
40903 t.Dcaron = 722;
40904 t.rcommaaccent = 389;
40905 t.Ntilde = 722;
40906 t.otilde = 611;
40907 t.Rcommaaccent = 722;
40908 t.Lcommaaccent = 611;
40909 t.Atilde = 722;
40910 t.Aogonek = 722;
40911 t.Aring = 722;
40912 t.Otilde = 778;
40913 t.zdotaccent = 500;
40914 t.Ecaron = 667;
40915 t.Iogonek = 278;
40916 t.kcommaaccent = 556;
40917 t.minus = 584;
40918 t.Icircumflex = 278;
40919 t.ncaron = 611;
40920 t.tcommaaccent = 333;
40921 t.logicalnot = 584;
40922 t.odieresis = 611;
40923 t.udieresis = 611;
40924 t.notequal = 549;
40925 t.gcommaaccent = 611;
40926 t.eth = 611;
40927 t.zcaron = 500;
40928 t.ncommaaccent = 611;
40929 t.onesuperior = 333;
40930 t.imacron = 278;
40931 t.Euro = 556;
40932 });
40933 t["Helvetica-Oblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
40934 t.space = 278;
40935 t.exclam = 278;
40936 t.quotedbl = 355;
40937 t.numbersign = 556;
40938 t.dollar = 556;
40939 t.percent = 889;
40940 t.ampersand = 667;
40941 t.quoteright = 222;
40942 t.parenleft = 333;
40943 t.parenright = 333;
40944 t.asterisk = 389;
40945 t.plus = 584;
40946 t.comma = 278;
40947 t.hyphen = 333;
40948 t.period = 278;
40949 t.slash = 278;
40950 t.zero = 556;
40951 t.one = 556;
40952 t.two = 556;
40953 t.three = 556;
40954 t.four = 556;
40955 t.five = 556;
40956 t.six = 556;
40957 t.seven = 556;
40958 t.eight = 556;
40959 t.nine = 556;
40960 t.colon = 278;
40961 t.semicolon = 278;
40962 t.less = 584;
40963 t.equal = 584;
40964 t.greater = 584;
40965 t.question = 556;
40966 t.at = 1015;
40967 t.A = 667;
40968 t.B = 667;
40969 t.C = 722;
40970 t.D = 722;
40971 t.E = 667;
40972 t.F = 611;
40973 t.G = 778;
40974 t.H = 722;
40975 t.I = 278;
40976 t.J = 500;
40977 t.K = 667;
40978 t.L = 556;
40979 t.M = 833;
40980 t.N = 722;
40981 t.O = 778;
40982 t.P = 667;
40983 t.Q = 778;
40984 t.R = 722;
40985 t.S = 667;
40986 t.T = 611;
40987 t.U = 722;
40988 t.V = 667;
40989 t.W = 944;
40990 t.X = 667;
40991 t.Y = 667;
40992 t.Z = 611;
40993 t.bracketleft = 278;
40994 t.backslash = 278;
40995 t.bracketright = 278;
40996 t.asciicircum = 469;
40997 t.underscore = 556;
40998 t.quoteleft = 222;
40999 t.a = 556;
41000 t.b = 556;
41001 t.c = 500;
41002 t.d = 556;
41003 t.e = 556;
41004 t.f = 278;
41005 t.g = 556;
41006 t.h = 556;
41007 t.i = 222;
41008 t.j = 222;
41009 t.k = 500;
41010 t.l = 222;
41011 t.m = 833;
41012 t.n = 556;
41013 t.o = 556;
41014 t.p = 556;
41015 t.q = 556;
41016 t.r = 333;
41017 t.s = 500;
41018 t.t = 278;
41019 t.u = 556;
41020 t.v = 500;
41021 t.w = 722;
41022 t.x = 500;
41023 t.y = 500;
41024 t.z = 500;
41025 t.braceleft = 334;
41026 t.bar = 260;
41027 t.braceright = 334;
41028 t.asciitilde = 584;
41029 t.exclamdown = 333;
41030 t.cent = 556;
41031 t.sterling = 556;
41032 t.fraction = 167;
41033 t.yen = 556;
41034 t.florin = 556;
41035 t.section = 556;
41036 t.currency = 556;
41037 t.quotesingle = 191;
41038 t.quotedblleft = 333;
41039 t.guillemotleft = 556;
41040 t.guilsinglleft = 333;
41041 t.guilsinglright = 333;
41042 t.fi = 500;
41043 t.fl = 500;
41044 t.endash = 556;
41045 t.dagger = 556;
41046 t.daggerdbl = 556;
41047 t.periodcentered = 278;
41048 t.paragraph = 537;
41049 t.bullet = 350;
41050 t.quotesinglbase = 222;
41051 t.quotedblbase = 333;
41052 t.quotedblright = 333;
41053 t.guillemotright = 556;
41054 t.ellipsis = 1000;
41055 t.perthousand = 1000;
41056 t.questiondown = 611;
41057 t.grave = 333;
41058 t.acute = 333;
41059 t.circumflex = 333;
41060 t.tilde = 333;
41061 t.macron = 333;
41062 t.breve = 333;
41063 t.dotaccent = 333;
41064 t.dieresis = 333;
41065 t.ring = 333;
41066 t.cedilla = 333;
41067 t.hungarumlaut = 333;
41068 t.ogonek = 333;
41069 t.caron = 333;
41070 t.emdash = 1000;
41071 t.AE = 1000;
41072 t.ordfeminine = 370;
41073 t.Lslash = 556;
41074 t.Oslash = 778;
41075 t.OE = 1000;
41076 t.ordmasculine = 365;
41077 t.ae = 889;
41078 t.dotlessi = 278;
41079 t.lslash = 222;
41080 t.oslash = 611;
41081 t.oe = 944;
41082 t.germandbls = 611;
41083 t.Idieresis = 278;
41084 t.eacute = 556;
41085 t.abreve = 556;
41086 t.uhungarumlaut = 556;
41087 t.ecaron = 556;
41088 t.Ydieresis = 667;
41089 t.divide = 584;
41090 t.Yacute = 667;
41091 t.Acircumflex = 667;
41092 t.aacute = 556;
41093 t.Ucircumflex = 722;
41094 t.yacute = 500;
41095 t.scommaaccent = 500;
41096 t.ecircumflex = 556;
41097 t.Uring = 722;
41098 t.Udieresis = 722;
41099 t.aogonek = 556;
41100 t.Uacute = 722;
41101 t.uogonek = 556;
41102 t.Edieresis = 667;
41103 t.Dcroat = 722;
41104 t.commaaccent = 250;
41105 t.copyright = 737;
41106 t.Emacron = 667;
41107 t.ccaron = 500;
41108 t.aring = 556;
41109 t.Ncommaaccent = 722;
41110 t.lacute = 222;
41111 t.agrave = 556;
41112 t.Tcommaaccent = 611;
41113 t.Cacute = 722;
41114 t.atilde = 556;
41115 t.Edotaccent = 667;
41116 t.scaron = 500;
41117 t.scedilla = 500;
41118 t.iacute = 278;
41119 t.lozenge = 471;
41120 t.Rcaron = 722;
41121 t.Gcommaaccent = 778;
41122 t.ucircumflex = 556;
41123 t.acircumflex = 556;
41124 t.Amacron = 667;
41125 t.rcaron = 333;
41126 t.ccedilla = 500;
41127 t.Zdotaccent = 611;
41128 t.Thorn = 667;
41129 t.Omacron = 778;
41130 t.Racute = 722;
41131 t.Sacute = 667;
41132 t.dcaron = 643;
41133 t.Umacron = 722;
41134 t.uring = 556;
41135 t.threesuperior = 333;
41136 t.Ograve = 778;
41137 t.Agrave = 667;
41138 t.Abreve = 667;
41139 t.multiply = 584;
41140 t.uacute = 556;
41141 t.Tcaron = 611;
41142 t.partialdiff = 476;
41143 t.ydieresis = 500;
41144 t.Nacute = 722;
41145 t.icircumflex = 278;
41146 t.Ecircumflex = 667;
41147 t.adieresis = 556;
41148 t.edieresis = 556;
41149 t.cacute = 500;
41150 t.nacute = 556;
41151 t.umacron = 556;
41152 t.Ncaron = 722;
41153 t.Iacute = 278;
41154 t.plusminus = 584;
41155 t.brokenbar = 260;
41156 t.registered = 737;
41157 t.Gbreve = 778;
41158 t.Idotaccent = 278;
41159 t.summation = 600;
41160 t.Egrave = 667;
41161 t.racute = 333;
41162 t.omacron = 556;
41163 t.Zacute = 611;
41164 t.Zcaron = 611;
41165 t.greaterequal = 549;
41166 t.Eth = 722;
41167 t.Ccedilla = 722;
41168 t.lcommaaccent = 222;
41169 t.tcaron = 317;
41170 t.eogonek = 556;
41171 t.Uogonek = 722;
41172 t.Aacute = 667;
41173 t.Adieresis = 667;
41174 t.egrave = 556;
41175 t.zacute = 500;
41176 t.iogonek = 222;
41177 t.Oacute = 778;
41178 t.oacute = 556;
41179 t.amacron = 556;
41180 t.sacute = 500;
41181 t.idieresis = 278;
41182 t.Ocircumflex = 778;
41183 t.Ugrave = 722;
41184 t.Delta = 612;
41185 t.thorn = 556;
41186 t.twosuperior = 333;
41187 t.Odieresis = 778;
41188 t.mu = 556;
41189 t.igrave = 278;
41190 t.ohungarumlaut = 556;
41191 t.Eogonek = 667;
41192 t.dcroat = 556;
41193 t.threequarters = 834;
41194 t.Scedilla = 667;
41195 t.lcaron = 299;
41196 t.Kcommaaccent = 667;
41197 t.Lacute = 556;
41198 t.trademark = 1000;
41199 t.edotaccent = 556;
41200 t.Igrave = 278;
41201 t.Imacron = 278;
41202 t.Lcaron = 556;
41203 t.onehalf = 834;
41204 t.lessequal = 549;
41205 t.ocircumflex = 556;
41206 t.ntilde = 556;
41207 t.Uhungarumlaut = 722;
41208 t.Eacute = 667;
41209 t.emacron = 556;
41210 t.gbreve = 556;
41211 t.onequarter = 834;
41212 t.Scaron = 667;
41213 t.Scommaaccent = 667;
41214 t.Ohungarumlaut = 778;
41215 t.degree = 400;
41216 t.ograve = 556;
41217 t.Ccaron = 722;
41218 t.ugrave = 556;
41219 t.radical = 453;
41220 t.Dcaron = 722;
41221 t.rcommaaccent = 333;
41222 t.Ntilde = 722;
41223 t.otilde = 556;
41224 t.Rcommaaccent = 722;
41225 t.Lcommaaccent = 556;
41226 t.Atilde = 667;
41227 t.Aogonek = 667;
41228 t.Aring = 667;
41229 t.Otilde = 778;
41230 t.zdotaccent = 500;
41231 t.Ecaron = 667;
41232 t.Iogonek = 278;
41233 t.kcommaaccent = 500;
41234 t.minus = 584;
41235 t.Icircumflex = 278;
41236 t.ncaron = 556;
41237 t.tcommaaccent = 278;
41238 t.logicalnot = 584;
41239 t.odieresis = 556;
41240 t.udieresis = 556;
41241 t.notequal = 549;
41242 t.gcommaaccent = 556;
41243 t.eth = 556;
41244 t.zcaron = 500;
41245 t.ncommaaccent = 556;
41246 t.onesuperior = 333;
41247 t.imacron = 278;
41248 t.Euro = 556;
41249 });
41250 t.Symbol = (0, _core_utils.getLookupTableFactory)(function (t) {
41251 t.space = 250;
41252 t.exclam = 333;
41253 t.universal = 713;
41254 t.numbersign = 500;
41255 t.existential = 549;
41256 t.percent = 833;
41257 t.ampersand = 778;
41258 t.suchthat = 439;
41259 t.parenleft = 333;
41260 t.parenright = 333;
41261 t.asteriskmath = 500;
41262 t.plus = 549;
41263 t.comma = 250;
41264 t.minus = 549;
41265 t.period = 250;
41266 t.slash = 278;
41267 t.zero = 500;
41268 t.one = 500;
41269 t.two = 500;
41270 t.three = 500;
41271 t.four = 500;
41272 t.five = 500;
41273 t.six = 500;
41274 t.seven = 500;
41275 t.eight = 500;
41276 t.nine = 500;
41277 t.colon = 278;
41278 t.semicolon = 278;
41279 t.less = 549;
41280 t.equal = 549;
41281 t.greater = 549;
41282 t.question = 444;
41283 t.congruent = 549;
41284 t.Alpha = 722;
41285 t.Beta = 667;
41286 t.Chi = 722;
41287 t.Delta = 612;
41288 t.Epsilon = 611;
41289 t.Phi = 763;
41290 t.Gamma = 603;
41291 t.Eta = 722;
41292 t.Iota = 333;
41293 t.theta1 = 631;
41294 t.Kappa = 722;
41295 t.Lambda = 686;
41296 t.Mu = 889;
41297 t.Nu = 722;
41298 t.Omicron = 722;
41299 t.Pi = 768;
41300 t.Theta = 741;
41301 t.Rho = 556;
41302 t.Sigma = 592;
41303 t.Tau = 611;
41304 t.Upsilon = 690;
41305 t.sigma1 = 439;
41306 t.Omega = 768;
41307 t.Xi = 645;
41308 t.Psi = 795;
41309 t.Zeta = 611;
41310 t.bracketleft = 333;
41311 t.therefore = 863;
41312 t.bracketright = 333;
41313 t.perpendicular = 658;
41314 t.underscore = 500;
41315 t.radicalex = 500;
41316 t.alpha = 631;
41317 t.beta = 549;
41318 t.chi = 549;
41319 t.delta = 494;
41320 t.epsilon = 439;
41321 t.phi = 521;
41322 t.gamma = 411;
41323 t.eta = 603;
41324 t.iota = 329;
41325 t.phi1 = 603;
41326 t.kappa = 549;
41327 t.lambda = 549;
41328 t.mu = 576;
41329 t.nu = 521;
41330 t.omicron = 549;
41331 t.pi = 549;
41332 t.theta = 521;
41333 t.rho = 549;
41334 t.sigma = 603;
41335 t.tau = 439;
41336 t.upsilon = 576;
41337 t.omega1 = 713;
41338 t.omega = 686;
41339 t.xi = 493;
41340 t.psi = 686;
41341 t.zeta = 494;
41342 t.braceleft = 480;
41343 t.bar = 200;
41344 t.braceright = 480;
41345 t.similar = 549;
41346 t.Euro = 750;
41347 t.Upsilon1 = 620;
41348 t.minute = 247;
41349 t.lessequal = 549;
41350 t.fraction = 167;
41351 t.infinity = 713;
41352 t.florin = 500;
41353 t.club = 753;
41354 t.diamond = 753;
41355 t.heart = 753;
41356 t.spade = 753;
41357 t.arrowboth = 1042;
41358 t.arrowleft = 987;
41359 t.arrowup = 603;
41360 t.arrowright = 987;
41361 t.arrowdown = 603;
41362 t.degree = 400;
41363 t.plusminus = 549;
41364 t.second = 411;
41365 t.greaterequal = 549;
41366 t.multiply = 549;
41367 t.proportional = 713;
41368 t.partialdiff = 494;
41369 t.bullet = 460;
41370 t.divide = 549;
41371 t.notequal = 549;
41372 t.equivalence = 549;
41373 t.approxequal = 549;
41374 t.ellipsis = 1000;
41375 t.arrowvertex = 603;
41376 t.arrowhorizex = 1000;
41377 t.carriagereturn = 658;
41378 t.aleph = 823;
41379 t.Ifraktur = 686;
41380 t.Rfraktur = 795;
41381 t.weierstrass = 987;
41382 t.circlemultiply = 768;
41383 t.circleplus = 768;
41384 t.emptyset = 823;
41385 t.intersection = 768;
41386 t.union = 768;
41387 t.propersuperset = 713;
41388 t.reflexsuperset = 713;
41389 t.notsubset = 713;
41390 t.propersubset = 713;
41391 t.reflexsubset = 713;
41392 t.element = 713;
41393 t.notelement = 713;
41394 t.angle = 768;
41395 t.gradient = 713;
41396 t.registerserif = 790;
41397 t.copyrightserif = 790;
41398 t.trademarkserif = 890;
41399 t.product = 823;
41400 t.radical = 549;
41401 t.dotmath = 250;
41402 t.logicalnot = 713;
41403 t.logicaland = 603;
41404 t.logicalor = 603;
41405 t.arrowdblboth = 1042;
41406 t.arrowdblleft = 987;
41407 t.arrowdblup = 603;
41408 t.arrowdblright = 987;
41409 t.arrowdbldown = 603;
41410 t.lozenge = 494;
41411 t.angleleft = 329;
41412 t.registersans = 790;
41413 t.copyrightsans = 790;
41414 t.trademarksans = 786;
41415 t.summation = 713;
41416 t.parenlefttp = 384;
41417 t.parenleftex = 384;
41418 t.parenleftbt = 384;
41419 t.bracketlefttp = 384;
41420 t.bracketleftex = 384;
41421 t.bracketleftbt = 384;
41422 t.bracelefttp = 494;
41423 t.braceleftmid = 494;
41424 t.braceleftbt = 494;
41425 t.braceex = 494;
41426 t.angleright = 329;
41427 t.integral = 274;
41428 t.integraltp = 686;
41429 t.integralex = 686;
41430 t.integralbt = 686;
41431 t.parenrighttp = 384;
41432 t.parenrightex = 384;
41433 t.parenrightbt = 384;
41434 t.bracketrighttp = 384;
41435 t.bracketrightex = 384;
41436 t.bracketrightbt = 384;
41437 t.bracerighttp = 494;
41438 t.bracerightmid = 494;
41439 t.bracerightbt = 494;
41440 t.apple = 790;
41441 });
41442 t["Times-Roman"] = (0, _core_utils.getLookupTableFactory)(function (t) {
41443 t.space = 250;
41444 t.exclam = 333;
41445 t.quotedbl = 408;
41446 t.numbersign = 500;
41447 t.dollar = 500;
41448 t.percent = 833;
41449 t.ampersand = 778;
41450 t.quoteright = 333;
41451 t.parenleft = 333;
41452 t.parenright = 333;
41453 t.asterisk = 500;
41454 t.plus = 564;
41455 t.comma = 250;
41456 t.hyphen = 333;
41457 t.period = 250;
41458 t.slash = 278;
41459 t.zero = 500;
41460 t.one = 500;
41461 t.two = 500;
41462 t.three = 500;
41463 t.four = 500;
41464 t.five = 500;
41465 t.six = 500;
41466 t.seven = 500;
41467 t.eight = 500;
41468 t.nine = 500;
41469 t.colon = 278;
41470 t.semicolon = 278;
41471 t.less = 564;
41472 t.equal = 564;
41473 t.greater = 564;
41474 t.question = 444;
41475 t.at = 921;
41476 t.A = 722;
41477 t.B = 667;
41478 t.C = 667;
41479 t.D = 722;
41480 t.E = 611;
41481 t.F = 556;
41482 t.G = 722;
41483 t.H = 722;
41484 t.I = 333;
41485 t.J = 389;
41486 t.K = 722;
41487 t.L = 611;
41488 t.M = 889;
41489 t.N = 722;
41490 t.O = 722;
41491 t.P = 556;
41492 t.Q = 722;
41493 t.R = 667;
41494 t.S = 556;
41495 t.T = 611;
41496 t.U = 722;
41497 t.V = 722;
41498 t.W = 944;
41499 t.X = 722;
41500 t.Y = 722;
41501 t.Z = 611;
41502 t.bracketleft = 333;
41503 t.backslash = 278;
41504 t.bracketright = 333;
41505 t.asciicircum = 469;
41506 t.underscore = 500;
41507 t.quoteleft = 333;
41508 t.a = 444;
41509 t.b = 500;
41510 t.c = 444;
41511 t.d = 500;
41512 t.e = 444;
41513 t.f = 333;
41514 t.g = 500;
41515 t.h = 500;
41516 t.i = 278;
41517 t.j = 278;
41518 t.k = 500;
41519 t.l = 278;
41520 t.m = 778;
41521 t.n = 500;
41522 t.o = 500;
41523 t.p = 500;
41524 t.q = 500;
41525 t.r = 333;
41526 t.s = 389;
41527 t.t = 278;
41528 t.u = 500;
41529 t.v = 500;
41530 t.w = 722;
41531 t.x = 500;
41532 t.y = 500;
41533 t.z = 444;
41534 t.braceleft = 480;
41535 t.bar = 200;
41536 t.braceright = 480;
41537 t.asciitilde = 541;
41538 t.exclamdown = 333;
41539 t.cent = 500;
41540 t.sterling = 500;
41541 t.fraction = 167;
41542 t.yen = 500;
41543 t.florin = 500;
41544 t.section = 500;
41545 t.currency = 500;
41546 t.quotesingle = 180;
41547 t.quotedblleft = 444;
41548 t.guillemotleft = 500;
41549 t.guilsinglleft = 333;
41550 t.guilsinglright = 333;
41551 t.fi = 556;
41552 t.fl = 556;
41553 t.endash = 500;
41554 t.dagger = 500;
41555 t.daggerdbl = 500;
41556 t.periodcentered = 250;
41557 t.paragraph = 453;
41558 t.bullet = 350;
41559 t.quotesinglbase = 333;
41560 t.quotedblbase = 444;
41561 t.quotedblright = 444;
41562 t.guillemotright = 500;
41563 t.ellipsis = 1000;
41564 t.perthousand = 1000;
41565 t.questiondown = 444;
41566 t.grave = 333;
41567 t.acute = 333;
41568 t.circumflex = 333;
41569 t.tilde = 333;
41570 t.macron = 333;
41571 t.breve = 333;
41572 t.dotaccent = 333;
41573 t.dieresis = 333;
41574 t.ring = 333;
41575 t.cedilla = 333;
41576 t.hungarumlaut = 333;
41577 t.ogonek = 333;
41578 t.caron = 333;
41579 t.emdash = 1000;
41580 t.AE = 889;
41581 t.ordfeminine = 276;
41582 t.Lslash = 611;
41583 t.Oslash = 722;
41584 t.OE = 889;
41585 t.ordmasculine = 310;
41586 t.ae = 667;
41587 t.dotlessi = 278;
41588 t.lslash = 278;
41589 t.oslash = 500;
41590 t.oe = 722;
41591 t.germandbls = 500;
41592 t.Idieresis = 333;
41593 t.eacute = 444;
41594 t.abreve = 444;
41595 t.uhungarumlaut = 500;
41596 t.ecaron = 444;
41597 t.Ydieresis = 722;
41598 t.divide = 564;
41599 t.Yacute = 722;
41600 t.Acircumflex = 722;
41601 t.aacute = 444;
41602 t.Ucircumflex = 722;
41603 t.yacute = 500;
41604 t.scommaaccent = 389;
41605 t.ecircumflex = 444;
41606 t.Uring = 722;
41607 t.Udieresis = 722;
41608 t.aogonek = 444;
41609 t.Uacute = 722;
41610 t.uogonek = 500;
41611 t.Edieresis = 611;
41612 t.Dcroat = 722;
41613 t.commaaccent = 250;
41614 t.copyright = 760;
41615 t.Emacron = 611;
41616 t.ccaron = 444;
41617 t.aring = 444;
41618 t.Ncommaaccent = 722;
41619 t.lacute = 278;
41620 t.agrave = 444;
41621 t.Tcommaaccent = 611;
41622 t.Cacute = 667;
41623 t.atilde = 444;
41624 t.Edotaccent = 611;
41625 t.scaron = 389;
41626 t.scedilla = 389;
41627 t.iacute = 278;
41628 t.lozenge = 471;
41629 t.Rcaron = 667;
41630 t.Gcommaaccent = 722;
41631 t.ucircumflex = 500;
41632 t.acircumflex = 444;
41633 t.Amacron = 722;
41634 t.rcaron = 333;
41635 t.ccedilla = 444;
41636 t.Zdotaccent = 611;
41637 t.Thorn = 556;
41638 t.Omacron = 722;
41639 t.Racute = 667;
41640 t.Sacute = 556;
41641 t.dcaron = 588;
41642 t.Umacron = 722;
41643 t.uring = 500;
41644 t.threesuperior = 300;
41645 t.Ograve = 722;
41646 t.Agrave = 722;
41647 t.Abreve = 722;
41648 t.multiply = 564;
41649 t.uacute = 500;
41650 t.Tcaron = 611;
41651 t.partialdiff = 476;
41652 t.ydieresis = 500;
41653 t.Nacute = 722;
41654 t.icircumflex = 278;
41655 t.Ecircumflex = 611;
41656 t.adieresis = 444;
41657 t.edieresis = 444;
41658 t.cacute = 444;
41659 t.nacute = 500;
41660 t.umacron = 500;
41661 t.Ncaron = 722;
41662 t.Iacute = 333;
41663 t.plusminus = 564;
41664 t.brokenbar = 200;
41665 t.registered = 760;
41666 t.Gbreve = 722;
41667 t.Idotaccent = 333;
41668 t.summation = 600;
41669 t.Egrave = 611;
41670 t.racute = 333;
41671 t.omacron = 500;
41672 t.Zacute = 611;
41673 t.Zcaron = 611;
41674 t.greaterequal = 549;
41675 t.Eth = 722;
41676 t.Ccedilla = 667;
41677 t.lcommaaccent = 278;
41678 t.tcaron = 326;
41679 t.eogonek = 444;
41680 t.Uogonek = 722;
41681 t.Aacute = 722;
41682 t.Adieresis = 722;
41683 t.egrave = 444;
41684 t.zacute = 444;
41685 t.iogonek = 278;
41686 t.Oacute = 722;
41687 t.oacute = 500;
41688 t.amacron = 444;
41689 t.sacute = 389;
41690 t.idieresis = 278;
41691 t.Ocircumflex = 722;
41692 t.Ugrave = 722;
41693 t.Delta = 612;
41694 t.thorn = 500;
41695 t.twosuperior = 300;
41696 t.Odieresis = 722;
41697 t.mu = 500;
41698 t.igrave = 278;
41699 t.ohungarumlaut = 500;
41700 t.Eogonek = 611;
41701 t.dcroat = 500;
41702 t.threequarters = 750;
41703 t.Scedilla = 556;
41704 t.lcaron = 344;
41705 t.Kcommaaccent = 722;
41706 t.Lacute = 611;
41707 t.trademark = 980;
41708 t.edotaccent = 444;
41709 t.Igrave = 333;
41710 t.Imacron = 333;
41711 t.Lcaron = 611;
41712 t.onehalf = 750;
41713 t.lessequal = 549;
41714 t.ocircumflex = 500;
41715 t.ntilde = 500;
41716 t.Uhungarumlaut = 722;
41717 t.Eacute = 611;
41718 t.emacron = 444;
41719 t.gbreve = 500;
41720 t.onequarter = 750;
41721 t.Scaron = 556;
41722 t.Scommaaccent = 556;
41723 t.Ohungarumlaut = 722;
41724 t.degree = 400;
41725 t.ograve = 500;
41726 t.Ccaron = 667;
41727 t.ugrave = 500;
41728 t.radical = 453;
41729 t.Dcaron = 722;
41730 t.rcommaaccent = 333;
41731 t.Ntilde = 722;
41732 t.otilde = 500;
41733 t.Rcommaaccent = 667;
41734 t.Lcommaaccent = 611;
41735 t.Atilde = 722;
41736 t.Aogonek = 722;
41737 t.Aring = 722;
41738 t.Otilde = 722;
41739 t.zdotaccent = 444;
41740 t.Ecaron = 611;
41741 t.Iogonek = 333;
41742 t.kcommaaccent = 500;
41743 t.minus = 564;
41744 t.Icircumflex = 333;
41745 t.ncaron = 500;
41746 t.tcommaaccent = 278;
41747 t.logicalnot = 564;
41748 t.odieresis = 500;
41749 t.udieresis = 500;
41750 t.notequal = 549;
41751 t.gcommaaccent = 500;
41752 t.eth = 500;
41753 t.zcaron = 444;
41754 t.ncommaaccent = 500;
41755 t.onesuperior = 300;
41756 t.imacron = 278;
41757 t.Euro = 500;
41758 });
41759 t["Times-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
41760 t.space = 250;
41761 t.exclam = 333;
41762 t.quotedbl = 555;
41763 t.numbersign = 500;
41764 t.dollar = 500;
41765 t.percent = 1000;
41766 t.ampersand = 833;
41767 t.quoteright = 333;
41768 t.parenleft = 333;
41769 t.parenright = 333;
41770 t.asterisk = 500;
41771 t.plus = 570;
41772 t.comma = 250;
41773 t.hyphen = 333;
41774 t.period = 250;
41775 t.slash = 278;
41776 t.zero = 500;
41777 t.one = 500;
41778 t.two = 500;
41779 t.three = 500;
41780 t.four = 500;
41781 t.five = 500;
41782 t.six = 500;
41783 t.seven = 500;
41784 t.eight = 500;
41785 t.nine = 500;
41786 t.colon = 333;
41787 t.semicolon = 333;
41788 t.less = 570;
41789 t.equal = 570;
41790 t.greater = 570;
41791 t.question = 500;
41792 t.at = 930;
41793 t.A = 722;
41794 t.B = 667;
41795 t.C = 722;
41796 t.D = 722;
41797 t.E = 667;
41798 t.F = 611;
41799 t.G = 778;
41800 t.H = 778;
41801 t.I = 389;
41802 t.J = 500;
41803 t.K = 778;
41804 t.L = 667;
41805 t.M = 944;
41806 t.N = 722;
41807 t.O = 778;
41808 t.P = 611;
41809 t.Q = 778;
41810 t.R = 722;
41811 t.S = 556;
41812 t.T = 667;
41813 t.U = 722;
41814 t.V = 722;
41815 t.W = 1000;
41816 t.X = 722;
41817 t.Y = 722;
41818 t.Z = 667;
41819 t.bracketleft = 333;
41820 t.backslash = 278;
41821 t.bracketright = 333;
41822 t.asciicircum = 581;
41823 t.underscore = 500;
41824 t.quoteleft = 333;
41825 t.a = 500;
41826 t.b = 556;
41827 t.c = 444;
41828 t.d = 556;
41829 t.e = 444;
41830 t.f = 333;
41831 t.g = 500;
41832 t.h = 556;
41833 t.i = 278;
41834 t.j = 333;
41835 t.k = 556;
41836 t.l = 278;
41837 t.m = 833;
41838 t.n = 556;
41839 t.o = 500;
41840 t.p = 556;
41841 t.q = 556;
41842 t.r = 444;
41843 t.s = 389;
41844 t.t = 333;
41845 t.u = 556;
41846 t.v = 500;
41847 t.w = 722;
41848 t.x = 500;
41849 t.y = 500;
41850 t.z = 444;
41851 t.braceleft = 394;
41852 t.bar = 220;
41853 t.braceright = 394;
41854 t.asciitilde = 520;
41855 t.exclamdown = 333;
41856 t.cent = 500;
41857 t.sterling = 500;
41858 t.fraction = 167;
41859 t.yen = 500;
41860 t.florin = 500;
41861 t.section = 500;
41862 t.currency = 500;
41863 t.quotesingle = 278;
41864 t.quotedblleft = 500;
41865 t.guillemotleft = 500;
41866 t.guilsinglleft = 333;
41867 t.guilsinglright = 333;
41868 t.fi = 556;
41869 t.fl = 556;
41870 t.endash = 500;
41871 t.dagger = 500;
41872 t.daggerdbl = 500;
41873 t.periodcentered = 250;
41874 t.paragraph = 540;
41875 t.bullet = 350;
41876 t.quotesinglbase = 333;
41877 t.quotedblbase = 500;
41878 t.quotedblright = 500;
41879 t.guillemotright = 500;
41880 t.ellipsis = 1000;
41881 t.perthousand = 1000;
41882 t.questiondown = 500;
41883 t.grave = 333;
41884 t.acute = 333;
41885 t.circumflex = 333;
41886 t.tilde = 333;
41887 t.macron = 333;
41888 t.breve = 333;
41889 t.dotaccent = 333;
41890 t.dieresis = 333;
41891 t.ring = 333;
41892 t.cedilla = 333;
41893 t.hungarumlaut = 333;
41894 t.ogonek = 333;
41895 t.caron = 333;
41896 t.emdash = 1000;
41897 t.AE = 1000;
41898 t.ordfeminine = 300;
41899 t.Lslash = 667;
41900 t.Oslash = 778;
41901 t.OE = 1000;
41902 t.ordmasculine = 330;
41903 t.ae = 722;
41904 t.dotlessi = 278;
41905 t.lslash = 278;
41906 t.oslash = 500;
41907 t.oe = 722;
41908 t.germandbls = 556;
41909 t.Idieresis = 389;
41910 t.eacute = 444;
41911 t.abreve = 500;
41912 t.uhungarumlaut = 556;
41913 t.ecaron = 444;
41914 t.Ydieresis = 722;
41915 t.divide = 570;
41916 t.Yacute = 722;
41917 t.Acircumflex = 722;
41918 t.aacute = 500;
41919 t.Ucircumflex = 722;
41920 t.yacute = 500;
41921 t.scommaaccent = 389;
41922 t.ecircumflex = 444;
41923 t.Uring = 722;
41924 t.Udieresis = 722;
41925 t.aogonek = 500;
41926 t.Uacute = 722;
41927 t.uogonek = 556;
41928 t.Edieresis = 667;
41929 t.Dcroat = 722;
41930 t.commaaccent = 250;
41931 t.copyright = 747;
41932 t.Emacron = 667;
41933 t.ccaron = 444;
41934 t.aring = 500;
41935 t.Ncommaaccent = 722;
41936 t.lacute = 278;
41937 t.agrave = 500;
41938 t.Tcommaaccent = 667;
41939 t.Cacute = 722;
41940 t.atilde = 500;
41941 t.Edotaccent = 667;
41942 t.scaron = 389;
41943 t.scedilla = 389;
41944 t.iacute = 278;
41945 t.lozenge = 494;
41946 t.Rcaron = 722;
41947 t.Gcommaaccent = 778;
41948 t.ucircumflex = 556;
41949 t.acircumflex = 500;
41950 t.Amacron = 722;
41951 t.rcaron = 444;
41952 t.ccedilla = 444;
41953 t.Zdotaccent = 667;
41954 t.Thorn = 611;
41955 t.Omacron = 778;
41956 t.Racute = 722;
41957 t.Sacute = 556;
41958 t.dcaron = 672;
41959 t.Umacron = 722;
41960 t.uring = 556;
41961 t.threesuperior = 300;
41962 t.Ograve = 778;
41963 t.Agrave = 722;
41964 t.Abreve = 722;
41965 t.multiply = 570;
41966 t.uacute = 556;
41967 t.Tcaron = 667;
41968 t.partialdiff = 494;
41969 t.ydieresis = 500;
41970 t.Nacute = 722;
41971 t.icircumflex = 278;
41972 t.Ecircumflex = 667;
41973 t.adieresis = 500;
41974 t.edieresis = 444;
41975 t.cacute = 444;
41976 t.nacute = 556;
41977 t.umacron = 556;
41978 t.Ncaron = 722;
41979 t.Iacute = 389;
41980 t.plusminus = 570;
41981 t.brokenbar = 220;
41982 t.registered = 747;
41983 t.Gbreve = 778;
41984 t.Idotaccent = 389;
41985 t.summation = 600;
41986 t.Egrave = 667;
41987 t.racute = 444;
41988 t.omacron = 500;
41989 t.Zacute = 667;
41990 t.Zcaron = 667;
41991 t.greaterequal = 549;
41992 t.Eth = 722;
41993 t.Ccedilla = 722;
41994 t.lcommaaccent = 278;
41995 t.tcaron = 416;
41996 t.eogonek = 444;
41997 t.Uogonek = 722;
41998 t.Aacute = 722;
41999 t.Adieresis = 722;
42000 t.egrave = 444;
42001 t.zacute = 444;
42002 t.iogonek = 278;
42003 t.Oacute = 778;
42004 t.oacute = 500;
42005 t.amacron = 500;
42006 t.sacute = 389;
42007 t.idieresis = 278;
42008 t.Ocircumflex = 778;
42009 t.Ugrave = 722;
42010 t.Delta = 612;
42011 t.thorn = 556;
42012 t.twosuperior = 300;
42013 t.Odieresis = 778;
42014 t.mu = 556;
42015 t.igrave = 278;
42016 t.ohungarumlaut = 500;
42017 t.Eogonek = 667;
42018 t.dcroat = 556;
42019 t.threequarters = 750;
42020 t.Scedilla = 556;
42021 t.lcaron = 394;
42022 t.Kcommaaccent = 778;
42023 t.Lacute = 667;
42024 t.trademark = 1000;
42025 t.edotaccent = 444;
42026 t.Igrave = 389;
42027 t.Imacron = 389;
42028 t.Lcaron = 667;
42029 t.onehalf = 750;
42030 t.lessequal = 549;
42031 t.ocircumflex = 500;
42032 t.ntilde = 556;
42033 t.Uhungarumlaut = 722;
42034 t.Eacute = 667;
42035 t.emacron = 444;
42036 t.gbreve = 500;
42037 t.onequarter = 750;
42038 t.Scaron = 556;
42039 t.Scommaaccent = 556;
42040 t.Ohungarumlaut = 778;
42041 t.degree = 400;
42042 t.ograve = 500;
42043 t.Ccaron = 722;
42044 t.ugrave = 556;
42045 t.radical = 549;
42046 t.Dcaron = 722;
42047 t.rcommaaccent = 444;
42048 t.Ntilde = 722;
42049 t.otilde = 500;
42050 t.Rcommaaccent = 722;
42051 t.Lcommaaccent = 667;
42052 t.Atilde = 722;
42053 t.Aogonek = 722;
42054 t.Aring = 722;
42055 t.Otilde = 778;
42056 t.zdotaccent = 444;
42057 t.Ecaron = 667;
42058 t.Iogonek = 389;
42059 t.kcommaaccent = 556;
42060 t.minus = 570;
42061 t.Icircumflex = 389;
42062 t.ncaron = 556;
42063 t.tcommaaccent = 333;
42064 t.logicalnot = 570;
42065 t.odieresis = 500;
42066 t.udieresis = 556;
42067 t.notequal = 549;
42068 t.gcommaaccent = 500;
42069 t.eth = 500;
42070 t.zcaron = 444;
42071 t.ncommaaccent = 556;
42072 t.onesuperior = 300;
42073 t.imacron = 278;
42074 t.Euro = 500;
42075 });
42076 t["Times-BoldItalic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
42077 t.space = 250;
42078 t.exclam = 389;
42079 t.quotedbl = 555;
42080 t.numbersign = 500;
42081 t.dollar = 500;
42082 t.percent = 833;
42083 t.ampersand = 778;
42084 t.quoteright = 333;
42085 t.parenleft = 333;
42086 t.parenright = 333;
42087 t.asterisk = 500;
42088 t.plus = 570;
42089 t.comma = 250;
42090 t.hyphen = 333;
42091 t.period = 250;
42092 t.slash = 278;
42093 t.zero = 500;
42094 t.one = 500;
42095 t.two = 500;
42096 t.three = 500;
42097 t.four = 500;
42098 t.five = 500;
42099 t.six = 500;
42100 t.seven = 500;
42101 t.eight = 500;
42102 t.nine = 500;
42103 t.colon = 333;
42104 t.semicolon = 333;
42105 t.less = 570;
42106 t.equal = 570;
42107 t.greater = 570;
42108 t.question = 500;
42109 t.at = 832;
42110 t.A = 667;
42111 t.B = 667;
42112 t.C = 667;
42113 t.D = 722;
42114 t.E = 667;
42115 t.F = 667;
42116 t.G = 722;
42117 t.H = 778;
42118 t.I = 389;
42119 t.J = 500;
42120 t.K = 667;
42121 t.L = 611;
42122 t.M = 889;
42123 t.N = 722;
42124 t.O = 722;
42125 t.P = 611;
42126 t.Q = 722;
42127 t.R = 667;
42128 t.S = 556;
42129 t.T = 611;
42130 t.U = 722;
42131 t.V = 667;
42132 t.W = 889;
42133 t.X = 667;
42134 t.Y = 611;
42135 t.Z = 611;
42136 t.bracketleft = 333;
42137 t.backslash = 278;
42138 t.bracketright = 333;
42139 t.asciicircum = 570;
42140 t.underscore = 500;
42141 t.quoteleft = 333;
42142 t.a = 500;
42143 t.b = 500;
42144 t.c = 444;
42145 t.d = 500;
42146 t.e = 444;
42147 t.f = 333;
42148 t.g = 500;
42149 t.h = 556;
42150 t.i = 278;
42151 t.j = 278;
42152 t.k = 500;
42153 t.l = 278;
42154 t.m = 778;
42155 t.n = 556;
42156 t.o = 500;
42157 t.p = 500;
42158 t.q = 500;
42159 t.r = 389;
42160 t.s = 389;
42161 t.t = 278;
42162 t.u = 556;
42163 t.v = 444;
42164 t.w = 667;
42165 t.x = 500;
42166 t.y = 444;
42167 t.z = 389;
42168 t.braceleft = 348;
42169 t.bar = 220;
42170 t.braceright = 348;
42171 t.asciitilde = 570;
42172 t.exclamdown = 389;
42173 t.cent = 500;
42174 t.sterling = 500;
42175 t.fraction = 167;
42176 t.yen = 500;
42177 t.florin = 500;
42178 t.section = 500;
42179 t.currency = 500;
42180 t.quotesingle = 278;
42181 t.quotedblleft = 500;
42182 t.guillemotleft = 500;
42183 t.guilsinglleft = 333;
42184 t.guilsinglright = 333;
42185 t.fi = 556;
42186 t.fl = 556;
42187 t.endash = 500;
42188 t.dagger = 500;
42189 t.daggerdbl = 500;
42190 t.periodcentered = 250;
42191 t.paragraph = 500;
42192 t.bullet = 350;
42193 t.quotesinglbase = 333;
42194 t.quotedblbase = 500;
42195 t.quotedblright = 500;
42196 t.guillemotright = 500;
42197 t.ellipsis = 1000;
42198 t.perthousand = 1000;
42199 t.questiondown = 500;
42200 t.grave = 333;
42201 t.acute = 333;
42202 t.circumflex = 333;
42203 t.tilde = 333;
42204 t.macron = 333;
42205 t.breve = 333;
42206 t.dotaccent = 333;
42207 t.dieresis = 333;
42208 t.ring = 333;
42209 t.cedilla = 333;
42210 t.hungarumlaut = 333;
42211 t.ogonek = 333;
42212 t.caron = 333;
42213 t.emdash = 1000;
42214 t.AE = 944;
42215 t.ordfeminine = 266;
42216 t.Lslash = 611;
42217 t.Oslash = 722;
42218 t.OE = 944;
42219 t.ordmasculine = 300;
42220 t.ae = 722;
42221 t.dotlessi = 278;
42222 t.lslash = 278;
42223 t.oslash = 500;
42224 t.oe = 722;
42225 t.germandbls = 500;
42226 t.Idieresis = 389;
42227 t.eacute = 444;
42228 t.abreve = 500;
42229 t.uhungarumlaut = 556;
42230 t.ecaron = 444;
42231 t.Ydieresis = 611;
42232 t.divide = 570;
42233 t.Yacute = 611;
42234 t.Acircumflex = 667;
42235 t.aacute = 500;
42236 t.Ucircumflex = 722;
42237 t.yacute = 444;
42238 t.scommaaccent = 389;
42239 t.ecircumflex = 444;
42240 t.Uring = 722;
42241 t.Udieresis = 722;
42242 t.aogonek = 500;
42243 t.Uacute = 722;
42244 t.uogonek = 556;
42245 t.Edieresis = 667;
42246 t.Dcroat = 722;
42247 t.commaaccent = 250;
42248 t.copyright = 747;
42249 t.Emacron = 667;
42250 t.ccaron = 444;
42251 t.aring = 500;
42252 t.Ncommaaccent = 722;
42253 t.lacute = 278;
42254 t.agrave = 500;
42255 t.Tcommaaccent = 611;
42256 t.Cacute = 667;
42257 t.atilde = 500;
42258 t.Edotaccent = 667;
42259 t.scaron = 389;
42260 t.scedilla = 389;
42261 t.iacute = 278;
42262 t.lozenge = 494;
42263 t.Rcaron = 667;
42264 t.Gcommaaccent = 722;
42265 t.ucircumflex = 556;
42266 t.acircumflex = 500;
42267 t.Amacron = 667;
42268 t.rcaron = 389;
42269 t.ccedilla = 444;
42270 t.Zdotaccent = 611;
42271 t.Thorn = 611;
42272 t.Omacron = 722;
42273 t.Racute = 667;
42274 t.Sacute = 556;
42275 t.dcaron = 608;
42276 t.Umacron = 722;
42277 t.uring = 556;
42278 t.threesuperior = 300;
42279 t.Ograve = 722;
42280 t.Agrave = 667;
42281 t.Abreve = 667;
42282 t.multiply = 570;
42283 t.uacute = 556;
42284 t.Tcaron = 611;
42285 t.partialdiff = 494;
42286 t.ydieresis = 444;
42287 t.Nacute = 722;
42288 t.icircumflex = 278;
42289 t.Ecircumflex = 667;
42290 t.adieresis = 500;
42291 t.edieresis = 444;
42292 t.cacute = 444;
42293 t.nacute = 556;
42294 t.umacron = 556;
42295 t.Ncaron = 722;
42296 t.Iacute = 389;
42297 t.plusminus = 570;
42298 t.brokenbar = 220;
42299 t.registered = 747;
42300 t.Gbreve = 722;
42301 t.Idotaccent = 389;
42302 t.summation = 600;
42303 t.Egrave = 667;
42304 t.racute = 389;
42305 t.omacron = 500;
42306 t.Zacute = 611;
42307 t.Zcaron = 611;
42308 t.greaterequal = 549;
42309 t.Eth = 722;
42310 t.Ccedilla = 667;
42311 t.lcommaaccent = 278;
42312 t.tcaron = 366;
42313 t.eogonek = 444;
42314 t.Uogonek = 722;
42315 t.Aacute = 667;
42316 t.Adieresis = 667;
42317 t.egrave = 444;
42318 t.zacute = 389;
42319 t.iogonek = 278;
42320 t.Oacute = 722;
42321 t.oacute = 500;
42322 t.amacron = 500;
42323 t.sacute = 389;
42324 t.idieresis = 278;
42325 t.Ocircumflex = 722;
42326 t.Ugrave = 722;
42327 t.Delta = 612;
42328 t.thorn = 500;
42329 t.twosuperior = 300;
42330 t.Odieresis = 722;
42331 t.mu = 576;
42332 t.igrave = 278;
42333 t.ohungarumlaut = 500;
42334 t.Eogonek = 667;
42335 t.dcroat = 500;
42336 t.threequarters = 750;
42337 t.Scedilla = 556;
42338 t.lcaron = 382;
42339 t.Kcommaaccent = 667;
42340 t.Lacute = 611;
42341 t.trademark = 1000;
42342 t.edotaccent = 444;
42343 t.Igrave = 389;
42344 t.Imacron = 389;
42345 t.Lcaron = 611;
42346 t.onehalf = 750;
42347 t.lessequal = 549;
42348 t.ocircumflex = 500;
42349 t.ntilde = 556;
42350 t.Uhungarumlaut = 722;
42351 t.Eacute = 667;
42352 t.emacron = 444;
42353 t.gbreve = 500;
42354 t.onequarter = 750;
42355 t.Scaron = 556;
42356 t.Scommaaccent = 556;
42357 t.Ohungarumlaut = 722;
42358 t.degree = 400;
42359 t.ograve = 500;
42360 t.Ccaron = 667;
42361 t.ugrave = 556;
42362 t.radical = 549;
42363 t.Dcaron = 722;
42364 t.rcommaaccent = 389;
42365 t.Ntilde = 722;
42366 t.otilde = 500;
42367 t.Rcommaaccent = 667;
42368 t.Lcommaaccent = 611;
42369 t.Atilde = 667;
42370 t.Aogonek = 667;
42371 t.Aring = 667;
42372 t.Otilde = 722;
42373 t.zdotaccent = 389;
42374 t.Ecaron = 667;
42375 t.Iogonek = 389;
42376 t.kcommaaccent = 500;
42377 t.minus = 606;
42378 t.Icircumflex = 389;
42379 t.ncaron = 556;
42380 t.tcommaaccent = 278;
42381 t.logicalnot = 606;
42382 t.odieresis = 500;
42383 t.udieresis = 556;
42384 t.notequal = 549;
42385 t.gcommaaccent = 500;
42386 t.eth = 500;
42387 t.zcaron = 389;
42388 t.ncommaaccent = 556;
42389 t.onesuperior = 300;
42390 t.imacron = 278;
42391 t.Euro = 500;
42392 });
42393 t["Times-Italic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
42394 t.space = 250;
42395 t.exclam = 333;
42396 t.quotedbl = 420;
42397 t.numbersign = 500;
42398 t.dollar = 500;
42399 t.percent = 833;
42400 t.ampersand = 778;
42401 t.quoteright = 333;
42402 t.parenleft = 333;
42403 t.parenright = 333;
42404 t.asterisk = 500;
42405 t.plus = 675;
42406 t.comma = 250;
42407 t.hyphen = 333;
42408 t.period = 250;
42409 t.slash = 278;
42410 t.zero = 500;
42411 t.one = 500;
42412 t.two = 500;
42413 t.three = 500;
42414 t.four = 500;
42415 t.five = 500;
42416 t.six = 500;
42417 t.seven = 500;
42418 t.eight = 500;
42419 t.nine = 500;
42420 t.colon = 333;
42421 t.semicolon = 333;
42422 t.less = 675;
42423 t.equal = 675;
42424 t.greater = 675;
42425 t.question = 500;
42426 t.at = 920;
42427 t.A = 611;
42428 t.B = 611;
42429 t.C = 667;
42430 t.D = 722;
42431 t.E = 611;
42432 t.F = 611;
42433 t.G = 722;
42434 t.H = 722;
42435 t.I = 333;
42436 t.J = 444;
42437 t.K = 667;
42438 t.L = 556;
42439 t.M = 833;
42440 t.N = 667;
42441 t.O = 722;
42442 t.P = 611;
42443 t.Q = 722;
42444 t.R = 611;
42445 t.S = 500;
42446 t.T = 556;
42447 t.U = 722;
42448 t.V = 611;
42449 t.W = 833;
42450 t.X = 611;
42451 t.Y = 556;
42452 t.Z = 556;
42453 t.bracketleft = 389;
42454 t.backslash = 278;
42455 t.bracketright = 389;
42456 t.asciicircum = 422;
42457 t.underscore = 500;
42458 t.quoteleft = 333;
42459 t.a = 500;
42460 t.b = 500;
42461 t.c = 444;
42462 t.d = 500;
42463 t.e = 444;
42464 t.f = 278;
42465 t.g = 500;
42466 t.h = 500;
42467 t.i = 278;
42468 t.j = 278;
42469 t.k = 444;
42470 t.l = 278;
42471 t.m = 722;
42472 t.n = 500;
42473 t.o = 500;
42474 t.p = 500;
42475 t.q = 500;
42476 t.r = 389;
42477 t.s = 389;
42478 t.t = 278;
42479 t.u = 500;
42480 t.v = 444;
42481 t.w = 667;
42482 t.x = 444;
42483 t.y = 444;
42484 t.z = 389;
42485 t.braceleft = 400;
42486 t.bar = 275;
42487 t.braceright = 400;
42488 t.asciitilde = 541;
42489 t.exclamdown = 389;
42490 t.cent = 500;
42491 t.sterling = 500;
42492 t.fraction = 167;
42493 t.yen = 500;
42494 t.florin = 500;
42495 t.section = 500;
42496 t.currency = 500;
42497 t.quotesingle = 214;
42498 t.quotedblleft = 556;
42499 t.guillemotleft = 500;
42500 t.guilsinglleft = 333;
42501 t.guilsinglright = 333;
42502 t.fi = 500;
42503 t.fl = 500;
42504 t.endash = 500;
42505 t.dagger = 500;
42506 t.daggerdbl = 500;
42507 t.periodcentered = 250;
42508 t.paragraph = 523;
42509 t.bullet = 350;
42510 t.quotesinglbase = 333;
42511 t.quotedblbase = 556;
42512 t.quotedblright = 556;
42513 t.guillemotright = 500;
42514 t.ellipsis = 889;
42515 t.perthousand = 1000;
42516 t.questiondown = 500;
42517 t.grave = 333;
42518 t.acute = 333;
42519 t.circumflex = 333;
42520 t.tilde = 333;
42521 t.macron = 333;
42522 t.breve = 333;
42523 t.dotaccent = 333;
42524 t.dieresis = 333;
42525 t.ring = 333;
42526 t.cedilla = 333;
42527 t.hungarumlaut = 333;
42528 t.ogonek = 333;
42529 t.caron = 333;
42530 t.emdash = 889;
42531 t.AE = 889;
42532 t.ordfeminine = 276;
42533 t.Lslash = 556;
42534 t.Oslash = 722;
42535 t.OE = 944;
42536 t.ordmasculine = 310;
42537 t.ae = 667;
42538 t.dotlessi = 278;
42539 t.lslash = 278;
42540 t.oslash = 500;
42541 t.oe = 667;
42542 t.germandbls = 500;
42543 t.Idieresis = 333;
42544 t.eacute = 444;
42545 t.abreve = 500;
42546 t.uhungarumlaut = 500;
42547 t.ecaron = 444;
42548 t.Ydieresis = 556;
42549 t.divide = 675;
42550 t.Yacute = 556;
42551 t.Acircumflex = 611;
42552 t.aacute = 500;
42553 t.Ucircumflex = 722;
42554 t.yacute = 444;
42555 t.scommaaccent = 389;
42556 t.ecircumflex = 444;
42557 t.Uring = 722;
42558 t.Udieresis = 722;
42559 t.aogonek = 500;
42560 t.Uacute = 722;
42561 t.uogonek = 500;
42562 t.Edieresis = 611;
42563 t.Dcroat = 722;
42564 t.commaaccent = 250;
42565 t.copyright = 760;
42566 t.Emacron = 611;
42567 t.ccaron = 444;
42568 t.aring = 500;
42569 t.Ncommaaccent = 667;
42570 t.lacute = 278;
42571 t.agrave = 500;
42572 t.Tcommaaccent = 556;
42573 t.Cacute = 667;
42574 t.atilde = 500;
42575 t.Edotaccent = 611;
42576 t.scaron = 389;
42577 t.scedilla = 389;
42578 t.iacute = 278;
42579 t.lozenge = 471;
42580 t.Rcaron = 611;
42581 t.Gcommaaccent = 722;
42582 t.ucircumflex = 500;
42583 t.acircumflex = 500;
42584 t.Amacron = 611;
42585 t.rcaron = 389;
42586 t.ccedilla = 444;
42587 t.Zdotaccent = 556;
42588 t.Thorn = 611;
42589 t.Omacron = 722;
42590 t.Racute = 611;
42591 t.Sacute = 500;
42592 t.dcaron = 544;
42593 t.Umacron = 722;
42594 t.uring = 500;
42595 t.threesuperior = 300;
42596 t.Ograve = 722;
42597 t.Agrave = 611;
42598 t.Abreve = 611;
42599 t.multiply = 675;
42600 t.uacute = 500;
42601 t.Tcaron = 556;
42602 t.partialdiff = 476;
42603 t.ydieresis = 444;
42604 t.Nacute = 667;
42605 t.icircumflex = 278;
42606 t.Ecircumflex = 611;
42607 t.adieresis = 500;
42608 t.edieresis = 444;
42609 t.cacute = 444;
42610 t.nacute = 500;
42611 t.umacron = 500;
42612 t.Ncaron = 667;
42613 t.Iacute = 333;
42614 t.plusminus = 675;
42615 t.brokenbar = 275;
42616 t.registered = 760;
42617 t.Gbreve = 722;
42618 t.Idotaccent = 333;
42619 t.summation = 600;
42620 t.Egrave = 611;
42621 t.racute = 389;
42622 t.omacron = 500;
42623 t.Zacute = 556;
42624 t.Zcaron = 556;
42625 t.greaterequal = 549;
42626 t.Eth = 722;
42627 t.Ccedilla = 667;
42628 t.lcommaaccent = 278;
42629 t.tcaron = 300;
42630 t.eogonek = 444;
42631 t.Uogonek = 722;
42632 t.Aacute = 611;
42633 t.Adieresis = 611;
42634 t.egrave = 444;
42635 t.zacute = 389;
42636 t.iogonek = 278;
42637 t.Oacute = 722;
42638 t.oacute = 500;
42639 t.amacron = 500;
42640 t.sacute = 389;
42641 t.idieresis = 278;
42642 t.Ocircumflex = 722;
42643 t.Ugrave = 722;
42644 t.Delta = 612;
42645 t.thorn = 500;
42646 t.twosuperior = 300;
42647 t.Odieresis = 722;
42648 t.mu = 500;
42649 t.igrave = 278;
42650 t.ohungarumlaut = 500;
42651 t.Eogonek = 611;
42652 t.dcroat = 500;
42653 t.threequarters = 750;
42654 t.Scedilla = 500;
42655 t.lcaron = 300;
42656 t.Kcommaaccent = 667;
42657 t.Lacute = 556;
42658 t.trademark = 980;
42659 t.edotaccent = 444;
42660 t.Igrave = 333;
42661 t.Imacron = 333;
42662 t.Lcaron = 611;
42663 t.onehalf = 750;
42664 t.lessequal = 549;
42665 t.ocircumflex = 500;
42666 t.ntilde = 500;
42667 t.Uhungarumlaut = 722;
42668 t.Eacute = 611;
42669 t.emacron = 444;
42670 t.gbreve = 500;
42671 t.onequarter = 750;
42672 t.Scaron = 500;
42673 t.Scommaaccent = 500;
42674 t.Ohungarumlaut = 722;
42675 t.degree = 400;
42676 t.ograve = 500;
42677 t.Ccaron = 667;
42678 t.ugrave = 500;
42679 t.radical = 453;
42680 t.Dcaron = 722;
42681 t.rcommaaccent = 389;
42682 t.Ntilde = 667;
42683 t.otilde = 500;
42684 t.Rcommaaccent = 611;
42685 t.Lcommaaccent = 556;
42686 t.Atilde = 611;
42687 t.Aogonek = 611;
42688 t.Aring = 611;
42689 t.Otilde = 722;
42690 t.zdotaccent = 389;
42691 t.Ecaron = 611;
42692 t.Iogonek = 333;
42693 t.kcommaaccent = 444;
42694 t.minus = 675;
42695 t.Icircumflex = 333;
42696 t.ncaron = 500;
42697 t.tcommaaccent = 278;
42698 t.logicalnot = 675;
42699 t.odieresis = 500;
42700 t.udieresis = 500;
42701 t.notequal = 549;
42702 t.gcommaaccent = 500;
42703 t.eth = 500;
42704 t.zcaron = 389;
42705 t.ncommaaccent = 500;
42706 t.onesuperior = 300;
42707 t.imacron = 278;
42708 t.Euro = 500;
42709 });
42710 t.ZapfDingbats = (0, _core_utils.getLookupTableFactory)(function (t) {
42711 t.space = 278;
42712 t.a1 = 974;
42713 t.a2 = 961;
42714 t.a202 = 974;
42715 t.a3 = 980;
42716 t.a4 = 719;
42717 t.a5 = 789;
42718 t.a119 = 790;
42719 t.a118 = 791;
42720 t.a117 = 690;
42721 t.a11 = 960;
42722 t.a12 = 939;
42723 t.a13 = 549;
42724 t.a14 = 855;
42725 t.a15 = 911;
42726 t.a16 = 933;
42727 t.a105 = 911;
42728 t.a17 = 945;
42729 t.a18 = 974;
42730 t.a19 = 755;
42731 t.a20 = 846;
42732 t.a21 = 762;
42733 t.a22 = 761;
42734 t.a23 = 571;
42735 t.a24 = 677;
42736 t.a25 = 763;
42737 t.a26 = 760;
42738 t.a27 = 759;
42739 t.a28 = 754;
42740 t.a6 = 494;
42741 t.a7 = 552;
42742 t.a8 = 537;
42743 t.a9 = 577;
42744 t.a10 = 692;
42745 t.a29 = 786;
42746 t.a30 = 788;
42747 t.a31 = 788;
42748 t.a32 = 790;
42749 t.a33 = 793;
42750 t.a34 = 794;
42751 t.a35 = 816;
42752 t.a36 = 823;
42753 t.a37 = 789;
42754 t.a38 = 841;
42755 t.a39 = 823;
42756 t.a40 = 833;
42757 t.a41 = 816;
42758 t.a42 = 831;
42759 t.a43 = 923;
42760 t.a44 = 744;
42761 t.a45 = 723;
42762 t.a46 = 749;
42763 t.a47 = 790;
42764 t.a48 = 792;
42765 t.a49 = 695;
42766 t.a50 = 776;
42767 t.a51 = 768;
42768 t.a52 = 792;
42769 t.a53 = 759;
42770 t.a54 = 707;
42771 t.a55 = 708;
42772 t.a56 = 682;
42773 t.a57 = 701;
42774 t.a58 = 826;
42775 t.a59 = 815;
42776 t.a60 = 789;
42777 t.a61 = 789;
42778 t.a62 = 707;
42779 t.a63 = 687;
42780 t.a64 = 696;
42781 t.a65 = 689;
42782 t.a66 = 786;
42783 t.a67 = 787;
42784 t.a68 = 713;
42785 t.a69 = 791;
42786 t.a70 = 785;
42787 t.a71 = 791;
42788 t.a72 = 873;
42789 t.a73 = 761;
42790 t.a74 = 762;
42791 t.a203 = 762;
42792 t.a75 = 759;
42793 t.a204 = 759;
42794 t.a76 = 892;
42795 t.a77 = 892;
42796 t.a78 = 788;
42797 t.a79 = 784;
42798 t.a81 = 438;
42799 t.a82 = 138;
42800 t.a83 = 277;
42801 t.a84 = 415;
42802 t.a97 = 392;
42803 t.a98 = 392;
42804 t.a99 = 668;
42805 t.a100 = 668;
42806 t.a89 = 390;
42807 t.a90 = 390;
42808 t.a93 = 317;
42809 t.a94 = 317;
42810 t.a91 = 276;
42811 t.a92 = 276;
42812 t.a205 = 509;
42813 t.a85 = 509;
42814 t.a206 = 410;
42815 t.a86 = 410;
42816 t.a87 = 234;
42817 t.a88 = 234;
42818 t.a95 = 334;
42819 t.a96 = 334;
42820 t.a101 = 732;
42821 t.a102 = 544;
42822 t.a103 = 544;
42823 t.a104 = 910;
42824 t.a106 = 667;
42825 t.a107 = 760;
42826 t.a108 = 760;
42827 t.a112 = 776;
42828 t.a111 = 595;
42829 t.a110 = 694;
42830 t.a109 = 626;
42831 t.a120 = 788;
42832 t.a121 = 788;
42833 t.a122 = 788;
42834 t.a123 = 788;
42835 t.a124 = 788;
42836 t.a125 = 788;
42837 t.a126 = 788;
42838 t.a127 = 788;
42839 t.a128 = 788;
42840 t.a129 = 788;
42841 t.a130 = 788;
42842 t.a131 = 788;
42843 t.a132 = 788;
42844 t.a133 = 788;
42845 t.a134 = 788;
42846 t.a135 = 788;
42847 t.a136 = 788;
42848 t.a137 = 788;
42849 t.a138 = 788;
42850 t.a139 = 788;
42851 t.a140 = 788;
42852 t.a141 = 788;
42853 t.a142 = 788;
42854 t.a143 = 788;
42855 t.a144 = 788;
42856 t.a145 = 788;
42857 t.a146 = 788;
42858 t.a147 = 788;
42859 t.a148 = 788;
42860 t.a149 = 788;
42861 t.a150 = 788;
42862 t.a151 = 788;
42863 t.a152 = 788;
42864 t.a153 = 788;
42865 t.a154 = 788;
42866 t.a155 = 788;
42867 t.a156 = 788;
42868 t.a157 = 788;
42869 t.a158 = 788;
42870 t.a159 = 788;
42871 t.a160 = 894;
42872 t.a161 = 838;
42873 t.a163 = 1016;
42874 t.a164 = 458;
42875 t.a196 = 748;
42876 t.a165 = 924;
42877 t.a192 = 748;
42878 t.a166 = 918;
42879 t.a167 = 927;
42880 t.a168 = 928;
42881 t.a169 = 928;
42882 t.a170 = 834;
42883 t.a171 = 873;
42884 t.a172 = 828;
42885 t.a173 = 924;
42886 t.a162 = 924;
42887 t.a174 = 917;
42888 t.a175 = 930;
42889 t.a176 = 931;
42890 t.a177 = 463;
42891 t.a178 = 883;
42892 t.a179 = 836;
42893 t.a193 = 836;
42894 t.a180 = 867;
42895 t.a199 = 867;
42896 t.a181 = 696;
42897 t.a200 = 696;
42898 t.a182 = 874;
42899 t.a201 = 874;
42900 t.a183 = 760;
42901 t.a184 = 946;
42902 t.a197 = 771;
42903 t.a185 = 865;
42904 t.a194 = 771;
42905 t.a198 = 888;
42906 t.a186 = 967;
42907 t.a195 = 888;
42908 t.a187 = 831;
42909 t.a188 = 873;
42910 t.a189 = 927;
42911 t.a190 = 970;
42912 t.a191 = 918;
42913 });
42914});
42915exports.getMetrics = getMetrics;
42916
42917/***/ }),
42918/* 41 */
42919/***/ (function(module, exports, __w_pdfjs_require__) {
42920
42921"use strict";
42922
42923
42924Object.defineProperty(exports, "__esModule", {
42925 value: true
42926});
42927exports.isPDFFunction = isPDFFunction;
42928exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = void 0;
42929
42930var _util = __w_pdfjs_require__(2);
42931
42932var _primitives = __w_pdfjs_require__(5);
42933
42934var _ps_parser = __w_pdfjs_require__(42);
42935
42936class PDFFunctionFactory {
42937 constructor({
42938 xref,
42939 isEvalSupported = true
42940 }) {
42941 this.xref = xref;
42942 this.isEvalSupported = isEvalSupported !== false;
42943 }
42944
42945 create(fn) {
42946 return PDFFunction.parse({
42947 xref: this.xref,
42948 isEvalSupported: this.isEvalSupported,
42949 fn
42950 });
42951 }
42952
42953 createFromArray(fnObj) {
42954 return PDFFunction.parseArray({
42955 xref: this.xref,
42956 isEvalSupported: this.isEvalSupported,
42957 fnObj
42958 });
42959 }
42960
42961}
42962
42963exports.PDFFunctionFactory = PDFFunctionFactory;
42964
42965function toNumberArray(arr) {
42966 if (!Array.isArray(arr)) {
42967 return null;
42968 }
42969
42970 const length = arr.length;
42971
42972 for (let i = 0; i < length; i++) {
42973 if (typeof arr[i] !== "number") {
42974 const result = new Array(length);
42975
42976 for (let j = 0; j < length; j++) {
42977 result[j] = +arr[j];
42978 }
42979
42980 return result;
42981 }
42982 }
42983
42984 return arr;
42985}
42986
42987var PDFFunction = function PDFFunctionClosure() {
42988 const CONSTRUCT_SAMPLED = 0;
42989 const CONSTRUCT_INTERPOLATED = 2;
42990 const CONSTRUCT_STICHED = 3;
42991 const CONSTRUCT_POSTSCRIPT = 4;
42992 return {
42993 getSampleArray(size, outputSize, bps, stream) {
42994 var i, ii;
42995 var length = 1;
42996
42997 for (i = 0, ii = size.length; i < ii; i++) {
42998 length *= size[i];
42999 }
43000
43001 length *= outputSize;
43002 var array = new Array(length);
43003 var codeSize = 0;
43004 var codeBuf = 0;
43005 var sampleMul = 1.0 / (2.0 ** bps - 1);
43006 var strBytes = stream.getBytes((length * bps + 7) / 8);
43007 var strIdx = 0;
43008
43009 for (i = 0; i < length; i++) {
43010 while (codeSize < bps) {
43011 codeBuf <<= 8;
43012 codeBuf |= strBytes[strIdx++];
43013 codeSize += 8;
43014 }
43015
43016 codeSize -= bps;
43017 array[i] = (codeBuf >> codeSize) * sampleMul;
43018 codeBuf &= (1 << codeSize) - 1;
43019 }
43020
43021 return array;
43022 },
43023
43024 getIR({
43025 xref,
43026 isEvalSupported,
43027 fn
43028 }) {
43029 var dict = fn.dict;
43030
43031 if (!dict) {
43032 dict = fn;
43033 }
43034
43035 var types = [this.constructSampled, null, this.constructInterpolated, this.constructStiched, this.constructPostScript];
43036 var typeNum = dict.get("FunctionType");
43037 var typeFn = types[typeNum];
43038
43039 if (!typeFn) {
43040 throw new _util.FormatError("Unknown type of function");
43041 }
43042
43043 return typeFn.call(this, {
43044 xref,
43045 isEvalSupported,
43046 fn,
43047 dict
43048 });
43049 },
43050
43051 fromIR({
43052 xref,
43053 isEvalSupported,
43054 IR
43055 }) {
43056 var type = IR[0];
43057
43058 switch (type) {
43059 case CONSTRUCT_SAMPLED:
43060 return this.constructSampledFromIR({
43061 xref,
43062 isEvalSupported,
43063 IR
43064 });
43065
43066 case CONSTRUCT_INTERPOLATED:
43067 return this.constructInterpolatedFromIR({
43068 xref,
43069 isEvalSupported,
43070 IR
43071 });
43072
43073 case CONSTRUCT_STICHED:
43074 return this.constructStichedFromIR({
43075 xref,
43076 isEvalSupported,
43077 IR
43078 });
43079
43080 default:
43081 return this.constructPostScriptFromIR({
43082 xref,
43083 isEvalSupported,
43084 IR
43085 });
43086 }
43087 },
43088
43089 parse({
43090 xref,
43091 isEvalSupported,
43092 fn
43093 }) {
43094 const IR = this.getIR({
43095 xref,
43096 isEvalSupported,
43097 fn
43098 });
43099 return this.fromIR({
43100 xref,
43101 isEvalSupported,
43102 IR
43103 });
43104 },
43105
43106 parseArray({
43107 xref,
43108 isEvalSupported,
43109 fnObj
43110 }) {
43111 if (!Array.isArray(fnObj)) {
43112 return this.parse({
43113 xref,
43114 isEvalSupported,
43115 fn: fnObj
43116 });
43117 }
43118
43119 var fnArray = [];
43120
43121 for (var j = 0, jj = fnObj.length; j < jj; j++) {
43122 fnArray.push(this.parse({
43123 xref,
43124 isEvalSupported,
43125 fn: xref.fetchIfRef(fnObj[j])
43126 }));
43127 }
43128
43129 return function (src, srcOffset, dest, destOffset) {
43130 for (var i = 0, ii = fnArray.length; i < ii; i++) {
43131 fnArray[i](src, srcOffset, dest, destOffset + i);
43132 }
43133 };
43134 },
43135
43136 constructSampled({
43137 xref,
43138 isEvalSupported,
43139 fn,
43140 dict
43141 }) {
43142 function toMultiArray(arr) {
43143 var inputLength = arr.length;
43144 var out = [];
43145 var index = 0;
43146
43147 for (var i = 0; i < inputLength; i += 2) {
43148 out[index] = [arr[i], arr[i + 1]];
43149 ++index;
43150 }
43151
43152 return out;
43153 }
43154
43155 var domain = toNumberArray(dict.getArray("Domain"));
43156 var range = toNumberArray(dict.getArray("Range"));
43157
43158 if (!domain || !range) {
43159 throw new _util.FormatError("No domain or range");
43160 }
43161
43162 var inputSize = domain.length / 2;
43163 var outputSize = range.length / 2;
43164 domain = toMultiArray(domain);
43165 range = toMultiArray(range);
43166 var size = toNumberArray(dict.getArray("Size"));
43167 var bps = dict.get("BitsPerSample");
43168 var order = dict.get("Order") || 1;
43169
43170 if (order !== 1) {
43171 (0, _util.info)("No support for cubic spline interpolation: " + order);
43172 }
43173
43174 var encode = toNumberArray(dict.getArray("Encode"));
43175
43176 if (!encode) {
43177 encode = [];
43178
43179 for (var i = 0; i < inputSize; ++i) {
43180 encode.push([0, size[i] - 1]);
43181 }
43182 } else {
43183 encode = toMultiArray(encode);
43184 }
43185
43186 var decode = toNumberArray(dict.getArray("Decode"));
43187
43188 if (!decode) {
43189 decode = range;
43190 } else {
43191 decode = toMultiArray(decode);
43192 }
43193
43194 var samples = this.getSampleArray(size, outputSize, bps, fn);
43195 return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize, 2 ** bps - 1, range];
43196 },
43197
43198 constructSampledFromIR({
43199 xref,
43200 isEvalSupported,
43201 IR
43202 }) {
43203 function interpolate(x, xmin, xmax, ymin, ymax) {
43204 return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
43205 }
43206
43207 return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
43208 var m = IR[1];
43209 var domain = IR[2];
43210 var encode = IR[3];
43211 var decode = IR[4];
43212 var samples = IR[5];
43213 var size = IR[6];
43214 var n = IR[7];
43215 var range = IR[9];
43216 var cubeVertices = 1 << m;
43217 var cubeN = new Float64Array(cubeVertices);
43218 var cubeVertex = new Uint32Array(cubeVertices);
43219 var i, j;
43220
43221 for (j = 0; j < cubeVertices; j++) {
43222 cubeN[j] = 1;
43223 }
43224
43225 var k = n,
43226 pos = 1;
43227
43228 for (i = 0; i < m; ++i) {
43229 var domain_2i = domain[i][0];
43230 var domain_2i_1 = domain[i][1];
43231 var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
43232 var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
43233 var size_i = size[i];
43234 e = Math.min(Math.max(e, 0), size_i - 1);
43235 var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
43236 var n0 = e0 + 1 - e;
43237 var n1 = e - e0;
43238 var offset0 = e0 * k;
43239 var offset1 = offset0 + k;
43240
43241 for (j = 0; j < cubeVertices; j++) {
43242 if (j & pos) {
43243 cubeN[j] *= n1;
43244 cubeVertex[j] += offset1;
43245 } else {
43246 cubeN[j] *= n0;
43247 cubeVertex[j] += offset0;
43248 }
43249 }
43250
43251 k *= size_i;
43252 pos <<= 1;
43253 }
43254
43255 for (j = 0; j < n; ++j) {
43256 var rj = 0;
43257
43258 for (i = 0; i < cubeVertices; i++) {
43259 rj += samples[cubeVertex[i] + j] * cubeN[i];
43260 }
43261
43262 rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
43263 dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
43264 }
43265 };
43266 },
43267
43268 constructInterpolated({
43269 xref,
43270 isEvalSupported,
43271 fn,
43272 dict
43273 }) {
43274 var c0 = toNumberArray(dict.getArray("C0")) || [0];
43275 var c1 = toNumberArray(dict.getArray("C1")) || [1];
43276 var n = dict.get("N");
43277 var length = c0.length;
43278 var diff = [];
43279
43280 for (var i = 0; i < length; ++i) {
43281 diff.push(c1[i] - c0[i]);
43282 }
43283
43284 return [CONSTRUCT_INTERPOLATED, c0, diff, n];
43285 },
43286
43287 constructInterpolatedFromIR({
43288 xref,
43289 isEvalSupported,
43290 IR
43291 }) {
43292 var c0 = IR[1];
43293 var diff = IR[2];
43294 var n = IR[3];
43295 var length = diff.length;
43296 return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
43297 var x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
43298
43299 for (var j = 0; j < length; ++j) {
43300 dest[destOffset + j] = c0[j] + x * diff[j];
43301 }
43302 };
43303 },
43304
43305 constructStiched({
43306 xref,
43307 isEvalSupported,
43308 fn,
43309 dict
43310 }) {
43311 var domain = toNumberArray(dict.getArray("Domain"));
43312
43313 if (!domain) {
43314 throw new _util.FormatError("No domain");
43315 }
43316
43317 var inputSize = domain.length / 2;
43318
43319 if (inputSize !== 1) {
43320 throw new _util.FormatError("Bad domain for stiched function");
43321 }
43322
43323 var fnRefs = dict.get("Functions");
43324 var fns = [];
43325
43326 for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
43327 fns.push(this.parse({
43328 xref,
43329 isEvalSupported,
43330 fn: xref.fetchIfRef(fnRefs[i])
43331 }));
43332 }
43333
43334 var bounds = toNumberArray(dict.getArray("Bounds"));
43335 var encode = toNumberArray(dict.getArray("Encode"));
43336 return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
43337 },
43338
43339 constructStichedFromIR({
43340 xref,
43341 isEvalSupported,
43342 IR
43343 }) {
43344 var domain = IR[1];
43345 var bounds = IR[2];
43346 var encode = IR[3];
43347 var fns = IR[4];
43348 var tmpBuf = new Float32Array(1);
43349 return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
43350 var clip = function constructStichedFromIRClip(v, min, max) {
43351 if (v > max) {
43352 v = max;
43353 } else if (v < min) {
43354 v = min;
43355 }
43356
43357 return v;
43358 };
43359
43360 var v = clip(src[srcOffset], domain[0], domain[1]);
43361
43362 for (var i = 0, ii = bounds.length; i < ii; ++i) {
43363 if (v < bounds[i]) {
43364 break;
43365 }
43366 }
43367
43368 var dmin = domain[0];
43369
43370 if (i > 0) {
43371 dmin = bounds[i - 1];
43372 }
43373
43374 var dmax = domain[1];
43375
43376 if (i < bounds.length) {
43377 dmax = bounds[i];
43378 }
43379
43380 var rmin = encode[2 * i];
43381 var rmax = encode[2 * i + 1];
43382 tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
43383 fns[i](tmpBuf, 0, dest, destOffset);
43384 };
43385 },
43386
43387 constructPostScript({
43388 xref,
43389 isEvalSupported,
43390 fn,
43391 dict
43392 }) {
43393 var domain = toNumberArray(dict.getArray("Domain"));
43394 var range = toNumberArray(dict.getArray("Range"));
43395
43396 if (!domain) {
43397 throw new _util.FormatError("No domain.");
43398 }
43399
43400 if (!range) {
43401 throw new _util.FormatError("No range.");
43402 }
43403
43404 var lexer = new _ps_parser.PostScriptLexer(fn);
43405 var parser = new _ps_parser.PostScriptParser(lexer);
43406 var code = parser.parse();
43407 return [CONSTRUCT_POSTSCRIPT, domain, range, code];
43408 },
43409
43410 constructPostScriptFromIR({
43411 xref,
43412 isEvalSupported,
43413 IR
43414 }) {
43415 var domain = IR[1];
43416 var range = IR[2];
43417 var code = IR[3];
43418
43419 if (isEvalSupported && _util.IsEvalSupportedCached.value) {
43420 const compiled = new PostScriptCompiler().compile(code, domain, range);
43421
43422 if (compiled) {
43423 return new Function("src", "srcOffset", "dest", "destOffset", compiled);
43424 }
43425 }
43426
43427 (0, _util.info)("Unable to compile PS function");
43428 var numOutputs = range.length >> 1;
43429 var numInputs = domain.length >> 1;
43430 var evaluator = new PostScriptEvaluator(code);
43431 var cache = Object.create(null);
43432 var MAX_CACHE_SIZE = 2048 * 4;
43433 var cache_available = MAX_CACHE_SIZE;
43434 var tmpBuf = new Float32Array(numInputs);
43435 return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
43436 var i, value;
43437 var key = "";
43438 var input = tmpBuf;
43439
43440 for (i = 0; i < numInputs; i++) {
43441 value = src[srcOffset + i];
43442 input[i] = value;
43443 key += value + "_";
43444 }
43445
43446 var cachedValue = cache[key];
43447
43448 if (cachedValue !== undefined) {
43449 dest.set(cachedValue, destOffset);
43450 return;
43451 }
43452
43453 var output = new Float32Array(numOutputs);
43454 var stack = evaluator.execute(input);
43455 var stackIndex = stack.length - numOutputs;
43456
43457 for (i = 0; i < numOutputs; i++) {
43458 value = stack[stackIndex + i];
43459 var bound = range[i * 2];
43460
43461 if (value < bound) {
43462 value = bound;
43463 } else {
43464 bound = range[i * 2 + 1];
43465
43466 if (value > bound) {
43467 value = bound;
43468 }
43469 }
43470
43471 output[i] = value;
43472 }
43473
43474 if (cache_available > 0) {
43475 cache_available--;
43476 cache[key] = output;
43477 }
43478
43479 dest.set(output, destOffset);
43480 };
43481 }
43482
43483 };
43484}();
43485
43486function isPDFFunction(v) {
43487 var fnDict;
43488
43489 if (typeof v !== "object") {
43490 return false;
43491 } else if ((0, _primitives.isDict)(v)) {
43492 fnDict = v;
43493 } else if ((0, _primitives.isStream)(v)) {
43494 fnDict = v.dict;
43495 } else {
43496 return false;
43497 }
43498
43499 return fnDict.has("FunctionType");
43500}
43501
43502var PostScriptStack = function PostScriptStackClosure() {
43503 var MAX_STACK_SIZE = 100;
43504
43505 function PostScriptStack(initialStack) {
43506 this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
43507 }
43508
43509 PostScriptStack.prototype = {
43510 push: function PostScriptStack_push(value) {
43511 if (this.stack.length >= MAX_STACK_SIZE) {
43512 throw new Error("PostScript function stack overflow.");
43513 }
43514
43515 this.stack.push(value);
43516 },
43517 pop: function PostScriptStack_pop() {
43518 if (this.stack.length <= 0) {
43519 throw new Error("PostScript function stack underflow.");
43520 }
43521
43522 return this.stack.pop();
43523 },
43524 copy: function PostScriptStack_copy(n) {
43525 if (this.stack.length + n >= MAX_STACK_SIZE) {
43526 throw new Error("PostScript function stack overflow.");
43527 }
43528
43529 var stack = this.stack;
43530
43531 for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
43532 stack.push(stack[i]);
43533 }
43534 },
43535 index: function PostScriptStack_index(n) {
43536 this.push(this.stack[this.stack.length - n - 1]);
43537 },
43538 roll: function PostScriptStack_roll(n, p) {
43539 var stack = this.stack;
43540 var l = stack.length - n;
43541 var r = stack.length - 1,
43542 c = l + (p - Math.floor(p / n) * n),
43543 i,
43544 j,
43545 t;
43546
43547 for (i = l, j = r; i < j; i++, j--) {
43548 t = stack[i];
43549 stack[i] = stack[j];
43550 stack[j] = t;
43551 }
43552
43553 for (i = l, j = c - 1; i < j; i++, j--) {
43554 t = stack[i];
43555 stack[i] = stack[j];
43556 stack[j] = t;
43557 }
43558
43559 for (i = c, j = r; i < j; i++, j--) {
43560 t = stack[i];
43561 stack[i] = stack[j];
43562 stack[j] = t;
43563 }
43564 }
43565 };
43566 return PostScriptStack;
43567}();
43568
43569var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
43570 function PostScriptEvaluator(operators) {
43571 this.operators = operators;
43572 }
43573
43574 PostScriptEvaluator.prototype = {
43575 execute: function PostScriptEvaluator_execute(initialStack) {
43576 var stack = new PostScriptStack(initialStack);
43577 var counter = 0;
43578 var operators = this.operators;
43579 var length = operators.length;
43580 var operator, a, b;
43581
43582 while (counter < length) {
43583 operator = operators[counter++];
43584
43585 if (typeof operator === "number") {
43586 stack.push(operator);
43587 continue;
43588 }
43589
43590 switch (operator) {
43591 case "jz":
43592 b = stack.pop();
43593 a = stack.pop();
43594
43595 if (!a) {
43596 counter = b;
43597 }
43598
43599 break;
43600
43601 case "j":
43602 a = stack.pop();
43603 counter = a;
43604 break;
43605
43606 case "abs":
43607 a = stack.pop();
43608 stack.push(Math.abs(a));
43609 break;
43610
43611 case "add":
43612 b = stack.pop();
43613 a = stack.pop();
43614 stack.push(a + b);
43615 break;
43616
43617 case "and":
43618 b = stack.pop();
43619 a = stack.pop();
43620
43621 if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
43622 stack.push(a && b);
43623 } else {
43624 stack.push(a & b);
43625 }
43626
43627 break;
43628
43629 case "atan":
43630 a = stack.pop();
43631 stack.push(Math.atan(a));
43632 break;
43633
43634 case "bitshift":
43635 b = stack.pop();
43636 a = stack.pop();
43637
43638 if (a > 0) {
43639 stack.push(a << b);
43640 } else {
43641 stack.push(a >> b);
43642 }
43643
43644 break;
43645
43646 case "ceiling":
43647 a = stack.pop();
43648 stack.push(Math.ceil(a));
43649 break;
43650
43651 case "copy":
43652 a = stack.pop();
43653 stack.copy(a);
43654 break;
43655
43656 case "cos":
43657 a = stack.pop();
43658 stack.push(Math.cos(a));
43659 break;
43660
43661 case "cvi":
43662 a = stack.pop() | 0;
43663 stack.push(a);
43664 break;
43665
43666 case "cvr":
43667 break;
43668
43669 case "div":
43670 b = stack.pop();
43671 a = stack.pop();
43672 stack.push(a / b);
43673 break;
43674
43675 case "dup":
43676 stack.copy(1);
43677 break;
43678
43679 case "eq":
43680 b = stack.pop();
43681 a = stack.pop();
43682 stack.push(a === b);
43683 break;
43684
43685 case "exch":
43686 stack.roll(2, 1);
43687 break;
43688
43689 case "exp":
43690 b = stack.pop();
43691 a = stack.pop();
43692 stack.push(a ** b);
43693 break;
43694
43695 case "false":
43696 stack.push(false);
43697 break;
43698
43699 case "floor":
43700 a = stack.pop();
43701 stack.push(Math.floor(a));
43702 break;
43703
43704 case "ge":
43705 b = stack.pop();
43706 a = stack.pop();
43707 stack.push(a >= b);
43708 break;
43709
43710 case "gt":
43711 b = stack.pop();
43712 a = stack.pop();
43713 stack.push(a > b);
43714 break;
43715
43716 case "idiv":
43717 b = stack.pop();
43718 a = stack.pop();
43719 stack.push(a / b | 0);
43720 break;
43721
43722 case "index":
43723 a = stack.pop();
43724 stack.index(a);
43725 break;
43726
43727 case "le":
43728 b = stack.pop();
43729 a = stack.pop();
43730 stack.push(a <= b);
43731 break;
43732
43733 case "ln":
43734 a = stack.pop();
43735 stack.push(Math.log(a));
43736 break;
43737
43738 case "log":
43739 a = stack.pop();
43740 stack.push(Math.log(a) / Math.LN10);
43741 break;
43742
43743 case "lt":
43744 b = stack.pop();
43745 a = stack.pop();
43746 stack.push(a < b);
43747 break;
43748
43749 case "mod":
43750 b = stack.pop();
43751 a = stack.pop();
43752 stack.push(a % b);
43753 break;
43754
43755 case "mul":
43756 b = stack.pop();
43757 a = stack.pop();
43758 stack.push(a * b);
43759 break;
43760
43761 case "ne":
43762 b = stack.pop();
43763 a = stack.pop();
43764 stack.push(a !== b);
43765 break;
43766
43767 case "neg":
43768 a = stack.pop();
43769 stack.push(-a);
43770 break;
43771
43772 case "not":
43773 a = stack.pop();
43774
43775 if ((0, _util.isBool)(a)) {
43776 stack.push(!a);
43777 } else {
43778 stack.push(~a);
43779 }
43780
43781 break;
43782
43783 case "or":
43784 b = stack.pop();
43785 a = stack.pop();
43786
43787 if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
43788 stack.push(a || b);
43789 } else {
43790 stack.push(a | b);
43791 }
43792
43793 break;
43794
43795 case "pop":
43796 stack.pop();
43797 break;
43798
43799 case "roll":
43800 b = stack.pop();
43801 a = stack.pop();
43802 stack.roll(a, b);
43803 break;
43804
43805 case "round":
43806 a = stack.pop();
43807 stack.push(Math.round(a));
43808 break;
43809
43810 case "sin":
43811 a = stack.pop();
43812 stack.push(Math.sin(a));
43813 break;
43814
43815 case "sqrt":
43816 a = stack.pop();
43817 stack.push(Math.sqrt(a));
43818 break;
43819
43820 case "sub":
43821 b = stack.pop();
43822 a = stack.pop();
43823 stack.push(a - b);
43824 break;
43825
43826 case "true":
43827 stack.push(true);
43828 break;
43829
43830 case "truncate":
43831 a = stack.pop();
43832 a = a < 0 ? Math.ceil(a) : Math.floor(a);
43833 stack.push(a);
43834 break;
43835
43836 case "xor":
43837 b = stack.pop();
43838 a = stack.pop();
43839
43840 if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
43841 stack.push(a !== b);
43842 } else {
43843 stack.push(a ^ b);
43844 }
43845
43846 break;
43847
43848 default:
43849 throw new _util.FormatError(`Unknown operator ${operator}`);
43850 }
43851 }
43852
43853 return stack.stack;
43854 }
43855 };
43856 return PostScriptEvaluator;
43857}();
43858
43859exports.PostScriptEvaluator = PostScriptEvaluator;
43860
43861var PostScriptCompiler = function PostScriptCompilerClosure() {
43862 function AstNode(type) {
43863 this.type = type;
43864 }
43865
43866 AstNode.prototype.visit = function (visitor) {
43867 (0, _util.unreachable)("abstract method");
43868 };
43869
43870 function AstArgument(index, min, max) {
43871 AstNode.call(this, "args");
43872 this.index = index;
43873 this.min = min;
43874 this.max = max;
43875 }
43876
43877 AstArgument.prototype = Object.create(AstNode.prototype);
43878
43879 AstArgument.prototype.visit = function (visitor) {
43880 visitor.visitArgument(this);
43881 };
43882
43883 function AstLiteral(number) {
43884 AstNode.call(this, "literal");
43885 this.number = number;
43886 this.min = number;
43887 this.max = number;
43888 }
43889
43890 AstLiteral.prototype = Object.create(AstNode.prototype);
43891
43892 AstLiteral.prototype.visit = function (visitor) {
43893 visitor.visitLiteral(this);
43894 };
43895
43896 function AstBinaryOperation(op, arg1, arg2, min, max) {
43897 AstNode.call(this, "binary");
43898 this.op = op;
43899 this.arg1 = arg1;
43900 this.arg2 = arg2;
43901 this.min = min;
43902 this.max = max;
43903 }
43904
43905 AstBinaryOperation.prototype = Object.create(AstNode.prototype);
43906
43907 AstBinaryOperation.prototype.visit = function (visitor) {
43908 visitor.visitBinaryOperation(this);
43909 };
43910
43911 function AstMin(arg, max) {
43912 AstNode.call(this, "max");
43913 this.arg = arg;
43914 this.min = arg.min;
43915 this.max = max;
43916 }
43917
43918 AstMin.prototype = Object.create(AstNode.prototype);
43919
43920 AstMin.prototype.visit = function (visitor) {
43921 visitor.visitMin(this);
43922 };
43923
43924 function AstVariable(index, min, max) {
43925 AstNode.call(this, "var");
43926 this.index = index;
43927 this.min = min;
43928 this.max = max;
43929 }
43930
43931 AstVariable.prototype = Object.create(AstNode.prototype);
43932
43933 AstVariable.prototype.visit = function (visitor) {
43934 visitor.visitVariable(this);
43935 };
43936
43937 function AstVariableDefinition(variable, arg) {
43938 AstNode.call(this, "definition");
43939 this.variable = variable;
43940 this.arg = arg;
43941 }
43942
43943 AstVariableDefinition.prototype = Object.create(AstNode.prototype);
43944
43945 AstVariableDefinition.prototype.visit = function (visitor) {
43946 visitor.visitVariableDefinition(this);
43947 };
43948
43949 function ExpressionBuilderVisitor() {
43950 this.parts = [];
43951 }
43952
43953 ExpressionBuilderVisitor.prototype = {
43954 visitArgument(arg) {
43955 this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
43956 },
43957
43958 visitVariable(variable) {
43959 this.parts.push("v", variable.index);
43960 },
43961
43962 visitLiteral(literal) {
43963 this.parts.push(literal.number);
43964 },
43965
43966 visitBinaryOperation(operation) {
43967 this.parts.push("(");
43968 operation.arg1.visit(this);
43969 this.parts.push(" ", operation.op, " ");
43970 operation.arg2.visit(this);
43971 this.parts.push(")");
43972 },
43973
43974 visitVariableDefinition(definition) {
43975 this.parts.push("var ");
43976 definition.variable.visit(this);
43977 this.parts.push(" = ");
43978 definition.arg.visit(this);
43979 this.parts.push(";");
43980 },
43981
43982 visitMin(max) {
43983 this.parts.push("Math.min(");
43984 max.arg.visit(this);
43985 this.parts.push(", ", max.max, ")");
43986 },
43987
43988 toString() {
43989 return this.parts.join("");
43990 }
43991
43992 };
43993
43994 function buildAddOperation(num1, num2) {
43995 if (num2.type === "literal" && num2.number === 0) {
43996 return num1;
43997 }
43998
43999 if (num1.type === "literal" && num1.number === 0) {
44000 return num2;
44001 }
44002
44003 if (num2.type === "literal" && num1.type === "literal") {
44004 return new AstLiteral(num1.number + num2.number);
44005 }
44006
44007 return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max);
44008 }
44009
44010 function buildMulOperation(num1, num2) {
44011 if (num2.type === "literal") {
44012 if (num2.number === 0) {
44013 return new AstLiteral(0);
44014 } else if (num2.number === 1) {
44015 return num1;
44016 } else if (num1.type === "literal") {
44017 return new AstLiteral(num1.number * num2.number);
44018 }
44019 }
44020
44021 if (num1.type === "literal") {
44022 if (num1.number === 0) {
44023 return new AstLiteral(0);
44024 } else if (num1.number === 1) {
44025 return num2;
44026 }
44027 }
44028
44029 var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
44030 var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
44031 return new AstBinaryOperation("*", num1, num2, min, max);
44032 }
44033
44034 function buildSubOperation(num1, num2) {
44035 if (num2.type === "literal") {
44036 if (num2.number === 0) {
44037 return num1;
44038 } else if (num1.type === "literal") {
44039 return new AstLiteral(num1.number - num2.number);
44040 }
44041 }
44042
44043 if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) {
44044 return num2.arg2;
44045 }
44046
44047 return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min);
44048 }
44049
44050 function buildMinOperation(num1, max) {
44051 if (num1.min >= max) {
44052 return new AstLiteral(max);
44053 } else if (num1.max <= max) {
44054 return num1;
44055 }
44056
44057 return new AstMin(num1, max);
44058 }
44059
44060 function PostScriptCompiler() {}
44061
44062 PostScriptCompiler.prototype = {
44063 compile: function PostScriptCompiler_compile(code, domain, range) {
44064 var stack = [];
44065 var instructions = [];
44066 var inputSize = domain.length >> 1,
44067 outputSize = range.length >> 1;
44068 var lastRegister = 0;
44069 var n, j;
44070 var num1, num2, ast1, ast2, tmpVar, item;
44071
44072 for (let i = 0; i < inputSize; i++) {
44073 stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
44074 }
44075
44076 for (let i = 0, ii = code.length; i < ii; i++) {
44077 item = code[i];
44078
44079 if (typeof item === "number") {
44080 stack.push(new AstLiteral(item));
44081 continue;
44082 }
44083
44084 switch (item) {
44085 case "add":
44086 if (stack.length < 2) {
44087 return null;
44088 }
44089
44090 num2 = stack.pop();
44091 num1 = stack.pop();
44092 stack.push(buildAddOperation(num1, num2));
44093 break;
44094
44095 case "cvr":
44096 if (stack.length < 1) {
44097 return null;
44098 }
44099
44100 break;
44101
44102 case "mul":
44103 if (stack.length < 2) {
44104 return null;
44105 }
44106
44107 num2 = stack.pop();
44108 num1 = stack.pop();
44109 stack.push(buildMulOperation(num1, num2));
44110 break;
44111
44112 case "sub":
44113 if (stack.length < 2) {
44114 return null;
44115 }
44116
44117 num2 = stack.pop();
44118 num1 = stack.pop();
44119 stack.push(buildSubOperation(num1, num2));
44120 break;
44121
44122 case "exch":
44123 if (stack.length < 2) {
44124 return null;
44125 }
44126
44127 ast1 = stack.pop();
44128 ast2 = stack.pop();
44129 stack.push(ast1, ast2);
44130 break;
44131
44132 case "pop":
44133 if (stack.length < 1) {
44134 return null;
44135 }
44136
44137 stack.pop();
44138 break;
44139
44140 case "index":
44141 if (stack.length < 1) {
44142 return null;
44143 }
44144
44145 num1 = stack.pop();
44146
44147 if (num1.type !== "literal") {
44148 return null;
44149 }
44150
44151 n = num1.number;
44152
44153 if (n < 0 || !Number.isInteger(n) || stack.length < n) {
44154 return null;
44155 }
44156
44157 ast1 = stack[stack.length - n - 1];
44158
44159 if (ast1.type === "literal" || ast1.type === "var") {
44160 stack.push(ast1);
44161 break;
44162 }
44163
44164 tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
44165 stack[stack.length - n - 1] = tmpVar;
44166 stack.push(tmpVar);
44167 instructions.push(new AstVariableDefinition(tmpVar, ast1));
44168 break;
44169
44170 case "dup":
44171 if (stack.length < 1) {
44172 return null;
44173 }
44174
44175 if (typeof code[i + 1] === "number" && code[i + 2] === "gt" && code[i + 3] === i + 7 && code[i + 4] === "jz" && code[i + 5] === "pop" && code[i + 6] === code[i + 1]) {
44176 num1 = stack.pop();
44177 stack.push(buildMinOperation(num1, code[i + 1]));
44178 i += 6;
44179 break;
44180 }
44181
44182 ast1 = stack[stack.length - 1];
44183
44184 if (ast1.type === "literal" || ast1.type === "var") {
44185 stack.push(ast1);
44186 break;
44187 }
44188
44189 tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
44190 stack[stack.length - 1] = tmpVar;
44191 stack.push(tmpVar);
44192 instructions.push(new AstVariableDefinition(tmpVar, ast1));
44193 break;
44194
44195 case "roll":
44196 if (stack.length < 2) {
44197 return null;
44198 }
44199
44200 num2 = stack.pop();
44201 num1 = stack.pop();
44202
44203 if (num2.type !== "literal" || num1.type !== "literal") {
44204 return null;
44205 }
44206
44207 j = num2.number;
44208 n = num1.number;
44209
44210 if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) {
44211 return null;
44212 }
44213
44214 j = (j % n + n) % n;
44215
44216 if (j === 0) {
44217 break;
44218 }
44219
44220 Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
44221 break;
44222
44223 default:
44224 return null;
44225 }
44226 }
44227
44228 if (stack.length !== outputSize) {
44229 return null;
44230 }
44231
44232 var result = [];
44233 instructions.forEach(function (instruction) {
44234 var statementBuilder = new ExpressionBuilderVisitor();
44235 instruction.visit(statementBuilder);
44236 result.push(statementBuilder.toString());
44237 });
44238 stack.forEach(function (expr, i) {
44239 var statementBuilder = new ExpressionBuilderVisitor();
44240 expr.visit(statementBuilder);
44241 var min = range[i * 2],
44242 max = range[i * 2 + 1];
44243 var out = [statementBuilder.toString()];
44244
44245 if (min > expr.min) {
44246 out.unshift("Math.max(", min, ", ");
44247 out.push(")");
44248 }
44249
44250 if (max < expr.max) {
44251 out.unshift("Math.min(", max, ", ");
44252 out.push(")");
44253 }
44254
44255 out.unshift("dest[destOffset + ", i, "] = ");
44256 out.push(";");
44257 result.push(out.join(""));
44258 });
44259 return result.join("\n");
44260 }
44261 };
44262 return PostScriptCompiler;
44263}();
44264
44265exports.PostScriptCompiler = PostScriptCompiler;
44266
44267/***/ }),
44268/* 42 */
44269/***/ (function(module, exports, __w_pdfjs_require__) {
44270
44271"use strict";
44272
44273
44274Object.defineProperty(exports, "__esModule", {
44275 value: true
44276});
44277exports.PostScriptParser = exports.PostScriptLexer = void 0;
44278
44279var _util = __w_pdfjs_require__(2);
44280
44281var _primitives = __w_pdfjs_require__(5);
44282
44283var _core_utils = __w_pdfjs_require__(8);
44284
44285class PostScriptParser {
44286 constructor(lexer) {
44287 this.lexer = lexer;
44288 this.operators = [];
44289 this.token = null;
44290 this.prev = null;
44291 }
44292
44293 nextToken() {
44294 this.prev = this.token;
44295 this.token = this.lexer.getToken();
44296 }
44297
44298 accept(type) {
44299 if (this.token.type === type) {
44300 this.nextToken();
44301 return true;
44302 }
44303
44304 return false;
44305 }
44306
44307 expect(type) {
44308 if (this.accept(type)) {
44309 return true;
44310 }
44311
44312 throw new _util.FormatError(`Unexpected symbol: found ${this.token.type} expected ${type}.`);
44313 }
44314
44315 parse() {
44316 this.nextToken();
44317 this.expect(PostScriptTokenTypes.LBRACE);
44318 this.parseBlock();
44319 this.expect(PostScriptTokenTypes.RBRACE);
44320 return this.operators;
44321 }
44322
44323 parseBlock() {
44324 while (true) {
44325 if (this.accept(PostScriptTokenTypes.NUMBER)) {
44326 this.operators.push(this.prev.value);
44327 } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
44328 this.operators.push(this.prev.value);
44329 } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
44330 this.parseCondition();
44331 } else {
44332 return;
44333 }
44334 }
44335 }
44336
44337 parseCondition() {
44338 const conditionLocation = this.operators.length;
44339 this.operators.push(null, null);
44340 this.parseBlock();
44341 this.expect(PostScriptTokenTypes.RBRACE);
44342
44343 if (this.accept(PostScriptTokenTypes.IF)) {
44344 this.operators[conditionLocation] = this.operators.length;
44345 this.operators[conditionLocation + 1] = "jz";
44346 } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
44347 const jumpLocation = this.operators.length;
44348 this.operators.push(null, null);
44349 const endOfTrue = this.operators.length;
44350 this.parseBlock();
44351 this.expect(PostScriptTokenTypes.RBRACE);
44352 this.expect(PostScriptTokenTypes.IFELSE);
44353 this.operators[jumpLocation] = this.operators.length;
44354 this.operators[jumpLocation + 1] = "j";
44355 this.operators[conditionLocation] = endOfTrue;
44356 this.operators[conditionLocation + 1] = "jz";
44357 } else {
44358 throw new _util.FormatError("PS Function: error parsing conditional.");
44359 }
44360 }
44361
44362}
44363
44364exports.PostScriptParser = PostScriptParser;
44365const PostScriptTokenTypes = {
44366 LBRACE: 0,
44367 RBRACE: 1,
44368 NUMBER: 2,
44369 OPERATOR: 3,
44370 IF: 4,
44371 IFELSE: 5
44372};
44373
44374const PostScriptToken = function PostScriptTokenClosure() {
44375 const opCache = Object.create(null);
44376
44377 class PostScriptToken {
44378 constructor(type, value) {
44379 this.type = type;
44380 this.value = value;
44381 }
44382
44383 static getOperator(op) {
44384 const opValue = opCache[op];
44385
44386 if (opValue) {
44387 return opValue;
44388 }
44389
44390 return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
44391 }
44392
44393 static get LBRACE() {
44394 return (0, _util.shadow)(this, "LBRACE", new PostScriptToken(PostScriptTokenTypes.LBRACE, "{"));
44395 }
44396
44397 static get RBRACE() {
44398 return (0, _util.shadow)(this, "RBRACE", new PostScriptToken(PostScriptTokenTypes.RBRACE, "}"));
44399 }
44400
44401 static get IF() {
44402 return (0, _util.shadow)(this, "IF", new PostScriptToken(PostScriptTokenTypes.IF, "IF"));
44403 }
44404
44405 static get IFELSE() {
44406 return (0, _util.shadow)(this, "IFELSE", new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE"));
44407 }
44408
44409 }
44410
44411 return PostScriptToken;
44412}();
44413
44414class PostScriptLexer {
44415 constructor(stream) {
44416 this.stream = stream;
44417 this.nextChar();
44418 this.strBuf = [];
44419 }
44420
44421 nextChar() {
44422 return this.currentChar = this.stream.getByte();
44423 }
44424
44425 getToken() {
44426 let comment = false;
44427 let ch = this.currentChar;
44428
44429 while (true) {
44430 if (ch < 0) {
44431 return _primitives.EOF;
44432 }
44433
44434 if (comment) {
44435 if (ch === 0x0a || ch === 0x0d) {
44436 comment = false;
44437 }
44438 } else if (ch === 0x25) {
44439 comment = true;
44440 } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
44441 break;
44442 }
44443
44444 ch = this.nextChar();
44445 }
44446
44447 switch (ch | 0) {
44448 case 0x30:
44449 case 0x31:
44450 case 0x32:
44451 case 0x33:
44452 case 0x34:
44453 case 0x35:
44454 case 0x36:
44455 case 0x37:
44456 case 0x38:
44457 case 0x39:
44458 case 0x2b:
44459 case 0x2d:
44460 case 0x2e:
44461 return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
44462
44463 case 0x7b:
44464 this.nextChar();
44465 return PostScriptToken.LBRACE;
44466
44467 case 0x7d:
44468 this.nextChar();
44469 return PostScriptToken.RBRACE;
44470 }
44471
44472 const strBuf = this.strBuf;
44473 strBuf.length = 0;
44474 strBuf[0] = String.fromCharCode(ch);
44475
44476 while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5a || ch >= 0x61 && ch <= 0x7a)) {
44477 strBuf.push(String.fromCharCode(ch));
44478 }
44479
44480 const str = strBuf.join("");
44481
44482 switch (str.toLowerCase()) {
44483 case "if":
44484 return PostScriptToken.IF;
44485
44486 case "ifelse":
44487 return PostScriptToken.IFELSE;
44488
44489 default:
44490 return PostScriptToken.getOperator(str);
44491 }
44492 }
44493
44494 getNumber() {
44495 let ch = this.currentChar;
44496 const strBuf = this.strBuf;
44497 strBuf.length = 0;
44498 strBuf[0] = String.fromCharCode(ch);
44499
44500 while ((ch = this.nextChar()) >= 0) {
44501 if (ch >= 0x30 && ch <= 0x39 || ch === 0x2d || ch === 0x2e) {
44502 strBuf.push(String.fromCharCode(ch));
44503 } else {
44504 break;
44505 }
44506 }
44507
44508 const value = parseFloat(strBuf.join(""));
44509
44510 if (isNaN(value)) {
44511 throw new _util.FormatError(`Invalid floating point number: ${value}`);
44512 }
44513
44514 return value;
44515 }
44516
44517}
44518
44519exports.PostScriptLexer = PostScriptLexer;
44520
44521/***/ }),
44522/* 43 */
44523/***/ (function(module, exports, __w_pdfjs_require__) {
44524
44525"use strict";
44526
44527
44528Object.defineProperty(exports, "__esModule", {
44529 value: true
44530});
44531exports.MurmurHash3_64 = void 0;
44532
44533var _util = __w_pdfjs_require__(2);
44534
44535const SEED = 0xc3d2e1f0;
44536const MASK_HIGH = 0xffff0000;
44537const MASK_LOW = 0xffff;
44538
44539class MurmurHash3_64 {
44540 constructor(seed) {
44541 this.h1 = seed ? seed & 0xffffffff : SEED;
44542 this.h2 = seed ? seed & 0xffffffff : SEED;
44543 }
44544
44545 update(input) {
44546 let data, length;
44547
44548 if ((0, _util.isString)(input)) {
44549 data = new Uint8Array(input.length * 2);
44550 length = 0;
44551
44552 for (let i = 0, ii = input.length; i < ii; i++) {
44553 const code = input.charCodeAt(i);
44554
44555 if (code <= 0xff) {
44556 data[length++] = code;
44557 } else {
44558 data[length++] = code >>> 8;
44559 data[length++] = code & 0xff;
44560 }
44561 }
44562 } else if ((0, _util.isArrayBuffer)(input)) {
44563 data = input;
44564 length = data.byteLength;
44565 } else {
44566 throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
44567 }
44568
44569 const blockCounts = length >> 2;
44570 const tailLength = length - blockCounts * 4;
44571 const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
44572 let k1 = 0,
44573 k2 = 0;
44574 let h1 = this.h1,
44575 h2 = this.h2;
44576 const C1 = 0xcc9e2d51,
44577 C2 = 0x1b873593;
44578 const C1_LOW = C1 & MASK_LOW,
44579 C2_LOW = C2 & MASK_LOW;
44580
44581 for (let i = 0; i < blockCounts; i++) {
44582 if (i & 1) {
44583 k1 = dataUint32[i];
44584 k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
44585 k1 = k1 << 15 | k1 >>> 17;
44586 k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
44587 h1 ^= k1;
44588 h1 = h1 << 13 | h1 >>> 19;
44589 h1 = h1 * 5 + 0xe6546b64;
44590 } else {
44591 k2 = dataUint32[i];
44592 k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
44593 k2 = k2 << 15 | k2 >>> 17;
44594 k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
44595 h2 ^= k2;
44596 h2 = h2 << 13 | h2 >>> 19;
44597 h2 = h2 * 5 + 0xe6546b64;
44598 }
44599 }
44600
44601 k1 = 0;
44602
44603 switch (tailLength) {
44604 case 3:
44605 k1 ^= data[blockCounts * 4 + 2] << 16;
44606
44607 case 2:
44608 k1 ^= data[blockCounts * 4 + 1] << 8;
44609
44610 case 1:
44611 k1 ^= data[blockCounts * 4];
44612 k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
44613 k1 = k1 << 15 | k1 >>> 17;
44614 k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
44615
44616 if (blockCounts & 1) {
44617 h1 ^= k1;
44618 } else {
44619 h2 ^= k1;
44620 }
44621
44622 }
44623
44624 this.h1 = h1;
44625 this.h2 = h2;
44626 }
44627
44628 hexdigest() {
44629 let h1 = this.h1,
44630 h2 = this.h2;
44631 h1 ^= h2 >>> 1;
44632 h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
44633 h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
44634 h1 ^= h2 >>> 1;
44635 h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
44636 h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
44637 h1 ^= h2 >>> 1;
44638 const hex1 = (h1 >>> 0).toString(16),
44639 hex2 = (h2 >>> 0).toString(16);
44640 return hex1.padStart(8, "0") + hex2.padStart(8, "0");
44641 }
44642
44643}
44644
44645exports.MurmurHash3_64 = MurmurHash3_64;
44646
44647/***/ }),
44648/* 44 */
44649/***/ (function(module, exports, __w_pdfjs_require__) {
44650
44651"use strict";
44652
44653
44654Object.defineProperty(exports, "__esModule", {
44655 value: true
44656});
44657exports.PDFImage = void 0;
44658
44659var _util = __w_pdfjs_require__(2);
44660
44661var _primitives = __w_pdfjs_require__(5);
44662
44663var _colorspace = __w_pdfjs_require__(23);
44664
44665var _stream = __w_pdfjs_require__(12);
44666
44667var _jpeg_stream = __w_pdfjs_require__(18);
44668
44669var _jpx = __w_pdfjs_require__(21);
44670
44671var PDFImage = function PDFImageClosure() {
44672 function decodeAndClamp(value, addend, coefficient, max) {
44673 value = addend + value * coefficient;
44674
44675 if (value < 0) {
44676 value = 0;
44677 } else if (value > max) {
44678 value = max;
44679 }
44680
44681 return value;
44682 }
44683
44684 function resizeImageMask(src, bpc, w1, h1, w2, h2) {
44685 var length = w2 * h2;
44686 let dest;
44687
44688 if (bpc <= 8) {
44689 dest = new Uint8Array(length);
44690 } else if (bpc <= 16) {
44691 dest = new Uint16Array(length);
44692 } else {
44693 dest = new Uint32Array(length);
44694 }
44695
44696 var xRatio = w1 / w2;
44697 var yRatio = h1 / h2;
44698 var i,
44699 j,
44700 py,
44701 newIndex = 0,
44702 oldIndex;
44703 var xScaled = new Uint16Array(w2);
44704 var w1Scanline = w1;
44705
44706 for (i = 0; i < w2; i++) {
44707 xScaled[i] = Math.floor(i * xRatio);
44708 }
44709
44710 for (i = 0; i < h2; i++) {
44711 py = Math.floor(i * yRatio) * w1Scanline;
44712
44713 for (j = 0; j < w2; j++) {
44714 oldIndex = py + xScaled[j];
44715 dest[newIndex++] = src[oldIndex];
44716 }
44717 }
44718
44719 return dest;
44720 }
44721
44722 function PDFImage({
44723 xref,
44724 res,
44725 image,
44726 isInline = false,
44727 smask = null,
44728 mask = null,
44729 isMask = false,
44730 pdfFunctionFactory
44731 }) {
44732 this.image = image;
44733 var dict = image.dict;
44734 const filter = dict.get("Filter");
44735
44736 if ((0, _primitives.isName)(filter)) {
44737 switch (filter.name) {
44738 case "JPXDecode":
44739 var jpxImage = new _jpx.JpxImage();
44740 jpxImage.parseImageProperties(image.stream);
44741 image.stream.reset();
44742 image.width = jpxImage.width;
44743 image.height = jpxImage.height;
44744 image.bitsPerComponent = jpxImage.bitsPerComponent;
44745 image.numComps = jpxImage.componentsCount;
44746 break;
44747
44748 case "JBIG2Decode":
44749 image.bitsPerComponent = 1;
44750 image.numComps = 1;
44751 break;
44752 }
44753 }
44754
44755 let width = dict.get("Width", "W");
44756 let height = dict.get("Height", "H");
44757
44758 if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) {
44759 (0, _util.warn)("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary.");
44760 width = image.width;
44761 height = image.height;
44762 }
44763
44764 if (width < 1 || height < 1) {
44765 throw new _util.FormatError(`Invalid image width: ${width} or height: ${height}`);
44766 }
44767
44768 this.width = width;
44769 this.height = height;
44770 this.interpolate = dict.get("Interpolate", "I") || false;
44771 this.imageMask = dict.get("ImageMask", "IM") || false;
44772 this.matte = dict.get("Matte") || false;
44773 var bitsPerComponent = image.bitsPerComponent;
44774
44775 if (!bitsPerComponent) {
44776 bitsPerComponent = dict.get("BitsPerComponent", "BPC");
44777
44778 if (!bitsPerComponent) {
44779 if (this.imageMask) {
44780 bitsPerComponent = 1;
44781 } else {
44782 throw new _util.FormatError(`Bits per component missing in image: ${this.imageMask}`);
44783 }
44784 }
44785 }
44786
44787 this.bpc = bitsPerComponent;
44788
44789 if (!this.imageMask) {
44790 var colorSpace = dict.get("ColorSpace", "CS");
44791
44792 if (!colorSpace) {
44793 (0, _util.info)("JPX images (which do not require color spaces)");
44794
44795 switch (image.numComps) {
44796 case 1:
44797 colorSpace = _primitives.Name.get("DeviceGray");
44798 break;
44799
44800 case 3:
44801 colorSpace = _primitives.Name.get("DeviceRGB");
44802 break;
44803
44804 case 4:
44805 colorSpace = _primitives.Name.get("DeviceCMYK");
44806 break;
44807
44808 default:
44809 throw new Error(`JPX images with ${image.numComps} ` + "color components not supported.");
44810 }
44811 }
44812
44813 const resources = isInline ? res : null;
44814 this.colorSpace = _colorspace.ColorSpace.parse(colorSpace, xref, resources, pdfFunctionFactory);
44815 this.numComps = this.colorSpace.numComps;
44816 }
44817
44818 this.decode = dict.getArray("Decode", "D");
44819 this.needsDecode = false;
44820
44821 if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !_colorspace.ColorSpace.isDefaultDecode(this.decode, 1))) {
44822 this.needsDecode = true;
44823 var max = (1 << bitsPerComponent) - 1;
44824 this.decodeCoefficients = [];
44825 this.decodeAddends = [];
44826 const isIndexed = this.colorSpace && this.colorSpace.name === "Indexed";
44827
44828 for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
44829 var dmin = this.decode[i];
44830 var dmax = this.decode[i + 1];
44831 this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin;
44832 this.decodeAddends[j] = isIndexed ? dmin : max * dmin;
44833 }
44834 }
44835
44836 if (smask) {
44837 this.smask = new PDFImage({
44838 xref,
44839 res,
44840 image: smask,
44841 isInline,
44842 pdfFunctionFactory
44843 });
44844 } else if (mask) {
44845 if ((0, _primitives.isStream)(mask)) {
44846 var maskDict = mask.dict,
44847 imageMask = maskDict.get("ImageMask", "IM");
44848
44849 if (!imageMask) {
44850 (0, _util.warn)("Ignoring /Mask in image without /ImageMask.");
44851 } else {
44852 this.mask = new PDFImage({
44853 xref,
44854 res,
44855 image: mask,
44856 isInline,
44857 isMask: true,
44858 pdfFunctionFactory
44859 });
44860 }
44861 } else {
44862 this.mask = mask;
44863 }
44864 }
44865 }
44866
44867 PDFImage.buildImage = function ({
44868 xref,
44869 res,
44870 image,
44871 isInline = false,
44872 pdfFunctionFactory
44873 }) {
44874 const imageData = image;
44875 let smaskData = null;
44876 let maskData = null;
44877 const smask = image.dict.get("SMask");
44878 const mask = image.dict.get("Mask");
44879
44880 if (smask) {
44881 smaskData = smask;
44882 } else if (mask) {
44883 if ((0, _primitives.isStream)(mask) || Array.isArray(mask)) {
44884 maskData = mask;
44885 } else {
44886 (0, _util.warn)("Unsupported mask format.");
44887 }
44888 }
44889
44890 return Promise.resolve(new PDFImage({
44891 xref,
44892 res,
44893 image: imageData,
44894 isInline,
44895 smask: smaskData,
44896 mask: maskData,
44897 pdfFunctionFactory
44898 }));
44899 };
44900
44901 PDFImage.createMask = function ({
44902 imgArray,
44903 width,
44904 height,
44905 imageIsFromDecodeStream,
44906 inverseDecode
44907 }) {
44908 var computedLength = (width + 7 >> 3) * height;
44909 var actualLength = imgArray.byteLength;
44910 var haveFullData = computedLength === actualLength;
44911 var data, i;
44912
44913 if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
44914 data = imgArray;
44915 } else if (!inverseDecode) {
44916 data = new Uint8ClampedArray(actualLength);
44917 data.set(imgArray);
44918 } else {
44919 data = new Uint8ClampedArray(computedLength);
44920 data.set(imgArray);
44921
44922 for (i = actualLength; i < computedLength; i++) {
44923 data[i] = 0xff;
44924 }
44925 }
44926
44927 if (inverseDecode) {
44928 for (i = 0; i < actualLength; i++) {
44929 data[i] ^= 0xff;
44930 }
44931 }
44932
44933 return {
44934 data,
44935 width,
44936 height
44937 };
44938 };
44939
44940 PDFImage.prototype = {
44941 get drawWidth() {
44942 return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
44943 },
44944
44945 get drawHeight() {
44946 return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
44947 },
44948
44949 decodeBuffer(buffer) {
44950 var bpc = this.bpc;
44951 var numComps = this.numComps;
44952 var decodeAddends = this.decodeAddends;
44953 var decodeCoefficients = this.decodeCoefficients;
44954 var max = (1 << bpc) - 1;
44955 var i, ii;
44956
44957 if (bpc === 1) {
44958 for (i = 0, ii = buffer.length; i < ii; i++) {
44959 buffer[i] = +!buffer[i];
44960 }
44961
44962 return;
44963 }
44964
44965 var index = 0;
44966
44967 for (i = 0, ii = this.width * this.height; i < ii; i++) {
44968 for (var j = 0; j < numComps; j++) {
44969 buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
44970 index++;
44971 }
44972 }
44973 },
44974
44975 getComponents(buffer) {
44976 var bpc = this.bpc;
44977
44978 if (bpc === 8) {
44979 return buffer;
44980 }
44981
44982 var width = this.width;
44983 var height = this.height;
44984 var numComps = this.numComps;
44985 var length = width * height * numComps;
44986 var bufferPos = 0;
44987 let output;
44988
44989 if (bpc <= 8) {
44990 output = new Uint8Array(length);
44991 } else if (bpc <= 16) {
44992 output = new Uint16Array(length);
44993 } else {
44994 output = new Uint32Array(length);
44995 }
44996
44997 var rowComps = width * numComps;
44998 var max = (1 << bpc) - 1;
44999 var i = 0,
45000 ii,
45001 buf;
45002
45003 if (bpc === 1) {
45004 var mask, loop1End, loop2End;
45005
45006 for (var j = 0; j < height; j++) {
45007 loop1End = i + (rowComps & ~7);
45008 loop2End = i + rowComps;
45009
45010 while (i < loop1End) {
45011 buf = buffer[bufferPos++];
45012 output[i] = buf >> 7 & 1;
45013 output[i + 1] = buf >> 6 & 1;
45014 output[i + 2] = buf >> 5 & 1;
45015 output[i + 3] = buf >> 4 & 1;
45016 output[i + 4] = buf >> 3 & 1;
45017 output[i + 5] = buf >> 2 & 1;
45018 output[i + 6] = buf >> 1 & 1;
45019 output[i + 7] = buf & 1;
45020 i += 8;
45021 }
45022
45023 if (i < loop2End) {
45024 buf = buffer[bufferPos++];
45025 mask = 128;
45026
45027 while (i < loop2End) {
45028 output[i++] = +!!(buf & mask);
45029 mask >>= 1;
45030 }
45031 }
45032 }
45033 } else {
45034 var bits = 0;
45035 buf = 0;
45036
45037 for (i = 0, ii = length; i < ii; ++i) {
45038 if (i % rowComps === 0) {
45039 buf = 0;
45040 bits = 0;
45041 }
45042
45043 while (bits < bpc) {
45044 buf = buf << 8 | buffer[bufferPos++];
45045 bits += 8;
45046 }
45047
45048 var remainingBits = bits - bpc;
45049 let value = buf >> remainingBits;
45050
45051 if (value < 0) {
45052 value = 0;
45053 } else if (value > max) {
45054 value = max;
45055 }
45056
45057 output[i] = value;
45058 buf = buf & (1 << remainingBits) - 1;
45059 bits = remainingBits;
45060 }
45061 }
45062
45063 return output;
45064 },
45065
45066 fillOpacity(rgbaBuf, width, height, actualHeight, image) {
45067 var smask = this.smask;
45068 var mask = this.mask;
45069 var alphaBuf, sw, sh, i, ii, j;
45070
45071 if (smask) {
45072 sw = smask.width;
45073 sh = smask.height;
45074 alphaBuf = new Uint8ClampedArray(sw * sh);
45075 smask.fillGrayBuffer(alphaBuf);
45076
45077 if (sw !== width || sh !== height) {
45078 alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
45079 }
45080 } else if (mask) {
45081 if (mask instanceof PDFImage) {
45082 sw = mask.width;
45083 sh = mask.height;
45084 alphaBuf = new Uint8ClampedArray(sw * sh);
45085 mask.numComps = 1;
45086 mask.fillGrayBuffer(alphaBuf);
45087
45088 for (i = 0, ii = sw * sh; i < ii; ++i) {
45089 alphaBuf[i] = 255 - alphaBuf[i];
45090 }
45091
45092 if (sw !== width || sh !== height) {
45093 alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
45094 }
45095 } else if (Array.isArray(mask)) {
45096 alphaBuf = new Uint8ClampedArray(width * height);
45097 var numComps = this.numComps;
45098
45099 for (i = 0, ii = width * height; i < ii; ++i) {
45100 var opacity = 0;
45101 var imageOffset = i * numComps;
45102
45103 for (j = 0; j < numComps; ++j) {
45104 var color = image[imageOffset + j];
45105 var maskOffset = j * 2;
45106
45107 if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
45108 opacity = 255;
45109 break;
45110 }
45111 }
45112
45113 alphaBuf[i] = opacity;
45114 }
45115 } else {
45116 throw new _util.FormatError("Unknown mask format.");
45117 }
45118 }
45119
45120 if (alphaBuf) {
45121 for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
45122 rgbaBuf[j] = alphaBuf[i];
45123 }
45124 } else {
45125 for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
45126 rgbaBuf[j] = 255;
45127 }
45128 }
45129 },
45130
45131 undoPreblend(buffer, width, height) {
45132 var matte = this.smask && this.smask.matte;
45133
45134 if (!matte) {
45135 return;
45136 }
45137
45138 var matteRgb = this.colorSpace.getRgb(matte, 0);
45139 var matteR = matteRgb[0];
45140 var matteG = matteRgb[1];
45141 var matteB = matteRgb[2];
45142 var length = width * height * 4;
45143
45144 for (var i = 0; i < length; i += 4) {
45145 var alpha = buffer[i + 3];
45146
45147 if (alpha === 0) {
45148 buffer[i] = 255;
45149 buffer[i + 1] = 255;
45150 buffer[i + 2] = 255;
45151 continue;
45152 }
45153
45154 var k = 255 / alpha;
45155 buffer[i] = (buffer[i] - matteR) * k + matteR;
45156 buffer[i + 1] = (buffer[i + 1] - matteG) * k + matteG;
45157 buffer[i + 2] = (buffer[i + 2] - matteB) * k + matteB;
45158 }
45159 },
45160
45161 createImageData(forceRGBA = false) {
45162 var drawWidth = this.drawWidth;
45163 var drawHeight = this.drawHeight;
45164 var imgData = {
45165 width: drawWidth,
45166 height: drawHeight,
45167 kind: 0,
45168 data: null
45169 };
45170 var numComps = this.numComps;
45171 var originalWidth = this.width;
45172 var originalHeight = this.height;
45173 var bpc = this.bpc;
45174 var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
45175 var imgArray;
45176
45177 if (!forceRGBA) {
45178 var kind;
45179
45180 if (this.colorSpace.name === "DeviceGray" && bpc === 1) {
45181 kind = _util.ImageKind.GRAYSCALE_1BPP;
45182 } else if (this.colorSpace.name === "DeviceRGB" && bpc === 8 && !this.needsDecode) {
45183 kind = _util.ImageKind.RGB_24BPP;
45184 }
45185
45186 if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
45187 imgData.kind = kind;
45188 imgArray = this.getImageBytes(originalHeight * rowBytes);
45189
45190 if (this.image instanceof _stream.DecodeStream) {
45191 imgData.data = imgArray;
45192 } else {
45193 var newArray = new Uint8ClampedArray(imgArray.length);
45194 newArray.set(imgArray);
45195 imgData.data = newArray;
45196 }
45197
45198 if (this.needsDecode) {
45199 (0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale.");
45200 var buffer = imgData.data;
45201
45202 for (var i = 0, ii = buffer.length; i < ii; i++) {
45203 buffer[i] ^= 0xff;
45204 }
45205 }
45206
45207 return imgData;
45208 }
45209
45210 if (this.image instanceof _jpeg_stream.JpegStream && !this.smask && !this.mask) {
45211 let imageLength = originalHeight * rowBytes;
45212
45213 switch (this.colorSpace.name) {
45214 case "DeviceGray":
45215 imageLength *= 3;
45216
45217 case "DeviceRGB":
45218 case "DeviceCMYK":
45219 imgData.kind = _util.ImageKind.RGB_24BPP;
45220 imgData.data = this.getImageBytes(imageLength, drawWidth, drawHeight, true);
45221 return imgData;
45222 }
45223 }
45224 }
45225
45226 imgArray = this.getImageBytes(originalHeight * rowBytes);
45227 var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
45228 var comps = this.getComponents(imgArray);
45229 var alpha01, maybeUndoPreblend;
45230
45231 if (!forceRGBA && !this.smask && !this.mask) {
45232 imgData.kind = _util.ImageKind.RGB_24BPP;
45233 imgData.data = new Uint8ClampedArray(drawWidth * drawHeight * 3);
45234 alpha01 = 0;
45235 maybeUndoPreblend = false;
45236 } else {
45237 imgData.kind = _util.ImageKind.RGBA_32BPP;
45238 imgData.data = new Uint8ClampedArray(drawWidth * drawHeight * 4);
45239 alpha01 = 1;
45240 maybeUndoPreblend = true;
45241 this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
45242 }
45243
45244 if (this.needsDecode) {
45245 this.decodeBuffer(comps);
45246 }
45247
45248 this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
45249
45250 if (maybeUndoPreblend) {
45251 this.undoPreblend(imgData.data, drawWidth, actualHeight);
45252 }
45253
45254 return imgData;
45255 },
45256
45257 fillGrayBuffer(buffer) {
45258 var numComps = this.numComps;
45259
45260 if (numComps !== 1) {
45261 throw new _util.FormatError(`Reading gray scale from a color image: ${numComps}`);
45262 }
45263
45264 var width = this.width;
45265 var height = this.height;
45266 var bpc = this.bpc;
45267 var rowBytes = width * numComps * bpc + 7 >> 3;
45268 var imgArray = this.getImageBytes(height * rowBytes);
45269 var comps = this.getComponents(imgArray);
45270 var i, length;
45271
45272 if (bpc === 1) {
45273 length = width * height;
45274
45275 if (this.needsDecode) {
45276 for (i = 0; i < length; ++i) {
45277 buffer[i] = comps[i] - 1 & 255;
45278 }
45279 } else {
45280 for (i = 0; i < length; ++i) {
45281 buffer[i] = -comps[i] & 255;
45282 }
45283 }
45284
45285 return;
45286 }
45287
45288 if (this.needsDecode) {
45289 this.decodeBuffer(comps);
45290 }
45291
45292 length = width * height;
45293 var scale = 255 / ((1 << bpc) - 1);
45294
45295 for (i = 0; i < length; ++i) {
45296 buffer[i] = scale * comps[i];
45297 }
45298 },
45299
45300 getImageBytes(length, drawWidth, drawHeight, forceRGB = false) {
45301 this.image.reset();
45302 this.image.drawWidth = drawWidth || this.width;
45303 this.image.drawHeight = drawHeight || this.height;
45304 this.image.forceRGB = !!forceRGB;
45305 return this.image.getBytes(length, true);
45306 }
45307
45308 };
45309 return PDFImage;
45310}();
45311
45312exports.PDFImage = PDFImage;
45313
45314/***/ }),
45315/* 45 */
45316/***/ (function(module, exports, __w_pdfjs_require__) {
45317
45318"use strict";
45319
45320
45321Object.defineProperty(exports, "__esModule", {
45322 value: true
45323});
45324exports.MessageHandler = void 0;
45325
45326var _util = __w_pdfjs_require__(2);
45327
45328const CallbackKind = {
45329 UNKNOWN: 0,
45330 DATA: 1,
45331 ERROR: 2
45332};
45333const StreamKind = {
45334 UNKNOWN: 0,
45335 CANCEL: 1,
45336 CANCEL_COMPLETE: 2,
45337 CLOSE: 3,
45338 ENQUEUE: 4,
45339 ERROR: 5,
45340 PULL: 6,
45341 PULL_COMPLETE: 7,
45342 START_COMPLETE: 8
45343};
45344
45345function wrapReason(reason) {
45346 if (typeof reason !== "object" || reason === null) {
45347 return reason;
45348 }
45349
45350 switch (reason.name) {
45351 case "AbortException":
45352 return new _util.AbortException(reason.message);
45353
45354 case "MissingPDFException":
45355 return new _util.MissingPDFException(reason.message);
45356
45357 case "UnexpectedResponseException":
45358 return new _util.UnexpectedResponseException(reason.message, reason.status);
45359
45360 case "UnknownErrorException":
45361 return new _util.UnknownErrorException(reason.message, reason.details);
45362
45363 default:
45364 return new _util.UnknownErrorException(reason.message, reason.toString());
45365 }
45366}
45367
45368class MessageHandler {
45369 constructor(sourceName, targetName, comObj) {
45370 this.sourceName = sourceName;
45371 this.targetName = targetName;
45372 this.comObj = comObj;
45373 this.callbackId = 1;
45374 this.streamId = 1;
45375 this.postMessageTransfers = true;
45376 this.streamSinks = Object.create(null);
45377 this.streamControllers = Object.create(null);
45378 this.callbackCapabilities = Object.create(null);
45379 this.actionHandler = Object.create(null);
45380
45381 this._onComObjOnMessage = event => {
45382 const data = event.data;
45383
45384 if (data.targetName !== this.sourceName) {
45385 return;
45386 }
45387
45388 if (data.stream) {
45389 this._processStreamMessage(data);
45390
45391 return;
45392 }
45393
45394 if (data.callback) {
45395 const callbackId = data.callbackId;
45396 const capability = this.callbackCapabilities[callbackId];
45397
45398 if (!capability) {
45399 throw new Error(`Cannot resolve callback ${callbackId}`);
45400 }
45401
45402 delete this.callbackCapabilities[callbackId];
45403
45404 if (data.callback === CallbackKind.DATA) {
45405 capability.resolve(data.data);
45406 } else if (data.callback === CallbackKind.ERROR) {
45407 capability.reject(wrapReason(data.reason));
45408 } else {
45409 throw new Error("Unexpected callback case");
45410 }
45411
45412 return;
45413 }
45414
45415 const action = this.actionHandler[data.action];
45416
45417 if (!action) {
45418 throw new Error(`Unknown action from worker: ${data.action}`);
45419 }
45420
45421 if (data.callbackId) {
45422 const cbSourceName = this.sourceName;
45423 const cbTargetName = data.sourceName;
45424 new Promise(function (resolve) {
45425 resolve(action(data.data));
45426 }).then(function (result) {
45427 comObj.postMessage({
45428 sourceName: cbSourceName,
45429 targetName: cbTargetName,
45430 callback: CallbackKind.DATA,
45431 callbackId: data.callbackId,
45432 data: result
45433 });
45434 }, function (reason) {
45435 comObj.postMessage({
45436 sourceName: cbSourceName,
45437 targetName: cbTargetName,
45438 callback: CallbackKind.ERROR,
45439 callbackId: data.callbackId,
45440 reason: wrapReason(reason)
45441 });
45442 });
45443 return;
45444 }
45445
45446 if (data.streamId) {
45447 this._createStreamSink(data);
45448
45449 return;
45450 }
45451
45452 action(data.data);
45453 };
45454
45455 comObj.addEventListener("message", this._onComObjOnMessage);
45456 }
45457
45458 on(actionName, handler) {
45459 const ah = this.actionHandler;
45460
45461 if (ah[actionName]) {
45462 throw new Error(`There is already an actionName called "${actionName}"`);
45463 }
45464
45465 ah[actionName] = handler;
45466 }
45467
45468 send(actionName, data, transfers) {
45469 this._postMessage({
45470 sourceName: this.sourceName,
45471 targetName: this.targetName,
45472 action: actionName,
45473 data
45474 }, transfers);
45475 }
45476
45477 sendWithPromise(actionName, data, transfers) {
45478 const callbackId = this.callbackId++;
45479 const capability = (0, _util.createPromiseCapability)();
45480 this.callbackCapabilities[callbackId] = capability;
45481
45482 try {
45483 this._postMessage({
45484 sourceName: this.sourceName,
45485 targetName: this.targetName,
45486 action: actionName,
45487 callbackId,
45488 data
45489 }, transfers);
45490 } catch (ex) {
45491 capability.reject(ex);
45492 }
45493
45494 return capability.promise;
45495 }
45496
45497 sendWithStream(actionName, data, queueingStrategy, transfers) {
45498 const streamId = this.streamId++;
45499 const sourceName = this.sourceName;
45500 const targetName = this.targetName;
45501 const comObj = this.comObj;
45502 return new ReadableStream({
45503 start: controller => {
45504 const startCapability = (0, _util.createPromiseCapability)();
45505 this.streamControllers[streamId] = {
45506 controller,
45507 startCall: startCapability,
45508 pullCall: null,
45509 cancelCall: null,
45510 isClosed: false
45511 };
45512
45513 this._postMessage({
45514 sourceName,
45515 targetName,
45516 action: actionName,
45517 streamId,
45518 data,
45519 desiredSize: controller.desiredSize
45520 }, transfers);
45521
45522 return startCapability.promise;
45523 },
45524 pull: controller => {
45525 const pullCapability = (0, _util.createPromiseCapability)();
45526 this.streamControllers[streamId].pullCall = pullCapability;
45527 comObj.postMessage({
45528 sourceName,
45529 targetName,
45530 stream: StreamKind.PULL,
45531 streamId,
45532 desiredSize: controller.desiredSize
45533 });
45534 return pullCapability.promise;
45535 },
45536 cancel: reason => {
45537 (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
45538 const cancelCapability = (0, _util.createPromiseCapability)();
45539 this.streamControllers[streamId].cancelCall = cancelCapability;
45540 this.streamControllers[streamId].isClosed = true;
45541 comObj.postMessage({
45542 sourceName,
45543 targetName,
45544 stream: StreamKind.CANCEL,
45545 streamId,
45546 reason: wrapReason(reason)
45547 });
45548 return cancelCapability.promise;
45549 }
45550 }, queueingStrategy);
45551 }
45552
45553 _createStreamSink(data) {
45554 const self = this;
45555 const action = this.actionHandler[data.action];
45556 const streamId = data.streamId;
45557 const sourceName = this.sourceName;
45558 const targetName = data.sourceName;
45559 const comObj = this.comObj;
45560 const streamSink = {
45561 enqueue(chunk, size = 1, transfers) {
45562 if (this.isCancelled) {
45563 return;
45564 }
45565
45566 const lastDesiredSize = this.desiredSize;
45567 this.desiredSize -= size;
45568
45569 if (lastDesiredSize > 0 && this.desiredSize <= 0) {
45570 this.sinkCapability = (0, _util.createPromiseCapability)();
45571 this.ready = this.sinkCapability.promise;
45572 }
45573
45574 self._postMessage({
45575 sourceName,
45576 targetName,
45577 stream: StreamKind.ENQUEUE,
45578 streamId,
45579 chunk
45580 }, transfers);
45581 },
45582
45583 close() {
45584 if (this.isCancelled) {
45585 return;
45586 }
45587
45588 this.isCancelled = true;
45589 comObj.postMessage({
45590 sourceName,
45591 targetName,
45592 stream: StreamKind.CLOSE,
45593 streamId
45594 });
45595 delete self.streamSinks[streamId];
45596 },
45597
45598 error(reason) {
45599 (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
45600
45601 if (this.isCancelled) {
45602 return;
45603 }
45604
45605 this.isCancelled = true;
45606 comObj.postMessage({
45607 sourceName,
45608 targetName,
45609 stream: StreamKind.ERROR,
45610 streamId,
45611 reason: wrapReason(reason)
45612 });
45613 },
45614
45615 sinkCapability: (0, _util.createPromiseCapability)(),
45616 onPull: null,
45617 onCancel: null,
45618 isCancelled: false,
45619 desiredSize: data.desiredSize,
45620 ready: null
45621 };
45622 streamSink.sinkCapability.resolve();
45623 streamSink.ready = streamSink.sinkCapability.promise;
45624 this.streamSinks[streamId] = streamSink;
45625 new Promise(function (resolve) {
45626 resolve(action(data.data, streamSink));
45627 }).then(function () {
45628 comObj.postMessage({
45629 sourceName,
45630 targetName,
45631 stream: StreamKind.START_COMPLETE,
45632 streamId,
45633 success: true
45634 });
45635 }, function (reason) {
45636 comObj.postMessage({
45637 sourceName,
45638 targetName,
45639 stream: StreamKind.START_COMPLETE,
45640 streamId,
45641 reason: wrapReason(reason)
45642 });
45643 });
45644 }
45645
45646 _processStreamMessage(data) {
45647 const streamId = data.streamId;
45648 const sourceName = this.sourceName;
45649 const targetName = data.sourceName;
45650 const comObj = this.comObj;
45651
45652 switch (data.stream) {
45653 case StreamKind.START_COMPLETE:
45654 if (data.success) {
45655 this.streamControllers[streamId].startCall.resolve();
45656 } else {
45657 this.streamControllers[streamId].startCall.reject(wrapReason(data.reason));
45658 }
45659
45660 break;
45661
45662 case StreamKind.PULL_COMPLETE:
45663 if (data.success) {
45664 this.streamControllers[streamId].pullCall.resolve();
45665 } else {
45666 this.streamControllers[streamId].pullCall.reject(wrapReason(data.reason));
45667 }
45668
45669 break;
45670
45671 case StreamKind.PULL:
45672 if (!this.streamSinks[streamId]) {
45673 comObj.postMessage({
45674 sourceName,
45675 targetName,
45676 stream: StreamKind.PULL_COMPLETE,
45677 streamId,
45678 success: true
45679 });
45680 break;
45681 }
45682
45683 if (this.streamSinks[streamId].desiredSize <= 0 && data.desiredSize > 0) {
45684 this.streamSinks[streamId].sinkCapability.resolve();
45685 }
45686
45687 this.streamSinks[streamId].desiredSize = data.desiredSize;
45688 const {
45689 onPull
45690 } = this.streamSinks[data.streamId];
45691 new Promise(function (resolve) {
45692 resolve(onPull && onPull());
45693 }).then(function () {
45694 comObj.postMessage({
45695 sourceName,
45696 targetName,
45697 stream: StreamKind.PULL_COMPLETE,
45698 streamId,
45699 success: true
45700 });
45701 }, function (reason) {
45702 comObj.postMessage({
45703 sourceName,
45704 targetName,
45705 stream: StreamKind.PULL_COMPLETE,
45706 streamId,
45707 reason: wrapReason(reason)
45708 });
45709 });
45710 break;
45711
45712 case StreamKind.ENQUEUE:
45713 (0, _util.assert)(this.streamControllers[streamId], "enqueue should have stream controller");
45714
45715 if (this.streamControllers[streamId].isClosed) {
45716 break;
45717 }
45718
45719 this.streamControllers[streamId].controller.enqueue(data.chunk);
45720 break;
45721
45722 case StreamKind.CLOSE:
45723 (0, _util.assert)(this.streamControllers[streamId], "close should have stream controller");
45724
45725 if (this.streamControllers[streamId].isClosed) {
45726 break;
45727 }
45728
45729 this.streamControllers[streamId].isClosed = true;
45730 this.streamControllers[streamId].controller.close();
45731
45732 this._deleteStreamController(streamId);
45733
45734 break;
45735
45736 case StreamKind.ERROR:
45737 (0, _util.assert)(this.streamControllers[streamId], "error should have stream controller");
45738 this.streamControllers[streamId].controller.error(wrapReason(data.reason));
45739
45740 this._deleteStreamController(streamId);
45741
45742 break;
45743
45744 case StreamKind.CANCEL_COMPLETE:
45745 if (data.success) {
45746 this.streamControllers[streamId].cancelCall.resolve();
45747 } else {
45748 this.streamControllers[streamId].cancelCall.reject(wrapReason(data.reason));
45749 }
45750
45751 this._deleteStreamController(streamId);
45752
45753 break;
45754
45755 case StreamKind.CANCEL:
45756 if (!this.streamSinks[streamId]) {
45757 break;
45758 }
45759
45760 const {
45761 onCancel
45762 } = this.streamSinks[data.streamId];
45763 new Promise(function (resolve) {
45764 resolve(onCancel && onCancel(wrapReason(data.reason)));
45765 }).then(function () {
45766 comObj.postMessage({
45767 sourceName,
45768 targetName,
45769 stream: StreamKind.CANCEL_COMPLETE,
45770 streamId,
45771 success: true
45772 });
45773 }, function (reason) {
45774 comObj.postMessage({
45775 sourceName,
45776 targetName,
45777 stream: StreamKind.CANCEL_COMPLETE,
45778 streamId,
45779 reason: wrapReason(reason)
45780 });
45781 });
45782 this.streamSinks[streamId].sinkCapability.reject(wrapReason(data.reason));
45783 this.streamSinks[streamId].isCancelled = true;
45784 delete this.streamSinks[streamId];
45785 break;
45786
45787 default:
45788 throw new Error("Unexpected stream case");
45789 }
45790 }
45791
45792 async _deleteStreamController(streamId) {
45793 await Promise.allSettled([this.streamControllers[streamId].startCall, this.streamControllers[streamId].pullCall, this.streamControllers[streamId].cancelCall].map(function (capability) {
45794 return capability && capability.promise;
45795 }));
45796 delete this.streamControllers[streamId];
45797 }
45798
45799 _postMessage(message, transfers) {
45800 if (transfers && this.postMessageTransfers) {
45801 this.comObj.postMessage(message, transfers);
45802 } else {
45803 this.comObj.postMessage(message);
45804 }
45805 }
45806
45807 destroy() {
45808 this.comObj.removeEventListener("message", this._onComObjOnMessage);
45809 }
45810
45811}
45812
45813exports.MessageHandler = MessageHandler;
45814
45815/***/ }),
45816/* 46 */
45817/***/ (function(module, exports, __w_pdfjs_require__) {
45818
45819"use strict";
45820
45821
45822Object.defineProperty(exports, "__esModule", {
45823 value: true
45824});
45825exports.PDFWorkerStream = void 0;
45826
45827var _util = __w_pdfjs_require__(2);
45828
45829class PDFWorkerStream {
45830 constructor(msgHandler) {
45831 this._msgHandler = msgHandler;
45832 this._contentLength = null;
45833 this._fullRequestReader = null;
45834 this._rangeRequestReaders = [];
45835 }
45836
45837 getFullReader() {
45838 (0, _util.assert)(!this._fullRequestReader, "PDFWorkerStream.getFullReader can only be called once.");
45839 this._fullRequestReader = new PDFWorkerStreamReader(this._msgHandler);
45840 return this._fullRequestReader;
45841 }
45842
45843 getRangeReader(begin, end) {
45844 const reader = new PDFWorkerStreamRangeReader(begin, end, this._msgHandler);
45845
45846 this._rangeRequestReaders.push(reader);
45847
45848 return reader;
45849 }
45850
45851 cancelAllRequests(reason) {
45852 if (this._fullRequestReader) {
45853 this._fullRequestReader.cancel(reason);
45854 }
45855
45856 const readers = this._rangeRequestReaders.slice(0);
45857
45858 readers.forEach(function (reader) {
45859 reader.cancel(reason);
45860 });
45861 }
45862
45863}
45864
45865exports.PDFWorkerStream = PDFWorkerStream;
45866
45867class PDFWorkerStreamReader {
45868 constructor(msgHandler) {
45869 this._msgHandler = msgHandler;
45870 this.onProgress = null;
45871 this._contentLength = null;
45872 this._isRangeSupported = false;
45873 this._isStreamingSupported = false;
45874
45875 const readableStream = this._msgHandler.sendWithStream("GetReader");
45876
45877 this._reader = readableStream.getReader();
45878 this._headersReady = this._msgHandler.sendWithPromise("ReaderHeadersReady").then(data => {
45879 this._isStreamingSupported = data.isStreamingSupported;
45880 this._isRangeSupported = data.isRangeSupported;
45881 this._contentLength = data.contentLength;
45882 });
45883 }
45884
45885 get headersReady() {
45886 return this._headersReady;
45887 }
45888
45889 get contentLength() {
45890 return this._contentLength;
45891 }
45892
45893 get isStreamingSupported() {
45894 return this._isStreamingSupported;
45895 }
45896
45897 get isRangeSupported() {
45898 return this._isRangeSupported;
45899 }
45900
45901 async read() {
45902 const {
45903 value,
45904 done
45905 } = await this._reader.read();
45906
45907 if (done) {
45908 return {
45909 value: undefined,
45910 done: true
45911 };
45912 }
45913
45914 return {
45915 value: value.buffer,
45916 done: false
45917 };
45918 }
45919
45920 cancel(reason) {
45921 this._reader.cancel(reason);
45922 }
45923
45924}
45925
45926class PDFWorkerStreamRangeReader {
45927 constructor(begin, end, msgHandler) {
45928 this._msgHandler = msgHandler;
45929 this.onProgress = null;
45930
45931 const readableStream = this._msgHandler.sendWithStream("GetRangeReader", {
45932 begin,
45933 end
45934 });
45935
45936 this._reader = readableStream.getReader();
45937 }
45938
45939 get isStreamingSupported() {
45940 return false;
45941 }
45942
45943 async read() {
45944 const {
45945 value,
45946 done
45947 } = await this._reader.read();
45948
45949 if (done) {
45950 return {
45951 value: undefined,
45952 done: true
45953 };
45954 }
45955
45956 return {
45957 value: value.buffer,
45958 done: false
45959 };
45960 }
45961
45962 cancel(reason) {
45963 this._reader.cancel(reason);
45964 }
45965
45966}
45967
45968/***/ })
45969/******/ ]);
45970});
45971//# sourceMappingURL=pdf.worker.js.map
\No newline at end of file