1/** 2 * @licstart The following is the entire license notice for the 3 * JavaScript code in this page 4 * 5 * Copyright 2022 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/web/pdf_viewer", [], factory); 28 else if(typeof exports === 'object') 29 exports["pdfjs-dist/web/pdf_viewer"] = factory(); 30 else 31 root["pdfjs-dist/web/pdf_viewer"] = root.pdfjsViewer = factory(); 32})(globalThis, () => { 33return /******/ (() => { // webpackBootstrap 34/******/ "use strict"; 35/******/ var __webpack_modules__ = ([ 36/* 0 */, 37/* 1 */ 38/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 39 40 41 42Object.defineProperty(exports, "__esModule", ({ 43 value: true 44})); 45exports.DefaultXfaLayerFactory = exports.DefaultTextLayerFactory = exports.DefaultStructTreeLayerFactory = exports.DefaultAnnotationLayerFactory = exports.DefaultAnnotationEditorLayerFactory = void 0; 46 47var _annotation_editor_layer_builder = __w_pdfjs_require__(2); 48 49var _annotation_layer_builder = __w_pdfjs_require__(5); 50 51var _l10n_utils = __w_pdfjs_require__(4); 52 53var _pdf_link_service = __w_pdfjs_require__(6); 54 55var _struct_tree_layer_builder = __w_pdfjs_require__(8); 56 57var _text_layer_builder = __w_pdfjs_require__(9); 58 59var _xfa_layer_builder = __w_pdfjs_require__(10); 60 61class DefaultAnnotationLayerFactory { 62 createAnnotationLayerBuilder(_ref) { 63 let { 64 pageDiv, 65 pdfPage, 66 annotationStorage = null, 67 imageResourcesPath = "", 68 renderForms = true, 69 l10n = _l10n_utils.NullL10n, 70 enableScripting = false, 71 hasJSActionsPromise = null, 72 mouseState = null, 73 fieldObjectsPromise = null, 74 annotationCanvasMap = null, 75 accessibilityManager = null 76 } = _ref; 77 return new _annotation_layer_builder.AnnotationLayerBuilder({ 78 pageDiv, 79 pdfPage, 80 imageResourcesPath, 81 renderForms, 82 linkService: new _pdf_link_service.SimpleLinkService(), 83 l10n, 84 annotationStorage, 85 enableScripting, 86 hasJSActionsPromise, 87 fieldObjectsPromise, 88 mouseState, 89 annotationCanvasMap, 90 accessibilityManager 91 }); 92 } 93 94} 95 96exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory; 97 98class DefaultAnnotationEditorLayerFactory { 99 createAnnotationEditorLayerBuilder(_ref2) { 100 let { 101 uiManager = null, 102 pageDiv, 103 pdfPage, 104 accessibilityManager = null, 105 l10n, 106 annotationStorage = null 107 } = _ref2; 108 return new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({ 109 uiManager, 110 pageDiv, 111 pdfPage, 112 accessibilityManager, 113 l10n, 114 annotationStorage 115 }); 116 } 117 118} 119 120exports.DefaultAnnotationEditorLayerFactory = DefaultAnnotationEditorLayerFactory; 121 122class DefaultStructTreeLayerFactory { 123 createStructTreeLayerBuilder(_ref3) { 124 let { 125 pdfPage 126 } = _ref3; 127 return new _struct_tree_layer_builder.StructTreeLayerBuilder({ 128 pdfPage 129 }); 130 } 131 132} 133 134exports.DefaultStructTreeLayerFactory = DefaultStructTreeLayerFactory; 135 136class DefaultTextLayerFactory { 137 createTextLayerBuilder(_ref4) { 138 let { 139 textLayerDiv, 140 pageIndex, 141 viewport, 142 enhanceTextSelection = false, 143 eventBus, 144 highlighter, 145 accessibilityManager = null 146 } = _ref4; 147 return new _text_layer_builder.TextLayerBuilder({ 148 textLayerDiv, 149 pageIndex, 150 viewport, 151 enhanceTextSelection, 152 eventBus, 153 highlighter, 154 accessibilityManager 155 }); 156 } 157 158} 159 160exports.DefaultTextLayerFactory = DefaultTextLayerFactory; 161 162class DefaultXfaLayerFactory { 163 createXfaLayerBuilder(_ref5) { 164 let { 165 pageDiv, 166 pdfPage, 167 annotationStorage = null 168 } = _ref5; 169 return new _xfa_layer_builder.XfaLayerBuilder({ 170 pageDiv, 171 pdfPage, 172 annotationStorage, 173 linkService: new _pdf_link_service.SimpleLinkService() 174 }); 175 } 176 177} 178 179exports.DefaultXfaLayerFactory = DefaultXfaLayerFactory; 180 181/***/ }), 182/* 2 */ 183/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 184 185 186 187Object.defineProperty(exports, "__esModule", ({ 188 value: true 189})); 190exports.AnnotationEditorLayerBuilder = void 0; 191 192var _pdfjsLib = __w_pdfjs_require__(3); 193 194var _l10n_utils = __w_pdfjs_require__(4); 195 196function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 197 198function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 199 200function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 201 202function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 203 204function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; } 205 206function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 207 208function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } } 209 210var _uiManager = /*#__PURE__*/new WeakMap(); 211 212class AnnotationEditorLayerBuilder { 213 constructor(options) { 214 _classPrivateFieldInitSpec(this, _uiManager, { 215 writable: true, 216 value: void 0 217 }); 218 219 this.pageDiv = options.pageDiv; 220 this.pdfPage = options.pdfPage; 221 this.annotationStorage = options.annotationStorage || null; 222 this.accessibilityManager = options.accessibilityManager; 223 this.l10n = options.l10n || _l10n_utils.NullL10n; 224 this.annotationEditorLayer = null; 225 this.div = null; 226 this._cancelled = false;
227 228 _classPrivateFieldSet(this, _uiManager, options.uiManager); 229 } 230 231 async render(viewport) { 232 let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display"; 233 234 if (intent !== "display") { 235 return; 236 } 237 238 if (this._cancelled) { 239 return; 240 } 241 242 const clonedViewport = viewport.clone({ 243 dontFlip: true 244 }); 245 246 if (this.div) { 247 this.annotationEditorLayer.update({ 248 viewport: clonedViewport 249 }); 250 this.show(); 251 return; 252 } 253 254 this.div = document.createElement("div"); 255 this.div.className = "annotationEditorLayer"; 256 this.div.tabIndex = 0; 257 this.pageDiv.append(this.div); 258 this.annotationEditorLayer = new _pdfjsLib.AnnotationEditorLayer({ 259 uiManager: _classPrivateFieldGet(this, _uiManager), 260 div: this.div, 261 annotationStorage: this.annotationStorage, 262 accessibilityManager: this.accessibilityManager, 263 pageIndex: this.pdfPage._pageIndex, 264 l10n: this.l10n, 265 viewport: clonedViewport 266 }); 267 const parameters = { 268 viewport: clonedViewport, 269 div: this.div, 270 annotations: null, 271 intent 272 }; 273 this.annotationEditorLayer.render(parameters); 274 } 275 276 cancel() { 277 this._cancelled = true; 278 this.destroy(); 279 } 280 281 hide() { 282 if (!this.div) { 283 return; 284 } 285 286 this.div.hidden = true; 287 } 288 289 show() { 290 if (!this.div) { 291 return; 292 } 293 294 this.div.hidden = false; 295 } 296 297 destroy() { 298 if (!this.div) { 299 return; 300 } 301 302 this.pageDiv = null; 303 this.annotationEditorLayer.destroy(); 304 this.div.remove(); 305 } 306 307} 308 309exports.AnnotationEditorLayerBuilder = AnnotationEditorLayerBuilder; 310 311/***/ }), 312/* 3 */ 313/***/ ((module) => { 314 315 316 317let pdfjsLib; 318 319if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) { 320 pdfjsLib = window["pdfjs-dist/build/pdf"]; 321} else { 322 pdfjsLib = require("../build/pdf.js"); 323} 324 325module.exports = pdfjsLib; 326 327/***/ }), 328/* 4 */ 329/***/ ((__unused_webpack_module, exports) => { 330 331 332 333Object.defineProperty(exports, "__esModule", ({ 334 value: true 335})); 336exports.NullL10n = void 0; 337exports.fixupLangCode = fixupLangCode; 338exports.getL10nFallback = getL10nFallback; 339const DEFAULT_L10N_STRINGS = { 340 of_pages: "of {{pagesCount}}", 341 page_of_pages: "({{pageNumber}} of {{pagesCount}})", 342 document_properties_kb: "{{size_kb}} KB ({{size_b}} bytes)", 343 document_properties_mb: "{{size_mb}} MB ({{size_b}} bytes)", 344 document_properties_date_string: "{{date}}, {{time}}", 345 document_properties_page_size_unit_inches: "in", 346 document_properties_page_size_unit_millimeters: "mm", 347 document_properties_page_size_orientation_portrait: "portrait", 348 document_properties_page_size_orientation_landscape: "landscape", 349 document_properties_page_size_name_a3: "A3", 350 document_properties_page_size_name_a4: "A4", 351 document_properties_page_size_name_letter: "Letter", 352 document_properties_page_size_name_legal: "Legal", 353 document_properties_page_size_dimension_string: "{{width}} à {{height}} {{unit}} ({{orientation}})", 354 document_properties_page_size_dimension_name_string: "{{width}} à {{height}} {{unit}} ({{name}}, {{orientation}})", 355 document_properties_linearized_yes: "Yes", 356 document_properties_linearized_no: "No", 357 print_progress_percent: "{{progress}}%", 358 "toggle_sidebar.title": "Toggle Sidebar", 359 "toggle_sidebar_notification2.title": "Toggle Sidebar (document contains outline/attachments/layers)", 360 additional_layers: "Additional Layers", 361 page_landmark: "Page {{page}}", 362 thumb_page_title: "Page {{page}}", 363 thumb_page_canvas: "Thumbnail of Page {{page}}", 364 find_reached_top: "Reached top of document, continued from bottom", 365 find_reached_bottom: "Reached end of document, continued from top", 366 "find_match_count[one]": "{{current}} of {{total}} match", 367 "find_match_count[other]": "{{current}} of {{total}} matches", 368 "find_match_count_limit[one]": "More than {{limit}} match", 369 "find_match_count_limit[other]": "More than {{limit}} matches", 370 find_not_found: "Phrase not found", 371 error_version_info: "PDF.js v{{version}} (build: {{build}})", 372 error_message: "Message: {{message}}", 373 error_stack: "Stack: {{stack}}", 374 error_file: "File: {{file}}", 375 error_line: "Line: {{line}}", 376 rendering_error: "An error occurred while rendering the page.", 377 page_scale_width: "Page Width", 378 page_scale_fit: "Page Fit", 379 page_scale_auto: "Automatic Zoom", 380 page_scale_actual: "Actual Size", 381 page_scale_percent: "{{scale}}%", 382 loading: "Loadingâ¦", 383 loading_error: "An error occurred while loading the PDF.", 384 invalid_file_error: "Invalid or corrupted PDF file.", 385 missing_file_error: "Missing PDF file.", 386 unexpected_response_error: "Unexpected server response.", 387 printing_not_supported: "Warning: Printing is not fully supported by this browser.", 388 printing_not_ready: "Warning: The PDF is not fully loaded for printing.", 389 web_fonts_disabled: "Web fonts are disabled: unable to use embedded PDF fonts.", 390 free_text_default_content: "Enter textâ¦", 391 editor_free_text_aria_label: "FreeText Editor", 392 editor_ink_aria_label: "Ink Editor", 393 editor_ink_canvas_aria_label: "User-created image" 394}; 395 396function getL10nFallback(key, args) { 397 switch (key) { 398 case "find_match_count": 399 key = `find_match_count[${args.total === 1 ? "one" : "other"}]`; 400 break; 401 402 case "find_match_count_limit": 403 key = `find_match_count_limit[${args.limit === 1 ? "one" : "other"}]`; 404 break; 405 } 406 407 return DEFAULT_L10N_STRINGS[key] || ""; 408} 409 410const PARTIAL_LANG_CODES = { 411 en: "en-US", 412 es: "es-ES", 413 fy: "fy-NL", 414 ga: "ga-IE", 415 gu: "gu-IN", 416 hi: "hi-IN", 417 hy: "hy-AM", 418 nb: "nb-NO", 419 ne: "ne-NP", 420 nn: "nn-NO", 421 pa: "pa-IN", 422 pt: "pt-PT", 423 sv: "sv-SE", 424 zh: "zh-CN" 425}; 426 427function fixupLangCode(langCode) { 428 return PARTIAL_LANG_CODES[langCode === null || langCode === void 0 ? void 0 : langCode.toLowerCase()] || langCode;
429} 430 431function formatL10nValue(text, args) { 432 if (!args) { 433 return text; 434 } 435 436 return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (all, name) => { 437 return name in args ? args[name] : "{{" + name + "}}"; 438 }); 439} 440 441const NullL10n = { 442 async getLanguage() { 443 return "en-us"; 444 }, 445 446 async getDirection() { 447 return "ltr"; 448 }, 449 450 async get(key) { 451 let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 452 let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getL10nFallback(key, args); 453 return formatL10nValue(fallback, args); 454 }, 455 456 async translate(element) {} 457 458}; 459exports.NullL10n = NullL10n; 460 461/***/ }), 462/* 5 */ 463/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 464 465 466 467Object.defineProperty(exports, "__esModule", ({ 468 value: true 469})); 470exports.AnnotationLayerBuilder = void 0; 471 472var _pdfjsLib = __w_pdfjs_require__(3); 473 474var _l10n_utils = __w_pdfjs_require__(4); 475 476class AnnotationLayerBuilder { 477 constructor(_ref) { 478 let { 479 pageDiv, 480 pdfPage, 481 linkService, 482 downloadManager, 483 annotationStorage = null, 484 imageResourcesPath = "", 485 renderForms = true, 486 l10n = _l10n_utils.NullL10n, 487 enableScripting = false, 488 hasJSActionsPromise = null, 489 fieldObjectsPromise = null, 490 mouseState = null, 491 annotationCanvasMap = null, 492 accessibilityManager = null 493 } = _ref; 494 this.pageDiv = pageDiv; 495 this.pdfPage = pdfPage; 496 this.linkService = linkService; 497 this.downloadManager = downloadManager; 498 this.imageResourcesPath = imageResourcesPath; 499 this.renderForms = renderForms; 500 this.l10n = l10n; 501 this.annotationStorage = annotationStorage; 502 this.enableScripting = enableScripting; 503 this._hasJSActionsPromise = hasJSActionsPromise; 504 this._fieldObjectsPromise = fieldObjectsPromise; 505 this._mouseState = mouseState; 506 this._annotationCanvasMap = annotationCanvasMap; 507 this._accessibilityManager = accessibilityManager; 508 this.div = null; 509 this._cancelled = false; 510 } 511 512 async render(viewport) { 513 let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display"; 514 const [annotations, hasJSActions = false, fieldObjects = null] = await Promise.all([this.pdfPage.getAnnotations({ 515 intent 516 }), this._hasJSActionsPromise, this._fieldObjectsPromise]); 517 518 if (this._cancelled || annotations.length === 0) { 519 return; 520 } 521 522 const parameters = { 523 viewport: viewport.clone({ 524 dontFlip: true 525 }), 526 div: this.div, 527 annotations, 528 page: this.pdfPage, 529 imageResourcesPath: this.imageResourcesPath, 530 renderForms: this.renderForms, 531 linkService: this.linkService, 532 downloadManager: this.downloadManager, 533 annotationStorage: this.annotationStorage, 534 enableScripting: this.enableScripting, 535 hasJSActions, 536 fieldObjects, 537 mouseState: this._mouseState, 538 annotationCanvasMap: this._annotationCanvasMap, 539 accessibilityManager: this._accessibilityManager 540 }; 541 542 if (this.div) { 543 _pdfjsLib.AnnotationLayer.update(parameters); 544 } else { 545 this.div = document.createElement("div"); 546 this.div.className = "annotationLayer"; 547 this.pageDiv.append(this.div); 548 parameters.div = this.div; 549 550 _pdfjsLib.AnnotationLayer.render(parameters); 551 552 this.l10n.translate(this.div); 553 } 554 } 555 556 cancel() { 557 this._cancelled = true; 558 } 559 560 hide() { 561 if (!this.div) { 562 return; 563 } 564 565 this.div.hidden = true; 566 } 567 568} 569 570exports.AnnotationLayerBuilder = AnnotationLayerBuilder; 571 572/***/ }), 573/* 6 */ 574/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 575 576 577 578Object.defineProperty(exports, "__esModule", ({ 579 value: true 580})); 581exports.SimpleLinkService = exports.PDFLinkService = exports.LinkTarget = void 0; 582 583var _ui_utils = __w_pdfjs_require__(7); 584 585function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 586 587function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 588 589function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 590 591function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 592 593function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 594 595function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 596 597function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 598 599function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 600 601function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 602 603const DEFAULT_LINK_REL = "noopener noreferrer nofollow"; 604const LinkTarget = { 605 NONE: 0, 606 SELF: 1, 607 BLANK: 2, 608 PARENT: 3, 609 TOP: 4 610}; 611exports.LinkTarget = LinkTarget; 612 613function addLinkAttributes(link) { 614 let { 615 url, 616 target, 617 rel, 618 enabled = true 619 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 620 621 if (!url || typeof url !== "string") { 622 throw new Error('A valid "url" parameter must provided.'); 623 } 624 625 const urlNullRemoved = (0, _ui_utils.removeNullCharacters)(url); 626 627 if (enabled) { 628 link.href = link.title = urlNullRemoved; 629 } else { 630 link.href = ""; 631 link.title = `Disabled: ${urlNullRemoved}`; 632 633 link.onclick = () => { 634 return false;
635 }; 636 } 637 638 let targetStr = ""; 639 640 switch (target) { 641 case LinkTarget.NONE: 642 break; 643 644 case LinkTarget.SELF: 645 targetStr = "_self"; 646 break; 647 648 case LinkTarget.BLANK: 649 targetStr = "_blank"; 650 break; 651 652 case LinkTarget.PARENT: 653 targetStr = "_parent"; 654 break; 655 656 case LinkTarget.TOP: 657 targetStr = "_top"; 658 break; 659 } 660 661 link.target = targetStr; 662 link.rel = typeof rel === "string" ? rel : DEFAULT_LINK_REL; 663} 664 665var _pagesRefCache = /*#__PURE__*/new WeakMap(); 666 667var _goToDestinationHelper = /*#__PURE__*/new WeakSet(); 668 669class PDFLinkService { 670 constructor() { 671 let { 672 eventBus, 673 externalLinkTarget = null, 674 externalLinkRel = null, 675 ignoreDestinationZoom = false 676 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 677 678 _classPrivateMethodInitSpec(this, _goToDestinationHelper); 679 680 _classPrivateFieldInitSpec(this, _pagesRefCache, { 681 writable: true, 682 value: new Map() 683 }); 684 685 this.eventBus = eventBus; 686 this.externalLinkTarget = externalLinkTarget; 687 this.externalLinkRel = externalLinkRel; 688 this.externalLinkEnabled = true; 689 this._ignoreDestinationZoom = ignoreDestinationZoom; 690 this.baseUrl = null; 691 this.pdfDocument = null; 692 this.pdfViewer = null; 693 this.pdfHistory = null; 694 } 695 696 setDocument(pdfDocument) { 697 let baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 698 this.baseUrl = baseUrl; 699 this.pdfDocument = pdfDocument; 700 701 _classPrivateFieldGet(this, _pagesRefCache).clear(); 702 } 703 704 setViewer(pdfViewer) { 705 this.pdfViewer = pdfViewer; 706 } 707 708 setHistory(pdfHistory) { 709 this.pdfHistory = pdfHistory; 710 } 711 712 get pagesCount() { 713 return this.pdfDocument ? this.pdfDocument.numPages : 0; 714 } 715 716 get page() { 717 return this.pdfViewer.currentPageNumber; 718 } 719 720 set page(value) { 721 this.pdfViewer.currentPageNumber = value; 722 } 723 724 get rotation() { 725 return this.pdfViewer.pagesRotation; 726 } 727 728 set rotation(value) { 729 this.pdfViewer.pagesRotation = value; 730 } 731 732 async goToDestination(dest) { 733 if (!this.pdfDocument) { 734 return; 735 } 736 737 let namedDest, explicitDest; 738 739 if (typeof dest === "string") { 740 namedDest = dest; 741 explicitDest = await this.pdfDocument.getDestination(dest); 742 } else { 743 namedDest = null; 744 explicitDest = await dest; 745 } 746 747 if (!Array.isArray(explicitDest)) { 748 console.error(`PDFLinkService.goToDestination: "${explicitDest}" is not ` + `a valid destination array, for dest="${dest}".`); 749 return; 750 } 751 752 _classPrivateMethodGet(this, _goToDestinationHelper, _goToDestinationHelper2).call(this, dest, namedDest, explicitDest); 753 } 754 755 goToPage(val) { 756 if (!this.pdfDocument) { 757 return; 758 } 759 760 const pageNumber = typeof val === "string" && this.pdfViewer.pageLabelToPageNumber(val) || val | 0; 761 762 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) { 763 console.error(`PDFLinkService.goToPage: "${val}" is not a valid page.`); 764 return; 765 } 766 767 if (this.pdfHistory) { 768 this.pdfHistory.pushCurrentPosition(); 769 this.pdfHistory.pushPage(pageNumber); 770 } 771 772 this.pdfViewer.scrollPageIntoView({ 773 pageNumber 774 }); 775 } 776 777 addLinkAttributes(link, url) { 778 let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 779 addLinkAttributes(link, { 780 url, 781 target: newWindow ? LinkTarget.BLANK : this.externalLinkTarget, 782 rel: this.externalLinkRel, 783 enabled: this.externalLinkEnabled 784 }); 785 } 786 787 getDestinationHash(dest) { 788 if (typeof dest === "string") { 789 if (dest.length > 0) { 790 return this.getAnchorUrl("#" + escape(dest)); 791 } 792 } else if (Array.isArray(dest)) { 793 const str = JSON.stringify(dest); 794 795 if (str.length > 0) { 796 return this.getAnchorUrl("#" + escape(str)); 797 } 798 } 799 800 return this.getAnchorUrl(""); 801 } 802 803 getAnchorUrl(anchor) { 804 return (this.baseUrl || "") + anchor; 805 } 806 807 setHash(hash) { 808 if (!this.pdfDocument) { 809 return; 810 } 811 812 let pageNumber, dest; 813 814 if (hash.includes("=")) {
815 const params = (0, _ui_utils.parseQueryString)(hash); 816 817 if (params.has("search")) { 818 this.eventBus.dispatch("findfromurlhash", { 819 source: this, 820 query: params.get("search").replace(/"/g, ""), 821 phraseSearch: params.get("phrase") === "true" 822 }); 823 } 824 825 if (params.has("page")) { 826 pageNumber = params.get("page") | 0 || 1; 827 } 828 829 if (params.has("zoom")) { 830 const zoomArgs = params.get("zoom").split(","); 831 const zoomArg = zoomArgs[0]; 832 const zoomArgNumber = parseFloat(zoomArg); 833 834 if (!zoomArg.includes("Fit")) { 835 dest = [null, { 836 name: "XYZ" 837 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg]; 838 } else { 839 if (zoomArg === "Fit" || zoomArg === "FitB") { 840 dest = [null, { 841 name: zoomArg 842 }]; 843 } else if (zoomArg === "FitH" || zoomArg === "FitBH" || zoomArg === "FitV" || zoomArg === "FitBV") { 844 dest = [null, { 845 name: zoomArg 846 }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null]; 847 } else if (zoomArg === "FitR") { 848 if (zoomArgs.length !== 5) { 849 console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'); 850 } else { 851 dest = [null, { 852 name: zoomArg 853 }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0]; 854 } 855 } else { 856 console.error(`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`); 857 } 858 } 859 } 860 861 if (dest) { 862 this.pdfViewer.scrollPageIntoView({ 863 pageNumber: pageNumber || this.page, 864 destArray: dest, 865 allowNegativeOffset: true 866 }); 867 } else if (pageNumber) { 868 this.page = pageNumber; 869 } 870 871 if (params.has("pagemode")) { 872 this.eventBus.dispatch("pagemode", { 873 source: this, 874 mode: params.get("pagemode") 875 }); 876 } 877 878 if (params.has("nameddest")) { 879 this.goToDestination(params.get("nameddest")); 880 } 881 } else { 882 dest = unescape(hash); 883 884 try { 885 dest = JSON.parse(dest); 886 887 if (!Array.isArray(dest)) { 888 dest = dest.toString(); 889 } 890 } catch (ex) {} 891 892 if (typeof dest === "string" || _classStaticPrivateMethodGet(PDFLinkService, PDFLinkService, _isValidExplicitDestination).call(PDFLinkService, dest)) { 893 this.goToDestination(dest); 894 return; 895 } 896 897 console.error(`PDFLinkService.setHash: "${unescape(hash)}" is not a valid destination.`); 898 } 899 } 900 901 executeNamedAction(action) { 902 var _this$pdfHistory, _this$pdfHistory2; 903 904 switch (action) { 905 case "GoBack": 906 (_this$pdfHistory = this.pdfHistory) === null || _this$pdfHistory === void 0 ? void 0 : _this$pdfHistory.back(); 907 break; 908 909 case "GoForward": 910 (_this$pdfHistory2 = this.pdfHistory) === null || _this$pdfHistory2 === void 0 ? void 0 : _this$pdfHistory2.forward(); 911 break; 912 913 case "NextPage": 914 this.pdfViewer.nextPage(); 915 break; 916 917 case "PrevPage": 918 this.pdfViewer.previousPage(); 919 break; 920 921 case "LastPage": 922 this.page = this.pagesCount; 923 break; 924 925 case "FirstPage": 926 this.page = 1; 927 break; 928 929 default: 930 break; 931 } 932 933 this.eventBus.dispatch("namedaction", { 934 source: this, 935 action 936 }); 937 } 938 939 cachePageRef(pageNum, pageRef) { 940 if (!pageRef) { 941 return; 942 } 943 944 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`; 945 946 _classPrivateFieldGet(this, _pagesRefCache).set(refStr, pageNum); 947 } 948 949 _cachedPageNumber(pageRef) { 950 if (!pageRef) { 951 return null; 952 } 953 954 const refStr = pageRef.gen === 0 ? `${pageRef.num}R` : `${pageRef.num}R${pageRef.gen}`; 955 return _classPrivateFieldGet(this, _pagesRefCache).get(refStr) || null; 956 } 957 958 isPageVisible(pageNumber) { 959 return this.pdfViewer.isPageVisible(pageNumber); 960 } 961 962 isPageCached(pageNumber) { 963 return this.pdfViewer.isPageCached(pageNumber); 964 } 965 966} 967 968exports.PDFLinkService = PDFLinkService; 969 970function _goToDestinationHelper2(rawDest) { 971 let namedDest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 972 let explicitDest = arguments.length > 2 ? arguments[2] : undefined; 973 const destRef = explicitDest[0]; 974 let pageNumber; 975 976 if (typeof destRef === "object" && destRef !== null) { 977 pageNumber = this._cachedPageNumber(destRef); 978 979 if (!pageNumber) { 980 this.pdfDocument.getPageIndex(destRef).then(pageIndex => { 981 this.cachePageRef(pageIndex + 1, destRef); 982 983 _classPrivateMethodGet(this, _goToDestinationHelper, _goToDestinationHelper2).call(this, rawDest, namedDest, explicitDest); 984 }).catch(() => { 985 console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid page reference, for dest="${rawDest}".`); 986 }); 987 return; 988 } 989 } else if (Number.isInteger(destRef)) { 990 pageNumber = destRef + 1; 991 } else { 992 console.error(`PDFLinkService.#goToDestinationHelper: "${destRef}" is not ` + `a valid destination reference, for dest="${rawDest}".`); 993 return; 994 } 995 996 if (!pageNumber || pageNumber < 1 || pageNumber > this.pagesCount) { 997 console.error(`PDFLinkService.#goToDestinationHelper: "${pageNumber}" is not ` + `a valid page number, for dest="${rawDest}".`); 998 return; 999 } 1000 1001 if (this.pdfHistory) { 1002 this.pdfHistory.pushCurrentPosition(); 1003 this.pdfHistory.push({ 1004 namedDest, 1005 explicitDest, 1006 pageNumber 1007 }); 1008 } 1009 1010 this.pdfViewer.scrollPageIntoView({ 1011 pageNumber, 1012 destArray: explicitDest, 1013 ignoreDestinationZoom: this._ignoreDestinationZoom 1014 }); 1015} 1016 1017function _isValidExplicitDestination(dest) { 1018 if (!Array.isArray(dest)) { 1019 return false;
1020 } 1021 1022 const destLength = dest.length; 1023 1024 if (destLength < 2) { 1025 return false; 1026 } 1027 1028 const page = dest[0]; 1029 1030 if (!(typeof page === "object" && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) { 1031 return false; 1032 } 1033 1034 const zoom = dest[1]; 1035 1036 if (!(typeof zoom === "object" && typeof zoom.name === "string")) { 1037 return false; 1038 } 1039 1040 let allowNull = true; 1041 1042 switch (zoom.name) { 1043 case "XYZ": 1044 if (destLength !== 5) { 1045 return false; 1046 } 1047 1048 break; 1049 1050 case "Fit": 1051 case "FitB": 1052 return destLength === 2; 1053 1054 case "FitH": 1055 case "FitBH": 1056 case "FitV": 1057 case "FitBV": 1058 if (destLength !== 3) { 1059 return false; 1060 } 1061 1062 break; 1063 1064 case "FitR": 1065 if (destLength !== 6) { 1066 return false; 1067 } 1068 1069 allowNull = false; 1070 break; 1071 1072 default: 1073 return false; 1074 } 1075 1076 for (let i = 2; i < destLength; i++) { 1077 const param = dest[i]; 1078 1079 if (!(typeof param === "number" || allowNull && param === null)) { 1080 return false; 1081 } 1082 } 1083 1084 return true; 1085} 1086 1087class SimpleLinkService { 1088 constructor() { 1089 this.externalLinkEnabled = true; 1090 } 1091 1092 get pagesCount() { 1093 return 0; 1094 } 1095 1096 get page() { 1097 return 0; 1098 } 1099 1100 set page(value) {} 1101 1102 get rotation() { 1103 return 0; 1104 } 1105 1106 set rotation(value) {} 1107 1108 async goToDestination(dest) {} 1109 1110 goToPage(val) {} 1111 1112 addLinkAttributes(link, url) { 1113 let newWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 1114 addLinkAttributes(link, { 1115 url, 1116 enabled: this.externalLinkEnabled 1117 }); 1118 } 1119 1120 getDestinationHash(dest) { 1121 return "#"; 1122 } 1123 1124 getAnchorUrl(hash) { 1125 return "#"; 1126 } 1127 1128 setHash(hash) {} 1129 1130 executeNamedAction(action) {} 1131 1132 cachePageRef(pageNum, pageRef) {} 1133 1134 isPageVisible(pageNumber) { 1135 return true; 1136 } 1137 1138 isPageCached(pageNumber) { 1139 return true; 1140 } 1141 1142} 1143 1144exports.SimpleLinkService = SimpleLinkService; 1145 1146/***/ }), 1147/* 7 */ 1148/***/ ((__unused_webpack_module, exports) => { 1149 1150 1151 1152Object.defineProperty(exports, "__esModule", ({ 1153 value: true 1154})); 1155exports.animationStarted = exports.VERTICAL_PADDING = exports.UNKNOWN_SCALE = exports.TextLayerMode = exports.SpreadMode = exports.SidebarView = exports.ScrollMode = exports.SCROLLBAR_PADDING = exports.RenderingStates = exp
1155orts.RendererType = exports.ProgressBar = exports.PresentationModeState = exports.OutputScale = exports.MIN_SCALE = exports.MAX_SCALE = exports.MAX_AUTO_SCALE = exports.DEFAULT_SCALE_VALUE = exports.DEFAULT_SCALE_DELTA = exports.DEFAULT_SCALE = exports.AutoPrintRegExp = void 0; 1156exports.apiPageLayoutToViewerModes = apiPageLayoutToViewerModes; 1157exports.apiPageModeToSidebarView = apiPageModeToSidebarView; 1158exports.approximateFraction = approximateFraction; 1159exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements; 1160exports.binarySearchFirstItem = binarySearchFirstItem; 1161exports.docStyle = void 0; 1162exports.getActiveOrFocusedElement = getActiveOrFocusedElement; 1163exports.getPageSizeInches = getPageSizeInches; 1164exports.getVisibleElements = getVisibleElements; 1165exports.isPortraitOrientation = isPortraitOrientation; 1166exports.isValidRotation = isValidRotation; 1167exports.isValidScrollMode = isValidScrollMode; 1168exports.isValidSpreadMode = isValidSpreadMode; 1169exports.noContextMenuHandler = noContextMenuHandler; 1170exports.normalizeWheelEventDelta = normalizeWheelEventDelta; 1171exports.normalizeWheelEventDirection = normalizeWheelEventDirection; 1172exports.parseQueryString = parseQueryString; 1173exports.removeNullCharacters = removeNullCharacters; 1174exports.roundToDivide = roundToDivide; 1175exports.scrollIntoView = scrollIntoView; 1176exports.watchScroll = watchScroll; 1177 1178function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 1179 1180function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 1181 1182function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 1183 1184function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 1185 1186function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; } 1187 1188function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 1189 1190function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } } 1191 1192const DEFAULT_SCALE_VALUE = "auto"; 1193exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE; 1194const DEFAULT_SCALE = 1.0; 1195exports.DEFAULT_SCALE = DEFAULT_SCALE; 1196const DEFAULT_SCALE_DELTA = 1.1; 1197exports.DEFAULT_SCALE_DELTA = DEFAULT_SCALE_DELTA; 1198const MIN_SCALE = 0.1; 1199exports.MIN_SCALE = MIN_SCALE; 1200const MAX_SCALE = 10.0; 1201exports.MAX_SCALE = MAX_SCALE; 1202const UNKNOWN_SCALE = 0; 1203exports.UNKNOWN_SCALE = UNKNOWN_SCALE; 1204const MAX_AUTO_SCALE = 1.25; 1205exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE; 1206const SCROLLBAR_PADDING = 40; 1207exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING; 1208const VERTICAL_PADDING = 5; 1209exports.VERTICAL_PADDING = VERTICAL_PADDING; 1210const RenderingStates = { 1211 INITIAL: 0, 1212 RUNNING: 1, 1213 PAUSED: 2, 1214 FINISHED: 3 1215}; 1216exports.RenderingStates = RenderingStates; 1217const PresentationModeState = { 1218 UNKNOWN: 0, 1219 NORMAL: 1, 1220 CHANGING: 2, 1221 FULLSCREEN: 3 1222}; 1223exports.PresentationModeState = PresentationModeState; 1224const SidebarView = { 1225 UNKNOWN: -1, 1226 NONE: 0, 1227 THUMBS: 1, 1228 OUTLINE: 2, 1229 ATTACHMENTS: 3, 1230 LAYERS: 4 1231}; 1232exports.SidebarView = SidebarView; 1233const RendererType = { 1234 CANVAS: "canvas", 1235 SVG: "svg" 1236}; 1237exports.RendererType = RendererType; 1238const TextLayerMode = { 1239 DISABLE: 0, 1240 ENABLE: 1, 1241 ENABLE_ENHANCE: 2 1242}; 1243exports.TextLayerMode = TextLayerMode; 1244const ScrollMode = { 1245 UNKNOWN: -1, 1246 VERTICAL: 0, 1247 HORIZONTAL: 1, 1248 WRAPPED: 2, 1249 PAGE: 3 1250}; 1251exports.ScrollMode = ScrollMode; 1252const SpreadMode = { 1253 UNKNOWN: -1, 1254 NONE: 0, 1255 ODD: 1, 1256 EVEN: 2 1257}; 1258exports.SpreadMode = SpreadMode;
1259const AutoPrintRegExp = /\bprint\s*\(/; 1260exports.AutoPrintRegExp = AutoPrintRegExp; 1261 1262class OutputScale { 1263 constructor() { 1264 const pixelRatio = window.devicePixelRatio || 1; 1265 this.sx = pixelRatio; 1266 this.sy = pixelRatio; 1267 } 1268 1269 get scaled() { 1270 return this.sx !== 1 || this.sy !== 1; 1271 } 1272 1273} 1274 1275exports.OutputScale = OutputScale; 1276 1277function scrollIntoView(element, spot) { 1278 let scrollMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 1279 let parent = element.offsetParent; 1280 1281 if (!parent) { 1282 console.error("offsetParent is not set -- cannot scroll"); 1283 return; 1284 } 1285 1286 let offsetY = element.offsetTop + element.clientTop; 1287 let offsetX = element.offsetLeft + element.clientLeft; 1288 1289 while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || scrollMatches && (parent.classList.contains("markedContent") || getComputedStyle(parent).overflow === "hidden")) { 1290 offsetY += parent.offsetTop; 1291 offsetX += parent.offsetLeft; 1292 parent = parent.offsetParent; 1293 1294 if (!parent) { 1295 return; 1296 } 1297 } 1298 1299 if (spot) { 1300 if (spot.top !== undefined) { 1301 offsetY += spot.top; 1302 } 1303 1304 if (spot.left !== undefined) { 1305 offsetX += spot.left; 1306 parent.scrollLeft = offsetX; 1307 } 1308 } 1309 1310 parent.scrollTop = offsetY; 1311} 1312 1313function watchScroll(viewAreaElement, callback) { 1314 const debounceScroll = function (evt) { 1315 if (rAF) { 1316 return; 1317 } 1318 1319 rAF = window.requestAnimationFrame(function viewAreaElementScrolled() { 1320 rAF = null; 1321 const currentX = viewAreaElement.scrollLeft; 1322 const lastX = state.lastX; 1323 1324 if (currentX !== lastX) { 1325 state.right = currentX > lastX; 1326 } 1327 1328 state.lastX = currentX; 1329 const currentY = viewAreaElement.scrollTop; 1330 const lastY = state.lastY; 1331 1332 if (currentY !== lastY) { 1333 state.down = currentY > lastY; 1334 } 1335 1336 state.lastY = currentY; 1337 callback(state); 1338 }); 1339 }; 1340 1341 const state = { 1342 right: true, 1343 down: true, 1344 lastX: viewAreaElement.scrollLeft, 1345 lastY: viewAreaElement.scrollTop, 1346 _eventHandler: debounceScroll 1347 }; 1348 let rAF = null; 1349 viewAreaElement.addEventListener("scroll", debounceScroll, true); 1350 return state; 1351} 1352 1353function parseQueryString(query) { 1354 const params = new Map(); 1355 1356 for (const [key, value] of new URLSearchParams(query)) { 1357 params.set(key.toLowerCase(), value); 1358 } 1359 1360 return params; 1361} 1362 1363const NullCharactersRegExp = /\x00/g; 1364const InvisibleCharactersRegExp = /[\x01-\x1F]/g; 1365 1366function removeNullCharacters(str) { 1367 let replaceInvisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 1368 1369 if (typeof str !== "string") { 1370 console.error(`The argument must be a string.`); 1371 return str; 1372 } 1373 1374 if (replaceInvisible) { 1375 str = str.replace(InvisibleCharactersRegExp, " "); 1376 } 1377 1378 return str.replace(NullCharactersRegExp, ""); 1379} 1380 1381function binarySearchFirstItem(items, condition) { 1382 let start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; 1383 let minIndex = start; 1384 let maxIndex = items.length - 1; 1385 1386 if (maxIndex < 0 || !condition(items[maxIndex])) { 1387 return items.length; 1388 } 1389 1390 if (condition(items[minIndex])) { 1391 return minIndex; 1392 } 1393 1394 while (minIndex < maxIndex) { 1395 const currentIndex = minIndex + maxIndex >> 1; 1396 const currentItem = items[currentIndex]; 1397 1398 if (condition(currentItem)) { 1399 maxIndex = currentIndex; 1400 } else { 1401 minIndex = currentIndex + 1; 1402 } 1403 } 1404 1405 return minIndex; 1406} 1407 1408function approximateFraction(x) { 1409 if (Math.floor(x) === x) { 1410 return [x, 1]; 1411 } 1412 1413 const xinv = 1 / x; 1414 const limit = 8; 1415 1416 if (xinv > limit) { 1417 return [1, limit]; 1418 } else if (Math.floor(xinv) === xinv) { 1419 return [1, xinv]; 1420 } 1421 1422 const x_ = x > 1 ? xinv : x; 1423 let a = 0, 1424 b = 1, 1425 c = 1, 1426 d = 1; 1427 1428 while (true) { 1429 const p = a + c, 1430 q = b + d; 1431 1432 if (q > limit) { 1433 break; 1434 } 1435 1436 if (x_ <= p / q) { 1437 c = p; 1438 d = q; 1439 } else { 1440 a = p; 1441 b = q; 1442 } 1443 } 1444 1445 let result; 1446 1447 if (x_ - a / b < c / d - x_) { 1448 result = x_ === x ? [a, b] : [b, a]; 1449 } else { 1450 result = x_ === x ? [c, d] : [d, c]; 1451 } 1452 1453 return result; 1454} 1455 1456function roundToDivide(x, div) { 1457 const r = x % div; 1458 return r === 0 ? x : Math.round(x - r + div); 1459} 1460 1461function getPageSizeInches(_ref) { 1462 let { 1463 view, 1464 userUnit, 1465 rotate 1466 } = _ref; 1467 const [x1, y1, x2, y2] = view; 1468 const changeOrientation = rotate % 180 !== 0; 1469 const width = (x2 - x1) / 72 * userUnit; 1470 const height = (y2 - y1) / 72 * userUnit; 1471 return { 1472 width: changeOrientation ? height : width, 1473 height: changeOrientation ? width : height 1474 }; 1475} 1476 1477function backtrackBeforeAllVisibleElements(index, views, top) { 1478 if (index < 2) { 1479 return index; 1480 } 1481 1482 let elt = views[index].div; 1483 let pageTop = elt.offsetTop + elt.clientTop; 1484 1485 if (pageTop >= top) { 1486 elt = views[index - 1].div; 1487 pageTop = elt.offsetTop + elt.clientTop; 1488 } 1489 1490 for (let i = index - 2; i >= 0; --i) { 1491 elt = views[i].div; 1492 1493 if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) { 1494 break; 1495 } 1496 1497 index = i; 1498 } 1499 1500 return index; 1501} 1502 1503function getVisibleElements(_ref2) { 1504 let { 1505 scrollEl, 1506 views, 1507 sortByVisibility = false, 1508 horizontal = false, 1509 rtl = false 1510 }
1510 = _ref2; 1511 const top = scrollEl.scrollTop, 1512 bottom = top + scrollEl.clientHeight; 1513 const left = scrollEl.scrollLeft, 1514 right = left + scrollEl.clientWidth; 1515 1516 function isElementBottomAfterViewTop(view) { 1517 const element = view.div; 1518 const elementBottom = element.offsetTop + element.clientTop + element.clientHeight; 1519 return elementBottom > top; 1520 } 1521 1522 function isElementNextAfterViewHorizontally(view) { 1523 const element = view.div; 1524 const elementLeft = element.offsetLeft + element.clientLeft; 1525 const elementRight = elementLeft + element.clientWidth; 1526 return rtl ? elementLeft < right : elementRight > left; 1527 } 1528 1529 const visible = [], 1530 ids = new Set(), 1531 numViews = views.length; 1532 let firstVisibleElementInd = binarySearchFirstItem(views, horizontal ? isElementNextAfterViewHorizontally : isElementBottomAfterViewTop); 1533 1534 if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) { 1535 firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top); 1536 } 1537 1538 let lastEdge = horizontal ? right : -1; 1539 1540 for (let i = firstVisibleElementInd; i < numViews; i++) { 1541 const view = views[i], 1542 element = view.div; 1543 const currentWidth = element.offsetLeft + element.clientLeft; 1544 const currentHeight = element.offsetTop + element.clientTop; 1545 const viewWidth = element.clientWidth, 1546 viewHeight = element.clientHeight; 1547 const viewRight = currentWidth + viewWidth; 1548 const viewBottom = currentHeight + viewHeight; 1549 1550 if (lastEdge === -1) { 1551 if (viewBottom >= bottom) { 1552 lastEdge = viewBottom; 1553 } 1554 } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) { 1555 break; 1556 } 1557 1558 if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) { 1559 continue; 1560 } 1561 1562 const hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom); 1563 const hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right); 1564 const fractionHeight = (viewHeight - hiddenHeight) / viewHeight, 1565 fractionWidth = (viewWidth - hiddenWidth) / viewWidth; 1566 const percent = fractionHeight * fractionWidth * 100 | 0; 1567 visible.push({ 1568 id: view.id, 1569 x: currentWidth, 1570 y: currentHeight, 1571 view, 1572 percent, 1573 widthPercent: fractionWidth * 100 | 0 1574 }); 1575 ids.add(view.id); 1576 } 1577 1578 const first = visible[0], 1579 last = visible.at(-1); 1580 1581 if (sortByVisibility) { 1582 visible.sort(function (a, b) { 1583 const pc = a.percent - b.percent; 1584 1585 if (Math.abs(pc) > 0.001) { 1586 return -pc; 1587 } 1588 1589 return a.id - b.id; 1590 }); 1591 } 1592 1593 return { 1594 first, 1595 last, 1596 views: visible, 1597 ids 1598 }; 1599} 1600 1601function noContextMenuHandler(evt) { 1602 evt.preventDefault(); 1603} 1604 1605function normalizeWheelEventDirection(evt) { 1606 let delta = Math.hypot(evt.deltaX, evt.deltaY); 1607 const angle = Math.atan2(evt.deltaY, evt.deltaX); 1608 1609 if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) { 1610 delta = -delta; 1611 } 1612 1613 return delta; 1614} 1615 1616function normalizeWheelEventDelta(evt) { 1617 let delta = normalizeWheelEventDirection(evt); 1618 const MOUSE_DOM_DELTA_PIXEL_MODE = 0; 1619 const MOUSE_DOM_DELTA_LINE_MODE = 1; 1620 const MOUSE_PIXELS_PER_LINE = 30; 1621 const MOUSE_LINES_PER_PAGE = 30; 1622 1623 if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) { 1624 delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE; 1625 } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) { 1626 delta /= MOUSE_LINES_PER_PAGE; 1627 } 1628 1629 return delta; 1630} 1631 1632function isValidRotation(angle) { 1633 return Number.isInteger(angle) && angle % 90 === 0; 1634} 1635 1636function isValidScrollMode(mode) { 1637 return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN; 1638} 1639 1640function isValidSpreadMode(mode) { 1641 return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN; 1642} 1643 1644function isPortraitOrientation(size) { 1645 return size.width <= size.height; 1646} 1647 1648const animationStarted = new Promise(function (resolve) { 1649 window.requestAnimationFrame(resolve); 1650}); 1651exports.animationStarted = animationStarted; 1652const docStyle = document.documentElement.style; 1653exports.docStyle = docStyle; 1654 1655function clamp(v, min, max) { 1656 return Math.min(Math.max(v, min), max); 1657} 1658 1659var _classList = /*#__PURE__*/new WeakMap(); 1660 1661var _percent = /*#__PURE__*/new WeakMap(); 1662 1663var _visible = /*#__PURE__*/new WeakMap(); 1664 1665class ProgressBar { 1666 constructor(id) { 1667 _classPrivateFieldInitSpec(this, _classList, { 1668 writable: true, 1669 value: null 1670 }); 1671 1672 _classPrivateFieldInitSpec(this, _percent, { 1673 writable: true, 1674 value: 0 1675 }); 1676 1677 _classPrivateFieldInitSpec(this, _visible, { 1678 writable: true, 1679 value: true 1680 }); 1681 1682 if (arguments.length > 1) { 1683 throw new Error("ProgressBar no longer accepts any additional options, " + "please use CSS rules to modify its appearance instead."); 1684 } 1685 1686 const bar = document.getElementById(id); 1687 1688 _classPrivateFieldSet(this, _classList, bar.classList); 1689 } 1690 1691 get percent() { 1692 return _classPrivateFieldGet(this, _percent); 1693 } 1694 1695 set percent(val) { 1696 _classPrivateFieldSet(this, _percent, clamp(val, 0, 100)); 1697 1698 if (isNaN(val)) { 1699 _classPrivateFieldGet(this, _classList).add("indeterminate"); 1700 1701 return; 1702 } 1703 1704 _classPrivateFieldGet(this, _classList).remove("indeterminate"); 1705 1706 docStyle.setProperty("--progressBar-percent", `${_classPrivateFieldGet(this, _percent)}
1706%`); 1707 } 1708 1709 setWidth(viewer) { 1710 if (!viewer) { 1711 return; 1712 } 1713 1714 const container = viewer.parentNode; 1715 const scrollbarWidth = container.offsetWidth - viewer.offsetWidth; 1716 1717 if (scrollbarWidth > 0) { 1718 docStyle.setProperty("--progressBar-end-offset", `${scrollbarWidth}px`); 1719 } 1720 } 1721 1722 hide() { 1723 if (!_classPrivateFieldGet(this, _visible)) { 1724 return; 1725 } 1726 1727 _classPrivateFieldSet(this, _visible, false); 1728 1729 _classPrivateFieldGet(this, _classList).add("hidden"); 1730 } 1731 1732 show() { 1733 if (_classPrivateFieldGet(this, _visible)) { 1734 return; 1735 } 1736 1737 _classPrivateFieldSet(this, _visible, true); 1738 1739 _classPrivateFieldGet(this, _classList).remove("hidden"); 1740 } 1741 1742} 1743 1744exports.ProgressBar = ProgressBar; 1745 1746function getActiveOrFocusedElement() { 1747 let curRoot = document; 1748 let curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus"); 1749 1750 while ((_curActiveOrFocused = curActiveOrFocused) !== null && _curActiveOrFocused !== void 0 && _curActiveOrFocused.shadowRoot) { 1751 var _curActiveOrFocused; 1752 1753 curRoot = curActiveOrFocused.shadowRoot; 1754 curActiveOrFocused = curRoot.activeElement || curRoot.querySelector(":focus"); 1755 } 1756 1757 return curActiveOrFocused; 1758} 1759 1760function apiPageLayoutToViewerModes(layout) { 1761 let scrollMode = ScrollMode.VERTICAL, 1762 spreadMode = SpreadMode.NONE; 1763 1764 switch (layout) { 1765 case "SinglePage": 1766 scrollMode = ScrollMode.PAGE; 1767 break; 1768 1769 case "OneColumn": 1770 break; 1771 1772 case "TwoPageLeft": 1773 scrollMode = ScrollMode.PAGE; 1774 1775 case "TwoColumnLeft": 1776 spreadMode = SpreadMode.ODD; 1777 break; 1778 1779 case "TwoPageRight": 1780 scrollMode = ScrollMode.PAGE; 1781 1782 case "TwoColumnRight": 1783 spreadMode = SpreadMode.EVEN; 1784 break; 1785 } 1786 1787 return { 1788 scrollMode, 1789 spreadMode 1790 }; 1791} 1792 1793function apiPageModeToSidebarView(mode) { 1794 switch (mode) { 1795 case "UseNone": 1796 return SidebarView.NONE; 1797 1798 case "UseThumbs": 1799 return SidebarView.THUMBS; 1800 1801 case "UseOutlines": 1802 return SidebarView.OUTLINE; 1803 1804 case "UseAttachments": 1805 return SidebarView.ATTACHMENTS; 1806 1807 case "UseOC": 1808 return SidebarView.LAYERS; 1809 } 1810 1811 return SidebarView.NONE; 1812} 1813 1814/***/ }), 1815/* 8 */ 1816/***/ ((__unused_webpack_module, exports) => { 1817 1818 1819 1820Object.defineProperty(exports, "__esModule", ({ 1821 value: true 1822})); 1823exports.StructTreeLayerBuilder = void 0; 1824const PDF_ROLE_TO_HTML_ROLE = { 1825 Document: null, 1826 DocumentFragment: null, 1827 Part: "group", 1828 Sect: "group", 1829 Div: "group", 1830 Aside: "note", 1831 NonStruct: "none", 1832 P: null, 1833 H: "heading", 1834 Title: null, 1835 FENote: "note", 1836 Sub: "group", 1837 Lbl: null, 1838 Span: null, 1839 Em: null, 1840 Strong: null, 1841 Link: "link", 1842 Annot: "note", 1843 Form: "form", 1844 Ruby: null, 1845 RB: null, 1846 RT: null, 1847 RP: null, 1848 Warichu: null, 1849 WT: null, 1850 WP: null, 1851 L: "list", 1852 LI: "listitem", 1853 LBody: null, 1854 Table: "table", 1855 TR: "row", 1856 TH: "columnheader", 1857 TD: "cell", 1858 THead: "columnheader", 1859 TBody: null, 1860 TFoot: null, 1861 Caption: null, 1862 Figure: "figure", 1863 Formula: null, 1864 Artifact: null 1865}; 1866const HEADING_PATTERN = /^H(\d+)$/; 1867 1868class StructTreeLayerBuilder { 1869 constructor(_ref) { 1870 let { 1871 pdfPage 1872 } = _ref; 1873 this.pdfPage = pdfPage; 1874 } 1875 1876 render(structTree) { 1877 return this._walk(structTree); 1878 } 1879 1880 _setAttributes(structElement, htmlElement) { 1881 if (structElement.alt !== undefined) { 1882 htmlElement.setAttribute("aria-label", structElement.alt); 1883 } 1884 1885 if (structElement.id !== undefined) { 1886 htmlElement.setAttribute("aria-owns", structElement.id); 1887 } 1888 1889 if (structElement.lang !== undefined) { 1890 htmlElement.setAttribute("lang", structElement.lang); 1891 } 1892 } 1893 1894 _walk(node) { 1895 if (!node) { 1896 return null; 1897 } 1898 1899 const element = document.createElement("span"); 1900 1901 if ("role" in node) { 1902 const { 1903 role 1904 } = node; 1905 const match = role.match(HEADING_PATTERN); 1906 1907 if (match) { 1908 element.setAttribute("role", "heading"); 1909 element.setAttribute("aria-level", match[1]); 1910 } else if (PDF_ROLE_TO_HTML_ROLE[role]) { 1911 element.setAttribute("role", PDF_ROLE_TO_HTML_ROLE[role]); 1912 } 1913 } 1914 1915 this._setAttributes(node, element); 1916 1917 if (node.children) { 1918 if (node.children.length === 1 && "id" in node.children[0]) { 1919 this._setAttributes(node.children[0], element); 1920 } else { 1921 for (const kid of node.children) { 1922 element.append(this._walk(kid)); 1923 } 1924 } 1925 } 1926 1927 return element; 1928 } 1929 1930} 1931 1932exports.StructTreeLayerBuilder = StructTreeLayerBuilder; 1933 1934/***/ }), 1935/* 9 */ 1936/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 1937 1938 1939 1940Object.defineProperty(exports, "__esModule", ({ 1941 value: true 1942})); 1943exports.TextLayerBuilder = void 0; 1944 1945var _pdfjsLib = __w_pdfjs_require__(3); 1946 1947const EXPAND_DIVS_TIMEOUT = 300; 1948 1949class TextLayerBuilder { 1950 constructor(_ref) { 1951 let { 1952 textLayerDiv, 1953 eventBus, 1954 pageIndex, 1955 viewport, 1956 highlighter = null, 1957 enhanceTextSelection = false, 1958 accessibilityManager = null 1959 } = _ref; 1960 this.textLayerDiv = textLayerDiv; 1961 this.eventBus = eventBus; 1962 this.textContent = null; 1963 this.textContentItemsStr = []; 1964 this.textContentStream = null; 1965 this.renderingDone = false;
1966 this.pageNumber = pageIndex + 1; 1967 this.viewport = viewport; 1968 this.textDivs = []; 1969 this.textLayerRenderTask = null; 1970 this.highlighter = highlighter; 1971 this.enhanceTextSelection = enhanceTextSelection; 1972 this.accessibilityManager = accessibilityManager; 1973 1974 this._bindMouse(); 1975 } 1976 1977 _finishRendering() { 1978 this.renderingDone = true; 1979 1980 if (!this.enhanceTextSelection) { 1981 const endOfContent = document.createElement("div"); 1982 endOfContent.className = "endOfContent"; 1983 this.textLayerDiv.append(endOfContent); 1984 } 1985 1986 this.eventBus.dispatch("textlayerrendered", { 1987 source: this, 1988 pageNumber: this.pageNumber, 1989 numTextDivs: this.textDivs.length 1990 }); 1991 } 1992 1993 render() { 1994 var _this$highlighter, _this$accessibilityMa; 1995 1996 let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; 1997 1998 if (!(this.textContent || this.textContentStream) || this.renderingDone) { 1999 return; 2000 } 2001 2002 this.cancel(); 2003 this.textDivs.length = 0; 2004 (_this$highlighter = this.highlighter) === null || _this$highlighter === void 0 ? void 0 : _this$highlighter.setTextMapping(this.textDivs, this.textContentItemsStr); 2005 (_this$accessibilityMa = this.accessibilityManager) === null || _this$accessibilityMa === void 0 ? void 0 : _this$accessibilityMa.setTextMapping(this.textDivs); 2006 const textLayerFrag = document.createDocumentFragment(); 2007 this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({ 2008 textContent: this.textContent, 2009 textContentStream: this.textContentStream, 2010 container: textLayerFrag, 2011 viewport: this.viewport, 2012 textDivs: this.textDivs, 2013 textContentItemsStr: this.textContentItemsStr, 2014 timeout, 2015 enhanceTextSelection: this.enhanceTextSelection 2016 }); 2017 this.textLayerRenderTask.promise.then(() => { 2018 var _this$highlighter2, _this$accessibilityMa2; 2019 2020 this.textLayerDiv.append(textLayerFrag); 2021 2022 this._finishRendering(); 2023 2024 (_this$highlighter2 = this.highlighter) === null || _this$highlighter2 === void 0 ? void 0 : _this$highlighter2.enable(); 2025 (_this$accessibilityMa2 = this.accessibilityManager) === null || _this$accessibilityMa2 === void 0 ? void 0 : _this$accessibilityMa2.enable(); 2026 }, function (reason) {}); 2027 } 2028 2029 cancel() { 2030 var _this$highlighter3, _this$accessibilityMa3; 2031 2032 if (this.textLayerRenderTask) { 2033 this.textLayerRenderTask.cancel(); 2034 this.textLayerRenderTask = null; 2035 } 2036 2037 (_this$highlighter3 = this.highlighter) === null || _this$highlighter3 === void 0 ? void 0 : _this$highlighter3.disable(); 2038 (_this$accessibilityMa3 = this.accessibilityManager) === null || _this$accessibilityMa3 === void 0 ? void 0 : _this$accessibilityMa3.disable(); 2039 } 2040 2041 setTextContentStream(readableStream) { 2042 this.cancel(); 2043 this.textContentStream = readableStream; 2044 } 2045 2046 setTextContent(textContent) { 2047 this.cancel(); 2048 this.textContent = textContent; 2049 } 2050 2051 _bindMouse() { 2052 const div = this.textLayerDiv; 2053 let expandDivsTimer = null; 2054 div.addEventListener("mousedown", evt => { 2055 if (this.enhanceTextSelection && this.textLayerRenderTask) { 2056 this.textLayerRenderTask.expandTextDivs(true); 2057 2058 if (expandDivsTimer) { 2059 clearTimeout(expandDivsTimer); 2060 expandDivsTimer = null; 2061 } 2062 2063 return; 2064 } 2065 2066 const end = div.querySelector(".endOfContent"); 2067 2068 if (!end) { 2069 return; 2070 } 2071 2072 let adjustTop = evt.target !== div; 2073 adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue("-moz-user-select") !== "none"; 2074 2075 if (adjustTop) { 2076 const divBounds = div.getBoundingClientRect(); 2077 const r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height); 2078 end.style.top = (r * 100).toFixed(2) + "%"; 2079 } 2080 2081 end.classList.add("active"); 2082 }); 2083 div.addEventListener("mouseup", () => { 2084 if (this.enhanceTextSelection && this.textLayerRenderTask) { 2085 expandDivsTimer = setTimeout(() => { 2086 if (this.textLayerRenderTask) { 2087 this.textLayerRenderTask.expandTextDivs(false); 2088 } 2089 2090 expandDivsTimer = null; 2091 }, EXPAND_DIVS_TIMEOUT); 2092 return; 2093 } 2094 2095 const end = div.querySelector(".endOfContent"); 2096 2097 if (!end) { 2098 return; 2099 } 2100 2101 end.style.top = ""; 2102 end.classList.remove("active"); 2103 }); 2104 } 2105 2106} 2107 2108exports.TextLayerBuilder = TextLayerBuilder; 2109 2110/***/ }), 2111/* 10 */ 2112/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 2113 2114 2115 2116Object.defineProperty(exports, "__esModule", ({ 2117 value: true 2118})); 2119exports.XfaLayerBuilder = void 0; 2120 2121var _pdfjsLib = __w_pdfjs_require__(3); 2122 2123class XfaLayerBuilder { 2124 constructor(_ref) { 2125 let { 2126 pageDiv, 2127 pdfPage, 2128 annotationStorage = null, 2129 linkService, 2130 xfaHtml = null 2131 } = _ref; 2132 this.pageDiv = pageDiv; 2133 this.pdfPage = pdfPage; 2134 this.annotationStorage = annotationStorage; 2135 this.linkService = linkService; 2136 this.xfaHtml = xfaHtml; 2137 this.div = null; 2138 this._cancelled = false;
2139 } 2140 2141 render(viewport) { 2142 let intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "display"; 2143 2144 if (intent === "print") { 2145 const parameters = { 2146 viewport: viewport.clone({ 2147 dontFlip: true 2148 }), 2149 div: this.div, 2150 xfaHtml: this.xfaHtml, 2151 annotationStorage: this.annotationStorage, 2152 linkService: this.linkService, 2153 intent 2154 }; 2155 const div = document.createElement("div"); 2156 this.pageDiv.append(div); 2157 parameters.div = div; 2158 2159 const result = _pdfjsLib.XfaLayer.render(parameters); 2160 2161 return Promise.resolve(result); 2162 } 2163 2164 return this.pdfPage.getXfa().then(xfaHtml => { 2165 if (this._cancelled || !xfaHtml) { 2166 return { 2167 textDivs: [] 2168 }; 2169 } 2170 2171 const parameters = { 2172 viewport: viewport.clone({ 2173 dontFlip: true 2174 }), 2175 div: this.div, 2176 xfaHtml, 2177 annotationStorage: this.annotationStorage, 2178 linkService: this.linkService, 2179 intent 2180 }; 2181 2182 if (this.div) { 2183 return _pdfjsLib.XfaLayer.update(parameters); 2184 } 2185 2186 this.div = document.createElement("div"); 2187 this.pageDiv.append(this.div); 2188 parameters.div = this.div; 2189 return _pdfjsLib.XfaLayer.render(parameters); 2190 }).catch(error => { 2191 console.error(error); 2192 }); 2193 } 2194 2195 cancel() { 2196 this._cancelled = true; 2197 } 2198 2199 hide() { 2200 if (!this.div) { 2201 return; 2202 } 2203 2204 this.div.hidden = true; 2205 } 2206 2207} 2208 2209exports.XfaLayerBuilder = XfaLayerBuilder; 2210 2211/***/ }), 2212/* 11 */ 2213/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 2214 2215 2216 2217Object.defineProperty(exports, "__esModule", ({ 2218 value: true 2219})); 2220exports.PDFViewer = exports.PDFSinglePageViewer = void 0; 2221 2222var _ui_utils = __w_pdfjs_require__(7); 2223 2224var _base_viewer = __w_pdfjs_require__(12); 2225 2226class PDFViewer extends _base_viewer.BaseViewer {} 2227 2228exports.PDFViewer = PDFViewer; 2229 2230class PDFSinglePageViewer extends _base_viewer.BaseViewer { 2231 _resetView() { 2232 super._resetView(); 2233 2234 this._scrollMode = _ui_utils.ScrollMode.PAGE; 2235 this._spreadMode = _ui_utils.SpreadMode.NONE; 2236 } 2237 2238 set scrollMode(mode) {} 2239 2240 _updateScrollMode() {} 2241 2242 set spreadMode(mode) {} 2243 2244 _updateSpreadMode() {} 2245 2246} 2247 2248exports.PDFSinglePageViewer = PDFSinglePageViewer; 2249 2250/***/ }), 2251/* 12 */ 2252/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 2253 2254 2255 2256Object.defineProperty(exports, "__esModule", ({ 2257 value: true 2258})); 2259exports.PagesCountLimit = exports.PDFPageViewBuffer = exports.BaseViewer = void 0; 2260 2261var _pdfjsLib = __w_pdfjs_require__(3); 2262 2263var _ui_utils = __w_pdfjs_require__(7); 2264 2265var _annotation_editor_layer_builder = __w_pdfjs_require__(2); 2266 2267var _annotation_layer_builder = __w_pdfjs_require__(5); 2268 2269var _l10n_utils = __w_pdfjs_require__(4); 2270 2271var _pdf_page_view = __w_pdfjs_require__(13); 2272 2273var _pdf_rendering_queue = __w_pdfjs_require__(16); 2274 2275var _pdf_link_service = __w_pdfjs_require__(6); 2276 2277var _struct_tree_layer_builder = __w_pdfjs_require__(8); 2278 2279var _text_highlighter = __w_pdfjs_require__(17); 2280 2281var _text_layer_builder = __w_pdfjs_require__(9); 2282 2283var _xfa_layer_builder = __w_pdfjs_require__(10); 2284 2285let _Symbol$iterator; 2286 2287function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 2288 2289function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 2290 2291function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 2292 2293function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 2294 2295function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 2296 2297function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 2298 2299function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; } 2300 2301function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 2302 2303function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } } 2304 2305const DEFAULT_CACHE_SIZE = 10; 2306const ENABLE_PERMISSIONS_CLASS = "enablePermissions"; 2307const PagesCountLimit = { 2308 FORCE_SCROLL_MODE_PAGE: 15000, 2309 FORCE_LAZY_PAGE_INIT: 7500, 2310 PAUSE_EAGER_PAGE_INIT: 250 2311}; 2312exports.PagesCountLimit = PagesCountLimit; 2313 2314function isValidAnnotationEditorMode(mode) { 2315 return Object.values(_pdfjsLib.AnnotationEditorType).includes(mode) && mode !== _pdfjsLib.AnnotationEditorType.DISABLE; 2316} 2317 2318var _buf = /*#__PURE__*/new WeakMap(); 2319 2320var _size = /*#__PURE__*/new WeakMap(); 2321 2322var _destroyFirstView = /*#__PURE__*/new WeakSet(); 2323 2324_Symbol$iterator = Symbol.iterator; 2325 2326class PDFPageViewBuffer {
2327 constructor(size) { 2328 _classPrivateMethodInitSpec(this, _destroyFirstView); 2329 2330 _classPrivateFieldInitSpec(this, _buf, { 2331 writable: true, 2332 value: new Set() 2333 }); 2334 2335 _classPrivateFieldInitSpec(this, _size, { 2336 writable: true, 2337 value: 0 2338 }); 2339 2340 _classPrivateFieldSet(this, _size, size); 2341 } 2342 2343 push(view) { 2344 const buf = _classPrivateFieldGet(this, _buf); 2345 2346 if (buf.has(view)) { 2347 buf.delete(view); 2348 } 2349 2350 buf.add(view); 2351 2352 if (buf.size > _classPrivateFieldGet(this, _size)) { 2353 _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(this); 2354 } 2355 } 2356 2357 resize(newSize) { 2358 let idsToKeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 2359 2360 _classPrivateFieldSet(this, _size, newSize); 2361 2362 const buf = _classPrivateFieldGet(this, _buf); 2363 2364 if (idsToKeep) { 2365 const ii = buf.size; 2366 let i = 1; 2367 2368 for (const view of buf) { 2369 if (idsToKeep.has(view.id)) { 2370 buf.delete(view); 2371 buf.add(view); 2372 } 2373 2374 if (++i > ii) { 2375 break; 2376 } 2377 } 2378 } 2379 2380 while (buf.size > _classPrivateFieldGet(this, _size)) { 2381 _classPrivateMethodGet(this, _destroyFirstView, _destroyFirstView2).call(this); 2382 } 2383 } 2384 2385 has(view) { 2386 return _classPrivateFieldGet(this, _buf).has(view); 2387 } 2388 2389 [_Symbol$iterator]() { 2390 return _classPrivateFieldGet(this, _buf).keys(); 2391 } 2392 2393} 2394 2395exports.PDFPageViewBuffer = PDFPageViewBuffer; 2396 2397function _destroyFirstView2() { 2398 const firstView = _classPrivateFieldGet(this, _buf).keys().next().value; 2399 2400 firstView === null || firstView === void 0 ? void 0 : firstView.destroy(); 2401 2402 _classPrivateFieldGet(this, _buf).delete(firstView); 2403} 2404 2405var _buffer = /*#__PURE__*/new WeakMap(); 2406 2407var _annotationEditorMode = /*#__PURE__*/new WeakMap(); 2408 2409var _annotationEditorUIManager = /*#__PURE__*/new WeakMap(); 2410 2411var _annotationMode = /*#__PURE__*/new WeakMap(); 2412 2413var _enablePermissions = /*#__PURE__*/new WeakMap(); 2414 2415var _previousContainerHeight = /*#__PURE__*/new WeakMap(); 2416 2417var _scrollModePageState = /*#__PURE__*/new WeakMap(); 2418 2419var _onVisibilityChange = /*#__PURE__*/new WeakMap(); 2420 2421var _initializePermissions = /*#__PURE__*/new WeakSet(); 2422 2423var _onePageRenderedOrForceFetch = /*#__PURE__*/new WeakSet(); 2424 2425var _ensurePageViewVisible = /*#__PURE__*/new WeakSet(); 2426 2427var _scrollIntoView = /*#__PURE__*/new WeakSet(); 2428 2429var _isSameScale = /*#__PURE__*/new WeakSet(); 2430 2431var _resetCurrentPageView = /*#__PURE__*/new WeakSet(); 2432 2433var _ensurePdfPageLoaded = /*#__PURE__*/new WeakSet(); 2434 2435var _getScrollAhead = /*#__PURE__*/new WeakSet(); 2436 2437var _toggleLoadingIconSpinner = /*#__PURE__*/new WeakSet(); 2438 2439class BaseViewer { 2440 constructor(options) { 2441 var _this$container, _this$viewer, _options$textLayerMod, _options$annotationMo, _options$annotationEd; 2442 2443 _classPrivateMethodInitSpec(this, _toggleLoadingIconSpinner); 2444 2445 _classPrivateMethodInitSpec(this, _getScrollAhead); 2446 2447 _classPrivateMethodInitSpec(this, _ensurePdfPageLoaded); 2448 2449 _classPrivateMethodInitSpec(this, _resetCurrentPageView); 2450 2451 _classPrivateMethodInitSpec(this, _isSameScale); 2452 2453 _classPrivateMethodInitSpec(this, _scrollIntoView); 2454 2455 _classPrivateMethodInitSpec(this, _ensurePageViewVisible); 2456 2457 _classPrivateMethodInitSpec(this, _onePageRenderedOrForceFetch); 2458 2459 _classPrivateMethodInitSpec(this, _initializePermissions); 2460 2461 _classPrivateFieldInitSpec(this, _buffer, { 2462 writable: true, 2463 value: null 2464 }); 2465 2466 _classPrivateFieldInitSpec(this, _annotationEditorMode, { 2467 writable: true, 2468 value: _pdfjsLib.AnnotationEditorType.DISABLE 2469 }); 2470 2471 _classPrivateFieldInitSpec(this, _annotationEditorUIManager, { 2472 writable: true, 2473 value: null 2474 }); 2475 2476 _classPrivateFieldInitSpec(this, _annotationMode, { 2477 writable: true, 2478 value: _pdfjsLib.AnnotationMode.ENABLE_FORMS 2479 }); 2480 2481 _classPrivateFieldInitSpec(this, _enablePermissions, { 2482 writable: true, 2483 value: false 2484 }); 2485 2486 _classPrivateFieldInitSpec(this, _previousContainerHeight, { 2487 writable: true, 2488 value: 0 2489 }); 2490 2491 _classPrivateFieldInitSpec(this, _scrollModePageState, { 2492 writable: true, 2493 value: null 2494 }); 2495 2496 _classPrivateFieldInitSpec(this, _onVisibilityChange, { 2497 writable: true, 2498 value: null 2499 }); 2500 2501 if (this.constructor === BaseViewer) { 2502 throw new Error("Cannot initialize BaseViewer."); 2503 } 2504 2505 const viewerVersion = '2.16.105'; 2506
2507 if (_pdfjsLib.version !== viewerVersion) { 2508 throw new Error(`The API version "${_pdfjsLib.version}" does not match the Viewer version "${viewerVersion}".`); 2509 } 2510 2511 this.container = options.container; 2512 this.viewer = options.viewer || options.container.firstElementChild; 2513 2514 if (!(((_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.tagName.toUpperCase()) === "DIV" && ((_this$viewer = this.viewer) === null || _this$viewer === void 0 ? void 0 : _this$viewer.tagName.toUpperCase()) === "DIV")) { 2515 throw new Error("Invalid `container` and/or `viewer` option."); 2516 } 2517 2518 if (this.container.offsetParent && getComputedStyle(this.container).position !== "absolute") { 2519 throw new Error("The `container` must be absolutely positioned."); 2520 } 2521 2522 this.eventBus = options.eventBus; 2523 this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService(); 2524 this.downloadManager = options.downloadManager || null; 2525 this.findController = options.findController || null; 2526 this._scriptingManager = options.scriptingManager || null; 2527 this.removePageBorders = options.removePageBorders || false; 2528 this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null && _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils.TextLayerMode.ENABLE; 2529 2530 _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options.annotationMode) !== null && _options$annotationMo !== void 0 ? _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS); 2531 2532 _classPrivateFieldSet(this, _annotationEditorMode, (_options$annotationEd = options.annotationEditorMode) !== null && _options$annotationEd !== void 0 ? _options$annotationEd : _pdfjsLib.AnnotationEditorType.DISABLE); 2533 2534 this.imageResourcesPath = options.imageResourcesPath || ""; 2535 this.enablePrintAutoRotate = options.enablePrintAutoRotate || false; 2536 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS; 2537 this.useOnlyCssZoom = options.useOnlyCssZoom || false; 2538 this.maxCanvasPixels = options.maxCanvasPixels; 2539 this.l10n = options.l10n || _l10n_utils.NullL10n; 2540 2541 _classPrivateFieldSet(this, _enablePermissions, options.enablePermissions || false); 2542 2543 this.pageColors = options.pageColors || null; 2544 2545 if (this.pageColors && !(CSS.supports("color", this.pageColors.background) && CSS.supports("color", this.pageColors.foreground))) { 2546 if (this.pageColors.background || this.pageColors.foreground) { 2547 console.warn("BaseViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."); 2548 } 2549 2550 this.pageColors = null; 2551 } 2552 2553 this.defaultRenderingQueue = !options.renderingQueue; 2554 2555 if (this.defaultRenderingQueue) { 2556 this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); 2557 this.renderingQueue.setViewer(this); 2558 } else { 2559 this.renderingQueue = options.renderingQueue; 2560 } 2561 2562 this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this)); 2563 this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN; 2564 this._onBeforeDraw = this._onAfterDraw = null; 2565 2566 this._resetView(); 2567 2568 if (this.removePageBorders) { 2569 this.viewer.classList.add("removePageBorders"); 2570 } 2571 2572 this.updateContainerHeightCss(); 2573 } 2574 2575 get pagesCount() { 2576 return this._pages.length; 2577 } 2578 2579 getPageView(index) { 2580 return this._pages[index]; 2581 } 2582 2583 get pageViewsReady() { 2584 if (!this._pagesCapability.settled) { 2585 return false; 2586 } 2587 2588 return this._pages.every(function (pageView) { 2589 return pageView === null || pageView === void 0 ? void 0 : pageView.pdfPage; 2590 }); 2591 } 2592 2593 get renderForms() { 2594 return _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS; 2595 } 2596 2597 get enableScripting() { 2598 return !!this._scriptingManager; 2599 } 2600 2601 get currentPageNumber() { 2602 return this._currentPageNumber; 2603 } 2604 2605 set currentPageNumber(val) { 2606 if (!Number.isInteger(val)) { 2607 throw new Error("Invalid page number."); 2608 } 2609 2610 if (!this.pdfDocument) { 2611 return; 2612 } 2613 2614 if (!this._setCurrentPageNumber(val, true)) { 2615 console.error(`currentPageNumber: "${val}" is not a valid page.`); 2616 } 2617 } 2618 2619 _setCurrentPageNumber(val) { 2620 var _this$_pageLabels, _this$_pageLabels2; 2621 2622 let resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2623 2624 if (this._currentPageNumber === val) { 2625 if (resetCurrentPageView) { 2626 _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2).call(this); 2627 } 2628 2629 return true; 2630 } 2631 2632 if (!(0 < val && val <= this.pagesCount)) { 2633 return false; 2634 } 2635 2636 const previous = this._currentPageNumber; 2637 this._currentPageNumber = val; 2638 this.eventBus.dispatch("pagechanging", { 2639 source: this, 2640 pageNumber: val, 2641 pageLabel: (_this$_pageLabels = (_this$_pageLabels2 = this._pageLabels) === null || _this$_pageLabels2 === void 0 ? void 0 : _this$_pageLabels2[val - 1]) !== null && _this$_pageLabels !== void 0 ? _this$_pageLabels : null, 2642 previous 2643 }); 2644 2645 if (resetCurrentPageView) { 2646 _classPrivateMethodGet(this, _resetCurrentPageView, _resetCurrentPageView2).call(this); 2647 } 2648 2649 return true; 2650 } 2651 2652 get currentPageLabel() { 2653 var _this$_pageLabels3, _this$_pageLabels4; 2654 2655 return (_this$_pageLabels3 = (_this$_pageLabels4 = this._pageLabels) === null || _this$_pageLabels4 === void 0 ? void 0 : _this$_pageLabels4[this._currentPageNumber - 1]) !== null && _this$_pageLabels3 !== void 0 ? _this$_pageLabels3 : null; 2656 } 2657 2658 set currentPageLabel(val) { 2659 if (!this.pdfDocument) { 2660 return; 2661 } 2662 2663 let page = val | 0; 2664 2665 if (this._pageLabels) { 2666 const i = this._pageLabels.indexOf(val); 2667 2668 if (i >= 0) { 2669 page = i + 1; 2670 } 2671 } 2672 2673 if (!this._setCurrentPageNumber(page, true)) { 2674 console.error(`currentPageLabel: "${val}" is not a valid page.`); 2675 } 2676 } 2677 2678 get currentScale() { 2679 return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE; 2680 } 2681 2682 set currentScale(val) { 2683 if (isNaN(val)) { 2684 throw new Error("Invalid numeric scale."); 2685 } 2686 2687 if (!this.pdfDocument) { 2688 return; 2689 } 2690 2691 this._setScale(val, false); 2692 } 2693 2694 get currentScaleValue() { 2695 return this._currentScaleValue; 2696 } 2697 2698 set currentScaleValue(val) { 2699 if (!this.pdfDocument) { 2700 return; 2701 } 2702 2703 this._setScale(val, false); 2704 } 2705 2706 get pagesRotation() { 2707 return this._pagesRotation; 2708 } 2709 2710 set pagesRotation(rotation) { 2711 if (!(0, _ui_utils.isValidRotation)(rotation)) { 2712 throw new Error("Invalid pages rotation angle."); 2713 } 2714 2715 if (!this.pdfDocument) { 2716 return; 2717 } 2718 2719 rotation %= 360; 2720 2721 if (rotation < 0) { 2722 rotation += 360; 2723 } 2724 2725 if (this._pagesRotation === rotation) { 2726 return; 2727 } 2728 2729 this._pagesRotation = rotation; 2730 const pageNumber = this._currentPageNumber; 2731 const updateArgs = { 2732 rotation 2733 }; 2734 2735 for (const pageView of this._pages) { 2736 pageView.update(updateArgs); 2737 } 2738 2739 if (this._currentScaleValue) { 2740 this._setScale(this._currentScaleValue, true); 2741 } 2742 2743 this.eventBus.dispatch("rotationchanging", { 2744 source: this, 2745 pagesRotation: rotation, 2746 pageNumber 2747 }); 2748 2749 if (this.defaultRenderingQueue) { 2750 this.update(); 2751 } 2752 } 2753 2754 get firstPagePromise() { 2755 return this.pdfDocument ? this._firstPageCapability.promise : null; 2756 } 2757 2758 get onePageRendered() { 2759 return this.pdfDocument ? this._onePageRenderedCapability.promise : null; 2760 } 2761 2762 get pagesPromise() { 2763 return this.pdfDocument ? this._pagesCapability.promise : null; 2764 } 2765 2766 setDocument(pdfDocument) { 2767 if (this.pdfDocument) { 2768 this.eventBus.dispatch("pagesdestroy", { 2769 source: this 2770 }); 2771 2772 this._cancelRendering(); 2773 2774 this._resetView(); 2775 2776 if (this.findController) { 2777 this.findController.setDocument(null); 2778 } 2779 2780 if (this._scriptingManager) { 2781 this._scriptingManager.setDocument(null); 2782 } 2783 2784 if (_classPrivateFieldGet(this, _annotationEditorUIManager)) { 2785 _classPrivateFieldGet(this, _annotationEditorUIManager).destroy(); 2786 2787 _classPrivateFieldSet(this, _annotationEditorUIManager, null); 2788 } 2789 } 2790 2791 this.pdfDocument = pdfDocument; 2792 2793 if (!pdfDocument) { 2794 return; 2795 } 2796 2797 const isPureXfa = pdfDocument.isPureXfa; 2798 const pagesCount = pdfDocument.numPages; 2799 const firstPagePromise = pdfDocument.getPage(1); 2800 const optionalContentConfigPromise = pdfDocument.getOptionalContentConfig(); 2801 const permissionsPromise = _classPrivateFieldGet(this, _enablePermissions) ? pdfDocument.getPermissions() : Promise.resolve(); 2802 2803 if (pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) { 2804 console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document."); 2805 const mode = this._scrollMode = _ui_utils.ScrollMode.PAGE; 2806 this.eventBus.dispatch("scrollmodechanged", { 2807 source: this, 2808 mode 2809 }); 2810 } 2811 2812 this._pagesCapability.promise.then(() => { 2813 this.eventBus.dispatch("pagesloaded", { 2814 source: this, 2815 pagesCount 2816 }); 2817 }, () => {}); 2818 2819 this._onBeforeDraw = evt => { 2820 const pageView = this._pages[evt.pageNumber - 1]; 2821 2822 if (!pageView) { 2823 return; 2824 } 2825 2826 _classPrivateFieldGet(this, _buffer).push(pageView); 2827 }; 2828 2829 this.eventBus._on("pagerender", this._onBeforeDraw); 2830 2831 this._onAfterDraw = evt => { 2832 if (evt.cssTransform || this._onePageRenderedCapability.settled) { 2833 return; 2834 } 2835 2836 this._onePageRenderedCapability.resolve({ 2837 timestamp: evt.timestamp 2838 }); 2839 2840 this.eventBus._off("pagerendered", this._onAfterDraw); 2841 2842 this._onAfterDraw = null; 2843 2844 if (_classPrivateFieldGet(this, _onVisibilityChange)) { 2845 document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange)); 2846 2847 _classPrivateFieldSet(this, _onVisibilityChange, null); 2848 } 2849 }; 2850 2851 this.eventBus._on("pagerendered", this._onAfterDraw); 2852 2853 Promise.all([firstPagePromise, permissionsPromise]).then(_ref => { 2854 let [firstPdfPage, permissions] = _ref; 2855 2856 if (pdfDocument !== this.pdfDocument) { 2857 return; 2858 } 2859 2860 this._firstPageCapability.resolve(firstPdfPage); 2861 2862 this._optionalContentConfigPromise = optionalContentConfigPromise; 2863 2864 const { 2865 annotationEditorMode, 2866 annotationMode, 2867 textLayerMode 2868 } = _classPrivateMethodGet(this, _initializePermissions, _initializePermissions2).call(this, permissions); 2869 2870 if (annotationEditorMode !== _pdfjsLib.AnnotationEditorType.DISABLE) { 2871 const mode = annotationEditorMode; 2872 2873 if (isPureXfa) { 2874 console.warn("Warning: XFA-editing is not implemented."); 2875 } else if (isValidAnnotationEditorMode(mode)) { 2876 _classPrivateFieldSet(this, _annotationEditorUIManager, new _pdfjsLib.AnnotationEditorUIManager(this.container, this.eventBus)); 2877 2878 if (mode !== _pdfjsLib.AnnotationEditorType.NONE) { 2879 _classPrivateFieldGet(this, _annotationEditorUIManager).updateMode(mode); 2880 } 2881 } else { 2882 console.error(`Invalid AnnotationEditor mode: ${mode}`); 2883 } 2884 } 2885 2886 const viewerElement = this._scrollMode === _ui_utils.ScrollMode.PAGE ? null : this.viewer; 2887 const scale = this.currentScale; 2888 const viewport = firstPdfPage.getViewport({ 2889 scale: scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS 2890 }); 2891 const textLayerFactory = textLayerMode !== _ui_utils.TextLayerMode.DISABLE && !isPureXfa ? this
2891: null; 2892 const annotationLayerFactory = annotationMode !== _pdfjsLib.AnnotationMode.DISABLE ? this : null; 2893 const xfaLayerFactory = isPureXfa ? this : null; 2894 const annotationEditorLayerFactory = _classPrivateFieldGet(this, _annotationEditorUIManager) ? this : null; 2895 2896 for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) { 2897 const pageView = new _pdf_page_view.PDFPageView({ 2898 container: viewerElement, 2899 eventBus: this.eventBus, 2900 id: pageNum, 2901 scale, 2902 defaultViewport: viewport.clone(), 2903 optionalContentConfigPromise, 2904 renderingQueue: this.renderingQueue, 2905 textLayerFactory, 2906 textLayerMode, 2907 annotationLayerFactory, 2908 annotationMode, 2909 xfaLayerFactory, 2910 annotationEditorLayerFactory, 2911 textHighlighterFactory: this, 2912 structTreeLayerFactory: this, 2913 imageResourcesPath: this.imageResourcesPath, 2914 renderer: this.renderer, 2915 useOnlyCssZoom: this.useOnlyCssZoom, 2916 maxCanvasPixels: this.maxCanvasPixels, 2917 pageColors: this.pageColors, 2918 l10n: this.l10n 2919 }); 2920 2921 this._pages.push(pageView); 2922 } 2923 2924 const firstPageView = this._pages[0]; 2925 2926 if (firstPageView) { 2927 firstPageView.setPdfPage(firstPdfPage); 2928 this.linkService.cachePageRef(1, firstPdfPage.ref); 2929 } 2930 2931 if (this._scrollMode === _ui_utils.ScrollMode.PAGE) { 2932 _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this); 2933 } else if (this._spreadMode !== _ui_utils.SpreadMode.NONE) { 2934 this._updateSpreadMode(); 2935 } 2936 2937 _classPrivateMethodGet(this, _onePageRenderedOrForceFetch, _onePageRenderedOrForceFetch2).call(this).then(async () => { 2938 if (this.findController) { 2939 this.findController.setDocument(pdfDocument); 2940 } 2941 2942 if (this._scriptingManager) { 2943 this._scriptingManager.setDocument(pdfDocument); 2944 } 2945 2946 if (_classPrivateFieldGet(this, _annotationEditorUIManager)) { 2947 this.eventBus.dispatch("annotationeditormodechanged", { 2948 source: this, 2949 mode: _classPrivateFieldGet(this, _annotationEditorMode) 2950 }); 2951 } 2952 2953 if (pdfDocument.loadingParams.disableAutoFetch || pagesCount > PagesCountLimit.FORCE_LAZY_PAGE_INIT) { 2954 this._pagesCapability.resolve(); 2955 2956 return; 2957 } 2958 2959 let getPagesLeft = pagesCount - 1; 2960 2961 if (getPagesLeft <= 0) { 2962 this._pagesCapability.resolve(); 2963 2964 return; 2965 } 2966 2967 for (let pageNum = 2; pageNum <= pagesCount; ++pageNum) { 2968 const promise = pdfDocument.getPage(pageNum).then(pdfPage => { 2969 const pageView = this._pages[pageNum - 1]; 2970 2971 if (!pageView.pdfPage) { 2972 pageView.setPdfPage(pdfPage); 2973 } 2974 2975 this.linkService.cachePageRef(pageNum, pdfPage.ref); 2976 2977 if (--getPagesLeft === 0) { 2978 this._pagesCapability.resolve(); 2979 } 2980 }, reason => { 2981 console.error(`Unable to get page ${pageNum} to initialize viewer`, reason); 2982 2983 if (--getPagesLeft === 0) { 2984 this._pagesCapability.resolve(); 2985 } 2986 }); 2987 2988 if (pageNum % PagesCountLimit.PAUSE_EAGER_PAGE_INIT === 0) { 2989 await promise; 2990 } 2991 } 2992 }); 2993 2994 this.eventBus.dispatch("pagesinit", { 2995 source: this 2996 }); 2997 pdfDocument.getMetadata().then(_ref2 => { 2998 let { 2999 info 3000 } = _ref2; 3001 3002 if (pdfDocument !== this.pdfDocument) { 3003 return; 3004 } 3005 3006 if (info.Language) { 3007 this.viewer.lang = info.Language; 3008 } 3009 }); 3010 3011 if (this.defaultRenderingQueue) { 3012 this.update(); 3013 } 3014 }).catch(reason => { 3015 console.error("Unable to initialize viewer", reason); 3016 3017 this._pagesCapability.reject(reason); 3018 }); 3019 } 3020 3021 setPageLabels(labels) { 3022 if (!this.pdfDocument) { 3023 return; 3024 } 3025 3026 if (!labels) { 3027 this._pageLabels = null; 3028 } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) { 3029 this._pageLabels = null; 3030 console.error(`setPageLabels: Invalid page labels.`); 3031 } else { 3032 this._pageLabels = labels; 3033 } 3034 3035 for (let i = 0, ii = this._pages.length; i < ii; i++) { 3036 var _this$_pageLabels$i, _this$_pageLabels5; 3037 3038 this._pages[i].setPageLabel((_this$_pageLabels$i = (_this$_pageLabels5 = this._pageLabels) === null || _this$_pageLabels5 === void 0 ? void 0 : _this$_pageLabels5[i]) !== null && _this$_pageLabels$i !== void 0 ? _this$_pageLabels$i : null); 3039 } 3040 } 3041 3042 _resetView() { 3043 this._pages = []; 3044 this._currentPageNumber = 1; 3045 this._currentScale = _ui_utils.UNKNOWN_SCALE; 3046 this._currentScaleValue = null; 3047 this._pageLabels = null; 3048 3049 _classPrivateFieldSet(this, _buffer, new PDFPageViewBuffer(DEFAULT_CACHE_SIZE)); 3050 3051 this._location = null; 3052 this._pagesRotation = 0; 3053 this._optionalContentConfigPromise = null; 3054 this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)(); 3055 this._onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)(); 3056 this._pagesCapability = (0, _pdfjsLib.createPromiseCapability)(); 3057 this._scrollMode = _ui_utils.ScrollMode.VERTICAL; 3058 this._previousScrollMode = _ui_utils.ScrollMode.UNKNOWN; 3059 this._spreadMode = _ui_utils.SpreadMode.NONE; 3060 3061 _classPrivateFieldSet(this, _scrollModePageState, { 3062 previousPageNumber: 1, 3063 scrollDown: true, 3064 pages: [] 3065 }); 3066 3067 if (this._onBeforeDraw) { 3068 this.eventBus._off("pagerender", this._onBeforeDraw); 3069 3070 this._onBeforeDraw = null; 3071 } 3072 3073 if (this._onAfterDraw) { 3074 this.eventBus._off("pagerendered", this._onAfterDraw); 3075 3076 this._onAfterDraw = null; 3077 } 3078 3079 if (_classPrivateFieldGet(this, _onVisibilityChange)) { 3080 document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange)); 3081 3082 _classPrivateFieldSet(this, _onVisibilityChange, null); 3083 } 3084 3085 this.viewer.textContent = ""; 3086 3087 this._updateScrollMode(); 3088 3089 this.viewer.removeAttribute("lang"); 3090 this.viewer.classList.remove(ENABLE_PERMISSIONS_CLASS); 3091 } 3092 3093 _scrollUpdate() { 3094 if (this.pagesCount === 0) { 3095 return; 3096 } 3097 3098 this.update(); 3099 } 3100 3101 _setScaleUpdatePages(newScale, newValue) { 3102 let noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3103 let preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 3104 this._currentScaleValue = newValue.toString(); 3105 3106 if (_classPrivateMethodGet(this, _isSameScale, _isSameScale2).call(this, newScale)) { 3107 if (preset) { 3108 this.eventBus.dispatch("scalechanging", { 3109 source: this, 3110 scale: newScale, 3111 presetValue: newValue 3112 }); 3113 } 3114 3115 return; 3116 } 3117 3118 _ui_utils.docStyle.setProperty("--scale-factor", newScale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS); 3119 3120 const updateArgs = { 3121 scale: newScale 3122 }; 3123 3124 for (const pageView of this._pages) { 3125 pageView.update(updateArgs); 3126 } 3127 3128 this._currentScale = newScale; 3129 3130 if (!noScroll) { 3131 let page = this._currentPageNumber, 3132 dest; 3133 3134 if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) { 3135 page = this._location.pageNumber; 3136 dest = [null, { 3137 name: "XYZ" 3138 }, this._location.left, this._location.top, null]; 3139 } 3140 3141 this.scrollPageIntoView({ 3142 pageNumber: page, 3143 destArray: dest, 3144 allowNegativeOffset: true 3145 }); 3146 } 3147 3148 this.eventBus.dispatch("scalechanging", { 3149 source: this, 3150 scale: newScale, 3151 presetValue: preset ? newValue : undefined 3152 }); 3153 3154 if (this.defaultRenderingQueue) { 3155 this.update(); 3156 } 3157 3158 this.updateContainerHeightCss(); 3159 } 3160 3161 get _pageWidthScaleFactor() { 3162 if (this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL) { 3163 return 2; 3164 } 3165 3166 return 1; 3167 } 3168 3169 _setScale(value) { 3170 let noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3171 let scale = parseFloat(value); 3172 3173 if (scale > 0) { 3174 this._setScaleUpdatePages(scale, value, noScroll, false); 3175 } else { 3176 const currentPage = this._pages[this._currentPageNumber - 1]; 3177 3178 if (!currentPage) { 3179 return; 3180 } 3181 3182 let hPadding = _ui_utils.SCROLLBAR_PADDING, 3183 vPadding = _ui_utils.VERTICAL_PADDING; 3184 3185 if (this.isInPresentationMode) { 3186 hPadding = vPadding = 4; 3187 } else if (this.removePageBorders) { 3188 hPadding = vPadding = 0; 3189 } else if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL) { 3190 [hPadding, vPadding] = [vPadding, hPadding]; 3191 } 3192 3193 const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale / this._pageWidthScaleFactor; 3194 const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale; 3195 3196 switch (value) { 3197 case "page-actual": 3198 scale = 1; 3199 break; 3200 3201 case "page-width": 3202 scale = pageWidthScale; 3203 break; 3204 3205 case "page-height": 3206 scale = pageHeightScale; 3207 break; 3208 3209 case "page-fit": 3210 scale = Math.min(pageWidthScale, pageHeightScale); 3211 break; 3212 3213 case "auto": 3214 const horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale); 3215 scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale); 3216 break; 3217 3218 default: 3219 console.error(`_setScale: "${value}" is an unknown zoom value.`); 3220 return; 3221 } 3222 3223 this._setScaleUpdatePages(scale, value, noScroll, true); 3224 } 3225 } 3226 3227 pageLabelToPageNumber(label) { 3228 if (!this._pageLabels) { 3229 return null; 3230 } 3231 3232 const i = this._pageLabels.indexOf(label); 3233 3234 if (i < 0) { 3235 return null; 3236 } 3237 3238 return i + 1; 3239 } 3240 3241 scrollPageIntoView(_ref3) { 3242 let { 3243 pageNumber, 3244 destArray = null, 3245 allowNegativeOffset = false, 3246 ignoreDestinationZoom = false 3247 } = _ref3; 3248 3249 if (!this.pdfDocument) { 3250 return; 3251 } 3252 3253 const pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1]; 3254 3255 if (!pageView) { 3256 console.error(`scrollPageIntoView: "${pageNumber}" is not a valid pageNumber parameter.`); 3257 return; 3258 } 3259 3260 if (this.isInPresentationMode || !destArray) { 3261 this._setCurrentPageNumber(pageNumber, true); 3262 3263 return; 3264 } 3265 3266 let x = 0, 3267 y = 0; 3268 let width = 0, 3269 height = 0, 3270 widthScale, 3271 heightScale; 3272 const changeOrientation = pageView.rotation % 180 !== 0; 3273 const pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS; 3274 const pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS; 3275 let scale = 0; 3276 3277 switch (destArray[1].name) { 3278 case "XYZ": 3279 x = destArray[2]; 3280 y = destArray[3]; 3281 scale = destArray[4]; 3282 x = x !== null ? x : 0; 3283 y = y !== null ? y : pageHeight; 3284 break; 3285 3286 case "Fit": 3287 case "FitB": 3288 scale = "page-fit"; 3289 break; 3290 3291 case "FitH": 3292 case "FitBH": 3293 y = destArray[2]; 3294 scale = "page-width"; 3295 3296 if (y === null && this._location) { 3297 x = this._location.left; 3298 y = this._location.top; 3299 } else if (typeof y !== "number" || y < 0) { 3300 y = pageHeight; 3301 } 3302 3303 break; 3304 3305 case "FitV": 3306 case "FitBV": 3307 x = destArray[2]; 3308 width = pageWidth; 3309 height = pageHeight; 3310 scale = "page-height"; 3311 break; 3312 3313 case "FitR": 3314 x = destArray[2]; 3315 y = destArray[3]; 3316 width = destArray[4] - x; 3317 height = destArray[5] - y; 3318 const hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING; 3319 const vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING; 3320 widthScale = (this.container.clientWidth - hPadding) / width / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS; 3321 heightScale = (this.container.clientHeight - vPadding) / height / _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS; 3322 scale = Math.min(Math.abs(widthScale), Math.abs(heightScale)); 3323 break; 3324 3325 default: 3326 console.error(`scrollPageIntoView: "${destArray[1].name}" is not a valid destination type.`); 3327 return; 3328 } 3329 3330 if (!ignoreDestinationZoom) { 3331 if (scale && scale !== this._currentScale) { 3332 this.currentScaleValue = scale; 3333 } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) { 3334 this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; 3335 } 3336 } 3337 3338 if (scale === "page-fit" && !destArray[4]) { 3339 _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView); 3340 3341 return; 3342 } 3343 3344 const boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)]; 3345 let left = Math.min(boundingRect[0][0], boundingRect[1][0]); 3346 let top = Math.min(boundingRect[0][1], boundingRect[1][1]); 3347 3348 if (!allowNegativeOffset) { 3349 left = Math.max(left, 0); 3350 top = Math.max(top, 0); 3351 } 3352 3353 _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView, { 3354 left, 3355 top 3356 }); 3357 } 3358 3359 _updateLocation(firstPage) { 3360 const currentScale = this._currentScale; 3361 const currentScaleValue = this._currentScaleValue; 3362 const normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue; 3363 const pageNumber = firstPage.id; 3364 const currentPageView = this._pages[pageNumber - 1]; 3365 const container = this.container; 3366 const topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y); 3367 const intLeft = Math.round(topLeft[0]); 3368 const intTop = Math.round(topLeft[1]); 3369 let pdfOpenParams = `#page=${pageNumber}`; 3370 3371 if (!this.isInPresentationMode) { 3372 pdfOpenParams += `&zoom=${normalizedScaleValue},${intLeft},${intTop}`; 3373 } 3374 3375 this._location = { 3376 pageNumber, 3377 scale: normalizedScaleValue, 3378 top: intTop, 3379 left: intLeft, 3380 rotation: this._pagesRotation, 3381 pdfOpenParams 3382 }; 3383 } 3384 3385 update() { 3386 const visible = this._getVisiblePages(); 3387 3388 const visiblePages = visible.views, 3389 numVisiblePages = visiblePages.length; 3390 3391 if (numVisiblePages === 0) { 3392 return; 3393 } 3394 3395 const newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1); 3396 3397 _classPrivateFieldGet(this, _buffer).resize(newCacheSize, visible.ids); 3398 3399 this.renderingQueue.renderHighestPriority(visible); 3400 const isSimpleLayout = this._spreadMode === _ui_utils.SpreadMode.NONE && (this._scrollMode === _ui_utils.ScrollMode.PAGE || this._scrollMode === _ui_utils.ScrollMode.VERTICAL); 3401 const currentId = this._currentPageNumber; 3402 let stillFullyVisible = false;
3403 3404 for (const page of visiblePages) { 3405 if (page.percent < 100) { 3406 break; 3407 } 3408 3409 if (page.id === currentId && isSimpleLayout) { 3410 stillFullyVisible = true; 3411 break; 3412 } 3413 } 3414 3415 this._setCurrentPageNumber(stillFullyVisible ? currentId : visiblePages[0].id); 3416 3417 this._updateLocation(visible.first); 3418 3419 this.eventBus.dispatch("updateviewarea", { 3420 source: this, 3421 location: this._location 3422 }); 3423 } 3424 3425 containsElement(element) { 3426 return this.container.contains(element); 3427 } 3428 3429 focus() { 3430 this.container.focus(); 3431 } 3432 3433 get _isContainerRtl() { 3434 return getComputedStyle(this.container).direction === "rtl"; 3435 } 3436 3437 get isInPresentationMode() { 3438 return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN; 3439 } 3440 3441 get isChangingPresentationMode() { 3442 return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING; 3443 } 3444 3445 get isHorizontalScrollbarEnabled() { 3446 return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth; 3447 } 3448 3449 get isVerticalScrollbarEnabled() { 3450 return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight; 3451 } 3452 3453 _getVisiblePages() { 3454 const views = this._scrollMode === _ui_utils.ScrollMode.PAGE ? _classPrivateFieldGet(this, _scrollModePageState).pages : this._pages, 3455 horizontal = this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL, 3456 rtl = horizontal && this._isContainerRtl; 3457 return (0, _ui_utils.getVisibleElements)({ 3458 scrollEl: this.container, 3459 views, 3460 sortByVisibility: true, 3461 horizontal, 3462 rtl 3463 }); 3464 } 3465 3466 isPageVisible(pageNumber) { 3467 if (!this.pdfDocument) { 3468 return false; 3469 } 3470 3471 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) { 3472 console.error(`isPageVisible: "${pageNumber}" is not a valid page.`); 3473 return false; 3474 } 3475 3476 return this._getVisiblePages().ids.has(pageNumber); 3477 } 3478 3479 isPageCached(pageNumber) { 3480 if (!this.pdfDocument) { 3481 return false; 3482 } 3483 3484 if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.pagesCount)) { 3485 console.error(`isPageCached: "${pageNumber}" is not a valid page.`); 3486 return false; 3487 } 3488 3489 const pageView = this._pages[pageNumber - 1]; 3490 return _classPrivateFieldGet(this, _buffer).has(pageView); 3491 } 3492 3493 cleanup() { 3494 for (const pageView of this._pages) { 3495 if (pageView.renderingState !== _ui_utils.RenderingStates.FINISHED) { 3496 pageView.reset(); 3497 } 3498 } 3499 } 3500 3501 _cancelRendering() { 3502 for (const pageView of this._pages) { 3503 pageView.cancelRendering(); 3504 } 3505 } 3506 3507 forceRendering(currentlyVisiblePages) { 3508 const visiblePages = currentlyVisiblePages || this._getVisiblePages(); 3509 3510 const scrollAhead = _classPrivateMethodGet(this, _getScrollAhead, _getScrollAhead2).call(this, visiblePages); 3511 3512 const preRenderExtra = this._spreadMode !== _ui_utils.SpreadMode.NONE && this._scrollMode !== _ui_utils.ScrollMode.HORIZONTAL; 3513 const pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead, preRenderExtra); 3514 3515 _classPrivateMethodGet(this, _toggleLoadingIconSpinner, _toggleLoadingIconSpinner2).call(this, visiblePages.ids); 3516 3517 if (pageView) { 3518 _classPrivateMethodGet(this, _ensurePdfPageLoaded, _ensurePdfPageLoaded2).call(this, pageView).then(() => { 3519 this.renderingQueue.renderView(pageView); 3520 }); 3521 3522 return true; 3523 } 3524 3525 return false; 3526 } 3527 3528 createTextLayerBuilder(_ref4) { 3529 let { 3530 textLayerDiv, 3531 pageIndex, 3532 viewport, 3533 enhanceTextSelection = false, 3534 eventBus, 3535 highlighter, 3536 accessibilityManager = null 3537 } = _ref4; 3538 return new _text_layer_builder.TextLayerBuilder({ 3539 textLayerDiv, 3540 eventBus, 3541 pageIndex, 3542 viewport, 3543 enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection, 3544 highlighter, 3545 accessibilityManager 3546 }); 3547 } 3548 3549 createTextHighlighter(_ref5) { 3550 let { 3551 pageIndex, 3552 eventBus 3553 } = _ref5; 3554 return new _text_highlighter.TextHighlighter({ 3555 eventBus, 3556 pageIndex, 3557 findController: this.isInPresentationMode ? null : this.findController 3558 }); 3559 } 3560 3561 createAnnotationLayerBuilder(_ref6) { 3562 var _this$pdfDocument, _this$pdfDocument2, _this$_scriptingManag, _this$pdfDocument3; 3563 3564 let { 3565 pageDiv, 3566 pdfPage, 3567 annotationStorage = (_this$pdfDocument = this.pdfDocument) === null || _this$pdfDocument === void 0 ? void 0 : _this$pdfDocument.annotationStorage, 3568 imageResourcesPath = "", 3569 renderForms = true, 3570 l10n = _l10n_utils.NullL10n, 3571 enableScripting = this.enableScripting,
3572 hasJSActionsPromise = (_this$pdfDocument2 = this.pdfDocument) === null || _this$pdfDocument2 === void 0 ? void 0 : _this$pdfDocument2.hasJSActions(), 3573 mouseState = (_this$_scriptingManag = this._scriptingManager) === null || _this$_scriptingManag === void 0 ? void 0 : _this$_scriptingManag.mouseState, 3574 fieldObjectsPromise = (_this$pdfDocument3 = this.pdfDocument) === null || _this$pdfDocument3 === void 0 ? void 0 : _this$pdfDocument3.getFieldObjects(), 3575 annotationCanvasMap = null, 3576 accessibilityManager = null 3577 } = _ref6; 3578 return new _annotation_layer_builder.AnnotationLayerBuilder({ 3579 pageDiv, 3580 pdfPage, 3581 annotationStorage, 3582 imageResourcesPath, 3583 renderForms, 3584 linkService: this.linkService, 3585 downloadManager: this.downloadManager, 3586 l10n, 3587 enableScripting, 3588 hasJSActionsPromise, 3589 mouseState, 3590 fieldObjectsPromise, 3591 annotationCanvasMap, 3592 accessibilityManager 3593 }); 3594 } 3595 3596 createAnnotationEditorLayerBuilder(_ref7) { 3597 var _this$pdfDocument4; 3598 3599 let { 3600 uiManager = _classPrivateFieldGet(this, _annotationEditorUIManager), 3601 pageDiv, 3602 pdfPage, 3603 accessibilityManager = null, 3604 l10n, 3605 annotationStorage = (_this$pdfDocument4 = this.pdfDocument) === null || _this$pdfDocument4 === void 0 ? void 0 : _this$pdfDocument4.annotationStorage 3606 } = _ref7; 3607 return new _annotation_editor_layer_builder.AnnotationEditorLayerBuilder({ 3608 uiManager, 3609 pageDiv, 3610 pdfPage, 3611 annotationStorage, 3612 accessibilityManager, 3613 l10n 3614 }); 3615 } 3616 3617 createXfaLayerBuilder(_ref8) { 3618 var _this$pdfDocument5; 3619 3620 let { 3621 pageDiv, 3622 pdfPage, 3623 annotationStorage = (_this$pdfDocument5 = this.pdfDocument) === null || _this$pdfDocument5 === void 0 ? void 0 : _this$pdfDocument5.annotationStorage 3624 } = _ref8; 3625 return new _xfa_layer_builder.XfaLayerBuilder({ 3626 pageDiv, 3627 pdfPage, 3628 annotationStorage, 3629 linkService: this.linkService 3630 }); 3631 } 3632 3633 createStructTreeLayerBuilder(_ref9) { 3634 let { 3635 pdfPage 3636 } = _ref9; 3637 return new _struct_tree_layer_builder.StructTreeLayerBuilder({ 3638 pdfPage 3639 }); 3640 } 3641 3642 get hasEqualPageSizes() { 3643 const firstPageView = this._pages[0]; 3644 3645 for (let i = 1, ii = this._pages.length; i < ii; ++i) { 3646 const pageView = this._pages[i]; 3647 3648 if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) { 3649 return false; 3650 } 3651 } 3652 3653 return true; 3654 } 3655 3656 getPagesOverview() { 3657 return this._pages.map(pageView => { 3658 const viewport = pageView.pdfPage.getViewport({ 3659 scale: 1 3660 }); 3661 3662 if (!this.enablePrintAutoRotate || (0, _ui_utils.isPortraitOrientation)(viewport)) { 3663 return { 3664 width: viewport.width, 3665 height: viewport.height, 3666 rotation: viewport.rotation 3667 }; 3668 } 3669 3670 return { 3671 width: viewport.height, 3672 height: viewport.width, 3673 rotation: (viewport.rotation - 90) % 360 3674 }; 3675 }); 3676 } 3677 3678 get optionalContentConfigPromise() { 3679 if (!this.pdfDocument) { 3680 return Promise.resolve(null); 3681 } 3682 3683 if (!this._optionalContentConfigPromise) { 3684 console.error("optionalContentConfigPromise: Not initialized yet."); 3685 return this.pdfDocument.getOptionalContentConfig(); 3686 } 3687 3688 return this._optionalContentConfigPromise; 3689 } 3690 3691 set optionalContentConfigPromise(promise) { 3692 if (!(promise instanceof Promise)) { 3693 throw new Error(`Invalid optionalContentConfigPromise: ${promise}`); 3694 } 3695 3696 if (!this.pdfDocument) { 3697 return; 3698 } 3699 3700 if (!this._optionalContentConfigPromise) { 3701 return; 3702 } 3703 3704 this._optionalContentConfigPromise = promise; 3705 const updateArgs = { 3706 optionalContentConfigPromise: promise 3707 }; 3708 3709 for (const pageView of this._pages) { 3710 pageView.update(updateArgs); 3711 } 3712 3713 this.update(); 3714 this.eventBus.dispatch("optionalcontentconfigchanged", { 3715 source: this, 3716 promise 3717 }); 3718 } 3719 3720 get scrollMode() { 3721 return this._scrollMode; 3722 } 3723 3724 set scrollMode(mode) { 3725 if (this._scrollMode === mode) { 3726 return; 3727 } 3728 3729 if (!(0, _ui_utils.isValidScrollMode)(mode)) { 3730 throw new Error(`Invalid scroll mode: ${mode}`); 3731 } 3732 3733 if (this.pagesCount > PagesCountLimit.FORCE_SCROLL_MODE_PAGE) { 3734 return; 3735 } 3736 3737 this._previousScrollMode = this._scrollMode; 3738 this._scrollMode = mode; 3739 this.eventBus.dispatch("scrollmodechanged", { 3740 source: this, 3741 mode 3742 }); 3743 3744 this._updateScrollMode(this._currentPageNumber); 3745 } 3746 3747 _updateScrollMode() { 3748 let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 3749 const scrollMode = this._scrollMode, 3750 viewer = this.viewer; 3751 viewer.classList.toggle("scrollHorizontal", scrollMode === _ui_utils.ScrollMode.HORIZONTAL); 3752 viewer.classList.toggle("scrollWrapped", scrollMode === _ui_utils.ScrollMode.WRAPPED); 3753 3754 if (!this.pdfDocument || !pageNumber) { 3755 return; 3756 } 3757 3758 if (scrollMode === _ui_utils.ScrollMode.PAGE) { 3759 _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this); 3760 } else if (this._previousScrollMode === _ui_utils.ScrollMode.PAGE) { 3761 this._updateSpreadMode(); 3762 } 3763 3764 if (this._currentScaleValue && isNaN(this._currentScaleValue)) { 3765 this._setScale(this._currentScaleValue, true); 3766 } 3767 3768 this._setCurrentPageNumber(pageNumber, true); 3769 3770 this.update(); 3771 } 3772 3773 get spreadMode() { 3774 return this._spreadMode;
3775 } 3776 3777 set spreadMode(mode) { 3778 if (this._spreadMode === mode) { 3779 return; 3780 } 3781 3782 if (!(0, _ui_utils.isValidSpreadMode)(mode)) { 3783 throw new Error(`Invalid spread mode: ${mode}`); 3784 } 3785 3786 this._spreadMode = mode; 3787 this.eventBus.dispatch("spreadmodechanged", { 3788 source: this, 3789 mode 3790 }); 3791 3792 this._updateSpreadMode(this._currentPageNumber); 3793 } 3794 3795 _updateSpreadMode() { 3796 let pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 3797 3798 if (!this.pdfDocument) { 3799 return; 3800 } 3801 3802 const viewer = this.viewer, 3803 pages = this._pages; 3804 3805 if (this._scrollMode === _ui_utils.ScrollMode.PAGE) { 3806 _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this); 3807 } else { 3808 viewer.textContent = ""; 3809 3810 if (this._spreadMode === _ui_utils.SpreadMode.NONE) { 3811 for (const pageView of this._pages) { 3812 viewer.append(pageView.div); 3813 } 3814 } else { 3815 const parity = this._spreadMode - 1; 3816 let spread = null; 3817 3818 for (let i = 0, ii = pages.length; i < ii; ++i) { 3819 if (spread === null) { 3820 spread = document.createElement("div"); 3821 spread.className = "spread"; 3822 viewer.append(spread); 3823 } else if (i % 2 === parity) { 3824 spread = spread.cloneNode(false); 3825 viewer.append(spread); 3826 } 3827 3828 spread.append(pages[i].div); 3829 } 3830 } 3831 } 3832 3833 if (!pageNumber) { 3834 return; 3835 } 3836 3837 if (this._currentScaleValue && isNaN(this._currentScaleValue)) { 3838 this._setScale(this._currentScaleValue, true); 3839 } 3840 3841 this._setCurrentPageNumber(pageNumber, true); 3842 3843 this.update(); 3844 } 3845 3846 _getPageAdvance(currentPageNumber) { 3847 let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 3848 3849 switch (this._scrollMode) { 3850 case _ui_utils.ScrollMode.WRAPPED: 3851 { 3852 const { 3853 views 3854 } = this._getVisiblePages(), 3855 pageLayout = new Map(); 3856 3857 for (const { 3858 id, 3859 y, 3860 percent, 3861 widthPercent 3862 } of views) { 3863 if (percent === 0 || widthPercent < 100) { 3864 continue; 3865 } 3866 3867 let yArray = pageLayout.get(y); 3868 3869 if (!yArray) { 3870 pageLayout.set(y, yArray || (yArray = [])); 3871 } 3872 3873 yArray.push(id); 3874 } 3875 3876 for (const yArray of pageLayout.values()) { 3877 const currentIndex = yArray.indexOf(currentPageNumber); 3878 3879 if (currentIndex === -1) { 3880 continue; 3881 } 3882 3883 const numPages = yArray.length; 3884 3885 if (numPages === 1) { 3886 break; 3887 } 3888 3889 if (previous) { 3890 for (let i = currentIndex - 1, ii = 0; i >= ii; i--) { 3891 const currentId = yArray[i], 3892 expectedId = yArray[i + 1] - 1; 3893 3894 if (currentId < expectedId) { 3895 return currentPageNumber - expectedId; 3896 } 3897 } 3898 } else { 3899 for (let i = currentIndex + 1, ii = numPages; i < ii; i++) { 3900 const currentId = yArray[i], 3901 expectedId = yArray[i - 1] + 1; 3902 3903 if (currentId > expectedId) { 3904 return expectedId - currentPageNumber; 3905 } 3906 } 3907 } 3908 3909 if (previous) { 3910 const firstId = yArray[0]; 3911 3912 if (firstId < currentPageNumber) { 3913 return currentPageNumber - firstId + 1; 3914 } 3915 } else { 3916 const lastId = yArray[numPages - 1]; 3917 3918 if (lastId > currentPageNumber) { 3919 return lastId - currentPageNumber + 1; 3920 } 3921 } 3922 3923 break; 3924 } 3925 3926 break; 3927 } 3928 3929 case _ui_utils.ScrollMode.HORIZONTAL: 3930 { 3931 break; 3932 } 3933 3934 case _ui_utils.ScrollMode.PAGE: 3935 case _ui_utils.ScrollMode.VERTICAL: 3936 { 3937 if (this._spreadMode === _ui_utils.SpreadMode.NONE) { 3938 break; 3939 } 3940 3941 const parity = this._spreadMode - 1; 3942 3943 if (previous && currentPageNumber % 2 !== parity) { 3944 break; 3945 } else if (!previous && currentPageNumber % 2 === parity) { 3946 break; 3947 } 3948 3949 const { 3950 views 3951 } = this._getVisiblePages(), 3952 expectedId = previous ? currentPageNumber - 1 : currentPageNumber + 1; 3953 3954 for (const { 3955 id, 3956 percent, 3957 widthPercent 3958 } of views) { 3959 if (id !== expectedId) { 3960 continue; 3961 } 3962 3963 if (percent > 0 && widthPercent === 100) { 3964 return 2; 3965 } 3966 3967 break; 3968 } 3969 3970 break; 3971 } 3972 } 3973 3974 return 1; 3975 } 3976 3977 nextPage() { 3978 const currentPageNumber = this._currentPageNumber, 3979 pagesCount = this.pagesCount; 3980 3981 if (currentPageNumber >= pagesCount) { 3982 return false;
3983 } 3984 3985 const advance = this._getPageAdvance(currentPageNumber, false) || 1; 3986 this.currentPageNumber = Math.min(currentPageNumber + advance, pagesCount); 3987 return true; 3988 } 3989 3990 previousPage() { 3991 const currentPageNumber = this._currentPageNumber; 3992 3993 if (currentPageNumber <= 1) { 3994 return false; 3995 } 3996 3997 const advance = this._getPageAdvance(currentPageNumber, true) || 1; 3998 this.currentPageNumber = Math.max(currentPageNumber - advance, 1); 3999 return true; 4000 } 4001 4002 increaseScale() { 4003 let steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; 4004 let newScale = this._currentScale; 4005 4006 do { 4007 newScale = (newScale * _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2); 4008 newScale = Math.ceil(newScale * 10) / 10; 4009 newScale = Math.min(_ui_utils.MAX_SCALE, newScale); 4010 } while (--steps > 0 && newScale < _ui_utils.MAX_SCALE); 4011 4012 this.currentScaleValue = newScale; 4013 } 4014 4015 decreaseScale() { 4016 let steps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; 4017 let newScale = this._currentScale; 4018 4019 do { 4020 newScale = (newScale / _ui_utils.DEFAULT_SCALE_DELTA).toFixed(2); 4021 newScale = Math.floor(newScale * 10) / 10; 4022 newScale = Math.max(_ui_utils.MIN_SCALE, newScale); 4023 } while (--steps > 0 && newScale > _ui_utils.MIN_SCALE); 4024 4025 this.currentScaleValue = newScale; 4026 } 4027 4028 updateContainerHeightCss() { 4029 const height = this.container.clientHeight; 4030 4031 if (height !== _classPrivateFieldGet(this, _previousContainerHeight)) { 4032 _classPrivateFieldSet(this, _previousContainerHeight, height); 4033 4034 _ui_utils.docStyle.setProperty("--viewer-container-height", `${height}px`); 4035 } 4036 } 4037 4038 get annotationEditorMode() { 4039 return _classPrivateFieldGet(this, _annotationEditorUIManager) ? _classPrivateFieldGet(this, _annotationEditorMode) : _pdfjsLib.AnnotationEditorType.DISABLE; 4040 } 4041 4042 set annotationEditorMode(mode) { 4043 if (!_classPrivateFieldGet(this, _annotationEditorUIManager)) { 4044 throw new Error(`The AnnotationEditor is not enabled.`); 4045 } 4046 4047 if (_classPrivateFieldGet(this, _annotationEditorMode) === mode) { 4048 return; 4049 } 4050 4051 if (!isValidAnnotationEditorMode(mode)) { 4052 throw new Error(`Invalid AnnotationEditor mode: ${mode}`); 4053 } 4054 4055 if (!this.pdfDocument) { 4056 return; 4057 } 4058 4059 _classPrivateFieldSet(this, _annotationEditorMode, mode); 4060 4061 this.eventBus.dispatch("annotationeditormodechanged", { 4062 source: this, 4063 mode 4064 }); 4065 4066 _classPrivateFieldGet(this, _annotationEditorUIManager).updateMode(mode); 4067 } 4068 4069 set annotationEditorParams(_ref10) { 4070 let { 4071 type, 4072 value 4073 } = _ref10; 4074 4075 if (!_classPrivateFieldGet(this, _annotationEditorUIManager)) { 4076 throw new Error(`The AnnotationEditor is not enabled.`); 4077 } 4078 4079 _classPrivateFieldGet(this, _annotationEditorUIManager).updateParams(type, value); 4080 } 4081 4082 refresh() { 4083 if (!this.pdfDocument) { 4084 return; 4085 } 4086 4087 const updateArgs = {}; 4088 4089 for (const pageView of this._pages) { 4090 pageView.update(updateArgs); 4091 } 4092 4093 this.update(); 4094 } 4095 4096} 4097 4098exports.BaseViewer = BaseViewer; 4099 4100function _initializePermissions2(permissions) { 4101 const params = { 4102 annotationEditorMode: _classPrivateFieldGet(this, _annotationEditorMode), 4103 annotationMode: _classPrivateFieldGet(this, _annotationMode), 4104 textLayerMode: this.textLayerMode 4105 }; 4106 4107 if (!permissions) { 4108 return params; 4109 } 4110 4111 if (!permissions.includes(_pdfjsLib.PermissionFlag.COPY)) { 4112 this.viewer.classList.add(ENABLE_PERMISSIONS_CLASS); 4113 } 4114 4115 if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_CONTENTS)) { 4116 params.annotationEditorMode = _pdfjsLib.AnnotationEditorType.DISABLE; 4117 } 4118 4119 if (!permissions.includes(_pdfjsLib.PermissionFlag.MODIFY_ANNOTATIONS) && !permissions.includes(_pdfjsLib.PermissionFlag.FILL_INTERACTIVE_FORMS) && _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS) { 4120 params.annotationMode = _pdfjsLib.AnnotationMode.ENABLE; 4121 } 4122 4123 return params; 4124} 4125 4126function _onePageRenderedOrForceFetch2() { 4127 if (document.visibilityState === "hidden" || !this.container.offsetParent || this._getVisiblePages().views.length === 0) { 4128 return Promise.resolve(); 4129 } 4130 4131 const visibilityChangePromise = new Promise(resolve => { 4132 _classPrivateFieldSet(this, _onVisibilityChange, () => { 4133 if (document.visibilityState !== "hidden") { 4134 return; 4135 } 4136 4137 resolve(); 4138 document.removeEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange)); 4139 4140 _classPrivateFieldSet(this, _onVisibilityChange, null); 4141 }); 4142 4143 document.addEventListener("visibilitychange", _classPrivateFieldGet(this, _onVisibilityChange)); 4144 }); 4145 return Promise.race([this._onePageRenderedCapability.promise, visibilityChangePromise]); 4146} 4147 4148function _ensurePageViewVisible2() { 4149 if (this._scrollMode !== _ui_utils.ScrollMode.PAGE) { 4150 throw new Error("#ensurePageViewVisible: Invalid scrollMode value."); 4151 } 4152 4153 const pageNumber = this._currentPageNumber, 4154 state = _classPrivateFieldGet(this, _scrollModePageState), 4155 viewer = this.viewer; 4156 4157 viewer.textContent = ""; 4158 state.pages.length = 0; 4159 4160 if (this._spreadMode === _ui_utils.SpreadMode.NONE && !this.isInPresentationMode) { 4161 const pageView = this._pages[pageNumber - 1]; 4162 viewer.append(pageView.div); 4163 state.pages.push(pageView); 4164 } else { 4165 const pageIndexSet = new Set(), 4166 parity = this._spreadMode - 1; 4167 4168 if (parity === -1) { 4169 pageIndexSet.add(pageNumber - 1); 4170 } else if (pageNumber % 2 !== parity) { 4171 pageIndexSet.add(pageNumber - 1); 4172 pageIndexSet.add(pageNumber); 4173 } else { 4174 pageIndexSet.add(pageNumber - 2); 4175 pageIndexSet.add(pageNumber - 1); 4176 } 4177 4178 const spread = document.createElement("div"); 4179 spread.className = "spread"; 4180 4181 if (this.isInPresentationMode) { 4182 const dummyPage = document.createElement("div"); 4183 dummyPage.className = "dummyPage"; 4184 spread.append(dummyPage); 4185 } 4186 4187 for (const i of pageIndexSet) { 4188 const pageView = this._pages[i]; 4189 4190 if (!pageView) { 4191 continue; 4192 } 4193 4194 spread.append(pageView.div); 4195 state.pages.push(pageView); 4196 } 4197 4198 viewer.append(spread); 4199 } 4200 4201 state.scrollDown = pageNumber >= state.previousPageNumber; 4202 state.previousPageNumber = pageNumber; 4203} 4204 4205function _scrollIntoView2(pageView) { 4206 let pageSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 4207 const { 4208 div, 4209 id 4210 } = pageView; 4211 4212 if (this._scrollMode === _ui_utils.ScrollMode.PAGE) { 4213 this._setCurrentPageNumber(id); 4214 4215 _classPrivateMethodGet(this, _ensurePageViewVisible, _ensurePageViewVisible2).call(this); 4216 4217 this.update(); 4218 } 4219 4220 if (!pageSpot && !this.isInPresentationMode) { 4221 const left = div.offsetLeft + div.clientLeft, 4222 right = left + div.clientWidth; 4223 const { 4224 scrollLeft, 4225 clientWidth 4226 } = this.container; 4227 4228 if (this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) { 4229 pageSpot = { 4230 left: 0, 4231 top: 0 4232 }; 4233 } 4234 } 4235 4236 (0, _ui_utils.scrollIntoView)(div, pageSpot); 4237} 4238 4239function _isSameScale2(newScale) { 4240 return newScale === this._currentScale || Math.abs(newScale - this._currentScale) < 1e-15; 4241} 4242 4243function _resetCurrentPageView2() { 4244 const pageView = this._pages[this._currentPageNumber - 1]; 4245 4246 if (this.isInPresentationMode) { 4247 this._setScale(this._currentScaleValue, true); 4248 } 4249 4250 _classPrivateMethodGet(this, _scrollIntoView, _scrollIntoView2).call(this, pageView); 4251} 4252 4253async function _ensurePdfPageLoaded2(pageView) { 4254 if (pageView.pdfPage) { 4255 return pageView.pdfPage; 4256 } 4257 4258 try { 4259 var _this$linkService$_ca, _this$linkService; 4260 4261 const pdfPage = await this.pdfDocument.getPage(pageView.id); 4262 4263 if (!pageView.pdfPage) { 4264 pageView.setPdfPage(pdfPage); 4265 } 4266 4267 if (!((_this$linkService$_ca = (_this$linkService = this.linkService)._cachedPageNumber) !== null && _this$linkService$_ca !== void 0 && _this$linkService$_ca.call(_this$linkService, pdfPage.ref))) { 4268 this.linkService.cachePageRef(pageView.id, pdfPage.ref); 4269 } 4270 4271 return pdfPage; 4272 } catch (reason) { 4273 console.error("Unable to get page for page view", reason); 4274 return null; 4275 } 4276} 4277 4278function _getScrollAhead2(visible) { 4279 var _visible$first, _visible$last; 4280 4281 if (((_visible$first = visible.first) === null || _visible$first === void 0 ? void 0 : _visible$first.id) === 1) { 4282 return true; 4283 } else if (((_visible$last = visible.last) === null || _visible$last === void 0 ? void 0 : _visible$last.id) === this.pagesCount) { 4284 return false;
4285 } 4286 4287 switch (this._scrollMode) { 4288 case _ui_utils.ScrollMode.PAGE: 4289 return _classPrivateFieldGet(this, _scrollModePageState).scrollDown; 4290 4291 case _ui_utils.ScrollMode.HORIZONTAL: 4292 return this.scroll.right; 4293 } 4294 4295 return this.scroll.down; 4296} 4297 4298function _toggleLoadingIconSpinner2(visibleIds) { 4299 for (const id of visibleIds) { 4300 const pageView = this._pages[id - 1]; 4301 pageView === null || pageView === void 0 ? void 0 : pageView.toggleLoadingIconSpinner(true); 4302 } 4303 4304 for (const pageView of _classPrivateFieldGet(this, _buffer)) { 4305 if (visibleIds.has(pageView.id)) { 4306 continue; 4307 } 4308 4309 pageView.toggleLoadingIconSpinner(false); 4310 } 4311} 4312 4313/***/ }), 4314/* 13 */ 4315/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 4316 4317 4318 4319Object.defineProperty(exports, "__esModule", ({ 4320 value: true 4321})); 4322exports.PDFPageView = void 0; 4323 4324var _pdfjsLib = __w_pdfjs_require__(3); 4325 4326var _ui_utils = __w_pdfjs_require__(7); 4327 4328var _app_options = __w_pdfjs_require__(14); 4329 4330var _l10n_utils = __w_pdfjs_require__(4); 4331 4332var _text_accessibility = __w_pdfjs_require__(15); 4333 4334function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 4335 4336function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 4337 4338function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 4339 4340function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 4341 4342function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; } 4343 4344function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 4345 4346function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } } 4347 4348const MAX_CANVAS_PIXELS = _app_options.compatibilityParams.maxCanvasPixels || 16777216; 4349 4350var _annotationMode = /*#__PURE__*/new WeakMap(); 4351 4352var _useThumbnailCanvas = /*#__PURE__*/new WeakMap(); 4353 4354class PDFPageView { 4355 constructor(options) { 4356 var _options$textLayerMod, _options$annotationMo, _options$textHighligh, _this$renderingQueue; 4357 4358 _classPrivateFieldInitSpec(this, _annotationMode, { 4359 writable: true, 4360 value: _pdfjsLib.AnnotationMode.ENABLE_FORMS 4361 }); 4362 4363 _classPrivateFieldInitSpec(this, _useThumbnailCanvas, { 4364 writable: true, 4365 value: { 4366 initialOptionalContent: true, 4367 regularAnnotations: true 4368 } 4369 }); 4370 4371 const container = options.container; 4372 const defaultViewport = options.defaultViewport; 4373 this.id = options.id; 4374 this.renderingId = "page" + this.id; 4375 this.pdfPage = null; 4376 this.pageLabel = null; 4377 this.rotation = 0; 4378 this.scale = options.scale || _ui_utils.DEFAULT_SCALE; 4379 this.viewport = defaultViewport; 4380 this.pdfPageRotate = defaultViewport.rotation; 4381 this._optionalContentConfigPromise = options.optionalContentConfigPromise || null; 4382 this.hasRestrictedScaling = false; 4383 this.textLayerMode = (_options$textLayerMod = options.textLayerMode) !== null && _options$textLayerMod !== void 0 ? _options$textLayerMod : _ui_utils.TextLayerMode.ENABLE; 4384 4385 _classPrivateFieldSet(this, _annotationMode, (_options$annotationMo = options.annotationMode) !== null && _options$annotationMo !== void 0 ? _options$annotationMo : _pdfjsLib.AnnotationMode.ENABLE_FORMS); 4386 4387 this.imageResourcesPath = options.imageResourcesPath || ""; 4388 this.useOnlyCssZoom = options.useOnlyCssZoom || false; 4389 this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS; 4390 this.pageColors = options.pageColors || null; 4391 this.eventBus = options.eventBus; 4392 this.renderingQueue = options.renderingQueue; 4393 this.textLayerFactory = options.textLayerFactory; 4394 this.annotationLayerFactory = options.annotationLayerFactory; 4395 this.annotationEditorLayerFactory = options.annotationEditorLayerFactory; 4396 this.xfaLayerFactory = options.xfaLayerFactory; 4397 this.textHighlighter = (_options$textHighligh = options.textHighlighterFactory) === null || _options$textHighligh === void 0 ? void 0 : _options$textHighligh.
4397createTextHighlighter({ 4398 pageIndex: this.id - 1, 4399 eventBus: this.eventBus 4400 }); 4401 this.structTreeLayerFactory = options.structTreeLayerFactory; 4402 this.renderer = options.renderer || _ui_utils.RendererType.CANVAS; 4403 this.l10n = options.l10n || _l10n_utils.NullL10n; 4404 this.paintTask = null; 4405 this.paintedViewportMap = new WeakMap(); 4406 this.renderingState = _ui_utils.RenderingStates.INITIAL; 4407 this.resume = null; 4408 this._renderError = null; 4409 this._isStandalone = !((_this$renderingQueue = this.renderingQueue) !== null && _this$renderingQueue !== void 0 && _this$renderingQueue.hasViewer()); 4410 this._annotationCanvasMap = null; 4411 this.annotationLayer = null; 4412 this.annotationEditorLayer = null; 4413 this.textLayer = null; 4414 this.zoomLayer = null; 4415 this.xfaLayer = null; 4416 this.structTreeLayer = null; 4417 const div = document.createElement("div"); 4418 div.className = "page"; 4419 div.style.width = Math.floor(this.viewport.width) + "px"; 4420 div.style.height = Math.floor(this.viewport.height) + "px"; 4421 div.setAttribute("data-page-number", this.id); 4422 div.setAttribute("role", "region"); 4423 this.l10n.get("page_landmark", { 4424 page: this.id 4425 }).then(msg => { 4426 div.setAttribute("aria-label", msg); 4427 }); 4428 this.div = div; 4429 container === null || container === void 0 ? void 0 : container.append(div); 4430 4431 if (this._isStandalone) { 4432 const { 4433 optionalContentConfigPromise 4434 } = options; 4435 4436 if (optionalContentConfigPromise) { 4437 optionalContentConfigPromise.then(optionalContentConfig => { 4438 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) { 4439 return; 4440 } 4441 4442 _classPrivateFieldGet(this, _useThumbnailCanvas).initialOptionalContent = optionalContentConfig.hasInitialVisibility; 4443 }); 4444 } 4445 } 4446 } 4447 4448 setPdfPage(pdfPage) { 4449 this.pdfPage = pdfPage; 4450 this.pdfPageRotate = pdfPage.rotate; 4451 const totalRotation = (this.rotation + this.pdfPageRotate) % 360; 4452 this.viewport = pdfPage.getViewport({ 4453 scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS, 4454 rotation: totalRotation 4455 }); 4456 this.reset(); 4457 } 4458 4459 destroy() { 4460 this.reset(); 4461 4462 if (this.pdfPage) { 4463 this.pdfPage.cleanup(); 4464 } 4465 } 4466 4467 async _renderAnnotationLayer() { 4468 let error = null; 4469 4470 try { 4471 await this.annotationLayer.render(this.viewport, "display"); 4472 } catch (ex) { 4473 console.error(`_renderAnnotationLayer: "${ex}".`); 4474 error = ex; 4475 } finally { 4476 this.eventBus.dispatch("annotationlayerrendered", { 4477 source: this, 4478 pageNumber: this.id, 4479 error 4480 }); 4481 } 4482 } 4483 4484 async _renderAnnotationEditorLayer() { 4485 let error = null; 4486 4487 try { 4488 await this.annotationEditorLayer.render(this.viewport, "display"); 4489 } catch (ex) { 4490 console.error(`_renderAnnotationEditorLayer: "${ex}".`); 4491 error = ex; 4492 } finally { 4493 this.eventBus.dispatch("annotationeditorlayerrendered", { 4494 source: this, 4495 pageNumber: this.id, 4496 error 4497 }); 4498 } 4499 } 4500 4501 async _renderXfaLayer() { 4502 let error = null; 4503 4504 try { 4505 const result = await this.xfaLayer.render(this.viewport, "display"); 4506 4507 if (this.textHighlighter) { 4508 this._buildXfaTextContentItems(result.textDivs); 4509 } 4510 } catch (ex) { 4511 console.error(`_renderXfaLayer: "${ex}".`); 4512 error = ex; 4513 } finally { 4514 this.eventBus.dispatch("xfalayerrendered", { 4515 source: this, 4516 pageNumber: this.id, 4517 error 4518 }); 4519 } 4520 } 4521 4522 async _buildXfaTextContentItems(textDivs) { 4523 const text = await this.pdfPage.getTextContent(); 4524 const items = []; 4525 4526 for (const item of text.items) { 4527 items.push(item.str); 4528 } 4529 4530 this.textHighlighter.setTextMapping(textDivs, items); 4531 this.textHighlighter.enable(); 4532 } 4533 4534 _resetZoomLayer() { 4535 let removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 4536 4537 if (!this.zoomLayer) { 4538 return; 4539 } 4540 4541 const zoomLayerCanvas = this.zoomLayer.firstChild; 4542 this.paintedViewportMap.delete(zoomLayerCanvas); 4543 zoomLayerCanvas.width = 0; 4544 zoomLayerCanvas.height = 0; 4545 4546 if (removeFromDOM) {
4547 this.zoomLayer.remove(); 4548 } 4549 4550 this.zoomLayer = null; 4551 } 4552 4553 reset() { 4554 var _this$annotationLayer, _this$annotationEdito, _this$xfaLayer; 4555 4556 let { 4557 keepZoomLayer = false, 4558 keepAnnotationLayer = false, 4559 keepAnnotationEditorLayer = false, 4560 keepXfaLayer = false 4561 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4562 this.cancelRendering({ 4563 keepAnnotationLayer, 4564 keepAnnotationEditorLayer, 4565 keepXfaLayer 4566 }); 4567 this.renderingState = _ui_utils.RenderingStates.INITIAL; 4568 const div = this.div; 4569 div.style.width = Math.floor(this.viewport.width) + "px"; 4570 div.style.height = Math.floor(this.viewport.height) + "px"; 4571 const childNodes = div.childNodes, 4572 zoomLayerNode = keepZoomLayer && this.zoomLayer || null, 4573 annotationLayerNode = keepAnnotationLayer && ((_this$annotationLayer = this.annotationLayer) === null || _this$annotationLayer === void 0 ? void 0 : _this$annotationLayer.div) || null, 4574 annotationEditorLayerNode = keepAnnotationEditorLayer && ((_this$annotationEdito = this.annotationEditorLayer) === null || _this$annotationEdito === void 0 ? void 0 : _this$annotationEdito.div) || null, 4575 xfaLayerNode = keepXfaLayer && ((_this$xfaLayer = this.xfaLayer) === null || _this$xfaLayer === void 0 ? void 0 : _this$xfaLayer.div) || null; 4576 4577 for (let i = childNodes.length - 1; i >= 0; i--) { 4578 const node = childNodes[i]; 4579 4580 switch (node) {
4581 case zoomLayerNode: 4582 case annotationLayerNode: 4583 case annotationEditorLayerNode: 4584 case xfaLayerNode: 4585 continue; 4586 } 4587 4588 node.remove(); 4589 } 4590 4591 div.removeAttribute("data-loaded"); 4592 4593 if (annotationLayerNode) { 4594 this.annotationLayer.hide(); 4595 } 4596 4597 if (annotationEditorLayerNode) { 4598 this.annotationEditorLayer.hide(); 4599 } else { 4600 var _this$annotationEdito2; 4601 4602 (_this$annotationEdito2 = this.annotationEditorLayer) === null || _this$annotationEdito2 === void 0 ? void 0 : _this$annotationEdito2.destroy(); 4603 } 4604 4605 if (xfaLayerNode) { 4606 this.xfaLayer.hide(); 4607 } 4608 4609 if (!zoomLayerNode) { 4610 if (this.canvas) { 4611 this.paintedViewportMap.delete(this.canvas); 4612 this.canvas.width = 0; 4613 this.canvas.height = 0; 4614 delete this.canvas; 4615 } 4616 4617 this._resetZoomLayer(); 4618 } 4619 4620 if (this.svg) { 4621 this.paintedViewportMap.delete(this.svg); 4622 delete this.svg; 4623 } 4624 4625 this.loadingIconDiv = document.createElement("div"); 4626 this.loadingIconDiv.className = "loadingIcon notVisible"; 4627 4628 if (this._isStandalone) { 4629 this.toggleLoadingIconSpinner(true); 4630 } 4631 4632 this.loadingIconDiv.setAttribute("role", "img"); 4633 this.l10n.get("loading").then(msg => { 4634 var _this$loadingIconDiv; 4635 4636 (_this$loadingIconDiv = this.loadingIconDiv) === null || _this$loadingIconDiv === void 0 ? void 0 : _this$loadingIconDiv.setAttribute("aria-label", msg); 4637 }); 4638 div.append(this.loadingIconDiv); 4639 } 4640 4641 update(_ref) { 4642 let { 4643 scale = 0, 4644 rotation = null, 4645 optionalContentConfigPromise = null 4646 } = _ref; 4647 this.scale = scale || this.scale; 4648 4649 if (typeof rotation === "number") { 4650 this.rotation = rotation; 4651 } 4652 4653 if (optionalContentConfigPromise instanceof Promise) { 4654 this._optionalContentConfigPromise = optionalContentConfigPromise; 4655 optionalContentConfigPromise.then(optionalContentConfig => { 4656 if (optionalContentConfigPromise !== this._optionalContentConfigPromise) { 4657 return; 4658 } 4659 4660 _classPrivateFieldGet(this, _useThumbnailCanvas).initialOptionalContent = optionalContentConfig.hasInitialVisibility; 4661 }); 4662 } 4663 4664 const totalRotation = (this.rotation + this.pdfPageRotate) % 360; 4665 this.viewport = this.viewport.clone({ 4666 scale: this.scale * _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS, 4667 rotation: totalRotation 4668 }); 4669 4670 if (this._isStandalone) { 4671 _ui_utils.docStyle.setProperty("--scale-factor", this.viewport.scale); 4672 } 4673 4674 if (this.svg) { 4675 this.cssTransform({ 4676 target: this.svg, 4677 redrawAnnotationLayer: true, 4678 redrawAnnotationEditorLayer: true, 4679 redrawXfaLayer: true 4680 }); 4681 this.eventBus.dispatch("pagerendered", { 4682 source: this, 4683 pageNumber: this.id, 4684 cssTransform: true, 4685 timestamp: performance.now(), 4686 error: this._renderError 4687 }); 4688 return; 4689 } 4690 4691 let isScalingRestricted = false; 4692 4693 if (this.canvas && this.maxCanvasPixels > 0) { 4694 const outputScale = this.outputScale; 4695 4696 if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) { 4697 isScalingRestricted = true; 4698 } 4699 } 4700 4701 if (this.canvas) { 4702 if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) { 4703 this.cssTransform({ 4704 target: this.canvas, 4705 redrawAnnotationLayer: true, 4706 redrawAnnotationEditorLayer: true, 4707 redrawXfaLayer: true 4708 }); 4709 this.eventBus.dispatch("pagerendered", { 4710 source: this, 4711 pageNumber: this.id, 4712 cssTransform: true, 4713 timestamp: performance.now(), 4714 error: this._renderError 4715 }); 4716 return; 4717 } 4718 4719 if (!this.zoomLayer && !this.canvas.hidden) { 4720 this.zoomLayer = this.canvas.parentNode; 4721 this.zoomLayer.style.position = "absolute"; 4722 } 4723 } 4724 4725 if (this.zoomLayer) { 4726 this.cssTransform({ 4727 target: this.zoomLayer.firstChild 4728 }); 4729 } 4730 4731 this.reset({ 4732 keepZoomLayer: true, 4733 keepAnnotationLayer: true, 4734 keepAnnotationEditorLayer: true, 4735 keepXfaLayer: true 4736 }); 4737 } 4738 4739 cancelRendering() { 4740 let { 4741 keepAnnotationLayer = false, 4742 keepAnnotationEditorLayer = false, 4743 keepXfaLayer = false 4744 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4745 4746 if (this.paintTask) { 4747 this.paintTask.cancel(); 4748 this.paintTask = null; 4749 } 4750 4751 this.resume = null; 4752 4753 if (this.textLayer) { 4754 this.textLayer.cancel(); 4755 this.textLayer = null; 4756 } 4757 4758 if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) { 4759 this.annotationLayer.cancel(); 4760 this.annotationLayer = null; 4761 this._annotationCanvasMap = null; 4762 } 4763 4764 if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) { 4765 this.annotationEditorLayer.cancel(); 4766 this.annotationEditorLayer = null; 4767 } 4768 4769 if (this.xfaLayer && (!keepXfaLayer || !this.xfaLayer.div)) { 4770 var _this$textHighlighter; 4771 4772 this.xfaLayer.cancel(); 4773 this.xfaLayer = null; 4774 (_this$textHighlighter = this.textHighlighter) === null || _this$textHighlighter === void 0 ? void 0 : _this$textHighlighter.disable(); 4775 } 4776 4777 if (this._onTextLayerRendered) { 4778 this.eventBus._off("textlayerrendered", this._onTextLayerRendered); 4779 4780 this._onTextLayerRendered = null; 4781 } 4782 } 4783 4784 cssTransform(_ref2) { 4785 let { 4786 target, 4787 redrawAnnotationLayer = false, 4788 redrawAnnotationEditorLayer = false, 4789 redrawXfaLayer = false 4790 } = _ref2; 4791 const width = this.viewport.width; 4792 const height = this.viewport.height; 4793 const div = this.div; 4794 target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + "px"; 4795 target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + "px"; 4796 const relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation; 4797 const absRotation = Math.abs(relativeRotation); 4798 let scaleX = 1, 4799 scaleY = 1; 4800 4801 if (absRotation === 90 || absRotation === 270) { 4802 scaleX = height / width; 4803 scaleY = width / height; 4804 } 4805 4806 target.style.transform = `rotate(${relativeRotation}deg) scale(${scaleX}, ${scaleY})`; 4807 4808 if (this.textLayer) { 4809 const textLayerViewport = this.textLayer.viewport; 4810 const textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation; 4811 const textAbsRotation = Math.abs(textRelativeRotation); 4812 let scale = width / textLayerViewport.width; 4813 4814 if (textAbsRotation === 90 || textAbsRotation === 270) { 4815 scale = width / textLayerViewport.height; 4816 } 4817 4818 const textLayerDiv = this.textLayer.textLayerDiv; 4819 let transX, transY; 4820 4821 switch (textAbsRotation) { 4822 case 0: 4823 transX = transY = 0; 4824 break; 4825 4826 case 90: 4827 transX = 0; 4828 transY = "-" + textLayerDiv.style.height; 4829 break; 4830 4831 case 180: 4832 transX = "-" + textLayerDiv.style.width; 4833 transY = "-" + textLayerDiv.style.height; 4834 break; 4835 4836 case 270: 4837 transX = "-" + textLayerDiv.style.width; 4838 transY = 0; 4839 break; 4840 4841 default: 4842 console.error("Bad rotation value."); 4843 break; 4844 } 4845 4846 textLayerDiv.style.transform = `rotate(${textAbsRotation}deg) ` + `scale(${scale}) ` + `translate(${transX}, ${transY})`; 4847 textLayerDiv.style.transformOrigin = "0% 0%"; 4848 } 4849 4850 if (redrawAnnotationLayer && this.annotationLayer) { 4851 this._renderAnnotationLayer(); 4852 } 4853 4854 if (redrawAnnotationEditorLayer && this.annotationEditorLayer) { 4855 this._renderAnnotationEditorLayer(); 4856 } 4857 4858 if (redrawXfaLayer && this.xfaLayer) { 4859 this._renderXfaLayer(); 4860 } 4861 } 4862 4863 get width() { 4864 return this.viewport.width; 4865 } 4866 4867 get height() { 4868 return this.viewport.height; 4869 } 4870 4871 getPagePoint(x, y) { 4872 return this.viewport.convertToPdfPoint(x, y); 4873 } 4874 4875 toggleLoadingIconSpinner() { 4876 var _this$loadingIconDiv2; 4877 4878 let viewVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4879 (_this$loadingIconDiv2 = this.loadingIconDiv) === null || _this$loadingIconDiv2 === void 0 ? void 0 : _this$loadingIconDiv2.classList.toggle("notVisible", !viewVisible); 4880 } 4881 4882 draw() { 4883 var _this$annotationLayer2, 4884 _this$annotationEdito3, 4885 _this$xfaLayer2, 4886 _this = this; 4887 4888 if (this.renderingState !== _ui_utils.RenderingStates.INITIAL) { 4889 console.error("Must be in new state before drawing"); 4890 this.reset(); 4891 } 4892 4893 const { 4894 div, 4895 pdfPage 4896 } = this; 4897 4898 if (!pdfPage) { 4899 this.renderingState = _ui_utils.RenderingStates.FINISHED; 4900 4901 if (this.loadingIconDiv) { 4902 this.loadingIconDiv.remove(); 4903 delete this.loadingIconDiv; 4904 } 4905 4906 return Promise.reject(new Error("pdfPage is not loaded")); 4907 } 4908 4909 this.renderingState = _ui_utils.RenderingStates.RUNNING; 4910 const canvasWrapper = document.createElement("div"); 4911 canvasWrapper.style.width = div.style.width; 4912 canvasWrapper.style.height = div.style.height; 4913 canvasWrapper.classList.add("canvasWrapper"); 4914 const lastDivBeforeTextDiv = ((_this$annotationLayer2 = this.annotationLayer) === null || _this$annotationLayer2 === void 0 ? void 0 : _this$annotationLayer2.div) || ((_this$annotationEdito3 = this.annotationEditorLayer) === null || _this$annotationEdito3 === void 0 ? void 0 : _this$annotationEdito3.div); 4915 4916 if (lastDivBeforeTextDiv) { 4917 lastDivBeforeTextDiv.before(canvasWrapper); 4918 } else { 4919 div.append(canvasWrapper); 4920 } 4921 4922 let textLayer = null; 4923 4924 if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) { 4925 this._accessibilityManager || (this._accessibilityManager = new _text_accessibility.TextAccessibilityManager()); 4926 const textLayerDiv = document.createElement("div"); 4927 textLayerDiv.className = "textLayer"; 4928 textLayerDiv.style.width = canvasWrapper.style.width; 4929 textLayerDiv.style.height = canvasWrapper.style.height; 4930 4931 if (lastDivBeforeTextDiv) { 4932 lastDivBeforeTextDiv.before(textLayerDiv); 4933 } else { 4934 div.append(textLayerDiv); 4935 } 4936 4937 textLayer = this.textLayerFactory.createTextLayerBuilder({ 4938 textLayerDiv, 4939 pageIndex: this.id - 1, 4940 viewport: this.viewport, 4941 enhanceTextSelection: this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE, 4942 eventBus: this.eventBus, 4943 highlighter: this.textHighlighter, 4944 accessibilityManager: this._accessibilityManager 4945 }); 4946 } 4947 4948 this.textLayer = textLayer; 4949 4950 if (_classPrivateFieldGet(this, _annotationMode) !== _pdfjsLib.AnnotationMode.DISABLE && this.annotationLayerFactory) { 4951 this._annotationCanvasMap || (this._annotationCanvasMap = new Map()); 4952 this.annotationLayer || (this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder({ 4953 pageDiv: div, 4954 pdfPage, 4955 imageResourcesPath: this.imageResourcesPath, 4956 renderForms: _classPrivateFieldGet(this, _annotationMode) === _pdfjsLib.AnnotationMode.ENABLE_FORMS, 4957 l10n: this.l10n, 4958 annotationCanvasMap: this._annotationCanvasMap, 4959 accessibilityManager: this._accessibilityManager 4960 })); 4961 } 4962 4963 if ((_this$xfaLayer2 = this.xfaLayer) !== null && _this$xfaLayer2 !== void 0 && _this$xfaLayer2.div) { 4964 div.append(this.xfaLayer.div); 4965 } 4966 4967 let renderContinueCallback = null; 4968 4969 if (this.renderingQueue) { 4970 renderContinueCallback = cont => { 4971 if (!this.renderingQueue.isHighestPriority(this)) { 4972 this.renderingState = _ui_utils.RenderingStates.PAUSED; 4973 4974 this.resume = () => { 4975 this.renderingState = _ui_utils.RenderingStates.RUNNING; 4976 cont(); 4977 }; 4978 4979 return; 4980 } 4981 4982 cont(); 4983 }; 4984 } 4985 4986 const finishPaintTask = async function () { 4987 let error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 4988 4989 if (paintTask === _this.paintTask) { 4990 _this.paintTask = null; 4991 } 4992 4993 if (error instanceof _pdfjsLib.RenderingCancelledException) { 4994 _this._renderError = null; 4995 return; 4996 } 4997 4998 _this._renderError = error; 4999 _this.renderingState = _ui_utils.RenderingStates.FINISHED; 5000 5001 if (_this.loadingIconDiv) { 5002 _this.loadingIconDiv.remove(); 5003 5004 delete _this.loadingIconDiv; 5005 } 5006 5007 _this._resetZoomLayer(true); 5008 5009 _classPrivateFieldGet(_this, _useThumbnailCanvas).regularAnnotations = !paintTask.separateAnnots; 5010 5011 _this.eventBus.dispatch("pagerendered", { 5012 source: _this, 5013 pageNumber: _this.id, 5014 cssTransform: false, 5015 timestamp: performance.now(), 5016 error: _this._renderError 5017 }); 5018 5019 if (error) { 5020 throw error; 5021 } 5022 }; 5023 5024 const paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper); 5025 paintTask.onRenderContinue = renderContinueCallback; 5026 this.paintTask = paintTask; 5027 const resultPromise = paintTask.promise.then(() => { 5028 return finishPaintTask(null).then(() => { 5029 if (textLayer) { 5030 const readableStream = pdfPage.streamTextContent({ 5031 includeMarkedContent: true 5032 }); 5033 textLayer.setTextContentStream(readableStream); 5034 textLayer.render(); 5035 } 5036 5037 if (this.annotationLayer) { 5038 this._renderAnnotationLayer().then(() => { 5039 if (this.annotationEditorLayerFactory) { 5040 this.annotationEditorLayer || (this.annotationEditorLayer = this.annotationEditorLayerFactory.createAnnotationEditorLayerBuilder({ 5041 pageDiv: div, 5042 pdfPage, 5043 l10n: this.l10n, 5044 accessibilityManager: this._accessibilityManager 5045 })); 5046 5047 this._renderAnnotationEditorLayer(); 5048 } 5049 }); 5050 } 5051 }); 5052 }, function (reason) { 5053 return finishPaintTask(reason); 5054 }); 5055 5056 if (this.xfaLayerFactory) { 5057 this.xfaLayer || (this.xfaLayer = this.xfaLayerFactory.createXfaLayerBuilder({ 5058 pageDiv: div, 5059 pdfPage 5060 })); 5061 5062 this._renderXfaLayer(); 5063 } 5064 5065 if (this.structTreeLayerFactory && this.textLayer && this.canvas) { 5066 this._onTextLayerRendered = event => { 5067 if (event.pageNumber !== this.id) { 5068 return; 5069 } 5070 5071 this.eventBus._off("textlayerrendered", this._onTextLayerRendered); 5072 5073 this._onTextLayerRendered = null; 5074 5075 if (!this.canvas) { 5076 return; 5077 } 5078 5079 this.pdfPage.getStructTree().then(tree => { 5080 if (!tree) { 5081 return; 5082 } 5083 5084 if (!this.canvas) { 5085 return; 5086 } 5087 5088 const treeDom = this.structTreeLayer.render(tree); 5089 treeDom.classList.add("structTree"); 5090 this.canvas.append(treeDom); 5091 }); 5092 }; 5093 5094 this.eventBus._on("textlayerrendered", this._onTextLayerRendered); 5095 5096 this.structTreeLayer = this.structTreeLayerFactory.createStructTreeLayerBuilder({ 5097 pdfPage 5098 }); 5099 } 5100 5101 div.setAttribute("data-loaded", true); 5102 this.eventBus.dispatch("pagerender", { 5103 source: this, 5104 pageNumber: this.id 5105 }); 5106 return resultPromise; 5107 } 5108 5109 paintOnCanvas(canvasWrapper) { 5110 const renderCapability = (0, _pdfjsLib.createPromiseCapability)(); 5111 const result = { 5112 promise: renderCapability.promise, 5113 5114 onRenderContinue(cont) { 5115 cont(); 5116 }, 5117 5118 cancel() { 5119 renderTask.cancel(); 5120 }, 5121 5122 get separateAnnots() { 5123 return renderTask.separateAnnots; 5124 } 5125 5126 }; 5127 const viewport = this.viewport; 5128 const canvas = document.createElement("canvas"); 5129 canvas.setAttribute("role", "presentation"); 5130 canvas.hidden = true; 5131 let isCanvasHidden = true; 5132 5133 const showCanvas = function () {
5134 if (isCanvasHidden) { 5135 canvas.hidden = false; 5136 isCanvasHidden = false; 5137 } 5138 }; 5139 5140 canvasWrapper.append(canvas); 5141 this.canvas = canvas; 5142 const ctx = canvas.getContext("2d", { 5143 alpha: false 5144 }); 5145 const outputScale = this.outputScale = new _ui_utils.OutputScale(); 5146 5147 if (this.useOnlyCssZoom) { 5148 const actualSizeViewport = viewport.clone({ 5149 scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS 5150 }); 5151 outputScale.sx *= actualSizeViewport.width / viewport.width; 5152 outputScale.sy *= actualSizeViewport.height / viewport.height; 5153 } 5154 5155 if (this.maxCanvasPixels > 0) { 5156 const pixelsInViewport = viewport.width * viewport.height; 5157 const maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport); 5158 5159 if (outputScale.sx > maxScale || outputScale.sy > maxScale) { 5160 outputScale.sx = maxScale; 5161 outputScale.sy = maxScale; 5162 this.hasRestrictedScaling = true; 5163 } else { 5164 this.hasRestrictedScaling = false; 5165 } 5166 } 5167 5168 const sfx = (0, _ui_utils.approximateFraction)(outputScale.sx); 5169 const sfy = (0, _ui_utils.approximateFraction)(outputScale.sy); 5170 canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]); 5171 canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]); 5172 canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + "px"; 5173 canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + "px"; 5174 this.paintedViewportMap.set(canvas, viewport); 5175 const transform = outputScale.scaled ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] : null; 5176 const renderContext = { 5177 canvasContext: ctx, 5178 transform, 5179 viewport: this.viewport, 5180 annotationMode: _classPrivateFieldGet(this, _annotationMode), 5181 optionalContentConfigPromise: this._optionalContentConfigPromise, 5182 annotationCanvasMap: this._annotationCanvasMap, 5183 pageColors: this.pageColors 5184 }; 5185 const renderTask = this.pdfPage.render(renderContext); 5186 5187 renderTask.onContinue = function (cont) { 5188 showCanvas(); 5189 5190 if (result.onRenderContinue) { 5191 result.onRenderContinue(cont); 5192 } else { 5193 cont(); 5194 } 5195 }; 5196 5197 renderTask.promise.then(function () { 5198 showCanvas(); 5199 renderCapability.resolve(); 5200 }, function (error) { 5201 showCanvas(); 5202 renderCapability.reject(error); 5203 }); 5204 return result; 5205 } 5206 5207 paintOnSvg(wrapper) { 5208 let cancelled = false; 5209 5210 const ensureNotCancelled = () => { 5211 if (cancelled) { 5212 throw new _pdfjsLib.RenderingCancelledException(`Rendering cancelled, page ${this.id}`, "svg"); 5213 } 5214 }; 5215 5216 const pdfPage = this.pdfPage; 5217 const actualSizeViewport = this.viewport.clone({ 5218 scale: _pdfjsLib.PixelsPerInch.PDF_TO_CSS_UNITS 5219 }); 5220 const promise = pdfPage.getOperatorList({ 5221 annotationMode: _classPrivateFieldGet(this, _annotationMode) 5222 }).then(opList => { 5223 ensureNotCancelled(); 5224 const svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs); 5225 return svgGfx.getSVG(opList, actualSizeViewport).then(svg => { 5226 ensureNotCancelled(); 5227 this.svg = svg; 5228 this.paintedViewportMap.set(svg, actualSizeViewport); 5229 svg.style.width = wrapper.style.width; 5230 svg.style.height = wrapper.style.height; 5231 this.renderingState = _ui_utils.RenderingStates.FINISHED; 5232 wrapper.append(svg); 5233 }); 5234 }); 5235 return { 5236 promise, 5237 5238 onRenderContinue(cont) { 5239 cont(); 5240 }, 5241 5242 cancel() { 5243 cancelled = true; 5244 }, 5245 5246 get separateAnnots() { 5247 return false; 5248 } 5249 5250 }; 5251 } 5252 5253 setPageLabel(label) { 5254 this.pageLabel = typeof label === "string" ? label : null; 5255 5256 if (this.pageLabel !== null) { 5257 this.div.setAttribute("data-page-label", this.pageLabel); 5258 } else { 5259 this.div.removeAttribute("data-page-label"); 5260 } 5261 } 5262 5263 get thumbnailCanvas() { 5264 const { 5265 initialOptionalContent, 5266 regularAnnotations 5267 } = _classPrivateFieldGet(this, _useThumbnailCanvas); 5268 5269 return initialOptionalContent && regularAnnotations ? this.canvas : null; 5270 } 5271 5272} 5273 5274exports.PDFPageView = PDFPageView; 5275 5276/***/ }), 5277/* 14 */
5278/***/ ((__unused_webpack_module, exports) => { 5279 5280 5281 5282Object.defineProperty(exports, "__esModule", ({ 5283 value: true 5284})); 5285exports.compatibilityParams = exports.OptionKind = exports.AppOptions = void 0; 5286const compatibilityParams = Object.create(null); 5287exports.compatibilityParams = compatibilityParams; 5288{ 5289 const userAgent = navigator.userAgent || ""; 5290 const platform = navigator.platform || ""; 5291 const maxTouchPoints = navigator.maxTouchPoints || 1; 5292 const isAndroid = /Android/.test(userAgent); 5293 const isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1; 5294 5295 (function checkCanvasSizeLimitation() { 5296 if (isIOS || isAndroid) { 5297 compatibilityParams.maxCanvasPixels = 5242880; 5298 } 5299 })(); 5300} 5301const OptionKind = { 5302 VIEWER: 0x02, 5303 API: 0x04, 5304 WORKER: 0x08, 5305 PREFERENCE: 0x80 5306}; 5307exports.OptionKind = OptionKind; 5308const defaultOptions = { 5309 annotationEditorMode: { 5310 value: -1, 5311 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5312 }, 5313 annotationMode: { 5314 value: 2, 5315 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5316 }, 5317 cursorToolOnLoad: { 5318 value: 0, 5319 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5320 }, 5321 defaultZoomValue: { 5322 value: "", 5323 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5324 }, 5325 disableHistory: { 5326 value: false, 5327 kind: OptionKind.VIEWER 5328 }, 5329 disablePageLabels: { 5330 value: false, 5331 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5332 }, 5333 enablePermissions: { 5334 value: false, 5335 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5336 }, 5337 enablePrintAutoRotate: { 5338 value: true, 5339 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5340 }, 5341 enableScripting: { 5342 value: true, 5343 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5344 }, 5345 externalLinkRel: { 5346 value: "noopener noreferrer nofollow", 5347 kind: OptionKind.VIEWER 5348 }, 5349 externalLinkTarget: { 5350 value: 0, 5351 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5352 }, 5353 historyUpdateUrl: { 5354 value: false, 5355 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5356 }, 5357 ignoreDestinationZoom: { 5358 value: false, 5359 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5360 }, 5361 imageResourcesPath: { 5362 value: "./images/", 5363 kind: OptionKind.VIEWER 5364 }, 5365 maxCanvasPixels: { 5366 value: 16777216, 5367 kind: OptionKind.VIEWER 5368 }, 5369 forcePageColors: { 5370 value: false, 5371 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5372 }, 5373 pageColorsBackground: { 5374 value: "Canvas", 5375 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5376 }, 5377 pageColorsForeground: { 5378 value: "CanvasText", 5379 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5380 }, 5381 pdfBugEnabled: { 5382 value: false, 5383 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5384 }, 5385 printResolution: { 5386 value: 150, 5387 kind: OptionKind.VIEWER 5388 }, 5389 sidebarViewOnLoad: { 5390 value: -1, 5391 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5392 }, 5393 scrollModeOnLoad: { 5394 value: -1, 5395 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5396 }, 5397 spreadModeOnLoad: { 5398 value: -1, 5399 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5400 }, 5401 textLayerMode: { 5402 value: 1, 5403 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5404 }, 5405 useOnlyCssZoom: { 5406 value: false, 5407 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5408 }, 5409 viewerCssTheme: { 5410 value: 0, 5411 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5412 }, 5413 viewOnLoad: { 5414 value: 0, 5415 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5416 }, 5417 cMapPacked: { 5418 value: true, 5419 kind: OptionKind.API 5420 }, 5421 cMapUrl: { 5422 value: "../web/cmaps/", 5423 kind: OptionKind.API 5424 }, 5425 disableAutoFetch: { 5426 value: false, 5427 kind: OptionKind.API + OptionKind.PREFERENCE 5428 }, 5429 disableFontFace: { 5430 value: false, 5431 kind: OptionKind.API + OptionKind.PREFERENCE 5432 }, 5433 disableRange: { 5434 value: false, 5435 kind: OptionKind.API + OptionKind.PREFERENCE 5436 }, 5437 disableStream: { 5438 value: false, 5439 kind: OptionKind.API + OptionKind.PREFERENCE 5440 }, 5441 docBaseUrl: { 5442 value: "", 5443 kind: OptionKind.API 5444 }, 5445 enableXfa: { 5446 value: true, 5447 kind: OptionKind.API + OptionKind.PREFERENCE 5448 }, 5449 fontExtraProperties: { 5450 value: false, 5451 kind: OptionKind.API 5452 }, 5453 isEvalSupported: { 5454 value: true, 5455 kind: OptionKind.API 5456 }, 5457 maxImageSize: { 5458 value: -1, 5459 kind: OptionKind.API 5460 }, 5461 pdfBug: { 5462 value: false, 5463 kind: OptionKind.API 5464 }, 5465 standardFontDataUrl: { 5466 value: "../web/standard_fonts/", 5467 kind: OptionKind.API 5468 }, 5469 verbosity: { 5470 value: 1, 5471 kind: OptionKind.API 5472 }, 5473 workerPort: { 5474 value: null, 5475 kind: OptionKind.WORKER 5476 }, 5477 workerSrc: { 5478 value: "../build/pdf.worker.js", 5479 kind: OptionKind.WORKER 5480 } 5481}; 5482{ 5483 defaultOptions.defaultUrl = { 5484 value: "compressed.tracemonkey-pldi-09.pdf", 5485 kind: OptionKind.VIEWER 5486 }; 5487 defaultOptions.disablePreferences = { 5488 value: false, 5489 kind: OptionKind.VIEWER 5490 }; 5491 defaultOptions.locale = { 5492 value: navigator.language || "en-US", 5493 kind: OptionKind.VIEWER 5494 }; 5495 defaultOptions.renderer = { 5496 value: "canvas", 5497 kind: OptionKind.VIEWER + OptionKind.PREFERENCE 5498 }; 5499 defaultOptions.sandboxBundleSrc = { 5500 value: "../build/pdf.sandbox.js", 5501 kind: OptionKind.VIEWER 5502 }; 5503} 5504const userOptions = Object.create(null); 5505 5506class AppOptions { 5507 constructor() { 5508 throw new Error("Cannot initialize AppOptions."); 5509 } 5510 5511 static get(name) { 5512 const userOption = userOptions[name]; 5513 5514 if (userOption !== undefined) { 5515 return userOption; 5516 } 5517 5518 const defaultOption = defaultOptions[name]; 5519 5520 if (defaultOption !== undefined) { 5521 var _compatibilityParams$; 5522 5523 return (_compatibilityParams$ = compatibilityParams[name]) !== null && _compatibilityParams$ !== void 0 ? _compatibilityParams$ : defaultOption.value; 5524 } 5525 5526 return undefined; 5527 } 5528 5529 static getAll() { 5530 let kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; 5531 const options = Object.create(null); 5532 5533 for (const name in defaultOptions) { 5534 var _compatibilityParams$2; 5535 5536 const defaultOption = defaultOptions[name]; 5537 5538 if (kind) { 5539 if ((kind & defaultOption.kind) === 0) { 5540 continue; 5541 } 5542 5543 if (kind === OptionKind.PREFERENCE) { 5544 const value = defaultOption.value, 5545 valueType = typeof value; 5546 5547 if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) { 5548 options[name] = value; 5549 continue; 5550 } 5551 5552 throw new Error(`Invalid type for preference: ${name}`); 5553 } 5554 } 5555 5556 const userOption = userOptions[name]; 5557 options[name] = userOption !== undefined ? userOption : (_compatibilityParams$2 = compatibilityParams[name]) !== null && _compatibilityParams$2 !== void 0 ? _compatibilityParams$2 : defaultOption.value; 5558 } 5559 5560 return options; 5561 } 5562 5563 static set(name, value) { 5564 userOptions[name] = value; 5565 } 5566 5567 static setAll(options) { 5568 for (const name in options) { 5569 userOptions[name] = options[name]; 5570 } 5571 } 5572 5573 static remove(name) { 5574 delete userOptions[name]; 5575 } 5576 5577 static _hasUserOptions() { 5578 return Object.keys(userOptions).length > 0; 5579 } 5580 5581} 5582 5583exports.AppOptions = AppOptions; 5584 5585/***/ }), 5586/* 15 */ 5587/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 5588 5589 5590 5591Object.defineProperty(exports, "__esModule", ({ 5592 value: true 5593})); 5594exports.TextAccessibilityManager = void 0; 5595 5596var _ui_utils = __w_pdfjs_require__(7); 5597 5598function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 5599 5600function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 5601 5602function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 5603 5604function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 5605 5606function _classStaticPrivateMethodGet(receiver, classConstructor, method) { _classCheckPrivateStaticAccess(receiver, classConstructor); return method; } 5607 5608function _classCheckPrivateStaticAccess(receiver, classConstructor) { if (receiver !== classConstructor) { throw new TypeError("Private static access of wrong provenance"); } } 5609 5610function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 5611 5612function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 5613 5614function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; } 5615 5616function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 5617 5618function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } } 5619 5620var _enabled = /*#__PURE__*/new WeakMap(); 5621 5622var _textChildren = /*#__PURE__*/new WeakMap(); 5623 5624var _textNodes = /*#__PURE__*/new WeakMap(); 5625 5626var _waitingElements = /*#__PURE__*/new WeakMap(); 5627 5628var _addIdToAriaOwns = /*#__PURE__*/new WeakSet(); 5629 5630class TextAccessibilityManager { 5631 constructor() { 5632 _classPrivateMethodInitSpec(this, _addIdToAriaOwns); 5633 5634 _classPrivateFieldInitSpec(this, _enabled, { 5635 writable: true, 5636 value: false 5637 }); 5638 5639 _classPrivateFieldInitSpec(this, _textChildren, { 5640 writable: true, 5641 value: null 5642 }); 5643 5644 _classPrivateFieldInitSpec(this, _textNodes, { 5645 writable: true, 5646 value: new Map() 5647 }); 5648 5649 _classPrivateFieldInitSpec(this, _waitingElements, { 5650 writable: true, 5651 value: new Map() 5652 }); 5653 } 5654 5655 setTextMapping(textDivs) { 5656 _classPrivateFieldSet(this, _textChildren, textDivs); 5657 } 5658 5659 enable() { 5660 if (_classPrivateFieldGet(this, _enabled)) { 5661 throw new Error("TextAccessibilityManager is already enabled."); 5662 } 5663 5664 if (!_classPrivateFieldGet(this, _textChildren)) { 5665 throw new Error("Text divs and strings have not been set."); 5666 } 5667 5668 _classPrivateFieldSet(this, _enabled, true); 5669 5670 _classPrivateFieldSet(this, _textChildren, _classPrivateFieldGet(this, _textChildren).slice()); 5671 5672 _classPrivateFieldGet(this, _textChildren).sort(_classStaticPrivateMethodGet(TextAccessibilityManager, TextAccessibilityManager, _compareElementPositions)); 5673 5674 if (_classPrivateFieldGet(this, _textNodes).size > 0) { 5675 const textChildren = _classPrivateFieldGet(this, _textChildren); 5676 5677 for (const [id, nodeIndex] of _classPrivateFieldGet(this, _textNodes)) { 5678 const element = document.getElementById(id); 5679 5680 if (!element) { 5681 _classPrivateFieldGet(this, _textNodes).delete(id); 5682 5683 continue; 5684 } 5685 5686 _classPrivateMethodGet(this, _addIdToAriaOwns, _addIdToAriaOwns2).call(this, id, textChildren[nodeIndex]); 5687 } 5688 } 5689 5690 for (const [element, isRemovable] of _classPrivateFieldGet(this, _waitingElements)) { 5691 this.addPointerInTextLayer(element, isRemovable); 5692 } 5693 5694 _classPrivateFieldGet(this, _waitingElements).clear(); 5695 } 5696 5697 disable() { 5698 if (!_classPrivateFieldGet(this, _enabled)) { 5699 return; 5700 } 5701 5702 _classPrivateFieldGet(this, _waitingElements).clear(); 5703 5704 _classPrivateFieldSet(this, _textChildren, null); 5705 5706 _classPrivateFieldSet(this, _enabled, false); 5707 } 5708 5709 removePointerInTextLayer(element) { 5710 var _owns; 5711 5712 if (!_classPrivateFieldGet(this, _enabled)) { 5713 _classPrivateFieldGet(this, _waitingElements).delete(element); 5714 5715 return; 5716 } 5717 5718 const children = _classPrivateFieldGet(this, _textChildren); 5719 5720 if (!children || children.length === 0) { 5721 return; 5722 } 5723 5724 const { 5725 id 5726 } = element; 5727 5728 const nodeIndex = _classPrivateFieldGet(this, _textNodes).get(id); 5729 5730 if (nodeIndex === undefined) { 5731 return; 5732 } 5733 5734 const node = children[nodeIndex]; 5735 5736 _classPrivateFieldGet(this, _textNodes).delete(id); 5737 5738 let owns = node.getAttribute("aria-owns"); 5739 5740 if ((_owns = owns) !== null && _owns !== void 0 && _owns.includes(id)) { 5741 owns = owns.split(" ").filter(x => x !== id).join(" "); 5742 5743 if (owns) { 5744 node.setAttribute("aria-owns", owns); 5745 } else { 5746 node.removeAttribute("aria-owns"); 5747 node.setAttribute("role", "presentation"); 5748 } 5749 } 5750 } 5751 5752 addPointerInTextLayer(element, isRemovable) { 5753 const { 5754 id 5755 } = element; 5756 5757 if (!id) { 5758 return; 5759 } 5760 5761 if (!_classPrivateFieldGet(this, _enabled)) { 5762 _classPrivateFieldGet(this, _waitingElements).set(element, isRemovable); 5763 5764 return; 5765 } 5766 5767 if (isRemovable) { 5768 this.removePointerInTextLayer(element); 5769 } 5770 5771 const children = _classPrivateFieldGet(this, _textChildren); 5772 5773 if (!children || children.length === 0) { 5774 return; 5775 } 5776 5777 const index = (0, _ui_utils.binarySearchFirstItem)(children, node => _classStaticPrivateMethodGet(TextAccessibilityManager, TextAccessibilityManager, _compareElementPositions).call(TextAccessibilityManager, element, node) < 0); 5778 const nodeIndex = Math.max(0, index - 1); 5779 5780 _classPrivateMethodGet(this, _addIdToAriaOwns, _addIdToAriaOwns2).call(this, id, children[nodeIndex]); 5781 5782 _classPrivateFieldGet(this, _textNodes).set(id, nodeIndex); 5783 } 5784 5785 moveElementInDOM(container, element, contentElement, isRemovable) { 5786 this.addPointerInTextLayer(contentElement, isRemovable); 5787 5788 if (!container.hasChildNodes()) { 5789 container.append(element); 5790 return; 5791 } 5792 5793 const children = Array.from(container.childNodes).filter(node =>
5793 node !== element); 5794 5795 if (children.length === 0) { 5796 return; 5797 } 5798 5799 const elementToCompare = contentElement || element; 5800 const index = (0, _ui_utils.binarySearchFirstItem)(children, node => _classStaticPrivateMethodGet(TextAccessibilityManager, TextAccessibilityManager, _compareElementPositions).call(TextAccessibilityManager, elementToCompare, node) < 0); 5801 5802 if (index === 0) { 5803 children[0].before(element); 5804 } else { 5805 children[index - 1].after(element); 5806 } 5807 } 5808 5809} 5810 5811exports.TextAccessibilityManager = TextAccessibilityManager; 5812 5813function _compareElementPositions(e1, e2) { 5814 const rect1 = e1.getBoundingClientRect(); 5815 const rect2 = e2.getBoundingClientRect(); 5816 5817 if (rect1.width === 0 && rect1.height === 0) { 5818 return +1; 5819 } 5820 5821 if (rect2.width === 0 && rect2.height === 0) { 5822 return -1; 5823 } 5824 5825 const top1 = rect1.y; 5826 const bot1 = rect1.y + rect1.height; 5827 const mid1 = rect1.y + rect1.height / 2; 5828 const top2 = rect2.y; 5829 const bot2 = rect2.y + rect2.height; 5830 const mid2 = rect2.y + rect2.height / 2; 5831 5832 if (mid1 <= top2 && mid2 >= bot1) { 5833 return -1; 5834 } 5835 5836 if (mid2 <= top1 && mid1 >= bot2) { 5837 return +1; 5838 } 5839 5840 const centerX1 = rect1.x + rect1.width / 2; 5841 const centerX2 = rect2.x + rect2.width / 2; 5842 return centerX1 - centerX2; 5843} 5844 5845function _addIdToAriaOwns2(id, node) { 5846 const owns = node.getAttribute("aria-owns"); 5847 5848 if (!(owns !== null && owns !== void 0 && owns.includes(id))) { 5849 node.setAttribute("aria-owns", owns ? `${owns} ${id}` : id); 5850 } 5851 5852 node.removeAttribute("role"); 5853} 5854 5855/***/ }), 5856/* 16 */ 5857/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 5858 5859 5860 5861Object.defineProperty(exports, "__esModule", ({ 5862 value: true 5863})); 5864exports.PDFRenderingQueue = void 0; 5865 5866var _pdfjsLib = __w_pdfjs_require__(3); 5867 5868var _ui_utils = __w_pdfjs_require__(7); 5869 5870const CLEANUP_TIMEOUT = 30000; 5871 5872class PDFRenderingQueue { 5873 constructor() { 5874 this.pdfViewer = null; 5875 this.pdfThumbnailViewer = null; 5876 this.onIdle = null; 5877 this.highestPriorityPage = null; 5878 this.idleTimeout = null; 5879 this.printing = false; 5880 this.isThumbnailViewEnabled = false; 5881 } 5882 5883 setViewer(pdfViewer) { 5884 this.pdfViewer = pdfViewer; 5885 } 5886 5887 setThumbnailViewer(pdfThumbnailViewer) { 5888 this.pdfThumbnailViewer = pdfThumbnailViewer; 5889 } 5890 5891 isHighestPriority(view) { 5892 return this.highestPriorityPage === view.renderingId; 5893 } 5894 5895 hasViewer() { 5896 return !!this.pdfViewer; 5897 } 5898 5899 renderHighestPriority(currentlyVisiblePages) { 5900 var _this$pdfThumbnailVie; 5901 5902 if (this.idleTimeout) { 5903 clearTimeout(this.idleTimeout); 5904 this.idleTimeout = null; 5905 } 5906 5907 if (this.pdfViewer.forceRendering(currentlyVisiblePages)) { 5908 return; 5909 } 5910 5911 if (this.isThumbnailViewEnabled && (_this$pdfThumbnailVie = this.pdfThumbnailViewer) !== null && _this$pdfThumbnailVie !== void 0 && _this$pdfThumbnailVie.forceRendering()) { 5912 return; 5913 } 5914 5915 if (this.printing) { 5916 return; 5917 } 5918 5919 if (this.onIdle) { 5920 this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT); 5921 } 5922 } 5923 5924 getHighestPriority(visible, views, scrolledDown) { 5925 let preRenderExtra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; 5926 const visibleViews = visible.views, 5927 numVisible = visibleViews.length; 5928 5929 if (numVisible === 0) { 5930 return null; 5931 } 5932 5933 for (let i = 0; i < numVisible; i++) { 5934 const view = visibleViews[i].view; 5935 5936 if (!this.isViewFinished(view)) { 5937 return view; 5938 } 5939 } 5940 5941 const firstId = visible.first.id, 5942 lastId = visible.last.id; 5943 5944 if (lastId - firstId + 1 > numVisible) { 5945 const visibleIds = visible.ids; 5946 5947 for (let i = 1, ii = lastId - firstId; i < ii; i++) { 5948 const holeId = scrolledDown ? firstId + i : lastId - i; 5949 5950 if (visibleIds.has(holeId)) { 5951 continue; 5952 } 5953 5954 const holeView = views[holeId - 1]; 5955 5956 if (!this.isViewFinished(holeView)) { 5957 return holeView; 5958 } 5959 } 5960 } 5961 5962 let preRenderIndex = scrolledDown ? lastId : firstId - 2; 5963 let preRenderView = views[preRenderIndex]; 5964 5965 if (preRenderView && !this.isViewFinished(preRenderView)) { 5966 return preRenderView; 5967 } 5968 5969 if (preRenderExtra) { 5970 preRenderIndex += scrolledDown ? 1 : -1; 5971 preRenderView = views[preRenderIndex]; 5972 5973 if (preRenderView && !this.isViewFinished(preRenderView)) { 5974 return preRenderView; 5975 } 5976 } 5977 5978 return null; 5979 } 5980 5981 isViewFinished(view) { 5982 return view.renderingState === _ui_utils.RenderingStates.FINISHED; 5983 } 5984 5985 renderView(view) { 5986 switch (view.renderingState) { 5987 case _ui_utils.RenderingStates.FINISHED: 5988 return false;
5989 5990 case _ui_utils.RenderingStates.PAUSED: 5991 this.highestPriorityPage = view.renderingId; 5992 view.resume(); 5993 break; 5994 5995 case _ui_utils.RenderingStates.RUNNING: 5996 this.highestPriorityPage = view.renderingId; 5997 break; 5998 5999 case _ui_utils.RenderingStates.INITIAL: 6000 this.highestPriorityPage = view.renderingId; 6001 view.draw().finally(() => { 6002 this.renderHighestPriority(); 6003 }).catch(reason => { 6004 if (reason instanceof _pdfjsLib.RenderingCancelledException) { 6005 return; 6006 } 6007 6008 console.error(`renderView: "${reason}"`); 6009 }); 6010 break; 6011 } 6012 6013 return true; 6014 } 6015 6016} 6017 6018exports.PDFRenderingQueue = PDFRenderingQueue; 6019 6020/***/ }), 6021/* 17 */ 6022/***/ ((__unused_webpack_module, exports) => { 6023 6024 6025 6026Object.defineProperty(exports, "__esModule", ({ 6027 value: true 6028})); 6029exports.TextHighlighter = void 0; 6030 6031class TextHighlighter { 6032 constructor(_ref) { 6033 let { 6034 findController, 6035 eventBus, 6036 pageIndex 6037 } = _ref; 6038 this.findController = findController; 6039 this.matches = []; 6040 this.eventBus = eventBus; 6041 this.pageIdx = pageIndex; 6042 this._onUpdateTextLayerMatches = null; 6043 this.textDivs = null; 6044 this.textContentItemsStr = null; 6045 this.enabled = false; 6046 } 6047 6048 setTextMapping(divs, texts) { 6049 this.textDivs = divs; 6050 this.textContentItemsStr = texts; 6051 } 6052 6053 enable() { 6054 if (!this.textDivs || !this.textContentItemsStr) { 6055 throw new Error("Text divs and strings have not been set."); 6056 } 6057 6058 if (this.enabled) { 6059 throw new Error("TextHighlighter is already enabled."); 6060 } 6061 6062 this.enabled = true; 6063 6064 if (!this._onUpdateTextLayerMatches) { 6065 this._onUpdateTextLayerMatches = evt => { 6066 if (evt.pageIndex === this.pageIdx || evt.pageIndex === -1) { 6067 this._updateMatches(); 6068 } 6069 }; 6070 6071 this.eventBus._on("updatetextlayermatches", this._onUpdateTextLayerMatches); 6072 } 6073 6074 this._updateMatches(); 6075 } 6076 6077 disable() { 6078 if (!this.enabled) { 6079 return; 6080 } 6081 6082 this.enabled = false; 6083 6084 if (this._onUpdateTextLayerMatches) { 6085 this.eventBus._off("updatetextlayermatches", this._onUpdateTextLayerMatches); 6086 6087 this._onUpdateTextLayerMatches = null; 6088 } 6089 } 6090 6091 _convertMatches(matches, matchesLength) { 6092 if (!matches) { 6093 return []; 6094 } 6095 6096 const { 6097 textContentItemsStr 6098 } = this; 6099 let i = 0, 6100 iIndex = 0; 6101 const end = textContentItemsStr.length - 1; 6102 const result = []; 6103 6104 for (let m = 0, mm = matches.length; m < mm; m++) { 6105 let matchIdx = matches[m]; 6106 6107 while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) { 6108 iIndex += textContentItemsStr[i].length; 6109 i++; 6110 } 6111 6112 if (i === textContentItemsStr.length) { 6113 console.error("Could not find a matching mapping"); 6114 } 6115 6116 const match = { 6117 begin: { 6118 divIdx: i,
6119 offset: matchIdx - iIndex 6120 } 6121 }; 6122 matchIdx += matchesLength[m]; 6123 6124 while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) { 6125 iIndex += textContentItemsStr[i].length; 6126 i++; 6127 } 6128 6129 match.end = { 6130 divIdx: i, 6131 offset: matchIdx - iIndex 6132 }; 6133 result.push(match); 6134 } 6135 6136 return result; 6137 } 6138 6139 _renderMatches(matches) { 6140 if (matches.length === 0) { 6141 return; 6142 } 6143 6144 const { 6145 findController, 6146 pageIdx 6147 } = this; 6148 const { 6149 textContentItemsStr, 6150 textDivs 6151 } = this; 6152 const isSelectedPage = pageIdx === findController.selected.pageIdx; 6153 const selectedMatchIdx = findController.selected.matchIdx; 6154 const highlightAll = findController.state.highlightAll; 6155 let prevEnd = null; 6156 const infinity = { 6157 divIdx: -1, 6158 offset: undefined 6159 }; 6160 6161 function beginText(begin, className) { 6162 const divIdx = begin.divIdx; 6163 textDivs[divIdx].textContent = ""; 6164 return appendTextToDiv(divIdx, 0, begin.offset, className); 6165 } 6166 6167 function appendTextToDiv(divIdx, fromOffset, toOffset, className) { 6168 let div = textDivs[divIdx]; 6169 6170 if (div.nodeType === Node.TEXT_NODE) { 6171 const span = document.createElement("span"); 6172 div.before(span); 6173 span.append(div); 6174 textDivs[divIdx] = span; 6175 div = span; 6176 } 6177 6178 const content = textContentItemsStr[divIdx].substring(fromOffset, toOffset); 6179 const node = document.createTextNode(content); 6180 6181 if (className) { 6182 const span = document.createElement("span"); 6183 span.className = `${className} appended`; 6184 span.append(node); 6185 div.append(span); 6186 return className.includes("selected") ? span.offsetLeft : 0; 6187 } 6188 6189 div.append(node); 6190 return 0; 6191 } 6192 6193 let i0 = selectedMatchIdx, 6194 i1 = i0 + 1; 6195 6196 if (highlightAll) { 6197 i0 = 0; 6198 i1 = matches.length; 6199 } else if (!isSelectedPage) { 6200 return; 6201 } 6202 6203 for (let i = i0; i < i1; i++) { 6204 const match = matches[i]; 6205 const begin = match.begin; 6206 const end = match.end; 6207 const isSelected = isSelectedPage && i === selectedMatchIdx; 6208 const highlightSuffix = isSelected ? " selected" : ""; 6209 let selectedLeft = 0; 6210 6211 if (!prevEnd || begin.divIdx !== prevEnd.divIdx) { 6212 if (prevEnd !== null) { 6213 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); 6214 } 6215 6216 beginText(begin); 6217 } else { 6218 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset); 6219 } 6220 6221 if (begin.divIdx === end.divIdx) { 6222 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, end.offset, "highlight" + highlightSuffix); 6223 } else { 6224 selectedLeft = appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, "highlight begin" + highlightSuffix); 6225 6226 for (let n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) { 6227 textDivs[n0].className = "highlight middle" + highlightSuffix; 6228 } 6229 6230 beginText(end, "highlight end" + highlightSuffix); 6231 } 6232 6233 prevEnd = end; 6234 6235 if (isSelected) { 6236 findController.scrollMatchIntoView({ 6237 element: textDivs[begin.divIdx], 6238 selectedLeft, 6239 pageIndex: pageIdx, 6240 matchIndex: selectedMatchIdx 6241 }); 6242 } 6243 } 6244 6245 if (prevEnd) { 6246 appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset); 6247 } 6248 } 6249 6250 _updateMatches() { 6251 if (!this.enabled) { 6252 return; 6253 } 6254 6255 const { 6256 findController, 6257 matches, 6258 pageIdx 6259 } = this; 6260 const { 6261 textContentItemsStr, 6262 textDivs 6263 } = this; 6264 let clearedUntilDivIdx = -1; 6265 6266 for (let i = 0, ii = matches.length; i < ii; i++) { 6267 const match = matches[i]; 6268 const begin = Math.max(clearedUntilDivIdx, match.begin.divIdx); 6269 6270 for (let n = begin, end = match.end.divIdx; n <= end; n++) { 6271 const div = textDivs[n]; 6272 div.textContent = textContentItemsStr[n]; 6273 div.className = ""; 6274 } 6275 6276 clearedUntilDivIdx = match.end.divIdx + 1; 6277 } 6278 6279 if (!(findController !== null && findController !== void 0 && findController.highlightMatches)) { 6280 return; 6281 } 6282 6283 const pageMatches = findController.pageMatches[pageIdx] || null; 6284 const pageMatchesLength = findController.pageMatchesLength[pageIdx] || null; 6285 this.matches = this._convertMatches(pageMatches, pageMatchesLength); 6286 6287 this._renderMatches(this.matches); 6288 } 6289 6290} 6291 6292exports.TextHighlighter = TextHighlighter; 6293 6294/***/ }), 6295/* 18 */ 6296/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 6297 6298 6299 6300Object.defineProperty(exports, "__esModule", ({ 6301 value: true 6302})); 6303exports.DownloadManager = void 0; 6304 6305var _pdfjsLib = __w_pdfjs_require__(3); 6306 6307; 6308 6309function download(blobUrl, filename) { 6310 const a = document.createElement("a"); 6311 6312 if (!a.click) { 6313 throw new Error('DownloadManager: "a.click()" is not supported.'); 6314 } 6315 6316 a.href = blobUrl; 6317 a.target = "_parent"; 6318 6319 if ("download" in a) { 6320 a.download = filename; 6321 } 6322 6323 (document.body || document.documentElement).append(a); 6324 a.click(); 6325 a.remove(); 6326} 6327 6328class DownloadManager { 6329 constructor() { 6330 this._openBlobUrls = new WeakMap(); 6331 } 6332 6333 downloadUrl(url, filename) { 6334 if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, "http://example.com")) { 6335 console.error(`downloadUrl - not a valid URL: ${url}`); 6336 return; 6337 } 6338 6339 download(url + "#pdfjs.action=download", filename); 6340 } 6341 6342 downloadData(data, filename, contentType) { 6343 const blobUrl = URL.createObjectURL(new Blob([data], { 6344 type: contentType 6345 })); 6346 download(blobUrl, filename); 6347 } 6348 6349 openOrDownloadData(element, data, filename) { 6350 const isPdfData = (0, _pdfjsLib.isPdfFile)(filename); 6351 const contentType = isPdfData ? "application/pdf" : ""; 6352 6353 if (isPdfData) { 6354 let blobUrl = this._openBlobUrls.get(element); 6355 6356 if (!blobUrl) { 6357 blobUrl = URL.createObjectURL(new Blob([data], { 6358 type: contentType 6359 })); 6360 6361 this._openBlobUrls.set(element, blobUrl); 6362 } 6363 6364 let viewerUrl; 6365 viewerUrl = "?file=" + encodeURIComponent(blobUrl + "#" + filename); 6366
6367 try { 6368 window.open(viewerUrl); 6369 return true; 6370 } catch (ex) { 6371 console.error(`openOrDownloadData: ${ex}`); 6372 URL.revokeObjectURL(blobUrl); 6373 6374 this._openBlobUrls.delete(element); 6375 } 6376 } 6377 6378 this.downloadData(data, filename, contentType); 6379 return false; 6380 } 6381 6382 download(blob, url, filename) { 6383 const blobUrl = URL.createObjectURL(blob); 6384 download(blobUrl, filename); 6385 } 6386 6387} 6388 6389exports.DownloadManager = DownloadManager; 6390 6391/***/ }), 6392/* 19 */ 6393/***/ ((__unused_webpack_module, exports) => { 6394 6395 6396 6397Object.defineProperty(exports, "__esModule", ({ 6398 value: true 6399})); 6400exports.WaitOnType = exports.EventBus = exports.AutomationEventBus = void 0; 6401exports.waitOnEventOrTimeout = waitOnEventOrTimeout; 6402const WaitOnType = { 6403 EVENT: "event", 6404 TIMEOUT: "timeout" 6405}; 6406exports.WaitOnType = WaitOnType; 6407 6408function waitOnEventOrTimeout(_ref) { 6409 let { 6410 target, 6411 name, 6412 delay = 0 6413 } = _ref; 6414 return new Promise(function (resolve, reject) { 6415 if (typeof target !== "object" || !(name && typeof name === "string") || !(Number.isInteger(delay) && delay >= 0)) { 6416 throw new Error("waitOnEventOrTimeout - invalid parameters."); 6417 } 6418 6419 function handler(type) { 6420 if (target instanceof EventBus) { 6421 target._off(name, eventHandler); 6422 } else { 6423 target.removeEventListener(name, eventHandler); 6424 } 6425 6426 if (timeout) { 6427 clearTimeout(timeout); 6428 } 6429 6430 resolve(type); 6431 } 6432 6433 const eventHandler = handler.bind(null, WaitOnType.EVENT); 6434 6435 if (target instanceof EventBus) { 6436 target._on(name, eventHandler); 6437 } else { 6438 target.addEventListener(name, eventHandler); 6439 } 6440 6441 const timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT); 6442 const timeout = setTimeout(timeoutHandler, delay); 6443 }); 6444} 6445 6446class EventBus { 6447 constructor() { 6448 this._listeners = Object.create(null); 6449 } 6450 6451 on(eventName, listener) { 6452 let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6453 6454 this._on(eventName, listener, { 6455 external: true, 6456 once: options === null || options === void 0 ? void 0 : options.once 6457 }); 6458 } 6459 6460 off(eventName, listener) { 6461 let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6462 6463 this._off(eventName, listener, { 6464 external: true, 6465 once: options === null || options === void 0 ? void 0 : options.once 6466 }); 6467 } 6468 6469 dispatch(eventName, data) { 6470 const eventListeners = this._listeners[eventName]; 6471 6472 if (!eventListeners || eventListeners.length === 0) { 6473 return; 6474 } 6475 6476 let externalListeners; 6477 6478 for (const { 6479 listener, 6480 external, 6481 once 6482 } of eventListeners.slice(0)) { 6483 if (once) { 6484 this._off(eventName, listener); 6485 } 6486 6487 if (external) { 6488 (externalListeners || (externalListeners = [])).push(listener); 6489 continue; 6490 } 6491 6492 listener(data); 6493 } 6494 6495 if (externalListeners) { 6496 for (const listener of externalListeners) { 6497 listener(data); 6498 } 6499 6500 externalListeners = null; 6501 } 6502 } 6503 6504 _on(eventName, listener) { 6505 var _this$_listeners; 6506 6507 let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6508 const eventListeners = (_this$_listeners = this._listeners)[eventName] || (_this$_listeners[eventName] = []); 6509 eventListeners.push({ 6510 listener, 6511 external: (options === null || options === void 0 ? void 0 : options.external) === true, 6512 once: (options === null || options === void 0 ? void 0 : options.once) === true 6513 }); 6514 } 6515 6516 _off(eventName, listener) { 6517 let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; 6518 const eventListeners = this._listeners[eventName]; 6519 6520 if (!eventListeners) { 6521 return; 6522 } 6523 6524 for (let i = 0, ii = eventListeners.length; i < ii; i++) { 6525 if (eventListeners[i].listener === listener) { 6526 eventListeners.splice(i, 1); 6527 return; 6528 } 6529 } 6530 } 6531 6532} 6533 6534exports.EventBus = EventBus; 6535 6536class AutomationEventBus extends EventBus { 6537 dispatch(eventName, data) { 6538 throw new Error("Not implemented: AutomationEventBus.dispatch"); 6539 } 6540 6541} 6542 6543exports.AutomationEventBus = AutomationEventBus; 6544 6545/***/ }), 6546/* 20 */ 6547/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 6548 6549 6550 6551Object.defineProperty(exports, "__esModule", ({ 6552 value: true 6553})); 6554exports.GenericL10n = void 0; 6555 6556__w_pdfjs_require__(21); 6557 6558var _l10n_utils = __w_pdfjs_require__(4); 6559 6560const webL10n = document.webL10n; 6561 6562class GenericL10n { 6563 constructor(lang) { 6564 this._lang = lang; 6565 this._ready = new Promise((resolve, reject) => { 6566 webL10n.setLanguage((0, _l10n_utils.fixupLangCode)(lang), (
6566) => { 6567 resolve(webL10n); 6568 }); 6569 }); 6570 } 6571 6572 async getLanguage() { 6573 const l10n = await this._ready; 6574 return l10n.getLanguage(); 6575 } 6576 6577 async getDirection() { 6578 const l10n = await this._ready; 6579 return l10n.getDirection(); 6580 } 6581 6582 async get(key) { 6583 let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 6584 let fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, _l10n_utils.getL10nFallback)(key, args); 6585 const l10n = await this._ready; 6586 return l10n.get(key, args, fallback); 6587 } 6588 6589 async translate(element) { 6590 const l10n = await this._ready; 6591 return l10n.translate(element); 6592 } 6593 6594} 6595 6596exports.GenericL10n = GenericL10n; 6597 6598/***/ }), 6599/* 21 */ 6600/***/ (() => { 6601 6602 6603 6604document.webL10n = function (window, document, undefined) { 6605 var gL10nData = {}; 6606 var gTextData = ''; 6607 var gTextProp = 'textContent'; 6608 var gLanguage = ''; 6609 var gMacros = {}; 6610 var gReadyState = 'loading'; 6611 var gAsyncResourceLoading = true; 6612 6613 function getL10nResourceLinks() { 6614 return document.querySelectorAll('link[type="application/l10n"]'); 6615 } 6616 6617 function getL10nDictionary() { 6618 var script = document.querySelector('script[type="application/l10n"]'); 6619 return script ? JSON.parse(script.innerHTML) : null; 6620 } 6621 6622 function getTranslatableChildren(element) { 6623 return element ? element.querySelectorAll('*[data-l10n-id]') : []; 6624 } 6625 6626 function getL10nAttributes(element) { 6627 if (!element) return {}; 6628 var l10nId = element.getAttribute('data-l10n-id'); 6629 var l10nArgs = element.getAttribute('data-l10n-args'); 6630 var args = {}; 6631 6632 if (l10nArgs) { 6633 try { 6634 args = JSON.parse(l10nArgs); 6635 } catch (e) { 6636 console.warn('could not parse arguments for #' + l10nId); 6637 } 6638 } 6639 6640 return { 6641 id: l10nId, 6642 args: args 6643 }; 6644 } 6645 6646 function xhrLoadText(url, onSuccess, onFailure) { 6647 onSuccess = onSuccess || function _onSuccess(data) {}; 6648 6649 onFailure = onFailure || function _onFailure() {}; 6650 6651 var xhr = new XMLHttpRequest(); 6652 xhr.open('GET', url, gAsyncResourceLoading); 6653 6654 if (xhr.overrideMimeType) { 6655 xhr.overrideMimeType('text/plain; charset=utf-8'); 6656 } 6657 6658 xhr.onreadystatechange = function () { 6659 if (xhr.readyState == 4) { 6660 if (xhr.status == 200 || xhr.status === 0) { 6661 onSuccess(xhr.responseText); 6662 } else { 6663 onFailure(); 6664 } 6665 } 6666 }; 6667 6668 xhr.onerror = onFailure; 6669 xhr.ontimeout = onFailure; 6670 6671 try { 6672 xhr.send(null); 6673 } catch (e) { 6674 onFailure(); 6675 } 6676 } 6677 6678 function parseResource(href, lang, successCallback, failureCallback) { 6679 var baseURL = href.replace(/[^\/]*$/, '') || './'; 6680 6681 function evalString(text) { 6682 if (text.lastIndexOf('\\') < 0) return text;
vendor: 5,840 bytes, lines 6683-6928
6683 return text.replace(/\\\\/g, '\\').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\b/g, '\b').replace(/\\f/g, '\f').replace(/\\{/g, '{').replace(/\\}/g, '}').replace(/\\"/g, '"').replace(/\\'/g, "'"); 6684 } 6685 6686 function parseProperties(text, parsedPropertiesCallback) { 6687 var dictionary = {}; 6688 var reBlank = /^\s*|\s*$/; 6689 var reComment = /^\s*#|^\s*$/; 6690 var reSection = /^\s*\[(.*)\]\s*$/; 6691 var reImport = /^\s*@import\s+url\((.*)\)\s*$/i; 6692 var reSplit = /^([^=\s]*)\s*=\s*(.+)$/; 6693 6694 function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) { 6695 var entries = rawText.replace(reBlank, '').split(/[\r\n]+/); 6696 var currentLang = '*'; 6697 var genericLang = lang.split('-', 1)[0]; 6698 var skipLang = false; 6699 var match = ''; 6700 6701 function nextEntry() { 6702 while (true) { 6703 if (!entries.length) { 6704 parsedRawLinesCallback(); 6705 return; 6706 } 6707 6708 var line = entries.shift(); 6709 if (reComment.test(line)) continue; 6710 6711 if (extendedSyntax) { 6712 match = reSection.exec(line); 6713 6714 if (match) { 6715 currentLang = match[1].toLowerCase(); 6716 skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang; 6717 continue; 6718 } else if (skipLang) { 6719 continue; 6720 } 6721 6722 match = reImport.exec(line); 6723 6724 if (match) { 6725 loadImport(baseURL + match[1], nextEntry); 6726 return; 6727 } 6728 } 6729 6730 var tmp = line.match(reSplit); 6731 6732 if (tmp && tmp.length == 3) { 6733 dictionary[tmp[1]] = evalString(tmp[2]); 6734 } 6735 } 6736 } 6737 6738 nextEntry(); 6739 } 6740 6741 function loadImport(url, callback) { 6742 xhrLoadText(url, function (content) { 6743 parseRawLines(content, false, callback); 6744 }, function () { 6745 console.warn(url + ' not found.'); 6746 callback(); 6747 }); 6748 } 6749 6750 parseRawLines(text, true, function () { 6751 parsedPropertiesCallback(dictionary); 6752 }); 6753 } 6754 6755 xhrLoadText(href, function (response) { 6756 gTextData += response; 6757 parseProperties(response, function (data) { 6758 for (var key in data) { 6759 var id, 6760 prop, 6761 index = key.lastIndexOf('.'); 6762 6763 if (index > 0) { 6764 id = key.substring(0, index); 6765 prop = key.substring(index + 1); 6766 } else { 6767 id = key; 6768 prop = gTextProp; 6769 } 6770 6771 if (!gL10nData[id]) { 6772 gL10nData[id] = {}; 6773 } 6774 6775 gL10nData[id][prop] = data[key]; 6776 } 6777 6778 if (successCallback) { 6779 successCallback(); 6780 } 6781 }); 6782 }, failureCallback); 6783 } 6784 6785 function loadLocale(lang, callback) { 6786 if (lang) { 6787 lang = lang.toLowerCase(); 6788 } 6789 6790 callback = callback || function _callback() {}; 6791 6792 clear(); 6793 gLanguage = lang; 6794 var langLinks = getL10nResourceLinks(); 6795 var langCount = langLinks.length; 6796 6797 if (langCount === 0) { 6798 var dict = getL10nDictionary(); 6799 6800 if (dict && dict.locales && dict.default_locale) { 6801 console.log('using the embedded JSON directory, early way out'); 6802 gL10nData = dict.locales[lang]; 6803 6804 if (!gL10nData) { 6805 var defaultLocale = dict.default_locale.toLowerCase(); 6806 6807 for (var anyCaseLang in dict.locales) { 6808 anyCaseLang = anyCaseLang.toLowerCase(); 6809 6810 if (anyCaseLang === lang) { 6811 gL10nData = dict.locales[lang]; 6812 break; 6813 } else if (anyCaseLang === defaultLocale) { 6814 gL10nData = dict.locales[defaultLocale]; 6815 } 6816 } 6817 } 6818 6819 callback(); 6820 } else { 6821 console.log('no resource to load, early way out'); 6822 } 6823 6824 gReadyState = 'complete'; 6825 return; 6826 } 6827 6828 var onResourceLoaded = null; 6829 var gResourceCount = 0; 6830 6831 onResourceLoaded = function () { 6832 gResourceCount++; 6833 6834 if (gResourceCount >= langCount) { 6835 callback(); 6836 gReadyState = 'complete'; 6837 } 6838 }; 6839 6840 function L10nResourceLink(link) { 6841 var href = link.href; 6842 6843 this.load = function (lang, callback) { 6844 parseResource(href, lang, callback, function () { 6845 console.warn(href + ' not found.'); 6846 console.warn('"' + lang + '" resource not found'); 6847 gLanguage = ''; 6848 callback(); 6849 }); 6850 }; 6851 } 6852 6853 for (var i = 0; i < langCount; i++) { 6854 var resource = new L10nResourceLink(langLinks[i]); 6855 resource.load(lang, onResourceLoaded); 6856 } 6857 } 6858 6859 function clear() { 6860 gL10nData = {}; 6861 gTextData = ''; 6862 gLanguage = ''; 6863 } 6864 6865 function getPluralRules(lang) { 6866 var locales2rules = { 6867 'af': 3, 6868 'ak': 4, 6869 'am': 4, 6870 'ar': 1, 6871 'asa': 3, 6872 'az': 0, 6873 'be': 11, 6874 'bem': 3, 6875 'bez': 3, 6876 'bg': 3, 6877 'bh': 4, 6878 'bm': 0, 6879 'bn': 3, 6880 'bo': 0, 6881 'br': 20, 6882 'brx': 3, 6883 'bs': 11, 6884 'ca': 3, 6885 'cgg': 3, 6886 'chr': 3, 6887 'cs': 12, 6888 'cy': 17, 6889 'da': 3, 6890 'de': 3, 6891 'dv': 3, 6892 'dz': 0, 6893 'ee': 3, 6894 'el': 3, 6895 'en': 3, 6896 'eo': 3, 6897 'es': 3, 6898 'et': 3, 6899 'eu': 3, 6900 'fa': 0, 6901 'ff': 5, 6902 'fi': 3, 6903 'fil': 4, 6904 'fo': 3, 6905 'fr': 5, 6906 'fur': 3, 6907 'fy': 3, 6908 'ga': 8, 6909 'gd': 24, 6910 'gl': 3, 6911 'gsw': 3, 6912 'gu': 3, 6913 'guw': 4, 6914 'gv': 23, 6915 'ha': 3, 6916 'haw': 3, 6917 'he': 2, 6918 'hi': 4, 6919 'hr': 11, 6920 'hu': 0, 6921 'id': 0, 6922 'ig': 0, 6923 'ii': 0, 6924 'is': 3, 6925 'it': 3, 6926 'iu': 7, 6927 'ja': 0, 6928 'jmc': 3,
6929 'jv': 0, 6930 'ka': 0, 6931 'kab': 5, 6932 'kaj': 3, 6933 'kcg': 3, 6934 'kde': 0, 6935 'kea': 0, 6936 'kk': 3, 6937 'kl': 3, 6938 'km': 0, 6939 'kn': 0, 6940 'ko': 0, 6941 'ksb': 3, 6942 'ksh': 21, 6943 'ku': 3, 6944 'kw': 7, 6945 'lag': 18, 6946 'lb': 3, 6947 'lg': 3, 6948 'ln': 4, 6949 'lo': 0, 6950 'lt': 10, 6951 'lv': 6, 6952 'mas': 3, 6953 'mg': 4, 6954 'mk': 16, 6955 'ml': 3, 6956 'mn': 3, 6957 'mo': 9, 6958 'mr': 3, 6959 'ms': 0, 6960 'mt': 15, 6961 'my': 0, 6962 'nah': 3, 6963 'naq': 7, 6964 'nb': 3, 6965 'nd': 3, 6966 'ne': 3, 6967 'nl': 3, 6968 'nn': 3, 6969 'no': 3, 6970 'nr': 3, 6971 'nso': 4, 6972 'ny': 3, 6973 'nyn': 3, 6974 'om': 3, 6975 'or': 3, 6976 'pa': 3, 6977 'pap': 3, 6978 'pl': 13, 6979 'ps': 3, 6980 'pt': 3, 6981 'rm': 3, 6982 'ro': 9, 6983 'rof': 3, 6984 'ru': 11, 6985 'rwk': 3, 6986 'sah': 0, 6987 'saq': 3, 6988 'se': 7, 6989 'seh': 3, 6990 'ses': 0, 6991 'sg': 0, 6992 'sh': 11, 6993 'shi': 19, 6994 'sk': 12, 6995 'sl': 14, 6996 'sma': 7, 6997 'smi': 7, 6998 'smj': 7, 6999 'smn': 7, 7000 'sms': 7, 7001 'sn': 3, 7002 'so': 3, 7003 'sq': 3, 7004 'sr': 11, 7005 'ss': 3, 7006 'ssy': 3, 7007 'st': 3, 7008 'sv': 3, 7009 'sw': 3, 7010 'syr': 3, 7011 'ta': 3, 7012 'te': 3, 7013 'teo': 3, 7014 'th': 0, 7015 'ti': 4, 7016 'tig': 3, 7017 'tk': 3, 7018 'tl': 4, 7019 'tn': 3, 7020 'to': 0, 7021 'tr': 0, 7022 'ts': 3, 7023 'tzm': 22, 7024 'uk': 11, 7025 'ur': 3, 7026 've': 3, 7027 'vi': 0, 7028 'vun': 3, 7029 'wa': 4, 7030 'wae': 3, 7031 'wo': 0, 7032 'xh': 3, 7033 'xog': 3, 7034 'yo': 0, 7035 'zh': 0, 7036 'zu': 3 7037 }; 7038 7039 function isIn(n, list) { 7040 return list.indexOf(n) !== -1; 7041 } 7042 7043 function isBetween(n, start, end) { 7044 return start <= n && n <= end; 7045 } 7046 7047 var pluralRules = { 7048 '0': function (n) { 7049 return 'other'; 7050 }, 7051 '1': function (n) { 7052 if (isBetween(n % 100, 3, 10)) return 'few'; 7053 if (n === 0) return 'zero'; 7054 if (isBetween(n % 100, 11, 99)) return 'many'; 7055 if (n == 2) return 'two'; 7056 if (n == 1) return 'one'; 7057 return 'other'; 7058 }, 7059 '2': function (n) { 7060 if (n !== 0 && n % 10 === 0) return 'many'; 7061 if (n == 2) return 'two'; 7062 if (n == 1) return 'one'; 7063 return 'other'; 7064 }, 7065 '3': function (n) { 7066 if (n == 1) return 'one'; 7067 return 'other'; 7068 }, 7069 '4': function (n) { 7070 if (isBetween(n, 0, 1)) return 'one'; 7071 return 'other'; 7072 }, 7073 '5': function (n) { 7074 if (isBetween(n, 0, 2) && n != 2) return 'one'; 7075 return 'other'; 7076 }, 7077 '6': function (n) { 7078 if (n === 0) return 'zero'; 7079 if (n % 10 == 1 && n % 100 != 11) return 'one'; 7080 return 'other'; 7081 }, 7082 '7': function (n) { 7083 if (n == 2) return 'two'; 7084 if (n == 1) return 'one'; 7085 return 'other'; 7086 }, 7087 '8': function (n) { 7088 if (isBetween(n, 3, 6)) return 'few'; 7089 if (isBetween(n, 7, 10)) return 'many'; 7090 if (n == 2) return 'two'; 7091 if (n == 1) return 'one'; 7092 return 'other'; 7093 }, 7094 '9': function (n) { 7095 if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few'; 7096 if (n == 1) return 'one'; 7097 return 'other'; 7098 }, 7099 '10': function (n) { 7100 if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few'; 7101 if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one'; 7102 return 'other'; 7103 }, 7104 '11': function (n) { 7105 if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few'; 7106 if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many'; 7107 if (n % 10 == 1 && n % 100 != 11) return 'one'; 7108 return 'other'; 7109 }, 7110 '12': function (n) { 7111 if (isBetween(n, 2, 4)) return 'few'; 7112 if (n == 1) return 'one'; 7113 return 'other'; 7114 }, 7115 '13': function (n) { 7116 if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few'; 7117 if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many'; 7118 if (n == 1) return 'one'; 7119 return 'other'; 7120 }, 7121 '14': function (n) { 7122 if (isBetween(n % 100, 3, 4)) return 'few'; 7123 if (n % 100 == 2) return 'two'; 7124 if (n % 100 == 1) return 'one'; 7125 return 'other'; 7126 }, 7127 '15': function (n) { 7128 if (n === 0 || isBetween(n % 100, 2, 10)) return 'few'; 7129 if (isBetween(n % 100, 11, 19)) return 'many'; 7130 if (n == 1) return 'one'; 7131 return 'other'; 7132 }, 7133 '16': function (n) { 7134 if (n % 10 == 1 && n != 11) return 'one'; 7135 return 'other'; 7136 }, 7137 '17': function (n) { 7138 if (n == 3) return 'few'; 7139 if (n === 0) return 'zero'; 7140 if (n == 6) return 'many'; 7141 if (n == 2) return 'two'; 7142 if (n == 1) return 'one'; 7143 return 'other'; 7144 }, 7145 '18': function (n) { 7146 if (n === 0) return 'zero'; 7147 if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one'; 7148 return 'other'; 7149 }, 7150 '19': function (n) { 7151 if (isBetween(n, 2, 10)) return 'few'; 7152 if (isBetween(n, 0, 1)) return 'one'; 7153 return 'other'; 7154 }, 7155 '20': function (n) { 7156 if ((isBetween(n % 10, 3, 4) || n % 10 == 9) && !(isBetween(n % 100, 10, 19) || isBetween(n % 100, 70, 79) || isBetween(n % 100, 90, 99))) return 'few'; 7157 if (n % 1000000 === 0 && n !== 0) return 'many'; 7158 if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two'; 7159 if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one'; 7160 return 'other'; 7161 }, 7162 '21': function (n) { 7163 if (n === 0) return 'zero'; 7164 if (n == 1) return 'one'; 7165 return 'other'; 7166 }, 7167 '22': function (n) { 7168 if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one'; 7169 return 'other'; 7170 }, 7171 '23': function (n) { 7172 if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one'; 7173 return 'other'; 7174 }, 7175 '24': function (n) { 7176 if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few'; 7177 if (isIn(n, [2, 12])) return 'two'; 7178 if (isIn(n, [1, 11])) return 'one'; 7179 return 'other'; 7180 } 7181 }; 7182 var index = locales2rules[lang.replace(/-.*$/, '')]; 7183 7184 if (!(index in pluralRules)) { 7185 console.warn('plural form unknown for [' + lang + ']'); 7186 return function () { 7187 return 'other'; 7188 }; 7189 } 7190 7191 return pluralRules[index]; 7192 } 7193 7194 gMacros.plural = function (str, param, key, prop) { 7195 var n = parseFloat(param); 7196 if (isNaN(n)) return str; 7197 if (prop != gTextProp) return str; 7198 7199 if (!gMacros._pluralRules) { 7200 gMacros._pluralRules = getPluralRules(gLanguage); 7201 } 7202 7203 var index = '[' + gMacros._pluralRules(n) + ']'; 7204 7205 if (n === 0 && key + '[zero]' in gL10nData) { 7206 str = gL10nData[key + '[zero]'][prop]; 7207 } else if (n == 1 && key + '[one]' in gL10nData) { 7208 str = gL10nData[key + '[one]'][prop]; 7209 } else if (n == 2 && key + '[two]' in gL10nData) { 7210 str = gL10nData[key + '[two]'][prop]; 7211 } else if (key + index in gL10nData) { 7212 str = gL10nData[key + index][prop]; 7213 } else if (key + '[other]' in gL10nData) { 7214 str = gL10nData[key + '[other]'][prop]; 7215 } 7216 7217 return str; 7218 }; 7219 7220 function getL10nData(key, args, fallback) { 7221 var data = gL10nData[key]; 7222 7223 if (!data) { 7224 console.warn('#' + key + ' is undefined.'); 7225 7226 if (!fallback) { 7227 return null; 7228 } 7229 7230 data = fallback; 7231 } 7232 7233 var rv = {}; 7234 7235 for (var prop in data) { 7236 var str = data[prop]; 7237 str = substIndexes(str, args, key, prop); 7238 str = substArguments(str, args, key); 7239 rv[prop] = str; 7240 } 7241 7242 return rv; 7243 } 7244 7245 function substIndexes(str, args, key, prop) { 7246 var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/; 7247 var reMatch = reIndex.exec(str); 7248 if (!reMatch || !reMatch.length) return str; 7249 var macroName = reMatch[1]; 7250 var paramName = reMatch[2]; 7251 var param; 7252 7253 if (args && paramName in args) { 7254 param = args[paramName]; 7255 } else if (paramName in gL10nData) { 7256 param = gL10nData[paramName]; 7257 } 7258 7259 if (macroName in gMacros) { 7260 var macro = gMacros[macroName]; 7261 str = macro(str, param, key, prop); 7262 } 7263 7264 return str; 7265 } 7266 7267 function substArguments(str, args, key) { 7268 var reArgs = /\{\{\s*(.+?)\s*\}\}/g; 7269 return str.replace(reArgs, function (matched_text, arg) { 7270 if (args && arg in args) { 7271 return args[arg]; 7272 } 7273 7274 if (arg in gL10nData) { 7275 return gL10nData[arg]; 7276 } 7277 7278 console.log('argument {{' + arg + '}} for #' + key + ' is undefined.'); 7279 return matched_text; 7280 }); 7281 } 7282 7283 function translateElement(element) { 7284 var l10n = getL10nAttributes(element); 7285 if (!l10n.id) return; 7286 var data = getL10nData(l10n.id, l10n.args); 7287 7288 if (!data) { 7289 console.warn('#' + l10n.id + ' is undefined.'); 7290 return; 7291 } 7292 7293 if (data[gTextProp]) { 7294 if (getChildElementCount(element) === 0) { 7295 element[gTextProp] = data[gTextProp]; 7296 } else { 7297 var children = element.childNodes; 7298 var found = false;
7299 7300 for (var i = 0, l = children.length; i < l; i++) { 7301 if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) { 7302 if (found) { 7303 children[i].nodeValue = ''; 7304 } else { 7305 children[i].nodeValue = data[gTextProp]; 7306 found = true; 7307 } 7308 } 7309 } 7310 7311 if (!found) { 7312 var textNode = document.createTextNode(data[gTextProp]); 7313 element.prepend(textNode); 7314 } 7315 } 7316 7317 delete data[gTextProp]; 7318 } 7319 7320 for (var k in data) { 7321 element[k] = data[k]; 7322 } 7323 } 7324 7325 function getChildElementCount(element) { 7326 if (element.children) { 7327 return element.children.length; 7328 } 7329 7330 if (typeof element.childElementCount !== 'undefined') { 7331 return element.childElementCount; 7332 } 7333 7334 var count = 0; 7335 7336 for (var i = 0; i < element.childNodes.length; i++) { 7337 count += element.nodeType === 1 ? 1 : 0; 7338 } 7339 7340 return count; 7341 } 7342 7343 function translateFragment(element) { 7344 element = element || document.documentElement; 7345 var children = getTranslatableChildren(element); 7346 var elementCount = children.length; 7347 7348 for (var i = 0; i < elementCount; i++) { 7349 translateElement(children[i]); 7350 } 7351 7352 translateElement(element); 7353 } 7354 7355 return { 7356 get: function (key, args, fallbackString) { 7357 var index = key.lastIndexOf('.'); 7358 var prop = gTextProp; 7359 7360 if (index > 0) { 7361 prop = key.substring(index + 1); 7362 key = key.substring(0, index); 7363 } 7364 7365 var fallback; 7366 7367 if (fallbackString) { 7368 fallback = {}; 7369 fallback[prop] = fallbackString; 7370 } 7371 7372 var data = getL10nData(key, args, fallback); 7373 7374 if (data && prop in data) { 7375 return data[prop]; 7376 } 7377 7378 return '{{' + key + '}}'; 7379 }, 7380 getData: function () { 7381 return gL10nData; 7382 }, 7383 getText: function () { 7384 return gTextData; 7385 }, 7386 getLanguage: function () { 7387 return gLanguage; 7388 }, 7389 setLanguage: function (lang, callback) { 7390 loadLocale(lang, function () { 7391 if (callback) callback(); 7392 }); 7393 }, 7394 getDirection: function () { 7395 var rtlList = ['ar', 'he', 'fa', 'ps', 'ur']; 7396 var shortCode = gLanguage.split('-', 1)[0]; 7397 return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr'; 7398 }, 7399 translate: translateFragment, 7400 getReadyState: function () { 7401 return gReadyState; 7402 }, 7403 ready: function (callback) { 7404 if (!callback) { 7405 return; 7406 } else if (gReadyState == 'complete' || gReadyState == 'interactive') { 7407 window.setTimeout(function () { 7408 callback(); 7409 }); 7410 } else if (document.addEventListener) { 7411 document.addEventListener('localized', function once() { 7412 document.removeEventListener('localized', once); 7413 callback(); 7414 }); 7415 } 7416 } 7417 }; 7418}(window, document); 7419 7420/***/ }), 7421/* 22 */ 7422/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 7423 7424 7425 7426Object.defineProperty(exports, "__esModule", ({ 7427 value: true 7428})); 7429exports.PDFFindController = exports.FindState = void 0; 7430 7431var _ui_utils = __w_pdfjs_require__(7); 7432 7433var _pdfjsLib = __w_pdfjs_require__(3); 7434 7435var _pdf_find_utils = __w_pdfjs_require__(23); 7436 7437function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } 7438 7439function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } 7440 7441function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } 7442 7443function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } 7444 7445function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } 7446 7447function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } 7448 7449function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } 7450 7451const FindState = { 7452 FOUND: 0, 7453 NOT_FOUND: 1, 7454 WRAPPED: 2, 7455 PENDING: 3 7456}; 7457exports.FindState = FindState; 7458const FIND_TIMEOUT = 250; 7459const MATCH_SCROLL_OFFSET_TOP = -50; 7460const MATCH_SCROLL_OFFSET_LEFT = -400; 7461const CHARACTERS_TO_NORMALIZE = { 7462 "\u2010": "-", 7463 "\u2018": "'", 7464 "\u2019": "'", 7465 "\u201A": "'", 7466 "\u201B": "'", 7467 "\u201C": '"', 7468 "\u201D": '"', 7469 "\u201E": '"', 7470 "\u201F": '"', 7471 "\u00BC": "1/4", 7472 "\u00BD": "1/2", 7473 "\u00BE": "3/4" 7474}; 7475const DIACRITICS_EXCEPTION = new Set([0x3099, 0x309a, 0x094d, 0x09cd, 0x0a4d, 0x0acd, 0x0b4d, 0x0bcd, 0x0c4d, 0x0ccd, 0x0d3b, 0x0d3c, 0x0d4d, 0x0dca, 0x0e3a, 0x0eba, 0x0f84, 0x1039, 0x103a, 0x1714, 0x1
7475734, 0x17d2, 0x1a60, 0x1b44, 0x1baa, 0x1bab, 0x1bf2, 0x1bf3, 0x2d7f, 0xa806, 0xa82c, 0xa8c4, 0xa953, 0xa9c0, 0xaaf6, 0xabed, 0x0c56, 0x0f71, 0x0f72, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f80, 0x0f74]); 7476const DIACRITICS_EXCEPTION_STR = [...DIACRITICS_EXCEPTION.values()].map(x => String.fromCharCode(x)).join(""); 7477const DIACRITICS_REG_EXP = /\p{M}+/gu; 7478const SPECIAL_CHARS_REG_EXP = /([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu; 7479const NOT_DIACRITIC_FROM_END_REG_EXP = /([^\p{M}])\p{M}*$/u; 7480const NOT_DIACRITIC_FROM_START_REG_EXP = /^\p{M}*([^\p{M}])/u; 7481const SYLLABLES_REG_EXP = /[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g; 7482const SYLLABLES_LENGTHS = new Map(); 7483const FIRST_CHAR_SYLLABLES_REG_EXP = "[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]"; 7484let noSyllablesRegExp = null; 7485let withSyllablesRegExp = null; 7486 7487function normalize(text) { 7488 const syllablePositions = []; 7489 let m; 7490 7491 while ((m = SYLLABLES_REG_EXP.exec(text)) !== null) { 7492 let { 7493 index 7494 } = m; 7495 7496 for (const char of m[0]) { 7497 let len = SYLLABLES_LENGTHS.get(char); 7498 7499 if (!len) { 7500 len = char.normalize("NFD").length; 7501 SYLLABLES_LENGTHS.set(char, len); 7502 } 7503 7504 syllablePositions.push([len, index++]); 7505 } 7506 } 7507 7508 let normalizationRegex; 7509 7510 if (syllablePositions.length === 0 && noSyllablesRegExp) { 7511 normalizationRegex = noSyllablesRegExp; 7512 } else if (syllablePositions.length > 0 && withSyllablesRegExp) { 7513 normalizationRegex = withSyllablesRegExp; 7514 } else { 7515 const replace = Object.keys(CHARACTERS_TO_NORMALIZE).join(""); 7516 const regexp = `([${replace}])|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(\\n)`; 7517 7518 if (syllablePositions.length === 0) { 7519 normalizationRegex = noSyllablesRegExp = new RegExp(regexp + "|(\\u0000)", "gum"); 7520 } else { 7521 normalizationRegex = withSyllablesRegExp = new RegExp(regexp + `|(${FIRST_CHAR_SYLLABLES_REG_EXP})`, "gum"); 7522 } 7523 } 7524 7525 const rawDiacriticsPositions = []; 7526 7527 while ((m = DIACRITICS_REG_EXP.exec(text)) !== null) { 7528 rawDiacriticsPositions.push([m[0].length, m.index]); 7529 } 7530 7531 let normalized = text.normalize("NFD"); 7532 const positions = [[0, 0]]; 7533 let rawDiacriticsIndex = 0; 7534 let syllableIndex = 0; 7535 let shift = 0; 7536 let shiftOrigin = 0; 7537 let eol = 0;
7538 let hasDiacritics = false; 7539 normalized = normalized.replace(normalizationRegex, (match, p1, p2, p3, p4, p5, i) => { 7540 var _syllablePositions$sy; 7541 7542 i -= shiftOrigin; 7543 7544 if (p1) { 7545 const replacement = CHARACTERS_TO_NORMALIZE[match]; 7546 const jj = replacement.length; 7547 7548 for (let j = 1; j < jj; j++) { 7549 positions.push([i - shift + j, shift - j]); 7550 } 7551 7552 shift -= jj - 1; 7553 return replacement; 7554 } 7555 7556 if (p2) { 7557 var _rawDiacriticsPositio; 7558 7559 const hasTrailingDashEOL = p2.endsWith("\n"); 7560 const len = hasTrailingDashEOL ? p2.length - 2 : p2.length; 7561 hasDiacritics = true; 7562 let jj = len; 7563 7564 if (i + eol === ((_rawDiacriticsPositio = rawDiacriticsPositions[rawDiacriticsIndex]) === null || _rawDiacriticsPositio === void 0 ? void 0 : _rawDiacriticsPositio[1])) { 7565 jj -= rawDiacriticsPositions[rawDiacriticsIndex][0]; 7566 ++rawDiacriticsIndex; 7567 } 7568 7569 for (let j = 1; j <= jj; j++) { 7570 positions.push([i - 1 - shift + j, shift - j]); 7571 } 7572 7573 shift -= jj; 7574 shiftOrigin += jj; 7575 7576 if (hasTrailingDashEOL) { 7577 i += len - 1; 7578 positions.push([i - shift + 1, 1 + shift]); 7579 shift += 1; 7580 shiftOrigin += 1; 7581 eol += 1; 7582 return p2.slice(0, len); 7583 } 7584 7585 return p2; 7586 } 7587 7588 if (p3) { 7589 positions.push([i - shift + 1, 1 + shift]); 7590 shift += 1; 7591 shiftOrigin += 1; 7592 eol += 1; 7593 return p3.charAt(0); 7594 } 7595 7596 if (p4) { 7597 positions.push([i - shift + 1, shift - 1]); 7598 shift -= 1; 7599 shiftOrigin += 1; 7600 eol += 1; 7601 return " "; 7602 } 7603 7604 if (i + eol === ((_syllablePositions$sy = syllablePositions[syllableIndex]) === null || _syllablePositions$sy === void 0 ? void 0 : _syllablePositions$sy[1])) { 7605 const newCharLen = syllablePositions[syllableIndex][0] - 1; 7606 ++syllableIndex; 7607 7608 for (let j = 1; j <= newCharLen; j++) { 7609 positions.push([i - (shift - j), shift - j]); 7610 } 7611 7612 shift -= newCharLen; 7613 shiftOrigin += newCharLen; 7614 } 7615 7616 return p5; 7617 }); 7618 positions.push([normalized.length, shift]); 7619 return [normalized, positions, hasDiacritics]; 7620} 7621 7622function getOriginalIndex(diffs, pos, len) { 7623 if (!diffs) { 7624 return [pos, len]; 7625 } 7626 7627 const start = pos; 7628 const end = pos + len; 7629 let i = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= start); 7630 7631 if (diffs[i][0] > start) { 7632 --i; 7633 } 7634 7635 let j = (0, _ui_utils.binarySearchFirstItem)(diffs, x => x[0] >= end, i); 7636 7637 if (diffs[j][0] > end) { 7638 --j; 7639 } 7640 7641 return [start + diffs[i][1], len + diffs[j][1] - diffs[i][1]]; 7642} 7643 7644var _onFind = /*#__PURE__*/new WeakSet(); 7645 7646var _reset = /*#__PURE__*/new WeakSet(); 7647 7648var _query = /*#__PURE__*/new WeakMap(); 7649 7650var _shouldDirtyMatch = /*#__PURE__*/new WeakSet(); 7651 7652var _isEntireWord = /*#__PURE__*/new WeakSet(); 7653 7654var _calculateRegExpMatch = /*#__PURE__*/new WeakSet(); 7655 7656var _convertToRegExpString = /*#__PURE__*/new WeakSet(); 7657 7658var _calculateMatch = /*#__PURE__*/new WeakSet(); 7659 7660var _extractText = /*#__PURE__*/new WeakSet(); 7661 7662var _updatePage = /*#__PURE__*/new WeakSet(); 7663 7664var _updateAllPages = /*#__PURE__*/new WeakSet(); 7665 7666var _nextMatch = /*#__PURE__*/new WeakSet(); 7667 7668var _matchesReady = /*#__PURE__*/new WeakSet(); 7669 7670var _nextPageMatch = /*#__PURE__*/new WeakSet(); 7671 7672var _advanceOffsetPage = /*#__PURE__*/new WeakSet(); 7673 7674var _updateMatch = /*#__PURE__*/new WeakSet(); 7675 7676var _onFindBarClose = /*#__PURE__*/new WeakSet(); 7677 7678var _requestMatchesCount = /*#__PURE__*/new WeakSet(); 7679 7680var _updateUIResultsCount = /*#__PURE__*/new WeakSet(); 7681 7682var _updateUIState = /*#__PURE__*/new WeakSet(); 7683 7684class PDFFindController { 7685 constructor(_ref) { 7686 let { 7687 linkService: _linkService, 7688 eventBus 7689 } = _ref; 7690 7691 _classPrivateMethodInitSpec(this, _updateUIState); 7692 7693 _classPrivateMethodInitSpec(this, _updateUIResultsCount); 7694 7695 _classPrivateMethodInitSpec(this, _requestMatchesCount); 7696 7697 _classPrivateMethodInitSpec(this, _onFindBarClose); 7698 7699 _classPrivateMethodInitSpec(this, _updateMatch); 7700 7701 _classPrivateMethodInitSpec(this, _advanceOffsetPage); 7702 7703 _classPrivateMethodInitSpec(this, _nextPageMatch); 7704 7705 _classPrivateMethodInitSpec(this, _matchesReady); 7706 7707 _classPrivateMethodInitSpec(this, _nextMatch); 7708 7709 _classPrivateMethodInitSpec(this, _updateAllPages); 7710 7711 _classPrivateMethodInitSpec(this, _updatePage); 7712 7713 _classPrivateMethodInitSpec(this, _extractText); 7714 7715 _classPrivateMethodInitSpec(this, _calculateMatch); 7716 7717 _classPrivateMethodInitSpec(this, _convertToRegExpString); 7718 7719 _classPrivateMethodInitSpec(this, _calculateRegExpMatch); 7720 7721 _classPrivateMethodInitSpec(this, _isEntireWord); 7722 7723 _classPrivateMethodInitSpec(this, _shouldDirtyMatch); 7724 7725 _classPrivateFieldInitSpec(this, _query, { 7726 get: _get_query, 7727 set: void 0 7728 }); 7729 7730 _classPrivateMethodInitSpec(this, _reset); 7731 7732 _classPrivateMethodInitSpec(this, _onFind); 7733 7734 this._linkService = _linkService; 7735 this._eventBus = eventBus; 7736 7737 _classPrivateMethodGet(this, _reset, _reset2).call(this); 7738 7739 eventBus._on("find", _classPrivateMethodGet(this, _onFind, _onFind2).bind(this)); 7740 7741 eventBus._on("findbarclose", _classPrivateMethodGet(this, _onFind
7741BarClose, _onFindBarClose2).bind(this)); 7742 } 7743 7744 get highlightMatches() { 7745 return this._highlightMatches; 7746 } 7747 7748 get pageMatches() { 7749 return this._pageMatches; 7750 } 7751 7752 get pageMatchesLength() { 7753 return this._pageMatchesLength; 7754 } 7755 7756 get selected() { 7757 return this._selected; 7758 } 7759 7760 get state() { 7761 return this._state; 7762 } 7763 7764 setDocument(pdfDocument) { 7765 if (this._pdfDocument) { 7766 _classPrivateMethodGet(this, _reset, _reset2).call(this); 7767 } 7768 7769 if (!pdfDocument) { 7770 return; 7771 } 7772 7773 this._pdfDocument = pdfDocument; 7774 7775 this._firstPageCapability.resolve(); 7776 } 7777 7778 scrollMatchIntoView(_ref2) { 7779 let { 7780 element = null, 7781 selectedLeft = 0, 7782 pageIndex = -1, 7783 matchIndex = -1 7784 } = _ref2; 7785 7786 if (!this._scrollMatches || !element) { 7787 return; 7788 } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) { 7789 return; 7790 } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) { 7791 return; 7792 } 7793 7794 this._scrollMatches = false; 7795 const spot = { 7796 top: MATCH_SCROLL_OFFSET_TOP, 7797 left: selectedLeft + MATCH_SCROLL_OFFSET_LEFT 7798 }; 7799 (0, _ui_utils.scrollIntoView)(element, spot, true); 7800 } 7801 7802} 7803 7804exports.PDFFindController = PDFFindController; 7805 7806function _onFind2(state) { 7807 if (!state) { 7808 return; 7809 } 7810 7811 const pdfDocument = this._pdfDocument; 7812 const { 7813 type 7814 } = state; 7815 7816 if (this._state === null || _classPrivateMethodGet(this, _shouldDirtyMatch, _shouldDirtyMatch2).call(this, state)) { 7817 this._dirtyMatch = true; 7818 } 7819 7820 this._state = state; 7821 7822 if (type !== "highlightallchange") { 7823 _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.PENDING); 7824 } 7825 7826 this._firstPageCapability.promise.then(() => { 7827 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) { 7828 return; 7829 } 7830 7831 _classPrivateMethodGet(this, _extractText, _extractText2).call(this); 7832 7833 const findbarClosed = !this._highlightMatches; 7834 const pendingTimeout = !!this._findTimeout; 7835 7836 if (this._findTimeout) { 7837 clearTimeout(this._findTimeout); 7838 this._findTimeout = null; 7839 } 7840 7841 if (!type) { 7842 this._findTimeout = setTimeout(() => { 7843 _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this); 7844 7845 this._findTimeout = null; 7846 }, FIND_TIMEOUT); 7847 } else if (this._dirtyMatch) { 7848 _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this); 7849 } else if (type === "again") { 7850 _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this); 7851 7852 if (findbarClosed && this._state.highlightAll) { 7853 _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this); 7854 } 7855 } else if (type === "highlightallchange") { 7856 if (pendingTimeout) { 7857 _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this); 7858 } else { 7859 this._highlightMatches = true; 7860 } 7861 7862 _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this); 7863 } else { 7864 _classPrivateMethodGet(this, _nextMatch, _nextMatch2).call(this); 7865 } 7866 }); 7867} 7868 7869function _reset2() { 7870 this._highlightMatches = false; 7871 this._scrollMatches = false; 7872 this._pdfDocument = null; 7873 this._pageMatches = []; 7874 this._pageMatchesLength = []; 7875 this._state = null; 7876 this._selected = { 7877 pageIdx: -1, 7878 matchIdx: -1 7879 }; 7880 this._offset = { 7881 pageIdx: null, 7882 matchIdx: null, 7883 wrapped: false 7884 }; 7885 this._extractTextPromises = []; 7886 this._pageContents = []; 7887 this._pageDiffs = [];
7888 this._hasDiacritics = []; 7889 this._matchesCountTotal = 0; 7890 this._pagesToSearch = null; 7891 this._pendingFindMatches = new Set(); 7892 this._resumePageIdx = null; 7893 this._dirtyMatch = false; 7894 clearTimeout(this._findTimeout); 7895 this._findTimeout = null; 7896 this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)(); 7897} 7898 7899function _get_query() { 7900 if (this._state.query !== this._rawQuery) { 7901 this._rawQuery = this._state.query; 7902 [this._normalizedQuery] = normalize(this._state.query); 7903 } 7904 7905 return this._normalizedQuery; 7906} 7907 7908function _shouldDirtyMatch2(state) { 7909 if (state.query !== this._state.query) { 7910 return true; 7911 } 7912 7913 switch (state.type) { 7914 case "again": 7915 const pageNumber = this._selected.pageIdx + 1; 7916 const linkService = this._linkService; 7917 7918 if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) { 7919 return true; 7920 } 7921 7922 return false; 7923 7924 case "highlightallchange": 7925 return false; 7926 } 7927 7928 return true; 7929} 7930 7931function _isEntireWord2(content, startIdx, length) { 7932 let match = content.slice(0, startIdx).match(NOT_DIACRITIC_FROM_END_REG_EXP); 7933 7934 if (match) { 7935 const first = content.charCodeAt(startIdx); 7936 const limit = match[1].charCodeAt(0); 7937 7938 if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) { 7939 return false; 7940 } 7941 } 7942 7943 match = content.slice(startIdx + length).match(NOT_DIACRITIC_FROM_START_REG_EXP); 7944 7945 if (match) { 7946 const last = content.charCodeAt(startIdx + length - 1); 7947 const limit = match[1].charCodeAt(0); 7948 7949 if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(limit)) { 7950 return false; 7951 } 7952 } 7953 7954 return true; 7955} 7956 7957function _calculateRegExpMatch2(query, entireWord, pageIndex, pageContent) { 7958 const matches = [], 7959 matchesLength = []; 7960 const diffs = this._pageDiffs[pageIndex]; 7961 let match; 7962 7963 while ((match = query.exec(pageContent)) !== null) { 7964 if (entireWord && !_classPrivateMethodGet(this, _isEntireWord, _isEntireWord2).call(this, pageContent, match.index, match[0].length)) { 7965 continue; 7966 } 7967 7968 const [matchPos, matchLen] = getOriginalIndex(diffs, match.index, match[0].length); 7969 7970 if (matchLen) { 7971 matches.push(matchPos); 7972 matchesLength.push(matchLen); 7973 } 7974 } 7975 7976 this._pageMatches[pageIndex] = matches; 7977 this._pageMatchesLength[pageIndex] = matchesLength; 7978} 7979 7980function _convertToRegExpString2(query, hasDiacritics) { 7981 const { 7982 matchDiacritics 7983 } = this._state; 7984 let isUnicode = false; 7985 query = query.replace(SPECIAL_CHARS_REG_EXP, (match, p1, p2, p3, p4, p5) => { 7986 if (p1) { 7987 return `[ ]*\\${p1}[ ]*`; 7988 } 7989 7990 if (p2) { 7991 return `[ ]*${p2}[ ]*`; 7992 } 7993 7994 if (p3) { 7995 return "[ ]+"; 7996 } 7997 7998 if (matchDiacritics) { 7999 return p4 || p5; 8000 } 8001 8002 if (p4) { 8003 return DIACRITICS_EXCEPTION.has(p4.charCodeAt(0)) ? p4 : ""; 8004 } 8005 8006 if (hasDiacritics) { 8007 isUnicode = true; 8008 return `${p5}\\p{M}*`; 8009 } 8010 8011 return p5; 8012 }); 8013 const trailingSpaces = "[ ]*"; 8014 8015 if (query.endsWith(trailingSpaces)) { 8016 query = query.slice(0, query.length - trailingSpaces.length); 8017 } 8018 8019 if (matchDiacritics) { 8020 if (hasDiacritics) { 8021 isUnicode = true; 8022 query = `${query}(?=[${DIACRITICS_EXCEPTION_STR}]|[^\\p{M}]|$)`; 8023 } 8024 } 8025 8026 return [isUnicode, query]; 8027} 8028 8029function _calculateMatch2(pageIndex) {
8030 let query = _classPrivateFieldGet(this, _query); 8031 8032 if (query.length === 0) { 8033 return; 8034 } 8035 8036 const { 8037 caseSensitive, 8038 entireWord, 8039 phraseSearch 8040 } = this._state; 8041 const pageContent = this._pageContents[pageIndex]; 8042 const hasDiacritics = this._hasDiacritics[pageIndex]; 8043 let isUnicode = false; 8044 8045 if (phraseSearch) { 8046 [isUnicode, query] = _classPrivateMethodGet(this, _convertToRegExpString, _convertToRegExpString2).call(this, query, hasDiacritics); 8047 } else { 8048 const match = query.match(/\S+/g); 8049 8050 if (match) { 8051 query = match.sort().reverse().map(q => { 8052 const [isUnicodePart, queryPart] = _classPrivateMethodGet(this, _convertToRegExpString, _convertToRegExpString2).call(this, q, hasDiacritics); 8053 8054 isUnicode || (isUnicode = isUnicodePart); 8055 return `(${queryPart})`; 8056 }).join("|"); 8057 } 8058 } 8059 8060 const flags = `g${isUnicode ? "u" : ""}${caseSensitive ? "" : "i"}`; 8061 query = new RegExp(query, flags); 8062 8063 _classPrivateMethodGet(this, _calculateRegExpMatch, _calculateRegExpMatch2).call(this, query, entireWord, pageIndex, pageContent); 8064 8065 if (this._state.highlightAll) { 8066 _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, pageIndex); 8067 } 8068 8069 if (this._resumePageIdx === pageIndex) { 8070 this._resumePageIdx = null; 8071 8072 _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this); 8073 } 8074 8075 const pageMatchesCount = this._pageMatches[pageIndex].length; 8076 8077 if (pageMatchesCount > 0) { 8078 this._matchesCountTotal += pageMatchesCount; 8079 8080 _classPrivateMethodGet(this, _updateUIResultsCount, _updateUIResultsCount2).call(this); 8081 } 8082} 8083 8084function _extractText2() { 8085 if (this._extractTextPromises.length > 0) { 8086 return; 8087 } 8088 8089 let promise = Promise.resolve(); 8090 8091 for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) { 8092 const extractTextCapability = (0, _pdfjsLib.createPromiseCapability)(); 8093 this._extractTextPromises[i] = extractTextCapability.promise; 8094 promise = promise.then(() => { 8095 return this._pdfDocument.getPage(i + 1).then(pdfPage => { 8096 return pdfPage.getTextContent(); 8097 }).then(textContent => { 8098 const strBuf = []; 8099 8100 for (const textItem of textContent.items) { 8101 strBuf.push(textItem.str); 8102 8103 if (textItem.hasEOL) { 8104 strBuf.push("\n"); 8105 } 8106 } 8107 8108 [this._pageContents[i], this._pageDiffs[i], this._hasDiacritics[i]] = normalize(strBuf.join("")); 8109 extractTextCapability.resolve(); 8110 }, reason => { 8111 console.error(`Unable to get text content for page ${i + 1}`, reason); 8112 this._pageContents[i] = ""; 8113 this._pageDiffs[i] = null; 8114 this._hasDiacritics[i] = false; 8115 extractTextCapability.resolve(); 8116 }); 8117 }); 8118 } 8119} 8120 8121function _updatePage2(index) { 8122 if (this._scrollMatches && this._selected.pageIdx === index) { 8123 this._linkService.page = index + 1; 8124 } 8125 8126 this._eventBus.dispatch("updatetextlayermatches", { 8127 source: this, 8128 pageIndex: index 8129 }); 8130} 8131 8132function _updateAllPages2() { 8133 this._eventBus.dispatch("updatetextlayermatches", { 8134 source: this, 8135 pageIndex: -1 8136 }); 8137} 8138 8139function _nextMatch2() { 8140 const previous = this._state.findPrevious; 8141 const currentPageIndex = this._linkService.page - 1; 8142 const numPages = this._linkService.pagesCount; 8143 this._highlightMatches = true; 8144 8145 if (this._dirtyMatch) { 8146 this._dirtyMatch = false; 8147 this._selected.pageIdx = this._selected.matchIdx = -1; 8148 this._offset.pageIdx = currentPageIndex; 8149 this._offset.matchIdx = null; 8150 this._offset.wrapped = false; 8151 this._resumePageIdx = null; 8152 this._pageMatches.length = 0; 8153 this._pageMatchesLength.length = 0; 8154 this._matchesCountTotal = 0; 8155 8156 _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this); 8157 8158 for (let i = 0; i < numPages; i++) { 8159 if (this._pendingFindMatches.has(i)) { 8160 continue; 8161 } 8162 8163 this._pendingFindMatches.add(i); 8164 8165 this._extractTextPromises[i].then(() => { 8166 this._pendingFindMatches.delete(i); 8167 8168 _classPrivateMethodGet(this, _calculateMatch, _calculateMatch2).call(this, i); 8169 }); 8170 } 8171 } 8172
8173 if (_classPrivateFieldGet(this, _query) === "") { 8174 _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.FOUND); 8175 8176 return; 8177 } 8178 8179 if (this._resumePageIdx) { 8180 return; 8181 } 8182 8183 const offset = this._offset; 8184 this._pagesToSearch = numPages; 8185 8186 if (offset.matchIdx !== null) { 8187 const numPageMatches = this._pageMatches[offset.pageIdx].length; 8188 8189 if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) { 8190 offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1; 8191 8192 _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true); 8193 8194 return; 8195 } 8196 8197 _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this, previous); 8198 } 8199 8200 _classPrivateMethodGet(this, _nextPageMatch, _nextPageMatch2).call(this); 8201} 8202 8203function _matchesReady2(matches) { 8204 const offset = this._offset; 8205 const numMatches = matches.length; 8206 const previous = this._state.findPrevious; 8207 8208 if (numMatches) { 8209 offset.matchIdx = previous ? numMatches - 1 : 0; 8210 8211 _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, true); 8212 8213 return true; 8214 } 8215 8216 _classPrivateMethodGet(this, _advanceOffsetPage, _advanceOffsetPage2).call(this, previous); 8217 8218 if (offset.wrapped) { 8219 offset.matchIdx = null; 8220 8221 if (this._pagesToSearch < 0) { 8222 _classPrivateMethodGet(this, _updateMatch, _updateMatch2).call(this, false); 8223 8224 return true; 8225 } 8226 } 8227 8228 return false; 8229} 8230 8231function _nextPageMatch2() { 8232 if (this._resumePageIdx !== null) { 8233 console.error("There can only be one pending page."); 8234 } 8235 8236 let matches = null; 8237 8238 do { 8239 const pageIdx = this._offset.pageIdx; 8240 matches = this._pageMatches[pageIdx]; 8241 8242 if (!matches) { 8243 this._resumePageIdx = pageIdx; 8244 break; 8245 } 8246 } while (!_classPrivateMethodGet(this, _matchesReady, _matchesReady2).call(this, matches)); 8247} 8248 8249function _advanceOffsetPage2(previous) { 8250 const offset = this._offset; 8251 const numPages = this._linkService.pagesCount; 8252 offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1; 8253 offset.matchIdx = null; 8254 this._pagesToSearch--; 8255 8256 if (offset.pageIdx >= numPages || offset.pageIdx < 0) { 8257 offset.pageIdx = previous ? numPages - 1 : 0; 8258 offset.wrapped = true; 8259 } 8260} 8261 8262function _updateMatch2() { 8263 let found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 8264 let state = FindState.NOT_FOUND; 8265 const wrapped = this._offset.wrapped; 8266 this._offset.wrapped = false; 8267 8268 if (found) { 8269 const previousPage = this._selected.pageIdx; 8270 this._selected.pageIdx = this._offset.pageIdx; 8271 this._selected.matchIdx = this._offset.matchIdx; 8272 state = wrapped ? FindState.WRAPPED : FindState.FOUND; 8273 8274 if (previousPage !== -1 && previousPage !== this._selected.pageIdx) { 8275 _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, previousPage); 8276 } 8277 } 8278 8279 _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, state, this._state.findPrevious); 8280 8281 if (this._selected.pageIdx !== -1) { 8282 this._scrollMatches = true; 8283 8284 _classPrivateMethodGet(this, _updatePage, _updatePage2).call(this, this._selected.pageIdx); 8285 } 8286} 8287 8288function _onFindBarClose2(evt) { 8289 const pdfDocument = this._pdfDocument; 8290 8291 this._firstPageCapability.promise.then(() => { 8292 if (!this._pdfDocument || pdfDocument && this._pdfDocument !== pdfDocument) { 8293 return; 8294 } 8295 8296 if (this._findTimeout) { 8297 clearTimeout(this._findTimeout); 8298 this._findTimeout = null; 8299 } 8300 8301 if (this._resumePageIdx) { 8302 this._resumePageIdx = null; 8303 this._dirtyMatch = true; 8304 } 8305 8306 _classPrivateMethodGet(this, _updateUIState, _updateUIState2).call(this, FindState.FOUND); 8307 8308 this._highlightMatches = false; 8309 8310 _classPrivateMethodGet(this, _updateAllPages, _updateAllPages2).call(this); 8311 }); 8312} 8313 8314function _requestMatchesCount2() { 8315 const { 8316 pageIdx, 8317 matchIdx 8318 } = this._selected; 8319 let current = 0, 8320 total = this._matchesCountTotal; 8321 8322 if (matchIdx !== -1) { 8323 for (let i = 0; i < pageIdx; i++) { 8324 var _this$_pageMatches$i; 8325 8326 current += ((_this$_pageMatches$i = this._pageMatches[i]) === null || _this$_pageMatches$i === void 0 ? void 0 : _this$_pageMatches$i.length) || 0; 8327 } 8328 8329 current += matchIdx + 1; 8330 } 8331 8332 if (current < 1 || current > total) { 8333 current = total = 0; 8334 } 8335 8336 return { 8337 current, 8338 total 8339 }; 8340} 8341 8342function _updateUIResultsCount2() { 8343 this._eventBus.dispatch("updatefindmatchescount", { 8344 source: this, 8345 matchesCount: _classPrivateMethodGet(this, _requestMatchesCount, _requestMatchesCount2).call(this) 8346 }); 8347} 8348 8349function _updateUIState2(state) { 8350 var _this$_state$query, _this$_state; 8351 8352 let previous = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
8353 8354 this._eventBus.dispatch("updatefindcontrolstate", { 8355 source: this, 8356 state, 8357 previous, 8358 matchesCount: _classPrivateMethodGet(this, _requestMatchesCount, _requestMatchesCount2).call(this), 8359 rawQuery: (_this$_state$query = (_this$_state = this._state) === null || _this$_state === void 0 ? void 0 : _this$_state.query) !== null && _this$_state$query !== void 0 ? _this$_state$query : null 8360 }); 8361} 8362 8363/***/ }), 8364/* 23 */ 8365/***/ ((__unused_webpack_module, exports) => { 8366 8367 8368 8369Object.defineProperty(exports, "__esModule", ({ 8370 value: true 8371})); 8372exports.CharacterType = void 0; 8373exports.getCharacterType = getCharacterType; 8374const CharacterType = { 8375 SPACE: 0, 8376 ALPHA_LETTER: 1, 8377 PUNCT: 2, 8378 HAN_LETTER: 3, 8379 KATAKANA_LETTER: 4, 8380 HIRAGANA_LETTER: 5, 8381 HALFWIDTH_KATAKANA_LETTER: 6, 8382 THAI_LETTER: 7 8383}; 8384exports.CharacterType = CharacterType; 8385 8386function isAlphabeticalScript(charCode) { 8387 return charCode < 0x2e80; 8388} 8389 8390function isAscii(charCode) { 8391 return (charCode & 0xff80) === 0; 8392} 8393 8394function isAsciiAlpha(charCode) { 8395 return charCode >= 0x61 && charCode <= 0x7a || charCode >
8395= 0x41 && charCode <= 0x5a; 8396} 8397 8398function isAsciiDigit(charCode) { 8399 return charCode >= 0x30 && charCode <= 0x39; 8400} 8401 8402function isAsciiSpace(charCode) { 8403 return charCode === 0x20 || charCode === 0x09 || charCode === 0x0d || charCode === 0x0a; 8404} 8405 8406function isHan(charCode) { 8407 return charCode >= 0x3400 && charCode <= 0x9fff || charCode >= 0xf900 && charCode <= 0xfaff; 8408} 8409 8410function isKatakana(charCode) { 8411 return charCode >= 0x30a0 && charCode <= 0x30ff; 8412} 8413 8414function isHiragana(charCode) { 8415 return charCode >= 0x3040 && charCode <= 0x309f; 8416} 8417 8418function isHalfwidthKatakana(charCode) { 8419 return charCode >= 0xff60 && charCode <= 0xff9f; 8420} 8421 8422function isThai(charCode) { 8423 return (charCode & 0xff80) === 0x0e00; 8424} 8425 8426function getCharacterType(charCode) { 8427 if (isAlphabeticalScript(charCode)) { 8428 if (isAscii(charCode)) { 8429 if (isAsciiSpace(charCode)) { 8430 return CharacterType.SPACE; 8431 } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5f) { 8432 return CharacterType.ALPHA_LETTER; 8433 } 8434 8435 return CharacterType.PUNCT; 8436 } else if (isThai(charCode)) { 8437 return CharacterType.THAI_LETTER; 8438 } else if (charCode === 0xa0) { 8439 return CharacterType.SPACE; 8440 } 8441 8442 return CharacterType.ALPHA_LETTER; 8443 } 8444 8445 if (isHan(charCode)) { 8446 return CharacterType.HAN_LETTER; 8447 } else if (isKatakana(charCode)) { 8448 return CharacterType.KATAKANA_LETTER; 8449 } else if (isHiragana(charCode)) { 8450 return CharacterType.HIRAGANA_LETTER; 8451 } else if (isHalfwidthKatakana(charCode)) { 8452 return CharacterType.HALFWIDTH_KATAKANA_LETTER; 8453 } 8454 8455 return CharacterType.ALPHA_LETTER; 8456} 8457 8458/***/ }), 8459/* 24 */ 8460/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 8461 8462 8463 8464Object.defineProperty(exports, "__esModule", ({ 8465 value: true 8466})); 8467exports.PDFHistory = void 0; 8468exports.isDestArraysEqual = isDestArraysEqual; 8469exports.isDestHashesEqual = isDestHashesEqual; 8470 8471var _ui_utils = __w_pdfjs_require__(7); 8472 8473var _event_utils = __w_pdfjs_require__(19); 8474 8475const HASH_CHANGE_TIMEOUT = 1000; 8476const POSITION_UPDATED_THRESHOLD = 50; 8477const UPDATE_VIEWAREA_TIMEOUT = 1000; 8478 8479function getCurrentHash() { 8480 return document.location.hash; 8481} 8482 8483class PDFHistory { 8484 constructor(_ref) { 8485 let { 8486 linkService, 8487 eventBus 8488 } = _ref; 8489 this.linkService = linkService; 8490 this.eventBus = eventBus; 8491 this._initialized = false; 8492 this._fingerprint = ""; 8493 this.reset(); 8494 this._boundEvents = null; 8495 8496 this.eventBus._on("pagesinit", () => { 8497 this._isPagesLoaded = false; 8498 8499 this.eventBus._on("pagesloaded", evt => { 8500 this._isPagesLoaded = !!evt.pagesCount; 8501 }, { 8502 once: true 8503 }); 8504 }); 8505 } 8506 8507 initialize(_ref2) { 8508 let { 8509 fingerprint, 8510 resetHistory = false, 8511 updateUrl = false 8512 } = _ref2; 8513 8514 if (!fingerprint || typeof fingerprint !== "string") { 8515 console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.'); 8516 return; 8517 } 8518 8519 if (this._initialized) { 8520 this.reset(); 8521 } 8522 8523 const reInitialized = this._fingerprint !== "" && this._fingerprint !== fingerprint; 8524 this._fingerprint = fingerprint; 8525 this._updateUrl = updateUrl === true; 8526 this._initialized = true; 8527 8528 this._bindEvents(); 8529 8530 const state = window.history.state; 8531 this._popStateInProgress = false; 8532 this._blockHashChange = 0; 8533 this._currentHash = getCurrentHash(); 8534 this._numPositionUpdates = 0; 8535 this._uid = this._maxUid = 0; 8536 this._destination = null; 8537 this._position = null; 8538 8539 if (!this._isValidState(state, true) || resetHistory) { 8540 const { 8541 hash, 8542 page, 8543 rotation 8544 } = this._parseCurrentHash(true); 8545 8546 if (!hash || reInitialized || resetHistory) { 8547 this._pushOrReplaceState(null, true); 8548 8549 return; 8550 } 8551 8552 this._pushOrReplaceState({ 8553 hash, 8554 page, 8555 rotation 8556 }, true); 8557 8558 return; 8559 } 8560 8561 const destination = state.destination; 8562 8563 this._updateInternalState(destination, state.uid, true); 8564 8565 if (destination.rotation !== undefined) { 8566 this._initialRotation = destination.rotation; 8567 } 8568 8569 if (destination.dest) { 8570 this._initialBookmark = JSON.stringify(destination.dest); 8571 this._destination.page = null; 8572 } else if (destination.hash) { 8573 this._initialBookmark = destination.hash; 8574 } else if (destination.page) { 8575 this._initialBookmark = `page=${destination.page}`; 8576 } 8577 } 8578 8579 reset() { 8580 if (this._initialized) { 8581 this._pageHide(); 8582 8583 this._initialized = false;
8584 8585 this._unbindEvents(); 8586 } 8587 8588 if (this._updateViewareaTimeout) { 8589 clearTimeout(this._updateViewareaTimeout); 8590 this._updateViewareaTimeout = null; 8591 } 8592 8593 this._initialBookmark = null; 8594 this._initialRotation = null; 8595 } 8596 8597 push(_ref3) { 8598 let { 8599 namedDest = null, 8600 explicitDest, 8601 pageNumber 8602 } = _ref3; 8603 8604 if (!this._initialized) { 8605 return; 8606 } 8607 8608 if (namedDest && typeof namedDest !== "string") { 8609 console.error("PDFHistory.push: " + `"${namedDest}" is not a valid namedDest parameter.`); 8610 return; 8611 } else if (!Array.isArray(explicitDest)) { 8612 console.error("PDFHistory.push: " + `"${explicitDest}" is not a valid explicitDest parameter.`); 8613 return; 8614 } else if (!this._isValidPage(pageNumber)) { 8615 if (pageNumber !== null || this._destination) { 8616 console.error("PDFHistory.push: " + `"${pageNumber}" is not a valid pageNumber parameter.`); 8617 return; 8618 } 8619 } 8620 8621 const hash = namedDest || JSON.stringify(explicitDest); 8622 8623 if (!hash) { 8624 return; 8625 } 8626 8627 let forceReplace = false; 8628 8629 if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) { 8630 if (this._destination.page) { 8631 return; 8632 } 8633 8634 forceReplace = true; 8635 } 8636 8637 if (this._popStateInProgress && !forceReplace) { 8638 return; 8639 } 8640 8641 this._pushOrReplaceState({ 8642 dest: explicitDest, 8643 hash, 8644 page: pageNumber, 8645 rotation: this.linkService.rotation 8646 }, forceReplace); 8647 8648 if (!this._popStateInProgress) { 8649 this._popStateInProgress = true; 8650 Promise.resolve().then(() => { 8651 this._popStateInProgress = false; 8652 }); 8653 } 8654 } 8655 8656 pushPage(pageNumber) { 8657 var _this$_destination; 8658 8659 if (!this._initialized) { 8660 return; 8661 } 8662 8663 if (!this._isValidPage(pageNumber)) { 8664 console.error(`PDFHistory.pushPage: "${pageNumber}" is not a valid page number.`); 8665 return; 8666 } 8667 8668 if (((_this$_destination = this._destination) === null || _this$_destination === void 0 ? void 0 : _this$_destination.page) === pageNumber) { 8669 return; 8670 } 8671 8672 if (this._popStateInProgress) { 8673 return; 8674 } 8675 8676 this._pushOrReplaceState({ 8677 dest: null, 8678 hash: `page=${pageNumber}`, 8679 page: pageNumber, 8680 rotation: this.linkService.rotation 8681 }); 8682 8683 if (!this._popStateInProgress) { 8684 this._popStateInProgress = true; 8685 Promise.resolve().then(() => { 8686 this._popStateInProgress = false; 8687 }); 8688 } 8689 } 8690 8691 pushCurrentPosition() { 8692 if (!this._initialized || this._popStateInProgress) { 8693 return; 8694 } 8695 8696 this._tryPushCurrentPosition(); 8697 } 8698 8699 back() { 8700 if (!this._initialized || this._popStateInProgress) { 8701 return; 8702 } 8703 8704 const state = window.history.state; 8705 8706 if (this._isValidState(state) && state.uid > 0) { 8707 window.history.back(); 8708 } 8709 } 8710 8711 forward() { 8712 if (!this._initialized || this._popStateInProgress) { 8713 return; 8714 } 8715 8716 const state = window.history.state; 8717 8718 if (this._isValidState(state) && state.uid < this._maxUid) { 8719 window.history.forward(); 8720 } 8721 } 8722 8723 get popStateInProgress() { 8724 return this._initialized && (this._popStateInProgress || this._blockHashChange > 0); 8725 } 8726 8727 get initialBookmark() { 8728 return this._initialized ? this._initialBookmark : null; 8729 } 8730 8731 get initialRotation() { 8732 return this._initialized ? this._initialRotation : null; 8733 } 8734 8735 _pushOrReplaceState(destination) { 8736 let forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 8737 const shouldReplace = forceReplace || !this._destination; 8738 const newState = { 8739 fingerprint: this._fingerprint, 8740 uid: shouldReplace ? this._uid : this._uid + 1, 8741 destination 8742 }; 8743 8744 this._updateInternalState(destination, newState.uid); 8745 8746 let newUrl; 8747 8748 if (this._updateUrl && destination !== null && destination !== void 0 && destination.hash) { 8749 const baseUrl = document.location.href.split("#")[0]; 8750 8751 if (!baseUrl.startsWith("file://")) { 8752 newUrl = `${baseUrl}#${destination.hash}`; 8753 } 8754 } 8755 8756 if (shouldReplace) { 8757 window.history.replaceState(newState, "", newUrl); 8758 } else { 8759 window.history.pushState(newState, "", newUrl); 8760 } 8761 } 8762 8763 _tryPushCurrentPosition() { 8764 let temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
8765 8766 if (!this._position) { 8767 return; 8768 } 8769 8770 let position = this._position; 8771 8772 if (temporary) { 8773 position = Object.assign(Object.create(null), this._position); 8774 position.temporary = true; 8775 } 8776 8777 if (!this._destination) { 8778 this._pushOrReplaceState(position); 8779 8780 return; 8781 } 8782 8783 if (this._destination.temporary) { 8784 this._pushOrReplaceState(position, true); 8785 8786 return; 8787 } 8788 8789 if (this._destination.hash === position.hash) { 8790 return; 8791 } 8792 8793 if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) { 8794 return; 8795 } 8796 8797 let forceReplace = false; 8798 8799 if (this._destination.page >= position.first && this._destination.page <= position.page) { 8800 if (this._destination.dest !== undefined || !this._destination.first) { 8801 return; 8802 } 8803 8804 forceReplace = true; 8805 } 8806 8807 this._pushOrReplaceState(position, forceReplace); 8808 } 8809 8810 _isValidPage(val) { 8811 return Number.isInteger(val) && val > 0 && val <= this.linkService.pagesCount; 8812 } 8813 8814 _isValidState(state) { 8815 let checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; 8816 8817 if (!state) { 8818 return false; 8819 } 8820 8821 if (state.fingerprint !== this._fingerprint) { 8822 if (checkReload) { 8823 if (typeof state.fingerprint !== "string" || state.fingerprint.length !== this._fingerprint.length) { 8824 return false; 8825 } 8826 8827 const [perfEntry] = performance.getEntriesByType("navigation"); 8828 8829 if ((perfEntry === null || perfEntry === void 0 ? void 0 : perfEntry.type) !== "reload") { 8830 return false; 8831 } 8832 } else { 8833 return false; 8834 } 8835 } 8836 8837 if (!Number.isInteger(state.uid) || state.uid < 0) { 8838 return false; 8839 } 8840 8841 if (state.destination === null || typeof state.destination !== "object") { 8842 return false; 8843 } 8844 8845 return true; 8846 } 8847 8848 _updateInternalState(destination, uid) { 8849 let removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 8850 8851 if (this._updateViewareaTimeout) { 8852 clearTimeout(this._updateViewareaTimeout); 8853 this._updateViewareaTimeout = null; 8854 } 8855 8856 if (removeTemporary && destination !== null && destination !== void 0 && destination.temporary) { 8857 delete destination.temporary; 8858 } 8859 8860 this._destination = destination; 8861 this._uid = uid; 8862 this._maxUid = Math.max(this._maxUid, uid); 8863 this._numPositionUpdates = 0; 8864 } 8865 8866 _parseCurrentHash() {
8867 let checkNameddest = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; 8868 const hash = unescape(getCurrentHash()).substring(1); 8869 const params = (0, _ui_utils.parseQueryString)(hash); 8870 const nameddest = params.get("nameddest") || ""; 8871 let page = params.get("page") | 0; 8872 8873 if (!this._isValidPage(page) || checkNameddest && nameddest.length > 0) { 8874 page = null; 8875 } 8876 8877 return { 8878 hash, 8879 page, 8880 rotation: this.linkService.rotation 8881 }; 8882 } 8883 8884 _updateViewarea(_ref4) { 8885 let { 8886 location 8887 } = _ref4; 8888 8889 if (this._updateViewareaTimeout) { 8890 clearTimeout(this._updateViewareaTimeout); 8891 this._updateViewareaTimeout = null; 8892 } 8893 8894 this._position = { 8895 hash: location.pdfOpenParams.substring(1), 8896 page: this.linkService.page, 8897 first: location.pageNumber, 8898 rotation: location.rotation 8899 }; 8900 8901 if (this._popStateInProgress) { 8902 return; 8903 } 8904 8905 if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) { 8906 this._numPositionUpdates++; 8907 } 8908 8909 if (UPDATE_VIEWAREA_TIMEOUT > 0) { 8910 this._updateViewareaTimeout = setTimeout(() => { 8911 if (!this._popStateInProgress) { 8912 this._tryPushCurrentPosition(true); 8913 } 8914 8915 this._updateViewareaTimeout = null; 8916 }, UPDATE_VIEWAREA_TIMEOUT); 8917 } 8918 } 8919 8920 _popState(_ref5) { 8921 let { 8922 state 8923 } = _ref5; 8924 const newHash = getCurrentHash(), 8925 hashChanged = this._currentHash !== newHash; 8926 this._currentHash = newHash; 8927 8928 if (!state) { 8929 this._uid++; 8930 8931 const { 8932 hash, 8933 page, 8934 rotation 8935 } = this._parseCurrentHash(); 8936 8937 this._pushOrReplaceState({ 8938 hash, 8939 page, 8940 rotation 8941 }, true); 8942 8943 return; 8944 } 8945 8946 if (!this._isValidState(state)) { 8947 return; 8948 } 8949 8950 this._popStateInProgress = true; 8951 8952 if (hashChanged) { 8953 this._blockHashChange++; 8954 (0, _event_utils.waitOnEventOrTimeout)({ 8955 target: window, 8956 name: "hashchange", 8957 delay: HASH_CHANGE_TIMEOUT 8958 }).then(() => { 8959 this._blockHashChange--; 8960 }); 8961 } 8962 8963 const destination = state.destination; 8964 8965 this._updateInternalState(destination, state.uid, true); 8966 8967 if ((0, _ui_utils.isValidRotation)(destination.rotation)) { 8968 this.linkService.rotation = destination.rotation; 8969 } 8970 8971 if (destination.dest) { 8972 this.linkService.goToDestination(destination.dest); 8973 } else if (destination.hash) { 8974 this.linkService.setHash(destination.hash); 8975 } else if (destination.page) { 8976 this.linkService.page = destination.page; 8977 } 8978 8979 Promise.resolve().then(() => { 8980 this._popStateInProgress = false; 8981 }); 8982 } 8983 8984 _pageHide() { 8985 if (!this._destination || this._destination.temporary) { 8986 this._tryPushCurrentPosition(); 8987 } 8988 } 8989 8990 _bindEvents() { 8991 if (this._boundEvents) { 8992 return; 8993 } 8994 8995 this._boundEvents = { 8996 updateViewarea: this._updateViewarea.bind(this), 8997 popState: this._popState.bind(this), 8998 pageHide: this._pageHide.bind(this) 8999 }; 9000 9001 this.eventBus._on("updateviewarea", this._boundEvents.updateViewarea); 9002 9003 window.addEventListener("popstate", this._boundEvents.popState); 9004 window.addEventListener("pagehide", this._boundEvents.pageHide); 9005 } 9006 9007 _unbindEvents() { 9008 if (!this._boundEvents) { 9009 return; 9010 } 9011 9012 this.eventBus._off("updateviewarea", this._boundEvents.updateViewarea); 9013 9014 window.removeEventListener("popstate", this._boundEvents.popState); 9015 window.removeEventListener("pagehide", this._boundEvents.pageHide); 9016 this._boundEvents = null; 9017 } 9018 9019} 9020 9021exports.PDFHistory = PDFHistory; 9022 9023function isDestHashesEqual(destHash, pushHash) { 9024 if (typeof destHash !== "string" || typeof pushHash !== "string") { 9025 return false; 9026 } 9027 9028 if (destHash === pushHash) { 9029 return true; 9030 } 9031 9032 const nameddest = (0, _ui_utils.parseQueryString)(destHash).get("nameddest"); 9033 9034 if (nameddest === pushHash) { 9035 return true; 9036 } 9037 9038 return false; 9039} 9040 9041function isDestArraysEqual(firstDest, secondDest) { 9042 function isEntryEqual(first, second) { 9043 if (typeof first !== typeof second) { 9044 return false;
9045 } 9046 9047 if (Array.isArray(first) || Array.isArray(second)) { 9048 return false; 9049 } 9050 9051 if (first !== null && typeof first === "object" && second !== null) { 9052 if (Object.keys(first).length !== Object.keys(second).length) { 9053 return false; 9054 } 9055 9056 for (const key in first) { 9057 if (!isEntryEqual(first[key], second[key])) { 9058 return false; 9059 } 9060 } 9061 9062 return true; 9063 } 9064 9065 return first === second || Number.isNaN(first) && Number.isNaN(second); 9066 } 9067 9068 if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) { 9069 return false; 9070 } 9071 9072 if (firstDest.length !== secondDest.length) { 9073 return false; 9074 } 9075 9076 for (let i = 0, ii = firstDest.length; i < ii; i++) { 9077 if (!isEntryEqual(firstDest[i], secondDest[i])) { 9078 return false; 9079 } 9080 } 9081 9082 return true; 9083} 9084 9085/***/ }), 9086/* 25 */ 9087/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 9088 9089 9090 9091Object.defineProperty(exports, "__esModule", ({ 9092 value: true 9093})); 9094exports.PDFScriptingManager = void 0; 9095 9096var _ui_utils = __w_pdfjs_require__(7); 9097 9098var _pdfjsLib = __w_pdfjs_require__(3); 9099 9100class PDFScriptingManager { 9101 constructor(_ref) { 9102 let { 9103 eventBus, 9104 sandboxBundleSrc = null, 9105 scriptingFactory = null, 9106 docPropertiesLookup = null 9107 } = _ref; 9108 this._pdfDocument = null; 9109 this._pdfViewer = null; 9110 this._closeCapability = null; 9111 this._destroyCapability = null; 9112 this._scripting = null; 9113 this._mouseState = Object.create(null); 9114 this._ready = false; 9115 this._eventBus = eventBus; 9116 this._sandboxBundleSrc = sandboxBundleSrc; 9117 this._scriptingFactory = scriptingFactory; 9118 this._docPropertiesLookup = docPropertiesLookup; 9119 9120 if (!this._scriptingFactory) { 9121 window.addEventListener("updatefromsandbox", event => { 9122 this._eventBus.dispatch("updatefromsandbox", { 9123 source: window, 9124 detail: event.detail 9125 }); 9126 }); 9127 } 9128 } 9129 9130 setViewer(pdfViewer) { 9131 this._pdfViewer = pdfViewer; 9132 } 9133 9134 async setDocument(pdfDocument) { 9135 var _this$_scripting3; 9136 9137 if (this._pdfDocument) { 9138 await this._destroyScripting(); 9139 } 9140 9141 this._pdfDocument = pdfDocument; 9142 9143 if (!pdfDocument) { 9144 return; 9145 } 9146 9147 const [objects, calculationOrder, docActions] = await Promise.all([pdfDocument.getFieldObjects(), pdfDocument.getCalculationOrderIds(), pdfDocument.getJSActions()]); 9148 9149 if (!objects && !docActions) { 9150 await this._destroyScripting(); 9151 return; 9152 } 9153 9154 if (pdfDocument !== this._pdfDocument) { 9155 return; 9156 } 9157 9158 try { 9159 this._scripting = this._createScripting(); 9160 } catch (error) { 9161 console.error(`PDFScriptingManager.setDocument: "${error === null || error === void 0 ? void 0 : error.message}".`); 9162 await this._destroyScripting(); 9163 return; 9164 } 9165 9166 this._internalEvents.set("updatefromsandbox", event => { 9167 if ((event === null || event === void 0 ? void 0 : event.source) !== window) { 9168 return; 9169 } 9170 9171 this._updateFromSandbox(event.detail); 9172 }); 9173 9174 this._internalEvents.set("dispatcheventinsandbox", event => { 9175 var _this$_scripting; 9176 9177 (_this$_scripting = this._scripting) === null || _this$_scripting === void 0 ? void 0 : _this$_scripting.dispatchEventInSandbox(event.detail); 9178 }); 9179 9180 this._internalEvents.set("pagechanging", _ref2 => { 9181 let { 9182 pageNumber, 9183 previous 9184 } = _ref2; 9185 9186 if (pageNumber === previous) { 9187 return; 9188 } 9189 9190 this._dispatchPageClose(previous); 9191 9192 this._dispatchPageOpen(pageNumber); 9193 }); 9194 9195 this._internalEvents.set("pagerendered", _ref3 => { 9196 let { 9197 pageNumber 9198 } = _ref3; 9199 9200 if (!this._pageOpenPending.has(pageNumber)) { 9201 return; 9202 } 9203 9204 if (pageNumber !== this._pdfViewer.currentPageNumber) { 9205 return; 9206 } 9207 9208 this._dispatchPageOpen(pageNumber); 9209 }); 9210 9211 this._internalEvents.set("pagesdestroy", async event => { 9212 var _this$_scripting2, _this$_closeCapabilit; 9213 9214 await this._dispatchPageClose(this._pdfViewer.currentPageNumber); 9215 await ((_this$_scripting2 = this._scripting) === null || _this$_scripting2 === void 0 ? void 0 : _this$_scripting2.dispatchEventInSandbox({ 9216 id: "doc", 9217 name: "WillClose" 9218 })); 9219 (_this$_closeCapabilit = this._closeCapability) === null || _this$_closeCapabilit === void 0 ? void 0 : _this$_closeCapabilit.resolve(); 9220 }); 9221 9222 this._domEvents.set("mousedown", event => { 9223 this._mouseState.isDown = true; 9224 }); 9225 9226 this._domEvents.set("mouseup", event => { 9227 this._mouseState.isDown = false;
9228 }); 9229 9230 for (const [name, listener] of this._internalEvents) { 9231 this._eventBus._on(name, listener); 9232 } 9233 9234 for (const [name, listener] of this._domEvents) { 9235 window.addEventListener(name, listener, true); 9236 } 9237 9238 try { 9239 const docProperties = await this._getDocProperties(); 9240 9241 if (pdfDocument !== this._pdfDocument) { 9242 return; 9243 } 9244 9245 await this._scripting.createSandbox({ 9246 objects, 9247 calculationOrder, 9248 appInfo: { 9249 platform: navigator.platform, 9250 language: navigator.language 9251 }, 9252 docInfo: { ...docProperties, 9253 actions: docActions 9254 } 9255 }); 9256 9257 this._eventBus.dispatch("sandboxcreated", { 9258 source: this 9259 }); 9260 } catch (error) { 9261 console.error(`PDFScriptingManager.setDocument: "${error === null || error === void 0 ? void 0 : error.message}".`); 9262 await this._destroyScripting(); 9263 return; 9264 } 9265 9266 await ((_this$_scripting3 = this._scripting) === null || _this$_scripting3 === void 0 ? void 0 : _this$_scripting3.dispatchEventInSandbox({ 9267 id: "doc", 9268 name: "Open" 9269 })); 9270 await this._dispatchPageOpen(this._pdfViewer.currentPageNumber, true); 9271 Promise.resolve().then(() => { 9272 if (pdfDocument === this._pdfDocument) { 9273 this._ready = true; 9274 } 9275 }); 9276 } 9277 9278 async dispatchWillSave(detail) { 9279 var _this$_scripting4; 9280 9281 return (_this$_scripting4 = this._scripting) === null || _this$_scripting4 === void 0 ? void 0 : _this$_scripting4.dispatchEventInSandbox({ 9282 id: "doc", 9283 name: "WillSave" 9284 }); 9285 } 9286 9287 async dispatchDidSave(detail) { 9288 var _this$_scripting5; 9289 9290 return (_this$_scripting5 = this._scripting) === null || _this$_scripting5 === void 0 ? void 0 : _this$_scripting5.dispatchEventInSandbox({ 9291 id: "doc", 9292 name: "DidSave" 9293 }); 9294 } 9295 9296 async dispatchWillPrint(detail) { 9297 var _this$_scripting6; 9298 9299 return (_this$_scripting6 = this._scripting) === null || _this$_scripting6 === void 0 ? void 0 : _this$_scripting6.dispatchEventInSandbox({ 9300 id: "doc", 9301 name: "WillPrint" 9302 }); 9303 } 9304 9305 async dispatchDidPrint(detail) { 9306 var _this$_scripting7; 9307 9308 return (_this$_scripting7 = this._scripting) === null || _this$_scripting7 === void 0 ? void 0 : _this$_scripting7.dispatchEventInSandbox({ 9309 id: "doc", 9310 name: "DidPrint" 9311 }); 9312 } 9313 9314 get mouseState() { 9315 return this._mouseState; 9316 } 9317 9318 get destroyPromise() { 9319 var _this$_destroyCapabil; 9320 9321 return ((_this$_destroyCapabil = this._destroyCapability) === null || _this$_destroyCapabil === void 0 ? void 0 : _this$_destroyCapabil.promise) || null; 9322 } 9323 9324 get ready() { 9325 return this._ready; 9326 } 9327 9328 get _internalEvents() { 9329 return (0, _pdfjsLib.shadow)(this, "_internalEvents", new Map()); 9330 } 9331 9332 get _domEvents() { 9333 return (0, _pdfjsLib.shadow)(this, "_domEvents", new Map()); 9334 } 9335 9336 get _pageOpenPending() { 9337 return (0, _pdfjsLib.shadow)(this, "_pageOpenPending", new Set()); 9338 } 9339 9340 get _visitedPages() { 9341 return (0, _pdfjsLib.shadow)(this, "_visitedPages", new Map()); 9342 } 9343 9344 async _updateFromSandbox(detail) { 9345 const isInPresentationMode = this._pdfViewer.isInPresentationMode || this._pdfViewer.isChangingPresentationMode; 9346 const { 9347 id, 9348 siblings, 9349 command, 9350 value 9351 } = detail; 9352 9353 if (!id) { 9354 switch (command) { 9355 case "clear": 9356 console.clear(); 9357 break; 9358 9359 case "error": 9360 console.error(value); 9361 break; 9362 9363 case "layout": 9364 if (isInPresentationMode) { 9365 return; 9366 } 9367 9368 const modes = (0, _ui_utils.apiPageLayoutToViewerModes)(value); 9369 this._pdfViewer.spreadMode = modes.spreadMode; 9370 break; 9371 9372 case "page-num": 9373 this._pdfViewer.currentPageNumber = value + 1; 9374 break; 9375 9376 case "print": 9377 await this._pdfViewer.pagesPromise; 9378 9379 this._eventBus.dispatch("print", { 9380 source: this 9381 }); 9382 9383 break; 9384 9385 case "println": 9386 console.log(value); 9387 break; 9388 9389 case "zoom": 9390 if (isInPresentationMode) { 9391 return; 9392 } 9393 9394 this._pdfViewer.currentScaleValue = value; 9395 break; 9396 9397 case "SaveAs": 9398 this._eventBus.dispatch("download", { 9399 source: this 9400 }); 9401 9402 break; 9403 9404 case "FirstPage": 9405 this._pdfViewer.currentPageNumber = 1; 9406 break; 9407 9408 case "LastPage": 9409 this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount; 9410 break; 9411 9412 case "NextPage": 9413 this._pdfViewer.nextPage(); 9414 9415 break; 9416 9417 case "PrevPage": 9418 this._pdfViewer.previousPage(); 9419 9420 break; 9421 9422 case "ZoomViewIn": 9423 if (isInPresentationMode) { 9424 return; 9425 } 9426 9427 this._pdfViewer.increaseScale(); 9428 9429 break; 9430 9431 case "ZoomViewOut": 9432 if (isInPresentationMode) { 9433 return; 9434 } 9435 9436 this._pdfViewer.decreaseScale(); 9437 9438 break; 9439 } 9440 9441 return; 9442 } 9443 9444 if (isInPresentationMode) { 9445 if (detail.focus) { 9446 return; 9447 } 9448 } 9449 9450 delete detail.id; 9451 delete detail.siblings; 9452 const ids = siblings ? [id, ...siblings] : [id]; 9453 9454 for (const elementId of ids) { 9455 const element = document.querySelector(`[data-element-id="${elementId}"]`); 9456 9457 if (element) { 9458 element.dispatchEvent(new CustomEvent("updatefromsandbox", { 9459 detail 9460 })); 9461 } else { 9462 var _this$_pdfDocument; 9463 9464 (_this$_pdfDocument = this._pdfDocument) === null || _this$_pdfDocument === void 0 ? void 0 : _this$_pdfDocument.annotationStorage.setValue(elementId, detail); 9465 } 9466 } 9467 } 9468 9469 async _dispatchPageOpen(pageNumber) { 9470 let initialize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
9471 const pdfDocument = this._pdfDocument, 9472 visitedPages = this._visitedPages; 9473 9474 if (initialize) { 9475 this._closeCapability = (0, _pdfjsLib.createPromiseCapability)(); 9476 } 9477 9478 if (!this._closeCapability) { 9479 return; 9480 } 9481 9482 const pageView = this._pdfViewer.getPageView(pageNumber - 1); 9483 9484 if ((pageView === null || pageView === void 0 ? void 0 : pageView.renderingState) !== _ui_utils.RenderingStates.FINISHED) { 9485 this._pageOpenPending.add(pageNumber); 9486 9487 return; 9488 } 9489 9490 this._pageOpenPending.delete(pageNumber); 9491 9492 const actionsPromise = (async () => { 9493 var _pageView$pdfPage, _this$_scripting8; 9494 9495 const actions = await (!visitedPages.has(pageNumber) ? (_pageView$pdfPage = pageView.pdfPage) === null || _pageView$pdfPage === void 0 ? void 0 : _pageView$pdfPage.getJSActions() : null); 9496 9497 if (pdfDocument !== this._pdfDocument) { 9498 return; 9499 } 9500 9501 await ((_this$_scripting8 = this._scripting) === null || _this$_scripting8 === void 0 ? void 0 : _this$_scripting8.dispatchEventInSandbox({ 9502 id: "page", 9503 name: "PageOpen", 9504 pageNumber, 9505 actions 9506 })); 9507 })(); 9508 9509 visitedPages.set(pageNumber, actionsPromise); 9510 } 9511 9512 async _dispatchPageClose(pageNumber) { 9513 var _this$_scripting9; 9514 9515 const pdfDocument = this._pdfDocument, 9516 visitedPages = this._visitedPages; 9517 9518 if (!this._closeCapability) { 9519 return; 9520 } 9521 9522 if (this._pageOpenPending.has(pageNumber)) { 9523 return; 9524 } 9525 9526 const actionsPromise = visitedPages.get(pageNumber); 9527 9528 if (!actionsPromise) { 9529 return; 9530 } 9531 9532 visitedPages.set(pageNumber, null); 9533 await actionsPromise; 9534 9535 if (pdfDocument !== this._pdfDocument) { 9536 return; 9537 } 9538 9539 await ((_this$_scripting9 = this._scripting) === null || _this$_scripting9 === void 0 ? void 0 : _this$_scripting9.dispatchEventInSandbox({ 9540 id: "page", 9541 name: "PageClose", 9542 pageNumber 9543 })); 9544 } 9545 9546 async _getDocProperties() { 9547 if (this._docPropertiesLookup) { 9548 return this._docPropertiesLookup(this._pdfDocument); 9549 } 9550 9551 const { 9552 docPropertiesLookup 9553 } = __w_pdfjs_require__(26); 9554 9555 return docPropertiesLookup(this._pdfDocument); 9556 } 9557 9558 _createScripting() { 9559 this._destroyCapability = (0, _pdfjsLib.createPromiseCapability)(); 9560 9561 if (this._scripting) { 9562 throw new Error("_createScripting: Scripting already exists."); 9563 } 9564 9565 if (this._scriptingFactory) { 9566 return this._scriptingFactory.createScripting({ 9567 sandboxBundleSrc: this._sandboxBundleSrc 9568 }); 9569 } 9570 9571 const { 9572 GenericScripting 9573 } = __w_pdfjs_require__(26); 9574 9575 return new GenericScripting(this._sandboxBundleSrc); 9576 } 9577 9578 async _destroyScripting() { 9579 var _this$_destroyCapabil3; 9580 9581 if (!this._scripting) { 9582 var _this$_destroyCapabil2; 9583 9584 this._pdfDocument = null; 9585 (_this$_destroyCapabil2 = this._destroyCapability) === null || _this$_destroyCapabil2 === void 0 ? void 0 : _this$_destroyCapabil2.resolve(); 9586 return; 9587 } 9588 9589 if (this._closeCapability) { 9590 await Promise.race([this._closeCapability.promise, new Promise(resolve => { 9591 setTimeout(resolve, 1000); 9592 })]).catch(reason => {}); 9593 this._closeCapability = null; 9594 } 9595 9596 this._pdfDocument = null; 9597 9598 try { 9599 await this._scripting.destroySandbox(); 9600 } catch (ex) {} 9601 9602 for (const [name, listener] of this._internalEvents) { 9603 this._eventBus._off(name, listener); 9604 } 9605 9606 this._internalEvents.clear(); 9607 9608 for (const [name, listener] of this._domEvents) { 9609 window.removeEventListener(name, listener, true); 9610 } 9611 9612 this._domEvents.clear(); 9613 9614 this._pageOpenPending.clear(); 9615 9616 this._visitedPages.clear(); 9617 9618 this._scripting = null; 9619 delete this._mouseState.isDown; 9620 this._ready = false; 9621 (_this$_destroyCapabil3 = this._destroyCapability) === null || _this$_destroyCapabil3 === void 0 ? void 0 : _this$_destroyCapabil3.resolve(); 9622 } 9623 9624} 9625 9626exports.PDFScriptingManager = PDFScriptingManager; 9627 9628/***/ }), 9629/* 26 */ 9630/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { 9631 9632 9633 9634Object.defineProperty(exports, "__esModule", ({ 9635 value: true 9636})); 9637exports.GenericScripting = void 0; 9638exports.docPropertiesLookup = docPropertiesLookup; 9639 9640var _pdfjsLib = __w_pdfjs_require__(3); 9641 9642async function docPropertiesLookup(pdfDocument) { 9643 const url = "", 9644 baseUrl = url.split("#")[0]; 9645 let { 9646 info, 9647 metadata, 9648 contentDispositionFilename, 9649 contentLength 9650 } = await pdfDocument.getMetadata(); 9651 9652 if (!contentLength) { 9653 const { 9654 length 9655 } = await pdfDocument.getDownloadInfo(); 9656 contentLength = length; 9657 } 9658 9659 return { ...info, 9660 baseURL: baseUrl, 9661 filesize: contentLength, 9662 filename: contentDispositionFilename || (0, _pdfjsLib.getPdfFilenameFromUrl)(url), 9663 metadata: metadata === null || metadata === void 0 ? void 0 : metadata.getRaw(), 9664 authors: metadata === null || metadata === void 0 ? void 0 : metadata.get("dc:creator"), 9665 numPages: pdfDocument.numPages, 9666 URL: url 9667 }; 9668} 9669 9670class GenericScripting { 9671 constructor(sandboxBundleSrc) { 9672 this._ready = (0, _pdfjsLib.loadScript)(sandboxBundleSrc, true).then(() => {
9673 return window.pdfjsSandbox.QuickJSSandbox(); 9674 }); 9675 } 9676 9677 async createSandbox(data) { 9678 const sandbox = await this._ready; 9679 sandbox.create(data); 9680 } 9681 9682 async dispatchEventInSandbox(event) { 9683 const sandbox = await this._ready; 9684 setTimeout(() => sandbox.dispatchEvent(event), 0); 9685 } 9686 9687 async destroySandbox() { 9688 const sandbox = await this._ready; 9689 sandbox.nukeSandbox(); 9690 } 9691 9692} 9693 9694exports.GenericScripting = GenericScripting; 9695 9696/***/ }) 9697/******/ ]); 9698/************************************************************************/ 9699/******/ // The module cache 9700/******/ var __webpack_module_cache__ = {}; 9701/******/ 9702/******/ // The require function 9703/******/ function __w_pdfjs_require__(moduleId) { 9704/******/ // Check if module is in cache 9705/******/ var cachedModule = __webpack_module_cache__[moduleId]; 9706/******/ if (cachedModule !== undefined) { 9707/******/ return cachedModule.exports; 9708/******/ } 9709/******/ // Create a new module (and put it into the cache) 9710/******/ var module = __webpack_module_cache__[moduleId] = { 9711/******/ // no module.id needed 9712/******/ // no module.loaded needed 9713/******/ exports: {} 9714/******/ }; 9715/******/ 9716/******/ // Execute the module function 9717/******/ __webpack_modules__[moduleId](module, module.exports, __w_pdfjs_require__); 9718/******/ 9719/******/ // Return the exports of the module 9720/******/ return module.exports; 9721/******/ } 9722/******/ 9723/************************************************************************/ 9724var __webpack_exports__ = {}; 9725// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 9726(() => { 9727var exports = __webpack_exports__; 9728 9729 9730Object.defineProperty(exports, "__esModule", ({ 9731 value: true 9732})); 9733Object.defineProperty(exports, "AnnotationLayerBuilder", ({ 9734 enumerable: true, 9735 get: function () { 9736 return _annotation_layer_builder.AnnotationLayerBuilder; 9737 } 9738})); 9739Object.defineProperty(exports, "DefaultAnnotationLayerFactory", ({ 9740 enumerable: true, 9741 get: function () { 9742 return _default_factory.DefaultAnnotationLayerFactory; 9743 } 9744})); 9745Object.defineProperty(exports, "DefaultStructTreeLayerFactory", ({ 9746 enumerable: true, 9747 get: function () { 9748 return _default_factory.DefaultStructTreeLayerFactory; 9749 } 9750})); 9751Object.defineProperty(exports, "DefaultTextLayerFactory", ({ 9752 enumerable: true, 9753 get: function () { 9754 return _default_factory.DefaultTextLayerFactory; 9755 } 9756})); 9757Object.defineProperty(exports, "DefaultXfaLayerFactory", ({ 9758 enumerable: true, 9759 get: function () { 9760 return _default_factory.DefaultXfaLayerFactory; 9761 } 9762})); 9763Object.defineProperty(exports, "DownloadManager", ({ 9764 enumerable: true, 9765 get: function () { 9766 return _download_manager.DownloadManager; 9767 } 9768})); 9769Object.defineProperty(exports, "EventBus", ({ 9770 enumerable: true, 9771 get: function () { 9772 return _event_utils.EventBus; 9773 } 9774})); 9775Object.defineProperty(exports, "GenericL10n", ({ 9776 enumerable: true, 9777 get: function () { 9778 return _genericl10n.GenericL10n; 9779 } 9780})); 9781Object.defineProperty(exports, "LinkTarget", ({ 9782 enumerable: true, 9783 get: function () { 9784 return _pdf_link_service.LinkTarget; 9785 } 9786})); 9787Object.defineProperty(exports, "NullL10n", ({ 9788 enumerable: true, 9789 get: function () { 9790 return _l10n_utils.NullL10n; 9791 } 9792})); 9793Object.defineProperty(exports, "PDFFindController", ({ 9794 enumerable: true, 9795 get: function () { 9796 return _pdf_find_controller.PDFFindController; 9797 } 9798})); 9799Object.defineProperty(exports, "PDFHistory", ({ 9800 enumerable: true, 9801 get: function () { 9802 return _pdf_history.PDFHistory; 9803 } 9804})); 9805Object.defineProperty(exports, "PDFLinkService", ({ 9806 enumerable: true, 9807 get: function () { 9808 return _pdf_link_service.PDFLinkService; 9809 } 9810})); 9811Object.defineProperty(exports, "PDFPageView", ({ 9812 enumerable: true, 9813 get: function () { 9814 return _pdf_page_view.PDFPageView; 9815 } 9816})); 9817Object.defineProperty(exports, "PDFScriptingManager", ({ 9818 enumerable: true, 9819 get: function () { 9820 return _pdf_scripting_manager.PDFScriptingManager; 9821 } 9822})); 9823Object.defineProperty(exports, "PDFSinglePageViewer", ({ 9824 enumerable: true, 9825 get: function () { 9826 return _pdf_viewer.PDFSinglePageViewer; 9827 } 9828})); 9829Object.defineProperty(exports, "PDFViewer", ({ 9830 enumerable: true, 9831 get: function () { 9832 return _pdf_viewer.PDFViewer; 9833 } 9834})); 9835Object.defineProperty(exports, "ProgressBar", ({ 9836 enumerable: true, 9837 get: function () { 9838 return _ui_utils.ProgressBar; 9839 } 9840})); 9841Object.defineProperty(exports, "RenderingStates", ({ 9842 enumerable: true, 9843 get: function () { 9844 return _ui_utils.RenderingStates; 9845 } 9846})); 9847Object.defineProperty(exports, "ScrollMode", ({ 9848 enumerable: true, 9849 get: function () { 9850 return _ui_utils.ScrollMode; 9851 } 9852})); 9853Object.defineProperty(exports, "SimpleLinkService", ({ 9854 enumerable: true, 9855 get: function () { 9856 return _pdf_link_service.SimpleLinkService; 9857 } 9858})); 9859Object.defineProperty(exports, "SpreadMode", ({ 9860 enumerable: true, 9861 get: function () { 9862 return _ui_utils.SpreadMode;
9863 } 9864})); 9865Object.defineProperty(exports, "StructTreeLayerBuilder", ({ 9866 enumerable: true, 9867 get: function () { 9868 return _struct_tree_layer_builder.StructTreeLayerBuilder; 9869 } 9870})); 9871Object.defineProperty(exports, "TextLayerBuilder", ({ 9872 enumerable: true, 9873 get: function () { 9874 return _text_layer_builder.TextLayerBuilder; 9875 } 9876})); 9877Object.defineProperty(exports, "XfaLayerBuilder", ({ 9878 enumerable: true, 9879 get: function () { 9880 return _xfa_layer_builder.XfaLayerBuilder; 9881 } 9882})); 9883Object.defineProperty(exports, "parseQueryString", ({ 9884 enumerable: true, 9885 get: function () { 9886 return _ui_utils.parseQueryString; 9887 } 9888})); 9889 9890var _default_factory = __w_pdfjs_require__(1); 9891 9892var _pdf_link_service = __w_pdfjs_require__(6); 9893 9894var _ui_utils = __w_pdfjs_require__(7); 9895 9896var _pdf_viewer = __w_pdfjs_require__(11); 9897 9898var _annotation_layer_builder = __w_pdfjs_require__(5); 9899 9900var _download_manager = __w_pdfjs_require__(18); 9901 9902var _event_utils = __w_pdfjs_require__(19); 9903 9904var _genericl10n = __w_pdfjs_require__(20); 9905 9906var _l10n_utils = __w_pdfjs_require__(4); 9907 9908var _pdf_find_controller = __w_pdfjs_require__(22); 9909 9910var _pdf_history = __w_pdfjs_require__(24); 9911 9912var _pdf_page_view = __w_pdfjs_require__(13); 9913 9914var _pdf_scripting_manager = __w_pdfjs_require__(25); 9915 9916var _struct_tree_layer_builder = __w_pdfjs_require__(8); 9917 9918var _text_layer_builder = __w_pdfjs_require__(9); 9919 9920var _xfa_layer_builder = __w_pdfjs_require__(10); 9921 9922const pdfjsVersion = '2.16.105'; 9923const pdfjsBuild = '172ccdbe5'; 9924})(); 9925 9926/******/ return __webpack_exports__; 9927/******/ })() 9928; 9929}); 9930//# sourceMappingURL=pdf_viewer.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.