本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23599 lines
681KB

  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2018 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. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf"] = factory();
  29. else
  30. root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. var pdfjsVersion = '2.1.266';
  123. var pdfjsBuild = '81f5835c';
  124. var pdfjsSharedUtil = __w_pdfjs_require__(1);
  125. var pdfjsDisplayAPI = __w_pdfjs_require__(146);
  126. var pdfjsDisplayTextLayer = __w_pdfjs_require__(162);
  127. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(163);
  128. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(151);
  129. var pdfjsDisplaySVG = __w_pdfjs_require__(164);
  130. var pdfjsDisplayWorkerOptions = __w_pdfjs_require__(156);
  131. var pdfjsDisplayAPICompatibility = __w_pdfjs_require__(153);
  132. {
  133. var isNodeJS = __w_pdfjs_require__(4);
  134. if (isNodeJS()) {
  135. var PDFNodeStream = __w_pdfjs_require__(165).PDFNodeStream;
  136. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  137. return new PDFNodeStream(params);
  138. });
  139. } else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
  140. var PDFFetchStream = __w_pdfjs_require__(168).PDFFetchStream;
  141. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  142. return new PDFFetchStream(params);
  143. });
  144. } else {
  145. var PDFNetworkStream = __w_pdfjs_require__(169).PDFNetworkStream;
  146. pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) {
  147. return new PDFNetworkStream(params);
  148. });
  149. }
  150. }
  151. exports.build = pdfjsDisplayAPI.build;
  152. exports.version = pdfjsDisplayAPI.version;
  153. exports.getDocument = pdfjsDisplayAPI.getDocument;
  154. exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort;
  155. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  156. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  157. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  158. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  159. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  160. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  161. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  162. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  163. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  164. exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding;
  165. exports.CMapCompressionType = pdfjsSharedUtil.CMapCompressionType;
  166. exports.PermissionFlag = pdfjsSharedUtil.PermissionFlag;
  167. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  168. exports.OPS = pdfjsSharedUtil.OPS;
  169. exports.VerbosityLevel = pdfjsSharedUtil.VerbosityLevel;
  170. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  171. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  172. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  173. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  174. exports.shadow = pdfjsSharedUtil.shadow;
  175. exports.Util = pdfjsSharedUtil.Util;
  176. exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
  177. exports.URL = pdfjsSharedUtil.URL;
  178. exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException;
  179. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  180. exports.LinkTarget = pdfjsDisplayDOMUtils.LinkTarget;
  181. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  182. exports.loadScript = pdfjsDisplayDOMUtils.loadScript;
  183. exports.GlobalWorkerOptions = pdfjsDisplayWorkerOptions.GlobalWorkerOptions;
  184. exports.apiCompatibilityParams = pdfjsDisplayAPICompatibility.apiCompatibilityParams;
  185. /***/ }),
  186. /* 1 */
  187. /***/ (function(module, exports, __w_pdfjs_require__) {
  188. "use strict";
  189. Object.defineProperty(exports, "__esModule", {
  190. value: true
  191. });
  192. exports.toRomanNumerals = toRomanNumerals;
  193. exports.arrayByteLength = arrayByteLength;
  194. exports.arraysToBytes = arraysToBytes;
  195. exports.assert = assert;
  196. exports.bytesToString = bytesToString;
  197. exports.createPromiseCapability = createPromiseCapability;
  198. exports.deprecated = deprecated;
  199. exports.getInheritableProperty = getInheritableProperty;
  200. exports.getLookupTableFactory = getLookupTableFactory;
  201. exports.getVerbosityLevel = getVerbosityLevel;
  202. exports.info = info;
  203. exports.isArrayBuffer = isArrayBuffer;
  204. exports.isBool = isBool;
  205. exports.isEmptyObj = isEmptyObj;
  206. exports.isNum = isNum;
  207. exports.isString = isString;
  208. exports.isSpace = isSpace;
  209. exports.isSameOrigin = isSameOrigin;
  210. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  211. exports.isLittleEndian = isLittleEndian;
  212. exports.isEvalSupported = isEvalSupported;
  213. exports.log2 = log2;
  214. exports.readInt8 = readInt8;
  215. exports.readUint16 = readUint16;
  216. exports.readUint32 = readUint32;
  217. exports.removeNullCharacters = removeNullCharacters;
  218. exports.setVerbosityLevel = setVerbosityLevel;
  219. exports.shadow = shadow;
  220. exports.string32 = string32;
  221. exports.stringToBytes = stringToBytes;
  222. exports.stringToPDFString = stringToPDFString;
  223. exports.stringToUTF8String = stringToUTF8String;
  224. exports.utf8StringToString = utf8StringToString;
  225. exports.warn = warn;
  226. exports.unreachable = unreachable;
  227. Object.defineProperty(exports, "ReadableStream", {
  228. enumerable: true,
  229. get: function get() {
  230. return _streams_polyfill.ReadableStream;
  231. }
  232. });
  233. Object.defineProperty(exports, "URL", {
  234. enumerable: true,
  235. get: function get() {
  236. return _url_polyfill.URL;
  237. }
  238. });
  239. exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.XRefEntryException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0;
  240. __w_pdfjs_require__(2);
  241. var _streams_polyfill = __w_pdfjs_require__(142);
  242. var _url_polyfill = __w_pdfjs_require__(144);
  243. function _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); }
  244. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  245. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  246. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  247. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  248. var NativeImageDecoding = {
  249. NONE: 'none',
  250. DECODE: 'decode',
  251. DISPLAY: 'display'
  252. };
  253. exports.NativeImageDecoding = NativeImageDecoding;
  254. var PermissionFlag = {
  255. PRINT: 0x04,
  256. MODIFY_CONTENTS: 0x08,
  257. COPY: 0x10,
  258. MODIFY_ANNOTATIONS: 0x20,
  259. FILL_INTERACTIVE_FORMS: 0x100,
  260. COPY_FOR_ACCESSIBILITY: 0x200,
  261. ASSEMBLE: 0x400,
  262. PRINT_HIGH_QUALITY: 0x800
  263. };
  264. exports.PermissionFlag = PermissionFlag;
  265. var TextRenderingMode = {
  266. FILL: 0,
  267. STROKE: 1,
  268. FILL_STROKE: 2,
  269. INVISIBLE: 3,
  270. FILL_ADD_TO_PATH: 4,
  271. STROKE_ADD_TO_PATH: 5,
  272. FILL_STROKE_ADD_TO_PATH: 6,
  273. ADD_TO_PATH: 7,
  274. FILL_STROKE_MASK: 3,
  275. ADD_TO_PATH_FLAG: 4
  276. };
  277. exports.TextRenderingMode = TextRenderingMode;
  278. var ImageKind = {
  279. GRAYSCALE_1BPP: 1,
  280. RGB_24BPP: 2,
  281. RGBA_32BPP: 3
  282. };
  283. exports.ImageKind = ImageKind;
  284. var AnnotationType = {
  285. TEXT: 1,
  286. LINK: 2,
  287. FREETEXT: 3,
  288. LINE: 4,
  289. SQUARE: 5,
  290. CIRCLE: 6,
  291. POLYGON: 7,
  292. POLYLINE: 8,
  293. HIGHLIGHT: 9,
  294. UNDERLINE: 10,
  295. SQUIGGLY: 11,
  296. STRIKEOUT: 12,
  297. STAMP: 13,
  298. CARET: 14,
  299. INK: 15,
  300. POPUP: 16,
  301. FILEATTACHMENT: 17,
  302. SOUND: 18,
  303. MOVIE: 19,
  304. WIDGET: 20,
  305. SCREEN: 21,
  306. PRINTERMARK: 22,
  307. TRAPNET: 23,
  308. WATERMARK: 24,
  309. THREED: 25,
  310. REDACT: 26
  311. };
  312. exports.AnnotationType = AnnotationType;
  313. var AnnotationFlag = {
  314. INVISIBLE: 0x01,
  315. HIDDEN: 0x02,
  316. PRINT: 0x04,
  317. NOZOOM: 0x08,
  318. NOROTATE: 0x10,
  319. NOVIEW: 0x20,
  320. READONLY: 0x40,
  321. LOCKED: 0x80,
  322. TOGGLENOVIEW: 0x100,
  323. LOCKEDCONTENTS: 0x200
  324. };
  325. exports.AnnotationFlag = AnnotationFlag;
  326. var AnnotationFieldFlag = {
  327. READONLY: 0x0000001,
  328. REQUIRED: 0x0000002,
  329. NOEXPORT: 0x0000004,
  330. MULTILINE: 0x0001000,
  331. PASSWORD: 0x0002000,
  332. NOTOGGLETOOFF: 0x0004000,
  333. RADIO: 0x0008000,
  334. PUSHBUTTON: 0x0010000,
  335. COMBO: 0x0020000,
  336. EDIT: 0x0040000,
  337. SORT: 0x0080000,
  338. FILESELECT: 0x0100000,
  339. MULTISELECT: 0x0200000,
  340. DONOTSPELLCHECK: 0x0400000,
  341. DONOTSCROLL: 0x0800000,
  342. COMB: 0x1000000,
  343. RICHTEXT: 0x2000000,
  344. RADIOSINUNISON: 0x2000000,
  345. COMMITONSELCHANGE: 0x4000000
  346. };
  347. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  348. var AnnotationBorderStyleType = {
  349. SOLID: 1,
  350. DASHED: 2,
  351. BEVELED: 3,
  352. INSET: 4,
  353. UNDERLINE: 5
  354. };
  355. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  356. var StreamType = {
  357. UNKNOWN: 0,
  358. FLATE: 1,
  359. LZW: 2,
  360. DCT: 3,
  361. JPX: 4,
  362. JBIG: 5,
  363. A85: 6,
  364. AHX: 7,
  365. CCF: 8,
  366. RL: 9
  367. };
  368. exports.StreamType = StreamType;
  369. var FontType = {
  370. UNKNOWN: 0,
  371. TYPE1: 1,
  372. TYPE1C: 2,
  373. CIDFONTTYPE0: 3,
  374. CIDFONTTYPE0C: 4,
  375. TRUETYPE: 5,
  376. CIDFONTTYPE2: 6,
  377. TYPE3: 7,
  378. OPENTYPE: 8,
  379. TYPE0: 9,
  380. MMTYPE1: 10
  381. };
  382. exports.FontType = FontType;
  383. var VerbosityLevel = {
  384. ERRORS: 0,
  385. WARNINGS: 1,
  386. INFOS: 5
  387. };
  388. exports.VerbosityLevel = VerbosityLevel;
  389. var CMapCompressionType = {
  390. NONE: 0,
  391. BINARY: 1,
  392. STREAM: 2
  393. };
  394. exports.CMapCompressionType = CMapCompressionType;
  395. var OPS = {
  396. dependency: 1,
  397. setLineWidth: 2,
  398. setLineCap: 3,
  399. setLineJoin: 4,
  400. setMiterLimit: 5,
  401. setDash: 6,
  402. setRenderingIntent: 7,
  403. setFlatness: 8,
  404. setGState: 9,
  405. save: 10,
  406. restore: 11,
  407. transform: 12,
  408. moveTo: 13,
  409. lineTo: 14,
  410. curveTo: 15,
  411. curveTo2: 16,
  412. curveTo3: 17,
  413. closePath: 18,
  414. rectangle: 19,
  415. stroke: 20,
  416. closeStroke: 21,
  417. fill: 22,
  418. eoFill: 23,
  419. fillStroke: 24,
  420. eoFillStroke: 25,
  421. closeFillStroke: 26,
  422. closeEOFillStroke: 27,
  423. endPath: 28,
  424. clip: 29,
  425. eoClip: 30,
  426. beginText: 31,
  427. endText: 32,
  428. setCharSpacing: 33,
  429. setWordSpacing: 34,
  430. setHScale: 35,
  431. setLeading: 36,
  432. setFont: 37,
  433. setTextRenderingMode: 38,
  434. setTextRise: 39,
  435. moveText: 40,
  436. setLeadingMoveText: 41,
  437. setTextMatrix: 42,
  438. nextLine: 43,
  439. showText: 44,
  440. showSpacedText: 45,
  441. nextLineShowText: 46,
  442. nextLineSetSpacingShowText: 47,
  443. setCharWidth: 48,
  444. setCharWidthAndBounds: 49,
  445. setStrokeColorSpace: 50,
  446. setFillColorSpace: 51,
  447. setStrokeColor: 52,
  448. setStrokeColorN: 53,
  449. setFillColor: 54,
  450. setFillColorN: 55,
  451. setStrokeGray: 56,
  452. setFillGray: 57,
  453. setStrokeRGBColor: 58,
  454. setFillRGBColor: 59,
  455. setStrokeCMYKColor: 60,
  456. setFillCMYKColor: 61,
  457. shadingFill: 62,
  458. beginInlineImage: 63,
  459. beginImageData: 64,
  460. endInlineImage: 65,
  461. paintXObject: 66,
  462. markPoint: 67,
  463. markPointProps: 68,
  464. beginMarkedContent: 69,
  465. beginMarkedContentProps: 70,
  466. endMarkedContent: 71,
  467. beginCompat: 72,
  468. endCompat: 73,
  469. paintFormXObjectBegin: 74,
  470. paintFormXObjectEnd: 75,
  471. beginGroup: 76,
  472. endGroup: 77,
  473. beginAnnotations: 78,
  474. endAnnotations: 79,
  475. beginAnnotation: 80,
  476. endAnnotation: 81,
  477. paintJpegXObject: 82,
  478. paintImageMaskXObject: 83,
  479. paintImageMaskXObjectGroup: 84,
  480. paintImageXObject: 85,
  481. paintInlineImageXObject: 86,
  482. paintInlineImageXObjectGroup: 87,
  483. paintImageXObjectRepeat: 88,
  484. paintImageMaskXObjectRepeat: 89,
  485. paintSolidColorImageMask: 90,
  486. constructPath: 91
  487. };
  488. exports.OPS = OPS;
  489. var UNSUPPORTED_FEATURES = {
  490. unknown: 'unknown',
  491. forms: 'forms',
  492. javaScript: 'javaScript',
  493. smask: 'smask',
  494. shadingPattern: 'shadingPattern',
  495. font: 'font'
  496. };
  497. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  498. var PasswordResponses = {
  499. NEED_PASSWORD: 1,
  500. INCORRECT_PASSWORD: 2
  501. };
  502. exports.PasswordResponses = PasswordResponses;
  503. var verbosity = VerbosityLevel.WARNINGS;
  504. function setVerbosityLevel(level) {
  505. if (Number.isInteger(level)) {
  506. verbosity = level;
  507. }
  508. }
  509. function getVerbosityLevel() {
  510. return verbosity;
  511. }
  512. function info(msg) {
  513. if (verbosity >= VerbosityLevel.INFOS) {
  514. console.log('Info: ' + msg);
  515. }
  516. }
  517. function warn(msg) {
  518. if (verbosity >= VerbosityLevel.WARNINGS) {
  519. console.log('Warning: ' + msg);
  520. }
  521. }
  522. function deprecated(details) {
  523. console.log('Deprecated API usage: ' + details);
  524. }
  525. function unreachable(msg) {
  526. throw new Error(msg);
  527. }
  528. function assert(cond, msg) {
  529. if (!cond) {
  530. unreachable(msg);
  531. }
  532. }
  533. function isSameOrigin(baseUrl, otherUrl) {
  534. try {
  535. var base = new _url_polyfill.URL(baseUrl);
  536. if (!base.origin || base.origin === 'null') {
  537. return false;
  538. }
  539. } catch (e) {
  540. return false;
  541. }
  542. var other = new _url_polyfill.URL(otherUrl, base);
  543. return base.origin === other.origin;
  544. }
  545. function _isValidProtocol(url) {
  546. if (!url) {
  547. return false;
  548. }
  549. switch (url.protocol) {
  550. case 'http:':
  551. case 'https:':
  552. case 'ftp:':
  553. case 'mailto:':
  554. case 'tel:':
  555. return true;
  556. default:
  557. return false;
  558. }
  559. }
  560. function createValidAbsoluteUrl(url, baseUrl) {
  561. if (!url) {
  562. return null;
  563. }
  564. try {
  565. var absoluteUrl = baseUrl ? new _url_polyfill.URL(url, baseUrl) : new _url_polyfill.URL(url);
  566. if (_isValidProtocol(absoluteUrl)) {
  567. return absoluteUrl;
  568. }
  569. } catch (ex) {}
  570. return null;
  571. }
  572. function shadow(obj, prop, value) {
  573. Object.defineProperty(obj, prop, {
  574. value: value,
  575. enumerable: true,
  576. configurable: true,
  577. writable: false
  578. });
  579. return value;
  580. }
  581. function getLookupTableFactory(initializer) {
  582. var lookup;
  583. return function () {
  584. if (initializer) {
  585. lookup = Object.create(null);
  586. initializer(lookup);
  587. initializer = null;
  588. }
  589. return lookup;
  590. };
  591. }
  592. var PasswordException = function PasswordExceptionClosure() {
  593. function PasswordException(msg, code) {
  594. this.name = 'PasswordException';
  595. this.message = msg;
  596. this.code = code;
  597. }
  598. PasswordException.prototype = new Error();
  599. PasswordException.constructor = PasswordException;
  600. return PasswordException;
  601. }();
  602. exports.PasswordException = PasswordException;
  603. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  604. function UnknownErrorException(msg, details) {
  605. this.name = 'UnknownErrorException';
  606. this.message = msg;
  607. this.details = details;
  608. }
  609. UnknownErrorException.prototype = new Error();
  610. UnknownErrorException.constructor = UnknownErrorException;
  611. return UnknownErrorException;
  612. }();
  613. exports.UnknownErrorException = UnknownErrorException;
  614. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  615. function InvalidPDFException(msg) {
  616. this.name = 'InvalidPDFException';
  617. this.message = msg;
  618. }
  619. InvalidPDFException.prototype = new Error();
  620. InvalidPDFException.constructor = InvalidPDFException;
  621. return InvalidPDFException;
  622. }();
  623. exports.InvalidPDFException = InvalidPDFException;
  624. var MissingPDFException = function MissingPDFExceptionClosure() {
  625. function MissingPDFException(msg) {
  626. this.name = 'MissingPDFException';
  627. this.message = msg;
  628. }
  629. MissingPDFException.prototype = new Error();
  630. MissingPDFException.constructor = MissingPDFException;
  631. return MissingPDFException;
  632. }();
  633. exports.MissingPDFException = MissingPDFException;
  634. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  635. function UnexpectedResponseException(msg, status) {
  636. this.name = 'UnexpectedResponseException';
  637. this.message = msg;
  638. this.status = status;
  639. }
  640. UnexpectedResponseException.prototype = new Error();
  641. UnexpectedResponseException.constructor = UnexpectedResponseException;
  642. return UnexpectedResponseException;
  643. }();
  644. exports.UnexpectedResponseException = UnexpectedResponseException;
  645. var MissingDataException = function MissingDataExceptionClosure() {
  646. function MissingDataException(begin, end) {
  647. this.begin = begin;
  648. this.end = end;
  649. this.message = 'Missing data [' + begin + ', ' + end + ')';
  650. }
  651. MissingDataException.prototype = new Error();
  652. MissingDataException.prototype.name = 'MissingDataException';
  653. MissingDataException.constructor = MissingDataException;
  654. return MissingDataException;
  655. }();
  656. exports.MissingDataException = MissingDataException;
  657. var XRefEntryException = function XRefEntryExceptionClosure() {
  658. function XRefEntryException(msg) {
  659. this.message = msg;
  660. }
  661. XRefEntryException.prototype = new Error();
  662. XRefEntryException.prototype.name = 'XRefEntryException';
  663. XRefEntryException.constructor = XRefEntryException;
  664. return XRefEntryException;
  665. }();
  666. exports.XRefEntryException = XRefEntryException;
  667. var XRefParseException = function XRefParseExceptionClosure() {
  668. function XRefParseException(msg) {
  669. this.message = msg;
  670. }
  671. XRefParseException.prototype = new Error();
  672. XRefParseException.prototype.name = 'XRefParseException';
  673. XRefParseException.constructor = XRefParseException;
  674. return XRefParseException;
  675. }();
  676. exports.XRefParseException = XRefParseException;
  677. var FormatError = function FormatErrorClosure() {
  678. function FormatError(msg) {
  679. this.message = msg;
  680. }
  681. FormatError.prototype = new Error();
  682. FormatError.prototype.name = 'FormatError';
  683. FormatError.constructor = FormatError;
  684. return FormatError;
  685. }();
  686. exports.FormatError = FormatError;
  687. var AbortException = function AbortExceptionClosure() {
  688. function AbortException(msg) {
  689. this.name = 'AbortException';
  690. this.message = msg;
  691. }
  692. AbortException.prototype = new Error();
  693. AbortException.constructor = AbortException;
  694. return AbortException;
  695. }();
  696. exports.AbortException = AbortException;
  697. var NullCharactersRegExp = /\x00/g;
  698. function removeNullCharacters(str) {
  699. if (typeof str !== 'string') {
  700. warn('The argument for removeNullCharacters must be a string.');
  701. return str;
  702. }
  703. return str.replace(NullCharactersRegExp, '');
  704. }
  705. function bytesToString(bytes) {
  706. assert(bytes !== null && _typeof(bytes) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  707. var length = bytes.length;
  708. var MAX_ARGUMENT_COUNT = 8192;
  709. if (length < MAX_ARGUMENT_COUNT) {
  710. return String.fromCharCode.apply(null, bytes);
  711. }
  712. var strBuf = [];
  713. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  714. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  715. var chunk = bytes.subarray(i, chunkEnd);
  716. strBuf.push(String.fromCharCode.apply(null, chunk));
  717. }
  718. return strBuf.join('');
  719. }
  720. function stringToBytes(str) {
  721. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  722. var length = str.length;
  723. var bytes = new Uint8Array(length);
  724. for (var i = 0; i < length; ++i) {
  725. bytes[i] = str.charCodeAt(i) & 0xFF;
  726. }
  727. return bytes;
  728. }
  729. function arrayByteLength(arr) {
  730. if (arr.length !== undefined) {
  731. return arr.length;
  732. }
  733. assert(arr.byteLength !== undefined);
  734. return arr.byteLength;
  735. }
  736. function arraysToBytes(arr) {
  737. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  738. return arr[0];
  739. }
  740. var resultLength = 0;
  741. var i,
  742. ii = arr.length;
  743. var item, itemLength;
  744. for (i = 0; i < ii; i++) {
  745. item = arr[i];
  746. itemLength = arrayByteLength(item);
  747. resultLength += itemLength;
  748. }
  749. var pos = 0;
  750. var data = new Uint8Array(resultLength);
  751. for (i = 0; i < ii; i++) {
  752. item = arr[i];
  753. if (!(item instanceof Uint8Array)) {
  754. if (typeof item === 'string') {
  755. item = stringToBytes(item);
  756. } else {
  757. item = new Uint8Array(item);
  758. }
  759. }
  760. itemLength = item.byteLength;
  761. data.set(item, pos);
  762. pos += itemLength;
  763. }
  764. return data;
  765. }
  766. function string32(value) {
  767. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  768. }
  769. function log2(x) {
  770. if (x <= 0) {
  771. return 0;
  772. }
  773. return Math.ceil(Math.log2(x));
  774. }
  775. function readInt8(data, start) {
  776. return data[start] << 24 >> 24;
  777. }
  778. function readUint16(data, offset) {
  779. return data[offset] << 8 | data[offset + 1];
  780. }
  781. function readUint32(data, offset) {
  782. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  783. }
  784. function isLittleEndian() {
  785. var buffer8 = new Uint8Array(4);
  786. buffer8[0] = 1;
  787. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  788. return view32[0] === 1;
  789. }
  790. function isEvalSupported() {
  791. try {
  792. new Function('');
  793. return true;
  794. } catch (e) {
  795. return false;
  796. }
  797. }
  798. function getInheritableProperty(_ref) {
  799. var dict = _ref.dict,
  800. key = _ref.key,
  801. _ref$getArray = _ref.getArray,
  802. getArray = _ref$getArray === void 0 ? false : _ref$getArray,
  803. _ref$stopWhenFound = _ref.stopWhenFound,
  804. stopWhenFound = _ref$stopWhenFound === void 0 ? true : _ref$stopWhenFound;
  805. var LOOP_LIMIT = 100;
  806. var loopCount = 0;
  807. var values;
  808. while (dict) {
  809. var value = getArray ? dict.getArray(key) : dict.get(key);
  810. if (value !== undefined) {
  811. if (stopWhenFound) {
  812. return value;
  813. }
  814. if (!values) {
  815. values = [];
  816. }
  817. values.push(value);
  818. }
  819. if (++loopCount > LOOP_LIMIT) {
  820. warn("getInheritableProperty: maximum loop count exceeded for \"".concat(key, "\""));
  821. break;
  822. }
  823. dict = dict.get('Parent');
  824. }
  825. return values;
  826. }
  827. var Util = function UtilClosure() {
  828. function Util() {}
  829. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  830. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  831. rgbBuf[1] = r;
  832. rgbBuf[3] = g;
  833. rgbBuf[5] = b;
  834. return rgbBuf.join('');
  835. };
  836. Util.transform = function Util_transform(m1, m2) {
  837. return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
  838. };
  839. Util.applyTransform = function Util_applyTransform(p, m) {
  840. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  841. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  842. return [xt, yt];
  843. };
  844. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  845. var d = m[0] * m[3] - m[1] * m[2];
  846. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  847. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  848. return [xt, yt];
  849. };
  850. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  851. var p1 = Util.applyTransform(r, m);
  852. var p2 = Util.applyTransform(r.slice(2, 4), m);
  853. var p3 = Util.applyTransform([r[0], r[3]], m);
  854. var p4 = Util.applyTransform([r[2], r[1]], m);
  855. return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
  856. };
  857. Util.inverseTransform = function Util_inverseTransform(m) {
  858. var d = m[0] * m[3] - m[1] * m[2];
  859. return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
  860. };
  861. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  862. return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
  863. };
  864. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  865. var transpose = [m[0], m[2], m[1], m[3]];
  866. var a = m[0] * transpose[0] + m[1] * transpose[2];
  867. var b = m[0] * transpose[1] + m[1] * transpose[3];
  868. var c = m[2] * transpose[0] + m[3] * transpose[2];
  869. var d = m[2] * transpose[1] + m[3] * transpose[3];
  870. var first = (a + d) / 2;
  871. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  872. var sx = first + second || 1;
  873. var sy = first - second || 1;
  874. return [Math.sqrt(sx), Math.sqrt(sy)];
  875. };
  876. Util.normalizeRect = function Util_normalizeRect(rect) {
  877. var r = rect.slice(0);
  878. if (rect[0] > rect[2]) {
  879. r[0] = rect[2];
  880. r[2] = rect[0];
  881. }
  882. if (rect[1] > rect[3]) {
  883. r[1] = rect[3];
  884. r[3] = rect[1];
  885. }
  886. return r;
  887. };
  888. Util.intersect = function Util_intersect(rect1, rect2) {
  889. function compare(a, b) {
  890. return a - b;
  891. }
  892. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  893. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  894. result = [];
  895. rect1 = Util.normalizeRect(rect1);
  896. rect2 = Util.normalizeRect(rect2);
  897. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  898. result[0] = orderedX[1];
  899. result[2] = orderedX[2];
  900. } else {
  901. return false;
  902. }
  903. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  904. result[1] = orderedY[1];
  905. result[3] = orderedY[2];
  906. } else {
  907. return false;
  908. }
  909. return result;
  910. };
  911. return Util;
  912. }();
  913. exports.Util = Util;
  914. var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
  915. function toRomanNumerals(number) {
  916. var lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  917. assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
  918. var pos,
  919. romanBuf = [];
  920. while (number >= 1000) {
  921. number -= 1000;
  922. romanBuf.push('M');
  923. }
  924. pos = number / 100 | 0;
  925. number %= 100;
  926. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  927. pos = number / 10 | 0;
  928. number %= 10;
  929. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  930. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  931. var romanStr = romanBuf.join('');
  932. return lowerCase ? romanStr.toLowerCase() : romanStr;
  933. }
  934. var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
  935. function stringToPDFString(str) {
  936. var i,
  937. n = str.length,
  938. strBuf = [];
  939. if (str[0] === '\xFE' && str[1] === '\xFF') {
  940. for (i = 2; i < n; i += 2) {
  941. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  942. }
  943. } else {
  944. for (i = 0; i < n; ++i) {
  945. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  946. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  947. }
  948. }
  949. return strBuf.join('');
  950. }
  951. function stringToUTF8String(str) {
  952. return decodeURIComponent(escape(str));
  953. }
  954. function utf8StringToString(str) {
  955. return unescape(encodeURIComponent(str));
  956. }
  957. function isEmptyObj(obj) {
  958. for (var key in obj) {
  959. return false;
  960. }
  961. return true;
  962. }
  963. function isBool(v) {
  964. return typeof v === 'boolean';
  965. }
  966. function isNum(v) {
  967. return typeof v === 'number';
  968. }
  969. function isString(v) {
  970. return typeof v === 'string';
  971. }
  972. function isArrayBuffer(v) {
  973. return _typeof(v) === 'object' && v !== null && v.byteLength !== undefined;
  974. }
  975. function isSpace(ch) {
  976. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  977. }
  978. function createPromiseCapability() {
  979. var capability = Object.create(null);
  980. var isSettled = false;
  981. Object.defineProperty(capability, 'settled', {
  982. get: function get() {
  983. return isSettled;
  984. }
  985. });
  986. capability.promise = new Promise(function (resolve, reject) {
  987. capability.resolve = function (data) {
  988. isSettled = true;
  989. resolve(data);
  990. };
  991. capability.reject = function (reason) {
  992. isSettled = true;
  993. reject(reason);
  994. };
  995. });
  996. return capability;
  997. }
  998. var createObjectURL = function createObjectURLClosure() {
  999. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1000. return function createObjectURL(data, contentType) {
  1001. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1002. if (!forceDataSchema && _url_polyfill.URL.createObjectURL) {
  1003. var blob = new Blob([data], {
  1004. type: contentType
  1005. });
  1006. return _url_polyfill.URL.createObjectURL(blob);
  1007. }
  1008. var buffer = 'data:' + contentType + ';base64,';
  1009. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1010. var b1 = data[i] & 0xFF;
  1011. var b2 = data[i + 1] & 0xFF;
  1012. var b3 = data[i + 2] & 0xFF;
  1013. var d1 = b1 >> 2,
  1014. d2 = (b1 & 3) << 4 | b2 >> 4;
  1015. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1016. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1017. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1018. }
  1019. return buffer;
  1020. };
  1021. }();
  1022. exports.createObjectURL = createObjectURL;
  1023. /***/ }),
  1024. /* 2 */
  1025. /***/ (function(module, exports, __w_pdfjs_require__) {
  1026. "use strict";
  1027. function _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); }
  1028. var globalScope = __w_pdfjs_require__(3);
  1029. if (!globalScope._pdfjsCompatibilityChecked) {
  1030. globalScope._pdfjsCompatibilityChecked = true;
  1031. var isNodeJS = __w_pdfjs_require__(4);
  1032. var hasDOM = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object';
  1033. (function checkNodeBtoa() {
  1034. if (globalScope.btoa || !isNodeJS()) {
  1035. return;
  1036. }
  1037. globalScope.btoa = function (chars) {
  1038. return Buffer.from(chars, 'binary').toString('base64');
  1039. };
  1040. })();
  1041. (function checkNodeAtob() {
  1042. if (globalScope.atob || !isNodeJS()) {
  1043. return;
  1044. }
  1045. globalScope.atob = function (input) {
  1046. return Buffer.from(input, 'base64').toString('binary');
  1047. };
  1048. })();
  1049. (function checkChildNodeRemove() {
  1050. if (!hasDOM) {
  1051. return;
  1052. }
  1053. if (typeof Element.prototype.remove !== 'undefined') {
  1054. return;
  1055. }
  1056. Element.prototype.remove = function () {
  1057. if (this.parentNode) {
  1058. this.parentNode.removeChild(this);
  1059. }
  1060. };
  1061. })();
  1062. (function checkDOMTokenListAddRemove() {
  1063. if (!hasDOM || isNodeJS()) {
  1064. return;
  1065. }
  1066. var div = document.createElement('div');
  1067. div.classList.add('testOne', 'testTwo');
  1068. if (div.classList.contains('testOne') === true && div.classList.contains('testTwo') === true) {
  1069. return;
  1070. }
  1071. var OriginalDOMTokenListAdd = DOMTokenList.prototype.add;
  1072. var OriginalDOMTokenListRemove = DOMTokenList.prototype.remove;
  1073. DOMTokenList.prototype.add = function () {
  1074. for (var _len = arguments.length, tokens = new Array(_len), _key = 0; _key < _len; _key++) {
  1075. tokens[_key] = arguments[_key];
  1076. }
  1077. for (var _i = 0; _i < tokens.length; _i++) {
  1078. var token = tokens[_i];
  1079. OriginalDOMTokenListAdd.call(this, token);
  1080. }
  1081. };
  1082. DOMTokenList.prototype.remove = function () {
  1083. for (var _len2 = arguments.length, tokens = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1084. tokens[_key2] = arguments[_key2];
  1085. }
  1086. for (var _i2 = 0; _i2 < tokens.length; _i2++) {
  1087. var token = tokens[_i2];
  1088. OriginalDOMTokenListRemove.call(this, token);
  1089. }
  1090. };
  1091. })();
  1092. (function checkDOMTokenListToggle() {
  1093. if (!hasDOM || isNodeJS()) {
  1094. return;
  1095. }
  1096. var div = document.createElement('div');
  1097. if (div.classList.toggle('test', 0) === false) {
  1098. return;
  1099. }
  1100. DOMTokenList.prototype.toggle = function (token) {
  1101. var force = arguments.length > 1 ? !!arguments[1] : !this.contains(token);
  1102. return this[force ? 'add' : 'remove'](token), force;
  1103. };
  1104. })();
  1105. (function checkStringStartsWith() {
  1106. if (String.prototype.startsWith) {
  1107. return;
  1108. }
  1109. __w_pdfjs_require__(5);
  1110. })();
  1111. (function checkStringEndsWith() {
  1112. if (String.prototype.endsWith) {
  1113. return;
  1114. }
  1115. __w_pdfjs_require__(35);
  1116. })();
  1117. (function checkStringIncludes() {
  1118. if (String.prototype.includes) {
  1119. return;
  1120. }
  1121. __w_pdfjs_require__(37);
  1122. })();
  1123. (function checkArrayIncludes() {
  1124. if (Array.prototype.includes) {
  1125. return;
  1126. }
  1127. __w_pdfjs_require__(39);
  1128. })();
  1129. (function checkArrayFrom() {
  1130. if (Array.from) {
  1131. return;
  1132. }
  1133. __w_pdfjs_require__(46);
  1134. })();
  1135. (function checkObjectAssign() {
  1136. if (Object.assign) {
  1137. return;
  1138. }
  1139. __w_pdfjs_require__(69);
  1140. })();
  1141. (function checkMathLog2() {
  1142. if (Math.log2) {
  1143. return;
  1144. }
  1145. Math.log2 = __w_pdfjs_require__(74);
  1146. })();
  1147. (function checkNumberIsNaN() {
  1148. if (Number.isNaN) {
  1149. return;
  1150. }
  1151. Number.isNaN = __w_pdfjs_require__(76);
  1152. })();
  1153. (function checkNumberIsInteger() {
  1154. if (Number.isInteger) {
  1155. return;
  1156. }
  1157. Number.isInteger = __w_pdfjs_require__(78);
  1158. })();
  1159. (function checkPromise() {
  1160. if (globalScope.Promise && globalScope.Promise.prototype && globalScope.Promise.prototype.finally) {
  1161. return;
  1162. }
  1163. globalScope.Promise = __w_pdfjs_require__(81);
  1164. })();
  1165. (function checkWeakMap() {
  1166. if (globalScope.WeakMap) {
  1167. return;
  1168. }
  1169. globalScope.WeakMap = __w_pdfjs_require__(101);
  1170. })();
  1171. (function checkWeakSet() {
  1172. if (globalScope.WeakSet) {
  1173. return;
  1174. }
  1175. globalScope.WeakSet = __w_pdfjs_require__(118);
  1176. })();
  1177. (function checkStringCodePointAt() {
  1178. if (String.codePointAt) {
  1179. return;
  1180. }
  1181. String.codePointAt = __w_pdfjs_require__(122);
  1182. })();
  1183. (function checkStringFromCodePoint() {
  1184. if (String.fromCodePoint) {
  1185. return;
  1186. }
  1187. String.fromCodePoint = __w_pdfjs_require__(124);
  1188. })();
  1189. (function checkSymbol() {
  1190. if (globalScope.Symbol) {
  1191. return;
  1192. }
  1193. __w_pdfjs_require__(126);
  1194. })();
  1195. (function checkStringPadStart() {
  1196. if (String.prototype.padStart) {
  1197. return;
  1198. }
  1199. __w_pdfjs_require__(133);
  1200. })();
  1201. (function checkStringPadEnd() {
  1202. if (String.prototype.padEnd) {
  1203. return;
  1204. }
  1205. __w_pdfjs_require__(137);
  1206. })();
  1207. (function checkObjectValues() {
  1208. if (Object.values) {
  1209. return;
  1210. }
  1211. Object.values = __w_pdfjs_require__(139);
  1212. })();
  1213. }
  1214. /***/ }),
  1215. /* 3 */
  1216. /***/ (function(module, exports, __w_pdfjs_require__) {
  1217. "use strict";
  1218. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  1219. /***/ }),
  1220. /* 4 */
  1221. /***/ (function(module, exports, __w_pdfjs_require__) {
  1222. "use strict";
  1223. function _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); }
  1224. module.exports = function isNodeJS() {
  1225. return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && process + '' === '[object process]' && !process.versions['nw'];
  1226. };
  1227. /***/ }),
  1228. /* 5 */
  1229. /***/ (function(module, exports, __w_pdfjs_require__) {
  1230. "use strict";
  1231. __w_pdfjs_require__(6);
  1232. module.exports = __w_pdfjs_require__(9).String.startsWith;
  1233. /***/ }),
  1234. /* 6 */
  1235. /***/ (function(module, exports, __w_pdfjs_require__) {
  1236. "use strict";
  1237. var $export = __w_pdfjs_require__(7);
  1238. var toLength = __w_pdfjs_require__(25);
  1239. var context = __w_pdfjs_require__(27);
  1240. var STARTS_WITH = 'startsWith';
  1241. var $startsWith = ''[STARTS_WITH];
  1242. $export($export.P + $export.F * __w_pdfjs_require__(34)(STARTS_WITH), 'String', {
  1243. startsWith: function startsWith(searchString) {
  1244. var that = context(this, searchString, STARTS_WITH);
  1245. var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
  1246. var search = String(searchString);
  1247. return $startsWith ? $startsWith.call(that, search, index) : that.slice(index, index + search.length) === search;
  1248. }
  1249. });
  1250. /***/ }),
  1251. /* 7 */
  1252. /***/ (function(module, exports, __w_pdfjs_require__) {
  1253. "use strict";
  1254. var global = __w_pdfjs_require__(8);
  1255. var core = __w_pdfjs_require__(9);
  1256. var hide = __w_pdfjs_require__(10);
  1257. var redefine = __w_pdfjs_require__(20);
  1258. var ctx = __w_pdfjs_require__(23);
  1259. var PROTOTYPE = 'prototype';
  1260. var $export = function $export(type, name, source) {
  1261. var IS_FORCED = type & $export.F;
  1262. var IS_GLOBAL = type & $export.G;
  1263. var IS_STATIC = type & $export.S;
  1264. var IS_PROTO = type & $export.P;
  1265. var IS_BIND = type & $export.B;
  1266. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  1267. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  1268. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  1269. var key, own, out, exp;
  1270. if (IS_GLOBAL) source = name;
  1271. for (key in source) {
  1272. own = !IS_FORCED && target && target[key] !== undefined;
  1273. out = (own ? target : source)[key];
  1274. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  1275. if (target) redefine(target, key, out, type & $export.U);
  1276. if (exports[key] != out) hide(exports, key, exp);
  1277. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  1278. }
  1279. };
  1280. global.core = core;
  1281. $export.F = 1;
  1282. $export.G = 2;
  1283. $export.S = 4;
  1284. $export.P = 8;
  1285. $export.B = 16;
  1286. $export.W = 32;
  1287. $export.U = 64;
  1288. $export.R = 128;
  1289. module.exports = $export;
  1290. /***/ }),
  1291. /* 8 */
  1292. /***/ (function(module, exports, __w_pdfjs_require__) {
  1293. "use strict";
  1294. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1295. if (typeof __g == 'number') __g = global;
  1296. /***/ }),
  1297. /* 9 */
  1298. /***/ (function(module, exports, __w_pdfjs_require__) {
  1299. "use strict";
  1300. var core = module.exports = {
  1301. version: '2.6.2'
  1302. };
  1303. if (typeof __e == 'number') __e = core;
  1304. /***/ }),
  1305. /* 10 */
  1306. /***/ (function(module, exports, __w_pdfjs_require__) {
  1307. "use strict";
  1308. var dP = __w_pdfjs_require__(11);
  1309. var createDesc = __w_pdfjs_require__(19);
  1310. module.exports = __w_pdfjs_require__(15) ? function (object, key, value) {
  1311. return dP.f(object, key, createDesc(1, value));
  1312. } : function (object, key, value) {
  1313. object[key] = value;
  1314. return object;
  1315. };
  1316. /***/ }),
  1317. /* 11 */
  1318. /***/ (function(module, exports, __w_pdfjs_require__) {
  1319. "use strict";
  1320. var anObject = __w_pdfjs_require__(12);
  1321. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  1322. var toPrimitive = __w_pdfjs_require__(18);
  1323. var dP = Object.defineProperty;
  1324. exports.f = __w_pdfjs_require__(15) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  1325. anObject(O);
  1326. P = toPrimitive(P, true);
  1327. anObject(Attributes);
  1328. if (IE8_DOM_DEFINE) try {
  1329. return dP(O, P, Attributes);
  1330. } catch (e) {}
  1331. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  1332. if ('value' in Attributes) O[P] = Attributes.value;
  1333. return O;
  1334. };
  1335. /***/ }),
  1336. /* 12 */
  1337. /***/ (function(module, exports, __w_pdfjs_require__) {
  1338. "use strict";
  1339. var isObject = __w_pdfjs_require__(13);
  1340. module.exports = function (it) {
  1341. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  1342. return it;
  1343. };
  1344. /***/ }),
  1345. /* 13 */
  1346. /***/ (function(module, exports, __w_pdfjs_require__) {
  1347. "use strict";
  1348. function _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); }
  1349. module.exports = function (it) {
  1350. return _typeof(it) === 'object' ? it !== null : typeof it === 'function';
  1351. };
  1352. /***/ }),
  1353. /* 14 */
  1354. /***/ (function(module, exports, __w_pdfjs_require__) {
  1355. "use strict";
  1356. module.exports = !__w_pdfjs_require__(15) && !__w_pdfjs_require__(16)(function () {
  1357. return Object.defineProperty(__w_pdfjs_require__(17)('div'), 'a', {
  1358. get: function get() {
  1359. return 7;
  1360. }
  1361. }).a != 7;
  1362. });
  1363. /***/ }),
  1364. /* 15 */
  1365. /***/ (function(module, exports, __w_pdfjs_require__) {
  1366. "use strict";
  1367. module.exports = !__w_pdfjs_require__(16)(function () {
  1368. return Object.defineProperty({}, 'a', {
  1369. get: function get() {
  1370. return 7;
  1371. }
  1372. }).a != 7;
  1373. });
  1374. /***/ }),
  1375. /* 16 */
  1376. /***/ (function(module, exports, __w_pdfjs_require__) {
  1377. "use strict";
  1378. module.exports = function (exec) {
  1379. try {
  1380. return !!exec();
  1381. } catch (e) {
  1382. return true;
  1383. }
  1384. };
  1385. /***/ }),
  1386. /* 17 */
  1387. /***/ (function(module, exports, __w_pdfjs_require__) {
  1388. "use strict";
  1389. var isObject = __w_pdfjs_require__(13);
  1390. var document = __w_pdfjs_require__(8).document;
  1391. var is = isObject(document) && isObject(document.createElement);
  1392. module.exports = function (it) {
  1393. return is ? document.createElement(it) : {};
  1394. };
  1395. /***/ }),
  1396. /* 18 */
  1397. /***/ (function(module, exports, __w_pdfjs_require__) {
  1398. "use strict";
  1399. var isObject = __w_pdfjs_require__(13);
  1400. module.exports = function (it, S) {
  1401. if (!isObject(it)) return it;
  1402. var fn, val;
  1403. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1404. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  1405. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  1406. throw TypeError("Can't convert object to primitive value");
  1407. };
  1408. /***/ }),
  1409. /* 19 */
  1410. /***/ (function(module, exports, __w_pdfjs_require__) {
  1411. "use strict";
  1412. module.exports = function (bitmap, value) {
  1413. return {
  1414. enumerable: !(bitmap & 1),
  1415. configurable: !(bitmap & 2),
  1416. writable: !(bitmap & 4),
  1417. value: value
  1418. };
  1419. };
  1420. /***/ }),
  1421. /* 20 */
  1422. /***/ (function(module, exports, __w_pdfjs_require__) {
  1423. "use strict";
  1424. var global = __w_pdfjs_require__(8);
  1425. var hide = __w_pdfjs_require__(10);
  1426. var has = __w_pdfjs_require__(21);
  1427. var SRC = __w_pdfjs_require__(22)('src');
  1428. var TO_STRING = 'toString';
  1429. var $toString = Function[TO_STRING];
  1430. var TPL = ('' + $toString).split(TO_STRING);
  1431. __w_pdfjs_require__(9).inspectSource = function (it) {
  1432. return $toString.call(it);
  1433. };
  1434. (module.exports = function (O, key, val, safe) {
  1435. var isFunction = typeof val == 'function';
  1436. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  1437. if (O[key] === val) return;
  1438. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  1439. if (O === global) {
  1440. O[key] = val;
  1441. } else if (!safe) {
  1442. delete O[key];
  1443. hide(O, key, val);
  1444. } else if (O[key]) {
  1445. O[key] = val;
  1446. } else {
  1447. hide(O, key, val);
  1448. }
  1449. })(Function.prototype, TO_STRING, function toString() {
  1450. return typeof this == 'function' && this[SRC] || $toString.call(this);
  1451. });
  1452. /***/ }),
  1453. /* 21 */
  1454. /***/ (function(module, exports, __w_pdfjs_require__) {
  1455. "use strict";
  1456. var hasOwnProperty = {}.hasOwnProperty;
  1457. module.exports = function (it, key) {
  1458. return hasOwnProperty.call(it, key);
  1459. };
  1460. /***/ }),
  1461. /* 22 */
  1462. /***/ (function(module, exports, __w_pdfjs_require__) {
  1463. "use strict";
  1464. var id = 0;
  1465. var px = Math.random();
  1466. module.exports = function (key) {
  1467. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  1468. };
  1469. /***/ }),
  1470. /* 23 */
  1471. /***/ (function(module, exports, __w_pdfjs_require__) {
  1472. "use strict";
  1473. var aFunction = __w_pdfjs_require__(24);
  1474. module.exports = function (fn, that, length) {
  1475. aFunction(fn);
  1476. if (that === undefined) return fn;
  1477. switch (length) {
  1478. case 1:
  1479. return function (a) {
  1480. return fn.call(that, a);
  1481. };
  1482. case 2:
  1483. return function (a, b) {
  1484. return fn.call(that, a, b);
  1485. };
  1486. case 3:
  1487. return function (a, b, c) {
  1488. return fn.call(that, a, b, c);
  1489. };
  1490. }
  1491. return function () {
  1492. return fn.apply(that, arguments);
  1493. };
  1494. };
  1495. /***/ }),
  1496. /* 24 */
  1497. /***/ (function(module, exports, __w_pdfjs_require__) {
  1498. "use strict";
  1499. module.exports = function (it) {
  1500. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  1501. return it;
  1502. };
  1503. /***/ }),
  1504. /* 25 */
  1505. /***/ (function(module, exports, __w_pdfjs_require__) {
  1506. "use strict";
  1507. var toInteger = __w_pdfjs_require__(26);
  1508. var min = Math.min;
  1509. module.exports = function (it) {
  1510. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  1511. };
  1512. /***/ }),
  1513. /* 26 */
  1514. /***/ (function(module, exports, __w_pdfjs_require__) {
  1515. "use strict";
  1516. var ceil = Math.ceil;
  1517. var floor = Math.floor;
  1518. module.exports = function (it) {
  1519. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  1520. };
  1521. /***/ }),
  1522. /* 27 */
  1523. /***/ (function(module, exports, __w_pdfjs_require__) {
  1524. "use strict";
  1525. var isRegExp = __w_pdfjs_require__(28);
  1526. var defined = __w_pdfjs_require__(33);
  1527. module.exports = function (that, searchString, NAME) {
  1528. if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
  1529. return String(defined(that));
  1530. };
  1531. /***/ }),
  1532. /* 28 */
  1533. /***/ (function(module, exports, __w_pdfjs_require__) {
  1534. "use strict";
  1535. var isObject = __w_pdfjs_require__(13);
  1536. var cof = __w_pdfjs_require__(29);
  1537. var MATCH = __w_pdfjs_require__(30)('match');
  1538. module.exports = function (it) {
  1539. var isRegExp;
  1540. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  1541. };
  1542. /***/ }),
  1543. /* 29 */
  1544. /***/ (function(module, exports, __w_pdfjs_require__) {
  1545. "use strict";
  1546. var toString = {}.toString;
  1547. module.exports = function (it) {
  1548. return toString.call(it).slice(8, -1);
  1549. };
  1550. /***/ }),
  1551. /* 30 */
  1552. /***/ (function(module, exports, __w_pdfjs_require__) {
  1553. "use strict";
  1554. var store = __w_pdfjs_require__(31)('wks');
  1555. var uid = __w_pdfjs_require__(22);
  1556. var _Symbol = __w_pdfjs_require__(8).Symbol;
  1557. var USE_SYMBOL = typeof _Symbol == 'function';
  1558. var $exports = module.exports = function (name) {
  1559. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1560. };
  1561. $exports.store = store;
  1562. /***/ }),
  1563. /* 31 */
  1564. /***/ (function(module, exports, __w_pdfjs_require__) {
  1565. "use strict";
  1566. var core = __w_pdfjs_require__(9);
  1567. var global = __w_pdfjs_require__(8);
  1568. var SHARED = '__core-js_shared__';
  1569. var store = global[SHARED] || (global[SHARED] = {});
  1570. (module.exports = function (key, value) {
  1571. return store[key] || (store[key] = value !== undefined ? value : {});
  1572. })('versions', []).push({
  1573. version: core.version,
  1574. mode: __w_pdfjs_require__(32) ? 'pure' : 'global',
  1575. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  1576. });
  1577. /***/ }),
  1578. /* 32 */
  1579. /***/ (function(module, exports, __w_pdfjs_require__) {
  1580. "use strict";
  1581. module.exports = false;
  1582. /***/ }),
  1583. /* 33 */
  1584. /***/ (function(module, exports, __w_pdfjs_require__) {
  1585. "use strict";
  1586. module.exports = function (it) {
  1587. if (it == undefined) throw TypeError("Can't call method on " + it);
  1588. return it;
  1589. };
  1590. /***/ }),
  1591. /* 34 */
  1592. /***/ (function(module, exports, __w_pdfjs_require__) {
  1593. "use strict";
  1594. var MATCH = __w_pdfjs_require__(30)('match');
  1595. module.exports = function (KEY) {
  1596. var re = /./;
  1597. try {
  1598. '/./'[KEY](re);
  1599. } catch (e) {
  1600. try {
  1601. re[MATCH] = false;
  1602. return !'/./'[KEY](re);
  1603. } catch (f) {}
  1604. }
  1605. return true;
  1606. };
  1607. /***/ }),
  1608. /* 35 */
  1609. /***/ (function(module, exports, __w_pdfjs_require__) {
  1610. "use strict";
  1611. __w_pdfjs_require__(36);
  1612. module.exports = __w_pdfjs_require__(9).String.endsWith;
  1613. /***/ }),
  1614. /* 36 */
  1615. /***/ (function(module, exports, __w_pdfjs_require__) {
  1616. "use strict";
  1617. var $export = __w_pdfjs_require__(7);
  1618. var toLength = __w_pdfjs_require__(25);
  1619. var context = __w_pdfjs_require__(27);
  1620. var ENDS_WITH = 'endsWith';
  1621. var $endsWith = ''[ENDS_WITH];
  1622. $export($export.P + $export.F * __w_pdfjs_require__(34)(ENDS_WITH), 'String', {
  1623. endsWith: function endsWith(searchString) {
  1624. var that = context(this, searchString, ENDS_WITH);
  1625. var endPosition = arguments.length > 1 ? arguments[1] : undefined;
  1626. var len = toLength(that.length);
  1627. var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
  1628. var search = String(searchString);
  1629. return $endsWith ? $endsWith.call(that, search, end) : that.slice(end - search.length, end) === search;
  1630. }
  1631. });
  1632. /***/ }),
  1633. /* 37 */
  1634. /***/ (function(module, exports, __w_pdfjs_require__) {
  1635. "use strict";
  1636. __w_pdfjs_require__(38);
  1637. module.exports = __w_pdfjs_require__(9).String.includes;
  1638. /***/ }),
  1639. /* 38 */
  1640. /***/ (function(module, exports, __w_pdfjs_require__) {
  1641. "use strict";
  1642. var $export = __w_pdfjs_require__(7);
  1643. var context = __w_pdfjs_require__(27);
  1644. var INCLUDES = 'includes';
  1645. $export($export.P + $export.F * __w_pdfjs_require__(34)(INCLUDES), 'String', {
  1646. includes: function includes(searchString) {
  1647. return !!~context(this, searchString, INCLUDES).indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  1648. }
  1649. });
  1650. /***/ }),
  1651. /* 39 */
  1652. /***/ (function(module, exports, __w_pdfjs_require__) {
  1653. "use strict";
  1654. __w_pdfjs_require__(40);
  1655. module.exports = __w_pdfjs_require__(9).Array.includes;
  1656. /***/ }),
  1657. /* 40 */
  1658. /***/ (function(module, exports, __w_pdfjs_require__) {
  1659. "use strict";
  1660. var $export = __w_pdfjs_require__(7);
  1661. var $includes = __w_pdfjs_require__(41)(true);
  1662. $export($export.P, 'Array', {
  1663. includes: function includes(el) {
  1664. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  1665. }
  1666. });
  1667. __w_pdfjs_require__(45)('includes');
  1668. /***/ }),
  1669. /* 41 */
  1670. /***/ (function(module, exports, __w_pdfjs_require__) {
  1671. "use strict";
  1672. var toIObject = __w_pdfjs_require__(42);
  1673. var toLength = __w_pdfjs_require__(25);
  1674. var toAbsoluteIndex = __w_pdfjs_require__(44);
  1675. module.exports = function (IS_INCLUDES) {
  1676. return function ($this, el, fromIndex) {
  1677. var O = toIObject($this);
  1678. var length = toLength(O.length);
  1679. var index = toAbsoluteIndex(fromIndex, length);
  1680. var value;
  1681. if (IS_INCLUDES && el != el) while (length > index) {
  1682. value = O[index++];
  1683. if (value != value) return true;
  1684. } else for (; length > index; index++) {
  1685. if (IS_INCLUDES || index in O) {
  1686. if (O[index] === el) return IS_INCLUDES || index || 0;
  1687. }
  1688. }
  1689. return !IS_INCLUDES && -1;
  1690. };
  1691. };
  1692. /***/ }),
  1693. /* 42 */
  1694. /***/ (function(module, exports, __w_pdfjs_require__) {
  1695. "use strict";
  1696. var IObject = __w_pdfjs_require__(43);
  1697. var defined = __w_pdfjs_require__(33);
  1698. module.exports = function (it) {
  1699. return IObject(defined(it));
  1700. };
  1701. /***/ }),
  1702. /* 43 */
  1703. /***/ (function(module, exports, __w_pdfjs_require__) {
  1704. "use strict";
  1705. var cof = __w_pdfjs_require__(29);
  1706. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  1707. return cof(it) == 'String' ? it.split('') : Object(it);
  1708. };
  1709. /***/ }),
  1710. /* 44 */
  1711. /***/ (function(module, exports, __w_pdfjs_require__) {
  1712. "use strict";
  1713. var toInteger = __w_pdfjs_require__(26);
  1714. var max = Math.max;
  1715. var min = Math.min;
  1716. module.exports = function (index, length) {
  1717. index = toInteger(index);
  1718. return index < 0 ? max(index + length, 0) : min(index, length);
  1719. };
  1720. /***/ }),
  1721. /* 45 */
  1722. /***/ (function(module, exports, __w_pdfjs_require__) {
  1723. "use strict";
  1724. var UNSCOPABLES = __w_pdfjs_require__(30)('unscopables');
  1725. var ArrayProto = Array.prototype;
  1726. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(10)(ArrayProto, UNSCOPABLES, {});
  1727. module.exports = function (key) {
  1728. ArrayProto[UNSCOPABLES][key] = true;
  1729. };
  1730. /***/ }),
  1731. /* 46 */
  1732. /***/ (function(module, exports, __w_pdfjs_require__) {
  1733. "use strict";
  1734. __w_pdfjs_require__(47);
  1735. __w_pdfjs_require__(62);
  1736. module.exports = __w_pdfjs_require__(9).Array.from;
  1737. /***/ }),
  1738. /* 47 */
  1739. /***/ (function(module, exports, __w_pdfjs_require__) {
  1740. "use strict";
  1741. var $at = __w_pdfjs_require__(48)(true);
  1742. __w_pdfjs_require__(49)(String, 'String', function (iterated) {
  1743. this._t = String(iterated);
  1744. this._i = 0;
  1745. }, function () {
  1746. var O = this._t;
  1747. var index = this._i;
  1748. var point;
  1749. if (index >= O.length) return {
  1750. value: undefined,
  1751. done: true
  1752. };
  1753. point = $at(O, index);
  1754. this._i += point.length;
  1755. return {
  1756. value: point,
  1757. done: false
  1758. };
  1759. });
  1760. /***/ }),
  1761. /* 48 */
  1762. /***/ (function(module, exports, __w_pdfjs_require__) {
  1763. "use strict";
  1764. var toInteger = __w_pdfjs_require__(26);
  1765. var defined = __w_pdfjs_require__(33);
  1766. module.exports = function (TO_STRING) {
  1767. return function (that, pos) {
  1768. var s = String(defined(that));
  1769. var i = toInteger(pos);
  1770. var l = s.length;
  1771. var a, b;
  1772. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  1773. a = s.charCodeAt(i);
  1774. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  1775. };
  1776. };
  1777. /***/ }),
  1778. /* 49 */
  1779. /***/ (function(module, exports, __w_pdfjs_require__) {
  1780. "use strict";
  1781. var LIBRARY = __w_pdfjs_require__(32);
  1782. var $export = __w_pdfjs_require__(7);
  1783. var redefine = __w_pdfjs_require__(20);
  1784. var hide = __w_pdfjs_require__(10);
  1785. var Iterators = __w_pdfjs_require__(50);
  1786. var $iterCreate = __w_pdfjs_require__(51);
  1787. var setToStringTag = __w_pdfjs_require__(59);
  1788. var getPrototypeOf = __w_pdfjs_require__(60);
  1789. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  1790. var BUGGY = !([].keys && 'next' in [].keys());
  1791. var FF_ITERATOR = '@@iterator';
  1792. var KEYS = 'keys';
  1793. var VALUES = 'values';
  1794. var returnThis = function returnThis() {
  1795. return this;
  1796. };
  1797. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  1798. $iterCreate(Constructor, NAME, next);
  1799. var getMethod = function getMethod(kind) {
  1800. if (!BUGGY && kind in proto) return proto[kind];
  1801. switch (kind) {
  1802. case KEYS:
  1803. return function keys() {
  1804. return new Constructor(this, kind);
  1805. };
  1806. case VALUES:
  1807. return function values() {
  1808. return new Constructor(this, kind);
  1809. };
  1810. }
  1811. return function entries() {
  1812. return new Constructor(this, kind);
  1813. };
  1814. };
  1815. var TAG = NAME + ' Iterator';
  1816. var DEF_VALUES = DEFAULT == VALUES;
  1817. var VALUES_BUG = false;
  1818. var proto = Base.prototype;
  1819. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  1820. var $default = $native || getMethod(DEFAULT);
  1821. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  1822. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  1823. var methods, key, IteratorPrototype;
  1824. if ($anyNative) {
  1825. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  1826. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  1827. setToStringTag(IteratorPrototype, TAG, true);
  1828. if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
  1829. }
  1830. }
  1831. if (DEF_VALUES && $native && $native.name !== VALUES) {
  1832. VALUES_BUG = true;
  1833. $default = function values() {
  1834. return $native.call(this);
  1835. };
  1836. }
  1837. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  1838. hide(proto, ITERATOR, $default);
  1839. }
  1840. Iterators[NAME] = $default;
  1841. Iterators[TAG] = returnThis;
  1842. if (DEFAULT) {
  1843. methods = {
  1844. values: DEF_VALUES ? $default : getMethod(VALUES),
  1845. keys: IS_SET ? $default : getMethod(KEYS),
  1846. entries: $entries
  1847. };
  1848. if (FORCED) for (key in methods) {
  1849. if (!(key in proto)) redefine(proto, key, methods[key]);
  1850. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  1851. }
  1852. return methods;
  1853. };
  1854. /***/ }),
  1855. /* 50 */
  1856. /***/ (function(module, exports, __w_pdfjs_require__) {
  1857. "use strict";
  1858. module.exports = {};
  1859. /***/ }),
  1860. /* 51 */
  1861. /***/ (function(module, exports, __w_pdfjs_require__) {
  1862. "use strict";
  1863. var create = __w_pdfjs_require__(52);
  1864. var descriptor = __w_pdfjs_require__(19);
  1865. var setToStringTag = __w_pdfjs_require__(59);
  1866. var IteratorPrototype = {};
  1867. __w_pdfjs_require__(10)(IteratorPrototype, __w_pdfjs_require__(30)('iterator'), function () {
  1868. return this;
  1869. });
  1870. module.exports = function (Constructor, NAME, next) {
  1871. Constructor.prototype = create(IteratorPrototype, {
  1872. next: descriptor(1, next)
  1873. });
  1874. setToStringTag(Constructor, NAME + ' Iterator');
  1875. };
  1876. /***/ }),
  1877. /* 52 */
  1878. /***/ (function(module, exports, __w_pdfjs_require__) {
  1879. "use strict";
  1880. var anObject = __w_pdfjs_require__(12);
  1881. var dPs = __w_pdfjs_require__(53);
  1882. var enumBugKeys = __w_pdfjs_require__(57);
  1883. var IE_PROTO = __w_pdfjs_require__(56)('IE_PROTO');
  1884. var Empty = function Empty() {};
  1885. var PROTOTYPE = 'prototype';
  1886. var _createDict = function createDict() {
  1887. var iframe = __w_pdfjs_require__(17)('iframe');
  1888. var i = enumBugKeys.length;
  1889. var lt = '<';
  1890. var gt = '>';
  1891. var iframeDocument;
  1892. iframe.style.display = 'none';
  1893. __w_pdfjs_require__(58).appendChild(iframe);
  1894. iframe.src = 'javascript:';
  1895. iframeDocument = iframe.contentWindow.document;
  1896. iframeDocument.open();
  1897. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  1898. iframeDocument.close();
  1899. _createDict = iframeDocument.F;
  1900. while (i--) {
  1901. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  1902. }
  1903. return _createDict();
  1904. };
  1905. module.exports = Object.create || function create(O, Properties) {
  1906. var result;
  1907. if (O !== null) {
  1908. Empty[PROTOTYPE] = anObject(O);
  1909. result = new Empty();
  1910. Empty[PROTOTYPE] = null;
  1911. result[IE_PROTO] = O;
  1912. } else result = _createDict();
  1913. return Properties === undefined ? result : dPs(result, Properties);
  1914. };
  1915. /***/ }),
  1916. /* 53 */
  1917. /***/ (function(module, exports, __w_pdfjs_require__) {
  1918. "use strict";
  1919. var dP = __w_pdfjs_require__(11);
  1920. var anObject = __w_pdfjs_require__(12);
  1921. var getKeys = __w_pdfjs_require__(54);
  1922. module.exports = __w_pdfjs_require__(15) ? Object.defineProperties : function defineProperties(O, Properties) {
  1923. anObject(O);
  1924. var keys = getKeys(Properties);
  1925. var length = keys.length;
  1926. var i = 0;
  1927. var P;
  1928. while (length > i) {
  1929. dP.f(O, P = keys[i++], Properties[P]);
  1930. }
  1931. return O;
  1932. };
  1933. /***/ }),
  1934. /* 54 */
  1935. /***/ (function(module, exports, __w_pdfjs_require__) {
  1936. "use strict";
  1937. var $keys = __w_pdfjs_require__(55);
  1938. var enumBugKeys = __w_pdfjs_require__(57);
  1939. module.exports = Object.keys || function keys(O) {
  1940. return $keys(O, enumBugKeys);
  1941. };
  1942. /***/ }),
  1943. /* 55 */
  1944. /***/ (function(module, exports, __w_pdfjs_require__) {
  1945. "use strict";
  1946. var has = __w_pdfjs_require__(21);
  1947. var toIObject = __w_pdfjs_require__(42);
  1948. var arrayIndexOf = __w_pdfjs_require__(41)(false);
  1949. var IE_PROTO = __w_pdfjs_require__(56)('IE_PROTO');
  1950. module.exports = function (object, names) {
  1951. var O = toIObject(object);
  1952. var i = 0;
  1953. var result = [];
  1954. var key;
  1955. for (key in O) {
  1956. if (key != IE_PROTO) has(O, key) && result.push(key);
  1957. }
  1958. while (names.length > i) {
  1959. if (has(O, key = names[i++])) {
  1960. ~arrayIndexOf(result, key) || result.push(key);
  1961. }
  1962. }
  1963. return result;
  1964. };
  1965. /***/ }),
  1966. /* 56 */
  1967. /***/ (function(module, exports, __w_pdfjs_require__) {
  1968. "use strict";
  1969. var shared = __w_pdfjs_require__(31)('keys');
  1970. var uid = __w_pdfjs_require__(22);
  1971. module.exports = function (key) {
  1972. return shared[key] || (shared[key] = uid(key));
  1973. };
  1974. /***/ }),
  1975. /* 57 */
  1976. /***/ (function(module, exports, __w_pdfjs_require__) {
  1977. "use strict";
  1978. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  1979. /***/ }),
  1980. /* 58 */
  1981. /***/ (function(module, exports, __w_pdfjs_require__) {
  1982. "use strict";
  1983. var document = __w_pdfjs_require__(8).document;
  1984. module.exports = document && document.documentElement;
  1985. /***/ }),
  1986. /* 59 */
  1987. /***/ (function(module, exports, __w_pdfjs_require__) {
  1988. "use strict";
  1989. var def = __w_pdfjs_require__(11).f;
  1990. var has = __w_pdfjs_require__(21);
  1991. var TAG = __w_pdfjs_require__(30)('toStringTag');
  1992. module.exports = function (it, tag, stat) {
  1993. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  1994. configurable: true,
  1995. value: tag
  1996. });
  1997. };
  1998. /***/ }),
  1999. /* 60 */
  2000. /***/ (function(module, exports, __w_pdfjs_require__) {
  2001. "use strict";
  2002. var has = __w_pdfjs_require__(21);
  2003. var toObject = __w_pdfjs_require__(61);
  2004. var IE_PROTO = __w_pdfjs_require__(56)('IE_PROTO');
  2005. var ObjectProto = Object.prototype;
  2006. module.exports = Object.getPrototypeOf || function (O) {
  2007. O = toObject(O);
  2008. if (has(O, IE_PROTO)) return O[IE_PROTO];
  2009. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  2010. return O.constructor.prototype;
  2011. }
  2012. return O instanceof Object ? ObjectProto : null;
  2013. };
  2014. /***/ }),
  2015. /* 61 */
  2016. /***/ (function(module, exports, __w_pdfjs_require__) {
  2017. "use strict";
  2018. var defined = __w_pdfjs_require__(33);
  2019. module.exports = function (it) {
  2020. return Object(defined(it));
  2021. };
  2022. /***/ }),
  2023. /* 62 */
  2024. /***/ (function(module, exports, __w_pdfjs_require__) {
  2025. "use strict";
  2026. var ctx = __w_pdfjs_require__(23);
  2027. var $export = __w_pdfjs_require__(7);
  2028. var toObject = __w_pdfjs_require__(61);
  2029. var call = __w_pdfjs_require__(63);
  2030. var isArrayIter = __w_pdfjs_require__(64);
  2031. var toLength = __w_pdfjs_require__(25);
  2032. var createProperty = __w_pdfjs_require__(65);
  2033. var getIterFn = __w_pdfjs_require__(66);
  2034. $export($export.S + $export.F * !__w_pdfjs_require__(68)(function (iter) {
  2035. Array.from(iter);
  2036. }), 'Array', {
  2037. from: function from(arrayLike) {
  2038. var O = toObject(arrayLike);
  2039. var C = typeof this == 'function' ? this : Array;
  2040. var aLen = arguments.length;
  2041. var mapfn = aLen > 1 ? arguments[1] : undefined;
  2042. var mapping = mapfn !== undefined;
  2043. var index = 0;
  2044. var iterFn = getIterFn(O);
  2045. var length, result, step, iterator;
  2046. if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  2047. if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
  2048. for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
  2049. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  2050. }
  2051. } else {
  2052. length = toLength(O.length);
  2053. for (result = new C(length); length > index; index++) {
  2054. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  2055. }
  2056. }
  2057. result.length = index;
  2058. return result;
  2059. }
  2060. });
  2061. /***/ }),
  2062. /* 63 */
  2063. /***/ (function(module, exports, __w_pdfjs_require__) {
  2064. "use strict";
  2065. var anObject = __w_pdfjs_require__(12);
  2066. module.exports = function (iterator, fn, value, entries) {
  2067. try {
  2068. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  2069. } catch (e) {
  2070. var ret = iterator['return'];
  2071. if (ret !== undefined) anObject(ret.call(iterator));
  2072. throw e;
  2073. }
  2074. };
  2075. /***/ }),
  2076. /* 64 */
  2077. /***/ (function(module, exports, __w_pdfjs_require__) {
  2078. "use strict";
  2079. var Iterators = __w_pdfjs_require__(50);
  2080. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  2081. var ArrayProto = Array.prototype;
  2082. module.exports = function (it) {
  2083. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  2084. };
  2085. /***/ }),
  2086. /* 65 */
  2087. /***/ (function(module, exports, __w_pdfjs_require__) {
  2088. "use strict";
  2089. var $defineProperty = __w_pdfjs_require__(11);
  2090. var createDesc = __w_pdfjs_require__(19);
  2091. module.exports = function (object, index, value) {
  2092. if (index in object) $defineProperty.f(object, index, createDesc(0, value));else object[index] = value;
  2093. };
  2094. /***/ }),
  2095. /* 66 */
  2096. /***/ (function(module, exports, __w_pdfjs_require__) {
  2097. "use strict";
  2098. var classof = __w_pdfjs_require__(67);
  2099. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  2100. var Iterators = __w_pdfjs_require__(50);
  2101. module.exports = __w_pdfjs_require__(9).getIteratorMethod = function (it) {
  2102. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  2103. };
  2104. /***/ }),
  2105. /* 67 */
  2106. /***/ (function(module, exports, __w_pdfjs_require__) {
  2107. "use strict";
  2108. var cof = __w_pdfjs_require__(29);
  2109. var TAG = __w_pdfjs_require__(30)('toStringTag');
  2110. var ARG = cof(function () {
  2111. return arguments;
  2112. }()) == 'Arguments';
  2113. var tryGet = function tryGet(it, key) {
  2114. try {
  2115. return it[key];
  2116. } catch (e) {}
  2117. };
  2118. module.exports = function (it) {
  2119. var O, T, B;
  2120. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  2121. };
  2122. /***/ }),
  2123. /* 68 */
  2124. /***/ (function(module, exports, __w_pdfjs_require__) {
  2125. "use strict";
  2126. var ITERATOR = __w_pdfjs_require__(30)('iterator');
  2127. var SAFE_CLOSING = false;
  2128. try {
  2129. var riter = [7][ITERATOR]();
  2130. riter['return'] = function () {
  2131. SAFE_CLOSING = true;
  2132. };
  2133. Array.from(riter, function () {
  2134. throw 2;
  2135. });
  2136. } catch (e) {}
  2137. module.exports = function (exec, skipClosing) {
  2138. if (!skipClosing && !SAFE_CLOSING) return false;
  2139. var safe = false;
  2140. try {
  2141. var arr = [7];
  2142. var iter = arr[ITERATOR]();
  2143. iter.next = function () {
  2144. return {
  2145. done: safe = true
  2146. };
  2147. };
  2148. arr[ITERATOR] = function () {
  2149. return iter;
  2150. };
  2151. exec(arr);
  2152. } catch (e) {}
  2153. return safe;
  2154. };
  2155. /***/ }),
  2156. /* 69 */
  2157. /***/ (function(module, exports, __w_pdfjs_require__) {
  2158. "use strict";
  2159. __w_pdfjs_require__(70);
  2160. module.exports = __w_pdfjs_require__(9).Object.assign;
  2161. /***/ }),
  2162. /* 70 */
  2163. /***/ (function(module, exports, __w_pdfjs_require__) {
  2164. "use strict";
  2165. var $export = __w_pdfjs_require__(7);
  2166. $export($export.S + $export.F, 'Object', {
  2167. assign: __w_pdfjs_require__(71)
  2168. });
  2169. /***/ }),
  2170. /* 71 */
  2171. /***/ (function(module, exports, __w_pdfjs_require__) {
  2172. "use strict";
  2173. var getKeys = __w_pdfjs_require__(54);
  2174. var gOPS = __w_pdfjs_require__(72);
  2175. var pIE = __w_pdfjs_require__(73);
  2176. var toObject = __w_pdfjs_require__(61);
  2177. var IObject = __w_pdfjs_require__(43);
  2178. var $assign = Object.assign;
  2179. module.exports = !$assign || __w_pdfjs_require__(16)(function () {
  2180. var A = {};
  2181. var B = {};
  2182. var S = Symbol();
  2183. var K = 'abcdefghijklmnopqrst';
  2184. A[S] = 7;
  2185. K.split('').forEach(function (k) {
  2186. B[k] = k;
  2187. });
  2188. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  2189. }) ? function assign(target, source) {
  2190. var T = toObject(target);
  2191. var aLen = arguments.length;
  2192. var index = 1;
  2193. var getSymbols = gOPS.f;
  2194. var isEnum = pIE.f;
  2195. while (aLen > index) {
  2196. var S = IObject(arguments[index++]);
  2197. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  2198. var length = keys.length;
  2199. var j = 0;
  2200. var key;
  2201. while (length > j) {
  2202. if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  2203. }
  2204. }
  2205. return T;
  2206. } : $assign;
  2207. /***/ }),
  2208. /* 72 */
  2209. /***/ (function(module, exports, __w_pdfjs_require__) {
  2210. "use strict";
  2211. exports.f = Object.getOwnPropertySymbols;
  2212. /***/ }),
  2213. /* 73 */
  2214. /***/ (function(module, exports, __w_pdfjs_require__) {
  2215. "use strict";
  2216. exports.f = {}.propertyIsEnumerable;
  2217. /***/ }),
  2218. /* 74 */
  2219. /***/ (function(module, exports, __w_pdfjs_require__) {
  2220. "use strict";
  2221. __w_pdfjs_require__(75);
  2222. module.exports = __w_pdfjs_require__(9).Math.log2;
  2223. /***/ }),
  2224. /* 75 */
  2225. /***/ (function(module, exports, __w_pdfjs_require__) {
  2226. "use strict";
  2227. var $export = __w_pdfjs_require__(7);
  2228. $export($export.S, 'Math', {
  2229. log2: function log2(x) {
  2230. return Math.log(x) / Math.LN2;
  2231. }
  2232. });
  2233. /***/ }),
  2234. /* 76 */
  2235. /***/ (function(module, exports, __w_pdfjs_require__) {
  2236. "use strict";
  2237. __w_pdfjs_require__(77);
  2238. module.exports = __w_pdfjs_require__(9).Number.isNaN;
  2239. /***/ }),
  2240. /* 77 */
  2241. /***/ (function(module, exports, __w_pdfjs_require__) {
  2242. "use strict";
  2243. var $export = __w_pdfjs_require__(7);
  2244. $export($export.S, 'Number', {
  2245. isNaN: function isNaN(number) {
  2246. return number != number;
  2247. }
  2248. });
  2249. /***/ }),
  2250. /* 78 */
  2251. /***/ (function(module, exports, __w_pdfjs_require__) {
  2252. "use strict";
  2253. __w_pdfjs_require__(79);
  2254. module.exports = __w_pdfjs_require__(9).Number.isInteger;
  2255. /***/ }),
  2256. /* 79 */
  2257. /***/ (function(module, exports, __w_pdfjs_require__) {
  2258. "use strict";
  2259. var $export = __w_pdfjs_require__(7);
  2260. $export($export.S, 'Number', {
  2261. isInteger: __w_pdfjs_require__(80)
  2262. });
  2263. /***/ }),
  2264. /* 80 */
  2265. /***/ (function(module, exports, __w_pdfjs_require__) {
  2266. "use strict";
  2267. var isObject = __w_pdfjs_require__(13);
  2268. var floor = Math.floor;
  2269. module.exports = function isInteger(it) {
  2270. return !isObject(it) && isFinite(it) && floor(it) === it;
  2271. };
  2272. /***/ }),
  2273. /* 81 */
  2274. /***/ (function(module, exports, __w_pdfjs_require__) {
  2275. "use strict";
  2276. __w_pdfjs_require__(82);
  2277. __w_pdfjs_require__(47);
  2278. __w_pdfjs_require__(83);
  2279. __w_pdfjs_require__(86);
  2280. __w_pdfjs_require__(99);
  2281. __w_pdfjs_require__(100);
  2282. module.exports = __w_pdfjs_require__(9).Promise;
  2283. /***/ }),
  2284. /* 82 */
  2285. /***/ (function(module, exports, __w_pdfjs_require__) {
  2286. "use strict";
  2287. var classof = __w_pdfjs_require__(67);
  2288. var test = {};
  2289. test[__w_pdfjs_require__(30)('toStringTag')] = 'z';
  2290. if (test + '' != '[object z]') {
  2291. __w_pdfjs_require__(20)(Object.prototype, 'toString', function toString() {
  2292. return '[object ' + classof(this) + ']';
  2293. }, true);
  2294. }
  2295. /***/ }),
  2296. /* 83 */
  2297. /***/ (function(module, exports, __w_pdfjs_require__) {
  2298. "use strict";
  2299. var $iterators = __w_pdfjs_require__(84);
  2300. var getKeys = __w_pdfjs_require__(54);
  2301. var redefine = __w_pdfjs_require__(20);
  2302. var global = __w_pdfjs_require__(8);
  2303. var hide = __w_pdfjs_require__(10);
  2304. var Iterators = __w_pdfjs_require__(50);
  2305. var wks = __w_pdfjs_require__(30);
  2306. var ITERATOR = wks('iterator');
  2307. var TO_STRING_TAG = wks('toStringTag');
  2308. var ArrayValues = Iterators.Array;
  2309. var DOMIterables = {
  2310. CSSRuleList: true,
  2311. CSSStyleDeclaration: false,
  2312. CSSValueList: false,
  2313. ClientRectList: false,
  2314. DOMRectList: false,
  2315. DOMStringList: false,
  2316. DOMTokenList: true,
  2317. DataTransferItemList: false,
  2318. FileList: false,
  2319. HTMLAllCollection: false,
  2320. HTMLCollection: false,
  2321. HTMLFormElement: false,
  2322. HTMLSelectElement: false,
  2323. MediaList: true,
  2324. MimeTypeArray: false,
  2325. NamedNodeMap: false,
  2326. NodeList: true,
  2327. PaintRequestList: false,
  2328. Plugin: false,
  2329. PluginArray: false,
  2330. SVGLengthList: false,
  2331. SVGNumberList: false,
  2332. SVGPathSegList: false,
  2333. SVGPointList: false,
  2334. SVGStringList: false,
  2335. SVGTransformList: false,
  2336. SourceBufferList: false,
  2337. StyleSheetList: true,
  2338. TextTrackCueList: false,
  2339. TextTrackList: false,
  2340. TouchList: false
  2341. };
  2342. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  2343. var NAME = collections[i];
  2344. var explicit = DOMIterables[NAME];
  2345. var Collection = global[NAME];
  2346. var proto = Collection && Collection.prototype;
  2347. var key;
  2348. if (proto) {
  2349. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  2350. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  2351. Iterators[NAME] = ArrayValues;
  2352. if (explicit) for (key in $iterators) {
  2353. if (!proto[key]) redefine(proto, key, $iterators[key], true);
  2354. }
  2355. }
  2356. }
  2357. /***/ }),
  2358. /* 84 */
  2359. /***/ (function(module, exports, __w_pdfjs_require__) {
  2360. "use strict";
  2361. var addToUnscopables = __w_pdfjs_require__(45);
  2362. var step = __w_pdfjs_require__(85);
  2363. var Iterators = __w_pdfjs_require__(50);
  2364. var toIObject = __w_pdfjs_require__(42);
  2365. module.exports = __w_pdfjs_require__(49)(Array, 'Array', function (iterated, kind) {
  2366. this._t = toIObject(iterated);
  2367. this._i = 0;
  2368. this._k = kind;
  2369. }, function () {
  2370. var O = this._t;
  2371. var kind = this._k;
  2372. var index = this._i++;
  2373. if (!O || index >= O.length) {
  2374. this._t = undefined;
  2375. return step(1);
  2376. }
  2377. if (kind == 'keys') return step(0, index);
  2378. if (kind == 'values') return step(0, O[index]);
  2379. return step(0, [index, O[index]]);
  2380. }, 'values');
  2381. Iterators.Arguments = Iterators.Array;
  2382. addToUnscopables('keys');
  2383. addToUnscopables('values');
  2384. addToUnscopables('entries');
  2385. /***/ }),
  2386. /* 85 */
  2387. /***/ (function(module, exports, __w_pdfjs_require__) {
  2388. "use strict";
  2389. module.exports = function (done, value) {
  2390. return {
  2391. value: value,
  2392. done: !!done
  2393. };
  2394. };
  2395. /***/ }),
  2396. /* 86 */
  2397. /***/ (function(module, exports, __w_pdfjs_require__) {
  2398. "use strict";
  2399. var LIBRARY = __w_pdfjs_require__(32);
  2400. var global = __w_pdfjs_require__(8);
  2401. var ctx = __w_pdfjs_require__(23);
  2402. var classof = __w_pdfjs_require__(67);
  2403. var $export = __w_pdfjs_require__(7);
  2404. var isObject = __w_pdfjs_require__(13);
  2405. var aFunction = __w_pdfjs_require__(24);
  2406. var anInstance = __w_pdfjs_require__(87);
  2407. var forOf = __w_pdfjs_require__(88);
  2408. var speciesConstructor = __w_pdfjs_require__(89);
  2409. var task = __w_pdfjs_require__(90).set;
  2410. var microtask = __w_pdfjs_require__(92)();
  2411. var newPromiseCapabilityModule = __w_pdfjs_require__(93);
  2412. var perform = __w_pdfjs_require__(94);
  2413. var userAgent = __w_pdfjs_require__(95);
  2414. var promiseResolve = __w_pdfjs_require__(96);
  2415. var PROMISE = 'Promise';
  2416. var TypeError = global.TypeError;
  2417. var process = global.process;
  2418. var versions = process && process.versions;
  2419. var v8 = versions && versions.v8 || '';
  2420. var $Promise = global[PROMISE];
  2421. var isNode = classof(process) == 'process';
  2422. var empty = function empty() {};
  2423. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  2424. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  2425. var USE_NATIVE = !!function () {
  2426. try {
  2427. var promise = $Promise.resolve(1);
  2428. var FakePromise = (promise.constructor = {})[__w_pdfjs_require__(30)('species')] = function (exec) {
  2429. exec(empty, empty);
  2430. };
  2431. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise && v8.indexOf('6.6') !== 0 && userAgent.indexOf('Chrome/66') === -1;
  2432. } catch (e) {}
  2433. }();
  2434. var isThenable = function isThenable(it) {
  2435. var then;
  2436. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  2437. };
  2438. var notify = function notify(promise, isReject) {
  2439. if (promise._n) return;
  2440. promise._n = true;
  2441. var chain = promise._c;
  2442. microtask(function () {
  2443. var value = promise._v;
  2444. var ok = promise._s == 1;
  2445. var i = 0;
  2446. var run = function run(reaction) {
  2447. var handler = ok ? reaction.ok : reaction.fail;
  2448. var resolve = reaction.resolve;
  2449. var reject = reaction.reject;
  2450. var domain = reaction.domain;
  2451. var result, then, exited;
  2452. try {
  2453. if (handler) {
  2454. if (!ok) {
  2455. if (promise._h == 2) onHandleUnhandled(promise);
  2456. promise._h = 1;
  2457. }
  2458. if (handler === true) result = value;else {
  2459. if (domain) domain.enter();
  2460. result = handler(value);
  2461. if (domain) {
  2462. domain.exit();
  2463. exited = true;
  2464. }
  2465. }
  2466. if (result === reaction.promise) {
  2467. reject(TypeError('Promise-chain cycle'));
  2468. } else if (then = isThenable(result)) {
  2469. then.call(result, resolve, reject);
  2470. } else resolve(result);
  2471. } else reject(value);
  2472. } catch (e) {
  2473. if (domain && !exited) domain.exit();
  2474. reject(e);
  2475. }
  2476. };
  2477. while (chain.length > i) {
  2478. run(chain[i++]);
  2479. }
  2480. promise._c = [];
  2481. promise._n = false;
  2482. if (isReject && !promise._h) onUnhandled(promise);
  2483. });
  2484. };
  2485. var onUnhandled = function onUnhandled(promise) {
  2486. task.call(global, function () {
  2487. var value = promise._v;
  2488. var unhandled = isUnhandled(promise);
  2489. var result, handler, console;
  2490. if (unhandled) {
  2491. result = perform(function () {
  2492. if (isNode) {
  2493. process.emit('unhandledRejection', value, promise);
  2494. } else if (handler = global.onunhandledrejection) {
  2495. handler({
  2496. promise: promise,
  2497. reason: value
  2498. });
  2499. } else if ((console = global.console) && console.error) {
  2500. console.error('Unhandled promise rejection', value);
  2501. }
  2502. });
  2503. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  2504. }
  2505. promise._a = undefined;
  2506. if (unhandled && result.e) throw result.v;
  2507. });
  2508. };
  2509. var isUnhandled = function isUnhandled(promise) {
  2510. return promise._h !== 1 && (promise._a || promise._c).length === 0;
  2511. };
  2512. var onHandleUnhandled = function onHandleUnhandled(promise) {
  2513. task.call(global, function () {
  2514. var handler;
  2515. if (isNode) {
  2516. process.emit('rejectionHandled', promise);
  2517. } else if (handler = global.onrejectionhandled) {
  2518. handler({
  2519. promise: promise,
  2520. reason: promise._v
  2521. });
  2522. }
  2523. });
  2524. };
  2525. var $reject = function $reject(value) {
  2526. var promise = this;
  2527. if (promise._d) return;
  2528. promise._d = true;
  2529. promise = promise._w || promise;
  2530. promise._v = value;
  2531. promise._s = 2;
  2532. if (!promise._a) promise._a = promise._c.slice();
  2533. notify(promise, true);
  2534. };
  2535. var $resolve = function $resolve(value) {
  2536. var promise = this;
  2537. var then;
  2538. if (promise._d) return;
  2539. promise._d = true;
  2540. promise = promise._w || promise;
  2541. try {
  2542. if (promise === value) throw TypeError("Promise can't be resolved itself");
  2543. if (then = isThenable(value)) {
  2544. microtask(function () {
  2545. var wrapper = {
  2546. _w: promise,
  2547. _d: false
  2548. };
  2549. try {
  2550. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  2551. } catch (e) {
  2552. $reject.call(wrapper, e);
  2553. }
  2554. });
  2555. } else {
  2556. promise._v = value;
  2557. promise._s = 1;
  2558. notify(promise, false);
  2559. }
  2560. } catch (e) {
  2561. $reject.call({
  2562. _w: promise,
  2563. _d: false
  2564. }, e);
  2565. }
  2566. };
  2567. if (!USE_NATIVE) {
  2568. $Promise = function Promise(executor) {
  2569. anInstance(this, $Promise, PROMISE, '_h');
  2570. aFunction(executor);
  2571. Internal.call(this);
  2572. try {
  2573. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  2574. } catch (err) {
  2575. $reject.call(this, err);
  2576. }
  2577. };
  2578. Internal = function Promise(executor) {
  2579. this._c = [];
  2580. this._a = undefined;
  2581. this._s = 0;
  2582. this._d = false;
  2583. this._v = undefined;
  2584. this._h = 0;
  2585. this._n = false;
  2586. };
  2587. Internal.prototype = __w_pdfjs_require__(97)($Promise.prototype, {
  2588. then: function then(onFulfilled, onRejected) {
  2589. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  2590. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  2591. reaction.fail = typeof onRejected == 'function' && onRejected;
  2592. reaction.domain = isNode ? process.domain : undefined;
  2593. this._c.push(reaction);
  2594. if (this._a) this._a.push(reaction);
  2595. if (this._s) notify(this, false);
  2596. return reaction.promise;
  2597. },
  2598. 'catch': function _catch(onRejected) {
  2599. return this.then(undefined, onRejected);
  2600. }
  2601. });
  2602. OwnPromiseCapability = function OwnPromiseCapability() {
  2603. var promise = new Internal();
  2604. this.promise = promise;
  2605. this.resolve = ctx($resolve, promise, 1);
  2606. this.reject = ctx($reject, promise, 1);
  2607. };
  2608. newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) {
  2609. return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  2610. };
  2611. }
  2612. $export($export.G + $export.W + $export.F * !USE_NATIVE, {
  2613. Promise: $Promise
  2614. });
  2615. __w_pdfjs_require__(59)($Promise, PROMISE);
  2616. __w_pdfjs_require__(98)(PROMISE);
  2617. Wrapper = __w_pdfjs_require__(9)[PROMISE];
  2618. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  2619. reject: function reject(r) {
  2620. var capability = newPromiseCapability(this);
  2621. var $$reject = capability.reject;
  2622. $$reject(r);
  2623. return capability.promise;
  2624. }
  2625. });
  2626. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  2627. resolve: function resolve(x) {
  2628. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  2629. }
  2630. });
  2631. $export($export.S + $export.F * !(USE_NATIVE && __w_pdfjs_require__(68)(function (iter) {
  2632. $Promise.all(iter)['catch'](empty);
  2633. })), PROMISE, {
  2634. all: function all(iterable) {
  2635. var C = this;
  2636. var capability = newPromiseCapability(C);
  2637. var resolve = capability.resolve;
  2638. var reject = capability.reject;
  2639. var result = perform(function () {
  2640. var values = [];
  2641. var index = 0;
  2642. var remaining = 1;
  2643. forOf(iterable, false, function (promise) {
  2644. var $index = index++;
  2645. var alreadyCalled = false;
  2646. values.push(undefined);
  2647. remaining++;
  2648. C.resolve(promise).then(function (value) {
  2649. if (alreadyCalled) return;
  2650. alreadyCalled = true;
  2651. values[$index] = value;
  2652. --remaining || resolve(values);
  2653. }, reject);
  2654. });
  2655. --remaining || resolve(values);
  2656. });
  2657. if (result.e) reject(result.v);
  2658. return capability.promise;
  2659. },
  2660. race: function race(iterable) {
  2661. var C = this;
  2662. var capability = newPromiseCapability(C);
  2663. var reject = capability.reject;
  2664. var result = perform(function () {
  2665. forOf(iterable, false, function (promise) {
  2666. C.resolve(promise).then(capability.resolve, reject);
  2667. });
  2668. });
  2669. if (result.e) reject(result.v);
  2670. return capability.promise;
  2671. }
  2672. });
  2673. /***/ }),
  2674. /* 87 */
  2675. /***/ (function(module, exports, __w_pdfjs_require__) {
  2676. "use strict";
  2677. module.exports = function (it, Constructor, name, forbiddenField) {
  2678. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  2679. throw TypeError(name + ': incorrect invocation!');
  2680. }
  2681. return it;
  2682. };
  2683. /***/ }),
  2684. /* 88 */
  2685. /***/ (function(module, exports, __w_pdfjs_require__) {
  2686. "use strict";
  2687. var ctx = __w_pdfjs_require__(23);
  2688. var call = __w_pdfjs_require__(63);
  2689. var isArrayIter = __w_pdfjs_require__(64);
  2690. var anObject = __w_pdfjs_require__(12);
  2691. var toLength = __w_pdfjs_require__(25);
  2692. var getIterFn = __w_pdfjs_require__(66);
  2693. var BREAK = {};
  2694. var RETURN = {};
  2695. var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  2696. var iterFn = ITERATOR ? function () {
  2697. return iterable;
  2698. } : getIterFn(iterable);
  2699. var f = ctx(fn, that, entries ? 2 : 1);
  2700. var index = 0;
  2701. var length, step, iterator, result;
  2702. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  2703. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  2704. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  2705. if (result === BREAK || result === RETURN) return result;
  2706. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  2707. result = call(iterator, f, step.value, entries);
  2708. if (result === BREAK || result === RETURN) return result;
  2709. }
  2710. };
  2711. _exports.BREAK = BREAK;
  2712. _exports.RETURN = RETURN;
  2713. /***/ }),
  2714. /* 89 */
  2715. /***/ (function(module, exports, __w_pdfjs_require__) {
  2716. "use strict";
  2717. var anObject = __w_pdfjs_require__(12);
  2718. var aFunction = __w_pdfjs_require__(24);
  2719. var SPECIES = __w_pdfjs_require__(30)('species');
  2720. module.exports = function (O, D) {
  2721. var C = anObject(O).constructor;
  2722. var S;
  2723. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  2724. };
  2725. /***/ }),
  2726. /* 90 */
  2727. /***/ (function(module, exports, __w_pdfjs_require__) {
  2728. "use strict";
  2729. var ctx = __w_pdfjs_require__(23);
  2730. var invoke = __w_pdfjs_require__(91);
  2731. var html = __w_pdfjs_require__(58);
  2732. var cel = __w_pdfjs_require__(17);
  2733. var global = __w_pdfjs_require__(8);
  2734. var process = global.process;
  2735. var setTask = global.setImmediate;
  2736. var clearTask = global.clearImmediate;
  2737. var MessageChannel = global.MessageChannel;
  2738. var Dispatch = global.Dispatch;
  2739. var counter = 0;
  2740. var queue = {};
  2741. var ONREADYSTATECHANGE = 'onreadystatechange';
  2742. var defer, channel, port;
  2743. var run = function run() {
  2744. var id = +this;
  2745. if (queue.hasOwnProperty(id)) {
  2746. var fn = queue[id];
  2747. delete queue[id];
  2748. fn();
  2749. }
  2750. };
  2751. var listener = function listener(event) {
  2752. run.call(event.data);
  2753. };
  2754. if (!setTask || !clearTask) {
  2755. setTask = function setImmediate(fn) {
  2756. var args = [];
  2757. var i = 1;
  2758. while (arguments.length > i) {
  2759. args.push(arguments[i++]);
  2760. }
  2761. queue[++counter] = function () {
  2762. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  2763. };
  2764. defer(counter);
  2765. return counter;
  2766. };
  2767. clearTask = function clearImmediate(id) {
  2768. delete queue[id];
  2769. };
  2770. if (__w_pdfjs_require__(29)(process) == 'process') {
  2771. defer = function defer(id) {
  2772. process.nextTick(ctx(run, id, 1));
  2773. };
  2774. } else if (Dispatch && Dispatch.now) {
  2775. defer = function defer(id) {
  2776. Dispatch.now(ctx(run, id, 1));
  2777. };
  2778. } else if (MessageChannel) {
  2779. channel = new MessageChannel();
  2780. port = channel.port2;
  2781. channel.port1.onmessage = listener;
  2782. defer = ctx(port.postMessage, port, 1);
  2783. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  2784. defer = function defer(id) {
  2785. global.postMessage(id + '', '*');
  2786. };
  2787. global.addEventListener('message', listener, false);
  2788. } else if (ONREADYSTATECHANGE in cel('script')) {
  2789. defer = function defer(id) {
  2790. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  2791. html.removeChild(this);
  2792. run.call(id);
  2793. };
  2794. };
  2795. } else {
  2796. defer = function defer(id) {
  2797. setTimeout(ctx(run, id, 1), 0);
  2798. };
  2799. }
  2800. }
  2801. module.exports = {
  2802. set: setTask,
  2803. clear: clearTask
  2804. };
  2805. /***/ }),
  2806. /* 91 */
  2807. /***/ (function(module, exports, __w_pdfjs_require__) {
  2808. "use strict";
  2809. module.exports = function (fn, args, that) {
  2810. var un = that === undefined;
  2811. switch (args.length) {
  2812. case 0:
  2813. return un ? fn() : fn.call(that);
  2814. case 1:
  2815. return un ? fn(args[0]) : fn.call(that, args[0]);
  2816. case 2:
  2817. return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
  2818. case 3:
  2819. return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
  2820. case 4:
  2821. return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
  2822. }
  2823. return fn.apply(that, args);
  2824. };
  2825. /***/ }),
  2826. /* 92 */
  2827. /***/ (function(module, exports, __w_pdfjs_require__) {
  2828. "use strict";
  2829. var global = __w_pdfjs_require__(8);
  2830. var macrotask = __w_pdfjs_require__(90).set;
  2831. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  2832. var process = global.process;
  2833. var Promise = global.Promise;
  2834. var isNode = __w_pdfjs_require__(29)(process) == 'process';
  2835. module.exports = function () {
  2836. var head, last, notify;
  2837. var flush = function flush() {
  2838. var parent, fn;
  2839. if (isNode && (parent = process.domain)) parent.exit();
  2840. while (head) {
  2841. fn = head.fn;
  2842. head = head.next;
  2843. try {
  2844. fn();
  2845. } catch (e) {
  2846. if (head) notify();else last = undefined;
  2847. throw e;
  2848. }
  2849. }
  2850. last = undefined;
  2851. if (parent) parent.enter();
  2852. };
  2853. if (isNode) {
  2854. notify = function notify() {
  2855. process.nextTick(flush);
  2856. };
  2857. } else if (Observer && !(global.navigator && global.navigator.standalone)) {
  2858. var toggle = true;
  2859. var node = document.createTextNode('');
  2860. new Observer(flush).observe(node, {
  2861. characterData: true
  2862. });
  2863. notify = function notify() {
  2864. node.data = toggle = !toggle;
  2865. };
  2866. } else if (Promise && Promise.resolve) {
  2867. var promise = Promise.resolve(undefined);
  2868. notify = function notify() {
  2869. promise.then(flush);
  2870. };
  2871. } else {
  2872. notify = function notify() {
  2873. macrotask.call(global, flush);
  2874. };
  2875. }
  2876. return function (fn) {
  2877. var task = {
  2878. fn: fn,
  2879. next: undefined
  2880. };
  2881. if (last) last.next = task;
  2882. if (!head) {
  2883. head = task;
  2884. notify();
  2885. }
  2886. last = task;
  2887. };
  2888. };
  2889. /***/ }),
  2890. /* 93 */
  2891. /***/ (function(module, exports, __w_pdfjs_require__) {
  2892. "use strict";
  2893. var aFunction = __w_pdfjs_require__(24);
  2894. function PromiseCapability(C) {
  2895. var resolve, reject;
  2896. this.promise = new C(function ($$resolve, $$reject) {
  2897. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  2898. resolve = $$resolve;
  2899. reject = $$reject;
  2900. });
  2901. this.resolve = aFunction(resolve);
  2902. this.reject = aFunction(reject);
  2903. }
  2904. module.exports.f = function (C) {
  2905. return new PromiseCapability(C);
  2906. };
  2907. /***/ }),
  2908. /* 94 */
  2909. /***/ (function(module, exports, __w_pdfjs_require__) {
  2910. "use strict";
  2911. module.exports = function (exec) {
  2912. try {
  2913. return {
  2914. e: false,
  2915. v: exec()
  2916. };
  2917. } catch (e) {
  2918. return {
  2919. e: true,
  2920. v: e
  2921. };
  2922. }
  2923. };
  2924. /***/ }),
  2925. /* 95 */
  2926. /***/ (function(module, exports, __w_pdfjs_require__) {
  2927. "use strict";
  2928. var global = __w_pdfjs_require__(8);
  2929. var navigator = global.navigator;
  2930. module.exports = navigator && navigator.userAgent || '';
  2931. /***/ }),
  2932. /* 96 */
  2933. /***/ (function(module, exports, __w_pdfjs_require__) {
  2934. "use strict";
  2935. var anObject = __w_pdfjs_require__(12);
  2936. var isObject = __w_pdfjs_require__(13);
  2937. var newPromiseCapability = __w_pdfjs_require__(93);
  2938. module.exports = function (C, x) {
  2939. anObject(C);
  2940. if (isObject(x) && x.constructor === C) return x;
  2941. var promiseCapability = newPromiseCapability.f(C);
  2942. var resolve = promiseCapability.resolve;
  2943. resolve(x);
  2944. return promiseCapability.promise;
  2945. };
  2946. /***/ }),
  2947. /* 97 */
  2948. /***/ (function(module, exports, __w_pdfjs_require__) {
  2949. "use strict";
  2950. var redefine = __w_pdfjs_require__(20);
  2951. module.exports = function (target, src, safe) {
  2952. for (var key in src) {
  2953. redefine(target, key, src[key], safe);
  2954. }
  2955. return target;
  2956. };
  2957. /***/ }),
  2958. /* 98 */
  2959. /***/ (function(module, exports, __w_pdfjs_require__) {
  2960. "use strict";
  2961. var global = __w_pdfjs_require__(8);
  2962. var dP = __w_pdfjs_require__(11);
  2963. var DESCRIPTORS = __w_pdfjs_require__(15);
  2964. var SPECIES = __w_pdfjs_require__(30)('species');
  2965. module.exports = function (KEY) {
  2966. var C = global[KEY];
  2967. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  2968. configurable: true,
  2969. get: function get() {
  2970. return this;
  2971. }
  2972. });
  2973. };
  2974. /***/ }),
  2975. /* 99 */
  2976. /***/ (function(module, exports, __w_pdfjs_require__) {
  2977. "use strict";
  2978. var $export = __w_pdfjs_require__(7);
  2979. var core = __w_pdfjs_require__(9);
  2980. var global = __w_pdfjs_require__(8);
  2981. var speciesConstructor = __w_pdfjs_require__(89);
  2982. var promiseResolve = __w_pdfjs_require__(96);
  2983. $export($export.P + $export.R, 'Promise', {
  2984. 'finally': function _finally(onFinally) {
  2985. var C = speciesConstructor(this, core.Promise || global.Promise);
  2986. var isFunction = typeof onFinally == 'function';
  2987. return this.then(isFunction ? function (x) {
  2988. return promiseResolve(C, onFinally()).then(function () {
  2989. return x;
  2990. });
  2991. } : onFinally, isFunction ? function (e) {
  2992. return promiseResolve(C, onFinally()).then(function () {
  2993. throw e;
  2994. });
  2995. } : onFinally);
  2996. }
  2997. });
  2998. /***/ }),
  2999. /* 100 */
  3000. /***/ (function(module, exports, __w_pdfjs_require__) {
  3001. "use strict";
  3002. var $export = __w_pdfjs_require__(7);
  3003. var newPromiseCapability = __w_pdfjs_require__(93);
  3004. var perform = __w_pdfjs_require__(94);
  3005. $export($export.S, 'Promise', {
  3006. 'try': function _try(callbackfn) {
  3007. var promiseCapability = newPromiseCapability.f(this);
  3008. var result = perform(callbackfn);
  3009. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  3010. return promiseCapability.promise;
  3011. }
  3012. });
  3013. /***/ }),
  3014. /* 101 */
  3015. /***/ (function(module, exports, __w_pdfjs_require__) {
  3016. "use strict";
  3017. __w_pdfjs_require__(82);
  3018. __w_pdfjs_require__(83);
  3019. __w_pdfjs_require__(102);
  3020. __w_pdfjs_require__(114);
  3021. __w_pdfjs_require__(116);
  3022. module.exports = __w_pdfjs_require__(9).WeakMap;
  3023. /***/ }),
  3024. /* 102 */
  3025. /***/ (function(module, exports, __w_pdfjs_require__) {
  3026. "use strict";
  3027. var each = __w_pdfjs_require__(103)(0);
  3028. var redefine = __w_pdfjs_require__(20);
  3029. var meta = __w_pdfjs_require__(107);
  3030. var assign = __w_pdfjs_require__(71);
  3031. var weak = __w_pdfjs_require__(108);
  3032. var isObject = __w_pdfjs_require__(13);
  3033. var fails = __w_pdfjs_require__(16);
  3034. var validate = __w_pdfjs_require__(109);
  3035. var WEAK_MAP = 'WeakMap';
  3036. var getWeak = meta.getWeak;
  3037. var isExtensible = Object.isExtensible;
  3038. var uncaughtFrozenStore = weak.ufstore;
  3039. var tmp = {};
  3040. var InternalMap;
  3041. var wrapper = function wrapper(get) {
  3042. return function WeakMap() {
  3043. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  3044. };
  3045. };
  3046. var methods = {
  3047. get: function get(key) {
  3048. if (isObject(key)) {
  3049. var data = getWeak(key);
  3050. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  3051. return data ? data[this._i] : undefined;
  3052. }
  3053. },
  3054. set: function set(key, value) {
  3055. return weak.def(validate(this, WEAK_MAP), key, value);
  3056. }
  3057. };
  3058. var $WeakMap = module.exports = __w_pdfjs_require__(110)(WEAK_MAP, wrapper, methods, weak, true, true);
  3059. if (fails(function () {
  3060. return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7;
  3061. })) {
  3062. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  3063. assign(InternalMap.prototype, methods);
  3064. meta.NEED = true;
  3065. each(['delete', 'has', 'get', 'set'], function (key) {
  3066. var proto = $WeakMap.prototype;
  3067. var method = proto[key];
  3068. redefine(proto, key, function (a, b) {
  3069. if (isObject(a) && !isExtensible(a)) {
  3070. if (!this._f) this._f = new InternalMap();
  3071. var result = this._f[key](a, b);
  3072. return key == 'set' ? this : result;
  3073. }
  3074. return method.call(this, a, b);
  3075. });
  3076. });
  3077. }
  3078. /***/ }),
  3079. /* 103 */
  3080. /***/ (function(module, exports, __w_pdfjs_require__) {
  3081. "use strict";
  3082. var ctx = __w_pdfjs_require__(23);
  3083. var IObject = __w_pdfjs_require__(43);
  3084. var toObject = __w_pdfjs_require__(61);
  3085. var toLength = __w_pdfjs_require__(25);
  3086. var asc = __w_pdfjs_require__(104);
  3087. module.exports = function (TYPE, $create) {
  3088. var IS_MAP = TYPE == 1;
  3089. var IS_FILTER = TYPE == 2;
  3090. var IS_SOME = TYPE == 3;
  3091. var IS_EVERY = TYPE == 4;
  3092. var IS_FIND_INDEX = TYPE == 6;
  3093. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  3094. var create = $create || asc;
  3095. return function ($this, callbackfn, that) {
  3096. var O = toObject($this);
  3097. var self = IObject(O);
  3098. var f = ctx(callbackfn, that, 3);
  3099. var length = toLength(self.length);
  3100. var index = 0;
  3101. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  3102. var val, res;
  3103. for (; length > index; index++) {
  3104. if (NO_HOLES || index in self) {
  3105. val = self[index];
  3106. res = f(val, index, O);
  3107. if (TYPE) {
  3108. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  3109. case 3:
  3110. return true;
  3111. case 5:
  3112. return val;
  3113. case 6:
  3114. return index;
  3115. case 2:
  3116. result.push(val);
  3117. } else if (IS_EVERY) return false;
  3118. }
  3119. }
  3120. }
  3121. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  3122. };
  3123. };
  3124. /***/ }),
  3125. /* 104 */
  3126. /***/ (function(module, exports, __w_pdfjs_require__) {
  3127. "use strict";
  3128. var speciesConstructor = __w_pdfjs_require__(105);
  3129. module.exports = function (original, length) {
  3130. return new (speciesConstructor(original))(length);
  3131. };
  3132. /***/ }),
  3133. /* 105 */
  3134. /***/ (function(module, exports, __w_pdfjs_require__) {
  3135. "use strict";
  3136. var isObject = __w_pdfjs_require__(13);
  3137. var isArray = __w_pdfjs_require__(106);
  3138. var SPECIES = __w_pdfjs_require__(30)('species');
  3139. module.exports = function (original) {
  3140. var C;
  3141. if (isArray(original)) {
  3142. C = original.constructor;
  3143. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  3144. if (isObject(C)) {
  3145. C = C[SPECIES];
  3146. if (C === null) C = undefined;
  3147. }
  3148. }
  3149. return C === undefined ? Array : C;
  3150. };
  3151. /***/ }),
  3152. /* 106 */
  3153. /***/ (function(module, exports, __w_pdfjs_require__) {
  3154. "use strict";
  3155. var cof = __w_pdfjs_require__(29);
  3156. module.exports = Array.isArray || function isArray(arg) {
  3157. return cof(arg) == 'Array';
  3158. };
  3159. /***/ }),
  3160. /* 107 */
  3161. /***/ (function(module, exports, __w_pdfjs_require__) {
  3162. "use strict";
  3163. function _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); }
  3164. var META = __w_pdfjs_require__(22)('meta');
  3165. var isObject = __w_pdfjs_require__(13);
  3166. var has = __w_pdfjs_require__(21);
  3167. var setDesc = __w_pdfjs_require__(11).f;
  3168. var id = 0;
  3169. var isExtensible = Object.isExtensible || function () {
  3170. return true;
  3171. };
  3172. var FREEZE = !__w_pdfjs_require__(16)(function () {
  3173. return isExtensible(Object.preventExtensions({}));
  3174. });
  3175. var setMeta = function setMeta(it) {
  3176. setDesc(it, META, {
  3177. value: {
  3178. i: 'O' + ++id,
  3179. w: {}
  3180. }
  3181. });
  3182. };
  3183. var fastKey = function fastKey(it, create) {
  3184. if (!isObject(it)) return _typeof(it) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  3185. if (!has(it, META)) {
  3186. if (!isExtensible(it)) return 'F';
  3187. if (!create) return 'E';
  3188. setMeta(it);
  3189. }
  3190. return it[META].i;
  3191. };
  3192. var getWeak = function getWeak(it, create) {
  3193. if (!has(it, META)) {
  3194. if (!isExtensible(it)) return true;
  3195. if (!create) return false;
  3196. setMeta(it);
  3197. }
  3198. return it[META].w;
  3199. };
  3200. var onFreeze = function onFreeze(it) {
  3201. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  3202. return it;
  3203. };
  3204. var meta = module.exports = {
  3205. KEY: META,
  3206. NEED: false,
  3207. fastKey: fastKey,
  3208. getWeak: getWeak,
  3209. onFreeze: onFreeze
  3210. };
  3211. /***/ }),
  3212. /* 108 */
  3213. /***/ (function(module, exports, __w_pdfjs_require__) {
  3214. "use strict";
  3215. var redefineAll = __w_pdfjs_require__(97);
  3216. var getWeak = __w_pdfjs_require__(107).getWeak;
  3217. var anObject = __w_pdfjs_require__(12);
  3218. var isObject = __w_pdfjs_require__(13);
  3219. var anInstance = __w_pdfjs_require__(87);
  3220. var forOf = __w_pdfjs_require__(88);
  3221. var createArrayMethod = __w_pdfjs_require__(103);
  3222. var $has = __w_pdfjs_require__(21);
  3223. var validate = __w_pdfjs_require__(109);
  3224. var arrayFind = createArrayMethod(5);
  3225. var arrayFindIndex = createArrayMethod(6);
  3226. var id = 0;
  3227. var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
  3228. return that._l || (that._l = new UncaughtFrozenStore());
  3229. };
  3230. var UncaughtFrozenStore = function UncaughtFrozenStore() {
  3231. this.a = [];
  3232. };
  3233. var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
  3234. return arrayFind(store.a, function (it) {
  3235. return it[0] === key;
  3236. });
  3237. };
  3238. UncaughtFrozenStore.prototype = {
  3239. get: function get(key) {
  3240. var entry = findUncaughtFrozen(this, key);
  3241. if (entry) return entry[1];
  3242. },
  3243. has: function has(key) {
  3244. return !!findUncaughtFrozen(this, key);
  3245. },
  3246. set: function set(key, value) {
  3247. var entry = findUncaughtFrozen(this, key);
  3248. if (entry) entry[1] = value;else this.a.push([key, value]);
  3249. },
  3250. 'delete': function _delete(key) {
  3251. var index = arrayFindIndex(this.a, function (it) {
  3252. return it[0] === key;
  3253. });
  3254. if (~index) this.a.splice(index, 1);
  3255. return !!~index;
  3256. }
  3257. };
  3258. module.exports = {
  3259. getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
  3260. var C = wrapper(function (that, iterable) {
  3261. anInstance(that, C, NAME, '_i');
  3262. that._t = NAME;
  3263. that._i = id++;
  3264. that._l = undefined;
  3265. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  3266. });
  3267. redefineAll(C.prototype, {
  3268. 'delete': function _delete(key) {
  3269. if (!isObject(key)) return false;
  3270. var data = getWeak(key);
  3271. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  3272. return data && $has(data, this._i) && delete data[this._i];
  3273. },
  3274. has: function has(key) {
  3275. if (!isObject(key)) return false;
  3276. var data = getWeak(key);
  3277. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  3278. return data && $has(data, this._i);
  3279. }
  3280. });
  3281. return C;
  3282. },
  3283. def: function def(that, key, value) {
  3284. var data = getWeak(anObject(key), true);
  3285. if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
  3286. return that;
  3287. },
  3288. ufstore: uncaughtFrozenStore
  3289. };
  3290. /***/ }),
  3291. /* 109 */
  3292. /***/ (function(module, exports, __w_pdfjs_require__) {
  3293. "use strict";
  3294. var isObject = __w_pdfjs_require__(13);
  3295. module.exports = function (it, TYPE) {
  3296. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  3297. return it;
  3298. };
  3299. /***/ }),
  3300. /* 110 */
  3301. /***/ (function(module, exports, __w_pdfjs_require__) {
  3302. "use strict";
  3303. var global = __w_pdfjs_require__(8);
  3304. var $export = __w_pdfjs_require__(7);
  3305. var redefine = __w_pdfjs_require__(20);
  3306. var redefineAll = __w_pdfjs_require__(97);
  3307. var meta = __w_pdfjs_require__(107);
  3308. var forOf = __w_pdfjs_require__(88);
  3309. var anInstance = __w_pdfjs_require__(87);
  3310. var isObject = __w_pdfjs_require__(13);
  3311. var fails = __w_pdfjs_require__(16);
  3312. var $iterDetect = __w_pdfjs_require__(68);
  3313. var setToStringTag = __w_pdfjs_require__(59);
  3314. var inheritIfRequired = __w_pdfjs_require__(111);
  3315. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  3316. var Base = global[NAME];
  3317. var C = Base;
  3318. var ADDER = IS_MAP ? 'set' : 'add';
  3319. var proto = C && C.prototype;
  3320. var O = {};
  3321. var fixMethod = function fixMethod(KEY) {
  3322. var fn = proto[KEY];
  3323. redefine(proto, KEY, KEY == 'delete' ? function (a) {
  3324. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  3325. } : KEY == 'has' ? function has(a) {
  3326. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  3327. } : KEY == 'get' ? function get(a) {
  3328. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  3329. } : KEY == 'add' ? function add(a) {
  3330. fn.call(this, a === 0 ? 0 : a);
  3331. return this;
  3332. } : function set(a, b) {
  3333. fn.call(this, a === 0 ? 0 : a, b);
  3334. return this;
  3335. });
  3336. };
  3337. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  3338. new C().entries().next();
  3339. }))) {
  3340. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  3341. redefineAll(C.prototype, methods);
  3342. meta.NEED = true;
  3343. } else {
  3344. var instance = new C();
  3345. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  3346. var THROWS_ON_PRIMITIVES = fails(function () {
  3347. instance.has(1);
  3348. });
  3349. var ACCEPT_ITERABLES = $iterDetect(function (iter) {
  3350. new C(iter);
  3351. });
  3352. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  3353. var $instance = new C();
  3354. var index = 5;
  3355. while (index--) {
  3356. $instance[ADDER](index, index);
  3357. }
  3358. return !$instance.has(-0);
  3359. });
  3360. if (!ACCEPT_ITERABLES) {
  3361. C = wrapper(function (target, iterable) {
  3362. anInstance(target, C, NAME);
  3363. var that = inheritIfRequired(new Base(), target, C);
  3364. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  3365. return that;
  3366. });
  3367. C.prototype = proto;
  3368. proto.constructor = C;
  3369. }
  3370. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  3371. fixMethod('delete');
  3372. fixMethod('has');
  3373. IS_MAP && fixMethod('get');
  3374. }
  3375. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  3376. if (IS_WEAK && proto.clear) delete proto.clear;
  3377. }
  3378. setToStringTag(C, NAME);
  3379. O[NAME] = C;
  3380. $export($export.G + $export.W + $export.F * (C != Base), O);
  3381. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  3382. return C;
  3383. };
  3384. /***/ }),
  3385. /* 111 */
  3386. /***/ (function(module, exports, __w_pdfjs_require__) {
  3387. "use strict";
  3388. var isObject = __w_pdfjs_require__(13);
  3389. var setPrototypeOf = __w_pdfjs_require__(112).set;
  3390. module.exports = function (that, target, C) {
  3391. var S = target.constructor;
  3392. var P;
  3393. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  3394. setPrototypeOf(that, P);
  3395. }
  3396. return that;
  3397. };
  3398. /***/ }),
  3399. /* 112 */
  3400. /***/ (function(module, exports, __w_pdfjs_require__) {
  3401. "use strict";
  3402. var isObject = __w_pdfjs_require__(13);
  3403. var anObject = __w_pdfjs_require__(12);
  3404. var check = function check(O, proto) {
  3405. anObject(O);
  3406. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  3407. };
  3408. module.exports = {
  3409. set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) {
  3410. try {
  3411. set = __w_pdfjs_require__(23)(Function.call, __w_pdfjs_require__(113).f(Object.prototype, '__proto__').set, 2);
  3412. set(test, []);
  3413. buggy = !(test instanceof Array);
  3414. } catch (e) {
  3415. buggy = true;
  3416. }
  3417. return function setPrototypeOf(O, proto) {
  3418. check(O, proto);
  3419. if (buggy) O.__proto__ = proto;else set(O, proto);
  3420. return O;
  3421. };
  3422. }({}, false) : undefined),
  3423. check: check
  3424. };
  3425. /***/ }),
  3426. /* 113 */
  3427. /***/ (function(module, exports, __w_pdfjs_require__) {
  3428. "use strict";
  3429. var pIE = __w_pdfjs_require__(73);
  3430. var createDesc = __w_pdfjs_require__(19);
  3431. var toIObject = __w_pdfjs_require__(42);
  3432. var toPrimitive = __w_pdfjs_require__(18);
  3433. var has = __w_pdfjs_require__(21);
  3434. var IE8_DOM_DEFINE = __w_pdfjs_require__(14);
  3435. var gOPD = Object.getOwnPropertyDescriptor;
  3436. exports.f = __w_pdfjs_require__(15) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  3437. O = toIObject(O);
  3438. P = toPrimitive(P, true);
  3439. if (IE8_DOM_DEFINE) try {
  3440. return gOPD(O, P);
  3441. } catch (e) {}
  3442. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  3443. };
  3444. /***/ }),
  3445. /* 114 */
  3446. /***/ (function(module, exports, __w_pdfjs_require__) {
  3447. "use strict";
  3448. __w_pdfjs_require__(115)('WeakMap');
  3449. /***/ }),
  3450. /* 115 */
  3451. /***/ (function(module, exports, __w_pdfjs_require__) {
  3452. "use strict";
  3453. var $export = __w_pdfjs_require__(7);
  3454. module.exports = function (COLLECTION) {
  3455. $export($export.S, COLLECTION, {
  3456. of: function of() {
  3457. var length = arguments.length;
  3458. var A = new Array(length);
  3459. while (length--) {
  3460. A[length] = arguments[length];
  3461. }
  3462. return new this(A);
  3463. }
  3464. });
  3465. };
  3466. /***/ }),
  3467. /* 116 */
  3468. /***/ (function(module, exports, __w_pdfjs_require__) {
  3469. "use strict";
  3470. __w_pdfjs_require__(117)('WeakMap');
  3471. /***/ }),
  3472. /* 117 */
  3473. /***/ (function(module, exports, __w_pdfjs_require__) {
  3474. "use strict";
  3475. var $export = __w_pdfjs_require__(7);
  3476. var aFunction = __w_pdfjs_require__(24);
  3477. var ctx = __w_pdfjs_require__(23);
  3478. var forOf = __w_pdfjs_require__(88);
  3479. module.exports = function (COLLECTION) {
  3480. $export($export.S, COLLECTION, {
  3481. from: function from(source) {
  3482. var mapFn = arguments[1];
  3483. var mapping, A, n, cb;
  3484. aFunction(this);
  3485. mapping = mapFn !== undefined;
  3486. if (mapping) aFunction(mapFn);
  3487. if (source == undefined) return new this();
  3488. A = [];
  3489. if (mapping) {
  3490. n = 0;
  3491. cb = ctx(mapFn, arguments[2], 2);
  3492. forOf(source, false, function (nextItem) {
  3493. A.push(cb(nextItem, n++));
  3494. });
  3495. } else {
  3496. forOf(source, false, A.push, A);
  3497. }
  3498. return new this(A);
  3499. }
  3500. });
  3501. };
  3502. /***/ }),
  3503. /* 118 */
  3504. /***/ (function(module, exports, __w_pdfjs_require__) {
  3505. "use strict";
  3506. __w_pdfjs_require__(82);
  3507. __w_pdfjs_require__(83);
  3508. __w_pdfjs_require__(119);
  3509. __w_pdfjs_require__(120);
  3510. __w_pdfjs_require__(121);
  3511. module.exports = __w_pdfjs_require__(9).WeakSet;
  3512. /***/ }),
  3513. /* 119 */
  3514. /***/ (function(module, exports, __w_pdfjs_require__) {
  3515. "use strict";
  3516. var weak = __w_pdfjs_require__(108);
  3517. var validate = __w_pdfjs_require__(109);
  3518. var WEAK_SET = 'WeakSet';
  3519. __w_pdfjs_require__(110)(WEAK_SET, function (get) {
  3520. return function WeakSet() {
  3521. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  3522. };
  3523. }, {
  3524. add: function add(value) {
  3525. return weak.def(validate(this, WEAK_SET), value, true);
  3526. }
  3527. }, weak, false, true);
  3528. /***/ }),
  3529. /* 120 */
  3530. /***/ (function(module, exports, __w_pdfjs_require__) {
  3531. "use strict";
  3532. __w_pdfjs_require__(115)('WeakSet');
  3533. /***/ }),
  3534. /* 121 */
  3535. /***/ (function(module, exports, __w_pdfjs_require__) {
  3536. "use strict";
  3537. __w_pdfjs_require__(117)('WeakSet');
  3538. /***/ }),
  3539. /* 122 */
  3540. /***/ (function(module, exports, __w_pdfjs_require__) {
  3541. "use strict";
  3542. __w_pdfjs_require__(123);
  3543. module.exports = __w_pdfjs_require__(9).String.codePointAt;
  3544. /***/ }),
  3545. /* 123 */
  3546. /***/ (function(module, exports, __w_pdfjs_require__) {
  3547. "use strict";
  3548. var $export = __w_pdfjs_require__(7);
  3549. var $at = __w_pdfjs_require__(48)(false);
  3550. $export($export.P, 'String', {
  3551. codePointAt: function codePointAt(pos) {
  3552. return $at(this, pos);
  3553. }
  3554. });
  3555. /***/ }),
  3556. /* 124 */
  3557. /***/ (function(module, exports, __w_pdfjs_require__) {
  3558. "use strict";
  3559. __w_pdfjs_require__(125);
  3560. module.exports = __w_pdfjs_require__(9).String.fromCodePoint;
  3561. /***/ }),
  3562. /* 125 */
  3563. /***/ (function(module, exports, __w_pdfjs_require__) {
  3564. "use strict";
  3565. var $export = __w_pdfjs_require__(7);
  3566. var toAbsoluteIndex = __w_pdfjs_require__(44);
  3567. var fromCharCode = String.fromCharCode;
  3568. var $fromCodePoint = String.fromCodePoint;
  3569. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  3570. fromCodePoint: function fromCodePoint(x) {
  3571. var res = [];
  3572. var aLen = arguments.length;
  3573. var i = 0;
  3574. var code;
  3575. while (aLen > i) {
  3576. code = +arguments[i++];
  3577. if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
  3578. res.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00));
  3579. }
  3580. return res.join('');
  3581. }
  3582. });
  3583. /***/ }),
  3584. /* 126 */
  3585. /***/ (function(module, exports, __w_pdfjs_require__) {
  3586. "use strict";
  3587. __w_pdfjs_require__(127);
  3588. __w_pdfjs_require__(82);
  3589. module.exports = __w_pdfjs_require__(9).Symbol;
  3590. /***/ }),
  3591. /* 127 */
  3592. /***/ (function(module, exports, __w_pdfjs_require__) {
  3593. "use strict";
  3594. function _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); }
  3595. var global = __w_pdfjs_require__(8);
  3596. var has = __w_pdfjs_require__(21);
  3597. var DESCRIPTORS = __w_pdfjs_require__(15);
  3598. var $export = __w_pdfjs_require__(7);
  3599. var redefine = __w_pdfjs_require__(20);
  3600. var META = __w_pdfjs_require__(107).KEY;
  3601. var $fails = __w_pdfjs_require__(16);
  3602. var shared = __w_pdfjs_require__(31);
  3603. var setToStringTag = __w_pdfjs_require__(59);
  3604. var uid = __w_pdfjs_require__(22);
  3605. var wks = __w_pdfjs_require__(30);
  3606. var wksExt = __w_pdfjs_require__(128);
  3607. var wksDefine = __w_pdfjs_require__(129);
  3608. var enumKeys = __w_pdfjs_require__(130);
  3609. var isArray = __w_pdfjs_require__(106);
  3610. var anObject = __w_pdfjs_require__(12);
  3611. var isObject = __w_pdfjs_require__(13);
  3612. var toIObject = __w_pdfjs_require__(42);
  3613. var toPrimitive = __w_pdfjs_require__(18);
  3614. var createDesc = __w_pdfjs_require__(19);
  3615. var _create = __w_pdfjs_require__(52);
  3616. var gOPNExt = __w_pdfjs_require__(131);
  3617. var $GOPD = __w_pdfjs_require__(113);
  3618. var $DP = __w_pdfjs_require__(11);
  3619. var $keys = __w_pdfjs_require__(54);
  3620. var gOPD = $GOPD.f;
  3621. var dP = $DP.f;
  3622. var gOPN = gOPNExt.f;
  3623. var $Symbol = global.Symbol;
  3624. var $JSON = global.JSON;
  3625. var _stringify = $JSON && $JSON.stringify;
  3626. var PROTOTYPE = 'prototype';
  3627. var HIDDEN = wks('_hidden');
  3628. var TO_PRIMITIVE = wks('toPrimitive');
  3629. var isEnum = {}.propertyIsEnumerable;
  3630. var SymbolRegistry = shared('symbol-registry');
  3631. var AllSymbols = shared('symbols');
  3632. var OPSymbols = shared('op-symbols');
  3633. var ObjectProto = Object[PROTOTYPE];
  3634. var USE_NATIVE = typeof $Symbol == 'function';
  3635. var QObject = global.QObject;
  3636. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  3637. var setSymbolDesc = DESCRIPTORS && $fails(function () {
  3638. return _create(dP({}, 'a', {
  3639. get: function get() {
  3640. return dP(this, 'a', {
  3641. value: 7
  3642. }).a;
  3643. }
  3644. })).a != 7;
  3645. }) ? function (it, key, D) {
  3646. var protoDesc = gOPD(ObjectProto, key);
  3647. if (protoDesc) delete ObjectProto[key];
  3648. dP(it, key, D);
  3649. if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
  3650. } : dP;
  3651. var wrap = function wrap(tag) {
  3652. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  3653. sym._k = tag;
  3654. return sym;
  3655. };
  3656. var isSymbol = USE_NATIVE && _typeof($Symbol.iterator) == 'symbol' ? function (it) {
  3657. return _typeof(it) == 'symbol';
  3658. } : function (it) {
  3659. return it instanceof $Symbol;
  3660. };
  3661. var $defineProperty = function defineProperty(it, key, D) {
  3662. if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
  3663. anObject(it);
  3664. key = toPrimitive(key, true);
  3665. anObject(D);
  3666. if (has(AllSymbols, key)) {
  3667. if (!D.enumerable) {
  3668. if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
  3669. it[HIDDEN][key] = true;
  3670. } else {
  3671. if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
  3672. D = _create(D, {
  3673. enumerable: createDesc(0, false)
  3674. });
  3675. }
  3676. return setSymbolDesc(it, key, D);
  3677. }
  3678. return dP(it, key, D);
  3679. };
  3680. var $defineProperties = function defineProperties(it, P) {
  3681. anObject(it);
  3682. var keys = enumKeys(P = toIObject(P));
  3683. var i = 0;
  3684. var l = keys.length;
  3685. var key;
  3686. while (l > i) {
  3687. $defineProperty(it, key = keys[i++], P[key]);
  3688. }
  3689. return it;
  3690. };
  3691. var $create = function create(it, P) {
  3692. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  3693. };
  3694. var $propertyIsEnumerable = function propertyIsEnumerable(key) {
  3695. var E = isEnum.call(this, key = toPrimitive(key, true));
  3696. if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
  3697. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  3698. };
  3699. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
  3700. it = toIObject(it);
  3701. key = toPrimitive(key, true);
  3702. if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
  3703. var D = gOPD(it, key);
  3704. if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
  3705. return D;
  3706. };
  3707. var $getOwnPropertyNames = function getOwnPropertyNames(it) {
  3708. var names = gOPN(toIObject(it));
  3709. var result = [];
  3710. var i = 0;
  3711. var key;
  3712. while (names.length > i) {
  3713. if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
  3714. }
  3715. return result;
  3716. };
  3717. var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
  3718. var IS_OP = it === ObjectProto;
  3719. var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
  3720. var result = [];
  3721. var i = 0;
  3722. var key;
  3723. while (names.length > i) {
  3724. if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
  3725. }
  3726. return result;
  3727. };
  3728. if (!USE_NATIVE) {
  3729. $Symbol = function _Symbol() {
  3730. if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
  3731. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  3732. var $set = function $set(value) {
  3733. if (this === ObjectProto) $set.call(OPSymbols, value);
  3734. if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
  3735. setSymbolDesc(this, tag, createDesc(1, value));
  3736. };
  3737. if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, {
  3738. configurable: true,
  3739. set: $set
  3740. });
  3741. return wrap(tag);
  3742. };
  3743. redefine($Symbol[PROTOTYPE], 'toString', function toString() {
  3744. return this._k;
  3745. });
  3746. $GOPD.f = $getOwnPropertyDescriptor;
  3747. $DP.f = $defineProperty;
  3748. __w_pdfjs_require__(132).f = gOPNExt.f = $getOwnPropertyNames;
  3749. __w_pdfjs_require__(73).f = $propertyIsEnumerable;
  3750. __w_pdfjs_require__(72).f = $getOwnPropertySymbols;
  3751. if (DESCRIPTORS && !__w_pdfjs_require__(32)) {
  3752. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  3753. }
  3754. wksExt.f = function (name) {
  3755. return wrap(wks(name));
  3756. };
  3757. }
  3758. $export($export.G + $export.W + $export.F * !USE_NATIVE, {
  3759. Symbol: $Symbol
  3760. });
  3761. for (var es6Symbols = 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) {
  3762. wks(es6Symbols[j++]);
  3763. }
  3764. for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) {
  3765. wksDefine(wellKnownSymbols[k++]);
  3766. }
  3767. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  3768. 'for': function _for(key) {
  3769. return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key);
  3770. },
  3771. keyFor: function keyFor(sym) {
  3772. if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
  3773. for (var key in SymbolRegistry) {
  3774. if (SymbolRegistry[key] === sym) return key;
  3775. }
  3776. },
  3777. useSetter: function useSetter() {
  3778. setter = true;
  3779. },
  3780. useSimple: function useSimple() {
  3781. setter = false;
  3782. }
  3783. });
  3784. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  3785. create: $create,
  3786. defineProperty: $defineProperty,
  3787. defineProperties: $defineProperties,
  3788. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  3789. getOwnPropertyNames: $getOwnPropertyNames,
  3790. getOwnPropertySymbols: $getOwnPropertySymbols
  3791. });
  3792. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
  3793. var S = $Symbol();
  3794. return _stringify([S]) != '[null]' || _stringify({
  3795. a: S
  3796. }) != '{}' || _stringify(Object(S)) != '{}';
  3797. })), 'JSON', {
  3798. stringify: function stringify(it) {
  3799. var args = [it];
  3800. var i = 1;
  3801. var replacer, $replacer;
  3802. while (arguments.length > i) {
  3803. args.push(arguments[i++]);
  3804. }
  3805. $replacer = replacer = args[1];
  3806. if (!isObject(replacer) && it === undefined || isSymbol(it)) return;
  3807. if (!isArray(replacer)) replacer = function replacer(key, value) {
  3808. if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
  3809. if (!isSymbol(value)) return value;
  3810. };
  3811. args[1] = replacer;
  3812. return _stringify.apply($JSON, args);
  3813. }
  3814. });
  3815. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __w_pdfjs_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  3816. setToStringTag($Symbol, 'Symbol');
  3817. setToStringTag(Math, 'Math', true);
  3818. setToStringTag(global.JSON, 'JSON', true);
  3819. /***/ }),
  3820. /* 128 */
  3821. /***/ (function(module, exports, __w_pdfjs_require__) {
  3822. "use strict";
  3823. exports.f = __w_pdfjs_require__(30);
  3824. /***/ }),
  3825. /* 129 */
  3826. /***/ (function(module, exports, __w_pdfjs_require__) {
  3827. "use strict";
  3828. var global = __w_pdfjs_require__(8);
  3829. var core = __w_pdfjs_require__(9);
  3830. var LIBRARY = __w_pdfjs_require__(32);
  3831. var wksExt = __w_pdfjs_require__(128);
  3832. var defineProperty = __w_pdfjs_require__(11).f;
  3833. module.exports = function (name) {
  3834. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  3835. if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, {
  3836. value: wksExt.f(name)
  3837. });
  3838. };
  3839. /***/ }),
  3840. /* 130 */
  3841. /***/ (function(module, exports, __w_pdfjs_require__) {
  3842. "use strict";
  3843. var getKeys = __w_pdfjs_require__(54);
  3844. var gOPS = __w_pdfjs_require__(72);
  3845. var pIE = __w_pdfjs_require__(73);
  3846. module.exports = function (it) {
  3847. var result = getKeys(it);
  3848. var getSymbols = gOPS.f;
  3849. if (getSymbols) {
  3850. var symbols = getSymbols(it);
  3851. var isEnum = pIE.f;
  3852. var i = 0;
  3853. var key;
  3854. while (symbols.length > i) {
  3855. if (isEnum.call(it, key = symbols[i++])) result.push(key);
  3856. }
  3857. }
  3858. return result;
  3859. };
  3860. /***/ }),
  3861. /* 131 */
  3862. /***/ (function(module, exports, __w_pdfjs_require__) {
  3863. "use strict";
  3864. function _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); }
  3865. var toIObject = __w_pdfjs_require__(42);
  3866. var gOPN = __w_pdfjs_require__(132).f;
  3867. var toString = {}.toString;
  3868. var windowNames = (typeof window === "undefined" ? "undefined" : _typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : [];
  3869. var getWindowNames = function getWindowNames(it) {
  3870. try {
  3871. return gOPN(it);
  3872. } catch (e) {
  3873. return windowNames.slice();
  3874. }
  3875. };
  3876. module.exports.f = function getOwnPropertyNames(it) {
  3877. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  3878. };
  3879. /***/ }),
  3880. /* 132 */
  3881. /***/ (function(module, exports, __w_pdfjs_require__) {
  3882. "use strict";
  3883. var $keys = __w_pdfjs_require__(55);
  3884. var hiddenKeys = __w_pdfjs_require__(57).concat('length', 'prototype');
  3885. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  3886. return $keys(O, hiddenKeys);
  3887. };
  3888. /***/ }),
  3889. /* 133 */
  3890. /***/ (function(module, exports, __w_pdfjs_require__) {
  3891. "use strict";
  3892. __w_pdfjs_require__(134);
  3893. module.exports = __w_pdfjs_require__(9).String.padStart;
  3894. /***/ }),
  3895. /* 134 */
  3896. /***/ (function(module, exports, __w_pdfjs_require__) {
  3897. "use strict";
  3898. var $export = __w_pdfjs_require__(7);
  3899. var $pad = __w_pdfjs_require__(135);
  3900. var userAgent = __w_pdfjs_require__(95);
  3901. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  3902. padStart: function padStart(maxLength) {
  3903. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  3904. }
  3905. });
  3906. /***/ }),
  3907. /* 135 */
  3908. /***/ (function(module, exports, __w_pdfjs_require__) {
  3909. "use strict";
  3910. var toLength = __w_pdfjs_require__(25);
  3911. var repeat = __w_pdfjs_require__(136);
  3912. var defined = __w_pdfjs_require__(33);
  3913. module.exports = function (that, maxLength, fillString, left) {
  3914. var S = String(defined(that));
  3915. var stringLength = S.length;
  3916. var fillStr = fillString === undefined ? ' ' : String(fillString);
  3917. var intMaxLength = toLength(maxLength);
  3918. if (intMaxLength <= stringLength || fillStr == '') return S;
  3919. var fillLen = intMaxLength - stringLength;
  3920. var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  3921. if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
  3922. return left ? stringFiller + S : S + stringFiller;
  3923. };
  3924. /***/ }),
  3925. /* 136 */
  3926. /***/ (function(module, exports, __w_pdfjs_require__) {
  3927. "use strict";
  3928. var toInteger = __w_pdfjs_require__(26);
  3929. var defined = __w_pdfjs_require__(33);
  3930. module.exports = function repeat(count) {
  3931. var str = String(defined(this));
  3932. var res = '';
  3933. var n = toInteger(count);
  3934. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  3935. for (; n > 0; (n >>>= 1) && (str += str)) {
  3936. if (n & 1) res += str;
  3937. }
  3938. return res;
  3939. };
  3940. /***/ }),
  3941. /* 137 */
  3942. /***/ (function(module, exports, __w_pdfjs_require__) {
  3943. "use strict";
  3944. __w_pdfjs_require__(138);
  3945. module.exports = __w_pdfjs_require__(9).String.padEnd;
  3946. /***/ }),
  3947. /* 138 */
  3948. /***/ (function(module, exports, __w_pdfjs_require__) {
  3949. "use strict";
  3950. var $export = __w_pdfjs_require__(7);
  3951. var $pad = __w_pdfjs_require__(135);
  3952. var userAgent = __w_pdfjs_require__(95);
  3953. $export($export.P + $export.F * /Version\/10\.\d+(\.\d+)? Safari\//.test(userAgent), 'String', {
  3954. padEnd: function padEnd(maxLength) {
  3955. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  3956. }
  3957. });
  3958. /***/ }),
  3959. /* 139 */
  3960. /***/ (function(module, exports, __w_pdfjs_require__) {
  3961. "use strict";
  3962. __w_pdfjs_require__(140);
  3963. module.exports = __w_pdfjs_require__(9).Object.values;
  3964. /***/ }),
  3965. /* 140 */
  3966. /***/ (function(module, exports, __w_pdfjs_require__) {
  3967. "use strict";
  3968. var $export = __w_pdfjs_require__(7);
  3969. var $values = __w_pdfjs_require__(141)(false);
  3970. $export($export.S, 'Object', {
  3971. values: function values(it) {
  3972. return $values(it);
  3973. }
  3974. });
  3975. /***/ }),
  3976. /* 141 */
  3977. /***/ (function(module, exports, __w_pdfjs_require__) {
  3978. "use strict";
  3979. var getKeys = __w_pdfjs_require__(54);
  3980. var toIObject = __w_pdfjs_require__(42);
  3981. var isEnum = __w_pdfjs_require__(73).f;
  3982. module.exports = function (isEntries) {
  3983. return function (it) {
  3984. var O = toIObject(it);
  3985. var keys = getKeys(O);
  3986. var length = keys.length;
  3987. var i = 0;
  3988. var result = [];
  3989. var key;
  3990. while (length > i) {
  3991. if (isEnum.call(O, key = keys[i++])) {
  3992. result.push(isEntries ? [key, O[key]] : O[key]);
  3993. }
  3994. }
  3995. return result;
  3996. };
  3997. };
  3998. /***/ }),
  3999. /* 142 */
  4000. /***/ (function(module, exports, __w_pdfjs_require__) {
  4001. "use strict";
  4002. {
  4003. var isReadableStreamSupported = false;
  4004. if (typeof ReadableStream !== 'undefined') {
  4005. try {
  4006. new ReadableStream({
  4007. start: function start(controller) {
  4008. controller.close();
  4009. }
  4010. });
  4011. isReadableStreamSupported = true;
  4012. } catch (e) {}
  4013. }
  4014. if (isReadableStreamSupported) {
  4015. exports.ReadableStream = ReadableStream;
  4016. } else {
  4017. exports.ReadableStream = __w_pdfjs_require__(143).ReadableStream;
  4018. }
  4019. }
  4020. /***/ }),
  4021. /* 143 */
  4022. /***/ (function(module, exports, __w_pdfjs_require__) {
  4023. "use strict";
  4024. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  4025. (function (e, a) {
  4026. for (var i in a) {
  4027. e[i] = a[i];
  4028. }
  4029. })(exports, function (modules) {
  4030. var installedModules = {};
  4031. function __w_pdfjs_require__(moduleId) {
  4032. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  4033. var module = installedModules[moduleId] = {
  4034. i: moduleId,
  4035. l: false,
  4036. exports: {}
  4037. };
  4038. modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  4039. module.l = true;
  4040. return module.exports;
  4041. }
  4042. __w_pdfjs_require__.m = modules;
  4043. __w_pdfjs_require__.c = installedModules;
  4044. __w_pdfjs_require__.i = function (value) {
  4045. return value;
  4046. };
  4047. __w_pdfjs_require__.d = function (exports, name, getter) {
  4048. if (!__w_pdfjs_require__.o(exports, name)) {
  4049. Object.defineProperty(exports, name, {
  4050. configurable: false,
  4051. enumerable: true,
  4052. get: getter
  4053. });
  4054. }
  4055. };
  4056. __w_pdfjs_require__.n = function (module) {
  4057. var getter = module && module.__esModule ? function getDefault() {
  4058. return module['default'];
  4059. } : function getModuleExports() {
  4060. return module;
  4061. };
  4062. __w_pdfjs_require__.d(getter, 'a', getter);
  4063. return getter;
  4064. };
  4065. __w_pdfjs_require__.o = function (object, property) {
  4066. return Object.prototype.hasOwnProperty.call(object, property);
  4067. };
  4068. __w_pdfjs_require__.p = "";
  4069. return __w_pdfjs_require__(__w_pdfjs_require__.s = 7);
  4070. }([function (module, exports, __w_pdfjs_require__) {
  4071. "use strict";
  4072. var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
  4073. return _typeof2(obj);
  4074. } : function (obj) {
  4075. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  4076. };
  4077. var _require = __w_pdfjs_require__(1),
  4078. assert = _require.assert;
  4079. function IsPropertyKey(argument) {
  4080. return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol';
  4081. }
  4082. exports.typeIsObject = function (x) {
  4083. return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function';
  4084. };
  4085. exports.createDataProperty = function (o, p, v) {
  4086. assert(exports.typeIsObject(o));
  4087. Object.defineProperty(o, p, {
  4088. value: v,
  4089. writable: true,
  4090. enumerable: true,
  4091. configurable: true
  4092. });
  4093. };
  4094. exports.createArrayFromList = function (elements) {
  4095. return elements.slice();
  4096. };
  4097. exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) {
  4098. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  4099. };
  4100. exports.CreateIterResultObject = function (value, done) {
  4101. assert(typeof done === 'boolean');
  4102. var obj = {};
  4103. Object.defineProperty(obj, 'value', {
  4104. value: value,
  4105. enumerable: true,
  4106. writable: true,
  4107. configurable: true
  4108. });
  4109. Object.defineProperty(obj, 'done', {
  4110. value: done,
  4111. enumerable: true,
  4112. writable: true,
  4113. configurable: true
  4114. });
  4115. return obj;
  4116. };
  4117. exports.IsFiniteNonNegativeNumber = function (v) {
  4118. if (Number.isNaN(v)) {
  4119. return false;
  4120. }
  4121. if (v === Infinity) {
  4122. return false;
  4123. }
  4124. if (v < 0) {
  4125. return false;
  4126. }
  4127. return true;
  4128. };
  4129. function Call(F, V, args) {
  4130. if (typeof F !== 'function') {
  4131. throw new TypeError('Argument is not a function');
  4132. }
  4133. return Function.prototype.apply.call(F, V, args);
  4134. }
  4135. exports.InvokeOrNoop = function (O, P, args) {
  4136. assert(O !== undefined);
  4137. assert(IsPropertyKey(P));
  4138. assert(Array.isArray(args));
  4139. var method = O[P];
  4140. if (method === undefined) {
  4141. return undefined;
  4142. }
  4143. return Call(method, O, args);
  4144. };
  4145. exports.PromiseInvokeOrNoop = function (O, P, args) {
  4146. assert(O !== undefined);
  4147. assert(IsPropertyKey(P));
  4148. assert(Array.isArray(args));
  4149. try {
  4150. return Promise.resolve(exports.InvokeOrNoop(O, P, args));
  4151. } catch (returnValueE) {
  4152. return Promise.reject(returnValueE);
  4153. }
  4154. };
  4155. exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) {
  4156. assert(O !== undefined);
  4157. assert(IsPropertyKey(P));
  4158. assert(Array.isArray(args));
  4159. assert(Array.isArray(argsF));
  4160. var method = void 0;
  4161. try {
  4162. method = O[P];
  4163. } catch (methodE) {
  4164. return Promise.reject(methodE);
  4165. }
  4166. if (method === undefined) {
  4167. return F.apply(null, argsF);
  4168. }
  4169. try {
  4170. return Promise.resolve(Call(method, O, args));
  4171. } catch (e) {
  4172. return Promise.reject(e);
  4173. }
  4174. };
  4175. exports.TransferArrayBuffer = function (O) {
  4176. return O.slice();
  4177. };
  4178. exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) {
  4179. highWaterMark = Number(highWaterMark);
  4180. if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
  4181. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  4182. }
  4183. return highWaterMark;
  4184. };
  4185. exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) {
  4186. if (size !== undefined && typeof size !== 'function') {
  4187. throw new TypeError('size property of a queuing strategy must be a function');
  4188. }
  4189. highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark);
  4190. return {
  4191. size: size,
  4192. highWaterMark: highWaterMark
  4193. };
  4194. };
  4195. }, function (module, exports, __w_pdfjs_require__) {
  4196. "use strict";
  4197. function rethrowAssertionErrorRejection(e) {
  4198. if (e && e.constructor === AssertionError) {
  4199. setTimeout(function () {
  4200. throw e;
  4201. }, 0);
  4202. }
  4203. }
  4204. function AssertionError(message) {
  4205. this.name = 'AssertionError';
  4206. this.message = message || '';
  4207. this.stack = new Error().stack;
  4208. }
  4209. AssertionError.prototype = Object.create(Error.prototype);
  4210. AssertionError.prototype.constructor = AssertionError;
  4211. function assert(value, message) {
  4212. if (!value) {
  4213. throw new AssertionError(message);
  4214. }
  4215. }
  4216. module.exports = {
  4217. rethrowAssertionErrorRejection: rethrowAssertionErrorRejection,
  4218. AssertionError: AssertionError,
  4219. assert: assert
  4220. };
  4221. }, function (module, exports, __w_pdfjs_require__) {
  4222. "use strict";
  4223. var _createClass = function () {
  4224. function defineProperties(target, props) {
  4225. for (var i = 0; i < props.length; i++) {
  4226. var descriptor = props[i];
  4227. descriptor.enumerable = descriptor.enumerable || false;
  4228. descriptor.configurable = true;
  4229. if ("value" in descriptor) descriptor.writable = true;
  4230. Object.defineProperty(target, descriptor.key, descriptor);
  4231. }
  4232. }
  4233. return function (Constructor, protoProps, staticProps) {
  4234. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  4235. if (staticProps) defineProperties(Constructor, staticProps);
  4236. return Constructor;
  4237. };
  4238. }();
  4239. function _classCallCheck(instance, Constructor) {
  4240. if (!(instance instanceof Constructor)) {
  4241. throw new TypeError("Cannot call a class as a function");
  4242. }
  4243. }
  4244. var _require = __w_pdfjs_require__(0),
  4245. InvokeOrNoop = _require.InvokeOrNoop,
  4246. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  4247. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  4248. typeIsObject = _require.typeIsObject;
  4249. var _require2 = __w_pdfjs_require__(1),
  4250. assert = _require2.assert,
  4251. rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection;
  4252. var _require3 = __w_pdfjs_require__(3),
  4253. DequeueValue = _require3.DequeueValue,
  4254. EnqueueValueWithSize = _require3.EnqueueValueWithSize,
  4255. PeekQueueValue = _require3.PeekQueueValue,
  4256. ResetQueue = _require3.ResetQueue;
  4257. var WritableStream = function () {
  4258. function WritableStream() {
  4259. var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4260. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  4261. size = _ref.size,
  4262. _ref$highWaterMark = _ref.highWaterMark,
  4263. highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark;
  4264. _classCallCheck(this, WritableStream);
  4265. this._state = 'writable';
  4266. this._storedError = undefined;
  4267. this._writer = undefined;
  4268. this._writableStreamController = undefined;
  4269. this._writeRequests = [];
  4270. this._inFlightWriteRequest = undefined;
  4271. this._closeRequest = undefined;
  4272. this._inFlightCloseRequest = undefined;
  4273. this._pendingAbortRequest = undefined;
  4274. this._backpressure = false;
  4275. var type = underlyingSink.type;
  4276. if (type !== undefined) {
  4277. throw new RangeError('Invalid type is specified');
  4278. }
  4279. this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark);
  4280. this._writableStreamController.__startSteps();
  4281. }
  4282. _createClass(WritableStream, [{
  4283. key: 'abort',
  4284. value: function abort(reason) {
  4285. if (IsWritableStream(this) === false) {
  4286. return Promise.reject(streamBrandCheckException('abort'));
  4287. }
  4288. if (IsWritableStreamLocked(this) === true) {
  4289. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  4290. }
  4291. return WritableStreamAbort(this, reason);
  4292. }
  4293. }, {
  4294. key: 'getWriter',
  4295. value: function getWriter() {
  4296. if (IsWritableStream(this) === false) {
  4297. throw streamBrandCheckException('getWriter');
  4298. }
  4299. return AcquireWritableStreamDefaultWriter(this);
  4300. }
  4301. }, {
  4302. key: 'locked',
  4303. get: function get() {
  4304. if (IsWritableStream(this) === false) {
  4305. throw streamBrandCheckException('locked');
  4306. }
  4307. return IsWritableStreamLocked(this);
  4308. }
  4309. }]);
  4310. return WritableStream;
  4311. }();
  4312. module.exports = {
  4313. AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter,
  4314. IsWritableStream: IsWritableStream,
  4315. IsWritableStreamLocked: IsWritableStreamLocked,
  4316. WritableStream: WritableStream,
  4317. WritableStreamAbort: WritableStreamAbort,
  4318. WritableStreamDefaultControllerError: WritableStreamDefaultControllerError,
  4319. WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation,
  4320. WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease,
  4321. WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite,
  4322. WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight
  4323. };
  4324. function AcquireWritableStreamDefaultWriter(stream) {
  4325. return new WritableStreamDefaultWriter(stream);
  4326. }
  4327. function IsWritableStream(x) {
  4328. if (!typeIsObject(x)) {
  4329. return false;
  4330. }
  4331. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  4332. return false;
  4333. }
  4334. return true;
  4335. }
  4336. function IsWritableStreamLocked(stream) {
  4337. assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams');
  4338. if (stream._writer === undefined) {
  4339. return false;
  4340. }
  4341. return true;
  4342. }
  4343. function WritableStreamAbort(stream, reason) {
  4344. var state = stream._state;
  4345. if (state === 'closed') {
  4346. return Promise.resolve(undefined);
  4347. }
  4348. if (state === 'errored') {
  4349. return Promise.reject(stream._storedError);
  4350. }
  4351. var error = new TypeError('Requested to abort');
  4352. if (stream._pendingAbortRequest !== undefined) {
  4353. return Promise.reject(error);
  4354. }
  4355. assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring');
  4356. var wasAlreadyErroring = false;
  4357. if (state === 'erroring') {
  4358. wasAlreadyErroring = true;
  4359. reason = undefined;
  4360. }
  4361. var promise = new Promise(function (resolve, reject) {
  4362. stream._pendingAbortRequest = {
  4363. _resolve: resolve,
  4364. _reject: reject,
  4365. _reason: reason,
  4366. _wasAlreadyErroring: wasAlreadyErroring
  4367. };
  4368. });
  4369. if (wasAlreadyErroring === false) {
  4370. WritableStreamStartErroring(stream, error);
  4371. }
  4372. return promise;
  4373. }
  4374. function WritableStreamAddWriteRequest(stream) {
  4375. assert(IsWritableStreamLocked(stream) === true);
  4376. assert(stream._state === 'writable');
  4377. var promise = new Promise(function (resolve, reject) {
  4378. var writeRequest = {
  4379. _resolve: resolve,
  4380. _reject: reject
  4381. };
  4382. stream._writeRequests.push(writeRequest);
  4383. });
  4384. return promise;
  4385. }
  4386. function WritableStreamDealWithRejection(stream, error) {
  4387. var state = stream._state;
  4388. if (state === 'writable') {
  4389. WritableStreamStartErroring(stream, error);
  4390. return;
  4391. }
  4392. assert(state === 'erroring');
  4393. WritableStreamFinishErroring(stream);
  4394. }
  4395. function WritableStreamStartErroring(stream, reason) {
  4396. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  4397. assert(stream._state === 'writable', 'state must be writable');
  4398. var controller = stream._writableStreamController;
  4399. assert(controller !== undefined, 'controller must not be undefined');
  4400. stream._state = 'erroring';
  4401. stream._storedError = reason;
  4402. var writer = stream._writer;
  4403. if (writer !== undefined) {
  4404. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  4405. }
  4406. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  4407. WritableStreamFinishErroring(stream);
  4408. }
  4409. }
  4410. function WritableStreamFinishErroring(stream) {
  4411. assert(stream._state === 'erroring', 'stream._state === erroring');
  4412. assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false');
  4413. stream._state = 'errored';
  4414. stream._writableStreamController.__errorSteps();
  4415. var storedError = stream._storedError;
  4416. for (var i = 0; i < stream._writeRequests.length; i++) {
  4417. var writeRequest = stream._writeRequests[i];
  4418. writeRequest._reject(storedError);
  4419. }
  4420. stream._writeRequests = [];
  4421. if (stream._pendingAbortRequest === undefined) {
  4422. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4423. return;
  4424. }
  4425. var abortRequest = stream._pendingAbortRequest;
  4426. stream._pendingAbortRequest = undefined;
  4427. if (abortRequest._wasAlreadyErroring === true) {
  4428. abortRequest._reject(storedError);
  4429. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4430. return;
  4431. }
  4432. var promise = stream._writableStreamController.__abortSteps(abortRequest._reason);
  4433. promise.then(function () {
  4434. abortRequest._resolve();
  4435. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4436. }, function (reason) {
  4437. abortRequest._reject(reason);
  4438. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  4439. });
  4440. }
  4441. function WritableStreamFinishInFlightWrite(stream) {
  4442. assert(stream._inFlightWriteRequest !== undefined);
  4443. stream._inFlightWriteRequest._resolve(undefined);
  4444. stream._inFlightWriteRequest = undefined;
  4445. }
  4446. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  4447. assert(stream._inFlightWriteRequest !== undefined);
  4448. stream._inFlightWriteRequest._reject(error);
  4449. stream._inFlightWriteRequest = undefined;
  4450. assert(stream._state === 'writable' || stream._state === 'erroring');
  4451. WritableStreamDealWithRejection(stream, error);
  4452. }
  4453. function WritableStreamFinishInFlightClose(stream) {
  4454. assert(stream._inFlightCloseRequest !== undefined);
  4455. stream._inFlightCloseRequest._resolve(undefined);
  4456. stream._inFlightCloseRequest = undefined;
  4457. var state = stream._state;
  4458. assert(state === 'writable' || state === 'erroring');
  4459. if (state === 'erroring') {
  4460. stream._storedError = undefined;
  4461. if (stream._pendingAbortRequest !== undefined) {
  4462. stream._pendingAbortRequest._resolve();
  4463. stream._pendingAbortRequest = undefined;
  4464. }
  4465. }
  4466. stream._state = 'closed';
  4467. var writer = stream._writer;
  4468. if (writer !== undefined) {
  4469. defaultWriterClosedPromiseResolve(writer);
  4470. }
  4471. assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined');
  4472. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  4473. }
  4474. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  4475. assert(stream._inFlightCloseRequest !== undefined);
  4476. stream._inFlightCloseRequest._reject(error);
  4477. stream._inFlightCloseRequest = undefined;
  4478. assert(stream._state === 'writable' || stream._state === 'erroring');
  4479. if (stream._pendingAbortRequest !== undefined) {
  4480. stream._pendingAbortRequest._reject(error);
  4481. stream._pendingAbortRequest = undefined;
  4482. }
  4483. WritableStreamDealWithRejection(stream, error);
  4484. }
  4485. function WritableStreamCloseQueuedOrInFlight(stream) {
  4486. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  4487. return false;
  4488. }
  4489. return true;
  4490. }
  4491. function WritableStreamHasOperationMarkedInFlight(stream) {
  4492. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  4493. return false;
  4494. }
  4495. return true;
  4496. }
  4497. function WritableStreamMarkCloseRequestInFlight(stream) {
  4498. assert(stream._inFlightCloseRequest === undefined);
  4499. assert(stream._closeRequest !== undefined);
  4500. stream._inFlightCloseRequest = stream._closeRequest;
  4501. stream._closeRequest = undefined;
  4502. }
  4503. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  4504. assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request');
  4505. assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty');
  4506. stream._inFlightWriteRequest = stream._writeRequests.shift();
  4507. }
  4508. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  4509. assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`');
  4510. if (stream._closeRequest !== undefined) {
  4511. assert(stream._inFlightCloseRequest === undefined);
  4512. stream._closeRequest._reject(stream._storedError);
  4513. stream._closeRequest = undefined;
  4514. }
  4515. var writer = stream._writer;
  4516. if (writer !== undefined) {
  4517. defaultWriterClosedPromiseReject(writer, stream._storedError);
  4518. writer._closedPromise.catch(function () {});
  4519. }
  4520. }
  4521. function WritableStreamUpdateBackpressure(stream, backpressure) {
  4522. assert(stream._state === 'writable');
  4523. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  4524. var writer = stream._writer;
  4525. if (writer !== undefined && backpressure !== stream._backpressure) {
  4526. if (backpressure === true) {
  4527. defaultWriterReadyPromiseReset(writer);
  4528. } else {
  4529. assert(backpressure === false);
  4530. defaultWriterReadyPromiseResolve(writer);
  4531. }
  4532. }
  4533. stream._backpressure = backpressure;
  4534. }
  4535. var WritableStreamDefaultWriter = function () {
  4536. function WritableStreamDefaultWriter(stream) {
  4537. _classCallCheck(this, WritableStreamDefaultWriter);
  4538. if (IsWritableStream(stream) === false) {
  4539. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  4540. }
  4541. if (IsWritableStreamLocked(stream) === true) {
  4542. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  4543. }
  4544. this._ownerWritableStream = stream;
  4545. stream._writer = this;
  4546. var state = stream._state;
  4547. if (state === 'writable') {
  4548. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  4549. defaultWriterReadyPromiseInitialize(this);
  4550. } else {
  4551. defaultWriterReadyPromiseInitializeAsResolved(this);
  4552. }
  4553. defaultWriterClosedPromiseInitialize(this);
  4554. } else if (state === 'erroring') {
  4555. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  4556. this._readyPromise.catch(function () {});
  4557. defaultWriterClosedPromiseInitialize(this);
  4558. } else if (state === 'closed') {
  4559. defaultWriterReadyPromiseInitializeAsResolved(this);
  4560. defaultWriterClosedPromiseInitializeAsResolved(this);
  4561. } else {
  4562. assert(state === 'errored', 'state must be errored');
  4563. var storedError = stream._storedError;
  4564. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  4565. this._readyPromise.catch(function () {});
  4566. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  4567. this._closedPromise.catch(function () {});
  4568. }
  4569. }
  4570. _createClass(WritableStreamDefaultWriter, [{
  4571. key: 'abort',
  4572. value: function abort(reason) {
  4573. if (IsWritableStreamDefaultWriter(this) === false) {
  4574. return Promise.reject(defaultWriterBrandCheckException('abort'));
  4575. }
  4576. if (this._ownerWritableStream === undefined) {
  4577. return Promise.reject(defaultWriterLockException('abort'));
  4578. }
  4579. return WritableStreamDefaultWriterAbort(this, reason);
  4580. }
  4581. }, {
  4582. key: 'close',
  4583. value: function close() {
  4584. if (IsWritableStreamDefaultWriter(this) === false) {
  4585. return Promise.reject(defaultWriterBrandCheckException('close'));
  4586. }
  4587. var stream = this._ownerWritableStream;
  4588. if (stream === undefined) {
  4589. return Promise.reject(defaultWriterLockException('close'));
  4590. }
  4591. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  4592. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  4593. }
  4594. return WritableStreamDefaultWriterClose(this);
  4595. }
  4596. }, {
  4597. key: 'releaseLock',
  4598. value: function releaseLock() {
  4599. if (IsWritableStreamDefaultWriter(this) === false) {
  4600. throw defaultWriterBrandCheckException('releaseLock');
  4601. }
  4602. var stream = this._ownerWritableStream;
  4603. if (stream === undefined) {
  4604. return;
  4605. }
  4606. assert(stream._writer !== undefined);
  4607. WritableStreamDefaultWriterRelease(this);
  4608. }
  4609. }, {
  4610. key: 'write',
  4611. value: function write(chunk) {
  4612. if (IsWritableStreamDefaultWriter(this) === false) {
  4613. return Promise.reject(defaultWriterBrandCheckException('write'));
  4614. }
  4615. if (this._ownerWritableStream === undefined) {
  4616. return Promise.reject(defaultWriterLockException('write to'));
  4617. }
  4618. return WritableStreamDefaultWriterWrite(this, chunk);
  4619. }
  4620. }, {
  4621. key: 'closed',
  4622. get: function get() {
  4623. if (IsWritableStreamDefaultWriter(this) === false) {
  4624. return Promise.reject(defaultWriterBrandCheckException('closed'));
  4625. }
  4626. return this._closedPromise;
  4627. }
  4628. }, {
  4629. key: 'desiredSize',
  4630. get: function get() {
  4631. if (IsWritableStreamDefaultWriter(this) === false) {
  4632. throw defaultWriterBrandCheckException('desiredSize');
  4633. }
  4634. if (this._ownerWritableStream === undefined) {
  4635. throw defaultWriterLockException('desiredSize');
  4636. }
  4637. return WritableStreamDefaultWriterGetDesiredSize(this);
  4638. }
  4639. }, {
  4640. key: 'ready',
  4641. get: function get() {
  4642. if (IsWritableStreamDefaultWriter(this) === false) {
  4643. return Promise.reject(defaultWriterBrandCheckException('ready'));
  4644. }
  4645. return this._readyPromise;
  4646. }
  4647. }]);
  4648. return WritableStreamDefaultWriter;
  4649. }();
  4650. function IsWritableStreamDefaultWriter(x) {
  4651. if (!typeIsObject(x)) {
  4652. return false;
  4653. }
  4654. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  4655. return false;
  4656. }
  4657. return true;
  4658. }
  4659. function WritableStreamDefaultWriterAbort(writer, reason) {
  4660. var stream = writer._ownerWritableStream;
  4661. assert(stream !== undefined);
  4662. return WritableStreamAbort(stream, reason);
  4663. }
  4664. function WritableStreamDefaultWriterClose(writer) {
  4665. var stream = writer._ownerWritableStream;
  4666. assert(stream !== undefined);
  4667. var state = stream._state;
  4668. if (state === 'closed' || state === 'errored') {
  4669. return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed'));
  4670. }
  4671. assert(state === 'writable' || state === 'erroring');
  4672. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  4673. var promise = new Promise(function (resolve, reject) {
  4674. var closeRequest = {
  4675. _resolve: resolve,
  4676. _reject: reject
  4677. };
  4678. stream._closeRequest = closeRequest;
  4679. });
  4680. if (stream._backpressure === true && state === 'writable') {
  4681. defaultWriterReadyPromiseResolve(writer);
  4682. }
  4683. WritableStreamDefaultControllerClose(stream._writableStreamController);
  4684. return promise;
  4685. }
  4686. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  4687. var stream = writer._ownerWritableStream;
  4688. assert(stream !== undefined);
  4689. var state = stream._state;
  4690. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  4691. return Promise.resolve();
  4692. }
  4693. if (state === 'errored') {
  4694. return Promise.reject(stream._storedError);
  4695. }
  4696. assert(state === 'writable' || state === 'erroring');
  4697. return WritableStreamDefaultWriterClose(writer);
  4698. }
  4699. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  4700. if (writer._closedPromiseState === 'pending') {
  4701. defaultWriterClosedPromiseReject(writer, error);
  4702. } else {
  4703. defaultWriterClosedPromiseResetToRejected(writer, error);
  4704. }
  4705. writer._closedPromise.catch(function () {});
  4706. }
  4707. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  4708. if (writer._readyPromiseState === 'pending') {
  4709. defaultWriterReadyPromiseReject(writer, error);
  4710. } else {
  4711. defaultWriterReadyPromiseResetToRejected(writer, error);
  4712. }
  4713. writer._readyPromise.catch(function () {});
  4714. }
  4715. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  4716. var stream = writer._ownerWritableStream;
  4717. var state = stream._state;
  4718. if (state === 'errored' || state === 'erroring') {
  4719. return null;
  4720. }
  4721. if (state === 'closed') {
  4722. return 0;
  4723. }
  4724. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  4725. }
  4726. function WritableStreamDefaultWriterRelease(writer) {
  4727. var stream = writer._ownerWritableStream;
  4728. assert(stream !== undefined);
  4729. assert(stream._writer === writer);
  4730. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  4731. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  4732. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  4733. stream._writer = undefined;
  4734. writer._ownerWritableStream = undefined;
  4735. }
  4736. function WritableStreamDefaultWriterWrite(writer, chunk) {
  4737. var stream = writer._ownerWritableStream;
  4738. assert(stream !== undefined);
  4739. var controller = stream._writableStreamController;
  4740. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  4741. if (stream !== writer._ownerWritableStream) {
  4742. return Promise.reject(defaultWriterLockException('write to'));
  4743. }
  4744. var state = stream._state;
  4745. if (state === 'errored') {
  4746. return Promise.reject(stream._storedError);
  4747. }
  4748. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  4749. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  4750. }
  4751. if (state === 'erroring') {
  4752. return Promise.reject(stream._storedError);
  4753. }
  4754. assert(state === 'writable');
  4755. var promise = WritableStreamAddWriteRequest(stream);
  4756. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  4757. return promise;
  4758. }
  4759. var WritableStreamDefaultController = function () {
  4760. function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) {
  4761. _classCallCheck(this, WritableStreamDefaultController);
  4762. if (IsWritableStream(stream) === false) {
  4763. throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance');
  4764. }
  4765. if (stream._writableStreamController !== undefined) {
  4766. throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor');
  4767. }
  4768. this._controlledWritableStream = stream;
  4769. this._underlyingSink = underlyingSink;
  4770. this._queue = undefined;
  4771. this._queueTotalSize = undefined;
  4772. ResetQueue(this);
  4773. this._started = false;
  4774. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  4775. this._strategySize = normalizedStrategy.size;
  4776. this._strategyHWM = normalizedStrategy.highWaterMark;
  4777. var backpressure = WritableStreamDefaultControllerGetBackpressure(this);
  4778. WritableStreamUpdateBackpressure(stream, backpressure);
  4779. }
  4780. _createClass(WritableStreamDefaultController, [{
  4781. key: 'error',
  4782. value: function error(e) {
  4783. if (IsWritableStreamDefaultController(this) === false) {
  4784. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  4785. }
  4786. var state = this._controlledWritableStream._state;
  4787. if (state !== 'writable') {
  4788. return;
  4789. }
  4790. WritableStreamDefaultControllerError(this, e);
  4791. }
  4792. }, {
  4793. key: '__abortSteps',
  4794. value: function __abortSteps(reason) {
  4795. return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]);
  4796. }
  4797. }, {
  4798. key: '__errorSteps',
  4799. value: function __errorSteps() {
  4800. ResetQueue(this);
  4801. }
  4802. }, {
  4803. key: '__startSteps',
  4804. value: function __startSteps() {
  4805. var _this = this;
  4806. var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]);
  4807. var stream = this._controlledWritableStream;
  4808. Promise.resolve(startResult).then(function () {
  4809. assert(stream._state === 'writable' || stream._state === 'erroring');
  4810. _this._started = true;
  4811. WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this);
  4812. }, function (r) {
  4813. assert(stream._state === 'writable' || stream._state === 'erroring');
  4814. _this._started = true;
  4815. WritableStreamDealWithRejection(stream, r);
  4816. }).catch(rethrowAssertionErrorRejection);
  4817. }
  4818. }]);
  4819. return WritableStreamDefaultController;
  4820. }();
  4821. function WritableStreamDefaultControllerClose(controller) {
  4822. EnqueueValueWithSize(controller, 'close', 0);
  4823. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4824. }
  4825. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  4826. var strategySize = controller._strategySize;
  4827. if (strategySize === undefined) {
  4828. return 1;
  4829. }
  4830. try {
  4831. return strategySize(chunk);
  4832. } catch (chunkSizeE) {
  4833. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  4834. return 1;
  4835. }
  4836. }
  4837. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  4838. return controller._strategyHWM - controller._queueTotalSize;
  4839. }
  4840. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  4841. var writeRecord = {
  4842. chunk: chunk
  4843. };
  4844. try {
  4845. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  4846. } catch (enqueueE) {
  4847. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  4848. return;
  4849. }
  4850. var stream = controller._controlledWritableStream;
  4851. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  4852. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  4853. WritableStreamUpdateBackpressure(stream, backpressure);
  4854. }
  4855. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4856. }
  4857. function IsWritableStreamDefaultController(x) {
  4858. if (!typeIsObject(x)) {
  4859. return false;
  4860. }
  4861. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) {
  4862. return false;
  4863. }
  4864. return true;
  4865. }
  4866. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  4867. var stream = controller._controlledWritableStream;
  4868. if (controller._started === false) {
  4869. return;
  4870. }
  4871. if (stream._inFlightWriteRequest !== undefined) {
  4872. return;
  4873. }
  4874. var state = stream._state;
  4875. if (state === 'closed' || state === 'errored') {
  4876. return;
  4877. }
  4878. if (state === 'erroring') {
  4879. WritableStreamFinishErroring(stream);
  4880. return;
  4881. }
  4882. if (controller._queue.length === 0) {
  4883. return;
  4884. }
  4885. var writeRecord = PeekQueueValue(controller);
  4886. if (writeRecord === 'close') {
  4887. WritableStreamDefaultControllerProcessClose(controller);
  4888. } else {
  4889. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  4890. }
  4891. }
  4892. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  4893. if (controller._controlledWritableStream._state === 'writable') {
  4894. WritableStreamDefaultControllerError(controller, error);
  4895. }
  4896. }
  4897. function WritableStreamDefaultControllerProcessClose(controller) {
  4898. var stream = controller._controlledWritableStream;
  4899. WritableStreamMarkCloseRequestInFlight(stream);
  4900. DequeueValue(controller);
  4901. assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued');
  4902. var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []);
  4903. sinkClosePromise.then(function () {
  4904. WritableStreamFinishInFlightClose(stream);
  4905. }, function (reason) {
  4906. WritableStreamFinishInFlightCloseWithError(stream, reason);
  4907. }).catch(rethrowAssertionErrorRejection);
  4908. }
  4909. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  4910. var stream = controller._controlledWritableStream;
  4911. WritableStreamMarkFirstWriteRequestInFlight(stream);
  4912. var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]);
  4913. sinkWritePromise.then(function () {
  4914. WritableStreamFinishInFlightWrite(stream);
  4915. var state = stream._state;
  4916. assert(state === 'writable' || state === 'erroring');
  4917. DequeueValue(controller);
  4918. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  4919. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  4920. WritableStreamUpdateBackpressure(stream, backpressure);
  4921. }
  4922. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  4923. }, function (reason) {
  4924. WritableStreamFinishInFlightWriteWithError(stream, reason);
  4925. }).catch(rethrowAssertionErrorRejection);
  4926. }
  4927. function WritableStreamDefaultControllerGetBackpressure(controller) {
  4928. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  4929. return desiredSize <= 0;
  4930. }
  4931. function WritableStreamDefaultControllerError(controller, error) {
  4932. var stream = controller._controlledWritableStream;
  4933. assert(stream._state === 'writable');
  4934. WritableStreamStartErroring(stream, error);
  4935. }
  4936. function streamBrandCheckException(name) {
  4937. return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream');
  4938. }
  4939. function defaultWriterBrandCheckException(name) {
  4940. return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter');
  4941. }
  4942. function defaultWriterLockException(name) {
  4943. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  4944. }
  4945. function defaultWriterClosedPromiseInitialize(writer) {
  4946. writer._closedPromise = new Promise(function (resolve, reject) {
  4947. writer._closedPromise_resolve = resolve;
  4948. writer._closedPromise_reject = reject;
  4949. writer._closedPromiseState = 'pending';
  4950. });
  4951. }
  4952. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  4953. writer._closedPromise = Promise.reject(reason);
  4954. writer._closedPromise_resolve = undefined;
  4955. writer._closedPromise_reject = undefined;
  4956. writer._closedPromiseState = 'rejected';
  4957. }
  4958. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  4959. writer._closedPromise = Promise.resolve(undefined);
  4960. writer._closedPromise_resolve = undefined;
  4961. writer._closedPromise_reject = undefined;
  4962. writer._closedPromiseState = 'resolved';
  4963. }
  4964. function defaultWriterClosedPromiseReject(writer, reason) {
  4965. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  4966. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  4967. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  4968. writer._closedPromise_reject(reason);
  4969. writer._closedPromise_resolve = undefined;
  4970. writer._closedPromise_reject = undefined;
  4971. writer._closedPromiseState = 'rejected';
  4972. }
  4973. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  4974. assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined');
  4975. assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined');
  4976. assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending');
  4977. writer._closedPromise = Promise.reject(reason);
  4978. writer._closedPromiseState = 'rejected';
  4979. }
  4980. function defaultWriterClosedPromiseResolve(writer) {
  4981. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  4982. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  4983. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  4984. writer._closedPromise_resolve(undefined);
  4985. writer._closedPromise_resolve = undefined;
  4986. writer._closedPromise_reject = undefined;
  4987. writer._closedPromiseState = 'resolved';
  4988. }
  4989. function defaultWriterReadyPromiseInitialize(writer) {
  4990. writer._readyPromise = new Promise(function (resolve, reject) {
  4991. writer._readyPromise_resolve = resolve;
  4992. writer._readyPromise_reject = reject;
  4993. });
  4994. writer._readyPromiseState = 'pending';
  4995. }
  4996. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  4997. writer._readyPromise = Promise.reject(reason);
  4998. writer._readyPromise_resolve = undefined;
  4999. writer._readyPromise_reject = undefined;
  5000. writer._readyPromiseState = 'rejected';
  5001. }
  5002. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  5003. writer._readyPromise = Promise.resolve(undefined);
  5004. writer._readyPromise_resolve = undefined;
  5005. writer._readyPromise_reject = undefined;
  5006. writer._readyPromiseState = 'fulfilled';
  5007. }
  5008. function defaultWriterReadyPromiseReject(writer, reason) {
  5009. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  5010. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  5011. writer._readyPromise_reject(reason);
  5012. writer._readyPromise_resolve = undefined;
  5013. writer._readyPromise_reject = undefined;
  5014. writer._readyPromiseState = 'rejected';
  5015. }
  5016. function defaultWriterReadyPromiseReset(writer) {
  5017. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  5018. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  5019. writer._readyPromise = new Promise(function (resolve, reject) {
  5020. writer._readyPromise_resolve = resolve;
  5021. writer._readyPromise_reject = reject;
  5022. });
  5023. writer._readyPromiseState = 'pending';
  5024. }
  5025. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  5026. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  5027. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  5028. writer._readyPromise = Promise.reject(reason);
  5029. writer._readyPromiseState = 'rejected';
  5030. }
  5031. function defaultWriterReadyPromiseResolve(writer) {
  5032. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  5033. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  5034. writer._readyPromise_resolve(undefined);
  5035. writer._readyPromise_resolve = undefined;
  5036. writer._readyPromise_reject = undefined;
  5037. writer._readyPromiseState = 'fulfilled';
  5038. }
  5039. }, function (module, exports, __w_pdfjs_require__) {
  5040. "use strict";
  5041. var _require = __w_pdfjs_require__(0),
  5042. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber;
  5043. var _require2 = __w_pdfjs_require__(1),
  5044. assert = _require2.assert;
  5045. exports.DequeueValue = function (container) {
  5046. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  5047. assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
  5048. var pair = container._queue.shift();
  5049. container._queueTotalSize -= pair.size;
  5050. if (container._queueTotalSize < 0) {
  5051. container._queueTotalSize = 0;
  5052. }
  5053. return pair.value;
  5054. };
  5055. exports.EnqueueValueWithSize = function (container, value, size) {
  5056. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].');
  5057. size = Number(size);
  5058. if (!IsFiniteNonNegativeNumber(size)) {
  5059. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  5060. }
  5061. container._queue.push({
  5062. value: value,
  5063. size: size
  5064. });
  5065. container._queueTotalSize += size;
  5066. };
  5067. exports.PeekQueueValue = function (container) {
  5068. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  5069. assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.');
  5070. var pair = container._queue[0];
  5071. return pair.value;
  5072. };
  5073. exports.ResetQueue = function (container) {
  5074. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  5075. container._queue = [];
  5076. container._queueTotalSize = 0;
  5077. };
  5078. }, function (module, exports, __w_pdfjs_require__) {
  5079. "use strict";
  5080. var _createClass = function () {
  5081. function defineProperties(target, props) {
  5082. for (var i = 0; i < props.length; i++) {
  5083. var descriptor = props[i];
  5084. descriptor.enumerable = descriptor.enumerable || false;
  5085. descriptor.configurable = true;
  5086. if ("value" in descriptor) descriptor.writable = true;
  5087. Object.defineProperty(target, descriptor.key, descriptor);
  5088. }
  5089. }
  5090. return function (Constructor, protoProps, staticProps) {
  5091. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  5092. if (staticProps) defineProperties(Constructor, staticProps);
  5093. return Constructor;
  5094. };
  5095. }();
  5096. function _classCallCheck(instance, Constructor) {
  5097. if (!(instance instanceof Constructor)) {
  5098. throw new TypeError("Cannot call a class as a function");
  5099. }
  5100. }
  5101. var _require = __w_pdfjs_require__(0),
  5102. ArrayBufferCopy = _require.ArrayBufferCopy,
  5103. CreateIterResultObject = _require.CreateIterResultObject,
  5104. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber,
  5105. InvokeOrNoop = _require.InvokeOrNoop,
  5106. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  5107. TransferArrayBuffer = _require.TransferArrayBuffer,
  5108. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  5109. ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark;
  5110. var _require2 = __w_pdfjs_require__(0),
  5111. createArrayFromList = _require2.createArrayFromList,
  5112. createDataProperty = _require2.createDataProperty,
  5113. typeIsObject = _require2.typeIsObject;
  5114. var _require3 = __w_pdfjs_require__(1),
  5115. assert = _require3.assert,
  5116. rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection;
  5117. var _require4 = __w_pdfjs_require__(3),
  5118. DequeueValue = _require4.DequeueValue,
  5119. EnqueueValueWithSize = _require4.EnqueueValueWithSize,
  5120. ResetQueue = _require4.ResetQueue;
  5121. var _require5 = __w_pdfjs_require__(2),
  5122. AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter,
  5123. IsWritableStream = _require5.IsWritableStream,
  5124. IsWritableStreamLocked = _require5.IsWritableStreamLocked,
  5125. WritableStreamAbort = _require5.WritableStreamAbort,
  5126. WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation,
  5127. WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease,
  5128. WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite,
  5129. WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight;
  5130. var ReadableStream = function () {
  5131. function ReadableStream() {
  5132. var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5133. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  5134. size = _ref.size,
  5135. highWaterMark = _ref.highWaterMark;
  5136. _classCallCheck(this, ReadableStream);
  5137. this._state = 'readable';
  5138. this._reader = undefined;
  5139. this._storedError = undefined;
  5140. this._disturbed = false;
  5141. this._readableStreamController = undefined;
  5142. var type = underlyingSource.type;
  5143. var typeString = String(type);
  5144. if (typeString === 'bytes') {
  5145. if (highWaterMark === undefined) {
  5146. highWaterMark = 0;
  5147. }
  5148. this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark);
  5149. } else if (type === undefined) {
  5150. if (highWaterMark === undefined) {
  5151. highWaterMark = 1;
  5152. }
  5153. this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark);
  5154. } else {
  5155. throw new RangeError('Invalid type is specified');
  5156. }
  5157. }
  5158. _createClass(ReadableStream, [{
  5159. key: 'cancel',
  5160. value: function cancel(reason) {
  5161. if (IsReadableStream(this) === false) {
  5162. return Promise.reject(streamBrandCheckException('cancel'));
  5163. }
  5164. if (IsReadableStreamLocked(this) === true) {
  5165. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  5166. }
  5167. return ReadableStreamCancel(this, reason);
  5168. }
  5169. }, {
  5170. key: 'getReader',
  5171. value: function getReader() {
  5172. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  5173. mode = _ref2.mode;
  5174. if (IsReadableStream(this) === false) {
  5175. throw streamBrandCheckException('getReader');
  5176. }
  5177. if (mode === undefined) {
  5178. return AcquireReadableStreamDefaultReader(this);
  5179. }
  5180. mode = String(mode);
  5181. if (mode === 'byob') {
  5182. return AcquireReadableStreamBYOBReader(this);
  5183. }
  5184. throw new RangeError('Invalid mode is specified');
  5185. }
  5186. }, {
  5187. key: 'pipeThrough',
  5188. value: function pipeThrough(_ref3, options) {
  5189. var writable = _ref3.writable,
  5190. readable = _ref3.readable;
  5191. var promise = this.pipeTo(writable, options);
  5192. ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise);
  5193. return readable;
  5194. }
  5195. }, {
  5196. key: 'pipeTo',
  5197. value: function pipeTo(dest) {
  5198. var _this = this;
  5199. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  5200. preventClose = _ref4.preventClose,
  5201. preventAbort = _ref4.preventAbort,
  5202. preventCancel = _ref4.preventCancel;
  5203. if (IsReadableStream(this) === false) {
  5204. return Promise.reject(streamBrandCheckException('pipeTo'));
  5205. }
  5206. if (IsWritableStream(dest) === false) {
  5207. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  5208. }
  5209. preventClose = Boolean(preventClose);
  5210. preventAbort = Boolean(preventAbort);
  5211. preventCancel = Boolean(preventCancel);
  5212. if (IsReadableStreamLocked(this) === true) {
  5213. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  5214. }
  5215. if (IsWritableStreamLocked(dest) === true) {
  5216. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  5217. }
  5218. var reader = AcquireReadableStreamDefaultReader(this);
  5219. var writer = AcquireWritableStreamDefaultWriter(dest);
  5220. var shuttingDown = false;
  5221. var currentWrite = Promise.resolve();
  5222. return new Promise(function (resolve, reject) {
  5223. function pipeLoop() {
  5224. currentWrite = Promise.resolve();
  5225. if (shuttingDown === true) {
  5226. return Promise.resolve();
  5227. }
  5228. return writer._readyPromise.then(function () {
  5229. return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) {
  5230. var value = _ref5.value,
  5231. done = _ref5.done;
  5232. if (done === true) {
  5233. return;
  5234. }
  5235. currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(function () {});
  5236. });
  5237. }).then(pipeLoop);
  5238. }
  5239. isOrBecomesErrored(_this, reader._closedPromise, function (storedError) {
  5240. if (preventAbort === false) {
  5241. shutdownWithAction(function () {
  5242. return WritableStreamAbort(dest, storedError);
  5243. }, true, storedError);
  5244. } else {
  5245. shutdown(true, storedError);
  5246. }
  5247. });
  5248. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  5249. if (preventCancel === false) {
  5250. shutdownWithAction(function () {
  5251. return ReadableStreamCancel(_this, storedError);
  5252. }, true, storedError);
  5253. } else {
  5254. shutdown(true, storedError);
  5255. }
  5256. });
  5257. isOrBecomesClosed(_this, reader._closedPromise, function () {
  5258. if (preventClose === false) {
  5259. shutdownWithAction(function () {
  5260. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  5261. });
  5262. } else {
  5263. shutdown();
  5264. }
  5265. });
  5266. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  5267. var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it');
  5268. if (preventCancel === false) {
  5269. shutdownWithAction(function () {
  5270. return ReadableStreamCancel(_this, destClosed);
  5271. }, true, destClosed);
  5272. } else {
  5273. shutdown(true, destClosed);
  5274. }
  5275. }
  5276. pipeLoop().catch(function (err) {
  5277. currentWrite = Promise.resolve();
  5278. rethrowAssertionErrorRejection(err);
  5279. });
  5280. function waitForWritesToFinish() {
  5281. var oldCurrentWrite = currentWrite;
  5282. return currentWrite.then(function () {
  5283. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  5284. });
  5285. }
  5286. function isOrBecomesErrored(stream, promise, action) {
  5287. if (stream._state === 'errored') {
  5288. action(stream._storedError);
  5289. } else {
  5290. promise.catch(action).catch(rethrowAssertionErrorRejection);
  5291. }
  5292. }
  5293. function isOrBecomesClosed(stream, promise, action) {
  5294. if (stream._state === 'closed') {
  5295. action();
  5296. } else {
  5297. promise.then(action).catch(rethrowAssertionErrorRejection);
  5298. }
  5299. }
  5300. function shutdownWithAction(action, originalIsError, originalError) {
  5301. if (shuttingDown === true) {
  5302. return;
  5303. }
  5304. shuttingDown = true;
  5305. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  5306. waitForWritesToFinish().then(doTheRest);
  5307. } else {
  5308. doTheRest();
  5309. }
  5310. function doTheRest() {
  5311. action().then(function () {
  5312. return finalize(originalIsError, originalError);
  5313. }, function (newError) {
  5314. return finalize(true, newError);
  5315. }).catch(rethrowAssertionErrorRejection);
  5316. }
  5317. }
  5318. function shutdown(isError, error) {
  5319. if (shuttingDown === true) {
  5320. return;
  5321. }
  5322. shuttingDown = true;
  5323. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  5324. waitForWritesToFinish().then(function () {
  5325. return finalize(isError, error);
  5326. }).catch(rethrowAssertionErrorRejection);
  5327. } else {
  5328. finalize(isError, error);
  5329. }
  5330. }
  5331. function finalize(isError, error) {
  5332. WritableStreamDefaultWriterRelease(writer);
  5333. ReadableStreamReaderGenericRelease(reader);
  5334. if (isError) {
  5335. reject(error);
  5336. } else {
  5337. resolve(undefined);
  5338. }
  5339. }
  5340. });
  5341. }
  5342. }, {
  5343. key: 'tee',
  5344. value: function tee() {
  5345. if (IsReadableStream(this) === false) {
  5346. throw streamBrandCheckException('tee');
  5347. }
  5348. var branches = ReadableStreamTee(this, false);
  5349. return createArrayFromList(branches);
  5350. }
  5351. }, {
  5352. key: 'locked',
  5353. get: function get() {
  5354. if (IsReadableStream(this) === false) {
  5355. throw streamBrandCheckException('locked');
  5356. }
  5357. return IsReadableStreamLocked(this);
  5358. }
  5359. }]);
  5360. return ReadableStream;
  5361. }();
  5362. module.exports = {
  5363. ReadableStream: ReadableStream,
  5364. IsReadableStreamDisturbed: IsReadableStreamDisturbed,
  5365. ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose,
  5366. ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue,
  5367. ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError,
  5368. ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize
  5369. };
  5370. function AcquireReadableStreamBYOBReader(stream) {
  5371. return new ReadableStreamBYOBReader(stream);
  5372. }
  5373. function AcquireReadableStreamDefaultReader(stream) {
  5374. return new ReadableStreamDefaultReader(stream);
  5375. }
  5376. function IsReadableStream(x) {
  5377. if (!typeIsObject(x)) {
  5378. return false;
  5379. }
  5380. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  5381. return false;
  5382. }
  5383. return true;
  5384. }
  5385. function IsReadableStreamDisturbed(stream) {
  5386. assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams');
  5387. return stream._disturbed;
  5388. }
  5389. function IsReadableStreamLocked(stream) {
  5390. assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams');
  5391. if (stream._reader === undefined) {
  5392. return false;
  5393. }
  5394. return true;
  5395. }
  5396. function ReadableStreamTee(stream, cloneForBranch2) {
  5397. assert(IsReadableStream(stream) === true);
  5398. assert(typeof cloneForBranch2 === 'boolean');
  5399. var reader = AcquireReadableStreamDefaultReader(stream);
  5400. var teeState = {
  5401. closedOrErrored: false,
  5402. canceled1: false,
  5403. canceled2: false,
  5404. reason1: undefined,
  5405. reason2: undefined
  5406. };
  5407. teeState.promise = new Promise(function (resolve) {
  5408. teeState._resolve = resolve;
  5409. });
  5410. var pull = create_ReadableStreamTeePullFunction();
  5411. pull._reader = reader;
  5412. pull._teeState = teeState;
  5413. pull._cloneForBranch2 = cloneForBranch2;
  5414. var cancel1 = create_ReadableStreamTeeBranch1CancelFunction();
  5415. cancel1._stream = stream;
  5416. cancel1._teeState = teeState;
  5417. var cancel2 = create_ReadableStreamTeeBranch2CancelFunction();
  5418. cancel2._stream = stream;
  5419. cancel2._teeState = teeState;
  5420. var underlyingSource1 = Object.create(Object.prototype);
  5421. createDataProperty(underlyingSource1, 'pull', pull);
  5422. createDataProperty(underlyingSource1, 'cancel', cancel1);
  5423. var branch1Stream = new ReadableStream(underlyingSource1);
  5424. var underlyingSource2 = Object.create(Object.prototype);
  5425. createDataProperty(underlyingSource2, 'pull', pull);
  5426. createDataProperty(underlyingSource2, 'cancel', cancel2);
  5427. var branch2Stream = new ReadableStream(underlyingSource2);
  5428. pull._branch1 = branch1Stream._readableStreamController;
  5429. pull._branch2 = branch2Stream._readableStreamController;
  5430. reader._closedPromise.catch(function (r) {
  5431. if (teeState.closedOrErrored === true) {
  5432. return;
  5433. }
  5434. ReadableStreamDefaultControllerError(pull._branch1, r);
  5435. ReadableStreamDefaultControllerError(pull._branch2, r);
  5436. teeState.closedOrErrored = true;
  5437. });
  5438. return [branch1Stream, branch2Stream];
  5439. }
  5440. function create_ReadableStreamTeePullFunction() {
  5441. function f() {
  5442. var reader = f._reader,
  5443. branch1 = f._branch1,
  5444. branch2 = f._branch2,
  5445. teeState = f._teeState;
  5446. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  5447. assert(typeIsObject(result));
  5448. var value = result.value;
  5449. var done = result.done;
  5450. assert(typeof done === 'boolean');
  5451. if (done === true && teeState.closedOrErrored === false) {
  5452. if (teeState.canceled1 === false) {
  5453. ReadableStreamDefaultControllerClose(branch1);
  5454. }
  5455. if (teeState.canceled2 === false) {
  5456. ReadableStreamDefaultControllerClose(branch2);
  5457. }
  5458. teeState.closedOrErrored = true;
  5459. }
  5460. if (teeState.closedOrErrored === true) {
  5461. return;
  5462. }
  5463. var value1 = value;
  5464. var value2 = value;
  5465. if (teeState.canceled1 === false) {
  5466. ReadableStreamDefaultControllerEnqueue(branch1, value1);
  5467. }
  5468. if (teeState.canceled2 === false) {
  5469. ReadableStreamDefaultControllerEnqueue(branch2, value2);
  5470. }
  5471. });
  5472. }
  5473. return f;
  5474. }
  5475. function create_ReadableStreamTeeBranch1CancelFunction() {
  5476. function f(reason) {
  5477. var stream = f._stream,
  5478. teeState = f._teeState;
  5479. teeState.canceled1 = true;
  5480. teeState.reason1 = reason;
  5481. if (teeState.canceled2 === true) {
  5482. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  5483. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  5484. teeState._resolve(cancelResult);
  5485. }
  5486. return teeState.promise;
  5487. }
  5488. return f;
  5489. }
  5490. function create_ReadableStreamTeeBranch2CancelFunction() {
  5491. function f(reason) {
  5492. var stream = f._stream,
  5493. teeState = f._teeState;
  5494. teeState.canceled2 = true;
  5495. teeState.reason2 = reason;
  5496. if (teeState.canceled1 === true) {
  5497. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  5498. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  5499. teeState._resolve(cancelResult);
  5500. }
  5501. return teeState.promise;
  5502. }
  5503. return f;
  5504. }
  5505. function ReadableStreamAddReadIntoRequest(stream) {
  5506. assert(IsReadableStreamBYOBReader(stream._reader) === true);
  5507. assert(stream._state === 'readable' || stream._state === 'closed');
  5508. var promise = new Promise(function (resolve, reject) {
  5509. var readIntoRequest = {
  5510. _resolve: resolve,
  5511. _reject: reject
  5512. };
  5513. stream._reader._readIntoRequests.push(readIntoRequest);
  5514. });
  5515. return promise;
  5516. }
  5517. function ReadableStreamAddReadRequest(stream) {
  5518. assert(IsReadableStreamDefaultReader(stream._reader) === true);
  5519. assert(stream._state === 'readable');
  5520. var promise = new Promise(function (resolve, reject) {
  5521. var readRequest = {
  5522. _resolve: resolve,
  5523. _reject: reject
  5524. };
  5525. stream._reader._readRequests.push(readRequest);
  5526. });
  5527. return promise;
  5528. }
  5529. function ReadableStreamCancel(stream, reason) {
  5530. stream._disturbed = true;
  5531. if (stream._state === 'closed') {
  5532. return Promise.resolve(undefined);
  5533. }
  5534. if (stream._state === 'errored') {
  5535. return Promise.reject(stream._storedError);
  5536. }
  5537. ReadableStreamClose(stream);
  5538. var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason);
  5539. return sourceCancelPromise.then(function () {
  5540. return undefined;
  5541. });
  5542. }
  5543. function ReadableStreamClose(stream) {
  5544. assert(stream._state === 'readable');
  5545. stream._state = 'closed';
  5546. var reader = stream._reader;
  5547. if (reader === undefined) {
  5548. return undefined;
  5549. }
  5550. if (IsReadableStreamDefaultReader(reader) === true) {
  5551. for (var i = 0; i < reader._readRequests.length; i++) {
  5552. var _resolve = reader._readRequests[i]._resolve;
  5553. _resolve(CreateIterResultObject(undefined, true));
  5554. }
  5555. reader._readRequests = [];
  5556. }
  5557. defaultReaderClosedPromiseResolve(reader);
  5558. return undefined;
  5559. }
  5560. function ReadableStreamError(stream, e) {
  5561. assert(IsReadableStream(stream) === true, 'stream must be ReadableStream');
  5562. assert(stream._state === 'readable', 'state must be readable');
  5563. stream._state = 'errored';
  5564. stream._storedError = e;
  5565. var reader = stream._reader;
  5566. if (reader === undefined) {
  5567. return undefined;
  5568. }
  5569. if (IsReadableStreamDefaultReader(reader) === true) {
  5570. for (var i = 0; i < reader._readRequests.length; i++) {
  5571. var readRequest = reader._readRequests[i];
  5572. readRequest._reject(e);
  5573. }
  5574. reader._readRequests = [];
  5575. } else {
  5576. assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader');
  5577. for (var _i = 0; _i < reader._readIntoRequests.length; _i++) {
  5578. var readIntoRequest = reader._readIntoRequests[_i];
  5579. readIntoRequest._reject(e);
  5580. }
  5581. reader._readIntoRequests = [];
  5582. }
  5583. defaultReaderClosedPromiseReject(reader, e);
  5584. reader._closedPromise.catch(function () {});
  5585. }
  5586. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  5587. var reader = stream._reader;
  5588. assert(reader._readIntoRequests.length > 0);
  5589. var readIntoRequest = reader._readIntoRequests.shift();
  5590. readIntoRequest._resolve(CreateIterResultObject(chunk, done));
  5591. }
  5592. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  5593. var reader = stream._reader;
  5594. assert(reader._readRequests.length > 0);
  5595. var readRequest = reader._readRequests.shift();
  5596. readRequest._resolve(CreateIterResultObject(chunk, done));
  5597. }
  5598. function ReadableStreamGetNumReadIntoRequests(stream) {
  5599. return stream._reader._readIntoRequests.length;
  5600. }
  5601. function ReadableStreamGetNumReadRequests(stream) {
  5602. return stream._reader._readRequests.length;
  5603. }
  5604. function ReadableStreamHasBYOBReader(stream) {
  5605. var reader = stream._reader;
  5606. if (reader === undefined) {
  5607. return false;
  5608. }
  5609. if (IsReadableStreamBYOBReader(reader) === false) {
  5610. return false;
  5611. }
  5612. return true;
  5613. }
  5614. function ReadableStreamHasDefaultReader(stream) {
  5615. var reader = stream._reader;
  5616. if (reader === undefined) {
  5617. return false;
  5618. }
  5619. if (IsReadableStreamDefaultReader(reader) === false) {
  5620. return false;
  5621. }
  5622. return true;
  5623. }
  5624. var ReadableStreamDefaultReader = function () {
  5625. function ReadableStreamDefaultReader(stream) {
  5626. _classCallCheck(this, ReadableStreamDefaultReader);
  5627. if (IsReadableStream(stream) === false) {
  5628. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  5629. }
  5630. if (IsReadableStreamLocked(stream) === true) {
  5631. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  5632. }
  5633. ReadableStreamReaderGenericInitialize(this, stream);
  5634. this._readRequests = [];
  5635. }
  5636. _createClass(ReadableStreamDefaultReader, [{
  5637. key: 'cancel',
  5638. value: function cancel(reason) {
  5639. if (IsReadableStreamDefaultReader(this) === false) {
  5640. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  5641. }
  5642. if (this._ownerReadableStream === undefined) {
  5643. return Promise.reject(readerLockException('cancel'));
  5644. }
  5645. return ReadableStreamReaderGenericCancel(this, reason);
  5646. }
  5647. }, {
  5648. key: 'read',
  5649. value: function read() {
  5650. if (IsReadableStreamDefaultReader(this) === false) {
  5651. return Promise.reject(defaultReaderBrandCheckException('read'));
  5652. }
  5653. if (this._ownerReadableStream === undefined) {
  5654. return Promise.reject(readerLockException('read from'));
  5655. }
  5656. return ReadableStreamDefaultReaderRead(this);
  5657. }
  5658. }, {
  5659. key: 'releaseLock',
  5660. value: function releaseLock() {
  5661. if (IsReadableStreamDefaultReader(this) === false) {
  5662. throw defaultReaderBrandCheckException('releaseLock');
  5663. }
  5664. if (this._ownerReadableStream === undefined) {
  5665. return;
  5666. }
  5667. if (this._readRequests.length > 0) {
  5668. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  5669. }
  5670. ReadableStreamReaderGenericRelease(this);
  5671. }
  5672. }, {
  5673. key: 'closed',
  5674. get: function get() {
  5675. if (IsReadableStreamDefaultReader(this) === false) {
  5676. return Promise.reject(defaultReaderBrandCheckException('closed'));
  5677. }
  5678. return this._closedPromise;
  5679. }
  5680. }]);
  5681. return ReadableStreamDefaultReader;
  5682. }();
  5683. var ReadableStreamBYOBReader = function () {
  5684. function ReadableStreamBYOBReader(stream) {
  5685. _classCallCheck(this, ReadableStreamBYOBReader);
  5686. if (!IsReadableStream(stream)) {
  5687. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  5688. }
  5689. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  5690. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  5691. }
  5692. if (IsReadableStreamLocked(stream)) {
  5693. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  5694. }
  5695. ReadableStreamReaderGenericInitialize(this, stream);
  5696. this._readIntoRequests = [];
  5697. }
  5698. _createClass(ReadableStreamBYOBReader, [{
  5699. key: 'cancel',
  5700. value: function cancel(reason) {
  5701. if (!IsReadableStreamBYOBReader(this)) {
  5702. return Promise.reject(byobReaderBrandCheckException('cancel'));
  5703. }
  5704. if (this._ownerReadableStream === undefined) {
  5705. return Promise.reject(readerLockException('cancel'));
  5706. }
  5707. return ReadableStreamReaderGenericCancel(this, reason);
  5708. }
  5709. }, {
  5710. key: 'read',
  5711. value: function read(view) {
  5712. if (!IsReadableStreamBYOBReader(this)) {
  5713. return Promise.reject(byobReaderBrandCheckException('read'));
  5714. }
  5715. if (this._ownerReadableStream === undefined) {
  5716. return Promise.reject(readerLockException('read from'));
  5717. }
  5718. if (!ArrayBuffer.isView(view)) {
  5719. return Promise.reject(new TypeError('view must be an array buffer view'));
  5720. }
  5721. if (view.byteLength === 0) {
  5722. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  5723. }
  5724. return ReadableStreamBYOBReaderRead(this, view);
  5725. }
  5726. }, {
  5727. key: 'releaseLock',
  5728. value: function releaseLock() {
  5729. if (!IsReadableStreamBYOBReader(this)) {
  5730. throw byobReaderBrandCheckException('releaseLock');
  5731. }
  5732. if (this._ownerReadableStream === undefined) {
  5733. return;
  5734. }
  5735. if (this._readIntoRequests.length > 0) {
  5736. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  5737. }
  5738. ReadableStreamReaderGenericRelease(this);
  5739. }
  5740. }, {
  5741. key: 'closed',
  5742. get: function get() {
  5743. if (!IsReadableStreamBYOBReader(this)) {
  5744. return Promise.reject(byobReaderBrandCheckException('closed'));
  5745. }
  5746. return this._closedPromise;
  5747. }
  5748. }]);
  5749. return ReadableStreamBYOBReader;
  5750. }();
  5751. function IsReadableStreamBYOBReader(x) {
  5752. if (!typeIsObject(x)) {
  5753. return false;
  5754. }
  5755. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  5756. return false;
  5757. }
  5758. return true;
  5759. }
  5760. function IsReadableStreamDefaultReader(x) {
  5761. if (!typeIsObject(x)) {
  5762. return false;
  5763. }
  5764. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  5765. return false;
  5766. }
  5767. return true;
  5768. }
  5769. function ReadableStreamReaderGenericInitialize(reader, stream) {
  5770. reader._ownerReadableStream = stream;
  5771. stream._reader = reader;
  5772. if (stream._state === 'readable') {
  5773. defaultReaderClosedPromiseInitialize(reader);
  5774. } else if (stream._state === 'closed') {
  5775. defaultReaderClosedPromiseInitializeAsResolved(reader);
  5776. } else {
  5777. assert(stream._state === 'errored', 'state must be errored');
  5778. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  5779. reader._closedPromise.catch(function () {});
  5780. }
  5781. }
  5782. function ReadableStreamReaderGenericCancel(reader, reason) {
  5783. var stream = reader._ownerReadableStream;
  5784. assert(stream !== undefined);
  5785. return ReadableStreamCancel(stream, reason);
  5786. }
  5787. function ReadableStreamReaderGenericRelease(reader) {
  5788. assert(reader._ownerReadableStream !== undefined);
  5789. assert(reader._ownerReadableStream._reader === reader);
  5790. if (reader._ownerReadableStream._state === 'readable') {
  5791. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  5792. } else {
  5793. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  5794. }
  5795. reader._closedPromise.catch(function () {});
  5796. reader._ownerReadableStream._reader = undefined;
  5797. reader._ownerReadableStream = undefined;
  5798. }
  5799. function ReadableStreamBYOBReaderRead(reader, view) {
  5800. var stream = reader._ownerReadableStream;
  5801. assert(stream !== undefined);
  5802. stream._disturbed = true;
  5803. if (stream._state === 'errored') {
  5804. return Promise.reject(stream._storedError);
  5805. }
  5806. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  5807. }
  5808. function ReadableStreamDefaultReaderRead(reader) {
  5809. var stream = reader._ownerReadableStream;
  5810. assert(stream !== undefined);
  5811. stream._disturbed = true;
  5812. if (stream._state === 'closed') {
  5813. return Promise.resolve(CreateIterResultObject(undefined, true));
  5814. }
  5815. if (stream._state === 'errored') {
  5816. return Promise.reject(stream._storedError);
  5817. }
  5818. assert(stream._state === 'readable');
  5819. return stream._readableStreamController.__pullSteps();
  5820. }
  5821. var ReadableStreamDefaultController = function () {
  5822. function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) {
  5823. _classCallCheck(this, ReadableStreamDefaultController);
  5824. if (IsReadableStream(stream) === false) {
  5825. throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');
  5826. }
  5827. if (stream._readableStreamController !== undefined) {
  5828. throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');
  5829. }
  5830. this._controlledReadableStream = stream;
  5831. this._underlyingSource = underlyingSource;
  5832. this._queue = undefined;
  5833. this._queueTotalSize = undefined;
  5834. ResetQueue(this);
  5835. this._started = false;
  5836. this._closeRequested = false;
  5837. this._pullAgain = false;
  5838. this._pulling = false;
  5839. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  5840. this._strategySize = normalizedStrategy.size;
  5841. this._strategyHWM = normalizedStrategy.highWaterMark;
  5842. var controller = this;
  5843. var startResult = InvokeOrNoop(underlyingSource, 'start', [this]);
  5844. Promise.resolve(startResult).then(function () {
  5845. controller._started = true;
  5846. assert(controller._pulling === false);
  5847. assert(controller._pullAgain === false);
  5848. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5849. }, function (r) {
  5850. ReadableStreamDefaultControllerErrorIfNeeded(controller, r);
  5851. }).catch(rethrowAssertionErrorRejection);
  5852. }
  5853. _createClass(ReadableStreamDefaultController, [{
  5854. key: 'close',
  5855. value: function close() {
  5856. if (IsReadableStreamDefaultController(this) === false) {
  5857. throw defaultControllerBrandCheckException('close');
  5858. }
  5859. if (this._closeRequested === true) {
  5860. throw new TypeError('The stream has already been closed; do not close it again!');
  5861. }
  5862. var state = this._controlledReadableStream._state;
  5863. if (state !== 'readable') {
  5864. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  5865. }
  5866. ReadableStreamDefaultControllerClose(this);
  5867. }
  5868. }, {
  5869. key: 'enqueue',
  5870. value: function enqueue(chunk) {
  5871. if (IsReadableStreamDefaultController(this) === false) {
  5872. throw defaultControllerBrandCheckException('enqueue');
  5873. }
  5874. if (this._closeRequested === true) {
  5875. throw new TypeError('stream is closed or draining');
  5876. }
  5877. var state = this._controlledReadableStream._state;
  5878. if (state !== 'readable') {
  5879. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  5880. }
  5881. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  5882. }
  5883. }, {
  5884. key: 'error',
  5885. value: function error(e) {
  5886. if (IsReadableStreamDefaultController(this) === false) {
  5887. throw defaultControllerBrandCheckException('error');
  5888. }
  5889. var stream = this._controlledReadableStream;
  5890. if (stream._state !== 'readable') {
  5891. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  5892. }
  5893. ReadableStreamDefaultControllerError(this, e);
  5894. }
  5895. }, {
  5896. key: '__cancelSteps',
  5897. value: function __cancelSteps(reason) {
  5898. ResetQueue(this);
  5899. return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);
  5900. }
  5901. }, {
  5902. key: '__pullSteps',
  5903. value: function __pullSteps() {
  5904. var stream = this._controlledReadableStream;
  5905. if (this._queue.length > 0) {
  5906. var chunk = DequeueValue(this);
  5907. if (this._closeRequested === true && this._queue.length === 0) {
  5908. ReadableStreamClose(stream);
  5909. } else {
  5910. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  5911. }
  5912. return Promise.resolve(CreateIterResultObject(chunk, false));
  5913. }
  5914. var pendingPromise = ReadableStreamAddReadRequest(stream);
  5915. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  5916. return pendingPromise;
  5917. }
  5918. }, {
  5919. key: 'desiredSize',
  5920. get: function get() {
  5921. if (IsReadableStreamDefaultController(this) === false) {
  5922. throw defaultControllerBrandCheckException('desiredSize');
  5923. }
  5924. return ReadableStreamDefaultControllerGetDesiredSize(this);
  5925. }
  5926. }]);
  5927. return ReadableStreamDefaultController;
  5928. }();
  5929. function IsReadableStreamDefaultController(x) {
  5930. if (!typeIsObject(x)) {
  5931. return false;
  5932. }
  5933. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {
  5934. return false;
  5935. }
  5936. return true;
  5937. }
  5938. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  5939. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  5940. if (shouldPull === false) {
  5941. return undefined;
  5942. }
  5943. if (controller._pulling === true) {
  5944. controller._pullAgain = true;
  5945. return undefined;
  5946. }
  5947. assert(controller._pullAgain === false);
  5948. controller._pulling = true;
  5949. var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);
  5950. pullPromise.then(function () {
  5951. controller._pulling = false;
  5952. if (controller._pullAgain === true) {
  5953. controller._pullAgain = false;
  5954. return ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  5955. }
  5956. return undefined;
  5957. }, function (e) {
  5958. ReadableStreamDefaultControllerErrorIfNeeded(controller, e);
  5959. }).catch(rethrowAssertionErrorRejection);
  5960. return undefined;
  5961. }
  5962. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  5963. var stream = controller._controlledReadableStream;
  5964. if (stream._state === 'closed' || stream._state === 'errored') {
  5965. return false;
  5966. }
  5967. if (controller._closeRequested === true) {
  5968. return false;
  5969. }
  5970. if (controller._started === false) {
  5971. return false;
  5972. }
  5973. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  5974. return true;
  5975. }
  5976. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  5977. if (desiredSize > 0) {
  5978. return true;
  5979. }
  5980. return false;
  5981. }
  5982. function ReadableStreamDefaultControllerClose(controller) {
  5983. var stream = controller._controlledReadableStream;
  5984. assert(controller._closeRequested === false);
  5985. assert(stream._state === 'readable');
  5986. controller._closeRequested = true;
  5987. if (controller._queue.length === 0) {
  5988. ReadableStreamClose(stream);
  5989. }
  5990. }
  5991. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  5992. var stream = controller._controlledReadableStream;
  5993. assert(controller._closeRequested === false);
  5994. assert(stream._state === 'readable');
  5995. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  5996. ReadableStreamFulfillReadRequest(stream, chunk, false);
  5997. } else {
  5998. var chunkSize = 1;
  5999. if (controller._strategySize !== undefined) {
  6000. var strategySize = controller._strategySize;
  6001. try {
  6002. chunkSize = strategySize(chunk);
  6003. } catch (chunkSizeE) {
  6004. ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  6005. throw chunkSizeE;
  6006. }
  6007. }
  6008. try {
  6009. EnqueueValueWithSize(controller, chunk, chunkSize);
  6010. } catch (enqueueE) {
  6011. ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  6012. throw enqueueE;
  6013. }
  6014. }
  6015. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  6016. return undefined;
  6017. }
  6018. function ReadableStreamDefaultControllerError(controller, e) {
  6019. var stream = controller._controlledReadableStream;
  6020. assert(stream._state === 'readable');
  6021. ResetQueue(controller);
  6022. ReadableStreamError(stream, e);
  6023. }
  6024. function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {
  6025. if (controller._controlledReadableStream._state === 'readable') {
  6026. ReadableStreamDefaultControllerError(controller, e);
  6027. }
  6028. }
  6029. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  6030. var stream = controller._controlledReadableStream;
  6031. var state = stream._state;
  6032. if (state === 'errored') {
  6033. return null;
  6034. }
  6035. if (state === 'closed') {
  6036. return 0;
  6037. }
  6038. return controller._strategyHWM - controller._queueTotalSize;
  6039. }
  6040. var ReadableStreamBYOBRequest = function () {
  6041. function ReadableStreamBYOBRequest(controller, view) {
  6042. _classCallCheck(this, ReadableStreamBYOBRequest);
  6043. this._associatedReadableByteStreamController = controller;
  6044. this._view = view;
  6045. }
  6046. _createClass(ReadableStreamBYOBRequest, [{
  6047. key: 'respond',
  6048. value: function respond(bytesWritten) {
  6049. if (IsReadableStreamBYOBRequest(this) === false) {
  6050. throw byobRequestBrandCheckException('respond');
  6051. }
  6052. if (this._associatedReadableByteStreamController === undefined) {
  6053. throw new TypeError('This BYOB request has been invalidated');
  6054. }
  6055. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  6056. }
  6057. }, {
  6058. key: 'respondWithNewView',
  6059. value: function respondWithNewView(view) {
  6060. if (IsReadableStreamBYOBRequest(this) === false) {
  6061. throw byobRequestBrandCheckException('respond');
  6062. }
  6063. if (this._associatedReadableByteStreamController === undefined) {
  6064. throw new TypeError('This BYOB request has been invalidated');
  6065. }
  6066. if (!ArrayBuffer.isView(view)) {
  6067. throw new TypeError('You can only respond with array buffer views');
  6068. }
  6069. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  6070. }
  6071. }, {
  6072. key: 'view',
  6073. get: function get() {
  6074. return this._view;
  6075. }
  6076. }]);
  6077. return ReadableStreamBYOBRequest;
  6078. }();
  6079. var ReadableByteStreamController = function () {
  6080. function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) {
  6081. _classCallCheck(this, ReadableByteStreamController);
  6082. if (IsReadableStream(stream) === false) {
  6083. throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source');
  6084. }
  6085. if (stream._readableStreamController !== undefined) {
  6086. throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source');
  6087. }
  6088. this._controlledReadableStream = stream;
  6089. this._underlyingByteSource = underlyingByteSource;
  6090. this._pullAgain = false;
  6091. this._pulling = false;
  6092. ReadableByteStreamControllerClearPendingPullIntos(this);
  6093. this._queue = this._queueTotalSize = undefined;
  6094. ResetQueue(this);
  6095. this._closeRequested = false;
  6096. this._started = false;
  6097. this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  6098. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  6099. if (autoAllocateChunkSize !== undefined) {
  6100. if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  6101. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  6102. }
  6103. }
  6104. this._autoAllocateChunkSize = autoAllocateChunkSize;
  6105. this._pendingPullIntos = [];
  6106. var controller = this;
  6107. var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);
  6108. Promise.resolve(startResult).then(function () {
  6109. controller._started = true;
  6110. assert(controller._pulling === false);
  6111. assert(controller._pullAgain === false);
  6112. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6113. }, function (r) {
  6114. if (stream._state === 'readable') {
  6115. ReadableByteStreamControllerError(controller, r);
  6116. }
  6117. }).catch(rethrowAssertionErrorRejection);
  6118. }
  6119. _createClass(ReadableByteStreamController, [{
  6120. key: 'close',
  6121. value: function close() {
  6122. if (IsReadableByteStreamController(this) === false) {
  6123. throw byteStreamControllerBrandCheckException('close');
  6124. }
  6125. if (this._closeRequested === true) {
  6126. throw new TypeError('The stream has already been closed; do not close it again!');
  6127. }
  6128. var state = this._controlledReadableStream._state;
  6129. if (state !== 'readable') {
  6130. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  6131. }
  6132. ReadableByteStreamControllerClose(this);
  6133. }
  6134. }, {
  6135. key: 'enqueue',
  6136. value: function enqueue(chunk) {
  6137. if (IsReadableByteStreamController(this) === false) {
  6138. throw byteStreamControllerBrandCheckException('enqueue');
  6139. }
  6140. if (this._closeRequested === true) {
  6141. throw new TypeError('stream is closed or draining');
  6142. }
  6143. var state = this._controlledReadableStream._state;
  6144. if (state !== 'readable') {
  6145. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  6146. }
  6147. if (!ArrayBuffer.isView(chunk)) {
  6148. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  6149. }
  6150. ReadableByteStreamControllerEnqueue(this, chunk);
  6151. }
  6152. }, {
  6153. key: 'error',
  6154. value: function error(e) {
  6155. if (IsReadableByteStreamController(this) === false) {
  6156. throw byteStreamControllerBrandCheckException('error');
  6157. }
  6158. var stream = this._controlledReadableStream;
  6159. if (stream._state !== 'readable') {
  6160. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  6161. }
  6162. ReadableByteStreamControllerError(this, e);
  6163. }
  6164. }, {
  6165. key: '__cancelSteps',
  6166. value: function __cancelSteps(reason) {
  6167. if (this._pendingPullIntos.length > 0) {
  6168. var firstDescriptor = this._pendingPullIntos[0];
  6169. firstDescriptor.bytesFilled = 0;
  6170. }
  6171. ResetQueue(this);
  6172. return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);
  6173. }
  6174. }, {
  6175. key: '__pullSteps',
  6176. value: function __pullSteps() {
  6177. var stream = this._controlledReadableStream;
  6178. assert(ReadableStreamHasDefaultReader(stream) === true);
  6179. if (this._queueTotalSize > 0) {
  6180. assert(ReadableStreamGetNumReadRequests(stream) === 0);
  6181. var entry = this._queue.shift();
  6182. this._queueTotalSize -= entry.byteLength;
  6183. ReadableByteStreamControllerHandleQueueDrain(this);
  6184. var view = void 0;
  6185. try {
  6186. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  6187. } catch (viewE) {
  6188. return Promise.reject(viewE);
  6189. }
  6190. return Promise.resolve(CreateIterResultObject(view, false));
  6191. }
  6192. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  6193. if (autoAllocateChunkSize !== undefined) {
  6194. var buffer = void 0;
  6195. try {
  6196. buffer = new ArrayBuffer(autoAllocateChunkSize);
  6197. } catch (bufferE) {
  6198. return Promise.reject(bufferE);
  6199. }
  6200. var pullIntoDescriptor = {
  6201. buffer: buffer,
  6202. byteOffset: 0,
  6203. byteLength: autoAllocateChunkSize,
  6204. bytesFilled: 0,
  6205. elementSize: 1,
  6206. ctor: Uint8Array,
  6207. readerType: 'default'
  6208. };
  6209. this._pendingPullIntos.push(pullIntoDescriptor);
  6210. }
  6211. var promise = ReadableStreamAddReadRequest(stream);
  6212. ReadableByteStreamControllerCallPullIfNeeded(this);
  6213. return promise;
  6214. }
  6215. }, {
  6216. key: 'byobRequest',
  6217. get: function get() {
  6218. if (IsReadableByteStreamController(this) === false) {
  6219. throw byteStreamControllerBrandCheckException('byobRequest');
  6220. }
  6221. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  6222. var firstDescriptor = this._pendingPullIntos[0];
  6223. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  6224. this._byobRequest = new ReadableStreamBYOBRequest(this, view);
  6225. }
  6226. return this._byobRequest;
  6227. }
  6228. }, {
  6229. key: 'desiredSize',
  6230. get: function get() {
  6231. if (IsReadableByteStreamController(this) === false) {
  6232. throw byteStreamControllerBrandCheckException('desiredSize');
  6233. }
  6234. return ReadableByteStreamControllerGetDesiredSize(this);
  6235. }
  6236. }]);
  6237. return ReadableByteStreamController;
  6238. }();
  6239. function IsReadableByteStreamController(x) {
  6240. if (!typeIsObject(x)) {
  6241. return false;
  6242. }
  6243. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {
  6244. return false;
  6245. }
  6246. return true;
  6247. }
  6248. function IsReadableStreamBYOBRequest(x) {
  6249. if (!typeIsObject(x)) {
  6250. return false;
  6251. }
  6252. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  6253. return false;
  6254. }
  6255. return true;
  6256. }
  6257. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  6258. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  6259. if (shouldPull === false) {
  6260. return undefined;
  6261. }
  6262. if (controller._pulling === true) {
  6263. controller._pullAgain = true;
  6264. return undefined;
  6265. }
  6266. assert(controller._pullAgain === false);
  6267. controller._pulling = true;
  6268. var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);
  6269. pullPromise.then(function () {
  6270. controller._pulling = false;
  6271. if (controller._pullAgain === true) {
  6272. controller._pullAgain = false;
  6273. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6274. }
  6275. }, function (e) {
  6276. if (controller._controlledReadableStream._state === 'readable') {
  6277. ReadableByteStreamControllerError(controller, e);
  6278. }
  6279. }).catch(rethrowAssertionErrorRejection);
  6280. return undefined;
  6281. }
  6282. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  6283. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6284. controller._pendingPullIntos = [];
  6285. }
  6286. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  6287. assert(stream._state !== 'errored', 'state must not be errored');
  6288. var done = false;
  6289. if (stream._state === 'closed') {
  6290. assert(pullIntoDescriptor.bytesFilled === 0);
  6291. done = true;
  6292. }
  6293. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  6294. if (pullIntoDescriptor.readerType === 'default') {
  6295. ReadableStreamFulfillReadRequest(stream, filledView, done);
  6296. } else {
  6297. assert(pullIntoDescriptor.readerType === 'byob');
  6298. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  6299. }
  6300. }
  6301. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  6302. var bytesFilled = pullIntoDescriptor.bytesFilled;
  6303. var elementSize = pullIntoDescriptor.elementSize;
  6304. assert(bytesFilled <= pullIntoDescriptor.byteLength);
  6305. assert(bytesFilled % elementSize === 0);
  6306. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  6307. }
  6308. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  6309. controller._queue.push({
  6310. buffer: buffer,
  6311. byteOffset: byteOffset,
  6312. byteLength: byteLength
  6313. });
  6314. controller._queueTotalSize += byteLength;
  6315. }
  6316. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  6317. var elementSize = pullIntoDescriptor.elementSize;
  6318. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  6319. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  6320. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  6321. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  6322. var totalBytesToCopyRemaining = maxBytesToCopy;
  6323. var ready = false;
  6324. if (maxAlignedBytes > currentAlignedBytes) {
  6325. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  6326. ready = true;
  6327. }
  6328. var queue = controller._queue;
  6329. while (totalBytesToCopyRemaining > 0) {
  6330. var headOfQueue = queue[0];
  6331. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  6332. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  6333. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  6334. if (headOfQueue.byteLength === bytesToCopy) {
  6335. queue.shift();
  6336. } else {
  6337. headOfQueue.byteOffset += bytesToCopy;
  6338. headOfQueue.byteLength -= bytesToCopy;
  6339. }
  6340. controller._queueTotalSize -= bytesToCopy;
  6341. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  6342. totalBytesToCopyRemaining -= bytesToCopy;
  6343. }
  6344. if (ready === false) {
  6345. assert(controller._queueTotalSize === 0, 'queue must be empty');
  6346. assert(pullIntoDescriptor.bytesFilled > 0);
  6347. assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
  6348. }
  6349. return ready;
  6350. }
  6351. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  6352. assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);
  6353. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6354. pullIntoDescriptor.bytesFilled += size;
  6355. }
  6356. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  6357. assert(controller._controlledReadableStream._state === 'readable');
  6358. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  6359. ReadableStreamClose(controller._controlledReadableStream);
  6360. } else {
  6361. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6362. }
  6363. }
  6364. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  6365. if (controller._byobRequest === undefined) {
  6366. return;
  6367. }
  6368. controller._byobRequest._associatedReadableByteStreamController = undefined;
  6369. controller._byobRequest._view = undefined;
  6370. controller._byobRequest = undefined;
  6371. }
  6372. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  6373. assert(controller._closeRequested === false);
  6374. while (controller._pendingPullIntos.length > 0) {
  6375. if (controller._queueTotalSize === 0) {
  6376. return;
  6377. }
  6378. var pullIntoDescriptor = controller._pendingPullIntos[0];
  6379. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  6380. ReadableByteStreamControllerShiftPendingPullInto(controller);
  6381. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  6382. }
  6383. }
  6384. }
  6385. function ReadableByteStreamControllerPullInto(controller, view) {
  6386. var stream = controller._controlledReadableStream;
  6387. var elementSize = 1;
  6388. if (view.constructor !== DataView) {
  6389. elementSize = view.constructor.BYTES_PER_ELEMENT;
  6390. }
  6391. var ctor = view.constructor;
  6392. var pullIntoDescriptor = {
  6393. buffer: view.buffer,
  6394. byteOffset: view.byteOffset,
  6395. byteLength: view.byteLength,
  6396. bytesFilled: 0,
  6397. elementSize: elementSize,
  6398. ctor: ctor,
  6399. readerType: 'byob'
  6400. };
  6401. if (controller._pendingPullIntos.length > 0) {
  6402. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6403. controller._pendingPullIntos.push(pullIntoDescriptor);
  6404. return ReadableStreamAddReadIntoRequest(stream);
  6405. }
  6406. if (stream._state === 'closed') {
  6407. var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  6408. return Promise.resolve(CreateIterResultObject(emptyView, true));
  6409. }
  6410. if (controller._queueTotalSize > 0) {
  6411. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  6412. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  6413. ReadableByteStreamControllerHandleQueueDrain(controller);
  6414. return Promise.resolve(CreateIterResultObject(filledView, false));
  6415. }
  6416. if (controller._closeRequested === true) {
  6417. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  6418. ReadableByteStreamControllerError(controller, e);
  6419. return Promise.reject(e);
  6420. }
  6421. }
  6422. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6423. controller._pendingPullIntos.push(pullIntoDescriptor);
  6424. var promise = ReadableStreamAddReadIntoRequest(stream);
  6425. ReadableByteStreamControllerCallPullIfNeeded(controller);
  6426. return promise;
  6427. }
  6428. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  6429. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  6430. assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');
  6431. var stream = controller._controlledReadableStream;
  6432. if (ReadableStreamHasBYOBReader(stream) === true) {
  6433. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  6434. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  6435. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  6436. }
  6437. }
  6438. }
  6439. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  6440. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  6441. throw new RangeError('bytesWritten out of range');
  6442. }
  6443. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  6444. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  6445. return;
  6446. }
  6447. ReadableByteStreamControllerShiftPendingPullInto(controller);
  6448. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  6449. if (remainderSize > 0) {
  6450. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  6451. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  6452. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  6453. }
  6454. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  6455. pullIntoDescriptor.bytesFilled -= remainderSize;
  6456. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  6457. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  6458. }
  6459. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  6460. var firstDescriptor = controller._pendingPullIntos[0];
  6461. var stream = controller._controlledReadableStream;
  6462. if (stream._state === 'closed') {
  6463. if (bytesWritten !== 0) {
  6464. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  6465. }
  6466. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  6467. } else {
  6468. assert(stream._state === 'readable');
  6469. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  6470. }
  6471. }
  6472. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  6473. var descriptor = controller._pendingPullIntos.shift();
  6474. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  6475. return descriptor;
  6476. }
  6477. function ReadableByteStreamControllerShouldCallPull(controller) {
  6478. var stream = controller._controlledReadableStream;
  6479. if (stream._state !== 'readable') {
  6480. return false;
  6481. }
  6482. if (controller._closeRequested === true) {
  6483. return false;
  6484. }
  6485. if (controller._started === false) {
  6486. return false;
  6487. }
  6488. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  6489. return true;
  6490. }
  6491. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  6492. return true;
  6493. }
  6494. if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
  6495. return true;
  6496. }
  6497. return false;
  6498. }
  6499. function ReadableByteStreamControllerClose(controller) {
  6500. var stream = controller._controlledReadableStream;
  6501. assert(controller._closeRequested === false);
  6502. assert(stream._state === 'readable');
  6503. if (controller._queueTotalSize > 0) {
  6504. controller._closeRequested = true;
  6505. return;
  6506. }
  6507. if (controller._pendingPullIntos.length > 0) {
  6508. var firstPendingPullInto = controller._pendingPullIntos[0];
  6509. if (firstPendingPullInto.bytesFilled > 0) {
  6510. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  6511. ReadableByteStreamControllerError(controller, e);
  6512. throw e;
  6513. }
  6514. }
  6515. ReadableStreamClose(stream);
  6516. }
  6517. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  6518. var stream = controller._controlledReadableStream;
  6519. assert(controller._closeRequested === false);
  6520. assert(stream._state === 'readable');
  6521. var buffer = chunk.buffer;
  6522. var byteOffset = chunk.byteOffset;
  6523. var byteLength = chunk.byteLength;
  6524. var transferredBuffer = TransferArrayBuffer(buffer);
  6525. if (ReadableStreamHasDefaultReader(stream) === true) {
  6526. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  6527. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6528. } else {
  6529. assert(controller._queue.length === 0);
  6530. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  6531. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  6532. }
  6533. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  6534. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6535. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  6536. } else {
  6537. assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');
  6538. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  6539. }
  6540. }
  6541. function ReadableByteStreamControllerError(controller, e) {
  6542. var stream = controller._controlledReadableStream;
  6543. assert(stream._state === 'readable');
  6544. ReadableByteStreamControllerClearPendingPullIntos(controller);
  6545. ResetQueue(controller);
  6546. ReadableStreamError(stream, e);
  6547. }
  6548. function ReadableByteStreamControllerGetDesiredSize(controller) {
  6549. var stream = controller._controlledReadableStream;
  6550. var state = stream._state;
  6551. if (state === 'errored') {
  6552. return null;
  6553. }
  6554. if (state === 'closed') {
  6555. return 0;
  6556. }
  6557. return controller._strategyHWM - controller._queueTotalSize;
  6558. }
  6559. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  6560. bytesWritten = Number(bytesWritten);
  6561. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  6562. throw new RangeError('bytesWritten must be a finite');
  6563. }
  6564. assert(controller._pendingPullIntos.length > 0);
  6565. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  6566. }
  6567. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  6568. assert(controller._pendingPullIntos.length > 0);
  6569. var firstDescriptor = controller._pendingPullIntos[0];
  6570. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  6571. throw new RangeError('The region specified by view does not match byobRequest');
  6572. }
  6573. if (firstDescriptor.byteLength !== view.byteLength) {
  6574. throw new RangeError('The buffer of view has different capacity than byobRequest');
  6575. }
  6576. firstDescriptor.buffer = view.buffer;
  6577. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  6578. }
  6579. function streamBrandCheckException(name) {
  6580. return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream');
  6581. }
  6582. function readerLockException(name) {
  6583. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  6584. }
  6585. function defaultReaderBrandCheckException(name) {
  6586. return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader');
  6587. }
  6588. function defaultReaderClosedPromiseInitialize(reader) {
  6589. reader._closedPromise = new Promise(function (resolve, reject) {
  6590. reader._closedPromise_resolve = resolve;
  6591. reader._closedPromise_reject = reject;
  6592. });
  6593. }
  6594. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  6595. reader._closedPromise = Promise.reject(reason);
  6596. reader._closedPromise_resolve = undefined;
  6597. reader._closedPromise_reject = undefined;
  6598. }
  6599. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  6600. reader._closedPromise = Promise.resolve(undefined);
  6601. reader._closedPromise_resolve = undefined;
  6602. reader._closedPromise_reject = undefined;
  6603. }
  6604. function defaultReaderClosedPromiseReject(reader, reason) {
  6605. assert(reader._closedPromise_resolve !== undefined);
  6606. assert(reader._closedPromise_reject !== undefined);
  6607. reader._closedPromise_reject(reason);
  6608. reader._closedPromise_resolve = undefined;
  6609. reader._closedPromise_reject = undefined;
  6610. }
  6611. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  6612. assert(reader._closedPromise_resolve === undefined);
  6613. assert(reader._closedPromise_reject === undefined);
  6614. reader._closedPromise = Promise.reject(reason);
  6615. }
  6616. function defaultReaderClosedPromiseResolve(reader) {
  6617. assert(reader._closedPromise_resolve !== undefined);
  6618. assert(reader._closedPromise_reject !== undefined);
  6619. reader._closedPromise_resolve(undefined);
  6620. reader._closedPromise_resolve = undefined;
  6621. reader._closedPromise_reject = undefined;
  6622. }
  6623. function byobReaderBrandCheckException(name) {
  6624. return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader');
  6625. }
  6626. function defaultControllerBrandCheckException(name) {
  6627. return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController');
  6628. }
  6629. function byobRequestBrandCheckException(name) {
  6630. return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest');
  6631. }
  6632. function byteStreamControllerBrandCheckException(name) {
  6633. return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController');
  6634. }
  6635. function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) {
  6636. try {
  6637. Promise.prototype.then.call(promise, undefined, function () {});
  6638. } catch (e) {}
  6639. }
  6640. }, function (module, exports, __w_pdfjs_require__) {
  6641. "use strict";
  6642. var transformStream = __w_pdfjs_require__(6);
  6643. var readableStream = __w_pdfjs_require__(4);
  6644. var writableStream = __w_pdfjs_require__(2);
  6645. exports.TransformStream = transformStream.TransformStream;
  6646. exports.ReadableStream = readableStream.ReadableStream;
  6647. exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed;
  6648. exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose;
  6649. exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue;
  6650. exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError;
  6651. exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize;
  6652. exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter;
  6653. exports.IsWritableStream = writableStream.IsWritableStream;
  6654. exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked;
  6655. exports.WritableStream = writableStream.WritableStream;
  6656. exports.WritableStreamAbort = writableStream.WritableStreamAbort;
  6657. exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError;
  6658. exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation;
  6659. exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease;
  6660. exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite;
  6661. }, function (module, exports, __w_pdfjs_require__) {
  6662. "use strict";
  6663. var _createClass = function () {
  6664. function defineProperties(target, props) {
  6665. for (var i = 0; i < props.length; i++) {
  6666. var descriptor = props[i];
  6667. descriptor.enumerable = descriptor.enumerable || false;
  6668. descriptor.configurable = true;
  6669. if ("value" in descriptor) descriptor.writable = true;
  6670. Object.defineProperty(target, descriptor.key, descriptor);
  6671. }
  6672. }
  6673. return function (Constructor, protoProps, staticProps) {
  6674. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  6675. if (staticProps) defineProperties(Constructor, staticProps);
  6676. return Constructor;
  6677. };
  6678. }();
  6679. function _classCallCheck(instance, Constructor) {
  6680. if (!(instance instanceof Constructor)) {
  6681. throw new TypeError("Cannot call a class as a function");
  6682. }
  6683. }
  6684. var _require = __w_pdfjs_require__(1),
  6685. assert = _require.assert;
  6686. var _require2 = __w_pdfjs_require__(0),
  6687. InvokeOrNoop = _require2.InvokeOrNoop,
  6688. PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback,
  6689. PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop,
  6690. typeIsObject = _require2.typeIsObject;
  6691. var _require3 = __w_pdfjs_require__(4),
  6692. ReadableStream = _require3.ReadableStream,
  6693. ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose,
  6694. ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue,
  6695. ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError,
  6696. ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize;
  6697. var _require4 = __w_pdfjs_require__(2),
  6698. WritableStream = _require4.WritableStream,
  6699. WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError;
  6700. function TransformStreamCloseReadable(transformStream) {
  6701. if (transformStream._errored === true) {
  6702. throw new TypeError('TransformStream is already errored');
  6703. }
  6704. if (transformStream._readableClosed === true) {
  6705. throw new TypeError('Readable side is already closed');
  6706. }
  6707. TransformStreamCloseReadableInternal(transformStream);
  6708. }
  6709. function TransformStreamEnqueueToReadable(transformStream, chunk) {
  6710. if (transformStream._errored === true) {
  6711. throw new TypeError('TransformStream is already errored');
  6712. }
  6713. if (transformStream._readableClosed === true) {
  6714. throw new TypeError('Readable side is already closed');
  6715. }
  6716. var controller = transformStream._readableController;
  6717. try {
  6718. ReadableStreamDefaultControllerEnqueue(controller, chunk);
  6719. } catch (e) {
  6720. transformStream._readableClosed = true;
  6721. TransformStreamErrorIfNeeded(transformStream, e);
  6722. throw transformStream._storedError;
  6723. }
  6724. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  6725. var maybeBackpressure = desiredSize <= 0;
  6726. if (maybeBackpressure === true && transformStream._backpressure === false) {
  6727. TransformStreamSetBackpressure(transformStream, true);
  6728. }
  6729. }
  6730. function TransformStreamError(transformStream, e) {
  6731. if (transformStream._errored === true) {
  6732. throw new TypeError('TransformStream is already errored');
  6733. }
  6734. TransformStreamErrorInternal(transformStream, e);
  6735. }
  6736. function TransformStreamCloseReadableInternal(transformStream) {
  6737. assert(transformStream._errored === false);
  6738. assert(transformStream._readableClosed === false);
  6739. try {
  6740. ReadableStreamDefaultControllerClose(transformStream._readableController);
  6741. } catch (e) {
  6742. assert(false);
  6743. }
  6744. transformStream._readableClosed = true;
  6745. }
  6746. function TransformStreamErrorIfNeeded(transformStream, e) {
  6747. if (transformStream._errored === false) {
  6748. TransformStreamErrorInternal(transformStream, e);
  6749. }
  6750. }
  6751. function TransformStreamErrorInternal(transformStream, e) {
  6752. assert(transformStream._errored === false);
  6753. transformStream._errored = true;
  6754. transformStream._storedError = e;
  6755. if (transformStream._writableDone === false) {
  6756. WritableStreamDefaultControllerError(transformStream._writableController, e);
  6757. }
  6758. if (transformStream._readableClosed === false) {
  6759. ReadableStreamDefaultControllerError(transformStream._readableController, e);
  6760. }
  6761. }
  6762. function TransformStreamReadableReadyPromise(transformStream) {
  6763. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6764. if (transformStream._backpressure === false) {
  6765. return Promise.resolve();
  6766. }
  6767. assert(transformStream._backpressure === true, '_backpressure should have been initialized');
  6768. return transformStream._backpressureChangePromise;
  6769. }
  6770. function TransformStreamSetBackpressure(transformStream, backpressure) {
  6771. assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed');
  6772. if (transformStream._backpressureChangePromise !== undefined) {
  6773. transformStream._backpressureChangePromise_resolve(backpressure);
  6774. }
  6775. transformStream._backpressureChangePromise = new Promise(function (resolve) {
  6776. transformStream._backpressureChangePromise_resolve = resolve;
  6777. });
  6778. transformStream._backpressureChangePromise.then(function (resolution) {
  6779. assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed');
  6780. });
  6781. transformStream._backpressure = backpressure;
  6782. }
  6783. function TransformStreamDefaultTransform(chunk, transformStreamController) {
  6784. var transformStream = transformStreamController._controlledTransformStream;
  6785. TransformStreamEnqueueToReadable(transformStream, chunk);
  6786. return Promise.resolve();
  6787. }
  6788. function TransformStreamTransform(transformStream, chunk) {
  6789. assert(transformStream._errored === false);
  6790. assert(transformStream._transforming === false);
  6791. assert(transformStream._backpressure === false);
  6792. transformStream._transforming = true;
  6793. var transformer = transformStream._transformer;
  6794. var controller = transformStream._transformStreamController;
  6795. var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]);
  6796. return transformPromise.then(function () {
  6797. transformStream._transforming = false;
  6798. return TransformStreamReadableReadyPromise(transformStream);
  6799. }, function (e) {
  6800. TransformStreamErrorIfNeeded(transformStream, e);
  6801. return Promise.reject(e);
  6802. });
  6803. }
  6804. function IsTransformStreamDefaultController(x) {
  6805. if (!typeIsObject(x)) {
  6806. return false;
  6807. }
  6808. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  6809. return false;
  6810. }
  6811. return true;
  6812. }
  6813. function IsTransformStream(x) {
  6814. if (!typeIsObject(x)) {
  6815. return false;
  6816. }
  6817. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  6818. return false;
  6819. }
  6820. return true;
  6821. }
  6822. var TransformStreamSink = function () {
  6823. function TransformStreamSink(transformStream, startPromise) {
  6824. _classCallCheck(this, TransformStreamSink);
  6825. this._transformStream = transformStream;
  6826. this._startPromise = startPromise;
  6827. }
  6828. _createClass(TransformStreamSink, [{
  6829. key: 'start',
  6830. value: function start(c) {
  6831. var transformStream = this._transformStream;
  6832. transformStream._writableController = c;
  6833. return this._startPromise.then(function () {
  6834. return TransformStreamReadableReadyPromise(transformStream);
  6835. });
  6836. }
  6837. }, {
  6838. key: 'write',
  6839. value: function write(chunk) {
  6840. var transformStream = this._transformStream;
  6841. return TransformStreamTransform(transformStream, chunk);
  6842. }
  6843. }, {
  6844. key: 'abort',
  6845. value: function abort() {
  6846. var transformStream = this._transformStream;
  6847. transformStream._writableDone = true;
  6848. TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted'));
  6849. }
  6850. }, {
  6851. key: 'close',
  6852. value: function close() {
  6853. var transformStream = this._transformStream;
  6854. assert(transformStream._transforming === false);
  6855. transformStream._writableDone = true;
  6856. var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]);
  6857. return flushPromise.then(function () {
  6858. if (transformStream._errored === true) {
  6859. return Promise.reject(transformStream._storedError);
  6860. }
  6861. if (transformStream._readableClosed === false) {
  6862. TransformStreamCloseReadableInternal(transformStream);
  6863. }
  6864. return Promise.resolve();
  6865. }).catch(function (r) {
  6866. TransformStreamErrorIfNeeded(transformStream, r);
  6867. return Promise.reject(transformStream._storedError);
  6868. });
  6869. }
  6870. }]);
  6871. return TransformStreamSink;
  6872. }();
  6873. var TransformStreamSource = function () {
  6874. function TransformStreamSource(transformStream, startPromise) {
  6875. _classCallCheck(this, TransformStreamSource);
  6876. this._transformStream = transformStream;
  6877. this._startPromise = startPromise;
  6878. }
  6879. _createClass(TransformStreamSource, [{
  6880. key: 'start',
  6881. value: function start(c) {
  6882. var transformStream = this._transformStream;
  6883. transformStream._readableController = c;
  6884. return this._startPromise.then(function () {
  6885. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6886. if (transformStream._backpressure === true) {
  6887. return Promise.resolve();
  6888. }
  6889. assert(transformStream._backpressure === false, '_backpressure should have been initialized');
  6890. return transformStream._backpressureChangePromise;
  6891. });
  6892. }
  6893. }, {
  6894. key: 'pull',
  6895. value: function pull() {
  6896. var transformStream = this._transformStream;
  6897. assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false');
  6898. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  6899. TransformStreamSetBackpressure(transformStream, false);
  6900. return transformStream._backpressureChangePromise;
  6901. }
  6902. }, {
  6903. key: 'cancel',
  6904. value: function cancel() {
  6905. var transformStream = this._transformStream;
  6906. transformStream._readableClosed = true;
  6907. TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled'));
  6908. }
  6909. }]);
  6910. return TransformStreamSource;
  6911. }();
  6912. var TransformStreamDefaultController = function () {
  6913. function TransformStreamDefaultController(transformStream) {
  6914. _classCallCheck(this, TransformStreamDefaultController);
  6915. if (IsTransformStream(transformStream) === false) {
  6916. throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance');
  6917. }
  6918. if (transformStream._transformStreamController !== undefined) {
  6919. throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor');
  6920. }
  6921. this._controlledTransformStream = transformStream;
  6922. }
  6923. _createClass(TransformStreamDefaultController, [{
  6924. key: 'enqueue',
  6925. value: function enqueue(chunk) {
  6926. if (IsTransformStreamDefaultController(this) === false) {
  6927. throw defaultControllerBrandCheckException('enqueue');
  6928. }
  6929. TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk);
  6930. }
  6931. }, {
  6932. key: 'close',
  6933. value: function close() {
  6934. if (IsTransformStreamDefaultController(this) === false) {
  6935. throw defaultControllerBrandCheckException('close');
  6936. }
  6937. TransformStreamCloseReadable(this._controlledTransformStream);
  6938. }
  6939. }, {
  6940. key: 'error',
  6941. value: function error(reason) {
  6942. if (IsTransformStreamDefaultController(this) === false) {
  6943. throw defaultControllerBrandCheckException('error');
  6944. }
  6945. TransformStreamError(this._controlledTransformStream, reason);
  6946. }
  6947. }, {
  6948. key: 'desiredSize',
  6949. get: function get() {
  6950. if (IsTransformStreamDefaultController(this) === false) {
  6951. throw defaultControllerBrandCheckException('desiredSize');
  6952. }
  6953. var transformStream = this._controlledTransformStream;
  6954. var readableController = transformStream._readableController;
  6955. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  6956. }
  6957. }]);
  6958. return TransformStreamDefaultController;
  6959. }();
  6960. var TransformStream = function () {
  6961. function TransformStream() {
  6962. var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  6963. _classCallCheck(this, TransformStream);
  6964. this._transformer = transformer;
  6965. var readableStrategy = transformer.readableStrategy,
  6966. writableStrategy = transformer.writableStrategy;
  6967. this._transforming = false;
  6968. this._errored = false;
  6969. this._storedError = undefined;
  6970. this._writableController = undefined;
  6971. this._readableController = undefined;
  6972. this._transformStreamController = undefined;
  6973. this._writableDone = false;
  6974. this._readableClosed = false;
  6975. this._backpressure = undefined;
  6976. this._backpressureChangePromise = undefined;
  6977. this._backpressureChangePromise_resolve = undefined;
  6978. this._transformStreamController = new TransformStreamDefaultController(this);
  6979. var startPromise_resolve = void 0;
  6980. var startPromise = new Promise(function (resolve) {
  6981. startPromise_resolve = resolve;
  6982. });
  6983. var source = new TransformStreamSource(this, startPromise);
  6984. this._readable = new ReadableStream(source, readableStrategy);
  6985. var sink = new TransformStreamSink(this, startPromise);
  6986. this._writable = new WritableStream(sink, writableStrategy);
  6987. assert(this._writableController !== undefined);
  6988. assert(this._readableController !== undefined);
  6989. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController);
  6990. TransformStreamSetBackpressure(this, desiredSize <= 0);
  6991. var transformStream = this;
  6992. var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]);
  6993. startPromise_resolve(startResult);
  6994. startPromise.catch(function (e) {
  6995. if (transformStream._errored === false) {
  6996. transformStream._errored = true;
  6997. transformStream._storedError = e;
  6998. }
  6999. });
  7000. }
  7001. _createClass(TransformStream, [{
  7002. key: 'readable',
  7003. get: function get() {
  7004. if (IsTransformStream(this) === false) {
  7005. throw streamBrandCheckException('readable');
  7006. }
  7007. return this._readable;
  7008. }
  7009. }, {
  7010. key: 'writable',
  7011. get: function get() {
  7012. if (IsTransformStream(this) === false) {
  7013. throw streamBrandCheckException('writable');
  7014. }
  7015. return this._writable;
  7016. }
  7017. }]);
  7018. return TransformStream;
  7019. }();
  7020. module.exports = {
  7021. TransformStream: TransformStream
  7022. };
  7023. function defaultControllerBrandCheckException(name) {
  7024. return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController');
  7025. }
  7026. function streamBrandCheckException(name) {
  7027. return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream');
  7028. }
  7029. }, function (module, exports, __w_pdfjs_require__) {
  7030. module.exports = __w_pdfjs_require__(5);
  7031. }]));
  7032. /***/ }),
  7033. /* 144 */
  7034. /***/ (function(module, exports, __w_pdfjs_require__) {
  7035. "use strict";
  7036. function _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); }
  7037. {
  7038. var isURLSupported = false;
  7039. try {
  7040. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  7041. var u = new URL('b', 'http://a');
  7042. u.pathname = 'c%20d';
  7043. isURLSupported = u.href === 'http://a/c%20d';
  7044. }
  7045. } catch (ex) {}
  7046. if (isURLSupported) {
  7047. exports.URL = URL;
  7048. } else {
  7049. var PolyfillURL = __w_pdfjs_require__(145).URL;
  7050. var OriginalURL = __w_pdfjs_require__(3).URL;
  7051. if (OriginalURL) {
  7052. PolyfillURL.createObjectURL = function (blob) {
  7053. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  7054. };
  7055. PolyfillURL.revokeObjectURL = function (url) {
  7056. OriginalURL.revokeObjectURL(url);
  7057. };
  7058. }
  7059. exports.URL = PolyfillURL;
  7060. }
  7061. }
  7062. /***/ }),
  7063. /* 145 */
  7064. /***/ (function(module, exports, __w_pdfjs_require__) {
  7065. "use strict";
  7066. (function URLConstructorClosure() {
  7067. 'use strict';
  7068. var relative = Object.create(null);
  7069. relative['ftp'] = 21;
  7070. relative['file'] = 0;
  7071. relative['gopher'] = 70;
  7072. relative['http'] = 80;
  7073. relative['https'] = 443;
  7074. relative['ws'] = 80;
  7075. relative['wss'] = 443;
  7076. var relativePathDotMapping = Object.create(null);
  7077. relativePathDotMapping['%2e'] = '.';
  7078. relativePathDotMapping['.%2e'] = '..';
  7079. relativePathDotMapping['%2e.'] = '..';
  7080. relativePathDotMapping['%2e%2e'] = '..';
  7081. function isRelativeScheme(scheme) {
  7082. return relative[scheme] !== undefined;
  7083. }
  7084. function invalid() {
  7085. clear.call(this);
  7086. this._isInvalid = true;
  7087. }
  7088. function IDNAToASCII(h) {
  7089. if (h === '') {
  7090. invalid.call(this);
  7091. }
  7092. return h.toLowerCase();
  7093. }
  7094. function percentEscape(c) {
  7095. var unicode = c.charCodeAt(0);
  7096. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) {
  7097. return c;
  7098. }
  7099. return encodeURIComponent(c);
  7100. }
  7101. function percentEscapeQuery(c) {
  7102. var unicode = c.charCodeAt(0);
  7103. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) {
  7104. return c;
  7105. }
  7106. return encodeURIComponent(c);
  7107. }
  7108. var EOF,
  7109. ALPHA = /[a-zA-Z]/,
  7110. ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  7111. function parse(input, stateOverride, base) {
  7112. function err(message) {
  7113. errors.push(message);
  7114. }
  7115. var state = stateOverride || 'scheme start',
  7116. cursor = 0,
  7117. buffer = '',
  7118. seenAt = false,
  7119. seenBracket = false,
  7120. errors = [];
  7121. loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  7122. var c = input[cursor];
  7123. switch (state) {
  7124. case 'scheme start':
  7125. if (c && ALPHA.test(c)) {
  7126. buffer += c.toLowerCase();
  7127. state = 'scheme';
  7128. } else if (!stateOverride) {
  7129. buffer = '';
  7130. state = 'no scheme';
  7131. continue;
  7132. } else {
  7133. err('Invalid scheme.');
  7134. break loop;
  7135. }
  7136. break;
  7137. case 'scheme':
  7138. if (c && ALPHANUMERIC.test(c)) {
  7139. buffer += c.toLowerCase();
  7140. } else if (c === ':') {
  7141. this._scheme = buffer;
  7142. buffer = '';
  7143. if (stateOverride) {
  7144. break loop;
  7145. }
  7146. if (isRelativeScheme(this._scheme)) {
  7147. this._isRelative = true;
  7148. }
  7149. if (this._scheme === 'file') {
  7150. state = 'relative';
  7151. } else if (this._isRelative && base && base._scheme === this._scheme) {
  7152. state = 'relative or authority';
  7153. } else if (this._isRelative) {
  7154. state = 'authority first slash';
  7155. } else {
  7156. state = 'scheme data';
  7157. }
  7158. } else if (!stateOverride) {
  7159. buffer = '';
  7160. cursor = 0;
  7161. state = 'no scheme';
  7162. continue;
  7163. } else if (c === EOF) {
  7164. break loop;
  7165. } else {
  7166. err('Code point not allowed in scheme: ' + c);
  7167. break loop;
  7168. }
  7169. break;
  7170. case 'scheme data':
  7171. if (c === '?') {
  7172. this._query = '?';
  7173. state = 'query';
  7174. } else if (c === '#') {
  7175. this._fragment = '#';
  7176. state = 'fragment';
  7177. } else {
  7178. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7179. this._schemeData += percentEscape(c);
  7180. }
  7181. }
  7182. break;
  7183. case 'no scheme':
  7184. if (!base || !isRelativeScheme(base._scheme)) {
  7185. err('Missing scheme.');
  7186. invalid.call(this);
  7187. } else {
  7188. state = 'relative';
  7189. continue;
  7190. }
  7191. break;
  7192. case 'relative or authority':
  7193. if (c === '/' && input[cursor + 1] === '/') {
  7194. state = 'authority ignore slashes';
  7195. } else {
  7196. err('Expected /, got: ' + c);
  7197. state = 'relative';
  7198. continue;
  7199. }
  7200. break;
  7201. case 'relative':
  7202. this._isRelative = true;
  7203. if (this._scheme !== 'file') {
  7204. this._scheme = base._scheme;
  7205. }
  7206. if (c === EOF) {
  7207. this._host = base._host;
  7208. this._port = base._port;
  7209. this._path = base._path.slice();
  7210. this._query = base._query;
  7211. this._username = base._username;
  7212. this._password = base._password;
  7213. break loop;
  7214. } else if (c === '/' || c === '\\') {
  7215. if (c === '\\') {
  7216. err('\\ is an invalid code point.');
  7217. }
  7218. state = 'relative slash';
  7219. } else if (c === '?') {
  7220. this._host = base._host;
  7221. this._port = base._port;
  7222. this._path = base._path.slice();
  7223. this._query = '?';
  7224. this._username = base._username;
  7225. this._password = base._password;
  7226. state = 'query';
  7227. } else if (c === '#') {
  7228. this._host = base._host;
  7229. this._port = base._port;
  7230. this._path = base._path.slice();
  7231. this._query = base._query;
  7232. this._fragment = '#';
  7233. this._username = base._username;
  7234. this._password = base._password;
  7235. state = 'fragment';
  7236. } else {
  7237. var nextC = input[cursor + 1];
  7238. var nextNextC = input[cursor + 2];
  7239. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  7240. this._host = base._host;
  7241. this._port = base._port;
  7242. this._username = base._username;
  7243. this._password = base._password;
  7244. this._path = base._path.slice();
  7245. this._path.pop();
  7246. }
  7247. state = 'relative path';
  7248. continue;
  7249. }
  7250. break;
  7251. case 'relative slash':
  7252. if (c === '/' || c === '\\') {
  7253. if (c === '\\') {
  7254. err('\\ is an invalid code point.');
  7255. }
  7256. if (this._scheme === 'file') {
  7257. state = 'file host';
  7258. } else {
  7259. state = 'authority ignore slashes';
  7260. }
  7261. } else {
  7262. if (this._scheme !== 'file') {
  7263. this._host = base._host;
  7264. this._port = base._port;
  7265. this._username = base._username;
  7266. this._password = base._password;
  7267. }
  7268. state = 'relative path';
  7269. continue;
  7270. }
  7271. break;
  7272. case 'authority first slash':
  7273. if (c === '/') {
  7274. state = 'authority second slash';
  7275. } else {
  7276. err('Expected \'/\', got: ' + c);
  7277. state = 'authority ignore slashes';
  7278. continue;
  7279. }
  7280. break;
  7281. case 'authority second slash':
  7282. state = 'authority ignore slashes';
  7283. if (c !== '/') {
  7284. err('Expected \'/\', got: ' + c);
  7285. continue;
  7286. }
  7287. break;
  7288. case 'authority ignore slashes':
  7289. if (c !== '/' && c !== '\\') {
  7290. state = 'authority';
  7291. continue;
  7292. } else {
  7293. err('Expected authority, got: ' + c);
  7294. }
  7295. break;
  7296. case 'authority':
  7297. if (c === '@') {
  7298. if (seenAt) {
  7299. err('@ already seen.');
  7300. buffer += '%40';
  7301. }
  7302. seenAt = true;
  7303. for (var i = 0; i < buffer.length; i++) {
  7304. var cp = buffer[i];
  7305. if (cp === '\t' || cp === '\n' || cp === '\r') {
  7306. err('Invalid whitespace in authority.');
  7307. continue;
  7308. }
  7309. if (cp === ':' && this._password === null) {
  7310. this._password = '';
  7311. continue;
  7312. }
  7313. var tempC = percentEscape(cp);
  7314. if (this._password !== null) {
  7315. this._password += tempC;
  7316. } else {
  7317. this._username += tempC;
  7318. }
  7319. }
  7320. buffer = '';
  7321. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7322. cursor -= buffer.length;
  7323. buffer = '';
  7324. state = 'host';
  7325. continue;
  7326. } else {
  7327. buffer += c;
  7328. }
  7329. break;
  7330. case 'file host':
  7331. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7332. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  7333. state = 'relative path';
  7334. } else if (buffer.length === 0) {
  7335. state = 'relative path start';
  7336. } else {
  7337. this._host = IDNAToASCII.call(this, buffer);
  7338. buffer = '';
  7339. state = 'relative path start';
  7340. }
  7341. continue;
  7342. } else if (c === '\t' || c === '\n' || c === '\r') {
  7343. err('Invalid whitespace in file host.');
  7344. } else {
  7345. buffer += c;
  7346. }
  7347. break;
  7348. case 'host':
  7349. case 'hostname':
  7350. if (c === ':' && !seenBracket) {
  7351. this._host = IDNAToASCII.call(this, buffer);
  7352. buffer = '';
  7353. state = 'port';
  7354. if (stateOverride === 'hostname') {
  7355. break loop;
  7356. }
  7357. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  7358. this._host = IDNAToASCII.call(this, buffer);
  7359. buffer = '';
  7360. state = 'relative path start';
  7361. if (stateOverride) {
  7362. break loop;
  7363. }
  7364. continue;
  7365. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  7366. if (c === '[') {
  7367. seenBracket = true;
  7368. } else if (c === ']') {
  7369. seenBracket = false;
  7370. }
  7371. buffer += c;
  7372. } else {
  7373. err('Invalid code point in host/hostname: ' + c);
  7374. }
  7375. break;
  7376. case 'port':
  7377. if (/[0-9]/.test(c)) {
  7378. buffer += c;
  7379. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  7380. if (buffer !== '') {
  7381. var temp = parseInt(buffer, 10);
  7382. if (temp !== relative[this._scheme]) {
  7383. this._port = temp + '';
  7384. }
  7385. buffer = '';
  7386. }
  7387. if (stateOverride) {
  7388. break loop;
  7389. }
  7390. state = 'relative path start';
  7391. continue;
  7392. } else if (c === '\t' || c === '\n' || c === '\r') {
  7393. err('Invalid code point in port: ' + c);
  7394. } else {
  7395. invalid.call(this);
  7396. }
  7397. break;
  7398. case 'relative path start':
  7399. if (c === '\\') {
  7400. err('\'\\\' not allowed in path.');
  7401. }
  7402. state = 'relative path';
  7403. if (c !== '/' && c !== '\\') {
  7404. continue;
  7405. }
  7406. break;
  7407. case 'relative path':
  7408. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  7409. if (c === '\\') {
  7410. err('\\ not allowed in relative path.');
  7411. }
  7412. var tmp;
  7413. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  7414. buffer = tmp;
  7415. }
  7416. if (buffer === '..') {
  7417. this._path.pop();
  7418. if (c !== '/' && c !== '\\') {
  7419. this._path.push('');
  7420. }
  7421. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  7422. this._path.push('');
  7423. } else if (buffer !== '.') {
  7424. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  7425. buffer = buffer[0] + ':';
  7426. }
  7427. this._path.push(buffer);
  7428. }
  7429. buffer = '';
  7430. if (c === '?') {
  7431. this._query = '?';
  7432. state = 'query';
  7433. } else if (c === '#') {
  7434. this._fragment = '#';
  7435. state = 'fragment';
  7436. }
  7437. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  7438. buffer += percentEscape(c);
  7439. }
  7440. break;
  7441. case 'query':
  7442. if (!stateOverride && c === '#') {
  7443. this._fragment = '#';
  7444. state = 'fragment';
  7445. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7446. this._query += percentEscapeQuery(c);
  7447. }
  7448. break;
  7449. case 'fragment':
  7450. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  7451. this._fragment += c;
  7452. }
  7453. break;
  7454. }
  7455. cursor++;
  7456. }
  7457. }
  7458. function clear() {
  7459. this._scheme = '';
  7460. this._schemeData = '';
  7461. this._username = '';
  7462. this._password = null;
  7463. this._host = '';
  7464. this._port = '';
  7465. this._path = [];
  7466. this._query = '';
  7467. this._fragment = '';
  7468. this._isInvalid = false;
  7469. this._isRelative = false;
  7470. }
  7471. function JURL(url, base) {
  7472. if (base !== undefined && !(base instanceof JURL)) {
  7473. base = new JURL(String(base));
  7474. }
  7475. this._url = url;
  7476. clear.call(this);
  7477. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  7478. parse.call(this, input, null, base);
  7479. }
  7480. JURL.prototype = {
  7481. toString: function toString() {
  7482. return this.href;
  7483. },
  7484. get href() {
  7485. if (this._isInvalid) {
  7486. return this._url;
  7487. }
  7488. var authority = '';
  7489. if (this._username !== '' || this._password !== null) {
  7490. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  7491. }
  7492. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  7493. },
  7494. set href(value) {
  7495. clear.call(this);
  7496. parse.call(this, value);
  7497. },
  7498. get protocol() {
  7499. return this._scheme + ':';
  7500. },
  7501. set protocol(value) {
  7502. if (this._isInvalid) {
  7503. return;
  7504. }
  7505. parse.call(this, value + ':', 'scheme start');
  7506. },
  7507. get host() {
  7508. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  7509. },
  7510. set host(value) {
  7511. if (this._isInvalid || !this._isRelative) {
  7512. return;
  7513. }
  7514. parse.call(this, value, 'host');
  7515. },
  7516. get hostname() {
  7517. return this._host;
  7518. },
  7519. set hostname(value) {
  7520. if (this._isInvalid || !this._isRelative) {
  7521. return;
  7522. }
  7523. parse.call(this, value, 'hostname');
  7524. },
  7525. get port() {
  7526. return this._port;
  7527. },
  7528. set port(value) {
  7529. if (this._isInvalid || !this._isRelative) {
  7530. return;
  7531. }
  7532. parse.call(this, value, 'port');
  7533. },
  7534. get pathname() {
  7535. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  7536. },
  7537. set pathname(value) {
  7538. if (this._isInvalid || !this._isRelative) {
  7539. return;
  7540. }
  7541. this._path = [];
  7542. parse.call(this, value, 'relative path start');
  7543. },
  7544. get search() {
  7545. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  7546. },
  7547. set search(value) {
  7548. if (this._isInvalid || !this._isRelative) {
  7549. return;
  7550. }
  7551. this._query = '?';
  7552. if (value[0] === '?') {
  7553. value = value.slice(1);
  7554. }
  7555. parse.call(this, value, 'query');
  7556. },
  7557. get hash() {
  7558. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  7559. },
  7560. set hash(value) {
  7561. if (this._isInvalid) {
  7562. return;
  7563. }
  7564. this._fragment = '#';
  7565. if (value[0] === '#') {
  7566. value = value.slice(1);
  7567. }
  7568. parse.call(this, value, 'fragment');
  7569. },
  7570. get origin() {
  7571. var host;
  7572. if (this._isInvalid || !this._scheme) {
  7573. return '';
  7574. }
  7575. switch (this._scheme) {
  7576. case 'data':
  7577. case 'file':
  7578. case 'javascript':
  7579. case 'mailto':
  7580. return 'null';
  7581. case 'blob':
  7582. try {
  7583. return new JURL(this._schemeData).origin || 'null';
  7584. } catch (_) {}
  7585. return 'null';
  7586. }
  7587. host = this.host;
  7588. if (!host) {
  7589. return '';
  7590. }
  7591. return this._scheme + '://' + host;
  7592. }
  7593. };
  7594. exports.URL = JURL;
  7595. })();
  7596. /***/ }),
  7597. /* 146 */
  7598. /***/ (function(module, exports, __w_pdfjs_require__) {
  7599. "use strict";
  7600. Object.defineProperty(exports, "__esModule", {
  7601. value: true
  7602. });
  7603. exports.getDocument = getDocument;
  7604. exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory;
  7605. exports.build = exports.version = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = void 0;
  7606. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  7607. var _util = __w_pdfjs_require__(1);
  7608. var _dom_utils = __w_pdfjs_require__(151);
  7609. var _font_loader = __w_pdfjs_require__(152);
  7610. var _api_compatibility = __w_pdfjs_require__(153);
  7611. var _canvas = __w_pdfjs_require__(154);
  7612. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  7613. var _worker_options = __w_pdfjs_require__(156);
  7614. var _message_handler = __w_pdfjs_require__(157);
  7615. var _metadata = __w_pdfjs_require__(158);
  7616. var _transport_stream = __w_pdfjs_require__(160);
  7617. var _webgl = __w_pdfjs_require__(161);
  7618. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7619. 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); } }
  7620. 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); }); }; }
  7621. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  7622. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  7623. function _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; }
  7624. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  7625. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  7626. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  7627. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  7628. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  7629. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7630. 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); } }
  7631. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  7632. function _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); }
  7633. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  7634. var isWorkerDisabled = false;
  7635. var fallbackWorkerSrc;
  7636. var fakeWorkerFilesLoader = null;
  7637. {
  7638. var useRequireEnsure = false;
  7639. if (typeof window === 'undefined') {
  7640. isWorkerDisabled = true;
  7641. if (typeof require.ensure === 'undefined') {
  7642. require.ensure = require('node-ensure');
  7643. }
  7644. useRequireEnsure = true;
  7645. } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') {
  7646. useRequireEnsure = true;
  7647. }
  7648. if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
  7649. fallbackWorkerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
  7650. }
  7651. var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
  7652. fakeWorkerFilesLoader = useRequireEnsure ? function () {
  7653. return new Promise(function (resolve, reject) {
  7654. require.ensure([], function () {
  7655. try {
  7656. var worker;
  7657. worker = require('./pdf.worker.js');
  7658. resolve(worker.WorkerMessageHandler);
  7659. } catch (ex) {
  7660. reject(ex);
  7661. }
  7662. }, reject, 'pdfjsWorker');
  7663. });
  7664. } : dynamicLoaderSupported ? function () {
  7665. return new Promise(function (resolve, reject) {
  7666. requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
  7667. try {
  7668. resolve(worker.WorkerMessageHandler);
  7669. } catch (ex) {
  7670. reject(ex);
  7671. }
  7672. }, reject);
  7673. });
  7674. } : null;
  7675. if (!fallbackWorkerSrc && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' && 'currentScript' in document) {
  7676. var pdfjsFilePath = document.currentScript && document.currentScript.src;
  7677. if (pdfjsFilePath) {
  7678. fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2');
  7679. }
  7680. }
  7681. }
  7682. var createPDFNetworkStream;
  7683. function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
  7684. createPDFNetworkStream = pdfNetworkStreamFactory;
  7685. }
  7686. function getDocument(src) {
  7687. var task = new PDFDocumentLoadingTask();
  7688. var source;
  7689. if (typeof src === 'string') {
  7690. source = {
  7691. url: src
  7692. };
  7693. } else if ((0, _util.isArrayBuffer)(src)) {
  7694. source = {
  7695. data: src
  7696. };
  7697. } else if (src instanceof PDFDataRangeTransport) {
  7698. source = {
  7699. range: src
  7700. };
  7701. } else {
  7702. if (_typeof(src) !== 'object') {
  7703. throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object');
  7704. }
  7705. if (!src.url && !src.data && !src.range) {
  7706. throw new Error('Invalid parameter object: need either .data, .range or .url');
  7707. }
  7708. source = src;
  7709. }
  7710. var params = Object.create(null);
  7711. var rangeTransport = null,
  7712. worker = null;
  7713. for (var key in source) {
  7714. if (key === 'url' && typeof window !== 'undefined') {
  7715. params[key] = new _util.URL(source[key], window.location).href;
  7716. continue;
  7717. } else if (key === 'range') {
  7718. rangeTransport = source[key];
  7719. continue;
  7720. } else if (key === 'worker') {
  7721. worker = source[key];
  7722. continue;
  7723. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  7724. var pdfBytes = source[key];
  7725. if (typeof pdfBytes === 'string') {
  7726. params[key] = (0, _util.stringToBytes)(pdfBytes);
  7727. } else if (_typeof(pdfBytes) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  7728. params[key] = new Uint8Array(pdfBytes);
  7729. } else if ((0, _util.isArrayBuffer)(pdfBytes)) {
  7730. params[key] = new Uint8Array(pdfBytes);
  7731. } else {
  7732. throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.');
  7733. }
  7734. continue;
  7735. }
  7736. params[key] = source[key];
  7737. }
  7738. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  7739. params.CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory;
  7740. params.ignoreErrors = params.stopAtErrors !== true;
  7741. params.pdfBug = params.pdfBug === true;
  7742. var NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
  7743. if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
  7744. params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
  7745. }
  7746. if (!Number.isInteger(params.maxImageSize)) {
  7747. params.maxImageSize = -1;
  7748. }
  7749. if (typeof params.isEvalSupported !== 'boolean') {
  7750. params.isEvalSupported = true;
  7751. }
  7752. if (typeof params.disableFontFace !== 'boolean') {
  7753. params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false;
  7754. }
  7755. if (typeof params.disableRange !== 'boolean') {
  7756. params.disableRange = false;
  7757. }
  7758. if (typeof params.disableStream !== 'boolean') {
  7759. params.disableStream = false;
  7760. }
  7761. if (typeof params.disableAutoFetch !== 'boolean') {
  7762. params.disableAutoFetch = false;
  7763. }
  7764. if (typeof params.disableCreateObjectURL !== 'boolean') {
  7765. params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
  7766. }
  7767. (0, _util.setVerbosityLevel)(params.verbosity);
  7768. if (!worker) {
  7769. var workerParams = {
  7770. postMessageTransfers: params.postMessageTransfers,
  7771. verbosity: params.verbosity,
  7772. port: _worker_options.GlobalWorkerOptions.workerPort
  7773. };
  7774. worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
  7775. task._worker = worker;
  7776. }
  7777. var docId = task.docId;
  7778. worker.promise.then(function () {
  7779. if (task.destroyed) {
  7780. throw new Error('Loading aborted');
  7781. }
  7782. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  7783. if (task.destroyed) {
  7784. throw new Error('Loading aborted');
  7785. }
  7786. var networkStream;
  7787. if (rangeTransport) {
  7788. networkStream = new _transport_stream.PDFDataTransportStream({
  7789. length: params.length,
  7790. initialData: params.initialData,
  7791. disableRange: params.disableRange,
  7792. disableStream: params.disableStream
  7793. }, rangeTransport);
  7794. } else if (!params.data) {
  7795. networkStream = createPDFNetworkStream({
  7796. url: params.url,
  7797. length: params.length,
  7798. httpHeaders: params.httpHeaders,
  7799. withCredentials: params.withCredentials,
  7800. rangeChunkSize: params.rangeChunkSize,
  7801. disableRange: params.disableRange,
  7802. disableStream: params.disableStream
  7803. });
  7804. }
  7805. var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port);
  7806. messageHandler.postMessageTransfers = worker.postMessageTransfers;
  7807. var transport = new WorkerTransport(messageHandler, task, networkStream, params);
  7808. task._transport = transport;
  7809. messageHandler.send('Ready', null);
  7810. });
  7811. }).catch(task._capability.reject);
  7812. return task;
  7813. }
  7814. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  7815. if (worker.destroyed) {
  7816. return Promise.reject(new Error('Worker was destroyed'));
  7817. }
  7818. if (pdfDataRangeTransport) {
  7819. source.length = pdfDataRangeTransport.length;
  7820. source.initialData = pdfDataRangeTransport.initialData;
  7821. }
  7822. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  7823. docId: docId,
  7824. apiVersion: '2.1.266',
  7825. source: {
  7826. data: source.data,
  7827. url: source.url,
  7828. password: source.password,
  7829. disableAutoFetch: source.disableAutoFetch,
  7830. rangeChunkSize: source.rangeChunkSize,
  7831. length: source.length
  7832. },
  7833. maxImageSize: source.maxImageSize,
  7834. disableFontFace: source.disableFontFace,
  7835. disableCreateObjectURL: source.disableCreateObjectURL,
  7836. postMessageTransfers: worker.postMessageTransfers,
  7837. docBaseUrl: source.docBaseUrl,
  7838. nativeImageDecoderSupport: source.nativeImageDecoderSupport,
  7839. ignoreErrors: source.ignoreErrors,
  7840. isEvalSupported: source.isEvalSupported
  7841. }).then(function (workerId) {
  7842. if (worker.destroyed) {
  7843. throw new Error('Worker was destroyed');
  7844. }
  7845. return workerId;
  7846. });
  7847. }
  7848. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  7849. var nextDocumentId = 0;
  7850. var PDFDocumentLoadingTask =
  7851. /*#__PURE__*/
  7852. function () {
  7853. function PDFDocumentLoadingTask() {
  7854. _classCallCheck(this, PDFDocumentLoadingTask);
  7855. this._capability = (0, _util.createPromiseCapability)();
  7856. this._transport = null;
  7857. this._worker = null;
  7858. this.docId = 'd' + nextDocumentId++;
  7859. this.destroyed = false;
  7860. this.onPassword = null;
  7861. this.onProgress = null;
  7862. this.onUnsupportedFeature = null;
  7863. }
  7864. _createClass(PDFDocumentLoadingTask, [{
  7865. key: "destroy",
  7866. value: function destroy() {
  7867. var _this = this;
  7868. this.destroyed = true;
  7869. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  7870. return transportDestroyed.then(function () {
  7871. _this._transport = null;
  7872. if (_this._worker) {
  7873. _this._worker.destroy();
  7874. _this._worker = null;
  7875. }
  7876. });
  7877. }
  7878. }, {
  7879. key: "then",
  7880. value: function then(onFulfilled, onRejected) {
  7881. (0, _util.deprecated)('PDFDocumentLoadingTask.then method, ' + 'use the `promise` getter instead.');
  7882. return this.promise.then.apply(this.promise, arguments);
  7883. }
  7884. }, {
  7885. key: "promise",
  7886. get: function get() {
  7887. return this._capability.promise;
  7888. }
  7889. }]);
  7890. return PDFDocumentLoadingTask;
  7891. }();
  7892. return PDFDocumentLoadingTask;
  7893. }();
  7894. var PDFDataRangeTransport =
  7895. /*#__PURE__*/
  7896. function () {
  7897. function PDFDataRangeTransport(length, initialData) {
  7898. _classCallCheck(this, PDFDataRangeTransport);
  7899. this.length = length;
  7900. this.initialData = initialData;
  7901. this._rangeListeners = [];
  7902. this._progressListeners = [];
  7903. this._progressiveReadListeners = [];
  7904. this._readyCapability = (0, _util.createPromiseCapability)();
  7905. }
  7906. _createClass(PDFDataRangeTransport, [{
  7907. key: "addRangeListener",
  7908. value: function addRangeListener(listener) {
  7909. this._rangeListeners.push(listener);
  7910. }
  7911. }, {
  7912. key: "addProgressListener",
  7913. value: function addProgressListener(listener) {
  7914. this._progressListeners.push(listener);
  7915. }
  7916. }, {
  7917. key: "addProgressiveReadListener",
  7918. value: function addProgressiveReadListener(listener) {
  7919. this._progressiveReadListeners.push(listener);
  7920. }
  7921. }, {
  7922. key: "onDataRange",
  7923. value: function onDataRange(begin, chunk) {
  7924. var _iteratorNormalCompletion = true;
  7925. var _didIteratorError = false;
  7926. var _iteratorError = undefined;
  7927. try {
  7928. for (var _iterator = this._rangeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  7929. var listener = _step.value;
  7930. listener(begin, chunk);
  7931. }
  7932. } catch (err) {
  7933. _didIteratorError = true;
  7934. _iteratorError = err;
  7935. } finally {
  7936. try {
  7937. if (!_iteratorNormalCompletion && _iterator.return != null) {
  7938. _iterator.return();
  7939. }
  7940. } finally {
  7941. if (_didIteratorError) {
  7942. throw _iteratorError;
  7943. }
  7944. }
  7945. }
  7946. }
  7947. }, {
  7948. key: "onDataProgress",
  7949. value: function onDataProgress(loaded) {
  7950. var _this2 = this;
  7951. this._readyCapability.promise.then(function () {
  7952. var _iteratorNormalCompletion2 = true;
  7953. var _didIteratorError2 = false;
  7954. var _iteratorError2 = undefined;
  7955. try {
  7956. for (var _iterator2 = _this2._progressListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  7957. var listener = _step2.value;
  7958. listener(loaded);
  7959. }
  7960. } catch (err) {
  7961. _didIteratorError2 = true;
  7962. _iteratorError2 = err;
  7963. } finally {
  7964. try {
  7965. if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
  7966. _iterator2.return();
  7967. }
  7968. } finally {
  7969. if (_didIteratorError2) {
  7970. throw _iteratorError2;
  7971. }
  7972. }
  7973. }
  7974. });
  7975. }
  7976. }, {
  7977. key: "onDataProgressiveRead",
  7978. value: function onDataProgressiveRead(chunk) {
  7979. var _this3 = this;
  7980. this._readyCapability.promise.then(function () {
  7981. var _iteratorNormalCompletion3 = true;
  7982. var _didIteratorError3 = false;
  7983. var _iteratorError3 = undefined;
  7984. try {
  7985. for (var _iterator3 = _this3._progressiveReadListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  7986. var listener = _step3.value;
  7987. listener(chunk);
  7988. }
  7989. } catch (err) {
  7990. _didIteratorError3 = true;
  7991. _iteratorError3 = err;
  7992. } finally {
  7993. try {
  7994. if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
  7995. _iterator3.return();
  7996. }
  7997. } finally {
  7998. if (_didIteratorError3) {
  7999. throw _iteratorError3;
  8000. }
  8001. }
  8002. }
  8003. });
  8004. }
  8005. }, {
  8006. key: "transportReady",
  8007. value: function transportReady() {
  8008. this._readyCapability.resolve();
  8009. }
  8010. }, {
  8011. key: "requestDataRange",
  8012. value: function requestDataRange(begin, end) {
  8013. (0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange');
  8014. }
  8015. }, {
  8016. key: "abort",
  8017. value: function abort() {}
  8018. }]);
  8019. return PDFDataRangeTransport;
  8020. }();
  8021. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  8022. var PDFDocumentProxy =
  8023. /*#__PURE__*/
  8024. function () {
  8025. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  8026. _classCallCheck(this, PDFDocumentProxy);
  8027. this.loadingTask = loadingTask;
  8028. this._pdfInfo = pdfInfo;
  8029. this._transport = transport;
  8030. }
  8031. _createClass(PDFDocumentProxy, [{
  8032. key: "getPage",
  8033. value: function getPage(pageNumber) {
  8034. return this._transport.getPage(pageNumber);
  8035. }
  8036. }, {
  8037. key: "getPageIndex",
  8038. value: function getPageIndex(ref) {
  8039. return this._transport.getPageIndex(ref);
  8040. }
  8041. }, {
  8042. key: "getDestinations",
  8043. value: function getDestinations() {
  8044. return this._transport.getDestinations();
  8045. }
  8046. }, {
  8047. key: "getDestination",
  8048. value: function getDestination(id) {
  8049. return this._transport.getDestination(id);
  8050. }
  8051. }, {
  8052. key: "getPageLabels",
  8053. value: function getPageLabels() {
  8054. return this._transport.getPageLabels();
  8055. }
  8056. }, {
  8057. key: "getPageMode",
  8058. value: function getPageMode() {
  8059. return this._transport.getPageMode();
  8060. }
  8061. }, {
  8062. key: "getOpenActionDestination",
  8063. value: function getOpenActionDestination() {
  8064. return this._transport.getOpenActionDestination();
  8065. }
  8066. }, {
  8067. key: "getAttachments",
  8068. value: function getAttachments() {
  8069. return this._transport.getAttachments();
  8070. }
  8071. }, {
  8072. key: "getJavaScript",
  8073. value: function getJavaScript() {
  8074. return this._transport.getJavaScript();
  8075. }
  8076. }, {
  8077. key: "getOutline",
  8078. value: function getOutline() {
  8079. return this._transport.getOutline();
  8080. }
  8081. }, {
  8082. key: "getPermissions",
  8083. value: function getPermissions() {
  8084. return this._transport.getPermissions();
  8085. }
  8086. }, {
  8087. key: "getMetadata",
  8088. value: function getMetadata() {
  8089. return this._transport.getMetadata();
  8090. }
  8091. }, {
  8092. key: "getData",
  8093. value: function getData() {
  8094. return this._transport.getData();
  8095. }
  8096. }, {
  8097. key: "getDownloadInfo",
  8098. value: function getDownloadInfo() {
  8099. return this._transport.downloadInfoCapability.promise;
  8100. }
  8101. }, {
  8102. key: "getStats",
  8103. value: function getStats() {
  8104. return this._transport.getStats();
  8105. }
  8106. }, {
  8107. key: "cleanup",
  8108. value: function cleanup() {
  8109. this._transport.startCleanup();
  8110. }
  8111. }, {
  8112. key: "destroy",
  8113. value: function destroy() {
  8114. return this.loadingTask.destroy();
  8115. }
  8116. }, {
  8117. key: "numPages",
  8118. get: function get() {
  8119. return this._pdfInfo.numPages;
  8120. }
  8121. }, {
  8122. key: "fingerprint",
  8123. get: function get() {
  8124. return this._pdfInfo.fingerprint;
  8125. }
  8126. }, {
  8127. key: "loadingParams",
  8128. get: function get() {
  8129. return this._transport.loadingParams;
  8130. }
  8131. }]);
  8132. return PDFDocumentProxy;
  8133. }();
  8134. exports.PDFDocumentProxy = PDFDocumentProxy;
  8135. var PDFPageProxy =
  8136. /*#__PURE__*/
  8137. function () {
  8138. function PDFPageProxy(pageIndex, pageInfo, transport) {
  8139. var pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  8140. _classCallCheck(this, PDFPageProxy);
  8141. this.pageIndex = pageIndex;
  8142. this._pageInfo = pageInfo;
  8143. this._transport = transport;
  8144. this._stats = pdfBug ? new _dom_utils.StatTimer() : _dom_utils.DummyStatTimer;
  8145. this._pdfBug = pdfBug;
  8146. this.commonObjs = transport.commonObjs;
  8147. this.objs = new PDFObjects();
  8148. this.cleanupAfterRender = false;
  8149. this.pendingCleanup = false;
  8150. this.intentStates = Object.create(null);
  8151. this.destroyed = false;
  8152. }
  8153. _createClass(PDFPageProxy, [{
  8154. key: "getViewport",
  8155. value: function getViewport() {
  8156. var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8157. scale = _ref.scale,
  8158. _ref$rotation = _ref.rotation,
  8159. rotation = _ref$rotation === void 0 ? this.rotate : _ref$rotation,
  8160. _ref$dontFlip = _ref.dontFlip,
  8161. dontFlip = _ref$dontFlip === void 0 ? false : _ref$dontFlip;
  8162. if (arguments.length > 1 || typeof arguments[0] === 'number') {
  8163. (0, _util.deprecated)('getViewport is called with obsolete arguments.');
  8164. scale = arguments[0];
  8165. rotation = typeof arguments[1] === 'number' ? arguments[1] : this.rotate;
  8166. dontFlip = typeof arguments[2] === 'boolean' ? arguments[2] : false;
  8167. }
  8168. return new _dom_utils.PageViewport({
  8169. viewBox: this.view,
  8170. scale: scale,
  8171. rotation: rotation,
  8172. dontFlip: dontFlip
  8173. });
  8174. }
  8175. }, {
  8176. key: "getAnnotations",
  8177. value: function getAnnotations() {
  8178. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8179. _ref2$intent = _ref2.intent,
  8180. intent = _ref2$intent === void 0 ? null : _ref2$intent;
  8181. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  8182. this.annotationsPromise = this._transport.getAnnotations(this.pageIndex, intent);
  8183. this.annotationsIntent = intent;
  8184. }
  8185. return this.annotationsPromise;
  8186. }
  8187. }, {
  8188. key: "render",
  8189. value: function render(_ref3) {
  8190. var _this4 = this;
  8191. var canvasContext = _ref3.canvasContext,
  8192. viewport = _ref3.viewport,
  8193. _ref3$intent = _ref3.intent,
  8194. intent = _ref3$intent === void 0 ? 'display' : _ref3$intent,
  8195. _ref3$enableWebGL = _ref3.enableWebGL,
  8196. enableWebGL = _ref3$enableWebGL === void 0 ? false : _ref3$enableWebGL,
  8197. _ref3$renderInteracti = _ref3.renderInteractiveForms,
  8198. renderInteractiveForms = _ref3$renderInteracti === void 0 ? false : _ref3$renderInteracti,
  8199. _ref3$transform = _ref3.transform,
  8200. transform = _ref3$transform === void 0 ? null : _ref3$transform,
  8201. _ref3$imageLayer = _ref3.imageLayer,
  8202. imageLayer = _ref3$imageLayer === void 0 ? null : _ref3$imageLayer,
  8203. _ref3$canvasFactory = _ref3.canvasFactory,
  8204. canvasFactory = _ref3$canvasFactory === void 0 ? null : _ref3$canvasFactory,
  8205. _ref3$background = _ref3.background,
  8206. background = _ref3$background === void 0 ? null : _ref3$background;
  8207. var stats = this._stats;
  8208. stats.time('Overall');
  8209. this.pendingCleanup = false;
  8210. var renderingIntent = intent === 'print' ? 'print' : 'display';
  8211. var canvasFactoryInstance = canvasFactory || new _dom_utils.DOMCanvasFactory();
  8212. var webGLContext = new _webgl.WebGLContext({
  8213. enable: enableWebGL
  8214. });
  8215. if (!this.intentStates[renderingIntent]) {
  8216. this.intentStates[renderingIntent] = Object.create(null);
  8217. }
  8218. var intentState = this.intentStates[renderingIntent];
  8219. if (!intentState.displayReadyCapability) {
  8220. intentState.receivingOperatorList = true;
  8221. intentState.displayReadyCapability = (0, _util.createPromiseCapability)();
  8222. intentState.operatorList = {
  8223. fnArray: [],
  8224. argsArray: [],
  8225. lastChunk: false
  8226. };
  8227. stats.time('Page Request');
  8228. this._transport.messageHandler.send('RenderPageRequest', {
  8229. pageIndex: this.pageNumber - 1,
  8230. intent: renderingIntent,
  8231. renderInteractiveForms: renderInteractiveForms === true
  8232. });
  8233. }
  8234. var complete = function complete(error) {
  8235. var i = intentState.renderTasks.indexOf(internalRenderTask);
  8236. if (i >= 0) {
  8237. intentState.renderTasks.splice(i, 1);
  8238. }
  8239. if (_this4.cleanupAfterRender) {
  8240. _this4.pendingCleanup = true;
  8241. }
  8242. _this4._tryCleanup();
  8243. if (error) {
  8244. internalRenderTask.capability.reject(error);
  8245. } else {
  8246. internalRenderTask.capability.resolve();
  8247. }
  8248. stats.timeEnd('Rendering');
  8249. stats.timeEnd('Overall');
  8250. };
  8251. var internalRenderTask = new InternalRenderTask({
  8252. callback: complete,
  8253. params: {
  8254. canvasContext: canvasContext,
  8255. viewport: viewport,
  8256. transform: transform,
  8257. imageLayer: imageLayer,
  8258. background: background
  8259. },
  8260. objs: this.objs,
  8261. commonObjs: this.commonObjs,
  8262. operatorList: intentState.operatorList,
  8263. pageNumber: this.pageNumber,
  8264. canvasFactory: canvasFactoryInstance,
  8265. webGLContext: webGLContext,
  8266. useRequestAnimationFrame: renderingIntent !== 'print',
  8267. pdfBug: this._pdfBug
  8268. });
  8269. if (!intentState.renderTasks) {
  8270. intentState.renderTasks = [];
  8271. }
  8272. intentState.renderTasks.push(internalRenderTask);
  8273. var renderTask = internalRenderTask.task;
  8274. intentState.displayReadyCapability.promise.then(function (transparency) {
  8275. if (_this4.pendingCleanup) {
  8276. complete();
  8277. return;
  8278. }
  8279. stats.time('Rendering');
  8280. internalRenderTask.initializeGraphics(transparency);
  8281. internalRenderTask.operatorListChanged();
  8282. }).catch(complete);
  8283. return renderTask;
  8284. }
  8285. }, {
  8286. key: "getOperatorList",
  8287. value: function getOperatorList() {
  8288. function operatorListChanged() {
  8289. if (intentState.operatorList.lastChunk) {
  8290. intentState.opListReadCapability.resolve(intentState.operatorList);
  8291. var i = intentState.renderTasks.indexOf(opListTask);
  8292. if (i >= 0) {
  8293. intentState.renderTasks.splice(i, 1);
  8294. }
  8295. }
  8296. }
  8297. var renderingIntent = 'oplist';
  8298. if (!this.intentStates[renderingIntent]) {
  8299. this.intentStates[renderingIntent] = Object.create(null);
  8300. }
  8301. var intentState = this.intentStates[renderingIntent];
  8302. var opListTask;
  8303. if (!intentState.opListReadCapability) {
  8304. opListTask = {};
  8305. opListTask.operatorListChanged = operatorListChanged;
  8306. intentState.receivingOperatorList = true;
  8307. intentState.opListReadCapability = (0, _util.createPromiseCapability)();
  8308. intentState.renderTasks = [];
  8309. intentState.renderTasks.push(opListTask);
  8310. intentState.operatorList = {
  8311. fnArray: [],
  8312. argsArray: [],
  8313. lastChunk: false
  8314. };
  8315. this._stats.time('Page Request');
  8316. this._transport.messageHandler.send('RenderPageRequest', {
  8317. pageIndex: this.pageIndex,
  8318. intent: renderingIntent
  8319. });
  8320. }
  8321. return intentState.opListReadCapability.promise;
  8322. }
  8323. }, {
  8324. key: "streamTextContent",
  8325. value: function streamTextContent() {
  8326. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8327. _ref4$normalizeWhites = _ref4.normalizeWhitespace,
  8328. normalizeWhitespace = _ref4$normalizeWhites === void 0 ? false : _ref4$normalizeWhites,
  8329. _ref4$disableCombineT = _ref4.disableCombineTextItems,
  8330. disableCombineTextItems = _ref4$disableCombineT === void 0 ? false : _ref4$disableCombineT;
  8331. var TEXT_CONTENT_CHUNK_SIZE = 100;
  8332. return this._transport.messageHandler.sendWithStream('GetTextContent', {
  8333. pageIndex: this.pageNumber - 1,
  8334. normalizeWhitespace: normalizeWhitespace === true,
  8335. combineTextItems: disableCombineTextItems !== true
  8336. }, {
  8337. highWaterMark: TEXT_CONTENT_CHUNK_SIZE,
  8338. size: function size(textContent) {
  8339. return textContent.items.length;
  8340. }
  8341. });
  8342. }
  8343. }, {
  8344. key: "getTextContent",
  8345. value: function getTextContent() {
  8346. var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8347. var readableStream = this.streamTextContent(params);
  8348. return new Promise(function (resolve, reject) {
  8349. function pump() {
  8350. reader.read().then(function (_ref5) {
  8351. var _textContent$items;
  8352. var value = _ref5.value,
  8353. done = _ref5.done;
  8354. if (done) {
  8355. resolve(textContent);
  8356. return;
  8357. }
  8358. Object.assign(textContent.styles, value.styles);
  8359. (_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items));
  8360. pump();
  8361. }, reject);
  8362. }
  8363. var reader = readableStream.getReader();
  8364. var textContent = {
  8365. items: [],
  8366. styles: Object.create(null)
  8367. };
  8368. pump();
  8369. });
  8370. }
  8371. }, {
  8372. key: "_destroy",
  8373. value: function _destroy() {
  8374. this.destroyed = true;
  8375. this._transport.pageCache[this.pageIndex] = null;
  8376. var waitOn = [];
  8377. Object.keys(this.intentStates).forEach(function (intent) {
  8378. if (intent === 'oplist') {
  8379. return;
  8380. }
  8381. var intentState = this.intentStates[intent];
  8382. intentState.renderTasks.forEach(function (renderTask) {
  8383. var renderCompleted = renderTask.capability.promise.catch(function () {});
  8384. waitOn.push(renderCompleted);
  8385. renderTask.cancel();
  8386. });
  8387. }, this);
  8388. this.objs.clear();
  8389. this.annotationsPromise = null;
  8390. this.pendingCleanup = false;
  8391. return Promise.all(waitOn);
  8392. }
  8393. }, {
  8394. key: "cleanup",
  8395. value: function cleanup() {
  8396. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8397. this.pendingCleanup = true;
  8398. this._tryCleanup(resetStats);
  8399. }
  8400. }, {
  8401. key: "_tryCleanup",
  8402. value: function _tryCleanup() {
  8403. var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  8404. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  8405. var intentState = this.intentStates[intent];
  8406. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  8407. }, this)) {
  8408. return;
  8409. }
  8410. Object.keys(this.intentStates).forEach(function (intent) {
  8411. delete this.intentStates[intent];
  8412. }, this);
  8413. this.objs.clear();
  8414. this.annotationsPromise = null;
  8415. if (resetStats && this._stats instanceof _dom_utils.StatTimer) {
  8416. this._stats = new _dom_utils.StatTimer();
  8417. }
  8418. this.pendingCleanup = false;
  8419. }
  8420. }, {
  8421. key: "_startRenderPage",
  8422. value: function _startRenderPage(transparency, intent) {
  8423. var intentState = this.intentStates[intent];
  8424. if (intentState.displayReadyCapability) {
  8425. intentState.displayReadyCapability.resolve(transparency);
  8426. }
  8427. }
  8428. }, {
  8429. key: "_renderPageChunk",
  8430. value: function _renderPageChunk(operatorListChunk, intent) {
  8431. var intentState = this.intentStates[intent];
  8432. for (var i = 0, ii = operatorListChunk.length; i < ii; i++) {
  8433. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  8434. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  8435. }
  8436. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  8437. for (var _i = 0; _i < intentState.renderTasks.length; _i++) {
  8438. intentState.renderTasks[_i].operatorListChanged();
  8439. }
  8440. if (operatorListChunk.lastChunk) {
  8441. intentState.receivingOperatorList = false;
  8442. this._tryCleanup();
  8443. }
  8444. }
  8445. }, {
  8446. key: "pageNumber",
  8447. get: function get() {
  8448. return this.pageIndex + 1;
  8449. }
  8450. }, {
  8451. key: "rotate",
  8452. get: function get() {
  8453. return this._pageInfo.rotate;
  8454. }
  8455. }, {
  8456. key: "ref",
  8457. get: function get() {
  8458. return this._pageInfo.ref;
  8459. }
  8460. }, {
  8461. key: "userUnit",
  8462. get: function get() {
  8463. return this._pageInfo.userUnit;
  8464. }
  8465. }, {
  8466. key: "view",
  8467. get: function get() {
  8468. return this._pageInfo.view;
  8469. }
  8470. }, {
  8471. key: "stats",
  8472. get: function get() {
  8473. return this._stats instanceof _dom_utils.StatTimer ? this._stats : null;
  8474. }
  8475. }]);
  8476. return PDFPageProxy;
  8477. }();
  8478. exports.PDFPageProxy = PDFPageProxy;
  8479. var LoopbackPort =
  8480. /*#__PURE__*/
  8481. function () {
  8482. function LoopbackPort() {
  8483. var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  8484. _classCallCheck(this, LoopbackPort);
  8485. this._listeners = [];
  8486. this._defer = defer;
  8487. this._deferred = Promise.resolve(undefined);
  8488. }
  8489. _createClass(LoopbackPort, [{
  8490. key: "postMessage",
  8491. value: function postMessage(obj, transfers) {
  8492. var _this5 = this;
  8493. function cloneValue(value) {
  8494. if (_typeof(value) !== 'object' || value === null) {
  8495. return value;
  8496. }
  8497. if (cloned.has(value)) {
  8498. return cloned.get(value);
  8499. }
  8500. var buffer, result;
  8501. if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
  8502. var transferable = transfers && transfers.includes(buffer);
  8503. if (value === buffer) {
  8504. result = value;
  8505. } else if (transferable) {
  8506. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  8507. } else {
  8508. result = new value.constructor(value);
  8509. }
  8510. cloned.set(value, result);
  8511. return result;
  8512. }
  8513. result = Array.isArray(value) ? [] : {};
  8514. cloned.set(value, result);
  8515. for (var i in value) {
  8516. var desc = void 0,
  8517. p = value;
  8518. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  8519. p = Object.getPrototypeOf(p);
  8520. }
  8521. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  8522. continue;
  8523. }
  8524. result[i] = cloneValue(desc.value);
  8525. }
  8526. return result;
  8527. }
  8528. if (!this._defer) {
  8529. this._listeners.forEach(function (listener) {
  8530. listener.call(this, {
  8531. data: obj
  8532. });
  8533. }, this);
  8534. return;
  8535. }
  8536. var cloned = new WeakMap();
  8537. var e = {
  8538. data: cloneValue(obj)
  8539. };
  8540. this._deferred.then(function () {
  8541. _this5._listeners.forEach(function (listener) {
  8542. listener.call(this, e);
  8543. }, _this5);
  8544. });
  8545. }
  8546. }, {
  8547. key: "addEventListener",
  8548. value: function addEventListener(name, listener) {
  8549. this._listeners.push(listener);
  8550. }
  8551. }, {
  8552. key: "removeEventListener",
  8553. value: function removeEventListener(name, listener) {
  8554. var i = this._listeners.indexOf(listener);
  8555. this._listeners.splice(i, 1);
  8556. }
  8557. }, {
  8558. key: "terminate",
  8559. value: function terminate() {
  8560. this._listeners = [];
  8561. }
  8562. }]);
  8563. return LoopbackPort;
  8564. }();
  8565. exports.LoopbackPort = LoopbackPort;
  8566. var PDFWorker = function PDFWorkerClosure() {
  8567. var pdfWorkerPorts = new WeakMap();
  8568. var nextFakeWorkerId = 0;
  8569. var fakeWorkerFilesLoadedCapability;
  8570. function _getWorkerSrc() {
  8571. if (_worker_options.GlobalWorkerOptions.workerSrc) {
  8572. return _worker_options.GlobalWorkerOptions.workerSrc;
  8573. }
  8574. if (typeof fallbackWorkerSrc !== 'undefined') {
  8575. return fallbackWorkerSrc;
  8576. }
  8577. throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');
  8578. }
  8579. function getMainThreadWorkerMessageHandler() {
  8580. try {
  8581. if (typeof window !== 'undefined') {
  8582. return window.pdfjsWorker && window.pdfjsWorker.WorkerMessageHandler;
  8583. }
  8584. } catch (ex) {}
  8585. return null;
  8586. }
  8587. function setupFakeWorkerGlobal() {
  8588. if (fakeWorkerFilesLoadedCapability) {
  8589. return fakeWorkerFilesLoadedCapability.promise;
  8590. }
  8591. fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)();
  8592. var mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
  8593. if (mainWorkerMessageHandler) {
  8594. fakeWorkerFilesLoadedCapability.resolve(mainWorkerMessageHandler);
  8595. return fakeWorkerFilesLoadedCapability.promise;
  8596. }
  8597. var loader = fakeWorkerFilesLoader || function () {
  8598. return (0, _dom_utils.loadScript)(_getWorkerSrc()).then(function () {
  8599. return window.pdfjsWorker.WorkerMessageHandler;
  8600. });
  8601. };
  8602. loader().then(fakeWorkerFilesLoadedCapability.resolve, fakeWorkerFilesLoadedCapability.reject);
  8603. return fakeWorkerFilesLoadedCapability.promise;
  8604. }
  8605. function createCDNWrapper(url) {
  8606. var wrapper = 'importScripts(\'' + url + '\');';
  8607. return _util.URL.createObjectURL(new Blob([wrapper]));
  8608. }
  8609. var PDFWorker =
  8610. /*#__PURE__*/
  8611. function () {
  8612. function PDFWorker() {
  8613. var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  8614. _ref6$name = _ref6.name,
  8615. name = _ref6$name === void 0 ? null : _ref6$name,
  8616. _ref6$port = _ref6.port,
  8617. port = _ref6$port === void 0 ? null : _ref6$port,
  8618. _ref6$postMessageTran = _ref6.postMessageTransfers,
  8619. postMessageTransfers = _ref6$postMessageTran === void 0 ? true : _ref6$postMessageTran,
  8620. _ref6$verbosity = _ref6.verbosity,
  8621. verbosity = _ref6$verbosity === void 0 ? (0, _util.getVerbosityLevel)() : _ref6$verbosity;
  8622. _classCallCheck(this, PDFWorker);
  8623. if (port && pdfWorkerPorts.has(port)) {
  8624. throw new Error('Cannot use more than one PDFWorker per port');
  8625. }
  8626. this.name = name;
  8627. this.destroyed = false;
  8628. this.postMessageTransfers = postMessageTransfers !== false;
  8629. this.verbosity = verbosity;
  8630. this._readyCapability = (0, _util.createPromiseCapability)();
  8631. this._port = null;
  8632. this._webWorker = null;
  8633. this._messageHandler = null;
  8634. if (port) {
  8635. pdfWorkerPorts.set(port, this);
  8636. this._initializeFromPort(port);
  8637. return;
  8638. }
  8639. this._initialize();
  8640. }
  8641. _createClass(PDFWorker, [{
  8642. key: "_initializeFromPort",
  8643. value: function _initializeFromPort(port) {
  8644. this._port = port;
  8645. this._messageHandler = new _message_handler.MessageHandler('main', 'worker', port);
  8646. this._messageHandler.on('ready', function () {});
  8647. this._readyCapability.resolve();
  8648. }
  8649. }, {
  8650. key: "_initialize",
  8651. value: function _initialize() {
  8652. var _this6 = this;
  8653. if (typeof Worker !== 'undefined' && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) {
  8654. var workerSrc = _getWorkerSrc();
  8655. try {
  8656. if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) {
  8657. workerSrc = createCDNWrapper(new _util.URL(workerSrc, window.location).href);
  8658. }
  8659. var worker = new Worker(workerSrc);
  8660. var messageHandler = new _message_handler.MessageHandler('main', 'worker', worker);
  8661. var terminateEarly = function terminateEarly() {
  8662. worker.removeEventListener('error', onWorkerError);
  8663. messageHandler.destroy();
  8664. worker.terminate();
  8665. if (_this6.destroyed) {
  8666. _this6._readyCapability.reject(new Error('Worker was destroyed'));
  8667. } else {
  8668. _this6._setupFakeWorker();
  8669. }
  8670. };
  8671. var onWorkerError = function onWorkerError() {
  8672. if (!_this6._webWorker) {
  8673. terminateEarly();
  8674. }
  8675. };
  8676. worker.addEventListener('error', onWorkerError);
  8677. messageHandler.on('test', function (data) {
  8678. worker.removeEventListener('error', onWorkerError);
  8679. if (_this6.destroyed) {
  8680. terminateEarly();
  8681. return;
  8682. }
  8683. if (data && data.supportTypedArray) {
  8684. _this6._messageHandler = messageHandler;
  8685. _this6._port = worker;
  8686. _this6._webWorker = worker;
  8687. if (!data.supportTransfers) {
  8688. _this6.postMessageTransfers = false;
  8689. }
  8690. _this6._readyCapability.resolve();
  8691. messageHandler.send('configure', {
  8692. verbosity: _this6.verbosity
  8693. });
  8694. } else {
  8695. _this6._setupFakeWorker();
  8696. messageHandler.destroy();
  8697. worker.terminate();
  8698. }
  8699. });
  8700. messageHandler.on('ready', function (data) {
  8701. worker.removeEventListener('error', onWorkerError);
  8702. if (_this6.destroyed) {
  8703. terminateEarly();
  8704. return;
  8705. }
  8706. try {
  8707. sendTest();
  8708. } catch (e) {
  8709. _this6._setupFakeWorker();
  8710. }
  8711. });
  8712. var sendTest = function sendTest() {
  8713. var testObj = new Uint8Array([_this6.postMessageTransfers ? 255 : 0]);
  8714. try {
  8715. messageHandler.send('test', testObj, [testObj.buffer]);
  8716. } catch (ex) {
  8717. (0, _util.info)('Cannot use postMessage transfers');
  8718. testObj[0] = 0;
  8719. messageHandler.send('test', testObj);
  8720. }
  8721. };
  8722. sendTest();
  8723. return;
  8724. } catch (e) {
  8725. (0, _util.info)('The worker has been disabled.');
  8726. }
  8727. }
  8728. this._setupFakeWorker();
  8729. }
  8730. }, {
  8731. key: "_setupFakeWorker",
  8732. value: function _setupFakeWorker() {
  8733. var _this7 = this;
  8734. if (!isWorkerDisabled) {
  8735. (0, _util.warn)('Setting up fake worker.');
  8736. isWorkerDisabled = true;
  8737. }
  8738. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  8739. if (_this7.destroyed) {
  8740. _this7._readyCapability.reject(new Error('Worker was destroyed'));
  8741. return;
  8742. }
  8743. var port = new LoopbackPort();
  8744. _this7._port = port;
  8745. var id = 'fake' + nextFakeWorkerId++;
  8746. var workerHandler = new _message_handler.MessageHandler(id + '_worker', id, port);
  8747. WorkerMessageHandler.setup(workerHandler, port);
  8748. var messageHandler = new _message_handler.MessageHandler(id, id + '_worker', port);
  8749. _this7._messageHandler = messageHandler;
  8750. _this7._readyCapability.resolve();
  8751. }).catch(function (reason) {
  8752. _this7._readyCapability.reject(new Error("Setting up fake worker failed: \"".concat(reason.message, "\".")));
  8753. });
  8754. }
  8755. }, {
  8756. key: "destroy",
  8757. value: function destroy() {
  8758. this.destroyed = true;
  8759. if (this._webWorker) {
  8760. this._webWorker.terminate();
  8761. this._webWorker = null;
  8762. }
  8763. pdfWorkerPorts.delete(this._port);
  8764. this._port = null;
  8765. if (this._messageHandler) {
  8766. this._messageHandler.destroy();
  8767. this._messageHandler = null;
  8768. }
  8769. }
  8770. }, {
  8771. key: "promise",
  8772. get: function get() {
  8773. return this._readyCapability.promise;
  8774. }
  8775. }, {
  8776. key: "port",
  8777. get: function get() {
  8778. return this._port;
  8779. }
  8780. }, {
  8781. key: "messageHandler",
  8782. get: function get() {
  8783. return this._messageHandler;
  8784. }
  8785. }], [{
  8786. key: "fromPort",
  8787. value: function fromPort(params) {
  8788. if (!params || !params.port) {
  8789. throw new Error('PDFWorker.fromPort - invalid method signature.');
  8790. }
  8791. if (pdfWorkerPorts.has(params.port)) {
  8792. return pdfWorkerPorts.get(params.port);
  8793. }
  8794. return new PDFWorker(params);
  8795. }
  8796. }, {
  8797. key: "getWorkerSrc",
  8798. value: function getWorkerSrc() {
  8799. return _getWorkerSrc();
  8800. }
  8801. }]);
  8802. return PDFWorker;
  8803. }();
  8804. return PDFWorker;
  8805. }();
  8806. exports.PDFWorker = PDFWorker;
  8807. var WorkerTransport =
  8808. /*#__PURE__*/
  8809. function () {
  8810. function WorkerTransport(messageHandler, loadingTask, networkStream, params) {
  8811. _classCallCheck(this, WorkerTransport);
  8812. this.messageHandler = messageHandler;
  8813. this.loadingTask = loadingTask;
  8814. this.commonObjs = new PDFObjects();
  8815. this.fontLoader = new _font_loader.FontLoader({
  8816. docId: loadingTask.docId,
  8817. onUnsupportedFeature: this._onUnsupportedFeature.bind(this)
  8818. });
  8819. this._params = params;
  8820. this.CMapReaderFactory = new params.CMapReaderFactory({
  8821. baseUrl: params.cMapUrl,
  8822. isCompressed: params.cMapPacked
  8823. });
  8824. this.destroyed = false;
  8825. this.destroyCapability = null;
  8826. this._passwordCapability = null;
  8827. this._networkStream = networkStream;
  8828. this._fullReader = null;
  8829. this._lastProgress = null;
  8830. this.pageCache = [];
  8831. this.pagePromises = [];
  8832. this.downloadInfoCapability = (0, _util.createPromiseCapability)();
  8833. this.setupMessageHandler();
  8834. }
  8835. _createClass(WorkerTransport, [{
  8836. key: "destroy",
  8837. value: function destroy() {
  8838. var _this8 = this;
  8839. if (this.destroyCapability) {
  8840. return this.destroyCapability.promise;
  8841. }
  8842. this.destroyed = true;
  8843. this.destroyCapability = (0, _util.createPromiseCapability)();
  8844. if (this._passwordCapability) {
  8845. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  8846. }
  8847. var waitOn = [];
  8848. this.pageCache.forEach(function (page) {
  8849. if (page) {
  8850. waitOn.push(page._destroy());
  8851. }
  8852. });
  8853. this.pageCache = [];
  8854. this.pagePromises = [];
  8855. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  8856. waitOn.push(terminated);
  8857. Promise.all(waitOn).then(function () {
  8858. _this8.fontLoader.clear();
  8859. if (_this8._networkStream) {
  8860. _this8._networkStream.cancelAllRequests();
  8861. }
  8862. if (_this8.messageHandler) {
  8863. _this8.messageHandler.destroy();
  8864. _this8.messageHandler = null;
  8865. }
  8866. _this8.destroyCapability.resolve();
  8867. }, this.destroyCapability.reject);
  8868. return this.destroyCapability.promise;
  8869. }
  8870. }, {
  8871. key: "setupMessageHandler",
  8872. value: function setupMessageHandler() {
  8873. var messageHandler = this.messageHandler,
  8874. loadingTask = this.loadingTask;
  8875. messageHandler.on('GetReader', function (data, sink) {
  8876. var _this9 = this;
  8877. (0, _util.assert)(this._networkStream);
  8878. this._fullReader = this._networkStream.getFullReader();
  8879. this._fullReader.onProgress = function (evt) {
  8880. _this9._lastProgress = {
  8881. loaded: evt.loaded,
  8882. total: evt.total
  8883. };
  8884. };
  8885. sink.onPull = function () {
  8886. _this9._fullReader.read().then(function (_ref7) {
  8887. var value = _ref7.value,
  8888. done = _ref7.done;
  8889. if (done) {
  8890. sink.close();
  8891. return;
  8892. }
  8893. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  8894. sink.enqueue(new Uint8Array(value), 1, [value]);
  8895. }).catch(function (reason) {
  8896. sink.error(reason);
  8897. });
  8898. };
  8899. sink.onCancel = function (reason) {
  8900. _this9._fullReader.cancel(reason);
  8901. };
  8902. }, this);
  8903. messageHandler.on('ReaderHeadersReady', function (data) {
  8904. var _this10 = this;
  8905. var headersCapability = (0, _util.createPromiseCapability)();
  8906. var fullReader = this._fullReader;
  8907. fullReader.headersReady.then(function () {
  8908. if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
  8909. if (_this10._lastProgress && loadingTask.onProgress) {
  8910. loadingTask.onProgress(_this10._lastProgress);
  8911. }
  8912. fullReader.onProgress = function (evt) {
  8913. if (loadingTask.onProgress) {
  8914. loadingTask.onProgress({
  8915. loaded: evt.loaded,
  8916. total: evt.total
  8917. });
  8918. }
  8919. };
  8920. }
  8921. headersCapability.resolve({
  8922. isStreamingSupported: fullReader.isStreamingSupported,
  8923. isRangeSupported: fullReader.isRangeSupported,
  8924. contentLength: fullReader.contentLength
  8925. });
  8926. }, headersCapability.reject);
  8927. return headersCapability.promise;
  8928. }, this);
  8929. messageHandler.on('GetRangeReader', function (data, sink) {
  8930. (0, _util.assert)(this._networkStream);
  8931. var rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
  8932. sink.onPull = function () {
  8933. rangeReader.read().then(function (_ref8) {
  8934. var value = _ref8.value,
  8935. done = _ref8.done;
  8936. if (done) {
  8937. sink.close();
  8938. return;
  8939. }
  8940. (0, _util.assert)((0, _util.isArrayBuffer)(value));
  8941. sink.enqueue(new Uint8Array(value), 1, [value]);
  8942. }).catch(function (reason) {
  8943. sink.error(reason);
  8944. });
  8945. };
  8946. sink.onCancel = function (reason) {
  8947. rangeReader.cancel(reason);
  8948. };
  8949. }, this);
  8950. messageHandler.on('GetDoc', function (_ref9) {
  8951. var pdfInfo = _ref9.pdfInfo;
  8952. this.numPages = pdfInfo.numPages;
  8953. this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  8954. loadingTask._capability.resolve(this.pdfDocument);
  8955. }, this);
  8956. messageHandler.on('PasswordRequest', function (exception) {
  8957. var _this11 = this;
  8958. this._passwordCapability = (0, _util.createPromiseCapability)();
  8959. if (loadingTask.onPassword) {
  8960. var updatePassword = function updatePassword(password) {
  8961. _this11._passwordCapability.resolve({
  8962. password: password
  8963. });
  8964. };
  8965. try {
  8966. loadingTask.onPassword(updatePassword, exception.code);
  8967. } catch (ex) {
  8968. this._passwordCapability.reject(ex);
  8969. }
  8970. } else {
  8971. this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
  8972. }
  8973. return this._passwordCapability.promise;
  8974. }, this);
  8975. messageHandler.on('PasswordException', function (exception) {
  8976. loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code));
  8977. }, this);
  8978. messageHandler.on('InvalidPDF', function (exception) {
  8979. loadingTask._capability.reject(new _util.InvalidPDFException(exception.message));
  8980. }, this);
  8981. messageHandler.on('MissingPDF', function (exception) {
  8982. loadingTask._capability.reject(new _util.MissingPDFException(exception.message));
  8983. }, this);
  8984. messageHandler.on('UnexpectedResponse', function (exception) {
  8985. loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status));
  8986. }, this);
  8987. messageHandler.on('UnknownError', function (exception) {
  8988. loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details));
  8989. }, this);
  8990. messageHandler.on('DataLoaded', function (data) {
  8991. if (loadingTask.onProgress) {
  8992. loadingTask.onProgress({
  8993. loaded: data.length,
  8994. total: data.length
  8995. });
  8996. }
  8997. this.downloadInfoCapability.resolve(data);
  8998. }, this);
  8999. messageHandler.on('StartRenderPage', function (data) {
  9000. if (this.destroyed) {
  9001. return;
  9002. }
  9003. var page = this.pageCache[data.pageIndex];
  9004. page._stats.timeEnd('Page Request');
  9005. page._startRenderPage(data.transparency, data.intent);
  9006. }, this);
  9007. messageHandler.on('RenderPageChunk', function (data) {
  9008. if (this.destroyed) {
  9009. return;
  9010. }
  9011. var page = this.pageCache[data.pageIndex];
  9012. page._renderPageChunk(data.operatorList, data.intent);
  9013. }, this);
  9014. messageHandler.on('commonobj', function (data) {
  9015. var _this12 = this;
  9016. if (this.destroyed) {
  9017. return;
  9018. }
  9019. var _data = _slicedToArray(data, 3),
  9020. id = _data[0],
  9021. type = _data[1],
  9022. exportedData = _data[2];
  9023. if (this.commonObjs.has(id)) {
  9024. return;
  9025. }
  9026. switch (type) {
  9027. case 'Font':
  9028. var params = this._params;
  9029. if ('error' in exportedData) {
  9030. var exportedError = exportedData.error;
  9031. (0, _util.warn)("Error during font loading: ".concat(exportedError));
  9032. this.commonObjs.resolve(id, exportedError);
  9033. break;
  9034. }
  9035. var fontRegistry = null;
  9036. if (params.pdfBug && _global_scope.default.FontInspector && _global_scope.default.FontInspector.enabled) {
  9037. fontRegistry = {
  9038. registerFont: function registerFont(font, url) {
  9039. _global_scope.default['FontInspector'].fontAdded(font, url);
  9040. }
  9041. };
  9042. }
  9043. var font = new _font_loader.FontFaceObject(exportedData, {
  9044. isEvalSupported: params.isEvalSupported,
  9045. disableFontFace: params.disableFontFace,
  9046. ignoreErrors: params.ignoreErrors,
  9047. onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
  9048. fontRegistry: fontRegistry
  9049. });
  9050. this.fontLoader.bind(font).then(function () {
  9051. _this12.commonObjs.resolve(id, font);
  9052. }, function (reason) {
  9053. messageHandler.sendWithPromise('FontFallback', {
  9054. id: id
  9055. }).finally(function () {
  9056. _this12.commonObjs.resolve(id, font);
  9057. });
  9058. });
  9059. break;
  9060. case 'FontPath':
  9061. this.commonObjs.resolve(id, exportedData);
  9062. break;
  9063. default:
  9064. throw new Error("Got unknown common object type ".concat(type));
  9065. }
  9066. }, this);
  9067. messageHandler.on('obj', function (data) {
  9068. if (this.destroyed) {
  9069. return;
  9070. }
  9071. var _data2 = _slicedToArray(data, 4),
  9072. id = _data2[0],
  9073. pageIndex = _data2[1],
  9074. type = _data2[2],
  9075. imageData = _data2[3];
  9076. var pageProxy = this.pageCache[pageIndex];
  9077. if (pageProxy.objs.has(id)) {
  9078. return;
  9079. }
  9080. switch (type) {
  9081. case 'JpegStream':
  9082. return new Promise(function (resolve, reject) {
  9083. var img = new Image();
  9084. img.onload = function () {
  9085. resolve(img);
  9086. };
  9087. img.onerror = function () {
  9088. reject(new Error('Error during JPEG image loading'));
  9089. };
  9090. img.src = imageData;
  9091. }).then(function (img) {
  9092. pageProxy.objs.resolve(id, img);
  9093. });
  9094. case 'Image':
  9095. pageProxy.objs.resolve(id, imageData);
  9096. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  9097. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  9098. pageProxy.cleanupAfterRender = true;
  9099. }
  9100. break;
  9101. default:
  9102. throw new Error("Got unknown object type ".concat(type));
  9103. }
  9104. }, this);
  9105. messageHandler.on('DocProgress', function (data) {
  9106. if (this.destroyed) {
  9107. return;
  9108. }
  9109. if (loadingTask.onProgress) {
  9110. loadingTask.onProgress({
  9111. loaded: data.loaded,
  9112. total: data.total
  9113. });
  9114. }
  9115. }, this);
  9116. messageHandler.on('PageError', function (data) {
  9117. if (this.destroyed) {
  9118. return;
  9119. }
  9120. var page = this.pageCache[data.pageNum - 1];
  9121. var intentState = page.intentStates[data.intent];
  9122. if (intentState.displayReadyCapability) {
  9123. intentState.displayReadyCapability.reject(data.error);
  9124. } else {
  9125. throw new Error(data.error);
  9126. }
  9127. if (intentState.operatorList) {
  9128. intentState.operatorList.lastChunk = true;
  9129. for (var i = 0; i < intentState.renderTasks.length; i++) {
  9130. intentState.renderTasks[i].operatorListChanged();
  9131. }
  9132. }
  9133. }, this);
  9134. messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this);
  9135. messageHandler.on('JpegDecode', function (data) {
  9136. if (this.destroyed) {
  9137. return Promise.reject(new Error('Worker was destroyed'));
  9138. }
  9139. if (typeof document === 'undefined') {
  9140. return Promise.reject(new Error('"document" is not defined.'));
  9141. }
  9142. var _data3 = _slicedToArray(data, 2),
  9143. imageUrl = _data3[0],
  9144. components = _data3[1];
  9145. if (components !== 3 && components !== 1) {
  9146. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  9147. }
  9148. return new Promise(function (resolve, reject) {
  9149. var img = new Image();
  9150. img.onload = function () {
  9151. var width = img.width;
  9152. var height = img.height;
  9153. var size = width * height;
  9154. var rgbaLength = size * 4;
  9155. var buf = new Uint8ClampedArray(size * components);
  9156. var tmpCanvas = document.createElement('canvas');
  9157. tmpCanvas.width = width;
  9158. tmpCanvas.height = height;
  9159. var tmpCtx = tmpCanvas.getContext('2d');
  9160. tmpCtx.drawImage(img, 0, 0);
  9161. var data = tmpCtx.getImageData(0, 0, width, height).data;
  9162. if (components === 3) {
  9163. for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  9164. buf[j] = data[i];
  9165. buf[j + 1] = data[i + 1];
  9166. buf[j + 2] = data[i + 2];
  9167. }
  9168. } else if (components === 1) {
  9169. for (var _i2 = 0, _j = 0; _i2 < rgbaLength; _i2 += 4, _j++) {
  9170. buf[_j] = data[_i2];
  9171. }
  9172. }
  9173. resolve({
  9174. data: buf,
  9175. width: width,
  9176. height: height
  9177. });
  9178. };
  9179. img.onerror = function () {
  9180. reject(new Error('JpegDecode failed to load image'));
  9181. };
  9182. img.src = imageUrl;
  9183. });
  9184. }, this);
  9185. messageHandler.on('FetchBuiltInCMap', function (data) {
  9186. if (this.destroyed) {
  9187. return Promise.reject(new Error('Worker was destroyed'));
  9188. }
  9189. return this.CMapReaderFactory.fetch({
  9190. name: data.name
  9191. });
  9192. }, this);
  9193. }
  9194. }, {
  9195. key: "_onUnsupportedFeature",
  9196. value: function _onUnsupportedFeature(_ref10) {
  9197. var featureId = _ref10.featureId;
  9198. if (this.destroyed) {
  9199. return;
  9200. }
  9201. if (this.loadingTask.onUnsupportedFeature) {
  9202. this.loadingTask.onUnsupportedFeature(featureId);
  9203. }
  9204. }
  9205. }, {
  9206. key: "getData",
  9207. value: function getData() {
  9208. return this.messageHandler.sendWithPromise('GetData', null);
  9209. }
  9210. }, {
  9211. key: "getPage",
  9212. value: function getPage(pageNumber) {
  9213. var _this13 = this;
  9214. if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  9215. return Promise.reject(new Error('Invalid page request'));
  9216. }
  9217. var pageIndex = pageNumber - 1;
  9218. if (pageIndex in this.pagePromises) {
  9219. return this.pagePromises[pageIndex];
  9220. }
  9221. var promise = this.messageHandler.sendWithPromise('GetPage', {
  9222. pageIndex: pageIndex
  9223. }).then(function (pageInfo) {
  9224. if (_this13.destroyed) {
  9225. throw new Error('Transport destroyed');
  9226. }
  9227. var page = new PDFPageProxy(pageIndex, pageInfo, _this13, _this13._params.pdfBug);
  9228. _this13.pageCache[pageIndex] = page;
  9229. return page;
  9230. });
  9231. this.pagePromises[pageIndex] = promise;
  9232. return promise;
  9233. }
  9234. }, {
  9235. key: "getPageIndex",
  9236. value: function getPageIndex(ref) {
  9237. return this.messageHandler.sendWithPromise('GetPageIndex', {
  9238. ref: ref
  9239. }).catch(function (reason) {
  9240. return Promise.reject(new Error(reason));
  9241. });
  9242. }
  9243. }, {
  9244. key: "getAnnotations",
  9245. value: function getAnnotations(pageIndex, intent) {
  9246. return this.messageHandler.sendWithPromise('GetAnnotations', {
  9247. pageIndex: pageIndex,
  9248. intent: intent
  9249. });
  9250. }
  9251. }, {
  9252. key: "getDestinations",
  9253. value: function getDestinations() {
  9254. return this.messageHandler.sendWithPromise('GetDestinations', null);
  9255. }
  9256. }, {
  9257. key: "getDestination",
  9258. value: function getDestination(id) {
  9259. if (typeof id !== 'string') {
  9260. return Promise.reject(new Error('Invalid destination request.'));
  9261. }
  9262. return this.messageHandler.sendWithPromise('GetDestination', {
  9263. id: id
  9264. });
  9265. }
  9266. }, {
  9267. key: "getPageLabels",
  9268. value: function getPageLabels() {
  9269. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  9270. }
  9271. }, {
  9272. key: "getPageMode",
  9273. value: function getPageMode() {
  9274. return this.messageHandler.sendWithPromise('GetPageMode', null);
  9275. }
  9276. }, {
  9277. key: "getOpenActionDestination",
  9278. value: function getOpenActionDestination() {
  9279. return this.messageHandler.sendWithPromise('getOpenActionDestination', null);
  9280. }
  9281. }, {
  9282. key: "getAttachments",
  9283. value: function getAttachments() {
  9284. return this.messageHandler.sendWithPromise('GetAttachments', null);
  9285. }
  9286. }, {
  9287. key: "getJavaScript",
  9288. value: function getJavaScript() {
  9289. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  9290. }
  9291. }, {
  9292. key: "getOutline",
  9293. value: function getOutline() {
  9294. return this.messageHandler.sendWithPromise('GetOutline', null);
  9295. }
  9296. }, {
  9297. key: "getPermissions",
  9298. value: function getPermissions() {
  9299. return this.messageHandler.sendWithPromise('GetPermissions', null);
  9300. }
  9301. }, {
  9302. key: "getMetadata",
  9303. value: function getMetadata() {
  9304. var _this14 = this;
  9305. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function (results) {
  9306. return {
  9307. info: results[0],
  9308. metadata: results[1] ? new _metadata.Metadata(results[1]) : null,
  9309. contentDispositionFilename: _this14._fullReader ? _this14._fullReader.filename : null
  9310. };
  9311. });
  9312. }
  9313. }, {
  9314. key: "getStats",
  9315. value: function getStats() {
  9316. return this.messageHandler.sendWithPromise('GetStats', null);
  9317. }
  9318. }, {
  9319. key: "startCleanup",
  9320. value: function startCleanup() {
  9321. var _this15 = this;
  9322. this.messageHandler.sendWithPromise('Cleanup', null).then(function () {
  9323. for (var i = 0, ii = _this15.pageCache.length; i < ii; i++) {
  9324. var page = _this15.pageCache[i];
  9325. if (page) {
  9326. page.cleanup();
  9327. }
  9328. }
  9329. _this15.commonObjs.clear();
  9330. _this15.fontLoader.clear();
  9331. });
  9332. }
  9333. }, {
  9334. key: "loadingParams",
  9335. get: function get() {
  9336. var params = this._params;
  9337. return (0, _util.shadow)(this, 'loadingParams', {
  9338. disableAutoFetch: params.disableAutoFetch,
  9339. disableCreateObjectURL: params.disableCreateObjectURL,
  9340. disableFontFace: params.disableFontFace,
  9341. nativeImageDecoderSupport: params.nativeImageDecoderSupport
  9342. });
  9343. }
  9344. }]);
  9345. return WorkerTransport;
  9346. }();
  9347. var PDFObjects =
  9348. /*#__PURE__*/
  9349. function () {
  9350. function PDFObjects() {
  9351. _classCallCheck(this, PDFObjects);
  9352. this._objs = Object.create(null);
  9353. }
  9354. _createClass(PDFObjects, [{
  9355. key: "_ensureObj",
  9356. value: function _ensureObj(objId) {
  9357. if (this._objs[objId]) {
  9358. return this._objs[objId];
  9359. }
  9360. return this._objs[objId] = {
  9361. capability: (0, _util.createPromiseCapability)(),
  9362. data: null,
  9363. resolved: false
  9364. };
  9365. }
  9366. }, {
  9367. key: "get",
  9368. value: function get(objId) {
  9369. var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  9370. if (callback) {
  9371. this._ensureObj(objId).capability.promise.then(callback);
  9372. return null;
  9373. }
  9374. var obj = this._objs[objId];
  9375. if (!obj || !obj.resolved) {
  9376. throw new Error("Requesting object that isn't resolved yet ".concat(objId, "."));
  9377. }
  9378. return obj.data;
  9379. }
  9380. }, {
  9381. key: "has",
  9382. value: function has(objId) {
  9383. var obj = this._objs[objId];
  9384. return obj ? obj.resolved : false;
  9385. }
  9386. }, {
  9387. key: "resolve",
  9388. value: function resolve(objId, data) {
  9389. var obj = this._ensureObj(objId);
  9390. obj.resolved = true;
  9391. obj.data = data;
  9392. obj.capability.resolve(data);
  9393. }
  9394. }, {
  9395. key: "clear",
  9396. value: function clear() {
  9397. this._objs = Object.create(null);
  9398. }
  9399. }]);
  9400. return PDFObjects;
  9401. }();
  9402. var RenderTask =
  9403. /*#__PURE__*/
  9404. function () {
  9405. function RenderTask(internalRenderTask) {
  9406. _classCallCheck(this, RenderTask);
  9407. this._internalRenderTask = internalRenderTask;
  9408. this.onContinue = null;
  9409. }
  9410. _createClass(RenderTask, [{
  9411. key: "cancel",
  9412. value: function cancel() {
  9413. this._internalRenderTask.cancel();
  9414. }
  9415. }, {
  9416. key: "then",
  9417. value: function then(onFulfilled, onRejected) {
  9418. (0, _util.deprecated)('RenderTask.then method, use the `promise` getter instead.');
  9419. return this.promise.then.apply(this.promise, arguments);
  9420. }
  9421. }, {
  9422. key: "promise",
  9423. get: function get() {
  9424. return this._internalRenderTask.capability.promise;
  9425. }
  9426. }]);
  9427. return RenderTask;
  9428. }();
  9429. var InternalRenderTask = function InternalRenderTaskClosure() {
  9430. var canvasInRendering = new WeakSet();
  9431. var InternalRenderTask =
  9432. /*#__PURE__*/
  9433. function () {
  9434. function InternalRenderTask(_ref11) {
  9435. var callback = _ref11.callback,
  9436. params = _ref11.params,
  9437. objs = _ref11.objs,
  9438. commonObjs = _ref11.commonObjs,
  9439. operatorList = _ref11.operatorList,
  9440. pageNumber = _ref11.pageNumber,
  9441. canvasFactory = _ref11.canvasFactory,
  9442. webGLContext = _ref11.webGLContext,
  9443. _ref11$useRequestAnim = _ref11.useRequestAnimationFrame,
  9444. useRequestAnimationFrame = _ref11$useRequestAnim === void 0 ? false : _ref11$useRequestAnim,
  9445. _ref11$pdfBug = _ref11.pdfBug,
  9446. pdfBug = _ref11$pdfBug === void 0 ? false : _ref11$pdfBug;
  9447. _classCallCheck(this, InternalRenderTask);
  9448. this.callback = callback;
  9449. this.params = params;
  9450. this.objs = objs;
  9451. this.commonObjs = commonObjs;
  9452. this.operatorListIdx = null;
  9453. this.operatorList = operatorList;
  9454. this.pageNumber = pageNumber;
  9455. this.canvasFactory = canvasFactory;
  9456. this.webGLContext = webGLContext;
  9457. this._pdfBug = pdfBug;
  9458. this.running = false;
  9459. this.graphicsReadyCallback = null;
  9460. this.graphicsReady = false;
  9461. this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== 'undefined';
  9462. this.cancelled = false;
  9463. this.capability = (0, _util.createPromiseCapability)();
  9464. this.task = new RenderTask(this);
  9465. this._continueBound = this._continue.bind(this);
  9466. this._scheduleNextBound = this._scheduleNext.bind(this);
  9467. this._nextBound = this._next.bind(this);
  9468. this._canvas = params.canvasContext.canvas;
  9469. }
  9470. _createClass(InternalRenderTask, [{
  9471. key: "initializeGraphics",
  9472. value: function initializeGraphics() {
  9473. var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  9474. if (this.cancelled) {
  9475. return;
  9476. }
  9477. if (this._canvas) {
  9478. if (canvasInRendering.has(this._canvas)) {
  9479. throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
  9480. }
  9481. canvasInRendering.add(this._canvas);
  9482. }
  9483. if (this._pdfBug && _global_scope.default.StepperManager && _global_scope.default.StepperManager.enabled) {
  9484. this.stepper = _global_scope.default.StepperManager.create(this.pageNumber - 1);
  9485. this.stepper.init(this.operatorList);
  9486. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  9487. }
  9488. var _this$params = this.params,
  9489. canvasContext = _this$params.canvasContext,
  9490. viewport = _this$params.viewport,
  9491. transform = _this$params.transform,
  9492. imageLayer = _this$params.imageLayer,
  9493. background = _this$params.background;
  9494. this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, imageLayer);
  9495. this.gfx.beginDrawing({
  9496. transform: transform,
  9497. viewport: viewport,
  9498. transparency: transparency,
  9499. background: background
  9500. });
  9501. this.operatorListIdx = 0;
  9502. this.graphicsReady = true;
  9503. if (this.graphicsReadyCallback) {
  9504. this.graphicsReadyCallback();
  9505. }
  9506. }
  9507. }, {
  9508. key: "cancel",
  9509. value: function cancel() {
  9510. var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  9511. this.running = false;
  9512. this.cancelled = true;
  9513. if (this.gfx) {
  9514. this.gfx.endDrawing();
  9515. }
  9516. if (this._canvas) {
  9517. canvasInRendering.delete(this._canvas);
  9518. }
  9519. this.callback(error || new _dom_utils.RenderingCancelledException("Rendering cancelled, page ".concat(this.pageNumber), 'canvas'));
  9520. }
  9521. }, {
  9522. key: "operatorListChanged",
  9523. value: function operatorListChanged() {
  9524. if (!this.graphicsReady) {
  9525. if (!this.graphicsReadyCallback) {
  9526. this.graphicsReadyCallback = this._continueBound;
  9527. }
  9528. return;
  9529. }
  9530. if (this.stepper) {
  9531. this.stepper.updateOperatorList(this.operatorList);
  9532. }
  9533. if (this.running) {
  9534. return;
  9535. }
  9536. this._continue();
  9537. }
  9538. }, {
  9539. key: "_continue",
  9540. value: function _continue() {
  9541. this.running = true;
  9542. if (this.cancelled) {
  9543. return;
  9544. }
  9545. if (this.task.onContinue) {
  9546. this.task.onContinue(this._scheduleNextBound);
  9547. } else {
  9548. this._scheduleNext();
  9549. }
  9550. }
  9551. }, {
  9552. key: "_scheduleNext",
  9553. value: function _scheduleNext() {
  9554. var _this16 = this;
  9555. if (this._useRequestAnimationFrame) {
  9556. window.requestAnimationFrame(function () {
  9557. _this16._nextBound().catch(_this16.cancel.bind(_this16));
  9558. });
  9559. } else {
  9560. Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this));
  9561. }
  9562. }
  9563. }, {
  9564. key: "_next",
  9565. value: function () {
  9566. var _next2 = _asyncToGenerator(
  9567. /*#__PURE__*/
  9568. _regenerator.default.mark(function _callee() {
  9569. return _regenerator.default.wrap(function _callee$(_context) {
  9570. while (1) {
  9571. switch (_context.prev = _context.next) {
  9572. case 0:
  9573. if (!this.cancelled) {
  9574. _context.next = 2;
  9575. break;
  9576. }
  9577. return _context.abrupt("return");
  9578. case 2:
  9579. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  9580. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  9581. this.running = false;
  9582. if (this.operatorList.lastChunk) {
  9583. this.gfx.endDrawing();
  9584. if (this._canvas) {
  9585. canvasInRendering.delete(this._canvas);
  9586. }
  9587. this.callback();
  9588. }
  9589. }
  9590. case 4:
  9591. case "end":
  9592. return _context.stop();
  9593. }
  9594. }
  9595. }, _callee, this);
  9596. }));
  9597. function _next() {
  9598. return _next2.apply(this, arguments);
  9599. }
  9600. return _next;
  9601. }()
  9602. }]);
  9603. return InternalRenderTask;
  9604. }();
  9605. return InternalRenderTask;
  9606. }();
  9607. var version = '2.1.266';
  9608. exports.version = version;
  9609. var build = '81f5835c';
  9610. exports.build = build;
  9611. /***/ }),
  9612. /* 147 */
  9613. /***/ (function(module, exports, __w_pdfjs_require__) {
  9614. "use strict";
  9615. module.exports = __w_pdfjs_require__(148);
  9616. /***/ }),
  9617. /* 148 */
  9618. /***/ (function(module, exports, __w_pdfjs_require__) {
  9619. "use strict";
  9620. function _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); }
  9621. var g = function () {
  9622. return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self;
  9623. }() || Function("return this")();
  9624. var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  9625. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  9626. g.regeneratorRuntime = undefined;
  9627. module.exports = __w_pdfjs_require__(149);
  9628. if (hadRuntime) {
  9629. g.regeneratorRuntime = oldRuntime;
  9630. } else {
  9631. try {
  9632. delete g.regeneratorRuntime;
  9633. } catch (e) {
  9634. g.regeneratorRuntime = undefined;
  9635. }
  9636. }
  9637. /***/ }),
  9638. /* 149 */
  9639. /***/ (function(module, exports, __w_pdfjs_require__) {
  9640. "use strict";
  9641. /* WEBPACK VAR INJECTION */(function(module) {
  9642. function _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); }
  9643. !function (global) {
  9644. "use strict";
  9645. var Op = Object.prototype;
  9646. var hasOwn = Op.hasOwnProperty;
  9647. var undefined;
  9648. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  9649. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  9650. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  9651. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  9652. var inModule = ( false ? undefined : _typeof(module)) === "object";
  9653. var runtime = global.regeneratorRuntime;
  9654. if (runtime) {
  9655. if (inModule) {
  9656. module.exports = runtime;
  9657. }
  9658. return;
  9659. }
  9660. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  9661. function wrap(innerFn, outerFn, self, tryLocsList) {
  9662. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  9663. var generator = Object.create(protoGenerator.prototype);
  9664. var context = new Context(tryLocsList || []);
  9665. generator._invoke = makeInvokeMethod(innerFn, self, context);
  9666. return generator;
  9667. }
  9668. runtime.wrap = wrap;
  9669. function tryCatch(fn, obj, arg) {
  9670. try {
  9671. return {
  9672. type: "normal",
  9673. arg: fn.call(obj, arg)
  9674. };
  9675. } catch (err) {
  9676. return {
  9677. type: "throw",
  9678. arg: err
  9679. };
  9680. }
  9681. }
  9682. var GenStateSuspendedStart = "suspendedStart";
  9683. var GenStateSuspendedYield = "suspendedYield";
  9684. var GenStateExecuting = "executing";
  9685. var GenStateCompleted = "completed";
  9686. var ContinueSentinel = {};
  9687. function Generator() {}
  9688. function GeneratorFunction() {}
  9689. function GeneratorFunctionPrototype() {}
  9690. var IteratorPrototype = {};
  9691. IteratorPrototype[iteratorSymbol] = function () {
  9692. return this;
  9693. };
  9694. var getProto = Object.getPrototypeOf;
  9695. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  9696. if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  9697. IteratorPrototype = NativeIteratorPrototype;
  9698. }
  9699. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  9700. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  9701. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  9702. GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction";
  9703. function defineIteratorMethods(prototype) {
  9704. ["next", "throw", "return"].forEach(function (method) {
  9705. prototype[method] = function (arg) {
  9706. return this._invoke(method, arg);
  9707. };
  9708. });
  9709. }
  9710. runtime.isGeneratorFunction = function (genFun) {
  9711. var ctor = typeof genFun === "function" && genFun.constructor;
  9712. return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
  9713. };
  9714. runtime.mark = function (genFun) {
  9715. if (Object.setPrototypeOf) {
  9716. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  9717. } else {
  9718. genFun.__proto__ = GeneratorFunctionPrototype;
  9719. if (!(toStringTagSymbol in genFun)) {
  9720. genFun[toStringTagSymbol] = "GeneratorFunction";
  9721. }
  9722. }
  9723. genFun.prototype = Object.create(Gp);
  9724. return genFun;
  9725. };
  9726. runtime.awrap = function (arg) {
  9727. return {
  9728. __await: arg
  9729. };
  9730. };
  9731. function AsyncIterator(generator) {
  9732. function invoke(method, arg, resolve, reject) {
  9733. var record = tryCatch(generator[method], generator, arg);
  9734. if (record.type === "throw") {
  9735. reject(record.arg);
  9736. } else {
  9737. var result = record.arg;
  9738. var value = result.value;
  9739. if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
  9740. return Promise.resolve(value.__await).then(function (value) {
  9741. invoke("next", value, resolve, reject);
  9742. }, function (err) {
  9743. invoke("throw", err, resolve, reject);
  9744. });
  9745. }
  9746. return Promise.resolve(value).then(function (unwrapped) {
  9747. result.value = unwrapped;
  9748. resolve(result);
  9749. }, function (error) {
  9750. return invoke("throw", error, resolve, reject);
  9751. });
  9752. }
  9753. }
  9754. var previousPromise;
  9755. function enqueue(method, arg) {
  9756. function callInvokeWithMethodAndArg() {
  9757. return new Promise(function (resolve, reject) {
  9758. invoke(method, arg, resolve, reject);
  9759. });
  9760. }
  9761. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  9762. }
  9763. this._invoke = enqueue;
  9764. }
  9765. defineIteratorMethods(AsyncIterator.prototype);
  9766. AsyncIterator.prototype[asyncIteratorSymbol] = function () {
  9767. return this;
  9768. };
  9769. runtime.AsyncIterator = AsyncIterator;
  9770. runtime.async = function (innerFn, outerFn, self, tryLocsList) {
  9771. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
  9772. return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  9773. return result.done ? result.value : iter.next();
  9774. });
  9775. };
  9776. function makeInvokeMethod(innerFn, self, context) {
  9777. var state = GenStateSuspendedStart;
  9778. return function invoke(method, arg) {
  9779. if (state === GenStateExecuting) {
  9780. throw new Error("Generator is already running");
  9781. }
  9782. if (state === GenStateCompleted) {
  9783. if (method === "throw") {
  9784. throw arg;
  9785. }
  9786. return doneResult();
  9787. }
  9788. context.method = method;
  9789. context.arg = arg;
  9790. while (true) {
  9791. var delegate = context.delegate;
  9792. if (delegate) {
  9793. var delegateResult = maybeInvokeDelegate(delegate, context);
  9794. if (delegateResult) {
  9795. if (delegateResult === ContinueSentinel) continue;
  9796. return delegateResult;
  9797. }
  9798. }
  9799. if (context.method === "next") {
  9800. context.sent = context._sent = context.arg;
  9801. } else if (context.method === "throw") {
  9802. if (state === GenStateSuspendedStart) {
  9803. state = GenStateCompleted;
  9804. throw context.arg;
  9805. }
  9806. context.dispatchException(context.arg);
  9807. } else if (context.method === "return") {
  9808. context.abrupt("return", context.arg);
  9809. }
  9810. state = GenStateExecuting;
  9811. var record = tryCatch(innerFn, self, context);
  9812. if (record.type === "normal") {
  9813. state = context.done ? GenStateCompleted : GenStateSuspendedYield;
  9814. if (record.arg === ContinueSentinel) {
  9815. continue;
  9816. }
  9817. return {
  9818. value: record.arg,
  9819. done: context.done
  9820. };
  9821. } else if (record.type === "throw") {
  9822. state = GenStateCompleted;
  9823. context.method = "throw";
  9824. context.arg = record.arg;
  9825. }
  9826. }
  9827. };
  9828. }
  9829. function maybeInvokeDelegate(delegate, context) {
  9830. var method = delegate.iterator[context.method];
  9831. if (method === undefined) {
  9832. context.delegate = null;
  9833. if (context.method === "throw") {
  9834. if (delegate.iterator.return) {
  9835. context.method = "return";
  9836. context.arg = undefined;
  9837. maybeInvokeDelegate(delegate, context);
  9838. if (context.method === "throw") {
  9839. return ContinueSentinel;
  9840. }
  9841. }
  9842. context.method = "throw";
  9843. context.arg = new TypeError("The iterator does not provide a 'throw' method");
  9844. }
  9845. return ContinueSentinel;
  9846. }
  9847. var record = tryCatch(method, delegate.iterator, context.arg);
  9848. if (record.type === "throw") {
  9849. context.method = "throw";
  9850. context.arg = record.arg;
  9851. context.delegate = null;
  9852. return ContinueSentinel;
  9853. }
  9854. var info = record.arg;
  9855. if (!info) {
  9856. context.method = "throw";
  9857. context.arg = new TypeError("iterator result is not an object");
  9858. context.delegate = null;
  9859. return ContinueSentinel;
  9860. }
  9861. if (info.done) {
  9862. context[delegate.resultName] = info.value;
  9863. context.next = delegate.nextLoc;
  9864. if (context.method !== "return") {
  9865. context.method = "next";
  9866. context.arg = undefined;
  9867. }
  9868. } else {
  9869. return info;
  9870. }
  9871. context.delegate = null;
  9872. return ContinueSentinel;
  9873. }
  9874. defineIteratorMethods(Gp);
  9875. Gp[toStringTagSymbol] = "Generator";
  9876. Gp[iteratorSymbol] = function () {
  9877. return this;
  9878. };
  9879. Gp.toString = function () {
  9880. return "[object Generator]";
  9881. };
  9882. function pushTryEntry(locs) {
  9883. var entry = {
  9884. tryLoc: locs[0]
  9885. };
  9886. if (1 in locs) {
  9887. entry.catchLoc = locs[1];
  9888. }
  9889. if (2 in locs) {
  9890. entry.finallyLoc = locs[2];
  9891. entry.afterLoc = locs[3];
  9892. }
  9893. this.tryEntries.push(entry);
  9894. }
  9895. function resetTryEntry(entry) {
  9896. var record = entry.completion || {};
  9897. record.type = "normal";
  9898. delete record.arg;
  9899. entry.completion = record;
  9900. }
  9901. function Context(tryLocsList) {
  9902. this.tryEntries = [{
  9903. tryLoc: "root"
  9904. }];
  9905. tryLocsList.forEach(pushTryEntry, this);
  9906. this.reset(true);
  9907. }
  9908. runtime.keys = function (object) {
  9909. var keys = [];
  9910. for (var key in object) {
  9911. keys.push(key);
  9912. }
  9913. keys.reverse();
  9914. return function next() {
  9915. while (keys.length) {
  9916. var key = keys.pop();
  9917. if (key in object) {
  9918. next.value = key;
  9919. next.done = false;
  9920. return next;
  9921. }
  9922. }
  9923. next.done = true;
  9924. return next;
  9925. };
  9926. };
  9927. function values(iterable) {
  9928. if (iterable) {
  9929. var iteratorMethod = iterable[iteratorSymbol];
  9930. if (iteratorMethod) {
  9931. return iteratorMethod.call(iterable);
  9932. }
  9933. if (typeof iterable.next === "function") {
  9934. return iterable;
  9935. }
  9936. if (!isNaN(iterable.length)) {
  9937. var i = -1,
  9938. next = function next() {
  9939. while (++i < iterable.length) {
  9940. if (hasOwn.call(iterable, i)) {
  9941. next.value = iterable[i];
  9942. next.done = false;
  9943. return next;
  9944. }
  9945. }
  9946. next.value = undefined;
  9947. next.done = true;
  9948. return next;
  9949. };
  9950. return next.next = next;
  9951. }
  9952. }
  9953. return {
  9954. next: doneResult
  9955. };
  9956. }
  9957. runtime.values = values;
  9958. function doneResult() {
  9959. return {
  9960. value: undefined,
  9961. done: true
  9962. };
  9963. }
  9964. Context.prototype = {
  9965. constructor: Context,
  9966. reset: function reset(skipTempReset) {
  9967. this.prev = 0;
  9968. this.next = 0;
  9969. this.sent = this._sent = undefined;
  9970. this.done = false;
  9971. this.delegate = null;
  9972. this.method = "next";
  9973. this.arg = undefined;
  9974. this.tryEntries.forEach(resetTryEntry);
  9975. if (!skipTempReset) {
  9976. for (var name in this) {
  9977. if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
  9978. this[name] = undefined;
  9979. }
  9980. }
  9981. }
  9982. },
  9983. stop: function stop() {
  9984. this.done = true;
  9985. var rootEntry = this.tryEntries[0];
  9986. var rootRecord = rootEntry.completion;
  9987. if (rootRecord.type === "throw") {
  9988. throw rootRecord.arg;
  9989. }
  9990. return this.rval;
  9991. },
  9992. dispatchException: function dispatchException(exception) {
  9993. if (this.done) {
  9994. throw exception;
  9995. }
  9996. var context = this;
  9997. function handle(loc, caught) {
  9998. record.type = "throw";
  9999. record.arg = exception;
  10000. context.next = loc;
  10001. if (caught) {
  10002. context.method = "next";
  10003. context.arg = undefined;
  10004. }
  10005. return !!caught;
  10006. }
  10007. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10008. var entry = this.tryEntries[i];
  10009. var record = entry.completion;
  10010. if (entry.tryLoc === "root") {
  10011. return handle("end");
  10012. }
  10013. if (entry.tryLoc <= this.prev) {
  10014. var hasCatch = hasOwn.call(entry, "catchLoc");
  10015. var hasFinally = hasOwn.call(entry, "finallyLoc");
  10016. if (hasCatch && hasFinally) {
  10017. if (this.prev < entry.catchLoc) {
  10018. return handle(entry.catchLoc, true);
  10019. } else if (this.prev < entry.finallyLoc) {
  10020. return handle(entry.finallyLoc);
  10021. }
  10022. } else if (hasCatch) {
  10023. if (this.prev < entry.catchLoc) {
  10024. return handle(entry.catchLoc, true);
  10025. }
  10026. } else if (hasFinally) {
  10027. if (this.prev < entry.finallyLoc) {
  10028. return handle(entry.finallyLoc);
  10029. }
  10030. } else {
  10031. throw new Error("try statement without catch or finally");
  10032. }
  10033. }
  10034. }
  10035. },
  10036. abrupt: function abrupt(type, arg) {
  10037. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10038. var entry = this.tryEntries[i];
  10039. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  10040. var finallyEntry = entry;
  10041. break;
  10042. }
  10043. }
  10044. if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
  10045. finallyEntry = null;
  10046. }
  10047. var record = finallyEntry ? finallyEntry.completion : {};
  10048. record.type = type;
  10049. record.arg = arg;
  10050. if (finallyEntry) {
  10051. this.method = "next";
  10052. this.next = finallyEntry.finallyLoc;
  10053. return ContinueSentinel;
  10054. }
  10055. return this.complete(record);
  10056. },
  10057. complete: function complete(record, afterLoc) {
  10058. if (record.type === "throw") {
  10059. throw record.arg;
  10060. }
  10061. if (record.type === "break" || record.type === "continue") {
  10062. this.next = record.arg;
  10063. } else if (record.type === "return") {
  10064. this.rval = this.arg = record.arg;
  10065. this.method = "return";
  10066. this.next = "end";
  10067. } else if (record.type === "normal" && afterLoc) {
  10068. this.next = afterLoc;
  10069. }
  10070. return ContinueSentinel;
  10071. },
  10072. finish: function finish(finallyLoc) {
  10073. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10074. var entry = this.tryEntries[i];
  10075. if (entry.finallyLoc === finallyLoc) {
  10076. this.complete(entry.completion, entry.afterLoc);
  10077. resetTryEntry(entry);
  10078. return ContinueSentinel;
  10079. }
  10080. }
  10081. },
  10082. "catch": function _catch(tryLoc) {
  10083. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  10084. var entry = this.tryEntries[i];
  10085. if (entry.tryLoc === tryLoc) {
  10086. var record = entry.completion;
  10087. if (record.type === "throw") {
  10088. var thrown = record.arg;
  10089. resetTryEntry(entry);
  10090. }
  10091. return thrown;
  10092. }
  10093. }
  10094. throw new Error("illegal catch attempt");
  10095. },
  10096. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  10097. this.delegate = {
  10098. iterator: values(iterable),
  10099. resultName: resultName,
  10100. nextLoc: nextLoc
  10101. };
  10102. if (this.method === "next") {
  10103. this.arg = undefined;
  10104. }
  10105. return ContinueSentinel;
  10106. }
  10107. };
  10108. }(function () {
  10109. return this || (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self;
  10110. }() || Function("return this")());
  10111. /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(150)(module)))
  10112. /***/ }),
  10113. /* 150 */
  10114. /***/ (function(module, exports, __w_pdfjs_require__) {
  10115. "use strict";
  10116. module.exports = function (module) {
  10117. if (!module.webpackPolyfill) {
  10118. module.deprecate = function () {};
  10119. module.paths = [];
  10120. if (!module.children) module.children = [];
  10121. Object.defineProperty(module, "loaded", {
  10122. enumerable: true,
  10123. get: function get() {
  10124. return module.l;
  10125. }
  10126. });
  10127. Object.defineProperty(module, "id", {
  10128. enumerable: true,
  10129. get: function get() {
  10130. return module.i;
  10131. }
  10132. });
  10133. module.webpackPolyfill = 1;
  10134. }
  10135. return module;
  10136. };
  10137. /***/ }),
  10138. /* 151 */
  10139. /***/ (function(module, exports, __w_pdfjs_require__) {
  10140. "use strict";
  10141. Object.defineProperty(exports, "__esModule", {
  10142. value: true
  10143. });
  10144. exports.addLinkAttributes = addLinkAttributes;
  10145. exports.getFilenameFromUrl = getFilenameFromUrl;
  10146. exports.loadScript = loadScript;
  10147. exports.DummyStatTimer = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
  10148. var _util = __w_pdfjs_require__(1);
  10149. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10150. 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); } }
  10151. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10152. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  10153. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  10154. var SVG_NS = 'http://www.w3.org/2000/svg';
  10155. var DOMCanvasFactory =
  10156. /*#__PURE__*/
  10157. function () {
  10158. function DOMCanvasFactory() {
  10159. _classCallCheck(this, DOMCanvasFactory);
  10160. }
  10161. _createClass(DOMCanvasFactory, [{
  10162. key: "create",
  10163. value: function create(width, height) {
  10164. if (width <= 0 || height <= 0) {
  10165. throw new Error('invalid canvas size');
  10166. }
  10167. var canvas = document.createElement('canvas');
  10168. var context = canvas.getContext('2d');
  10169. canvas.width = width;
  10170. canvas.height = height;
  10171. return {
  10172. canvas: canvas,
  10173. context: context
  10174. };
  10175. }
  10176. }, {
  10177. key: "reset",
  10178. value: function reset(canvasAndContext, width, height) {
  10179. if (!canvasAndContext.canvas) {
  10180. throw new Error('canvas is not specified');
  10181. }
  10182. if (width <= 0 || height <= 0) {
  10183. throw new Error('invalid canvas size');
  10184. }
  10185. canvasAndContext.canvas.width = width;
  10186. canvasAndContext.canvas.height = height;
  10187. }
  10188. }, {
  10189. key: "destroy",
  10190. value: function destroy(canvasAndContext) {
  10191. if (!canvasAndContext.canvas) {
  10192. throw new Error('canvas is not specified');
  10193. }
  10194. canvasAndContext.canvas.width = 0;
  10195. canvasAndContext.canvas.height = 0;
  10196. canvasAndContext.canvas = null;
  10197. canvasAndContext.context = null;
  10198. }
  10199. }]);
  10200. return DOMCanvasFactory;
  10201. }();
  10202. exports.DOMCanvasFactory = DOMCanvasFactory;
  10203. var DOMCMapReaderFactory =
  10204. /*#__PURE__*/
  10205. function () {
  10206. function DOMCMapReaderFactory(_ref) {
  10207. var _ref$baseUrl = _ref.baseUrl,
  10208. baseUrl = _ref$baseUrl === void 0 ? null : _ref$baseUrl,
  10209. _ref$isCompressed = _ref.isCompressed,
  10210. isCompressed = _ref$isCompressed === void 0 ? false : _ref$isCompressed;
  10211. _classCallCheck(this, DOMCMapReaderFactory);
  10212. this.baseUrl = baseUrl;
  10213. this.isCompressed = isCompressed;
  10214. }
  10215. _createClass(DOMCMapReaderFactory, [{
  10216. key: "fetch",
  10217. value: function fetch(_ref2) {
  10218. var _this = this;
  10219. var name = _ref2.name;
  10220. if (!this.baseUrl) {
  10221. return Promise.reject(new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.'));
  10222. }
  10223. if (!name) {
  10224. return Promise.reject(new Error('CMap name must be specified.'));
  10225. }
  10226. return new Promise(function (resolve, reject) {
  10227. var url = _this.baseUrl + name + (_this.isCompressed ? '.bcmap' : '');
  10228. var request = new XMLHttpRequest();
  10229. request.open('GET', url, true);
  10230. if (_this.isCompressed) {
  10231. request.responseType = 'arraybuffer';
  10232. }
  10233. request.onreadystatechange = function () {
  10234. if (request.readyState !== XMLHttpRequest.DONE) {
  10235. return;
  10236. }
  10237. if (request.status === 200 || request.status === 0) {
  10238. var data;
  10239. if (_this.isCompressed && request.response) {
  10240. data = new Uint8Array(request.response);
  10241. } else if (!_this.isCompressed && request.responseText) {
  10242. data = (0, _util.stringToBytes)(request.responseText);
  10243. }
  10244. if (data) {
  10245. resolve({
  10246. cMapData: data,
  10247. compressionType: _this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
  10248. });
  10249. return;
  10250. }
  10251. }
  10252. reject(new Error('Unable to load ' + (_this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
  10253. };
  10254. request.send(null);
  10255. });
  10256. }
  10257. }]);
  10258. return DOMCMapReaderFactory;
  10259. }();
  10260. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  10261. var DOMSVGFactory =
  10262. /*#__PURE__*/
  10263. function () {
  10264. function DOMSVGFactory() {
  10265. _classCallCheck(this, DOMSVGFactory);
  10266. }
  10267. _createClass(DOMSVGFactory, [{
  10268. key: "create",
  10269. value: function create(width, height) {
  10270. (0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions');
  10271. var svg = document.createElementNS(SVG_NS, 'svg:svg');
  10272. svg.setAttribute('version', '1.1');
  10273. svg.setAttribute('width', width + 'px');
  10274. svg.setAttribute('height', height + 'px');
  10275. svg.setAttribute('preserveAspectRatio', 'none');
  10276. svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
  10277. return svg;
  10278. }
  10279. }, {
  10280. key: "createElement",
  10281. value: function createElement(type) {
  10282. (0, _util.assert)(typeof type === 'string', 'Invalid SVG element type');
  10283. return document.createElementNS(SVG_NS, type);
  10284. }
  10285. }]);
  10286. return DOMSVGFactory;
  10287. }();
  10288. exports.DOMSVGFactory = DOMSVGFactory;
  10289. var PageViewport =
  10290. /*#__PURE__*/
  10291. function () {
  10292. function PageViewport(_ref3) {
  10293. var viewBox = _ref3.viewBox,
  10294. scale = _ref3.scale,
  10295. rotation = _ref3.rotation,
  10296. _ref3$offsetX = _ref3.offsetX,
  10297. offsetX = _ref3$offsetX === void 0 ? 0 : _ref3$offsetX,
  10298. _ref3$offsetY = _ref3.offsetY,
  10299. offsetY = _ref3$offsetY === void 0 ? 0 : _ref3$offsetY,
  10300. _ref3$dontFlip = _ref3.dontFlip,
  10301. dontFlip = _ref3$dontFlip === void 0 ? false : _ref3$dontFlip;
  10302. _classCallCheck(this, PageViewport);
  10303. this.viewBox = viewBox;
  10304. this.scale = scale;
  10305. this.rotation = rotation;
  10306. this.offsetX = offsetX;
  10307. this.offsetY = offsetY;
  10308. var centerX = (viewBox[2] + viewBox[0]) / 2;
  10309. var centerY = (viewBox[3] + viewBox[1]) / 2;
  10310. var rotateA, rotateB, rotateC, rotateD;
  10311. rotation = rotation % 360;
  10312. rotation = rotation < 0 ? rotation + 360 : rotation;
  10313. switch (rotation) {
  10314. case 180:
  10315. rotateA = -1;
  10316. rotateB = 0;
  10317. rotateC = 0;
  10318. rotateD = 1;
  10319. break;
  10320. case 90:
  10321. rotateA = 0;
  10322. rotateB = 1;
  10323. rotateC = 1;
  10324. rotateD = 0;
  10325. break;
  10326. case 270:
  10327. rotateA = 0;
  10328. rotateB = -1;
  10329. rotateC = -1;
  10330. rotateD = 0;
  10331. break;
  10332. default:
  10333. rotateA = 1;
  10334. rotateB = 0;
  10335. rotateC = 0;
  10336. rotateD = -1;
  10337. break;
  10338. }
  10339. if (dontFlip) {
  10340. rotateC = -rotateC;
  10341. rotateD = -rotateD;
  10342. }
  10343. var offsetCanvasX, offsetCanvasY;
  10344. var width, height;
  10345. if (rotateA === 0) {
  10346. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  10347. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  10348. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  10349. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  10350. } else {
  10351. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  10352. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  10353. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  10354. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  10355. }
  10356. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  10357. this.width = width;
  10358. this.height = height;
  10359. }
  10360. _createClass(PageViewport, [{
  10361. key: "clone",
  10362. value: function clone() {
  10363. var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  10364. _ref4$scale = _ref4.scale,
  10365. scale = _ref4$scale === void 0 ? this.scale : _ref4$scale,
  10366. _ref4$rotation = _ref4.rotation,
  10367. rotation = _ref4$rotation === void 0 ? this.rotation : _ref4$rotation,
  10368. _ref4$dontFlip = _ref4.dontFlip,
  10369. dontFlip = _ref4$dontFlip === void 0 ? false : _ref4$dontFlip;
  10370. return new PageViewport({
  10371. viewBox: this.viewBox.slice(),
  10372. scale: scale,
  10373. rotation: rotation,
  10374. offsetX: this.offsetX,
  10375. offsetY: this.offsetY,
  10376. dontFlip: dontFlip
  10377. });
  10378. }
  10379. }, {
  10380. key: "convertToViewportPoint",
  10381. value: function convertToViewportPoint(x, y) {
  10382. return _util.Util.applyTransform([x, y], this.transform);
  10383. }
  10384. }, {
  10385. key: "convertToViewportRectangle",
  10386. value: function convertToViewportRectangle(rect) {
  10387. var tl = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
  10388. var br = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
  10389. return [tl[0], tl[1], br[0], br[1]];
  10390. }
  10391. }, {
  10392. key: "convertToPdfPoint",
  10393. value: function convertToPdfPoint(x, y) {
  10394. return _util.Util.applyInverseTransform([x, y], this.transform);
  10395. }
  10396. }]);
  10397. return PageViewport;
  10398. }();
  10399. exports.PageViewport = PageViewport;
  10400. var RenderingCancelledException = function RenderingCancelledException() {
  10401. function RenderingCancelledException(msg, type) {
  10402. this.message = msg;
  10403. this.type = type;
  10404. }
  10405. RenderingCancelledException.prototype = new Error();
  10406. RenderingCancelledException.prototype.name = 'RenderingCancelledException';
  10407. RenderingCancelledException.constructor = RenderingCancelledException;
  10408. return RenderingCancelledException;
  10409. }();
  10410. exports.RenderingCancelledException = RenderingCancelledException;
  10411. var LinkTarget = {
  10412. NONE: 0,
  10413. SELF: 1,
  10414. BLANK: 2,
  10415. PARENT: 3,
  10416. TOP: 4
  10417. };
  10418. exports.LinkTarget = LinkTarget;
  10419. var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
  10420. function addLinkAttributes(link) {
  10421. var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  10422. url = _ref5.url,
  10423. target = _ref5.target,
  10424. rel = _ref5.rel;
  10425. link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
  10426. if (url) {
  10427. var LinkTargetValues = Object.values(LinkTarget);
  10428. var targetIndex = LinkTargetValues.includes(target) ? target : LinkTarget.NONE;
  10429. link.target = LinkTargetStringMap[targetIndex];
  10430. link.rel = typeof rel === 'string' ? rel : DEFAULT_LINK_REL;
  10431. }
  10432. }
  10433. function getFilenameFromUrl(url) {
  10434. var anchor = url.indexOf('#');
  10435. var query = url.indexOf('?');
  10436. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  10437. return url.substring(url.lastIndexOf('/', end) + 1, end);
  10438. }
  10439. var StatTimer =
  10440. /*#__PURE__*/
  10441. function () {
  10442. function StatTimer() {
  10443. var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  10444. _classCallCheck(this, StatTimer);
  10445. this.enabled = !!enable;
  10446. this.started = Object.create(null);
  10447. this.times = [];
  10448. }
  10449. _createClass(StatTimer, [{
  10450. key: "time",
  10451. value: function time(name) {
  10452. if (!this.enabled) {
  10453. return;
  10454. }
  10455. if (name in this.started) {
  10456. (0, _util.warn)('Timer is already running for ' + name);
  10457. }
  10458. this.started[name] = Date.now();
  10459. }
  10460. }, {
  10461. key: "timeEnd",
  10462. value: function timeEnd(name) {
  10463. if (!this.enabled) {
  10464. return;
  10465. }
  10466. if (!(name in this.started)) {
  10467. (0, _util.warn)('Timer has not been started for ' + name);
  10468. }
  10469. this.times.push({
  10470. 'name': name,
  10471. 'start': this.started[name],
  10472. 'end': Date.now()
  10473. });
  10474. delete this.started[name];
  10475. }
  10476. }, {
  10477. key: "toString",
  10478. value: function toString() {
  10479. var times = this.times;
  10480. var out = '',
  10481. longest = 0;
  10482. for (var i = 0, ii = times.length; i < ii; ++i) {
  10483. var name = times[i]['name'];
  10484. if (name.length > longest) {
  10485. longest = name.length;
  10486. }
  10487. }
  10488. for (var _i = 0, _ii = times.length; _i < _ii; ++_i) {
  10489. var span = times[_i];
  10490. var duration = span.end - span.start;
  10491. out += "".concat(span['name'].padEnd(longest), " ").concat(duration, "ms\n");
  10492. }
  10493. return out;
  10494. }
  10495. }]);
  10496. return StatTimer;
  10497. }();
  10498. exports.StatTimer = StatTimer;
  10499. var DummyStatTimer =
  10500. /*#__PURE__*/
  10501. function () {
  10502. function DummyStatTimer() {
  10503. _classCallCheck(this, DummyStatTimer);
  10504. (0, _util.unreachable)('Cannot initialize DummyStatTimer.');
  10505. }
  10506. _createClass(DummyStatTimer, null, [{
  10507. key: "time",
  10508. value: function time(name) {}
  10509. }, {
  10510. key: "timeEnd",
  10511. value: function timeEnd(name) {}
  10512. }, {
  10513. key: "toString",
  10514. value: function toString() {
  10515. return '';
  10516. }
  10517. }]);
  10518. return DummyStatTimer;
  10519. }();
  10520. exports.DummyStatTimer = DummyStatTimer;
  10521. function loadScript(src) {
  10522. return new Promise(function (resolve, reject) {
  10523. var script = document.createElement('script');
  10524. script.src = src;
  10525. script.onload = resolve;
  10526. script.onerror = function () {
  10527. reject(new Error("Cannot load script at: ".concat(script.src)));
  10528. };
  10529. (document.head || document.documentElement).appendChild(script);
  10530. });
  10531. }
  10532. /***/ }),
  10533. /* 152 */
  10534. /***/ (function(module, exports, __w_pdfjs_require__) {
  10535. "use strict";
  10536. Object.defineProperty(exports, "__esModule", {
  10537. value: true
  10538. });
  10539. exports.FontLoader = exports.FontFaceObject = void 0;
  10540. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  10541. var _util = __w_pdfjs_require__(1);
  10542. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10543. function _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); }
  10544. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10545. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  10546. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  10547. function _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); }
  10548. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  10549. 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); } }
  10550. 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); }); }; }
  10551. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10552. 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); } }
  10553. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10554. var BaseFontLoader =
  10555. /*#__PURE__*/
  10556. function () {
  10557. function BaseFontLoader(_ref) {
  10558. var docId = _ref.docId,
  10559. onUnsupportedFeature = _ref.onUnsupportedFeature;
  10560. _classCallCheck(this, BaseFontLoader);
  10561. if (this.constructor === BaseFontLoader) {
  10562. (0, _util.unreachable)('Cannot initialize BaseFontLoader.');
  10563. }
  10564. this.docId = docId;
  10565. this._onUnsupportedFeature = onUnsupportedFeature;
  10566. this.nativeFontFaces = [];
  10567. this.styleElement = null;
  10568. }
  10569. _createClass(BaseFontLoader, [{
  10570. key: "addNativeFontFace",
  10571. value: function addNativeFontFace(nativeFontFace) {
  10572. this.nativeFontFaces.push(nativeFontFace);
  10573. document.fonts.add(nativeFontFace);
  10574. }
  10575. }, {
  10576. key: "insertRule",
  10577. value: function insertRule(rule) {
  10578. var styleElement = this.styleElement;
  10579. if (!styleElement) {
  10580. styleElement = this.styleElement = document.createElement('style');
  10581. styleElement.id = "PDFJS_FONT_STYLE_TAG_".concat(this.docId);
  10582. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  10583. }
  10584. var styleSheet = styleElement.sheet;
  10585. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  10586. }
  10587. }, {
  10588. key: "clear",
  10589. value: function clear() {
  10590. this.nativeFontFaces.forEach(function (nativeFontFace) {
  10591. document.fonts.delete(nativeFontFace);
  10592. });
  10593. this.nativeFontFaces.length = 0;
  10594. if (this.styleElement) {
  10595. this.styleElement.remove();
  10596. this.styleElement = null;
  10597. }
  10598. }
  10599. }, {
  10600. key: "bind",
  10601. value: function () {
  10602. var _bind = _asyncToGenerator(
  10603. /*#__PURE__*/
  10604. _regenerator.default.mark(function _callee(font) {
  10605. var _this = this;
  10606. var nativeFontFace, rule;
  10607. return _regenerator.default.wrap(function _callee$(_context) {
  10608. while (1) {
  10609. switch (_context.prev = _context.next) {
  10610. case 0:
  10611. if (!(font.attached || font.missingFile)) {
  10612. _context.next = 2;
  10613. break;
  10614. }
  10615. return _context.abrupt("return");
  10616. case 2:
  10617. font.attached = true;
  10618. if (!this.isFontLoadingAPISupported) {
  10619. _context.next = 19;
  10620. break;
  10621. }
  10622. nativeFontFace = font.createNativeFontFace();
  10623. if (!nativeFontFace) {
  10624. _context.next = 18;
  10625. break;
  10626. }
  10627. this.addNativeFontFace(nativeFontFace);
  10628. _context.prev = 7;
  10629. _context.next = 10;
  10630. return nativeFontFace.loaded;
  10631. case 10:
  10632. _context.next = 18;
  10633. break;
  10634. case 12:
  10635. _context.prev = 12;
  10636. _context.t0 = _context["catch"](7);
  10637. this._onUnsupportedFeature({
  10638. featureId: _util.UNSUPPORTED_FEATURES.font
  10639. });
  10640. (0, _util.warn)("Failed to load font '".concat(nativeFontFace.family, "': '").concat(_context.t0, "'."));
  10641. font.disableFontFace = true;
  10642. throw _context.t0;
  10643. case 18:
  10644. return _context.abrupt("return");
  10645. case 19:
  10646. rule = font.createFontFaceRule();
  10647. if (!rule) {
  10648. _context.next = 25;
  10649. break;
  10650. }
  10651. this.insertRule(rule);
  10652. if (!this.isSyncFontLoadingSupported) {
  10653. _context.next = 24;
  10654. break;
  10655. }
  10656. return _context.abrupt("return");
  10657. case 24:
  10658. return _context.abrupt("return", new Promise(function (resolve) {
  10659. var request = _this._queueLoadingCallback(resolve);
  10660. _this._prepareFontLoadEvent([rule], [font], request);
  10661. }));
  10662. case 25:
  10663. case "end":
  10664. return _context.stop();
  10665. }
  10666. }
  10667. }, _callee, this, [[7, 12]]);
  10668. }));
  10669. function bind(_x) {
  10670. return _bind.apply(this, arguments);
  10671. }
  10672. return bind;
  10673. }()
  10674. }, {
  10675. key: "_queueLoadingCallback",
  10676. value: function _queueLoadingCallback(callback) {
  10677. (0, _util.unreachable)('Abstract method `_queueLoadingCallback`.');
  10678. }
  10679. }, {
  10680. key: "_prepareFontLoadEvent",
  10681. value: function _prepareFontLoadEvent(rules, fontsToLoad, request) {
  10682. (0, _util.unreachable)('Abstract method `_prepareFontLoadEvent`.');
  10683. }
  10684. }, {
  10685. key: "isFontLoadingAPISupported",
  10686. get: function get() {
  10687. (0, _util.unreachable)('Abstract method `isFontLoadingAPISupported`.');
  10688. }
  10689. }, {
  10690. key: "isSyncFontLoadingSupported",
  10691. get: function get() {
  10692. (0, _util.unreachable)('Abstract method `isSyncFontLoadingSupported`.');
  10693. }
  10694. }, {
  10695. key: "_loadTestFont",
  10696. get: function get() {
  10697. (0, _util.unreachable)('Abstract method `_loadTestFont`.');
  10698. }
  10699. }]);
  10700. return BaseFontLoader;
  10701. }();
  10702. var FontLoader;
  10703. exports.FontLoader = FontLoader;
  10704. {
  10705. exports.FontLoader = FontLoader =
  10706. /*#__PURE__*/
  10707. function (_BaseFontLoader) {
  10708. _inherits(GenericFontLoader, _BaseFontLoader);
  10709. function GenericFontLoader(docId) {
  10710. var _this2;
  10711. _classCallCheck(this, GenericFontLoader);
  10712. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(GenericFontLoader).call(this, docId));
  10713. _this2.loadingContext = {
  10714. requests: [],
  10715. nextRequestId: 0
  10716. };
  10717. _this2.loadTestFontId = 0;
  10718. return _this2;
  10719. }
  10720. _createClass(GenericFontLoader, [{
  10721. key: "_queueLoadingCallback",
  10722. value: function _queueLoadingCallback(callback) {
  10723. function completeRequest() {
  10724. (0, _util.assert)(!request.done, 'completeRequest() cannot be called twice.');
  10725. request.done = true;
  10726. while (context.requests.length > 0 && context.requests[0].done) {
  10727. var otherRequest = context.requests.shift();
  10728. setTimeout(otherRequest.callback, 0);
  10729. }
  10730. }
  10731. var context = this.loadingContext;
  10732. var request = {
  10733. id: "pdfjs-font-loading-".concat(context.nextRequestId++),
  10734. done: false,
  10735. complete: completeRequest,
  10736. callback: callback
  10737. };
  10738. context.requests.push(request);
  10739. return request;
  10740. }
  10741. }, {
  10742. key: "_prepareFontLoadEvent",
  10743. value: function _prepareFontLoadEvent(rules, fonts, request) {
  10744. function int32(data, offset) {
  10745. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  10746. }
  10747. function spliceString(s, offset, remove, insert) {
  10748. var chunk1 = s.substring(0, offset);
  10749. var chunk2 = s.substring(offset + remove);
  10750. return chunk1 + insert + chunk2;
  10751. }
  10752. var i, ii;
  10753. var canvas = document.createElement('canvas');
  10754. canvas.width = 1;
  10755. canvas.height = 1;
  10756. var ctx = canvas.getContext('2d');
  10757. var called = 0;
  10758. function isFontReady(name, callback) {
  10759. called++;
  10760. if (called > 30) {
  10761. (0, _util.warn)('Load test font never loaded.');
  10762. callback();
  10763. return;
  10764. }
  10765. ctx.font = '30px ' + name;
  10766. ctx.fillText('.', 0, 20);
  10767. var imageData = ctx.getImageData(0, 0, 1, 1);
  10768. if (imageData.data[3] > 0) {
  10769. callback();
  10770. return;
  10771. }
  10772. setTimeout(isFontReady.bind(null, name, callback));
  10773. }
  10774. var loadTestFontId = "lt".concat(Date.now()).concat(this.loadTestFontId++);
  10775. var data = this._loadTestFont;
  10776. var COMMENT_OFFSET = 976;
  10777. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  10778. var CFF_CHECKSUM_OFFSET = 16;
  10779. var XXXX_VALUE = 0x58585858;
  10780. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  10781. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  10782. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  10783. }
  10784. if (i < loadTestFontId.length) {
  10785. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  10786. }
  10787. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum));
  10788. var url = "url(data:font/opentype;base64,".concat(btoa(data), ");");
  10789. var rule = "@font-face {font-family:\"".concat(loadTestFontId, "\";src:").concat(url, "}");
  10790. this.insertRule(rule);
  10791. var names = [];
  10792. for (i = 0, ii = fonts.length; i < ii; i++) {
  10793. names.push(fonts[i].loadedName);
  10794. }
  10795. names.push(loadTestFontId);
  10796. var div = document.createElement('div');
  10797. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  10798. for (i = 0, ii = names.length; i < ii; ++i) {
  10799. var span = document.createElement('span');
  10800. span.textContent = 'Hi';
  10801. span.style.fontFamily = names[i];
  10802. div.appendChild(span);
  10803. }
  10804. document.body.appendChild(div);
  10805. isFontReady(loadTestFontId, function () {
  10806. document.body.removeChild(div);
  10807. request.complete();
  10808. });
  10809. }
  10810. }, {
  10811. key: "isFontLoadingAPISupported",
  10812. get: function get() {
  10813. var supported = typeof document !== 'undefined' && !!document.fonts;
  10814. if (supported && typeof navigator !== 'undefined') {
  10815. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  10816. if (m && m[1] < 63) {
  10817. supported = false;
  10818. }
  10819. }
  10820. return (0, _util.shadow)(this, 'isFontLoadingAPISupported', supported);
  10821. }
  10822. }, {
  10823. key: "isSyncFontLoadingSupported",
  10824. get: function get() {
  10825. var supported = false;
  10826. if (typeof navigator === 'undefined') {
  10827. supported = true;
  10828. } else {
  10829. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  10830. if (m && m[1] >= 14) {
  10831. supported = true;
  10832. }
  10833. }
  10834. return (0, _util.shadow)(this, 'isSyncFontLoadingSupported', supported);
  10835. }
  10836. }, {
  10837. key: "_loadTestFont",
  10838. get: function get() {
  10839. var getLoadTestFont = function getLoadTestFont() {
  10840. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA' + 'FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA' + 'ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA' + 'AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1' + 'AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD' + '6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM' + 'AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D' + 'IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA' + 'AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA' + 'AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB' + 'AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY' + 'AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA' + 'AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA' + 'AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC' + 'AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3' + 'Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj' + 'FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==');
  10841. };
  10842. return (0, _util.shadow)(this, '_loadTestFont', getLoadTestFont());
  10843. }
  10844. }]);
  10845. return GenericFontLoader;
  10846. }(BaseFontLoader);
  10847. }
  10848. var IsEvalSupportedCached = {
  10849. get value() {
  10850. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  10851. }
  10852. };
  10853. var FontFaceObject =
  10854. /*#__PURE__*/
  10855. function () {
  10856. function FontFaceObject(translatedData, _ref2) {
  10857. var _ref2$isEvalSupported = _ref2.isEvalSupported,
  10858. isEvalSupported = _ref2$isEvalSupported === void 0 ? true : _ref2$isEvalSupported,
  10859. _ref2$disableFontFace = _ref2.disableFontFace,
  10860. disableFontFace = _ref2$disableFontFace === void 0 ? false : _ref2$disableFontFace,
  10861. _ref2$ignoreErrors = _ref2.ignoreErrors,
  10862. ignoreErrors = _ref2$ignoreErrors === void 0 ? false : _ref2$ignoreErrors,
  10863. _ref2$onUnsupportedFe = _ref2.onUnsupportedFeature,
  10864. onUnsupportedFeature = _ref2$onUnsupportedFe === void 0 ? null : _ref2$onUnsupportedFe,
  10865. _ref2$fontRegistry = _ref2.fontRegistry,
  10866. fontRegistry = _ref2$fontRegistry === void 0 ? null : _ref2$fontRegistry;
  10867. _classCallCheck(this, FontFaceObject);
  10868. this.compiledGlyphs = Object.create(null);
  10869. for (var i in translatedData) {
  10870. this[i] = translatedData[i];
  10871. }
  10872. this.isEvalSupported = isEvalSupported !== false;
  10873. this.disableFontFace = disableFontFace === true;
  10874. this.ignoreErrors = ignoreErrors === true;
  10875. this._onUnsupportedFeature = onUnsupportedFeature;
  10876. this.fontRegistry = fontRegistry;
  10877. }
  10878. _createClass(FontFaceObject, [{
  10879. key: "createNativeFontFace",
  10880. value: function createNativeFontFace() {
  10881. if (!this.data || this.disableFontFace) {
  10882. return null;
  10883. }
  10884. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  10885. if (this.fontRegistry) {
  10886. this.fontRegistry.registerFont(this);
  10887. }
  10888. return nativeFontFace;
  10889. }
  10890. }, {
  10891. key: "createFontFaceRule",
  10892. value: function createFontFaceRule() {
  10893. if (!this.data || this.disableFontFace) {
  10894. return null;
  10895. }
  10896. var data = (0, _util.bytesToString)(new Uint8Array(this.data));
  10897. var url = "url(data:".concat(this.mimetype, ";base64,").concat(btoa(data), ");");
  10898. var rule = "@font-face {font-family:\"".concat(this.loadedName, "\";src:").concat(url, "}");
  10899. if (this.fontRegistry) {
  10900. this.fontRegistry.registerFont(this, url);
  10901. }
  10902. return rule;
  10903. }
  10904. }, {
  10905. key: "getPathGenerator",
  10906. value: function getPathGenerator(objs, character) {
  10907. if (this.compiledGlyphs[character] !== undefined) {
  10908. return this.compiledGlyphs[character];
  10909. }
  10910. var cmds, current;
  10911. try {
  10912. cmds = objs.get(this.loadedName + '_path_' + character);
  10913. } catch (ex) {
  10914. if (!this.ignoreErrors) {
  10915. throw ex;
  10916. }
  10917. if (this._onUnsupportedFeature) {
  10918. this._onUnsupportedFeature({
  10919. featureId: _util.UNSUPPORTED_FEATURES.font
  10920. });
  10921. }
  10922. (0, _util.warn)("getPathGenerator - ignoring character: \"".concat(ex, "\"."));
  10923. return this.compiledGlyphs[character] = function (c, size) {};
  10924. }
  10925. if (this.isEvalSupported && IsEvalSupportedCached.value) {
  10926. var args,
  10927. js = '';
  10928. for (var i = 0, ii = cmds.length; i < ii; i++) {
  10929. current = cmds[i];
  10930. if (current.args !== undefined) {
  10931. args = current.args.join(',');
  10932. } else {
  10933. args = '';
  10934. }
  10935. js += 'c.' + current.cmd + '(' + args + ');\n';
  10936. }
  10937. return this.compiledGlyphs[character] = new Function('c', 'size', js);
  10938. }
  10939. return this.compiledGlyphs[character] = function (c, size) {
  10940. for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) {
  10941. current = cmds[_i];
  10942. if (current.cmd === 'scale') {
  10943. current.args = [size, -size];
  10944. }
  10945. c[current.cmd].apply(c, current.args);
  10946. }
  10947. };
  10948. }
  10949. }]);
  10950. return FontFaceObject;
  10951. }();
  10952. exports.FontFaceObject = FontFaceObject;
  10953. /***/ }),
  10954. /* 153 */
  10955. /***/ (function(module, exports, __w_pdfjs_require__) {
  10956. "use strict";
  10957. var compatibilityParams = Object.create(null);
  10958. {
  10959. var isNodeJS = __w_pdfjs_require__(4);
  10960. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  10961. var isIE = /Trident/.test(userAgent);
  10962. var isIOSChrome = /CriOS/.test(userAgent);
  10963. (function checkOnBlobSupport() {
  10964. if (isIE || isIOSChrome) {
  10965. compatibilityParams.disableCreateObjectURL = true;
  10966. }
  10967. })();
  10968. (function checkFontFaceAndImage() {
  10969. if (isNodeJS()) {
  10970. compatibilityParams.disableFontFace = true;
  10971. compatibilityParams.nativeImageDecoderSupport = 'none';
  10972. }
  10973. })();
  10974. }
  10975. exports.apiCompatibilityParams = Object.freeze(compatibilityParams);
  10976. /***/ }),
  10977. /* 154 */
  10978. /***/ (function(module, exports, __w_pdfjs_require__) {
  10979. "use strict";
  10980. Object.defineProperty(exports, "__esModule", {
  10981. value: true
  10982. });
  10983. exports.CanvasGraphics = void 0;
  10984. var _util = __w_pdfjs_require__(1);
  10985. var _pattern_helper = __w_pdfjs_require__(155);
  10986. var MIN_FONT_SIZE = 16;
  10987. var MAX_FONT_SIZE = 100;
  10988. var MAX_GROUP_SIZE = 4096;
  10989. var MIN_WIDTH_FACTOR = 0.65;
  10990. var COMPILE_TYPE3_GLYPHS = true;
  10991. var MAX_SIZE_TO_COMPILE = 1000;
  10992. var FULL_CHUNK_HEIGHT = 16;
  10993. var IsLittleEndianCached = {
  10994. get value() {
  10995. return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
  10996. }
  10997. };
  10998. function addContextCurrentTransform(ctx) {
  10999. if (!ctx.mozCurrentTransform) {
  11000. ctx._originalSave = ctx.save;
  11001. ctx._originalRestore = ctx.restore;
  11002. ctx._originalRotate = ctx.rotate;
  11003. ctx._originalScale = ctx.scale;
  11004. ctx._originalTranslate = ctx.translate;
  11005. ctx._originalTransform = ctx.transform;
  11006. ctx._originalSetTransform = ctx.setTransform;
  11007. ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
  11008. ctx._transformStack = [];
  11009. Object.defineProperty(ctx, 'mozCurrentTransform', {
  11010. get: function getCurrentTransform() {
  11011. return this._transformMatrix;
  11012. }
  11013. });
  11014. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  11015. get: function getCurrentTransformInverse() {
  11016. var m = this._transformMatrix;
  11017. var a = m[0],
  11018. b = m[1],
  11019. c = m[2],
  11020. d = m[3],
  11021. e = m[4],
  11022. f = m[5];
  11023. var ad_bc = a * d - b * c;
  11024. var bc_ad = b * c - a * d;
  11025. return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc];
  11026. }
  11027. });
  11028. ctx.save = function ctxSave() {
  11029. var old = this._transformMatrix;
  11030. this._transformStack.push(old);
  11031. this._transformMatrix = old.slice(0, 6);
  11032. this._originalSave();
  11033. };
  11034. ctx.restore = function ctxRestore() {
  11035. var prev = this._transformStack.pop();
  11036. if (prev) {
  11037. this._transformMatrix = prev;
  11038. this._originalRestore();
  11039. }
  11040. };
  11041. ctx.translate = function ctxTranslate(x, y) {
  11042. var m = this._transformMatrix;
  11043. m[4] = m[0] * x + m[2] * y + m[4];
  11044. m[5] = m[1] * x + m[3] * y + m[5];
  11045. this._originalTranslate(x, y);
  11046. };
  11047. ctx.scale = function ctxScale(x, y) {
  11048. var m = this._transformMatrix;
  11049. m[0] = m[0] * x;
  11050. m[1] = m[1] * x;
  11051. m[2] = m[2] * y;
  11052. m[3] = m[3] * y;
  11053. this._originalScale(x, y);
  11054. };
  11055. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  11056. var m = this._transformMatrix;
  11057. this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]];
  11058. ctx._originalTransform(a, b, c, d, e, f);
  11059. };
  11060. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  11061. this._transformMatrix = [a, b, c, d, e, f];
  11062. ctx._originalSetTransform(a, b, c, d, e, f);
  11063. };
  11064. ctx.rotate = function ctxRotate(angle) {
  11065. var cosValue = Math.cos(angle);
  11066. var sinValue = Math.sin(angle);
  11067. var m = this._transformMatrix;
  11068. this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]];
  11069. this._originalRotate(angle);
  11070. };
  11071. }
  11072. }
  11073. var CachedCanvases = function CachedCanvasesClosure() {
  11074. function CachedCanvases(canvasFactory) {
  11075. this.canvasFactory = canvasFactory;
  11076. this.cache = Object.create(null);
  11077. }
  11078. CachedCanvases.prototype = {
  11079. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  11080. var canvasEntry;
  11081. if (this.cache[id] !== undefined) {
  11082. canvasEntry = this.cache[id];
  11083. this.canvasFactory.reset(canvasEntry, width, height);
  11084. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  11085. } else {
  11086. canvasEntry = this.canvasFactory.create(width, height);
  11087. this.cache[id] = canvasEntry;
  11088. }
  11089. if (trackTransform) {
  11090. addContextCurrentTransform(canvasEntry.context);
  11091. }
  11092. return canvasEntry;
  11093. },
  11094. clear: function clear() {
  11095. for (var id in this.cache) {
  11096. var canvasEntry = this.cache[id];
  11097. this.canvasFactory.destroy(canvasEntry);
  11098. delete this.cache[id];
  11099. }
  11100. }
  11101. };
  11102. return CachedCanvases;
  11103. }();
  11104. function compileType3Glyph(imgData) {
  11105. var POINT_TO_PROCESS_LIMIT = 1000;
  11106. var width = imgData.width,
  11107. height = imgData.height;
  11108. var i,
  11109. j,
  11110. j0,
  11111. width1 = width + 1;
  11112. var points = new Uint8Array(width1 * (height + 1));
  11113. var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
  11114. var lineSize = width + 7 & ~7,
  11115. data0 = imgData.data;
  11116. var data = new Uint8Array(lineSize * height),
  11117. pos = 0,
  11118. ii;
  11119. for (i = 0, ii = data0.length; i < ii; i++) {
  11120. var mask = 128,
  11121. elem = data0[i];
  11122. while (mask > 0) {
  11123. data[pos++] = elem & mask ? 0 : 255;
  11124. mask >>= 1;
  11125. }
  11126. }
  11127. var count = 0;
  11128. pos = 0;
  11129. if (data[pos] !== 0) {
  11130. points[0] = 1;
  11131. ++count;
  11132. }
  11133. for (j = 1; j < width; j++) {
  11134. if (data[pos] !== data[pos + 1]) {
  11135. points[j] = data[pos] ? 2 : 1;
  11136. ++count;
  11137. }
  11138. pos++;
  11139. }
  11140. if (data[pos] !== 0) {
  11141. points[j] = 2;
  11142. ++count;
  11143. }
  11144. for (i = 1; i < height; i++) {
  11145. pos = i * lineSize;
  11146. j0 = i * width1;
  11147. if (data[pos - lineSize] !== data[pos]) {
  11148. points[j0] = data[pos] ? 1 : 8;
  11149. ++count;
  11150. }
  11151. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  11152. for (j = 1; j < width; j++) {
  11153. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  11154. if (POINT_TYPES[sum]) {
  11155. points[j0 + j] = POINT_TYPES[sum];
  11156. ++count;
  11157. }
  11158. pos++;
  11159. }
  11160. if (data[pos - lineSize] !== data[pos]) {
  11161. points[j0 + j] = data[pos] ? 2 : 4;
  11162. ++count;
  11163. }
  11164. if (count > POINT_TO_PROCESS_LIMIT) {
  11165. return null;
  11166. }
  11167. }
  11168. pos = lineSize * (height - 1);
  11169. j0 = i * width1;
  11170. if (data[pos] !== 0) {
  11171. points[j0] = 8;
  11172. ++count;
  11173. }
  11174. for (j = 1; j < width; j++) {
  11175. if (data[pos] !== data[pos + 1]) {
  11176. points[j0 + j] = data[pos] ? 4 : 8;
  11177. ++count;
  11178. }
  11179. pos++;
  11180. }
  11181. if (data[pos] !== 0) {
  11182. points[j0 + j] = 4;
  11183. ++count;
  11184. }
  11185. if (count > POINT_TO_PROCESS_LIMIT) {
  11186. return null;
  11187. }
  11188. var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
  11189. var outlines = [];
  11190. for (i = 0; count && i <= height; i++) {
  11191. var p = i * width1;
  11192. var end = p + width;
  11193. while (p < end && !points[p]) {
  11194. p++;
  11195. }
  11196. if (p === end) {
  11197. continue;
  11198. }
  11199. var coords = [p % width1, i];
  11200. var type = points[p],
  11201. p0 = p,
  11202. pp;
  11203. do {
  11204. var step = steps[type];
  11205. do {
  11206. p += step;
  11207. } while (!points[p]);
  11208. pp = points[p];
  11209. if (pp !== 5 && pp !== 10) {
  11210. type = pp;
  11211. points[p] = 0;
  11212. } else {
  11213. type = pp & 0x33 * type >> 4;
  11214. points[p] &= type >> 2 | type << 2;
  11215. }
  11216. coords.push(p % width1);
  11217. coords.push(p / width1 | 0);
  11218. --count;
  11219. } while (p0 !== p);
  11220. outlines.push(coords);
  11221. --i;
  11222. }
  11223. var drawOutline = function drawOutline(c) {
  11224. c.save();
  11225. c.scale(1 / width, -1 / height);
  11226. c.translate(0, -height);
  11227. c.beginPath();
  11228. for (var i = 0, ii = outlines.length; i < ii; i++) {
  11229. var o = outlines[i];
  11230. c.moveTo(o[0], o[1]);
  11231. for (var j = 2, jj = o.length; j < jj; j += 2) {
  11232. c.lineTo(o[j], o[j + 1]);
  11233. }
  11234. }
  11235. c.fill();
  11236. c.beginPath();
  11237. c.restore();
  11238. };
  11239. return drawOutline;
  11240. }
  11241. var CanvasExtraState = function CanvasExtraStateClosure() {
  11242. function CanvasExtraState() {
  11243. this.alphaIsShape = false;
  11244. this.fontSize = 0;
  11245. this.fontSizeScale = 1;
  11246. this.textMatrix = _util.IDENTITY_MATRIX;
  11247. this.textMatrixScale = 1;
  11248. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  11249. this.leading = 0;
  11250. this.x = 0;
  11251. this.y = 0;
  11252. this.lineX = 0;
  11253. this.lineY = 0;
  11254. this.charSpacing = 0;
  11255. this.wordSpacing = 0;
  11256. this.textHScale = 1;
  11257. this.textRenderingMode = _util.TextRenderingMode.FILL;
  11258. this.textRise = 0;
  11259. this.fillColor = '#000000';
  11260. this.strokeColor = '#000000';
  11261. this.patternFill = false;
  11262. this.fillAlpha = 1;
  11263. this.strokeAlpha = 1;
  11264. this.lineWidth = 1;
  11265. this.activeSMask = null;
  11266. this.resumeSMaskCtx = null;
  11267. }
  11268. CanvasExtraState.prototype = {
  11269. clone: function CanvasExtraState_clone() {
  11270. return Object.create(this);
  11271. },
  11272. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  11273. this.x = x;
  11274. this.y = y;
  11275. }
  11276. };
  11277. return CanvasExtraState;
  11278. }();
  11279. var CanvasGraphics = function CanvasGraphicsClosure() {
  11280. var EXECUTION_TIME = 15;
  11281. var EXECUTION_STEPS = 10;
  11282. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
  11283. this.ctx = canvasCtx;
  11284. this.current = new CanvasExtraState();
  11285. this.stateStack = [];
  11286. this.pendingClip = null;
  11287. this.pendingEOFill = false;
  11288. this.res = null;
  11289. this.xobjs = null;
  11290. this.commonObjs = commonObjs;
  11291. this.objs = objs;
  11292. this.canvasFactory = canvasFactory;
  11293. this.webGLContext = webGLContext;
  11294. this.imageLayer = imageLayer;
  11295. this.groupStack = [];
  11296. this.processingType3 = null;
  11297. this.baseTransform = null;
  11298. this.baseTransformStack = [];
  11299. this.groupLevel = 0;
  11300. this.smaskStack = [];
  11301. this.smaskCounter = 0;
  11302. this.tempSMask = null;
  11303. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  11304. if (canvasCtx) {
  11305. addContextCurrentTransform(canvasCtx);
  11306. }
  11307. this._cachedGetSinglePixelWidth = null;
  11308. }
  11309. function putBinaryImageData(ctx, imgData) {
  11310. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  11311. ctx.putImageData(imgData, 0, 0);
  11312. return;
  11313. }
  11314. var height = imgData.height,
  11315. width = imgData.width;
  11316. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  11317. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  11318. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  11319. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  11320. var srcPos = 0,
  11321. destPos;
  11322. var src = imgData.data;
  11323. var dest = chunkImgData.data;
  11324. var i, j, thisChunkHeight, elemsInThisChunk;
  11325. if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
  11326. var srcLength = src.byteLength;
  11327. var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
  11328. var dest32DataLength = dest32.length;
  11329. var fullSrcDiff = width + 7 >> 3;
  11330. var white = 0xFFFFFFFF;
  11331. var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
  11332. for (i = 0; i < totalChunks; i++) {
  11333. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  11334. destPos = 0;
  11335. for (j = 0; j < thisChunkHeight; j++) {
  11336. var srcDiff = srcLength - srcPos;
  11337. var k = 0;
  11338. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  11339. var kEndUnrolled = kEnd & ~7;
  11340. var mask = 0;
  11341. var srcByte = 0;
  11342. for (; k < kEndUnrolled; k += 8) {
  11343. srcByte = src[srcPos++];
  11344. dest32[destPos++] = srcByte & 128 ? white : black;
  11345. dest32[destPos++] = srcByte & 64 ? white : black;
  11346. dest32[destPos++] = srcByte & 32 ? white : black;
  11347. dest32[destPos++] = srcByte & 16 ? white : black;
  11348. dest32[destPos++] = srcByte & 8 ? white : black;
  11349. dest32[destPos++] = srcByte & 4 ? white : black;
  11350. dest32[destPos++] = srcByte & 2 ? white : black;
  11351. dest32[destPos++] = srcByte & 1 ? white : black;
  11352. }
  11353. for (; k < kEnd; k++) {
  11354. if (mask === 0) {
  11355. srcByte = src[srcPos++];
  11356. mask = 128;
  11357. }
  11358. dest32[destPos++] = srcByte & mask ? white : black;
  11359. mask >>= 1;
  11360. }
  11361. }
  11362. while (destPos < dest32DataLength) {
  11363. dest32[destPos++] = 0;
  11364. }
  11365. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  11366. }
  11367. } else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
  11368. j = 0;
  11369. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  11370. for (i = 0; i < fullChunks; i++) {
  11371. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  11372. srcPos += elemsInThisChunk;
  11373. ctx.putImageData(chunkImgData, 0, j);
  11374. j += FULL_CHUNK_HEIGHT;
  11375. }
  11376. if (i < totalChunks) {
  11377. elemsInThisChunk = width * partialChunkHeight * 4;
  11378. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  11379. ctx.putImageData(chunkImgData, 0, j);
  11380. }
  11381. } else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
  11382. thisChunkHeight = FULL_CHUNK_HEIGHT;
  11383. elemsInThisChunk = width * thisChunkHeight;
  11384. for (i = 0; i < totalChunks; i++) {
  11385. if (i >= fullChunks) {
  11386. thisChunkHeight = partialChunkHeight;
  11387. elemsInThisChunk = width * thisChunkHeight;
  11388. }
  11389. destPos = 0;
  11390. for (j = elemsInThisChunk; j--;) {
  11391. dest[destPos++] = src[srcPos++];
  11392. dest[destPos++] = src[srcPos++];
  11393. dest[destPos++] = src[srcPos++];
  11394. dest[destPos++] = 255;
  11395. }
  11396. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  11397. }
  11398. } else {
  11399. throw new Error("bad image kind: ".concat(imgData.kind));
  11400. }
  11401. }
  11402. function putBinaryImageMask(ctx, imgData) {
  11403. var height = imgData.height,
  11404. width = imgData.width;
  11405. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  11406. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  11407. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  11408. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  11409. var srcPos = 0;
  11410. var src = imgData.data;
  11411. var dest = chunkImgData.data;
  11412. for (var i = 0; i < totalChunks; i++) {
  11413. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  11414. var destPos = 3;
  11415. for (var j = 0; j < thisChunkHeight; j++) {
  11416. var mask = 0;
  11417. for (var k = 0; k < width; k++) {
  11418. if (!mask) {
  11419. var elem = src[srcPos++];
  11420. mask = 128;
  11421. }
  11422. dest[destPos] = elem & mask ? 0 : 255;
  11423. destPos += 4;
  11424. mask >>= 1;
  11425. }
  11426. }
  11427. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  11428. }
  11429. }
  11430. function copyCtxState(sourceCtx, destCtx) {
  11431. var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
  11432. for (var i = 0, ii = properties.length; i < ii; i++) {
  11433. var property = properties[i];
  11434. if (sourceCtx[property] !== undefined) {
  11435. destCtx[property] = sourceCtx[property];
  11436. }
  11437. }
  11438. if (sourceCtx.setLineDash !== undefined) {
  11439. destCtx.setLineDash(sourceCtx.getLineDash());
  11440. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  11441. }
  11442. }
  11443. function resetCtxToDefault(ctx) {
  11444. ctx.strokeStyle = '#000000';
  11445. ctx.fillStyle = '#000000';
  11446. ctx.fillRule = 'nonzero';
  11447. ctx.globalAlpha = 1;
  11448. ctx.lineWidth = 1;
  11449. ctx.lineCap = 'butt';
  11450. ctx.lineJoin = 'miter';
  11451. ctx.miterLimit = 10;
  11452. ctx.globalCompositeOperation = 'source-over';
  11453. ctx.font = '10px sans-serif';
  11454. if (ctx.setLineDash !== undefined) {
  11455. ctx.setLineDash([]);
  11456. ctx.lineDashOffset = 0;
  11457. }
  11458. }
  11459. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  11460. var length = bytes.length;
  11461. for (var i = 3; i < length; i += 4) {
  11462. var alpha = bytes[i];
  11463. if (alpha === 0) {
  11464. bytes[i - 3] = r0;
  11465. bytes[i - 2] = g0;
  11466. bytes[i - 1] = b0;
  11467. } else if (alpha < 255) {
  11468. var alpha_ = 255 - alpha;
  11469. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  11470. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  11471. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  11472. }
  11473. }
  11474. }
  11475. function composeSMaskAlpha(maskData, layerData, transferMap) {
  11476. var length = maskData.length;
  11477. var scale = 1 / 255;
  11478. for (var i = 3; i < length; i += 4) {
  11479. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  11480. layerData[i] = layerData[i] * alpha * scale | 0;
  11481. }
  11482. }
  11483. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  11484. var length = maskData.length;
  11485. for (var i = 3; i < length; i += 4) {
  11486. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  11487. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  11488. }
  11489. }
  11490. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  11491. var hasBackdrop = !!backdrop;
  11492. var r0 = hasBackdrop ? backdrop[0] : 0;
  11493. var g0 = hasBackdrop ? backdrop[1] : 0;
  11494. var b0 = hasBackdrop ? backdrop[2] : 0;
  11495. var composeFn;
  11496. if (subtype === 'Luminosity') {
  11497. composeFn = composeSMaskLuminosity;
  11498. } else {
  11499. composeFn = composeSMaskAlpha;
  11500. }
  11501. var PIXELS_TO_PROCESS = 1048576;
  11502. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  11503. for (var row = 0; row < height; row += chunkSize) {
  11504. var chunkHeight = Math.min(chunkSize, height - row);
  11505. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  11506. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  11507. if (hasBackdrop) {
  11508. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  11509. }
  11510. composeFn(maskData.data, layerData.data, transferMap);
  11511. maskCtx.putImageData(layerData, 0, row);
  11512. }
  11513. }
  11514. function composeSMask(ctx, smask, layerCtx, webGLContext) {
  11515. var mask = smask.canvas;
  11516. var maskCtx = smask.context;
  11517. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  11518. var backdrop = smask.backdrop || null;
  11519. if (!smask.transferMap && webGLContext.isEnabled) {
  11520. var composed = webGLContext.composeSMask({
  11521. layer: layerCtx.canvas,
  11522. mask: mask,
  11523. properties: {
  11524. subtype: smask.subtype,
  11525. backdrop: backdrop
  11526. }
  11527. });
  11528. ctx.setTransform(1, 0, 0, 1, 0, 0);
  11529. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  11530. return;
  11531. }
  11532. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  11533. ctx.drawImage(mask, 0, 0);
  11534. }
  11535. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  11536. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  11537. var NORMAL_CLIP = {};
  11538. var EO_CLIP = {};
  11539. CanvasGraphics.prototype = {
  11540. beginDrawing: function beginDrawing(_ref) {
  11541. var transform = _ref.transform,
  11542. viewport = _ref.viewport,
  11543. _ref$transparency = _ref.transparency,
  11544. transparency = _ref$transparency === void 0 ? false : _ref$transparency,
  11545. _ref$background = _ref.background,
  11546. background = _ref$background === void 0 ? null : _ref$background;
  11547. var width = this.ctx.canvas.width;
  11548. var height = this.ctx.canvas.height;
  11549. this.ctx.save();
  11550. this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
  11551. this.ctx.fillRect(0, 0, width, height);
  11552. this.ctx.restore();
  11553. if (transparency) {
  11554. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  11555. this.compositeCtx = this.ctx;
  11556. this.transparentCanvas = transparentCanvas.canvas;
  11557. this.ctx = transparentCanvas.context;
  11558. this.ctx.save();
  11559. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  11560. }
  11561. this.ctx.save();
  11562. resetCtxToDefault(this.ctx);
  11563. if (transform) {
  11564. this.ctx.transform.apply(this.ctx, transform);
  11565. }
  11566. this.ctx.transform.apply(this.ctx, viewport.transform);
  11567. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  11568. if (this.imageLayer) {
  11569. this.imageLayer.beginLayout();
  11570. }
  11571. },
  11572. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  11573. var argsArray = operatorList.argsArray;
  11574. var fnArray = operatorList.fnArray;
  11575. var i = executionStartIdx || 0;
  11576. var argsArrayLen = argsArray.length;
  11577. if (argsArrayLen === i) {
  11578. return i;
  11579. }
  11580. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  11581. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  11582. var steps = 0;
  11583. var commonObjs = this.commonObjs;
  11584. var objs = this.objs;
  11585. var fnId;
  11586. while (true) {
  11587. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  11588. stepper.breakIt(i, continueCallback);
  11589. return i;
  11590. }
  11591. fnId = fnArray[i];
  11592. if (fnId !== _util.OPS.dependency) {
  11593. this[fnId].apply(this, argsArray[i]);
  11594. } else {
  11595. var deps = argsArray[i];
  11596. for (var n = 0, nn = deps.length; n < nn; n++) {
  11597. var depObjId = deps[n];
  11598. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  11599. var objsPool = common ? commonObjs : objs;
  11600. if (!objsPool.has(depObjId)) {
  11601. objsPool.get(depObjId, continueCallback);
  11602. return i;
  11603. }
  11604. }
  11605. }
  11606. i++;
  11607. if (i === argsArrayLen) {
  11608. return i;
  11609. }
  11610. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  11611. if (Date.now() > endTime) {
  11612. continueCallback();
  11613. return i;
  11614. }
  11615. steps = 0;
  11616. }
  11617. }
  11618. },
  11619. endDrawing: function CanvasGraphics_endDrawing() {
  11620. if (this.current.activeSMask !== null) {
  11621. this.endSMaskGroup();
  11622. }
  11623. this.ctx.restore();
  11624. if (this.transparentCanvas) {
  11625. this.ctx = this.compositeCtx;
  11626. this.ctx.save();
  11627. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  11628. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  11629. this.ctx.restore();
  11630. this.transparentCanvas = null;
  11631. }
  11632. this.cachedCanvases.clear();
  11633. this.webGLContext.clear();
  11634. if (this.imageLayer) {
  11635. this.imageLayer.endLayout();
  11636. }
  11637. },
  11638. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  11639. this.current.lineWidth = width;
  11640. this.ctx.lineWidth = width;
  11641. },
  11642. setLineCap: function CanvasGraphics_setLineCap(style) {
  11643. this.ctx.lineCap = LINE_CAP_STYLES[style];
  11644. },
  11645. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  11646. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  11647. },
  11648. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  11649. this.ctx.miterLimit = limit;
  11650. },
  11651. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  11652. var ctx = this.ctx;
  11653. if (ctx.setLineDash !== undefined) {
  11654. ctx.setLineDash(dashArray);
  11655. ctx.lineDashOffset = dashPhase;
  11656. }
  11657. },
  11658. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
  11659. setFlatness: function CanvasGraphics_setFlatness(flatness) {},
  11660. setGState: function CanvasGraphics_setGState(states) {
  11661. for (var i = 0, ii = states.length; i < ii; i++) {
  11662. var state = states[i];
  11663. var key = state[0];
  11664. var value = state[1];
  11665. switch (key) {
  11666. case 'LW':
  11667. this.setLineWidth(value);
  11668. break;
  11669. case 'LC':
  11670. this.setLineCap(value);
  11671. break;
  11672. case 'LJ':
  11673. this.setLineJoin(value);
  11674. break;
  11675. case 'ML':
  11676. this.setMiterLimit(value);
  11677. break;
  11678. case 'D':
  11679. this.setDash(value[0], value[1]);
  11680. break;
  11681. case 'RI':
  11682. this.setRenderingIntent(value);
  11683. break;
  11684. case 'FL':
  11685. this.setFlatness(value);
  11686. break;
  11687. case 'Font':
  11688. this.setFont(value[0], value[1]);
  11689. break;
  11690. case 'CA':
  11691. this.current.strokeAlpha = state[1];
  11692. break;
  11693. case 'ca':
  11694. this.current.fillAlpha = state[1];
  11695. this.ctx.globalAlpha = state[1];
  11696. break;
  11697. case 'BM':
  11698. this.ctx.globalCompositeOperation = value;
  11699. break;
  11700. case 'SMask':
  11701. if (this.current.activeSMask) {
  11702. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  11703. this.suspendSMaskGroup();
  11704. } else {
  11705. this.endSMaskGroup();
  11706. }
  11707. }
  11708. this.current.activeSMask = value ? this.tempSMask : null;
  11709. if (this.current.activeSMask) {
  11710. this.beginSMaskGroup();
  11711. }
  11712. this.tempSMask = null;
  11713. break;
  11714. }
  11715. }
  11716. },
  11717. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  11718. var activeSMask = this.current.activeSMask;
  11719. var drawnWidth = activeSMask.canvas.width;
  11720. var drawnHeight = activeSMask.canvas.height;
  11721. var cacheId = 'smaskGroupAt' + this.groupLevel;
  11722. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  11723. var currentCtx = this.ctx;
  11724. var currentTransform = currentCtx.mozCurrentTransform;
  11725. this.ctx.save();
  11726. var groupCtx = scratchCanvas.context;
  11727. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  11728. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  11729. groupCtx.transform.apply(groupCtx, currentTransform);
  11730. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  11731. copyCtxState(currentCtx, groupCtx);
  11732. this.ctx = groupCtx;
  11733. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  11734. this.groupStack.push(currentCtx);
  11735. this.groupLevel++;
  11736. },
  11737. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  11738. var groupCtx = this.ctx;
  11739. this.groupLevel--;
  11740. this.ctx = this.groupStack.pop();
  11741. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  11742. this.ctx.restore();
  11743. this.ctx.save();
  11744. copyCtxState(groupCtx, this.ctx);
  11745. this.current.resumeSMaskCtx = groupCtx;
  11746. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  11747. this.ctx.transform.apply(this.ctx, deltaTransform);
  11748. groupCtx.save();
  11749. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  11750. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  11751. groupCtx.restore();
  11752. },
  11753. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  11754. var groupCtx = this.current.resumeSMaskCtx;
  11755. var currentCtx = this.ctx;
  11756. this.ctx = groupCtx;
  11757. this.groupStack.push(currentCtx);
  11758. this.groupLevel++;
  11759. },
  11760. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  11761. var groupCtx = this.ctx;
  11762. this.groupLevel--;
  11763. this.ctx = this.groupStack.pop();
  11764. composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext);
  11765. this.ctx.restore();
  11766. copyCtxState(groupCtx, this.ctx);
  11767. var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  11768. this.ctx.transform.apply(this.ctx, deltaTransform);
  11769. },
  11770. save: function CanvasGraphics_save() {
  11771. this.ctx.save();
  11772. var old = this.current;
  11773. this.stateStack.push(old);
  11774. this.current = old.clone();
  11775. this.current.resumeSMaskCtx = null;
  11776. },
  11777. restore: function CanvasGraphics_restore() {
  11778. if (this.current.resumeSMaskCtx) {
  11779. this.resumeSMaskGroup();
  11780. }
  11781. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  11782. this.endSMaskGroup();
  11783. }
  11784. if (this.stateStack.length !== 0) {
  11785. this.current = this.stateStack.pop();
  11786. this.ctx.restore();
  11787. this.pendingClip = null;
  11788. this._cachedGetSinglePixelWidth = null;
  11789. }
  11790. },
  11791. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  11792. this.ctx.transform(a, b, c, d, e, f);
  11793. this._cachedGetSinglePixelWidth = null;
  11794. },
  11795. constructPath: function CanvasGraphics_constructPath(ops, args) {
  11796. var ctx = this.ctx;
  11797. var current = this.current;
  11798. var x = current.x,
  11799. y = current.y;
  11800. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  11801. switch (ops[i] | 0) {
  11802. case _util.OPS.rectangle:
  11803. x = args[j++];
  11804. y = args[j++];
  11805. var width = args[j++];
  11806. var height = args[j++];
  11807. if (width === 0) {
  11808. width = this.getSinglePixelWidth();
  11809. }
  11810. if (height === 0) {
  11811. height = this.getSinglePixelWidth();
  11812. }
  11813. var xw = x + width;
  11814. var yh = y + height;
  11815. this.ctx.moveTo(x, y);
  11816. this.ctx.lineTo(xw, y);
  11817. this.ctx.lineTo(xw, yh);
  11818. this.ctx.lineTo(x, yh);
  11819. this.ctx.lineTo(x, y);
  11820. this.ctx.closePath();
  11821. break;
  11822. case _util.OPS.moveTo:
  11823. x = args[j++];
  11824. y = args[j++];
  11825. ctx.moveTo(x, y);
  11826. break;
  11827. case _util.OPS.lineTo:
  11828. x = args[j++];
  11829. y = args[j++];
  11830. ctx.lineTo(x, y);
  11831. break;
  11832. case _util.OPS.curveTo:
  11833. x = args[j + 4];
  11834. y = args[j + 5];
  11835. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  11836. j += 6;
  11837. break;
  11838. case _util.OPS.curveTo2:
  11839. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  11840. x = args[j + 2];
  11841. y = args[j + 3];
  11842. j += 4;
  11843. break;
  11844. case _util.OPS.curveTo3:
  11845. x = args[j + 2];
  11846. y = args[j + 3];
  11847. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  11848. j += 4;
  11849. break;
  11850. case _util.OPS.closePath:
  11851. ctx.closePath();
  11852. break;
  11853. }
  11854. }
  11855. current.setCurrentPoint(x, y);
  11856. },
  11857. closePath: function CanvasGraphics_closePath() {
  11858. this.ctx.closePath();
  11859. },
  11860. stroke: function CanvasGraphics_stroke(consumePath) {
  11861. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  11862. var ctx = this.ctx;
  11863. var strokeColor = this.current.strokeColor;
  11864. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  11865. ctx.globalAlpha = this.current.strokeAlpha;
  11866. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  11867. ctx.save();
  11868. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  11869. ctx.stroke();
  11870. ctx.restore();
  11871. } else {
  11872. ctx.stroke();
  11873. }
  11874. if (consumePath) {
  11875. this.consumePath();
  11876. }
  11877. ctx.globalAlpha = this.current.fillAlpha;
  11878. },
  11879. closeStroke: function CanvasGraphics_closeStroke() {
  11880. this.closePath();
  11881. this.stroke();
  11882. },
  11883. fill: function CanvasGraphics_fill(consumePath) {
  11884. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  11885. var ctx = this.ctx;
  11886. var fillColor = this.current.fillColor;
  11887. var isPatternFill = this.current.patternFill;
  11888. var needRestore = false;
  11889. if (isPatternFill) {
  11890. ctx.save();
  11891. if (this.baseTransform) {
  11892. ctx.setTransform.apply(ctx, this.baseTransform);
  11893. }
  11894. ctx.fillStyle = fillColor.getPattern(ctx, this);
  11895. needRestore = true;
  11896. }
  11897. if (this.pendingEOFill) {
  11898. ctx.fill('evenodd');
  11899. this.pendingEOFill = false;
  11900. } else {
  11901. ctx.fill();
  11902. }
  11903. if (needRestore) {
  11904. ctx.restore();
  11905. }
  11906. if (consumePath) {
  11907. this.consumePath();
  11908. }
  11909. },
  11910. eoFill: function CanvasGraphics_eoFill() {
  11911. this.pendingEOFill = true;
  11912. this.fill();
  11913. },
  11914. fillStroke: function CanvasGraphics_fillStroke() {
  11915. this.fill(false);
  11916. this.stroke(false);
  11917. this.consumePath();
  11918. },
  11919. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  11920. this.pendingEOFill = true;
  11921. this.fillStroke();
  11922. },
  11923. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  11924. this.closePath();
  11925. this.fillStroke();
  11926. },
  11927. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  11928. this.pendingEOFill = true;
  11929. this.closePath();
  11930. this.fillStroke();
  11931. },
  11932. endPath: function CanvasGraphics_endPath() {
  11933. this.consumePath();
  11934. },
  11935. clip: function CanvasGraphics_clip() {
  11936. this.pendingClip = NORMAL_CLIP;
  11937. },
  11938. eoClip: function CanvasGraphics_eoClip() {
  11939. this.pendingClip = EO_CLIP;
  11940. },
  11941. beginText: function CanvasGraphics_beginText() {
  11942. this.current.textMatrix = _util.IDENTITY_MATRIX;
  11943. this.current.textMatrixScale = 1;
  11944. this.current.x = this.current.lineX = 0;
  11945. this.current.y = this.current.lineY = 0;
  11946. },
  11947. endText: function CanvasGraphics_endText() {
  11948. var paths = this.pendingTextPaths;
  11949. var ctx = this.ctx;
  11950. if (paths === undefined) {
  11951. ctx.beginPath();
  11952. return;
  11953. }
  11954. ctx.save();
  11955. ctx.beginPath();
  11956. for (var i = 0; i < paths.length; i++) {
  11957. var path = paths[i];
  11958. ctx.setTransform.apply(ctx, path.transform);
  11959. ctx.translate(path.x, path.y);
  11960. path.addToPath(ctx, path.fontSize);
  11961. }
  11962. ctx.restore();
  11963. ctx.clip();
  11964. ctx.beginPath();
  11965. delete this.pendingTextPaths;
  11966. },
  11967. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  11968. this.current.charSpacing = spacing;
  11969. },
  11970. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  11971. this.current.wordSpacing = spacing;
  11972. },
  11973. setHScale: function CanvasGraphics_setHScale(scale) {
  11974. this.current.textHScale = scale / 100;
  11975. },
  11976. setLeading: function CanvasGraphics_setLeading(leading) {
  11977. this.current.leading = -leading;
  11978. },
  11979. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  11980. var fontObj = this.commonObjs.get(fontRefName);
  11981. var current = this.current;
  11982. if (!fontObj) {
  11983. throw new Error("Can't find font for ".concat(fontRefName));
  11984. }
  11985. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  11986. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  11987. (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
  11988. }
  11989. if (size < 0) {
  11990. size = -size;
  11991. current.fontDirection = -1;
  11992. } else {
  11993. current.fontDirection = 1;
  11994. }
  11995. this.current.font = fontObj;
  11996. this.current.fontSize = size;
  11997. if (fontObj.isType3Font) {
  11998. return;
  11999. }
  12000. var name = fontObj.loadedName || 'sans-serif';
  12001. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  12002. var italic = fontObj.italic ? 'italic' : 'normal';
  12003. var typeface = "\"".concat(name, "\", ").concat(fontObj.fallbackName);
  12004. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  12005. this.current.fontSizeScale = size / browserFontSize;
  12006. this.ctx.font = "".concat(italic, " ").concat(bold, " ").concat(browserFontSize, "px ").concat(typeface);
  12007. },
  12008. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  12009. this.current.textRenderingMode = mode;
  12010. },
  12011. setTextRise: function CanvasGraphics_setTextRise(rise) {
  12012. this.current.textRise = rise;
  12013. },
  12014. moveText: function CanvasGraphics_moveText(x, y) {
  12015. this.current.x = this.current.lineX += x;
  12016. this.current.y = this.current.lineY += y;
  12017. },
  12018. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  12019. this.setLeading(-y);
  12020. this.moveText(x, y);
  12021. },
  12022. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  12023. this.current.textMatrix = [a, b, c, d, e, f];
  12024. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  12025. this.current.x = this.current.lineX = 0;
  12026. this.current.y = this.current.lineY = 0;
  12027. },
  12028. nextLine: function CanvasGraphics_nextLine() {
  12029. this.moveText(0, this.current.leading);
  12030. },
  12031. paintChar: function paintChar(character, x, y, patternTransform) {
  12032. var ctx = this.ctx;
  12033. var current = this.current;
  12034. var font = current.font;
  12035. var textRenderingMode = current.textRenderingMode;
  12036. var fontSize = current.fontSize / current.fontSizeScale;
  12037. var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  12038. var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  12039. var patternFill = current.patternFill && font.data;
  12040. var addToPath;
  12041. if (font.disableFontFace || isAddToPathSet || patternFill) {
  12042. addToPath = font.getPathGenerator(this.commonObjs, character);
  12043. }
  12044. if (font.disableFontFace || patternFill) {
  12045. ctx.save();
  12046. ctx.translate(x, y);
  12047. ctx.beginPath();
  12048. addToPath(ctx, fontSize);
  12049. if (patternTransform) {
  12050. ctx.setTransform.apply(ctx, patternTransform);
  12051. }
  12052. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12053. ctx.fill();
  12054. }
  12055. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12056. ctx.stroke();
  12057. }
  12058. ctx.restore();
  12059. } else {
  12060. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12061. ctx.fillText(character, x, y);
  12062. }
  12063. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12064. ctx.strokeText(character, x, y);
  12065. }
  12066. }
  12067. if (isAddToPathSet) {
  12068. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  12069. paths.push({
  12070. transform: ctx.mozCurrentTransform,
  12071. x: x,
  12072. y: y,
  12073. fontSize: fontSize,
  12074. addToPath: addToPath
  12075. });
  12076. }
  12077. },
  12078. get isFontSubpixelAAEnabled() {
  12079. var ctx = this.canvasFactory.create(10, 10).context;
  12080. ctx.scale(1.5, 1);
  12081. ctx.fillText('I', 0, 10);
  12082. var data = ctx.getImageData(0, 0, 10, 10).data;
  12083. var enabled = false;
  12084. for (var i = 3; i < data.length; i += 4) {
  12085. if (data[i] > 0 && data[i] < 255) {
  12086. enabled = true;
  12087. break;
  12088. }
  12089. }
  12090. return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
  12091. },
  12092. showText: function CanvasGraphics_showText(glyphs) {
  12093. var current = this.current;
  12094. var font = current.font;
  12095. if (font.isType3Font) {
  12096. return this.showType3Text(glyphs);
  12097. }
  12098. var fontSize = current.fontSize;
  12099. if (fontSize === 0) {
  12100. return;
  12101. }
  12102. var ctx = this.ctx;
  12103. var fontSizeScale = current.fontSizeScale;
  12104. var charSpacing = current.charSpacing;
  12105. var wordSpacing = current.wordSpacing;
  12106. var fontDirection = current.fontDirection;
  12107. var textHScale = current.textHScale * fontDirection;
  12108. var glyphsLength = glyphs.length;
  12109. var vertical = font.vertical;
  12110. var spacingDir = vertical ? 1 : -1;
  12111. var defaultVMetrics = font.defaultVMetrics;
  12112. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  12113. var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
  12114. ctx.save();
  12115. var patternTransform;
  12116. if (current.patternFill) {
  12117. ctx.save();
  12118. var pattern = current.fillColor.getPattern(ctx, this);
  12119. patternTransform = ctx.mozCurrentTransform;
  12120. ctx.restore();
  12121. ctx.fillStyle = pattern;
  12122. }
  12123. ctx.transform.apply(ctx, current.textMatrix);
  12124. ctx.translate(current.x, current.y + current.textRise);
  12125. if (fontDirection > 0) {
  12126. ctx.scale(textHScale, -1);
  12127. } else {
  12128. ctx.scale(textHScale, 1);
  12129. }
  12130. var lineWidth = current.lineWidth;
  12131. var scale = current.textMatrixScale;
  12132. if (scale === 0 || lineWidth === 0) {
  12133. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  12134. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  12135. this._cachedGetSinglePixelWidth = null;
  12136. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  12137. }
  12138. } else {
  12139. lineWidth /= scale;
  12140. }
  12141. if (fontSizeScale !== 1.0) {
  12142. ctx.scale(fontSizeScale, fontSizeScale);
  12143. lineWidth /= fontSizeScale;
  12144. }
  12145. ctx.lineWidth = lineWidth;
  12146. var x = 0,
  12147. i;
  12148. for (i = 0; i < glyphsLength; ++i) {
  12149. var glyph = glyphs[i];
  12150. if ((0, _util.isNum)(glyph)) {
  12151. x += spacingDir * glyph * fontSize / 1000;
  12152. continue;
  12153. }
  12154. var restoreNeeded = false;
  12155. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  12156. var character = glyph.fontChar;
  12157. var accent = glyph.accent;
  12158. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  12159. var width = glyph.width;
  12160. if (vertical) {
  12161. var vmetric, vx, vy;
  12162. vmetric = glyph.vmetric || defaultVMetrics;
  12163. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  12164. vx = -vx * widthAdvanceScale;
  12165. vy = vmetric[2] * widthAdvanceScale;
  12166. width = vmetric ? -vmetric[0] : width;
  12167. scaledX = vx / fontSizeScale;
  12168. scaledY = (x + vy) / fontSizeScale;
  12169. } else {
  12170. scaledX = x / fontSizeScale;
  12171. scaledY = 0;
  12172. }
  12173. if (font.remeasure && width > 0) {
  12174. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  12175. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  12176. var characterScaleX = width / measuredWidth;
  12177. restoreNeeded = true;
  12178. ctx.save();
  12179. ctx.scale(characterScaleX, 1);
  12180. scaledX /= characterScaleX;
  12181. } else if (width !== measuredWidth) {
  12182. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  12183. }
  12184. }
  12185. if (glyph.isInFont || font.missingFile) {
  12186. if (simpleFillText && !accent) {
  12187. ctx.fillText(character, scaledX, scaledY);
  12188. } else {
  12189. this.paintChar(character, scaledX, scaledY, patternTransform);
  12190. if (accent) {
  12191. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  12192. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  12193. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
  12194. }
  12195. }
  12196. }
  12197. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  12198. x += charWidth;
  12199. if (restoreNeeded) {
  12200. ctx.restore();
  12201. }
  12202. }
  12203. if (vertical) {
  12204. current.y -= x * textHScale;
  12205. } else {
  12206. current.x += x * textHScale;
  12207. }
  12208. ctx.restore();
  12209. },
  12210. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  12211. var ctx = this.ctx;
  12212. var current = this.current;
  12213. var font = current.font;
  12214. var fontSize = current.fontSize;
  12215. var fontDirection = current.fontDirection;
  12216. var spacingDir = font.vertical ? 1 : -1;
  12217. var charSpacing = current.charSpacing;
  12218. var wordSpacing = current.wordSpacing;
  12219. var textHScale = current.textHScale * fontDirection;
  12220. var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  12221. var glyphsLength = glyphs.length;
  12222. var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE;
  12223. var i, glyph, width, spacingLength;
  12224. if (isTextInvisible || fontSize === 0) {
  12225. return;
  12226. }
  12227. this._cachedGetSinglePixelWidth = null;
  12228. ctx.save();
  12229. ctx.transform.apply(ctx, current.textMatrix);
  12230. ctx.translate(current.x, current.y);
  12231. ctx.scale(textHScale, fontDirection);
  12232. for (i = 0; i < glyphsLength; ++i) {
  12233. glyph = glyphs[i];
  12234. if ((0, _util.isNum)(glyph)) {
  12235. spacingLength = spacingDir * glyph * fontSize / 1000;
  12236. this.ctx.translate(spacingLength, 0);
  12237. current.x += spacingLength * textHScale;
  12238. continue;
  12239. }
  12240. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  12241. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  12242. if (!operatorList) {
  12243. (0, _util.warn)("Type3 character \"".concat(glyph.operatorListId, "\" is not available."));
  12244. continue;
  12245. }
  12246. this.processingType3 = glyph;
  12247. this.save();
  12248. ctx.scale(fontSize, fontSize);
  12249. ctx.transform.apply(ctx, fontMatrix);
  12250. this.executeOperatorList(operatorList);
  12251. this.restore();
  12252. var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
  12253. width = transformed[0] * fontSize + spacing;
  12254. ctx.translate(width, 0);
  12255. current.x += width * textHScale;
  12256. }
  12257. ctx.restore();
  12258. this.processingType3 = null;
  12259. },
  12260. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {},
  12261. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  12262. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  12263. this.clip();
  12264. this.endPath();
  12265. },
  12266. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  12267. var _this = this;
  12268. var pattern;
  12269. if (IR[0] === 'TilingPattern') {
  12270. var color = IR[1];
  12271. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  12272. var canvasGraphicsFactory = {
  12273. createCanvasGraphics: function createCanvasGraphics(ctx) {
  12274. return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
  12275. }
  12276. };
  12277. pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  12278. } else {
  12279. pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR);
  12280. }
  12281. return pattern;
  12282. },
  12283. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  12284. this.current.strokeColor = this.getColorN_Pattern(arguments);
  12285. },
  12286. setFillColorN: function CanvasGraphics_setFillColorN() {
  12287. this.current.fillColor = this.getColorN_Pattern(arguments);
  12288. this.current.patternFill = true;
  12289. },
  12290. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  12291. var color = _util.Util.makeCssRgb(r, g, b);
  12292. this.ctx.strokeStyle = color;
  12293. this.current.strokeColor = color;
  12294. },
  12295. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  12296. var color = _util.Util.makeCssRgb(r, g, b);
  12297. this.ctx.fillStyle = color;
  12298. this.current.fillColor = color;
  12299. this.current.patternFill = false;
  12300. },
  12301. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  12302. var ctx = this.ctx;
  12303. this.save();
  12304. var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
  12305. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  12306. var inv = ctx.mozCurrentTransformInverse;
  12307. if (inv) {
  12308. var canvas = ctx.canvas;
  12309. var width = canvas.width;
  12310. var height = canvas.height;
  12311. var bl = _util.Util.applyTransform([0, 0], inv);
  12312. var br = _util.Util.applyTransform([0, height], inv);
  12313. var ul = _util.Util.applyTransform([width, 0], inv);
  12314. var ur = _util.Util.applyTransform([width, height], inv);
  12315. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  12316. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  12317. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  12318. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  12319. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  12320. } else {
  12321. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  12322. }
  12323. this.restore();
  12324. },
  12325. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  12326. (0, _util.unreachable)('Should not call beginInlineImage');
  12327. },
  12328. beginImageData: function CanvasGraphics_beginImageData() {
  12329. (0, _util.unreachable)('Should not call beginImageData');
  12330. },
  12331. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  12332. this.save();
  12333. this.baseTransformStack.push(this.baseTransform);
  12334. if (Array.isArray(matrix) && matrix.length === 6) {
  12335. this.transform.apply(this, matrix);
  12336. }
  12337. this.baseTransform = this.ctx.mozCurrentTransform;
  12338. if (bbox) {
  12339. var width = bbox[2] - bbox[0];
  12340. var height = bbox[3] - bbox[1];
  12341. this.ctx.rect(bbox[0], bbox[1], width, height);
  12342. this.clip();
  12343. this.endPath();
  12344. }
  12345. },
  12346. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  12347. this.restore();
  12348. this.baseTransform = this.baseTransformStack.pop();
  12349. },
  12350. beginGroup: function CanvasGraphics_beginGroup(group) {
  12351. this.save();
  12352. var currentCtx = this.ctx;
  12353. if (!group.isolated) {
  12354. (0, _util.info)('TODO: Support non-isolated groups.');
  12355. }
  12356. if (group.knockout) {
  12357. (0, _util.warn)('Knockout groups not supported.');
  12358. }
  12359. var currentTransform = currentCtx.mozCurrentTransform;
  12360. if (group.matrix) {
  12361. currentCtx.transform.apply(currentCtx, group.matrix);
  12362. }
  12363. if (!group.bbox) {
  12364. throw new Error('Bounding box is required.');
  12365. }
  12366. var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  12367. var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
  12368. bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
  12369. var offsetX = Math.floor(bounds[0]);
  12370. var offsetY = Math.floor(bounds[1]);
  12371. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  12372. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  12373. var scaleX = 1,
  12374. scaleY = 1;
  12375. if (drawnWidth > MAX_GROUP_SIZE) {
  12376. scaleX = drawnWidth / MAX_GROUP_SIZE;
  12377. drawnWidth = MAX_GROUP_SIZE;
  12378. }
  12379. if (drawnHeight > MAX_GROUP_SIZE) {
  12380. scaleY = drawnHeight / MAX_GROUP_SIZE;
  12381. drawnHeight = MAX_GROUP_SIZE;
  12382. }
  12383. var cacheId = 'groupAt' + this.groupLevel;
  12384. if (group.smask) {
  12385. cacheId += '_smask_' + this.smaskCounter++ % 2;
  12386. }
  12387. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  12388. var groupCtx = scratchCanvas.context;
  12389. groupCtx.scale(1 / scaleX, 1 / scaleY);
  12390. groupCtx.translate(-offsetX, -offsetY);
  12391. groupCtx.transform.apply(groupCtx, currentTransform);
  12392. if (group.smask) {
  12393. this.smaskStack.push({
  12394. canvas: scratchCanvas.canvas,
  12395. context: groupCtx,
  12396. offsetX: offsetX,
  12397. offsetY: offsetY,
  12398. scaleX: scaleX,
  12399. scaleY: scaleY,
  12400. subtype: group.smask.subtype,
  12401. backdrop: group.smask.backdrop,
  12402. transferMap: group.smask.transferMap || null,
  12403. startTransformInverse: null
  12404. });
  12405. } else {
  12406. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  12407. currentCtx.translate(offsetX, offsetY);
  12408. currentCtx.scale(scaleX, scaleY);
  12409. }
  12410. copyCtxState(currentCtx, groupCtx);
  12411. this.ctx = groupCtx;
  12412. this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
  12413. this.groupStack.push(currentCtx);
  12414. this.groupLevel++;
  12415. this.current.activeSMask = null;
  12416. },
  12417. endGroup: function CanvasGraphics_endGroup(group) {
  12418. this.groupLevel--;
  12419. var groupCtx = this.ctx;
  12420. this.ctx = this.groupStack.pop();
  12421. if (this.ctx.imageSmoothingEnabled !== undefined) {
  12422. this.ctx.imageSmoothingEnabled = false;
  12423. } else {
  12424. this.ctx.mozImageSmoothingEnabled = false;
  12425. }
  12426. if (group.smask) {
  12427. this.tempSMask = this.smaskStack.pop();
  12428. } else {
  12429. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  12430. }
  12431. this.restore();
  12432. },
  12433. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  12434. this.save();
  12435. if (this.baseTransform) {
  12436. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  12437. }
  12438. },
  12439. endAnnotations: function CanvasGraphics_endAnnotations() {
  12440. this.restore();
  12441. },
  12442. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  12443. this.save();
  12444. resetCtxToDefault(this.ctx);
  12445. this.current = new CanvasExtraState();
  12446. if (Array.isArray(rect) && rect.length === 4) {
  12447. var width = rect[2] - rect[0];
  12448. var height = rect[3] - rect[1];
  12449. this.ctx.rect(rect[0], rect[1], width, height);
  12450. this.clip();
  12451. this.endPath();
  12452. }
  12453. this.transform.apply(this, transform);
  12454. this.transform.apply(this, matrix);
  12455. },
  12456. endAnnotation: function CanvasGraphics_endAnnotation() {
  12457. this.restore();
  12458. },
  12459. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  12460. var domImage = this.objs.get(objId);
  12461. if (!domImage) {
  12462. (0, _util.warn)('Dependent image isn\'t ready yet');
  12463. return;
  12464. }
  12465. this.save();
  12466. var ctx = this.ctx;
  12467. ctx.scale(1 / w, -1 / h);
  12468. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  12469. if (this.imageLayer) {
  12470. var currentTransform = ctx.mozCurrentTransformInverse;
  12471. var position = this.getCanvasPosition(0, 0);
  12472. this.imageLayer.appendImage({
  12473. objId: objId,
  12474. left: position[0],
  12475. top: position[1],
  12476. width: w / currentTransform[0],
  12477. height: h / currentTransform[3]
  12478. });
  12479. }
  12480. this.restore();
  12481. },
  12482. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  12483. var ctx = this.ctx;
  12484. var width = img.width,
  12485. height = img.height;
  12486. var fillColor = this.current.fillColor;
  12487. var isPatternFill = this.current.patternFill;
  12488. var glyph = this.processingType3;
  12489. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  12490. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  12491. glyph.compiled = compileType3Glyph({
  12492. data: img.data,
  12493. width: width,
  12494. height: height
  12495. });
  12496. } else {
  12497. glyph.compiled = null;
  12498. }
  12499. }
  12500. if (glyph && glyph.compiled) {
  12501. glyph.compiled(ctx);
  12502. return;
  12503. }
  12504. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  12505. var maskCtx = maskCanvas.context;
  12506. maskCtx.save();
  12507. putBinaryImageMask(maskCtx, img);
  12508. maskCtx.globalCompositeOperation = 'source-in';
  12509. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  12510. maskCtx.fillRect(0, 0, width, height);
  12511. maskCtx.restore();
  12512. this.paintInlineImageXObject(maskCanvas.canvas);
  12513. },
  12514. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  12515. var width = imgData.width;
  12516. var height = imgData.height;
  12517. var fillColor = this.current.fillColor;
  12518. var isPatternFill = this.current.patternFill;
  12519. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  12520. var maskCtx = maskCanvas.context;
  12521. maskCtx.save();
  12522. putBinaryImageMask(maskCtx, imgData);
  12523. maskCtx.globalCompositeOperation = 'source-in';
  12524. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  12525. maskCtx.fillRect(0, 0, width, height);
  12526. maskCtx.restore();
  12527. var ctx = this.ctx;
  12528. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  12529. ctx.save();
  12530. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  12531. ctx.scale(1, -1);
  12532. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  12533. ctx.restore();
  12534. }
  12535. },
  12536. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  12537. var ctx = this.ctx;
  12538. var fillColor = this.current.fillColor;
  12539. var isPatternFill = this.current.patternFill;
  12540. for (var i = 0, ii = images.length; i < ii; i++) {
  12541. var image = images[i];
  12542. var width = image.width,
  12543. height = image.height;
  12544. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  12545. var maskCtx = maskCanvas.context;
  12546. maskCtx.save();
  12547. putBinaryImageMask(maskCtx, image);
  12548. maskCtx.globalCompositeOperation = 'source-in';
  12549. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  12550. maskCtx.fillRect(0, 0, width, height);
  12551. maskCtx.restore();
  12552. ctx.save();
  12553. ctx.transform.apply(ctx, image.transform);
  12554. ctx.scale(1, -1);
  12555. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  12556. ctx.restore();
  12557. }
  12558. },
  12559. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  12560. var imgData = this.objs.get(objId);
  12561. if (!imgData) {
  12562. (0, _util.warn)('Dependent image isn\'t ready yet');
  12563. return;
  12564. }
  12565. this.paintInlineImageXObject(imgData);
  12566. },
  12567. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  12568. var imgData = this.objs.get(objId);
  12569. if (!imgData) {
  12570. (0, _util.warn)('Dependent image isn\'t ready yet');
  12571. return;
  12572. }
  12573. var width = imgData.width;
  12574. var height = imgData.height;
  12575. var map = [];
  12576. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  12577. map.push({
  12578. transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],
  12579. x: 0,
  12580. y: 0,
  12581. w: width,
  12582. h: height
  12583. });
  12584. }
  12585. this.paintInlineImageXObjectGroup(imgData, map);
  12586. },
  12587. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  12588. var width = imgData.width;
  12589. var height = imgData.height;
  12590. var ctx = this.ctx;
  12591. this.save();
  12592. ctx.scale(1 / width, -1 / height);
  12593. var currentTransform = ctx.mozCurrentTransformInverse;
  12594. var a = currentTransform[0],
  12595. b = currentTransform[1];
  12596. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  12597. var c = currentTransform[2],
  12598. d = currentTransform[3];
  12599. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  12600. var imgToPaint, tmpCanvas;
  12601. if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) {
  12602. imgToPaint = imgData;
  12603. } else {
  12604. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  12605. var tmpCtx = tmpCanvas.context;
  12606. putBinaryImageData(tmpCtx, imgData);
  12607. imgToPaint = tmpCanvas.canvas;
  12608. }
  12609. var paintWidth = width,
  12610. paintHeight = height;
  12611. var tmpCanvasId = 'prescale1';
  12612. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  12613. var newWidth = paintWidth,
  12614. newHeight = paintHeight;
  12615. if (widthScale > 2 && paintWidth > 1) {
  12616. newWidth = Math.ceil(paintWidth / 2);
  12617. widthScale /= paintWidth / newWidth;
  12618. }
  12619. if (heightScale > 2 && paintHeight > 1) {
  12620. newHeight = Math.ceil(paintHeight / 2);
  12621. heightScale /= paintHeight / newHeight;
  12622. }
  12623. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  12624. tmpCtx = tmpCanvas.context;
  12625. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  12626. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  12627. imgToPaint = tmpCanvas.canvas;
  12628. paintWidth = newWidth;
  12629. paintHeight = newHeight;
  12630. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  12631. }
  12632. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  12633. if (this.imageLayer) {
  12634. var position = this.getCanvasPosition(0, -height);
  12635. this.imageLayer.appendImage({
  12636. imgData: imgData,
  12637. left: position[0],
  12638. top: position[1],
  12639. width: width / currentTransform[0],
  12640. height: height / currentTransform[3]
  12641. });
  12642. }
  12643. this.restore();
  12644. },
  12645. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  12646. var ctx = this.ctx;
  12647. var w = imgData.width;
  12648. var h = imgData.height;
  12649. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  12650. var tmpCtx = tmpCanvas.context;
  12651. putBinaryImageData(tmpCtx, imgData);
  12652. for (var i = 0, ii = map.length; i < ii; i++) {
  12653. var entry = map[i];
  12654. ctx.save();
  12655. ctx.transform.apply(ctx, entry.transform);
  12656. ctx.scale(1, -1);
  12657. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  12658. if (this.imageLayer) {
  12659. var position = this.getCanvasPosition(entry.x, entry.y);
  12660. this.imageLayer.appendImage({
  12661. imgData: imgData,
  12662. left: position[0],
  12663. top: position[1],
  12664. width: w,
  12665. height: h
  12666. });
  12667. }
  12668. ctx.restore();
  12669. }
  12670. },
  12671. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  12672. this.ctx.fillRect(0, 0, 1, 1);
  12673. },
  12674. paintXObject: function CanvasGraphics_paintXObject() {
  12675. (0, _util.warn)('Unsupported \'paintXObject\' command.');
  12676. },
  12677. markPoint: function CanvasGraphics_markPoint(tag) {},
  12678. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
  12679. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {},
  12680. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {},
  12681. endMarkedContent: function CanvasGraphics_endMarkedContent() {},
  12682. beginCompat: function CanvasGraphics_beginCompat() {},
  12683. endCompat: function CanvasGraphics_endCompat() {},
  12684. consumePath: function CanvasGraphics_consumePath() {
  12685. var ctx = this.ctx;
  12686. if (this.pendingClip) {
  12687. if (this.pendingClip === EO_CLIP) {
  12688. ctx.clip('evenodd');
  12689. } else {
  12690. ctx.clip();
  12691. }
  12692. this.pendingClip = null;
  12693. }
  12694. ctx.beginPath();
  12695. },
  12696. getSinglePixelWidth: function getSinglePixelWidth(scale) {
  12697. if (this._cachedGetSinglePixelWidth === null) {
  12698. var inverse = this.ctx.mozCurrentTransformInverse;
  12699. this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  12700. }
  12701. return this._cachedGetSinglePixelWidth;
  12702. },
  12703. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  12704. var transform = this.ctx.mozCurrentTransform;
  12705. return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
  12706. }
  12707. };
  12708. for (var op in _util.OPS) {
  12709. CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op];
  12710. }
  12711. return CanvasGraphics;
  12712. }();
  12713. exports.CanvasGraphics = CanvasGraphics;
  12714. /***/ }),
  12715. /* 155 */
  12716. /***/ (function(module, exports, __w_pdfjs_require__) {
  12717. "use strict";
  12718. Object.defineProperty(exports, "__esModule", {
  12719. value: true
  12720. });
  12721. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  12722. exports.TilingPattern = void 0;
  12723. var _util = __w_pdfjs_require__(1);
  12724. var ShadingIRs = {};
  12725. ShadingIRs.RadialAxial = {
  12726. fromIR: function RadialAxial_fromIR(raw) {
  12727. var type = raw[1];
  12728. var colorStops = raw[2];
  12729. var p0 = raw[3];
  12730. var p1 = raw[4];
  12731. var r0 = raw[5];
  12732. var r1 = raw[6];
  12733. return {
  12734. type: 'Pattern',
  12735. getPattern: function RadialAxial_getPattern(ctx) {
  12736. var grad;
  12737. if (type === 'axial') {
  12738. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  12739. } else if (type === 'radial') {
  12740. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  12741. }
  12742. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  12743. var c = colorStops[i];
  12744. grad.addColorStop(c[0], c[1]);
  12745. }
  12746. return grad;
  12747. }
  12748. };
  12749. }
  12750. };
  12751. var createMeshCanvas = function createMeshCanvasClosure() {
  12752. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  12753. var coords = context.coords,
  12754. colors = context.colors;
  12755. var bytes = data.data,
  12756. rowSize = data.width * 4;
  12757. var tmp;
  12758. if (coords[p1 + 1] > coords[p2 + 1]) {
  12759. tmp = p1;
  12760. p1 = p2;
  12761. p2 = tmp;
  12762. tmp = c1;
  12763. c1 = c2;
  12764. c2 = tmp;
  12765. }
  12766. if (coords[p2 + 1] > coords[p3 + 1]) {
  12767. tmp = p2;
  12768. p2 = p3;
  12769. p3 = tmp;
  12770. tmp = c2;
  12771. c2 = c3;
  12772. c3 = tmp;
  12773. }
  12774. if (coords[p1 + 1] > coords[p2 + 1]) {
  12775. tmp = p1;
  12776. p1 = p2;
  12777. p2 = tmp;
  12778. tmp = c1;
  12779. c1 = c2;
  12780. c2 = tmp;
  12781. }
  12782. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  12783. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  12784. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  12785. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  12786. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  12787. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  12788. if (y1 >= y3) {
  12789. return;
  12790. }
  12791. var c1r = colors[c1],
  12792. c1g = colors[c1 + 1],
  12793. c1b = colors[c1 + 2];
  12794. var c2r = colors[c2],
  12795. c2g = colors[c2 + 1],
  12796. c2b = colors[c2 + 2];
  12797. var c3r = colors[c3],
  12798. c3g = colors[c3 + 1],
  12799. c3b = colors[c3 + 2];
  12800. var minY = Math.round(y1),
  12801. maxY = Math.round(y3);
  12802. var xa, car, cag, cab;
  12803. var xb, cbr, cbg, cbb;
  12804. var k;
  12805. for (var y = minY; y <= maxY; y++) {
  12806. if (y < y2) {
  12807. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  12808. xa = x1 - (x1 - x2) * k;
  12809. car = c1r - (c1r - c2r) * k;
  12810. cag = c1g - (c1g - c2g) * k;
  12811. cab = c1b - (c1b - c2b) * k;
  12812. } else {
  12813. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  12814. xa = x2 - (x2 - x3) * k;
  12815. car = c2r - (c2r - c3r) * k;
  12816. cag = c2g - (c2g - c3g) * k;
  12817. cab = c2b - (c2b - c3b) * k;
  12818. }
  12819. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  12820. xb = x1 - (x1 - x3) * k;
  12821. cbr = c1r - (c1r - c3r) * k;
  12822. cbg = c1g - (c1g - c3g) * k;
  12823. cbb = c1b - (c1b - c3b) * k;
  12824. var x1_ = Math.round(Math.min(xa, xb));
  12825. var x2_ = Math.round(Math.max(xa, xb));
  12826. var j = rowSize * y + x1_ * 4;
  12827. for (var x = x1_; x <= x2_; x++) {
  12828. k = (xa - x) / (xa - xb);
  12829. k = k < 0 ? 0 : k > 1 ? 1 : k;
  12830. bytes[j++] = car - (car - cbr) * k | 0;
  12831. bytes[j++] = cag - (cag - cbg) * k | 0;
  12832. bytes[j++] = cab - (cab - cbb) * k | 0;
  12833. bytes[j++] = 255;
  12834. }
  12835. }
  12836. }
  12837. function drawFigure(data, figure, context) {
  12838. var ps = figure.coords;
  12839. var cs = figure.colors;
  12840. var i, ii;
  12841. switch (figure.type) {
  12842. case 'lattice':
  12843. var verticesPerRow = figure.verticesPerRow;
  12844. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  12845. var cols = verticesPerRow - 1;
  12846. for (i = 0; i < rows; i++) {
  12847. var q = i * verticesPerRow;
  12848. for (var j = 0; j < cols; j++, q++) {
  12849. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  12850. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  12851. }
  12852. }
  12853. break;
  12854. case 'triangles':
  12855. for (i = 0, ii = ps.length; i < ii; i += 3) {
  12856. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  12857. }
  12858. break;
  12859. default:
  12860. throw new Error('illegal figure');
  12861. }
  12862. }
  12863. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) {
  12864. var EXPECTED_SCALE = 1.1;
  12865. var MAX_PATTERN_SIZE = 3000;
  12866. var BORDER_SIZE = 2;
  12867. var offsetX = Math.floor(bounds[0]);
  12868. var offsetY = Math.floor(bounds[1]);
  12869. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  12870. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  12871. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  12872. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  12873. var scaleX = boundsWidth / width;
  12874. var scaleY = boundsHeight / height;
  12875. var context = {
  12876. coords: coords,
  12877. colors: colors,
  12878. offsetX: -offsetX,
  12879. offsetY: -offsetY,
  12880. scaleX: 1 / scaleX,
  12881. scaleY: 1 / scaleY
  12882. };
  12883. var paddedWidth = width + BORDER_SIZE * 2;
  12884. var paddedHeight = height + BORDER_SIZE * 2;
  12885. var canvas, tmpCanvas, i, ii;
  12886. if (webGLContext.isEnabled) {
  12887. canvas = webGLContext.drawFigures({
  12888. width: width,
  12889. height: height,
  12890. backgroundColor: backgroundColor,
  12891. figures: figures,
  12892. context: context
  12893. });
  12894. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  12895. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  12896. canvas = tmpCanvas.canvas;
  12897. } else {
  12898. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  12899. var tmpCtx = tmpCanvas.context;
  12900. var data = tmpCtx.createImageData(width, height);
  12901. if (backgroundColor) {
  12902. var bytes = data.data;
  12903. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  12904. bytes[i] = backgroundColor[0];
  12905. bytes[i + 1] = backgroundColor[1];
  12906. bytes[i + 2] = backgroundColor[2];
  12907. bytes[i + 3] = 255;
  12908. }
  12909. }
  12910. for (i = 0; i < figures.length; i++) {
  12911. drawFigure(data, figures[i], context);
  12912. }
  12913. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  12914. canvas = tmpCanvas.canvas;
  12915. }
  12916. return {
  12917. canvas: canvas,
  12918. offsetX: offsetX - BORDER_SIZE * scaleX,
  12919. offsetY: offsetY - BORDER_SIZE * scaleY,
  12920. scaleX: scaleX,
  12921. scaleY: scaleY
  12922. };
  12923. }
  12924. return createMeshCanvas;
  12925. }();
  12926. ShadingIRs.Mesh = {
  12927. fromIR: function Mesh_fromIR(raw) {
  12928. var coords = raw[2];
  12929. var colors = raw[3];
  12930. var figures = raw[4];
  12931. var bounds = raw[5];
  12932. var matrix = raw[6];
  12933. var background = raw[8];
  12934. return {
  12935. type: 'Pattern',
  12936. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  12937. var scale;
  12938. if (shadingFill) {
  12939. scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  12940. } else {
  12941. scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform);
  12942. if (matrix) {
  12943. var matrixScale = _util.Util.singularValueDecompose2dScale(matrix);
  12944. scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
  12945. }
  12946. }
  12947. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext);
  12948. if (!shadingFill) {
  12949. ctx.setTransform.apply(ctx, owner.baseTransform);
  12950. if (matrix) {
  12951. ctx.transform.apply(ctx, matrix);
  12952. }
  12953. }
  12954. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  12955. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  12956. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  12957. }
  12958. };
  12959. }
  12960. };
  12961. ShadingIRs.Dummy = {
  12962. fromIR: function Dummy_fromIR() {
  12963. return {
  12964. type: 'Pattern',
  12965. getPattern: function Dummy_fromIR_getPattern() {
  12966. return 'hotpink';
  12967. }
  12968. };
  12969. }
  12970. };
  12971. function getShadingPatternFromIR(raw) {
  12972. var shadingIR = ShadingIRs[raw[0]];
  12973. if (!shadingIR) {
  12974. throw new Error("Unknown IR type: ".concat(raw[0]));
  12975. }
  12976. return shadingIR.fromIR(raw);
  12977. }
  12978. var TilingPattern = function TilingPatternClosure() {
  12979. var PaintType = {
  12980. COLORED: 1,
  12981. UNCOLORED: 2
  12982. };
  12983. var MAX_PATTERN_SIZE = 3000;
  12984. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  12985. this.operatorList = IR[2];
  12986. this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
  12987. this.bbox = IR[4];
  12988. this.xstep = IR[5];
  12989. this.ystep = IR[6];
  12990. this.paintType = IR[7];
  12991. this.tilingType = IR[8];
  12992. this.color = color;
  12993. this.canvasGraphicsFactory = canvasGraphicsFactory;
  12994. this.baseTransform = baseTransform;
  12995. this.type = 'Pattern';
  12996. this.ctx = ctx;
  12997. }
  12998. TilingPattern.prototype = {
  12999. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  13000. var operatorList = this.operatorList;
  13001. var bbox = this.bbox;
  13002. var xstep = this.xstep;
  13003. var ystep = this.ystep;
  13004. var paintType = this.paintType;
  13005. var tilingType = this.tilingType;
  13006. var color = this.color;
  13007. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  13008. (0, _util.info)('TilingType: ' + tilingType);
  13009. var x0 = bbox[0],
  13010. y0 = bbox[1],
  13011. x1 = bbox[2],
  13012. y1 = bbox[3];
  13013. var topLeft = [x0, y0];
  13014. var botRight = [x0 + xstep, y0 + ystep];
  13015. var width = botRight[0] - topLeft[0];
  13016. var height = botRight[1] - topLeft[1];
  13017. var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix);
  13018. var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform);
  13019. var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]];
  13020. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  13021. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  13022. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  13023. var tmpCtx = tmpCanvas.context;
  13024. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  13025. graphics.groupLevel = owner.groupLevel;
  13026. this.setFillAndStrokeStyleToContext(graphics, paintType, color);
  13027. this.setScale(width, height, xstep, ystep);
  13028. this.transformToScale(graphics);
  13029. var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]];
  13030. graphics.transform.apply(graphics, tmpTranslate);
  13031. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  13032. graphics.executeOperatorList(operatorList);
  13033. return tmpCanvas.canvas;
  13034. },
  13035. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  13036. this.scale = [width / xstep, height / ystep];
  13037. },
  13038. transformToScale: function TilingPattern_transformToScale(graphics) {
  13039. var scale = this.scale;
  13040. var tmpScale = [scale[0], 0, 0, scale[1], 0, 0];
  13041. graphics.transform.apply(graphics, tmpScale);
  13042. },
  13043. scaleToContext: function TilingPattern_scaleToContext() {
  13044. var scale = this.scale;
  13045. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  13046. },
  13047. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  13048. if (Array.isArray(bbox) && bbox.length === 4) {
  13049. var bboxWidth = x1 - x0;
  13050. var bboxHeight = y1 - y0;
  13051. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  13052. graphics.clip();
  13053. graphics.endPath();
  13054. }
  13055. },
  13056. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) {
  13057. var context = graphics.ctx,
  13058. current = graphics.current;
  13059. switch (paintType) {
  13060. case PaintType.COLORED:
  13061. var ctx = this.ctx;
  13062. context.fillStyle = ctx.fillStyle;
  13063. context.strokeStyle = ctx.strokeStyle;
  13064. current.fillColor = ctx.fillStyle;
  13065. current.strokeColor = ctx.strokeStyle;
  13066. break;
  13067. case PaintType.UNCOLORED:
  13068. var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]);
  13069. context.fillStyle = cssColor;
  13070. context.strokeStyle = cssColor;
  13071. current.fillColor = cssColor;
  13072. current.strokeColor = cssColor;
  13073. break;
  13074. default:
  13075. throw new _util.FormatError("Unsupported paint type: ".concat(paintType));
  13076. }
  13077. },
  13078. getPattern: function TilingPattern_getPattern(ctx, owner) {
  13079. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  13080. ctx = this.ctx;
  13081. ctx.setTransform.apply(ctx, this.baseTransform);
  13082. ctx.transform.apply(ctx, this.matrix);
  13083. this.scaleToContext();
  13084. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  13085. }
  13086. };
  13087. return TilingPattern;
  13088. }();
  13089. exports.TilingPattern = TilingPattern;
  13090. /***/ }),
  13091. /* 156 */
  13092. /***/ (function(module, exports, __w_pdfjs_require__) {
  13093. "use strict";
  13094. Object.defineProperty(exports, "__esModule", {
  13095. value: true
  13096. });
  13097. exports.GlobalWorkerOptions = void 0;
  13098. var GlobalWorkerOptions = Object.create(null);
  13099. exports.GlobalWorkerOptions = GlobalWorkerOptions;
  13100. GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort;
  13101. GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? '' : GlobalWorkerOptions.workerSrc;
  13102. /***/ }),
  13103. /* 157 */
  13104. /***/ (function(module, exports, __w_pdfjs_require__) {
  13105. "use strict";
  13106. Object.defineProperty(exports, "__esModule", {
  13107. value: true
  13108. });
  13109. exports.MessageHandler = MessageHandler;
  13110. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  13111. var _util = __w_pdfjs_require__(1);
  13112. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  13113. function _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); }
  13114. 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); } }
  13115. 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); }); }; }
  13116. function resolveCall(_x, _x2) {
  13117. return _resolveCall.apply(this, arguments);
  13118. }
  13119. function _resolveCall() {
  13120. _resolveCall = _asyncToGenerator(
  13121. /*#__PURE__*/
  13122. _regenerator.default.mark(function _callee(fn, args) {
  13123. var thisArg,
  13124. _args = arguments;
  13125. return _regenerator.default.wrap(function _callee$(_context) {
  13126. while (1) {
  13127. switch (_context.prev = _context.next) {
  13128. case 0:
  13129. thisArg = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
  13130. if (fn) {
  13131. _context.next = 3;
  13132. break;
  13133. }
  13134. return _context.abrupt("return");
  13135. case 3:
  13136. return _context.abrupt("return", fn.apply(thisArg, args));
  13137. case 4:
  13138. case "end":
  13139. return _context.stop();
  13140. }
  13141. }
  13142. }, _callee, this);
  13143. }));
  13144. return _resolveCall.apply(this, arguments);
  13145. }
  13146. function wrapReason(reason) {
  13147. if (_typeof(reason) !== 'object') {
  13148. return reason;
  13149. }
  13150. switch (reason.name) {
  13151. case 'AbortException':
  13152. return new _util.AbortException(reason.message);
  13153. case 'MissingPDFException':
  13154. return new _util.MissingPDFException(reason.message);
  13155. case 'UnexpectedResponseException':
  13156. return new _util.UnexpectedResponseException(reason.message, reason.status);
  13157. default:
  13158. return new _util.UnknownErrorException(reason.message, reason.details);
  13159. }
  13160. }
  13161. function makeReasonSerializable(reason) {
  13162. if (!(reason instanceof Error) || reason instanceof _util.AbortException || reason instanceof _util.MissingPDFException || reason instanceof _util.UnexpectedResponseException || reason instanceof _util.UnknownErrorException) {
  13163. return reason;
  13164. }
  13165. return new _util.UnknownErrorException(reason.message, reason.toString());
  13166. }
  13167. function resolveOrReject(capability, success, reason) {
  13168. if (success) {
  13169. capability.resolve();
  13170. } else {
  13171. capability.reject(reason);
  13172. }
  13173. }
  13174. function finalize(promise) {
  13175. return Promise.resolve(promise).catch(function () {});
  13176. }
  13177. function MessageHandler(sourceName, targetName, comObj) {
  13178. var _this = this;
  13179. this.sourceName = sourceName;
  13180. this.targetName = targetName;
  13181. this.comObj = comObj;
  13182. this.callbackId = 1;
  13183. this.streamId = 1;
  13184. this.postMessageTransfers = true;
  13185. this.streamSinks = Object.create(null);
  13186. this.streamControllers = Object.create(null);
  13187. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  13188. var ah = this.actionHandler = Object.create(null);
  13189. this._onComObjOnMessage = function (event) {
  13190. var data = event.data;
  13191. if (data.targetName !== _this.sourceName) {
  13192. return;
  13193. }
  13194. if (data.stream) {
  13195. _this._processStreamMessage(data);
  13196. } else if (data.isReply) {
  13197. var callbackId = data.callbackId;
  13198. if (data.callbackId in callbacksCapabilities) {
  13199. var callback = callbacksCapabilities[callbackId];
  13200. delete callbacksCapabilities[callbackId];
  13201. if ('error' in data) {
  13202. callback.reject(wrapReason(data.error));
  13203. } else {
  13204. callback.resolve(data.data);
  13205. }
  13206. } else {
  13207. throw new Error("Cannot resolve callback ".concat(callbackId));
  13208. }
  13209. } else if (data.action in ah) {
  13210. var action = ah[data.action];
  13211. if (data.callbackId) {
  13212. var _sourceName = _this.sourceName;
  13213. var _targetName = data.sourceName;
  13214. Promise.resolve().then(function () {
  13215. return action[0].call(action[1], data.data);
  13216. }).then(function (result) {
  13217. comObj.postMessage({
  13218. sourceName: _sourceName,
  13219. targetName: _targetName,
  13220. isReply: true,
  13221. callbackId: data.callbackId,
  13222. data: result
  13223. });
  13224. }, function (reason) {
  13225. comObj.postMessage({
  13226. sourceName: _sourceName,
  13227. targetName: _targetName,
  13228. isReply: true,
  13229. callbackId: data.callbackId,
  13230. error: makeReasonSerializable(reason)
  13231. });
  13232. });
  13233. } else if (data.streamId) {
  13234. _this._createStreamSink(data);
  13235. } else {
  13236. action[0].call(action[1], data.data);
  13237. }
  13238. } else {
  13239. throw new Error("Unknown action from worker: ".concat(data.action));
  13240. }
  13241. };
  13242. comObj.addEventListener('message', this._onComObjOnMessage);
  13243. }
  13244. MessageHandler.prototype = {
  13245. on: function on(actionName, handler, scope) {
  13246. var ah = this.actionHandler;
  13247. if (ah[actionName]) {
  13248. throw new Error("There is already an actionName called \"".concat(actionName, "\""));
  13249. }
  13250. ah[actionName] = [handler, scope];
  13251. },
  13252. send: function send(actionName, data, transfers) {
  13253. var message = {
  13254. sourceName: this.sourceName,
  13255. targetName: this.targetName,
  13256. action: actionName,
  13257. data: data
  13258. };
  13259. this.postMessage(message, transfers);
  13260. },
  13261. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  13262. var callbackId = this.callbackId++;
  13263. var message = {
  13264. sourceName: this.sourceName,
  13265. targetName: this.targetName,
  13266. action: actionName,
  13267. data: data,
  13268. callbackId: callbackId
  13269. };
  13270. var capability = (0, _util.createPromiseCapability)();
  13271. this.callbacksCapabilities[callbackId] = capability;
  13272. try {
  13273. this.postMessage(message, transfers);
  13274. } catch (e) {
  13275. capability.reject(e);
  13276. }
  13277. return capability.promise;
  13278. },
  13279. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  13280. var _this2 = this;
  13281. var streamId = this.streamId++;
  13282. var sourceName = this.sourceName;
  13283. var targetName = this.targetName;
  13284. return new _util.ReadableStream({
  13285. start: function start(controller) {
  13286. var startCapability = (0, _util.createPromiseCapability)();
  13287. _this2.streamControllers[streamId] = {
  13288. controller: controller,
  13289. startCall: startCapability,
  13290. isClosed: false
  13291. };
  13292. _this2.postMessage({
  13293. sourceName: sourceName,
  13294. targetName: targetName,
  13295. action: actionName,
  13296. streamId: streamId,
  13297. data: data,
  13298. desiredSize: controller.desiredSize
  13299. });
  13300. return startCapability.promise;
  13301. },
  13302. pull: function pull(controller) {
  13303. var pullCapability = (0, _util.createPromiseCapability)();
  13304. _this2.streamControllers[streamId].pullCall = pullCapability;
  13305. _this2.postMessage({
  13306. sourceName: sourceName,
  13307. targetName: targetName,
  13308. stream: 'pull',
  13309. streamId: streamId,
  13310. desiredSize: controller.desiredSize
  13311. });
  13312. return pullCapability.promise;
  13313. },
  13314. cancel: function cancel(reason) {
  13315. var cancelCapability = (0, _util.createPromiseCapability)();
  13316. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  13317. _this2.streamControllers[streamId].isClosed = true;
  13318. _this2.postMessage({
  13319. sourceName: sourceName,
  13320. targetName: targetName,
  13321. stream: 'cancel',
  13322. reason: reason,
  13323. streamId: streamId
  13324. });
  13325. return cancelCapability.promise;
  13326. }
  13327. }, queueingStrategy);
  13328. },
  13329. _createStreamSink: function _createStreamSink(data) {
  13330. var _this3 = this;
  13331. var self = this;
  13332. var action = this.actionHandler[data.action];
  13333. var streamId = data.streamId;
  13334. var desiredSize = data.desiredSize;
  13335. var sourceName = this.sourceName;
  13336. var targetName = data.sourceName;
  13337. var capability = (0, _util.createPromiseCapability)();
  13338. var sendStreamRequest = function sendStreamRequest(_ref) {
  13339. var stream = _ref.stream,
  13340. chunk = _ref.chunk,
  13341. transfers = _ref.transfers,
  13342. success = _ref.success,
  13343. reason = _ref.reason;
  13344. _this3.postMessage({
  13345. sourceName: sourceName,
  13346. targetName: targetName,
  13347. stream: stream,
  13348. streamId: streamId,
  13349. chunk: chunk,
  13350. success: success,
  13351. reason: reason
  13352. }, transfers);
  13353. };
  13354. var streamSink = {
  13355. enqueue: function enqueue(chunk) {
  13356. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  13357. var transfers = arguments.length > 2 ? arguments[2] : undefined;
  13358. if (this.isCancelled) {
  13359. return;
  13360. }
  13361. var lastDesiredSize = this.desiredSize;
  13362. this.desiredSize -= size;
  13363. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  13364. this.sinkCapability = (0, _util.createPromiseCapability)();
  13365. this.ready = this.sinkCapability.promise;
  13366. }
  13367. sendStreamRequest({
  13368. stream: 'enqueue',
  13369. chunk: chunk,
  13370. transfers: transfers
  13371. });
  13372. },
  13373. close: function close() {
  13374. if (this.isCancelled) {
  13375. return;
  13376. }
  13377. this.isCancelled = true;
  13378. sendStreamRequest({
  13379. stream: 'close'
  13380. });
  13381. delete self.streamSinks[streamId];
  13382. },
  13383. error: function error(reason) {
  13384. if (this.isCancelled) {
  13385. return;
  13386. }
  13387. this.isCancelled = true;
  13388. sendStreamRequest({
  13389. stream: 'error',
  13390. reason: reason
  13391. });
  13392. },
  13393. sinkCapability: capability,
  13394. onPull: null,
  13395. onCancel: null,
  13396. isCancelled: false,
  13397. desiredSize: desiredSize,
  13398. ready: null
  13399. };
  13400. streamSink.sinkCapability.resolve();
  13401. streamSink.ready = streamSink.sinkCapability.promise;
  13402. this.streamSinks[streamId] = streamSink;
  13403. resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
  13404. sendStreamRequest({
  13405. stream: 'start_complete',
  13406. success: true
  13407. });
  13408. }, function (reason) {
  13409. sendStreamRequest({
  13410. stream: 'start_complete',
  13411. success: false,
  13412. reason: reason
  13413. });
  13414. });
  13415. },
  13416. _processStreamMessage: function _processStreamMessage(data) {
  13417. var _this4 = this;
  13418. var sourceName = this.sourceName;
  13419. var targetName = data.sourceName;
  13420. var streamId = data.streamId;
  13421. var sendStreamResponse = function sendStreamResponse(_ref2) {
  13422. var stream = _ref2.stream,
  13423. success = _ref2.success,
  13424. reason = _ref2.reason;
  13425. _this4.comObj.postMessage({
  13426. sourceName: sourceName,
  13427. targetName: targetName,
  13428. stream: stream,
  13429. success: success,
  13430. streamId: streamId,
  13431. reason: reason
  13432. });
  13433. };
  13434. var deleteStreamController = function deleteStreamController() {
  13435. Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
  13436. return capability && finalize(capability.promise);
  13437. })).then(function () {
  13438. delete _this4.streamControllers[data.streamId];
  13439. });
  13440. };
  13441. switch (data.stream) {
  13442. case 'start_complete':
  13443. resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
  13444. break;
  13445. case 'pull_complete':
  13446. resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
  13447. break;
  13448. case 'pull':
  13449. if (!this.streamSinks[data.streamId]) {
  13450. sendStreamResponse({
  13451. stream: 'pull_complete',
  13452. success: true
  13453. });
  13454. break;
  13455. }
  13456. if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
  13457. this.streamSinks[data.streamId].sinkCapability.resolve();
  13458. }
  13459. this.streamSinks[data.streamId].desiredSize = data.desiredSize;
  13460. resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
  13461. sendStreamResponse({
  13462. stream: 'pull_complete',
  13463. success: true
  13464. });
  13465. }, function (reason) {
  13466. sendStreamResponse({
  13467. stream: 'pull_complete',
  13468. success: false,
  13469. reason: reason
  13470. });
  13471. });
  13472. break;
  13473. case 'enqueue':
  13474. (0, _util.assert)(this.streamControllers[data.streamId], 'enqueue should have stream controller');
  13475. if (!this.streamControllers[data.streamId].isClosed) {
  13476. this.streamControllers[data.streamId].controller.enqueue(data.chunk);
  13477. }
  13478. break;
  13479. case 'close':
  13480. (0, _util.assert)(this.streamControllers[data.streamId], 'close should have stream controller');
  13481. if (this.streamControllers[data.streamId].isClosed) {
  13482. break;
  13483. }
  13484. this.streamControllers[data.streamId].isClosed = true;
  13485. this.streamControllers[data.streamId].controller.close();
  13486. deleteStreamController();
  13487. break;
  13488. case 'error':
  13489. (0, _util.assert)(this.streamControllers[data.streamId], 'error should have stream controller');
  13490. this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
  13491. deleteStreamController();
  13492. break;
  13493. case 'cancel_complete':
  13494. resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
  13495. deleteStreamController();
  13496. break;
  13497. case 'cancel':
  13498. if (!this.streamSinks[data.streamId]) {
  13499. break;
  13500. }
  13501. resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
  13502. sendStreamResponse({
  13503. stream: 'cancel_complete',
  13504. success: true
  13505. });
  13506. }, function (reason) {
  13507. sendStreamResponse({
  13508. stream: 'cancel_complete',
  13509. success: false,
  13510. reason: reason
  13511. });
  13512. });
  13513. this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason));
  13514. this.streamSinks[data.streamId].isCancelled = true;
  13515. delete this.streamSinks[data.streamId];
  13516. break;
  13517. default:
  13518. throw new Error('Unexpected stream case');
  13519. }
  13520. },
  13521. postMessage: function postMessage(message, transfers) {
  13522. if (transfers && this.postMessageTransfers) {
  13523. this.comObj.postMessage(message, transfers);
  13524. } else {
  13525. this.comObj.postMessage(message);
  13526. }
  13527. },
  13528. destroy: function destroy() {
  13529. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  13530. }
  13531. };
  13532. /***/ }),
  13533. /* 158 */
  13534. /***/ (function(module, exports, __w_pdfjs_require__) {
  13535. "use strict";
  13536. Object.defineProperty(exports, "__esModule", {
  13537. value: true
  13538. });
  13539. exports.Metadata = void 0;
  13540. var _util = __w_pdfjs_require__(1);
  13541. var _xml_parser = __w_pdfjs_require__(159);
  13542. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13543. 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); } }
  13544. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13545. var Metadata =
  13546. /*#__PURE__*/
  13547. function () {
  13548. function Metadata(data) {
  13549. _classCallCheck(this, Metadata);
  13550. (0, _util.assert)(typeof data === 'string', 'Metadata: input is not a string');
  13551. data = this._repair(data);
  13552. var parser = new _xml_parser.SimpleXMLParser();
  13553. var xmlDocument = parser.parseFromString(data);
  13554. this._metadata = Object.create(null);
  13555. if (xmlDocument) {
  13556. this._parse(xmlDocument);
  13557. }
  13558. }
  13559. _createClass(Metadata, [{
  13560. key: "_repair",
  13561. value: function _repair(data) {
  13562. return data.replace(/^([^<]+)/, '').replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  13563. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  13564. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  13565. }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
  13566. switch (name) {
  13567. case 'amp':
  13568. return '&';
  13569. case 'apos':
  13570. return '\'';
  13571. case 'gt':
  13572. return '>';
  13573. case 'lt':
  13574. return '<';
  13575. case 'quot':
  13576. return '\"';
  13577. }
  13578. throw new Error("_repair: ".concat(name, " isn't defined."));
  13579. });
  13580. var chars = '';
  13581. for (var i = 0, ii = bytes.length; i < ii; i += 2) {
  13582. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  13583. if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
  13584. chars += String.fromCharCode(code);
  13585. } else {
  13586. chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  13587. }
  13588. }
  13589. return '>' + chars;
  13590. });
  13591. }
  13592. }, {
  13593. key: "_parse",
  13594. value: function _parse(xmlDocument) {
  13595. var rdf = xmlDocument.documentElement;
  13596. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  13597. rdf = rdf.firstChild;
  13598. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  13599. rdf = rdf.nextSibling;
  13600. }
  13601. }
  13602. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  13603. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  13604. return;
  13605. }
  13606. var children = rdf.childNodes;
  13607. for (var i = 0, ii = children.length; i < ii; i++) {
  13608. var desc = children[i];
  13609. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  13610. continue;
  13611. }
  13612. for (var j = 0, jj = desc.childNodes.length; j < jj; j++) {
  13613. if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') {
  13614. var entry = desc.childNodes[j];
  13615. var name = entry.nodeName.toLowerCase();
  13616. this._metadata[name] = entry.textContent.trim();
  13617. }
  13618. }
  13619. }
  13620. }
  13621. }, {
  13622. key: "get",
  13623. value: function get(name) {
  13624. var data = this._metadata[name];
  13625. return typeof data !== 'undefined' ? data : null;
  13626. }
  13627. }, {
  13628. key: "getAll",
  13629. value: function getAll() {
  13630. return this._metadata;
  13631. }
  13632. }, {
  13633. key: "has",
  13634. value: function has(name) {
  13635. return typeof this._metadata[name] !== 'undefined';
  13636. }
  13637. }]);
  13638. return Metadata;
  13639. }();
  13640. exports.Metadata = Metadata;
  13641. /***/ }),
  13642. /* 159 */
  13643. /***/ (function(module, exports, __w_pdfjs_require__) {
  13644. "use strict";
  13645. Object.defineProperty(exports, "__esModule", {
  13646. value: true
  13647. });
  13648. exports.SimpleXMLParser = void 0;
  13649. function _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); }
  13650. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  13651. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  13652. function _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; }
  13653. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  13654. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13655. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13656. function _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); }
  13657. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  13658. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13659. function _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); }
  13660. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13661. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13662. 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); } }
  13663. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13664. var XMLParserErrorCode = {
  13665. NoError: 0,
  13666. EndOfDocument: -1,
  13667. UnterminatedCdat: -2,
  13668. UnterminatedXmlDeclaration: -3,
  13669. UnterminatedDoctypeDeclaration: -4,
  13670. UnterminatedComment: -5,
  13671. MalformedElement: -6,
  13672. OutOfMemory: -7,
  13673. UnterminatedAttributeValue: -8,
  13674. UnterminatedElement: -9,
  13675. ElementNeverBegun: -10
  13676. };
  13677. function isWhitespace(s, index) {
  13678. var ch = s[index];
  13679. return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t';
  13680. }
  13681. function isWhitespaceString(s) {
  13682. for (var i = 0, ii = s.length; i < ii; i++) {
  13683. if (!isWhitespace(s, i)) {
  13684. return false;
  13685. }
  13686. }
  13687. return true;
  13688. }
  13689. var XMLParserBase =
  13690. /*#__PURE__*/
  13691. function () {
  13692. function XMLParserBase() {
  13693. _classCallCheck(this, XMLParserBase);
  13694. }
  13695. _createClass(XMLParserBase, [{
  13696. key: "_resolveEntities",
  13697. value: function _resolveEntities(s) {
  13698. var _this = this;
  13699. return s.replace(/&([^;]+);/g, function (all, entity) {
  13700. if (entity.substring(0, 2) === '#x') {
  13701. return String.fromCharCode(parseInt(entity.substring(2), 16));
  13702. } else if (entity.substring(0, 1) === '#') {
  13703. return String.fromCharCode(parseInt(entity.substring(1), 10));
  13704. }
  13705. switch (entity) {
  13706. case 'lt':
  13707. return '<';
  13708. case 'gt':
  13709. return '>';
  13710. case 'amp':
  13711. return '&';
  13712. case 'quot':
  13713. return '\"';
  13714. }
  13715. return _this.onResolveEntity(entity);
  13716. });
  13717. }
  13718. }, {
  13719. key: "_parseContent",
  13720. value: function _parseContent(s, start) {
  13721. var pos = start,
  13722. name,
  13723. attributes = [];
  13724. function skipWs() {
  13725. while (pos < s.length && isWhitespace(s, pos)) {
  13726. ++pos;
  13727. }
  13728. }
  13729. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  13730. ++pos;
  13731. }
  13732. name = s.substring(start, pos);
  13733. skipWs();
  13734. while (pos < s.length && s[pos] !== '>' && s[pos] !== '/' && s[pos] !== '?') {
  13735. skipWs();
  13736. var attrName = '',
  13737. attrValue = '';
  13738. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '=') {
  13739. attrName += s[pos];
  13740. ++pos;
  13741. }
  13742. skipWs();
  13743. if (s[pos] !== '=') {
  13744. return null;
  13745. }
  13746. ++pos;
  13747. skipWs();
  13748. var attrEndChar = s[pos];
  13749. if (attrEndChar !== '\"' && attrEndChar !== '\'') {
  13750. return null;
  13751. }
  13752. var attrEndIndex = s.indexOf(attrEndChar, ++pos);
  13753. if (attrEndIndex < 0) {
  13754. return null;
  13755. }
  13756. attrValue = s.substring(pos, attrEndIndex);
  13757. attributes.push({
  13758. name: attrName,
  13759. value: this._resolveEntities(attrValue)
  13760. });
  13761. pos = attrEndIndex + 1;
  13762. skipWs();
  13763. }
  13764. return {
  13765. name: name,
  13766. attributes: attributes,
  13767. parsed: pos - start
  13768. };
  13769. }
  13770. }, {
  13771. key: "_parseProcessingInstruction",
  13772. value: function _parseProcessingInstruction(s, start) {
  13773. var pos = start,
  13774. name,
  13775. value;
  13776. function skipWs() {
  13777. while (pos < s.length && isWhitespace(s, pos)) {
  13778. ++pos;
  13779. }
  13780. }
  13781. while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') {
  13782. ++pos;
  13783. }
  13784. name = s.substring(start, pos);
  13785. skipWs();
  13786. var attrStart = pos;
  13787. while (pos < s.length && (s[pos] !== '?' || s[pos + 1] !== '>')) {
  13788. ++pos;
  13789. }
  13790. value = s.substring(attrStart, pos);
  13791. return {
  13792. name: name,
  13793. value: value,
  13794. parsed: pos - start
  13795. };
  13796. }
  13797. }, {
  13798. key: "parseXml",
  13799. value: function parseXml(s) {
  13800. var i = 0;
  13801. while (i < s.length) {
  13802. var ch = s[i];
  13803. var j = i;
  13804. if (ch === '<') {
  13805. ++j;
  13806. var ch2 = s[j];
  13807. var q = void 0;
  13808. switch (ch2) {
  13809. case '/':
  13810. ++j;
  13811. q = s.indexOf('>', j);
  13812. if (q < 0) {
  13813. this.onError(XMLParserErrorCode.UnterminatedElement);
  13814. return;
  13815. }
  13816. this.onEndElement(s.substring(j, q));
  13817. j = q + 1;
  13818. break;
  13819. case '?':
  13820. ++j;
  13821. var pi = this._parseProcessingInstruction(s, j);
  13822. if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== '?>') {
  13823. this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
  13824. return;
  13825. }
  13826. this.onPi(pi.name, pi.value);
  13827. j += pi.parsed + 2;
  13828. break;
  13829. case '!':
  13830. if (s.substring(j + 1, j + 3) === '--') {
  13831. q = s.indexOf('-->', j + 3);
  13832. if (q < 0) {
  13833. this.onError(XMLParserErrorCode.UnterminatedComment);
  13834. return;
  13835. }
  13836. this.onComment(s.substring(j + 3, q));
  13837. j = q + 3;
  13838. } else if (s.substring(j + 1, j + 8) === '[CDATA[') {
  13839. q = s.indexOf(']]>', j + 8);
  13840. if (q < 0) {
  13841. this.onError(XMLParserErrorCode.UnterminatedCdat);
  13842. return;
  13843. }
  13844. this.onCdata(s.substring(j + 8, q));
  13845. j = q + 3;
  13846. } else if (s.substring(j + 1, j + 8) === 'DOCTYPE') {
  13847. var q2 = s.indexOf('[', j + 8);
  13848. var complexDoctype = false;
  13849. q = s.indexOf('>', j + 8);
  13850. if (q < 0) {
  13851. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  13852. return;
  13853. }
  13854. if (q2 > 0 && q > q2) {
  13855. q = s.indexOf(']>', j + 8);
  13856. if (q < 0) {
  13857. this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
  13858. return;
  13859. }
  13860. complexDoctype = true;
  13861. }
  13862. var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
  13863. this.onDoctype(doctypeContent);
  13864. j = q + (complexDoctype ? 2 : 1);
  13865. } else {
  13866. this.onError(XMLParserErrorCode.MalformedElement);
  13867. return;
  13868. }
  13869. break;
  13870. default:
  13871. var content = this._parseContent(s, j);
  13872. if (content === null) {
  13873. this.onError(XMLParserErrorCode.MalformedElement);
  13874. return;
  13875. }
  13876. var isClosed = false;
  13877. if (s.substring(j + content.parsed, j + content.parsed + 2) === '/>') {
  13878. isClosed = true;
  13879. } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== '>') {
  13880. this.onError(XMLParserErrorCode.UnterminatedElement);
  13881. return;
  13882. }
  13883. this.onBeginElement(content.name, content.attributes, isClosed);
  13884. j += content.parsed + (isClosed ? 2 : 1);
  13885. break;
  13886. }
  13887. } else {
  13888. while (j < s.length && s[j] !== '<') {
  13889. j++;
  13890. }
  13891. var text = s.substring(i, j);
  13892. this.onText(this._resolveEntities(text));
  13893. }
  13894. i = j;
  13895. }
  13896. }
  13897. }, {
  13898. key: "onResolveEntity",
  13899. value: function onResolveEntity(name) {
  13900. return "&".concat(name, ";");
  13901. }
  13902. }, {
  13903. key: "onPi",
  13904. value: function onPi(name, value) {}
  13905. }, {
  13906. key: "onComment",
  13907. value: function onComment(text) {}
  13908. }, {
  13909. key: "onCdata",
  13910. value: function onCdata(text) {}
  13911. }, {
  13912. key: "onDoctype",
  13913. value: function onDoctype(doctypeContent) {}
  13914. }, {
  13915. key: "onText",
  13916. value: function onText(text) {}
  13917. }, {
  13918. key: "onBeginElement",
  13919. value: function onBeginElement(name, attributes, isEmpty) {}
  13920. }, {
  13921. key: "onEndElement",
  13922. value: function onEndElement(name) {}
  13923. }, {
  13924. key: "onError",
  13925. value: function onError(code) {}
  13926. }]);
  13927. return XMLParserBase;
  13928. }();
  13929. var SimpleDOMNode =
  13930. /*#__PURE__*/
  13931. function () {
  13932. function SimpleDOMNode(nodeName, nodeValue) {
  13933. _classCallCheck(this, SimpleDOMNode);
  13934. this.nodeName = nodeName;
  13935. this.nodeValue = nodeValue;
  13936. Object.defineProperty(this, 'parentNode', {
  13937. value: null,
  13938. writable: true
  13939. });
  13940. }
  13941. _createClass(SimpleDOMNode, [{
  13942. key: "hasChildNodes",
  13943. value: function hasChildNodes() {
  13944. return this.childNodes && this.childNodes.length > 0;
  13945. }
  13946. }, {
  13947. key: "firstChild",
  13948. get: function get() {
  13949. return this.childNodes && this.childNodes[0];
  13950. }
  13951. }, {
  13952. key: "nextSibling",
  13953. get: function get() {
  13954. var childNodes = this.parentNode.childNodes;
  13955. if (!childNodes) {
  13956. return undefined;
  13957. }
  13958. var index = childNodes.indexOf(this);
  13959. if (index === -1) {
  13960. return undefined;
  13961. }
  13962. return childNodes[index + 1];
  13963. }
  13964. }, {
  13965. key: "textContent",
  13966. get: function get() {
  13967. if (!this.childNodes) {
  13968. return this.nodeValue || '';
  13969. }
  13970. return this.childNodes.map(function (child) {
  13971. return child.textContent;
  13972. }).join('');
  13973. }
  13974. }]);
  13975. return SimpleDOMNode;
  13976. }();
  13977. var SimpleXMLParser =
  13978. /*#__PURE__*/
  13979. function (_XMLParserBase) {
  13980. _inherits(SimpleXMLParser, _XMLParserBase);
  13981. function SimpleXMLParser() {
  13982. var _this2;
  13983. _classCallCheck(this, SimpleXMLParser);
  13984. _this2 = _possibleConstructorReturn(this, _getPrototypeOf(SimpleXMLParser).call(this));
  13985. _this2._currentFragment = null;
  13986. _this2._stack = null;
  13987. _this2._errorCode = XMLParserErrorCode.NoError;
  13988. return _this2;
  13989. }
  13990. _createClass(SimpleXMLParser, [{
  13991. key: "parseFromString",
  13992. value: function parseFromString(data) {
  13993. this._currentFragment = [];
  13994. this._stack = [];
  13995. this._errorCode = XMLParserErrorCode.NoError;
  13996. this.parseXml(data);
  13997. if (this._errorCode !== XMLParserErrorCode.NoError) {
  13998. return undefined;
  13999. }
  14000. var _this$_currentFragmen = _slicedToArray(this._currentFragment, 1),
  14001. documentElement = _this$_currentFragmen[0];
  14002. if (!documentElement) {
  14003. return undefined;
  14004. }
  14005. return {
  14006. documentElement: documentElement
  14007. };
  14008. }
  14009. }, {
  14010. key: "onResolveEntity",
  14011. value: function onResolveEntity(name) {
  14012. switch (name) {
  14013. case 'apos':
  14014. return '\'';
  14015. }
  14016. return _get(_getPrototypeOf(SimpleXMLParser.prototype), "onResolveEntity", this).call(this, name);
  14017. }
  14018. }, {
  14019. key: "onText",
  14020. value: function onText(text) {
  14021. if (isWhitespaceString(text)) {
  14022. return;
  14023. }
  14024. var node = new SimpleDOMNode('#text', text);
  14025. this._currentFragment.push(node);
  14026. }
  14027. }, {
  14028. key: "onCdata",
  14029. value: function onCdata(text) {
  14030. var node = new SimpleDOMNode('#text', text);
  14031. this._currentFragment.push(node);
  14032. }
  14033. }, {
  14034. key: "onBeginElement",
  14035. value: function onBeginElement(name, attributes, isEmpty) {
  14036. var node = new SimpleDOMNode(name);
  14037. node.childNodes = [];
  14038. this._currentFragment.push(node);
  14039. if (isEmpty) {
  14040. return;
  14041. }
  14042. this._stack.push(this._currentFragment);
  14043. this._currentFragment = node.childNodes;
  14044. }
  14045. }, {
  14046. key: "onEndElement",
  14047. value: function onEndElement(name) {
  14048. this._currentFragment = this._stack.pop() || [];
  14049. var lastElement = this._currentFragment[this._currentFragment.length - 1];
  14050. if (!lastElement) {
  14051. return;
  14052. }
  14053. for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) {
  14054. lastElement.childNodes[i].parentNode = lastElement;
  14055. }
  14056. }
  14057. }, {
  14058. key: "onError",
  14059. value: function onError(code) {
  14060. this._errorCode = code;
  14061. }
  14062. }]);
  14063. return SimpleXMLParser;
  14064. }(XMLParserBase);
  14065. exports.SimpleXMLParser = SimpleXMLParser;
  14066. /***/ }),
  14067. /* 160 */
  14068. /***/ (function(module, exports, __w_pdfjs_require__) {
  14069. "use strict";
  14070. Object.defineProperty(exports, "__esModule", {
  14071. value: true
  14072. });
  14073. exports.PDFDataTransportStream = void 0;
  14074. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  14075. var _util = __w_pdfjs_require__(1);
  14076. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14077. 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); } }
  14078. 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); }); }; }
  14079. var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
  14080. function PDFDataTransportStream(params, pdfDataRangeTransport) {
  14081. var _this = this;
  14082. (0, _util.assert)(pdfDataRangeTransport);
  14083. this._queuedChunks = [];
  14084. var initialData = params.initialData;
  14085. if (initialData && initialData.length > 0) {
  14086. var buffer = new Uint8Array(initialData).buffer;
  14087. this._queuedChunks.push(buffer);
  14088. }
  14089. this._pdfDataRangeTransport = pdfDataRangeTransport;
  14090. this._isStreamingSupported = !params.disableStream;
  14091. this._isRangeSupported = !params.disableRange;
  14092. this._contentLength = params.length;
  14093. this._fullRequestReader = null;
  14094. this._rangeReaders = [];
  14095. this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  14096. _this._onReceiveData({
  14097. begin: begin,
  14098. chunk: chunk
  14099. });
  14100. });
  14101. this._pdfDataRangeTransport.addProgressListener(function (loaded) {
  14102. _this._onProgress({
  14103. loaded: loaded
  14104. });
  14105. });
  14106. this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  14107. _this._onReceiveData({
  14108. chunk: chunk
  14109. });
  14110. });
  14111. this._pdfDataRangeTransport.transportReady();
  14112. }
  14113. PDFDataTransportStream.prototype = {
  14114. _onReceiveData: function PDFDataTransportStream_onReceiveData(args) {
  14115. var buffer = new Uint8Array(args.chunk).buffer;
  14116. if (args.begin === undefined) {
  14117. if (this._fullRequestReader) {
  14118. this._fullRequestReader._enqueue(buffer);
  14119. } else {
  14120. this._queuedChunks.push(buffer);
  14121. }
  14122. } else {
  14123. var found = this._rangeReaders.some(function (rangeReader) {
  14124. if (rangeReader._begin !== args.begin) {
  14125. return false;
  14126. }
  14127. rangeReader._enqueue(buffer);
  14128. return true;
  14129. });
  14130. (0, _util.assert)(found);
  14131. }
  14132. },
  14133. _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
  14134. if (this._rangeReaders.length > 0) {
  14135. var firstReader = this._rangeReaders[0];
  14136. if (firstReader.onProgress) {
  14137. firstReader.onProgress({
  14138. loaded: evt.loaded
  14139. });
  14140. }
  14141. }
  14142. },
  14143. _removeRangeReader: function PDFDataTransportStream_removeRangeReader(reader) {
  14144. var i = this._rangeReaders.indexOf(reader);
  14145. if (i >= 0) {
  14146. this._rangeReaders.splice(i, 1);
  14147. }
  14148. },
  14149. getFullReader: function PDFDataTransportStream_getFullReader() {
  14150. (0, _util.assert)(!this._fullRequestReader);
  14151. var queuedChunks = this._queuedChunks;
  14152. this._queuedChunks = null;
  14153. return new PDFDataTransportStreamReader(this, queuedChunks);
  14154. },
  14155. getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) {
  14156. var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
  14157. this._pdfDataRangeTransport.requestDataRange(begin, end);
  14158. this._rangeReaders.push(reader);
  14159. return reader;
  14160. },
  14161. cancelAllRequests: function PDFDataTransportStream_cancelAllRequests(reason) {
  14162. if (this._fullRequestReader) {
  14163. this._fullRequestReader.cancel(reason);
  14164. }
  14165. var readers = this._rangeReaders.slice(0);
  14166. readers.forEach(function (rangeReader) {
  14167. rangeReader.cancel(reason);
  14168. });
  14169. this._pdfDataRangeTransport.abort();
  14170. }
  14171. };
  14172. function PDFDataTransportStreamReader(stream, queuedChunks) {
  14173. this._stream = stream;
  14174. this._done = false;
  14175. this._filename = null;
  14176. this._queuedChunks = queuedChunks || [];
  14177. this._requests = [];
  14178. this._headersReady = Promise.resolve();
  14179. stream._fullRequestReader = this;
  14180. this.onProgress = null;
  14181. }
  14182. PDFDataTransportStreamReader.prototype = {
  14183. _enqueue: function PDFDataTransportStreamReader_enqueue(chunk) {
  14184. if (this._done) {
  14185. return;
  14186. }
  14187. if (this._requests.length > 0) {
  14188. var requestCapability = this._requests.shift();
  14189. requestCapability.resolve({
  14190. value: chunk,
  14191. done: false
  14192. });
  14193. return;
  14194. }
  14195. this._queuedChunks.push(chunk);
  14196. },
  14197. get headersReady() {
  14198. return this._headersReady;
  14199. },
  14200. get filename() {
  14201. return this._filename;
  14202. },
  14203. get isRangeSupported() {
  14204. return this._stream._isRangeSupported;
  14205. },
  14206. get isStreamingSupported() {
  14207. return this._stream._isStreamingSupported;
  14208. },
  14209. get contentLength() {
  14210. return this._stream._contentLength;
  14211. },
  14212. read: function () {
  14213. var _read = _asyncToGenerator(
  14214. /*#__PURE__*/
  14215. _regenerator.default.mark(function _callee() {
  14216. var chunk, requestCapability;
  14217. return _regenerator.default.wrap(function _callee$(_context) {
  14218. while (1) {
  14219. switch (_context.prev = _context.next) {
  14220. case 0:
  14221. if (!(this._queuedChunks.length > 0)) {
  14222. _context.next = 3;
  14223. break;
  14224. }
  14225. chunk = this._queuedChunks.shift();
  14226. return _context.abrupt("return", {
  14227. value: chunk,
  14228. done: false
  14229. });
  14230. case 3:
  14231. if (!this._done) {
  14232. _context.next = 5;
  14233. break;
  14234. }
  14235. return _context.abrupt("return", {
  14236. value: undefined,
  14237. done: true
  14238. });
  14239. case 5:
  14240. requestCapability = (0, _util.createPromiseCapability)();
  14241. this._requests.push(requestCapability);
  14242. return _context.abrupt("return", requestCapability.promise);
  14243. case 8:
  14244. case "end":
  14245. return _context.stop();
  14246. }
  14247. }
  14248. }, _callee, this);
  14249. }));
  14250. function read() {
  14251. return _read.apply(this, arguments);
  14252. }
  14253. return read;
  14254. }(),
  14255. cancel: function PDFDataTransportStreamReader_cancel(reason) {
  14256. this._done = true;
  14257. this._requests.forEach(function (requestCapability) {
  14258. requestCapability.resolve({
  14259. value: undefined,
  14260. done: true
  14261. });
  14262. });
  14263. this._requests = [];
  14264. }
  14265. };
  14266. function PDFDataTransportStreamRangeReader(stream, begin, end) {
  14267. this._stream = stream;
  14268. this._begin = begin;
  14269. this._end = end;
  14270. this._queuedChunk = null;
  14271. this._requests = [];
  14272. this._done = false;
  14273. this.onProgress = null;
  14274. }
  14275. PDFDataTransportStreamRangeReader.prototype = {
  14276. _enqueue: function PDFDataTransportStreamRangeReader_enqueue(chunk) {
  14277. if (this._done) {
  14278. return;
  14279. }
  14280. if (this._requests.length === 0) {
  14281. this._queuedChunk = chunk;
  14282. } else {
  14283. var requestsCapability = this._requests.shift();
  14284. requestsCapability.resolve({
  14285. value: chunk,
  14286. done: false
  14287. });
  14288. this._requests.forEach(function (requestCapability) {
  14289. requestCapability.resolve({
  14290. value: undefined,
  14291. done: true
  14292. });
  14293. });
  14294. this._requests = [];
  14295. }
  14296. this._done = true;
  14297. this._stream._removeRangeReader(this);
  14298. },
  14299. get isStreamingSupported() {
  14300. return false;
  14301. },
  14302. read: function () {
  14303. var _read2 = _asyncToGenerator(
  14304. /*#__PURE__*/
  14305. _regenerator.default.mark(function _callee2() {
  14306. var chunk, requestCapability;
  14307. return _regenerator.default.wrap(function _callee2$(_context2) {
  14308. while (1) {
  14309. switch (_context2.prev = _context2.next) {
  14310. case 0:
  14311. if (!this._queuedChunk) {
  14312. _context2.next = 4;
  14313. break;
  14314. }
  14315. chunk = this._queuedChunk;
  14316. this._queuedChunk = null;
  14317. return _context2.abrupt("return", {
  14318. value: chunk,
  14319. done: false
  14320. });
  14321. case 4:
  14322. if (!this._done) {
  14323. _context2.next = 6;
  14324. break;
  14325. }
  14326. return _context2.abrupt("return", {
  14327. value: undefined,
  14328. done: true
  14329. });
  14330. case 6:
  14331. requestCapability = (0, _util.createPromiseCapability)();
  14332. this._requests.push(requestCapability);
  14333. return _context2.abrupt("return", requestCapability.promise);
  14334. case 9:
  14335. case "end":
  14336. return _context2.stop();
  14337. }
  14338. }
  14339. }, _callee2, this);
  14340. }));
  14341. function read() {
  14342. return _read2.apply(this, arguments);
  14343. }
  14344. return read;
  14345. }(),
  14346. cancel: function PDFDataTransportStreamRangeReader_cancel(reason) {
  14347. this._done = true;
  14348. this._requests.forEach(function (requestCapability) {
  14349. requestCapability.resolve({
  14350. value: undefined,
  14351. done: true
  14352. });
  14353. });
  14354. this._requests = [];
  14355. this._stream._removeRangeReader(this);
  14356. }
  14357. };
  14358. return PDFDataTransportStream;
  14359. }();
  14360. exports.PDFDataTransportStream = PDFDataTransportStream;
  14361. /***/ }),
  14362. /* 161 */
  14363. /***/ (function(module, exports, __w_pdfjs_require__) {
  14364. "use strict";
  14365. Object.defineProperty(exports, "__esModule", {
  14366. value: true
  14367. });
  14368. exports.WebGLContext = void 0;
  14369. var _util = __w_pdfjs_require__(1);
  14370. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14371. 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); } }
  14372. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14373. var WebGLContext =
  14374. /*#__PURE__*/
  14375. function () {
  14376. function WebGLContext(_ref) {
  14377. var _ref$enable = _ref.enable,
  14378. enable = _ref$enable === void 0 ? false : _ref$enable;
  14379. _classCallCheck(this, WebGLContext);
  14380. this._enabled = enable === true;
  14381. }
  14382. _createClass(WebGLContext, [{
  14383. key: "composeSMask",
  14384. value: function composeSMask(_ref2) {
  14385. var layer = _ref2.layer,
  14386. mask = _ref2.mask,
  14387. properties = _ref2.properties;
  14388. return WebGLUtils.composeSMask(layer, mask, properties);
  14389. }
  14390. }, {
  14391. key: "drawFigures",
  14392. value: function drawFigures(_ref3) {
  14393. var width = _ref3.width,
  14394. height = _ref3.height,
  14395. backgroundColor = _ref3.backgroundColor,
  14396. figures = _ref3.figures,
  14397. context = _ref3.context;
  14398. return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  14399. }
  14400. }, {
  14401. key: "clear",
  14402. value: function clear() {
  14403. WebGLUtils.cleanup();
  14404. }
  14405. }, {
  14406. key: "isEnabled",
  14407. get: function get() {
  14408. var enabled = this._enabled;
  14409. if (enabled) {
  14410. enabled = WebGLUtils.tryInitGL();
  14411. }
  14412. return (0, _util.shadow)(this, 'isEnabled', enabled);
  14413. }
  14414. }]);
  14415. return WebGLContext;
  14416. }();
  14417. exports.WebGLContext = WebGLContext;
  14418. var WebGLUtils = function WebGLUtilsClosure() {
  14419. function loadShader(gl, code, shaderType) {
  14420. var shader = gl.createShader(shaderType);
  14421. gl.shaderSource(shader, code);
  14422. gl.compileShader(shader);
  14423. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  14424. if (!compiled) {
  14425. var errorMsg = gl.getShaderInfoLog(shader);
  14426. throw new Error('Error during shader compilation: ' + errorMsg);
  14427. }
  14428. return shader;
  14429. }
  14430. function createVertexShader(gl, code) {
  14431. return loadShader(gl, code, gl.VERTEX_SHADER);
  14432. }
  14433. function createFragmentShader(gl, code) {
  14434. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  14435. }
  14436. function createProgram(gl, shaders) {
  14437. var program = gl.createProgram();
  14438. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  14439. gl.attachShader(program, shaders[i]);
  14440. }
  14441. gl.linkProgram(program);
  14442. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  14443. if (!linked) {
  14444. var errorMsg = gl.getProgramInfoLog(program);
  14445. throw new Error('Error during program linking: ' + errorMsg);
  14446. }
  14447. return program;
  14448. }
  14449. function createTexture(gl, image, textureId) {
  14450. gl.activeTexture(textureId);
  14451. var texture = gl.createTexture();
  14452. gl.bindTexture(gl.TEXTURE_2D, texture);
  14453. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  14454. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  14455. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  14456. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  14457. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  14458. return texture;
  14459. }
  14460. var currentGL, currentCanvas;
  14461. function generateGL() {
  14462. if (currentGL) {
  14463. return;
  14464. }
  14465. currentCanvas = document.createElement('canvas');
  14466. currentGL = currentCanvas.getContext('webgl', {
  14467. premultipliedalpha: false
  14468. });
  14469. }
  14470. var smaskVertexShaderCode = '\
  14471. attribute vec2 a_position; \
  14472. attribute vec2 a_texCoord; \
  14473. \
  14474. uniform vec2 u_resolution; \
  14475. \
  14476. varying vec2 v_texCoord; \
  14477. \
  14478. void main() { \
  14479. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  14480. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  14481. \
  14482. v_texCoord = a_texCoord; \
  14483. } ';
  14484. var smaskFragmentShaderCode = '\
  14485. precision mediump float; \
  14486. \
  14487. uniform vec4 u_backdrop; \
  14488. uniform int u_subtype; \
  14489. uniform sampler2D u_image; \
  14490. uniform sampler2D u_mask; \
  14491. \
  14492. varying vec2 v_texCoord; \
  14493. \
  14494. void main() { \
  14495. vec4 imageColor = texture2D(u_image, v_texCoord); \
  14496. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  14497. if (u_backdrop.a > 0.0) { \
  14498. maskColor.rgb = maskColor.rgb * maskColor.a + \
  14499. u_backdrop.rgb * (1.0 - maskColor.a); \
  14500. } \
  14501. float lum; \
  14502. if (u_subtype == 0) { \
  14503. lum = maskColor.a; \
  14504. } else { \
  14505. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  14506. maskColor.b * 0.11; \
  14507. } \
  14508. imageColor.a *= lum; \
  14509. imageColor.rgb *= imageColor.a; \
  14510. gl_FragColor = imageColor; \
  14511. } ';
  14512. var smaskCache = null;
  14513. function initSmaskGL() {
  14514. var canvas, gl;
  14515. generateGL();
  14516. canvas = currentCanvas;
  14517. currentCanvas = null;
  14518. gl = currentGL;
  14519. currentGL = null;
  14520. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  14521. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  14522. var program = createProgram(gl, [vertexShader, fragmentShader]);
  14523. gl.useProgram(program);
  14524. var cache = {};
  14525. cache.gl = gl;
  14526. cache.canvas = canvas;
  14527. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  14528. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  14529. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  14530. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  14531. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  14532. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  14533. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  14534. var texCoordBuffer = gl.createBuffer();
  14535. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  14536. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW);
  14537. gl.enableVertexAttribArray(texCoordLocation);
  14538. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  14539. gl.uniform1i(texLayerLocation, 0);
  14540. gl.uniform1i(texMaskLocation, 1);
  14541. smaskCache = cache;
  14542. }
  14543. function composeSMask(layer, mask, properties) {
  14544. var width = layer.width,
  14545. height = layer.height;
  14546. if (!smaskCache) {
  14547. initSmaskGL();
  14548. }
  14549. var cache = smaskCache,
  14550. canvas = cache.canvas,
  14551. gl = cache.gl;
  14552. canvas.width = width;
  14553. canvas.height = height;
  14554. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  14555. gl.uniform2f(cache.resolutionLocation, width, height);
  14556. if (properties.backdrop) {
  14557. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  14558. } else {
  14559. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  14560. }
  14561. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  14562. var texture = createTexture(gl, layer, gl.TEXTURE0);
  14563. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  14564. var buffer = gl.createBuffer();
  14565. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  14566. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW);
  14567. gl.enableVertexAttribArray(cache.positionLocation);
  14568. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  14569. gl.clearColor(0, 0, 0, 0);
  14570. gl.enable(gl.BLEND);
  14571. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  14572. gl.clear(gl.COLOR_BUFFER_BIT);
  14573. gl.drawArrays(gl.TRIANGLES, 0, 6);
  14574. gl.flush();
  14575. gl.deleteTexture(texture);
  14576. gl.deleteTexture(maskTexture);
  14577. gl.deleteBuffer(buffer);
  14578. return canvas;
  14579. }
  14580. var figuresVertexShaderCode = '\
  14581. attribute vec2 a_position; \
  14582. attribute vec3 a_color; \
  14583. \
  14584. uniform vec2 u_resolution; \
  14585. uniform vec2 u_scale; \
  14586. uniform vec2 u_offset; \
  14587. \
  14588. varying vec4 v_color; \
  14589. \
  14590. void main() { \
  14591. vec2 position = (a_position + u_offset) * u_scale; \
  14592. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  14593. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  14594. \
  14595. v_color = vec4(a_color / 255.0, 1.0); \
  14596. } ';
  14597. var figuresFragmentShaderCode = '\
  14598. precision mediump float; \
  14599. \
  14600. varying vec4 v_color; \
  14601. \
  14602. void main() { \
  14603. gl_FragColor = v_color; \
  14604. } ';
  14605. var figuresCache = null;
  14606. function initFiguresGL() {
  14607. var canvas, gl;
  14608. generateGL();
  14609. canvas = currentCanvas;
  14610. currentCanvas = null;
  14611. gl = currentGL;
  14612. currentGL = null;
  14613. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  14614. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  14615. var program = createProgram(gl, [vertexShader, fragmentShader]);
  14616. gl.useProgram(program);
  14617. var cache = {};
  14618. cache.gl = gl;
  14619. cache.canvas = canvas;
  14620. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  14621. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  14622. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  14623. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  14624. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  14625. figuresCache = cache;
  14626. }
  14627. function drawFigures(width, height, backgroundColor, figures, context) {
  14628. if (!figuresCache) {
  14629. initFiguresGL();
  14630. }
  14631. var cache = figuresCache,
  14632. canvas = cache.canvas,
  14633. gl = cache.gl;
  14634. canvas.width = width;
  14635. canvas.height = height;
  14636. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  14637. gl.uniform2f(cache.resolutionLocation, width, height);
  14638. var count = 0;
  14639. var i, ii, rows;
  14640. for (i = 0, ii = figures.length; i < ii; i++) {
  14641. switch (figures[i].type) {
  14642. case 'lattice':
  14643. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  14644. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  14645. break;
  14646. case 'triangles':
  14647. count += figures[i].coords.length;
  14648. break;
  14649. }
  14650. }
  14651. var coords = new Float32Array(count * 2);
  14652. var colors = new Uint8Array(count * 3);
  14653. var coordsMap = context.coords,
  14654. colorsMap = context.colors;
  14655. var pIndex = 0,
  14656. cIndex = 0;
  14657. for (i = 0, ii = figures.length; i < ii; i++) {
  14658. var figure = figures[i],
  14659. ps = figure.coords,
  14660. cs = figure.colors;
  14661. switch (figure.type) {
  14662. case 'lattice':
  14663. var cols = figure.verticesPerRow;
  14664. rows = ps.length / cols | 0;
  14665. for (var row = 1; row < rows; row++) {
  14666. var offset = row * cols + 1;
  14667. for (var col = 1; col < cols; col++, offset++) {
  14668. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  14669. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  14670. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  14671. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  14672. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  14673. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  14674. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  14675. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  14676. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  14677. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  14678. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  14679. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  14680. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  14681. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  14682. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  14683. coords[pIndex + 6] = coords[pIndex + 2];
  14684. coords[pIndex + 7] = coords[pIndex + 3];
  14685. coords[pIndex + 8] = coords[pIndex + 4];
  14686. coords[pIndex + 9] = coords[pIndex + 5];
  14687. coords[pIndex + 10] = coordsMap[ps[offset]];
  14688. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  14689. colors[cIndex + 9] = colors[cIndex + 3];
  14690. colors[cIndex + 10] = colors[cIndex + 4];
  14691. colors[cIndex + 11] = colors[cIndex + 5];
  14692. colors[cIndex + 12] = colors[cIndex + 6];
  14693. colors[cIndex + 13] = colors[cIndex + 7];
  14694. colors[cIndex + 14] = colors[cIndex + 8];
  14695. colors[cIndex + 15] = colorsMap[cs[offset]];
  14696. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  14697. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  14698. pIndex += 12;
  14699. cIndex += 18;
  14700. }
  14701. }
  14702. break;
  14703. case 'triangles':
  14704. for (var j = 0, jj = ps.length; j < jj; j++) {
  14705. coords[pIndex] = coordsMap[ps[j]];
  14706. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  14707. colors[cIndex] = colorsMap[cs[j]];
  14708. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  14709. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  14710. pIndex += 2;
  14711. cIndex += 3;
  14712. }
  14713. break;
  14714. }
  14715. }
  14716. if (backgroundColor) {
  14717. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  14718. } else {
  14719. gl.clearColor(0, 0, 0, 0);
  14720. }
  14721. gl.clear(gl.COLOR_BUFFER_BIT);
  14722. var coordsBuffer = gl.createBuffer();
  14723. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  14724. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  14725. gl.enableVertexAttribArray(cache.positionLocation);
  14726. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  14727. var colorsBuffer = gl.createBuffer();
  14728. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  14729. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  14730. gl.enableVertexAttribArray(cache.colorLocation);
  14731. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  14732. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  14733. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  14734. gl.drawArrays(gl.TRIANGLES, 0, count);
  14735. gl.flush();
  14736. gl.deleteBuffer(coordsBuffer);
  14737. gl.deleteBuffer(colorsBuffer);
  14738. return canvas;
  14739. }
  14740. return {
  14741. tryInitGL: function tryInitGL() {
  14742. try {
  14743. generateGL();
  14744. return !!currentGL;
  14745. } catch (ex) {}
  14746. return false;
  14747. },
  14748. composeSMask: composeSMask,
  14749. drawFigures: drawFigures,
  14750. cleanup: function cleanup() {
  14751. if (smaskCache && smaskCache.canvas) {
  14752. smaskCache.canvas.width = 0;
  14753. smaskCache.canvas.height = 0;
  14754. }
  14755. if (figuresCache && figuresCache.canvas) {
  14756. figuresCache.canvas.width = 0;
  14757. figuresCache.canvas.height = 0;
  14758. }
  14759. smaskCache = null;
  14760. figuresCache = null;
  14761. }
  14762. };
  14763. }();
  14764. /***/ }),
  14765. /* 162 */
  14766. /***/ (function(module, exports, __w_pdfjs_require__) {
  14767. "use strict";
  14768. Object.defineProperty(exports, "__esModule", {
  14769. value: true
  14770. });
  14771. exports.renderTextLayer = void 0;
  14772. var _util = __w_pdfjs_require__(1);
  14773. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  14774. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14775. var renderTextLayer = function renderTextLayerClosure() {
  14776. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  14777. var NonWhitespaceRegexp = /\S/;
  14778. function isAllWhitespace(str) {
  14779. return !NonWhitespaceRegexp.test(str);
  14780. }
  14781. var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';'];
  14782. function appendText(task, geom, styles) {
  14783. var textDiv = document.createElement('span');
  14784. var textDivProperties = {
  14785. style: null,
  14786. angle: 0,
  14787. canvasWidth: 0,
  14788. isWhitespace: false,
  14789. originalTransform: null,
  14790. paddingBottom: 0,
  14791. paddingLeft: 0,
  14792. paddingRight: 0,
  14793. paddingTop: 0,
  14794. scale: 1
  14795. };
  14796. task._textDivs.push(textDiv);
  14797. if (isAllWhitespace(geom.str)) {
  14798. textDivProperties.isWhitespace = true;
  14799. task._textDivProperties.set(textDiv, textDivProperties);
  14800. return;
  14801. }
  14802. var tx = _util.Util.transform(task._viewport.transform, geom.transform);
  14803. var angle = Math.atan2(tx[1], tx[0]);
  14804. var style = styles[geom.fontName];
  14805. if (style.vertical) {
  14806. angle += Math.PI / 2;
  14807. }
  14808. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  14809. var fontAscent = fontHeight;
  14810. if (style.ascent) {
  14811. fontAscent = style.ascent * fontAscent;
  14812. } else if (style.descent) {
  14813. fontAscent = (1 + style.descent) * fontAscent;
  14814. }
  14815. var left;
  14816. var top;
  14817. if (angle === 0) {
  14818. left = tx[4];
  14819. top = tx[5] - fontAscent;
  14820. } else {
  14821. left = tx[4] + fontAscent * Math.sin(angle);
  14822. top = tx[5] - fontAscent * Math.cos(angle);
  14823. }
  14824. styleBuf[1] = left;
  14825. styleBuf[3] = top;
  14826. styleBuf[5] = fontHeight;
  14827. styleBuf[7] = style.fontFamily;
  14828. textDivProperties.style = styleBuf.join('');
  14829. textDiv.setAttribute('style', textDivProperties.style);
  14830. textDiv.textContent = geom.str;
  14831. if (task._fontInspectorEnabled) {
  14832. textDiv.dataset.fontName = geom.fontName;
  14833. }
  14834. if (angle !== 0) {
  14835. textDivProperties.angle = angle * (180 / Math.PI);
  14836. }
  14837. if (geom.str.length > 1) {
  14838. if (style.vertical) {
  14839. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  14840. } else {
  14841. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  14842. }
  14843. }
  14844. task._textDivProperties.set(textDiv, textDivProperties);
  14845. if (task._textContentStream) {
  14846. task._layoutText(textDiv);
  14847. }
  14848. if (task._enhanceTextSelection) {
  14849. var angleCos = 1,
  14850. angleSin = 0;
  14851. if (angle !== 0) {
  14852. angleCos = Math.cos(angle);
  14853. angleSin = Math.sin(angle);
  14854. }
  14855. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  14856. var divHeight = fontHeight;
  14857. var m, b;
  14858. if (angle !== 0) {
  14859. m = [angleCos, angleSin, -angleSin, angleCos, left, top];
  14860. b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
  14861. } else {
  14862. b = [left, top, left + divWidth, top + divHeight];
  14863. }
  14864. task._bounds.push({
  14865. left: b[0],
  14866. top: b[1],
  14867. right: b[2],
  14868. bottom: b[3],
  14869. div: textDiv,
  14870. size: [divWidth, divHeight],
  14871. m: m
  14872. });
  14873. }
  14874. }
  14875. function render(task) {
  14876. if (task._canceled) {
  14877. return;
  14878. }
  14879. var textDivs = task._textDivs;
  14880. var capability = task._capability;
  14881. var textDivsLength = textDivs.length;
  14882. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  14883. task._renderingDone = true;
  14884. capability.resolve();
  14885. return;
  14886. }
  14887. if (!task._textContentStream) {
  14888. for (var i = 0; i < textDivsLength; i++) {
  14889. task._layoutText(textDivs[i]);
  14890. }
  14891. }
  14892. task._renderingDone = true;
  14893. capability.resolve();
  14894. }
  14895. function expand(task) {
  14896. var bounds = task._bounds;
  14897. var viewport = task._viewport;
  14898. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  14899. for (var i = 0; i < expanded.length; i++) {
  14900. var div = bounds[i].div;
  14901. var divProperties = task._textDivProperties.get(div);
  14902. if (divProperties.angle === 0) {
  14903. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  14904. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  14905. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  14906. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  14907. task._textDivProperties.set(div, divProperties);
  14908. continue;
  14909. }
  14910. var e = expanded[i],
  14911. b = bounds[i];
  14912. var m = b.m,
  14913. c = m[0],
  14914. s = m[1];
  14915. var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
  14916. var ts = new Float64Array(64);
  14917. points.forEach(function (p, i) {
  14918. var t = _util.Util.applyTransform(p, m);
  14919. ts[i + 0] = c && (e.left - t[0]) / c;
  14920. ts[i + 4] = s && (e.top - t[1]) / s;
  14921. ts[i + 8] = c && (e.right - t[0]) / c;
  14922. ts[i + 12] = s && (e.bottom - t[1]) / s;
  14923. ts[i + 16] = s && (e.left - t[0]) / -s;
  14924. ts[i + 20] = c && (e.top - t[1]) / c;
  14925. ts[i + 24] = s && (e.right - t[0]) / -s;
  14926. ts[i + 28] = c && (e.bottom - t[1]) / c;
  14927. ts[i + 32] = c && (e.left - t[0]) / -c;
  14928. ts[i + 36] = s && (e.top - t[1]) / -s;
  14929. ts[i + 40] = c && (e.right - t[0]) / -c;
  14930. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  14931. ts[i + 48] = s && (e.left - t[0]) / s;
  14932. ts[i + 52] = c && (e.top - t[1]) / -c;
  14933. ts[i + 56] = s && (e.right - t[0]) / s;
  14934. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  14935. });
  14936. var findPositiveMin = function findPositiveMin(ts, offset, count) {
  14937. var result = 0;
  14938. for (var i = 0; i < count; i++) {
  14939. var t = ts[offset++];
  14940. if (t > 0) {
  14941. result = result ? Math.min(t, result) : t;
  14942. }
  14943. }
  14944. return result;
  14945. };
  14946. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  14947. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  14948. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  14949. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  14950. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  14951. task._textDivProperties.set(div, divProperties);
  14952. }
  14953. }
  14954. function expandBounds(width, height, boxes) {
  14955. var bounds = boxes.map(function (box, i) {
  14956. return {
  14957. x1: box.left,
  14958. y1: box.top,
  14959. x2: box.right,
  14960. y2: box.bottom,
  14961. index: i,
  14962. x1New: undefined,
  14963. x2New: undefined
  14964. };
  14965. });
  14966. expandBoundsLTR(width, bounds);
  14967. var expanded = new Array(boxes.length);
  14968. bounds.forEach(function (b) {
  14969. var i = b.index;
  14970. expanded[i] = {
  14971. left: b.x1New,
  14972. top: 0,
  14973. right: b.x2New,
  14974. bottom: 0
  14975. };
  14976. });
  14977. boxes.map(function (box, i) {
  14978. var e = expanded[i],
  14979. b = bounds[i];
  14980. b.x1 = box.top;
  14981. b.y1 = width - e.right;
  14982. b.x2 = box.bottom;
  14983. b.y2 = width - e.left;
  14984. b.index = i;
  14985. b.x1New = undefined;
  14986. b.x2New = undefined;
  14987. });
  14988. expandBoundsLTR(height, bounds);
  14989. bounds.forEach(function (b) {
  14990. var i = b.index;
  14991. expanded[i].top = b.x1New;
  14992. expanded[i].bottom = b.x2New;
  14993. });
  14994. return expanded;
  14995. }
  14996. function expandBoundsLTR(width, bounds) {
  14997. bounds.sort(function (a, b) {
  14998. return a.x1 - b.x1 || a.index - b.index;
  14999. });
  15000. var fakeBoundary = {
  15001. x1: -Infinity,
  15002. y1: -Infinity,
  15003. x2: 0,
  15004. y2: Infinity,
  15005. index: -1,
  15006. x1New: 0,
  15007. x2New: 0
  15008. };
  15009. var horizon = [{
  15010. start: -Infinity,
  15011. end: Infinity,
  15012. boundary: fakeBoundary
  15013. }];
  15014. bounds.forEach(function (boundary) {
  15015. var i = 0;
  15016. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  15017. i++;
  15018. }
  15019. var j = horizon.length - 1;
  15020. while (j >= 0 && horizon[j].start >= boundary.y2) {
  15021. j--;
  15022. }
  15023. var horizonPart, affectedBoundary;
  15024. var q,
  15025. k,
  15026. maxXNew = -Infinity;
  15027. for (q = i; q <= j; q++) {
  15028. horizonPart = horizon[q];
  15029. affectedBoundary = horizonPart.boundary;
  15030. var xNew;
  15031. if (affectedBoundary.x2 > boundary.x1) {
  15032. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  15033. } else if (affectedBoundary.x2New === undefined) {
  15034. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  15035. } else {
  15036. xNew = affectedBoundary.x2New;
  15037. }
  15038. if (xNew > maxXNew) {
  15039. maxXNew = xNew;
  15040. }
  15041. }
  15042. boundary.x1New = maxXNew;
  15043. for (q = i; q <= j; q++) {
  15044. horizonPart = horizon[q];
  15045. affectedBoundary = horizonPart.boundary;
  15046. if (affectedBoundary.x2New === undefined) {
  15047. if (affectedBoundary.x2 > boundary.x1) {
  15048. if (affectedBoundary.index > boundary.index) {
  15049. affectedBoundary.x2New = affectedBoundary.x2;
  15050. }
  15051. } else {
  15052. affectedBoundary.x2New = maxXNew;
  15053. }
  15054. } else if (affectedBoundary.x2New > maxXNew) {
  15055. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  15056. }
  15057. }
  15058. var changedHorizon = [],
  15059. lastBoundary = null;
  15060. for (q = i; q <= j; q++) {
  15061. horizonPart = horizon[q];
  15062. affectedBoundary = horizonPart.boundary;
  15063. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  15064. if (lastBoundary === useBoundary) {
  15065. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  15066. } else {
  15067. changedHorizon.push({
  15068. start: horizonPart.start,
  15069. end: horizonPart.end,
  15070. boundary: useBoundary
  15071. });
  15072. lastBoundary = useBoundary;
  15073. }
  15074. }
  15075. if (horizon[i].start < boundary.y1) {
  15076. changedHorizon[0].start = boundary.y1;
  15077. changedHorizon.unshift({
  15078. start: horizon[i].start,
  15079. end: boundary.y1,
  15080. boundary: horizon[i].boundary
  15081. });
  15082. }
  15083. if (boundary.y2 < horizon[j].end) {
  15084. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  15085. changedHorizon.push({
  15086. start: boundary.y2,
  15087. end: horizon[j].end,
  15088. boundary: horizon[j].boundary
  15089. });
  15090. }
  15091. for (q = i; q <= j; q++) {
  15092. horizonPart = horizon[q];
  15093. affectedBoundary = horizonPart.boundary;
  15094. if (affectedBoundary.x2New !== undefined) {
  15095. continue;
  15096. }
  15097. var used = false;
  15098. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  15099. used = horizon[k].boundary === affectedBoundary;
  15100. }
  15101. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  15102. used = horizon[k].boundary === affectedBoundary;
  15103. }
  15104. for (k = 0; !used && k < changedHorizon.length; k++) {
  15105. used = changedHorizon[k].boundary === affectedBoundary;
  15106. }
  15107. if (!used) {
  15108. affectedBoundary.x2New = maxXNew;
  15109. }
  15110. }
  15111. Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon));
  15112. });
  15113. horizon.forEach(function (horizonPart) {
  15114. var affectedBoundary = horizonPart.boundary;
  15115. if (affectedBoundary.x2New === undefined) {
  15116. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  15117. }
  15118. });
  15119. }
  15120. function TextLayerRenderTask(_ref) {
  15121. var textContent = _ref.textContent,
  15122. textContentStream = _ref.textContentStream,
  15123. container = _ref.container,
  15124. viewport = _ref.viewport,
  15125. textDivs = _ref.textDivs,
  15126. textContentItemsStr = _ref.textContentItemsStr,
  15127. enhanceTextSelection = _ref.enhanceTextSelection;
  15128. this._textContent = textContent;
  15129. this._textContentStream = textContentStream;
  15130. this._container = container;
  15131. this._viewport = viewport;
  15132. this._textDivs = textDivs || [];
  15133. this._textContentItemsStr = textContentItemsStr || [];
  15134. this._enhanceTextSelection = !!enhanceTextSelection;
  15135. this._fontInspectorEnabled = !!(_global_scope.default.FontInspector && _global_scope.default.FontInspector.enabled);
  15136. this._reader = null;
  15137. this._layoutTextLastFontSize = null;
  15138. this._layoutTextLastFontFamily = null;
  15139. this._layoutTextCtx = null;
  15140. this._textDivProperties = new WeakMap();
  15141. this._renderingDone = false;
  15142. this._canceled = false;
  15143. this._capability = (0, _util.createPromiseCapability)();
  15144. this._renderTimer = null;
  15145. this._bounds = [];
  15146. }
  15147. TextLayerRenderTask.prototype = {
  15148. get promise() {
  15149. return this._capability.promise;
  15150. },
  15151. cancel: function TextLayer_cancel() {
  15152. if (this._reader) {
  15153. this._reader.cancel(new _util.AbortException('text layer task cancelled'));
  15154. this._reader = null;
  15155. }
  15156. this._canceled = true;
  15157. if (this._renderTimer !== null) {
  15158. clearTimeout(this._renderTimer);
  15159. this._renderTimer = null;
  15160. }
  15161. this._capability.reject('canceled');
  15162. },
  15163. _processItems: function _processItems(items, styleCache) {
  15164. for (var i = 0, len = items.length; i < len; i++) {
  15165. this._textContentItemsStr.push(items[i].str);
  15166. appendText(this, items[i], styleCache);
  15167. }
  15168. },
  15169. _layoutText: function _layoutText(textDiv) {
  15170. var textLayerFrag = this._container;
  15171. var textDivProperties = this._textDivProperties.get(textDiv);
  15172. if (textDivProperties.isWhitespace) {
  15173. return;
  15174. }
  15175. var fontSize = textDiv.style.fontSize;
  15176. var fontFamily = textDiv.style.fontFamily;
  15177. if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) {
  15178. this._layoutTextCtx.font = fontSize + ' ' + fontFamily;
  15179. this._layoutTextLastFontSize = fontSize;
  15180. this._layoutTextLastFontFamily = fontFamily;
  15181. }
  15182. var width = this._layoutTextCtx.measureText(textDiv.textContent).width;
  15183. var transform = '';
  15184. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  15185. textDivProperties.scale = textDivProperties.canvasWidth / width;
  15186. transform = "scaleX(".concat(textDivProperties.scale, ")");
  15187. }
  15188. if (textDivProperties.angle !== 0) {
  15189. transform = "rotate(".concat(textDivProperties.angle, "deg) ").concat(transform);
  15190. }
  15191. if (transform.length > 0) {
  15192. textDivProperties.originalTransform = transform;
  15193. textDiv.style.transform = transform;
  15194. }
  15195. this._textDivProperties.set(textDiv, textDivProperties);
  15196. textLayerFrag.appendChild(textDiv);
  15197. },
  15198. _render: function TextLayer_render(timeout) {
  15199. var _this = this;
  15200. var capability = (0, _util.createPromiseCapability)();
  15201. var styleCache = Object.create(null);
  15202. var canvas = document.createElement('canvas');
  15203. canvas.mozOpaque = true;
  15204. this._layoutTextCtx = canvas.getContext('2d', {
  15205. alpha: false
  15206. });
  15207. if (this._textContent) {
  15208. var textItems = this._textContent.items;
  15209. var textStyles = this._textContent.styles;
  15210. this._processItems(textItems, textStyles);
  15211. capability.resolve();
  15212. } else if (this._textContentStream) {
  15213. var pump = function pump() {
  15214. _this._reader.read().then(function (_ref2) {
  15215. var value = _ref2.value,
  15216. done = _ref2.done;
  15217. if (done) {
  15218. capability.resolve();
  15219. return;
  15220. }
  15221. Object.assign(styleCache, value.styles);
  15222. _this._processItems(value.items, styleCache);
  15223. pump();
  15224. }, capability.reject);
  15225. };
  15226. this._reader = this._textContentStream.getReader();
  15227. pump();
  15228. } else {
  15229. throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.');
  15230. }
  15231. capability.promise.then(function () {
  15232. styleCache = null;
  15233. if (!timeout) {
  15234. render(_this);
  15235. } else {
  15236. _this._renderTimer = setTimeout(function () {
  15237. render(_this);
  15238. _this._renderTimer = null;
  15239. }, timeout);
  15240. }
  15241. }, this._capability.reject);
  15242. },
  15243. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  15244. if (!this._enhanceTextSelection || !this._renderingDone) {
  15245. return;
  15246. }
  15247. if (this._bounds !== null) {
  15248. expand(this);
  15249. this._bounds = null;
  15250. }
  15251. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  15252. var div = this._textDivs[i];
  15253. var divProperties = this._textDivProperties.get(div);
  15254. if (divProperties.isWhitespace) {
  15255. continue;
  15256. }
  15257. if (expandDivs) {
  15258. var transform = '',
  15259. padding = '';
  15260. if (divProperties.scale !== 1) {
  15261. transform = 'scaleX(' + divProperties.scale + ')';
  15262. }
  15263. if (divProperties.angle !== 0) {
  15264. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  15265. }
  15266. if (divProperties.paddingLeft !== 0) {
  15267. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  15268. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  15269. }
  15270. if (divProperties.paddingTop !== 0) {
  15271. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  15272. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  15273. }
  15274. if (divProperties.paddingRight !== 0) {
  15275. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  15276. }
  15277. if (divProperties.paddingBottom !== 0) {
  15278. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  15279. }
  15280. if (padding !== '') {
  15281. div.setAttribute('style', divProperties.style + padding);
  15282. }
  15283. if (transform !== '') {
  15284. div.style.transform = transform;
  15285. }
  15286. } else {
  15287. div.style.padding = 0;
  15288. div.style.transform = divProperties.originalTransform || '';
  15289. }
  15290. }
  15291. }
  15292. };
  15293. function renderTextLayer(renderParameters) {
  15294. var task = new TextLayerRenderTask({
  15295. textContent: renderParameters.textContent,
  15296. textContentStream: renderParameters.textContentStream,
  15297. container: renderParameters.container,
  15298. viewport: renderParameters.viewport,
  15299. textDivs: renderParameters.textDivs,
  15300. textContentItemsStr: renderParameters.textContentItemsStr,
  15301. enhanceTextSelection: renderParameters.enhanceTextSelection
  15302. });
  15303. task._render(renderParameters.timeout);
  15304. return task;
  15305. }
  15306. return renderTextLayer;
  15307. }();
  15308. exports.renderTextLayer = renderTextLayer;
  15309. /***/ }),
  15310. /* 163 */
  15311. /***/ (function(module, exports, __w_pdfjs_require__) {
  15312. "use strict";
  15313. Object.defineProperty(exports, "__esModule", {
  15314. value: true
  15315. });
  15316. exports.AnnotationLayer = void 0;
  15317. var _dom_utils = __w_pdfjs_require__(151);
  15318. var _util = __w_pdfjs_require__(1);
  15319. function _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); }
  15320. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  15321. function _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); }
  15322. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15323. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  15324. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  15325. function _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); }
  15326. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  15327. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15328. 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); } }
  15329. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15330. var AnnotationElementFactory =
  15331. /*#__PURE__*/
  15332. function () {
  15333. function AnnotationElementFactory() {
  15334. _classCallCheck(this, AnnotationElementFactory);
  15335. }
  15336. _createClass(AnnotationElementFactory, null, [{
  15337. key: "create",
  15338. value: function create(parameters) {
  15339. var subtype = parameters.data.annotationType;
  15340. switch (subtype) {
  15341. case _util.AnnotationType.LINK:
  15342. return new LinkAnnotationElement(parameters);
  15343. case _util.AnnotationType.TEXT:
  15344. return new TextAnnotationElement(parameters);
  15345. case _util.AnnotationType.WIDGET:
  15346. var fieldType = parameters.data.fieldType;
  15347. switch (fieldType) {
  15348. case 'Tx':
  15349. return new TextWidgetAnnotationElement(parameters);
  15350. case 'Btn':
  15351. if (parameters.data.radioButton) {
  15352. return new RadioButtonWidgetAnnotationElement(parameters);
  15353. } else if (parameters.data.checkBox) {
  15354. return new CheckboxWidgetAnnotationElement(parameters);
  15355. }
  15356. return new PushButtonWidgetAnnotationElement(parameters);
  15357. case 'Ch':
  15358. return new ChoiceWidgetAnnotationElement(parameters);
  15359. }
  15360. return new WidgetAnnotationElement(parameters);
  15361. case _util.AnnotationType.POPUP:
  15362. return new PopupAnnotationElement(parameters);
  15363. case _util.AnnotationType.LINE:
  15364. return new LineAnnotationElement(parameters);
  15365. case _util.AnnotationType.SQUARE:
  15366. return new SquareAnnotationElement(parameters);
  15367. case _util.AnnotationType.CIRCLE:
  15368. return new CircleAnnotationElement(parameters);
  15369. case _util.AnnotationType.POLYLINE:
  15370. return new PolylineAnnotationElement(parameters);
  15371. case _util.AnnotationType.INK:
  15372. return new InkAnnotationElement(parameters);
  15373. case _util.AnnotationType.POLYGON:
  15374. return new PolygonAnnotationElement(parameters);
  15375. case _util.AnnotationType.HIGHLIGHT:
  15376. return new HighlightAnnotationElement(parameters);
  15377. case _util.AnnotationType.UNDERLINE:
  15378. return new UnderlineAnnotationElement(parameters);
  15379. case _util.AnnotationType.SQUIGGLY:
  15380. return new SquigglyAnnotationElement(parameters);
  15381. case _util.AnnotationType.STRIKEOUT:
  15382. return new StrikeOutAnnotationElement(parameters);
  15383. case _util.AnnotationType.STAMP:
  15384. return new StampAnnotationElement(parameters);
  15385. case _util.AnnotationType.FILEATTACHMENT:
  15386. return new FileAttachmentAnnotationElement(parameters);
  15387. default:
  15388. return new AnnotationElement(parameters);
  15389. }
  15390. }
  15391. }]);
  15392. return AnnotationElementFactory;
  15393. }();
  15394. var AnnotationElement =
  15395. /*#__PURE__*/
  15396. function () {
  15397. function AnnotationElement(parameters) {
  15398. var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  15399. var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  15400. _classCallCheck(this, AnnotationElement);
  15401. this.isRenderable = isRenderable;
  15402. this.data = parameters.data;
  15403. this.layer = parameters.layer;
  15404. this.page = parameters.page;
  15405. this.viewport = parameters.viewport;
  15406. this.linkService = parameters.linkService;
  15407. this.downloadManager = parameters.downloadManager;
  15408. this.imageResourcesPath = parameters.imageResourcesPath;
  15409. this.renderInteractiveForms = parameters.renderInteractiveForms;
  15410. this.svgFactory = parameters.svgFactory;
  15411. if (isRenderable) {
  15412. this.container = this._createContainer(ignoreBorder);
  15413. }
  15414. }
  15415. _createClass(AnnotationElement, [{
  15416. key: "_createContainer",
  15417. value: function _createContainer() {
  15418. var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15419. var data = this.data,
  15420. page = this.page,
  15421. viewport = this.viewport;
  15422. var container = document.createElement('section');
  15423. var width = data.rect[2] - data.rect[0];
  15424. var height = data.rect[3] - data.rect[1];
  15425. container.setAttribute('data-annotation-id', data.id);
  15426. var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);
  15427. container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';
  15428. container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';
  15429. if (!ignoreBorder && data.borderStyle.width > 0) {
  15430. container.style.borderWidth = data.borderStyle.width + 'px';
  15431. if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {
  15432. width = width - 2 * data.borderStyle.width;
  15433. height = height - 2 * data.borderStyle.width;
  15434. }
  15435. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  15436. var verticalRadius = data.borderStyle.verticalCornerRadius;
  15437. if (horizontalRadius > 0 || verticalRadius > 0) {
  15438. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  15439. container.style.borderRadius = radius;
  15440. }
  15441. switch (data.borderStyle.style) {
  15442. case _util.AnnotationBorderStyleType.SOLID:
  15443. container.style.borderStyle = 'solid';
  15444. break;
  15445. case _util.AnnotationBorderStyleType.DASHED:
  15446. container.style.borderStyle = 'dashed';
  15447. break;
  15448. case _util.AnnotationBorderStyleType.BEVELED:
  15449. (0, _util.warn)('Unimplemented border style: beveled');
  15450. break;
  15451. case _util.AnnotationBorderStyleType.INSET:
  15452. (0, _util.warn)('Unimplemented border style: inset');
  15453. break;
  15454. case _util.AnnotationBorderStyleType.UNDERLINE:
  15455. container.style.borderBottomStyle = 'solid';
  15456. break;
  15457. default:
  15458. break;
  15459. }
  15460. if (data.color) {
  15461. container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  15462. } else {
  15463. container.style.borderWidth = 0;
  15464. }
  15465. }
  15466. container.style.left = rect[0] + 'px';
  15467. container.style.top = rect[1] + 'px';
  15468. container.style.width = width + 'px';
  15469. container.style.height = height + 'px';
  15470. return container;
  15471. }
  15472. }, {
  15473. key: "_createPopup",
  15474. value: function _createPopup(container, trigger, data) {
  15475. if (!trigger) {
  15476. trigger = document.createElement('div');
  15477. trigger.style.height = container.style.height;
  15478. trigger.style.width = container.style.width;
  15479. container.appendChild(trigger);
  15480. }
  15481. var popupElement = new PopupElement({
  15482. container: container,
  15483. trigger: trigger,
  15484. color: data.color,
  15485. title: data.title,
  15486. contents: data.contents,
  15487. hideWrapper: true
  15488. });
  15489. var popup = popupElement.render();
  15490. popup.style.left = container.style.width;
  15491. container.appendChild(popup);
  15492. }
  15493. }, {
  15494. key: "render",
  15495. value: function render() {
  15496. (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');
  15497. }
  15498. }]);
  15499. return AnnotationElement;
  15500. }();
  15501. var LinkAnnotationElement =
  15502. /*#__PURE__*/
  15503. function (_AnnotationElement) {
  15504. _inherits(LinkAnnotationElement, _AnnotationElement);
  15505. function LinkAnnotationElement(parameters) {
  15506. _classCallCheck(this, LinkAnnotationElement);
  15507. var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);
  15508. return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));
  15509. }
  15510. _createClass(LinkAnnotationElement, [{
  15511. key: "render",
  15512. value: function render() {
  15513. this.container.className = 'linkAnnotation';
  15514. var data = this.data,
  15515. linkService = this.linkService;
  15516. var link = document.createElement('a');
  15517. (0, _dom_utils.addLinkAttributes)(link, {
  15518. url: data.url,
  15519. target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget,
  15520. rel: linkService.externalLinkRel
  15521. });
  15522. if (!data.url) {
  15523. if (data.action) {
  15524. this._bindNamedAction(link, data.action);
  15525. } else {
  15526. this._bindLink(link, data.dest);
  15527. }
  15528. }
  15529. this.container.appendChild(link);
  15530. return this.container;
  15531. }
  15532. }, {
  15533. key: "_bindLink",
  15534. value: function _bindLink(link, destination) {
  15535. var _this = this;
  15536. link.href = this.linkService.getDestinationHash(destination);
  15537. link.onclick = function () {
  15538. if (destination) {
  15539. _this.linkService.navigateTo(destination);
  15540. }
  15541. return false;
  15542. };
  15543. if (destination) {
  15544. link.className = 'internalLink';
  15545. }
  15546. }
  15547. }, {
  15548. key: "_bindNamedAction",
  15549. value: function _bindNamedAction(link, action) {
  15550. var _this2 = this;
  15551. link.href = this.linkService.getAnchorUrl('');
  15552. link.onclick = function () {
  15553. _this2.linkService.executeNamedAction(action);
  15554. return false;
  15555. };
  15556. link.className = 'internalLink';
  15557. }
  15558. }]);
  15559. return LinkAnnotationElement;
  15560. }(AnnotationElement);
  15561. var TextAnnotationElement =
  15562. /*#__PURE__*/
  15563. function (_AnnotationElement2) {
  15564. _inherits(TextAnnotationElement, _AnnotationElement2);
  15565. function TextAnnotationElement(parameters) {
  15566. _classCallCheck(this, TextAnnotationElement);
  15567. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15568. return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));
  15569. }
  15570. _createClass(TextAnnotationElement, [{
  15571. key: "render",
  15572. value: function render() {
  15573. this.container.className = 'textAnnotation';
  15574. var image = document.createElement('img');
  15575. image.style.height = this.container.style.height;
  15576. image.style.width = this.container.style.width;
  15577. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  15578. image.alt = '[{{type}} Annotation]';
  15579. image.dataset.l10nId = 'text_annotation_type';
  15580. image.dataset.l10nArgs = JSON.stringify({
  15581. type: this.data.name
  15582. });
  15583. if (!this.data.hasPopup) {
  15584. this._createPopup(this.container, image, this.data);
  15585. }
  15586. this.container.appendChild(image);
  15587. return this.container;
  15588. }
  15589. }]);
  15590. return TextAnnotationElement;
  15591. }(AnnotationElement);
  15592. var WidgetAnnotationElement =
  15593. /*#__PURE__*/
  15594. function (_AnnotationElement3) {
  15595. _inherits(WidgetAnnotationElement, _AnnotationElement3);
  15596. function WidgetAnnotationElement() {
  15597. _classCallCheck(this, WidgetAnnotationElement);
  15598. return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));
  15599. }
  15600. _createClass(WidgetAnnotationElement, [{
  15601. key: "render",
  15602. value: function render() {
  15603. return this.container;
  15604. }
  15605. }]);
  15606. return WidgetAnnotationElement;
  15607. }(AnnotationElement);
  15608. var TextWidgetAnnotationElement =
  15609. /*#__PURE__*/
  15610. function (_WidgetAnnotationElem) {
  15611. _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);
  15612. function TextWidgetAnnotationElement(parameters) {
  15613. _classCallCheck(this, TextWidgetAnnotationElement);
  15614. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  15615. return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));
  15616. }
  15617. _createClass(TextWidgetAnnotationElement, [{
  15618. key: "render",
  15619. value: function render() {
  15620. var TEXT_ALIGNMENT = ['left', 'center', 'right'];
  15621. this.container.className = 'textWidgetAnnotation';
  15622. var element = null;
  15623. if (this.renderInteractiveForms) {
  15624. if (this.data.multiLine) {
  15625. element = document.createElement('textarea');
  15626. element.textContent = this.data.fieldValue;
  15627. } else {
  15628. element = document.createElement('input');
  15629. element.type = 'text';
  15630. element.setAttribute('value', this.data.fieldValue);
  15631. }
  15632. element.disabled = this.data.readOnly;
  15633. if (this.data.maxLen !== null) {
  15634. element.maxLength = this.data.maxLen;
  15635. }
  15636. if (this.data.comb) {
  15637. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  15638. var combWidth = fieldWidth / this.data.maxLen;
  15639. element.classList.add('comb');
  15640. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  15641. }
  15642. } else {
  15643. element = document.createElement('div');
  15644. element.textContent = this.data.fieldValue;
  15645. element.style.verticalAlign = 'middle';
  15646. element.style.display = 'table-cell';
  15647. var font = null;
  15648. if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {
  15649. font = this.page.commonObjs.get(this.data.fontRefName);
  15650. }
  15651. this._setTextStyle(element, font);
  15652. }
  15653. if (this.data.textAlignment !== null) {
  15654. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  15655. }
  15656. this.container.appendChild(element);
  15657. return this.container;
  15658. }
  15659. }, {
  15660. key: "_setTextStyle",
  15661. value: function _setTextStyle(element, font) {
  15662. var style = element.style;
  15663. style.fontSize = this.data.fontSize + 'px';
  15664. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  15665. if (!font) {
  15666. return;
  15667. }
  15668. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  15669. style.fontStyle = font.italic ? 'italic' : 'normal';
  15670. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  15671. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  15672. style.fontFamily = fontFamily + fallbackName;
  15673. }
  15674. }]);
  15675. return TextWidgetAnnotationElement;
  15676. }(WidgetAnnotationElement);
  15677. var CheckboxWidgetAnnotationElement =
  15678. /*#__PURE__*/
  15679. function (_WidgetAnnotationElem2) {
  15680. _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);
  15681. function CheckboxWidgetAnnotationElement(parameters) {
  15682. _classCallCheck(this, CheckboxWidgetAnnotationElement);
  15683. return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  15684. }
  15685. _createClass(CheckboxWidgetAnnotationElement, [{
  15686. key: "render",
  15687. value: function render() {
  15688. this.container.className = 'buttonWidgetAnnotation checkBox';
  15689. var element = document.createElement('input');
  15690. element.disabled = this.data.readOnly;
  15691. element.type = 'checkbox';
  15692. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  15693. element.setAttribute('checked', true);
  15694. }
  15695. this.container.appendChild(element);
  15696. return this.container;
  15697. }
  15698. }]);
  15699. return CheckboxWidgetAnnotationElement;
  15700. }(WidgetAnnotationElement);
  15701. var RadioButtonWidgetAnnotationElement =
  15702. /*#__PURE__*/
  15703. function (_WidgetAnnotationElem3) {
  15704. _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);
  15705. function RadioButtonWidgetAnnotationElement(parameters) {
  15706. _classCallCheck(this, RadioButtonWidgetAnnotationElement);
  15707. return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  15708. }
  15709. _createClass(RadioButtonWidgetAnnotationElement, [{
  15710. key: "render",
  15711. value: function render() {
  15712. this.container.className = 'buttonWidgetAnnotation radioButton';
  15713. var element = document.createElement('input');
  15714. element.disabled = this.data.readOnly;
  15715. element.type = 'radio';
  15716. element.name = this.data.fieldName;
  15717. if (this.data.fieldValue === this.data.buttonValue) {
  15718. element.setAttribute('checked', true);
  15719. }
  15720. this.container.appendChild(element);
  15721. return this.container;
  15722. }
  15723. }]);
  15724. return RadioButtonWidgetAnnotationElement;
  15725. }(WidgetAnnotationElement);
  15726. var PushButtonWidgetAnnotationElement =
  15727. /*#__PURE__*/
  15728. function (_LinkAnnotationElemen) {
  15729. _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);
  15730. function PushButtonWidgetAnnotationElement() {
  15731. _classCallCheck(this, PushButtonWidgetAnnotationElement);
  15732. return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));
  15733. }
  15734. _createClass(PushButtonWidgetAnnotationElement, [{
  15735. key: "render",
  15736. value: function render() {
  15737. var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);
  15738. container.className = 'buttonWidgetAnnotation pushButton';
  15739. return container;
  15740. }
  15741. }]);
  15742. return PushButtonWidgetAnnotationElement;
  15743. }(LinkAnnotationElement);
  15744. var ChoiceWidgetAnnotationElement =
  15745. /*#__PURE__*/
  15746. function (_WidgetAnnotationElem4) {
  15747. _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);
  15748. function ChoiceWidgetAnnotationElement(parameters) {
  15749. _classCallCheck(this, ChoiceWidgetAnnotationElement);
  15750. return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));
  15751. }
  15752. _createClass(ChoiceWidgetAnnotationElement, [{
  15753. key: "render",
  15754. value: function render() {
  15755. this.container.className = 'choiceWidgetAnnotation';
  15756. var selectElement = document.createElement('select');
  15757. selectElement.disabled = this.data.readOnly;
  15758. if (!this.data.combo) {
  15759. selectElement.size = this.data.options.length;
  15760. if (this.data.multiSelect) {
  15761. selectElement.multiple = true;
  15762. }
  15763. }
  15764. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  15765. var option = this.data.options[i];
  15766. var optionElement = document.createElement('option');
  15767. optionElement.textContent = option.displayValue;
  15768. optionElement.value = option.exportValue;
  15769. if (this.data.fieldValue.includes(option.displayValue)) {
  15770. optionElement.setAttribute('selected', true);
  15771. }
  15772. selectElement.appendChild(optionElement);
  15773. }
  15774. this.container.appendChild(selectElement);
  15775. return this.container;
  15776. }
  15777. }]);
  15778. return ChoiceWidgetAnnotationElement;
  15779. }(WidgetAnnotationElement);
  15780. var PopupAnnotationElement =
  15781. /*#__PURE__*/
  15782. function (_AnnotationElement4) {
  15783. _inherits(PopupAnnotationElement, _AnnotationElement4);
  15784. function PopupAnnotationElement(parameters) {
  15785. _classCallCheck(this, PopupAnnotationElement);
  15786. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  15787. return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));
  15788. }
  15789. _createClass(PopupAnnotationElement, [{
  15790. key: "render",
  15791. value: function render() {
  15792. var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];
  15793. this.container.className = 'popupAnnotation';
  15794. if (IGNORE_TYPES.includes(this.data.parentType)) {
  15795. return this.container;
  15796. }
  15797. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  15798. var parentElement = this.layer.querySelector(selector);
  15799. if (!parentElement) {
  15800. return this.container;
  15801. }
  15802. var popup = new PopupElement({
  15803. container: this.container,
  15804. trigger: parentElement,
  15805. color: this.data.color,
  15806. title: this.data.title,
  15807. contents: this.data.contents
  15808. });
  15809. var parentLeft = parseFloat(parentElement.style.left);
  15810. var parentWidth = parseFloat(parentElement.style.width);
  15811. this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;
  15812. this.container.style.left = parentLeft + parentWidth + 'px';
  15813. this.container.appendChild(popup.render());
  15814. return this.container;
  15815. }
  15816. }]);
  15817. return PopupAnnotationElement;
  15818. }(AnnotationElement);
  15819. var PopupElement =
  15820. /*#__PURE__*/
  15821. function () {
  15822. function PopupElement(parameters) {
  15823. _classCallCheck(this, PopupElement);
  15824. this.container = parameters.container;
  15825. this.trigger = parameters.trigger;
  15826. this.color = parameters.color;
  15827. this.title = parameters.title;
  15828. this.contents = parameters.contents;
  15829. this.hideWrapper = parameters.hideWrapper || false;
  15830. this.pinned = false;
  15831. }
  15832. _createClass(PopupElement, [{
  15833. key: "render",
  15834. value: function render() {
  15835. var BACKGROUND_ENLIGHT = 0.7;
  15836. var wrapper = document.createElement('div');
  15837. wrapper.className = 'popupWrapper';
  15838. this.hideElement = this.hideWrapper ? wrapper : this.container;
  15839. this.hideElement.setAttribute('hidden', true);
  15840. var popup = document.createElement('div');
  15841. popup.className = 'popup';
  15842. var color = this.color;
  15843. if (color) {
  15844. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  15845. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  15846. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  15847. popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);
  15848. }
  15849. var contents = this._formatContents(this.contents);
  15850. var title = document.createElement('h1');
  15851. title.textContent = this.title;
  15852. this.trigger.addEventListener('click', this._toggle.bind(this));
  15853. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  15854. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  15855. popup.addEventListener('click', this._hide.bind(this, true));
  15856. popup.appendChild(title);
  15857. popup.appendChild(contents);
  15858. wrapper.appendChild(popup);
  15859. return wrapper;
  15860. }
  15861. }, {
  15862. key: "_formatContents",
  15863. value: function _formatContents(contents) {
  15864. var p = document.createElement('p');
  15865. var lines = contents.split(/(?:\r\n?|\n)/);
  15866. for (var i = 0, ii = lines.length; i < ii; ++i) {
  15867. var line = lines[i];
  15868. p.appendChild(document.createTextNode(line));
  15869. if (i < ii - 1) {
  15870. p.appendChild(document.createElement('br'));
  15871. }
  15872. }
  15873. return p;
  15874. }
  15875. }, {
  15876. key: "_toggle",
  15877. value: function _toggle() {
  15878. if (this.pinned) {
  15879. this._hide(true);
  15880. } else {
  15881. this._show(true);
  15882. }
  15883. }
  15884. }, {
  15885. key: "_show",
  15886. value: function _show() {
  15887. var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  15888. if (pin) {
  15889. this.pinned = true;
  15890. }
  15891. if (this.hideElement.hasAttribute('hidden')) {
  15892. this.hideElement.removeAttribute('hidden');
  15893. this.container.style.zIndex += 1;
  15894. }
  15895. }
  15896. }, {
  15897. key: "_hide",
  15898. value: function _hide() {
  15899. var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  15900. if (unpin) {
  15901. this.pinned = false;
  15902. }
  15903. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  15904. this.hideElement.setAttribute('hidden', true);
  15905. this.container.style.zIndex -= 1;
  15906. }
  15907. }
  15908. }]);
  15909. return PopupElement;
  15910. }();
  15911. var LineAnnotationElement =
  15912. /*#__PURE__*/
  15913. function (_AnnotationElement5) {
  15914. _inherits(LineAnnotationElement, _AnnotationElement5);
  15915. function LineAnnotationElement(parameters) {
  15916. _classCallCheck(this, LineAnnotationElement);
  15917. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15918. return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));
  15919. }
  15920. _createClass(LineAnnotationElement, [{
  15921. key: "render",
  15922. value: function render() {
  15923. this.container.className = 'lineAnnotation';
  15924. var data = this.data;
  15925. var width = data.rect[2] - data.rect[0];
  15926. var height = data.rect[3] - data.rect[1];
  15927. var svg = this.svgFactory.create(width, height);
  15928. var line = this.svgFactory.createElement('svg:line');
  15929. line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
  15930. line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
  15931. line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
  15932. line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
  15933. line.setAttribute('stroke-width', data.borderStyle.width);
  15934. line.setAttribute('stroke', 'transparent');
  15935. svg.appendChild(line);
  15936. this.container.append(svg);
  15937. this._createPopup(this.container, line, data);
  15938. return this.container;
  15939. }
  15940. }]);
  15941. return LineAnnotationElement;
  15942. }(AnnotationElement);
  15943. var SquareAnnotationElement =
  15944. /*#__PURE__*/
  15945. function (_AnnotationElement6) {
  15946. _inherits(SquareAnnotationElement, _AnnotationElement6);
  15947. function SquareAnnotationElement(parameters) {
  15948. _classCallCheck(this, SquareAnnotationElement);
  15949. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15950. return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));
  15951. }
  15952. _createClass(SquareAnnotationElement, [{
  15953. key: "render",
  15954. value: function render() {
  15955. this.container.className = 'squareAnnotation';
  15956. var data = this.data;
  15957. var width = data.rect[2] - data.rect[0];
  15958. var height = data.rect[3] - data.rect[1];
  15959. var svg = this.svgFactory.create(width, height);
  15960. var borderWidth = data.borderStyle.width;
  15961. var square = this.svgFactory.createElement('svg:rect');
  15962. square.setAttribute('x', borderWidth / 2);
  15963. square.setAttribute('y', borderWidth / 2);
  15964. square.setAttribute('width', width - borderWidth);
  15965. square.setAttribute('height', height - borderWidth);
  15966. square.setAttribute('stroke-width', borderWidth);
  15967. square.setAttribute('stroke', 'transparent');
  15968. square.setAttribute('fill', 'none');
  15969. svg.appendChild(square);
  15970. this.container.append(svg);
  15971. this._createPopup(this.container, square, data);
  15972. return this.container;
  15973. }
  15974. }]);
  15975. return SquareAnnotationElement;
  15976. }(AnnotationElement);
  15977. var CircleAnnotationElement =
  15978. /*#__PURE__*/
  15979. function (_AnnotationElement7) {
  15980. _inherits(CircleAnnotationElement, _AnnotationElement7);
  15981. function CircleAnnotationElement(parameters) {
  15982. _classCallCheck(this, CircleAnnotationElement);
  15983. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  15984. return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));
  15985. }
  15986. _createClass(CircleAnnotationElement, [{
  15987. key: "render",
  15988. value: function render() {
  15989. this.container.className = 'circleAnnotation';
  15990. var data = this.data;
  15991. var width = data.rect[2] - data.rect[0];
  15992. var height = data.rect[3] - data.rect[1];
  15993. var svg = this.svgFactory.create(width, height);
  15994. var borderWidth = data.borderStyle.width;
  15995. var circle = this.svgFactory.createElement('svg:ellipse');
  15996. circle.setAttribute('cx', width / 2);
  15997. circle.setAttribute('cy', height / 2);
  15998. circle.setAttribute('rx', width / 2 - borderWidth / 2);
  15999. circle.setAttribute('ry', height / 2 - borderWidth / 2);
  16000. circle.setAttribute('stroke-width', borderWidth);
  16001. circle.setAttribute('stroke', 'transparent');
  16002. circle.setAttribute('fill', 'none');
  16003. svg.appendChild(circle);
  16004. this.container.append(svg);
  16005. this._createPopup(this.container, circle, data);
  16006. return this.container;
  16007. }
  16008. }]);
  16009. return CircleAnnotationElement;
  16010. }(AnnotationElement);
  16011. var PolylineAnnotationElement =
  16012. /*#__PURE__*/
  16013. function (_AnnotationElement8) {
  16014. _inherits(PolylineAnnotationElement, _AnnotationElement8);
  16015. function PolylineAnnotationElement(parameters) {
  16016. var _this3;
  16017. _classCallCheck(this, PolylineAnnotationElement);
  16018. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16019. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));
  16020. _this3.containerClassName = 'polylineAnnotation';
  16021. _this3.svgElementName = 'svg:polyline';
  16022. return _this3;
  16023. }
  16024. _createClass(PolylineAnnotationElement, [{
  16025. key: "render",
  16026. value: function render() {
  16027. this.container.className = this.containerClassName;
  16028. var data = this.data;
  16029. var width = data.rect[2] - data.rect[0];
  16030. var height = data.rect[3] - data.rect[1];
  16031. var svg = this.svgFactory.create(width, height);
  16032. var vertices = data.vertices;
  16033. var points = [];
  16034. for (var i = 0, ii = vertices.length; i < ii; i++) {
  16035. var x = vertices[i].x - data.rect[0];
  16036. var y = data.rect[3] - vertices[i].y;
  16037. points.push(x + ',' + y);
  16038. }
  16039. points = points.join(' ');
  16040. var borderWidth = data.borderStyle.width;
  16041. var polyline = this.svgFactory.createElement(this.svgElementName);
  16042. polyline.setAttribute('points', points);
  16043. polyline.setAttribute('stroke-width', borderWidth);
  16044. polyline.setAttribute('stroke', 'transparent');
  16045. polyline.setAttribute('fill', 'none');
  16046. svg.appendChild(polyline);
  16047. this.container.append(svg);
  16048. this._createPopup(this.container, polyline, data);
  16049. return this.container;
  16050. }
  16051. }]);
  16052. return PolylineAnnotationElement;
  16053. }(AnnotationElement);
  16054. var PolygonAnnotationElement =
  16055. /*#__PURE__*/
  16056. function (_PolylineAnnotationEl) {
  16057. _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);
  16058. function PolygonAnnotationElement(parameters) {
  16059. var _this4;
  16060. _classCallCheck(this, PolygonAnnotationElement);
  16061. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));
  16062. _this4.containerClassName = 'polygonAnnotation';
  16063. _this4.svgElementName = 'svg:polygon';
  16064. return _this4;
  16065. }
  16066. return PolygonAnnotationElement;
  16067. }(PolylineAnnotationElement);
  16068. var InkAnnotationElement =
  16069. /*#__PURE__*/
  16070. function (_AnnotationElement9) {
  16071. _inherits(InkAnnotationElement, _AnnotationElement9);
  16072. function InkAnnotationElement(parameters) {
  16073. var _this5;
  16074. _classCallCheck(this, InkAnnotationElement);
  16075. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16076. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotationElement).call(this, parameters, isRenderable, true));
  16077. _this5.containerClassName = 'inkAnnotation';
  16078. _this5.svgElementName = 'svg:polyline';
  16079. return _this5;
  16080. }
  16081. _createClass(InkAnnotationElement, [{
  16082. key: "render",
  16083. value: function render() {
  16084. this.container.className = this.containerClassName;
  16085. var data = this.data;
  16086. var width = data.rect[2] - data.rect[0];
  16087. var height = data.rect[3] - data.rect[1];
  16088. var svg = this.svgFactory.create(width, height);
  16089. var inkLists = data.inkLists;
  16090. for (var i = 0, ii = inkLists.length; i < ii; i++) {
  16091. var inkList = inkLists[i];
  16092. var points = [];
  16093. for (var j = 0, jj = inkList.length; j < jj; j++) {
  16094. var x = inkList[j].x - data.rect[0];
  16095. var y = data.rect[3] - inkList[j].y;
  16096. points.push(x + ',' + y);
  16097. }
  16098. points = points.join(' ');
  16099. var borderWidth = data.borderStyle.width;
  16100. var polyline = this.svgFactory.createElement(this.svgElementName);
  16101. polyline.setAttribute('points', points);
  16102. polyline.setAttribute('stroke-width', borderWidth);
  16103. polyline.setAttribute('stroke', 'transparent');
  16104. polyline.setAttribute('fill', 'none');
  16105. this._createPopup(this.container, polyline, data);
  16106. svg.appendChild(polyline);
  16107. }
  16108. this.container.append(svg);
  16109. return this.container;
  16110. }
  16111. }]);
  16112. return InkAnnotationElement;
  16113. }(AnnotationElement);
  16114. var HighlightAnnotationElement =
  16115. /*#__PURE__*/
  16116. function (_AnnotationElement10) {
  16117. _inherits(HighlightAnnotationElement, _AnnotationElement10);
  16118. function HighlightAnnotationElement(parameters) {
  16119. _classCallCheck(this, HighlightAnnotationElement);
  16120. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16121. return _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotationElement).call(this, parameters, isRenderable, true));
  16122. }
  16123. _createClass(HighlightAnnotationElement, [{
  16124. key: "render",
  16125. value: function render() {
  16126. this.container.className = 'highlightAnnotation';
  16127. if (!this.data.hasPopup) {
  16128. this._createPopup(this.container, null, this.data);
  16129. }
  16130. return this.container;
  16131. }
  16132. }]);
  16133. return HighlightAnnotationElement;
  16134. }(AnnotationElement);
  16135. var UnderlineAnnotationElement =
  16136. /*#__PURE__*/
  16137. function (_AnnotationElement11) {
  16138. _inherits(UnderlineAnnotationElement, _AnnotationElement11);
  16139. function UnderlineAnnotationElement(parameters) {
  16140. _classCallCheck(this, UnderlineAnnotationElement);
  16141. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16142. return _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotationElement).call(this, parameters, isRenderable, true));
  16143. }
  16144. _createClass(UnderlineAnnotationElement, [{
  16145. key: "render",
  16146. value: function render() {
  16147. this.container.className = 'underlineAnnotation';
  16148. if (!this.data.hasPopup) {
  16149. this._createPopup(this.container, null, this.data);
  16150. }
  16151. return this.container;
  16152. }
  16153. }]);
  16154. return UnderlineAnnotationElement;
  16155. }(AnnotationElement);
  16156. var SquigglyAnnotationElement =
  16157. /*#__PURE__*/
  16158. function (_AnnotationElement12) {
  16159. _inherits(SquigglyAnnotationElement, _AnnotationElement12);
  16160. function SquigglyAnnotationElement(parameters) {
  16161. _classCallCheck(this, SquigglyAnnotationElement);
  16162. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16163. return _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotationElement).call(this, parameters, isRenderable, true));
  16164. }
  16165. _createClass(SquigglyAnnotationElement, [{
  16166. key: "render",
  16167. value: function render() {
  16168. this.container.className = 'squigglyAnnotation';
  16169. if (!this.data.hasPopup) {
  16170. this._createPopup(this.container, null, this.data);
  16171. }
  16172. return this.container;
  16173. }
  16174. }]);
  16175. return SquigglyAnnotationElement;
  16176. }(AnnotationElement);
  16177. var StrikeOutAnnotationElement =
  16178. /*#__PURE__*/
  16179. function (_AnnotationElement13) {
  16180. _inherits(StrikeOutAnnotationElement, _AnnotationElement13);
  16181. function StrikeOutAnnotationElement(parameters) {
  16182. _classCallCheck(this, StrikeOutAnnotationElement);
  16183. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16184. return _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotationElement).call(this, parameters, isRenderable, true));
  16185. }
  16186. _createClass(StrikeOutAnnotationElement, [{
  16187. key: "render",
  16188. value: function render() {
  16189. this.container.className = 'strikeoutAnnotation';
  16190. if (!this.data.hasPopup) {
  16191. this._createPopup(this.container, null, this.data);
  16192. }
  16193. return this.container;
  16194. }
  16195. }]);
  16196. return StrikeOutAnnotationElement;
  16197. }(AnnotationElement);
  16198. var StampAnnotationElement =
  16199. /*#__PURE__*/
  16200. function (_AnnotationElement14) {
  16201. _inherits(StampAnnotationElement, _AnnotationElement14);
  16202. function StampAnnotationElement(parameters) {
  16203. _classCallCheck(this, StampAnnotationElement);
  16204. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  16205. return _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotationElement).call(this, parameters, isRenderable, true));
  16206. }
  16207. _createClass(StampAnnotationElement, [{
  16208. key: "render",
  16209. value: function render() {
  16210. this.container.className = 'stampAnnotation';
  16211. if (!this.data.hasPopup) {
  16212. this._createPopup(this.container, null, this.data);
  16213. }
  16214. return this.container;
  16215. }
  16216. }]);
  16217. return StampAnnotationElement;
  16218. }(AnnotationElement);
  16219. var FileAttachmentAnnotationElement =
  16220. /*#__PURE__*/
  16221. function (_AnnotationElement15) {
  16222. _inherits(FileAttachmentAnnotationElement, _AnnotationElement15);
  16223. function FileAttachmentAnnotationElement(parameters) {
  16224. var _this6;
  16225. _classCallCheck(this, FileAttachmentAnnotationElement);
  16226. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotationElement).call(this, parameters, true));
  16227. var _this6$data$file = _this6.data.file,
  16228. filename = _this6$data$file.filename,
  16229. content = _this6$data$file.content;
  16230. _this6.filename = (0, _dom_utils.getFilenameFromUrl)(filename);
  16231. _this6.content = content;
  16232. if (_this6.linkService.eventBus) {
  16233. _this6.linkService.eventBus.dispatch('fileattachmentannotation', {
  16234. source: _assertThisInitialized(_assertThisInitialized(_this6)),
  16235. id: (0, _util.stringToPDFString)(filename),
  16236. filename: filename,
  16237. content: content
  16238. });
  16239. }
  16240. return _this6;
  16241. }
  16242. _createClass(FileAttachmentAnnotationElement, [{
  16243. key: "render",
  16244. value: function render() {
  16245. this.container.className = 'fileAttachmentAnnotation';
  16246. var trigger = document.createElement('div');
  16247. trigger.style.height = this.container.style.height;
  16248. trigger.style.width = this.container.style.width;
  16249. trigger.addEventListener('dblclick', this._download.bind(this));
  16250. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  16251. this._createPopup(this.container, trigger, this.data);
  16252. }
  16253. this.container.appendChild(trigger);
  16254. return this.container;
  16255. }
  16256. }, {
  16257. key: "_download",
  16258. value: function _download() {
  16259. if (!this.downloadManager) {
  16260. (0, _util.warn)('Download cannot be started due to unavailable download manager');
  16261. return;
  16262. }
  16263. this.downloadManager.downloadData(this.content, this.filename, '');
  16264. }
  16265. }]);
  16266. return FileAttachmentAnnotationElement;
  16267. }(AnnotationElement);
  16268. var AnnotationLayer =
  16269. /*#__PURE__*/
  16270. function () {
  16271. function AnnotationLayer() {
  16272. _classCallCheck(this, AnnotationLayer);
  16273. }
  16274. _createClass(AnnotationLayer, null, [{
  16275. key: "render",
  16276. value: function render(parameters) {
  16277. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  16278. var data = parameters.annotations[i];
  16279. if (!data) {
  16280. continue;
  16281. }
  16282. var element = AnnotationElementFactory.create({
  16283. data: data,
  16284. layer: parameters.div,
  16285. page: parameters.page,
  16286. viewport: parameters.viewport,
  16287. linkService: parameters.linkService,
  16288. downloadManager: parameters.downloadManager,
  16289. imageResourcesPath: parameters.imageResourcesPath || '',
  16290. renderInteractiveForms: parameters.renderInteractiveForms || false,
  16291. svgFactory: new _dom_utils.DOMSVGFactory()
  16292. });
  16293. if (element.isRenderable) {
  16294. parameters.div.appendChild(element.render());
  16295. }
  16296. }
  16297. }
  16298. }, {
  16299. key: "update",
  16300. value: function update(parameters) {
  16301. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  16302. var data = parameters.annotations[i];
  16303. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  16304. if (element) {
  16305. element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')';
  16306. }
  16307. }
  16308. parameters.div.removeAttribute('hidden');
  16309. }
  16310. }]);
  16311. return AnnotationLayer;
  16312. }();
  16313. exports.AnnotationLayer = AnnotationLayer;
  16314. /***/ }),
  16315. /* 164 */
  16316. /***/ (function(module, exports, __w_pdfjs_require__) {
  16317. "use strict";
  16318. Object.defineProperty(exports, "__esModule", {
  16319. value: true
  16320. });
  16321. exports.SVGGraphics = void 0;
  16322. var _util = __w_pdfjs_require__(1);
  16323. var _dom_utils = __w_pdfjs_require__(151);
  16324. var _is_node = _interopRequireDefault(__w_pdfjs_require__(4));
  16325. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16326. var SVGGraphics = function SVGGraphics() {
  16327. throw new Error('Not implemented: SVGGraphics');
  16328. };
  16329. exports.SVGGraphics = SVGGraphics;
  16330. {
  16331. var SVG_DEFAULTS = {
  16332. fontStyle: 'normal',
  16333. fontWeight: 'normal',
  16334. fillColor: '#000000'
  16335. };
  16336. var convertImgDataToPng = function convertImgDataToPngClosure() {
  16337. var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
  16338. var CHUNK_WRAPPER_SIZE = 12;
  16339. var crcTable = new Int32Array(256);
  16340. for (var i = 0; i < 256; i++) {
  16341. var c = i;
  16342. for (var h = 0; h < 8; h++) {
  16343. if (c & 1) {
  16344. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  16345. } else {
  16346. c = c >> 1 & 0x7fffffff;
  16347. }
  16348. }
  16349. crcTable[i] = c;
  16350. }
  16351. function crc32(data, start, end) {
  16352. var crc = -1;
  16353. for (var i = start; i < end; i++) {
  16354. var a = (crc ^ data[i]) & 0xff;
  16355. var b = crcTable[a];
  16356. crc = crc >>> 8 ^ b;
  16357. }
  16358. return crc ^ -1;
  16359. }
  16360. function writePngChunk(type, body, data, offset) {
  16361. var p = offset;
  16362. var len = body.length;
  16363. data[p] = len >> 24 & 0xff;
  16364. data[p + 1] = len >> 16 & 0xff;
  16365. data[p + 2] = len >> 8 & 0xff;
  16366. data[p + 3] = len & 0xff;
  16367. p += 4;
  16368. data[p] = type.charCodeAt(0) & 0xff;
  16369. data[p + 1] = type.charCodeAt(1) & 0xff;
  16370. data[p + 2] = type.charCodeAt(2) & 0xff;
  16371. data[p + 3] = type.charCodeAt(3) & 0xff;
  16372. p += 4;
  16373. data.set(body, p);
  16374. p += body.length;
  16375. var crc = crc32(data, offset + 4, p);
  16376. data[p] = crc >> 24 & 0xff;
  16377. data[p + 1] = crc >> 16 & 0xff;
  16378. data[p + 2] = crc >> 8 & 0xff;
  16379. data[p + 3] = crc & 0xff;
  16380. }
  16381. function adler32(data, start, end) {
  16382. var a = 1;
  16383. var b = 0;
  16384. for (var i = start; i < end; ++i) {
  16385. a = (a + (data[i] & 0xff)) % 65521;
  16386. b = (b + a) % 65521;
  16387. }
  16388. return b << 16 | a;
  16389. }
  16390. function deflateSync(literals) {
  16391. if (!(0, _is_node.default)()) {
  16392. return deflateSyncUncompressed(literals);
  16393. }
  16394. try {
  16395. var input;
  16396. if (parseInt(process.versions.node) >= 8) {
  16397. input = literals;
  16398. } else {
  16399. input = new Buffer(literals);
  16400. }
  16401. var output = require('zlib').deflateSync(input, {
  16402. level: 9
  16403. });
  16404. return output instanceof Uint8Array ? output : new Uint8Array(output);
  16405. } catch (e) {
  16406. (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
  16407. }
  16408. return deflateSyncUncompressed(literals);
  16409. }
  16410. function deflateSyncUncompressed(literals) {
  16411. var len = literals.length;
  16412. var maxBlockLength = 0xFFFF;
  16413. var deflateBlocks = Math.ceil(len / maxBlockLength);
  16414. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  16415. var pi = 0;
  16416. idat[pi++] = 0x78;
  16417. idat[pi++] = 0x9c;
  16418. var pos = 0;
  16419. while (len > maxBlockLength) {
  16420. idat[pi++] = 0x00;
  16421. idat[pi++] = 0xff;
  16422. idat[pi++] = 0xff;
  16423. idat[pi++] = 0x00;
  16424. idat[pi++] = 0x00;
  16425. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  16426. pi += maxBlockLength;
  16427. pos += maxBlockLength;
  16428. len -= maxBlockLength;
  16429. }
  16430. idat[pi++] = 0x01;
  16431. idat[pi++] = len & 0xff;
  16432. idat[pi++] = len >> 8 & 0xff;
  16433. idat[pi++] = ~len & 0xffff & 0xff;
  16434. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  16435. idat.set(literals.subarray(pos), pi);
  16436. pi += literals.length - pos;
  16437. var adler = adler32(literals, 0, literals.length);
  16438. idat[pi++] = adler >> 24 & 0xff;
  16439. idat[pi++] = adler >> 16 & 0xff;
  16440. idat[pi++] = adler >> 8 & 0xff;
  16441. idat[pi++] = adler & 0xff;
  16442. return idat;
  16443. }
  16444. function encode(imgData, kind, forceDataSchema, isMask) {
  16445. var width = imgData.width;
  16446. var height = imgData.height;
  16447. var bitDepth, colorType, lineSize;
  16448. var bytes = imgData.data;
  16449. switch (kind) {
  16450. case _util.ImageKind.GRAYSCALE_1BPP:
  16451. colorType = 0;
  16452. bitDepth = 1;
  16453. lineSize = width + 7 >> 3;
  16454. break;
  16455. case _util.ImageKind.RGB_24BPP:
  16456. colorType = 2;
  16457. bitDepth = 8;
  16458. lineSize = width * 3;
  16459. break;
  16460. case _util.ImageKind.RGBA_32BPP:
  16461. colorType = 6;
  16462. bitDepth = 8;
  16463. lineSize = width * 4;
  16464. break;
  16465. default:
  16466. throw new Error('invalid format');
  16467. }
  16468. var literals = new Uint8Array((1 + lineSize) * height);
  16469. var offsetLiterals = 0,
  16470. offsetBytes = 0;
  16471. var y, i;
  16472. for (y = 0; y < height; ++y) {
  16473. literals[offsetLiterals++] = 0;
  16474. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  16475. offsetBytes += lineSize;
  16476. offsetLiterals += lineSize;
  16477. }
  16478. if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
  16479. offsetLiterals = 0;
  16480. for (y = 0; y < height; y++) {
  16481. offsetLiterals++;
  16482. for (i = 0; i < lineSize; i++) {
  16483. literals[offsetLiterals++] ^= 0xFF;
  16484. }
  16485. }
  16486. }
  16487. var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
  16488. var idat = deflateSync(literals);
  16489. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  16490. var data = new Uint8Array(pngLength);
  16491. var offset = 0;
  16492. data.set(PNG_HEADER, offset);
  16493. offset += PNG_HEADER.length;
  16494. writePngChunk('IHDR', ihdr, data, offset);
  16495. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  16496. writePngChunk('IDATA', idat, data, offset);
  16497. offset += CHUNK_WRAPPER_SIZE + idat.length;
  16498. writePngChunk('IEND', new Uint8Array(0), data, offset);
  16499. return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
  16500. }
  16501. return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
  16502. var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
  16503. return encode(imgData, kind, forceDataSchema, isMask);
  16504. };
  16505. }();
  16506. var SVGExtraState = function SVGExtraStateClosure() {
  16507. function SVGExtraState() {
  16508. this.fontSizeScale = 1;
  16509. this.fontWeight = SVG_DEFAULTS.fontWeight;
  16510. this.fontSize = 0;
  16511. this.textMatrix = _util.IDENTITY_MATRIX;
  16512. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  16513. this.leading = 0;
  16514. this.textRenderingMode = _util.TextRenderingMode.FILL;
  16515. this.x = 0;
  16516. this.y = 0;
  16517. this.lineX = 0;
  16518. this.lineY = 0;
  16519. this.charSpacing = 0;
  16520. this.wordSpacing = 0;
  16521. this.textHScale = 1;
  16522. this.textRise = 0;
  16523. this.fillColor = SVG_DEFAULTS.fillColor;
  16524. this.strokeColor = '#000000';
  16525. this.fillAlpha = 1;
  16526. this.strokeAlpha = 1;
  16527. this.lineWidth = 1;
  16528. this.lineJoin = '';
  16529. this.lineCap = '';
  16530. this.miterLimit = 0;
  16531. this.dashArray = [];
  16532. this.dashPhase = 0;
  16533. this.dependencies = [];
  16534. this.activeClipUrl = null;
  16535. this.clipGroup = null;
  16536. this.maskId = '';
  16537. }
  16538. SVGExtraState.prototype = {
  16539. clone: function SVGExtraState_clone() {
  16540. return Object.create(this);
  16541. },
  16542. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  16543. this.x = x;
  16544. this.y = y;
  16545. }
  16546. };
  16547. return SVGExtraState;
  16548. }();
  16549. exports.SVGGraphics = SVGGraphics = function SVGGraphicsClosure() {
  16550. function opListToTree(opList) {
  16551. var opTree = [];
  16552. var tmp = [];
  16553. var opListLen = opList.length;
  16554. for (var x = 0; x < opListLen; x++) {
  16555. if (opList[x].fn === 'save') {
  16556. opTree.push({
  16557. 'fnId': 92,
  16558. 'fn': 'group',
  16559. 'items': []
  16560. });
  16561. tmp.push(opTree);
  16562. opTree = opTree[opTree.length - 1].items;
  16563. continue;
  16564. }
  16565. if (opList[x].fn === 'restore') {
  16566. opTree = tmp.pop();
  16567. } else {
  16568. opTree.push(opList[x]);
  16569. }
  16570. }
  16571. return opTree;
  16572. }
  16573. function pf(value) {
  16574. if (Number.isInteger(value)) {
  16575. return value.toString();
  16576. }
  16577. var s = value.toFixed(10);
  16578. var i = s.length - 1;
  16579. if (s[i] !== '0') {
  16580. return s;
  16581. }
  16582. do {
  16583. i--;
  16584. } while (s[i] === '0');
  16585. return s.substring(0, s[i] === '.' ? i : i + 1);
  16586. }
  16587. function pm(m) {
  16588. if (m[4] === 0 && m[5] === 0) {
  16589. if (m[1] === 0 && m[2] === 0) {
  16590. if (m[0] === 1 && m[3] === 1) {
  16591. return '';
  16592. }
  16593. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  16594. }
  16595. if (m[0] === m[3] && m[1] === -m[2]) {
  16596. var a = Math.acos(m[0]) * 180 / Math.PI;
  16597. return 'rotate(' + pf(a) + ')';
  16598. }
  16599. } else {
  16600. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  16601. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  16602. }
  16603. }
  16604. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  16605. }
  16606. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  16607. this.svgFactory = new _dom_utils.DOMSVGFactory();
  16608. this.current = new SVGExtraState();
  16609. this.transformMatrix = _util.IDENTITY_MATRIX;
  16610. this.transformStack = [];
  16611. this.extraStack = [];
  16612. this.commonObjs = commonObjs;
  16613. this.objs = objs;
  16614. this.pendingClip = null;
  16615. this.pendingEOFill = false;
  16616. this.embedFonts = false;
  16617. this.embeddedFonts = Object.create(null);
  16618. this.cssStyle = null;
  16619. this.forceDataSchema = !!forceDataSchema;
  16620. }
  16621. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  16622. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  16623. var LINE_CAP_STYLES = ['butt', 'round', 'square'];
  16624. var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
  16625. var clipCount = 0;
  16626. var maskCount = 0;
  16627. SVGGraphics.prototype = {
  16628. save: function SVGGraphics_save() {
  16629. this.transformStack.push(this.transformMatrix);
  16630. var old = this.current;
  16631. this.extraStack.push(old);
  16632. this.current = old.clone();
  16633. },
  16634. restore: function SVGGraphics_restore() {
  16635. this.transformMatrix = this.transformStack.pop();
  16636. this.current = this.extraStack.pop();
  16637. this.pendingClip = null;
  16638. this.tgrp = null;
  16639. },
  16640. group: function SVGGraphics_group(items) {
  16641. this.save();
  16642. this.executeOpTree(items);
  16643. this.restore();
  16644. },
  16645. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  16646. var _this = this;
  16647. var fnArray = operatorList.fnArray;
  16648. var fnArrayLen = fnArray.length;
  16649. var argsArray = operatorList.argsArray;
  16650. for (var i = 0; i < fnArrayLen; i++) {
  16651. if (_util.OPS.dependency === fnArray[i]) {
  16652. var deps = argsArray[i];
  16653. for (var n = 0, nn = deps.length; n < nn; n++) {
  16654. var obj = deps[n];
  16655. var common = obj.substring(0, 2) === 'g_';
  16656. var promise;
  16657. if (common) {
  16658. promise = new Promise(function (resolve) {
  16659. _this.commonObjs.get(obj, resolve);
  16660. });
  16661. } else {
  16662. promise = new Promise(function (resolve) {
  16663. _this.objs.get(obj, resolve);
  16664. });
  16665. }
  16666. this.current.dependencies.push(promise);
  16667. }
  16668. }
  16669. }
  16670. return Promise.all(this.current.dependencies);
  16671. },
  16672. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  16673. var transformMatrix = [a, b, c, d, e, f];
  16674. this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
  16675. this.tgrp = null;
  16676. },
  16677. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  16678. var _this2 = this;
  16679. this.viewport = viewport;
  16680. var svgElement = this._initialize(viewport);
  16681. return this.loadDependencies(operatorList).then(function () {
  16682. _this2.transformMatrix = _util.IDENTITY_MATRIX;
  16683. var opTree = _this2.convertOpList(operatorList);
  16684. _this2.executeOpTree(opTree);
  16685. return svgElement;
  16686. });
  16687. },
  16688. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  16689. var argsArray = operatorList.argsArray;
  16690. var fnArray = operatorList.fnArray;
  16691. var fnArrayLen = fnArray.length;
  16692. var REVOPS = [];
  16693. var opList = [];
  16694. for (var op in _util.OPS) {
  16695. REVOPS[_util.OPS[op]] = op;
  16696. }
  16697. for (var x = 0; x < fnArrayLen; x++) {
  16698. var fnId = fnArray[x];
  16699. opList.push({
  16700. 'fnId': fnId,
  16701. 'fn': REVOPS[fnId],
  16702. 'args': argsArray[x]
  16703. });
  16704. }
  16705. return opListToTree(opList);
  16706. },
  16707. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  16708. var opTreeLen = opTree.length;
  16709. for (var x = 0; x < opTreeLen; x++) {
  16710. var fn = opTree[x].fn;
  16711. var fnId = opTree[x].fnId;
  16712. var args = opTree[x].args;
  16713. switch (fnId | 0) {
  16714. case _util.OPS.beginText:
  16715. this.beginText();
  16716. break;
  16717. case _util.OPS.dependency:
  16718. break;
  16719. case _util.OPS.setLeading:
  16720. this.setLeading(args);
  16721. break;
  16722. case _util.OPS.setLeadingMoveText:
  16723. this.setLeadingMoveText(args[0], args[1]);
  16724. break;
  16725. case _util.OPS.setFont:
  16726. this.setFont(args);
  16727. break;
  16728. case _util.OPS.showText:
  16729. this.showText(args[0]);
  16730. break;
  16731. case _util.OPS.showSpacedText:
  16732. this.showText(args[0]);
  16733. break;
  16734. case _util.OPS.endText:
  16735. this.endText();
  16736. break;
  16737. case _util.OPS.moveText:
  16738. this.moveText(args[0], args[1]);
  16739. break;
  16740. case _util.OPS.setCharSpacing:
  16741. this.setCharSpacing(args[0]);
  16742. break;
  16743. case _util.OPS.setWordSpacing:
  16744. this.setWordSpacing(args[0]);
  16745. break;
  16746. case _util.OPS.setHScale:
  16747. this.setHScale(args[0]);
  16748. break;
  16749. case _util.OPS.setTextMatrix:
  16750. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  16751. break;
  16752. case _util.OPS.setTextRise:
  16753. this.setTextRise(args[0]);
  16754. break;
  16755. case _util.OPS.setTextRenderingMode:
  16756. this.setTextRenderingMode(args[0]);
  16757. break;
  16758. case _util.OPS.setLineWidth:
  16759. this.setLineWidth(args[0]);
  16760. break;
  16761. case _util.OPS.setLineJoin:
  16762. this.setLineJoin(args[0]);
  16763. break;
  16764. case _util.OPS.setLineCap:
  16765. this.setLineCap(args[0]);
  16766. break;
  16767. case _util.OPS.setMiterLimit:
  16768. this.setMiterLimit(args[0]);
  16769. break;
  16770. case _util.OPS.setFillRGBColor:
  16771. this.setFillRGBColor(args[0], args[1], args[2]);
  16772. break;
  16773. case _util.OPS.setStrokeRGBColor:
  16774. this.setStrokeRGBColor(args[0], args[1], args[2]);
  16775. break;
  16776. case _util.OPS.setDash:
  16777. this.setDash(args[0], args[1]);
  16778. break;
  16779. case _util.OPS.setGState:
  16780. this.setGState(args[0]);
  16781. break;
  16782. case _util.OPS.fill:
  16783. this.fill();
  16784. break;
  16785. case _util.OPS.eoFill:
  16786. this.eoFill();
  16787. break;
  16788. case _util.OPS.stroke:
  16789. this.stroke();
  16790. break;
  16791. case _util.OPS.fillStroke:
  16792. this.fillStroke();
  16793. break;
  16794. case _util.OPS.eoFillStroke:
  16795. this.eoFillStroke();
  16796. break;
  16797. case _util.OPS.clip:
  16798. this.clip('nonzero');
  16799. break;
  16800. case _util.OPS.eoClip:
  16801. this.clip('evenodd');
  16802. break;
  16803. case _util.OPS.paintSolidColorImageMask:
  16804. this.paintSolidColorImageMask();
  16805. break;
  16806. case _util.OPS.paintJpegXObject:
  16807. this.paintJpegXObject(args[0], args[1], args[2]);
  16808. break;
  16809. case _util.OPS.paintImageXObject:
  16810. this.paintImageXObject(args[0]);
  16811. break;
  16812. case _util.OPS.paintInlineImageXObject:
  16813. this.paintInlineImageXObject(args[0]);
  16814. break;
  16815. case _util.OPS.paintImageMaskXObject:
  16816. this.paintImageMaskXObject(args[0]);
  16817. break;
  16818. case _util.OPS.paintFormXObjectBegin:
  16819. this.paintFormXObjectBegin(args[0], args[1]);
  16820. break;
  16821. case _util.OPS.paintFormXObjectEnd:
  16822. this.paintFormXObjectEnd();
  16823. break;
  16824. case _util.OPS.closePath:
  16825. this.closePath();
  16826. break;
  16827. case _util.OPS.closeStroke:
  16828. this.closeStroke();
  16829. break;
  16830. case _util.OPS.closeFillStroke:
  16831. this.closeFillStroke();
  16832. break;
  16833. case _util.OPS.closeEOFillStroke:
  16834. this.closeEOFillStroke();
  16835. break;
  16836. case _util.OPS.nextLine:
  16837. this.nextLine();
  16838. break;
  16839. case _util.OPS.transform:
  16840. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  16841. break;
  16842. case _util.OPS.constructPath:
  16843. this.constructPath(args[0], args[1]);
  16844. break;
  16845. case _util.OPS.endPath:
  16846. this.endPath();
  16847. break;
  16848. case 92:
  16849. this.group(opTree[x].items);
  16850. break;
  16851. default:
  16852. (0, _util.warn)('Unimplemented operator ' + fn);
  16853. break;
  16854. }
  16855. }
  16856. },
  16857. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  16858. this.current.wordSpacing = wordSpacing;
  16859. },
  16860. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  16861. this.current.charSpacing = charSpacing;
  16862. },
  16863. nextLine: function SVGGraphics_nextLine() {
  16864. this.moveText(0, this.current.leading);
  16865. },
  16866. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  16867. var current = this.current;
  16868. this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
  16869. this.current.x = this.current.lineX = 0;
  16870. this.current.y = this.current.lineY = 0;
  16871. current.xcoords = [];
  16872. current.tspan = this.svgFactory.createElement('svg:tspan');
  16873. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  16874. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  16875. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16876. current.txtElement = this.svgFactory.createElement('svg:text');
  16877. current.txtElement.appendChild(current.tspan);
  16878. },
  16879. beginText: function SVGGraphics_beginText() {
  16880. this.current.x = this.current.lineX = 0;
  16881. this.current.y = this.current.lineY = 0;
  16882. this.current.textMatrix = _util.IDENTITY_MATRIX;
  16883. this.current.lineMatrix = _util.IDENTITY_MATRIX;
  16884. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  16885. this.current.txtElement = this.svgFactory.createElement('svg:text');
  16886. this.current.txtgrp = this.svgFactory.createElement('svg:g');
  16887. this.current.xcoords = [];
  16888. },
  16889. moveText: function SVGGraphics_moveText(x, y) {
  16890. var current = this.current;
  16891. this.current.x = this.current.lineX += x;
  16892. this.current.y = this.current.lineY += y;
  16893. current.xcoords = [];
  16894. current.tspan = this.svgFactory.createElement('svg:tspan');
  16895. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  16896. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  16897. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16898. },
  16899. showText: function SVGGraphics_showText(glyphs) {
  16900. var current = this.current;
  16901. var font = current.font;
  16902. var fontSize = current.fontSize;
  16903. if (fontSize === 0) {
  16904. return;
  16905. }
  16906. var charSpacing = current.charSpacing;
  16907. var wordSpacing = current.wordSpacing;
  16908. var fontDirection = current.fontDirection;
  16909. var textHScale = current.textHScale * fontDirection;
  16910. var glyphsLength = glyphs.length;
  16911. var vertical = font.vertical;
  16912. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  16913. var x = 0,
  16914. i;
  16915. for (i = 0; i < glyphsLength; ++i) {
  16916. var glyph = glyphs[i];
  16917. if (glyph === null) {
  16918. x += fontDirection * wordSpacing;
  16919. continue;
  16920. } else if ((0, _util.isNum)(glyph)) {
  16921. x += -glyph * fontSize * 0.001;
  16922. continue;
  16923. }
  16924. var width = glyph.width;
  16925. var character = glyph.fontChar;
  16926. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  16927. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  16928. if (!glyph.isInFont && !font.missingFile) {
  16929. x += charWidth;
  16930. continue;
  16931. }
  16932. current.xcoords.push(current.x + x * textHScale);
  16933. current.tspan.textContent += character;
  16934. x += charWidth;
  16935. }
  16936. if (vertical) {
  16937. current.y -= x * textHScale;
  16938. } else {
  16939. current.x += x * textHScale;
  16940. }
  16941. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  16942. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  16943. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  16944. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  16945. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  16946. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  16947. }
  16948. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  16949. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  16950. }
  16951. var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
  16952. if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  16953. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  16954. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  16955. }
  16956. if (current.fillAlpha < 1) {
  16957. current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  16958. }
  16959. } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
  16960. current.tspan.setAttributeNS(null, 'fill', 'transparent');
  16961. } else {
  16962. current.tspan.setAttributeNS(null, 'fill', 'none');
  16963. }
  16964. if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
  16965. this._setStrokeAttributes(current.tspan);
  16966. }
  16967. var textMatrix = current.textMatrix;
  16968. if (current.textRise !== 0) {
  16969. textMatrix = textMatrix.slice();
  16970. textMatrix[5] += current.textRise;
  16971. }
  16972. current.txtElement.setAttributeNS(null, 'transform', pm(textMatrix) + ' scale(1, -1)');
  16973. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  16974. current.txtElement.appendChild(current.tspan);
  16975. current.txtgrp.appendChild(current.txtElement);
  16976. this._ensureTransformGroup().appendChild(current.txtElement);
  16977. },
  16978. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  16979. this.setLeading(-y);
  16980. this.moveText(x, y);
  16981. },
  16982. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  16983. if (!this.cssStyle) {
  16984. this.cssStyle = this.svgFactory.createElement('svg:style');
  16985. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  16986. this.defs.appendChild(this.cssStyle);
  16987. }
  16988. var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  16989. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  16990. },
  16991. setFont: function SVGGraphics_setFont(details) {
  16992. var current = this.current;
  16993. var fontObj = this.commonObjs.get(details[0]);
  16994. var size = details[1];
  16995. this.current.font = fontObj;
  16996. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  16997. this.addFontStyle(fontObj);
  16998. this.embeddedFonts[fontObj.loadedName] = fontObj;
  16999. }
  17000. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
  17001. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  17002. var italic = fontObj.italic ? 'italic' : 'normal';
  17003. if (size < 0) {
  17004. size = -size;
  17005. current.fontDirection = -1;
  17006. } else {
  17007. current.fontDirection = 1;
  17008. }
  17009. current.fontSize = size;
  17010. current.fontFamily = fontObj.loadedName;
  17011. current.fontWeight = bold;
  17012. current.fontStyle = italic;
  17013. current.tspan = this.svgFactory.createElement('svg:tspan');
  17014. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  17015. current.xcoords = [];
  17016. },
  17017. endText: function endText() {
  17018. var current = this.current;
  17019. if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
  17020. current.element = current.txtElement;
  17021. this.clip('nonzero');
  17022. this.endPath();
  17023. }
  17024. },
  17025. setLineWidth: function SVGGraphics_setLineWidth(width) {
  17026. if (width > 0) {
  17027. this.current.lineWidth = width;
  17028. }
  17029. },
  17030. setLineCap: function SVGGraphics_setLineCap(style) {
  17031. this.current.lineCap = LINE_CAP_STYLES[style];
  17032. },
  17033. setLineJoin: function SVGGraphics_setLineJoin(style) {
  17034. this.current.lineJoin = LINE_JOIN_STYLES[style];
  17035. },
  17036. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  17037. this.current.miterLimit = limit;
  17038. },
  17039. setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
  17040. this.current.strokeAlpha = strokeAlpha;
  17041. },
  17042. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  17043. var color = _util.Util.makeCssRgb(r, g, b);
  17044. this.current.strokeColor = color;
  17045. },
  17046. setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) {
  17047. this.current.fillAlpha = fillAlpha;
  17048. },
  17049. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  17050. var color = _util.Util.makeCssRgb(r, g, b);
  17051. this.current.fillColor = color;
  17052. this.current.tspan = this.svgFactory.createElement('svg:tspan');
  17053. this.current.xcoords = [];
  17054. },
  17055. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  17056. this.current.dashArray = dashArray;
  17057. this.current.dashPhase = dashPhase;
  17058. },
  17059. constructPath: function SVGGraphics_constructPath(ops, args) {
  17060. var current = this.current;
  17061. var x = current.x,
  17062. y = current.y;
  17063. current.path = this.svgFactory.createElement('svg:path');
  17064. var d = [];
  17065. var opLength = ops.length;
  17066. for (var i = 0, j = 0; i < opLength; i++) {
  17067. switch (ops[i] | 0) {
  17068. case _util.OPS.rectangle:
  17069. x = args[j++];
  17070. y = args[j++];
  17071. var width = args[j++];
  17072. var height = args[j++];
  17073. var xw = x + width;
  17074. var yh = y + height;
  17075. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  17076. break;
  17077. case _util.OPS.moveTo:
  17078. x = args[j++];
  17079. y = args[j++];
  17080. d.push('M', pf(x), pf(y));
  17081. break;
  17082. case _util.OPS.lineTo:
  17083. x = args[j++];
  17084. y = args[j++];
  17085. d.push('L', pf(x), pf(y));
  17086. break;
  17087. case _util.OPS.curveTo:
  17088. x = args[j + 4];
  17089. y = args[j + 5];
  17090. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  17091. j += 6;
  17092. break;
  17093. case _util.OPS.curveTo2:
  17094. x = args[j + 2];
  17095. y = args[j + 3];
  17096. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  17097. j += 4;
  17098. break;
  17099. case _util.OPS.curveTo3:
  17100. x = args[j + 2];
  17101. y = args[j + 3];
  17102. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  17103. j += 4;
  17104. break;
  17105. case _util.OPS.closePath:
  17106. d.push('Z');
  17107. break;
  17108. }
  17109. }
  17110. current.path.setAttributeNS(null, 'd', d.join(' '));
  17111. current.path.setAttributeNS(null, 'fill', 'none');
  17112. this._ensureTransformGroup().appendChild(current.path);
  17113. current.element = current.path;
  17114. current.setCurrentPoint(x, y);
  17115. },
  17116. endPath: function SVGGraphics_endPath() {
  17117. if (!this.pendingClip) {
  17118. return;
  17119. }
  17120. var current = this.current;
  17121. var clipId = 'clippath' + clipCount;
  17122. clipCount++;
  17123. var clipPath = this.svgFactory.createElement('svg:clipPath');
  17124. clipPath.setAttributeNS(null, 'id', clipId);
  17125. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  17126. var clipElement = current.element.cloneNode(true);
  17127. if (this.pendingClip === 'evenodd') {
  17128. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  17129. } else {
  17130. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  17131. }
  17132. this.pendingClip = null;
  17133. clipPath.appendChild(clipElement);
  17134. this.defs.appendChild(clipPath);
  17135. if (current.activeClipUrl) {
  17136. current.clipGroup = null;
  17137. this.extraStack.forEach(function (prev) {
  17138. prev.clipGroup = null;
  17139. });
  17140. clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl);
  17141. }
  17142. current.activeClipUrl = 'url(#' + clipId + ')';
  17143. this.tgrp = null;
  17144. },
  17145. clip: function SVGGraphics_clip(type) {
  17146. this.pendingClip = type;
  17147. },
  17148. closePath: function SVGGraphics_closePath() {
  17149. var current = this.current;
  17150. if (current.path) {
  17151. var d = current.path.getAttributeNS(null, 'd');
  17152. d += 'Z';
  17153. current.path.setAttributeNS(null, 'd', d);
  17154. }
  17155. },
  17156. setLeading: function SVGGraphics_setLeading(leading) {
  17157. this.current.leading = -leading;
  17158. },
  17159. setTextRise: function SVGGraphics_setTextRise(textRise) {
  17160. this.current.textRise = textRise;
  17161. },
  17162. setTextRenderingMode: function setTextRenderingMode(textRenderingMode) {
  17163. this.current.textRenderingMode = textRenderingMode;
  17164. },
  17165. setHScale: function SVGGraphics_setHScale(scale) {
  17166. this.current.textHScale = scale / 100;
  17167. },
  17168. setGState: function SVGGraphics_setGState(states) {
  17169. for (var i = 0, ii = states.length; i < ii; i++) {
  17170. var state = states[i];
  17171. var key = state[0];
  17172. var value = state[1];
  17173. switch (key) {
  17174. case 'LW':
  17175. this.setLineWidth(value);
  17176. break;
  17177. case 'LC':
  17178. this.setLineCap(value);
  17179. break;
  17180. case 'LJ':
  17181. this.setLineJoin(value);
  17182. break;
  17183. case 'ML':
  17184. this.setMiterLimit(value);
  17185. break;
  17186. case 'D':
  17187. this.setDash(value[0], value[1]);
  17188. break;
  17189. case 'Font':
  17190. this.setFont(value);
  17191. break;
  17192. case 'CA':
  17193. this.setStrokeAlpha(value);
  17194. break;
  17195. case 'ca':
  17196. this.setFillAlpha(value);
  17197. break;
  17198. default:
  17199. (0, _util.warn)('Unimplemented graphic state ' + key);
  17200. break;
  17201. }
  17202. }
  17203. },
  17204. fill: function SVGGraphics_fill() {
  17205. var current = this.current;
  17206. if (current.element) {
  17207. current.element.setAttributeNS(null, 'fill', current.fillColor);
  17208. current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
  17209. this.endPath();
  17210. }
  17211. },
  17212. stroke: function SVGGraphics_stroke() {
  17213. var current = this.current;
  17214. if (current.element) {
  17215. this._setStrokeAttributes(current.element);
  17216. current.element.setAttributeNS(null, 'fill', 'none');
  17217. this.endPath();
  17218. }
  17219. },
  17220. _setStrokeAttributes: function _setStrokeAttributes(element) {
  17221. var current = this.current;
  17222. element.setAttributeNS(null, 'stroke', current.strokeColor);
  17223. element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
  17224. element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  17225. element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  17226. element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  17227. element.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  17228. element.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  17229. element.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  17230. },
  17231. eoFill: function SVGGraphics_eoFill() {
  17232. if (this.current.element) {
  17233. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  17234. }
  17235. this.fill();
  17236. },
  17237. fillStroke: function SVGGraphics_fillStroke() {
  17238. this.stroke();
  17239. this.fill();
  17240. },
  17241. eoFillStroke: function SVGGraphics_eoFillStroke() {
  17242. if (this.current.element) {
  17243. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  17244. }
  17245. this.fillStroke();
  17246. },
  17247. closeStroke: function SVGGraphics_closeStroke() {
  17248. this.closePath();
  17249. this.stroke();
  17250. },
  17251. closeFillStroke: function SVGGraphics_closeFillStroke() {
  17252. this.closePath();
  17253. this.fillStroke();
  17254. },
  17255. closeEOFillStroke: function closeEOFillStroke() {
  17256. this.closePath();
  17257. this.eoFillStroke();
  17258. },
  17259. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  17260. var current = this.current;
  17261. var rect = this.svgFactory.createElement('svg:rect');
  17262. rect.setAttributeNS(null, 'x', '0');
  17263. rect.setAttributeNS(null, 'y', '0');
  17264. rect.setAttributeNS(null, 'width', '1px');
  17265. rect.setAttributeNS(null, 'height', '1px');
  17266. rect.setAttributeNS(null, 'fill', current.fillColor);
  17267. this._ensureTransformGroup().appendChild(rect);
  17268. },
  17269. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  17270. var imgObj = this.objs.get(objId);
  17271. var imgEl = this.svgFactory.createElement('svg:image');
  17272. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  17273. imgEl.setAttributeNS(null, 'width', pf(w));
  17274. imgEl.setAttributeNS(null, 'height', pf(h));
  17275. imgEl.setAttributeNS(null, 'x', '0');
  17276. imgEl.setAttributeNS(null, 'y', pf(-h));
  17277. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  17278. this._ensureTransformGroup().appendChild(imgEl);
  17279. },
  17280. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  17281. var imgData = this.objs.get(objId);
  17282. if (!imgData) {
  17283. (0, _util.warn)('Dependent image isn\'t ready yet');
  17284. return;
  17285. }
  17286. this.paintInlineImageXObject(imgData);
  17287. },
  17288. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  17289. var width = imgData.width;
  17290. var height = imgData.height;
  17291. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
  17292. var cliprect = this.svgFactory.createElement('svg:rect');
  17293. cliprect.setAttributeNS(null, 'x', '0');
  17294. cliprect.setAttributeNS(null, 'y', '0');
  17295. cliprect.setAttributeNS(null, 'width', pf(width));
  17296. cliprect.setAttributeNS(null, 'height', pf(height));
  17297. this.current.element = cliprect;
  17298. this.clip('nonzero');
  17299. var imgEl = this.svgFactory.createElement('svg:image');
  17300. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  17301. imgEl.setAttributeNS(null, 'x', '0');
  17302. imgEl.setAttributeNS(null, 'y', pf(-height));
  17303. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  17304. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  17305. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  17306. if (mask) {
  17307. mask.appendChild(imgEl);
  17308. } else {
  17309. this._ensureTransformGroup().appendChild(imgEl);
  17310. }
  17311. },
  17312. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  17313. var current = this.current;
  17314. var width = imgData.width;
  17315. var height = imgData.height;
  17316. var fillColor = current.fillColor;
  17317. current.maskId = 'mask' + maskCount++;
  17318. var mask = this.svgFactory.createElement('svg:mask');
  17319. mask.setAttributeNS(null, 'id', current.maskId);
  17320. var rect = this.svgFactory.createElement('svg:rect');
  17321. rect.setAttributeNS(null, 'x', '0');
  17322. rect.setAttributeNS(null, 'y', '0');
  17323. rect.setAttributeNS(null, 'width', pf(width));
  17324. rect.setAttributeNS(null, 'height', pf(height));
  17325. rect.setAttributeNS(null, 'fill', fillColor);
  17326. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  17327. this.defs.appendChild(mask);
  17328. this._ensureTransformGroup().appendChild(rect);
  17329. this.paintInlineImageXObject(imgData, mask);
  17330. },
  17331. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  17332. if (Array.isArray(matrix) && matrix.length === 6) {
  17333. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  17334. }
  17335. if (bbox) {
  17336. var width = bbox[2] - bbox[0];
  17337. var height = bbox[3] - bbox[1];
  17338. var cliprect = this.svgFactory.createElement('svg:rect');
  17339. cliprect.setAttributeNS(null, 'x', bbox[0]);
  17340. cliprect.setAttributeNS(null, 'y', bbox[1]);
  17341. cliprect.setAttributeNS(null, 'width', pf(width));
  17342. cliprect.setAttributeNS(null, 'height', pf(height));
  17343. this.current.element = cliprect;
  17344. this.clip('nonzero');
  17345. this.endPath();
  17346. }
  17347. },
  17348. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {},
  17349. _initialize: function _initialize(viewport) {
  17350. var svg = this.svgFactory.create(viewport.width, viewport.height);
  17351. var definitions = this.svgFactory.createElement('svg:defs');
  17352. svg.appendChild(definitions);
  17353. this.defs = definitions;
  17354. var rootGroup = this.svgFactory.createElement('svg:g');
  17355. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  17356. svg.appendChild(rootGroup);
  17357. this.svg = rootGroup;
  17358. return svg;
  17359. },
  17360. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  17361. if (!this.current.clipGroup) {
  17362. var clipGroup = this.svgFactory.createElement('svg:g');
  17363. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  17364. this.svg.appendChild(clipGroup);
  17365. this.current.clipGroup = clipGroup;
  17366. }
  17367. return this.current.clipGroup;
  17368. },
  17369. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  17370. if (!this.tgrp) {
  17371. this.tgrp = this.svgFactory.createElement('svg:g');
  17372. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  17373. if (this.current.activeClipUrl) {
  17374. this._ensureClipGroup().appendChild(this.tgrp);
  17375. } else {
  17376. this.svg.appendChild(this.tgrp);
  17377. }
  17378. }
  17379. return this.tgrp;
  17380. }
  17381. };
  17382. return SVGGraphics;
  17383. }();
  17384. }
  17385. /***/ }),
  17386. /* 165 */
  17387. /***/ (function(module, exports, __w_pdfjs_require__) {
  17388. "use strict";
  17389. Object.defineProperty(exports, "__esModule", {
  17390. value: true
  17391. });
  17392. exports.PDFNodeStream = void 0;
  17393. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  17394. var _util = __w_pdfjs_require__(1);
  17395. var _network_utils = __w_pdfjs_require__(166);
  17396. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17397. function _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); }
  17398. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17399. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17400. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17401. function _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); }
  17402. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17403. 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); } }
  17404. 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); }); }; }
  17405. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17406. 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); } }
  17407. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17408. var fs = require('fs');
  17409. var http = require('http');
  17410. var https = require('https');
  17411. var url = require('url');
  17412. var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
  17413. function parseUrl(sourceUrl) {
  17414. var parsedUrl = url.parse(sourceUrl);
  17415. if (parsedUrl.protocol === 'file:' || parsedUrl.host) {
  17416. return parsedUrl;
  17417. }
  17418. if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
  17419. return url.parse("file:///".concat(sourceUrl));
  17420. }
  17421. if (!parsedUrl.host) {
  17422. parsedUrl.protocol = 'file:';
  17423. }
  17424. return parsedUrl;
  17425. }
  17426. var PDFNodeStream =
  17427. /*#__PURE__*/
  17428. function () {
  17429. function PDFNodeStream(source) {
  17430. _classCallCheck(this, PDFNodeStream);
  17431. this.source = source;
  17432. this.url = parseUrl(source.url);
  17433. this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:';
  17434. this.isFsUrl = this.url.protocol === 'file:';
  17435. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  17436. this._fullRequest = null;
  17437. this._rangeRequestReaders = [];
  17438. }
  17439. _createClass(PDFNodeStream, [{
  17440. key: "getFullReader",
  17441. value: function getFullReader() {
  17442. (0, _util.assert)(!this._fullRequest);
  17443. this._fullRequest = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
  17444. return this._fullRequest;
  17445. }
  17446. }, {
  17447. key: "getRangeReader",
  17448. value: function getRangeReader(start, end) {
  17449. var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
  17450. this._rangeRequestReaders.push(rangeReader);
  17451. return rangeReader;
  17452. }
  17453. }, {
  17454. key: "cancelAllRequests",
  17455. value: function cancelAllRequests(reason) {
  17456. if (this._fullRequest) {
  17457. this._fullRequest.cancel(reason);
  17458. }
  17459. var readers = this._rangeRequestReaders.slice(0);
  17460. readers.forEach(function (reader) {
  17461. reader.cancel(reason);
  17462. });
  17463. }
  17464. }]);
  17465. return PDFNodeStream;
  17466. }();
  17467. exports.PDFNodeStream = PDFNodeStream;
  17468. var BaseFullReader =
  17469. /*#__PURE__*/
  17470. function () {
  17471. function BaseFullReader(stream) {
  17472. _classCallCheck(this, BaseFullReader);
  17473. this._url = stream.url;
  17474. this._done = false;
  17475. this._storedError = null;
  17476. this.onProgress = null;
  17477. var source = stream.source;
  17478. this._contentLength = source.length;
  17479. this._loaded = 0;
  17480. this._filename = null;
  17481. this._disableRange = source.disableRange || false;
  17482. this._rangeChunkSize = source.rangeChunkSize;
  17483. if (!this._rangeChunkSize && !this._disableRange) {
  17484. this._disableRange = true;
  17485. }
  17486. this._isStreamingSupported = !source.disableStream;
  17487. this._isRangeSupported = !source.disableRange;
  17488. this._readableStream = null;
  17489. this._readCapability = (0, _util.createPromiseCapability)();
  17490. this._headersCapability = (0, _util.createPromiseCapability)();
  17491. }
  17492. _createClass(BaseFullReader, [{
  17493. key: "read",
  17494. value: function () {
  17495. var _read = _asyncToGenerator(
  17496. /*#__PURE__*/
  17497. _regenerator.default.mark(function _callee() {
  17498. var chunk, buffer;
  17499. return _regenerator.default.wrap(function _callee$(_context) {
  17500. while (1) {
  17501. switch (_context.prev = _context.next) {
  17502. case 0:
  17503. _context.next = 2;
  17504. return this._readCapability.promise;
  17505. case 2:
  17506. if (!this._done) {
  17507. _context.next = 4;
  17508. break;
  17509. }
  17510. return _context.abrupt("return", {
  17511. value: undefined,
  17512. done: true
  17513. });
  17514. case 4:
  17515. if (!this._storedError) {
  17516. _context.next = 6;
  17517. break;
  17518. }
  17519. throw this._storedError;
  17520. case 6:
  17521. chunk = this._readableStream.read();
  17522. if (!(chunk === null)) {
  17523. _context.next = 10;
  17524. break;
  17525. }
  17526. this._readCapability = (0, _util.createPromiseCapability)();
  17527. return _context.abrupt("return", this.read());
  17528. case 10:
  17529. this._loaded += chunk.length;
  17530. if (this.onProgress) {
  17531. this.onProgress({
  17532. loaded: this._loaded,
  17533. total: this._contentLength
  17534. });
  17535. }
  17536. buffer = new Uint8Array(chunk).buffer;
  17537. return _context.abrupt("return", {
  17538. value: buffer,
  17539. done: false
  17540. });
  17541. case 14:
  17542. case "end":
  17543. return _context.stop();
  17544. }
  17545. }
  17546. }, _callee, this);
  17547. }));
  17548. function read() {
  17549. return _read.apply(this, arguments);
  17550. }
  17551. return read;
  17552. }()
  17553. }, {
  17554. key: "cancel",
  17555. value: function cancel(reason) {
  17556. if (!this._readableStream) {
  17557. this._error(reason);
  17558. return;
  17559. }
  17560. this._readableStream.destroy(reason);
  17561. }
  17562. }, {
  17563. key: "_error",
  17564. value: function _error(reason) {
  17565. this._storedError = reason;
  17566. this._readCapability.resolve();
  17567. }
  17568. }, {
  17569. key: "_setReadableStream",
  17570. value: function _setReadableStream(readableStream) {
  17571. var _this = this;
  17572. this._readableStream = readableStream;
  17573. readableStream.on('readable', function () {
  17574. _this._readCapability.resolve();
  17575. });
  17576. readableStream.on('end', function () {
  17577. readableStream.destroy();
  17578. _this._done = true;
  17579. _this._readCapability.resolve();
  17580. });
  17581. readableStream.on('error', function (reason) {
  17582. _this._error(reason);
  17583. });
  17584. if (!this._isStreamingSupported && this._isRangeSupported) {
  17585. this._error(new _util.AbortException('streaming is disabled'));
  17586. }
  17587. if (this._storedError) {
  17588. this._readableStream.destroy(this._storedError);
  17589. }
  17590. }
  17591. }, {
  17592. key: "headersReady",
  17593. get: function get() {
  17594. return this._headersCapability.promise;
  17595. }
  17596. }, {
  17597. key: "filename",
  17598. get: function get() {
  17599. return this._filename;
  17600. }
  17601. }, {
  17602. key: "contentLength",
  17603. get: function get() {
  17604. return this._contentLength;
  17605. }
  17606. }, {
  17607. key: "isRangeSupported",
  17608. get: function get() {
  17609. return this._isRangeSupported;
  17610. }
  17611. }, {
  17612. key: "isStreamingSupported",
  17613. get: function get() {
  17614. return this._isStreamingSupported;
  17615. }
  17616. }]);
  17617. return BaseFullReader;
  17618. }();
  17619. var BaseRangeReader =
  17620. /*#__PURE__*/
  17621. function () {
  17622. function BaseRangeReader(stream) {
  17623. _classCallCheck(this, BaseRangeReader);
  17624. this._url = stream.url;
  17625. this._done = false;
  17626. this._storedError = null;
  17627. this.onProgress = null;
  17628. this._loaded = 0;
  17629. this._readableStream = null;
  17630. this._readCapability = (0, _util.createPromiseCapability)();
  17631. var source = stream.source;
  17632. this._isStreamingSupported = !source.disableStream;
  17633. }
  17634. _createClass(BaseRangeReader, [{
  17635. key: "read",
  17636. value: function () {
  17637. var _read2 = _asyncToGenerator(
  17638. /*#__PURE__*/
  17639. _regenerator.default.mark(function _callee2() {
  17640. var chunk, buffer;
  17641. return _regenerator.default.wrap(function _callee2$(_context2) {
  17642. while (1) {
  17643. switch (_context2.prev = _context2.next) {
  17644. case 0:
  17645. _context2.next = 2;
  17646. return this._readCapability.promise;
  17647. case 2:
  17648. if (!this._done) {
  17649. _context2.next = 4;
  17650. break;
  17651. }
  17652. return _context2.abrupt("return", {
  17653. value: undefined,
  17654. done: true
  17655. });
  17656. case 4:
  17657. if (!this._storedError) {
  17658. _context2.next = 6;
  17659. break;
  17660. }
  17661. throw this._storedError;
  17662. case 6:
  17663. chunk = this._readableStream.read();
  17664. if (!(chunk === null)) {
  17665. _context2.next = 10;
  17666. break;
  17667. }
  17668. this._readCapability = (0, _util.createPromiseCapability)();
  17669. return _context2.abrupt("return", this.read());
  17670. case 10:
  17671. this._loaded += chunk.length;
  17672. if (this.onProgress) {
  17673. this.onProgress({
  17674. loaded: this._loaded
  17675. });
  17676. }
  17677. buffer = new Uint8Array(chunk).buffer;
  17678. return _context2.abrupt("return", {
  17679. value: buffer,
  17680. done: false
  17681. });
  17682. case 14:
  17683. case "end":
  17684. return _context2.stop();
  17685. }
  17686. }
  17687. }, _callee2, this);
  17688. }));
  17689. function read() {
  17690. return _read2.apply(this, arguments);
  17691. }
  17692. return read;
  17693. }()
  17694. }, {
  17695. key: "cancel",
  17696. value: function cancel(reason) {
  17697. if (!this._readableStream) {
  17698. this._error(reason);
  17699. return;
  17700. }
  17701. this._readableStream.destroy(reason);
  17702. }
  17703. }, {
  17704. key: "_error",
  17705. value: function _error(reason) {
  17706. this._storedError = reason;
  17707. this._readCapability.resolve();
  17708. }
  17709. }, {
  17710. key: "_setReadableStream",
  17711. value: function _setReadableStream(readableStream) {
  17712. var _this2 = this;
  17713. this._readableStream = readableStream;
  17714. readableStream.on('readable', function () {
  17715. _this2._readCapability.resolve();
  17716. });
  17717. readableStream.on('end', function () {
  17718. readableStream.destroy();
  17719. _this2._done = true;
  17720. _this2._readCapability.resolve();
  17721. });
  17722. readableStream.on('error', function (reason) {
  17723. _this2._error(reason);
  17724. });
  17725. if (this._storedError) {
  17726. this._readableStream.destroy(this._storedError);
  17727. }
  17728. }
  17729. }, {
  17730. key: "isStreamingSupported",
  17731. get: function get() {
  17732. return this._isStreamingSupported;
  17733. }
  17734. }]);
  17735. return BaseRangeReader;
  17736. }();
  17737. function createRequestOptions(url, headers) {
  17738. return {
  17739. protocol: url.protocol,
  17740. auth: url.auth,
  17741. host: url.hostname,
  17742. port: url.port,
  17743. path: url.path,
  17744. method: 'GET',
  17745. headers: headers
  17746. };
  17747. }
  17748. var PDFNodeStreamFullReader =
  17749. /*#__PURE__*/
  17750. function (_BaseFullReader) {
  17751. _inherits(PDFNodeStreamFullReader, _BaseFullReader);
  17752. function PDFNodeStreamFullReader(stream) {
  17753. var _this3;
  17754. _classCallCheck(this, PDFNodeStreamFullReader);
  17755. _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFullReader).call(this, stream));
  17756. var handleResponse = function handleResponse(response) {
  17757. if (response.statusCode === 404) {
  17758. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this3._url, "\"."));
  17759. _this3._storedError = error;
  17760. _this3._headersCapability.reject(error);
  17761. return;
  17762. }
  17763. _this3._headersCapability.resolve();
  17764. _this3._setReadableStream(response);
  17765. var getResponseHeader = function getResponseHeader(name) {
  17766. return _this3._readableStream.headers[name.toLowerCase()];
  17767. };
  17768. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  17769. getResponseHeader: getResponseHeader,
  17770. isHttp: stream.isHttp,
  17771. rangeChunkSize: _this3._rangeChunkSize,
  17772. disableRange: _this3._disableRange
  17773. }),
  17774. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  17775. suggestedLength = _validateRangeRequest.suggestedLength;
  17776. _this3._isRangeSupported = allowRangeRequests;
  17777. _this3._contentLength = suggestedLength || _this3._contentLength;
  17778. _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  17779. };
  17780. _this3._request = null;
  17781. if (_this3._url.protocol === 'http:') {
  17782. _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  17783. } else {
  17784. _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
  17785. }
  17786. _this3._request.on('error', function (reason) {
  17787. _this3._storedError = reason;
  17788. _this3._headersCapability.reject(reason);
  17789. });
  17790. _this3._request.end();
  17791. return _this3;
  17792. }
  17793. return PDFNodeStreamFullReader;
  17794. }(BaseFullReader);
  17795. var PDFNodeStreamRangeReader =
  17796. /*#__PURE__*/
  17797. function (_BaseRangeReader) {
  17798. _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
  17799. function PDFNodeStreamRangeReader(stream, start, end) {
  17800. var _this4;
  17801. _classCallCheck(this, PDFNodeStreamRangeReader);
  17802. _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamRangeReader).call(this, stream));
  17803. _this4._httpHeaders = {};
  17804. for (var property in stream.httpHeaders) {
  17805. var value = stream.httpHeaders[property];
  17806. if (typeof value === 'undefined') {
  17807. continue;
  17808. }
  17809. _this4._httpHeaders[property] = value;
  17810. }
  17811. _this4._httpHeaders['Range'] = "bytes=".concat(start, "-").concat(end - 1);
  17812. var handleResponse = function handleResponse(response) {
  17813. if (response.statusCode === 404) {
  17814. var error = new _util.MissingPDFException("Missing PDF \"".concat(_this4._url, "\"."));
  17815. _this4._storedError = error;
  17816. return;
  17817. }
  17818. _this4._setReadableStream(response);
  17819. };
  17820. _this4._request = null;
  17821. if (_this4._url.protocol === 'http:') {
  17822. _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  17823. } else {
  17824. _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
  17825. }
  17826. _this4._request.on('error', function (reason) {
  17827. _this4._storedError = reason;
  17828. });
  17829. _this4._request.end();
  17830. return _this4;
  17831. }
  17832. return PDFNodeStreamRangeReader;
  17833. }(BaseRangeReader);
  17834. var PDFNodeStreamFsFullReader =
  17835. /*#__PURE__*/
  17836. function (_BaseFullReader2) {
  17837. _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
  17838. function PDFNodeStreamFsFullReader(stream) {
  17839. var _this5;
  17840. _classCallCheck(this, PDFNodeStreamFsFullReader);
  17841. _this5 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsFullReader).call(this, stream));
  17842. var path = decodeURIComponent(_this5._url.path);
  17843. if (fileUriRegex.test(_this5._url.href)) {
  17844. path = path.replace(/^\//, '');
  17845. }
  17846. fs.lstat(path, function (error, stat) {
  17847. if (error) {
  17848. if (error.code === 'ENOENT') {
  17849. error = new _util.MissingPDFException("Missing PDF \"".concat(path, "\"."));
  17850. }
  17851. _this5._storedError = error;
  17852. _this5._headersCapability.reject(error);
  17853. return;
  17854. }
  17855. _this5._contentLength = stat.size;
  17856. _this5._setReadableStream(fs.createReadStream(path));
  17857. _this5._headersCapability.resolve();
  17858. });
  17859. return _this5;
  17860. }
  17861. return PDFNodeStreamFsFullReader;
  17862. }(BaseFullReader);
  17863. var PDFNodeStreamFsRangeReader =
  17864. /*#__PURE__*/
  17865. function (_BaseRangeReader2) {
  17866. _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
  17867. function PDFNodeStreamFsRangeReader(stream, start, end) {
  17868. var _this6;
  17869. _classCallCheck(this, PDFNodeStreamFsRangeReader);
  17870. _this6 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsRangeReader).call(this, stream));
  17871. var path = decodeURIComponent(_this6._url.path);
  17872. if (fileUriRegex.test(_this6._url.href)) {
  17873. path = path.replace(/^\//, '');
  17874. }
  17875. _this6._setReadableStream(fs.createReadStream(path, {
  17876. start: start,
  17877. end: end - 1
  17878. }));
  17879. return _this6;
  17880. }
  17881. return PDFNodeStreamFsRangeReader;
  17882. }(BaseRangeReader);
  17883. /***/ }),
  17884. /* 166 */
  17885. /***/ (function(module, exports, __w_pdfjs_require__) {
  17886. "use strict";
  17887. Object.defineProperty(exports, "__esModule", {
  17888. value: true
  17889. });
  17890. exports.createResponseStatusError = createResponseStatusError;
  17891. exports.extractFilenameFromHeader = extractFilenameFromHeader;
  17892. exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
  17893. exports.validateResponseStatus = validateResponseStatus;
  17894. var _util = __w_pdfjs_require__(1);
  17895. var _content_disposition = __w_pdfjs_require__(167);
  17896. function validateRangeRequestCapabilities(_ref) {
  17897. var getResponseHeader = _ref.getResponseHeader,
  17898. isHttp = _ref.isHttp,
  17899. rangeChunkSize = _ref.rangeChunkSize,
  17900. disableRange = _ref.disableRange;
  17901. (0, _util.assert)(rangeChunkSize > 0, 'Range chunk size must be larger than zero');
  17902. var returnValues = {
  17903. allowRangeRequests: false,
  17904. suggestedLength: undefined
  17905. };
  17906. var length = parseInt(getResponseHeader('Content-Length'), 10);
  17907. if (!Number.isInteger(length)) {
  17908. return returnValues;
  17909. }
  17910. returnValues.suggestedLength = length;
  17911. if (length <= 2 * rangeChunkSize) {
  17912. return returnValues;
  17913. }
  17914. if (disableRange || !isHttp) {
  17915. return returnValues;
  17916. }
  17917. if (getResponseHeader('Accept-Ranges') !== 'bytes') {
  17918. return returnValues;
  17919. }
  17920. var contentEncoding = getResponseHeader('Content-Encoding') || 'identity';
  17921. if (contentEncoding !== 'identity') {
  17922. return returnValues;
  17923. }
  17924. returnValues.allowRangeRequests = true;
  17925. return returnValues;
  17926. }
  17927. function extractFilenameFromHeader(getResponseHeader) {
  17928. var contentDisposition = getResponseHeader('Content-Disposition');
  17929. if (contentDisposition) {
  17930. var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition);
  17931. if (/\.pdf$/i.test(filename)) {
  17932. return filename;
  17933. }
  17934. }
  17935. return null;
  17936. }
  17937. function createResponseStatusError(status, url) {
  17938. if (status === 404 || status === 0 && /^file:/.test(url)) {
  17939. return new _util.MissingPDFException('Missing PDF "' + url + '".');
  17940. }
  17941. return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  17942. }
  17943. function validateResponseStatus(status) {
  17944. return status === 200 || status === 206;
  17945. }
  17946. /***/ }),
  17947. /* 167 */
  17948. /***/ (function(module, exports, __w_pdfjs_require__) {
  17949. "use strict";
  17950. Object.defineProperty(exports, "__esModule", {
  17951. value: true
  17952. });
  17953. exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader;
  17954. function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
  17955. function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
  17956. function _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; }
  17957. function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  17958. function getFilenameFromContentDispositionHeader(contentDisposition) {
  17959. var needsEncodingFixup = true;
  17960. var tmp = toParamRegExp('filename\\*', 'i').exec(contentDisposition);
  17961. if (tmp) {
  17962. tmp = tmp[1];
  17963. var filename = rfc2616unquote(tmp);
  17964. filename = unescape(filename);
  17965. filename = rfc5987decode(filename);
  17966. filename = rfc2047decode(filename);
  17967. return fixupEncoding(filename);
  17968. }
  17969. tmp = rfc2231getparam(contentDisposition);
  17970. if (tmp) {
  17971. var _filename = rfc2047decode(tmp);
  17972. return fixupEncoding(_filename);
  17973. }
  17974. tmp = toParamRegExp('filename', 'i').exec(contentDisposition);
  17975. if (tmp) {
  17976. tmp = tmp[1];
  17977. var _filename2 = rfc2616unquote(tmp);
  17978. _filename2 = rfc2047decode(_filename2);
  17979. return fixupEncoding(_filename2);
  17980. }
  17981. function toParamRegExp(attributePattern, flags) {
  17982. return new RegExp('(?:^|;)\\s*' + attributePattern + '\\s*=\\s*' + '(' + '[^";\\s][^;\\s]*' + '|' + '"(?:[^"\\\\]|\\\\"?)+"?' + ')', flags);
  17983. }
  17984. function textdecode(encoding, value) {
  17985. if (encoding) {
  17986. if (!/^[\x00-\xFF]+$/.test(value)) {
  17987. return value;
  17988. }
  17989. try {
  17990. var decoder = new TextDecoder(encoding, {
  17991. fatal: true
  17992. });
  17993. var bytes = Array.from(value, function (ch) {
  17994. return ch.charCodeAt(0) & 0xFF;
  17995. });
  17996. value = decoder.decode(new Uint8Array(bytes));
  17997. needsEncodingFixup = false;
  17998. } catch (e) {
  17999. if (/^utf-?8$/i.test(encoding)) {
  18000. try {
  18001. value = decodeURIComponent(escape(value));
  18002. needsEncodingFixup = false;
  18003. } catch (err) {}
  18004. }
  18005. }
  18006. }
  18007. return value;
  18008. }
  18009. function fixupEncoding(value) {
  18010. if (needsEncodingFixup && /[\x80-\xff]/.test(value)) {
  18011. value = textdecode('utf-8', value);
  18012. if (needsEncodingFixup) {
  18013. value = textdecode('iso-8859-1', value);
  18014. }
  18015. }
  18016. return value;
  18017. }
  18018. function rfc2231getparam(contentDisposition) {
  18019. var matches = [],
  18020. match;
  18021. var iter = toParamRegExp('filename\\*((?!0\\d)\\d+)(\\*?)', 'ig');
  18022. while ((match = iter.exec(contentDisposition)) !== null) {
  18023. var _match = match,
  18024. _match2 = _slicedToArray(_match, 4),
  18025. n = _match2[1],
  18026. quot = _match2[2],
  18027. part = _match2[3];
  18028. n = parseInt(n, 10);
  18029. if (n in matches) {
  18030. if (n === 0) {
  18031. break;
  18032. }
  18033. continue;
  18034. }
  18035. matches[n] = [quot, part];
  18036. }
  18037. var parts = [];
  18038. for (var n = 0; n < matches.length; ++n) {
  18039. if (!(n in matches)) {
  18040. break;
  18041. }
  18042. var _matches$n = _slicedToArray(matches[n], 2),
  18043. quot = _matches$n[0],
  18044. part = _matches$n[1];
  18045. part = rfc2616unquote(part);
  18046. if (quot) {
  18047. part = unescape(part);
  18048. if (n === 0) {
  18049. part = rfc5987decode(part);
  18050. }
  18051. }
  18052. parts.push(part);
  18053. }
  18054. return parts.join('');
  18055. }
  18056. function rfc2616unquote(value) {
  18057. if (value.startsWith('"')) {
  18058. var parts = value.slice(1).split('\\"');
  18059. for (var i = 0; i < parts.length; ++i) {
  18060. var quotindex = parts[i].indexOf('"');
  18061. if (quotindex !== -1) {
  18062. parts[i] = parts[i].slice(0, quotindex);
  18063. parts.length = i + 1;
  18064. }
  18065. parts[i] = parts[i].replace(/\\(.)/g, '$1');
  18066. }
  18067. value = parts.join('"');
  18068. }
  18069. return value;
  18070. }
  18071. function rfc5987decode(extvalue) {
  18072. var encodingend = extvalue.indexOf('\'');
  18073. if (encodingend === -1) {
  18074. return extvalue;
  18075. }
  18076. var encoding = extvalue.slice(0, encodingend);
  18077. var langvalue = extvalue.slice(encodingend + 1);
  18078. var value = langvalue.replace(/^[^']*'/, '');
  18079. return textdecode(encoding, value);
  18080. }
  18081. function rfc2047decode(value) {
  18082. if (!value.startsWith('=?') || /[\x00-\x19\x80-\xff]/.test(value)) {
  18083. return value;
  18084. }
  18085. return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (_, charset, encoding, text) {
  18086. if (encoding === 'q' || encoding === 'Q') {
  18087. text = text.replace(/_/g, ' ');
  18088. text = text.replace(/=([0-9a-fA-F]{2})/g, function (_, hex) {
  18089. return String.fromCharCode(parseInt(hex, 16));
  18090. });
  18091. return textdecode(charset, text);
  18092. }
  18093. try {
  18094. text = atob(text);
  18095. } catch (e) {}
  18096. return textdecode(charset, text);
  18097. });
  18098. }
  18099. return '';
  18100. }
  18101. /***/ }),
  18102. /* 168 */
  18103. /***/ (function(module, exports, __w_pdfjs_require__) {
  18104. "use strict";
  18105. Object.defineProperty(exports, "__esModule", {
  18106. value: true
  18107. });
  18108. exports.PDFFetchStream = void 0;
  18109. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  18110. var _util = __w_pdfjs_require__(1);
  18111. var _network_utils = __w_pdfjs_require__(166);
  18112. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18113. 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); } }
  18114. 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); }); }; }
  18115. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18116. 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); } }
  18117. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18118. function createFetchOptions(headers, withCredentials, abortController) {
  18119. return {
  18120. method: 'GET',
  18121. headers: headers,
  18122. signal: abortController && abortController.signal,
  18123. mode: 'cors',
  18124. credentials: withCredentials ? 'include' : 'same-origin',
  18125. redirect: 'follow'
  18126. };
  18127. }
  18128. var PDFFetchStream =
  18129. /*#__PURE__*/
  18130. function () {
  18131. function PDFFetchStream(source) {
  18132. _classCallCheck(this, PDFFetchStream);
  18133. this.source = source;
  18134. this.isHttp = /^https?:/i.test(source.url);
  18135. this.httpHeaders = this.isHttp && source.httpHeaders || {};
  18136. this._fullRequestReader = null;
  18137. this._rangeRequestReaders = [];
  18138. }
  18139. _createClass(PDFFetchStream, [{
  18140. key: "getFullReader",
  18141. value: function getFullReader() {
  18142. (0, _util.assert)(!this._fullRequestReader);
  18143. this._fullRequestReader = new PDFFetchStreamReader(this);
  18144. return this._fullRequestReader;
  18145. }
  18146. }, {
  18147. key: "getRangeReader",
  18148. value: function getRangeReader(begin, end) {
  18149. var reader = new PDFFetchStreamRangeReader(this, begin, end);
  18150. this._rangeRequestReaders.push(reader);
  18151. return reader;
  18152. }
  18153. }, {
  18154. key: "cancelAllRequests",
  18155. value: function cancelAllRequests(reason) {
  18156. if (this._fullRequestReader) {
  18157. this._fullRequestReader.cancel(reason);
  18158. }
  18159. var readers = this._rangeRequestReaders.slice(0);
  18160. readers.forEach(function (reader) {
  18161. reader.cancel(reason);
  18162. });
  18163. }
  18164. }]);
  18165. return PDFFetchStream;
  18166. }();
  18167. exports.PDFFetchStream = PDFFetchStream;
  18168. var PDFFetchStreamReader =
  18169. /*#__PURE__*/
  18170. function () {
  18171. function PDFFetchStreamReader(stream) {
  18172. var _this = this;
  18173. _classCallCheck(this, PDFFetchStreamReader);
  18174. this._stream = stream;
  18175. this._reader = null;
  18176. this._loaded = 0;
  18177. this._filename = null;
  18178. var source = stream.source;
  18179. this._withCredentials = source.withCredentials;
  18180. this._contentLength = source.length;
  18181. this._headersCapability = (0, _util.createPromiseCapability)();
  18182. this._disableRange = source.disableRange || false;
  18183. this._rangeChunkSize = source.rangeChunkSize;
  18184. if (!this._rangeChunkSize && !this._disableRange) {
  18185. this._disableRange = true;
  18186. }
  18187. if (typeof AbortController !== 'undefined') {
  18188. this._abortController = new AbortController();
  18189. }
  18190. this._isStreamingSupported = !source.disableStream;
  18191. this._isRangeSupported = !source.disableRange;
  18192. this._headers = new Headers();
  18193. for (var property in this._stream.httpHeaders) {
  18194. var value = this._stream.httpHeaders[property];
  18195. if (typeof value === 'undefined') {
  18196. continue;
  18197. }
  18198. this._headers.append(property, value);
  18199. }
  18200. var url = source.url;
  18201. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  18202. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  18203. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  18204. }
  18205. _this._reader = response.body.getReader();
  18206. _this._headersCapability.resolve();
  18207. var getResponseHeader = function getResponseHeader(name) {
  18208. return response.headers.get(name);
  18209. };
  18210. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  18211. getResponseHeader: getResponseHeader,
  18212. isHttp: _this._stream.isHttp,
  18213. rangeChunkSize: _this._rangeChunkSize,
  18214. disableRange: _this._disableRange
  18215. }),
  18216. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  18217. suggestedLength = _validateRangeRequest.suggestedLength;
  18218. _this._isRangeSupported = allowRangeRequests;
  18219. _this._contentLength = suggestedLength || _this._contentLength;
  18220. _this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  18221. if (!_this._isStreamingSupported && _this._isRangeSupported) {
  18222. _this.cancel(new _util.AbortException('streaming is disabled'));
  18223. }
  18224. }).catch(this._headersCapability.reject);
  18225. this.onProgress = null;
  18226. }
  18227. _createClass(PDFFetchStreamReader, [{
  18228. key: "read",
  18229. value: function () {
  18230. var _read = _asyncToGenerator(
  18231. /*#__PURE__*/
  18232. _regenerator.default.mark(function _callee() {
  18233. var _ref, value, done, buffer;
  18234. return _regenerator.default.wrap(function _callee$(_context) {
  18235. while (1) {
  18236. switch (_context.prev = _context.next) {
  18237. case 0:
  18238. _context.next = 2;
  18239. return this._headersCapability.promise;
  18240. case 2:
  18241. _context.next = 4;
  18242. return this._reader.read();
  18243. case 4:
  18244. _ref = _context.sent;
  18245. value = _ref.value;
  18246. done = _ref.done;
  18247. if (!done) {
  18248. _context.next = 9;
  18249. break;
  18250. }
  18251. return _context.abrupt("return", {
  18252. value: value,
  18253. done: done
  18254. });
  18255. case 9:
  18256. this._loaded += value.byteLength;
  18257. if (this.onProgress) {
  18258. this.onProgress({
  18259. loaded: this._loaded,
  18260. total: this._contentLength
  18261. });
  18262. }
  18263. buffer = new Uint8Array(value).buffer;
  18264. return _context.abrupt("return", {
  18265. value: buffer,
  18266. done: false
  18267. });
  18268. case 13:
  18269. case "end":
  18270. return _context.stop();
  18271. }
  18272. }
  18273. }, _callee, this);
  18274. }));
  18275. function read() {
  18276. return _read.apply(this, arguments);
  18277. }
  18278. return read;
  18279. }()
  18280. }, {
  18281. key: "cancel",
  18282. value: function cancel(reason) {
  18283. if (this._reader) {
  18284. this._reader.cancel(reason);
  18285. }
  18286. if (this._abortController) {
  18287. this._abortController.abort();
  18288. }
  18289. }
  18290. }, {
  18291. key: "headersReady",
  18292. get: function get() {
  18293. return this._headersCapability.promise;
  18294. }
  18295. }, {
  18296. key: "filename",
  18297. get: function get() {
  18298. return this._filename;
  18299. }
  18300. }, {
  18301. key: "contentLength",
  18302. get: function get() {
  18303. return this._contentLength;
  18304. }
  18305. }, {
  18306. key: "isRangeSupported",
  18307. get: function get() {
  18308. return this._isRangeSupported;
  18309. }
  18310. }, {
  18311. key: "isStreamingSupported",
  18312. get: function get() {
  18313. return this._isStreamingSupported;
  18314. }
  18315. }]);
  18316. return PDFFetchStreamReader;
  18317. }();
  18318. var PDFFetchStreamRangeReader =
  18319. /*#__PURE__*/
  18320. function () {
  18321. function PDFFetchStreamRangeReader(stream, begin, end) {
  18322. var _this2 = this;
  18323. _classCallCheck(this, PDFFetchStreamRangeReader);
  18324. this._stream = stream;
  18325. this._reader = null;
  18326. this._loaded = 0;
  18327. var source = stream.source;
  18328. this._withCredentials = source.withCredentials;
  18329. this._readCapability = (0, _util.createPromiseCapability)();
  18330. this._isStreamingSupported = !source.disableStream;
  18331. if (typeof AbortController !== 'undefined') {
  18332. this._abortController = new AbortController();
  18333. }
  18334. this._headers = new Headers();
  18335. for (var property in this._stream.httpHeaders) {
  18336. var value = this._stream.httpHeaders[property];
  18337. if (typeof value === 'undefined') {
  18338. continue;
  18339. }
  18340. this._headers.append(property, value);
  18341. }
  18342. var rangeStr = begin + '-' + (end - 1);
  18343. this._headers.append('Range', 'bytes=' + rangeStr);
  18344. var url = source.url;
  18345. fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) {
  18346. if (!(0, _network_utils.validateResponseStatus)(response.status)) {
  18347. throw (0, _network_utils.createResponseStatusError)(response.status, url);
  18348. }
  18349. _this2._readCapability.resolve();
  18350. _this2._reader = response.body.getReader();
  18351. });
  18352. this.onProgress = null;
  18353. }
  18354. _createClass(PDFFetchStreamRangeReader, [{
  18355. key: "read",
  18356. value: function () {
  18357. var _read2 = _asyncToGenerator(
  18358. /*#__PURE__*/
  18359. _regenerator.default.mark(function _callee2() {
  18360. var _ref2, value, done, buffer;
  18361. return _regenerator.default.wrap(function _callee2$(_context2) {
  18362. while (1) {
  18363. switch (_context2.prev = _context2.next) {
  18364. case 0:
  18365. _context2.next = 2;
  18366. return this._readCapability.promise;
  18367. case 2:
  18368. _context2.next = 4;
  18369. return this._reader.read();
  18370. case 4:
  18371. _ref2 = _context2.sent;
  18372. value = _ref2.value;
  18373. done = _ref2.done;
  18374. if (!done) {
  18375. _context2.next = 9;
  18376. break;
  18377. }
  18378. return _context2.abrupt("return", {
  18379. value: value,
  18380. done: done
  18381. });
  18382. case 9:
  18383. this._loaded += value.byteLength;
  18384. if (this.onProgress) {
  18385. this.onProgress({
  18386. loaded: this._loaded
  18387. });
  18388. }
  18389. buffer = new Uint8Array(value).buffer;
  18390. return _context2.abrupt("return", {
  18391. value: buffer,
  18392. done: false
  18393. });
  18394. case 13:
  18395. case "end":
  18396. return _context2.stop();
  18397. }
  18398. }
  18399. }, _callee2, this);
  18400. }));
  18401. function read() {
  18402. return _read2.apply(this, arguments);
  18403. }
  18404. return read;
  18405. }()
  18406. }, {
  18407. key: "cancel",
  18408. value: function cancel(reason) {
  18409. if (this._reader) {
  18410. this._reader.cancel(reason);
  18411. }
  18412. if (this._abortController) {
  18413. this._abortController.abort();
  18414. }
  18415. }
  18416. }, {
  18417. key: "isStreamingSupported",
  18418. get: function get() {
  18419. return this._isStreamingSupported;
  18420. }
  18421. }]);
  18422. return PDFFetchStreamRangeReader;
  18423. }();
  18424. /***/ }),
  18425. /* 169 */
  18426. /***/ (function(module, exports, __w_pdfjs_require__) {
  18427. "use strict";
  18428. Object.defineProperty(exports, "__esModule", {
  18429. value: true
  18430. });
  18431. exports.PDFNetworkStream = PDFNetworkStream;
  18432. exports.NetworkManager = NetworkManager;
  18433. var _regenerator = _interopRequireDefault(__w_pdfjs_require__(147));
  18434. var _util = __w_pdfjs_require__(1);
  18435. var _network_utils = __w_pdfjs_require__(166);
  18436. var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
  18437. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18438. 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); } }
  18439. 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); }); }; }
  18440. ;
  18441. var OK_RESPONSE = 200;
  18442. var PARTIAL_CONTENT_RESPONSE = 206;
  18443. function NetworkManager(url, args) {
  18444. this.url = url;
  18445. args = args || {};
  18446. this.isHttp = /^https?:/i.test(url);
  18447. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  18448. this.withCredentials = args.withCredentials || false;
  18449. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  18450. return new XMLHttpRequest();
  18451. };
  18452. this.currXhrId = 0;
  18453. this.pendingRequests = Object.create(null);
  18454. this.loadedRequests = Object.create(null);
  18455. }
  18456. function getArrayBuffer(xhr) {
  18457. var data = xhr.response;
  18458. if (typeof data !== 'string') {
  18459. return data;
  18460. }
  18461. var array = (0, _util.stringToBytes)(data);
  18462. return array.buffer;
  18463. }
  18464. var supportsMozChunked = function supportsMozChunkedClosure() {
  18465. try {
  18466. var x = new XMLHttpRequest();
  18467. x.open('GET', _global_scope.default.location.href);
  18468. x.responseType = 'moz-chunked-arraybuffer';
  18469. return x.responseType === 'moz-chunked-arraybuffer';
  18470. } catch (e) {
  18471. return false;
  18472. }
  18473. }();
  18474. NetworkManager.prototype = {
  18475. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  18476. var args = {
  18477. begin: begin,
  18478. end: end
  18479. };
  18480. for (var prop in listeners) {
  18481. args[prop] = listeners[prop];
  18482. }
  18483. return this.request(args);
  18484. },
  18485. requestFull: function NetworkManager_requestFull(listeners) {
  18486. return this.request(listeners);
  18487. },
  18488. request: function NetworkManager_request(args) {
  18489. var xhr = this.getXhr();
  18490. var xhrId = this.currXhrId++;
  18491. var pendingRequest = this.pendingRequests[xhrId] = {
  18492. xhr: xhr
  18493. };
  18494. xhr.open('GET', this.url);
  18495. xhr.withCredentials = this.withCredentials;
  18496. for (var property in this.httpHeaders) {
  18497. var value = this.httpHeaders[property];
  18498. if (typeof value === 'undefined') {
  18499. continue;
  18500. }
  18501. xhr.setRequestHeader(property, value);
  18502. }
  18503. if (this.isHttp && 'begin' in args && 'end' in args) {
  18504. var rangeStr = args.begin + '-' + (args.end - 1);
  18505. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  18506. pendingRequest.expectedStatus = 206;
  18507. } else {
  18508. pendingRequest.expectedStatus = 200;
  18509. }
  18510. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  18511. if (useMozChunkedLoading) {
  18512. xhr.responseType = 'moz-chunked-arraybuffer';
  18513. pendingRequest.onProgressiveData = args.onProgressiveData;
  18514. pendingRequest.mozChunked = true;
  18515. } else {
  18516. xhr.responseType = 'arraybuffer';
  18517. }
  18518. if (args.onError) {
  18519. xhr.onerror = function (evt) {
  18520. args.onError(xhr.status);
  18521. };
  18522. }
  18523. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  18524. xhr.onprogress = this.onProgress.bind(this, xhrId);
  18525. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  18526. pendingRequest.onDone = args.onDone;
  18527. pendingRequest.onError = args.onError;
  18528. pendingRequest.onProgress = args.onProgress;
  18529. xhr.send(null);
  18530. return xhrId;
  18531. },
  18532. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  18533. var pendingRequest = this.pendingRequests[xhrId];
  18534. if (!pendingRequest) {
  18535. return;
  18536. }
  18537. if (pendingRequest.mozChunked) {
  18538. var chunk = getArrayBuffer(pendingRequest.xhr);
  18539. pendingRequest.onProgressiveData(chunk);
  18540. }
  18541. var onProgress = pendingRequest.onProgress;
  18542. if (onProgress) {
  18543. onProgress(evt);
  18544. }
  18545. },
  18546. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  18547. var pendingRequest = this.pendingRequests[xhrId];
  18548. if (!pendingRequest) {
  18549. return;
  18550. }
  18551. var xhr = pendingRequest.xhr;
  18552. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  18553. pendingRequest.onHeadersReceived();
  18554. delete pendingRequest.onHeadersReceived;
  18555. }
  18556. if (xhr.readyState !== 4) {
  18557. return;
  18558. }
  18559. if (!(xhrId in this.pendingRequests)) {
  18560. return;
  18561. }
  18562. delete this.pendingRequests[xhrId];
  18563. if (xhr.status === 0 && this.isHttp) {
  18564. if (pendingRequest.onError) {
  18565. pendingRequest.onError(xhr.status);
  18566. }
  18567. return;
  18568. }
  18569. var xhrStatus = xhr.status || OK_RESPONSE;
  18570. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  18571. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  18572. if (pendingRequest.onError) {
  18573. pendingRequest.onError(xhr.status);
  18574. }
  18575. return;
  18576. }
  18577. this.loadedRequests[xhrId] = true;
  18578. var chunk = getArrayBuffer(xhr);
  18579. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  18580. var rangeHeader = xhr.getResponseHeader('Content-Range');
  18581. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  18582. var begin = parseInt(matches[1], 10);
  18583. pendingRequest.onDone({
  18584. begin: begin,
  18585. chunk: chunk
  18586. });
  18587. } else if (pendingRequest.onProgressiveData) {
  18588. pendingRequest.onDone(null);
  18589. } else if (chunk) {
  18590. pendingRequest.onDone({
  18591. begin: 0,
  18592. chunk: chunk
  18593. });
  18594. } else if (pendingRequest.onError) {
  18595. pendingRequest.onError(xhr.status);
  18596. }
  18597. },
  18598. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  18599. for (var xhrId in this.pendingRequests) {
  18600. return true;
  18601. }
  18602. return false;
  18603. },
  18604. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  18605. return this.pendingRequests[xhrId].xhr;
  18606. },
  18607. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  18608. return !!this.pendingRequests[xhrId].onProgressiveData;
  18609. },
  18610. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  18611. return xhrId in this.pendingRequests;
  18612. },
  18613. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  18614. return xhrId in this.loadedRequests;
  18615. },
  18616. abortAllRequests: function NetworkManager_abortAllRequests() {
  18617. for (var xhrId in this.pendingRequests) {
  18618. this.abortRequest(xhrId | 0);
  18619. }
  18620. },
  18621. abortRequest: function NetworkManager_abortRequest(xhrId) {
  18622. var xhr = this.pendingRequests[xhrId].xhr;
  18623. delete this.pendingRequests[xhrId];
  18624. xhr.abort();
  18625. }
  18626. };
  18627. function PDFNetworkStream(source) {
  18628. this._source = source;
  18629. this._manager = new NetworkManager(source.url, {
  18630. httpHeaders: source.httpHeaders,
  18631. withCredentials: source.withCredentials
  18632. });
  18633. this._rangeChunkSize = source.rangeChunkSize;
  18634. this._fullRequestReader = null;
  18635. this._rangeRequestReaders = [];
  18636. }
  18637. PDFNetworkStream.prototype = {
  18638. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  18639. var i = this._rangeRequestReaders.indexOf(reader);
  18640. if (i >= 0) {
  18641. this._rangeRequestReaders.splice(i, 1);
  18642. }
  18643. },
  18644. getFullReader: function PDFNetworkStream_getFullReader() {
  18645. (0, _util.assert)(!this._fullRequestReader);
  18646. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
  18647. return this._fullRequestReader;
  18648. },
  18649. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  18650. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  18651. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  18652. this._rangeRequestReaders.push(reader);
  18653. return reader;
  18654. },
  18655. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  18656. if (this._fullRequestReader) {
  18657. this._fullRequestReader.cancel(reason);
  18658. }
  18659. var readers = this._rangeRequestReaders.slice(0);
  18660. readers.forEach(function (reader) {
  18661. reader.cancel(reason);
  18662. });
  18663. }
  18664. };
  18665. function PDFNetworkStreamFullRequestReader(manager, source) {
  18666. this._manager = manager;
  18667. var args = {
  18668. onHeadersReceived: this._onHeadersReceived.bind(this),
  18669. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  18670. onDone: this._onDone.bind(this),
  18671. onError: this._onError.bind(this),
  18672. onProgress: this._onProgress.bind(this)
  18673. };
  18674. this._url = source.url;
  18675. this._fullRequestId = manager.requestFull(args);
  18676. this._headersReceivedCapability = (0, _util.createPromiseCapability)();
  18677. this._disableRange = source.disableRange || false;
  18678. this._contentLength = source.length;
  18679. this._rangeChunkSize = source.rangeChunkSize;
  18680. if (!this._rangeChunkSize && !this._disableRange) {
  18681. this._disableRange = true;
  18682. }
  18683. this._isStreamingSupported = false;
  18684. this._isRangeSupported = false;
  18685. this._cachedChunks = [];
  18686. this._requests = [];
  18687. this._done = false;
  18688. this._storedError = undefined;
  18689. this._filename = null;
  18690. this.onProgress = null;
  18691. }
  18692. PDFNetworkStreamFullRequestReader.prototype = {
  18693. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  18694. var fullRequestXhrId = this._fullRequestId;
  18695. var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
  18696. var getResponseHeader = function getResponseHeader(name) {
  18697. return fullRequestXhr.getResponseHeader(name);
  18698. };
  18699. var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
  18700. getResponseHeader: getResponseHeader,
  18701. isHttp: this._manager.isHttp,
  18702. rangeChunkSize: this._rangeChunkSize,
  18703. disableRange: this._disableRange
  18704. }),
  18705. allowRangeRequests = _validateRangeRequest.allowRangeRequests,
  18706. suggestedLength = _validateRangeRequest.suggestedLength;
  18707. if (allowRangeRequests) {
  18708. this._isRangeSupported = true;
  18709. }
  18710. this._contentLength = suggestedLength || this._contentLength;
  18711. this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
  18712. var networkManager = this._manager;
  18713. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  18714. this._isStreamingSupported = true;
  18715. } else if (this._isRangeSupported) {
  18716. networkManager.abortRequest(fullRequestXhrId);
  18717. }
  18718. this._headersReceivedCapability.resolve();
  18719. },
  18720. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  18721. if (this._requests.length > 0) {
  18722. var requestCapability = this._requests.shift();
  18723. requestCapability.resolve({
  18724. value: chunk,
  18725. done: false
  18726. });
  18727. } else {
  18728. this._cachedChunks.push(chunk);
  18729. }
  18730. },
  18731. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  18732. if (args) {
  18733. this._onProgressiveData(args.chunk);
  18734. }
  18735. this._done = true;
  18736. if (this._cachedChunks.length > 0) {
  18737. return;
  18738. }
  18739. this._requests.forEach(function (requestCapability) {
  18740. requestCapability.resolve({
  18741. value: undefined,
  18742. done: true
  18743. });
  18744. });
  18745. this._requests = [];
  18746. },
  18747. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  18748. var url = this._url;
  18749. var exception = (0, _network_utils.createResponseStatusError)(status, url);
  18750. this._storedError = exception;
  18751. this._headersReceivedCapability.reject(exception);
  18752. this._requests.forEach(function (requestCapability) {
  18753. requestCapability.reject(exception);
  18754. });
  18755. this._requests = [];
  18756. this._cachedChunks = [];
  18757. },
  18758. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  18759. if (this.onProgress) {
  18760. this.onProgress({
  18761. loaded: data.loaded,
  18762. total: data.lengthComputable ? data.total : this._contentLength
  18763. });
  18764. }
  18765. },
  18766. get filename() {
  18767. return this._filename;
  18768. },
  18769. get isRangeSupported() {
  18770. return this._isRangeSupported;
  18771. },
  18772. get isStreamingSupported() {
  18773. return this._isStreamingSupported;
  18774. },
  18775. get contentLength() {
  18776. return this._contentLength;
  18777. },
  18778. get headersReady() {
  18779. return this._headersReceivedCapability.promise;
  18780. },
  18781. read: function () {
  18782. var _read = _asyncToGenerator(
  18783. /*#__PURE__*/
  18784. _regenerator.default.mark(function _callee() {
  18785. var chunk, requestCapability;
  18786. return _regenerator.default.wrap(function _callee$(_context) {
  18787. while (1) {
  18788. switch (_context.prev = _context.next) {
  18789. case 0:
  18790. if (!this._storedError) {
  18791. _context.next = 2;
  18792. break;
  18793. }
  18794. throw this._storedError;
  18795. case 2:
  18796. if (!(this._cachedChunks.length > 0)) {
  18797. _context.next = 5;
  18798. break;
  18799. }
  18800. chunk = this._cachedChunks.shift();
  18801. return _context.abrupt("return", {
  18802. value: chunk,
  18803. done: false
  18804. });
  18805. case 5:
  18806. if (!this._done) {
  18807. _context.next = 7;
  18808. break;
  18809. }
  18810. return _context.abrupt("return", {
  18811. value: undefined,
  18812. done: true
  18813. });
  18814. case 7:
  18815. requestCapability = (0, _util.createPromiseCapability)();
  18816. this._requests.push(requestCapability);
  18817. return _context.abrupt("return", requestCapability.promise);
  18818. case 10:
  18819. case "end":
  18820. return _context.stop();
  18821. }
  18822. }
  18823. }, _callee, this);
  18824. }));
  18825. function read() {
  18826. return _read.apply(this, arguments);
  18827. }
  18828. return read;
  18829. }(),
  18830. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  18831. this._done = true;
  18832. this._headersReceivedCapability.reject(reason);
  18833. this._requests.forEach(function (requestCapability) {
  18834. requestCapability.resolve({
  18835. value: undefined,
  18836. done: true
  18837. });
  18838. });
  18839. this._requests = [];
  18840. if (this._manager.isPendingRequest(this._fullRequestId)) {
  18841. this._manager.abortRequest(this._fullRequestId);
  18842. }
  18843. this._fullRequestReader = null;
  18844. }
  18845. };
  18846. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  18847. this._manager = manager;
  18848. var args = {
  18849. onDone: this._onDone.bind(this),
  18850. onProgress: this._onProgress.bind(this)
  18851. };
  18852. this._requestId = manager.requestRange(begin, end, args);
  18853. this._requests = [];
  18854. this._queuedChunk = null;
  18855. this._done = false;
  18856. this.onProgress = null;
  18857. this.onClosed = null;
  18858. }
  18859. PDFNetworkStreamRangeRequestReader.prototype = {
  18860. _close: function PDFNetworkStreamRangeRequestReader_close() {
  18861. if (this.onClosed) {
  18862. this.onClosed(this);
  18863. }
  18864. },
  18865. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  18866. var chunk = data.chunk;
  18867. if (this._requests.length > 0) {
  18868. var requestCapability = this._requests.shift();
  18869. requestCapability.resolve({
  18870. value: chunk,
  18871. done: false
  18872. });
  18873. } else {
  18874. this._queuedChunk = chunk;
  18875. }
  18876. this._done = true;
  18877. this._requests.forEach(function (requestCapability) {
  18878. requestCapability.resolve({
  18879. value: undefined,
  18880. done: true
  18881. });
  18882. });
  18883. this._requests = [];
  18884. this._close();
  18885. },
  18886. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  18887. if (!this.isStreamingSupported && this.onProgress) {
  18888. this.onProgress({
  18889. loaded: evt.loaded
  18890. });
  18891. }
  18892. },
  18893. get isStreamingSupported() {
  18894. return false;
  18895. },
  18896. read: function () {
  18897. var _read2 = _asyncToGenerator(
  18898. /*#__PURE__*/
  18899. _regenerator.default.mark(function _callee2() {
  18900. var chunk, requestCapability;
  18901. return _regenerator.default.wrap(function _callee2$(_context2) {
  18902. while (1) {
  18903. switch (_context2.prev = _context2.next) {
  18904. case 0:
  18905. if (!(this._queuedChunk !== null)) {
  18906. _context2.next = 4;
  18907. break;
  18908. }
  18909. chunk = this._queuedChunk;
  18910. this._queuedChunk = null;
  18911. return _context2.abrupt("return", {
  18912. value: chunk,
  18913. done: false
  18914. });
  18915. case 4:
  18916. if (!this._done) {
  18917. _context2.next = 6;
  18918. break;
  18919. }
  18920. return _context2.abrupt("return", {
  18921. value: undefined,
  18922. done: true
  18923. });
  18924. case 6:
  18925. requestCapability = (0, _util.createPromiseCapability)();
  18926. this._requests.push(requestCapability);
  18927. return _context2.abrupt("return", requestCapability.promise);
  18928. case 9:
  18929. case "end":
  18930. return _context2.stop();
  18931. }
  18932. }
  18933. }, _callee2, this);
  18934. }));
  18935. function read() {
  18936. return _read2.apply(this, arguments);
  18937. }
  18938. return read;
  18939. }(),
  18940. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  18941. this._done = true;
  18942. this._requests.forEach(function (requestCapability) {
  18943. requestCapability.resolve({
  18944. value: undefined,
  18945. done: true
  18946. });
  18947. });
  18948. this._requests = [];
  18949. if (this._manager.isPendingRequest(this._requestId)) {
  18950. this._manager.abortRequest(this._requestId);
  18951. }
  18952. this._close();
  18953. }
  18954. };
  18955. /***/ })
  18956. /******/ ]);
  18957. });
  18958. //# sourceMappingURL=pdf.js.map
上海开阖软件有限公司 沪ICP备12045867号-1