Skip to content
Snippets Groups Projects
1.index.js 1.51 MiB
Newer Older
  • Learn to ignore specific revisions
  • Romain CREY's avatar
    Romain CREY committed
    9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 9178 9179 9180 9181 9182 9183 9184 9185 9186 9187 9188 9189 9190 9191 9192 9193 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 9225 9226 9227 9228 9229 9230 9231 9232 9233 9234 9235 9236 9237 9238 9239 9240 9241 9242 9243 9244 9245 9246 9247 9248 9249 9250 9251 9252 9253 9254 9255 9256 9257 9258 9259 9260 9261 9262 9263 9264 9265 9266 9267 9268 9269 9270 9271 9272 9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 9460 9461 9462 9463 9464 9465 9466 9467 9468 9469 9470 9471 9472 9473 9474 9475 9476 9477 9478 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 9494 9495 9496 9497 9498 9499 9500 9501 9502 9503 9504 9505 9506 9507 9508 9509 9510 9511 9512 9513 9514 9515 9516 9517 9518 9519 9520 9521 9522 9523 9524 9525 9526 9527 9528 9529 9530 9531 9532 9533 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 9554 9555 9556 9557 9558 9559 9560 9561 9562 9563 9564 9565 9566 9567 9568 9569 9570 9571 9572 9573 9574 9575 9576 9577 9578 9579 9580 9581 9582 9583 9584 9585 9586 9587 9588 9589 9590 9591 9592 9593 9594 9595 9596 9597 9598 9599 9600 9601 9602 9603 9604 9605 9606 9607 9608 9609 9610 9611 9612 9613 9614 9615 9616 9617 9618 9619 9620 9621 9622 9623 9624 9625 9626 9627 9628 9629 9630 9631 9632 9633 9634 9635 9636 9637 9638 9639 9640 9641 9642 9643 9644 9645 9646 9647 9648 9649 9650 9651 9652 9653 9654 9655 9656 9657 9658 9659 9660 9661 9662 9663 9664 9665 9666 9667 9668 9669 9670 9671 9672 9673 9674 9675 9676 9677 9678 9679 9680 9681 9682 9683 9684 9685 9686 9687 9688 9689 9690 9691 9692 9693 9694 9695 9696 9697 9698 9699 9700 9701 9702 9703 9704 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 9717 9718 9719 9720 9721 9722 9723 9724 9725 9726 9727 9728 9729 9730 9731 9732 9733 9734 9735 9736 9737 9738 9739 9740 9741 9742 9743 9744 9745 9746 9747 9748 9749 9750 9751 9752 9753 9754 9755 9756 9757 9758 9759 9760 9761 9762 9763 9764 9765 9766 9767 9768 9769 9770 9771 9772 9773 9774 9775 9776 9777 9778 9779 9780 9781 9782 9783 9784 9785 9786 9787 9788 9789 9790 9791 9792 9793 9794 9795 9796 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 9817 9818 9819 9820 9821 9822 9823 9824 9825 9826 9827 9828 9829 9830 9831 9832 9833 9834 9835 9836 9837 9838 9839 9840 9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 9851 9852 9853 9854 9855 9856 9857 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 9873 9874 9875 9876 9877 9878 9879 9880 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 9902 9903 9904 9905 9906 9907 9908 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 9927 9928 9929 9930 9931 9932 9933 9934 9935 9936 9937 9938 9939 9940 9941 9942 9943 9944 9945 9946 9947 9948 9949 9950 9951 9952 9953 9954 9955 9956 9957 9958 9959 9960 9961 9962 9963 9964 9965 9966 9967 9968 9969 9970 9971 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000
              return next;
            }
          }
          next.done = true;
          return next;
        };
      };
      function values(iterable) {
        if (iterable) {
          var iteratorMethod = iterable[iteratorSymbol];
          if (iteratorMethod) {
            return iteratorMethod.call(iterable);
          }
          if (typeof iterable.next === "function") {
            return iterable;
          }
          if (!isNaN(iterable.length)) {
            var i = -1,
                next = function next() {
              while (++i < iterable.length) {
                if (hasOwn.call(iterable, i)) {
                  next.value = iterable[i];
                  next.done = false;
                  return next;
                }
              }
              next.value = undefined;
              next.done = true;
              return next;
            };
            return next.next = next;
          }
        }
        return { next: doneResult };
      }
      runtime.values = values;
      function doneResult() {
        return {
          value: undefined,
          done: true
        };
      }
      Context.prototype = {
        constructor: Context,
        reset: function reset(skipTempReset) {
          this.prev = 0;
          this.next = 0;
          this.sent = this._sent = undefined;
          this.done = false;
          this.delegate = null;
          this.method = "next";
          this.arg = undefined;
          this.tryEntries.forEach(resetTryEntry);
          if (!skipTempReset) {
            for (var name in this) {
              if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
                this[name] = undefined;
              }
            }
          }
        },
        stop: function stop() {
          this.done = true;
          var rootEntry = this.tryEntries[0];
          var rootRecord = rootEntry.completion;
          if (rootRecord.type === "throw") {
            throw rootRecord.arg;
          }
          return this.rval;
        },
        dispatchException: function dispatchException(exception) {
          if (this.done) {
            throw exception;
          }
          var context = this;
          function handle(loc, caught) {
            record.type = "throw";
            record.arg = exception;
            context.next = loc;
            if (caught) {
              context.method = "next";
              context.arg = undefined;
            }
            return !!caught;
          }
          for (var i = this.tryEntries.length - 1; i >= 0; --i) {
            var entry = this.tryEntries[i];
            var record = entry.completion;
            if (entry.tryLoc === "root") {
              return handle("end");
            }
            if (entry.tryLoc <= this.prev) {
              var hasCatch = hasOwn.call(entry, "catchLoc");
              var hasFinally = hasOwn.call(entry, "finallyLoc");
              if (hasCatch && hasFinally) {
                if (this.prev < entry.catchLoc) {
                  return handle(entry.catchLoc, true);
                } else if (this.prev < entry.finallyLoc) {
                  return handle(entry.finallyLoc);
                }
              } else if (hasCatch) {
                if (this.prev < entry.catchLoc) {
                  return handle(entry.catchLoc, true);
                }
              } else if (hasFinally) {
                if (this.prev < entry.finallyLoc) {
                  return handle(entry.finallyLoc);
                }
              } else {
                throw new Error("try statement without catch or finally");
              }
            }
          }
        },
        abrupt: function abrupt(type, arg) {
          for (var i = this.tryEntries.length - 1; i >= 0; --i) {
            var entry = this.tryEntries[i];
            if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
              var finallyEntry = entry;
              break;
            }
          }
          if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
            finallyEntry = null;
          }
          var record = finallyEntry ? finallyEntry.completion : {};
          record.type = type;
          record.arg = arg;
          if (finallyEntry) {
            this.method = "next";
            this.next = finallyEntry.finallyLoc;
            return ContinueSentinel;
          }
          return this.complete(record);
        },
        complete: function complete(record, afterLoc) {
          if (record.type === "throw") {
            throw record.arg;
          }
          if (record.type === "break" || record.type === "continue") {
            this.next = record.arg;
          } else if (record.type === "return") {
            this.rval = this.arg = record.arg;
            this.method = "return";
            this.next = "end";
          } else if (record.type === "normal" && afterLoc) {
            this.next = afterLoc;
          }
          return ContinueSentinel;
        },
        finish: function finish(finallyLoc) {
          for (var i = this.tryEntries.length - 1; i >= 0; --i) {
            var entry = this.tryEntries[i];
            if (entry.finallyLoc === finallyLoc) {
              this.complete(entry.completion, entry.afterLoc);
              resetTryEntry(entry);
              return ContinueSentinel;
            }
          }
        },
        "catch": function _catch(tryLoc) {
          for (var i = this.tryEntries.length - 1; i >= 0; --i) {
            var entry = this.tryEntries[i];
            if (entry.tryLoc === tryLoc) {
              var record = entry.completion;
              if (record.type === "throw") {
                var thrown = record.arg;
                resetTryEntry(entry);
              }
              return thrown;
            }
          }
          throw new Error("illegal catch attempt");
        },
        delegateYield: function delegateYield(iterable, resultName, nextLoc) {
          this.delegate = {
            iterator: values(iterable),
            resultName: resultName,
            nextLoc: nextLoc
          };
          if (this.method === "next") {
            this.arg = undefined;
          }
          return ContinueSentinel;
        }
      };
    }(function () {
      return this;
    }() || Function("return this")());
    /* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(134)(module)))
    
    /***/ }),
    /* 134 */
    /***/ (function(module, exports, __w_pdfjs_require__) {
    
    "use strict";
    
    
    module.exports = function (module) {
      if (!module.webpackPolyfill) {
        module.deprecate = function () {};
        module.paths = [];
        if (!module.children) module.children = [];
        Object.defineProperty(module, "loaded", {
          enumerable: true,
          get: function get() {
            return module.l;
          }
        });
        Object.defineProperty(module, "id", {
          enumerable: true,
          get: function get() {
            return module.i;
          }
        });
        module.webpackPolyfill = 1;
      }
      return module;
    };
    
    /***/ }),
    /* 135 */
    /***/ (function(module, exports, __w_pdfjs_require__) {
    
    "use strict";
    
    
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.ChunkedStreamManager = exports.ChunkedStream = undefined;
    
    var _util = __w_pdfjs_require__(2);
    
    var ChunkedStream = function ChunkedStreamClosure() {
      function ChunkedStream(length, chunkSize, manager) {
        this.bytes = new Uint8Array(length);
        this.start = 0;
        this.pos = 0;
        this.end = length;
        this.chunkSize = chunkSize;
        this.loadedChunks = [];
        this.numChunksLoaded = 0;
        this.numChunks = Math.ceil(length / chunkSize);
        this.manager = manager;
        this.progressiveDataLength = 0;
        this.lastSuccessfulEnsureByteChunk = -1;
      }
      ChunkedStream.prototype = {
        getMissingChunks: function ChunkedStream_getMissingChunks() {
          var chunks = [];
          for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
            if (!this.loadedChunks[chunk]) {
              chunks.push(chunk);
            }
          }
          return chunks;
        },
        getBaseStreams: function ChunkedStream_getBaseStreams() {
          return [this];
        },
        allChunksLoaded: function ChunkedStream_allChunksLoaded() {
          return this.numChunksLoaded === this.numChunks;
        },
        onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
          var end = begin + chunk.byteLength;
          if (begin % this.chunkSize !== 0) {
            throw new Error('Bad begin offset: ' + begin);
          }
          var length = this.bytes.length;
          if (end % this.chunkSize !== 0 && end !== length) {
            throw new Error('Bad end offset: ' + end);
          }
          this.bytes.set(new Uint8Array(chunk), begin);
          var chunkSize = this.chunkSize;
          var beginChunk = Math.floor(begin / chunkSize);
          var endChunk = Math.floor((end - 1) / chunkSize) + 1;
          var curChunk;
          for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
            if (!this.loadedChunks[curChunk]) {
              this.loadedChunks[curChunk] = true;
              ++this.numChunksLoaded;
            }
          }
        },
        onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
          var position = this.progressiveDataLength;
          var beginChunk = Math.floor(position / this.chunkSize);
          this.bytes.set(new Uint8Array(data), position);
          position += data.byteLength;
          this.progressiveDataLength = position;
          var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
          var curChunk;
          for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
            if (!this.loadedChunks[curChunk]) {
              this.loadedChunks[curChunk] = true;
              ++this.numChunksLoaded;
            }
          }
        },
        ensureByte: function ChunkedStream_ensureByte(pos) {
          var chunk = Math.floor(pos / this.chunkSize);
          if (chunk === this.lastSuccessfulEnsureByteChunk) {
            return;
          }
          if (!this.loadedChunks[chunk]) {
            throw new _util.MissingDataException(pos, pos + 1);
          }
          this.lastSuccessfulEnsureByteChunk = chunk;
        },
        ensureRange: function ChunkedStream_ensureRange(begin, end) {
          if (begin >= end) {
            return;
          }
          if (end <= this.progressiveDataLength) {
            return;
          }
          var chunkSize = this.chunkSize;
          var beginChunk = Math.floor(begin / chunkSize);
          var endChunk = Math.floor((end - 1) / chunkSize) + 1;
          for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
            if (!this.loadedChunks[chunk]) {
              throw new _util.MissingDataException(begin, end);
            }
          }
        },
        nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
          var chunk,
              numChunks = this.numChunks;
          for (var i = 0; i < numChunks; ++i) {
            chunk = (beginChunk + i) % numChunks;
            if (!this.loadedChunks[chunk]) {
              return chunk;
            }
          }
          return null;
        },
        hasChunk: function ChunkedStream_hasChunk(chunk) {
          return !!this.loadedChunks[chunk];
        },
        get length() {
          return this.end - this.start;
        },
        get isEmpty() {
          return this.length === 0;
        },
        getByte: function ChunkedStream_getByte() {
          var pos = this.pos;
          if (pos >= this.end) {
            return -1;
          }
          this.ensureByte(pos);
          return this.bytes[this.pos++];
        },
        getUint16: function ChunkedStream_getUint16() {
          var b0 = this.getByte();
          var b1 = this.getByte();
          if (b0 === -1 || b1 === -1) {
            return -1;
          }
          return (b0 << 8) + b1;
        },
        getInt32: function ChunkedStream_getInt32() {
          var b0 = this.getByte();
          var b1 = this.getByte();
          var b2 = this.getByte();
          var b3 = this.getByte();
          return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
        },
        getBytes: function getBytes(length) {
          var forceClamped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
    
          var bytes = this.bytes;
          var pos = this.pos;
          var strEnd = this.end;
          if (!length) {
            this.ensureRange(pos, strEnd);
            var _subarray = bytes.subarray(pos, strEnd);
            return forceClamped ? new Uint8ClampedArray(_subarray) : _subarray;
          }
          var end = pos + length;
          if (end > strEnd) {
            end = strEnd;
          }
          this.ensureRange(pos, end);
          this.pos = end;
          var subarray = bytes.subarray(pos, end);
          return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
        },
    
        peekByte: function ChunkedStream_peekByte() {
          var peekedByte = this.getByte();
          this.pos--;
          return peekedByte;
        },
        peekBytes: function peekBytes(length) {
          var forceClamped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
    
          var bytes = this.getBytes(length, forceClamped);
          this.pos -= bytes.length;
          return bytes;
        },
    
        getByteRange: function ChunkedStream_getBytes(begin, end) {
          this.ensureRange(begin, end);
          return this.bytes.subarray(begin, end);
        },
        skip: function ChunkedStream_skip(n) {
          if (!n) {
            n = 1;
          }
          this.pos += n;
        },
        reset: function ChunkedStream_reset() {
          this.pos = this.start;
        },
        moveStart: function ChunkedStream_moveStart() {
          this.start = this.pos;
        },
        makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
          this.ensureRange(start, start + length);
          function ChunkedStreamSubstream() {}
          ChunkedStreamSubstream.prototype = Object.create(this);
          ChunkedStreamSubstream.prototype.getMissingChunks = function () {
            var chunkSize = this.chunkSize;
            var beginChunk = Math.floor(this.start / chunkSize);
            var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
            var missingChunks = [];
            for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
              if (!this.loadedChunks[chunk]) {
                missingChunks.push(chunk);
              }
            }
            return missingChunks;
          };
          var subStream = new ChunkedStreamSubstream();
          subStream.pos = subStream.start = start;
          subStream.end = start + length || this.end;
          subStream.dict = dict;
          return subStream;
        }
      };
      return ChunkedStream;
    }();
    var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
      function ChunkedStreamManager(pdfNetworkStream, args) {
        var chunkSize = args.rangeChunkSize;
        var length = args.length;
        this.stream = new ChunkedStream(length, chunkSize, this);
        this.length = length;
        this.chunkSize = chunkSize;
        this.pdfNetworkStream = pdfNetworkStream;
        this.url = args.url;
        this.disableAutoFetch = args.disableAutoFetch;
        this.msgHandler = args.msgHandler;
        this.currRequestId = 0;
        this.chunksNeededByRequest = Object.create(null);
        this.requestsByChunk = Object.create(null);
        this.promisesByRequest = Object.create(null);
        this.progressiveDataLength = 0;
        this.aborted = false;
        this._loadedStreamCapability = (0, _util.createPromiseCapability)();
      }
      ChunkedStreamManager.prototype = {
        onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
          return this._loadedStreamCapability.promise;
        },
        sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
          var _this = this;
    
          var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
          if (!rangeReader.isStreamingSupported) {
            rangeReader.onProgress = this.onProgress.bind(this);
          }
          var chunks = [],
              loaded = 0;
          var manager = this;
          var promise = new Promise(function (resolve, reject) {
            var readChunk = function readChunk(chunk) {
              try {
                if (!chunk.done) {
                  var data = chunk.value;
                  chunks.push(data);
                  loaded += (0, _util.arrayByteLength)(data);
                  if (rangeReader.isStreamingSupported) {
                    manager.onProgress({ loaded: loaded });
                  }
                  rangeReader.read().then(readChunk, reject);
                  return;
                }
                var chunkData = (0, _util.arraysToBytes)(chunks);
                chunks = null;
                resolve(chunkData);
              } catch (e) {
                reject(e);
              }
            };
            rangeReader.read().then(readChunk, reject);
          });
          promise.then(function (data) {
            if (_this.aborted) {
              return;
            }
            _this.onReceiveData({
              chunk: data,
              begin: begin
            });
          });
        },
        requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
          var missingChunks = this.stream.getMissingChunks();
          this._requestChunks(missingChunks);
          return this._loadedStreamCapability.promise;
        },
        _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
          var requestId = this.currRequestId++;
          var i, ii;
          var chunksNeeded = Object.create(null);
          this.chunksNeededByRequest[requestId] = chunksNeeded;
          for (i = 0, ii = chunks.length; i < ii; i++) {
            if (!this.stream.hasChunk(chunks[i])) {
              chunksNeeded[chunks[i]] = true;
            }
          }
          if ((0, _util.isEmptyObj)(chunksNeeded)) {
            return Promise.resolve();
          }
          var capability = (0, _util.createPromiseCapability)();
          this.promisesByRequest[requestId] = capability;
          var chunksToRequest = [];
          for (var chunk in chunksNeeded) {
            chunk = chunk | 0;
            if (!(chunk in this.requestsByChunk)) {
              this.requestsByChunk[chunk] = [];
              chunksToRequest.push(chunk);
            }
            this.requestsByChunk[chunk].push(requestId);
          }
          if (!chunksToRequest.length) {
            return capability.promise;
          }
          var groupedChunksToRequest = this.groupChunks(chunksToRequest);
          for (i = 0; i < groupedChunksToRequest.length; ++i) {
            var groupedChunk = groupedChunksToRequest[i];
            var begin = groupedChunk.beginChunk * this.chunkSize;
            var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
            this.sendRequest(begin, end);
          }
          return capability.promise;
        },
        getStream: function ChunkedStreamManager_getStream() {
          return this.stream;
        },
        requestRange: function ChunkedStreamManager_requestRange(begin, end) {
          end = Math.min(end, this.length);
          var beginChunk = this.getBeginChunk(begin);
          var endChunk = this.getEndChunk(end);
          var chunks = [];
          for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
            chunks.push(chunk);
          }
          return this._requestChunks(chunks);
        },
        requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
          ranges = ranges || [];
          var chunksToRequest = [];
          for (var i = 0; i < ranges.length; i++) {
            var beginChunk = this.getBeginChunk(ranges[i].begin);
            var endChunk = this.getEndChunk(ranges[i].end);
            for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
              if (!chunksToRequest.includes(chunk)) {
                chunksToRequest.push(chunk);
              }
            }
          }
          chunksToRequest.sort(function (a, b) {
            return a - b;
          });
          return this._requestChunks(chunksToRequest);
        },
        groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
          var groupedChunks = [];
          var beginChunk = -1;
          var prevChunk = -1;
          for (var i = 0; i < chunks.length; ++i) {
            var chunk = chunks[i];
            if (beginChunk < 0) {
              beginChunk = chunk;
            }
            if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
              groupedChunks.push({
                beginChunk: beginChunk,
                endChunk: prevChunk + 1
              });
              beginChunk = chunk;
            }
            if (i + 1 === chunks.length) {
              groupedChunks.push({
                beginChunk: beginChunk,
                endChunk: chunk + 1
              });
            }
            prevChunk = chunk;
          }
          return groupedChunks;
        },
        onProgress: function ChunkedStreamManager_onProgress(args) {
          var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
          this.msgHandler.send('DocProgress', {
            loaded: bytesLoaded,
            total: this.length
          });
        },
        onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
          var chunk = args.chunk;
          var isProgressive = args.begin === undefined;
          var begin = isProgressive ? this.progressiveDataLength : args.begin;
          var end = begin + chunk.byteLength;
          var beginChunk = Math.floor(begin / this.chunkSize);
          var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
          if (isProgressive) {
            this.stream.onReceiveProgressiveData(chunk);
            this.progressiveDataLength = end;
          } else {
            this.stream.onReceiveData(begin, chunk);
          }
          if (this.stream.allChunksLoaded()) {
            this._loadedStreamCapability.resolve(this.stream);
          }
          var loadedRequests = [];
          var i, requestId;
          for (chunk = beginChunk; chunk < endChunk; ++chunk) {
            var requestIds = this.requestsByChunk[chunk] || [];
            delete this.requestsByChunk[chunk];
            for (i = 0; i < requestIds.length; ++i) {
              requestId = requestIds[i];
              var chunksNeeded = this.chunksNeededByRequest[requestId];
              if (chunk in chunksNeeded) {
                delete chunksNeeded[chunk];
              }
              if (!(0, _util.isEmptyObj)(chunksNeeded)) {
                continue;
              }
              loadedRequests.push(requestId);
            }
          }
          if (!this.disableAutoFetch && (0, _util.isEmptyObj)(this.requestsByChunk)) {
            var nextEmptyChunk;
            if (this.stream.numChunksLoaded === 1) {
              var lastChunk = this.stream.numChunks - 1;
              if (!this.stream.hasChunk(lastChunk)) {
                nextEmptyChunk = lastChunk;
              }
            } else {
              nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
            }
            if (Number.isInteger(nextEmptyChunk)) {
              this._requestChunks([nextEmptyChunk]);
            }
          }
          for (i = 0; i < loadedRequests.length; ++i) {
            requestId = loadedRequests[i];
            var capability = this.promisesByRequest[requestId];
            delete this.promisesByRequest[requestId];
            capability.resolve();
          }
          this.msgHandler.send('DocProgress', {
            loaded: this.stream.numChunksLoaded * this.chunkSize,
            total: this.length
          });
        },
        onError: function ChunkedStreamManager_onError(err) {
          this._loadedStreamCapability.reject(err);
        },
        getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
          var chunk = Math.floor(begin / this.chunkSize);
          return chunk;
        },
        getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
          var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
          return chunk;
        },
        abort: function ChunkedStreamManager_abort() {
          this.aborted = true;
          if (this.pdfNetworkStream) {
            this.pdfNetworkStream.cancelAllRequests('abort');
          }
          for (var requestId in this.promisesByRequest) {
            var capability = this.promisesByRequest[requestId];
            capability.reject(new Error('Request was aborted'));
          }
        }
      };
      return ChunkedStreamManager;
    }();
    exports.ChunkedStream = ChunkedStream;
    exports.ChunkedStreamManager = ChunkedStreamManager;
    
    /***/ }),
    /* 136 */
    /***/ (function(module, exports, __w_pdfjs_require__) {
    
    "use strict";
    
    
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.PDFDocument = exports.Page = undefined;
    
    var _slicedToArray = function () { function sliceIterator(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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
    
    var _util = __w_pdfjs_require__(2);
    
    var _obj = __w_pdfjs_require__(137);
    
    var _primitives = __w_pdfjs_require__(138);
    
    var _stream = __w_pdfjs_require__(140);
    
    var _annotation = __w_pdfjs_require__(152);
    
    var _crypto = __w_pdfjs_require__(150);
    
    var _parser = __w_pdfjs_require__(139);
    
    var _operator_list = __w_pdfjs_require__(153);
    
    var _evaluator = __w_pdfjs_require__(154);
    
    var _function = __w_pdfjs_require__(168);
    
    var Page = function PageClosure() {
      var DEFAULT_USER_UNIT = 1.0;
      var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
      function isAnnotationRenderable(annotation, intent) {
        return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
      }
      function Page(_ref) {
        var pdfManager = _ref.pdfManager,
            xref = _ref.xref,
            pageIndex = _ref.pageIndex,
            pageDict = _ref.pageDict,
            ref = _ref.ref,
            fontCache = _ref.fontCache,
            builtInCMapCache = _ref.builtInCMapCache,
            pdfFunctionFactory = _ref.pdfFunctionFactory;
    
        this.pdfManager = pdfManager;
        this.pageIndex = pageIndex;
        this.pageDict = pageDict;
        this.xref = xref;
        this.ref = ref;
        this.fontCache = fontCache;
        this.builtInCMapCache = builtInCMapCache;
        this.pdfFunctionFactory = pdfFunctionFactory;
        this.evaluatorOptions = pdfManager.evaluatorOptions;
        this.resourcesPromise = null;
        var uniquePrefix = 'p' + this.pageIndex + '_';
        var idCounters = { obj: 0 };
        this.idFactory = {
          createObjId: function createObjId() {
            return uniquePrefix + ++idCounters.obj;
          }
        };
      }
      Page.prototype = {
        _getInheritableProperty: function _getInheritableProperty(key) {
          var getArray = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
    
          var value = (0, _util.getInheritableProperty)({
            dict: this.pageDict,
            key: key,
            getArray: getArray,
            stopWhenFound: false
          });
          if (!Array.isArray(value)) {
            return value;
          }
          if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
            return value[0];
          }
          return _primitives.Dict.merge(this.xref, value);
        },
    
        get content() {
          return this.pageDict.get('Contents');
        },
        get resources() {
          return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
        },
        get mediaBox() {
          var mediaBox = this._getInheritableProperty('MediaBox', true);
          if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
            return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
          }
          return (0, _util.shadow)(this, 'mediaBox', mediaBox);
        },
        get cropBox() {
          var cropBox = this._getInheritableProperty('CropBox', true);
          if (!Array.isArray(cropBox) || cropBox.length !== 4) {
            return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
          }
          return (0, _util.shadow)(this, 'cropBox', cropBox);
        },
        get userUnit() {
          var obj = this.pageDict.get('UserUnit');
          if (!(0, _util.isNum)(obj) || obj <= 0) {
            obj = DEFAULT_USER_UNIT;
          }
          return (0, _util.shadow)(this, 'userUnit', obj);
        },
        get view() {
          var mediaBox = this.mediaBox,
              cropBox = this.cropBox;
          if (mediaBox === cropBox) {
            return (0, _util.shadow)(this, 'view', mediaBox);
          }
          var intersection = _util.Util.intersect(cropBox, mediaBox);
          return (0, _util.shadow)(this, 'view', intersection || mediaBox);
        },
        get rotate() {
          var rotate = this._getInheritableProperty('Rotate') || 0;
          if (rotate % 90 !== 0) {
            rotate = 0;
          } else if (rotate >= 360) {
            rotate = rotate % 360;
          } else if (rotate < 0) {
            rotate = (rotate % 360 + 360) % 360;
          }
          return (0, _util.shadow)(this, 'rotate', rotate);
        },
        getContentStream: function Page_getContentStream() {
          var content = this.content;
          var stream;
          if (Array.isArray(content)) {
            var xref = this.xref;
            var i,
                n = content.length;
            var streams = [];
            for (i = 0; i < n; ++i) {
              streams.push(xref.fetchIfRef(content[i]));
            }
            stream = new _stream.StreamsSequenceStream(streams);
          } else if ((0, _primitives.isStream)(content)) {
            stream = content;
          } else {
            stream = new _stream.NullStream();
          }
          return stream;
        },
        loadResources: function Page_loadResources(keys) {
          var _this = this;
    
          if (!this.resourcesPromise) {
            this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
          }
          return this.resourcesPromise.then(function () {
            var objectLoader = new _obj.ObjectLoader(_this.resources, keys, _this.xref);
            return objectLoader.load();
          });
        },
        getOperatorList: function getOperatorList(_ref2) {
          var _this2 = this;
    
          var handler = _ref2.handler,
              task = _ref2.task,
              intent = _ref2.intent,
              renderInteractiveForms = _ref2.renderInteractiveForms;
    
          var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
          var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
          var partialEvaluator = new _evaluator.PartialEvaluator({
            pdfManager: this.pdfManager,
            xref: this.xref,
            handler: handler,
            pageIndex: this.pageIndex,
            idFactory: this.idFactory,
            fontCache: this.fontCache,
            builtInCMapCache: this.builtInCMapCache,
            options: this.evaluatorOptions,
            pdfFunctionFactory: this.pdfFunctionFactory
          });
          var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
          var pageListPromise = dataPromises.then(function (_ref3) {
            var _ref4 = _slicedToArray(_ref3, 1),
                contentStream = _ref4[0];
    
            var opList = new _operator_list.OperatorList(intent, handler, _this2.pageIndex);
            handler.send('StartRenderPage', {
              transparency: partialEvaluator.hasBlendModes(_this2.resources),
              pageIndex: _this2.pageIndex,
              intent: intent
            });
            return partialEvaluator.getOperatorList({
              stream: contentStream,
              task: task,
              resources: _this2.resources,
              operatorList: opList
            }).then(function () {
              return opList;
            });
          });
          return Promise.all([pageListPromise, this._parsedAnnotations]).then(function (_ref5) {
            var _ref6 = _slicedToArray(_ref5, 2),
                pageOpList = _ref6[0],
                annotations = _ref6[1];
    
            if (annotations.length === 0) {
              pageOpList.flush(true);
              return pageOpList;
            }
            var i,
                ii,
                opListPromises = [];
            for (i = 0, ii = annotations.length; i < ii; i++) {
              if (isAnnotationRenderable(annotations[i], intent)) {
                opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
              }
            }
            return Promise.all(opListPromises).then(function (opLists) {
              pageOpList.addOp(_util.OPS.beginAnnotations, []);
              for (i = 0, ii = opLists.length; i < ii; i++) {
                pageOpList.addOpList(opLists[i]);
              }
              pageOpList.addOp(_util.OPS.endAnnotations, []);
              pageOpList.flush(true);
              return pageOpList;
            });
          });
        },
        extractTextContent: function extractTextContent(_ref7) {
          var _this3 = this;
    
          var handler = _ref7.handler,
              task = _ref7.task,
              normalizeWhitespace = _ref7.normalizeWhitespace,
              sink = _ref7.sink,
              combineTextItems = _ref7.combineTextItems;
    
          var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
          var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
          var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
          return dataPromises.then(function (_ref8) {
            var _ref9 = _slicedToArray(_ref8, 1),
                contentStream = _ref9[0];
    
            var partialEvaluator = new _evaluator.PartialEvaluator({
              pdfManager: _this3.pdfManager,
              xref: _this3.xref,
              handler: handler,
              pageIndex: _this3.pageIndex,
              idFactory: _this3.idFactory,
              fontCache: _this3.fontCache,
              builtInCMapCache: _this3.builtInCMapCache,
              options: _this3.evaluatorOptions,
              pdfFunctionFactory: _this3.pdfFunctionFactory
            });
            return partialEvaluator.getTextContent({
              stream: contentStream,
              task: task,
              resources: _this3.resources,
              normalizeWhitespace: normalizeWhitespace,
              combineTextItems: combineTextItems,
              sink: sink
            });
          });
        },
        getAnnotationsData: function getAnnotationsData(intent) {
          return this._parsedAnnotations.then(function (annotations) {
            var annotationsData = [];
            for (var i = 0, ii = annotations.length; i < ii; i++) {
              if (!intent || isAnnotationRenderable(annotations[i], intent)) {
                annotationsData.push(annotations[i].data);
              }
            }
            return annotationsData;
          });
        },
    
        get annotations() {
          return (0, _util.shadow)(this, 'annotations', this._getInheritableProperty('Annots') || []);
        },
        get _parsedAnnotations() {
          var _this4 = this;
    
          var parsedAnnotations = this.pdfManager.ensure(this, 'annotations').then(function () {
            var annotationRefs = _this4.annotations;
            var annotationPromises = [];
            for (var i = 0, ii = annotationRefs.length; i < ii; i++) {
              annotationPromises.push(_annotation.AnnotationFactory.create(_this4.xref, annotationRefs[i], _this4.pdfManager, _this4.idFactory));
            }
            return Promise.all(annotationPromises).then(function (annotations) {
              return annotations.filter(function isDefined(annotation) {
                return !!annotation;
              });
            }, function (reason) {
              (0, _util.warn)('_parsedAnnotations: "' + reason + '".');
              return [];
            });