UNPKG

ngx-extended-pdf-viewer

Version:

Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.

1,387 lines (1,186 loc) 947 kB
/** * @licstart The following is the entire license notice for the * Javascript code in this page * * Copyright 2020 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * Javascript code in this page */ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ([ /* 0 */ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "PDFViewerApplicationOptions", ({ enumerable: true, get: function get() { return _app_options.AppOptions; } })); Object.defineProperty(exports, "PDFViewerApplication", ({ enumerable: true, get: function get() { return _app.PDFViewerApplication; } })); var _app_options = __webpack_require__(1); var _app = __webpack_require__(3); var pdfjsVersion = '2.7.673'; var pdfjsBuild = 'e50f03ecd'; window.PDFViewerApplication = _app.PDFViewerApplication; window.PDFViewerApplicationOptions = _app_options.AppOptions; if (!HTMLCollection.prototype[Symbol.iterator]) { HTMLCollection.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator]; } (function () { if (typeof window.CustomEvent === "function") { return; } function CustomEvent(event, params) { params = params || { bubbles: false, cancelable: false, detail: null }; var evt = document.createEvent("CustomEvent"); evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; } window.CustomEvent = CustomEvent; })(); ; ; { __webpack_require__(170); } ; { __webpack_require__(176); } function getViewerConfiguration() { return { appContainer: document.body, mainContainer: document.getElementById("viewerContainer"), viewerContainer: document.getElementById("viewer"), eventBus: null, toolbar: { container: document.getElementById("toolbarViewer"), numPages: document.getElementById("numPages"), pageNumber: document.getElementById("pageNumber"), scaleSelectContainer: document.getElementById("scaleSelectContainer"), scaleSelect: document.getElementById("scaleSelect"), customScaleOption: document.getElementById("customScaleOption"), previous: document.getElementById("previous"), next: document.getElementById("next"), zoomIn: document.getElementById("zoomIn"), zoomOut: document.getElementById("zoomOut"), viewFind: document.getElementById("viewFind"), openFile: document.getElementById("openFile"), print: document.getElementById("print"), presentationModeButton: document.getElementById("presentationMode"), download: document.getElementById("download"), viewBookmark: document.getElementById("viewBookmark") }, secondaryToolbar: { toolbar: document.getElementById("secondaryToolbar"), toggleButton: document.getElementById("secondaryToolbarToggle"), toolbarButtonContainer: document.getElementById("secondaryToolbarButtonContainer"), presentationModeButton: document.getElementById("secondaryPresentationMode"), openFileButton: document.getElementById("secondaryOpenFile"), printButton: document.getElementById("secondaryPrint"), downloadButton: document.getElementById("secondaryDownload"), viewBookmarkButton: document.getElementById("secondaryViewBookmark"), firstPageButton: document.getElementById("firstPage"), lastPageButton: document.getElementById("lastPage"), pageRotateCwButton: document.getElementById("pageRotateCw"), pageRotateCcwButton: document.getElementById("pageRotateCcw"), cursorSelectToolButton: document.getElementById("cursorSelectTool"), cursorHandToolButton: document.getElementById("cursorHandTool"), scrollVerticalButton: document.getElementById("scrollVertical"), scrollHorizontalButton: document.getElementById("scrollHorizontal"), scrollWrappedButton: document.getElementById("scrollWrapped"), spreadNoneButton: document.getElementById("spreadNone"), spreadOddButton: document.getElementById("spreadOdd"), spreadEvenButton: document.getElementById("spreadEven"), documentPropertiesButton: document.getElementById("documentProperties") }, fullscreen: { contextFirstPage: document.getElementById("contextFirstPage"), contextLastPage: document.getElementById("contextLastPage"), contextPageRotateCw: document.getElementById("contextPageRotateCw"), contextPageRotateCcw: document.getElementById("contextPageRotateCcw") }, sidebar: { outerContainer: document.getElementById("outerContainer"), viewerContainer: document.getElementById("viewerContainer"), toggleButton: document.getElementById("sidebarToggle"), thumbnailButton: document.getElementById("viewThumbnail"), outlineButton: document.getElementById("viewOutline"), attachmentsButton: document.getElementById("viewAttachments"), layersButton: document.getElementById("viewLayers"), thumbnailView: document.getElementById("thumbnailView"), outlineView: document.getElementById("outlineView"), attachmentsView: document.getElementById("attachmentsView"), layersView: document.getElementById("layersView"), outlineOptionsContainer: document.getElementById("outlineOptionsContainer"), currentOutlineItemButton: document.getElementById("currentOutlineItem") }, sidebarResizer: { outerContainer: document.getElementById("outerContainer"), resizer: document.getElementById("sidebarResizer") }, findBar: { bar: document.getElementById("findbar"), toggleButton: document.getElementById("viewFind"), findField: document.getElementById("findInput"), findFieldMultiline: document.getElementById("findInputMultiline"), highlightAllCheckbox: document.getElementById("findHighlightAll"), caseSensitiveCheckbox: document.getElementById("findMatchCase"), entireWordCheckbox: document.getElementById("findEntireWord"), findMultipleSearchTextsCheckbox: document.getElementById("findMultipleSearchTexts"), ignoreAccentsCheckbox: document.getElementById("findIgnoreAccents"), fuzzyCheckbox: document.getElementById("findFuzzy"), findMsg: document.getElementById("findMsg"), findResultsCount: document.getElementById("findResultsCount"), findPreviousButton: document.getElementById("findPrevious"), findNextButton: document.getElementById("findNext") }, passwordOverlay: { overlayName: "passwordOverlay", container: document.getElementById("passwordOverlay"), label: document.getElementById("passwordText"), input: document.getElementById("password"), submitButton: document.getElementById("passwordSubmit"), cancelButton: document.getElementById("passwordCancel") }, documentProperties: { overlayName: "documentPropertiesOverlay", container: document.getElementById("documentPropertiesOverlay"), closeButton: document.getElementById("documentPropertiesClose"), fields: { fileName: document.getElementById("fileNameField"), fileSize: document.getElementById("fileSizeField"), title: document.getElementById("titleField"), author: document.getElementById("authorField"), subject: document.getElementById("subjectField"), keywords: document.getElementById("keywordsField"), creationDate: document.getElementById("creationDateField"), modificationDate: document.getElementById("modificationDateField"), creator: document.getElementById("creatorField"), producer: document.getElementById("producerField"), version: document.getElementById("versionField"), pageCount: document.getElementById("pageCountField"), pageSize: document.getElementById("pageSizeField"), linearized: document.getElementById("linearizedField") } }, errorWrapper: { container: document.getElementById("errorWrapper"), errorMessage: document.getElementById("errorMessage"), closeButton: document.getElementById("errorClose"), errorMoreInfo: document.getElementById("errorMoreInfo"), moreInfoButton: document.getElementById("errorShowMore"), lessInfoButton: document.getElementById("errorShowLess") }, printContainer: document.getElementById("printContainer"), openFileInputName: "fileInput", debuggerScriptPath: "./debugger.js" }; } function webViewerLoad() { var config = getViewerConfiguration(); var event = document.createEvent("CustomEvent"); event.initCustomEvent("webviewerloaded", true, true, { source: window }); try { parent.document.dispatchEvent(event); } catch (ex) { console.error("webviewerloaded: ".concat(ex)); document.dispatchEvent(event); } _app.PDFViewerApplication.run(config); } { window.webViewerLoad = webViewerLoad; } /***/ }), /* 1 */ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OptionKind = exports.AppOptions = void 0; var _viewer_compatibility = __webpack_require__(2); function _typeof(obj) { "@babel/helpers - typeof"; 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); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var OptionKind = { VIEWER: 0x02, API: 0x04, WORKER: 0x08, PREFERENCE: 0x80 }; exports.OptionKind = OptionKind; var defaultOptions = { cursorToolOnLoad: { value: 0, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, defaultUrl: { value: "", kind: OptionKind.VIEWER }, defaultZoomValue: { value: "", kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, disableHistory: { value: false, kind: OptionKind.VIEWER }, disablePageLabels: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, enablePermissions: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, enablePrintAutoRotate: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, enableScripting: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, enableWebGL: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, externalLinkRel: { value: "noopener noreferrer nofollow", kind: OptionKind.VIEWER }, externalLinkTarget: { value: 0, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, historyUpdateUrl: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, ignoreDestinationZoom: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, imageResourcesPath: { value: "./images/", kind: OptionKind.VIEWER }, maxCanvasPixels: { value: 16777216, compatibility: _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels, kind: OptionKind.VIEWER }, pdfBugEnabled: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, printResolution: { value: 150, kind: OptionKind.VIEWER }, removePageBorders: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, renderer: { value: "canvas", kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, renderInteractiveForms: { value: true, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, sidebarViewOnLoad: { value: -1, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, scrollModeOnLoad: { value: -1, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, spreadModeOnLoad: { value: -1, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, textLayerMode: { value: 1, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, useOnlyCssZoom: { value: false, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, viewerCssTheme: { value: 0, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, viewOnLoad: { value: 0, kind: OptionKind.VIEWER + OptionKind.PREFERENCE }, cMapPacked: { value: true, kind: OptionKind.API }, cMapUrl: { value: "../web/cmaps/", kind: OptionKind.API }, disableAutoFetch: { value: false, kind: OptionKind.API + OptionKind.PREFERENCE }, disableFontFace: { value: false, kind: OptionKind.API + OptionKind.PREFERENCE }, disableRange: { value: false, kind: OptionKind.API + OptionKind.PREFERENCE }, disableStream: { value: false, kind: OptionKind.API + OptionKind.PREFERENCE }, docBaseUrl: { value: "", kind: OptionKind.API }, fontExtraProperties: { value: false, kind: OptionKind.API }, isEvalSupported: { value: true, kind: OptionKind.API }, maxImageSize: { value: -1, kind: OptionKind.API }, pdfBug: { value: false, kind: OptionKind.API }, verbosity: { value: 1, kind: OptionKind.API }, workerPort: { value: null, kind: OptionKind.WORKER }, workerSrc: { value: "./assets/pdf.worker.js", kind: OptionKind.WORKER } }; { defaultOptions.disablePreferences = { value: false, kind: OptionKind.VIEWER }; defaultOptions.locale = { value: typeof navigator !== "undefined" ? navigator.language : "en-US", kind: OptionKind.VIEWER }; defaultOptions.sandboxBundleSrc = { value: "../build/pdf.sandbox.js", kind: OptionKind.VIEWER }; } var userOptions = Object.create(null); var AppOptions = /*#__PURE__*/function () { function AppOptions() { _classCallCheck(this, AppOptions); throw new Error("Cannot initialize AppOptions."); } _createClass(AppOptions, null, [{ key: "get", value: function get(name) { var userOption = userOptions[name]; if (userOption !== undefined) { return userOption; } var defaultOption = defaultOptions[name]; if (defaultOption !== undefined) { return defaultOption.compatibility || defaultOption.value; } return undefined; } }, { key: "getAll", value: function getAll() { var kind = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var options = Object.create(null); for (var name in defaultOptions) { var defaultOption = defaultOptions[name]; if (kind) { if ((kind & defaultOption.kind) === 0) { continue; } if (kind === OptionKind.PREFERENCE) { var value = defaultOption.value, valueType = _typeof(value); if (valueType === "boolean" || valueType === "string" || valueType === "number" && Number.isInteger(value)) { options[name] = value; continue; } throw new Error("Invalid type for preference: ".concat(name)); } } var userOption = userOptions[name]; options[name] = userOption !== undefined ? userOption : defaultOption.compatibility || defaultOption.value; } return options; } }, { key: "set", value: function set(name, value) { userOptions[name] = value; } }, { key: "setAll", value: function setAll(options) { for (var name in options) { userOptions[name] = options[name]; } } }, { key: "remove", value: function remove(name) { delete userOptions[name]; } }]); return AppOptions; }(); exports.AppOptions = AppOptions; /***/ }), /* 2 */ /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.viewerCompatibilityParams = void 0; var compatibilityParams = Object.create(null); { var userAgent = typeof navigator !== "undefined" && navigator.userAgent || ""; var platform = typeof navigator !== "undefined" && navigator.platform || ""; var maxTouchPoints = typeof navigator !== "undefined" && navigator.maxTouchPoints || 1; var isAndroid = /Android/.test(userAgent); var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || platform === "MacIntel" && maxTouchPoints > 1; var isIOSChrome = /CriOS/.test(userAgent); (function checkOnBlobSupport() { if (isIOSChrome) { compatibilityParams.disableCreateObjectURL = true; } })(); (function checkCanvasSizeLimitation() { if (isIOS || isAndroid) { compatibilityParams.maxCanvasPixels = 5242880; } })(); } var viewerCompatibilityParams = Object.freeze(compatibilityParams); exports.viewerCompatibilityParams = viewerCompatibilityParams; /***/ }), /* 3 */ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.PDFViewerApplication = exports.PDFPrintServiceFactory = exports.DefaultExternalServices = void 0; var _regenerator = _interopRequireDefault(__webpack_require__(4)); var _ui_utils = __webpack_require__(6); var _app_options = __webpack_require__(1); var _pdfjsLib = __webpack_require__(7); var _pdf_cursor_tools = __webpack_require__(8); var _pdf_rendering_queue = __webpack_require__(10); var _overlay_manager = __webpack_require__(11); var _password_prompt = __webpack_require__(12); var _pdf_attachment_viewer = __webpack_require__(13); var _pdf_document_properties = __webpack_require__(15); var _pdf_find_bar = __webpack_require__(16); var _pdf_find_controller = __webpack_require__(17); var _pdf_history = __webpack_require__(21); var _pdf_layer_viewer = __webpack_require__(22); var _pdf_link_service = __webpack_require__(23); var _pdf_outline_viewer = __webpack_require__(24); var _pdf_presentation_mode = __webpack_require__(25); var _pdf_sidebar = __webpack_require__(26); var _pdf_sidebar_resizer = __webpack_require__(27); var _pdf_thumbnail_viewer = __webpack_require__(28); var _pdf_viewer = __webpack_require__(30); var _secondary_toolbar = __webpack_require__(166); var _toolbar = __webpack_require__(168); var _viewer_compatibility = __webpack_require__(2); var _view_history = __webpack_require__(169); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; 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; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function 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); } } function _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); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var DEFAULT_SCALE_DELTA = 1.1; var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; var FORCE_PAGES_LOADED_TIMEOUT = 10000; var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000; var ENABLE_PERMISSIONS_CLASS = "enablePermissions"; var ViewOnLoad = { UNKNOWN: -1, PREVIOUS: 0, INITIAL: 1 }; var ViewerCssTheme = { AUTOMATIC: 0, LIGHT: 1, DARK: 2 }; var KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"]; var KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"]; var DefaultExternalServices = /*#__PURE__*/function () { function DefaultExternalServices() { _classCallCheck(this, DefaultExternalServices); throw new Error("Cannot initialize DefaultExternalServices."); } _createClass(DefaultExternalServices, null, [{ key: "updateFindControlState", value: function updateFindControlState(data) {} }, { key: "updateFindMatchesCount", value: function updateFindMatchesCount(data) {} }, { key: "initPassiveLoading", value: function initPassiveLoading(callbacks) {} }, { key: "fallback", value: function () { var _fallback = _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) { return _regenerator["default"].wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: case "end": return _context.stop(); } } }, _callee); })); function fallback(_x) { return _fallback.apply(this, arguments); } return fallback; }() }, { key: "reportTelemetry", value: function reportTelemetry(data) {} }, { key: "createDownloadManager", value: function createDownloadManager(options) { throw new Error("Not implemented: createDownloadManager"); } }, { key: "createPreferences", value: function createPreferences() { throw new Error("Not implemented: createPreferences"); } }, { key: "createL10n", value: function createL10n(options) { throw new Error("Not implemented: createL10n"); } }, { key: "createScripting", value: function createScripting(options) { throw new Error("Not implemented: createScripting"); } }, { key: "supportsIntegratedFind", get: function get() { return (0, _pdfjsLib.shadow)(this, "supportsIntegratedFind", false); } }, { key: "supportsDocumentFonts", get: function get() { return (0, _pdfjsLib.shadow)(this, "supportsDocumentFonts", true); } }, { key: "supportedMouseWheelZoomModifierKeys", get: function get() { return (0, _pdfjsLib.shadow)(this, "supportedMouseWheelZoomModifierKeys", { ctrlKey: true, metaKey: true }); } }, { key: "isInAutomation", get: function get() { return (0, _pdfjsLib.shadow)(this, "isInAutomation", false); } }]); return DefaultExternalServices; }(); exports.DefaultExternalServices = DefaultExternalServices; var PDFViewerApplication = { initialBookmark: document.location.hash.substring(1), _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(), fellback: false, appConfig: null, pdfDocument: null, pdfLoadingTask: null, printService: null, pdfViewer: null, pdfThumbnailViewer: null, pdfRenderingQueue: null, pdfPresentationMode: null, pdfDocumentProperties: null, pdfLinkService: null, pdfHistory: null, pdfSidebar: null, pdfSidebarResizer: null, pdfOutlineViewer: null, pdfAttachmentViewer: null, pdfLayerViewer: null, pdfCursorTools: null, store: null, downloadManager: null, overlayManager: null, preferences: null, toolbar: null, secondaryToolbar: null, eventBus: null, l10n: null, isInitialViewSet: false, downloadComplete: false, isViewerEmbedded: window.parent !== window, url: "", baseUrl: "", externalServices: DefaultExternalServices, _boundEvents: Object.create(null), documentInfo: null, metadata: null, _contentDispositionFilename: null, _contentLength: null, triggerDelayedFallback: null, _saveInProgress: false, _wheelUnusedTicks: 0, _idleCallbacks: new Set(), _scriptingInstance: null, _mouseState: Object.create(null), initialize: function initialize(appConfig) { var _this = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { var appContainer; return _regenerator["default"].wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _this.preferences = _this.externalServices.createPreferences(); _this.appConfig = appConfig; _context2.next = 4; return _this._readPreferences(); case 4: _context2.next = 6; return _this._parseHashParameters(); case 6: _this._forceCssTheme(); _context2.next = 9; return _this._initializeL10n(); case 9: if (_this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdfjsLib.LinkTarget.NONE) { _app_options.AppOptions.set("externalLinkTarget", _pdfjsLib.LinkTarget.TOP); } _context2.next = 12; return _this._initializeViewerComponents(); case 12: _this.bindEvents(); _this.bindWindowEvents(); appContainer = appConfig.appContainer || document.documentElement; _this.l10n.translate(appContainer).then(function () { _this.eventBus.dispatch("localized", { source: _this }); }); _this._initializedCapability.resolve(); _this.initializeLoadingBar(); case 18: case "end": return _context2.stop(); } } }, _callee2); }))(); }, _readPreferences: function _readPreferences() { var _this2 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee3() { return _regenerator["default"].wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: if (!_app_options.AppOptions.get("disablePreferences")) { _context3.next = 2; break; } return _context3.abrupt("return"); case 2: _context3.prev = 2; _context3.t0 = _app_options.AppOptions; _context3.next = 6; return _this2.preferences.getAll(); case 6: _context3.t1 = _context3.sent; _context3.t0.setAll.call(_context3.t0, _context3.t1); _context3.next = 13; break; case 10: _context3.prev = 10; _context3.t2 = _context3["catch"](2); console.error("_readPreferences: \"".concat(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message, "\".")); case 13: case "end": return _context3.stop(); } } }, _callee3, null, [[2, 10]]); }))(); }, _parseHashParameters: function _parseHashParameters() { var _this3 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { var hash, hashParams, waitOn, viewer, enabled; return _regenerator["default"].wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: if (_app_options.AppOptions.get("pdfBugEnabled")) { _context4.next = 2; break; } return _context4.abrupt("return", undefined); case 2: hash = document.location.hash.substring(1); if (hash) { _context4.next = 5; break; } return _context4.abrupt("return", undefined); case 5: hashParams = (0, _ui_utils.parseQueryString)(hash), waitOn = []; if ("disableworker" in hashParams && hashParams.disableworker === "true") { waitOn.push(loadFakeWorker()); } if ("disablerange" in hashParams) { _app_options.AppOptions.set("disableRange", hashParams.disablerange === "true"); } if ("disablestream" in hashParams) { _app_options.AppOptions.set("disableStream", hashParams.disablestream === "true"); } if ("disableautofetch" in hashParams) { _app_options.AppOptions.set("disableAutoFetch", hashParams.disableautofetch === "true"); } if ("disablefontface" in hashParams) { _app_options.AppOptions.set("disableFontFace", hashParams.disablefontface === "true"); } if ("disablehistory" in hashParams) { _app_options.AppOptions.set("disableHistory", hashParams.disablehistory === "true"); } if ("webgl" in hashParams) { _app_options.AppOptions.set("enableWebGL", hashParams.webgl === "true"); } if ("removepageborders" in hashParams) { _app_options.AppOptions.set("removePageBorders", hashParams["removepageborders"] === "true"); } if ("verbosity" in hashParams) { _app_options.AppOptions.set("verbosity", hashParams.verbosity | 0); } if (!("textlayer" in hashParams)) { _context4.next = 24; break; } _context4.t0 = hashParams.textlayer; _context4.next = _context4.t0 === "off" ? 19 : _context4.t0 === "visible" ? 21 : _context4.t0 === "shadow" ? 21 : _context4.t0 === "hover" ? 21 : 24; break; case 19: _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE); return _context4.abrupt("break", 24); case 21: viewer = _this3.appConfig.viewerContainer; viewer.classList.add("textLayer-" + hashParams.textlayer); return _context4.abrupt("break", 24); case 24: if ("pdfbug" in hashParams) { _app_options.AppOptions.set("pdfBug", true); _app_options.AppOptions.set("fontExtraProperties", true); enabled = hashParams.pdfbug.split(","); waitOn.push(loadAndEnablePDFBug(enabled)); } if ("locale" in hashParams) { _app_options.AppOptions.set("locale", hashParams.locale); } if (!(waitOn.length === 0)) { _context4.next = 28; break; } return _context4.abrupt("return", undefined); case 28: return _context4.abrupt("return", Promise.all(waitOn)["catch"](function (reason) { console.error("_parseHashParameters: \"".concat(reason.message, "\".")); })); case 29: case "end": return _context4.stop(); } } }, _callee4); }))(); }, _initializeL10n: function _initializeL10n() { var _this4 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee5() { var dir; return _regenerator["default"].wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _this4.l10n = _this4.externalServices.createL10n({ locale: _app_options.AppOptions.get("locale") }); _context5.next = 3; return _this4.l10n.getDirection(); case 3: dir = _context5.sent; document.getElementsByTagName("html")[0].dir = dir; case 5: case "end": return _context5.stop(); } } }, _callee5); }))(); }, _forceCssTheme: function _forceCssTheme() { var cssTheme = _app_options.AppOptions.get("viewerCssTheme"); if (cssTheme === ViewerCssTheme.AUTOMATIC || !Object.values(ViewerCssTheme).includes(cssTheme)) { return; } try { var styleSheet = document.styleSheets[0]; var cssRules = (styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.cssRules) || []; for (var i = 0, ii = cssRules.length; i < ii; i++) { var _rule$media; var rule = cssRules[i]; if (rule instanceof CSSMediaRule && ((_rule$media = rule.media) === null || _rule$media === void 0 ? void 0 : _rule$media[0]) === "(prefers-color-scheme: dark)") { if (cssTheme === ViewerCssTheme.LIGHT) { styleSheet.deleteRule(i); return; } var darkRules = /^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(rule.cssText); if (darkRules !== null && darkRules !== void 0 && darkRules[1]) { styleSheet.deleteRule(i); styleSheet.insertRule(darkRules[1], i); } return; } } } catch (reason) { console.error("_forceCssTheme: \"".concat(reason === null || reason === void 0 ? void 0 : reason.message, "\".")); } }, _initializeViewerComponents: function _initializeViewerComponents() { var _this5 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee6() { var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer; return _regenerator["default"].wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: appConfig = _this5.appConfig; eventBus = appConfig.eventBus || new _ui_utils.EventBus({ isInAutomation: _this5.externalServices.isInAutomation }); _this5.eventBus = eventBus; _this5.overlayManager = new _overlay_manager.OverlayManager(); pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue(); pdfRenderingQueue.onIdle = _this5.cleanup.bind(_this5); _this5.pdfRenderingQueue = pdfRenderingQueue; pdfLinkService = new _pdf_link_service.PDFLinkService({ eventBus: eventBus, externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"), externalLinkRel: _app_options.AppOptions.get("externalLinkRel"), ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom") }); _this5.pdfLinkService = pdfLinkService; downloadManager = _this5.externalServices.createDownloadManager(); _this5.downloadManager = downloadManager; findController = new _pdf_find_controller.PDFFindController({ linkService: pdfLinkService, eventBus: eventBus, pageViewMode: _app_options.AppOptions.get("pageViewMode") }); _this5.findController = findController; container = appConfig.mainContainer; viewer = appConfig.viewerContainer; _this5.pdfViewer = new _pdf_viewer.PDFViewer({ container: container, viewer: viewer, eventBus: eventBus, renderingQueue: pdfRenderingQueue, linkService: pdfLinkService, downloadManager: downloadManager, findController: findController, renderer: _app_options.AppOptions.get("renderer"), enableWebGL: _app_options.AppOptions.get("enableWebGL"), l10n: _this5.l10n, textLayerMode: _app_options.AppOptions.get("textLayerMode"), imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"), removePageBorders: _app_options.AppOptions.get("removePageBorders"), renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"), enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"), useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"), maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels"), pageViewMode: _app_options.AppOptions.get("pageViewMode"), enableScripting: _app_options.AppOptions.get("enableScripting"), mouseState: _this5._mouseState }); pdfRenderingQueue.setViewer(_this5.pdfViewer); pdfLinkService.setViewer(_this5.pdfViewer); _this5.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({ container: appConfig.sidebar.thumbnailView, eventBus: eventBus, renderingQueue: pdfRenderingQueue, linkService: pdfLinkService, l10n: _this5.l10n }); pdfRenderingQueue.setThumbnailViewer(_this5.pdfThumbnailViewer); _this5.pdfHistory = new _pdf_history.PDFHistory({ linkService: pdfLinkService, eventBus: eventBus }); pdfLinkService.setHistory(_this5.pdfHistory); if (!_this5.supportsIntegratedFind) { _this5.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, _this5.l10n); } _this5.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, _this5.overlayManager, eventBus, _this5.l10n); _this5.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({ container: container, eventBus: eventBus, cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad") }); _this5.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, _this5.l10n); _this5.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus); if (_this5.supportsFullscreen) { _this5.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({ container: container, pdfViewer: _this5.pdfViewer, eventBus: eventBus, contextMenuItems: appConfig.fullscreen }); } _this5.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, _this5.overlayManager, _this5.l10n); _this5.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({ container: appConfig.sidebar.outlineView, eventBus: eventBus, linkService: pdfLinkService }); _this5.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({ container: appConfig.sidebar.attachmentsView, eventBus: eventBus, downloadManager: downloadManager }); _this5.pdfLayerViewer = new _pdf_layer_viewer.PDFLayerViewer({ container: appConfig.sidebar.layersView, eventBus: eventBus, l10n: _this5.l10n }); _this5.pdfSidebar = new _pdf_sidebar.PDFSidebar({ elements: appConfig.sidebar, pdfViewer: _this5.pdfViewer, pdfThumbnailViewer: _this5.pdfThumbnailViewer, eventBus: eventBus, l10n: _this5.l10n }); _this5.pdfSidebar.onToggled = _this5.forceRendering.bind(_this5); _this5.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, _this5.l10n); case 35: case "end": return _context6.stop(); } } }, _callee6); }))(); }, run: function run(config) { this.initialize(config).then(webViewerInitialized); }, get initialized() { return this._initializedCapability.settled; }, get initializedPromise() { return this._initializedCapability.promise; }, zoomIn: function zoomIn(ticks) { if (this.pdfViewer.isInPresentationMode) { return; } var newScale = this.pdfViewer.currentScale; var maxScale = Number(_app_options.AppOptions.get("maxZoom")); if (!maxScale) { maxScale = _ui_utils.MAX_SCALE; } do { newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2); newScale = Math.ceil(newScale * 10) / 10; newScale = Math.min(maxScale, newScale); } while (--ticks > 0 && newScale < maxScale); this.pdfViewer.currentScaleValue = newScale; }, zoomOut: function zoomOut(ticks) { if (this.pdfViewer.isInPresentationMode) { return; } var newScale = this.pdfViewer.currentScale; var minScale = Number(_app_options.AppOptions.get("minZoom")); if (!minScale) { minScale = _ui_utils.MIN_SCALE; } do { newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2); newScale = Math.floor(newScale * 10) / 10; newScale = Math.max(minScale, newScale); } while (--ticks > 0 && newScale > minScale); this.pdfViewer.currentScaleValue = newScale; }, zoomReset: function zoomReset() { if (this.pdfViewer.isInPresentationMode) { return; } this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE; }, get pagesCount() { return this.pdfDocument ? this.pdfDocument.numPages : 0; }, get page() { return this.pdfViewer.currentPageNumber; }, set page(val) { this.pdfViewer.currentPageNumber = val; }, get supportsPrinting() { return PDFPrintServiceFactory.instance.supportsPrinting; }, get supportsFullscreen() { var support; var doc = document.documentElement; support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen); if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false) { support = false; } return (0, _pdfjsLib.shadow)(this, "supportsFullscreen", support); }, get supportsIntegratedFind() { return this.externalServices.supportsIntegratedFind; }, get supportsDocumentFonts() { return this.externalServices.supportsDocumentFonts; }, initializeLoadingBar: function initializeLoadingBar() { var bar = new _ui_utils.ProgressBar("#loadingBar"); bar.hide(); return (0, _pdfjsLib.shadow)(this, "loadingBar", bar); }, get supportedMouseWheelZoomModifierKeys() { return this.externalServices.supportedMouseWheelZoomModifierKeys; }, initPassiveLoading: function initPassiveLoading() { throw new Error("Not implemented: initPassiveLoading"); }, setTitleUsingUrl: function setTitleUsingUrl() { var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; this.url = url; this.baseUrl = url.split("#")[0]; var title = (0, _ui_utils.getPDFFileNameFromURL)(url, ""); if (!title) { try { title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url; } catch (ex) { title = url; } } this.setTitle(title); }, setTitle: function setTitle(title) { if (this.isViewerEmbedded) { return; } document.title = title; }, get _docFilename() { return this._contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url); }, _cancelIdleCallbacks: function _cancelIdleCallbacks() { if (!this._idleCallbacks.size) { return; } var _iterator = _createForOfIteratorHelper(this._idleCallbacks), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var callback = _step.value; window.cancelIdleCallback(callback); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } this._idleCallbacks.clear(); }, _destroyScriptingInstance: function _destroyScriptingInstance() { var _this6 = this; return _asyncToGenerator( /*#__PURE__*/_regenerator["default"].mark(function _callee7() { var _this6$_scriptingInst, scripting, internalEvents, domEvents, _iterator2, _step2, _step2$value, name, listener, _iterator3, _step3, _step3$val