1/**
2 * @licstart The following is the entire license notice for the
3 * Javascript code in this page
4 *
5 * Copyright 2019 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(modules) { // webpackBootstrap
24/******/ 	// The module cache
25/******/ 	var installedModules = {};
26/******/
27/******/ 	// The require function
28/******/ 	function __webpack_require__(moduleId) {
29/******/
30/******/ 		// Check if module is in cache
31/******/ 		if(installedModules[moduleId]) {
32/******/ 			return installedModules[moduleId].exports;
33/******/ 		}
34/******/ 		// Create a new module (and put it into the cache)
35/******/ 		var module = installedModules[moduleId] = {
36/******/ 			i: moduleId,
37/******/ 			l: false,
38/******/ 			exports: {}
39/******/ 		};
40/******/
41/******/ 		// Execute the module function
42/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
43/******/
44/******/ 		// Flag the module as loaded
45/******/ 		module.l = true;
46/******/
47/******/ 		// Return the exports of the module
48/******/ 		return module.exports;
49/******/ 	}
50/******/
51/******/
52/******/ 	// expose the modules object (__webpack_modules__)
53/******/ 	__webpack_require__.m = modules;
54/******/
55/******/ 	// expose the module cache
56/******/ 	__webpack_require__.c = installedModules;
57/******/
58/******/ 	// define getter function for harmony exports
59/******/ 	__webpack_require__.d = function(exports, name, getter) {
60/******/ 		if(!__webpack_require__.o(exports, name)) {
61/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
62/******/ 		}
63/******/ 	};
64/******/
65/******/ 	// define __esModule on exports
66/******/ 	__webpack_require__.r = function(exports) {
67/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
68/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
69/******/ 		}
70/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
71/******/ 	};
72/******/
73/******/ 	// create a fake namespace object
74/******/ 	// mode & 1: value is a module id, require it
75/******/ 	// mode & 2: merge all properties of value into the ns
76/******/ 	// mode & 4: return value when already ns object
77/******/ 	// mode & 8|1: behave like require
78/******/ 	__webpack_require__.t = function(value, mode) {
79/******/ 		if(mode & 1) value = __webpack_require__(value);
80/******/ 		if(mode & 8) return value;
81/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
82/******/ 		var ns = Object.create(null);
83/******/ 		__webpack_require__.r(ns);
84/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
85/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
86/******/ 		return ns;
87/******/ 	};
88/******/
89/******/ 	// getDefaultExport function for compatibility with non-harmony modules
90/******/ 	__webpack_require__.n = function(module) {
91/******/ 		var getter = module && module.__esModule ?
92/******/ 			function getDefault() { return module['default']; } :
93/******/ 			function getModuleExports() { return module; };
94/******/ 		__webpack_require__.d(getter, 'a', getter);
95/******/ 		return getter;
96/******/ 	};
97/******/
98/******/ 	// Object.prototype.hasOwnProperty.call
99/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
100/******/
101/******/ 	// __webpack_public_path__
102/******/ 	__webpack_require__.p = "";
103/******/
104/******/
105/******/ 	// Load entry module and return exports
106/******/ 	return __webpack_require__(__webpack_require__.s = 0);
107/******/ })
108/************************************************************************/
109/******/ ([
110/* 0 */
111/***/ (function(module, exports, __webpack_require__) {
112
113"use strict";
114
115
116;
117var pdfjsWebApp, pdfjsWebAppOptions;
118{
119  pdfjsWebApp = __webpack_require__(1);
120  pdfjsWebAppOptions = __webpack_require__(6);
121}
122;
123{
124  __webpack_require__(36);
125}
126;
127{
128  __webpack_require__(41);
129}
130
131function getViewerConfiguration() {
132  return {
133    appContainer: document.body,
134    mainContainer: document.getElementById('viewerContainer'),
135    viewerContainer: document.getElementById('viewer'),
136    eventBus: null,
137    toolbar: {
138      container: document.getElementById('toolbarViewer'),
139      numPages: document.getElementById('numPages'),
140      pageNumber: document.getElementById('pageNumber'),
141      scaleSelectContainer: document.getElementById('scaleSelectContainer'),
142      scaleSelect: document.getElementById('scaleSelect'),
143      customScaleOption: document.getElementById('customScaleOption'),
144      previous: document.getElementById('previous'),
145      next: document.getElementById('next'),
146      zoomIn: document.getElementById('zoomIn'),
147      zoomOut: document.getElementById('zoomOut'),
148      viewFind: document.getElementById('viewFind'),
149      openFile: document.getElementById('openFile'),
150      print: document.getElementById('print'),
151      presentationModeButton: document.getElementById('presentationMode'),
152      download: document.getElementById('download'),
153      viewBookmark: document.getElementById('viewBookmark')
154    },
155    secondaryToolbar: {
156      toolbar: document.getElementById('secondaryToolbar'),
157      toggleButton: document.getElementById('secondaryToolbarToggle'),
158      toolbarButtonContainer: document.getElementById('secondaryToolbarButtonContainer'),
159      presentationModeButton: document.getElementById('secondaryPresentationMode'),
160      openFileButton: document.getElementById('secondaryOpenFile'),
161      printButton: document.getElementById('secondaryPrint'),
162      downloadButton: document.getElementById('secondaryDownload'),
163      viewBookmarkButton: document.getElementById('secondaryViewBookmark'),
164      firstPageButton: document.getElementById('firstPage'),
165      lastPageButton: document.getElementById('lastPage'),
166      pageRotateCwButton: document.getElementById('pageRotateCw'),
167      pageRotateCcwButton: document.getElementById('pageRotateCcw'),
168      cursorSelectToolButton: document.getElementById('cursorSelectTool'),
169      cursorHandToolButton: document.getElementById('cursorHandTool'),
170      scrollVerticalButton: document.getElementById('scrollVertical'),
171      scrollHorizontalButton: document.getElementById('scrollHorizontal'),
172      scrollWrappedButton: document.getElementById('scrollWrapped'),
173      spreadNoneButton: document.getElementById('spreadNone'),
174      spreadOddButton: document.getElementById('spreadOdd'),
175      spreadEvenButton: document.getElementById('spreadEven'),
176      documentPropertiesButton: document.getElementById('documentProperties')
177    },
178    fullscreen: {
179      contextFirstPage: document.getElementById('contextFirstPage'),
180      contextLastPage: document.getElementById('contextLastPage'),
181      contextPageRotateCw: document.getElementById('contextPageRotateCw'),
182      contextPageRotateCcw: document.getElementById('contextPageRotateCcw')
183    },
184    sidebar: {
185      outerContainer: document.getElementById('outerContainer'),
186      viewerContainer: document.getElementById('viewerContainer'),
187      toggleButton: document.getElementById('sidebarToggle'),
188      thumbnailButton: document.getElementById('viewThumbnail'),
189      outlineButton: document.getElementById('viewOutline'),
190      attachmentsButton: document.getElementById('viewAttachments'),
191      thumbnailView: document.getElementById('thumbnailView'),
192      outlineView: document.getElementById('outlineView'),
193      attachmentsView: document.getElementById('attachmentsView')
194    },
195    sidebarResizer: {
196      outerContainer: document.getElementById('outerContainer'),
197      resizer: document.getElementById('sidebarResizer')
198    },
199    findBar: {
200      bar: document.getElementById('findbar'),
201      toggleButton: document.getElementById('viewFind'),
202      findField: document.getElementById('findInput'),
203      highlightAllCheckbox: document.getElementById('findHighlightAll'),
204      caseSensitiveCheckbox: document.getElementById('findMatchCase'),
205      entireWordCheckbox: document.getElementById('findEntireWord'),
206      findMsg: document.getElementById('findMsg'),
207      findResultsCount: document.getElementById('findResultsCount'),
208      findPreviousButton: document.getElementById('findPrevious'),
209      findNextButton: document.getElementById('findNext')
210    },
211    passwordOverlay: {
212      overlayName: 'passwordOverlay',
213      container: document.getElementById('passwordOverlay'),
214      label: document.getElementById('passwordText'),
215      input: document.getElementById('password'),
216      submitButton: document.getElementById('passwordSubmit'),
217      cancelButton: document.getElementById('passwordCancel')
218    },
219    documentProperties: {
220      overlayName: 'documentPropertiesOverlay',
221      container: document.getElementById('documentPropertiesOverlay'),
222      closeButton: document.getElementById('documentPropertiesClose'),
223      fields: {
224        'fileName': document.getElementById('fileNameField'),
225        'fileSize': document.getElementById('fileSizeField'),
226        'title': document.getElementById('titleField'),
227        'author': document.getElementById('authorField'),
228        'subject': document.getElementById('subjectField'),
229        'keywords': document.getElementById('keywordsField'),
230        'creationDate': document.getElementById('creationDateField'),
231        'modificationDate': document.getElementById('modificationDateField'),
232        'creator': document.getElementById('creatorField'),
233        'producer': document.getElementById('producerField'),
234        'version': document.getElementById('versionField'),
235        'pageCount': document.getElementById('pageCountField'),
236        'pageSize': document.getElementById('pageSizeField'),
237        'linearized': document.getElementById('linearizedField')
238      }
239    },
240    errorWrapper: {
241      container: document.getElementById('errorWrapper'),
242      errorMessage: document.getElementById('errorMessage'),
243      closeButton: document.getElementById('errorClose'),
244      errorMoreInfo: document.getElementById('errorMoreInfo'),
245      moreInfoButton: document.getElementById('errorShowMore'),
246      lessInfoButton: document.getElementById('errorShowLess')
247    },
248    printContainer: document.getElementById('printContainer'),
249    openFileInputName: 'fileInput',
250    debuggerScriptPath: './debugger.js'
251  };
252}
253
254function webViewerLoad() {
255  var config = getViewerConfiguration();
256  window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
257  window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
258  var event = document.createEvent('CustomEvent');
259  event.initCustomEvent('webviewerloaded', true, true, {});
260  document.dispatchEvent(event);
261  pdfjsWebApp.PDFViewerApplication.run(config);
262}
263
264if (document.readyState === 'interactive' || document.readyState === 'complete') {
265  webViewerLoad();
266} else {
267  document.addEventListener('DOMContentLoaded', webViewerLoad, true);
268}
269
270/***/ }),
271/* 1 */
272/***/ (function(module, exports, __webpack_require__) {
273
274"use strict";
275
276
277Object.defineProperty(exports, "__esModule", {
278  value: true
279});
280exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
281
282var _regenerator = _interopRequireDefault(__webpack_require__(2));
283
284var _ui_utils = __webpack_require__(5);
285
286var _app_options = __webpack_require__(6);
287
288var _pdfjsLib = __webpack_require__(7);
289
290var _pdf_cursor_tools = __webpack_require__(9);
291
292var _pdf_rendering_queue = __webpack_require__(11);
293
294var _pdf_sidebar = __webpack_require__(12);
295
296var _overlay_manager = __webpack_require__(13);
297
298var _password_prompt = __webpack_require__(14);
299
300var _pdf_attachment_viewer = __webpack_require__(15);
301
302var _pdf_document_properties = __webpack_require__(16);
303
304var _pdf_find_bar = __webpack_require__(17);
305
306var _pdf_find_controller = __webpack_require__(18);
307
308var _pdf_history = __webpack_require__(20);
309
310var _pdf_link_service = __webpack_require__(21);
311
312var _pdf_outline_viewer = __webpack_require__(22);
313
314var _pdf_presentation_mode = __webpack_require__(23);
315
316var _pdf_sidebar_resizer = __webpack_require__(24);
317
318var _pdf_thumbnail_viewer = __webpack_require__(25);
319
320var _pdf_viewer = __webpack_require__(27);
321
322var _secondary_toolbar = __webpack_require__(32);
323
324var _toolbar = __webpack_require__(34);
325
326var _view_history = __webpack_require__(35);
327
328function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
329
330function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
331
332function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
333
334function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
335
336function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
337
338function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
339
340function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
341
342var DEFAULT_SCALE_DELTA = 1.1;
343var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
344var FORCE_PAGES_LOADED_TIMEOUT = 10000;
345var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
346var ViewOnLoad = {
347  UNKNOWN: -1,
348  PREVIOUS: 0,
349  INITIAL: 1
350};
351var DefaultExternalServices = {
352  updateFindControlState: function updateFindControlState(data) {},
353  updateFindMatchesCount: function updateFindMatchesCount(data) {},
354  initPassiveLoading: function initPassiveLoading(callbacks) {},
355  fallback: function fallback(data, callback) {},
356  reportTelemetry: function reportTelemetry(data) {},
357  createDownloadManager: function createDownloadManager(options) {
358    throw new Error('Not implemented: createDownloadManager');
359  },
360  createPreferences: function createPreferences() {
361    throw new Error('Not implemented: createPreferences');
362  },
363  createL10n: function createL10n(options) {
364    throw new Error('Not implemented: createL10n');
365  },
366  supportsIntegratedFind: false,
367  supportsDocumentFonts: true,
368  supportsDocumentColors: true,
369  supportedMouseWheelZoomModifierKeys: {
370    ctrlKey: true,
371    metaKey: true
372  }
373};
374exports.DefaultExternalServices = DefaultExternalServices;
375var PDFViewerApplication = {
376  initialBookmark: document.location.hash.substring(1),
377  initialized: false,
378  fellback: false,
379  appConfig: null,
380  pdfDocument: null,
381  pdfLoadingTask: null,
382  printService: null,
383  pdfViewer: null,
384  pdfThumbnailViewer: null,
385  pdfRenderingQueue: null,
386  pdfPresentationMode: null,
387  pdfDocumentProperties: null,
388  pdfLinkService: null,
389  pdfHistory: null,
390  pdfSidebar: null,
391  pdfSidebarResizer: null,
392  pdfOutlineViewer: null,
393  pdfAttachmentViewer: null,
394  pdfCursorTools: null,
395  store: null,
396  downloadManager: null,
397  overlayManager: null,
398  preferences: null,
399  toolbar: null,
400  secondaryToolbar: null,
401  eventBus: null,
402  l10n: null,
403  isInitialViewSet: false,
404  downloadComplete: false,
405  isViewerEmbedded: window.parent !== window,
406  url: '',
407  baseUrl: '',
408  externalServices: DefaultExternalServices,
409  _boundEvents: {},
410  contentDispositionFilename: null,
411  initialize: function () {
412    var _initialize = _asyncToGenerator(
413    /*#__PURE__*/
414    _regenerator["default"].mark(function _callee(appConfig) {
415      var _this = this;
416
417      var appContainer;
418      return _regenerator["default"].wrap(function _callee$(_context) {
419        while (1) {
420          switch (_context.prev = _context.next) {
421            case 0:
422              this.preferences = this.externalServices.createPreferences();
423              this.appConfig = appConfig;
424              _context.next = 4;
425              return this._readPreferences();
426
427            case 4:
428              _context.next = 6;
429              return this._parseHashParameters();
430
431            case 6:
432              _context.next = 8;
433              return this._initializeL10n();
434
435            case 8:
436              if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdfjsLib.LinkTarget.NONE) {
437                _app_options.AppOptions.set('externalLinkTarget', _pdfjsLib.LinkTarget.TOP);
438              }
439
440              _context.next = 11;
441              return this._initializeViewerComponents();
442
443            case 11:
444              this.bindEvents();
445              this.bindWindowEvents();
446              appContainer = appConfig.appContainer || document.documentElement;
447              this.l10n.translate(appContainer).then(function () {
448                _this.eventBus.dispatch('localized', {
449                  source: _this
450                });
451              });
452              this.initialized = true;
453
454            case 16:
455            case "end":
456              return _context.stop();
457          }
458        }
459      }, _callee, this);
460    }));
461
462    function initialize(_x) {
463      return _initialize.apply(this, arguments);
464    }
465
466    return initialize;
467  }(),
468  _readPreferences: function () {
469    var _readPreferences2 = _asyncToGenerator(
470    /*#__PURE__*/
471    _regenerator["default"].mark(function _callee2() {
472      var prefs, name;
473      return _regenerator["default"].wrap(function _callee2$(_context2) {
474        while (1) {
475          switch (_context2.prev = _context2.next) {
476            case 0:
477              if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
478                _context2.next = 2;
479                break;
480              }
481
482              return _context2.abrupt("return");
483
484            case 2:
485              _context2.prev = 2;
486              _context2.next = 5;
487              return this.preferences.getAll();
488
489            case 5:
490              prefs = _context2.sent;
491
492              for (name in prefs) {
493                _app_options.AppOptions.set(name, prefs[name]);
494              }
495
496              _context2.next = 12;
497              break;
498
499            case 9:
500              _context2.prev = 9;
501              _context2.t0 = _context2["catch"](2);
502              console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
503
504            case 12:
505            case "end":
506              return _context2.stop();
507          }
508        }
509      }, _callee2, this, [[2, 9]]);
510    }));
511
512    function _readPreferences() {
513      return _readPreferences2.apply(this, arguments);
514    }
515
516    return _readPreferences;
517  }(),
518  _parseHashParameters: function () {
519    var _parseHashParameters2 = _asyncToGenerator(
520    /*#__PURE__*/
521    _regenerator["default"].mark(function _callee3() {
522      var waitOn, hash, hashParams, viewer, enabled;
523      return _regenerator["default"].wrap(function _callee3$(_context3) {
524        while (1) {
525          switch (_context3.prev = _context3.next) {
526            case 0:
527              if (_app_options.AppOptions.get('pdfBugEnabled')) {
528                _context3.next = 2;
529                break;
530              }
531
532              return _context3.abrupt("return", undefined);
533
534            case 2:
535              waitOn = [];
536              hash = document.location.hash.substring(1);
537              hashParams = (0, _ui_utils.parseQueryString)(hash);
538
539              if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
540                waitOn.push(loadFakeWorker());
541              }
542
543              if ('disablerange' in hashParams) {
544                _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
545              }
546
547              if ('disablestream' in hashParams) {
548                _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
549              }
550
551              if ('disableautofetch' in hashParams) {
552                _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
553              }
554
555              if ('disablefontface' in hashParams) {
556                _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
557              }
558
559              if ('disablehistory' in hashParams) {
560                _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
561              }
562
563              if ('webgl' in hashParams) {
564                _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
565              }
566
567              if ('useonlycsszoom' in hashParams) {
568                _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
569              }
570
571              if ('verbosity' in hashParams) {
572                _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
573              }
574
575              if (!('textlayer' in hashParams)) {
576                _context3.next = 23;
577                break;
578              }
579
580              _context3.t0 = hashParams['textlayer'];
581              _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
582              break;
583
584            case 18:
585              _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
586
587              return _context3.abrupt("break", 23);
588
589            case 20:
590              viewer = this.appConfig.viewerContainer;
591              viewer.classList.add('textLayer-' + hashParams['textlayer']);
592              return _context3.abrupt("break", 23);
593
594            case 23:
595              if ('pdfbug' in hashParams) {
596                _app_options.AppOptions.set('pdfBug', true);
597
598                enabled = hashParams['pdfbug'].split(',');
599                waitOn.push(loadAndEnablePDFBug(enabled));
600              }
601
602              if ('locale' in hashParams) {
603                _app_options.AppOptions.set('locale', hashParams['locale']);
604              }
605
606              return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
607                console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
608              }));
609
610            case 26:
611            case "end":
612              return _context3.stop();
613          }
614        }
615      }, _callee3, this);
616    }));
617
618    function _parseHashParameters() {
619      return _parseHashParameters2.apply(this, arguments);
620    }
621
622    return _parseHashParameters;
623  }(),
624  _initializeL10n: function () {
625    var _initializeL10n2 = _asyncToGenerator(
626    /*#__PURE__*/
627    _regenerator["default"].mark(function _callee4() {
628      var dir;
629      return _regenerator["default"].wrap(function _callee4$(_context4) {
630        while (1) {
631          switch (_context4.prev = _context4.next) {
632            case 0:
633              this.l10n = this.externalServices.createL10n({
634                locale: _app_options.AppOptions.get('locale')
635              });
636              _context4.next = 3;
637              return this.l10n.getDirection();
638
639            case 3:
640              dir = _context4.sent;
641              document.getElementsByTagName('html')[0].dir = dir;
642
643            case 5:
644            case "end":
645              return _context4.stop();
646          }
647        }
648      }, _callee4, this);
649    }));
650
651    function _initializeL10n() {
652      return _initializeL10n2.apply(this, arguments);
653    }
654
655    return _initializeL10n;
656  }(),
657  _initializeViewerComponents: function () {
658    var _initializeViewerComponents2 = _asyncToGenerator(
659    /*#__PURE__*/
660    _regenerator["default"].mark(function _callee5() {
661      var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
662      return _regenerator["default"].wrap(function _callee5$(_context5) {
663        while (1) {
664          switch (_context5.prev = _context5.next) {
665            case 0:
666              appConfig = this.appConfig;
667              this.overlayManager = new _overlay_manager.OverlayManager();
668              eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(_app_options.AppOptions.get('eventBusDispatchToDOM'));
669              this.eventBus = eventBus;
670              pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
671              pdfRenderingQueue.onIdle = this.cleanup.bind(this);
672              this.pdfRenderingQueue = pdfRenderingQueue;
673              pdfLinkService = new _pdf_link_service.PDFLinkService({
674                eventBus: eventBus,
675                externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
676                externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
677              });
678              this.pdfLinkService = pdfLinkService;
679              downloadManager = this.externalServices.createDownloadManager({
680                disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
681              });
682              this.downloadManager = downloadManager;
683              findController = new _pdf_find_controller.PDFFindController({
684                linkService: pdfLinkService,
685                eventBus: eventBus
686              });
687              this.findController = findController;
688              container = appConfig.mainContainer;
689              viewer = appConfig.viewerContainer;
690              this.pdfViewer = new _pdf_viewer.PDFViewer({
691                container: container,
692                viewer: viewer,
693                eventBus: eventBus,
694                renderingQueue: pdfRenderingQueue,
695                linkService: pdfLinkService,
696                downloadManager: downloadManager,
697                findController: findController,
698                renderer: _app_options.AppOptions.get('renderer'),
699                enableWebGL: _app_options.AppOptions.get('enableWebGL'),
700                l10n: this.l10n,
701                textLayerMode: _app_options.AppOptions.get('textLayerMode'),
702                imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
703                renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
704                enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
705                useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
706                maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
707              });
708              pdfRenderingQueue.setViewer(this.pdfViewer);
709              pdfLinkService.setViewer(this.pdfViewer);
710              this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
711                container: appConfig.sidebar.thumbnailView,
712                renderingQueue: pdfRenderingQueue,
713                linkService: pdfLinkService,
714                l10n: this.l10n
715              });
716              pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
717              this.pdfHistory = new _pdf_history.PDFHistory({
718                linkService: pdfLinkService,
719                eventBus: eventBus
720              });
721              pdfLinkService.setHistory(this.pdfHistory);
722              this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
723              this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
724              this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
725                container: container,
726                eventBus: eventBus,
727                cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
728              });
729              this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
730              this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
731
732              if (this.supportsFullscreen) {
733                this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
734                  container: container,
735                  viewer: viewer,
736                  pdfViewer: this.pdfViewer,
737                  eventBus: eventBus,
738                  contextMenuItems: appConfig.fullscreen
739                });
740              }
741
742              this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
743              this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
744                container: appConfig.sidebar.outlineView,
745                eventBus: eventBus,
746                linkService: pdfLinkService
747              });
748              this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
749                container: appConfig.sidebar.attachmentsView,
750                eventBus: eventBus,
751                downloadManager: downloadManager
752              });
753              this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
754                elements: appConfig.sidebar,
755                pdfViewer: this.pdfViewer,
756                pdfThumbnailViewer: this.pdfThumbnailViewer,
757                eventBus: eventBus,
758                l10n: this.l10n
759              });
760              this.pdfSidebar.onToggled = this.forceRendering.bind(this);
761              this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
762
763            case 34:
764            case "end":
765              return _context5.stop();
766          }
767        }
768      }, _callee5, this);
769    }));
770
771    function _initializeViewerComponents() {
772      return _initializeViewerComponents2.apply(this, arguments);
773    }
774
775    return _initializeViewerComponents;
776  }(),
777  run: function run(config) {
778    this.initialize(config).then(webViewerInitialized);
779  },
780  zoomIn: function zoomIn(ticks) {
781    var newScale = this.pdfViewer.currentScale;
782
783    do {
784      newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
785      newScale = Math.ceil(newScale * 10) / 10;
786      newScale = Math.min(_ui_utils.MAX_SCALE, newScale);
787    } while (--ticks > 0 && newScale < _ui_utils.MAX_SCALE);
788
789    this.pdfViewer.currentScaleValue = newScale;
790  },
791  zoomOut: function zoomOut(ticks) {
792    var newScale = this.pdfViewer.currentScale;
793
794    do {
795      newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
796      newScale = Math.floor(newScale * 10) / 10;
797      newScale = Math.max(_ui_utils.MIN_SCALE, newScale);
798    } while (--ticks > 0 && newScale > _ui_utils.MIN_SCALE);
799
800    this.pdfViewer.currentScaleValue = newScale;
801  },
802  zoomReset: function zoomReset() {
803    var ignoreDuplicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
804
805    if (this.pdfViewer.isInPresentationMode) {
806      return;
807    } else if (ignoreDuplicate && this.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
808      return;
809    }
810
811    this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
812  },
813
814  get pagesCount() {
815    return this.pdfDocument ? this.pdfDocument.numPages : 0;
816  },
817
818  set page(val) {
819    this.pdfViewer.currentPageNumber = val;
820  },
821
822  get page() {
823    return this.pdfViewer.currentPageNumber;
824  },
825
826  get printing() {
827    return !!this.printService;
828  },
829
830  get supportsPrinting() {
831    return PDFPrintServiceFactory.instance.supportsPrinting;
832  },
833
834  get supportsFullscreen() {
835    var support;
836    var doc = document.documentElement;
837    support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
838
839    if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
840      support = false;
841    }
842
843    return (0, _pdfjsLib.shadow)(this, 'supportsFullscreen', support);
844  },
845
846  get supportsIntegratedFind() {
847    return this.externalServices.supportsIntegratedFind;
848  },
849
850  get supportsDocumentFonts() {
851    return this.externalServices.supportsDocumentFonts;
852  },
853
854  get supportsDocumentColors() {
855    return this.externalServices.supportsDocumentColors;
856  },
857
858  get loadingBar() {
859    var bar = new _ui_utils.ProgressBar('#loadingBar');
860    return (0, _pdfjsLib.shadow)(this, 'loadingBar', bar);
861  },
862
863  get supportedMouseWheelZoomModifierKeys() {
864    return this.externalServices.supportedMouseWheelZoomModifierKeys;
865  },
866
867  initPassiveLoading: function initPassiveLoading() {
868    throw new Error('Not implemented: initPassiveLoading');
869  },
870  setTitleUsingUrl: function setTitleUsingUrl() {
871    var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
872    this.url = url;
873    this.baseUrl = url.split('#')[0];
874    var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
875
876    if (!title) {
877      try {
878        title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
879      } catch (ex) {
880        title = url;
881      }
882    }
883
884    this.setTitle(title);
885  },
886  setTitle: function setTitle(title) {
887    if (this.isViewerEmbedded) {
888      return;
889    }
890
891    document.title = title;
892  },
893  close: function () {
894    var _close = _asyncToGenerator(
895    /*#__PURE__*/
896    _regenerator["default"].mark(function _callee6() {
897      var errorWrapper, promise;
898      return _regenerator["default"].wrap(function _callee6$(_context6) {
899        while (1) {
900          switch (_context6.prev = _context6.next) {
901            case 0:
902              errorWrapper = this.appConfig.errorWrapper.container;
903              errorWrapper.setAttribute('hidden', 'true');
904
905              if (this.pdfLoadingTask) {
906                _context6.next = 4;
907                break;
908              }
909
910              return _context6.abrupt("return", undefined);
911
912            case 4:
913              promise = this.pdfLoadingTask.destroy();
914              this.pdfLoadingTask = null;
915
916              if (this.pdfDocument) {
917                this.pdfDocument = null;
918                this.pdfThumbnailViewer.setDocument(null);
919                this.pdfViewer.setDocument(null);
920                this.pdfLinkService.setDocument(null);
921                this.pdfDocumentProperties.setDocument(null);
922              }
923
924              this.store = null;
925              this.isInitialViewSet = false;
926              this.downloadComplete = false;
927              this.url = '';
928              this.baseUrl = '';
929              this.contentDispositionFilename = null;
930              this.pdfSidebar.reset();
931              this.pdfOutlineViewer.reset();
932              this.pdfAttachmentViewer.reset();
933              this.findBar.reset();
934              this.toolbar.reset();
935              this.secondaryToolbar.reset();
936
937              if (typeof PDFBug !== 'undefined') {
938                PDFBug.cleanup();
939              }
940
941              return _context6.abrupt("return", promise);
942
943            case 21:
944            case "end":
945              return _context6.stop();
946          }
947        }
948      }, _callee6, this);
949    }));
950
951    function close() {
952      return _close.apply(this, arguments);
953    }
954
955    return close;
956  }(),
957  open: function () {
958    var _open = _asyncToGenerator(
959    /*#__PURE__*/
960    _regenerator["default"].mark(function _callee7(file, args) {
961      var _this2 = this;
962
963      var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
964
965      return _regenerator["default"].wrap(function _callee7$(_context7) {
966        while (1) {
967          switch (_context7.prev = _context7.next) {
968            case 0:
969              if (!this.pdfLoadingTask) {
970                _context7.next = 3;
971                break;
972              }
973
974              _context7.next = 3;
975              return this.close();
976
977            case 3:
978              workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
979
980              for (key in workerParameters) {
981                _pdfjsLib.GlobalWorkerOptions[key] = workerParameters[key];
982              }
983
984              parameters = Object.create(null);
985
986              if (typeof file === 'string') {
987                this.setTitleUsingUrl(file);
988                parameters.url = file;
989              } else if (file && 'byteLength' in file) {
990                parameters.data = file;
991              } else if (file.url && file.originalUrl) {
992                this.setTitleUsingUrl(file.originalUrl);
993                parameters.url = file.url;
994              }
995
996              apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
997
998              for (_key in apiParameters) {
999                parameters[_key] = apiParameters[_key];
1000              }
1001
1002              if (args) {
1003                for (prop in args) {
1004                  if (prop === 'length') {
1005                    this.pdfDocumentProperties.setFileSize(args[prop]);
1006                  }
1007
1008                  parameters[prop] = args[prop];
1009                }
1010              }
1011
1012              loadingTask = (0, _pdfjsLib.getDocument)(parameters);
1013              this.pdfLoadingTask = loadingTask;
1014
1015              loadingTask.onPassword = function (updateCallback, reason) {
1016                _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
1017
1018                _this2.passwordPrompt.open();
1019              };
1020
1021              loadingTask.onProgress = function (_ref) {
1022                var loaded = _ref.loaded,
1023                    total = _ref.total;
1024
1025                _this2.progress(loaded / total);
1026              };
1027
1028              loadingTask.onUnsupportedFeature = this.fallback.bind(this);
1029              return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
1030                _this2.load(pdfDocument);
1031              }, function (exception) {
1032                if (loadingTask !== _this2.pdfLoadingTask) {
1033                  return undefined;
1034                }
1035
1036                var message = exception && exception.message;
1037                var loadingErrorMessage;
1038
1039                if (exception instanceof _pdfjsLib.InvalidPDFException) {
1040                  loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
1041                } else if (exception instanceof _pdfjsLib.MissingPDFException) {
1042                  loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
1043                } else if (exception instanceof _pdfjsLib.UnexpectedResponseException) {
1044                  loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
1045                } else {
1046                  loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
1047                }
1048
1049                return loadingErrorMessage.then(function (msg) {
1050                  _this2.error(msg, {
1051                    message: message
1052                  });
1053
1054                  throw new Error(msg);
1055                });
1056              }));
1057
1058            case 16:
1059            case "end":
1060              return _context7.stop();
1061          }
1062        }
1063      }, _callee7, this);
1064    }));
1065
1066    function open(_x2, _x3) {
1067      return _open.apply(this, arguments);
1068    }
1069
1070    return open;
1071  }(),
1072  download: function download() {
1073    var _this3 = this;
1074
1075    function downloadByUrl() {
1076      downloadManager.downloadUrl(url, filename);
1077    }
1078
1079    var url = this.baseUrl;
1080    var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
1081    var downloadManager = this.downloadManager;
1082
1083    downloadManager.onerror = function (err) {
1084      _this3.error("PDF failed to download: ".concat(err));
1085    };
1086
1087    if (!this.pdfDocument || !this.downloadComplete) {
1088      downloadByUrl();
1089      return;
1090    }
1091
1092    this.pdfDocument.getData().then(function (data) {
1093      var blob = new Blob([data], {
1094        type: 'application/pdf'
1095      });
1096      downloadManager.download(blob, url, filename);
1097    })["catch"](downloadByUrl);
1098  },
1099  fallback: function fallback(featureId) {},
1100  error: function error(message, moreInfo) {
1101    var moreInfoText = [this.l10n.get('error_version_info', {
1102      version: _pdfjsLib.version || '?',
1103      build: _pdfjsLib.build || '?'
1104    }, 'PDF.js v{{version}} (build: {{build}})')];
1105
1106    if (moreInfo) {
1107      moreInfoText.push(this.l10n.get('error_message', {
1108        message: moreInfo.message
1109      }, 'Message: {{message}}'));
1110
1111      if (moreInfo.stack) {
1112        moreInfoText.push(this.l10n.get('error_stack', {
1113          stack: moreInfo.stack
1114        }, 'Stack: {{stack}}'));
1115      } else {
1116        if (moreInfo.filename) {
1117          moreInfoText.push(this.l10n.get('error_file', {
1118            file: moreInfo.filename
1119          }, 'File: {{file}}'));
1120        }
1121
1122        if (moreInfo.lineNumber) {
1123          moreInfoText.push(this.l10n.get('error_line', {
1124            line: moreInfo.lineNumber
1125          }, 'Line: {{line}}'));
1126        }
1127      }
1128    }
1129
1130    var errorWrapperConfig = this.appConfig.errorWrapper;
1131    var errorWrapper = errorWrapperConfig.container;
1132    errorWrapper.removeAttribute('hidden');
1133    var errorMessage = errorWrapperConfig.errorMessage;
1134    errorMessage.textContent = message;
1135    var closeButton = errorWrapperConfig.closeButton;
1136
1137    closeButton.onclick = function () {
1138      errorWrapper.setAttribute('hidden', 'true');
1139    };
1140
1141    var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
1142    var moreInfoButton = errorWrapperConfig.moreInfoButton;
1143    var lessInfoButton = errorWrapperConfig.lessInfoButton;
1144
1145    moreInfoButton.onclick = function () {
1146      errorMoreInfo.removeAttribute('hidden');
1147      moreInfoButton.setAttribute('hidden', 'true');
1148      lessInfoButton.removeAttribute('hidden');
1149      errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
1150    };
1151
1152    lessInfoButton.onclick = function () {
1153      errorMoreInfo.setAttribute('hidden', 'true');
1154      moreInfoButton.removeAttribute('hidden');
1155      lessInfoButton.setAttribute('hidden', 'true');
1156    };
1157
1158    moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
1159    lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
1160    closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
1161    moreInfoButton.removeAttribute('hidden');
1162    lessInfoButton.setAttribute('hidden', 'true');
1163    Promise.all(moreInfoText).then(function (parts) {
1164      errorMoreInfo.value = parts.join('\n');
1165    });
1166  },
1167  progress: function progress(level) {
1168    var _this4 = this;
1169
1170    if (this.downloadComplete) {
1171      return;
1172    }
1173
1174    var percent = Math.round(level * 100);
1175
1176    if (percent > this.loadingBar.percent || isNaN(percent)) {
1177      this.loadingBar.percent = percent;
1178      var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
1179
1180      if (disableAutoFetch && percent) {
1181        if (this.disableAutoFetchLoadingBarTimeout) {
1182          clearTimeout(this.disableAutoFetchLoadingBarTimeout);
1183          this.disableAutoFetchLoadingBarTimeout = null;
1184        }
1185
1186        this.loadingBar.show();
1187        this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
1188          _this4.loadingBar.hide();
1189
1190          _this4.disableAutoFetchLoadingBarTimeout = null;
1191        }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
1192      }
1193    }
1194  },
1195  load: function load(pdfDocument) {
1196    var _this5 = this;
1197
1198    this.pdfDocument = pdfDocument;
1199    pdfDocument.getDownloadInfo().then(function () {
1200      _this5.downloadComplete = true;
1201
1202      _this5.loadingBar.hide();
1203
1204      firstPagePromise.then(function () {
1205        _this5.eventBus.dispatch('documentloaded', {
1206          source: _this5
1207        });
1208      });
1209    });
1210    var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
1211    var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
1212    var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](function () {});
1213    this.toolbar.setPagesCount(pdfDocument.numPages, false);
1214    this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
1215    var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
1216    var baseDocumentUrl;
1217    baseDocumentUrl = null;
1218    this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
1219    this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
1220    var pdfViewer = this.pdfViewer;
1221    pdfViewer.setDocument(pdfDocument);
1222    var firstPagePromise = pdfViewer.firstPagePromise;
1223    var pagesPromise = pdfViewer.pagesPromise;
1224    var onePageRendered = pdfViewer.onePageRendered;
1225    var pdfThumbnailViewer = this.pdfThumbnailViewer;
1226    pdfThumbnailViewer.setDocument(pdfDocument);
1227    firstPagePromise.then(function (pdfPage) {
1228      _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
1229
1230      var storePromise = store.getMultiple({
1231        page: null,
1232        zoom: _ui_utils.DEFAULT_SCALE_VALUE,
1233        scrollLeft: '0',
1234        scrollTop: '0',
1235        rotation: null,
1236        sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
1237        scrollMode: _ui_utils.ScrollMode.UNKNOWN,
1238        spreadMode: _ui_utils.SpreadMode.UNKNOWN
1239      })["catch"](function () {});
1240      Promise.all([storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(
1241      /*#__PURE__*/
1242      function () {
1243        var _ref3 = _asyncToGenerator(
1244        /*#__PURE__*/
1245        _regenerator["default"].mark(function _callee8(_ref2) {
1246          var _ref4, _ref4$, values, pageLayout, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
1247
1248          return _regenerator["default"].wrap(function _callee8$(_context8) {
1249            while (1) {
1250              switch (_context8.prev = _context8.next) {
1251                case 0:
1252                  _ref4 = _slicedToArray(_ref2, 4), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageLayout = _ref4[1], pageMode = _ref4[2], openActionDest = _ref4[3];
1253                  viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
1254
1255                  _this5._initializePdfHistory({
1256                    fingerprint: pdfDocument.fingerprint,
1257                    viewOnLoad: viewOnLoad,
1258                    initialDest: openActionDest
1259                  });
1260
1261                  initialBookmark = _this5.initialBookmark;
1262                  zoom = _app_options.AppOptions.get('defaultZoomValue');
1263                  hash = zoom ? "zoom=".concat(zoom) : null;
1264                  rotation = null;
1265                  sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
1266                  scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
1267                  spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
1268
1269                  if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
1270                    hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
1271                    rotation = parseInt(values.rotation, 10);
1272
1273                    if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
1274                      sidebarView = values.sidebarView | 0;
1275                    }
1276
1277                    if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
1278                      scrollMode = values.scrollMode | 0;
1279                    }
1280
1281                    if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
1282                      spreadMode = values.spreadMode | 0;
1283                    }
1284                  }
1285
1286                  if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
1287                    sidebarView = apiPageModeToSidebarView(pageMode);
1288                  }
1289
1290                  if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
1291                    spreadMode = apiPageLayoutToSpreadMode(pageLayout);
1292                  }
1293
1294                  _this5.setInitialView(hash, {
1295                    rotation: rotation,
1296                    sidebarView: sidebarView,
1297                    scrollMode: scrollMode,
1298                    spreadMode: spreadMode
1299                  });
1300
1301                  _this5.eventBus.dispatch('documentinit', {
1302                    source: _this5
1303                  });
1304
1305                  if (!_this5.isViewerEmbedded) {
1306                    pdfViewer.focus();
1307                  }
1308
1309                  _context8.next = 18;
1310                  return Promise.race([pagesPromise, new Promise(function (resolve) {
1311                    setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
1312                  })]);
1313
1314                case 18:
1315                  if (!(!initialBookmark && !hash)) {
1316                    _context8.next = 20;
1317                    break;
1318                  }
1319
1320                  return _context8.abrupt("return");
1321
1322                case 20:
1323                  if (!pdfViewer.hasEqualPageSizes) {
1324                    _context8.next = 22;
1325                    break;
1326                  }
1327
1328                  return _context8.abrupt("return");
1329
1330                case 22:
1331                  _this5.initialBookmark = initialBookmark;
1332                  pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
1333
1334                  _this5.setInitialView(hash);
1335
1336                case 25:
1337                case "end":
1338                  return _context8.stop();
1339              }
1340            }
1341          }, _callee8);
1342        }));
1343
1344        return function (_x4) {
1345          return _ref3.apply(this, arguments);
1346        };
1347      }())["catch"](function () {
1348        _this5.setInitialView();
1349      }).then(function () {
1350        pdfViewer.update();
1351      });
1352    });
1353    pdfDocument.getPageLabels().then(function (labels) {
1354      if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
1355        return;
1356      }
1357
1358      var i = 0,
1359          numLabels = labels.length;
1360
1361      if (numLabels !== _this5.pagesCount) {
1362        console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
1363        return;
1364      }
1365
1366      while (i < numLabels && labels[i] === (i + 1).toString()) {
1367        i++;
1368      }
1369
1370      if (i === numLabels) {
1371        return;
1372      }
1373
1374      pdfViewer.setPageLabels(labels);
1375      pdfThumbnailViewer.setPageLabels(labels);
1376
1377      _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
1378
1379      _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
1380    });
1381    pagesPromise.then(function () {
1382      if (!_this5.supportsPrinting) {
1383        return;
1384      }
1385
1386      pdfDocument.getJavaScript().then(function (javaScript) {
1387        if (!javaScript) {
1388          return;
1389        }
1390
1391        javaScript.some(function (js) {
1392          if (!js) {
1393            return false;
1394          }
1395
1396          console.warn('Warning: JavaScript is not supported');
1397
1398          _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
1399
1400          return true;
1401        });
1402        var regex = /\bprint\s*\(/;
1403
1404        for (var i = 0, ii = javaScript.length; i < ii; i++) {
1405          var js = javaScript[i];
1406
1407          if (js && regex.test(js)) {
1408            setTimeout(function () {
1409              window.print();
1410            });
1411            return;
1412          }
1413        }
1414      });
1415    });
1416    Promise.all([onePageRendered, _ui_utils.animationStarted]).then(function () {
1417      pdfDocument.getOutline().then(function (outline) {
1418        _this5.pdfOutlineViewer.render({
1419          outline: outline
1420        });
1421      });
1422      pdfDocument.getAttachments().then(function (attachments) {
1423        _this5.pdfAttachmentViewer.render({
1424          attachments: attachments
1425        });
1426      });
1427    });
1428    pdfDocument.getMetadata().then(function (_ref5) {
1429      var info = _ref5.info,
1430          metadata = _ref5.metadata,
1431          contentDispositionFilename = _ref5.contentDispositionFilename;
1432      _this5.documentInfo = info;
1433      _this5.metadata = metadata;
1434      _this5.contentDispositionFilename = contentDispositionFilename;
1435      console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdfjsLib.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
1436      var pdfTitle;
1437
1438      if (metadata && metadata.has('dc:title')) {
1439        var title = metadata.get('dc:title');
1440
1441        if (title !== 'Untitled') {
1442          pdfTitle = title;
1443        }
1444      }
1445
1446      if (!pdfTitle && info && info['Title']) {
1447        pdfTitle = info['Title'];
1448      }
1449
1450      if (pdfTitle) {
1451        _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
1452      } else if (contentDispositionFilename) {
1453        _this5.setTitle(contentDispositionFilename);
1454      }
1455
1456      if (info.IsAcroFormPresent) {
1457        console.warn('Warning: AcroForm/XFA is not supported');
1458
1459        _this5.fallback(_pdfjsLib.UNSUPPORTED_FEATURES.forms);
1460      }
1461    });
1462  },
1463  _initializePdfHistory: function _initializePdfHistory(_ref6) {
1464    var fingerprint = _ref6.fingerprint,
1465        viewOnLoad = _ref6.viewOnLoad,
1466        _ref6$initialDest = _ref6.initialDest,
1467        initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
1468
1469    if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
1470      return;
1471    }
1472
1473    this.pdfHistory.initialize({
1474      fingerprint: fingerprint,
1475      resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
1476      updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
1477    });
1478
1479    if (this.pdfHistory.initialBookmark) {
1480      this.initialBookmark = this.pdfHistory.initialBookmark;
1481      this.initialRotation = this.pdfHistory.initialRotation;
1482    }
1483
1484    if (initialDest && !this.initialBookmark && viewOnLoad === ViewOnLoad.UNKNOWN) {
1485      this.initialBookmark = JSON.stringify(initialDest);
1486      this.pdfHistory.push({
1487        explicitDest: initialDest,
1488        pageNumber: null
1489      });
1490    }
1491  },
1492  setInitialView: function setInitialView(storedHash) {
1493    var _this6 = this;
1494
1495    var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1496        rotation = _ref7.rotation,
1497        sidebarView = _ref7.sidebarView,
1498        scrollMode = _ref7.scrollMode,
1499        spreadMode = _ref7.spreadMode;
1500
1501    var setRotation = function setRotation(angle) {
1502      if ((0, _ui_utils.isValidRotation)(angle)) {
1503        _this6.pdfViewer.pagesRotation = angle;
1504      }
1505    };
1506
1507    var setViewerModes = function setViewerModes(scroll, spread) {
1508      if ((0, _ui_utils.isValidScrollMode)(scroll)) {
1509        _this6.pdfViewer.scrollMode = scroll;
1510      }
1511
1512      if ((0, _ui_utils.isValidSpreadMode)(spread)) {
1513        _this6.pdfViewer.spreadMode = spread;
1514      }
1515    };
1516
1517    this.isInitialViewSet = true;
1518    this.pdfSidebar.setInitialView(sidebarView);
1519    setViewerModes(scrollMode, spreadMode);
1520
1521    if (this.initialBookmark) {
1522      setRotation(this.initialRotation);
1523      delete this.initialRotation;
1524      this.pdfLinkService.setHash(this.initialBookmark);
1525      this.initialBookmark = null;
1526    } else if (storedHash) {
1527      setRotation(rotation);
1528      this.pdfLinkService.setHash(storedHash);
1529    }
1530
1531    this.toolbar.setPageNumber(this.pdfViewer.currentPageNumber, this.pdfViewer.currentPageLabel);
1532    this.secondaryToolbar.setPageNumber(this.pdfViewer.currentPageNumber);
1533
1534    if (!this.pdfViewer.currentScaleValue) {
1535      this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
1536    }
1537  },
1538  cleanup: function cleanup() {
1539    if (!this.pdfDocument) {
1540      return;
1541    }
1542
1543    this.pdfViewer.cleanup();
1544    this.pdfThumbnailViewer.cleanup();
1545
1546    if (this.pdfViewer.renderer !== _ui_utils.RendererType.SVG) {
1547      this.pdfDocument.cleanup();
1548    }
1549  },
1550  forceRendering: function forceRendering() {
1551    this.pdfRenderingQueue.printing = this.printing;
1552    this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
1553    this.pdfRenderingQueue.renderHighestPriority();
1554  },
1555  beforePrint: function beforePrint() {
1556    var _this7 = this;
1557
1558    if (this.printService) {
1559      return;
1560    }
1561
1562    if (!this.supportsPrinting) {
1563      this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
1564        _this7.error(printMessage);
1565      });
1566      return;
1567    }
1568
1569    if (!this.pdfViewer.pageViewsReady) {
1570      this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
1571        window.alert(notReadyMessage);
1572      });
1573      return;
1574    }
1575
1576    var pagesOverview = this.pdfViewer.getPagesOverview();
1577    var printContainer = this.appConfig.printContainer;
1578    var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
1579    this.printService = printService;
1580    this.forceRendering();
1581    printService.layout();
1582  },
1583  afterPrint: function pdfViewSetupAfterPrint() {
1584    if (this.printService) {
1585      this.printService.destroy();
1586      this.printService = null;
1587    }
1588
1589    this.forceRendering();
1590  },
1591  rotatePages: function rotatePages(delta) {
1592    if (!this.pdfDocument) {
1593      return;
1594    }
1595
1596    var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
1597    this.pdfViewer.pagesRotation = newRotation;
1598  },
1599  requestPresentationMode: function requestPresentationMode() {
1600    if (!this.pdfPresentationMode) {
1601      return;
1602    }
1603
1604    this.pdfPresentationMode.request();
1605  },
1606  bindEvents: function bindEvents() {
1607    var eventBus = this.eventBus,
1608        _boundEvents = this._boundEvents;
1609    _boundEvents.beforePrint = this.beforePrint.bind(this);
1610    _boundEvents.afterPrint = this.afterPrint.bind(this);
1611    eventBus.on('resize', webViewerResize);
1612    eventBus.on('hashchange', webViewerHashchange);
1613    eventBus.on('beforeprint', _boundEvents.beforePrint);
1614    eventBus.on('afterprint', _boundEvents.afterPrint);
1615    eventBus.on('pagerendered', webViewerPageRendered);
1616    eventBus.on('textlayerrendered', webViewerTextLayerRendered);
1617    eventBus.on('updateviewarea', webViewerUpdateViewarea);
1618    eventBus.on('pagechanging', webViewerPageChanging);
1619    eventBus.on('scalechanging', webViewerScaleChanging);
1620    eventBus.on('rotationchanging', webViewerRotationChanging);
1621    eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
1622    eventBus.on('pagemode', webViewerPageMode);
1623    eventBus.on('namedaction', webViewerNamedAction);
1624    eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
1625    eventBus.on('presentationmode', webViewerPresentationMode);
1626    eventBus.on('openfile', webViewerOpenFile);
1627    eventBus.on('print', webViewerPrint);
1628    eventBus.on('download', webViewerDownload);
1629    eventBus.on('firstpage', webViewerFirstPage);
1630    eventBus.on('lastpage', webViewerLastPage);
1631    eventBus.on('nextpage', webViewerNextPage);
1632    eventBus.on('previouspage', webViewerPreviousPage);
1633    eventBus.on('zoomin', webViewerZoomIn);
1634    eventBus.on('zoomout', webViewerZoomOut);
1635    eventBus.on('zoomreset', webViewerZoomReset);
1636    eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
1637    eventBus.on('scalechanged', webViewerScaleChanged);
1638    eventBus.on('rotatecw', webViewerRotateCw);
1639    eventBus.on('rotateccw', webViewerRotateCcw);
1640    eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
1641    eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
1642    eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
1643    eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
1644    eventBus.on('documentproperties', webViewerDocumentProperties);
1645    eventBus.on('find', webViewerFind);
1646    eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
1647    eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
1648    eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
1649    eventBus.on('fileinputchange', webViewerFileInputChange);
1650  },
1651  bindWindowEvents: function bindWindowEvents() {
1652    var eventBus = this.eventBus,
1653        _boundEvents = this._boundEvents;
1654
1655    _boundEvents.windowResize = function () {
1656      eventBus.dispatch('resize', {
1657        source: window
1658      });
1659    };
1660
1661    _boundEvents.windowHashChange = function () {
1662      eventBus.dispatch('hashchange', {
1663        source: window,
1664        hash: document.location.hash.substring(1)
1665      });
1666    };
1667
1668    _boundEvents.windowBeforePrint = function () {
1669      eventBus.dispatch('beforeprint', {
1670        source: window
1671      });
1672    };
1673
1674    _boundEvents.windowAfterPrint = function () {
1675      eventBus.dispatch('afterprint', {
1676        source: window
1677      });
1678    };
1679
1680    window.addEventListener('visibilitychange', webViewerVisibilityChange);
1681    window.addEventListener('wheel', webViewerWheel, {
1682      passive: false
1683    });
1684    window.addEventListener('click', webViewerClick);
1685    window.addEventListener('keydown', webViewerKeyDown);
1686    window.addEventListener('resize', _boundEvents.windowResize);
1687    window.addEventListener('hashchange', _boundEvents.windowHashChange);
1688    window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
1689    window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
1690  },
1691  unbindEvents: function unbindEvents() {
1692    var eventBus = this.eventBus,
1693        _boundEvents = this._boundEvents;
1694    eventBus.off('resize', webViewerResize);
1695    eventBus.off('hashchange', webViewerHashchange);
1696    eventBus.off('beforeprint', _boundEvents.beforePrint);
1697    eventBus.off('afterprint', _boundEvents.afterPrint);
1698    eventBus.off('pagerendered', webViewerPageRendered);
1699    eventBus.off('textlayerrendered', webViewerTextLayerRendered);
1700    eventBus.off('updateviewarea', webViewerUpdateViewarea);
1701    eventBus.off('pagechanging', webViewerPageChanging);
1702    eventBus.off('scalechanging', webViewerScaleChanging);
1703    eventBus.off('rotationchanging', webViewerRotationChanging);
1704    eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
1705    eventBus.off('pagemode', webViewerPageMode);
1706    eventBus.off('namedaction', webViewerNamedAction);
1707    eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
1708    eventBus.off('presentationmode', webViewerPresentationMode);
1709    eventBus.off('openfile', webViewerOpenFile);
1710    eventBus.off('print', webViewerPrint);
1711    eventBus.off('download', webViewerDownload);
1712    eventBus.off('firstpage', webViewerFirstPage);
1713    eventBus.off('lastpage', webViewerLastPage);
1714    eventBus.off('nextpage', webViewerNextPage);
1715    eventBus.off('previouspage', webViewerPreviousPage);
1716    eventBus.off('zoomin', webViewerZoomIn);
1717    eventBus.off('zoomout', webViewerZoomOut);
1718    eventBus.off('zoomreset', webViewerZoomReset);
1719    eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
1720    eventBus.off('scalechanged', webViewerScaleChanged);
1721    eventBus.off('rotatecw', webViewerRotateCw);
1722    eventBus.off('rotateccw', webViewerRotateCcw);
1723    eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
1724    eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
1725    eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
1726    eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
1727    eventBus.off('documentproperties', webViewerDocumentProperties);
1728    eventBus.off('find', webViewerFind);
1729    eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
1730    eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
1731    eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
1732    eventBus.off('fileinputchange', webViewerFileInputChange);
1733    _boundEvents.beforePrint = null;
1734    _boundEvents.afterPrint = null;
1735  },
1736  unbindWindowEvents: function unbindWindowEvents() {
1737    var _boundEvents = this._boundEvents;
1738    window.removeEventListener('visibilitychange', webViewerVisibilityChange);
1739    window.removeEventListener('wheel', webViewerWheel);
1740    window.removeEventListener('click', webViewerClick);
1741    window.removeEventListener('keydown', webViewerKeyDown);
1742    window.removeEventListener('resize', _boundEvents.windowResize);
1743    window.removeEventListener('hashchange', _boundEvents.windowHashChange);
1744    window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
1745    window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
1746    _boundEvents.windowResize = null;
1747    _boundEvents.windowHashChange = null;
1748    _boundEvents.windowBeforePrint = null;
1749    _boundEvents.windowAfterPrint = null;
1750  }
1751};
1752exports.PDFViewerApplication = PDFViewerApplication;
1753var validateFileURL;
1754{
1755  var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
1756
1757  validateFileURL = function validateFileURL(file) {
1758    if (file === undefined) {
1759      return;
1760    }
1761
1762    try {
1763      var viewerOrigin = new _pdfjsLib.URL(window.location.href).origin || 'null';
1764
1765      if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
1766        return;
1767      }
1768
1769      var _ref8 = new _pdfjsLib.URL(file, window.location.href),
1770          origin = _ref8.origin,
1771          protocol = _ref8.protocol;
1772
1773      if (origin !== viewerOrigin && protocol !== 'blob:') {
1774        throw new Error('file origin does not match viewer\'s');
1775      }
1776    } catch (ex) {
1777      var message = ex && ex.message;
1778      PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
1779        PDFViewerApplication.error(loadingErrorMessage, {
1780          message: message
1781        });
1782      });
1783      throw ex;
1784    }
1785  };
1786}
1787
1788function loadFakeWorker() {
1789  if (!_pdfjsLib.GlobalWorkerOptions.workerSrc) {
1790    _pdfjsLib.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
1791  }
1792
1793  return (0, _pdfjsLib.loadScript)(_pdfjsLib.PDFWorker.getWorkerSrc());
1794}
1795
1796function loadAndEnablePDFBug(enabledTabs) {
1797  var appConfig = PDFViewerApplication.appConfig;
1798  return (0, _pdfjsLib.loadScript)(appConfig.debuggerScriptPath).then(function () {
1799    PDFBug.enable(enabledTabs);
1800    PDFBug.init({
1801      OPS: _pdfjsLib.OPS,
1802      createObjectURL: _pdfjsLib.createObjectURL
1803    }, appConfig.mainContainer);
1804  });
1805}
1806
1807function webViewerInitialized() {
1808  var appConfig = PDFViewerApplication.appConfig;
1809  var file;
1810  var queryString = document.location.search.substring(1);
1811  var params = (0, _ui_utils.parseQueryString)(queryString);
1812  file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
1813  validateFileURL(file);
1814  var fileInput = document.createElement('input');
1815  fileInput.id = appConfig.openFileInputName;
1816  fileInput.className = 'fileInput';
1817  fileInput.setAttribute('type', 'file');
1818  fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
1819  document.body.appendChild(fileInput);
1820
1821  if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
1822    appConfig.toolbar.openFile.setAttribute('hidden', 'true');
1823    appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
1824  } else {
1825    fileInput.value = null;
1826  }
1827
1828  fileInput.addEventListener('change', function (evt) {
1829    var files = evt.target.files;
1830
1831    if (!files || files.length === 0) {
1832      return;
1833    }
1834
1835    PDFViewerApplication.eventBus.dispatch('fileinputchange', {
1836      source: this,
1837      fileInput: evt.target
1838    });
1839  });
1840  appConfig.mainContainer.addEventListener('dragover', function (evt) {
1841    evt.preventDefault();
1842    evt.dataTransfer.dropEffect = 'move';
1843  });
1844  appConfig.mainContainer.addEventListener('drop', function (evt) {
1845    evt.preventDefault();
1846    var files = evt.dataTransfer.files;
1847
1848    if (!files || files.length === 0) {
1849      return;
1850    }
1851
1852    PDFViewerApplication.eventBus.dispatch('fileinputchange', {
1853      source: this,
1854      fileInput: evt.dataTransfer
1855    });
1856  });
1857
1858  if (!PDFViewerApplication.supportsPrinting) {
1859    appConfig.toolbar.print.classList.add('hidden');
1860    appConfig.secondaryToolbar.printButton.classList.add('hidden');
1861  }
1862
1863  if (!PDFViewerApplication.supportsFullscreen) {
1864    appConfig.toolbar.presentationModeButton.classList.add('hidden');
1865    appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
1866  }
1867
1868  if (PDFViewerApplication.supportsIntegratedFind) {
1869    appConfig.toolbar.viewFind.classList.add('hidden');
1870  }
1871
1872  appConfig.mainContainer.addEventListener('transitionend', function (evt) {
1873    if (evt.target === this) {
1874      PDFViewerApplication.eventBus.dispatch('resize', {
1875        source: this
1876      });
1877    }
1878  }, true);
1879  appConfig.sidebar.toggleButton.addEventListener('click', function () {
1880    PDFViewerApplication.pdfSidebar.toggle();
1881  });
1882
1883  try {
1884    webViewerOpenFileViaURL(file);
1885  } catch (reason) {
1886    PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
1887      PDFViewerApplication.error(msg, reason);
1888    });
1889  }
1890}
1891
1892var webViewerOpenFileViaURL;
1893{
1894  webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
1895    if (file && file.lastIndexOf('file:', 0) === 0) {
1896      PDFViewerApplication.setTitleUsingUrl(file);
1897      var xhr = new XMLHttpRequest();
1898
1899      xhr.onload = function () {
1900        PDFViewerApplication.open(new Uint8Array(xhr.response));
1901      };
1902
1903      xhr.open('GET', file);
1904      xhr.responseType = 'arraybuffer';
1905      xhr.send();
1906      return;
1907    }
1908
1909    if (file) {
1910      PDFViewerApplication.open(file);
1911    }
1912  };
1913}
1914
1915function webViewerPageRendered(evt) {
1916  var pageNumber = evt.pageNumber;
1917  var pageIndex = pageNumber - 1;
1918  var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
1919
1920  if (pageNumber === PDFViewerApplication.page) {
1921    PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
1922  }
1923
1924  if (!pageView) {
1925    return;
1926  }
1927
1928  if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
1929    var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
1930    thumbnailView.setImage(pageView);
1931  }
1932
1933  if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
1934    Stats.add(pageNumber, pageView.stats);
1935  }
1936
1937  if (pageView.error) {
1938    PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
1939      PDFViewerApplication.error(msg, pageView.error);
1940    });
1941  }
1942}
1943
1944function webViewerTextLayerRendered(evt) {}
1945
1946function webViewerPageMode(evt) {
1947  var mode = evt.mode,
1948      view;
1949
1950  switch (mode) {
1951    case 'thumbs':
1952      view = _pdf_sidebar.SidebarView.THUMBS;
1953      break;
1954
1955    case 'bookmarks':
1956    case 'outline':
1957      view = _pdf_sidebar.SidebarView.OUTLINE;
1958      break;
1959
1960    case 'attachments':
1961      view = _pdf_sidebar.SidebarView.ATTACHMENTS;
1962      break;
1963
1964    case 'none':
1965      view = _pdf_sidebar.SidebarView.NONE;
1966      break;
1967
1968    default:
1969      console.error('Invalid "pagemode" hash parameter: ' + mode);
1970      return;
1971  }
1972
1973  PDFViewerApplication.pdfSidebar.switchView(view, true);
1974}
1975
1976function webViewerNamedAction(evt) {
1977  var action = evt.action;
1978
1979  switch (action) {
1980    case 'GoToPage':
1981      PDFViewerApplication.appConfig.toolbar.pageNumber.select();
1982      break;
1983
1984    case 'Find':
1985      if (!PDFViewerApplication.supportsIntegratedFind) {
1986        PDFViewerApplication.findBar.toggle();
1987      }
1988
1989      break;
1990  }
1991}
1992
1993function webViewerPresentationModeChanged(evt) {
1994  var active = evt.active,
1995      switchInProgress = evt.switchInProgress;
1996  PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
1997}
1998
1999function webViewerSidebarViewChanged(evt) {
2000  PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
2001  var store = PDFViewerApplication.store;
2002
2003  if (store && PDFViewerApplication.isInitialViewSet) {
2004    store.set('sidebarView', evt.view)["catch"](function () {});
2005  }
2006}
2007
2008function webViewerUpdateViewarea(evt) {
2009  var location = evt.location,
2010      store = PDFViewerApplication.store;
2011
2012  if (store && PDFViewerApplication.isInitialViewSet) {
2013    store.setMultiple({
2014      'page': location.pageNumber,
2015      'zoom': location.scale,
2016      'scrollLeft': location.left,
2017      'scrollTop': location.top,
2018      'rotation': location.rotation
2019    })["catch"](function () {});
2020  }
2021
2022  var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
2023  PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
2024  PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
2025  var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
2026  var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
2027  PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
2028}
2029
2030function webViewerScrollModeChanged(evt) {
2031  var store = PDFViewerApplication.store;
2032
2033  if (store && PDFViewerApplication.isInitialViewSet) {
2034    store.set('scrollMode', evt.mode)["catch"](function () {});
2035  }
2036}
2037
2038function webViewerSpreadModeChanged(evt) {
2039  var store = PDFViewerApplication.store;
2040
2041  if (store && PDFViewerApplication.isInitialViewSet) {
2042    store.set('spreadMode', evt.mode)["catch"](function () {});
2043  }
2044}
2045
2046function webViewerResize() {
2047  var pdfDocument = PDFViewerApplication.pdfDocument,
2048      pdfViewer = PDFViewerApplication.pdfViewer;
2049
2050  if (!pdfDocument) {
2051    return;
2052  }
2053
2054  var currentScaleValue = pdfViewer.currentScaleValue;
2055
2056  if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
2057    pdfViewer.currentScaleValue = currentScaleValue;
2058  }
2059
2060  pdfViewer.update();
2061}
2062
2063function webViewerHashchange(evt) {
2064  var hash = evt.hash;
2065
2066  if (!hash) {
2067    return;
2068  }
2069
2070  if (!PDFViewerApplication.isInitialViewSet) {
2071    PDFViewerApplication.initialBookmark = hash;
2072  } else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
2073    PDFViewerApplication.pdfLinkService.setHash(hash);
2074  }
2075}
2076
2077var webViewerFileInputChange;
2078{
2079  webViewerFileInputChange = function webViewerFileInputChange(evt) {
2080    if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
2081      return;
2082    }
2083
2084    var file = evt.fileInput.files[0];
2085
2086    if (_pdfjsLib.URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
2087      var url = _pdfjsLib.URL.createObjectURL(file);
2088
2089      if (file.name) {
2090        url = {
2091          url: url,
2092          originalUrl: file.name
2093        };
2094      }
2095
2096      PDFViewerApplication.open(url);
2097    } else {
2098      PDFViewerApplication.setTitleUsingUrl(file.name);
2099      var fileReader = new FileReader();
2100
2101      fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
2102        var buffer = evt.target.result;
2103        PDFViewerApplication.open(new Uint8Array(buffer));
2104      };
2105
2106      fileReader.readAsArrayBuffer(file);
2107    }
2108
2109    var appConfig = PDFViewerApplication.appConfig;
2110    appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
2111    appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
2112    appConfig.toolbar.download.setAttribute('hidden', 'true');
2113    appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
2114  };
2115}
2116
2117function webViewerPresentationMode() {
2118  PDFViewerApplication.requestPresentationMode();
2119}
2120
2121function webViewerOpenFile() {
2122  var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
2123  document.getElementById(openFileInputName).click();
2124}
2125
2126function webViewerPrint() {
2127  window.print();
2128}
2129
2130function webViewerDownload() {
2131  PDFViewerApplication.download();
2132}
2133
2134function webViewerFirstPage() {
2135  if (PDFViewerApplication.pdfDocument) {
2136    PDFViewerApplication.page = 1;
2137  }
2138}
2139
2140function webViewerLastPage() {
2141  if (PDFViewerApplication.pdfDocument) {
2142    PDFViewerApplication.page = PDFViewerApplication.pagesCount;
2143  }
2144}
2145
2146function webViewerNextPage() {
2147  PDFViewerApplication.page++;
2148}
2149
2150function webViewerPreviousPage() {
2151  PDFViewerApplication.page--;
2152}
2153
2154function webViewerZoomIn() {
2155  PDFViewerApplication.zoomIn();
2156}
2157
2158function webViewerZoomOut() {
2159  PDFViewerApplication.zoomOut();
2160}
2161
2162function webViewerZoomReset(evt) {
2163  PDFViewerApplication.zoomReset(evt && evt.ignoreDuplicate);
2164}
2165
2166function webViewerPageNumberChanged(evt) {
2167  var pdfViewer = PDFViewerApplication.pdfViewer;
2168
2169  if (evt.value !== '') {
2170    pdfViewer.currentPageLabel = evt.value;
2171  }
2172
2173  if (evt.value !== pdfViewer.currentPageNumber.toString() && evt.value !== pdfViewer.currentPageLabel) {
2174    PDFViewerApplication.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
2175  }
2176}
2177
2178function webViewerScaleChanged(evt) {
2179  PDFViewerApplication.pdfViewer.currentScaleValue = evt.value;
2180}
2181
2182function webViewerRotateCw() {
2183  PDFViewerApplication.rotatePages(90);
2184}
2185
2186function webViewerRotateCcw() {
2187  PDFViewerApplication.rotatePages(-90);
2188}
2189
2190function webViewerSwitchScrollMode(evt) {
2191  PDFViewerApplication.pdfViewer.scrollMode = evt.mode;
2192}
2193
2194function webViewerSwitchSpreadMode(evt) {
2195  PDFViewerApplication.pdfViewer.spreadMode = evt.mode;
2196}
2197
2198function webViewerDocumentProperties() {
2199  PDFViewerApplication.pdfDocumentProperties.open();
2200}
2201
2202function webViewerFind(evt) {
2203  PDFViewerApplication.findController.executeCommand('find' + evt.type, {
2204    query: evt.query,
2205    phraseSearch: evt.phraseSearch,
2206    caseSensitive: evt.caseSensitive,
2207    entireWord: evt.entireWord,
2208    highlightAll: evt.highlightAll,
2209    findPrevious: evt.findPrevious
2210  });
2211}
2212
2213function webViewerFindFromUrlHash(evt) {
2214  PDFViewerApplication.findController.executeCommand('find', {
2215    query: evt.query,
2216    phraseSearch: evt.phraseSearch,
2217    caseSensitive: false,
2218    entireWord: false,
2219    highlightAll: true,
2220    findPrevious: false
2221  });
2222}
2223
2224function webViewerUpdateFindMatchesCount(_ref9) {
2225  var matchesCount = _ref9.matchesCount;
2226
2227  if (PDFViewerApplication.supportsIntegratedFind) {
2228    PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
2229  } else {
2230    PDFViewerApplication.findBar.updateResultsCount(matchesCount);
2231  }
2232}
2233
2234function webViewerUpdateFindControlState(_ref10) {
2235  var state = _ref10.state,
2236      previous = _ref10.previous,
2237      matchesCount = _ref10.matchesCount;
2238
2239  if (PDFViewerApplication.supportsIntegratedFind) {
2240    PDFViewerApplication.externalServices.updateFindControlState({
2241      result: state,
2242      findPrevious: previous,
2243      matchesCount: matchesCount
2244    });
2245  } else {
2246    PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
2247  }
2248}
2249
2250function webViewerScaleChanging(evt) {
2251  PDFViewerApplication.toolbar.setPageScale(evt.presetValue, evt.scale);
2252  PDFViewerApplication.pdfViewer.update();
2253}
2254
2255function webViewerRotationChanging(evt) {
2256  PDFViewerApplication.pdfThumbnailViewer.pagesRotation = evt.pagesRotation;
2257  PDFViewerApplication.forceRendering();
2258  PDFViewerApplication.pdfViewer.currentPageNumber = evt.pageNumber;
2259}
2260
2261function webViewerPageChanging(evt) {
2262  var page = evt.pageNumber;
2263  PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
2264  PDFViewerApplication.secondaryToolbar.setPageNumber(page);
2265
2266  if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
2267    PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
2268  }
2269
2270  if (typeof Stats !== 'undefined' && Stats.enabled) {
2271    var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
2272
2273    if (pageView && pageView.stats) {
2274      Stats.add(page, pageView.stats);
2275    }
2276  }
2277}
2278
2279function webViewerVisibilityChange(evt) {
2280  if (document.visibilityState === 'visible') {
2281    setZoomDisabledTimeout();
2282  }
2283}
2284
2285var zoomDisabledTimeout = null;
2286
2287function setZoomDisabledTimeout() {
2288  if (zoomDisabledTimeout) {
2289    clearTimeout(zoomDisabledTimeout);
2290  }
2291
2292  zoomDisabledTimeout = setTimeout(function () {
2293    zoomDisabledTimeout = null;
2294  }, WHEEL_ZOOM_DISABLED_TIMEOUT);
2295}
2296
2297function webViewerWheel(evt) {
2298  var pdfViewer = PDFViewerApplication.pdfViewer;
2299
2300  if (pdfViewer.isInPresentationMode) {
2301    return;
2302  }
2303
2304  if (evt.ctrlKey || evt.metaKey) {
2305    var support = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
2306
2307    if (evt.ctrlKey && !support.ctrlKey || evt.metaKey && !support.metaKey) {
2308      return;
2309    }
2310
2311    evt.preventDefault();
2312
2313    if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
2314      return;
2315    }
2316
2317    var previousScale = pdfViewer.currentScale;
2318    var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
2319    var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
2320    var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
2321
2322    if (ticks < 0) {
2323      PDFViewerApplication.zoomOut(-ticks);
2324    } else {
2325      PDFViewerApplication.zoomIn(ticks);
2326    }
2327
2328    var currentScale = pdfViewer.currentScale;
2329
2330    if (previousScale !== currentScale) {
2331      var scaleCorrectionFactor = currentScale / previousScale - 1;
2332      var rect = pdfViewer.container.getBoundingClientRect();
2333      var dx = evt.clientX - rect.left;
2334      var dy = evt.clientY - rect.top;
2335      pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
2336      pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
2337    }
2338  } else {
2339    setZoomDisabledTimeout();
2340  }
2341}
2342
2343function webViewerClick(evt) {
2344  if (!PDFViewerApplication.secondaryToolbar.isOpen) {
2345    return;
2346  }
2347
2348  var appConfig = PDFViewerApplication.appConfig;
2349
2350  if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
2351    PDFViewerApplication.secondaryToolbar.close();
2352  }
2353}
2354
2355function webViewerKeyDown(evt) {
2356  if (PDFViewerApplication.overlayManager.active) {
2357    return;
2358  }
2359
2360  var handled = false,
2361      ensureViewerFocused = false;
2362  var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
2363  var pdfViewer = PDFViewerApplication.pdfViewer;
2364  var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
2365
2366  if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
2367    switch (evt.keyCode) {
2368      case 70:
2369        if (!PDFViewerApplication.supportsIntegratedFind) {
2370          PDFViewerApplication.findBar.open();
2371          handled = true;
2372        }
2373
2374        break;
2375
2376      case 71:
2377        if (!PDFViewerApplication.supportsIntegratedFind) {
2378          var findState = PDFViewerApplication.findController.state;
2379
2380          if (findState) {
2381            PDFViewerApplication.findController.executeCommand('findagain', {
2382              query: findState.query,
2383              phraseSearch: findState.phraseSearch,
2384              caseSensitive: findState.caseSensitive,
2385              entireWord: findState.entireWord,
2386              highlightAll: findState.highlightAll,
2387              findPrevious: cmd === 5 || cmd === 12
2388            });
2389          }
2390
2391          handled = true;
2392        }
2393
2394        break;
2395
2396      case 61:
2397      case 107:
2398      case 187:
2399      case 171:
2400        if (!isViewerInPresentationMode) {
2401          PDFViewerApplication.zoomIn();
2402        }
2403
2404        handled = true;
2405        break;
2406
2407      case 173:
2408      case 109:
2409      case 189:
2410        if (!isViewerInPresentationMode) {
2411          PDFViewerApplication.zoomOut();
2412        }
2413
2414        handled = true;
2415        break;
2416
2417      case 48:
2418      case 96:
2419        if (!isViewerInPresentationMode) {
2420          setTimeout(function () {
2421            PDFViewerApplication.zoomReset();
2422          });
2423          handled = false;
2424        }
2425
2426        break;
2427
2428      case 38:
2429        if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
2430          PDFViewerApplication.page = 1;
2431          handled = true;
2432          ensureViewerFocused = true;
2433        }
2434
2435        break;
2436
2437      case 40:
2438        if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
2439          PDFViewerApplication.page = PDFViewerApplication.pagesCount;
2440          handled = true;
2441          ensureViewerFocused = true;
2442        }
2443
2444        break;
2445    }
2446  }
2447
2448  if (cmd === 1 || cmd === 8) {
2449    switch (evt.keyCode) {
2450      case 83:
2451        PDFViewerApplication.download();
2452        handled = true;
2453        break;
2454    }
2455  }
2456
2457  if (cmd === 3 || cmd === 10) {
2458    switch (evt.keyCode) {
2459      case 80:
2460        PDFViewerApplication.requestPresentationMode();
2461        handled = true;
2462        break;
2463
2464      case 71:
2465        PDFViewerApplication.appConfig.toolbar.pageNumber.select();
2466        handled = true;
2467        break;
2468    }
2469  }
2470
2471  if (handled) {
2472    if (ensureViewerFocused && !isViewerInPresentationMode) {
2473      pdfViewer.focus();
2474    }
2475
2476    evt.preventDefault();
2477    return;
2478  }
2479
2480  var curElement = document.activeElement || document.querySelector(':focus');
2481  var curElementTagName = curElement && curElement.tagName.toUpperCase();
2482
2483  if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
2484    if (evt.keyCode !== 27) {
2485      return;
2486    }
2487  }
2488
2489  if (cmd === 0) {
2490    var turnPage = 0,
2491        turnOnlyIfPageFit = false;
2492
2493    switch (evt.keyCode) {
2494      case 38:
2495      case 33:
2496        if (pdfViewer.isVerticalScrollbarEnabled) {
2497          turnOnlyIfPageFit = true;
2498        }
2499
2500        turnPage = -1;
2501        break;
2502
2503      case 8:
2504        if (!isViewerInPresentationMode) {
2505          turnOnlyIfPageFit = true;
2506        }
2507
2508        turnPage = -1;
2509        break;
2510
2511      case 37:
2512        if (pdfViewer.isHorizontalScrollbarEnabled) {
2513          turnOnlyIfPageFit = true;
2514        }
2515
2516      case 75:
2517      case 80:
2518        turnPage = -1;
2519        break;
2520
2521      case 27:
2522        if (PDFViewerApplication.secondaryToolbar.isOpen) {
2523          PDFViewerApplication.secondaryToolbar.close();
2524          handled = true;
2525        }
2526
2527        if (!PDFViewerApplication.supportsIntegratedFind && PDFViewerApplication.findBar.opened) {
2528          PDFViewerApplication.findBar.close();
2529          handled = true;
2530        }
2531
2532        break;
2533
2534      case 40:
2535      case 34:
2536        if (pdfViewer.isVerticalScrollbarEnabled) {
2537          turnOnlyIfPageFit = true;
2538        }
2539
2540        turnPage = 1;
2541        break;
2542
2543      case 13:
2544      case 32:
2545        if (!isViewerInPresentationMode) {
2546          turnOnlyIfPageFit = true;
2547        }
2548
2549        turnPage = 1;
2550        break;
2551
2552      case 39:
2553        if (pdfViewer.isHorizontalScrollbarEnabled) {
2554          turnOnlyIfPageFit = true;
2555        }
2556
2557      case 74:
2558      case 78:
2559        turnPage = 1;
2560        break;
2561
2562      case 36:
2563        if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
2564          PDFViewerApplication.page = 1;
2565          handled = true;
2566          ensureViewerFocused = true;
2567        }
2568
2569        break;
2570
2571      case 35:
2572        if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
2573          PDFViewerApplication.page = PDFViewerApplication.pagesCount;
2574          handled = true;
2575          ensureViewerFocused = true;
2576        }
2577
2578        break;
2579
2580      case 83:
2581        PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.SELECT);
2582        break;
2583
2584      case 72:
2585        PDFViewerApplication.pdfCursorTools.switchTool(_pdf_cursor_tools.CursorTool.HAND);
2586        break;
2587
2588      case 82:
2589        PDFViewerApplication.rotatePages(90);
2590        break;
2591
2592      case 115:
2593        PDFViewerApplication.pdfSidebar.toggle();
2594        break;
2595    }
2596
2597    if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
2598      if (turnPage > 0) {
2599        if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
2600          PDFViewerApplication.page++;
2601        }
2602      } else {
2603        if (PDFViewerApplication.page > 1) {
2604          PDFViewerApplication.page--;
2605        }
2606      }
2607
2608      handled = true;
2609    }
2610  }
2611
2612  if (cmd === 4) {
2613    switch (evt.keyCode) {
2614      case 13:
2615      case 32:
2616        if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
2617          break;
2618        }
2619
2620        if (PDFViewerApplication.page > 1) {
2621          PDFViewerApplication.page--;
2622        }
2623
2624        handled = true;
2625        break;
2626
2627      case 82:
2628        PDFViewerApplication.rotatePages(-90);
2629        break;
2630    }
2631  }
2632
2633  if (!handled && !isViewerInPresentationMode) {
2634    if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
2635      ensureViewerFocused = true;
2636    }
2637  }
2638
2639  if (ensureViewerFocused && !pdfViewer.containsElement(curElement)) {
2640    pdfViewer.focus();
2641  }
2642
2643  if (handled) {
2644    evt.preventDefault();
2645  }
2646}
2647
2648function apiPageLayoutToSpreadMode(layout) {
2649  switch (layout) {
2650    case 'SinglePage':
2651    case 'OneColumn':
2652      return _ui_utils.SpreadMode.NONE;
2653
2654    case 'TwoColumnLeft':
2655    case 'TwoPageLeft':
2656      return _ui_utils.SpreadMode.ODD;
2657
2658    case 'TwoColumnRight':
2659    case 'TwoPageRight':
2660      return _ui_utils.SpreadMode.EVEN;
2661  }
2662
2663  return _ui_utils.SpreadMode.NONE;
2664}
2665
2666function apiPageModeToSidebarView(mode) {
2667  switch (mode) {
2668    case 'UseNone':
2669      return _pdf_sidebar.SidebarView.NONE;
2670
2671    case 'UseThumbs':
2672      return _pdf_sidebar.SidebarView.THUMBS;
2673
2674    case 'UseOutlines':
2675      return _pdf_sidebar.SidebarView.OUTLINE;
2676
2677    case 'UseAttachments':
2678      return _pdf_sidebar.SidebarView.ATTACHMENTS;
2679
2680    case 'UseOC':
2681  }
2682
2683  return _pdf_sidebar.SidebarView.NONE;
2684}
2685
2686var PDFPrintServiceFactory = {
2687  instance: {
2688    supportsPrinting: false,
2689    createPrintService: function createPrintService() {
2690      throw new Error('Not implemented: createPrintService');
2691    }
2692  }
2693};
2694exports.PDFPrintServiceFactory = PDFPrintServiceFactory;
2695
2696/***/ }),
2697/* 2 */
2698/***/ (function(module, exports, __webpack_require__) {
2699
2700"use strict";
2701
2702
2703module.exports = __webpack_require__(3);
2704
2705/***/ }),
2706/* 3 */
2707/***/ (function(module, exports, __webpack_require__) {
2708
2709"use strict";
2710/* WEBPACK VAR INJECTION */(function(module) {
2711
2712function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2713
2714var runtime = function (exports) {
2715  "use strict";
2716
2717  var Op = Object.prototype;
2718  var hasOwn = Op.hasOwnProperty;
2719  var undefined;
2720  var $Symbol = typeof Symbol === "function" ? Symbol : {};
2721  var iteratorSymbol = $Symbol.iterator || "@@iterator";
2722  var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
2723  var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
2724
2725  function wrap(innerFn, outerFn, self, tryLocsList) {
2726    var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
2727    var generator = Object.create(protoGenerator.prototype);
2728    var context = new Context(tryLocsList || []);
2729    generator._invoke = makeInvokeMethod(innerFn, self, context);
2730    return generator;
2731  }
2732
2733  exports.wrap = wrap;
2734
2735  function tryCatch(fn, obj, arg) {
2736    try {
2737      return {
2738        type: "normal",
2739        arg: fn.call(obj, arg)
2740      };
2741    } catch (err) {
2742      return {
2743        type: "throw",
2744        arg: err
2745      };
2746    }
2747  }
2748
2749  var GenStateSuspendedStart = "suspendedStart";
2750  var GenStateSuspendedYield = "suspendedYield";
2751  var GenStateExecuting = "executing";
2752  var GenStateCompleted = "completed";
2753  var ContinueSentinel = {};
2754
2755  function Generator() {}
2756
2757  function GeneratorFunction() {}
2758
2759  function GeneratorFunctionPrototype() {}
2760
2761  var IteratorPrototype = {};
2762
2763  IteratorPrototype[iteratorSymbol] = function () {
2764    return this;
2765  };
2766
2767  var getProto = Object.getPrototypeOf;
2768  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
2769
2770  if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
2771    IteratorPrototype = NativeIteratorPrototype;
2772  }
2773
2774  var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
2775  GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
2776  GeneratorFunctionPrototype.constructor = GeneratorFunction;
2777  GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
2778
2779  function defineIteratorMethods(prototype) {
2780    ["next", "throw", "return"].forEach(function (method) {
2781      prototype[method] = function (arg) {
2782        return this._invoke(method, arg);
2783      };
2784    });
2785  }
2786
2787  exports.isGeneratorFunction = function (genFun) {
2788    var ctor = typeof genFun === "function" && genFun.constructor;
2789    return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
2790  };
2791
2792  exports.mark = function (genFun) {
2793    if (Object.setPrototypeOf) {
2794      Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
2795    } else {
2796      genFun.__proto__ = GeneratorFunctionPrototype;
2797
2798      if (!(toStringTagSymbol in genFun)) {
2799        genFun[toStringTagSymbol] = "GeneratorFunction";
2800      }
2801    }
2802
2803    genFun.prototype = Object.create(Gp);
2804    return genFun;
2805  };
2806
2807  exports.awrap = function (arg) {
2808    return {
2809      __await: arg
2810    };
2811  };
2812
2813  function AsyncIterator(generator) {
2814    function invoke(method, arg, resolve, reject) {
2815      var record = tryCatch(generator[method], generator, arg);
2816
2817      if (record.type === "throw") {
2818        reject(record.arg);
2819      } else {
2820        var result = record.arg;
2821        var value = result.value;
2822
2823        if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
2824          return Promise.resolve(value.__await).then(function (value) {
2825            invoke("next", value, resolve, reject);
2826          }, function (err) {
2827            invoke("throw", err, resolve, reject);
2828          });
2829        }
2830
2831        return Promise.resolve(value).then(function (unwrapped) {
2832          result.value = unwrapped;
2833          resolve(result);
2834        }, function (error) {
2835          return invoke("throw", error, resolve, reject);
2836        });
2837      }
2838    }
2839
2840    var previousPromise;
2841
2842    function enqueue(method, arg) {
2843      function callInvokeWithMethodAndArg() {
2844        return new Promise(function (resolve, reject) {
2845          invoke(method, arg, resolve, reject);
2846        });
2847      }
2848
2849      return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
2850    }
2851
2852    this._invoke = enqueue;
2853  }
2854
2855  defineIteratorMethods(AsyncIterator.prototype);
2856
2857  AsyncIterator.prototype[asyncIteratorSymbol] = function () {
2858    return this;
2859  };
2860
2861  exports.AsyncIterator = AsyncIterator;
2862
2863  exports.async = function (innerFn, outerFn, self, tryLocsList) {
2864    var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
2865    return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
2866      return result.done ? result.value : iter.next();
2867    });
2868  };
2869
2870  function makeInvokeMethod(innerFn, self, context) {
2871    var state = GenStateSuspendedStart;
2872    return function invoke(method, arg) {
2873      if (state === GenStateExecuting) {
2874        throw new Error("Generator is already running");
2875      }
2876
2877      if (state === GenStateCompleted) {
2878        if (method === "throw") {
2879          throw arg;
2880        }
2881
2882        return doneResult();
2883      }
2884
2885      context.method = method;
2886      context.arg = arg;
2887
2888      while (true) {
2889        var delegate = context.delegate;
2890
2891        if (delegate) {
2892          var delegateResult = maybeInvokeDelegate(delegate, context);
2893
2894          if (delegateResult) {
2895            if (delegateResult === ContinueSentinel) continue;
2896            return delegateResult;
2897          }
2898        }
2899
2900        if (context.method === "next") {
2901          context.sent = context._sent = context.arg;
2902        } else if (context.method === "throw") {
2903          if (state === GenStateSuspendedStart) {
2904            state = GenStateCompleted;
2905            throw context.arg;
2906          }
2907
2908          context.dispatchException(context.arg);
2909        } else if (context.method === "return") {
2910          context.abrupt("return", context.arg);
2911        }
2912
2913        state = GenStateExecuting;
2914        var record = tryCatch(innerFn, self, context);
2915
2916        if (record.type === "normal") {
2917          state = context.done ? GenStateCompleted : GenStateSuspendedYield;
2918
2919          if (record.arg === ContinueSentinel) {
2920            continue;
2921          }
2922
2923          return {
2924            value: record.arg,
2925            done: context.done
2926          };
2927        } else if (record.type === "throw") {
2928          state = GenStateCompleted;
2929          context.method = "throw";
2930          context.arg = record.arg;
2931        }
2932      }
2933    };
2934  }
2935
2936  function maybeInvokeDelegate(delegate, context) {
2937    var method = delegate.iterator[context.method];
2938
2939    if (method === undefined) {
2940      context.delegate = null;
2941
2942      if (context.method === "throw") {
2943        if (delegate.iterator["return"]) {
2944          context.method = "return";
2945          context.arg = undefined;
2946          maybeInvokeDelegate(delegate, context);
2947
2948          if (context.method === "throw") {
2949            return ContinueSentinel;
2950          }
2951        }
2952
2953        context.method = "throw";
2954        context.arg = new TypeError("The iterator does not provide a 'throw' method");
2955      }
2956
2957      return ContinueSentinel;
2958    }
2959
2960    var record = tryCatch(method, delegate.iterator, context.arg);
2961
2962    if (record.type === "throw") {
2963      context.method = "throw";
2964      context.arg = record.arg;
2965      context.delegate = null;
2966      return ContinueSentinel;
2967    }
2968
2969    var info = record.arg;
2970
2971    if (!info) {
2972      context.method = "throw";
2973      context.arg = new TypeError("iterator result is not an object");
2974      context.delegate = null;
2975      return ContinueSentinel;
2976    }
2977
2978    if (info.done) {
2979      context[delegate.resultName] = info.value;
2980      context.next = delegate.nextLoc;
2981
2982      if (context.method !== "return") {
2983        context.method = "next";
2984        context.arg = undefined;
2985      }
2986    } else {
2987      return info;
2988    }
2989
2990    context.delegate = null;
2991    return ContinueSentinel;
2992  }
2993
2994  defineIteratorMethods(Gp);
2995  Gp[toStringTagSymbol] = "Generator";
2996
2997  Gp[iteratorSymbol] = function () {
2998    return this;
2999  };
3000
3001  Gp.toString = function () {
3002    return "[object Generator]";
3003  };
3004
3005  function pushTryEntry(locs) {
3006    var entry = {
3007      tryLoc: locs[0]
3008    };
3009
3010    if (1 in locs) {
3011      entry.catchLoc = locs[1];
3012    }
3013
3014    if (2 in locs) {
3015      entry.finallyLoc = locs[2];
3016      entry.afterLoc = locs[3];
3017    }
3018
3019    this.tryEntries.push(entry);
3020  }
3021
3022  function resetTryEntry(entry) {
3023    var record = entry.completion || {};
3024    record.type = "normal";
3025    delete record.arg;
3026    entry.completion = record;
3027  }
3028
3029  function Context(tryLocsList) {
3030    this.tryEntries = [{
3031      tryLoc: "root"
3032    }];
3033    tryLocsList.forEach(pushTryEntry, this);
3034    this.reset(true);
3035  }
3036
3037  exports.keys = function (object) {
3038    var keys = [];
3039
3040    for (var key in object) {
3041      keys.push(key);
3042    }
3043
3044    keys.reverse();
3045    return function next() {
3046      while (keys.length) {
3047        var key = keys.pop();
3048
3049        if (key in object) {
3050          next.value = key;
3051          next.done = false;
3052          return next;
3053        }
3054      }
3055
3056      next.done = true;
3057      return next;
3058    };
3059  };
3060
3061  function values(iterable) {
3062    if (iterable) {
3063      var iteratorMethod = iterable[iteratorSymbol];
3064
3065      if (iteratorMethod) {
3066        return iteratorMethod.call(iterable);
3067      }
3068
3069      if (typeof iterable.next === "function") {
3070        return iterable;
3071      }
3072
3073      if (!isNaN(iterable.length)) {
3074        var i = -1,
3075            next = function next() {
3076          while (++i < iterable.length) {
3077            if (hasOwn.call(iterable, i)) {
3078              next.value = iterable[i];
3079              next.done = false;
3080              return next;
3081            }
3082          }
3083
3084          next.value = undefined;
3085          next.done = true;
3086          return next;
3087        };
3088
3089        return next.next = next;
3090      }
3091    }
3092
3093    return {
3094      next: doneResult
3095    };
3096  }
3097
3098  exports.values = values;
3099
3100  function doneResult() {
3101    return {
3102      value: undefined,
3103      done: true
3104    };
3105  }
3106
3107  Context.prototype = {
3108    constructor: Context,
3109    reset: function reset(skipTempReset) {
3110      this.prev = 0;
3111      this.next = 0;
3112      this.sent = this._sent = undefined;
3113      this.done = false;
3114      this.delegate = null;
3115      this.method = "next";
3116      this.arg = undefined;
3117      this.tryEntries.forEach(resetTryEntry);
3118
3119      if (!skipTempReset) {
3120        for (var name in this) {
3121          if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
3122            this[name] = undefined;
3123          }
3124        }
3125      }
3126    },
3127    stop: function stop() {
3128      this.done = true;
3129      var rootEntry = this.tryEntries[0];
3130      var rootRecord = rootEntry.completion;
3131
3132      if (rootRecord.type === "throw") {
3133        throw rootRecord.arg;
3134      }
3135
3136      return this.rval;
3137    },
3138    dispatchException: function dispatchException(exception) {
3139      if (this.done) {
3140        throw exception;
3141      }
3142
3143      var context = this;
3144
3145      function handle(loc, caught) {
3146        record.type = "throw";
3147        record.arg = exception;
3148        context.next = loc;
3149
3150        if (caught) {
3151          context.method = "next";
3152          context.arg = undefined;
3153        }
3154
3155        return !!caught;
3156      }
3157
3158      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3159        var entry = this.tryEntries[i];
3160        var record = entry.completion;
3161
3162        if (entry.tryLoc === "root") {
3163          return handle("end");
3164        }
3165
3166        if (entry.tryLoc <= this.prev) {
3167          var hasCatch = hasOwn.call(entry, "catchLoc");
3168          var hasFinally = hasOwn.call(entry, "finallyLoc");
3169
3170          if (hasCatch && hasFinally) {
3171            if (this.prev < entry.catchLoc) {
3172              return handle(entry.catchLoc, true);
3173            } else if (this.prev < entry.finallyLoc) {
3174              return handle(entry.finallyLoc);
3175            }
3176          } else if (hasCatch) {
3177            if (this.prev < entry.catchLoc) {
3178              return handle(entry.catchLoc, true);
3179            }
3180          } else if (hasFinally) {
3181            if (this.prev < entry.finallyLoc) {
3182              return handle(entry.finallyLoc);
3183            }
3184          } else {
3185            throw new Error("try statement without catch or finally");
3186          }
3187        }
3188      }
3189    },
3190    abrupt: function abrupt(type, arg) {
3191      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3192        var entry = this.tryEntries[i];
3193
3194        if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
3195          var finallyEntry = entry;
3196          break;
3197        }
3198      }
3199
3200      if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
3201        finallyEntry = null;
3202      }
3203
3204      var record = finallyEntry ? finallyEntry.completion : {};
3205      record.type = type;
3206      record.arg = arg;
3207
3208      if (finallyEntry) {
3209        this.method = "next";
3210        this.next = finallyEntry.finallyLoc;
3211        return ContinueSentinel;
3212      }
3213
3214      return this.complete(record);
3215    },
3216    complete: function complete(record, afterLoc) {
3217      if (record.type === "throw") {
3218        throw record.arg;
3219      }
3220
3221      if (record.type === "break" || record.type === "continue") {
3222        this.next = record.arg;
3223      } else if (record.type === "return") {
3224        this.rval = this.arg = record.arg;
3225        this.method = "return";
3226        this.next = "end";
3227      } else if (record.type === "normal" && afterLoc) {
3228        this.next = afterLoc;
3229      }
3230
3231      return ContinueSentinel;
3232    },
3233    finish: function finish(finallyLoc) {
3234      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3235        var entry = this.tryEntries[i];
3236
3237        if (entry.finallyLoc === finallyLoc) {
3238          this.complete(entry.completion, entry.afterLoc);
3239          resetTryEntry(entry);
3240          return ContinueSentinel;
3241        }
3242      }
3243    },
3244    "catch": function _catch(tryLoc) {
3245      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
3246        var entry = this.tryEntries[i];
3247
3248        if (entry.tryLoc === tryLoc) {
3249          var record = entry.completion;
3250
3251          if (record.type === "throw") {
3252            var thrown = record.arg;
3253            resetTryEntry(entry);
3254          }
3255
3256          return thrown;
3257        }
3258      }
3259
3260      throw new Error("illegal catch attempt");
3261    },
3262    delegateYield: function delegateYield(iterable, resultName, nextLoc) {
3263      this.delegate = {
3264        iterator: values(iterable),
3265        resultName: resultName,
3266        nextLoc: nextLoc
3267      };
3268
3269      if (this.method === "next") {
3270        this.arg = undefined;
3271      }
3272
3273      return ContinueSentinel;
3274    }
3275  };
3276  return exports;
3277}(( false ? undefined : _typeof(module)) === "object" ? module.exports : {});
3278
3279try {
3280  regeneratorRuntime = runtime;
3281} catch (accidentalStrictMode) {
3282  Function("r", "regeneratorRuntime = r")(runtime);
3283}
3284/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(4)(module)))
3285
3286/***/ }),
3287/* 4 */
3288/***/ (function(module, exports, __webpack_require__) {
3289
3290"use strict";
3291
3292
3293module.exports = function (module) {
3294  if (!module.webpackPolyfill) {
3295    module.deprecate = function () {};
3296
3297    module.paths = [];
3298    if (!module.children) module.children = [];
3299    Object.defineProperty(module, "loaded", {
3300      enumerable: true,
3301      get: function get() {
3302        return module.l;
3303      }
3304    });
3305    Object.defineProperty(module, "id", {
3306      enumerable: true,
3307      get: function get() {
3308        return module.i;
3309      }
3310    });
3311    module.webpackPolyfill = 1;
3312  }
3313
3314  return module;
3315};
3316
3317/***/ }),
3318/* 5 */
3319/***/ (function(module, exports, __webpack_require__) {
3320
3321"use strict";
3322
3323
3324Object.defineProperty(exports, "__esModule", {
3325  value: true
3326});
3327exports.isValidRotation = isValidRotation;
3328exports.isValidScrollMode = isValidScrollMode;
3329exports.isValidSpreadMode = isValidSpreadMode;
3330exports.isPortraitOrientation = isPortraitOrientation;
3331exports.getGlobalEventBus = getGlobalEventBus;
3332exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
3333exports.noContextMenuHandler = noContextMenuHandler;
3334exports.parseQueryString = parseQueryString;
3335exports.backtrackBeforeAllVisibleElements = backtrackBeforeAllVisibleElements;
3336exports.getVisibleElements = getVisibleElements;
3337exports.roundToDivide = roundToDivide;
3338exports.getPageSizeInches = getPageSizeInches;
3339exports.approximateFraction = approximateFraction;
3340exports.getOutputScale = getOutputScale;
3341exports.scrollIntoView = scrollIntoView;
3342exports.watchScroll = watchScroll;
3343exports.binarySearchFirstItem = binarySearchFirstItem;
3344exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
3345exports.waitOnEventOrTimeout = waitOnEventOrTimeout;
3346exports.moveToEndOfArray = moveToEndOfArray;
3347exports.WaitOnType = exports.animationStarted = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.SpreadMode = exports.ScrollMode = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = void 0;
3348
3349var _regenerator = _interopRequireDefault(__webpack_require__(2));
3350
3351function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
3352
3353function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3354
3355function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
3356
3357function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
3358
3359function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3360
3361function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
3362
3363function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
3364
3365function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
3366
3367function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3368
3369function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3370
3371function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3372
3373var CSS_UNITS = 96.0 / 72.0;
3374exports.CSS_UNITS = CSS_UNITS;
3375var DEFAULT_SCALE_VALUE = 'auto';
3376exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
3377var DEFAULT_SCALE = 1.0;
3378exports.DEFAULT_SCALE = DEFAULT_SCALE;
3379var MIN_SCALE = 0.10;
3380exports.MIN_SCALE = MIN_SCALE;
3381var MAX_SCALE = 10.0;
3382exports.MAX_SCALE = MAX_SCALE;
3383var UNKNOWN_SCALE = 0;
3384exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
3385var MAX_AUTO_SCALE = 1.25;
3386exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
3387var SCROLLBAR_PADDING = 40;
3388exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
3389var VERTICAL_PADDING = 5;
3390exports.VERTICAL_PADDING = VERTICAL_PADDING;
3391var PresentationModeState = {
3392  UNKNOWN: 0,
3393  NORMAL: 1,
3394  CHANGING: 2,
3395  FULLSCREEN: 3
3396};
3397exports.PresentationModeState = PresentationModeState;
3398var RendererType = {
3399  CANVAS: 'canvas',
3400  SVG: 'svg'
3401};
3402exports.RendererType = RendererType;
3403var TextLayerMode = {
3404  DISABLE: 0,
3405  ENABLE: 1,
3406  ENABLE_ENHANCE: 2
3407};
3408exports.TextLayerMode = TextLayerMode;
3409var ScrollMode = {
3410  UNKNOWN: -1,
3411  VERTICAL: 0,
3412  HORIZONTAL: 1,
3413  WRAPPED: 2
3414};
3415exports.ScrollMode = ScrollMode;
3416var SpreadMode = {
3417  UNKNOWN: -1,
3418  NONE: 0,
3419  ODD: 1,
3420  EVEN: 2
3421};
3422exports.SpreadMode = SpreadMode;
3423
3424function formatL10nValue(text, args) {
3425  if (!args) {
3426    return text;
3427  }
3428
3429  return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
3430    return name in args ? args[name] : '{{' + name + '}}';
3431  });
3432}
3433
3434var NullL10n = {
3435  getLanguage: function () {
3436    var _getLanguage = _asyncToGenerator(
3437    /*#__PURE__*/
3438    _regenerator["default"].mark(function _callee() {
3439      return _regenerator["default"].wrap(function _callee$(_context) {
3440        while (1) {
3441          switch (_context.prev = _context.next) {
3442            case 0:
3443              return _context.abrupt("return", 'en-us');
3444
3445            case 1:
3446            case "end":
3447              return _context.stop();
3448          }
3449        }
3450      }, _callee);
3451    }));
3452
3453    function getLanguage() {
3454      return _getLanguage.apply(this, arguments);
3455    }
3456
3457    return getLanguage;
3458  }(),
3459  getDirection: function () {
3460    var _getDirection = _asyncToGenerator(
3461    /*#__PURE__*/
3462    _regenerator["default"].mark(function _callee2() {
3463      return _regenerator["default"].wrap(function _callee2$(_context2) {
3464        while (1) {
3465          switch (_context2.prev = _context2.next) {
3466            case 0:
3467              return _context2.abrupt("return", 'ltr');
3468
3469            case 1:
3470            case "end":
3471              return _context2.stop();
3472          }
3473        }
3474      }, _callee2);
3475    }));
3476
3477    function getDirection() {
3478      return _getDirection.apply(this, arguments);
3479    }
3480
3481    return getDirection;
3482  }(),
3483  get: function () {
3484    var _get = _asyncToGenerator(
3485    /*#__PURE__*/
3486    _regenerator["default"].mark(function _callee3(property, args, fallback) {
3487      return _regenerator["default"].wrap(function _callee3$(_context3) {
3488        while (1) {
3489          switch (_context3.prev = _context3.next) {
3490            case 0:
3491              return _context3.abrupt("return", formatL10nValue(fallback, args));
3492
3493            case 1:
3494            case "end":
3495              return _context3.stop();
3496          }
3497        }
3498      }, _callee3);
3499    }));
3500
3501    function get(_x, _x2, _x3) {
3502      return _get.apply(this, arguments);
3503    }
3504
3505    return get;
3506  }(),
3507  translate: function () {
3508    var _translate = _asyncToGenerator(
3509    /*#__PURE__*/
3510    _regenerator["default"].mark(function _callee4(element) {
3511      return _regenerator["default"].wrap(function _callee4$(_context4) {
3512        while (1) {
3513          switch (_context4.prev = _context4.next) {
3514            case 0:
3515            case "end":
3516              return _context4.stop();
3517          }
3518        }
3519      }, _callee4);
3520    }));
3521
3522    function translate(_x4) {
3523      return _translate.apply(this, arguments);
3524    }
3525
3526    return translate;
3527  }()
3528};
3529exports.NullL10n = NullL10n;
3530
3531function getOutputScale(ctx) {
3532  var devicePixelRatio = window.devicePixelRatio || 1;
3533  var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
3534  var pixelRatio = devicePixelRatio / backingStoreRatio;
3535  return {
3536    sx: pixelRatio,
3537    sy: pixelRatio,
3538    scaled: pixelRatio !== 1
3539  };
3540}
3541
3542function scrollIntoView(element, spot) {
3543  var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3544  var parent = element.offsetParent;
3545
3546  if (!parent) {
3547    console.error('offsetParent is not set -- cannot scroll');
3548    return;
3549  }
3550
3551  var offsetY = element.offsetTop + element.clientTop;
3552  var offsetX = element.offsetLeft + element.clientLeft;
3553
3554  while (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
3555    if (parent.dataset._scaleY) {
3556      offsetY /= parent.dataset._scaleY;
3557      offsetX /= parent.dataset._scaleX;
3558    }
3559
3560    offsetY += parent.offsetTop;
3561    offsetX += parent.offsetLeft;
3562    parent = parent.offsetParent;
3563
3564    if (!parent) {
3565      return;
3566    }
3567  }
3568
3569  if (spot) {
3570    if (spot.top !== undefined) {
3571      offsetY += spot.top;
3572    }
3573
3574    if (spot.left !== undefined) {
3575      offsetX += spot.left;
3576      parent.scrollLeft = offsetX;
3577    }
3578  }
3579
3580  parent.scrollTop = offsetY;
3581}
3582
3583function watchScroll(viewAreaElement, callback) {
3584  var debounceScroll = function debounceScroll(evt) {
3585    if (rAF) {
3586      return;
3587    }
3588
3589    rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
3590      rAF = null;
3591      var currentX = viewAreaElement.scrollLeft;
3592      var lastX = state.lastX;
3593
3594      if (currentX !== lastX) {
3595        state.right = currentX > lastX;
3596      }
3597
3598      state.lastX = currentX;
3599      var currentY = viewAreaElement.scrollTop;
3600      var lastY = state.lastY;
3601
3602      if (currentY !== lastY) {
3603        state.down = currentY > lastY;
3604      }
3605
3606      state.lastY = currentY;
3607      callback(state);
3608    });
3609  };
3610
3611  var state = {
3612    right: true,
3613    down: true,
3614    lastX: viewAreaElement.scrollLeft,
3615    lastY: viewAreaElement.scrollTop,
3616    _eventHandler: debounceScroll
3617  };
3618  var rAF = null;
3619  viewAreaElement.addEventListener('scroll', debounceScroll, true);
3620  return state;
3621}
3622
3623function parseQueryString(query) {
3624  var parts = query.split('&');
3625  var params = Object.create(null);
3626
3627  for (var i = 0, ii = parts.length; i < ii; ++i) {
3628    var param = parts[i].split('=');
3629    var key = param[0].toLowerCase();
3630    var value = param.length > 1 ? param[1] : null;
3631    params[decodeURIComponent(key)] = decodeURIComponent(value);
3632  }
3633
3634  return params;
3635}
3636
3637function binarySearchFirstItem(items, condition) {
3638  var minIndex = 0;
3639  var maxIndex = items.length - 1;
3640
3641  if (items.length === 0 || !condition(items[maxIndex])) {
3642    return items.length;
3643  }
3644
3645  if (condition(items[minIndex])) {
3646    return minIndex;
3647  }
3648
3649  while (minIndex < maxIndex) {
3650    var currentIndex = minIndex + maxIndex >> 1;
3651    var currentItem = items[currentIndex];
3652
3653    if (condition(currentItem)) {
3654      maxIndex = currentIndex;
3655    } else {
3656      minIndex = currentIndex + 1;
3657    }
3658  }
3659
3660  return minIndex;
3661}
3662
3663function approximateFraction(x) {
3664  if (Math.floor(x) === x) {
3665    return [x, 1];
3666  }
3667
3668  var xinv = 1 / x;
3669  var limit = 8;
3670
3671  if (xinv > limit) {
3672    return [1, limit];
3673  } else if (Math.floor(xinv) === xinv) {
3674    return [1, xinv];
3675  }
3676
3677  var x_ = x > 1 ? xinv : x;
3678  var a = 0,
3679      b = 1,
3680      c = 1,
3681      d = 1;
3682
3683  while (true) {
3684    var p = a + c,
3685        q = b + d;
3686
3687    if (q > limit) {
3688      break;
3689    }
3690
3691    if (x_ <= p / q) {
3692      c = p;
3693      d = q;
3694    } else {
3695      a = p;
3696      b = q;
3697    }
3698  }
3699
3700  var result;
3701
3702  if (x_ - a / b < c / d - x_) {
3703    result = x_ === x ? [a, b] : [b, a];
3704  } else {
3705    result = x_ === x ? [c, d] : [d, c];
3706  }
3707
3708  return result;
3709}
3710
3711function roundToDivide(x, div) {
3712  var r = x % div;
3713  return r === 0 ? x : Math.round(x - r + div);
3714}
3715
3716function getPageSizeInches(_ref) {
3717  var view = _ref.view,
3718      userUnit = _ref.userUnit,
3719      rotate = _ref.rotate;
3720
3721  var _view = _slicedToArray(view, 4),
3722      x1 = _view[0],
3723      y1 = _view[1],
3724      x2 = _view[2],
3725      y2 = _view[3];
3726
3727  var changeOrientation = rotate % 180 !== 0;
3728  var width = (x2 - x1) / 72 * userUnit;
3729  var height = (y2 - y1) / 72 * userUnit;
3730  return {
3731    width: changeOrientation ? height : width,
3732    height: changeOrientation ? width : height
3733  };
3734}
3735
3736function backtrackBeforeAllVisibleElements(index, views, top) {
3737  if (index < 2) {
3738    return index;
3739  }
3740
3741  var elt = views[index].div;
3742  var pageTop = elt.offsetTop + elt.clientTop;
3743
3744  if (pageTop >= top) {
3745    elt = views[index - 1].div;
3746    pageTop = elt.offsetTop + elt.clientTop;
3747  }
3748
3749  for (var i = index - 2; i >= 0; --i) {
3750    elt = views[i].div;
3751
3752    if (elt.offsetTop + elt.clientTop + elt.clientHeight <= pageTop) {
3753      break;
3754    }
3755
3756    index = i;
3757  }
3758
3759  return index;
3760}
3761
3762function getVisibleElements(scrollEl, views) {
3763  var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
3764  var horizontal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
3765  var top = scrollEl.scrollTop,
3766      bottom = top + scrollEl.clientHeight;
3767  var left = scrollEl.scrollLeft,
3768      right = left + scrollEl.clientWidth;
3769
3770  function isElementBottomAfterViewTop(view) {
3771    var element = view.div;
3772    var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
3773    return elementBottom > top;
3774  }
3775
3776  function isElementRightAfterViewLeft(view) {
3777    var element = view.div;
3778    var elementRight = element.offsetLeft + element.clientLeft + element.clientWidth;
3779    return elementRight > left;
3780  }
3781
3782  var visible = [],
3783      numViews = views.length;
3784  var firstVisibleElementInd = numViews === 0 ? 0 : binarySearchFirstItem(views, horizontal ? isElementRightAfterViewLeft : isElementBottomAfterViewTop);
3785
3786  if (firstVisibleElementInd > 0 && firstVisibleElementInd < numViews && !horizontal) {
3787    firstVisibleElementInd = backtrackBeforeAllVisibleElements(firstVisibleElementInd, views, top);
3788  }
3789
3790  var lastEdge = horizontal ? right : -1;
3791
3792  for (var i = firstVisibleElementInd; i < numViews; i++) {
3793    var view = views[i],
3794        element = view.div;
3795    var currentWidth = element.offsetLeft + element.clientLeft;
3796    var currentHeight = element.offsetTop + element.clientTop;
3797    var viewWidth = element.clientWidth,
3798        viewHeight = element.clientHeight;
3799    var viewRight = currentWidth + viewWidth;
3800    var viewBottom = currentHeight + viewHeight;
3801
3802    if (lastEdge === -1) {
3803      if (viewBottom >= bottom) {
3804        lastEdge = viewBottom;
3805      }
3806    } else if ((horizontal ? currentWidth : currentHeight) > lastEdge) {
3807      break;
3808    }
3809
3810    if (viewBottom <= top || currentHeight >= bottom || viewRight <= left || currentWidth >= right) {
3811      continue;
3812    }
3813
3814    var hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, viewBottom - bottom);
3815    var hiddenWidth = Math.max(0, left - currentWidth) + Math.max(0, viewRight - right);
3816    var percent = (viewHeight - hiddenHeight) * (viewWidth - hiddenWidth) * 100 / viewHeight / viewWidth | 0;
3817    visible.push({
3818      id: view.id,
3819      x: currentWidth,
3820      y: currentHeight,
3821      view: view,
3822      percent: percent
3823    });
3824  }
3825
3826  var first = visible[0],
3827      last = visible[visible.length - 1];
3828
3829  if (sortByVisibility) {
3830    visible.sort(function (a, b) {
3831      var pc = a.percent - b.percent;
3832
3833      if (Math.abs(pc) > 0.001) {
3834        return -pc;
3835      }
3836
3837      return a.id - b.id;
3838    });
3839  }
3840
3841  return {
3842    first: first,
3843    last: last,
3844    views: visible
3845  };
3846}
3847
3848function noContextMenuHandler(evt) {
3849  evt.preventDefault();
3850}
3851
3852function isDataSchema(url) {
3853  var i = 0,
3854      ii = url.length;
3855
3856  while (i < ii && url[i].trim() === '') {
3857    i++;
3858  }
3859
3860  return url.substring(i, i + 5).toLowerCase() === 'data:';
3861}
3862
3863function getPDFFileNameFromURL(url) {
3864  var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
3865
3866  if (typeof url !== 'string') {
3867    return defaultFilename;
3868  }
3869
3870  if (isDataSchema(url)) {
3871    console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
3872    return defaultFilename;
3873  }
3874
3875  var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
3876  var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
3877  var splitURI = reURI.exec(url);
3878  var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
3879
3880  if (suggestedFilename) {
3881    suggestedFilename = suggestedFilename[0];
3882
3883    if (suggestedFilename.includes('%')) {
3884      try {
3885        suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
3886      } catch (ex) {}
3887    }
3888  }
3889
3890  return suggestedFilename || defaultFilename;
3891}
3892
3893function normalizeWheelEventDelta(evt) {
3894  var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
3895  var angle = Math.atan2(evt.deltaY, evt.deltaX);
3896
3897  if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
3898    delta = -delta;
3899  }
3900
3901  var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
3902  var MOUSE_DOM_DELTA_LINE_MODE = 1;
3903  var MOUSE_PIXELS_PER_LINE = 30;
3904  var MOUSE_LINES_PER_PAGE = 30;
3905
3906  if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
3907    delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
3908  } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
3909    delta /= MOUSE_LINES_PER_PAGE;
3910  }
3911
3912  return delta;
3913}
3914
3915function isValidRotation(angle) {
3916  return Number.isInteger(angle) && angle % 90 === 0;
3917}
3918
3919function isValidScrollMode(mode) {
3920  return Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) && mode !== ScrollMode.UNKNOWN;
3921}
3922
3923function isValidSpreadMode(mode) {
3924  return Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) && mode !== SpreadMode.UNKNOWN;
3925}
3926
3927function isPortraitOrientation(size) {
3928  return size.width <= size.height;
3929}
3930
3931var WaitOnType = {
3932  EVENT: 'event',
3933  TIMEOUT: 'timeout'
3934};
3935exports.WaitOnType = WaitOnType;
3936
3937function waitOnEventOrTimeout(_ref2) {
3938  var target = _ref2.target,
3939      name = _ref2.name,
3940      _ref2$delay = _ref2.delay,
3941      delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
3942  return new Promise(function (resolve, reject) {
3943    if (_typeof(target) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
3944      throw new Error('waitOnEventOrTimeout - invalid parameters.');
3945    }
3946
3947    function handler(type) {
3948      if (target instanceof EventBus) {
3949        target.off(name, eventHandler);
3950      } else {
3951        target.removeEventListener(name, eventHandler);
3952      }
3953
3954      if (timeout) {
3955        clearTimeout(timeout);
3956      }
3957
3958      resolve(type);
3959    }
3960
3961    var eventHandler = handler.bind(null, WaitOnType.EVENT);
3962
3963    if (target instanceof EventBus) {
3964      target.on(name, eventHandler);
3965    } else {
3966      target.addEventListener(name, eventHandler);
3967    }
3968
3969    var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
3970    var timeout = setTimeout(timeoutHandler, delay);
3971  });
3972}
3973
3974var animationStarted = new Promise(function (resolve) {
3975  window.requestAnimationFrame(resolve);
3976});
3977exports.animationStarted = animationStarted;
3978
3979var EventBus =
3980/*#__PURE__*/
3981function () {
3982  function EventBus() {
3983    var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
3984        _ref3$dispatchToDOM = _ref3.dispatchToDOM,
3985        dispatchToDOM = _ref3$dispatchToDOM === void 0 ? false : _ref3$dispatchToDOM;
3986
3987    _classCallCheck(this, EventBus);
3988
3989    this._listeners = Object.create(null);
3990    this._dispatchToDOM = dispatchToDOM === true;
3991  }
3992
3993  _createClass(EventBus, [{
3994    key: "on",
3995    value: function on(eventName, listener) {
3996      var eventListeners = this._listeners[eventName];
3997
3998      if (!eventListeners) {
3999        eventListeners = [];
4000        this._listeners[eventName] = eventListeners;
4001      }
4002
4003      eventListeners.push(listener);
4004    }
4005  }, {
4006    key: "off",
4007    value: function off(eventName, listener) {
4008      var eventListeners = this._listeners[eventName];
4009      var i;
4010
4011      if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
4012        return;
4013      }
4014
4015      eventListeners.splice(i, 1);
4016    }
4017  }, {
4018    key: "dispatch",
4019    value: function dispatch(eventName) {
4020      var eventListeners = this._listeners[eventName];
4021
4022      if (!eventListeners || eventListeners.length === 0) {
4023        if (this._dispatchToDOM) {
4024          var _args5 = Array.prototype.slice.call(arguments, 1);
4025
4026          this._dispatchDOMEvent(eventName, _args5);
4027        }
4028
4029        return;
4030      }
4031
4032      var args = Array.prototype.slice.call(arguments, 1);
4033      eventListeners.slice(0).forEach(function (listener) {
4034        listener.apply(null, args);
4035      });
4036
4037      if (this._dispatchToDOM) {
4038        this._dispatchDOMEvent(eventName, args);
4039      }
4040    }
4041  }, {
4042    key: "_dispatchDOMEvent",
4043    value: function _dispatchDOMEvent(eventName) {
4044      var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
4045      var details = Object.create(null);
4046
4047      if (args && args.length > 0) {
4048        var obj = args[0];
4049
4050        for (var key in obj) {
4051          var value = obj[key];
4052
4053          if (key === 'source') {
4054            if (value === window || value === document) {
4055              return;
4056            }
4057
4058            continue;
4059          }
4060
4061          details[key] = value;
4062        }
4063      }
4064
4065      var event = document.createEvent('CustomEvent');
4066      event.initCustomEvent(eventName, true, true, details);
4067      document.dispatchEvent(event);
4068    }
4069  }]);
4070
4071  return EventBus;
4072}();
4073
4074exports.EventBus = EventBus;
4075var globalEventBus = null;
4076
4077function getGlobalEventBus() {
4078  var dispatchToDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4079
4080  if (!globalEventBus) {
4081    globalEventBus = new EventBus({
4082      dispatchToDOM: dispatchToDOM
4083    });
4084  }
4085
4086  return globalEventBus;
4087}
4088
4089function clamp(v, min, max) {
4090  return Math.min(Math.max(v, min), max);
4091}
4092
4093var ProgressBar =
4094/*#__PURE__*/
4095function () {
4096  function ProgressBar(id) {
4097    var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
4098        height = _ref4.height,
4099        width = _ref4.width,
4100        units = _ref4.units;
4101
4102    _classCallCheck(this, ProgressBar);
4103
4104    this.visible = true;
4105    this.div = document.querySelector(id + ' .progress');
4106    this.bar = this.div.parentNode;
4107    this.height = height || 100;
4108    this.width = width || 100;
4109    this.units = units || '%';
4110    this.div.style.height = this.height + this.units;
4111    this.percent = 0;
4112  }
4113
4114  _createClass(ProgressBar, [{
4115    key: "_updateBar",
4116    value: function _updateBar() {
4117      if (this._indeterminate) {
4118        this.div.classList.add('indeterminate');
4119        this.div.style.width = this.width + this.units;
4120        return;
4121      }
4122
4123      this.div.classList.remove('indeterminate');
4124      var progressSize = this.width * this._percent / 100;
4125      this.div.style.width = progressSize + this.units;
4126    }
4127  }, {
4128    key: "setWidth",
4129    value: function setWidth(viewer) {
4130      if (!viewer) {
4131        return;
4132      }
4133
4134      var container = viewer.parentNode;
4135      var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
4136
4137      if (scrollbarWidth > 0) {
4138        this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
4139      }
4140    }
4141  }, {
4142    key: "hide",
4143    value: function hide() {
4144      if (!this.visible) {
4145        return;
4146      }
4147
4148      this.visible = false;
4149      this.bar.classList.add('hidden');
4150      document.body.classList.remove('loadingInProgress');
4151    }
4152  }, {
4153    key: "show",
4154    value: function show() {
4155      if (this.visible) {
4156        return;
4157      }
4158
4159      this.visible = true;
4160      document.body.classList.add('loadingInProgress');
4161      this.bar.classList.remove('hidden');
4162    }
4163  }, {
4164    key: "percent",
4165    get: function get() {
4166      return this._percent;
4167    },
4168    set: function set(val) {
4169      this._indeterminate = isNaN(val);
4170      this._percent = clamp(val, 0, 100);
4171
4172      this._updateBar();
4173    }
4174  }]);
4175
4176  return ProgressBar;
4177}();
4178
4179exports.ProgressBar = ProgressBar;
4180
4181function moveToEndOfArray(arr, condition) {
4182  var moved = [],
4183      len = arr.length;
4184  var write = 0;
4185
4186  for (var read = 0; read < len; ++read) {
4187    if (condition(arr[read])) {
4188      moved.push(arr[read]);
4189    } else {
4190      arr[write] = arr[read];
4191      ++write;
4192    }
4193  }
4194
4195  for (var _read = 0; write < len; ++_read, ++write) {
4196    arr[write] = moved[_read];
4197  }
4198}
4199
4200/***/ }),
4201/* 6 */
4202/***/ (function(module, exports, __webpack_require__) {
4203
4204"use strict";
4205
4206
4207Object.defineProperty(exports, "__esModule", {
4208  value: true
4209});
4210exports.OptionKind = exports.AppOptions = void 0;
4211
4212var _pdfjsLib = __webpack_require__(7);
4213
4214var _viewer_compatibility = __webpack_require__(8);
4215
4216function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4217
4218function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4219
4220function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4221
4222function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4223
4224var OptionKind = {
4225  VIEWER: 0x02,
4226  API: 0x04,
4227  WORKER: 0x08,
4228  PREFERENCE: 0x80
4229};
4230exports.OptionKind = OptionKind;
4231var defaultOptions = {
4232  cursorToolOnLoad: {
4233    value: 0,
4234    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4235  },
4236  defaultUrl: {
4237    value: 'compressed.tracemonkey-pldi-09.pdf',
4238    kind: OptionKind.VIEWER
4239  },
4240  defaultZoomValue: {
4241    value: '',
4242    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4243  },
4244  disableHistory: {
4245    value: false,
4246    kind: OptionKind.VIEWER
4247  },
4248  disablePageLabels: {
4249    value: false,
4250    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4251  },
4252  enablePrintAutoRotate: {
4253    value: false,
4254    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4255  },
4256  enableWebGL: {
4257    value: false,
4258    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4259  },
4260  eventBusDispatchToDOM: {
4261    value: false,
4262    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4263  },
4264  externalLinkRel: {
4265    value: 'noopener noreferrer nofollow',
4266    kind: OptionKind.VIEWER
4267  },
4268  externalLinkTarget: {
4269    value: 0,
4270    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4271  },
4272  historyUpdateUrl: {
4273    value: false,
4274    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4275  },
4276  imageResourcesPath: {
4277    value: './images/',
4278    kind: OptionKind.VIEWER
4279  },
4280  maxCanvasPixels: {
4281    value: 16777216,
4282    compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels,
4283    kind: OptionKind.VIEWER
4284  },
4285  pdfBugEnabled: {
4286    value: false,
4287    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4288  },
4289  renderer: {
4290    value: 'canvas',
4291    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4292  },
4293  renderInteractiveForms: {
4294    value: false,
4295    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4296  },
4297  sidebarViewOnLoad: {
4298    value: -1,
4299    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4300  },
4301  scrollModeOnLoad: {
4302    value: -1,
4303    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4304  },
4305  spreadModeOnLoad: {
4306    value: -1,
4307    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4308  },
4309  textLayerMode: {
4310    value: 1,
4311    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4312  },
4313  useOnlyCssZoom: {
4314    value: false,
4315    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4316  },
4317  viewOnLoad: {
4318    value: 0,
4319    kind: OptionKind.VIEWER + OptionKind.PREFERENCE
4320  },
4321  cMapPacked: {
4322    value: true,
4323    kind: OptionKind.API
4324  },
4325  cMapUrl: {
4326    value: '../web/cmaps/',
4327    kind: OptionKind.API
4328  },
4329  disableAutoFetch: {
4330    value: false,
4331    kind: OptionKind.API + OptionKind.PREFERENCE
4332  },
4333  disableCreateObjectURL: {
4334    value: false,
4335    compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
4336    kind: OptionKind.API
4337  },
4338  disableFontFace: {
4339    value: false,
4340    kind: OptionKind.API + OptionKind.PREFERENCE
4341  },
4342  disableRange: {
4343    value: false,
4344    kind: OptionKind.API + OptionKind.PREFERENCE
4345  },
4346  disableStream: {
4347    value: false,
4348    kind: OptionKind.API + OptionKind.PREFERENCE
4349  },
4350  isEvalSupported: {
4351    value: true,
4352    kind: OptionKind.API
4353  },
4354  maxImageSize: {
4355    value: -1,
4356    kind: OptionKind.API
4357  },
4358  pdfBug: {
4359    value: false,
4360    kind: OptionKind.API
4361  },
4362  postMessageTransfers: {
4363    value: true,
4364    kind: OptionKind.API
4365  },
4366  verbosity: {
4367    value: 1,
4368    kind: OptionKind.API
4369  },
4370  workerPort: {
4371    value: null,
4372    kind: OptionKind.WORKER
4373  },
4374  workerSrc: {
4375    value: '../build/pdf.worker.js',
4376    kind: OptionKind.WORKER
4377  }
4378};
4379{
4380  defaultOptions.disablePreferences = {
4381    value: false,
4382    kind: OptionKind.VIEWER
4383  };
4384  defaultOptions.locale = {
4385    value: typeof navigator !== 'undefined' ? navigator.language : 'en-US',
4386    kind: OptionKind.VIEWER
4387  };
4388  defaultOptions.printResolution = {
4389    value: 150,
4390    kind: OptionKind.VIEWER
4391  };
4392}
4393var userOptions = Object.create(null);
4394
4395var AppOptions =
4396/*#__PURE__*/
4397function () {
4398  function AppOptions() {
4399    _classCallCheck(this, AppOptions);
4400
4401    throw new Error('Cannot initialize AppOptions.');
4402  }
4403
4404  _createClass(AppOptions, null, [{
4405    key: "get",
4406    value: function get(name) {
4407      var userOption = userOptions[name];
4408
4409      if (userOption !== undefined) {
4410        return userOption;
4411      }
4412
4413      var defaultOption = defaultOptions[name];
4414
4415      if (defaultOption !== undefined) {
4416        return defaultOption.compatibility || defaultOption.value;
4417      }
4418
4419      return undefined;
4420    }
4421  }, {
4422    key: "getAll",
4423    value: function getAll() {
4424      var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
4425      var options = Object.create(null);
4426
4427      for (var name in defaultOptions) {
4428        var defaultOption = defaultOptions[name];
4429
4430        if (kind) {
4431          if ((kind & defaultOption.kind) === 0) {
4432            continue;
4433          }
4434
4435          if (kind === OptionKind.PREFERENCE) {
4436            var value = defaultOption.value,
4437                valueType = _typeof(value);
4438
4439            if (valueType === 'boolean' || valueType === 'string' || valueType === 'number' && Number.isInteger(value)) {
4440              options[name] = value;
4441              continue;
4442            }
4443
4444            throw new Error("Invalid type for preference: ".concat(name));
4445          }
4446        }
4447
4448        var userOption = userOptions[name];
4449        options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value;
4450      }
4451
4452      return options;
4453    }
4454  }, {
4455    key: "set",
4456    value: function set(name, value) {
4457      userOptions[name] = value;
4458    }
4459  }, {
4460    key: "remove",
4461    value: function remove(name) {
4462      delete userOptions[name];
4463    }
4464  }]);
4465
4466  return AppOptions;
4467}();
4468
4469exports.AppOptions = AppOptions;
4470
4471/***/ }),
4472/* 7 */
4473/***/ (function(module, exports, __webpack_require__) {
4474
4475"use strict";
4476
4477
4478var pdfjsLib;
4479
4480if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
4481  pdfjsLib = window['pdfjs-dist/build/pdf'];
4482} else {
4483  pdfjsLib = require('../build/pdf.js');
4484}
4485
4486module.exports = pdfjsLib;
4487
4488/***/ }),
4489/* 8 */
4490/***/ (function(module, exports, __webpack_require__) {
4491
4492"use strict";
4493
4494
4495var compatibilityParams = Object.create(null);
4496{
4497  var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
4498  var isAndroid = /Android/.test(userAgent);
4499  var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
4500
4501  (function checkCanvasSizeLimitation() {
4502    if (isIOS || isAndroid) {
4503      compatibilityParams.maxCanvasPixels = 5242880;
4504    }
4505  })();
4506}
4507exports.viewerCompatibilityParams = Object.freeze(compatibilityParams);
4508
4509/***/ }),
4510/* 9 */
4511/***/ (function(module, exports, __webpack_require__) {
4512
4513"use strict";
4514
4515
4516Object.defineProperty(exports, "__esModule", {
4517  value: true
4518});
4519exports.PDFCursorTools = exports.CursorTool = void 0;
4520
4521var _grab_to_pan = __webpack_require__(10);
4522
4523function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4524
4525function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4526
4527function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4528
4529var CursorTool = {
4530  SELECT: 0,
4531  HAND: 1,
4532  ZOOM: 2
4533};
4534exports.CursorTool = CursorTool;
4535
4536var PDFCursorTools =
4537/*#__PURE__*/
4538function () {
4539  function PDFCursorTools(_ref) {
4540    var _this = this;
4541
4542    var container = _ref.container,
4543        eventBus = _ref.eventBus,
4544        _ref$cursorToolOnLoad = _ref.cursorToolOnLoad,
4545        cursorToolOnLoad = _ref$cursorToolOnLoad === void 0 ? CursorTool.SELECT : _ref$cursorToolOnLoad;
4546
4547    _classCallCheck(this, PDFCursorTools);
4548
4549    this.container = container;
4550    this.eventBus = eventBus;
4551    this.active = CursorTool.SELECT;
4552    this.activeBeforePresentationMode = null;
4553    this.handTool = new _grab_to_pan.GrabToPan({
4554      element: this.container
4555    });
4556
4557    this._addEventListeners();
4558
4559    Promise.resolve().then(function () {
4560      _this.switchTool(cursorToolOnLoad);
4561    });
4562  }
4563
4564  _createClass(PDFCursorTools, [{
4565    key: "switchTool",
4566    value: function switchTool(tool) {
4567      var _this2 = this;
4568
4569      if (this.activeBeforePresentationMode !== null) {
4570        return;
4571      }
4572
4573      if (tool === this.active) {
4574        return;
4575      }
4576
4577      var disableActiveTool = function disableActiveTool() {
4578        switch (_this2.active) {
4579          case CursorTool.SELECT:
4580            break;
4581
4582          case CursorTool.HAND:
4583            _this2.handTool.deactivate();
4584
4585            break;
4586
4587          case CursorTool.ZOOM:
4588        }
4589      };
4590
4591      switch (tool) {
4592        case CursorTool.SELECT:
4593          disableActiveTool();
4594          break;
4595
4596        case CursorTool.HAND:
4597          disableActiveTool();
4598          this.handTool.activate();
4599          break;
4600
4601        case CursorTool.ZOOM:
4602        default:
4603          console.error("switchTool: \"".concat(tool, "\" is an unsupported value."));
4604          return;
4605      }
4606
4607      this.active = tool;
4608
4609      this._dispatchEvent();
4610    }
4611  }, {
4612    key: "_dispatchEvent",
4613    value: function _dispatchEvent() {
4614      this.eventBus.dispatch('cursortoolchanged', {
4615        source: this,
4616        tool: this.active
4617      });
4618    }
4619  }, {
4620    key: "_addEventListeners",
4621    value: function _addEventListeners() {
4622      var _this3 = this;
4623
4624      this.eventBus.on('switchcursortool', function (evt) {
4625        _this3.switchTool(evt.tool);
4626      });
4627      this.eventBus.on('presentationmodechanged', function (evt) {
4628        if (evt.switchInProgress) {
4629          return;
4630        }
4631
4632        var previouslyActive;
4633
4634        if (evt.active) {
4635          previouslyActive = _this3.active;
4636
4637          _this3.switchTool(CursorTool.SELECT);
4638
4639          _this3.activeBeforePresentationMode = previouslyActive;
4640        } else {
4641          previouslyActive = _this3.activeBeforePresentationMode;
4642          _this3.activeBeforePresentationMode = null;
4643
4644          _this3.switchTool(previouslyActive);
4645        }
4646      });
4647    }
4648  }, {
4649    key: "activeTool",
4650    get: function get() {
4651      return this.active;
4652    }
4653  }]);
4654
4655  return PDFCursorTools;
4656}();
4657
4658exports.PDFCursorTools = PDFCursorTools;
4659
4660/***/ }),
4661/* 10 */
4662/***/ (function(module, exports, __webpack_require__) {
4663
4664"use strict";
4665
4666
4667Object.defineProperty(exports, "__esModule", {
4668  value: true
4669});
4670exports.GrabToPan = GrabToPan;
4671
4672function GrabToPan(options) {
4673  this.element = options.element;
4674  this.document = options.element.ownerDocument;
4675
4676  if (typeof options.ignoreTarget === 'function') {
4677    this.ignoreTarget = options.ignoreTarget;
4678  }
4679
4680  this.onActiveChanged = options.onActiveChanged;
4681  this.activate = this.activate.bind(this);
4682  this.deactivate = this.deactivate.bind(this);
4683  this.toggle = this.toggle.bind(this);
4684  this._onmousedown = this._onmousedown.bind(this);
4685  this._onmousemove = this._onmousemove.bind(this);
4686  this._endPan = this._endPan.bind(this);
4687  var overlay = this.overlay = document.createElement('div');
4688  overlay.className = 'grab-to-pan-grabbing';
4689}
4690
4691GrabToPan.prototype = {
4692  CSS_CLASS_GRAB: 'grab-to-pan-grab',
4693  activate: function GrabToPan_activate() {
4694    if (!this.active) {
4695      this.active = true;
4696      this.element.addEventListener('mousedown', this._onmousedown, true);
4697      this.element.classList.add(this.CSS_CLASS_GRAB);
4698
4699      if (this.onActiveChanged) {
4700        this.onActiveChanged(true);
4701      }
4702    }
4703  },
4704  deactivate: function GrabToPan_deactivate() {
4705    if (this.active) {
4706      this.active = false;
4707      this.element.removeEventListener('mousedown', this._onmousedown, true);
4708
4709      this._endPan();
4710
4711      this.element.classList.remove(this.CSS_CLASS_GRAB);
4712
4713      if (this.onActiveChanged) {
4714        this.onActiveChanged(false);
4715      }
4716    }
4717  },
4718  toggle: function GrabToPan_toggle() {
4719    if (this.active) {
4720      this.deactivate();
4721    } else {
4722      this.activate();
4723    }
4724  },
4725  ignoreTarget: function GrabToPan_ignoreTarget(node) {
4726    return node[matchesSelector]('a[href], a[href] *, input, textarea, button, button *, select, option');
4727  },
4728  _onmousedown: function GrabToPan__onmousedown(event) {
4729    if (event.button !== 0 || this.ignoreTarget(event.target)) {
4730      return;
4731    }
4732
4733    if (event.originalTarget) {
4734      try {
4735        event.originalTarget.tagName;
4736      } catch (e) {
4737        return;
4738      }
4739    }
4740
4741    this.scrollLeftStart = this.element.scrollLeft;
4742    this.scrollTopStart = this.element.scrollTop;
4743    this.clientXStart = event.clientX;
4744    this.clientYStart = event.clientY;
4745    this.document.addEventListener('mousemove', this._onmousemove, true);
4746    this.document.addEventListener('mouseup', this._endPan, true);
4747    this.element.addEventListener('scroll', this._endPan, true);
4748    event.preventDefault();
4749    event.stopPropagation();
4750    var focusedElement = document.activeElement;
4751
4752    if (focusedElement && !focusedElement.contains(event.target)) {
4753      focusedElement.blur();
4754    }
4755  },
4756  _onmousemove: function GrabToPan__onmousemove(event) {
4757    this.element.removeEventListener('scroll', this._endPan, true);
4758
4759    if (isLeftMouseReleased(event)) {
4760      this._endPan();
4761
4762      return;
4763    }
4764
4765    var xDiff = event.clientX - this.clientXStart;
4766    var yDiff = event.clientY - this.clientYStart;
4767    var scrollTop = this.scrollTopStart - yDiff;
4768    var scrollLeft = this.scrollLeftStart - xDiff;
4769
4770    if (this.element.scrollTo) {
4771      this.element.scrollTo({
4772        top: scrollTop,
4773        left: scrollLeft,
4774        behavior: 'instant'
4775      });
4776    } else {
4777      this.element.scrollTop = scrollTop;
4778      this.element.scrollLeft = scrollLeft;
4779    }
4780
4781    if (!this.overlay.parentNode) {
4782      document.body.appendChild(this.overlay);
4783    }
4784  },
4785  _endPan: function GrabToPan__endPan() {
4786    this.element.removeEventListener('scroll', this._endPan, true);
4787    this.document.removeEventListener('mousemove', this._onmousemove, true);
4788    this.document.removeEventListener('mouseup', this._endPan, true);
4789    this.overlay.remove();
4790  }
4791};
4792var matchesSelector;
4793['webkitM', 'mozM', 'msM', 'oM', 'm'].some(function (prefix) {
4794  var name = prefix + 'atches';
4795
4796  if (name in document.documentElement) {
4797    matchesSelector = name;
4798  }
4799
4800  name += 'Selector';
4801
4802  if (name in document.documentElement) {
4803    matchesSelector = name;
4804  }
4805
4806  return matchesSelector;
4807});
4808var isNotIEorIsIE10plus = !document.documentMode || document.documentMode > 9;
4809var chrome = window.chrome;
4810var isChrome15OrOpera15plus = chrome && (chrome.webstore || chrome.app);
4811var isSafari6plus = /Apple/.test(navigator.vendor) && /Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);
4812
4813function isLeftMouseReleased(event) {
4814  if ('buttons' in event && isNotIEorIsIE10plus) {
4815    return !(event.buttons & 1);
4816  }
4817
4818  if (isChrome15OrOpera15plus || isSafari6plus) {
4819    return event.which === 0;
4820  }
4821
4822  return false;
4823}
4824
4825/***/ }),
4826/* 11 */
4827/***/ (function(module, exports, __webpack_require__) {
4828
4829"use strict";
4830
4831
4832Object.defineProperty(exports, "__esModule", {
4833  value: true
4834});
4835exports.PDFRenderingQueue = exports.RenderingStates = void 0;
4836
4837function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4838
4839function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4840
4841function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
4842
4843var CLEANUP_TIMEOUT = 30000;
4844var RenderingStates = {
4845  INITIAL: 0,
4846  RUNNING: 1,
4847  PAUSED: 2,
4848  FINISHED: 3
4849};
4850exports.RenderingStates = RenderingStates;
4851
4852var PDFRenderingQueue =
4853/*#__PURE__*/
4854function () {
4855  function PDFRenderingQueue() {
4856    _classCallCheck(this, PDFRenderingQueue);
4857
4858    this.pdfViewer = null;
4859    this.pdfThumbnailViewer = null;
4860    this.onIdle = null;
4861    this.highestPriorityPage = null;
4862    this.idleTimeout = null;
4863    this.printing = false;
4864    this.isThumbnailViewEnabled = false;
4865  }
4866
4867  _createClass(PDFRenderingQueue, [{
4868    key: "setViewer",
4869    value: function setViewer(pdfViewer) {
4870      this.pdfViewer = pdfViewer;
4871    }
4872  }, {
4873    key: "setThumbnailViewer",
4874    value: function setThumbnailViewer(pdfThumbnailViewer) {
4875      this.pdfThumbnailViewer = pdfThumbnailViewer;
4876    }
4877  }, {
4878    key: "isHighestPriority",
4879    value: function isHighestPriority(view) {
4880      return this.highestPriorityPage === view.renderingId;
4881    }
4882  }, {
4883    key: "renderHighestPriority",
4884    value: function renderHighestPriority(currentlyVisiblePages) {
4885      if (this.idleTimeout) {
4886        clearTimeout(this.idleTimeout);
4887        this.idleTimeout = null;
4888      }
4889
4890      if (this.pdfViewer.forceRendering(currentlyVisiblePages)) {
4891        return;
4892      }
4893
4894      if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) {
4895        if (this.pdfThumbnailViewer.forceRendering()) {
4896          return;
4897        }
4898      }
4899
4900      if (this.printing) {
4901        return;
4902      }
4903
4904      if (this.onIdle) {
4905        this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
4906      }
4907    }
4908  }, {
4909    key: "getHighestPriority",
4910    value: function getHighestPriority(visible, views, scrolledDown) {
4911      var visibleViews = visible.views;
4912      var numVisible = visibleViews.length;
4913
4914      if (numVisible === 0) {
4915        return null;
4916      }
4917
4918      for (var i = 0; i < numVisible; ++i) {
4919        var view = visibleViews[i].view;
4920
4921        if (!this.isViewFinished(view)) {
4922          return view;
4923        }
4924      }
4925
4926      if (scrolledDown) {
4927        var nextPageIndex = visible.last.id;
4928
4929        if (views[nextPageIndex] && !this.isViewFinished(views[nextPageIndex])) {
4930          return views[nextPageIndex];
4931        }
4932      } else {
4933        var previousPageIndex = visible.first.id - 2;
4934
4935        if (views[previousPageIndex] && !this.isViewFinished(views[previousPageIndex])) {
4936          return views[previousPageIndex];
4937        }
4938      }
4939
4940      return null;
4941    }
4942  }, {
4943    key: "isViewFinished",
4944    value: function isViewFinished(view) {
4945      return view.renderingState === RenderingStates.FINISHED;
4946    }
4947  }, {
4948    key: "renderView",
4949    value: function renderView(view) {
4950      var _this = this;
4951
4952      switch (view.renderingState) {
4953        case RenderingStates.FINISHED:
4954          return false;
4955
4956        case RenderingStates.PAUSED:
4957          this.highestPriorityPage = view.renderingId;
4958          view.resume();
4959          break;
4960
4961        case RenderingStates.RUNNING:
4962          this.highestPriorityPage = view.renderingId;
4963          break;
4964
4965        case RenderingStates.INITIAL:
4966          this.highestPriorityPage = view.renderingId;
4967          view.draw()["finally"](function () {
4968            _this.renderHighestPriority();
4969          });
4970          break;
4971      }
4972
4973      return true;
4974    }
4975  }]);
4976
4977  return PDFRenderingQueue;
4978}();
4979
4980exports.PDFRenderingQueue = PDFRenderingQueue;
4981
4982/***/ }),
4983/* 12 */
4984/***/ (function(module, exports, __webpack_require__) {
4985
4986"use strict";
4987
4988
4989Object.defineProperty(exports, "__esModule", {
4990  value: true
4991});
4992exports.PDFSidebar = exports.SidebarView = void 0;
4993
4994var _ui_utils = __webpack_require__(5);
4995
4996var _pdf_rendering_queue = __webpack_require__(11);
4997
4998function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4999
5000function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5001
5002function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5003
5004var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
5005var SidebarView = {
5006  UNKNOWN: -1,
5007  NONE: 0,
5008  THUMBS: 1,
5009  OUTLINE: 2,
5010  ATTACHMENTS: 3,
5011  LAYERS: 4
5012};
5013exports.SidebarView = SidebarView;
5014
5015var PDFSidebar =
5016/*#__PURE__*/
5017function () {
5018  function PDFSidebar(_ref) {
5019    var elements = _ref.elements,
5020        pdfViewer = _ref.pdfViewer,
5021        pdfThumbnailViewer = _ref.pdfThumbnailViewer,
5022        eventBus = _ref.eventBus,
5023        _ref$l10n = _ref.l10n,
5024        l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n,
5025        _ref$disableNotificat = _ref.disableNotification,
5026        disableNotification = _ref$disableNotificat === void 0 ? false : _ref$disableNotificat;
5027
5028    _classCallCheck(this, PDFSidebar);
5029
5030    this.isOpen = false;
5031    this.active = SidebarView.THUMBS;
5032    this.isInitialViewSet = false;
5033    this.onToggled = null;
5034    this.pdfViewer = pdfViewer;
5035    this.pdfThumbnailViewer = pdfThumbnailViewer;
5036    this.outerContainer = elements.outerContainer;
5037    this.viewerContainer = elements.viewerContainer;
5038    this.toggleButton = elements.toggleButton;
5039    this.thumbnailButton = elements.thumbnailButton;
5040    this.outlineButton = elements.outlineButton;
5041    this.attachmentsButton = elements.attachmentsButton;
5042    this.thumbnailView = elements.thumbnailView;
5043    this.outlineView = elements.outlineView;
5044    this.attachmentsView = elements.attachmentsView;
5045    this.eventBus = eventBus;
5046    this.l10n = l10n;
5047    this._disableNotification = disableNotification;
5048
5049    this._addEventListeners();
5050  }
5051
5052  _createClass(PDFSidebar, [{
5053    key: "reset",
5054    value: function reset() {
5055      this.isInitialViewSet = false;
5056
5057      this._hideUINotification(null);
5058
5059      this.switchView(SidebarView.THUMBS);
5060      this.outlineButton.disabled = false;
5061      this.attachmentsButton.disabled = false;
5062    }
5063  }, {
5064    key: "setInitialView",
5065    value: function setInitialView() {
5066      var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
5067
5068      if (this.isInitialViewSet) {
5069        return;
5070      }
5071
5072      this.isInitialViewSet = true;
5073
5074      if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
5075        this._dispatchEvent();
5076
5077        return;
5078      }
5079
5080      if (!this._switchView(view, true)) {
5081        this._dispatchEvent();
5082      }
5083    }
5084  }, {
5085    key: "switchView",
5086    value: function switchView(view) {
5087      var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5088
5089      this._switchView(view, forceOpen);
5090    }
5091  }, {
5092    key: "_switchView",
5093    value: function _switchView(view) {
5094      var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5095      var isViewChanged = view !== this.active;
5096      var shouldForceRendering = false;
5097
5098      switch (view) {
5099        case SidebarView.NONE:
5100          if (this.isOpen) {
5101            this.close();
5102            return true;
5103          }
5104
5105          return false;
5106
5107        case SidebarView.THUMBS:
5108          if (this.isOpen && isViewChanged) {
5109            shouldForceRendering = true;
5110          }
5111
5112          break;
5113
5114        case SidebarView.OUTLINE:
5115          if (this.outlineButton.disabled) {
5116            return false;
5117          }
5118
5119          break;
5120
5121        case SidebarView.ATTACHMENTS:
5122          if (this.attachmentsButton.disabled) {
5123            return false;
5124          }
5125
5126          break;
5127
5128        default:
5129          console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
5130          return false;
5131      }
5132
5133      this.active = view;
5134      this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
5135      this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
5136      this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
5137      this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
5138      this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
5139      this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
5140
5141      if (forceOpen && !this.isOpen) {
5142        this.open();
5143        return true;
5144      }
5145
5146      if (shouldForceRendering) {
5147        this._updateThumbnailViewer();
5148
5149        this._forceRendering();
5150      }
5151
5152      if (isViewChanged) {
5153        this._dispatchEvent();
5154      }
5155
5156      this._hideUINotification(this.active);
5157
5158      return isViewChanged;
5159    }
5160  }, {
5161    key: "open",
5162    value: function open() {
5163      if (this.isOpen) {
5164        return;
5165      }
5166
5167      this.isOpen = true;
5168      this.toggleButton.classList.add('toggled');
5169      this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
5170
5171      if (this.active === SidebarView.THUMBS) {
5172        this._updateThumbnailViewer();
5173      }
5174
5175      this._forceRendering();
5176
5177      this._dispatchEvent();
5178
5179      this._hideUINotification(this.active);
5180    }
5181  }, {
5182    key: "close",
5183    value: function close() {
5184      if (!this.isOpen) {
5185        return;
5186      }
5187
5188      this.isOpen = false;
5189      this.toggleButton.classList.remove('toggled');
5190      this.outerContainer.classList.add('sidebarMoving');
5191      this.outerContainer.classList.remove('sidebarOpen');
5192
5193      this._forceRendering();
5194
5195      this._dispatchEvent();
5196    }
5197  }, {
5198    key: "toggle",
5199    value: function toggle() {
5200      if (this.isOpen) {
5201        this.close();
5202      } else {
5203        this.open();
5204      }
5205    }
5206  }, {
5207    key: "_dispatchEvent",
5208    value: function _dispatchEvent() {
5209      this.eventBus.dispatch('sidebarviewchanged', {
5210        source: this,
5211        view: this.visibleView
5212      });
5213    }
5214  }, {
5215    key: "_forceRendering",
5216    value: function _forceRendering() {
5217      if (this.onToggled) {
5218        this.onToggled();
5219      } else {
5220        this.pdfViewer.forceRendering();
5221        this.pdfThumbnailViewer.forceRendering();
5222      }
5223    }
5224  }, {
5225    key: "_updateThumbnailViewer",
5226    value: function _updateThumbnailViewer() {
5227      var pdfViewer = this.pdfViewer,
5228          pdfThumbnailViewer = this.pdfThumbnailViewer;
5229      var pagesCount = pdfViewer.pagesCount;
5230
5231      for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
5232        var pageView = pdfViewer.getPageView(pageIndex);
5233
5234        if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
5235          var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
5236          thumbnailView.setImage(pageView);
5237        }
5238      }
5239
5240      pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
5241    }
5242  }, {
5243    key: "_showUINotification",
5244    value: function _showUINotification(view) {
5245      var _this = this;
5246
5247      if (this._disableNotification) {
5248        return;
5249      }
5250
5251      this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
5252        _this.toggleButton.title = msg;
5253      });
5254
5255      if (!this.isOpen) {
5256        this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
5257      } else if (view === this.active) {
5258        return;
5259      }
5260
5261      switch (view) {
5262        case SidebarView.OUTLINE:
5263          this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
5264          break;
5265
5266        case SidebarView.ATTACHMENTS:
5267          this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
5268          break;
5269      }
5270    }
5271  }, {
5272    key: "_hideUINotification",
5273    value: function _hideUINotification(view) {
5274      var _this2 = this;
5275
5276      if (this._disableNotification) {
5277        return;
5278      }
5279
5280      var removeNotification = function removeNotification(view) {
5281        switch (view) {
5282          case SidebarView.OUTLINE:
5283            _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
5284
5285            break;
5286
5287          case SidebarView.ATTACHMENTS:
5288            _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
5289
5290            break;
5291        }
5292      };
5293
5294      if (!this.isOpen && view !== null) {
5295        return;
5296      }
5297
5298      this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
5299
5300      if (view !== null) {
5301        removeNotification(view);
5302        return;
5303      }
5304
5305      for (view in SidebarView) {
5306        removeNotification(SidebarView[view]);
5307      }
5308
5309      this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
5310        _this2.toggleButton.title = msg;
5311      });
5312    }
5313  }, {
5314    key: "_addEventListeners",
5315    value: function _addEventListeners() {
5316      var _this3 = this;
5317
5318      this.viewerContainer.addEventListener('transitionend', function (evt) {
5319        if (evt.target === _this3.viewerContainer) {
5320          _this3.outerContainer.classList.remove('sidebarMoving');
5321        }
5322      });
5323      this.thumbnailButton.addEventListener('click', function () {
5324        _this3.switchView(SidebarView.THUMBS);
5325      });
5326      this.outlineButton.addEventListener('click', function () {
5327        _this3.switchView(SidebarView.OUTLINE);
5328      });
5329      this.outlineButton.addEventListener('dblclick', function () {
5330        _this3.eventBus.dispatch('toggleoutlinetree', {
5331          source: _this3
5332        });
5333      });
5334      this.attachmentsButton.addEventListener('click', function () {
5335        _this3.switchView(SidebarView.ATTACHMENTS);
5336      });
5337      this.eventBus.on('outlineloaded', function (evt) {
5338        var outlineCount = evt.outlineCount;
5339        _this3.outlineButton.disabled = !outlineCount;
5340
5341        if (outlineCount) {
5342          _this3._showUINotification(SidebarView.OUTLINE);
5343        } else if (_this3.active === SidebarView.OUTLINE) {
5344          _this3.switchView(SidebarView.THUMBS);
5345        }
5346      });
5347      this.eventBus.on('attachmentsloaded', function (evt) {
5348        if (evt.attachmentsCount) {
5349          _this3.attachmentsButton.disabled = false;
5350
5351          _this3._showUINotification(SidebarView.ATTACHMENTS);
5352
5353          return;
5354        }
5355
5356        Promise.resolve().then(function () {
5357          if (_this3.attachmentsView.hasChildNodes()) {
5358            return;
5359          }
5360
5361          _this3.attachmentsButton.disabled = true;
5362
5363          if (_this3.active === SidebarView.ATTACHMENTS) {
5364            _this3.switchView(SidebarView.THUMBS);
5365          }
5366        });
5367      });
5368      this.eventBus.on('presentationmodechanged', function (evt) {
5369        if (!evt.active && !evt.switchInProgress && _this3.isThumbnailViewVisible) {
5370          _this3._updateThumbnailViewer();
5371        }
5372      });
5373    }
5374  }, {
5375    key: "visibleView",
5376    get: function get() {
5377      return this.isOpen ? this.active : SidebarView.NONE;
5378    }
5379  }, {
5380    key: "isThumbnailViewVisible",
5381    get: function get() {
5382      return this.isOpen && this.active === SidebarView.THUMBS;
5383    }
5384  }, {
5385    key: "isOutlineViewVisible",
5386    get: function get() {
5387      return this.isOpen && this.active === SidebarView.OUTLINE;
5388    }
5389  }, {
5390    key: "isAttachmentsViewVisible",
5391    get: function get() {
5392      return this.isOpen && this.active === SidebarView.ATTACHMENTS;
5393    }
5394  }]);
5395
5396  return PDFSidebar;
5397}();
5398
5399exports.PDFSidebar = PDFSidebar;
5400
5401/***/ }),
5402/* 13 */
5403/***/ (function(module, exports, __webpack_require__) {
5404
5405"use strict";
5406
5407
5408Object.defineProperty(exports, "__esModule", {
5409  value: true
5410});
5411exports.OverlayManager = void 0;
5412
5413var _regenerator = _interopRequireDefault(__webpack_require__(2));
5414
5415function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
5416
5417function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5418
5419function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5420
5421function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5422
5423function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5424
5425function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5426
5427var OverlayManager =
5428/*#__PURE__*/
5429function () {
5430  function OverlayManager() {
5431    _classCallCheck(this, OverlayManager);
5432
5433    this._overlays = {};
5434    this._active = null;
5435    this._keyDownBound = this._keyDown.bind(this);
5436  }
5437
5438  _createClass(OverlayManager, [{
5439    key: "register",
5440    value: function () {
5441      var _register = _asyncToGenerator(
5442      /*#__PURE__*/
5443      _regenerator["default"].mark(function _callee(name, element) {
5444        var callerCloseMethod,
5445            canForceClose,
5446            container,
5447            _args = arguments;
5448        return _regenerator["default"].wrap(function _callee$(_context) {
5449          while (1) {
5450            switch (_context.prev = _context.next) {
5451              case 0:
5452                callerCloseMethod = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
5453                canForceClose = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
5454
5455                if (!(!name || !element || !(container = element.parentNode))) {
5456                  _context.next = 6;
5457                  break;
5458                }
5459
5460                throw new Error('Not enough parameters.');
5461
5462              case 6:
5463                if (!this._overlays[name]) {
5464                  _context.next = 8;
5465                  break;
5466                }
5467
5468                throw new Error('The overlay is already registered.');
5469
5470              case 8:
5471                this._overlays[name] = {
5472                  element: element,
5473                  container: container,
5474                  callerCloseMethod: callerCloseMethod,
5475                  canForceClose: canForceClose
5476                };
5477
5478              case 9:
5479              case "end":
5480                return _context.stop();
5481            }
5482          }
5483        }, _callee, this);
5484      }));
5485
5486      function register(_x, _x2) {
5487        return _register.apply(this, arguments);
5488      }
5489
5490      return register;
5491    }()
5492  }, {
5493    key: "unregister",
5494    value: function () {
5495      var _unregister = _asyncToGenerator(
5496      /*#__PURE__*/
5497      _regenerator["default"].mark(function _callee2(name) {
5498        return _regenerator["default"].wrap(function _callee2$(_context2) {
5499          while (1) {
5500            switch (_context2.prev = _context2.next) {
5501              case 0:
5502                if (this._overlays[name]) {
5503                  _context2.next = 4;
5504                  break;
5505                }
5506
5507                throw new Error('The overlay does not exist.');
5508
5509              case 4:
5510                if (!(this._active === name)) {
5511                  _context2.next = 6;
5512                  break;
5513                }
5514
5515                throw new Error('The overlay cannot be removed while it is active.');
5516
5517              case 6:
5518                delete this._overlays[name];
5519
5520              case 7:
5521              case "end":
5522                return _context2.stop();
5523            }
5524          }
5525        }, _callee2, this);
5526      }));
5527
5528      function unregister(_x3) {
5529        return _unregister.apply(this, arguments);
5530      }
5531
5532      return unregister;
5533    }()
5534  }, {
5535    key: "open",
5536    value: function () {
5537      var _open = _asyncToGenerator(
5538      /*#__PURE__*/
5539      _regenerator["default"].mark(function _callee3(name) {
5540        return _regenerator["default"].wrap(function _callee3$(_context3) {
5541          while (1) {
5542            switch (_context3.prev = _context3.next) {
5543              case 0:
5544                if (this._overlays[name]) {
5545                  _context3.next = 4;
5546                  break;
5547                }
5548
5549                throw new Error('The overlay does not exist.');
5550
5551              case 4:
5552                if (!this._active) {
5553                  _context3.next = 14;
5554                  break;
5555                }
5556
5557                if (!this._overlays[name].canForceClose) {
5558                  _context3.next = 9;
5559                  break;
5560                }
5561
5562                this._closeThroughCaller();
5563
5564                _context3.next = 14;
5565                break;
5566
5567              case 9:
5568                if (!(this._active === name)) {
5569                  _context3.next = 13;
5570                  break;
5571                }
5572
5573                throw new Error('The overlay is already active.');
5574
5575              case 13:
5576                throw new Error('Another overlay is currently active.');
5577
5578              case 14:
5579                this._active = name;
5580
5581                this._overlays[this._active].element.classList.remove('hidden');
5582
5583                this._overlays[this._active].container.classList.remove('hidden');
5584
5585                window.addEventListener('keydown', this._keyDownBound);
5586
5587              case 18:
5588              case "end":
5589                return _context3.stop();
5590            }
5591          }
5592        }, _callee3, this);
5593      }));
5594
5595      function open(_x4) {
5596        return _open.apply(this, arguments);
5597      }
5598
5599      return open;
5600    }()
5601  }, {
5602    key: "close",
5603    value: function () {
5604      var _close = _asyncToGenerator(
5605      /*#__PURE__*/
5606      _regenerator["default"].mark(function _callee4(name) {
5607        return _regenerator["default"].wrap(function _callee4$(_context4) {
5608          while (1) {
5609            switch (_context4.prev = _context4.next) {
5610              case 0:
5611                if (this._overlays[name]) {
5612                  _context4.next = 4;
5613                  break;
5614                }
5615
5616                throw new Error('The overlay does not exist.');
5617
5618              case 4:
5619                if (this._active) {
5620                  _context4.next = 8;
5621                  break;
5622                }
5623
5624                throw new Error('The overlay is currently not active.');
5625
5626              case 8:
5627                if (!(this._active !== name)) {
5628                  _context4.next = 10;
5629                  break;
5630                }
5631
5632                throw new Error('Another overlay is currently active.');
5633
5634              case 10:
5635                this._overlays[this._active].container.classList.add('hidden');
5636
5637                this._overlays[this._active].element.classList.add('hidden');
5638
5639                this._active = null;
5640                window.removeEventListener('keydown', this._keyDownBound);
5641
5642              case 14:
5643              case "end":
5644                return _context4.stop();
5645            }
5646          }
5647        }, _callee4, this);
5648      }));
5649
5650      function close(_x5) {
5651        return _close.apply(this, arguments);
5652      }
5653
5654      return close;
5655    }()
5656  }, {
5657    key: "_keyDown",
5658    value: function _keyDown(evt) {
5659      if (this._active && evt.keyCode === 27) {
5660        this._closeThroughCaller();
5661
5662        evt.preventDefault();
5663      }
5664    }
5665  }, {
5666    key: "_closeThroughCaller",
5667    value: function _closeThroughCaller() {
5668      if (this._overlays[this._active].callerCloseMethod) {
5669        this._overlays[this._active].callerCloseMethod();
5670      }
5671
5672      if (this._active) {
5673        this.close(this._active);
5674      }
5675    }
5676  }, {
5677    key: "active",
5678    get: function get() {
5679      return this._active;
5680    }
5681  }]);
5682
5683  return OverlayManager;
5684}();
5685
5686exports.OverlayManager = OverlayManager;
5687
5688/***/ }),
5689/* 14 */
5690/***/ (function(module, exports, __webpack_require__) {
5691
5692"use strict";
5693
5694
5695Object.defineProperty(exports, "__esModule", {
5696  value: true
5697});
5698exports.PasswordPrompt = void 0;
5699
5700var _ui_utils = __webpack_require__(5);
5701
5702var _pdfjsLib = __webpack_require__(7);
5703
5704function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5705
5706function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5707
5708function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5709
5710var PasswordPrompt =
5711/*#__PURE__*/
5712function () {
5713  function PasswordPrompt(options, overlayManager) {
5714    var _this = this;
5715
5716    var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
5717
5718    _classCallCheck(this, PasswordPrompt);
5719
5720    this.overlayName = options.overlayName;
5721    this.container = options.container;
5722    this.label = options.label;
5723    this.input = options.input;
5724    this.submitButton = options.submitButton;
5725    this.cancelButton = options.cancelButton;
5726    this.overlayManager = overlayManager;
5727    this.l10n = l10n;
5728    this.updateCallback = null;
5729    this.reason = null;
5730    this.submitButton.addEventListener('click', this.verify.bind(this));
5731    this.cancelButton.addEventListener('click', this.close.bind(this));
5732    this.input.addEventListener('keydown', function (e) {
5733      if (e.keyCode === 13) {
5734        _this.verify();
5735      }
5736    });
5737    this.overlayManager.register(this.overlayName, this.container, this.close.bind(this), true);
5738  }
5739
5740  _createClass(PasswordPrompt, [{
5741    key: "open",
5742    value: function open() {
5743      var _this2 = this;
5744
5745      this.overlayManager.open(this.overlayName).then(function () {
5746        _this2.input.focus();
5747
5748        var promptString;
5749
5750        if (_this2.reason === _pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
5751          promptString = _this2.l10n.get('password_invalid', null, 'Invalid password. Please try again.');
5752        } else {
5753          promptString = _this2.l10n.get('password_label', null, 'Enter the password to open this PDF file.');
5754        }
5755
5756        promptString.then(function (msg) {
5757          _this2.label.textContent = msg;
5758        });
5759      });
5760    }
5761  }, {
5762    key: "close",
5763    value: function close() {
5764      var _this3 = this;
5765
5766      this.overlayManager.close(this.overlayName).then(function () {
5767        _this3.input.value = '';
5768      });
5769    }
5770  }, {
5771    key: "verify",
5772    value: function verify() {
5773      var password = this.input.value;
5774
5775      if (password && password.length > 0) {
5776        this.close();
5777        this.updateCallback(password);
5778      }
5779    }
5780  }, {
5781    key: "setUpdateCallback",
5782    value: function setUpdateCallback(updateCallback, reason) {
5783      this.updateCallback = updateCallback;
5784      this.reason = reason;
5785    }
5786  }]);
5787
5788  return PasswordPrompt;
5789}();
5790
5791exports.PasswordPrompt = PasswordPrompt;
5792
5793/***/ }),
5794/* 15 */
5795/***/ (function(module, exports, __webpack_require__) {
5796
5797"use strict";
5798
5799
5800Object.defineProperty(exports, "__esModule", {
5801  value: true
5802});
5803exports.PDFAttachmentViewer = void 0;
5804
5805var _pdfjsLib = __webpack_require__(7);
5806
5807function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5808
5809function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
5810
5811function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5812
5813var PDFAttachmentViewer =
5814/*#__PURE__*/
5815function () {
5816  function PDFAttachmentViewer(_ref) {
5817    var container = _ref.container,
5818        eventBus = _ref.eventBus,
5819        downloadManager = _ref.downloadManager;
5820
5821    _classCallCheck(this, PDFAttachmentViewer);
5822
5823    this.container = container;
5824    this.eventBus = eventBus;
5825    this.downloadManager = downloadManager;
5826    this.reset();
5827    this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this));
5828  }
5829
5830  _createClass(PDFAttachmentViewer, [{
5831    key: "reset",
5832    value: function reset() {
5833      var keepRenderedCapability = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
5834      this.attachments = null;
5835      this.container.textContent = '';
5836
5837      if (!keepRenderedCapability) {
5838        this._renderedCapability = (0, _pdfjsLib.createPromiseCapability)();
5839      }
5840    }
5841  }, {
5842    key: "_dispatchEvent",
5843    value: function _dispatchEvent(attachmentsCount) {
5844      this._renderedCapability.resolve();
5845
5846      this.eventBus.dispatch('attachmentsloaded', {
5847        source: this,
5848        attachmentsCount: attachmentsCount
5849      });
5850    }
5851  }, {
5852    key: "_bindPdfLink",
5853    value: function _bindPdfLink(button, content, filename) {
5854      if (this.downloadManager.disableCreateObjectURL) {
5855        throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
5856      }
5857
5858      var blobUrl;
5859
5860      button.onclick = function () {
5861        if (!blobUrl) {
5862          blobUrl = (0, _pdfjsLib.createObjectURL)(content, 'application/pdf');
5863        }
5864
5865        var viewerUrl;
5866        viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename);
5867        window.open(viewerUrl);
5868        return false;
5869      };
5870    }
5871  }, {
5872    key: "_bindLink",
5873    value: function _bindLink(button, content, filename) {
5874      var _this = this;
5875
5876      button.onclick = function () {
5877        _this.downloadManager.downloadData(content, filename, '');
5878
5879        return false;
5880      };
5881    }
5882  }, {
5883    key: "render",
5884    value: function render(_ref2) {
5885      var attachments = _ref2.attachments,
5886          _ref2$keepRenderedCap = _ref2.keepRenderedCapability,
5887          keepRenderedCapability = _ref2$keepRenderedCap === void 0 ? false : _ref2$keepRenderedCap;
5888      var attachmentsCount = 0;
5889
5890      if (this.attachments) {
5891        this.reset(keepRenderedCapability === true);
5892      }
5893
5894      this.attachments = attachments || null;
5895
5896      if (!attachments) {
5897        this._dispatchEvent(attachmentsCount);
5898
5899        return;
5900      }
5901
5902      var names = Object.keys(attachments).sort(function (a, b) {
5903        return a.toLowerCase().localeCompare(b.toLowerCase());
5904      });
5905      attachmentsCount = names.length;
5906
5907      for (var i = 0; i < attachmentsCount; i++) {
5908        var item = attachments[names[i]];
5909        var filename = (0, _pdfjsLib.removeNullCharacters)((0, _pdfjsLib.getFilenameFromUrl)(item.filename));
5910        var div = document.createElement('div');
5911        div.className = 'attachmentsItem';
5912        var button = document.createElement('button');
5913        button.textContent = filename;
5914
5915        if (/\.pdf$/i.test(filename) && !this.downloadManager.disableCreateObjectURL) {
5916          this._bindPdfLink(button, item.content, filename);
5917        } else {
5918          this._bindLink(button, item.content, filename);
5919        }
5920
5921        div.appendChild(button);
5922        this.container.appendChild(div);
5923      }
5924
5925      this._dispatchEvent(attachmentsCount);
5926    }
5927  }, {
5928    key: "_appendAttachment",
5929    value: function _appendAttachment(_ref3) {
5930      var _this2 = this;
5931
5932      var id = _ref3.id,
5933          filename = _ref3.filename,
5934          content = _ref3.content;
5935
5936      this._renderedCapability.promise.then(function () {
5937        var attachments = _this2.attachments;
5938
5939        if (!attachments) {
5940          attachments = Object.create(null);
5941        } else {
5942          for (var name in attachments) {
5943            if (id === name) {
5944              return;
5945            }
5946          }
5947        }
5948
5949        attachments[id] = {
5950          filename: filename,
5951          content: content
5952        };
5953
5954        _this2.render({
5955          attachments: attachments,
5956          keepRenderedCapability: true
5957        });
5958      });
5959    }
5960  }]);
5961
5962  return PDFAttachmentViewer;
5963}();
5964
5965exports.PDFAttachmentViewer = PDFAttachmentViewer;
5966
5967/***/ }),
5968/* 16 */
5969/***/ (function(module, exports, __webpack_require__) {
5970
5971"use strict";
5972
5973
5974Object.defineProperty(exports, "__esModule", {
5975  value: true
5976});
5977exports.PDFDocumentProperties = void 0;
5978
5979var _regenerator = _interopRequireDefault(__webpack_require__(2));
5980
5981var _pdfjsLib = __webpack_require__(7);
5982
5983var _ui_utils = __webpack_require__(5);
5984
5985function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
5986
5987function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5988
5989function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5990
5991function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
5992
5993function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
5994
5995function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
5996
5997function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5998
5999function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6000
6001function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6002
6003function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6004
6005var DEFAULT_FIELD_CONTENT = '-';
6006var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
6007var US_PAGE_NAMES = {
6008  '8.5x11': 'Letter',
6009  '8.5x14': 'Legal'
6010};
6011var METRIC_PAGE_NAMES = {
6012  '297x420': 'A3',
6013  '210x297': 'A4'
6014};
6015
6016function getPageName(size, isPortrait, pageNames) {
6017  var width = isPortrait ? size.width : size.height;
6018  var height = isPortrait ? size.height : size.width;
6019  return pageNames["".concat(width, "x").concat(height)];
6020}
6021
6022var PDFDocumentProperties =
6023/*#__PURE__*/
6024function () {
6025  function PDFDocumentProperties(_ref, overlayManager, eventBus) {
6026    var _this = this;
6027
6028    var overlayName = _ref.overlayName,
6029        fields = _ref.fields,
6030        container = _ref.container,
6031        closeButton = _ref.closeButton;
6032    var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
6033
6034    _classCallCheck(this, PDFDocumentProperties);
6035
6036    this.overlayName = overlayName;
6037    this.fields = fields;
6038    this.container = container;
6039    this.overlayManager = overlayManager;
6040    this.l10n = l10n;
6041
6042    this._reset();
6043
6044    if (closeButton) {
6045      closeButton.addEventListener('click', this.close.bind(this));
6046    }
6047
6048    this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
6049
6050    if (eventBus) {
6051      eventBus.on('pagechanging', function (evt) {
6052        _this._currentPageNumber = evt.pageNumber;
6053      });
6054      eventBus.on('rotationchanging', function (evt) {
6055        _this._pagesRotation = evt.pagesRotation;
6056      });
6057    }
6058
6059    this._isNonMetricLocale = true;
6060    l10n.getLanguage().then(function (locale) {
6061      _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
6062    });
6063  }
6064
6065  _createClass(PDFDocumentProperties, [{
6066    key: "open",
6067    value: function open() {
6068      var _this2 = this;
6069
6070      var freezeFieldData = function freezeFieldData(data) {
6071        Object.defineProperty(_this2, 'fieldData', {
6072          value: Object.freeze(data),
6073          writable: false,
6074          enumerable: true,
6075          configurable: true
6076        });
6077      };
6078
6079      Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
6080        var currentPageNumber = _this2._currentPageNumber;
6081        var pagesRotation = _this2._pagesRotation;
6082
6083        if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
6084          _this2._updateUI();
6085
6086          return;
6087        }
6088
6089        _this2.pdfDocument.getMetadata().then(function (_ref2) {
6090          var info = _ref2.info,
6091              metadata = _ref2.metadata,
6092              contentDispositionFilename = _ref2.contentDispositionFilename;
6093          return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url || ''), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
6094            return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
6095          }), _this2._parseLinearization(info.IsLinearized)]);
6096        }).then(function (_ref3) {
6097          var _ref4 = _slicedToArray(_ref3, 8),
6098              info = _ref4[0],
6099              metadata = _ref4[1],
6100              fileName = _ref4[2],
6101              fileSize = _ref4[3],
6102              creationDate = _ref4[4],
6103              modDate = _ref4[5],
6104              pageSize = _ref4[6],
6105              isLinearized = _ref4[7];
6106
6107          freezeFieldData({
6108            'fileName': fileName,
6109            'fileSize': fileSize,
6110            'title': info.Title,
6111            'author': info.Author,
6112            'subject': info.Subject,
6113            'keywords': info.Keywords,
6114            'creationDate': creationDate,
6115            'modificationDate': modDate,
6116            'creator': info.Creator,
6117            'producer': info.Producer,
6118            'version': info.PDFFormatVersion,
6119            'pageCount': _this2.pdfDocument.numPages,
6120            'pageSize': pageSize,
6121            'linearized': isLinearized,
6122            '_currentPageNumber': currentPageNumber,
6123            '_pagesRotation': pagesRotation
6124          });
6125
6126          _this2._updateUI();
6127
6128          return _this2.pdfDocument.getDownloadInfo();
6129        }).then(function (_ref5) {
6130          var length = _ref5.length;
6131          _this2.maybeFileSize = length;
6132          return _this2._parseFileSize(length);
6133        }).then(function (fileSize) {
6134          if (fileSize === _this2.fieldData['fileSize']) {
6135            return;
6136          }
6137
6138          var data = Object.assign(Object.create(null), _this2.fieldData);
6139          data['fileSize'] = fileSize;
6140          freezeFieldData(data);
6141
6142          _this2._updateUI();
6143        });
6144      });
6145    }
6146  }, {
6147    key: "close",
6148    value: function close() {
6149      this.overlayManager.close(this.overlayName);
6150    }
6151  }, {
6152    key: "setDocument",
6153    value: function setDocument(pdfDocument) {
6154      var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
6155
6156      if (this.pdfDocument) {
6157        this._reset();
6158
6159        this._updateUI(true);
6160      }
6161
6162      if (!pdfDocument) {
6163        return;
6164      }
6165
6166      this.pdfDocument = pdfDocument;
6167      this.url = url;
6168
6169      this._dataAvailableCapability.resolve();
6170    }
6171  }, {
6172    key: "setFileSize",
6173    value: function setFileSize(fileSize) {
6174      if (Number.isInteger(fileSize) && fileSize > 0) {
6175        this.maybeFileSize = fileSize;
6176      }
6177    }
6178  }, {
6179    key: "_reset",
6180    value: function _reset() {
6181      this.pdfDocument = null;
6182      this.url = null;
6183      this.maybeFileSize = 0;
6184      delete this.fieldData;
6185      this._dataAvailableCapability = (0, _pdfjsLib.createPromiseCapability)();
6186      this._currentPageNumber = 1;
6187      this._pagesRotation = 0;
6188    }
6189  }, {
6190    key: "_updateUI",
6191    value: function _updateUI() {
6192      var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
6193
6194      if (reset || !this.fieldData) {
6195        for (var id in this.fields) {
6196          this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
6197        }
6198
6199        return;
6200      }
6201
6202      if (this.overlayManager.active !== this.overlayName) {
6203        return;
6204      }
6205
6206      for (var _id in this.fields) {
6207        var content = this.fieldData[_id];
6208        this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
6209      }
6210    }
6211  }, {
6212    key: "_parseFileSize",
6213    value: function () {
6214      var _parseFileSize2 = _asyncToGenerator(
6215      /*#__PURE__*/
6216      _regenerator["default"].mark(function _callee() {
6217        var fileSize,
6218            kb,
6219            _args = arguments;
6220        return _regenerator["default"].wrap(function _callee$(_context) {
6221          while (1) {
6222            switch (_context.prev = _context.next) {
6223              case 0:
6224                fileSize = _args.length > 0 && _args[0] !== undefined ? _args[0] : 0;
6225                kb = fileSize / 1024;
6226
6227                if (kb) {
6228                  _context.next = 6;
6229                  break;
6230                }
6231
6232                return _context.abrupt("return", undefined);
6233
6234              case 6:
6235                if (!(kb < 1024)) {
6236                  _context.next = 8;
6237                  break;
6238                }
6239
6240                return _context.abrupt("return", this.l10n.get('document_properties_kb', {
6241                  size_kb: (+kb.toPrecision(3)).toLocaleString(),
6242                  size_b: fileSize.toLocaleString()
6243                }, '{{size_kb}} KB ({{size_b}} bytes)'));
6244
6245              case 8:
6246                return _context.abrupt("return", this.l10n.get('document_properties_mb', {
6247                  size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
6248                  size_b: fileSize.toLocaleString()
6249                }, '{{size_mb}} MB ({{size_b}} bytes)'));
6250
6251              case 9:
6252              case "end":
6253                return _context.stop();
6254            }
6255          }
6256        }, _callee, this);
6257      }));
6258
6259      function _parseFileSize() {
6260        return _parseFileSize2.apply(this, arguments);
6261      }
6262
6263      return _parseFileSize;
6264    }()
6265  }, {
6266    key: "_parsePageSize",
6267    value: function () {
6268      var _parsePageSize2 = _asyncToGenerator(
6269      /*#__PURE__*/
6270      _regenerator["default"].mark(function _callee2(pageSizeInches, pagesRotation) {
6271        var _this3 = this;
6272
6273        var isPortrait, sizeInches, sizeMillimeters, pageName, name, exactMillimeters, intMillimeters;
6274        return _regenerator["default"].wrap(function _callee2$(_context2) {
6275          while (1) {
6276            switch (_context2.prev = _context2.next) {
6277              case 0:
6278                if (pageSizeInches) {
6279                  _context2.next = 2;
6280                  break;
6281                }
6282
6283                return _context2.abrupt("return", undefined);
6284
6285              case 2:
6286                if (pagesRotation % 180 !== 0) {
6287                  pageSizeInches = {
6288                    width: pageSizeInches.height,
6289                    height: pageSizeInches.width
6290                  };
6291                }
6292
6293                isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
6294                sizeInches = {
6295                  width: Math.round(pageSizeInches.width * 100) / 100,
6296                  height: Math.round(pageSizeInches.height * 100) / 100
6297                };
6298                sizeMillimeters = {
6299                  width: Math.round(pageSizeInches.width * 25.4 * 10) / 10,
6300                  height: Math.round(pageSizeInches.height * 25.4 * 10) / 10
6301                };
6302                pageName = null;
6303                name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
6304
6305                if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
6306                  exactMillimeters = {
6307                    width: pageSizeInches.width * 25.4,
6308                    height: pageSizeInches.height * 25.4
6309                  };
6310                  intMillimeters = {
6311                    width: Math.round(sizeMillimeters.width),
6312                    height: Math.round(sizeMillimeters.height)
6313                  };
6314
6315                  if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
6316                    name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
6317
6318                    if (name) {
6319                      sizeInches = {
6320                        width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
6321                        height: Math.round(intMillimeters.height / 25.4 * 100) / 100
6322                      };
6323                      sizeMillimeters = intMillimeters;
6324                    }
6325                  }
6326                }
6327
6328                if (name) {
6329                  pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
6330                }
6331
6332                return _context2.abrupt("return", Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
6333                  var _ref7 = _slicedToArray(_ref6, 4),
6334                      _ref7$ = _ref7[0],
6335                      width = _ref7$.width,
6336                      height = _ref7$.height,
6337                      unit = _ref7[1],
6338                      name = _ref7[2],
6339                      orientation = _ref7[3];
6340
6341                  return _this3.l10n.get('document_properties_page_size_dimension_' + (name ? 'name_' : '') + 'string', {
6342                    width: width.toLocaleString(),
6343                    height: height.toLocaleString(),
6344                    unit: unit,
6345                    name: name,
6346                    orientation: orientation
6347                  }, '{{width}} × {{height}} {{unit}} (' + (name ? '{{name}}, ' : '') + '{{orientation}})');
6348                }));
6349
6350              case 11:
6351              case "end":
6352                return _context2.stop();
6353            }
6354          }
6355        }, _callee2, this);
6356      }));
6357
6358      function _parsePageSize(_x, _x2) {
6359        return _parsePageSize2.apply(this, arguments);
6360      }
6361
6362      return _parsePageSize;
6363    }()
6364  }, {
6365    key: "_parseDate",
6366    value: function () {
6367      var _parseDate2 = _asyncToGenerator(
6368      /*#__PURE__*/
6369      _regenerator["default"].mark(function _callee3(inputDate) {
6370        var dateObject;
6371        return _regenerator["default"].wrap(function _callee3$(_context3) {
6372          while (1) {
6373            switch (_context3.prev = _context3.next) {
6374              case 0:
6375                dateObject = _pdfjsLib.PDFDateString.toDateObject(inputDate);
6376
6377                if (dateObject) {
6378                  _context3.next = 3;
6379                  break;
6380                }
6381
6382                return _context3.abrupt("return", undefined);
6383
6384              case 3:
6385                return _context3.abrupt("return", this.l10n.get('document_properties_date_string', {
6386                  date: dateObject.toLocaleDateString(),
6387                  time: dateObject.toLocaleTimeString()
6388                }, '{{date}}, {{time}}'));
6389
6390              case 4:
6391              case "end":
6392                return _context3.stop();
6393            }
6394          }
6395        }, _callee3, this);
6396      }));
6397
6398      function _parseDate(_x3) {
6399        return _parseDate2.apply(this, arguments);
6400      }
6401
6402      return _parseDate;
6403    }()
6404  }, {
6405    key: "_parseLinearization",
6406    value: function _parseLinearization(isLinearized) {
6407      return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
6408    }
6409  }]);
6410
6411  return PDFDocumentProperties;
6412}();
6413
6414exports.PDFDocumentProperties = PDFDocumentProperties;
6415
6416/***/ }),
6417/* 17 */
6418/***/ (function(module, exports, __webpack_require__) {
6419
6420"use strict";
6421
6422
6423Object.defineProperty(exports, "__esModule", {
6424  value: true
6425});
6426exports.PDFFindBar = void 0;
6427
6428var _ui_utils = __webpack_require__(5);
6429
6430var _pdf_find_controller = __webpack_require__(18);
6431
6432function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6433
6434function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6435
6436function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6437
6438var MATCHES_COUNT_LIMIT = 1000;
6439
6440var PDFFindBar =
6441/*#__PURE__*/
6442function () {
6443  function PDFFindBar(options) {
6444    var _this = this;
6445
6446    var eventBus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _ui_utils.getGlobalEventBus)();
6447    var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
6448
6449    _classCallCheck(this, PDFFindBar);
6450
6451    this.opened = false;
6452    this.bar = options.bar || null;
6453    this.toggleButton = options.toggleButton || null;
6454    this.findField = options.findField || null;
6455    this.highlightAll = options.highlightAllCheckbox || null;
6456    this.caseSensitive = options.caseSensitiveCheckbox || null;
6457    this.entireWord = options.entireWordCheckbox || null;
6458    this.findMsg = options.findMsg || null;
6459    this.findResultsCount = options.findResultsCount || null;
6460    this.findPreviousButton = options.findPreviousButton || null;
6461    this.findNextButton = options.findNextButton || null;
6462    this.eventBus = eventBus;
6463    this.l10n = l10n;
6464    this.toggleButton.addEventListener('click', function () {
6465      _this.toggle();
6466    });
6467    this.findField.addEventListener('input', function () {
6468      _this.dispatchEvent('');
6469    });
6470    this.bar.addEventListener('keydown', function (e) {
6471      switch (e.keyCode) {
6472        case 13:
6473          if (e.target === _this.findField) {
6474            _this.dispatchEvent('again', e.shiftKey);
6475          }
6476
6477          break;
6478
6479        case 27:
6480          _this.close();
6481
6482          break;
6483      }
6484    });
6485    this.findPreviousButton.addEventListener('click', function () {
6486      _this.dispatchEvent('again', true);
6487    });
6488    this.findNextButton.addEventListener('click', function () {
6489      _this.dispatchEvent('again', false);
6490    });
6491    this.highlightAll.addEventListener('click', function () {
6492      _this.dispatchEvent('highlightallchange');
6493    });
6494    this.caseSensitive.addEventListener('click', function () {
6495      _this.dispatchEvent('casesensitivitychange');
6496    });
6497    this.entireWord.addEventListener('click', function () {
6498      _this.dispatchEvent('entirewordchange');
6499    });
6500    this.eventBus.on('resize', this._adjustWidth.bind(this));
6501  }
6502
6503  _createClass(PDFFindBar, [{
6504    key: "reset",
6505    value: function reset() {
6506      this.updateUIState();
6507    }
6508  }, {
6509    key: "dispatchEvent",
6510    value: function dispatchEvent(type, findPrev) {
6511      this.eventBus.dispatch('find', {
6512        source: this,
6513        type: type,
6514        query: this.findField.value,
6515        phraseSearch: true,
6516        caseSensitive: this.caseSensitive.checked,
6517        entireWord: this.entireWord.checked,
6518        highlightAll: this.highlightAll.checked,
6519        findPrevious: findPrev
6520      });
6521    }
6522  }, {
6523    key: "updateUIState",
6524    value: function updateUIState(state, previous, matchesCount) {
6525      var _this2 = this;
6526
6527      var notFound = false;
6528      var findMsg = '';
6529      var status = '';
6530
6531      switch (state) {
6532        case _pdf_find_controller.FindState.FOUND:
6533          break;
6534
6535        case _pdf_find_controller.FindState.PENDING:
6536          status = 'pending';
6537          break;
6538
6539        case _pdf_find_controller.FindState.NOT_FOUND:
6540          findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
6541          notFound = true;
6542          break;
6543
6544        case _pdf_find_controller.FindState.WRAPPED:
6545          if (previous) {
6546            findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
6547          } else {
6548            findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
6549          }
6550
6551          break;
6552      }
6553
6554      this.findField.classList.toggle('notFound', notFound);
6555      this.findField.setAttribute('data-status', status);
6556      Promise.resolve(findMsg).then(function (msg) {
6557        _this2.findMsg.textContent = msg;
6558
6559        _this2._adjustWidth();
6560      });
6561      this.updateResultsCount(matchesCount);
6562    }
6563  }, {
6564    key: "updateResultsCount",
6565    value: function updateResultsCount() {
6566      var _this3 = this;
6567
6568      var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
6569          _ref$current = _ref.current,
6570          current = _ref$current === void 0 ? 0 : _ref$current,
6571          _ref$total = _ref.total,
6572          total = _ref$total === void 0 ? 0 : _ref$total;
6573
6574      if (!this.findResultsCount) {
6575        return;
6576      }
6577
6578      var matchesCountMsg = '',
6579          limit = MATCHES_COUNT_LIMIT;
6580
6581      if (total > 0) {
6582        if (total > limit) {
6583          matchesCountMsg = this.l10n.get('find_match_count_limit', {
6584            limit: limit
6585          }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
6586        } else {
6587          matchesCountMsg = this.l10n.get('find_match_count', {
6588            current: current,
6589            total: total
6590          }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
6591        }
6592      }
6593
6594      Promise.resolve(matchesCountMsg).then(function (msg) {
6595        _this3.findResultsCount.textContent = msg;
6596
6597        _this3.findResultsCount.classList.toggle('hidden', !total);
6598
6599        _this3._adjustWidth();
6600      });
6601    }
6602  }, {
6603    key: "open",
6604    value: function open() {
6605      if (!this.opened) {
6606        this.opened = true;
6607        this.toggleButton.classList.add('toggled');
6608        this.bar.classList.remove('hidden');
6609      }
6610
6611      this.findField.select();
6612      this.findField.focus();
6613
6614      this._adjustWidth();
6615    }
6616  }, {
6617    key: "close",
6618    value: function close() {
6619      if (!this.opened) {
6620        return;
6621      }
6622
6623      this.opened = false;
6624      this.toggleButton.classList.remove('toggled');
6625      this.bar.classList.add('hidden');
6626      this.eventBus.dispatch('findbarclose', {
6627        source: this
6628      });
6629    }
6630  }, {
6631    key: "toggle",
6632    value: function toggle() {
6633      if (this.opened) {
6634        this.close();
6635      } else {
6636        this.open();
6637      }
6638    }
6639  }, {
6640    key: "_adjustWidth",
6641    value: function _adjustWidth() {
6642      if (!this.opened) {
6643        return;
6644      }
6645
6646      this.bar.classList.remove('wrapContainers');
6647      var findbarHeight = this.bar.clientHeight;
6648      var inputContainerHeight = this.bar.firstElementChild.clientHeight;
6649
6650      if (findbarHeight > inputContainerHeight) {
6651        this.bar.classList.add('wrapContainers');
6652      }
6653    }
6654  }]);
6655
6656  return PDFFindBar;
6657}();
6658
6659exports.PDFFindBar = PDFFindBar;
6660
6661/***/ }),
6662/* 18 */
6663/***/ (function(module, exports, __webpack_require__) {
6664
6665"use strict";
6666
6667
6668Object.defineProperty(exports, "__esModule", {
6669  value: true
6670});
6671exports.PDFFindController = exports.FindState = void 0;
6672
6673var _ui_utils = __webpack_require__(5);
6674
6675var _pdfjsLib = __webpack_require__(7);
6676
6677var _pdf_find_utils = __webpack_require__(19);
6678
6679function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6680
6681function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6682
6683function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6684
6685var FindState = {
6686  FOUND: 0,
6687  NOT_FOUND: 1,
6688  WRAPPED: 2,
6689  PENDING: 3
6690};
6691exports.FindState = FindState;
6692var FIND_TIMEOUT = 250;
6693var MATCH_SCROLL_OFFSET_TOP = -50;
6694var MATCH_SCROLL_OFFSET_LEFT = -400;
6695var CHARACTERS_TO_NORMALIZE = {
6696  "\u2018": '\'',
6697  "\u2019": '\'',
6698  "\u201A": '\'',
6699  "\u201B": '\'',
6700  "\u201C": '"',
6701  "\u201D": '"',
6702  "\u201E": '"',
6703  "\u201F": '"',
6704  "\xBC": '1/4',
6705  "\xBD": '1/2',
6706  "\xBE": '3/4'
6707};
6708var normalizationRegex = null;
6709
6710function normalize(text) {
6711  if (!normalizationRegex) {
6712    var replace = Object.keys(CHARACTERS_TO_NORMALIZE).join('');
6713    normalizationRegex = new RegExp("[".concat(replace, "]"), 'g');
6714  }
6715
6716  return text.replace(normalizationRegex, function (ch) {
6717    return CHARACTERS_TO_NORMALIZE[ch];
6718  });
6719}
6720
6721var PDFFindController =
6722/*#__PURE__*/
6723function () {
6724  function PDFFindController(_ref) {
6725    var linkService = _ref.linkService,
6726        _ref$eventBus = _ref.eventBus,
6727        eventBus = _ref$eventBus === void 0 ? (0, _ui_utils.getGlobalEventBus)() : _ref$eventBus;
6728
6729    _classCallCheck(this, PDFFindController);
6730
6731    this._linkService = linkService;
6732    this._eventBus = eventBus;
6733
6734    this._reset();
6735
6736    eventBus.on('findbarclose', this._onFindBarClose.bind(this));
6737  }
6738
6739  _createClass(PDFFindController, [{
6740    key: "setDocument",
6741    value: function setDocument(pdfDocument) {
6742      if (this._pdfDocument) {
6743        this._reset();
6744      }
6745
6746      if (!pdfDocument) {
6747        return;
6748      }
6749
6750      this._pdfDocument = pdfDocument;
6751
6752      this._firstPageCapability.resolve();
6753    }
6754  }, {
6755    key: "executeCommand",
6756    value: function executeCommand(cmd, state) {
6757      var _this = this;
6758
6759      if (!state) {
6760        return;
6761      }
6762
6763      var pdfDocument = this._pdfDocument;
6764
6765      if (this._state === null || this._shouldDirtyMatch(cmd, state)) {
6766        this._dirtyMatch = true;
6767      }
6768
6769      this._state = state;
6770
6771      if (cmd !== 'findhighlightallchange') {
6772        this._updateUIState(FindState.PENDING);
6773      }
6774
6775      this._firstPageCapability.promise.then(function () {
6776        if (!_this._pdfDocument || pdfDocument && _this._pdfDocument !== pdfDocument) {
6777          return;
6778        }
6779
6780        _this._extractText();
6781
6782        var findbarClosed = !_this._highlightMatches;
6783        var pendingTimeout = !!_this._findTimeout;
6784
6785        if (_this._findTimeout) {
6786          clearTimeout(_this._findTimeout);
6787          _this._findTimeout = null;
6788        }
6789
6790        if (cmd === 'find') {
6791          _this._findTimeout = setTimeout(function () {
6792            _this._nextMatch();
6793
6794            _this._findTimeout = null;
6795          }, FIND_TIMEOUT);
6796        } else if (_this._dirtyMatch) {
6797          _this._nextMatch();
6798        } else if (cmd === 'findagain') {
6799          _this._nextMatch();
6800
6801          if (findbarClosed && _this._state.highlightAll) {
6802            _this._updateAllPages();
6803          }
6804        } else if (cmd === 'findhighlightallchange') {
6805          if (pendingTimeout) {
6806            _this._nextMatch();
6807          } else {
6808            _this._highlightMatches = true;
6809          }
6810
6811          _this._updateAllPages();
6812        } else {
6813          _this._nextMatch();
6814        }
6815      });
6816    }
6817  }, {
6818    key: "scrollMatchIntoView",
6819    value: function scrollMatchIntoView(_ref2) {
6820      var _ref2$element = _ref2.element,
6821          element = _ref2$element === void 0 ? null : _ref2$element,
6822          _ref2$pageIndex = _ref2.pageIndex,
6823          pageIndex = _ref2$pageIndex === void 0 ? -1 : _ref2$pageIndex,
6824          _ref2$matchIndex = _ref2.matchIndex,
6825          matchIndex = _ref2$matchIndex === void 0 ? -1 : _ref2$matchIndex;
6826
6827      if (!this._scrollMatches || !element) {
6828        return;
6829      } else if (matchIndex === -1 || matchIndex !== this._selected.matchIdx) {
6830        return;
6831      } else if (pageIndex === -1 || pageIndex !== this._selected.pageIdx) {
6832        return;
6833      }
6834
6835      this._scrollMatches = false;
6836      var spot = {
6837        top: MATCH_SCROLL_OFFSET_TOP,
6838        left: MATCH_SCROLL_OFFSET_LEFT
6839      };
6840      (0, _ui_utils.scrollIntoView)(element, spot, true);
6841    }
6842  }, {
6843    key: "_reset",
6844    value: function _reset() {
6845      this._highlightMatches = false;
6846      this._scrollMatches = false;
6847      this._pdfDocument = null;
6848      this._pageMatches = [];
6849      this._pageMatchesLength = [];
6850      this._state = null;
6851      this._selected = {
6852        pageIdx: -1,
6853        matchIdx: -1
6854      };
6855      this._offset = {
6856        pageIdx: null,
6857        matchIdx: null,
6858        wrapped: false
6859      };
6860      this._extractTextPromises = [];
6861      this._pageContents = [];
6862      this._matchesCountTotal = 0;
6863      this._pagesToSearch = null;
6864      this._pendingFindMatches = Object.create(null);
6865      this._resumePageIdx = null;
6866      this._dirtyMatch = false;
6867      clearTimeout(this._findTimeout);
6868      this._findTimeout = null;
6869      this._firstPageCapability = (0, _pdfjsLib.createPromiseCapability)();
6870    }
6871  }, {
6872    key: "_shouldDirtyMatch",
6873    value: function _shouldDirtyMatch(cmd, state) {
6874      if (state.query !== this._state.query) {
6875        return true;
6876      }
6877
6878      switch (cmd) {
6879        case 'findagain':
6880          var pageNumber = this._selected.pageIdx + 1;
6881          var linkService = this._linkService;
6882
6883          if (pageNumber >= 1 && pageNumber <= linkService.pagesCount && pageNumber !== linkService.page && !linkService.isPageVisible(pageNumber)) {
6884            return true;
6885          }
6886
6887          return false;
6888
6889        case 'findhighlightallchange':
6890          return false;
6891      }
6892
6893      return true;
6894    }
6895  }, {
6896    key: "_prepareMatches",
6897    value: function _prepareMatches(matchesWithLength, matches, matchesLength) {
6898      function isSubTerm(matchesWithLength, currentIndex) {
6899        var currentElem = matchesWithLength[currentIndex];
6900        var nextElem = matchesWithLength[currentIndex + 1];
6901
6902        if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
6903          currentElem.skipped = true;
6904          return true;
6905        }
6906
6907        for (var i = currentIndex - 1; i >= 0; i--) {
6908          var prevElem = matchesWithLength[i];
6909
6910          if (prevElem.skipped) {
6911            continue;
6912          }
6913
6914          if (prevElem.match + prevElem.matchLength < currentElem.match) {
6915            break;
6916          }
6917
6918          if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
6919            currentElem.skipped = true;
6920            return true;
6921          }
6922        }
6923
6924        return false;
6925      }
6926
6927      matchesWithLength.sort(function (a, b) {
6928        return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
6929      });
6930
6931      for (var i = 0, len = matchesWithLength.length; i < len; i++) {
6932        if (isSubTerm(matchesWithLength, i)) {
6933          continue;
6934        }
6935
6936        matches.push(matchesWithLength[i].match);
6937        matchesLength.push(matchesWithLength[i].matchLength);
6938      }
6939    }
6940  }, {
6941    key: "_isEntireWord",
6942    value: function _isEntireWord(content, startIdx, length) {
6943      if (startIdx > 0) {
6944        var first = content.charCodeAt(startIdx);
6945        var limit = content.charCodeAt(startIdx - 1);
6946
6947        if ((0, _pdf_find_utils.getCharacterType)(first) === (0, _pdf_find_utils.getCharacterType)(limit)) {
6948          return false;
6949        }
6950      }
6951
6952      var endIdx = startIdx + length - 1;
6953
6954      if (endIdx < content.length - 1) {
6955        var last = content.charCodeAt(endIdx);
6956
6957        var _limit = content.charCodeAt(endIdx + 1);
6958
6959        if ((0, _pdf_find_utils.getCharacterType)(last) === (0, _pdf_find_utils.getCharacterType)(_limit)) {
6960          return false;
6961        }
6962      }
6963
6964      return true;
6965    }
6966  }, {
6967    key: "_calculatePhraseMatch",
6968    value: function _calculatePhraseMatch(query, pageIndex, pageContent, entireWord) {
6969      var matches = [];
6970      var queryLen = query.length;
6971      var matchIdx = -queryLen;
6972
6973      while (true) {
6974        matchIdx = pageContent.indexOf(query, matchIdx + queryLen);
6975
6976        if (matchIdx === -1) {
6977          break;
6978        }
6979
6980        if (entireWord && !this._isEntireWord(pageContent, matchIdx, queryLen)) {
6981          continue;
6982        }
6983
6984        matches.push(matchIdx);
6985      }
6986
6987      this._pageMatches[pageIndex] = matches;
6988    }
6989  }, {
6990    key: "_calculateWordMatch",
6991    value: function _calculateWordMatch(query, pageIndex, pageContent, entireWord) {
6992      var matchesWithLength = [];
6993      var queryArray = query.match(/\S+/g);
6994
6995      for (var i = 0, len = queryArray.length; i < len; i++) {
6996        var subquery = queryArray[i];
6997        var subqueryLen = subquery.length;
6998        var matchIdx = -subqueryLen;
6999
7000        while (true) {
7001          matchIdx = pageContent.indexOf(subquery, matchIdx + subqueryLen);
7002
7003          if (matchIdx === -1) {
7004            break;
7005          }
7006
7007          if (entireWord && !this._isEntireWord(pageContent, matchIdx, subqueryLen)) {
7008            continue;
7009          }
7010
7011          matchesWithLength.push({
7012            match: matchIdx,
7013            matchLength: subqueryLen,
7014            skipped: false
7015          });
7016        }
7017      }
7018
7019      this._pageMatchesLength[pageIndex] = [];
7020      this._pageMatches[pageIndex] = [];
7021
7022      this._prepareMatches(matchesWithLength, this._pageMatches[pageIndex], this._pageMatchesLength[pageIndex]);
7023    }
7024  }, {
7025    key: "_calculateMatch",
7026    value: function _calculateMatch(pageIndex) {
7027      var pageContent = this._pageContents[pageIndex];
7028      var query = this._query;
7029      var _this$_state = this._state,
7030          caseSensitive = _this$_state.caseSensitive,
7031          entireWord = _this$_state.entireWord,
7032          phraseSearch = _this$_state.phraseSearch;
7033
7034      if (query.length === 0) {
7035        return;
7036      }
7037
7038      if (!caseSensitive) {
7039        pageContent = pageContent.toLowerCase();
7040        query = query.toLowerCase();
7041      }
7042
7043      if (phraseSearch) {
7044        this._calculatePhraseMatch(query, pageIndex, pageContent, entireWord);
7045      } else {
7046        this._calculateWordMatch(query, pageIndex, pageContent, entireWord);
7047      }
7048
7049      if (this._state.highlightAll) {
7050        this._updatePage(pageIndex);
7051      }
7052
7053      if (this._resumePageIdx === pageIndex) {
7054        this._resumePageIdx = null;
7055
7056        this._nextPageMatch();
7057      }
7058
7059      var pageMatchesCount = this._pageMatches[pageIndex].length;
7060
7061      if (pageMatchesCount > 0) {
7062        this._matchesCountTotal += pageMatchesCount;
7063
7064        this._updateUIResultsCount();
7065      }
7066    }
7067  }, {
7068    key: "_extractText",
7069    value: function _extractText() {
7070      var _this2 = this;
7071
7072      if (this._extractTextPromises.length > 0) {
7073        return;
7074      }
7075
7076      var promise = Promise.resolve();
7077
7078      var _loop = function _loop(i, ii) {
7079        var extractTextCapability = (0, _pdfjsLib.createPromiseCapability)();
7080        _this2._extractTextPromises[i] = extractTextCapability.promise;
7081        promise = promise.then(function () {
7082          return _this2._pdfDocument.getPage(i + 1).then(function (pdfPage) {
7083            return pdfPage.getTextContent({
7084              normalizeWhitespace: true
7085            });
7086          }).then(function (textContent) {
7087            var textItems = textContent.items;
7088            var strBuf = [];
7089
7090            for (var j = 0, jj = textItems.length; j < jj; j++) {
7091              strBuf.push(textItems[j].str);
7092            }
7093
7094            _this2._pageContents[i] = normalize(strBuf.join(''));
7095            extractTextCapability.resolve(i);
7096          }, function (reason) {
7097            console.error("Unable to get text content for page ".concat(i + 1), reason);
7098            _this2._pageContents[i] = '';
7099            extractTextCapability.resolve(i);
7100          });
7101        });
7102      };
7103
7104      for (var i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
7105        _loop(i, ii);
7106      }
7107    }
7108  }, {
7109    key: "_updatePage",
7110    value: function _updatePage(index) {
7111      if (this._scrollMatches && this._selected.pageIdx === index) {
7112        this._linkService.page = index + 1;
7113      }
7114
7115      this._eventBus.dispatch('updatetextlayermatches', {
7116        source: this,
7117        pageIndex: index
7118      });
7119    }
7120  }, {
7121    key: "_updateAllPages",
7122    value: function _updateAllPages() {
7123      this._eventBus.dispatch('updatetextlayermatches', {
7124        source: this,
7125        pageIndex: -1
7126      });
7127    }
7128  }, {
7129    key: "_nextMatch",
7130    value: function _nextMatch() {
7131      var _this3 = this;
7132
7133      var previous = this._state.findPrevious;
7134      var currentPageIndex = this._linkService.page - 1;
7135      var numPages = this._linkService.pagesCount;
7136      this._highlightMatches = true;
7137
7138      if (this._dirtyMatch) {
7139        this._dirtyMatch = false;
7140        this._selected.pageIdx = this._selected.matchIdx = -1;
7141        this._offset.pageIdx = currentPageIndex;
7142        this._offset.matchIdx = null;
7143        this._offset.wrapped = false;
7144        this._resumePageIdx = null;
7145        this._pageMatches.length = 0;
7146        this._pageMatchesLength.length = 0;
7147        this._matchesCountTotal = 0;
7148
7149        this._updateAllPages();
7150
7151        for (var i = 0; i < numPages; i++) {
7152          if (this._pendingFindMatches[i] === true) {
7153            continue;
7154          }
7155
7156          this._pendingFindMatches[i] = true;
7157
7158          this._extractTextPromises[i].then(function (pageIdx) {
7159            delete _this3._pendingFindMatches[pageIdx];
7160
7161            _this3._calculateMatch(pageIdx);
7162          });
7163        }
7164      }
7165
7166      if (this._query === '') {
7167        this._updateUIState(FindState.FOUND);
7168
7169        return;
7170      }
7171
7172      if (this._resumePageIdx) {
7173        return;
7174      }
7175
7176      var offset = this._offset;
7177      this._pagesToSearch = numPages;
7178
7179      if (offset.matchIdx !== null) {
7180        var numPageMatches = this._pageMatches[offset.pageIdx].length;
7181
7182        if (!previous && offset.matchIdx + 1 < numPageMatches || previous && offset.matchIdx > 0) {
7183          offset.matchIdx = previous ? offset.matchIdx - 1 : offset.matchIdx + 1;
7184
7185          this._updateMatch(true);
7186
7187          return;
7188        }
7189
7190        this._advanceOffsetPage(previous);
7191      }
7192
7193      this._nextPageMatch();
7194    }
7195  }, {
7196    key: "_matchesReady",
7197    value: function _matchesReady(matches) {
7198      var offset = this._offset;
7199      var numMatches = matches.length;
7200      var previous = this._state.findPrevious;
7201
7202      if (numMatches) {
7203        offset.matchIdx = previous ? numMatches - 1 : 0;
7204
7205        this._updateMatch(true);
7206
7207        return true;
7208      }
7209
7210      this._advanceOffsetPage(previous);
7211
7212      if (offset.wrapped) {
7213        offset.matchIdx = null;
7214
7215        if (this._pagesToSearch < 0) {
7216          this._updateMatch(false);
7217
7218          return true;
7219        }
7220      }
7221
7222      return false;
7223    }
7224  }, {
7225    key: "_nextPageMatch",
7226    value: function _nextPageMatch() {
7227      if (this._resumePageIdx !== null) {
7228        console.error('There can only be one pending page.');
7229      }
7230
7231      var matches = null;
7232
7233      do {
7234        var pageIdx = this._offset.pageIdx;
7235        matches = this._pageMatches[pageIdx];
7236
7237        if (!matches) {
7238          this._resumePageIdx = pageIdx;
7239          break;
7240        }
7241      } while (!this._matchesReady(matches));
7242    }
7243  }, {
7244    key: "_advanceOffsetPage",
7245    value: function _advanceOffsetPage(previous) {
7246      var offset = this._offset;
7247      var numPages = this._linkService.pagesCount;
7248      offset.pageIdx = previous ? offset.pageIdx - 1 : offset.pageIdx + 1;
7249      offset.matchIdx = null;
7250      this._pagesToSearch--;
7251
7252      if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
7253        offset.pageIdx = previous ? numPages - 1 : 0;
7254        offset.wrapped = true;
7255      }
7256    }
7257  }, {
7258    key: "_updateMatch",
7259    value: function _updateMatch() {
7260      var found = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7261      var state = FindState.NOT_FOUND;
7262      var wrapped = this._offset.wrapped;
7263      this._offset.wrapped = false;
7264
7265      if (found) {
7266        var previousPage = this._selected.pageIdx;
7267        this._selected.pageIdx = this._offset.pageIdx;
7268        this._selected.matchIdx = this._offset.matchIdx;
7269        state = wrapped ? FindState.WRAPPED : FindState.FOUND;
7270
7271        if (previousPage !== -1 && previousPage !== this._selected.pageIdx) {
7272          this._updatePage(previousPage);
7273        }
7274      }
7275
7276      this._updateUIState(state, this._state.findPrevious);
7277
7278      if (this._selected.pageIdx !== -1) {
7279        this._scrollMatches = true;
7280
7281        this._updatePage(this._selected.pageIdx);
7282      }
7283    }
7284  }, {
7285    key: "_onFindBarClose",
7286    value: function _onFindBarClose(evt) {
7287      var _this4 = this;
7288
7289      var pdfDocument = this._pdfDocument;
7290
7291      this._firstPageCapability.promise.then(function () {
7292        if (!_this4._pdfDocument || pdfDocument && _this4._pdfDocument !== pdfDocument) {
7293          return;
7294        }
7295
7296        if (_this4._findTimeout) {
7297          clearTimeout(_this4._findTimeout);
7298          _this4._findTimeout = null;
7299        }
7300
7301        if (_this4._resumePageIdx) {
7302          _this4._resumePageIdx = null;
7303          _this4._dirtyMatch = true;
7304        }
7305
7306        _this4._updateUIState(FindState.FOUND);
7307
7308        _this4._highlightMatches = false;
7309
7310        _this4._updateAllPages();
7311      });
7312    }
7313  }, {
7314    key: "_requestMatchesCount",
7315    value: function _requestMatchesCount() {
7316      var _this$_selected = this._selected,
7317          pageIdx = _this$_selected.pageIdx,
7318          matchIdx = _this$_selected.matchIdx;
7319      var current = 0,
7320          total = this._matchesCountTotal;
7321
7322      if (matchIdx !== -1) {
7323        for (var i = 0; i < pageIdx; i++) {
7324          current += this._pageMatches[i] && this._pageMatches[i].length || 0;
7325        }
7326
7327        current += matchIdx + 1;
7328      }
7329
7330      if (current < 1 || current > total) {
7331        current = total = 0;
7332      }
7333
7334      return {
7335        current: current,
7336        total: total
7337      };
7338    }
7339  }, {
7340    key: "_updateUIResultsCount",
7341    value: function _updateUIResultsCount() {
7342      this._eventBus.dispatch('updatefindmatchescount', {
7343        source: this,
7344        matchesCount: this._requestMatchesCount()
7345      });
7346    }
7347  }, {
7348    key: "_updateUIState",
7349    value: function _updateUIState(state, previous) {
7350      this._eventBus.dispatch('updatefindcontrolstate', {
7351        source: this,
7352        state: state,
7353        previous: previous,
7354        matchesCount: this._requestMatchesCount()
7355      });
7356    }
7357  }, {
7358    key: "highlightMatches",
7359    get: function get() {
7360      return this._highlightMatches;
7361    }
7362  }, {
7363    key: "pageMatches",
7364    get: function get() {
7365      return this._pageMatches;
7366    }
7367  }, {
7368    key: "pageMatchesLength",
7369    get: function get() {
7370      return this._pageMatchesLength;
7371    }
7372  }, {
7373    key: "selected",
7374    get: function get() {
7375      return this._selected;
7376    }
7377  }, {
7378    key: "state",
7379    get: function get() {
7380      return this._state;
7381    }
7382  }, {
7383    key: "_query",
7384    get: function get() {
7385      if (this._state.query !== this._rawQuery) {
7386        this._rawQuery = this._state.query;
7387        this._normalizedQuery = normalize(this._state.query);
7388      }
7389
7390      return this._normalizedQuery;
7391    }
7392  }]);
7393
7394  return PDFFindController;
7395}();
7396
7397exports.PDFFindController = PDFFindController;
7398
7399/***/ }),
7400/* 19 */
7401/***/ (function(module, exports, __webpack_require__) {
7402
7403"use strict";
7404
7405
7406Object.defineProperty(exports, "__esModule", {
7407  value: true
7408});
7409exports.getCharacterType = getCharacterType;
7410exports.CharacterType = void 0;
7411var CharacterType = {
7412  SPACE: 0,
7413  ALPHA_LETTER: 1,
7414  PUNCT: 2,
7415  HAN_LETTER: 3,
7416  KATAKANA_LETTER: 4,
7417  HIRAGANA_LETTER: 5,
7418  HALFWIDTH_KATAKANA_LETTER: 6,
7419  THAI_LETTER: 7
7420};
7421exports.CharacterType = CharacterType;
7422
7423function isAlphabeticalScript(charCode) {
7424  return charCode < 0x2E80;
7425}
7426
7427function isAscii(charCode) {
7428  return (charCode & 0xFF80) === 0;
7429}
7430
7431function isAsciiAlpha(charCode) {
7432  return charCode >= 0x61 && charCode <= 0x7A || charCode >= 0x41 && charCode <= 0x5A;
7433}
7434
7435function isAsciiDigit(charCode) {
7436  return charCode >= 0x30 && charCode <= 0x39;
7437}
7438
7439function isAsciiSpace(charCode) {
7440  return charCode === 0x20 || charCode === 0x09 || charCode === 0x0D || charCode === 0x0A;
7441}
7442
7443function isHan(charCode) {
7444  return charCode >= 0x3400 && charCode <= 0x9FFF || charCode >= 0xF900 && charCode <= 0xFAFF;
7445}
7446
7447function isKatakana(charCode) {
7448  return charCode >= 0x30A0 && charCode <= 0x30FF;
7449}
7450
7451function isHiragana(charCode) {
7452  return charCode >= 0x3040 && charCode <= 0x309F;
7453}
7454
7455function isHalfwidthKatakana(charCode) {
7456  return charCode >= 0xFF60 && charCode <= 0xFF9F;
7457}
7458
7459function isThai(charCode) {
7460  return (charCode & 0xFF80) === 0x0E00;
7461}
7462
7463function getCharacterType(charCode) {
7464  if (isAlphabeticalScript(charCode)) {
7465    if (isAscii(charCode)) {
7466      if (isAsciiSpace(charCode)) {
7467        return CharacterType.SPACE;
7468      } else if (isAsciiAlpha(charCode) || isAsciiDigit(charCode) || charCode === 0x5F) {
7469        return CharacterType.ALPHA_LETTER;
7470      }
7471
7472      return CharacterType.PUNCT;
7473    } else if (isThai(charCode)) {
7474      return CharacterType.THAI_LETTER;
7475    } else if (charCode === 0xA0) {
7476      return CharacterType.SPACE;
7477    }
7478
7479    return CharacterType.ALPHA_LETTER;
7480  }
7481
7482  if (isHan(charCode)) {
7483    return CharacterType.HAN_LETTER;
7484  } else if (isKatakana(charCode)) {
7485    return CharacterType.KATAKANA_LETTER;
7486  } else if (isHiragana(charCode)) {
7487    return CharacterType.HIRAGANA_LETTER;
7488  } else if (isHalfwidthKatakana(charCode)) {
7489    return CharacterType.HALFWIDTH_KATAKANA_LETTER;
7490  }
7491
7492  return CharacterType.ALPHA_LETTER;
7493}
7494
7495/***/ }),
7496/* 20 */
7497/***/ (function(module, exports, __webpack_require__) {
7498
7499"use strict";
7500
7501
7502Object.defineProperty(exports, "__esModule", {
7503  value: true
7504});
7505exports.isDestHashesEqual = isDestHashesEqual;
7506exports.isDestArraysEqual = isDestArraysEqual;
7507exports.PDFHistory = void 0;
7508
7509var _ui_utils = __webpack_require__(5);
7510
7511function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
7512
7513function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
7514
7515function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
7516
7517function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
7518
7519function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7520
7521function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7522
7523function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
7524
7525function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
7526
7527var HASH_CHANGE_TIMEOUT = 1000;
7528var POSITION_UPDATED_THRESHOLD = 50;
7529var UPDATE_VIEWAREA_TIMEOUT = 1000;
7530
7531function getCurrentHash() {
7532  return document.location.hash;
7533}
7534
7535function parseCurrentHash(linkService) {
7536  var hash = unescape(getCurrentHash()).substring(1);
7537  var params = (0, _ui_utils.parseQueryString)(hash);
7538  var page = params.page | 0;
7539
7540  if (!(Number.isInteger(page) && page > 0 && page <= linkService.pagesCount)) {
7541    page = null;
7542  }
7543
7544  return {
7545    hash: hash,
7546    page: page,
7547    rotation: linkService.rotation
7548  };
7549}
7550
7551var PDFHistory =
7552/*#__PURE__*/
7553function () {
7554  function PDFHistory(_ref) {
7555    var _this = this;
7556
7557    var linkService = _ref.linkService,
7558        eventBus = _ref.eventBus;
7559
7560    _classCallCheck(this, PDFHistory);
7561
7562    this.linkService = linkService;
7563    this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
7564    this.initialized = false;
7565    this.initialBookmark = null;
7566    this.initialRotation = null;
7567    this._boundEvents = Object.create(null);
7568    this._isViewerInPresentationMode = false;
7569    this._isPagesLoaded = false;
7570    this.eventBus.on('presentationmodechanged', function (evt) {
7571      _this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
7572    });
7573    this.eventBus.on('pagesloaded', function (evt) {
7574      _this._isPagesLoaded = !!evt.pagesCount;
7575    });
7576  }
7577
7578  _createClass(PDFHistory, [{
7579    key: "initialize",
7580    value: function initialize(_ref2) {
7581      var fingerprint = _ref2.fingerprint,
7582          _ref2$resetHistory = _ref2.resetHistory,
7583          resetHistory = _ref2$resetHistory === void 0 ? false : _ref2$resetHistory,
7584          _ref2$updateUrl = _ref2.updateUrl,
7585          updateUrl = _ref2$updateUrl === void 0 ? false : _ref2$updateUrl;
7586
7587      if (!fingerprint || typeof fingerprint !== 'string') {
7588        console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');
7589        return;
7590      }
7591
7592      var reInitialized = this.initialized && this.fingerprint !== fingerprint;
7593      this.fingerprint = fingerprint;
7594      this._updateUrl = updateUrl === true;
7595
7596      if (!this.initialized) {
7597        this._bindEvents();
7598      }
7599
7600      var state = window.history.state;
7601      this.initialized = true;
7602      this.initialBookmark = null;
7603      this.initialRotation = null;
7604      this._popStateInProgress = false;
7605      this._blockHashChange = 0;
7606      this._currentHash = getCurrentHash();
7607      this._numPositionUpdates = 0;
7608      this._uid = this._maxUid = 0;
7609      this._destination = null;
7610      this._position = null;
7611
7612      if (!this._isValidState(state, true) || resetHistory) {
7613        var _parseCurrentHash = parseCurrentHash(this.linkService),
7614            hash = _parseCurrentHash.hash,
7615            page = _parseCurrentHash.page,
7616            rotation = _parseCurrentHash.rotation;
7617
7618        if (!hash || reInitialized || resetHistory) {
7619          this._pushOrReplaceState(null, true);
7620
7621          return;
7622        }
7623
7624        this._pushOrReplaceState({
7625          hash: hash,
7626          page: page,
7627          rotation: rotation
7628        }, true);
7629
7630        return;
7631      }
7632
7633      var destination = state.destination;
7634
7635      this._updateInternalState(destination, state.uid, true);
7636
7637      if (this._uid > this._maxUid) {
7638        this._maxUid = this._uid;
7639      }
7640
7641      if (destination.rotation !== undefined) {
7642        this.initialRotation = destination.rotation;
7643      }
7644
7645      if (destination.dest) {
7646        this.initialBookmark = JSON.stringify(destination.dest);
7647        this._destination.page = null;
7648      } else if (destination.hash) {
7649        this.initialBookmark = destination.hash;
7650      } else if (destination.page) {
7651        this.initialBookmark = "page=".concat(destination.page);
7652      }
7653    }
7654  }, {
7655    key: "push",
7656    value: function push(_ref3) {
7657      var _this2 = this;
7658
7659      var _ref3$namedDest = _ref3.namedDest,
7660          namedDest = _ref3$namedDest === void 0 ? null : _ref3$namedDest,
7661          explicitDest = _ref3.explicitDest,
7662          pageNumber = _ref3.pageNumber;
7663
7664      if (!this.initialized) {
7665        return;
7666      }
7667
7668      if (namedDest && typeof namedDest !== 'string') {
7669        console.error('PDFHistory.push: ' + "\"".concat(namedDest, "\" is not a valid namedDest parameter."));
7670        return;
7671      } else if (!Array.isArray(explicitDest)) {
7672        console.error('PDFHistory.push: ' + "\"".concat(explicitDest, "\" is not a valid explicitDest parameter."));
7673        return;
7674      } else if (!(Number.isInteger(pageNumber) && pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
7675        if (pageNumber !== null || this._destination) {
7676          console.error('PDFHistory.push: ' + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
7677          return;
7678        }
7679      }
7680
7681      var hash = namedDest || JSON.stringify(explicitDest);
7682
7683      if (!hash) {
7684        return;
7685      }
7686
7687      var forceReplace = false;
7688
7689      if (this._destination && (isDestHashesEqual(this._destination.hash, hash) || isDestArraysEqual(this._destination.dest, explicitDest))) {
7690        if (this._destination.page) {
7691          return;
7692        }
7693
7694        forceReplace = true;
7695      }
7696
7697      if (this._popStateInProgress && !forceReplace) {
7698        return;
7699      }
7700
7701      this._pushOrReplaceState({
7702        dest: explicitDest,
7703        hash: hash,
7704        page: pageNumber,
7705        rotation: this.linkService.rotation
7706      }, forceReplace);
7707
7708      if (!this._popStateInProgress) {
7709        this._popStateInProgress = true;
7710        Promise.resolve().then(function () {
7711          _this2._popStateInProgress = false;
7712        });
7713      }
7714    }
7715  }, {
7716    key: "pushCurrentPosition",
7717    value: function pushCurrentPosition() {
7718      if (!this.initialized || this._popStateInProgress) {
7719        return;
7720      }
7721
7722      this._tryPushCurrentPosition();
7723    }
7724  }, {
7725    key: "back",
7726    value: function back() {
7727      if (!this.initialized || this._popStateInProgress) {
7728        return;
7729      }
7730
7731      var state = window.history.state;
7732
7733      if (this._isValidState(state) && state.uid > 0) {
7734        window.history.back();
7735      }
7736    }
7737  }, {
7738    key: "forward",
7739    value: function forward() {
7740      if (!this.initialized || this._popStateInProgress) {
7741        return;
7742      }
7743
7744      var state = window.history.state;
7745
7746      if (this._isValidState(state) && state.uid < this._maxUid) {
7747        window.history.forward();
7748      }
7749    }
7750  }, {
7751    key: "_pushOrReplaceState",
7752    value: function _pushOrReplaceState(destination) {
7753      var forceReplace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7754      var shouldReplace = forceReplace || !this._destination;
7755      var newState = {
7756        fingerprint: this.fingerprint,
7757        uid: shouldReplace ? this._uid : this._uid + 1,
7758        destination: destination
7759      };
7760
7761      this._updateInternalState(destination, newState.uid);
7762
7763      var newUrl;
7764
7765      if (this._updateUrl && destination && destination.hash) {
7766        var baseUrl = document.location.href.split('#')[0];
7767
7768        if (!baseUrl.startsWith('file://')) {
7769          newUrl = "".concat(baseUrl, "#").concat(destination.hash);
7770        }
7771      }
7772
7773      if (shouldReplace) {
7774        if (newUrl) {
7775          window.history.replaceState(newState, '', newUrl);
7776        } else {
7777          window.history.replaceState(newState, '');
7778        }
7779      } else {
7780        this._maxUid = this._uid;
7781
7782        if (newUrl) {
7783          window.history.pushState(newState, '', newUrl);
7784        } else {
7785          window.history.pushState(newState, '');
7786        }
7787      }
7788    }
7789  }, {
7790    key: "_tryPushCurrentPosition",
7791    value: function _tryPushCurrentPosition() {
7792      var temporary = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
7793
7794      if (!this._position) {
7795        return;
7796      }
7797
7798      var position = this._position;
7799
7800      if (temporary) {
7801        position = Object.assign(Object.create(null), this._position);
7802        position.temporary = true;
7803      }
7804
7805      if (!this._destination) {
7806        this._pushOrReplaceState(position);
7807
7808        return;
7809      }
7810
7811      if (this._destination.temporary) {
7812        this._pushOrReplaceState(position, true);
7813
7814        return;
7815      }
7816
7817      if (this._destination.hash === position.hash) {
7818        return;
7819      }
7820
7821      if (!this._destination.page && (POSITION_UPDATED_THRESHOLD <= 0 || this._numPositionUpdates <= POSITION_UPDATED_THRESHOLD)) {
7822        return;
7823      }
7824
7825      var forceReplace = false;
7826
7827      if (this._destination.page >= position.first && this._destination.page <= position.page) {
7828        if (this._destination.dest || !this._destination.first) {
7829          return;
7830        }
7831
7832        forceReplace = true;
7833      }
7834
7835      this._pushOrReplaceState(position, forceReplace);
7836    }
7837  }, {
7838    key: "_isValidState",
7839    value: function _isValidState(state) {
7840      var checkReload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7841
7842      if (!state) {
7843        return false;
7844      }
7845
7846      if (state.fingerprint !== this.fingerprint) {
7847        if (checkReload) {
7848          if (typeof state.fingerprint !== 'string' || state.fingerprint.length !== this.fingerprint.length) {
7849            return false;
7850          }
7851
7852          var _performance$getEntri = performance.getEntriesByType('navigation'),
7853              _performance$getEntri2 = _slicedToArray(_performance$getEntri, 1),
7854              perfEntry = _performance$getEntri2[0];
7855
7856          if (!perfEntry || perfEntry.type !== 'reload') {
7857            return false;
7858          }
7859        } else {
7860          return false;
7861        }
7862      }
7863
7864      if (!Number.isInteger(state.uid) || state.uid < 0) {
7865        return false;
7866      }
7867
7868      if (state.destination === null || _typeof(state.destination) !== 'object') {
7869        return false;
7870      }
7871
7872      return true;
7873    }
7874  }, {
7875    key: "_updateInternalState",
7876    value: function _updateInternalState(destination, uid) {
7877      var removeTemporary = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
7878
7879      if (this._updateViewareaTimeout) {
7880        clearTimeout(this._updateViewareaTimeout);
7881        this._updateViewareaTimeout = null;
7882      }
7883
7884      if (removeTemporary && destination && destination.temporary) {
7885        delete destination.temporary;
7886      }
7887
7888      this._destination = destination;
7889      this._uid = uid;
7890      this._numPositionUpdates = 0;
7891    }
7892  }, {
7893    key: "_updateViewarea",
7894    value: function _updateViewarea(_ref4) {
7895      var _this3 = this;
7896
7897      var location = _ref4.location;
7898
7899      if (this._updateViewareaTimeout) {
7900        clearTimeout(this._updateViewareaTimeout);
7901        this._updateViewareaTimeout = null;
7902      }
7903
7904      this._position = {
7905        hash: this._isViewerInPresentationMode ? "page=".concat(location.pageNumber) : location.pdfOpenParams.substring(1),
7906        page: this.linkService.page,
7907        first: location.pageNumber,
7908        rotation: location.rotation
7909      };
7910
7911      if (this._popStateInProgress) {
7912        return;
7913      }
7914
7915      if (POSITION_UPDATED_THRESHOLD > 0 && this._isPagesLoaded && this._destination && !this._destination.page) {
7916        this._numPositionUpdates++;
7917      }
7918
7919      if (UPDATE_VIEWAREA_TIMEOUT > 0) {
7920        this._updateViewareaTimeout = setTimeout(function () {
7921          if (!_this3._popStateInProgress) {
7922            _this3._tryPushCurrentPosition(true);
7923          }
7924
7925          _this3._updateViewareaTimeout = null;
7926        }, UPDATE_VIEWAREA_TIMEOUT);
7927      }
7928    }
7929  }, {
7930    key: "_popState",
7931    value: function _popState(_ref5) {
7932      var _this4 = this;
7933
7934      var state = _ref5.state;
7935      var newHash = getCurrentHash(),
7936          hashChanged = this._currentHash !== newHash;
7937      this._currentHash = newHash;
7938
7939      if (!state || false) {
7940        this._uid++;
7941
7942        var _parseCurrentHash2 = parseCurrentHash(this.linkService),
7943            hash = _parseCurrentHash2.hash,
7944            page = _parseCurrentHash2.page,
7945            rotation = _parseCurrentHash2.rotation;
7946
7947        this._pushOrReplaceState({
7948          hash: hash,
7949          page: page,
7950          rotation: rotation
7951        }, true);
7952
7953        return;
7954      }
7955
7956      if (!this._isValidState(state)) {
7957        return;
7958      }
7959
7960      this._popStateInProgress = true;
7961
7962      if (hashChanged) {
7963        this._blockHashChange++;
7964        (0, _ui_utils.waitOnEventOrTimeout)({
7965          target: window,
7966          name: 'hashchange',
7967          delay: HASH_CHANGE_TIMEOUT
7968        }).then(function () {
7969          _this4._blockHashChange--;
7970        });
7971      }
7972
7973      var destination = state.destination;
7974
7975      this._updateInternalState(destination, state.uid, true);
7976
7977      if (this._uid > this._maxUid) {
7978        this._maxUid = this._uid;
7979      }
7980
7981      if ((0, _ui_utils.isValidRotation)(destination.rotation)) {
7982        this.linkService.rotation = destination.rotation;
7983      }
7984
7985      if (destination.dest) {
7986        this.linkService.navigateTo(destination.dest);
7987      } else if (destination.hash) {
7988        this.linkService.setHash(destination.hash);
7989      } else if (destination.page) {
7990        this.linkService.page = destination.page;
7991      }
7992
7993      Promise.resolve().then(function () {
7994        _this4._popStateInProgress = false;
7995      });
7996    }
7997  }, {
7998    key: "_bindEvents",
7999    value: function _bindEvents() {
8000      var _this5 = this;
8001
8002      var _boundEvents = this._boundEvents,
8003          eventBus = this.eventBus;
8004      _boundEvents.updateViewarea = this._updateViewarea.bind(this);
8005      _boundEvents.popState = this._popState.bind(this);
8006
8007      _boundEvents.pageHide = function (evt) {
8008        if (!_this5._destination || _this5._destination.temporary) {
8009          _this5._tryPushCurrentPosition();
8010        }
8011      };
8012
8013      eventBus.on('updateviewarea', _boundEvents.updateViewarea);
8014      window.addEventListener('popstate', _boundEvents.popState);
8015      window.addEventListener('pagehide', _boundEvents.pageHide);
8016    }
8017  }, {
8018    key: "popStateInProgress",
8019    get: function get() {
8020      return this.initialized && (this._popStateInProgress || this._blockHashChange > 0);
8021    }
8022  }]);
8023
8024  return PDFHistory;
8025}();
8026
8027exports.PDFHistory = PDFHistory;
8028
8029function isDestHashesEqual(destHash, pushHash) {
8030  if (typeof destHash !== 'string' || typeof pushHash !== 'string') {
8031    return false;
8032  }
8033
8034  if (destHash === pushHash) {
8035    return true;
8036  }
8037
8038  var _parseQueryString = (0, _ui_utils.parseQueryString)(destHash),
8039      nameddest = _parseQueryString.nameddest;
8040
8041  if (nameddest === pushHash) {
8042    return true;
8043  }
8044
8045  return false;
8046}
8047
8048function isDestArraysEqual(firstDest, secondDest) {
8049  function isEntryEqual(first, second) {
8050    if (_typeof(first) !== _typeof(second)) {
8051      return false;
8052    }
8053
8054    if (Array.isArray(first) || Array.isArray(second)) {
8055      return false;
8056    }
8057
8058    if (first !== null && _typeof(first) === 'object' && second !== null) {
8059      if (Object.keys(first).length !== Object.keys(second).length) {
8060        return false;
8061      }
8062
8063      for (var key in first) {
8064        if (!isEntryEqual(first[key], second[key])) {
8065          return false;
8066        }
8067      }
8068
8069      return true;
8070    }
8071
8072    return first === second || Number.isNaN(first) && Number.isNaN(second);
8073  }
8074
8075  if (!(Array.isArray(firstDest) && Array.isArray(secondDest))) {
8076    return false;
8077  }
8078
8079  if (firstDest.length !== secondDest.length) {
8080    return false;
8081  }
8082
8083  for (var i = 0, ii = firstDest.length; i < ii; i++) {
8084    if (!isEntryEqual(firstDest[i], secondDest[i])) {
8085      return false;
8086    }
8087  }
8088
8089  return true;
8090}
8091
8092/***/ }),
8093/* 21 */
8094/***/ (function(module, exports, __webpack_require__) {
8095
8096"use strict";
8097
8098
8099Object.defineProperty(exports, "__esModule", {
8100  value: true
8101});
8102exports.SimpleLinkService = exports.PDFLinkService = void 0;
8103
8104var _ui_utils = __webpack_require__(5);
8105
8106function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
8107
8108function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8109
8110function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8111
8112function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8113
8114var PDFLinkService =
8115/*#__PURE__*/
8116function () {
8117  function PDFLinkService() {
8118    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
8119        eventBus = _ref.eventBus,
8120        _ref$externalLinkTarg = _ref.externalLinkTarget,
8121        externalLinkTarget = _ref$externalLinkTarg === void 0 ? null : _ref$externalLinkTarg,
8122        _ref$externalLinkRel = _ref.externalLinkRel,
8123        externalLinkRel = _ref$externalLinkRel === void 0 ? null : _ref$externalLinkRel;
8124
8125    _classCallCheck(this, PDFLinkService);
8126
8127    this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
8128    this.externalLinkTarget = externalLinkTarget;
8129    this.externalLinkRel = externalLinkRel;
8130    this.baseUrl = null;
8131    this.pdfDocument = null;
8132    this.pdfViewer = null;
8133    this.pdfHistory = null;
8134    this._pagesRefCache = null;
8135  }
8136
8137  _createClass(PDFLinkService, [{
8138    key: "setDocument",
8139    value: function setDocument(pdfDocument) {
8140      var baseUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
8141      this.baseUrl = baseUrl;
8142      this.pdfDocument = pdfDocument;
8143      this._pagesRefCache = Object.create(null);
8144    }
8145  }, {
8146    key: "setViewer",
8147    value: function setViewer(pdfViewer) {
8148      this.pdfViewer = pdfViewer;
8149    }
8150  }, {
8151    key: "setHistory",
8152    value: function setHistory(pdfHistory) {
8153      this.pdfHistory = pdfHistory;
8154    }
8155  }, {
8156    key: "navigateTo",
8157    value: function navigateTo(dest) {
8158      var _this = this;
8159
8160      var goToDestination = function goToDestination(_ref2) {
8161        var namedDest = _ref2.namedDest,
8162            explicitDest = _ref2.explicitDest;
8163        var destRef = explicitDest[0],
8164            pageNumber;
8165
8166        if (destRef instanceof Object) {
8167          pageNumber = _this._cachedPageNumber(destRef);
8168
8169          if (pageNumber === null) {
8170            _this.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
8171              _this.cachePageRef(pageIndex + 1, destRef);
8172
8173              goToDestination({
8174                namedDest: namedDest,
8175                explicitDest: explicitDest
8176              });
8177            })["catch"](function () {
8178              console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid page reference, for dest=\"".concat(dest, "\"."));
8179            });
8180
8181            return;
8182          }
8183        } else if (Number.isInteger(destRef)) {
8184          pageNumber = destRef + 1;
8185        } else {
8186          console.error("PDFLinkService.navigateTo: \"".concat(destRef, "\" is not ") + "a valid destination reference, for dest=\"".concat(dest, "\"."));
8187          return;
8188        }
8189
8190        if (!pageNumber || pageNumber < 1 || pageNumber > _this.pagesCount) {
8191          console.error("PDFLinkService.navigateTo: \"".concat(pageNumber, "\" is not ") + "a valid page number, for dest=\"".concat(dest, "\"."));
8192          return;
8193        }
8194
8195        if (_this.pdfHistory) {
8196          _this.pdfHistory.pushCurrentPosition();
8197
8198          _this.pdfHistory.push({
8199            namedDest: namedDest,
8200            explicitDest: explicitDest,
8201            pageNumber: pageNumber
8202          });
8203        }
8204
8205        _this.pdfViewer.scrollPageIntoView({
8206          pageNumber: pageNumber,
8207          destArray: explicitDest
8208        });
8209      };
8210
8211      new Promise(function (resolve, reject) {
8212        if (typeof dest === 'string') {
8213          _this.pdfDocument.getDestination(dest).then(function (destArray) {
8214            resolve({
8215              namedDest: dest,
8216              explicitDest: destArray
8217            });
8218          });
8219
8220          return;
8221        }
8222
8223        resolve({
8224          namedDest: '',
8225          explicitDest: dest
8226        });
8227      }).then(function (data) {
8228        if (!Array.isArray(data.explicitDest)) {
8229          console.error("PDFLinkService.navigateTo: \"".concat(data.explicitDest, "\" is") + " not a valid destination array, for dest=\"".concat(dest, "\"."));
8230          return;
8231        }
8232
8233        goToDestination(data);
8234      });
8235    }
8236  }, {
8237    key: "getDestinationHash",
8238    value: function getDestinationHash(dest) {
8239      if (typeof dest === 'string') {
8240        return this.getAnchorUrl('#' + escape(dest));
8241      }
8242
8243      if (Array.isArray(dest)) {
8244        var str = JSON.stringify(dest);
8245        return this.getAnchorUrl('#' + escape(str));
8246      }
8247
8248      return this.getAnchorUrl('');
8249    }
8250  }, {
8251    key: "getAnchorUrl",
8252    value: function getAnchorUrl(anchor) {
8253      return (this.baseUrl || '') + anchor;
8254    }
8255  }, {
8256    key: "setHash",
8257    value: function setHash(hash) {
8258      var pageNumber, dest;
8259
8260      if (hash.includes('=')) {
8261        var params = (0, _ui_utils.parseQueryString)(hash);
8262
8263        if ('search' in params) {
8264          this.eventBus.dispatch('findfromurlhash', {
8265            source: this,
8266            query: params['search'].replace(/"/g, ''),
8267            phraseSearch: params['phrase'] === 'true'
8268          });
8269        }
8270
8271        if ('nameddest' in params) {
8272          this.navigateTo(params.nameddest);
8273          return;
8274        }
8275
8276        if ('page' in params) {
8277          pageNumber = params.page | 0 || 1;
8278        }
8279
8280        if ('zoom' in params) {
8281          var zoomArgs = params.zoom.split(',');
8282          var zoomArg = zoomArgs[0];
8283          var zoomArgNumber = parseFloat(zoomArg);
8284
8285          if (!zoomArg.includes('Fit')) {
8286            dest = [null, {
8287              name: 'XYZ'
8288            }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null, zoomArgs.length > 2 ? zoomArgs[2] | 0 : null, zoomArgNumber ? zoomArgNumber / 100 : zoomArg];
8289          } else {
8290            if (zoomArg === 'Fit' || zoomArg === 'FitB') {
8291              dest = [null, {
8292                name: zoomArg
8293              }];
8294            } else if (zoomArg === 'FitH' || zoomArg === 'FitBH' || zoomArg === 'FitV' || zoomArg === 'FitBV') {
8295              dest = [null, {
8296                name: zoomArg
8297              }, zoomArgs.length > 1 ? zoomArgs[1] | 0 : null];
8298            } else if (zoomArg === 'FitR') {
8299              if (zoomArgs.length !== 5) {
8300                console.error('PDFLinkService.setHash: Not enough parameters for "FitR".');
8301              } else {
8302                dest = [null, {
8303                  name: zoomArg
8304                }, zoomArgs[1] | 0, zoomArgs[2] | 0, zoomArgs[3] | 0, zoomArgs[4] | 0];
8305              }
8306            } else {
8307              console.error("PDFLinkService.setHash: \"".concat(zoomArg, "\" is not ") + 'a valid zoom value.');
8308            }
8309          }
8310        }
8311
8312        if (dest) {
8313          this.pdfViewer.scrollPageIntoView({
8314            pageNumber: pageNumber || this.page,
8315            destArray: dest,
8316            allowNegativeOffset: true
8317          });
8318        } else if (pageNumber) {
8319          this.page = pageNumber;
8320        }
8321
8322        if ('pagemode' in params) {
8323          this.eventBus.dispatch('pagemode', {
8324            source: this,
8325            mode: params.pagemode
8326          });
8327        }
8328      } else {
8329        dest = unescape(hash);
8330
8331        try {
8332          dest = JSON.parse(dest);
8333
8334          if (!Array.isArray(dest)) {
8335            dest = dest.toString();
8336          }
8337        } catch (ex) {}
8338
8339        if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
8340          this.navigateTo(dest);
8341          return;
8342        }
8343
8344        console.error("PDFLinkService.setHash: \"".concat(unescape(hash), "\" is not ") + 'a valid destination.');
8345      }
8346    }
8347  }, {
8348    key: "executeNamedAction",
8349    value: function executeNamedAction(action) {
8350      switch (action) {
8351        case 'GoBack':
8352          if (this.pdfHistory) {
8353            this.pdfHistory.back();
8354          }
8355
8356          break;
8357
8358        case 'GoForward':
8359          if (this.pdfHistory) {
8360            this.pdfHistory.forward();
8361          }
8362
8363          break;
8364
8365        case 'NextPage':
8366          if (this.page < this.pagesCount) {
8367            this.page++;
8368          }
8369
8370          break;
8371
8372        case 'PrevPage':
8373          if (this.page > 1) {
8374            this.page--;
8375          }
8376
8377          break;
8378
8379        case 'LastPage':
8380          this.page = this.pagesCount;
8381          break;
8382
8383        case 'FirstPage':
8384          this.page = 1;
8385          break;
8386
8387        default:
8388          break;
8389      }
8390
8391      this.eventBus.dispatch('namedaction', {
8392        source: this,
8393        action: action
8394      });
8395    }
8396  }, {
8397    key: "cachePageRef",
8398    value: function cachePageRef(pageNum, pageRef) {
8399      if (!pageRef) {
8400        return;
8401      }
8402
8403      var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
8404      this._pagesRefCache[refStr] = pageNum;
8405    }
8406  }, {
8407    key: "_cachedPageNumber",
8408    value: function _cachedPageNumber(pageRef) {
8409      var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
8410      return this._pagesRefCache && this._pagesRefCache[refStr] || null;
8411    }
8412  }, {
8413    key: "isPageVisible",
8414    value: function isPageVisible(pageNumber) {
8415      return this.pdfViewer.isPageVisible(pageNumber);
8416    }
8417  }, {
8418    key: "pagesCount",
8419    get: function get() {
8420      return this.pdfDocument ? this.pdfDocument.numPages : 0;
8421    }
8422  }, {
8423    key: "page",
8424    get: function get() {
8425      return this.pdfViewer.currentPageNumber;
8426    },
8427    set: function set(value) {
8428      this.pdfViewer.currentPageNumber = value;
8429    }
8430  }, {
8431    key: "rotation",
8432    get: function get() {
8433      return this.pdfViewer.pagesRotation;
8434    },
8435    set: function set(value) {
8436      this.pdfViewer.pagesRotation = value;
8437    }
8438  }]);
8439
8440  return PDFLinkService;
8441}();
8442
8443exports.PDFLinkService = PDFLinkService;
8444
8445function isValidExplicitDestination(dest) {
8446  if (!Array.isArray(dest)) {
8447    return false;
8448  }
8449
8450  var destLength = dest.length,
8451      allowNull = true;
8452
8453  if (destLength < 2) {
8454    return false;
8455  }
8456
8457  var page = dest[0];
8458
8459  if (!(_typeof(page) === 'object' && Number.isInteger(page.num) && Number.isInteger(page.gen)) && !(Number.isInteger(page) && page >= 0)) {
8460    return false;
8461  }
8462
8463  var zoom = dest[1];
8464
8465  if (!(_typeof(zoom) === 'object' && typeof zoom.name === 'string')) {
8466    return false;
8467  }
8468
8469  switch (zoom.name) {
8470    case 'XYZ':
8471      if (destLength !== 5) {
8472        return false;
8473      }
8474
8475      break;
8476
8477    case 'Fit':
8478    case 'FitB':
8479      return destLength === 2;
8480
8481    case 'FitH':
8482    case 'FitBH':
8483    case 'FitV':
8484    case 'FitBV':
8485      if (destLength !== 3) {
8486        return false;
8487      }
8488
8489      break;
8490
8491    case 'FitR':
8492      if (destLength !== 6) {
8493        return false;
8494      }
8495
8496      allowNull = false;
8497      break;
8498
8499    default:
8500      return false;
8501  }
8502
8503  for (var i = 2; i < destLength; i++) {
8504    var param = dest[i];
8505
8506    if (!(typeof param === 'number' || allowNull && param === null)) {
8507      return false;
8508    }
8509  }
8510
8511  return true;
8512}
8513
8514var SimpleLinkService =
8515/*#__PURE__*/
8516function () {
8517  function SimpleLinkService() {
8518    _classCallCheck(this, SimpleLinkService);
8519
8520    this.externalLinkTarget = null;
8521    this.externalLinkRel = null;
8522  }
8523
8524  _createClass(SimpleLinkService, [{
8525    key: "navigateTo",
8526    value: function navigateTo(dest) {}
8527  }, {
8528    key: "getDestinationHash",
8529    value: function getDestinationHash(dest) {
8530      return '#';
8531    }
8532  }, {
8533    key: "getAnchorUrl",
8534    value: function getAnchorUrl(hash) {
8535      return '#';
8536    }
8537  }, {
8538    key: "setHash",
8539    value: function setHash(hash) {}
8540  }, {
8541    key: "executeNamedAction",
8542    value: function executeNamedAction(action) {}
8543  }, {
8544    key: "cachePageRef",
8545    value: function cachePageRef(pageNum, pageRef) {}
8546  }, {
8547    key: "isPageVisible",
8548    value: function isPageVisible(pageNumber) {
8549      return true;
8550    }
8551  }, {
8552    key: "pagesCount",
8553    get: function get() {
8554      return 0;
8555    }
8556  }, {
8557    key: "page",
8558    get: function get() {
8559      return 0;
8560    },
8561    set: function set(value) {}
8562  }, {
8563    key: "rotation",
8564    get: function get() {
8565      return 0;
8566    },
8567    set: function set(value) {}
8568  }]);
8569
8570  return SimpleLinkService;
8571}();
8572
8573exports.SimpleLinkService = SimpleLinkService;
8574
8575/***/ }),
8576/* 22 */
8577/***/ (function(module, exports, __webpack_require__) {
8578
8579"use strict";
8580
8581
8582Object.defineProperty(exports, "__esModule", {
8583  value: true
8584});
8585exports.PDFOutlineViewer = void 0;
8586
8587var _pdfjsLib = __webpack_require__(7);
8588
8589function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8590
8591function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8592
8593function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8594
8595var DEFAULT_TITLE = "\u2013";
8596
8597var PDFOutlineViewer =
8598/*#__PURE__*/
8599function () {
8600  function PDFOutlineViewer(_ref) {
8601    var container = _ref.container,
8602        linkService = _ref.linkService,
8603        eventBus = _ref.eventBus;
8604
8605    _classCallCheck(this, PDFOutlineViewer);
8606
8607    this.container = container;
8608    this.linkService = linkService;
8609    this.eventBus = eventBus;
8610    this.reset();
8611    eventBus.on('toggleoutlinetree', this.toggleOutlineTree.bind(this));
8612  }
8613
8614  _createClass(PDFOutlineViewer, [{
8615    key: "reset",
8616    value: function reset() {
8617      this.outline = null;
8618      this.lastToggleIsShow = true;
8619      this.container.textContent = '';
8620      this.container.classList.remove('outlineWithDeepNesting');
8621    }
8622  }, {
8623    key: "_dispatchEvent",
8624    value: function _dispatchEvent(outlineCount) {
8625      this.eventBus.dispatch('outlineloaded', {
8626        source: this,
8627        outlineCount: outlineCount
8628      });
8629    }
8630  }, {
8631    key: "_bindLink",
8632    value: function _bindLink(element, _ref2) {
8633      var url = _ref2.url,
8634          newWindow = _ref2.newWindow,
8635          dest = _ref2.dest;
8636      var linkService = this.linkService;
8637
8638      if (url) {
8639        (0, _pdfjsLib.addLinkAttributes)(element, {
8640          url: url,
8641          target: newWindow ? _pdfjsLib.LinkTarget.BLANK : linkService.externalLinkTarget,
8642          rel: linkService.externalLinkRel
8643        });
8644        return;
8645      }
8646
8647      element.href = linkService.getDestinationHash(dest);
8648
8649      element.onclick = function () {
8650        if (dest) {
8651          linkService.navigateTo(dest);
8652        }
8653
8654        return false;
8655      };
8656    }
8657  }, {
8658    key: "_setStyles",
8659    value: function _setStyles(element, _ref3) {
8660      var bold = _ref3.bold,
8661          italic = _ref3.italic;
8662      var styleStr = '';
8663
8664      if (bold) {
8665        styleStr += 'font-weight: bold;';
8666      }
8667
8668      if (italic) {
8669        styleStr += 'font-style: italic;';
8670      }
8671
8672      if (styleStr) {
8673        element.setAttribute('style', styleStr);
8674      }
8675    }
8676  }, {
8677    key: "_addToggleButton",
8678    value: function _addToggleButton(div, _ref4) {
8679      var _this = this;
8680
8681      var count = _ref4.count,
8682          items = _ref4.items;
8683      var toggler = document.createElement('div');
8684      toggler.className = 'outlineItemToggler';
8685
8686      if (count < 0 && Math.abs(count) === items.length) {
8687        toggler.classList.add('outlineItemsHidden');
8688      }
8689
8690      toggler.onclick = function (evt) {
8691        evt.stopPropagation();
8692        toggler.classList.toggle('outlineItemsHidden');
8693
8694        if (evt.shiftKey) {
8695          var shouldShowAll = !toggler.classList.contains('outlineItemsHidden');
8696
8697          _this._toggleOutlineItem(div, shouldShowAll);
8698        }
8699      };
8700
8701      div.insertBefore(toggler, div.firstChild);
8702    }
8703  }, {
8704    key: "_toggleOutlineItem",
8705    value: function _toggleOutlineItem(root) {
8706      var show = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
8707      this.lastToggleIsShow = show;
8708      var _iteratorNormalCompletion = true;
8709      var _didIteratorError = false;
8710      var _iteratorError = undefined;
8711
8712      try {
8713        for (var _iterator = root.querySelectorAll('.outlineItemToggler')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
8714          var toggler = _step.value;
8715          toggler.classList.toggle('outlineItemsHidden', !show);
8716        }
8717      } catch (err) {
8718        _didIteratorError = true;
8719        _iteratorError = err;
8720      } finally {
8721        try {
8722          if (!_iteratorNormalCompletion && _iterator["return"] != null) {
8723            _iterator["return"]();
8724          }
8725        } finally {
8726          if (_didIteratorError) {
8727            throw _iteratorError;
8728          }
8729        }
8730      }
8731    }
8732  }, {
8733    key: "toggleOutlineTree",
8734    value: function toggleOutlineTree() {
8735      if (!this.outline) {
8736        return;
8737      }
8738
8739      this._toggleOutlineItem(this.container, !this.lastToggleIsShow);
8740    }
8741  }, {
8742    key: "render",
8743    value: function render(_ref5) {
8744      var outline = _ref5.outline;
8745      var outlineCount = 0;
8746
8747      if (this.outline) {
8748        this.reset();
8749      }
8750
8751      this.outline = outline || null;
8752
8753      if (!outline) {
8754        this._dispatchEvent(outlineCount);
8755
8756        return;
8757      }
8758
8759      var fragment = document.createDocumentFragment();
8760      var queue = [{
8761        parent: fragment,
8762        items: this.outline
8763      }];
8764      var hasAnyNesting = false;
8765
8766      while (queue.length > 0) {
8767        var levelData = queue.shift();
8768        var _iteratorNormalCompletion2 = true;
8769        var _didIteratorError2 = false;
8770        var _iteratorError2 = undefined;
8771
8772        try {
8773          for (var _iterator2 = levelData.items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
8774            var item = _step2.value;
8775            var div = document.createElement('div');
8776            div.className = 'outlineItem';
8777            var element = document.createElement('a');
8778
8779            this._bindLink(element, item);
8780
8781            this._setStyles(element, item);
8782
8783            element.textContent = (0, _pdfjsLib.removeNullCharacters)(item.title) || DEFAULT_TITLE;
8784            div.appendChild(element);
8785
8786            if (item.items.length > 0) {
8787              hasAnyNesting = true;
8788
8789              this._addToggleButton(div, item);
8790
8791              var itemsDiv = document.createElement('div');
8792              itemsDiv.className = 'outlineItems';
8793              div.appendChild(itemsDiv);
8794              queue.push({
8795                parent: itemsDiv,
8796                items: item.items
8797              });
8798            }
8799
8800            levelData.parent.appendChild(div);
8801            outlineCount++;
8802          }
8803        } catch (err) {
8804          _didIteratorError2 = true;
8805          _iteratorError2 = err;
8806        } finally {
8807          try {
8808            if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
8809              _iterator2["return"]();
8810            }
8811          } finally {
8812            if (_didIteratorError2) {
8813              throw _iteratorError2;
8814            }
8815          }
8816        }
8817      }
8818
8819      if (hasAnyNesting) {
8820        this.container.classList.add('outlineWithDeepNesting');
8821        this.lastToggleIsShow = fragment.querySelectorAll('.outlineItemsHidden').length === 0;
8822      }
8823
8824      this.container.appendChild(fragment);
8825
8826      this._dispatchEvent(outlineCount);
8827    }
8828  }]);
8829
8830  return PDFOutlineViewer;
8831}();
8832
8833exports.PDFOutlineViewer = PDFOutlineViewer;
8834
8835/***/ }),
8836/* 23 */
8837/***/ (function(module, exports, __webpack_require__) {
8838
8839"use strict";
8840
8841
8842Object.defineProperty(exports, "__esModule", {
8843  value: true
8844});
8845exports.PDFPresentationMode = void 0;
8846
8847var _ui_utils = __webpack_require__(5);
8848
8849function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8850
8851function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8852
8853function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8854
8855var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
8856var DELAY_BEFORE_HIDING_CONTROLS = 3000;
8857var ACTIVE_SELECTOR = 'pdfPresentationMode';
8858var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
8859var MOUSE_SCROLL_COOLDOWN_TIME = 50;
8860var PAGE_SWITCH_THRESHOLD = 0.1;
8861var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
8862var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
8863
8864var PDFPresentationMode =
8865/*#__PURE__*/
8866function () {
8867  function PDFPresentationMode(_ref) {
8868    var _this = this;
8869
8870    var container = _ref.container,
8871        _ref$viewer = _ref.viewer,
8872        viewer = _ref$viewer === void 0 ? null : _ref$viewer,
8873        pdfViewer = _ref.pdfViewer,
8874        eventBus = _ref.eventBus,
8875        _ref$contextMenuItems = _ref.contextMenuItems,
8876        contextMenuItems = _ref$contextMenuItems === void 0 ? null : _ref$contextMenuItems;
8877
8878    _classCallCheck(this, PDFPresentationMode);
8879
8880    this.container = container;
8881    this.viewer = viewer || container.firstElementChild;
8882    this.pdfViewer = pdfViewer;
8883    this.eventBus = eventBus;
8884    this.active = false;
8885    this.args = null;
8886    this.contextMenuOpen = false;
8887    this.mouseScrollTimeStamp = 0;
8888    this.mouseScrollDelta = 0;
8889    this.touchSwipeState = null;
8890
8891    if (contextMenuItems) {
8892      contextMenuItems.contextFirstPage.addEventListener('click', function () {
8893        _this.contextMenuOpen = false;
8894
8895        _this.eventBus.dispatch('firstpage', {
8896          source: _this
8897        });
8898      });
8899      contextMenuItems.contextLastPage.addEventListener('click', function () {
8900        _this.contextMenuOpen = false;
8901
8902        _this.eventBus.dispatch('lastpage', {
8903          source: _this
8904        });
8905      });
8906      contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
8907        _this.contextMenuOpen = false;
8908
8909        _this.eventBus.dispatch('rotatecw', {
8910          source: _this
8911        });
8912      });
8913      contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
8914        _this.contextMenuOpen = false;
8915
8916        _this.eventBus.dispatch('rotateccw', {
8917          source: _this
8918        });
8919      });
8920    }
8921  }
8922
8923  _createClass(PDFPresentationMode, [{
8924    key: "request",
8925    value: function request() {
8926      if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
8927        return false;
8928      }
8929
8930      this._addFullscreenChangeListeners();
8931
8932      this._setSwitchInProgress();
8933
8934      this._notifyStateChange();
8935
8936      if (this.container.requestFullscreen) {
8937        this.container.requestFullscreen();
8938      } else if (this.container.mozRequestFullScreen) {
8939        this.container.mozRequestFullScreen();
8940      } else if (this.container.webkitRequestFullscreen) {
8941        this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
8942      } else if (this.container.msRequestFullscreen) {
8943        this.container.msRequestFullscreen();
8944      } else {
8945        return false;
8946      }
8947
8948      this.args = {
8949        page: this.pdfViewer.currentPageNumber,
8950        previousScale: this.pdfViewer.currentScaleValue
8951      };
8952      return true;
8953    }
8954  }, {
8955    key: "_mouseWheel",
8956    value: function _mouseWheel(evt) {
8957      if (!this.active) {
8958        return;
8959      }
8960
8961      evt.preventDefault();
8962      var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
8963      var currentTime = new Date().getTime();
8964      var storedTime = this.mouseScrollTimeStamp;
8965
8966      if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
8967        return;
8968      }
8969
8970      if (this.mouseScrollDelta > 0 && delta < 0 || this.mouseScrollDelta < 0 && delta > 0) {
8971        this._resetMouseScrollState();
8972      }
8973
8974      this.mouseScrollDelta += delta;
8975
8976      if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
8977        var totalDelta = this.mouseScrollDelta;
8978
8979        this._resetMouseScrollState();
8980
8981        var success = totalDelta > 0 ? this._goToPreviousPage() : this._goToNextPage();
8982
8983        if (success) {
8984          this.mouseScrollTimeStamp = currentTime;
8985        }
8986      }
8987    }
8988  }, {
8989    key: "_goToPreviousPage",
8990    value: function _goToPreviousPage() {
8991      var page = this.pdfViewer.currentPageNumber;
8992
8993      if (page <= 1) {
8994        return false;
8995      }
8996
8997      this.pdfViewer.currentPageNumber = page - 1;
8998      return true;
8999    }
9000  }, {
9001    key: "_goToNextPage",
9002    value: function _goToNextPage() {
9003      var page = this.pdfViewer.currentPageNumber;
9004
9005      if (page >= this.pdfViewer.pagesCount) {
9006        return false;
9007      }
9008
9009      this.pdfViewer.currentPageNumber = page + 1;
9010      return true;
9011    }
9012  }, {
9013    key: "_notifyStateChange",
9014    value: function _notifyStateChange() {
9015      this.eventBus.dispatch('presentationmodechanged', {
9016        source: this,
9017        active: this.active,
9018        switchInProgress: !!this.switchInProgress
9019      });
9020    }
9021  }, {
9022    key: "_setSwitchInProgress",
9023    value: function _setSwitchInProgress() {
9024      var _this2 = this;
9025
9026      if (this.switchInProgress) {
9027        clearTimeout(this.switchInProgress);
9028      }
9029
9030      this.switchInProgress = setTimeout(function () {
9031        _this2._removeFullscreenChangeListeners();
9032
9033        delete _this2.switchInProgress;
9034
9035        _this2._notifyStateChange();
9036      }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
9037    }
9038  }, {
9039    key: "_resetSwitchInProgress",
9040    value: function _resetSwitchInProgress() {
9041      if (this.switchInProgress) {
9042        clearTimeout(this.switchInProgress);
9043        delete this.switchInProgress;
9044      }
9045    }
9046  }, {
9047    key: "_enter",
9048    value: function _enter() {
9049      var _this3 = this;
9050
9051      this.active = true;
9052
9053      this._resetSwitchInProgress();
9054
9055      this._notifyStateChange();
9056
9057      this.container.classList.add(ACTIVE_SELECTOR);
9058      setTimeout(function () {
9059        _this3.pdfViewer.currentPageNumber = _this3.args.page;
9060        _this3.pdfViewer.currentScaleValue = 'page-fit';
9061      }, 0);
9062
9063      this._addWindowListeners();
9064
9065      this._showControls();
9066
9067      this.contextMenuOpen = false;
9068      this.container.setAttribute('contextmenu', 'viewerContextMenu');
9069      window.getSelection().removeAllRanges();
9070    }
9071  }, {
9072    key: "_exit",
9073    value: function _exit() {
9074      var _this4 = this;
9075
9076      var page = this.pdfViewer.currentPageNumber;
9077      this.container.classList.remove(ACTIVE_SELECTOR);
9078      setTimeout(function () {
9079        _this4.active = false;
9080
9081        _this4._removeFullscreenChangeListeners();
9082
9083        _this4._notifyStateChange();
9084
9085        _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
9086        _this4.pdfViewer.currentPageNumber = page;
9087        _this4.args = null;
9088      }, 0);
9089
9090      this._removeWindowListeners();
9091
9092      this._hideControls();
9093
9094      this._resetMouseScrollState();
9095
9096      this.container.removeAttribute('contextmenu');
9097      this.contextMenuOpen = false;
9098    }
9099  }, {
9100    key: "_mouseDown",
9101    value: function _mouseDown(evt) {
9102      if (this.contextMenuOpen) {
9103        this.contextMenuOpen = false;
9104        evt.preventDefault();
9105        return;
9106      }
9107
9108      if (evt.button === 0) {
9109        var isInternalLink = evt.target.href && evt.target.classList.contains('internalLink');
9110
9111        if (!isInternalLink) {
9112          evt.preventDefault();
9113
9114          if (evt.shiftKey) {
9115            this._goToPreviousPage();
9116          } else {
9117            this._goToNextPage();
9118          }
9119        }
9120      }
9121    }
9122  }, {
9123    key: "_contextMenu",
9124    value: function _contextMenu() {
9125      this.contextMenuOpen = true;
9126    }
9127  }, {
9128    key: "_showControls",
9129    value: function _showControls() {
9130      var _this5 = this;
9131
9132      if (this.controlsTimeout) {
9133        clearTimeout(this.controlsTimeout);
9134      } else {
9135        this.container.classList.add(CONTROLS_SELECTOR);
9136      }
9137
9138      this.controlsTimeout = setTimeout(function () {
9139        _this5.container.classList.remove(CONTROLS_SELECTOR);
9140
9141        delete _this5.controlsTimeout;
9142      }, DELAY_BEFORE_HIDING_CONTROLS);
9143    }
9144  }, {
9145    key: "_hideControls",
9146    value: function _hideControls() {
9147      if (!this.controlsTimeout) {
9148        return;
9149      }
9150
9151      clearTimeout(this.controlsTimeout);
9152      this.container.classList.remove(CONTROLS_SELECTOR);
9153      delete this.controlsTimeout;
9154    }
9155  }, {
9156    key: "_resetMouseScrollState",
9157    value: function _resetMouseScrollState() {
9158      this.mouseScrollTimeStamp = 0;
9159      this.mouseScrollDelta = 0;
9160    }
9161  }, {
9162    key: "_touchSwipe",
9163    value: function _touchSwipe(evt) {
9164      if (!this.active) {
9165        return;
9166      }
9167
9168      if (evt.touches.length > 1) {
9169        this.touchSwipeState = null;
9170        return;
9171      }
9172
9173      switch (evt.type) {
9174        case 'touchstart':
9175          this.touchSwipeState = {
9176            startX: evt.touches[0].pageX,
9177            startY: evt.touches[0].pageY,
9178            endX: evt.touches[0].pageX,
9179            endY: evt.touches[0].pageY
9180          };
9181          break;
9182
9183        case 'touchmove':
9184          if (this.touchSwipeState === null) {
9185            return;
9186          }
9187
9188          this.touchSwipeState.endX = evt.touches[0].pageX;
9189          this.touchSwipeState.endY = evt.touches[0].pageY;
9190          evt.preventDefault();
9191          break;
9192
9193        case 'touchend':
9194          if (this.touchSwipeState === null) {
9195            return;
9196          }
9197
9198          var delta = 0;
9199          var dx = this.touchSwipeState.endX - this.touchSwipeState.startX;
9200          var dy = this.touchSwipeState.endY - this.touchSwipeState.startY;
9201          var absAngle = Math.abs(Math.atan2(dy, dx));
9202
9203          if (Math.abs(dx) > SWIPE_MIN_DISTANCE_THRESHOLD && (absAngle <= SWIPE_ANGLE_THRESHOLD || absAngle >= Math.PI - SWIPE_ANGLE_THRESHOLD)) {
9204            delta = dx;
9205          } else if (Math.abs(dy) > SWIPE_MIN_DISTANCE_THRESHOLD && Math.abs(absAngle - Math.PI / 2) <= SWIPE_ANGLE_THRESHOLD) {
9206            delta = dy;
9207          }
9208
9209          if (delta > 0) {
9210            this._goToPreviousPage();
9211          } else if (delta < 0) {
9212            this._goToNextPage();
9213          }
9214
9215          break;
9216      }
9217    }
9218  }, {
9219    key: "_addWindowListeners",
9220    value: function _addWindowListeners() {
9221      this.showControlsBind = this._showControls.bind(this);
9222      this.mouseDownBind = this._mouseDown.bind(this);
9223      this.mouseWheelBind = this._mouseWheel.bind(this);
9224      this.resetMouseScrollStateBind = this._resetMouseScrollState.bind(this);
9225      this.contextMenuBind = this._contextMenu.bind(this);
9226      this.touchSwipeBind = this._touchSwipe.bind(this);
9227      window.addEventListener('mousemove', this.showControlsBind);
9228      window.addEventListener('mousedown', this.mouseDownBind);
9229      window.addEventListener('wheel', this.mouseWheelBind);
9230      window.addEventListener('keydown', this.resetMouseScrollStateBind);
9231      window.addEventListener('contextmenu', this.contextMenuBind);
9232      window.addEventListener('touchstart', this.touchSwipeBind);
9233      window.addEventListener('touchmove', this.touchSwipeBind);
9234      window.addEventListener('touchend', this.touchSwipeBind);
9235    }
9236  }, {
9237    key: "_removeWindowListeners",
9238    value: function _removeWindowListeners() {
9239      window.removeEventListener('mousemove', this.showControlsBind);
9240      window.removeEventListener('mousedown', this.mouseDownBind);
9241      window.removeEventListener('wheel', this.mouseWheelBind);
9242      window.removeEventListener('keydown', this.resetMouseScrollStateBind);
9243      window.removeEventListener('contextmenu', this.contextMenuBind);
9244      window.removeEventListener('touchstart', this.touchSwipeBind);
9245      window.removeEventListener('touchmove', this.touchSwipeBind);
9246      window.removeEventListener('touchend', this.touchSwipeBind);
9247      delete this.showControlsBind;
9248      delete this.mouseDownBind;
9249      delete this.mouseWheelBind;
9250      delete this.resetMouseScrollStateBind;
9251      delete this.contextMenuBind;
9252      delete this.touchSwipeBind;
9253    }
9254  }, {
9255    key: "_fullscreenChange",
9256    value: function _fullscreenChange() {
9257      if (this.isFullscreen) {
9258        this._enter();
9259      } else {
9260        this._exit();
9261      }
9262    }
9263  }, {
9264    key: "_addFullscreenChangeListeners",
9265    value: function _addFullscreenChangeListeners() {
9266      this.fullscreenChangeBind = this._fullscreenChange.bind(this);
9267      window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
9268      window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
9269      window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
9270      window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
9271    }
9272  }, {
9273    key: "_removeFullscreenChangeListeners",
9274    value: function _removeFullscreenChangeListeners() {
9275      window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
9276      window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
9277      window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
9278      window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
9279      delete this.fullscreenChangeBind;
9280    }
9281  }, {
9282    key: "isFullscreen",
9283    get: function get() {
9284      return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
9285    }
9286  }]);
9287
9288  return PDFPresentationMode;
9289}();
9290
9291exports.PDFPresentationMode = PDFPresentationMode;
9292
9293/***/ }),
9294/* 24 */
9295/***/ (function(module, exports, __webpack_require__) {
9296
9297"use strict";
9298
9299
9300Object.defineProperty(exports, "__esModule", {
9301  value: true
9302});
9303exports.PDFSidebarResizer = void 0;
9304
9305var _ui_utils = __webpack_require__(5);
9306
9307function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9308
9309function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9310
9311function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9312
9313var SIDEBAR_WIDTH_VAR = '--sidebar-width';
9314var SIDEBAR_MIN_WIDTH = 200;
9315var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
9316
9317var PDFSidebarResizer =
9318/*#__PURE__*/
9319function () {
9320  function PDFSidebarResizer(options, eventBus) {
9321    var _this = this;
9322
9323    var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
9324
9325    _classCallCheck(this, PDFSidebarResizer);
9326
9327    this.enabled = false;
9328    this.isRTL = false;
9329    this.sidebarOpen = false;
9330    this.doc = document.documentElement;
9331    this._width = null;
9332    this._outerContainerWidth = null;
9333    this._boundEvents = Object.create(null);
9334    this.outerContainer = options.outerContainer;
9335    this.resizer = options.resizer;
9336    this.eventBus = eventBus;
9337    this.l10n = l10n;
9338
9339    if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
9340      console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
9341      return;
9342    }
9343
9344    this.enabled = true;
9345    this.resizer.classList.remove('hidden');
9346    this.l10n.getDirection().then(function (dir) {
9347      _this.isRTL = dir === 'rtl';
9348    });
9349
9350    this._addEventListeners();
9351  }
9352
9353  _createClass(PDFSidebarResizer, [{
9354    key: "_updateWidth",
9355    value: function _updateWidth() {
9356      var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
9357
9358      if (!this.enabled) {
9359        return false;
9360      }
9361
9362      var maxWidth = Math.floor(this.outerContainerWidth / 2);
9363
9364      if (width > maxWidth) {
9365        width = maxWidth;
9366      }
9367
9368      if (width < SIDEBAR_MIN_WIDTH) {
9369        width = SIDEBAR_MIN_WIDTH;
9370      }
9371
9372      if (width === this._width) {
9373        return false;
9374      }
9375
9376      this._width = width;
9377      this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
9378      return true;
9379    }
9380  }, {
9381    key: "_mouseMove",
9382    value: function _mouseMove(evt) {
9383      var width = evt.clientX;
9384
9385      if (this.isRTL) {
9386        width = this.outerContainerWidth - width;
9387      }
9388
9389      this._updateWidth(width);
9390    }
9391  }, {
9392    key: "_mouseUp",
9393    value: function _mouseUp(evt) {
9394      this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
9395      this.eventBus.dispatch('resize', {
9396        source: this
9397      });
9398      var _boundEvents = this._boundEvents;
9399      window.removeEventListener('mousemove', _boundEvents.mouseMove);
9400      window.removeEventListener('mouseup', _boundEvents.mouseUp);
9401    }
9402  }, {
9403    key: "_addEventListeners",
9404    value: function _addEventListeners() {
9405      var _this2 = this;
9406
9407      if (!this.enabled) {
9408        return;
9409      }
9410
9411      var _boundEvents = this._boundEvents;
9412      _boundEvents.mouseMove = this._mouseMove.bind(this);
9413      _boundEvents.mouseUp = this._mouseUp.bind(this);
9414      this.resizer.addEventListener('mousedown', function (evt) {
9415        if (evt.button !== 0) {
9416          return;
9417        }
9418
9419        _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
9420
9421        window.addEventListener('mousemove', _boundEvents.mouseMove);
9422        window.addEventListener('mouseup', _boundEvents.mouseUp);
9423      });
9424      this.eventBus.on('sidebarviewchanged', function (evt) {
9425        _this2.sidebarOpen = !!(evt && evt.view);
9426      });
9427      this.eventBus.on('resize', function (evt) {
9428        if (evt && evt.source === window) {
9429          _this2._outerContainerWidth = null;
9430
9431          if (_this2._width) {
9432            if (_this2.sidebarOpen) {
9433              _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
9434
9435              var updated = _this2._updateWidth(_this2._width);
9436
9437              Promise.resolve().then(function () {
9438                _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
9439
9440                if (updated) {
9441                  _this2.eventBus.dispatch('resize', {
9442                    source: _this2
9443                  });
9444                }
9445              });
9446            } else {
9447              _this2._updateWidth(_this2._width);
9448            }
9449          }
9450        }
9451      });
9452    }
9453  }, {
9454    key: "outerContainerWidth",
9455    get: function get() {
9456      if (!this._outerContainerWidth) {
9457        this._outerContainerWidth = this.outerContainer.clientWidth;
9458      }
9459
9460      return this._outerContainerWidth;
9461    }
9462  }]);
9463
9464  return PDFSidebarResizer;
9465}();
9466
9467exports.PDFSidebarResizer = PDFSidebarResizer;
9468
9469/***/ }),
9470/* 25 */
9471/***/ (function(module, exports, __webpack_require__) {
9472
9473"use strict";
9474
9475
9476Object.defineProperty(exports, "__esModule", {
9477  value: true
9478});
9479exports.PDFThumbnailViewer = void 0;
9480
9481var _ui_utils = __webpack_require__(5);
9482
9483var _pdf_thumbnail_view = __webpack_require__(26);
9484
9485function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9486
9487function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9488
9489function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9490
9491var THUMBNAIL_SCROLL_MARGIN = -19;
9492var THUMBNAIL_SELECTED_CLASS = 'selected';
9493
9494var PDFThumbnailViewer =
9495/*#__PURE__*/
9496function () {
9497  function PDFThumbnailViewer(_ref) {
9498    var container = _ref.container,
9499        linkService = _ref.linkService,
9500        renderingQueue = _ref.renderingQueue,
9501        _ref$l10n = _ref.l10n,
9502        l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
9503
9504    _classCallCheck(this, PDFThumbnailViewer);
9505
9506    this.container = container;
9507    this.linkService = linkService;
9508    this.renderingQueue = renderingQueue;
9509    this.l10n = l10n;
9510    this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
9511
9512    this._resetView();
9513  }
9514
9515  _createClass(PDFThumbnailViewer, [{
9516    key: "_scrollUpdated",
9517    value: function _scrollUpdated() {
9518      this.renderingQueue.renderHighestPriority();
9519    }
9520  }, {
9521    key: "getThumbnail",
9522    value: function getThumbnail(index) {
9523      return this._thumbnails[index];
9524    }
9525  }, {
9526    key: "_getVisibleThumbs",
9527    value: function _getVisibleThumbs() {
9528      return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
9529    }
9530  }, {
9531    key: "scrollThumbnailIntoView",
9532    value: function scrollThumbnailIntoView(pageNumber) {
9533      if (!this.pdfDocument) {
9534        return;
9535      }
9536
9537      var thumbnailView = this._thumbnails[pageNumber - 1];
9538
9539      if (!thumbnailView) {
9540        console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
9541        return;
9542      }
9543
9544      if (pageNumber !== this._currentPageNumber) {
9545        var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
9546        prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
9547        thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
9548      }
9549
9550      var visibleThumbs = this._getVisibleThumbs();
9551
9552      var numVisibleThumbs = visibleThumbs.views.length;
9553
9554      if (numVisibleThumbs > 0) {
9555        var first = visibleThumbs.first.id;
9556        var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
9557        var shouldScroll = false;
9558
9559        if (pageNumber <= first || pageNumber >= last) {
9560          shouldScroll = true;
9561        } else {
9562          visibleThumbs.views.some(function (view) {
9563            if (view.id !== pageNumber) {
9564              return false;
9565            }
9566
9567            shouldScroll = view.percent < 100;
9568            return true;
9569          });
9570        }
9571
9572        if (shouldScroll) {
9573          (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
9574            top: THUMBNAIL_SCROLL_MARGIN
9575          });
9576        }
9577      }
9578
9579      this._currentPageNumber = pageNumber;
9580    }
9581  }, {
9582    key: "cleanup",
9583    value: function cleanup() {
9584      _pdf_thumbnail_view.PDFThumbnailView.cleanup();
9585    }
9586  }, {
9587    key: "_resetView",
9588    value: function _resetView() {
9589      this._thumbnails = [];
9590      this._currentPageNumber = 1;
9591      this._pageLabels = null;
9592      this._pagesRotation = 0;
9593      this._pagesRequests = [];
9594      this.container.textContent = '';
9595    }
9596  }, {
9597    key: "setDocument",
9598    value: function setDocument(pdfDocument) {
9599      var _this = this;
9600
9601      if (this.pdfDocument) {
9602        this._cancelRendering();
9603
9604        this._resetView();
9605      }
9606
9607      this.pdfDocument = pdfDocument;
9608
9609      if (!pdfDocument) {
9610        return;
9611      }
9612
9613      pdfDocument.getPage(1).then(function (firstPage) {
9614        var pagesCount = pdfDocument.numPages;
9615        var viewport = firstPage.getViewport({
9616          scale: 1
9617        });
9618
9619        for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
9620          var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
9621            container: _this.container,
9622            id: pageNum,
9623            defaultViewport: viewport.clone(),
9624            linkService: _this.linkService,
9625            renderingQueue: _this.renderingQueue,
9626            disableCanvasToImageConversion: false,
9627            l10n: _this.l10n
9628          });
9629
9630          _this._thumbnails.push(thumbnail);
9631        }
9632
9633        var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
9634        thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
9635      })["catch"](function (reason) {
9636        console.error('Unable to initialize thumbnail viewer', reason);
9637      });
9638    }
9639  }, {
9640    key: "_cancelRendering",
9641    value: function _cancelRendering() {
9642      for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
9643        if (this._thumbnails[i]) {
9644          this._thumbnails[i].cancelRendering();
9645        }
9646      }
9647    }
9648  }, {
9649    key: "setPageLabels",
9650    value: function setPageLabels(labels) {
9651      if (!this.pdfDocument) {
9652        return;
9653      }
9654
9655      if (!labels) {
9656        this._pageLabels = null;
9657      } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
9658        this._pageLabels = null;
9659        console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
9660      } else {
9661        this._pageLabels = labels;
9662      }
9663
9664      for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
9665        var label = this._pageLabels && this._pageLabels[i];
9666
9667        this._thumbnails[i].setPageLabel(label);
9668      }
9669    }
9670  }, {
9671    key: "_ensurePdfPageLoaded",
9672    value: function _ensurePdfPageLoaded(thumbView) {
9673      var _this2 = this;
9674
9675      if (thumbView.pdfPage) {
9676        return Promise.resolve(thumbView.pdfPage);
9677      }
9678
9679      var pageNumber = thumbView.id;
9680
9681      if (this._pagesRequests[pageNumber]) {
9682        return this._pagesRequests[pageNumber];
9683      }
9684
9685      var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
9686        thumbView.setPdfPage(pdfPage);
9687        _this2._pagesRequests[pageNumber] = null;
9688        return pdfPage;
9689      })["catch"](function (reason) {
9690        console.error('Unable to get page for thumb view', reason);
9691        _this2._pagesRequests[pageNumber] = null;
9692      });
9693      this._pagesRequests[pageNumber] = promise;
9694      return promise;
9695    }
9696  }, {
9697    key: "forceRendering",
9698    value: function forceRendering() {
9699      var _this3 = this;
9700
9701      var visibleThumbs = this._getVisibleThumbs();
9702
9703      var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
9704
9705      if (thumbView) {
9706        this._ensurePdfPageLoaded(thumbView).then(function () {
9707          _this3.renderingQueue.renderView(thumbView);
9708        });
9709
9710        return true;
9711      }
9712
9713      return false;
9714    }
9715  }, {
9716    key: "pagesRotation",
9717    get: function get() {
9718      return this._pagesRotation;
9719    },
9720    set: function set(rotation) {
9721      if (!(0, _ui_utils.isValidRotation)(rotation)) {
9722        throw new Error('Invalid thumbnails rotation angle.');
9723      }
9724
9725      if (!this.pdfDocument) {
9726        return;
9727      }
9728
9729      if (this._pagesRotation === rotation) {
9730        return;
9731      }
9732
9733      this._pagesRotation = rotation;
9734
9735      for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
9736        this._thumbnails[i].update(rotation);
9737      }
9738    }
9739  }]);
9740
9741  return PDFThumbnailViewer;
9742}();
9743
9744exports.PDFThumbnailViewer = PDFThumbnailViewer;
9745
9746/***/ }),
9747/* 26 */
9748/***/ (function(module, exports, __webpack_require__) {
9749
9750"use strict";
9751
9752
9753Object.defineProperty(exports, "__esModule", {
9754  value: true
9755});
9756exports.PDFThumbnailView = void 0;
9757
9758var _pdfjsLib = __webpack_require__(7);
9759
9760var _ui_utils = __webpack_require__(5);
9761
9762var _pdf_rendering_queue = __webpack_require__(11);
9763
9764function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9765
9766function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
9767
9768function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
9769
9770var MAX_NUM_SCALING_STEPS = 3;
9771var THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
9772var THUMBNAIL_WIDTH = 98;
9773
9774var TempImageFactory = function TempImageFactoryClosure() {
9775  var tempCanvasCache = null;
9776  return {
9777    getCanvas: function getCanvas(width, height) {
9778      var tempCanvas = tempCanvasCache;
9779
9780      if (!tempCanvas) {
9781        tempCanvas = document.createElement('canvas');
9782        tempCanvasCache = tempCanvas;
9783      }
9784
9785      tempCanvas.width = width;
9786      tempCanvas.height = height;
9787      tempCanvas.mozOpaque = true;
9788      var ctx = tempCanvas.getContext('2d', {
9789        alpha: false
9790      });
9791      ctx.save();
9792      ctx.fillStyle = 'rgb(255, 255, 255)';
9793      ctx.fillRect(0, 0, width, height);
9794      ctx.restore();
9795      return tempCanvas;
9796    },
9797    destroyCanvas: function destroyCanvas() {
9798      var tempCanvas = tempCanvasCache;
9799
9800      if (tempCanvas) {
9801        tempCanvas.width = 0;
9802        tempCanvas.height = 0;
9803      }
9804
9805      tempCanvasCache = null;
9806    }
9807  };
9808}();
9809
9810var PDFThumbnailView =
9811/*#__PURE__*/
9812function () {
9813  function PDFThumbnailView(_ref) {
9814    var container = _ref.container,
9815        id = _ref.id,
9816        defaultViewport = _ref.defaultViewport,
9817        linkService = _ref.linkService,
9818        renderingQueue = _ref.renderingQueue,
9819        _ref$disableCanvasToI = _ref.disableCanvasToImageConversion,
9820        disableCanvasToImageConversion = _ref$disableCanvasToI === void 0 ? false : _ref$disableCanvasToI,
9821        _ref$l10n = _ref.l10n,
9822        l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
9823
9824    _classCallCheck(this, PDFThumbnailView);
9825
9826    this.id = id;
9827    this.renderingId = 'thumbnail' + id;
9828    this.pageLabel = null;
9829    this.pdfPage = null;
9830    this.rotation = 0;
9831    this.viewport = defaultViewport;
9832    this.pdfPageRotate = defaultViewport.rotation;
9833    this.linkService = linkService;
9834    this.renderingQueue = renderingQueue;
9835    this.renderTask = null;
9836    this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
9837    this.resume = null;
9838    this.disableCanvasToImageConversion = disableCanvasToImageConversion;
9839    this.pageWidth = this.viewport.width;
9840    this.pageHeight = this.viewport.height;
9841    this.pageRatio = this.pageWidth / this.pageHeight;
9842    this.canvasWidth = THUMBNAIL_WIDTH;
9843    this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
9844    this.scale = this.canvasWidth / this.pageWidth;
9845    this.l10n = l10n;
9846    var anchor = document.createElement('a');
9847    anchor.href = linkService.getAnchorUrl('#page=' + id);
9848    this.l10n.get('thumb_page_title', {
9849      page: id
9850    }, 'Page {{page}}').then(function (msg) {
9851      anchor.title = msg;
9852    });
9853
9854    anchor.onclick = function () {
9855      linkService.page = id;
9856      return false;
9857    };
9858
9859    this.anchor = anchor;
9860    var div = document.createElement('div');
9861    div.className = 'thumbnail';
9862    div.setAttribute('data-page-number', this.id);
9863    this.div = div;
9864    var ring = document.createElement('div');
9865    ring.className = 'thumbnailSelectionRing';
9866    var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
9867    ring.style.width = this.canvasWidth + borderAdjustment + 'px';
9868    ring.style.height = this.canvasHeight + borderAdjustment + 'px';
9869    this.ring = ring;
9870    div.appendChild(ring);
9871    anchor.appendChild(div);
9872    container.appendChild(anchor);
9873  }
9874
9875  _createClass(PDFThumbnailView, [{
9876    key: "setPdfPage",
9877    value: function setPdfPage(pdfPage) {
9878      this.pdfPage = pdfPage;
9879      this.pdfPageRotate = pdfPage.rotate;
9880      var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
9881      this.viewport = pdfPage.getViewport({
9882        scale: 1,
9883        rotation: totalRotation
9884      });
9885      this.reset();
9886    }
9887  }, {
9888    key: "reset",
9889    value: function reset() {
9890      this.cancelRendering();
9891      this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
9892      this.pageWidth = this.viewport.width;
9893      this.pageHeight = this.viewport.height;
9894      this.pageRatio = this.pageWidth / this.pageHeight;
9895      this.canvasHeight = this.canvasWidth / this.pageRatio | 0;
9896      this.scale = this.canvasWidth / this.pageWidth;
9897      this.div.removeAttribute('data-loaded');
9898      var ring = this.ring;
9899      var childNodes = ring.childNodes;
9900
9901      for (var i = childNodes.length - 1; i >= 0; i--) {
9902        ring.removeChild(childNodes[i]);
9903      }
9904
9905      var borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
9906      ring.style.width = this.canvasWidth + borderAdjustment + 'px';
9907      ring.style.height = this.canvasHeight + borderAdjustment + 'px';
9908
9909      if (this.canvas) {
9910        this.canvas.width = 0;
9911        this.canvas.height = 0;
9912        delete this.canvas;
9913      }
9914
9915      if (this.image) {
9916        this.image.removeAttribute('src');
9917        delete this.image;
9918      }
9919    }
9920  }, {
9921    key: "update",
9922    value: function update(rotation) {
9923      if (typeof rotation !== 'undefined') {
9924        this.rotation = rotation;
9925      }
9926
9927      var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
9928      this.viewport = this.viewport.clone({
9929        scale: 1,
9930        rotation: totalRotation
9931      });
9932      this.reset();
9933    }
9934  }, {
9935    key: "cancelRendering",
9936    value: function cancelRendering() {
9937      if (this.renderTask) {
9938        this.renderTask.cancel();
9939        this.renderTask = null;
9940      }
9941
9942      this.resume = null;
9943    }
9944  }, {
9945    key: "_getPageDrawContext",
9946    value: function _getPageDrawContext() {
9947      var noCtxScale = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
9948      var canvas = document.createElement('canvas');
9949      this.canvas = canvas;
9950      canvas.mozOpaque = true;
9951      var ctx = canvas.getContext('2d', {
9952        alpha: false
9953      });
9954      var outputScale = (0, _ui_utils.getOutputScale)(ctx);
9955      canvas.width = this.canvasWidth * outputScale.sx | 0;
9956      canvas.height = this.canvasHeight * outputScale.sy | 0;
9957      canvas.style.width = this.canvasWidth + 'px';
9958      canvas.style.height = this.canvasHeight + 'px';
9959
9960      if (!noCtxScale && outputScale.scaled) {
9961        ctx.scale(outputScale.sx, outputScale.sy);
9962      }
9963
9964      return ctx;
9965    }
9966  }, {
9967    key: "_convertCanvasToImage",
9968    value: function _convertCanvasToImage() {
9969      var _this = this;
9970
9971      if (!this.canvas) {
9972        return;
9973      }
9974
9975      if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
9976        return;
9977      }
9978
9979      var id = this.renderingId;
9980      var className = 'thumbnailImage';
9981
9982      if (this.disableCanvasToImageConversion) {
9983        this.canvas.id = id;
9984        this.canvas.className = className;
9985        this.l10n.get('thumb_page_canvas', {
9986          page: this.pageId
9987        }, 'Thumbnail of Page {{page}}').then(function (msg) {
9988          _this.canvas.setAttribute('aria-label', msg);
9989        });
9990        this.div.setAttribute('data-loaded', true);
9991        this.ring.appendChild(this.canvas);
9992        return;
9993      }
9994
9995      var image = document.createElement('img');
9996      image.id = id;
9997      image.className = className;
9998      this.l10n.get('thumb_page_canvas', {
9999        page: this.pageId
10000      }, 'Thumbnail of Page {{page}}').then(function (msg) {
10001        image.setAttribute('aria-label', msg);
10002      });
10003      image.style.width = this.canvasWidth + 'px';
10004      image.style.height = this.canvasHeight + 'px';
10005      image.src = this.canvas.toDataURL();
10006      this.image = image;
10007      this.div.setAttribute('data-loaded', true);
10008      this.ring.appendChild(image);
10009      this.canvas.width = 0;
10010      this.canvas.height = 0;
10011      delete this.canvas;
10012    }
10013  }, {
10014    key: "draw",
10015    value: function draw() {
10016      var _this2 = this;
10017
10018      if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
10019        console.error('Must be in new state before drawing');
10020        return Promise.resolve(undefined);
10021      }
10022
10023      this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
10024      var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
10025
10026      var finishRenderTask = function finishRenderTask(error) {
10027        if (renderTask === _this2.renderTask) {
10028          _this2.renderTask = null;
10029        }
10030
10031        if (error instanceof _pdfjsLib.RenderingCancelledException) {
10032          renderCapability.resolve(undefined);
10033          return;
10034        }
10035
10036        _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
10037
10038        _this2._convertCanvasToImage();
10039
10040        if (!error) {
10041          renderCapability.resolve(undefined);
10042        } else {
10043          renderCapability.reject(error);
10044        }
10045      };
10046
10047      var ctx = this._getPageDrawContext();
10048
10049      var drawViewport = this.viewport.clone({
10050        scale: this.scale
10051      });
10052
10053      var renderContinueCallback = function renderContinueCallback(cont) {
10054        if (!_this2.renderingQueue.isHighestPriority(_this2)) {
10055          _this2.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
10056
10057          _this2.resume = function () {
10058            _this2.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
10059            cont();
10060          };
10061
10062          return;
10063        }
10064
10065        cont();
10066      };
10067
10068      var renderContext = {
10069        canvasContext: ctx,
10070        viewport: drawViewport
10071      };
10072      var renderTask = this.renderTask = this.pdfPage.render(renderContext);
10073      renderTask.onContinue = renderContinueCallback;
10074      renderTask.promise.then(function () {
10075        finishRenderTask(null);
10076      }, function (error) {
10077        finishRenderTask(error);
10078      });
10079      return renderCapability.promise;
10080    }
10081  }, {
10082    key: "setImage",
10083    value: function setImage(pageView) {
10084      if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
10085        return;
10086      }
10087
10088      var img = pageView.canvas;
10089
10090      if (!img) {
10091        return;
10092      }
10093
10094      if (!this.pdfPage) {
10095        this.setPdfPage(pageView.pdfPage);
10096      }
10097
10098      this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
10099
10100      var ctx = this._getPageDrawContext(true);
10101
10102      var canvas = ctx.canvas;
10103
10104      if (img.width <= 2 * canvas.width) {
10105        ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width, canvas.height);
10106
10107        this._convertCanvasToImage();
10108
10109        return;
10110      }
10111
10112      var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
10113      var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
10114      var reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
10115      var reducedImageCtx = reducedImage.getContext('2d');
10116
10117      while (reducedWidth > img.width || reducedHeight > img.height) {
10118        reducedWidth >>= 1;
10119        reducedHeight >>= 1;
10120      }
10121
10122      reducedImageCtx.drawImage(img, 0, 0, img.width, img.height, 0, 0, reducedWidth, reducedHeight);
10123
10124      while (reducedWidth > 2 * canvas.width) {
10125        reducedImageCtx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, reducedWidth >> 1, reducedHeight >> 1);
10126        reducedWidth >>= 1;
10127        reducedHeight >>= 1;
10128      }
10129
10130      ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight, 0, 0, canvas.width, canvas.height);
10131
10132      this._convertCanvasToImage();
10133    }
10134  }, {
10135    key: "setPageLabel",
10136    value: function setPageLabel(label) {
10137      var _this3 = this;
10138
10139      this.pageLabel = typeof label === 'string' ? label : null;
10140      this.l10n.get('thumb_page_title', {
10141        page: this.pageId
10142      }, 'Page {{page}}').then(function (msg) {
10143        _this3.anchor.title = msg;
10144      });
10145
10146      if (this.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
10147        return;
10148      }
10149
10150      this.l10n.get('thumb_page_canvas', {
10151        page: this.pageId
10152      }, 'Thumbnail of Page {{page}}').then(function (ariaLabel) {
10153        if (_this3.image) {
10154          _this3.image.setAttribute('aria-label', ariaLabel);
10155        } else if (_this3.disableCanvasToImageConversion && _this3.canvas) {
10156          _this3.canvas.setAttribute('aria-label', ariaLabel);
10157        }
10158      });
10159    }
10160  }, {
10161    key: "pageId",
10162    get: function get() {
10163      return this.pageLabel !== null ? this.pageLabel : this.id;
10164    }
10165  }], [{
10166    key: "cleanup",
10167    value: function cleanup() {
10168      TempImageFactory.destroyCanvas();
10169    }
10170  }]);
10171
10172  return PDFThumbnailView;
10173}();
10174
10175exports.PDFThumbnailView = PDFThumbnailView;
10176
10177/***/ }),
10178/* 27 */
10179/***/ (function(module, exports, __webpack_require__) {
10180
10181"use strict";
10182
10183
10184Object.defineProperty(exports, "__esModule", {
10185  value: true
10186});
10187exports.PDFViewer = void 0;
10188
10189var _base_viewer = __webpack_require__(28);
10190
10191var _pdfjsLib = __webpack_require__(7);
10192
10193function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10194
10195function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10196
10197function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10198
10199function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10200
10201function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
10202
10203function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10204
10205function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
10206
10207function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
10208
10209function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
10210
10211function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10212
10213function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10214
10215var PDFViewer =
10216/*#__PURE__*/
10217function (_BaseViewer) {
10218  _inherits(PDFViewer, _BaseViewer);
10219
10220  function PDFViewer() {
10221    _classCallCheck(this, PDFViewer);
10222
10223    return _possibleConstructorReturn(this, _getPrototypeOf(PDFViewer).apply(this, arguments));
10224  }
10225
10226  _createClass(PDFViewer, [{
10227    key: "_scrollIntoView",
10228    value: function _scrollIntoView(_ref) {
10229      var pageDiv = _ref.pageDiv,
10230          _ref$pageSpot = _ref.pageSpot,
10231          pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
10232          _ref$pageNumber = _ref.pageNumber,
10233          pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
10234
10235      if (!pageSpot && !this.isInPresentationMode) {
10236        var left = pageDiv.offsetLeft + pageDiv.clientLeft;
10237        var right = left + pageDiv.clientWidth;
10238        var _this$container = this.container,
10239            scrollLeft = _this$container.scrollLeft,
10240            clientWidth = _this$container.clientWidth;
10241
10242        if (this._isScrollModeHorizontal || left < scrollLeft || right > scrollLeft + clientWidth) {
10243          pageSpot = {
10244            left: 0,
10245            top: 0
10246          };
10247        }
10248      }
10249
10250      _get(_getPrototypeOf(PDFViewer.prototype), "_scrollIntoView", this).call(this, {
10251        pageDiv: pageDiv,
10252        pageSpot: pageSpot,
10253        pageNumber: pageNumber
10254      });
10255    }
10256  }, {
10257    key: "_getVisiblePages",
10258    value: function _getVisiblePages() {
10259      if (this.isInPresentationMode) {
10260        return this._getCurrentVisiblePage();
10261      }
10262
10263      return _get(_getPrototypeOf(PDFViewer.prototype), "_getVisiblePages", this).call(this);
10264    }
10265  }, {
10266    key: "_updateHelper",
10267    value: function _updateHelper(visiblePages) {
10268      if (this.isInPresentationMode) {
10269        return;
10270      }
10271
10272      var currentId = this._currentPageNumber;
10273      var stillFullyVisible = false;
10274      var _iteratorNormalCompletion = true;
10275      var _didIteratorError = false;
10276      var _iteratorError = undefined;
10277
10278      try {
10279        for (var _iterator = visiblePages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
10280          var page = _step.value;
10281
10282          if (page.percent < 100) {
10283            break;
10284          }
10285
10286          if (page.id === currentId) {
10287            stillFullyVisible = true;
10288            break;
10289          }
10290        }
10291      } catch (err) {
10292        _didIteratorError = true;
10293        _iteratorError = err;
10294      } finally {
10295        try {
10296          if (!_iteratorNormalCompletion && _iterator["return"] != null) {
10297            _iterator["return"]();
10298          }
10299        } finally {
10300          if (_didIteratorError) {
10301            throw _iteratorError;
10302          }
10303        }
10304      }
10305
10306      if (!stillFullyVisible) {
10307        currentId = visiblePages[0].id;
10308      }
10309
10310      this._setCurrentPageNumber(currentId);
10311    }
10312  }, {
10313    key: "_setDocumentViewerElement",
10314    get: function get() {
10315      return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer);
10316    }
10317  }]);
10318
10319  return PDFViewer;
10320}(_base_viewer.BaseViewer);
10321
10322exports.PDFViewer = PDFViewer;
10323
10324/***/ }),
10325/* 28 */
10326/***/ (function(module, exports, __webpack_require__) {
10327
10328"use strict";
10329
10330
10331Object.defineProperty(exports, "__esModule", {
10332  value: true
10333});
10334exports.BaseViewer = void 0;
10335
10336var _ui_utils = __webpack_require__(5);
10337
10338var _pdf_rendering_queue = __webpack_require__(11);
10339
10340var _annotation_layer_builder = __webpack_require__(29);
10341
10342var _pdfjsLib = __webpack_require__(7);
10343
10344var _pdf_page_view = __webpack_require__(30);
10345
10346var _pdf_link_service = __webpack_require__(21);
10347
10348var _text_layer_builder = __webpack_require__(31);
10349
10350function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10351
10352function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10353
10354function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10355
10356var DEFAULT_CACHE_SIZE = 10;
10357
10358function PDFPageViewBuffer(size) {
10359  var data = [];
10360
10361  this.push = function (view) {
10362    var i = data.indexOf(view);
10363
10364    if (i >= 0) {
10365      data.splice(i, 1);
10366    }
10367
10368    data.push(view);
10369
10370    if (data.length > size) {
10371      data.shift().destroy();
10372    }
10373  };
10374
10375  this.resize = function (newSize, pagesToKeep) {
10376    size = newSize;
10377
10378    if (pagesToKeep) {
10379      var pageIdsToKeep = new Set();
10380
10381      for (var i = 0, iMax = pagesToKeep.length; i < iMax; ++i) {
10382        pageIdsToKeep.add(pagesToKeep[i].id);
10383      }
10384
10385      (0, _ui_utils.moveToEndOfArray)(data, function (page) {
10386        return pageIdsToKeep.has(page.id);
10387      });
10388    }
10389
10390    while (data.length > size) {
10391      data.shift().destroy();
10392    }
10393  };
10394}
10395
10396function isSameScale(oldScale, newScale) {
10397  if (newScale === oldScale) {
10398    return true;
10399  }
10400
10401  if (Math.abs(newScale - oldScale) < 1e-15) {
10402    return true;
10403  }
10404
10405  return false;
10406}
10407
10408var BaseViewer =
10409/*#__PURE__*/
10410function () {
10411  function BaseViewer(options) {
10412    var _this = this;
10413
10414    _classCallCheck(this, BaseViewer);
10415
10416    if (this.constructor === BaseViewer) {
10417      throw new Error('Cannot initialize BaseViewer.');
10418    }
10419
10420    this._name = this.constructor.name;
10421    this.container = options.container;
10422    this.viewer = options.viewer || options.container.firstElementChild;
10423    this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
10424    this.linkService = options.linkService || new _pdf_link_service.SimpleLinkService();
10425    this.downloadManager = options.downloadManager || null;
10426    this.findController = options.findController || null;
10427    this.removePageBorders = options.removePageBorders || false;
10428    this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
10429    this.imageResourcesPath = options.imageResourcesPath || '';
10430    this.renderInteractiveForms = options.renderInteractiveForms || false;
10431    this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
10432    this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
10433    this.enableWebGL = options.enableWebGL || false;
10434    this.useOnlyCssZoom = options.useOnlyCssZoom || false;
10435    this.maxCanvasPixels = options.maxCanvasPixels;
10436    this.l10n = options.l10n || _ui_utils.NullL10n;
10437    this.defaultRenderingQueue = !options.renderingQueue;
10438
10439    if (this.defaultRenderingQueue) {
10440      this.renderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
10441      this.renderingQueue.setViewer(this);
10442    } else {
10443      this.renderingQueue = options.renderingQueue;
10444    }
10445
10446    this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdate.bind(this));
10447    this.presentationModeState = _ui_utils.PresentationModeState.UNKNOWN;
10448
10449    this._resetView();
10450
10451    if (this.removePageBorders) {
10452      this.viewer.classList.add('removePageBorders');
10453    }
10454
10455    Promise.resolve().then(function () {
10456      _this.eventBus.dispatch('baseviewerinit', {
10457        source: _this
10458      });
10459    });
10460  }
10461
10462  _createClass(BaseViewer, [{
10463    key: "getPageView",
10464    value: function getPageView(index) {
10465      return this._pages[index];
10466    }
10467  }, {
10468    key: "_setCurrentPageNumber",
10469    value: function _setCurrentPageNumber(val) {
10470      var resetCurrentPageView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
10471
10472      if (this._currentPageNumber === val) {
10473        if (resetCurrentPageView) {
10474          this._resetCurrentPageView();
10475        }
10476
10477        return true;
10478      }
10479
10480      if (!(0 < val && val <= this.pagesCount)) {
10481        return false;
10482      }
10483
10484      this._currentPageNumber = val;
10485      this.eventBus.dispatch('pagechanging', {
10486        source: this,
10487        pageNumber: val,
10488        pageLabel: this._pageLabels && this._pageLabels[val - 1]
10489      });
10490
10491      if (resetCurrentPageView) {
10492        this._resetCurrentPageView();
10493      }
10494
10495      return true;
10496    }
10497  }, {
10498    key: "setDocument",
10499    value: function setDocument(pdfDocument) {
10500      var _this2 = this;
10501
10502      if (this.pdfDocument) {
10503        this._cancelRendering();
10504
10505        this._resetView();
10506
10507        if (this.findController) {
10508          this.findController.setDocument(null);
10509        }
10510      }
10511
10512      this.pdfDocument = pdfDocument;
10513
10514      if (!pdfDocument) {
10515        return;
10516      }
10517
10518      var pagesCount = pdfDocument.numPages;
10519      var pagesCapability = (0, _pdfjsLib.createPromiseCapability)();
10520      this.pagesPromise = pagesCapability.promise;
10521      pagesCapability.promise.then(function () {
10522        _this2._pageViewsReady = true;
10523
10524        _this2.eventBus.dispatch('pagesloaded', {
10525          source: _this2,
10526          pagesCount: pagesCount
10527        });
10528      });
10529      var onePageRenderedCapability = (0, _pdfjsLib.createPromiseCapability)();
10530      this.onePageRendered = onePageRenderedCapability.promise;
10531
10532      var bindOnAfterAndBeforeDraw = function bindOnAfterAndBeforeDraw(pageView) {
10533        pageView.onBeforeDraw = function () {
10534          _this2._buffer.push(pageView);
10535        };
10536
10537        pageView.onAfterDraw = function () {
10538          if (!onePageRenderedCapability.settled) {
10539            onePageRenderedCapability.resolve();
10540          }
10541        };
10542      };
10543
10544      var firstPagePromise = pdfDocument.getPage(1);
10545      this.firstPagePromise = firstPagePromise;
10546      firstPagePromise.then(function (pdfPage) {
10547        var scale = _this2.currentScale;
10548        var viewport = pdfPage.getViewport({
10549          scale: scale * _ui_utils.CSS_UNITS
10550        });
10551
10552        for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
10553          var textLayerFactory = null;
10554
10555          if (_this2.textLayerMode !== _ui_utils.TextLayerMode.DISABLE) {
10556            textLayerFactory = _this2;
10557          }
10558
10559          var pageView = new _pdf_page_view.PDFPageView({
10560            container: _this2._setDocumentViewerElement,
10561            eventBus: _this2.eventBus,
10562            id: pageNum,
10563            scale: scale,
10564            defaultViewport: viewport.clone(),
10565            renderingQueue: _this2.renderingQueue,
10566            textLayerFactory: textLayerFactory,
10567            textLayerMode: _this2.textLayerMode,
10568            annotationLayerFactory: _this2,
10569            imageResourcesPath: _this2.imageResourcesPath,
10570            renderInteractiveForms: _this2.renderInteractiveForms,
10571            renderer: _this2.renderer,
10572            enableWebGL: _this2.enableWebGL,
10573            useOnlyCssZoom: _this2.useOnlyCssZoom,
10574            maxCanvasPixels: _this2.maxCanvasPixels,
10575            l10n: _this2.l10n
10576          });
10577          bindOnAfterAndBeforeDraw(pageView);
10578
10579          _this2._pages.push(pageView);
10580        }
10581
10582        if (_this2._spreadMode !== _ui_utils.SpreadMode.NONE) {
10583          _this2._updateSpreadMode();
10584        }
10585
10586        onePageRenderedCapability.promise.then(function () {
10587          if (_this2.findController) {
10588            _this2.findController.setDocument(pdfDocument);
10589          }
10590
10591          if (pdfDocument.loadingParams['disableAutoFetch']) {
10592            pagesCapability.resolve();
10593            return;
10594          }
10595
10596          var getPagesLeft = pagesCount;
10597
10598          var _loop = function _loop(_pageNum) {
10599            pdfDocument.getPage(_pageNum).then(function (pdfPage) {
10600              var pageView = _this2._pages[_pageNum - 1];
10601
10602              if (!pageView.pdfPage) {
10603                pageView.setPdfPage(pdfPage);
10604              }
10605
10606              _this2.linkService.cachePageRef(_pageNum, pdfPage.ref);
10607
10608              if (--getPagesLeft === 0) {
10609                pagesCapability.resolve();
10610              }
10611            }, function (reason) {
10612              console.error("Unable to get page ".concat(_pageNum, " to initialize viewer"), reason);
10613
10614              if (--getPagesLeft === 0) {
10615                pagesCapability.resolve();
10616              }
10617            });
10618          };
10619
10620          for (var _pageNum = 1; _pageNum <= pagesCount; ++_pageNum) {
10621            _loop(_pageNum);
10622          }
10623        });
10624
10625        _this2.eventBus.dispatch('pagesinit', {
10626          source: _this2
10627        });
10628
10629        if (_this2.defaultRenderingQueue) {
10630          _this2.update();
10631        }
10632      })["catch"](function (reason) {
10633        console.error('Unable to initialize viewer', reason);
10634      });
10635    }
10636  }, {
10637    key: "setPageLabels",
10638    value: function setPageLabels(labels) {
10639      if (!this.pdfDocument) {
10640        return;
10641      }
10642
10643      if (!labels) {
10644        this._pageLabels = null;
10645      } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
10646        this._pageLabels = null;
10647        console.error("".concat(this._name, ".setPageLabels: Invalid page labels."));
10648      } else {
10649        this._pageLabels = labels;
10650      }
10651
10652      for (var i = 0, ii = this._pages.length; i < ii; i++) {
10653        var pageView = this._pages[i];
10654        var label = this._pageLabels && this._pageLabels[i];
10655        pageView.setPageLabel(label);
10656      }
10657    }
10658  }, {
10659    key: "_resetView",
10660    value: function _resetView() {
10661      this._pages = [];
10662      this._currentPageNumber = 1;
10663      this._currentScale = _ui_utils.UNKNOWN_SCALE;
10664      this._currentScaleValue = null;
10665      this._pageLabels = null;
10666      this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
10667      this._location = null;
10668      this._pagesRotation = 0;
10669      this._pagesRequests = [];
10670      this._pageViewsReady = false;
10671      this._scrollMode = _ui_utils.ScrollMode.VERTICAL;
10672      this._spreadMode = _ui_utils.SpreadMode.NONE;
10673      this.viewer.textContent = '';
10674
10675      this._updateScrollMode();
10676    }
10677  }, {
10678    key: "_scrollUpdate",
10679    value: function _scrollUpdate() {
10680      if (this.pagesCount === 0) {
10681        return;
10682      }
10683
10684      this.update();
10685    }
10686  }, {
10687    key: "_scrollIntoView",
10688    value: function _scrollIntoView(_ref) {
10689      var pageDiv = _ref.pageDiv,
10690          _ref$pageSpot = _ref.pageSpot,
10691          pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
10692          _ref$pageNumber = _ref.pageNumber,
10693          pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
10694      (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot);
10695    }
10696  }, {
10697    key: "_setScaleUpdatePages",
10698    value: function _setScaleUpdatePages(newScale, newValue) {
10699      var noScroll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
10700      var preset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
10701      this._currentScaleValue = newValue.toString();
10702
10703      if (isSameScale(this._currentScale, newScale)) {
10704        if (preset) {
10705          this.eventBus.dispatch('scalechanging', {
10706            source: this,
10707            scale: newScale,
10708            presetValue: newValue
10709          });
10710        }
10711
10712        return;
10713      }
10714
10715      for (var i = 0, ii = this._pages.length; i < ii; i++) {
10716        this._pages[i].update(newScale);
10717      }
10718
10719      this._currentScale = newScale;
10720
10721      if (!noScroll) {
10722        var page = this._currentPageNumber,
10723            dest;
10724
10725        if (this._location && !(this.isInPresentationMode || this.isChangingPresentationMode)) {
10726          page = this._location.pageNumber;
10727          dest = [null, {
10728            name: 'XYZ'
10729          }, this._location.left, this._location.top, null];
10730        }
10731
10732        this.scrollPageIntoView({
10733          pageNumber: page,
10734          destArray: dest,
10735          allowNegativeOffset: true
10736        });
10737      }
10738
10739      this.eventBus.dispatch('scalechanging', {
10740        source: this,
10741        scale: newScale,
10742        presetValue: preset ? newValue : undefined
10743      });
10744
10745      if (this.defaultRenderingQueue) {
10746        this.update();
10747      }
10748    }
10749  }, {
10750    key: "_setScale",
10751    value: function _setScale(value) {
10752      var noScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
10753      var scale = parseFloat(value);
10754
10755      if (scale > 0) {
10756        this._setScaleUpdatePages(scale, value, noScroll, false);
10757      } else {
10758        var currentPage = this._pages[this._currentPageNumber - 1];
10759
10760        if (!currentPage) {
10761          return;
10762        }
10763
10764        var noPadding = this.isInPresentationMode || this.removePageBorders;
10765        var hPadding = noPadding ? 0 : _ui_utils.SCROLLBAR_PADDING;
10766        var vPadding = noPadding ? 0 : _ui_utils.VERTICAL_PADDING;
10767
10768        if (!noPadding && this._isScrollModeHorizontal) {
10769          var _ref2 = [vPadding, hPadding];
10770          hPadding = _ref2[0];
10771          vPadding = _ref2[1];
10772        }
10773
10774        var pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
10775        var pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;
10776
10777        switch (value) {
10778          case 'page-actual':
10779            scale = 1;
10780            break;
10781
10782          case 'page-width':
10783            scale = pageWidthScale;
10784            break;
10785
10786          case 'page-height':
10787            scale = pageHeightScale;
10788            break;
10789
10790          case 'page-fit':
10791            scale = Math.min(pageWidthScale, pageHeightScale);
10792            break;
10793
10794          case 'auto':
10795            var horizontalScale = (0, _ui_utils.isPortraitOrientation)(currentPage) ? pageWidthScale : Math.min(pageHeightScale, pageWidthScale);
10796            scale = Math.min(_ui_utils.MAX_AUTO_SCALE, horizontalScale);
10797            break;
10798
10799          default:
10800            console.error("".concat(this._name, "._setScale: \"").concat(value, "\" is an unknown zoom value."));
10801            return;
10802        }
10803
10804        this._setScaleUpdatePages(scale, value, noScroll, true);
10805      }
10806    }
10807  }, {
10808    key: "_resetCurrentPageView",
10809    value: function _resetCurrentPageView() {
10810      if (this.isInPresentationMode) {
10811        this._setScale(this._currentScaleValue, true);
10812      }
10813
10814      var pageView = this._pages[this._currentPageNumber - 1];
10815
10816      this._scrollIntoView({
10817        pageDiv: pageView.div
10818      });
10819    }
10820  }, {
10821    key: "scrollPageIntoView",
10822    value: function scrollPageIntoView(_ref3) {
10823      var pageNumber = _ref3.pageNumber,
10824          _ref3$destArray = _ref3.destArray,
10825          destArray = _ref3$destArray === void 0 ? null : _ref3$destArray,
10826          _ref3$allowNegativeOf = _ref3.allowNegativeOffset,
10827          allowNegativeOffset = _ref3$allowNegativeOf === void 0 ? false : _ref3$allowNegativeOf;
10828
10829      if (!this.pdfDocument) {
10830        return;
10831      }
10832
10833      var pageView = Number.isInteger(pageNumber) && this._pages[pageNumber - 1];
10834
10835      if (!pageView) {
10836        console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(pageNumber, "\" is not a valid pageNumber parameter."));
10837        return;
10838      }
10839
10840      if (this.isInPresentationMode || !destArray) {
10841        this._setCurrentPageNumber(pageNumber, true);
10842
10843        return;
10844      }
10845
10846      var x = 0,
10847          y = 0;
10848      var width = 0,
10849          height = 0,
10850          widthScale,
10851          heightScale;
10852      var changeOrientation = pageView.rotation % 180 === 0 ? false : true;
10853      var pageWidth = (changeOrientation ? pageView.height : pageView.width) / pageView.scale / _ui_utils.CSS_UNITS;
10854      var pageHeight = (changeOrientation ? pageView.width : pageView.height) / pageView.scale / _ui_utils.CSS_UNITS;
10855      var scale = 0;
10856
10857      switch (destArray[1].name) {
10858        case 'XYZ':
10859          x = destArray[2];
10860          y = destArray[3];
10861          scale = destArray[4];
10862          x = x !== null ? x : 0;
10863          y = y !== null ? y : pageHeight;
10864          break;
10865
10866        case 'Fit':
10867        case 'FitB':
10868          scale = 'page-fit';
10869          break;
10870
10871        case 'FitH':
10872        case 'FitBH':
10873          y = destArray[2];
10874          scale = 'page-width';
10875
10876          if (y === null && this._location) {
10877            x = this._location.left;
10878            y = this._location.top;
10879          }
10880
10881          break;
10882
10883        case 'FitV':
10884        case 'FitBV':
10885          x = destArray[2];
10886          width = pageWidth;
10887          height = pageHeight;
10888          scale = 'page-height';
10889          break;
10890
10891        case 'FitR':
10892          x = destArray[2];
10893          y = destArray[3];
10894          width = destArray[4] - x;
10895          height = destArray[5] - y;
10896          var hPadding = this.removePageBorders ? 0 : _ui_utils.SCROLLBAR_PADDING;
10897          var vPadding = this.removePageBorders ? 0 : _ui_utils.VERTICAL_PADDING;
10898          widthScale = (this.container.clientWidth - hPadding) / width / _ui_utils.CSS_UNITS;
10899          heightScale = (this.container.clientHeight - vPadding) / height / _ui_utils.CSS_UNITS;
10900          scale = Math.min(Math.abs(widthScale), Math.abs(heightScale));
10901          break;
10902
10903        default:
10904          console.error("".concat(this._name, ".scrollPageIntoView: ") + "\"".concat(destArray[1].name, "\" is not a valid destination type."));
10905          return;
10906      }
10907
10908      if (scale && scale !== this._currentScale) {
10909        this.currentScaleValue = scale;
10910      } else if (this._currentScale === _ui_utils.UNKNOWN_SCALE) {
10911        this.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
10912      }
10913
10914      if (scale === 'page-fit' && !destArray[4]) {
10915        this._scrollIntoView({
10916          pageDiv: pageView.div,
10917          pageNumber: pageNumber
10918        });
10919
10920        return;
10921      }
10922
10923      var boundingRect = [pageView.viewport.convertToViewportPoint(x, y), pageView.viewport.convertToViewportPoint(x + width, y + height)];
10924      var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
10925      var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
10926
10927      if (!allowNegativeOffset) {
10928        left = Math.max(left, 0);
10929        top = Math.max(top, 0);
10930      }
10931
10932      this._scrollIntoView({
10933        pageDiv: pageView.div,
10934        pageSpot: {
10935          left: left,
10936          top: top
10937        },
10938        pageNumber: pageNumber
10939      });
10940    }
10941  }, {
10942    key: "_updateLocation",
10943    value: function _updateLocation(firstPage) {
10944      var currentScale = this._currentScale;
10945      var currentScaleValue = this._currentScaleValue;
10946      var normalizedScaleValue = parseFloat(currentScaleValue) === currentScale ? Math.round(currentScale * 10000) / 100 : currentScaleValue;
10947      var pageNumber = firstPage.id;
10948      var pdfOpenParams = '#page=' + pageNumber;
10949      pdfOpenParams += '&zoom=' + normalizedScaleValue;
10950      var currentPageView = this._pages[pageNumber - 1];
10951      var container = this.container;
10952      var topLeft = currentPageView.getPagePoint(container.scrollLeft - firstPage.x, container.scrollTop - firstPage.y);
10953      var intLeft = Math.round(topLeft[0]);
10954      var intTop = Math.round(topLeft[1]);
10955      pdfOpenParams += ',' + intLeft + ',' + intTop;
10956      this._location = {
10957        pageNumber: pageNumber,
10958        scale: normalizedScaleValue,
10959        top: intTop,
10960        left: intLeft,
10961        rotation: this._pagesRotation,
10962        pdfOpenParams: pdfOpenParams
10963      };
10964    }
10965  }, {
10966    key: "_updateHelper",
10967    value: function _updateHelper(visiblePages) {
10968      throw new Error('Not implemented: _updateHelper');
10969    }
10970  }, {
10971    key: "update",
10972    value: function update() {
10973      var visible = this._getVisiblePages();
10974
10975      var visiblePages = visible.views,
10976          numVisiblePages = visiblePages.length;
10977
10978      if (numVisiblePages === 0) {
10979        return;
10980      }
10981
10982      var newCacheSize = Math.max(DEFAULT_CACHE_SIZE, 2 * numVisiblePages + 1);
10983
10984      this._buffer.resize(newCacheSize, visiblePages);
10985
10986      this.renderingQueue.renderHighestPriority(visible);
10987
10988      this._updateHelper(visiblePages);
10989
10990      this._updateLocation(visible.first);
10991
10992      this.eventBus.dispatch('updateviewarea', {
10993        source: this,
10994        location: this._location
10995      });
10996    }
10997  }, {
10998    key: "containsElement",
10999    value: function containsElement(element) {
11000      return this.container.contains(element);
11001    }
11002  }, {
11003    key: "focus",
11004    value: function focus() {
11005      this.container.focus();
11006    }
11007  }, {
11008    key: "_getCurrentVisiblePage",
11009    value: function _getCurrentVisiblePage() {
11010      if (!this.pagesCount) {
11011        return {
11012          views: []
11013        };
11014      }
11015
11016      var pageView = this._pages[this._currentPageNumber - 1];
11017      var element = pageView.div;
11018      var view = {
11019        id: pageView.id,
11020        x: element.offsetLeft + element.clientLeft,
11021        y: element.offsetTop + element.clientTop,
11022        view: pageView
11023      };
11024      return {
11025        first: view,
11026        last: view,
11027        views: [view]
11028      };
11029    }
11030  }, {
11031    key: "_getVisiblePages",
11032    value: function _getVisiblePages() {
11033      return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._isScrollModeHorizontal);
11034    }
11035  }, {
11036    key: "isPageVisible",
11037    value: function isPageVisible(pageNumber) {
11038      if (!this.pdfDocument) {
11039        return false;
11040      }
11041
11042      if (this.pageNumber < 1 || pageNumber > this.pagesCount) {
11043        console.error("".concat(this._name, ".isPageVisible: \"").concat(pageNumber, "\" is out of bounds."));
11044        return false;
11045      }
11046
11047      return this._getVisiblePages().views.some(function (view) {
11048        return view.id === pageNumber;
11049      });
11050    }
11051  }, {
11052    key: "cleanup",
11053    value: function cleanup() {
11054      for (var i = 0, ii = this._pages.length; i < ii; i++) {
11055        if (this._pages[i] && this._pages[i].renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED) {
11056          this._pages[i].reset();
11057        }
11058      }
11059    }
11060  }, {
11061    key: "_cancelRendering",
11062    value: function _cancelRendering() {
11063      for (var i = 0, ii = this._pages.length; i < ii; i++) {
11064        if (this._pages[i]) {
11065          this._pages[i].cancelRendering();
11066        }
11067      }
11068    }
11069  }, {
11070    key: "_ensurePdfPageLoaded",
11071    value: function _ensurePdfPageLoaded(pageView) {
11072      var _this3 = this;
11073
11074      if (pageView.pdfPage) {
11075        return Promise.resolve(pageView.pdfPage);
11076      }
11077
11078      var pageNumber = pageView.id;
11079
11080      if (this._pagesRequests[pageNumber]) {
11081        return this._pagesRequests[pageNumber];
11082      }
11083
11084      var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
11085        if (!pageView.pdfPage) {
11086          pageView.setPdfPage(pdfPage);
11087        }
11088
11089        _this3._pagesRequests[pageNumber] = null;
11090        return pdfPage;
11091      })["catch"](function (reason) {
11092        console.error('Unable to get page for page view', reason);
11093        _this3._pagesRequests[pageNumber] = null;
11094      });
11095      this._pagesRequests[pageNumber] = promise;
11096      return promise;
11097    }
11098  }, {
11099    key: "forceRendering",
11100    value: function forceRendering(currentlyVisiblePages) {
11101      var _this4 = this;
11102
11103      var visiblePages = currentlyVisiblePages || this._getVisiblePages();
11104
11105      var scrollAhead = this._isScrollModeHorizontal ? this.scroll.right : this.scroll.down;
11106      var pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, scrollAhead);
11107
11108      if (pageView) {
11109        this._ensurePdfPageLoaded(pageView).then(function () {
11110          _this4.renderingQueue.renderView(pageView);
11111        });
11112
11113        return true;
11114      }
11115
11116      return false;
11117    }
11118  }, {
11119    key: "createTextLayerBuilder",
11120    value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
11121      var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
11122      return new _text_layer_builder.TextLayerBuilder({
11123        textLayerDiv: textLayerDiv,
11124        eventBus: this.eventBus,
11125        pageIndex: pageIndex,
11126        viewport: viewport,
11127        findController: this.isInPresentationMode ? null : this.findController,
11128        enhanceTextSelection: this.isInPresentationMode ? false : enhanceTextSelection
11129      });
11130    }
11131  }, {
11132    key: "createAnnotationLayerBuilder",
11133    value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
11134      var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
11135      var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
11136      var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
11137      return new _annotation_layer_builder.AnnotationLayerBuilder({
11138        pageDiv: pageDiv,
11139        pdfPage: pdfPage,
11140        imageResourcesPath: imageResourcesPath,
11141        renderInteractiveForms: renderInteractiveForms,
11142        linkService: this.linkService,
11143        downloadManager: this.downloadManager,
11144        l10n: l10n
11145      });
11146    }
11147  }, {
11148    key: "getPagesOverview",
11149    value: function getPagesOverview() {
11150      var pagesOverview = this._pages.map(function (pageView) {
11151        var viewport = pageView.pdfPage.getViewport({
11152          scale: 1
11153        });
11154        return {
11155          width: viewport.width,
11156          height: viewport.height,
11157          rotation: viewport.rotation
11158        };
11159      });
11160
11161      if (!this.enablePrintAutoRotate) {
11162        return pagesOverview;
11163      }
11164
11165      var isFirstPagePortrait = (0, _ui_utils.isPortraitOrientation)(pagesOverview[0]);
11166      return pagesOverview.map(function (size) {
11167        if (isFirstPagePortrait === (0, _ui_utils.isPortraitOrientation)(size)) {
11168          return size;
11169        }
11170
11171        return {
11172          width: size.height,
11173          height: size.width,
11174          rotation: (size.rotation + 90) % 360
11175        };
11176      });
11177    }
11178  }, {
11179    key: "_updateScrollMode",
11180    value: function _updateScrollMode() {
11181      var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
11182      var scrollMode = this._scrollMode,
11183          viewer = this.viewer;
11184      viewer.classList.toggle('scrollHorizontal', scrollMode === _ui_utils.ScrollMode.HORIZONTAL);
11185      viewer.classList.toggle('scrollWrapped', scrollMode === _ui_utils.ScrollMode.WRAPPED);
11186
11187      if (!this.pdfDocument || !pageNumber) {
11188        return;
11189      }
11190
11191      if (this._currentScaleValue && isNaN(this._currentScaleValue)) {
11192        this._setScale(this._currentScaleValue, true);
11193      }
11194
11195      this._setCurrentPageNumber(pageNumber, true);
11196
11197      this.update();
11198    }
11199  }, {
11200    key: "_updateSpreadMode",
11201    value: function _updateSpreadMode() {
11202      var pageNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
11203
11204      if (!this.pdfDocument) {
11205        return;
11206      }
11207
11208      var viewer = this.viewer,
11209          pages = this._pages;
11210      viewer.textContent = '';
11211
11212      if (this._spreadMode === _ui_utils.SpreadMode.NONE) {
11213        for (var i = 0, iMax = pages.length; i < iMax; ++i) {
11214          viewer.appendChild(pages[i].div);
11215        }
11216      } else {
11217        var parity = this._spreadMode - 1;
11218        var spread = null;
11219
11220        for (var _i = 0, _iMax = pages.length; _i < _iMax; ++_i) {
11221          if (spread === null) {
11222            spread = document.createElement('div');
11223            spread.className = 'spread';
11224            viewer.appendChild(spread);
11225          } else if (_i % 2 === parity) {
11226            spread = spread.cloneNode(false);
11227            viewer.appendChild(spread);
11228          }
11229
11230          spread.appendChild(pages[_i].div);
11231        }
11232      }
11233
11234      if (!pageNumber) {
11235        return;
11236      }
11237
11238      this._setCurrentPageNumber(pageNumber, true);
11239
11240      this.update();
11241    }
11242  }, {
11243    key: "pagesCount",
11244    get: function get() {
11245      return this._pages.length;
11246    }
11247  }, {
11248    key: "pageViewsReady",
11249    get: function get() {
11250      return this._pageViewsReady;
11251    }
11252  }, {
11253    key: "currentPageNumber",
11254    get: function get() {
11255      return this._currentPageNumber;
11256    },
11257    set: function set(val) {
11258      if (!Number.isInteger(val)) {
11259        throw new Error('Invalid page number.');
11260      }
11261
11262      if (!this.pdfDocument) {
11263        return;
11264      }
11265
11266      if (!this._setCurrentPageNumber(val, true)) {
11267        console.error("".concat(this._name, ".currentPageNumber: \"").concat(val, "\" is not a valid page."));
11268      }
11269    }
11270  }, {
11271    key: "currentPageLabel",
11272    get: function get() {
11273      return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
11274    },
11275    set: function set(val) {
11276      if (!this.pdfDocument) {
11277        return;
11278      }
11279
11280      var page = val | 0;
11281
11282      if (this._pageLabels) {
11283        var i = this._pageLabels.indexOf(val);
11284
11285        if (i >= 0) {
11286          page = i + 1;
11287        }
11288      }
11289
11290      if (!this._setCurrentPageNumber(page, true)) {
11291        console.error("".concat(this._name, ".currentPageLabel: \"").concat(val, "\" is not a valid page."));
11292      }
11293    }
11294  }, {
11295    key: "currentScale",
11296    get: function get() {
11297      return this._currentScale !== _ui_utils.UNKNOWN_SCALE ? this._currentScale : _ui_utils.DEFAULT_SCALE;
11298    },
11299    set: function set(val) {
11300      if (isNaN(val)) {
11301        throw new Error('Invalid numeric scale.');
11302      }
11303
11304      if (!this.pdfDocument) {
11305        return;
11306      }
11307
11308      this._setScale(val, false);
11309    }
11310  }, {
11311    key: "currentScaleValue",
11312    get: function get() {
11313      return this._currentScaleValue;
11314    },
11315    set: function set(val) {
11316      if (!this.pdfDocument) {
11317        return;
11318      }
11319
11320      this._setScale(val, false);
11321    }
11322  }, {
11323    key: "pagesRotation",
11324    get: function get() {
11325      return this._pagesRotation;
11326    },
11327    set: function set(rotation) {
11328      if (!(0, _ui_utils.isValidRotation)(rotation)) {
11329        throw new Error('Invalid pages rotation angle.');
11330      }
11331
11332      if (!this.pdfDocument) {
11333        return;
11334      }
11335
11336      if (this._pagesRotation === rotation) {
11337        return;
11338      }
11339
11340      this._pagesRotation = rotation;
11341      var pageNumber = this._currentPageNumber;
11342
11343      for (var i = 0, ii = this._pages.length; i < ii; i++) {
11344        var pageView = this._pages[i];
11345        pageView.update(pageView.scale, rotation);
11346      }
11347
11348      if (this._currentScaleValue) {
11349        this._setScale(this._currentScaleValue, true);
11350      }
11351
11352      this.eventBus.dispatch('rotationchanging', {
11353        source: this,
11354        pagesRotation: rotation,
11355        pageNumber: pageNumber
11356      });
11357
11358      if (this.defaultRenderingQueue) {
11359        this.update();
11360      }
11361    }
11362  }, {
11363    key: "_setDocumentViewerElement",
11364    get: function get() {
11365      throw new Error('Not implemented: _setDocumentViewerElement');
11366    }
11367  }, {
11368    key: "_isScrollModeHorizontal",
11369    get: function get() {
11370      return this.isInPresentationMode ? false : this._scrollMode === _ui_utils.ScrollMode.HORIZONTAL;
11371    }
11372  }, {
11373    key: "isInPresentationMode",
11374    get: function get() {
11375      return this.presentationModeState === _ui_utils.PresentationModeState.FULLSCREEN;
11376    }
11377  }, {
11378    key: "isChangingPresentationMode",
11379    get: function get() {
11380      return this.presentationModeState === _ui_utils.PresentationModeState.CHANGING;
11381    }
11382  }, {
11383    key: "isHorizontalScrollbarEnabled",
11384    get: function get() {
11385      return this.isInPresentationMode ? false : this.container.scrollWidth > this.container.clientWidth;
11386    }
11387  }, {
11388    key: "isVerticalScrollbarEnabled",
11389    get: function get() {
11390      return this.isInPresentationMode ? false : this.container.scrollHeight > this.container.clientHeight;
11391    }
11392  }, {
11393    key: "hasEqualPageSizes",
11394    get: function get() {
11395      var firstPageView = this._pages[0];
11396
11397      for (var i = 1, ii = this._pages.length; i < ii; ++i) {
11398        var pageView = this._pages[i];
11399
11400        if (pageView.width !== firstPageView.width || pageView.height !== firstPageView.height) {
11401          return false;
11402        }
11403      }
11404
11405      return true;
11406    }
11407  }, {
11408    key: "scrollMode",
11409    get: function get() {
11410      return this._scrollMode;
11411    },
11412    set: function set(mode) {
11413      if (this._scrollMode === mode) {
11414        return;
11415      }
11416
11417      if (!(0, _ui_utils.isValidScrollMode)(mode)) {
11418        throw new Error("Invalid scroll mode: ".concat(mode));
11419      }
11420
11421      this._scrollMode = mode;
11422      this.eventBus.dispatch('scrollmodechanged', {
11423        source: this,
11424        mode: mode
11425      });
11426
11427      this._updateScrollMode(this._currentPageNumber);
11428    }
11429  }, {
11430    key: "spreadMode",
11431    get: function get() {
11432      return this._spreadMode;
11433    },
11434    set: function set(mode) {
11435      if (this._spreadMode === mode) {
11436        return;
11437      }
11438
11439      if (!(0, _ui_utils.isValidSpreadMode)(mode)) {
11440        throw new Error("Invalid spread mode: ".concat(mode));
11441      }
11442
11443      this._spreadMode = mode;
11444      this.eventBus.dispatch('spreadmodechanged', {
11445        source: this,
11446        mode: mode
11447      });
11448
11449      this._updateSpreadMode(this._currentPageNumber);
11450    }
11451  }]);
11452
11453  return BaseViewer;
11454}();
11455
11456exports.BaseViewer = BaseViewer;
11457
11458/***/ }),
11459/* 29 */
11460/***/ (function(module, exports, __webpack_require__) {
11461
11462"use strict";
11463
11464
11465Object.defineProperty(exports, "__esModule", {
11466  value: true
11467});
11468exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
11469
11470var _pdfjsLib = __webpack_require__(7);
11471
11472var _ui_utils = __webpack_require__(5);
11473
11474var _pdf_link_service = __webpack_require__(21);
11475
11476function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11477
11478function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11479
11480function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11481
11482var AnnotationLayerBuilder =
11483/*#__PURE__*/
11484function () {
11485  function AnnotationLayerBuilder(_ref) {
11486    var pageDiv = _ref.pageDiv,
11487        pdfPage = _ref.pdfPage,
11488        linkService = _ref.linkService,
11489        downloadManager = _ref.downloadManager,
11490        _ref$imageResourcesPa = _ref.imageResourcesPath,
11491        imageResourcesPath = _ref$imageResourcesPa === void 0 ? '' : _ref$imageResourcesPa,
11492        _ref$renderInteractiv = _ref.renderInteractiveForms,
11493        renderInteractiveForms = _ref$renderInteractiv === void 0 ? false : _ref$renderInteractiv,
11494        _ref$l10n = _ref.l10n,
11495        l10n = _ref$l10n === void 0 ? _ui_utils.NullL10n : _ref$l10n;
11496
11497    _classCallCheck(this, AnnotationLayerBuilder);
11498
11499    this.pageDiv = pageDiv;
11500    this.pdfPage = pdfPage;
11501    this.linkService = linkService;
11502    this.downloadManager = downloadManager;
11503    this.imageResourcesPath = imageResourcesPath;
11504    this.renderInteractiveForms = renderInteractiveForms;
11505    this.l10n = l10n;
11506    this.div = null;
11507    this._cancelled = false;
11508  }
11509
11510  _createClass(AnnotationLayerBuilder, [{
11511    key: "render",
11512    value: function render(viewport) {
11513      var _this = this;
11514
11515      var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
11516      this.pdfPage.getAnnotations({
11517        intent: intent
11518      }).then(function (annotations) {
11519        if (_this._cancelled) {
11520          return;
11521        }
11522
11523        var parameters = {
11524          viewport: viewport.clone({
11525            dontFlip: true
11526          }),
11527          div: _this.div,
11528          annotations: annotations,
11529          page: _this.pdfPage,
11530          imageResourcesPath: _this.imageResourcesPath,
11531          renderInteractiveForms: _this.renderInteractiveForms,
11532          linkService: _this.linkService,
11533          downloadManager: _this.downloadManager
11534        };
11535
11536        if (_this.div) {
11537          _pdfjsLib.AnnotationLayer.update(parameters);
11538        } else {
11539          if (annotations.length === 0) {
11540            return;
11541          }
11542
11543          _this.div = document.createElement('div');
11544          _this.div.className = 'annotationLayer';
11545
11546          _this.pageDiv.appendChild(_this.div);
11547
11548          parameters.div = _this.div;
11549
11550          _pdfjsLib.AnnotationLayer.render(parameters);
11551
11552          _this.l10n.translate(_this.div);
11553        }
11554      });
11555    }
11556  }, {
11557    key: "cancel",
11558    value: function cancel() {
11559      this._cancelled = true;
11560    }
11561  }, {
11562    key: "hide",
11563    value: function hide() {
11564      if (!this.div) {
11565        return;
11566      }
11567
11568      this.div.setAttribute('hidden', 'true');
11569    }
11570  }]);
11571
11572  return AnnotationLayerBuilder;
11573}();
11574
11575exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
11576
11577var DefaultAnnotationLayerFactory =
11578/*#__PURE__*/
11579function () {
11580  function DefaultAnnotationLayerFactory() {
11581    _classCallCheck(this, DefaultAnnotationLayerFactory);
11582  }
11583
11584  _createClass(DefaultAnnotationLayerFactory, [{
11585    key: "createAnnotationLayerBuilder",
11586    value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
11587      var imageResourcesPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
11588      var renderInteractiveForms = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
11589      var l10n = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _ui_utils.NullL10n;
11590      return new AnnotationLayerBuilder({
11591        pageDiv: pageDiv,
11592        pdfPage: pdfPage,
11593        imageResourcesPath: imageResourcesPath,
11594        renderInteractiveForms: renderInteractiveForms,
11595        linkService: new _pdf_link_service.SimpleLinkService(),
11596        l10n: l10n
11597      });
11598    }
11599  }]);
11600
11601  return DefaultAnnotationLayerFactory;
11602}();
11603
11604exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
11605
11606/***/ }),
11607/* 30 */
11608/***/ (function(module, exports, __webpack_require__) {
11609
11610"use strict";
11611
11612
11613Object.defineProperty(exports, "__esModule", {
11614  value: true
11615});
11616exports.PDFPageView = void 0;
11617
11618var _regenerator = _interopRequireDefault(__webpack_require__(2));
11619
11620var _ui_utils = __webpack_require__(5);
11621
11622var _pdfjsLib = __webpack_require__(7);
11623
11624var _pdf_rendering_queue = __webpack_require__(11);
11625
11626var _viewer_compatibility = __webpack_require__(8);
11627
11628function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11629
11630function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11631
11632function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11633
11634function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11635
11636function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
11637
11638function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
11639
11640var MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
11641
11642var PDFPageView =
11643/*#__PURE__*/
11644function () {
11645  function PDFPageView(options) {
11646    _classCallCheck(this, PDFPageView);
11647
11648    var container = options.container;
11649    var defaultViewport = options.defaultViewport;
11650    this.id = options.id;
11651    this.renderingId = 'page' + this.id;
11652    this.pdfPage = null;
11653    this.pageLabel = null;
11654    this.rotation = 0;
11655    this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
11656    this.viewport = defaultViewport;
11657    this.pdfPageRotate = defaultViewport.rotation;
11658    this.hasRestrictedScaling = false;
11659    this.textLayerMode = Number.isInteger(options.textLayerMode) ? options.textLayerMode : _ui_utils.TextLayerMode.ENABLE;
11660    this.imageResourcesPath = options.imageResourcesPath || '';
11661    this.renderInteractiveForms = options.renderInteractiveForms || false;
11662    this.useOnlyCssZoom = options.useOnlyCssZoom || false;
11663    this.maxCanvasPixels = options.maxCanvasPixels || MAX_CANVAS_PIXELS;
11664    this.eventBus = options.eventBus || (0, _ui_utils.getGlobalEventBus)();
11665    this.renderingQueue = options.renderingQueue;
11666    this.textLayerFactory = options.textLayerFactory;
11667    this.annotationLayerFactory = options.annotationLayerFactory;
11668    this.renderer = options.renderer || _ui_utils.RendererType.CANVAS;
11669    this.enableWebGL = options.enableWebGL || false;
11670    this.l10n = options.l10n || _ui_utils.NullL10n;
11671    this.paintTask = null;
11672    this.paintedViewportMap = new WeakMap();
11673    this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
11674    this.resume = null;
11675    this.error = null;
11676    this.onBeforeDraw = null;
11677    this.onAfterDraw = null;
11678    this.annotationLayer = null;
11679    this.textLayer = null;
11680    this.zoomLayer = null;
11681    var div = document.createElement('div');
11682    div.className = 'page';
11683    div.style.width = Math.floor(this.viewport.width) + 'px';
11684    div.style.height = Math.floor(this.viewport.height) + 'px';
11685    div.setAttribute('data-page-number', this.id);
11686    this.div = div;
11687    container.appendChild(div);
11688  }
11689
11690  _createClass(PDFPageView, [{
11691    key: "setPdfPage",
11692    value: function setPdfPage(pdfPage) {
11693      this.pdfPage = pdfPage;
11694      this.pdfPageRotate = pdfPage.rotate;
11695      var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
11696      this.viewport = pdfPage.getViewport({
11697        scale: this.scale * _ui_utils.CSS_UNITS,
11698        rotation: totalRotation
11699      });
11700      this.stats = pdfPage.stats;
11701      this.reset();
11702    }
11703  }, {
11704    key: "destroy",
11705    value: function destroy() {
11706      this.reset();
11707
11708      if (this.pdfPage) {
11709        this.pdfPage.cleanup();
11710      }
11711    }
11712  }, {
11713    key: "_resetZoomLayer",
11714    value: function _resetZoomLayer() {
11715      var removeFromDOM = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11716
11717      if (!this.zoomLayer) {
11718        return;
11719      }
11720
11721      var zoomLayerCanvas = this.zoomLayer.firstChild;
11722      this.paintedViewportMap["delete"](zoomLayerCanvas);
11723      zoomLayerCanvas.width = 0;
11724      zoomLayerCanvas.height = 0;
11725
11726      if (removeFromDOM) {
11727        this.zoomLayer.remove();
11728      }
11729
11730      this.zoomLayer = null;
11731    }
11732  }, {
11733    key: "reset",
11734    value: function reset() {
11735      var keepZoomLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11736      var keepAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
11737      this.cancelRendering(keepAnnotations);
11738      this.renderingState = _pdf_rendering_queue.RenderingStates.INITIAL;
11739      var div = this.div;
11740      div.style.width = Math.floor(this.viewport.width) + 'px';
11741      div.style.height = Math.floor(this.viewport.height) + 'px';
11742      var childNodes = div.childNodes;
11743      var currentZoomLayerNode = keepZoomLayer && this.zoomLayer || null;
11744      var currentAnnotationNode = keepAnnotations && this.annotationLayer && this.annotationLayer.div || null;
11745
11746      for (var i = childNodes.length - 1; i >= 0; i--) {
11747        var node = childNodes[i];
11748
11749        if (currentZoomLayerNode === node || currentAnnotationNode === node) {
11750          continue;
11751        }
11752
11753        div.removeChild(node);
11754      }
11755
11756      div.removeAttribute('data-loaded');
11757
11758      if (currentAnnotationNode) {
11759        this.annotationLayer.hide();
11760      } else if (this.annotationLayer) {
11761        this.annotationLayer.cancel();
11762        this.annotationLayer = null;
11763      }
11764
11765      if (!currentZoomLayerNode) {
11766        if (this.canvas) {
11767          this.paintedViewportMap["delete"](this.canvas);
11768          this.canvas.width = 0;
11769          this.canvas.height = 0;
11770          delete this.canvas;
11771        }
11772
11773        this._resetZoomLayer();
11774      }
11775
11776      if (this.svg) {
11777        this.paintedViewportMap["delete"](this.svg);
11778        delete this.svg;
11779      }
11780
11781      this.loadingIconDiv = document.createElement('div');
11782      this.loadingIconDiv.className = 'loadingIcon';
11783      div.appendChild(this.loadingIconDiv);
11784    }
11785  }, {
11786    key: "update",
11787    value: function update(scale, rotation) {
11788      this.scale = scale || this.scale;
11789
11790      if (typeof rotation !== 'undefined') {
11791        this.rotation = rotation;
11792      }
11793
11794      var totalRotation = (this.rotation + this.pdfPageRotate) % 360;
11795      this.viewport = this.viewport.clone({
11796        scale: this.scale * _ui_utils.CSS_UNITS,
11797        rotation: totalRotation
11798      });
11799
11800      if (this.svg) {
11801        this.cssTransform(this.svg, true);
11802        this.eventBus.dispatch('pagerendered', {
11803          source: this,
11804          pageNumber: this.id,
11805          cssTransform: true
11806        });
11807        return;
11808      }
11809
11810      var isScalingRestricted = false;
11811
11812      if (this.canvas && this.maxCanvasPixels > 0) {
11813        var outputScale = this.outputScale;
11814
11815        if ((Math.floor(this.viewport.width) * outputScale.sx | 0) * (Math.floor(this.viewport.height) * outputScale.sy | 0) > this.maxCanvasPixels) {
11816          isScalingRestricted = true;
11817        }
11818      }
11819
11820      if (this.canvas) {
11821        if (this.useOnlyCssZoom || this.hasRestrictedScaling && isScalingRestricted) {
11822          this.cssTransform(this.canvas, true);
11823          this.eventBus.dispatch('pagerendered', {
11824            source: this,
11825            pageNumber: this.id,
11826            cssTransform: true
11827          });
11828          return;
11829        }
11830
11831        if (!this.zoomLayer && !this.canvas.hasAttribute('hidden')) {
11832          this.zoomLayer = this.canvas.parentNode;
11833          this.zoomLayer.style.position = 'absolute';
11834        }
11835      }
11836
11837      if (this.zoomLayer) {
11838        this.cssTransform(this.zoomLayer.firstChild);
11839      }
11840
11841      this.reset(true, true);
11842    }
11843  }, {
11844    key: "cancelRendering",
11845    value: function cancelRendering() {
11846      var keepAnnotations = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
11847
11848      if (this.paintTask) {
11849        this.paintTask.cancel();
11850        this.paintTask = null;
11851      }
11852
11853      this.resume = null;
11854
11855      if (this.textLayer) {
11856        this.textLayer.cancel();
11857        this.textLayer = null;
11858      }
11859
11860      if (!keepAnnotations && this.annotationLayer) {
11861        this.annotationLayer.cancel();
11862        this.annotationLayer = null;
11863      }
11864    }
11865  }, {
11866    key: "cssTransform",
11867    value: function cssTransform(target) {
11868      var redrawAnnotations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
11869      var width = this.viewport.width;
11870      var height = this.viewport.height;
11871      var div = this.div;
11872      target.style.width = target.parentNode.style.width = div.style.width = Math.floor(width) + 'px';
11873      target.style.height = target.parentNode.style.height = div.style.height = Math.floor(height) + 'px';
11874      var relativeRotation = this.viewport.rotation - this.paintedViewportMap.get(target).rotation;
11875      var absRotation = Math.abs(relativeRotation);
11876      var scaleX = 1,
11877          scaleY = 1;
11878
11879      if (absRotation === 90 || absRotation === 270) {
11880        scaleX = height / width;
11881        scaleY = width / height;
11882      }
11883
11884      var cssTransform = 'rotate(' + relativeRotation + 'deg) ' + 'scale(' + scaleX + ',' + scaleY + ')';
11885      target.style.transform = cssTransform;
11886
11887      if (this.textLayer) {
11888        var textLayerViewport = this.textLayer.viewport;
11889        var textRelativeRotation = this.viewport.rotation - textLayerViewport.rotation;
11890        var textAbsRotation = Math.abs(textRelativeRotation);
11891        var scale = width / textLayerViewport.width;
11892
11893        if (textAbsRotation === 90 || textAbsRotation === 270) {
11894          scale = width / textLayerViewport.height;
11895        }
11896
11897        var textLayerDiv = this.textLayer.textLayerDiv;
11898        var transX, transY;
11899
11900        switch (textAbsRotation) {
11901          case 0:
11902            transX = transY = 0;
11903            break;
11904
11905          case 90:
11906            transX = 0;
11907            transY = '-' + textLayerDiv.style.height;
11908            break;
11909
11910          case 180:
11911            transX = '-' + textLayerDiv.style.width;
11912            transY = '-' + textLayerDiv.style.height;
11913            break;
11914
11915          case 270:
11916            transX = '-' + textLayerDiv.style.width;
11917            transY = 0;
11918            break;
11919
11920          default:
11921            console.error('Bad rotation value.');
11922            break;
11923        }
11924
11925        textLayerDiv.style.transform = 'rotate(' + textAbsRotation + 'deg) ' + 'scale(' + scale + ', ' + scale + ') ' + 'translate(' + transX + ', ' + transY + ')';
11926        textLayerDiv.style.transformOrigin = '0% 0%';
11927      }
11928
11929      if (redrawAnnotations && this.annotationLayer) {
11930        this.annotationLayer.render(this.viewport, 'display');
11931      }
11932    }
11933  }, {
11934    key: "getPagePoint",
11935    value: function getPagePoint(x, y) {
11936      return this.viewport.convertToPdfPoint(x, y);
11937    }
11938  }, {
11939    key: "draw",
11940    value: function draw() {
11941      var _this = this;
11942
11943      if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
11944        console.error('Must be in new state before drawing');
11945        this.reset();
11946      }
11947
11948      if (!this.pdfPage) {
11949        this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
11950        return Promise.reject(new Error('Page is not loaded'));
11951      }
11952
11953      this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
11954      var pdfPage = this.pdfPage;
11955      var div = this.div;
11956      var canvasWrapper = document.createElement('div');
11957      canvasWrapper.style.width = div.style.width;
11958      canvasWrapper.style.height = div.style.height;
11959      canvasWrapper.classList.add('canvasWrapper');
11960
11961      if (this.annotationLayer && this.annotationLayer.div) {
11962        div.insertBefore(canvasWrapper, this.annotationLayer.div);
11963      } else {
11964        div.appendChild(canvasWrapper);
11965      }
11966
11967      var textLayer = null;
11968
11969      if (this.textLayerMode !== _ui_utils.TextLayerMode.DISABLE && this.textLayerFactory) {
11970        var textLayerDiv = document.createElement('div');
11971        textLayerDiv.className = 'textLayer';
11972        textLayerDiv.style.width = canvasWrapper.style.width;
11973        textLayerDiv.style.height = canvasWrapper.style.height;
11974
11975        if (this.annotationLayer && this.annotationLayer.div) {
11976          div.insertBefore(textLayerDiv, this.annotationLayer.div);
11977        } else {
11978          div.appendChild(textLayerDiv);
11979        }
11980
11981        textLayer = this.textLayerFactory.createTextLayerBuilder(textLayerDiv, this.id - 1, this.viewport, this.textLayerMode === _ui_utils.TextLayerMode.ENABLE_ENHANCE);
11982      }
11983
11984      this.textLayer = textLayer;
11985      var renderContinueCallback = null;
11986
11987      if (this.renderingQueue) {
11988        renderContinueCallback = function renderContinueCallback(cont) {
11989          if (!_this.renderingQueue.isHighestPriority(_this)) {
11990            _this.renderingState = _pdf_rendering_queue.RenderingStates.PAUSED;
11991
11992            _this.resume = function () {
11993              _this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
11994              cont();
11995            };
11996
11997            return;
11998          }
11999
12000          cont();
12001        };
12002      }
12003
12004      var finishPaintTask =
12005      /*#__PURE__*/
12006      function () {
12007        var _ref = _asyncToGenerator(
12008        /*#__PURE__*/
12009        _regenerator["default"].mark(function _callee(error) {
12010          return _regenerator["default"].wrap(function _callee$(_context) {
12011            while (1) {
12012              switch (_context.prev = _context.next) {
12013                case 0:
12014                  if (paintTask === _this.paintTask) {
12015                    _this.paintTask = null;
12016                  }
12017
12018                  if (!(error instanceof _pdfjsLib.RenderingCancelledException)) {
12019                    _context.next = 4;
12020                    break;
12021                  }
12022
12023                  _this.error = null;
12024                  return _context.abrupt("return");
12025
12026                case 4:
12027                  _this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
12028
12029                  if (_this.loadingIconDiv) {
12030                    div.removeChild(_this.loadingIconDiv);
12031                    delete _this.loadingIconDiv;
12032                  }
12033
12034                  _this._resetZoomLayer(true);
12035
12036                  _this.error = error;
12037                  _this.stats = pdfPage.stats;
12038
12039                  if (_this.onAfterDraw) {
12040                    _this.onAfterDraw();
12041                  }
12042
12043                  _this.eventBus.dispatch('pagerendered', {
12044                    source: _this,
12045                    pageNumber: _this.id,
12046                    cssTransform: false
12047                  });
12048
12049                  if (!error) {
12050                    _context.next = 13;
12051                    break;
12052                  }
12053
12054                  throw error;
12055
12056                case 13:
12057                case "end":
12058                  return _context.stop();
12059              }
12060            }
12061          }, _callee);
12062        }));
12063
12064        return function finishPaintTask(_x) {
12065          return _ref.apply(this, arguments);
12066        };
12067      }();
12068
12069      var paintTask = this.renderer === _ui_utils.RendererType.SVG ? this.paintOnSvg(canvasWrapper) : this.paintOnCanvas(canvasWrapper);
12070      paintTask.onRenderContinue = renderContinueCallback;
12071      this.paintTask = paintTask;
12072      var resultPromise = paintTask.promise.then(function () {
12073        return finishPaintTask(null).then(function () {
12074          if (textLayer) {
12075            var readableStream = pdfPage.streamTextContent({
12076              normalizeWhitespace: true
12077            });
12078            textLayer.setTextContentStream(readableStream);
12079            textLayer.render();
12080          }
12081        });
12082      }, function (reason) {
12083        return finishPaintTask(reason);
12084      });
12085
12086      if (this.annotationLayerFactory) {
12087        if (!this.annotationLayer) {
12088          this.annotationLayer = this.annotationLayerFactory.createAnnotationLayerBuilder(div, pdfPage, this.imageResourcesPath, this.renderInteractiveForms, this.l10n);
12089        }
12090
12091        this.annotationLayer.render(this.viewport, 'display');
12092      }
12093
12094      div.setAttribute('data-loaded', true);
12095
12096      if (this.onBeforeDraw) {
12097        this.onBeforeDraw();
12098      }
12099
12100      return resultPromise;
12101    }
12102  }, {
12103    key: "paintOnCanvas",
12104    value: function paintOnCanvas(canvasWrapper) {
12105      var renderCapability = (0, _pdfjsLib.createPromiseCapability)();
12106      var result = {
12107        promise: renderCapability.promise,
12108        onRenderContinue: function onRenderContinue(cont) {
12109          cont();
12110        },
12111        cancel: function cancel() {
12112          renderTask.cancel();
12113        }
12114      };
12115      var viewport = this.viewport;
12116      var canvas = document.createElement('canvas');
12117      canvas.id = this.renderingId;
12118      canvas.setAttribute('hidden', 'hidden');
12119      var isCanvasHidden = true;
12120
12121      var showCanvas = function showCanvas() {
12122        if (isCanvasHidden) {
12123          canvas.removeAttribute('hidden');
12124          isCanvasHidden = false;
12125        }
12126      };
12127
12128      canvasWrapper.appendChild(canvas);
12129      this.canvas = canvas;
12130      canvas.mozOpaque = true;
12131      var ctx = canvas.getContext('2d', {
12132        alpha: false
12133      });
12134      var outputScale = (0, _ui_utils.getOutputScale)(ctx);
12135      this.outputScale = outputScale;
12136
12137      if (this.useOnlyCssZoom) {
12138        var actualSizeViewport = viewport.clone({
12139          scale: _ui_utils.CSS_UNITS
12140        });
12141        outputScale.sx *= actualSizeViewport.width / viewport.width;
12142        outputScale.sy *= actualSizeViewport.height / viewport.height;
12143        outputScale.scaled = true;
12144      }
12145
12146      if (this.maxCanvasPixels > 0) {
12147        var pixelsInViewport = viewport.width * viewport.height;
12148        var maxScale = Math.sqrt(this.maxCanvasPixels / pixelsInViewport);
12149
12150        if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
12151          outputScale.sx = maxScale;
12152          outputScale.sy = maxScale;
12153          outputScale.scaled = true;
12154          this.hasRestrictedScaling = true;
12155        } else {
12156          this.hasRestrictedScaling = false;
12157        }
12158      }
12159
12160      var sfx = (0, _ui_utils.approximateFraction)(outputScale.sx);
12161      var sfy = (0, _ui_utils.approximateFraction)(outputScale.sy);
12162      canvas.width = (0, _ui_utils.roundToDivide)(viewport.width * outputScale.sx, sfx[0]);
12163      canvas.height = (0, _ui_utils.roundToDivide)(viewport.height * outputScale.sy, sfy[0]);
12164      canvas.style.width = (0, _ui_utils.roundToDivide)(viewport.width, sfx[1]) + 'px';
12165      canvas.style.height = (0, _ui_utils.roundToDivide)(viewport.height, sfy[1]) + 'px';
12166      this.paintedViewportMap.set(canvas, viewport);
12167      var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];
12168      var renderContext = {
12169        canvasContext: ctx,
12170        transform: transform,
12171        viewport: this.viewport,
12172        enableWebGL: this.enableWebGL,
12173        renderInteractiveForms: this.renderInteractiveForms
12174      };
12175      var renderTask = this.pdfPage.render(renderContext);
12176
12177      renderTask.onContinue = function (cont) {
12178        showCanvas();
12179
12180        if (result.onRenderContinue) {
12181          result.onRenderContinue(cont);
12182        } else {
12183          cont();
12184        }
12185      };
12186
12187      renderTask.promise.then(function () {
12188        showCanvas();
12189        renderCapability.resolve(undefined);
12190      }, function (error) {
12191        showCanvas();
12192        renderCapability.reject(error);
12193      });
12194      return result;
12195    }
12196  }, {
12197    key: "paintOnSvg",
12198    value: function paintOnSvg(wrapper) {
12199      var _this2 = this;
12200
12201      var cancelled = false;
12202
12203      var ensureNotCancelled = function ensureNotCancelled() {
12204        if (cancelled) {
12205          throw new _pdfjsLib.RenderingCancelledException('Rendering cancelled, page ' + _this2.id, 'svg');
12206        }
12207      };
12208
12209      var pdfPage = this.pdfPage;
12210      var actualSizeViewport = this.viewport.clone({
12211        scale: _ui_utils.CSS_UNITS
12212      });
12213      var promise = pdfPage.getOperatorList().then(function (opList) {
12214        ensureNotCancelled();
12215        var svgGfx = new _pdfjsLib.SVGGraphics(pdfPage.commonObjs, pdfPage.objs);
12216        return svgGfx.getSVG(opList, actualSizeViewport).then(function (svg) {
12217          ensureNotCancelled();
12218          _this2.svg = svg;
12219
12220          _this2.paintedViewportMap.set(svg, actualSizeViewport);
12221
12222          svg.style.width = wrapper.style.width;
12223          svg.style.height = wrapper.style.height;
12224          _this2.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
12225          wrapper.appendChild(svg);
12226        });
12227      });
12228      return {
12229        promise: promise,
12230        onRenderContinue: function onRenderContinue(cont) {
12231          cont();
12232        },
12233        cancel: function cancel() {
12234          cancelled = true;
12235        }
12236      };
12237    }
12238  }, {
12239    key: "setPageLabel",
12240    value: function setPageLabel(label) {
12241      this.pageLabel = typeof label === 'string' ? label : null;
12242
12243      if (this.pageLabel !== null) {
12244        this.div.setAttribute('data-page-label', this.pageLabel);
12245      } else {
12246        this.div.removeAttribute('data-page-label');
12247      }
12248    }
12249  }, {
12250    key: "width",
12251    get: function get() {
12252      return this.viewport.width;
12253    }
12254  }, {
12255    key: "height",
12256    get: function get() {
12257      return this.viewport.height;
12258    }
12259  }]);
12260
12261  return PDFPageView;
12262}();
12263
12264exports.PDFPageView = PDFPageView;
12265
12266/***/ }),
12267/* 31 */
12268/***/ (function(module, exports, __webpack_require__) {
12269
12270"use strict";
12271
12272
12273Object.defineProperty(exports, "__esModule", {
12274  value: true
12275});
12276exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
12277
12278var _ui_utils = __webpack_require__(5);
12279
12280var _pdfjsLib = __webpack_require__(7);
12281
12282function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12283
12284function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12285
12286function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12287
12288var EXPAND_DIVS_TIMEOUT = 300;
12289
12290var TextLayerBuilder =
12291/*#__PURE__*/
12292function () {
12293  function TextLayerBuilder(_ref) {
12294    var textLayerDiv = _ref.textLayerDiv,
12295        eventBus = _ref.eventBus,
12296        pageIndex = _ref.pageIndex,
12297        viewport = _ref.viewport,
12298        _ref$findController = _ref.findController,
12299        findController = _ref$findController === void 0 ? null : _ref$findController,
12300        _ref$enhanceTextSelec = _ref.enhanceTextSelection,
12301        enhanceTextSelection = _ref$enhanceTextSelec === void 0 ? false : _ref$enhanceTextSelec;
12302
12303    _classCallCheck(this, TextLayerBuilder);
12304
12305    this.textLayerDiv = textLayerDiv;
12306    this.eventBus = eventBus || (0, _ui_utils.getGlobalEventBus)();
12307    this.textContent = null;
12308    this.textContentItemsStr = [];
12309    this.textContentStream = null;
12310    this.renderingDone = false;
12311    this.pageIdx = pageIndex;
12312    this.pageNumber = this.pageIdx + 1;
12313    this.matches = [];
12314    this.viewport = viewport;
12315    this.textDivs = [];
12316    this.findController = findController;
12317    this.textLayerRenderTask = null;
12318    this.enhanceTextSelection = enhanceTextSelection;
12319    this._onUpdateTextLayerMatches = null;
12320
12321    this._bindMouse();
12322  }
12323
12324  _createClass(TextLayerBuilder, [{
12325    key: "_finishRendering",
12326    value: function _finishRendering() {
12327      this.renderingDone = true;
12328
12329      if (!this.enhanceTextSelection) {
12330        var endOfContent = document.createElement('div');
12331        endOfContent.className = 'endOfContent';
12332        this.textLayerDiv.appendChild(endOfContent);
12333      }
12334
12335      this.eventBus.dispatch('textlayerrendered', {
12336        source: this,
12337        pageNumber: this.pageNumber,
12338        numTextDivs: this.textDivs.length
12339      });
12340    }
12341  }, {
12342    key: "render",
12343    value: function render() {
12344      var _this = this;
12345
12346      var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
12347
12348      if (!(this.textContent || this.textContentStream) || this.renderingDone) {
12349        return;
12350      }
12351
12352      this.cancel();
12353      this.textDivs = [];
12354      var textLayerFrag = document.createDocumentFragment();
12355      this.textLayerRenderTask = (0, _pdfjsLib.renderTextLayer)({
12356        textContent: this.textContent,
12357        textContentStream: this.textContentStream,
12358        container: textLayerFrag,
12359        viewport: this.viewport,
12360        textDivs: this.textDivs,
12361        textContentItemsStr: this.textContentItemsStr,
12362        timeout: timeout,
12363        enhanceTextSelection: this.enhanceTextSelection
12364      });
12365      this.textLayerRenderTask.promise.then(function () {
12366        _this.textLayerDiv.appendChild(textLayerFrag);
12367
12368        _this._finishRendering();
12369
12370        _this._updateMatches();
12371      }, function (reason) {});
12372
12373      if (!this._onUpdateTextLayerMatches) {
12374        this._onUpdateTextLayerMatches = function (evt) {
12375          if (evt.pageIndex === _this.pageIdx || evt.pageIndex === -1) {
12376            _this._updateMatches();
12377          }
12378        };
12379
12380        this.eventBus.on('updatetextlayermatches', this._onUpdateTextLayerMatches);
12381      }
12382    }
12383  }, {
12384    key: "cancel",
12385    value: function cancel() {
12386      if (this.textLayerRenderTask) {
12387        this.textLayerRenderTask.cancel();
12388        this.textLayerRenderTask = null;
12389      }
12390
12391      if (this._onUpdateTextLayerMatches) {
12392        this.eventBus.off('updatetextlayermatches', this._onUpdateTextLayerMatches);
12393        this._onUpdateTextLayerMatches = null;
12394      }
12395    }
12396  }, {
12397    key: "setTextContentStream",
12398    value: function setTextContentStream(readableStream) {
12399      this.cancel();
12400      this.textContentStream = readableStream;
12401    }
12402  }, {
12403    key: "setTextContent",
12404    value: function setTextContent(textContent) {
12405      this.cancel();
12406      this.textContent = textContent;
12407    }
12408  }, {
12409    key: "_convertMatches",
12410    value: function _convertMatches(matches, matchesLength) {
12411      if (!matches) {
12412        return [];
12413      }
12414
12415      var findController = this.findController,
12416          textContentItemsStr = this.textContentItemsStr;
12417      var i = 0,
12418          iIndex = 0;
12419      var end = textContentItemsStr.length - 1;
12420      var queryLen = findController.state.query.length;
12421      var result = [];
12422
12423      for (var m = 0, mm = matches.length; m < mm; m++) {
12424        var matchIdx = matches[m];
12425
12426        while (i !== end && matchIdx >= iIndex + textContentItemsStr[i].length) {
12427          iIndex += textContentItemsStr[i].length;
12428          i++;
12429        }
12430
12431        if (i === textContentItemsStr.length) {
12432          console.error('Could not find a matching mapping');
12433        }
12434
12435        var match = {
12436          begin: {
12437            divIdx: i,
12438            offset: matchIdx - iIndex
12439          }
12440        };
12441
12442        if (matchesLength) {
12443          matchIdx += matchesLength[m];
12444        } else {
12445          matchIdx += queryLen;
12446        }
12447
12448        while (i !== end && matchIdx > iIndex + textContentItemsStr[i].length) {
12449          iIndex += textContentItemsStr[i].length;
12450          i++;
12451        }
12452
12453        match.end = {
12454          divIdx: i,
12455          offset: matchIdx - iIndex
12456        };
12457        result.push(match);
12458      }
12459
12460      return result;
12461    }
12462  }, {
12463    key: "_renderMatches",
12464    value: function _renderMatches(matches) {
12465      if (matches.length === 0) {
12466        return;
12467      }
12468
12469      var findController = this.findController,
12470          pageIdx = this.pageIdx,
12471          textContentItemsStr = this.textContentItemsStr,
12472          textDivs = this.textDivs;
12473      var isSelectedPage = pageIdx === findController.selected.pageIdx;
12474      var selectedMatchIdx = findController.selected.matchIdx;
12475      var highlightAll = findController.state.highlightAll;
12476      var prevEnd = null;
12477      var infinity = {
12478        divIdx: -1,
12479        offset: undefined
12480      };
12481
12482      function beginText(begin, className) {
12483        var divIdx = begin.divIdx;
12484        textDivs[divIdx].textContent = '';
12485        appendTextToDiv(divIdx, 0, begin.offset, className);
12486      }
12487
12488      function appendTextToDiv(divIdx, fromOffset, toOffset, className) {
12489        var div = textDivs[divIdx];
12490        var content = textContentItemsStr[divIdx].substring(fromOffset, toOffset);
12491        var node = document.createTextNode(content);
12492
12493        if (className) {
12494          var span = document.createElement('span');
12495          span.className = className;
12496          span.appendChild(node);
12497          div.appendChild(span);
12498          return;
12499        }
12500
12501        div.appendChild(node);
12502      }
12503
12504      var i0 = selectedMatchIdx,
12505          i1 = i0 + 1;
12506
12507      if (highlightAll) {
12508        i0 = 0;
12509        i1 = matches.length;
12510      } else if (!isSelectedPage) {
12511        return;
12512      }
12513
12514      for (var i = i0; i < i1; i++) {
12515        var match = matches[i];
12516        var begin = match.begin;
12517        var end = match.end;
12518        var isSelected = isSelectedPage && i === selectedMatchIdx;
12519        var highlightSuffix = isSelected ? ' selected' : '';
12520
12521        if (isSelected) {
12522          findController.scrollMatchIntoView({
12523            element: textDivs[begin.divIdx],
12524            pageIndex: pageIdx,
12525            matchIndex: selectedMatchIdx
12526          });
12527        }
12528
12529        if (!prevEnd || begin.divIdx !== prevEnd.divIdx) {
12530          if (prevEnd !== null) {
12531            appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
12532          }
12533
12534          beginText(begin);
12535        } else {
12536          appendTextToDiv(prevEnd.divIdx, prevEnd.offset, begin.offset);
12537        }
12538
12539        if (begin.divIdx === end.divIdx) {
12540          appendTextToDiv(begin.divIdx, begin.offset, end.offset, 'highlight' + highlightSuffix);
12541        } else {
12542          appendTextToDiv(begin.divIdx, begin.offset, infinity.offset, 'highlight begin' + highlightSuffix);
12543
12544          for (var n0 = begin.divIdx + 1, n1 = end.divIdx; n0 < n1; n0++) {
12545            textDivs[n0].className = 'highlight middle' + highlightSuffix;
12546          }
12547
12548          beginText(end, 'highlight end' + highlightSuffix);
12549        }
12550
12551        prevEnd = end;
12552      }
12553
12554      if (prevEnd) {
12555        appendTextToDiv(prevEnd.divIdx, prevEnd.offset, infinity.offset);
12556      }
12557    }
12558  }, {
12559    key: "_updateMatches",
12560    value: function _updateMatches() {
12561      if (!this.renderingDone) {
12562        return;
12563      }
12564
12565      var findController = this.findController,
12566          matches = this.matches,
12567          pageIdx = this.pageIdx,
12568          textContentItemsStr = this.textContentItemsStr,
12569          textDivs = this.textDivs;
12570      var clearedUntilDivIdx = -1;
12571
12572      for (var i = 0, ii = matches.length; i < ii; i++) {
12573        var match = matches[i];
12574        var begin = Math.max(clearedUntilDivIdx, match.begin.divIdx);
12575
12576        for (var n = begin, end = match.end.divIdx; n <= end; n++) {
12577          var div = textDivs[n];
12578          div.textContent = textContentItemsStr[n];
12579          div.className = '';
12580        }
12581
12582        clearedUntilDivIdx = match.end.divIdx + 1;
12583      }
12584
12585      if (!findController || !findController.highlightMatches) {
12586        return;
12587      }
12588
12589      var pageMatches = findController.pageMatches[pageIdx] || null;
12590      var pageMatchesLength = findController.pageMatchesLength[pageIdx] || null;
12591      this.matches = this._convertMatches(pageMatches, pageMatchesLength);
12592
12593      this._renderMatches(this.matches);
12594    }
12595  }, {
12596    key: "_bindMouse",
12597    value: function _bindMouse() {
12598      var _this2 = this;
12599
12600      var div = this.textLayerDiv;
12601      var expandDivsTimer = null;
12602      div.addEventListener('mousedown', function (evt) {
12603        if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
12604          _this2.textLayerRenderTask.expandTextDivs(true);
12605
12606          if (expandDivsTimer) {
12607            clearTimeout(expandDivsTimer);
12608            expandDivsTimer = null;
12609          }
12610
12611          return;
12612        }
12613
12614        var end = div.querySelector('.endOfContent');
12615
12616        if (!end) {
12617          return;
12618        }
12619
12620        var adjustTop = evt.target !== div;
12621        adjustTop = adjustTop && window.getComputedStyle(end).getPropertyValue('-moz-user-select') !== 'none';
12622
12623        if (adjustTop) {
12624          var divBounds = div.getBoundingClientRect();
12625          var r = Math.max(0, (evt.pageY - divBounds.top) / divBounds.height);
12626          end.style.top = (r * 100).toFixed(2) + '%';
12627        }
12628
12629        end.classList.add('active');
12630      });
12631      div.addEventListener('mouseup', function () {
12632        if (_this2.enhanceTextSelection && _this2.textLayerRenderTask) {
12633          expandDivsTimer = setTimeout(function () {
12634            if (_this2.textLayerRenderTask) {
12635              _this2.textLayerRenderTask.expandTextDivs(false);
12636            }
12637
12638            expandDivsTimer = null;
12639          }, EXPAND_DIVS_TIMEOUT);
12640          return;
12641        }
12642
12643        var end = div.querySelector('.endOfContent');
12644
12645        if (!end) {
12646          return;
12647        }
12648
12649        end.style.top = '';
12650        end.classList.remove('active');
12651      });
12652    }
12653  }]);
12654
12655  return TextLayerBuilder;
12656}();
12657
12658exports.TextLayerBuilder = TextLayerBuilder;
12659
12660var DefaultTextLayerFactory =
12661/*#__PURE__*/
12662function () {
12663  function DefaultTextLayerFactory() {
12664    _classCallCheck(this, DefaultTextLayerFactory);
12665  }
12666
12667  _createClass(DefaultTextLayerFactory, [{
12668    key: "createTextLayerBuilder",
12669    value: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport) {
12670      var enhanceTextSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
12671      return new TextLayerBuilder({
12672        textLayerDiv: textLayerDiv,
12673        pageIndex: pageIndex,
12674        viewport: viewport,
12675        enhanceTextSelection: enhanceTextSelection
12676      });
12677    }
12678  }]);
12679
12680  return DefaultTextLayerFactory;
12681}();
12682
12683exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
12684
12685/***/ }),
12686/* 32 */
12687/***/ (function(module, exports, __webpack_require__) {
12688
12689"use strict";
12690
12691
12692Object.defineProperty(exports, "__esModule", {
12693  value: true
12694});
12695exports.SecondaryToolbar = void 0;
12696
12697var _ui_utils = __webpack_require__(5);
12698
12699var _pdf_cursor_tools = __webpack_require__(9);
12700
12701var _pdf_single_page_viewer = __webpack_require__(33);
12702
12703function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12704
12705function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
12706
12707function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12708
12709var SecondaryToolbar =
12710/*#__PURE__*/
12711function () {
12712  function SecondaryToolbar(options, mainContainer, eventBus) {
12713    var _this = this;
12714
12715    _classCallCheck(this, SecondaryToolbar);
12716
12717    this.toolbar = options.toolbar;
12718    this.toggleButton = options.toggleButton;
12719    this.toolbarButtonContainer = options.toolbarButtonContainer;
12720    this.buttons = [{
12721      element: options.presentationModeButton,
12722      eventName: 'presentationmode',
12723      close: true
12724    }, {
12725      element: options.openFileButton,
12726      eventName: 'openfile',
12727      close: true
12728    }, {
12729      element: options.printButton,
12730      eventName: 'print',
12731      close: true
12732    }, {
12733      element: options.downloadButton,
12734      eventName: 'download',
12735      close: true
12736    }, {
12737      element: options.viewBookmarkButton,
12738      eventName: null,
12739      close: true
12740    }, {
12741      element: options.firstPageButton,
12742      eventName: 'firstpage',
12743      close: true
12744    }, {
12745      element: options.lastPageButton,
12746      eventName: 'lastpage',
12747      close: true
12748    }, {
12749      element: options.pageRotateCwButton,
12750      eventName: 'rotatecw',
12751      close: false
12752    }, {
12753      element: options.pageRotateCcwButton,
12754      eventName: 'rotateccw',
12755      close: false
12756    }, {
12757      element: options.cursorSelectToolButton,
12758      eventName: 'switchcursortool',
12759      eventDetails: {
12760        tool: _pdf_cursor_tools.CursorTool.SELECT
12761      },
12762      close: true
12763    }, {
12764      element: options.cursorHandToolButton,
12765      eventName: 'switchcursortool',
12766      eventDetails: {
12767        tool: _pdf_cursor_tools.CursorTool.HAND
12768      },
12769      close: true
12770    }, {
12771      element: options.scrollVerticalButton,
12772      eventName: 'switchscrollmode',
12773      eventDetails: {
12774        mode: _ui_utils.ScrollMode.VERTICAL
12775      },
12776      close: true
12777    }, {
12778      element: options.scrollHorizontalButton,
12779      eventName: 'switchscrollmode',
12780      eventDetails: {
12781        mode: _ui_utils.ScrollMode.HORIZONTAL
12782      },
12783      close: true
12784    }, {
12785      element: options.scrollWrappedButton,
12786      eventName: 'switchscrollmode',
12787      eventDetails: {
12788        mode: _ui_utils.ScrollMode.WRAPPED
12789      },
12790      close: true
12791    }, {
12792      element: options.spreadNoneButton,
12793      eventName: 'switchspreadmode',
12794      eventDetails: {
12795        mode: _ui_utils.SpreadMode.NONE
12796      },
12797      close: true
12798    }, {
12799      element: options.spreadOddButton,
12800      eventName: 'switchspreadmode',
12801      eventDetails: {
12802        mode: _ui_utils.SpreadMode.ODD
12803      },
12804      close: true
12805    }, {
12806      element: options.spreadEvenButton,
12807      eventName: 'switchspreadmode',
12808      eventDetails: {
12809        mode: _ui_utils.SpreadMode.EVEN
12810      },
12811      close: true
12812    }, {
12813      element: options.documentPropertiesButton,
12814      eventName: 'documentproperties',
12815      close: true
12816    }];
12817    this.items = {
12818      firstPage: options.firstPageButton,
12819      lastPage: options.lastPageButton,
12820      pageRotateCw: options.pageRotateCwButton,
12821      pageRotateCcw: options.pageRotateCcwButton
12822    };
12823    this.mainContainer = mainContainer;
12824    this.eventBus = eventBus;
12825    this.opened = false;
12826    this.containerHeight = null;
12827    this.previousContainerHeight = null;
12828    this.reset();
12829
12830    this._bindClickListeners();
12831
12832    this._bindCursorToolsListener(options);
12833
12834    this._bindScrollModeListener(options);
12835
12836    this._bindSpreadModeListener(options);
12837
12838    this.eventBus.on('resize', this._setMaxHeight.bind(this));
12839    this.eventBus.on('baseviewerinit', function (evt) {
12840      if (evt.source instanceof _pdf_single_page_viewer.PDFSinglePageViewer) {
12841        _this.toolbarButtonContainer.classList.add('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
12842      } else {
12843        _this.toolbarButtonContainer.classList.remove('hiddenScrollModeButtons', 'hiddenSpreadModeButtons');
12844      }
12845    });
12846  }
12847
12848  _createClass(SecondaryToolbar, [{
12849    key: "setPageNumber",
12850    value: function setPageNumber(pageNumber) {
12851      this.pageNumber = pageNumber;
12852
12853      this._updateUIState();
12854    }
12855  }, {
12856    key: "setPagesCount",
12857    value: function setPagesCount(pagesCount) {
12858      this.pagesCount = pagesCount;
12859
12860      this._updateUIState();
12861    }
12862  }, {
12863    key: "reset",
12864    value: function reset() {
12865      this.pageNumber = 0;
12866      this.pagesCount = 0;
12867
12868      this._updateUIState();
12869
12870      this.eventBus.dispatch('secondarytoolbarreset', {
12871        source: this
12872      });
12873    }
12874  }, {
12875    key: "_updateUIState",
12876    value: function _updateUIState() {
12877      this.items.firstPage.disabled = this.pageNumber <= 1;
12878      this.items.lastPage.disabled = this.pageNumber >= this.pagesCount;
12879      this.items.pageRotateCw.disabled = this.pagesCount === 0;
12880      this.items.pageRotateCcw.disabled = this.pagesCount === 0;
12881    }
12882  }, {
12883    key: "_bindClickListeners",
12884    value: function _bindClickListeners() {
12885      var _this2 = this;
12886
12887      this.toggleButton.addEventListener('click', this.toggle.bind(this));
12888
12889      var _loop = function _loop(button) {
12890        var _this2$buttons$button = _this2.buttons[button],
12891            element = _this2$buttons$button.element,
12892            eventName = _this2$buttons$button.eventName,
12893            close = _this2$buttons$button.close,
12894            eventDetails = _this2$buttons$button.eventDetails;
12895        element.addEventListener('click', function (evt) {
12896          if (eventName !== null) {
12897            var details = {
12898              source: _this2
12899            };
12900
12901            for (var property in eventDetails) {
12902              details[property] = eventDetails[property];
12903            }
12904
12905            _this2.eventBus.dispatch(eventName, details);
12906          }
12907
12908          if (close) {
12909            _this2.close();
12910          }
12911        });
12912      };
12913
12914      for (var button in this.buttons) {
12915        _loop(button);
12916      }
12917    }
12918  }, {
12919    key: "_bindCursorToolsListener",
12920    value: function _bindCursorToolsListener(buttons) {
12921      this.eventBus.on('cursortoolchanged', function (_ref) {
12922        var tool = _ref.tool;
12923        buttons.cursorSelectToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.SELECT);
12924        buttons.cursorHandToolButton.classList.toggle('toggled', tool === _pdf_cursor_tools.CursorTool.HAND);
12925      });
12926    }
12927  }, {
12928    key: "_bindScrollModeListener",
12929    value: function _bindScrollModeListener(buttons) {
12930      var _this3 = this;
12931
12932      function scrollModeChanged(_ref2) {
12933        var mode = _ref2.mode;
12934        buttons.scrollVerticalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.VERTICAL);
12935        buttons.scrollHorizontalButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.HORIZONTAL);
12936        buttons.scrollWrappedButton.classList.toggle('toggled', mode === _ui_utils.ScrollMode.WRAPPED);
12937        var isScrollModeHorizontal = mode === _ui_utils.ScrollMode.HORIZONTAL;
12938        buttons.spreadNoneButton.disabled = isScrollModeHorizontal;
12939        buttons.spreadOddButton.disabled = isScrollModeHorizontal;
12940        buttons.spreadEvenButton.disabled = isScrollModeHorizontal;
12941      }
12942
12943      this.eventBus.on('scrollmodechanged', scrollModeChanged);
12944      this.eventBus.on('secondarytoolbarreset', function (evt) {
12945        if (evt.source === _this3) {
12946          scrollModeChanged({
12947            mode: _ui_utils.ScrollMode.VERTICAL
12948          });
12949        }
12950      });
12951    }
12952  }, {
12953    key: "_bindSpreadModeListener",
12954    value: function _bindSpreadModeListener(buttons) {
12955      var _this4 = this;
12956
12957      function spreadModeChanged(_ref3) {
12958        var mode = _ref3.mode;
12959        buttons.spreadNoneButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.NONE);
12960        buttons.spreadOddButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.ODD);
12961        buttons.spreadEvenButton.classList.toggle('toggled', mode === _ui_utils.SpreadMode.EVEN);
12962      }
12963
12964      this.eventBus.on('spreadmodechanged', spreadModeChanged);
12965      this.eventBus.on('secondarytoolbarreset', function (evt) {
12966        if (evt.source === _this4) {
12967          spreadModeChanged({
12968            mode: _ui_utils.SpreadMode.NONE
12969          });
12970        }
12971      });
12972    }
12973  }, {
12974    key: "open",
12975    value: function open() {
12976      if (this.opened) {
12977        return;
12978      }
12979
12980      this.opened = true;
12981
12982      this._setMaxHeight();
12983
12984      this.toggleButton.classList.add('toggled');
12985      this.toolbar.classList.remove('hidden');
12986    }
12987  }, {
12988    key: "close",
12989    value: function close() {
12990      if (!this.opened) {
12991        return;
12992      }
12993
12994      this.opened = false;
12995      this.toolbar.classList.add('hidden');
12996      this.toggleButton.classList.remove('toggled');
12997    }
12998  }, {
12999    key: "toggle",
13000    value: function toggle() {
13001      if (this.opened) {
13002        this.close();
13003      } else {
13004        this.open();
13005      }
13006    }
13007  }, {
13008    key: "_setMaxHeight",
13009    value: function _setMaxHeight() {
13010      if (!this.opened) {
13011        return;
13012      }
13013
13014      this.containerHeight = this.mainContainer.clientHeight;
13015
13016      if (this.containerHeight === this.previousContainerHeight) {
13017        return;
13018      }
13019
13020      this.toolbarButtonContainer.setAttribute('style', 'max-height: ' + (this.containerHeight - _ui_utils.SCROLLBAR_PADDING) + 'px;');
13021      this.previousContainerHeight = this.containerHeight;
13022    }
13023  }, {
13024    key: "isOpen",
13025    get: function get() {
13026      return this.opened;
13027    }
13028  }]);
13029
13030  return SecondaryToolbar;
13031}();
13032
13033exports.SecondaryToolbar = SecondaryToolbar;
13034
13035/***/ }),
13036/* 33 */
13037/***/ (function(module, exports, __webpack_require__) {
13038
13039"use strict";
13040
13041
13042Object.defineProperty(exports, "__esModule", {
13043  value: true
13044});
13045exports.PDFSinglePageViewer = void 0;
13046
13047var _base_viewer = __webpack_require__(28);
13048
13049var _pdfjsLib = __webpack_require__(7);
13050
13051function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13052
13053function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13054
13055function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13056
13057function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13058
13059function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13060
13061function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13062
13063function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
13064
13065function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
13066
13067function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13068
13069function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13070
13071function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13072
13073var PDFSinglePageViewer =
13074/*#__PURE__*/
13075function (_BaseViewer) {
13076  _inherits(PDFSinglePageViewer, _BaseViewer);
13077
13078  function PDFSinglePageViewer(options) {
13079    var _this;
13080
13081    _classCallCheck(this, PDFSinglePageViewer);
13082
13083    _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFSinglePageViewer).call(this, options));
13084
13085    _this.eventBus.on('pagesinit', function (evt) {
13086      _this._ensurePageViewVisible();
13087    });
13088
13089    return _this;
13090  }
13091
13092  _createClass(PDFSinglePageViewer, [{
13093    key: "_resetView",
13094    value: function _resetView() {
13095      _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_resetView", this).call(this);
13096
13097      this._previousPageNumber = 1;
13098      this._shadowViewer = document.createDocumentFragment();
13099      this._updateScrollDown = null;
13100    }
13101  }, {
13102    key: "_ensurePageViewVisible",
13103    value: function _ensurePageViewVisible() {
13104      var pageView = this._pages[this._currentPageNumber - 1];
13105      var previousPageView = this._pages[this._previousPageNumber - 1];
13106      var viewerNodes = this.viewer.childNodes;
13107
13108      switch (viewerNodes.length) {
13109        case 0:
13110          this.viewer.appendChild(pageView.div);
13111          break;
13112
13113        case 1:
13114          if (viewerNodes[0] !== previousPageView.div) {
13115            throw new Error('_ensurePageViewVisible: Unexpected previously visible page.');
13116          }
13117
13118          if (pageView === previousPageView) {
13119            break;
13120          }
13121
13122          this._shadowViewer.appendChild(previousPageView.div);
13123
13124          this.viewer.appendChild(pageView.div);
13125          this.container.scrollTop = 0;
13126          break;
13127
13128        default:
13129          throw new Error('_ensurePageViewVisible: Only one page should be visible at a time.');
13130      }
13131
13132      this._previousPageNumber = this._currentPageNumber;
13133    }
13134  }, {
13135    key: "_scrollUpdate",
13136    value: function _scrollUpdate() {
13137      if (this._updateScrollDown) {
13138        this._updateScrollDown();
13139      }
13140
13141      _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollUpdate", this).call(this);
13142    }
13143  }, {
13144    key: "_scrollIntoView",
13145    value: function _scrollIntoView(_ref) {
13146      var _this2 = this;
13147
13148      var pageDiv = _ref.pageDiv,
13149          _ref$pageSpot = _ref.pageSpot,
13150          pageSpot = _ref$pageSpot === void 0 ? null : _ref$pageSpot,
13151          _ref$pageNumber = _ref.pageNumber,
13152          pageNumber = _ref$pageNumber === void 0 ? null : _ref$pageNumber;
13153
13154      if (pageNumber) {
13155        this._setCurrentPageNumber(pageNumber);
13156      }
13157
13158      var scrolledDown = this._currentPageNumber >= this._previousPageNumber;
13159
13160      this._ensurePageViewVisible();
13161
13162      this.update();
13163
13164      _get(_getPrototypeOf(PDFSinglePageViewer.prototype), "_scrollIntoView", this).call(this, {
13165        pageDiv: pageDiv,
13166        pageSpot: pageSpot,
13167        pageNumber: pageNumber
13168      });
13169
13170      this._updateScrollDown = function () {
13171        _this2.scroll.down = scrolledDown;
13172        _this2._updateScrollDown = null;
13173      };
13174    }
13175  }, {
13176    key: "_getVisiblePages",
13177    value: function _getVisiblePages() {
13178      return this._getCurrentVisiblePage();
13179    }
13180  }, {
13181    key: "_updateHelper",
13182    value: function _updateHelper(visiblePages) {}
13183  }, {
13184    key: "_updateScrollMode",
13185    value: function _updateScrollMode() {}
13186  }, {
13187    key: "_updateSpreadMode",
13188    value: function _updateSpreadMode() {}
13189  }, {
13190    key: "_setDocumentViewerElement",
13191    get: function get() {
13192      return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this._shadowViewer);
13193    }
13194  }, {
13195    key: "_isScrollModeHorizontal",
13196    get: function get() {
13197      return (0, _pdfjsLib.shadow)(this, '_isScrollModeHorizontal', false);
13198    }
13199  }]);
13200
13201  return PDFSinglePageViewer;
13202}(_base_viewer.BaseViewer);
13203
13204exports.PDFSinglePageViewer = PDFSinglePageViewer;
13205
13206/***/ }),
13207/* 34 */
13208/***/ (function(module, exports, __webpack_require__) {
13209
13210"use strict";
13211
13212
13213Object.defineProperty(exports, "__esModule", {
13214  value: true
13215});
13216exports.Toolbar = void 0;
13217
13218var _ui_utils = __webpack_require__(5);
13219
13220function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13221
13222function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13223
13224function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13225
13226var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
13227var SCALE_SELECT_CONTAINER_PADDING = 8;
13228var SCALE_SELECT_PADDING = 22;
13229
13230var Toolbar =
13231/*#__PURE__*/
13232function () {
13233  function Toolbar(options, eventBus) {
13234    var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
13235
13236    _classCallCheck(this, Toolbar);
13237
13238    this.toolbar = options.container;
13239    this.eventBus = eventBus;
13240    this.l10n = l10n;
13241    this.items = options;
13242    this._wasLocalized = false;
13243    this.reset();
13244
13245    this._bindListeners();
13246  }
13247
13248  _createClass(Toolbar, [{
13249    key: "setPageNumber",
13250    value: function setPageNumber(pageNumber, pageLabel) {
13251      this.pageNumber = pageNumber;
13252      this.pageLabel = pageLabel;
13253
13254      this._updateUIState(false);
13255    }
13256  }, {
13257    key: "setPagesCount",
13258    value: function setPagesCount(pagesCount, hasPageLabels) {
13259      this.pagesCount = pagesCount;
13260      this.hasPageLabels = hasPageLabels;
13261
13262      this._updateUIState(true);
13263    }
13264  }, {
13265    key: "setPageScale",
13266    value: function setPageScale(pageScaleValue, pageScale) {
13267      this.pageScaleValue = (pageScaleValue || pageScale).toString();
13268      this.pageScale = pageScale;
13269
13270      this._updateUIState(false);
13271    }
13272  }, {
13273    key: "reset",
13274    value: function reset() {
13275      this.pageNumber = 0;
13276      this.pageLabel = null;
13277      this.hasPageLabels = false;
13278      this.pagesCount = 0;
13279      this.pageScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
13280      this.pageScale = _ui_utils.DEFAULT_SCALE;
13281
13282      this._updateUIState(true);
13283    }
13284  }, {
13285    key: "_bindListeners",
13286    value: function _bindListeners() {
13287      var _this = this;
13288
13289      var eventBus = this.eventBus,
13290          items = this.items;
13291      var self = this;
13292      items.previous.addEventListener('click', function () {
13293        eventBus.dispatch('previouspage', {
13294          source: self
13295        });
13296      });
13297      items.next.addEventListener('click', function () {
13298        eventBus.dispatch('nextpage', {
13299          source: self
13300        });
13301      });
13302      items.zoomIn.addEventListener('click', function () {
13303        eventBus.dispatch('zoomin', {
13304          source: self
13305        });
13306      });
13307      items.zoomOut.addEventListener('click', function () {
13308        eventBus.dispatch('zoomout', {
13309          source: self
13310        });
13311      });
13312      items.pageNumber.addEventListener('click', function () {
13313        this.select();
13314      });
13315      items.pageNumber.addEventListener('change', function () {
13316        eventBus.dispatch('pagenumberchanged', {
13317          source: self,
13318          value: this.value
13319        });
13320      });
13321      items.scaleSelect.addEventListener('change', function () {
13322        if (this.value === 'custom') {
13323          return;
13324        }
13325
13326        eventBus.dispatch('scalechanged', {
13327          source: self,
13328          value: this.value
13329        });
13330      });
13331      items.presentationModeButton.addEventListener('click', function () {
13332        eventBus.dispatch('presentationmode', {
13333          source: self
13334        });
13335      });
13336      items.openFile.addEventListener('click', function () {
13337        eventBus.dispatch('openfile', {
13338          source: self
13339        });
13340      });
13341      items.print.addEventListener('click', function () {
13342        eventBus.dispatch('print', {
13343          source: self
13344        });
13345      });
13346      items.download.addEventListener('click', function () {
13347        eventBus.dispatch('download', {
13348          source: self
13349        });
13350      });
13351      items.scaleSelect.oncontextmenu = _ui_utils.noContextMenuHandler;
13352      eventBus.on('localized', function () {
13353        _this._localized();
13354      });
13355    }
13356  }, {
13357    key: "_localized",
13358    value: function _localized() {
13359      this._wasLocalized = true;
13360
13361      this._adjustScaleWidth();
13362
13363      this._updateUIState(true);
13364    }
13365  }, {
13366    key: "_updateUIState",
13367    value: function _updateUIState() {
13368      var resetNumPages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13369
13370      if (!this._wasLocalized) {
13371        return;
13372      }
13373
13374      var pageNumber = this.pageNumber,
13375          pagesCount = this.pagesCount,
13376          pageScaleValue = this.pageScaleValue,
13377          pageScale = this.pageScale,
13378          items = this.items;
13379
13380      if (resetNumPages) {
13381        if (this.hasPageLabels) {
13382          items.pageNumber.type = 'text';
13383        } else {
13384          items.pageNumber.type = 'number';
13385          this.l10n.get('of_pages', {
13386            pagesCount: pagesCount
13387          }, 'of {{pagesCount}}').then(function (msg) {
13388            items.numPages.textContent = msg;
13389          });
13390        }
13391
13392        items.pageNumber.max = pagesCount;
13393      }
13394
13395      if (this.hasPageLabels) {
13396        items.pageNumber.value = this.pageLabel;
13397        this.l10n.get('page_of_pages', {
13398          pageNumber: pageNumber,
13399          pagesCount: pagesCount
13400        }, '({{pageNumber}} of {{pagesCount}})').then(function (msg) {
13401          items.numPages.textContent = msg;
13402        });
13403      } else {
13404        items.pageNumber.value = pageNumber;
13405      }
13406
13407      items.previous.disabled = pageNumber <= 1;
13408      items.next.disabled = pageNumber >= pagesCount;
13409      items.zoomOut.disabled = pageScale <= _ui_utils.MIN_SCALE;
13410      items.zoomIn.disabled = pageScale >= _ui_utils.MAX_SCALE;
13411      var customScale = Math.round(pageScale * 10000) / 100;
13412      this.l10n.get('page_scale_percent', {
13413        scale: customScale
13414      }, '{{scale}}%').then(function (msg) {
13415        var options = items.scaleSelect.options;
13416        var predefinedValueFound = false;
13417
13418        for (var i = 0, ii = options.length; i < ii; i++) {
13419          var option = options[i];
13420
13421          if (option.value !== pageScaleValue) {
13422            option.selected = false;
13423            continue;
13424          }
13425
13426          option.selected = true;
13427          predefinedValueFound = true;
13428        }
13429
13430        if (!predefinedValueFound) {
13431          items.customScaleOption.textContent = msg;
13432          items.customScaleOption.selected = true;
13433        }
13434      });
13435    }
13436  }, {
13437    key: "updateLoadingIndicatorState",
13438    value: function updateLoadingIndicatorState() {
13439      var loading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13440      var pageNumberInput = this.items.pageNumber;
13441      pageNumberInput.classList.toggle(PAGE_NUMBER_LOADING_INDICATOR, loading);
13442    }
13443  }, {
13444    key: "_adjustScaleWidth",
13445    value: function _adjustScaleWidth() {
13446      var container = this.items.scaleSelectContainer;
13447      var select = this.items.scaleSelect;
13448
13449      _ui_utils.animationStarted.then(function () {
13450        if (container.clientWidth === 0) {
13451          container.setAttribute('style', 'display: inherit;');
13452        }
13453
13454        if (container.clientWidth > 0) {
13455          select.setAttribute('style', 'min-width: inherit;');
13456          var width = select.clientWidth + SCALE_SELECT_CONTAINER_PADDING;
13457          select.setAttribute('style', 'min-width: ' + (width + SCALE_SELECT_PADDING) + 'px;');
13458          container.setAttribute('style', 'min-width: ' + width + 'px; ' + 'max-width: ' + width + 'px;');
13459        }
13460      });
13461    }
13462  }]);
13463
13464  return Toolbar;
13465}();
13466
13467exports.Toolbar = Toolbar;
13468
13469/***/ }),
13470/* 35 */
13471/***/ (function(module, exports, __webpack_require__) {
13472
13473"use strict";
13474
13475
13476Object.defineProperty(exports, "__esModule", {
13477  value: true
13478});
13479exports.ViewHistory = void 0;
13480
13481var _regenerator = _interopRequireDefault(__webpack_require__(2));
13482
13483function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13484
13485function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13486
13487function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13488
13489function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13490
13491function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13492
13493function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13494
13495var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
13496
13497var ViewHistory =
13498/*#__PURE__*/
13499function () {
13500  function ViewHistory(fingerprint) {
13501    var _this = this;
13502
13503    var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
13504
13505    _classCallCheck(this, ViewHistory);
13506
13507    this.fingerprint = fingerprint;
13508    this.cacheSize = cacheSize;
13509    this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
13510      var database = JSON.parse(databaseStr || '{}');
13511
13512      if (!('files' in database)) {
13513        database.files = [];
13514      } else {
13515        while (database.files.length >= _this.cacheSize) {
13516          database.files.shift();
13517        }
13518      }
13519
13520      var index = -1;
13521
13522      for (var i = 0, length = database.files.length; i < length; i++) {
13523        var branch = database.files[i];
13524
13525        if (branch.fingerprint === _this.fingerprint) {
13526          index = i;
13527          break;
13528        }
13529      }
13530
13531      if (index === -1) {
13532        index = database.files.push({
13533          fingerprint: _this.fingerprint
13534        }) - 1;
13535      }
13536
13537      _this.file = database.files[index];
13538      _this.database = database;
13539    });
13540  }
13541
13542  _createClass(ViewHistory, [{
13543    key: "_writeToStorage",
13544    value: function () {
13545      var _writeToStorage2 = _asyncToGenerator(
13546      /*#__PURE__*/
13547      _regenerator["default"].mark(function _callee() {
13548        var databaseStr;
13549        return _regenerator["default"].wrap(function _callee$(_context) {
13550          while (1) {
13551            switch (_context.prev = _context.next) {
13552              case 0:
13553                databaseStr = JSON.stringify(this.database);
13554                localStorage.setItem('pdfjs.history', databaseStr);
13555
13556              case 2:
13557              case "end":
13558                return _context.stop();
13559            }
13560          }
13561        }, _callee, this);
13562      }));
13563
13564      function _writeToStorage() {
13565        return _writeToStorage2.apply(this, arguments);
13566      }
13567
13568      return _writeToStorage;
13569    }()
13570  }, {
13571    key: "_readFromStorage",
13572    value: function () {
13573      var _readFromStorage2 = _asyncToGenerator(
13574      /*#__PURE__*/
13575      _regenerator["default"].mark(function _callee2() {
13576        return _regenerator["default"].wrap(function _callee2$(_context2) {
13577          while (1) {
13578            switch (_context2.prev = _context2.next) {
13579              case 0:
13580                return _context2.abrupt("return", localStorage.getItem('pdfjs.history'));
13581
13582              case 1:
13583              case "end":
13584                return _context2.stop();
13585            }
13586          }
13587        }, _callee2);
13588      }));
13589
13590      function _readFromStorage() {
13591        return _readFromStorage2.apply(this, arguments);
13592      }
13593
13594      return _readFromStorage;
13595    }()
13596  }, {
13597    key: "set",
13598    value: function () {
13599      var _set = _asyncToGenerator(
13600      /*#__PURE__*/
13601      _regenerator["default"].mark(function _callee3(name, val) {
13602        return _regenerator["default"].wrap(function _callee3$(_context3) {
13603          while (1) {
13604            switch (_context3.prev = _context3.next) {
13605              case 0:
13606                _context3.next = 2;
13607                return this._initializedPromise;
13608
13609              case 2:
13610                this.file[name] = val;
13611                return _context3.abrupt("return", this._writeToStorage());
13612
13613              case 4:
13614              case "end":
13615                return _context3.stop();
13616            }
13617          }
13618        }, _callee3, this);
13619      }));
13620
13621      function set(_x, _x2) {
13622        return _set.apply(this, arguments);
13623      }
13624
13625      return set;
13626    }()
13627  }, {
13628    key: "setMultiple",
13629    value: function () {
13630      var _setMultiple = _asyncToGenerator(
13631      /*#__PURE__*/
13632      _regenerator["default"].mark(function _callee4(properties) {
13633        var name;
13634        return _regenerator["default"].wrap(function _callee4$(_context4) {
13635          while (1) {
13636            switch (_context4.prev = _context4.next) {
13637              case 0:
13638                _context4.next = 2;
13639                return this._initializedPromise;
13640
13641              case 2:
13642                for (name in properties) {
13643                  this.file[name] = properties[name];
13644                }
13645
13646                return _context4.abrupt("return", this._writeToStorage());
13647
13648              case 4:
13649              case "end":
13650                return _context4.stop();
13651            }
13652          }
13653        }, _callee4, this);
13654      }));
13655
13656      function setMultiple(_x3) {
13657        return _setMultiple.apply(this, arguments);
13658      }
13659
13660      return setMultiple;
13661    }()
13662  }, {
13663    key: "get",
13664    value: function () {
13665      var _get = _asyncToGenerator(
13666      /*#__PURE__*/
13667      _regenerator["default"].mark(function _callee5(name, defaultValue) {
13668        var val;
13669        return _regenerator["default"].wrap(function _callee5$(_context5) {
13670          while (1) {
13671            switch (_context5.prev = _context5.next) {
13672              case 0:
13673                _context5.next = 2;
13674                return this._initializedPromise;
13675
13676              case 2:
13677                val = this.file[name];
13678                return _context5.abrupt("return", val !== undefined ? val : defaultValue);
13679
13680              case 4:
13681              case "end":
13682                return _context5.stop();
13683            }
13684          }
13685        }, _callee5, this);
13686      }));
13687
13688      function get(_x4, _x5) {
13689        return _get.apply(this, arguments);
13690      }
13691
13692      return get;
13693    }()
13694  }, {
13695    key: "getMultiple",
13696    value: function () {
13697      var _getMultiple = _asyncToGenerator(
13698      /*#__PURE__*/
13699      _regenerator["default"].mark(function _callee6(properties) {
13700        var values, name, val;
13701        return _regenerator["default"].wrap(function _callee6$(_context6) {
13702          while (1) {
13703            switch (_context6.prev = _context6.next) {
13704              case 0:
13705                _context6.next = 2;
13706                return this._initializedPromise;
13707
13708              case 2:
13709                values = Object.create(null);
13710
13711                for (name in properties) {
13712                  val = this.file[name];
13713                  values[name] = val !== undefined ? val : properties[name];
13714                }
13715
13716                return _context6.abrupt("return", values);
13717
13718              case 5:
13719              case "end":
13720                return _context6.stop();
13721            }
13722          }
13723        }, _callee6, this);
13724      }));
13725
13726      function getMultiple(_x6) {
13727        return _getMultiple.apply(this, arguments);
13728      }
13729
13730      return getMultiple;
13731    }()
13732  }]);
13733
13734  return ViewHistory;
13735}();
13736
13737exports.ViewHistory = ViewHistory;
13738
13739/***/ }),
13740/* 36 */
13741/***/ (function(module, exports, __webpack_require__) {
13742
13743"use strict";
13744
13745
13746Object.defineProperty(exports, "__esModule", {
13747  value: true
13748});
13749exports.GenericCom = void 0;
13750
13751var _regenerator = _interopRequireDefault(__webpack_require__(2));
13752
13753var _app = __webpack_require__(1);
13754
13755var _preferences = __webpack_require__(37);
13756
13757var _download_manager = __webpack_require__(38);
13758
13759var _genericl10n = __webpack_require__(39);
13760
13761function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13762
13763function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13764
13765function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13766
13767function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13768
13769function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13770
13771function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13772
13773function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13774
13775function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
13776
13777function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13778
13779function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13780
13781function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
13782
13783function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
13784
13785;
13786var GenericCom = {};
13787exports.GenericCom = GenericCom;
13788
13789var GenericPreferences =
13790/*#__PURE__*/
13791function (_BasePreferences) {
13792  _inherits(GenericPreferences, _BasePreferences);
13793
13794  function GenericPreferences() {
13795    _classCallCheck(this, GenericPreferences);
13796
13797    return _possibleConstructorReturn(this, _getPrototypeOf(GenericPreferences).apply(this, arguments));
13798  }
13799
13800  _createClass(GenericPreferences, [{
13801    key: "_writeToStorage",
13802    value: function () {
13803      var _writeToStorage2 = _asyncToGenerator(
13804      /*#__PURE__*/
13805      _regenerator["default"].mark(function _callee(prefObj) {
13806        return _regenerator["default"].wrap(function _callee$(_context) {
13807          while (1) {
13808            switch (_context.prev = _context.next) {
13809              case 0:
13810                localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
13811
13812              case 1:
13813              case "end":
13814                return _context.stop();
13815            }
13816          }
13817        }, _callee);
13818      }));
13819
13820      function _writeToStorage(_x) {
13821        return _writeToStorage2.apply(this, arguments);
13822      }
13823
13824      return _writeToStorage;
13825    }()
13826  }, {
13827    key: "_readFromStorage",
13828    value: function () {
13829      var _readFromStorage2 = _asyncToGenerator(
13830      /*#__PURE__*/
13831      _regenerator["default"].mark(function _callee2(prefObj) {
13832        return _regenerator["default"].wrap(function _callee2$(_context2) {
13833          while (1) {
13834            switch (_context2.prev = _context2.next) {
13835              case 0:
13836                return _context2.abrupt("return", JSON.parse(localStorage.getItem('pdfjs.preferences')));
13837
13838              case 1:
13839              case "end":
13840                return _context2.stop();
13841            }
13842          }
13843        }, _callee2);
13844      }));
13845
13846      function _readFromStorage(_x2) {
13847        return _readFromStorage2.apply(this, arguments);
13848      }
13849
13850      return _readFromStorage;
13851    }()
13852  }]);
13853
13854  return GenericPreferences;
13855}(_preferences.BasePreferences);
13856
13857var GenericExternalServices = Object.create(_app.DefaultExternalServices);
13858
13859GenericExternalServices.createDownloadManager = function (options) {
13860  return new _download_manager.DownloadManager(options);
13861};
13862
13863GenericExternalServices.createPreferences = function () {
13864  return new GenericPreferences();
13865};
13866
13867GenericExternalServices.createL10n = function (_ref) {
13868  var _ref$locale = _ref.locale,
13869      locale = _ref$locale === void 0 ? 'en-US' : _ref$locale;
13870  return new _genericl10n.GenericL10n(locale);
13871};
13872
13873_app.PDFViewerApplication.externalServices = GenericExternalServices;
13874
13875/***/ }),
13876/* 37 */
13877/***/ (function(module, exports, __webpack_require__) {
13878
13879"use strict";
13880
13881
13882Object.defineProperty(exports, "__esModule", {
13883  value: true
13884});
13885exports.BasePreferences = void 0;
13886
13887var _regenerator = _interopRequireDefault(__webpack_require__(2));
13888
13889function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13890
13891function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
13892
13893function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13894
13895function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13896
13897function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13898
13899function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13900
13901function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
13902
13903var defaultPreferences = null;
13904
13905function getDefaultPreferences() {
13906  if (!defaultPreferences) {
13907    defaultPreferences = Promise.resolve({
13908      "cursorToolOnLoad": 0,
13909      "defaultZoomValue": "",
13910      "disablePageLabels": false,
13911      "enablePrintAutoRotate": false,
13912      "enableWebGL": false,
13913      "eventBusDispatchToDOM": false,
13914      "externalLinkTarget": 0,
13915      "historyUpdateUrl": false,
13916      "pdfBugEnabled": false,
13917      "renderer": "canvas",
13918      "renderInteractiveForms": false,
13919      "sidebarViewOnLoad": -1,
13920      "scrollModeOnLoad": -1,
13921      "spreadModeOnLoad": -1,
13922      "textLayerMode": 1,
13923      "useOnlyCssZoom": false,
13924      "viewOnLoad": 0,
13925      "disableAutoFetch": false,
13926      "disableFontFace": false,
13927      "disableRange": false,
13928      "disableStream": false
13929    });
13930  }
13931
13932  return defaultPreferences;
13933}
13934
13935var BasePreferences =
13936/*#__PURE__*/
13937function () {
13938  function BasePreferences() {
13939    var _this = this;
13940
13941    _classCallCheck(this, BasePreferences);
13942
13943    if (this.constructor === BasePreferences) {
13944      throw new Error('Cannot initialize BasePreferences.');
13945    }
13946
13947    this.prefs = null;
13948    this._initializedPromise = getDefaultPreferences().then(function (defaults) {
13949      Object.defineProperty(_this, 'defaults', {
13950        value: Object.freeze(defaults),
13951        writable: false,
13952        enumerable: true,
13953        configurable: false
13954      });
13955      _this.prefs = Object.assign(Object.create(null), defaults);
13956      return _this._readFromStorage(defaults);
13957    }).then(function (prefs) {
13958      if (!prefs) {
13959        return;
13960      }
13961
13962      for (var name in prefs) {
13963        var defaultValue = _this.defaults[name],
13964            prefValue = prefs[name];
13965
13966        if (defaultValue === undefined || _typeof(prefValue) !== _typeof(defaultValue)) {
13967          continue;
13968        }
13969
13970        _this.prefs[name] = prefValue;
13971      }
13972    });
13973  }
13974
13975  _createClass(BasePreferences, [{
13976    key: "_writeToStorage",
13977    value: function () {
13978      var _writeToStorage2 = _asyncToGenerator(
13979      /*#__PURE__*/
13980      _regenerator["default"].mark(function _callee(prefObj) {
13981        return _regenerator["default"].wrap(function _callee$(_context) {
13982          while (1) {
13983            switch (_context.prev = _context.next) {
13984              case 0:
13985                throw new Error('Not implemented: _writeToStorage');
13986
13987              case 1:
13988              case "end":
13989                return _context.stop();
13990            }
13991          }
13992        }, _callee);
13993      }));
13994
13995      function _writeToStorage(_x) {
13996        return _writeToStorage2.apply(this, arguments);
13997      }
13998
13999      return _writeToStorage;
14000    }()
14001  }, {
14002    key: "_readFromStorage",
14003    value: function () {
14004      var _readFromStorage2 = _asyncToGenerator(
14005      /*#__PURE__*/
14006      _regenerator["default"].mark(function _callee2(prefObj) {
14007        return _regenerator["default"].wrap(function _callee2$(_context2) {
14008          while (1) {
14009            switch (_context2.prev = _context2.next) {
14010              case 0:
14011                throw new Error('Not implemented: _readFromStorage');
14012
14013              case 1:
14014              case "end":
14015                return _context2.stop();
14016            }
14017          }
14018        }, _callee2);
14019      }));
14020
14021      function _readFromStorage(_x2) {
14022        return _readFromStorage2.apply(this, arguments);
14023      }
14024
14025      return _readFromStorage;
14026    }()
14027  }, {
14028    key: "reset",
14029    value: function () {
14030      var _reset = _asyncToGenerator(
14031      /*#__PURE__*/
14032      _regenerator["default"].mark(function _callee3() {
14033        return _regenerator["default"].wrap(function _callee3$(_context3) {
14034          while (1) {
14035            switch (_context3.prev = _context3.next) {
14036              case 0:
14037                _context3.next = 2;
14038                return this._initializedPromise;
14039
14040              case 2:
14041                this.prefs = Object.assign(Object.create(null), this.defaults);
14042                return _context3.abrupt("return", this._writeToStorage(this.defaults));
14043
14044              case 4:
14045              case "end":
14046                return _context3.stop();
14047            }
14048          }
14049        }, _callee3, this);
14050      }));
14051
14052      function reset() {
14053        return _reset.apply(this, arguments);
14054      }
14055
14056      return reset;
14057    }()
14058  }, {
14059    key: "set",
14060    value: function () {
14061      var _set = _asyncToGenerator(
14062      /*#__PURE__*/
14063      _regenerator["default"].mark(function _callee4(name, value) {
14064        var defaultValue, valueType, defaultType;
14065        return _regenerator["default"].wrap(function _callee4$(_context4) {
14066          while (1) {
14067            switch (_context4.prev = _context4.next) {
14068              case 0:
14069                _context4.next = 2;
14070                return this._initializedPromise;
14071
14072              case 2:
14073                defaultValue = this.defaults[name];
14074
14075                if (!(defaultValue === undefined)) {
14076                  _context4.next = 7;
14077                  break;
14078                }
14079
14080                throw new Error("Set preference: \"".concat(name, "\" is undefined."));
14081
14082              case 7:
14083                if (!(value === undefined)) {
14084                  _context4.next = 9;
14085                  break;
14086                }
14087
14088                throw new Error('Set preference: no value is specified.');
14089
14090              case 9:
14091                valueType = _typeof(value);
14092                defaultType = _typeof(defaultValue);
14093
14094                if (!(valueType !== defaultType)) {
14095                  _context4.next = 19;
14096                  break;
14097                }
14098
14099                if (!(valueType === 'number' && defaultType === 'string')) {
14100                  _context4.next = 16;
14101                  break;
14102                }
14103
14104                value = value.toString();
14105                _context4.next = 17;
14106                break;
14107
14108              case 16:
14109                throw new Error("Set preference: \"".concat(value, "\" is a ").concat(valueType, ", ") + "expected a ".concat(defaultType, "."));
14110
14111              case 17:
14112                _context4.next = 21;
14113                break;
14114
14115              case 19:
14116                if (!(valueType === 'number' && !Number.isInteger(value))) {
14117                  _context4.next = 21;
14118                  break;
14119                }
14120
14121                throw new Error("Set preference: \"".concat(value, "\" must be an integer."));
14122
14123              case 21:
14124                this.prefs[name] = value;
14125                return _context4.abrupt("return", this._writeToStorage(this.prefs));
14126
14127              case 23:
14128              case "end":
14129                return _context4.stop();
14130            }
14131          }
14132        }, _callee4, this);
14133      }));
14134
14135      function set(_x3, _x4) {
14136        return _set.apply(this, arguments);
14137      }
14138
14139      return set;
14140    }()
14141  }, {
14142    key: "get",
14143    value: function () {
14144      var _get = _asyncToGenerator(
14145      /*#__PURE__*/
14146      _regenerator["default"].mark(function _callee5(name) {
14147        var defaultValue, prefValue;
14148        return _regenerator["default"].wrap(function _callee5$(_context5) {
14149          while (1) {
14150            switch (_context5.prev = _context5.next) {
14151              case 0:
14152                _context5.next = 2;
14153                return this._initializedPromise;
14154
14155              case 2:
14156                defaultValue = this.defaults[name];
14157
14158                if (!(defaultValue === undefined)) {
14159                  _context5.next = 7;
14160                  break;
14161                }
14162
14163                throw new Error("Get preference: \"".concat(name, "\" is undefined."));
14164
14165              case 7:
14166                prefValue = this.prefs[name];
14167
14168                if (!(prefValue !== undefined)) {
14169                  _context5.next = 10;
14170                  break;
14171                }
14172
14173                return _context5.abrupt("return", prefValue);
14174
14175              case 10:
14176                return _context5.abrupt("return", defaultValue);
14177
14178              case 11:
14179              case "end":
14180                return _context5.stop();
14181            }
14182          }
14183        }, _callee5, this);
14184      }));
14185
14186      function get(_x5) {
14187        return _get.apply(this, arguments);
14188      }
14189
14190      return get;
14191    }()
14192  }, {
14193    key: "getAll",
14194    value: function () {
14195      var _getAll = _asyncToGenerator(
14196      /*#__PURE__*/
14197      _regenerator["default"].mark(function _callee6() {
14198        return _regenerator["default"].wrap(function _callee6$(_context6) {
14199          while (1) {
14200            switch (_context6.prev = _context6.next) {
14201              case 0:
14202                _context6.next = 2;
14203                return this._initializedPromise;
14204
14205              case 2:
14206                return _context6.abrupt("return", Object.assign(Object.create(null), this.defaults, this.prefs));
14207
14208              case 3:
14209              case "end":
14210                return _context6.stop();
14211            }
14212          }
14213        }, _callee6, this);
14214      }));
14215
14216      function getAll() {
14217        return _getAll.apply(this, arguments);
14218      }
14219
14220      return getAll;
14221    }()
14222  }]);
14223
14224  return BasePreferences;
14225}();
14226
14227exports.BasePreferences = BasePreferences;
14228
14229/***/ }),
14230/* 38 */
14231/***/ (function(module, exports, __webpack_require__) {
14232
14233"use strict";
14234
14235
14236Object.defineProperty(exports, "__esModule", {
14237  value: true
14238});
14239exports.DownloadManager = void 0;
14240
14241var _pdfjsLib = __webpack_require__(7);
14242
14243function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14244
14245function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14246
14247function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14248
14249;
14250var DISABLE_CREATE_OBJECT_URL = _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL || false;
14251
14252function _download(blobUrl, filename) {
14253  var a = document.createElement('a');
14254
14255  if (!a.click) {
14256    throw new Error('DownloadManager: "a.click()" is not supported.');
14257  }
14258
14259  a.href = blobUrl;
14260  a.target = '_parent';
14261
14262  if ('download' in a) {
14263    a.download = filename;
14264  }
14265
14266  (document.body || document.documentElement).appendChild(a);
14267  a.click();
14268  a.remove();
14269}
14270
14271var DownloadManager =
14272/*#__PURE__*/
14273function () {
14274  function DownloadManager(_ref) {
14275    var _ref$disableCreateObj = _ref.disableCreateObjectURL,
14276        disableCreateObjectURL = _ref$disableCreateObj === void 0 ? DISABLE_CREATE_OBJECT_URL : _ref$disableCreateObj;
14277
14278    _classCallCheck(this, DownloadManager);
14279
14280    this.disableCreateObjectURL = disableCreateObjectURL;
14281  }
14282
14283  _createClass(DownloadManager, [{
14284    key: "downloadUrl",
14285    value: function downloadUrl(url, filename) {
14286      if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
14287        return;
14288      }
14289
14290      _download(url + '#pdfjs.action=download', filename);
14291    }
14292  }, {
14293    key: "downloadData",
14294    value: function downloadData(data, filename, contentType) {
14295      if (navigator.msSaveBlob) {
14296        navigator.msSaveBlob(new Blob([data], {
14297          type: contentType
14298        }), filename);
14299        return;
14300      }
14301
14302      var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, this.disableCreateObjectURL);
14303
14304      _download(blobUrl, filename);
14305    }
14306  }, {
14307    key: "download",
14308    value: function download(blob, url, filename) {
14309      if (navigator.msSaveBlob) {
14310        if (!navigator.msSaveBlob(blob, filename)) {
14311          this.downloadUrl(url, filename);
14312        }
14313
14314        return;
14315      }
14316
14317      if (this.disableCreateObjectURL) {
14318        this.downloadUrl(url, filename);
14319        return;
14320      }
14321
14322      var blobUrl = _pdfjsLib.URL.createObjectURL(blob);
14323
14324      _download(blobUrl, filename);
14325    }
14326  }]);
14327
14328  return DownloadManager;
14329}();
14330
14331exports.DownloadManager = DownloadManager;
14332
14333/***/ }),
14334/* 39 */
14335/***/ (function(module, exports, __webpack_require__) {
14336
14337"use strict";
14338
14339
14340Object.defineProperty(exports, "__esModule", {
14341  value: true
14342});
14343exports.GenericL10n = void 0;
14344
14345var _regenerator = _interopRequireDefault(__webpack_require__(2));
14346
14347__webpack_require__(40);
14348
14349function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14350
14351function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
14352
14353function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14354
14355function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14356
14357function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
14358
14359function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
14360
14361var webL10n = document.webL10n;
14362
14363var GenericL10n =
14364/*#__PURE__*/
14365function () {
14366  function GenericL10n(lang) {
14367    _classCallCheck(this, GenericL10n);
14368
14369    this._lang = lang;
14370    this._ready = new Promise(function (resolve, reject) {
14371      webL10n.setLanguage(lang, function () {
14372        resolve(webL10n);
14373      });
14374    });
14375  }
14376
14377  _createClass(GenericL10n, [{
14378    key: "getLanguage",
14379    value: function () {
14380      var _getLanguage = _asyncToGenerator(
14381      /*#__PURE__*/
14382      _regenerator["default"].mark(function _callee() {
14383        var l10n;
14384        return _regenerator["default"].wrap(function _callee$(_context) {
14385          while (1) {
14386            switch (_context.prev = _context.next) {
14387              case 0:
14388                _context.next = 2;
14389                return this._ready;
14390
14391              case 2:
14392                l10n = _context.sent;
14393                return _context.abrupt("return", l10n.getLanguage());
14394
14395              case 4:
14396              case "end":
14397                return _context.stop();
14398            }
14399          }
14400        }, _callee, this);
14401      }));
14402
14403      function getLanguage() {
14404        return _getLanguage.apply(this, arguments);
14405      }
14406
14407      return getLanguage;
14408    }()
14409  }, {
14410    key: "getDirection",
14411    value: function () {
14412      var _getDirection = _asyncToGenerator(
14413      /*#__PURE__*/
14414      _regenerator["default"].mark(function _callee2() {
14415        var l10n;
14416        return _regenerator["default"].wrap(function _callee2$(_context2) {
14417          while (1) {
14418            switch (_context2.prev = _context2.next) {
14419              case 0:
14420                _context2.next = 2;
14421                return this._ready;
14422
14423              case 2:
14424                l10n = _context2.sent;
14425                return _context2.abrupt("return", l10n.getDirection());
14426
14427              case 4:
14428              case "end":
14429                return _context2.stop();
14430            }
14431          }
14432        }, _callee2, this);
14433      }));
14434
14435      function getDirection() {
14436        return _getDirection.apply(this, arguments);
14437      }
14438
14439      return getDirection;
14440    }()
14441  }, {
14442    key: "get",
14443    value: function () {
14444      var _get = _asyncToGenerator(
14445      /*#__PURE__*/
14446      _regenerator["default"].mark(function _callee3(property, args, fallback) {
14447        var l10n;
14448        return _regenerator["default"].wrap(function _callee3$(_context3) {
14449          while (1) {
14450            switch (_context3.prev = _context3.next) {
14451              case 0:
14452                _context3.next = 2;
14453                return this._ready;
14454
14455              case 2:
14456                l10n = _context3.sent;
14457                return _context3.abrupt("return", l10n.get(property, args, fallback));
14458
14459              case 4:
14460              case "end":
14461                return _context3.stop();
14462            }
14463          }
14464        }, _callee3, this);
14465      }));
14466
14467      function get(_x, _x2, _x3) {
14468        return _get.apply(this, arguments);
14469      }
14470
14471      return get;
14472    }()
14473  }, {
14474    key: "translate",
14475    value: function () {
14476      var _translate = _asyncToGenerator(
14477      /*#__PURE__*/
14478      _regenerator["default"].mark(function _callee4(element) {
14479        var l10n;
14480        return _regenerator["default"].wrap(function _callee4$(_context4) {
14481          while (1) {
14482            switch (_context4.prev = _context4.next) {
14483              case 0:
14484                _context4.next = 2;
14485                return this._ready;
14486
14487              case 2:
14488                l10n = _context4.sent;
14489                return _context4.abrupt("return", l10n.translate(element));
14490
14491              case 4:
14492              case "end":
14493                return _context4.stop();
14494            }
14495          }
14496        }, _callee4, this);
14497      }));
14498
14499      function translate(_x4) {
14500        return _translate.apply(this, arguments);
14501      }
14502
14503      return translate;
14504    }()
14505  }]);
14506
14507  return GenericL10n;
14508}();
14509
14510exports.GenericL10n = GenericL10n;
14511
14512/***/ }),
14513/* 40 */
14514/***/ (function(module, exports, __webpack_require__) {
14515
14516"use strict";
14517
14518
14519document.webL10n = function (window, document, undefined) {
14520  var gL10nData = {};
14521  var gTextData = '';
14522  var gTextProp = 'textContent';
14523  var gLanguage = '';
14524  var gMacros = {};
14525  var gReadyState = 'loading';
14526  var gAsyncResourceLoading = true;
14527
14528  function getL10nResourceLinks() {
14529    return document.querySelectorAll('link[type="application/l10n"]');
14530  }
14531
14532  function getL10nDictionary() {
14533    var script = document.querySelector('script[type="application/l10n"]');
14534    return script ? JSON.parse(script.innerHTML) : null;
14535  }
14536
14537  function getTranslatableChildren(element) {
14538    return element ? element.querySelectorAll('*[data-l10n-id]') : [];
14539  }
14540
14541  function getL10nAttributes(element) {
14542    if (!element) return {};
14543    var l10nId = element.getAttribute('data-l10n-id');
14544    var l10nArgs = element.getAttribute('data-l10n-args');
14545    var args = {};
14546
14547    if (l10nArgs) {
14548      try {
14549        args = JSON.parse(l10nArgs);
14550      } catch (e) {
14551        console.warn('could not parse arguments for #' + l10nId);
14552      }
14553    }
14554
14555    return {
14556      id: l10nId,
14557      args: args
14558    };
14559  }
14560
14561  function fireL10nReadyEvent(lang) {
14562    var evtObject = document.createEvent('Event');
14563    evtObject.initEvent('localized', true, false);
14564    evtObject.language = lang;
14565    document.dispatchEvent(evtObject);
14566  }
14567
14568  function xhrLoadText(url, onSuccess, onFailure) {
14569    onSuccess = onSuccess || function _onSuccess(data) {};
14570
14571    onFailure = onFailure || function _onFailure() {};
14572
14573    var xhr = new XMLHttpRequest();
14574    xhr.open('GET', url, gAsyncResourceLoading);
14575
14576    if (xhr.overrideMimeType) {
14577      xhr.overrideMimeType('text/plain; charset=utf-8');
14578    }
14579
14580    xhr.onreadystatechange = function () {
14581      if (xhr.readyState == 4) {
14582        if (xhr.status == 200 || xhr.status === 0) {
14583          onSuccess(xhr.responseText);
14584        } else {
14585          onFailure();
14586        }
14587      }
14588    };
14589
14590    xhr.onerror = onFailure;
14591    xhr.ontimeout = onFailure;
14592
14593    try {
14594      xhr.send(null);
14595    } catch (e) {
14596      onFailure();
14597    }
14598  }
14599
14600  function parseResource(href, lang, successCallback, failureCallback) {
14601    var baseURL = href.replace(/[^\/]*$/, '') || './';
14602
14603    function evalString(text) {
14604      if (text.lastIndexOf('\\') < 0) return text;
14605      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, "'");
14606    }
14607
14608    function parseProperties(text, parsedPropertiesCallback) {
14609      var dictionary = {};
14610      var reBlank = /^\s*|\s*$/;
14611      var reComment = /^\s*#|^\s*$/;
14612      var reSection = /^\s*\[(.*)\]\s*$/;
14613      var reImport = /^\s*@import\s+url\((.*)\)\s*$/i;
14614      var reSplit = /^([^=\s]*)\s*=\s*(.+)$/;
14615
14616      function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
14617        var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
14618        var currentLang = '*';
14619        var genericLang = lang.split('-', 1)[0];
14620        var skipLang = false;
14621        var match = '';
14622
14623        function nextEntry() {
14624          while (true) {
14625            if (!entries.length) {
14626              parsedRawLinesCallback();
14627              return;
14628            }
14629
14630            var line = entries.shift();
14631            if (reComment.test(line)) continue;
14632
14633            if (extendedSyntax) {
14634              match = reSection.exec(line);
14635
14636              if (match) {
14637                currentLang = match[1].toLowerCase();
14638                skipLang = currentLang !== '*' && currentLang !== lang && currentLang !== genericLang;
14639                continue;
14640              } else if (skipLang) {
14641                continue;
14642              }
14643
14644              match = reImport.exec(line);
14645
14646              if (match) {
14647                loadImport(baseURL + match[1], nextEntry);
14648                return;
14649              }
14650            }
14651
14652            var tmp = line.match(reSplit);
14653
14654            if (tmp && tmp.length == 3) {
14655              dictionary[tmp[1]] = evalString(tmp[2]);
14656            }
14657          }
14658        }
14659
14660        nextEntry();
14661      }
14662
14663      function loadImport(url, callback) {
14664        xhrLoadText(url, function (content) {
14665          parseRawLines(content, false, callback);
14666        }, function () {
14667          console.warn(url + ' not found.');
14668          callback();
14669        });
14670      }
14671
14672      parseRawLines(text, true, function () {
14673        parsedPropertiesCallback(dictionary);
14674      });
14675    }
14676
14677    xhrLoadText(href, function (response) {
14678      gTextData += response;
14679      parseProperties(response, function (data) {
14680        for (var key in data) {
14681          var id,
14682              prop,
14683              index = key.lastIndexOf('.');
14684
14685          if (index > 0) {
14686            id = key.substring(0, index);
14687            prop = key.substring(index + 1);
14688          } else {
14689            id = key;
14690            prop = gTextProp;
14691          }
14692
14693          if (!gL10nData[id]) {
14694            gL10nData[id] = {};
14695          }
14696
14697          gL10nData[id][prop] = data[key];
14698        }
14699
14700        if (successCallback) {
14701          successCallback();
14702        }
14703      });
14704    }, failureCallback);
14705  }
14706
14707  function loadLocale(lang, callback) {
14708    if (lang) {
14709      lang = lang.toLowerCase();
14710    }
14711
14712    callback = callback || function _callback() {};
14713
14714    clear();
14715    gLanguage = lang;
14716    var langLinks = getL10nResourceLinks();
14717    var langCount = langLinks.length;
14718
14719    if (langCount === 0) {
14720      var dict = getL10nDictionary();
14721
14722      if (dict && dict.locales && dict.default_locale) {
14723        console.log('using the embedded JSON directory, early way out');
14724        gL10nData = dict.locales[lang];
14725
14726        if (!gL10nData) {
14727          var defaultLocale = dict.default_locale.toLowerCase();
14728
14729          for (var anyCaseLang in dict.locales) {
14730            anyCaseLang = anyCaseLang.toLowerCase();
14731
14732            if (anyCaseLang === lang) {
14733              gL10nData = dict.locales[lang];
14734              break;
14735            } else if (anyCaseLang === defaultLocale) {
14736              gL10nData = dict.locales[defaultLocale];
14737            }
14738          }
14739        }
14740
14741        callback();
14742      } else {
14743        console.log('no resource to load, early way out');
14744      }
14745
14746      fireL10nReadyEvent(lang);
14747      gReadyState = 'complete';
14748      return;
14749    }
14750
14751    var onResourceLoaded = null;
14752    var gResourceCount = 0;
14753
14754    onResourceLoaded = function onResourceLoaded() {
14755      gResourceCount++;
14756
14757      if (gResourceCount >= langCount) {
14758        callback();
14759        fireL10nReadyEvent(lang);
14760        gReadyState = 'complete';
14761      }
14762    };
14763
14764    function L10nResourceLink(link) {
14765      var href = link.href;
14766
14767      this.load = function (lang, callback) {
14768        parseResource(href, lang, callback, function () {
14769          console.warn(href + ' not found.');
14770          console.warn('"' + lang + '" resource not found');
14771          gLanguage = '';
14772          callback();
14773        });
14774      };
14775    }
14776
14777    for (var i = 0; i < langCount; i++) {
14778      var resource = new L10nResourceLink(langLinks[i]);
14779      resource.load(lang, onResourceLoaded);
14780    }
14781  }
14782
14783  function clear() {
14784    gL10nData = {};
14785    gTextData = '';
14786    gLanguage = '';
14787  }
14788
14789  function getPluralRules(lang) {
14790    var locales2rules = {
14791      'af': 3,
14792      'ak': 4,
14793      'am': 4,
14794      'ar': 1,
14795      'asa': 3,
14796      'az': 0,
14797      'be': 11,
14798      'bem': 3,
14799      'bez': 3,
14800      'bg': 3,
14801      'bh': 4,
14802      'bm': 0,
14803      'bn': 3,
14804      'bo': 0,
14805      'br': 20,
14806      'brx': 3,
14807      'bs': 11,
14808      'ca': 3,
14809      'cgg': 3,
14810      'chr': 3,
14811      'cs': 12,
14812      'cy': 17,
14813      'da': 3,
14814      'de': 3,
14815      'dv': 3,
14816      'dz': 0,
14817      'ee': 3,
14818      'el': 3,
14819      'en': 3,
14820      'eo': 3,
14821      'es': 3,
14822      'et': 3,
14823      'eu': 3,
14824      'fa': 0,
14825      'ff': 5,
14826      'fi': 3,
14827      'fil': 4,
14828      'fo': 3,
14829      'fr': 5,
14830      'fur': 3,
14831      'fy': 3,
14832      'ga': 8,
14833      'gd': 24,
14834      'gl': 3,
14835      'gsw': 3,
14836      'gu': 3,
14837      'guw': 4,
14838      'gv': 23,
14839      'ha': 3,
14840      'haw': 3,
14841      'he': 2,
14842      'hi': 4,
14843      'hr': 11,
14844      'hu': 0,
14845      'id': 0,
14846      'ig': 0,
14847      'ii': 0,
14848      'is': 3,
14849      'it': 3,
14850      'iu': 7,
14851      'ja': 0,
14852      'jmc': 3,
14853      'jv': 0,
14854      'ka': 0,
14855      'kab': 5,
14856      'kaj': 3,
14857      'kcg': 3,
14858      'kde': 0,
14859      'kea': 0,
14860      'kk': 3,
14861      'kl': 3,
14862      'km': 0,
14863      'kn': 0,
14864      'ko': 0,
14865      'ksb': 3,
14866      'ksh': 21,
14867      'ku': 3,
14868      'kw': 7,
14869      'lag': 18,
14870      'lb': 3,
14871      'lg': 3,
14872      'ln': 4,
14873      'lo': 0,
14874      'lt': 10,
14875      'lv': 6,
14876      'mas': 3,
14877      'mg': 4,
14878      'mk': 16,
14879      'ml': 3,
14880      'mn': 3,
14881      'mo': 9,
14882      'mr': 3,
14883      'ms': 0,
14884      'mt': 15,
14885      'my': 0,
14886      'nah': 3,
14887      'naq': 7,
14888      'nb': 3,
14889      'nd': 3,
14890      'ne': 3,
14891      'nl': 3,
14892      'nn': 3,
14893      'no': 3,
14894      'nr': 3,
14895      'nso': 4,
14896      'ny': 3,
14897      'nyn': 3,
14898      'om': 3,
14899      'or': 3,
14900      'pa': 3,
14901      'pap': 3,
14902      'pl': 13,
14903      'ps': 3,
14904      'pt': 3,
14905      'rm': 3,
14906      'ro': 9,
14907      'rof': 3,
14908      'ru': 11,
14909      'rwk': 3,
14910      'sah': 0,
14911      'saq': 3,
14912      'se': 7,
14913      'seh': 3,
14914      'ses': 0,
14915      'sg': 0,
14916      'sh': 11,
14917      'shi': 19,
14918      'sk': 12,
14919      'sl': 14,
14920      'sma': 7,
14921      'smi': 7,
14922      'smj': 7,
14923      'smn': 7,
14924      'sms': 7,
14925      'sn': 3,
14926      'so': 3,
14927      'sq': 3,
14928      'sr': 11,
14929      'ss': 3,
14930      'ssy': 3,
14931      'st': 3,
14932      'sv': 3,
14933      'sw': 3,
14934      'syr': 3,
14935      'ta': 3,
14936      'te': 3,
14937      'teo': 3,
14938      'th': 0,
14939      'ti': 4,
14940      'tig': 3,
14941      'tk': 3,
14942      'tl': 4,
14943      'tn': 3,
14944      'to': 0,
14945      'tr': 0,
14946      'ts': 3,
14947      'tzm': 22,
14948      'uk': 11,
14949      'ur': 3,
14950      've': 3,
14951      'vi': 0,
14952      'vun': 3,
14953      'wa': 4,
14954      'wae': 3,
14955      'wo': 0,
14956      'xh': 3,
14957      'xog': 3,
14958      'yo': 0,
14959      'zh': 0,
14960      'zu': 3
14961    };
14962
14963    function isIn(n, list) {
14964      return list.indexOf(n) !== -1;
14965    }
14966
14967    function isBetween(n, start, end) {
14968      return start <= n && n <= end;
14969    }
14970
14971    var pluralRules = {
14972      '0': function _(n) {
14973        return 'other';
14974      },
14975      '1': function _(n) {
14976        if (isBetween(n % 100, 3, 10)) return 'few';
14977        if (n === 0) return 'zero';
14978        if (isBetween(n % 100, 11, 99)) return 'many';
14979        if (n == 2) return 'two';
14980        if (n == 1) return 'one';
14981        return 'other';
14982      },
14983      '2': function _(n) {
14984        if (n !== 0 && n % 10 === 0) return 'many';
14985        if (n == 2) return 'two';
14986        if (n == 1) return 'one';
14987        return 'other';
14988      },
14989      '3': function _(n) {
14990        if (n == 1) return 'one';
14991        return 'other';
14992      },
14993      '4': function _(n) {
14994        if (isBetween(n, 0, 1)) return 'one';
14995        return 'other';
14996      },
14997      '5': function _(n) {
14998        if (isBetween(n, 0, 2) && n != 2) return 'one';
14999        return 'other';
15000      },
15001      '6': function _(n) {
15002        if (n === 0) return 'zero';
15003        if (n % 10 == 1 && n % 100 != 11) return 'one';
15004        return 'other';
15005      },
15006      '7': function _(n) {
15007        if (n == 2) return 'two';
15008        if (n == 1) return 'one';
15009        return 'other';
15010      },
15011      '8': function _(n) {
15012        if (isBetween(n, 3, 6)) return 'few';
15013        if (isBetween(n, 7, 10)) return 'many';
15014        if (n == 2) return 'two';
15015        if (n == 1) return 'one';
15016        return 'other';
15017      },
15018      '9': function _(n) {
15019        if (n === 0 || n != 1 && isBetween(n % 100, 1, 19)) return 'few';
15020        if (n == 1) return 'one';
15021        return 'other';
15022      },
15023      '10': function _(n) {
15024        if (isBetween(n % 10, 2, 9) && !isBetween(n % 100, 11, 19)) return 'few';
15025        if (n % 10 == 1 && !isBetween(n % 100, 11, 19)) return 'one';
15026        return 'other';
15027      },
15028      '11': function _(n) {
15029        if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
15030        if (n % 10 === 0 || isBetween(n % 10, 5, 9) || isBetween(n % 100, 11, 14)) return 'many';
15031        if (n % 10 == 1 && n % 100 != 11) return 'one';
15032        return 'other';
15033      },
15034      '12': function _(n) {
15035        if (isBetween(n, 2, 4)) return 'few';
15036        if (n == 1) return 'one';
15037        return 'other';
15038      },
15039      '13': function _(n) {
15040        if (isBetween(n % 10, 2, 4) && !isBetween(n % 100, 12, 14)) return 'few';
15041        if (n != 1 && isBetween(n % 10, 0, 1) || isBetween(n % 10, 5, 9) || isBetween(n % 100, 12, 14)) return 'many';
15042        if (n == 1) return 'one';
15043        return 'other';
15044      },
15045      '14': function _(n) {
15046        if (isBetween(n % 100, 3, 4)) return 'few';
15047        if (n % 100 == 2) return 'two';
15048        if (n % 100 == 1) return 'one';
15049        return 'other';
15050      },
15051      '15': function _(n) {
15052        if (n === 0 || isBetween(n % 100, 2, 10)) return 'few';
15053        if (isBetween(n % 100, 11, 19)) return 'many';
15054        if (n == 1) return 'one';
15055        return 'other';
15056      },
15057      '16': function _(n) {
15058        if (n % 10 == 1 && n != 11) return 'one';
15059        return 'other';
15060      },
15061      '17': function _(n) {
15062        if (n == 3) return 'few';
15063        if (n === 0) return 'zero';
15064        if (n == 6) return 'many';
15065        if (n == 2) return 'two';
15066        if (n == 1) return 'one';
15067        return 'other';
15068      },
15069      '18': function _(n) {
15070        if (n === 0) return 'zero';
15071        if (isBetween(n, 0, 2) && n !== 0 && n != 2) return 'one';
15072        return 'other';
15073      },
15074      '19': function _(n) {
15075        if (isBetween(n, 2, 10)) return 'few';
15076        if (isBetween(n, 0, 1)) return 'one';
15077        return 'other';
15078      },
15079      '20': function _(n) {
15080        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';
15081        if (n % 1000000 === 0 && n !== 0) return 'many';
15082        if (n % 10 == 2 && !isIn(n % 100, [12, 72, 92])) return 'two';
15083        if (n % 10 == 1 && !isIn(n % 100, [11, 71, 91])) return 'one';
15084        return 'other';
15085      },
15086      '21': function _(n) {
15087        if (n === 0) return 'zero';
15088        if (n == 1) return 'one';
15089        return 'other';
15090      },
15091      '22': function _(n) {
15092        if (isBetween(n, 0, 1) || isBetween(n, 11, 99)) return 'one';
15093        return 'other';
15094      },
15095      '23': function _(n) {
15096        if (isBetween(n % 10, 1, 2) || n % 20 === 0) return 'one';
15097        return 'other';
15098      },
15099      '24': function _(n) {
15100        if (isBetween(n, 3, 10) || isBetween(n, 13, 19)) return 'few';
15101        if (isIn(n, [2, 12])) return 'two';
15102        if (isIn(n, [1, 11])) return 'one';
15103        return 'other';
15104      }
15105    };
15106    var index = locales2rules[lang.replace(/-.*$/, '')];
15107
15108    if (!(index in pluralRules)) {
15109      console.warn('plural form unknown for [' + lang + ']');
15110      return function () {
15111        return 'other';
15112      };
15113    }
15114
15115    return pluralRules[index];
15116  }
15117
15118  gMacros.plural = function (str, param, key, prop) {
15119    var n = parseFloat(param);
15120    if (isNaN(n)) return str;
15121    if (prop != gTextProp) return str;
15122
15123    if (!gMacros._pluralRules) {
15124      gMacros._pluralRules = getPluralRules(gLanguage);
15125    }
15126
15127    var index = '[' + gMacros._pluralRules(n) + ']';
15128
15129    if (n === 0 && key + '[zero]' in gL10nData) {
15130      str = gL10nData[key + '[zero]'][prop];
15131    } else if (n == 1 && key + '[one]' in gL10nData) {
15132      str = gL10nData[key + '[one]'][prop];
15133    } else if (n == 2 && key + '[two]' in gL10nData) {
15134      str = gL10nData[key + '[two]'][prop];
15135    } else if (key + index in gL10nData) {
15136      str = gL10nData[key + index][prop];
15137    } else if (key + '[other]' in gL10nData) {
15138      str = gL10nData[key + '[other]'][prop];
15139    }
15140
15141    return str;
15142  };
15143
15144  function getL10nData(key, args, fallback) {
15145    var data = gL10nData[key];
15146
15147    if (!data) {
15148      console.warn('#' + key + ' is undefined.');
15149
15150      if (!fallback) {
15151        return null;
15152      }
15153
15154      data = fallback;
15155    }
15156
15157    var rv = {};
15158
15159    for (var prop in data) {
15160      var str = data[prop];
15161      str = substIndexes(str, args, key, prop);
15162      str = substArguments(str, args, key);
15163      rv[prop] = str;
15164    }
15165
15166    return rv;
15167  }
15168
15169  function substIndexes(str, args, key, prop) {
15170    var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/;
15171    var reMatch = reIndex.exec(str);
15172    if (!reMatch || !reMatch.length) return str;
15173    var macroName = reMatch[1];
15174    var paramName = reMatch[2];
15175    var param;
15176
15177    if (args && paramName in args) {
15178      param = args[paramName];
15179    } else if (paramName in gL10nData) {
15180      param = gL10nData[paramName];
15181    }
15182
15183    if (macroName in gMacros) {
15184      var macro = gMacros[macroName];
15185      str = macro(str, param, key, prop);
15186    }
15187
15188    return str;
15189  }
15190
15191  function substArguments(str, args, key) {
15192    var reArgs = /\{\{\s*(.+?)\s*\}\}/g;
15193    return str.replace(reArgs, function (matched_text, arg) {
15194      if (args && arg in args) {
15195        return args[arg];
15196      }
15197
15198      if (arg in gL10nData) {
15199        return gL10nData[arg];
15200      }
15201
15202      console.log('argument {{' + arg + '}} for #' + key + ' is undefined.');
15203      return matched_text;
15204    });
15205  }
15206
15207  function translateElement(element) {
15208    var l10n = getL10nAttributes(element);
15209    if (!l10n.id) return;
15210    var data = getL10nData(l10n.id, l10n.args);
15211
15212    if (!data) {
15213      console.warn('#' + l10n.id + ' is undefined.');
15214      return;
15215    }
15216
15217    if (data[gTextProp]) {
15218      if (getChildElementCount(element) === 0) {
15219        element[gTextProp] = data[gTextProp];
15220      } else {
15221        var children = element.childNodes;
15222        var found = false;
15223
15224        for (var i = 0, l = children.length; i < l; i++) {
15225          if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) {
15226            if (found) {
15227              children[i].nodeValue = '';
15228            } else {
15229              children[i].nodeValue = data[gTextProp];
15230              found = true;
15231            }
15232          }
15233        }
15234
15235        if (!found) {
15236          var textNode = document.createTextNode(data[gTextProp]);
15237          element.insertBefore(textNode, element.firstChild);
15238        }
15239      }
15240
15241      delete data[gTextProp];
15242    }
15243
15244    for (var k in data) {
15245      element[k] = data[k];
15246    }
15247  }
15248
15249  function getChildElementCount(element) {
15250    if (element.children) {
15251      return element.children.length;
15252    }
15253
15254    if (typeof element.childElementCount !== 'undefined') {
15255      return element.childElementCount;
15256    }
15257
15258    var count = 0;
15259
15260    for (var i = 0; i < element.childNodes.length; i++) {
15261      count += element.nodeType === 1 ? 1 : 0;
15262    }
15263
15264    return count;
15265  }
15266
15267  function translateFragment(element) {
15268    element = element || document.documentElement;
15269    var children = getTranslatableChildren(element);
15270    var elementCount = children.length;
15271
15272    for (var i = 0; i < elementCount; i++) {
15273      translateElement(children[i]);
15274    }
15275
15276    translateElement(element);
15277  }
15278
15279  return {
15280    get: function get(key, args, fallbackString) {
15281      var index = key.lastIndexOf('.');
15282      var prop = gTextProp;
15283
15284      if (index > 0) {
15285        prop = key.substring(index + 1);
15286        key = key.substring(0, index);
15287      }
15288
15289      var fallback;
15290
15291      if (fallbackString) {
15292        fallback = {};
15293        fallback[prop] = fallbackString;
15294      }
15295
15296      var data = getL10nData(key, args, fallback);
15297
15298      if (data && prop in data) {
15299        return data[prop];
15300      }
15301
15302      return '{{' + key + '}}';
15303    },
15304    getData: function getData() {
15305      return gL10nData;
15306    },
15307    getText: function getText() {
15308      return gTextData;
15309    },
15310    getLanguage: function getLanguage() {
15311      return gLanguage;
15312    },
15313    setLanguage: function setLanguage(lang, callback) {
15314      loadLocale(lang, function () {
15315        if (callback) callback();
15316      });
15317    },
15318    getDirection: function getDirection() {
15319      var rtlList = ['ar', 'he', 'fa', 'ps', 'ur'];
15320      var shortCode = gLanguage.split('-', 1)[0];
15321      return rtlList.indexOf(shortCode) >= 0 ? 'rtl' : 'ltr';
15322    },
15323    translate: translateFragment,
15324    getReadyState: function getReadyState() {
15325      return gReadyState;
15326    },
15327    ready: function ready(callback) {
15328      if (!callback) {
15329        return;
15330      } else if (gReadyState == 'complete' || gReadyState == 'interactive') {
15331        window.setTimeout(function () {
15332          callback();
15333        });
15334      } else if (document.addEventListener) {
15335        document.addEventListener('localized', function once() {
15336          document.removeEventListener('localized', once);
15337          callback();
15338        });
15339      }
15340    }
15341  };
15342}(window, document);
15343
15344/***/ }),
15345/* 41 */
15346/***/ (function(module, exports, __webpack_require__) {
15347
15348"use strict";
15349
15350
15351Object.defineProperty(exports, "__esModule", {
15352  value: true
15353});
15354exports.PDFPrintService = PDFPrintService;
15355
15356var _ui_utils = __webpack_require__(5);
15357
15358var _app = __webpack_require__(1);
15359
15360var _app_options = __webpack_require__(6);
15361
15362var _pdfjsLib = __webpack_require__(7);
15363
15364var activeService = null;
15365var overlayManager = null;
15366
15367function renderPage(activeServiceOnEntry, pdfDocument, pageNumber, size) {
15368  var scratchCanvas = activeService.scratchCanvas;
15369  var PRINT_RESOLUTION = _app_options.AppOptions.get('printResolution') || 150;
15370  var PRINT_UNITS = PRINT_RESOLUTION / 72.0;
15371  scratchCanvas.width = Math.floor(size.width * PRINT_UNITS);
15372  scratchCanvas.height = Math.floor(size.height * PRINT_UNITS);
15373  var width = Math.floor(size.width * _ui_utils.CSS_UNITS) + 'px';
15374  var height = Math.floor(size.height * _ui_utils.CSS_UNITS) + 'px';
15375  var ctx = scratchCanvas.getContext('2d');
15376  ctx.save();
15377  ctx.fillStyle = 'rgb(255, 255, 255)';
15378  ctx.fillRect(0, 0, scratchCanvas.width, scratchCanvas.height);
15379  ctx.restore();
15380  return pdfDocument.getPage(pageNumber).then(function (pdfPage) {
15381    var renderContext = {
15382      canvasContext: ctx,
15383      transform: [PRINT_UNITS, 0, 0, PRINT_UNITS, 0, 0],
15384      viewport: pdfPage.getViewport({
15385        scale: 1,
15386        rotation: size.rotation
15387      }),
15388      intent: 'print'
15389    };
15390    return pdfPage.render(renderContext).promise;
15391  }).then(function () {
15392    return {
15393      width: width,
15394      height: height
15395    };
15396  });
15397}
15398
15399function PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
15400  this.pdfDocument = pdfDocument;
15401  this.pagesOverview = pagesOverview;
15402  this.printContainer = printContainer;
15403  this.l10n = l10n || _ui_utils.NullL10n;
15404  this.disableCreateObjectURL = pdfDocument.loadingParams['disableCreateObjectURL'];
15405  this.currentPage = -1;
15406  this.scratchCanvas = document.createElement('canvas');
15407}
15408
15409PDFPrintService.prototype = {
15410  layout: function layout() {
15411    this.throwIfInactive();
15412    var body = document.querySelector('body');
15413    body.setAttribute('data-pdfjsprinting', true);
15414    var hasEqualPageSizes = this.pagesOverview.every(function (size) {
15415      return size.width === this.pagesOverview[0].width && size.height === this.pagesOverview[0].height;
15416    }, this);
15417
15418    if (!hasEqualPageSizes) {
15419      console.warn('Not all pages have the same size. The printed ' + 'result may be incorrect!');
15420    }
15421
15422    this.pageStyleSheet = document.createElement('style');
15423    var pageSize = this.pagesOverview[0];
15424    this.pageStyleSheet.textContent = '@supports ((size:A4) and (size:1pt 1pt)) {' + '@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' + '}';
15425    body.appendChild(this.pageStyleSheet);
15426  },
15427  destroy: function destroy() {
15428    if (activeService !== this) {
15429      return;
15430    }
15431
15432    this.printContainer.textContent = '';
15433
15434    if (this.pageStyleSheet) {
15435      this.pageStyleSheet.remove();
15436      this.pageStyleSheet = null;
15437    }
15438
15439    this.scratchCanvas.width = this.scratchCanvas.height = 0;
15440    this.scratchCanvas = null;
15441    activeService = null;
15442    ensureOverlay().then(function () {
15443      if (overlayManager.active !== 'printServiceOverlay') {
15444        return;
15445      }
15446
15447      overlayManager.close('printServiceOverlay');
15448    });
15449  },
15450  renderPages: function renderPages() {
15451    var _this = this;
15452
15453    var pageCount = this.pagesOverview.length;
15454
15455    var renderNextPage = function renderNextPage(resolve, reject) {
15456      _this.throwIfInactive();
15457
15458      if (++_this.currentPage >= pageCount) {
15459        renderProgress(pageCount, pageCount, _this.l10n);
15460        resolve();
15461        return;
15462      }
15463
15464      var index = _this.currentPage;
15465      renderProgress(index, pageCount, _this.l10n);
15466      renderPage(_this, _this.pdfDocument, index + 1, _this.pagesOverview[index]).then(_this.useRenderedPage.bind(_this)).then(function () {
15467        renderNextPage(resolve, reject);
15468      }, reject);
15469    };
15470
15471    return new Promise(renderNextPage);
15472  },
15473  useRenderedPage: function useRenderedPage(printItem) {
15474    this.throwIfInactive();
15475    var img = document.createElement('img');
15476    img.style.width = printItem.width;
15477    img.style.height = printItem.height;
15478    var scratchCanvas = this.scratchCanvas;
15479
15480    if ('toBlob' in scratchCanvas && !this.disableCreateObjectURL) {
15481      scratchCanvas.toBlob(function (blob) {
15482        img.src = _pdfjsLib.URL.createObjectURL(blob);
15483      });
15484    } else {
15485      img.src = scratchCanvas.toDataURL();
15486    }
15487
15488    var wrapper = document.createElement('div');
15489    wrapper.appendChild(img);
15490    this.printContainer.appendChild(wrapper);
15491    return new Promise(function (resolve, reject) {
15492      img.onload = resolve;
15493      img.onerror = reject;
15494    });
15495  },
15496  performPrint: function performPrint() {
15497    var _this2 = this;
15498
15499    this.throwIfInactive();
15500    return new Promise(function (resolve) {
15501      setTimeout(function () {
15502        if (!_this2.active) {
15503          resolve();
15504          return;
15505        }
15506
15507        print.call(window);
15508        setTimeout(resolve, 20);
15509      }, 0);
15510    });
15511  },
15512
15513  get active() {
15514    return this === activeService;
15515  },
15516
15517  throwIfInactive: function throwIfInactive() {
15518    if (!this.active) {
15519      throw new Error('This print request was cancelled or completed.');
15520    }
15521  }
15522};
15523var print = window.print;
15524
15525window.print = function print() {
15526  if (activeService) {
15527    console.warn('Ignored window.print() because of a pending print job.');
15528    return;
15529  }
15530
15531  ensureOverlay().then(function () {
15532    if (activeService) {
15533      overlayManager.open('printServiceOverlay');
15534    }
15535  });
15536
15537  try {
15538    dispatchEvent('beforeprint');
15539  } finally {
15540    if (!activeService) {
15541      console.error('Expected print service to be initialized.');
15542      ensureOverlay().then(function () {
15543        if (overlayManager.active === 'printServiceOverlay') {
15544          overlayManager.close('printServiceOverlay');
15545        }
15546      });
15547      return;
15548    }
15549
15550    var activeServiceOnEntry = activeService;
15551    activeService.renderPages().then(function () {
15552      return activeServiceOnEntry.performPrint();
15553    })["catch"](function () {}).then(function () {
15554      if (activeServiceOnEntry.active) {
15555        abort();
15556      }
15557    });
15558  }
15559};
15560
15561function dispatchEvent(eventType) {
15562  var event = document.createEvent('CustomEvent');
15563  event.initCustomEvent(eventType, false, false, 'custom');
15564  window.dispatchEvent(event);
15565}
15566
15567function abort() {
15568  if (activeService) {
15569    activeService.destroy();
15570    dispatchEvent('afterprint');
15571  }
15572}
15573
15574function renderProgress(index, total, l10n) {
15575  var progressContainer = document.getElementById('printServiceOverlay');
15576  var progress = Math.round(100 * index / total);
15577  var progressBar = progressContainer.querySelector('progress');
15578  var progressPerc = progressContainer.querySelector('.relative-progress');
15579  progressBar.value = progress;
15580  l10n.get('print_progress_percent', {
15581    progress: progress
15582  }, progress + '%').then(function (msg) {
15583    progressPerc.textContent = msg;
15584  });
15585}
15586
15587var hasAttachEvent = !!document.attachEvent;
15588window.addEventListener('keydown', function (event) {
15589  if (event.keyCode === 80 && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
15590    window.print();
15591
15592    if (hasAttachEvent) {
15593      return;
15594    }
15595
15596    event.preventDefault();
15597
15598    if (event.stopImmediatePropagation) {
15599      event.stopImmediatePropagation();
15600    } else {
15601      event.stopPropagation();
15602    }
15603
15604    return;
15605  }
15606}, true);
15607
15608if (hasAttachEvent) {
15609  document.attachEvent('onkeydown', function (event) {
15610    event = event || window.event;
15611
15612    if (event.keyCode === 80 && event.ctrlKey) {
15613      event.keyCode = 0;
15614      return false;
15615    }
15616  });
15617}
15618
15619if ('onbeforeprint' in window) {
15620  var stopPropagationIfNeeded = function stopPropagationIfNeeded(event) {
15621    if (event.detail !== 'custom' && event.stopImmediatePropagation) {
15622      event.stopImmediatePropagation();
15623    }
15624  };
15625
15626  window.addEventListener('beforeprint', stopPropagationIfNeeded);
15627  window.addEventListener('afterprint', stopPropagationIfNeeded);
15628}
15629
15630var overlayPromise;
15631
15632function ensureOverlay() {
15633  if (!overlayPromise) {
15634    overlayManager = _app.PDFViewerApplication.overlayManager;
15635
15636    if (!overlayManager) {
15637      throw new Error('The overlay manager has not yet been initialized.');
15638    }
15639
15640    overlayPromise = overlayManager.register('printServiceOverlay', document.getElementById('printServiceOverlay'), abort, true);
15641    document.getElementById('printCancel').onclick = abort;
15642  }
15643
15644  return overlayPromise;
15645}
15646
15647_app.PDFPrintServiceFactory.instance = {
15648  supportsPrinting: true,
15649  createPrintService: function createPrintService(pdfDocument, pagesOverview, printContainer, l10n) {
15650    if (activeService) {
15651      throw new Error('The print service is created and active.');
15652    }
15653
15654    activeService = new PDFPrintService(pdfDocument, pagesOverview, printContainer, l10n);
15655    return activeService;
15656  }
15657};
15658
15659/***/ })
15660/******/ ]);
15661//# sourceMappingURL=viewer.js.map