From e7b5324b76f2cc7fe913298cde784ce6ae3d4671 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Tue, 1 Aug 2017 09:31:43 -0500 Subject: include cropper jQuery plugin as an npm module --- vendor/assets/javascripts/cropper.js | 2993 ---------------------------------- 1 file changed, 2993 deletions(-) delete mode 100644 vendor/assets/javascripts/cropper.js (limited to 'vendor') diff --git a/vendor/assets/javascripts/cropper.js b/vendor/assets/javascripts/cropper.js deleted file mode 100644 index 805485904a5..00000000000 --- a/vendor/assets/javascripts/cropper.js +++ /dev/null @@ -1,2993 +0,0 @@ -/*! - * Cropper v2.3.0 - * https://github.com/fengyuanchen/cropper - * - * Copyright (c) 2014-2016 Fengyuan Chen and contributors - * Released under the MIT license - * - * Date: 2016-02-22T02:13:13.332Z - */ - -(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. - define(['jquery'], factory); - } else if (typeof exports === 'object') { - // Node / CommonJS - factory(require('jquery')); - } else { - // Browser globals. - factory(jQuery); - } -})(function ($) { - - 'use strict'; - - // Globals - var $window = $(window); - var $document = $(document); - var location = window.location; - var navigator = window.navigator; - var ArrayBuffer = window.ArrayBuffer; - var Uint8Array = window.Uint8Array; - var DataView = window.DataView; - var btoa = window.btoa; - - // Constants - var NAMESPACE = 'cropper'; - - // Classes - var CLASS_MODAL = 'cropper-modal'; - var CLASS_HIDE = 'cropper-hide'; - var CLASS_HIDDEN = 'cropper-hidden'; - var CLASS_INVISIBLE = 'cropper-invisible'; - var CLASS_MOVE = 'cropper-move'; - var CLASS_CROP = 'cropper-crop'; - var CLASS_DISABLED = 'cropper-disabled'; - var CLASS_BG = 'cropper-bg'; - - // Events - var EVENT_MOUSE_DOWN = 'mousedown touchstart pointerdown MSPointerDown'; - var EVENT_MOUSE_MOVE = 'mousemove touchmove pointermove MSPointerMove'; - var EVENT_MOUSE_UP = 'mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel'; - var EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll'; - var EVENT_DBLCLICK = 'dblclick'; - var EVENT_LOAD = 'load.' + NAMESPACE; - var EVENT_ERROR = 'error.' + NAMESPACE; - var EVENT_RESIZE = 'resize.' + NAMESPACE; // Bind to window with namespace - var EVENT_BUILD = 'build.' + NAMESPACE; - var EVENT_BUILT = 'built.' + NAMESPACE; - var EVENT_CROP_START = 'cropstart.' + NAMESPACE; - var EVENT_CROP_MOVE = 'cropmove.' + NAMESPACE; - var EVENT_CROP_END = 'cropend.' + NAMESPACE; - var EVENT_CROP = 'crop.' + NAMESPACE; - var EVENT_ZOOM = 'zoom.' + NAMESPACE; - - // RegExps - var REGEXP_ACTIONS = /e|w|s|n|se|sw|ne|nw|all|crop|move|zoom/; - var REGEXP_DATA_URL = /^data\:/; - var REGEXP_DATA_URL_HEAD = /^data\:([^\;]+)\;base64,/; - var REGEXP_DATA_URL_JPEG = /^data\:image\/jpeg.*;base64,/; - - // Data keys - var DATA_PREVIEW = 'preview'; - var DATA_ACTION = 'action'; - - // Actions - var ACTION_EAST = 'e'; - var ACTION_WEST = 'w'; - var ACTION_SOUTH = 's'; - var ACTION_NORTH = 'n'; - var ACTION_SOUTH_EAST = 'se'; - var ACTION_SOUTH_WEST = 'sw'; - var ACTION_NORTH_EAST = 'ne'; - var ACTION_NORTH_WEST = 'nw'; - var ACTION_ALL = 'all'; - var ACTION_CROP = 'crop'; - var ACTION_MOVE = 'move'; - var ACTION_ZOOM = 'zoom'; - var ACTION_NONE = 'none'; - - // Supports - var SUPPORT_CANVAS = $.isFunction($('')[0].getContext); - var IS_SAFARI = navigator && /safari/i.test(navigator.userAgent) && /apple computer/i.test(navigator.vendor); - - // Maths - var num = Number; - var min = Math.min; - var max = Math.max; - var abs = Math.abs; - var sin = Math.sin; - var cos = Math.cos; - var sqrt = Math.sqrt; - var round = Math.round; - var floor = Math.floor; - - // Utilities - var fromCharCode = String.fromCharCode; - - function isNumber(n) { - return typeof n === 'number' && !isNaN(n); - } - - function isUndefined(n) { - return typeof n === 'undefined'; - } - - function toArray(obj, offset) { - var args = []; - - // This is necessary for IE8 - if (isNumber(offset)) { - args.push(offset); - } - - return args.slice.apply(obj, args); - } - - // Custom proxy to avoid jQuery's guid - function proxy(fn, context) { - var args = toArray(arguments, 2); - - return function () { - return fn.apply(context, args.concat(toArray(arguments))); - }; - } - - function isCrossOriginURL(url) { - var parts = url.match(/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i); - - return parts && ( - parts[1] !== location.protocol || - parts[2] !== location.hostname || - parts[3] !== location.port - ); - } - - function addTimestamp(url) { - var timestamp = 'timestamp=' + (new Date()).getTime(); - - return (url + (url.indexOf('?') === -1 ? '?' : '&') + timestamp); - } - - function getCrossOrigin(crossOrigin) { - return crossOrigin ? ' crossOrigin="' + crossOrigin + '"' : ''; - } - - function getImageSize(image, callback) { - var newImage; - - // Modern browsers (ignore Safari, #120 & #509) - if (image.naturalWidth && !IS_SAFARI) { - return callback(image.naturalWidth, image.naturalHeight); - } - - // IE8: Don't use `new Image()` here (#319) - newImage = document.createElement('img'); - - newImage.onload = function () { - callback(this.width, this.height); - }; - - newImage.src = image.src; - } - - function getTransform(options) { - var transforms = []; - var rotate = options.rotate; - var scaleX = options.scaleX; - var scaleY = options.scaleY; - - if (isNumber(rotate)) { - transforms.push('rotate(' + rotate + 'deg)'); - } - - if (isNumber(scaleX) && isNumber(scaleY)) { - transforms.push('scale(' + scaleX + ',' + scaleY + ')'); - } - - return transforms.length ? transforms.join(' ') : 'none'; - } - - function getRotatedSizes(data, isReversed) { - var deg = abs(data.degree) % 180; - var arc = (deg > 90 ? (180 - deg) : deg) * Math.PI / 180; - var sinArc = sin(arc); - var cosArc = cos(arc); - var width = data.width; - var height = data.height; - var aspectRatio = data.aspectRatio; - var newWidth; - var newHeight; - - if (!isReversed) { - newWidth = width * cosArc + height * sinArc; - newHeight = width * sinArc + height * cosArc; - } else { - newWidth = width / (cosArc + sinArc / aspectRatio); - newHeight = newWidth / aspectRatio; - } - - return { - width: newWidth, - height: newHeight - }; - } - - function getSourceCanvas(image, data) { - var canvas = $('')[0]; - var context = canvas.getContext('2d'); - var dstX = 0; - var dstY = 0; - var dstWidth = data.naturalWidth; - var dstHeight = data.naturalHeight; - var rotate = data.rotate; - var scaleX = data.scaleX; - var scaleY = data.scaleY; - var scalable = isNumber(scaleX) && isNumber(scaleY) && (scaleX !== 1 || scaleY !== 1); - var rotatable = isNumber(rotate) && rotate !== 0; - var advanced = rotatable || scalable; - var canvasWidth = dstWidth * abs(scaleX || 1); - var canvasHeight = dstHeight * abs(scaleY || 1); - var translateX; - var translateY; - var rotated; - - if (scalable) { - translateX = canvasWidth / 2; - translateY = canvasHeight / 2; - } - - if (rotatable) { - rotated = getRotatedSizes({ - width: canvasWidth, - height: canvasHeight, - degree: rotate - }); - - canvasWidth = rotated.width; - canvasHeight = rotated.height; - translateX = canvasWidth / 2; - translateY = canvasHeight / 2; - } - - canvas.width = canvasWidth; - canvas.height = canvasHeight; - - if (advanced) { - dstX = -dstWidth / 2; - dstY = -dstHeight / 2; - - context.save(); - context.translate(translateX, translateY); - } - - if (rotatable) { - context.rotate(rotate * Math.PI / 180); - } - - // Should call `scale` after rotated - if (scalable) { - context.scale(scaleX, scaleY); - } - - context.drawImage(image, floor(dstX), floor(dstY), floor(dstWidth), floor(dstHeight)); - - if (advanced) { - context.restore(); - } - - return canvas; - } - - function getTouchesCenter(touches) { - var length = touches.length; - var pageX = 0; - var pageY = 0; - - if (length) { - $.each(touches, function (i, touch) { - pageX += touch.pageX; - pageY += touch.pageY; - }); - - pageX /= length; - pageY /= length; - } - - return { - pageX: pageX, - pageY: pageY - }; - } - - function getStringFromCharCode(dataView, start, length) { - var str = ''; - var i; - - for (i = start, length += start; i < length; i++) { - str += fromCharCode(dataView.getUint8(i)); - } - - return str; - } - - function getOrientation(arrayBuffer) { - var dataView = new DataView(arrayBuffer); - var length = dataView.byteLength; - var orientation; - var exifIDCode; - var tiffOffset; - var firstIFDOffset; - var littleEndian; - var endianness; - var app1Start; - var ifdStart; - var offset; - var i; - - // Only handle JPEG image (start by 0xFFD8) - if (dataView.getUint8(0) === 0xFF && dataView.getUint8(1) === 0xD8) { - offset = 2; - - while (offset < length) { - if (dataView.getUint8(offset) === 0xFF && dataView.getUint8(offset + 1) === 0xE1) { - app1Start = offset; - break; - } - - offset++; - } - } - - if (app1Start) { - exifIDCode = app1Start + 4; - tiffOffset = app1Start + 10; - - if (getStringFromCharCode(dataView, exifIDCode, 4) === 'Exif') { - endianness = dataView.getUint16(tiffOffset); - littleEndian = endianness === 0x4949; - - if (littleEndian || endianness === 0x4D4D /* bigEndian */) { - if (dataView.getUint16(tiffOffset + 2, littleEndian) === 0x002A) { - firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian); - - if (firstIFDOffset >= 0x00000008) { - ifdStart = tiffOffset + firstIFDOffset; - } - } - } - } - } - - if (ifdStart) { - length = dataView.getUint16(ifdStart, littleEndian); - - for (i = 0; i < length; i++) { - offset = ifdStart + i * 12 + 2; - - if (dataView.getUint16(offset, littleEndian) === 0x0112 /* Orientation */) { - - // 8 is the offset of the current tag's value - offset += 8; - - // Get the original orientation value - orientation = dataView.getUint16(offset, littleEndian); - - // Override the orientation with its default value for Safari (#120) - if (IS_SAFARI) { - dataView.setUint16(offset, 1, littleEndian); - } - - break; - } - } - } - - return orientation; - } - - function dataURLToArrayBuffer(dataURL) { - var base64 = dataURL.replace(REGEXP_DATA_URL_HEAD, ''); - var binary = atob(base64); - var length = binary.length; - var arrayBuffer = new ArrayBuffer(length); - var dataView = new Uint8Array(arrayBuffer); - var i; - - for (i = 0; i < length; i++) { - dataView[i] = binary.charCodeAt(i); - } - - return arrayBuffer; - } - - // Only available for JPEG image - function arrayBufferToDataURL(arrayBuffer) { - var dataView = new Uint8Array(arrayBuffer); - var length = dataView.length; - var base64 = ''; - var i; - - for (i = 0; i < length; i++) { - base64 += fromCharCode(dataView[i]); - } - - return 'data:image/jpeg;base64,' + btoa(base64); - } - - function Cropper(element, options) { - this.$element = $(element); - this.options = $.extend({}, Cropper.DEFAULTS, $.isPlainObject(options) && options); - this.isLoaded = false; - this.isBuilt = false; - this.isCompleted = false; - this.isRotated = false; - this.isCropped = false; - this.isDisabled = false; - this.isReplaced = false; - this.isLimited = false; - this.wheeling = false; - this.isImg = false; - this.originalUrl = ''; - this.canvas = null; - this.cropBox = null; - this.init(); - } - - Cropper.prototype = { - constructor: Cropper, - - init: function () { - var $this = this.$element; - var url; - - if ($this.is('img')) { - this.isImg = true; - - // Should use `$.fn.attr` here. e.g.: "img/picture.jpg" - this.originalUrl = url = $this.attr('src'); - - // Stop when it's a blank image - if (!url) { - return; - } - - // Should use `$.fn.prop` here. e.g.: "http://example.com/img/picture.jpg" - url = $this.prop('src'); - } else if ($this.is('canvas') && SUPPORT_CANVAS) { - url = $this[0].toDataURL(); - } - - this.load(url); - }, - - // A shortcut for triggering custom events - trigger: function (type, data) { - var e = $.Event(type, data); - - this.$element.trigger(e); - - return e; - }, - - load: function (url) { - var options = this.options; - var $this = this.$element; - var read; - var xhr; - - if (!url) { - return; - } - - // Trigger build event first - $this.one(EVENT_BUILD, options.build); - - if (this.trigger(EVENT_BUILD).isDefaultPrevented()) { - return; - } - - this.url = url; - this.image = {}; - - if (!options.checkOrientation || !ArrayBuffer) { - return this.clone(); - } - - read = $.proxy(this.read, this); - - // XMLHttpRequest disallows to open a Data URL in some browsers like IE11 and Safari - if (REGEXP_DATA_URL.test(url)) { - return REGEXP_DATA_URL_JPEG.test(url) ? - read(dataURLToArrayBuffer(url)) : - this.clone(); - } - - xhr = new XMLHttpRequest(); - - xhr.onerror = xhr.onabort = $.proxy(function () { - this.clone(); - }, this); - - xhr.onload = function () { - read(this.response); - }; - - xhr.open('get', url); - xhr.responseType = 'arraybuffer'; - xhr.send(); - }, - - read: function (arrayBuffer) { - var options = this.options; - var orientation = getOrientation(arrayBuffer); - var image = this.image; - var rotate; - var scaleX; - var scaleY; - - if (orientation > 1) { - this.url = arrayBufferToDataURL(arrayBuffer); - - switch (orientation) { - - // flip horizontal - case 2: - scaleX = -1; - break; - - // rotate left 180° - case 3: - rotate = -180; - break; - - // flip vertical - case 4: - scaleY = -1; - break; - - // flip vertical + rotate right 90° - case 5: - rotate = 90; - scaleY = -1; - break; - - // rotate right 90° - case 6: - rotate = 90; - break; - - // flip horizontal + rotate right 90° - case 7: - rotate = 90; - scaleX = -1; - break; - - // rotate left 90° - case 8: - rotate = -90; - break; - } - } - - if (options.rotatable) { - image.rotate = rotate; - } - - if (options.scalable) { - image.scaleX = scaleX; - image.scaleY = scaleY; - } - - this.clone(); - }, - - clone: function () { - var options = this.options; - var $this = this.$element; - var url = this.url; - var crossOrigin = ''; - var crossOriginUrl; - var $clone; - - if (options.checkCrossOrigin && isCrossOriginURL(url)) { - crossOrigin = $this.prop('crossOrigin'); - - if (crossOrigin) { - crossOriginUrl = url; - } else { - crossOrigin = 'anonymous'; - - // Bust cache (#148) when there is not a "crossOrigin" property - crossOriginUrl = addTimestamp(url); - } - } - - this.crossOrigin = crossOrigin; - this.crossOriginUrl = crossOriginUrl; - this.$clone = $clone = $(''); - - if (this.isImg) { - if ($this[0].complete) { - this.start(); - } else { - $this.one(EVENT_LOAD, $.proxy(this.start, this)); - } - } else { - $clone. - one(EVENT_LOAD, $.proxy(this.start, this)). - one(EVENT_ERROR, $.proxy(this.stop, this)). - addClass(CLASS_HIDE). - insertAfter($this); - } - }, - - start: function () { - var $image = this.$element; - var $clone = this.$clone; - - if (!this.isImg) { - $clone.off(EVENT_ERROR, this.stop); - $image = $clone; - } - - getImageSize($image[0], $.proxy(function (naturalWidth, naturalHeight) { - $.extend(this.image, { - naturalWidth: naturalWidth, - naturalHeight: naturalHeight, - aspectRatio: naturalWidth / naturalHeight - }); - - this.isLoaded = true; - this.build(); - }, this)); - }, - - stop: function () { - this.$clone.remove(); - this.$clone = null; - }, - - build: function () { - var options = this.options; - var $this = this.$element; - var $clone = this.$clone; - var $cropper; - var $cropBox; - var $face; - - if (!this.isLoaded) { - return; - } - - // Unbuild first when replace - if (this.isBuilt) { - this.unbuild(); - } - - // Create cropper elements - this.$container = $this.parent(); - this.$cropper = $cropper = $(Cropper.TEMPLATE); - this.$canvas = $cropper.find('.cropper-canvas').append($clone); - this.$dragBox = $cropper.find('.cropper-drag-box'); - this.$cropBox = $cropBox = $cropper.find('.cropper-crop-box'); - this.$viewBox = $cropper.find('.cropper-view-box'); - this.$face = $face = $cropBox.find('.cropper-face'); - - // Hide the original image - $this.addClass(CLASS_HIDDEN).after($cropper); - - // Show the clone image if is hidden - if (!this.isImg) { - $clone.removeClass(CLASS_HIDE); - } - - this.initPreview(); - this.bind(); - - options.aspectRatio = max(0, options.aspectRatio) || NaN; - options.viewMode = max(0, min(3, round(options.viewMode))) || 0; - - if (options.autoCrop) { - this.isCropped = true; - - if (options.modal) { - this.$dragBox.addClass(CLASS_MODAL); - } - } else { - $cropBox.addClass(CLASS_HIDDEN); - } - - if (!options.guides) { - $cropBox.find('.cropper-dashed').addClass(CLASS_HIDDEN); - } - - if (!options.center) { - $cropBox.find('.cropper-center').addClass(CLASS_HIDDEN); - } - - if (options.cropBoxMovable) { - $face.addClass(CLASS_MOVE).data(DATA_ACTION, ACTION_ALL); - } - - if (!options.highlight) { - $face.addClass(CLASS_INVISIBLE); - } - - if (options.background) { - $cropper.addClass(CLASS_BG); - } - - if (!options.cropBoxResizable) { - $cropBox.find('.cropper-line, .cropper-point').addClass(CLASS_HIDDEN); - } - - this.setDragMode(options.dragMode); - this.render(); - this.isBuilt = true; - this.setData(options.data); - $this.one(EVENT_BUILT, options.built); - - // Trigger the built event asynchronously to keep `data('cropper')` is defined - setTimeout($.proxy(function () { - this.trigger(EVENT_BUILT); - this.isCompleted = true; - }, this), 0); - }, - - unbuild: function () { - if (!this.isBuilt) { - return; - } - - this.isBuilt = false; - this.isCompleted = false; - this.initialImage = null; - - // Clear `initialCanvas` is necessary when replace - this.initialCanvas = null; - this.initialCropBox = null; - this.container = null; - this.canvas = null; - - // Clear `cropBox` is necessary when replace - this.cropBox = null; - this.unbind(); - - this.resetPreview(); - this.$preview = null; - - this.$viewBox = null; - this.$cropBox = null; - this.$dragBox = null; - this.$canvas = null; - this.$container = null; - - this.$cropper.remove(); - this.$cropper = null; - }, - - render: function () { - this.initContainer(); - this.initCanvas(); - this.initCropBox(); - - this.renderCanvas(); - - if (this.isCropped) { - this.renderCropBox(); - } - }, - - initContainer: function () { - var options = this.options; - var $this = this.$element; - var $container = this.$container; - var $cropper = this.$cropper; - - $cropper.addClass(CLASS_HIDDEN); - $this.removeClass(CLASS_HIDDEN); - - $cropper.css((this.container = { - width: max($container.width(), num(options.minContainerWidth) || 200), - height: max($container.height(), num(options.minContainerHeight) || 100) - })); - - $this.addClass(CLASS_HIDDEN); - $cropper.removeClass(CLASS_HIDDEN); - }, - - // Canvas (image wrapper) - initCanvas: function () { - var viewMode = this.options.viewMode; - var container = this.container; - var containerWidth = container.width; - var containerHeight = container.height; - var image = this.image; - var imageNaturalWidth = image.naturalWidth; - var imageNaturalHeight = image.naturalHeight; - var is90Degree = abs(image.rotate) === 90; - var naturalWidth = is90Degree ? imageNaturalHeight : imageNaturalWidth; - var naturalHeight = is90Degree ? imageNaturalWidth : imageNaturalHeight; - var aspectRatio = naturalWidth / naturalHeight; - var canvasWidth = containerWidth; - var canvasHeight = containerHeight; - var canvas; - - if (containerHeight * aspectRatio > containerWidth) { - if (viewMode === 3) { - canvasWidth = containerHeight * aspectRatio; - } else { - canvasHeight = containerWidth / aspectRatio; - } - } else { - if (viewMode === 3) { - canvasHeight = containerWidth / aspectRatio; - } else { - canvasWidth = containerHeight * aspectRatio; - } - } - - canvas = { - naturalWidth: naturalWidth, - naturalHeight: naturalHeight, - aspectRatio: aspectRatio, - width: canvasWidth, - height: canvasHeight - }; - - canvas.oldLeft = canvas.left = (containerWidth - canvasWidth) / 2; - canvas.oldTop = canvas.top = (containerHeight - canvasHeight) / 2; - - this.canvas = canvas; - this.isLimited = (viewMode === 1 || viewMode === 2); - this.limitCanvas(true, true); - this.initialImage = $.extend({}, image); - this.initialCanvas = $.extend({}, canvas); - }, - - limitCanvas: function (isSizeLimited, isPositionLimited) { - var options = this.options; - var viewMode = options.viewMode; - var container = this.container; - var containerWidth = container.width; - var containerHeight = container.height; - var canvas = this.canvas; - var aspectRatio = canvas.aspectRatio; - var cropBox = this.cropBox; - var isCropped = this.isCropped && cropBox; - var minCanvasWidth; - var minCanvasHeight; - var newCanvasLeft; - var newCanvasTop; - - if (isSizeLimited) { - minCanvasWidth = num(options.minCanvasWidth) || 0; - minCanvasHeight = num(options.minCanvasHeight) || 0; - - if (viewMode) { - if (viewMode > 1) { - minCanvasWidth = max(minCanvasWidth, containerWidth); - minCanvasHeight = max(minCanvasHeight, containerHeight); - - if (viewMode === 3) { - if (minCanvasHeight * aspectRatio > minCanvasWidth) { - minCanvasWidth = minCanvasHeight * aspectRatio; - } else { - minCanvasHeight = minCanvasWidth / aspectRatio; - } - } - } else { - if (minCanvasWidth) { - minCanvasWidth = max(minCanvasWidth, isCropped ? cropBox.width : 0); - } else if (minCanvasHeight) { - minCanvasHeight = max(minCanvasHeight, isCropped ? cropBox.height : 0); - } else if (isCropped) { - minCanvasWidth = cropBox.width; - minCanvasHeight = cropBox.height; - - if (minCanvasHeight * aspectRatio > minCanvasWidth) { - minCanvasWidth = minCanvasHeight * aspectRatio; - } else { - minCanvasHeight = minCanvasWidth / aspectRatio; - } - } - } - } - - if (minCanvasWidth && minCanvasHeight) { - if (minCanvasHeight * aspectRatio > minCanvasWidth) { - minCanvasHeight = minCanvasWidth / aspectRatio; - } else { - minCanvasWidth = minCanvasHeight * aspectRatio; - } - } else if (minCanvasWidth) { - minCanvasHeight = minCanvasWidth / aspectRatio; - } else if (minCanvasHeight) { - minCanvasWidth = minCanvasHeight * aspectRatio; - } - - canvas.minWidth = minCanvasWidth; - canvas.minHeight = minCanvasHeight; - canvas.maxWidth = Infinity; - canvas.maxHeight = Infinity; - } - - if (isPositionLimited) { - if (viewMode) { - newCanvasLeft = containerWidth - canvas.width; - newCanvasTop = containerHeight - canvas.height; - - canvas.minLeft = min(0, newCanvasLeft); - canvas.minTop = min(0, newCanvasTop); - canvas.maxLeft = max(0, newCanvasLeft); - canvas.maxTop = max(0, newCanvasTop); - - if (isCropped && this.isLimited) { - canvas.minLeft = min( - cropBox.left, - cropBox.left + cropBox.width - canvas.width - ); - canvas.minTop = min( - cropBox.top, - cropBox.top + cropBox.height - canvas.height - ); - canvas.maxLeft = cropBox.left; - canvas.maxTop = cropBox.top; - - if (viewMode === 2) { - if (canvas.width >= containerWidth) { - canvas.minLeft = min(0, newCanvasLeft); - canvas.maxLeft = max(0, newCanvasLeft); - } - - if (canvas.height >= containerHeight) { - canvas.minTop = min(0, newCanvasTop); - canvas.maxTop = max(0, newCanvasTop); - } - } - } - } else { - canvas.minLeft = -canvas.width; - canvas.minTop = -canvas.height; - canvas.maxLeft = containerWidth; - canvas.maxTop = containerHeight; - } - } - }, - - renderCanvas: function (isChanged) { - var canvas = this.canvas; - var image = this.image; - var rotate = image.rotate; - var naturalWidth = image.naturalWidth; - var naturalHeight = image.naturalHeight; - var aspectRatio; - var rotated; - - if (this.isRotated) { - this.isRotated = false; - - // Computes rotated sizes with image sizes - rotated = getRotatedSizes({ - width: image.width, - height: image.height, - degree: rotate - }); - - aspectRatio = rotated.width / rotated.height; - - if (aspectRatio !== canvas.aspectRatio) { - canvas.left -= (rotated.width - canvas.width) / 2; - canvas.top -= (rotated.height - canvas.height) / 2; - canvas.width = rotated.width; - canvas.height = rotated.height; - canvas.aspectRatio = aspectRatio; - canvas.naturalWidth = naturalWidth; - canvas.naturalHeight = naturalHeight; - - // Computes rotated sizes with natural image sizes - if (rotate % 180) { - rotated = getRotatedSizes({ - width: naturalWidth, - height: naturalHeight, - degree: rotate - }); - - canvas.naturalWidth = rotated.width; - canvas.naturalHeight = rotated.height; - } - - this.limitCanvas(true, false); - } - } - - if (canvas.width > canvas.maxWidth || canvas.width < canvas.minWidth) { - canvas.left = canvas.oldLeft; - } - - if (canvas.height > canvas.maxHeight || canvas.height < canvas.minHeight) { - canvas.top = canvas.oldTop; - } - - canvas.width = min(max(canvas.width, canvas.minWidth), canvas.maxWidth); - canvas.height = min(max(canvas.height, canvas.minHeight), canvas.maxHeight); - - this.limitCanvas(false, true); - - canvas.oldLeft = canvas.left = min(max(canvas.left, canvas.minLeft), canvas.maxLeft); - canvas.oldTop = canvas.top = min(max(canvas.top, canvas.minTop), canvas.maxTop); - - this.$canvas.css({ - width: canvas.width, - height: canvas.height, - left: canvas.left, - top: canvas.top - }); - - this.renderImage(); - - if (this.isCropped && this.isLimited) { - this.limitCropBox(true, true); - } - - if (isChanged) { - this.output(); - } - }, - - renderImage: function (isChanged) { - var canvas = this.canvas; - var image = this.image; - var reversed; - - if (image.rotate) { - reversed = getRotatedSizes({ - width: canvas.width, - height: canvas.height, - degree: image.rotate, - aspectRatio: image.aspectRatio - }, true); - } - - $.extend(image, reversed ? { - width: reversed.width, - height: reversed.height, - left: (canvas.width - reversed.width) / 2, - top: (canvas.height - reversed.height) / 2 - } : { - width: canvas.width, - height: canvas.height, - left: 0, - top: 0 - }); - - this.$clone.css({ - width: image.width, - height: image.height, - marginLeft: image.left, - marginTop: image.top, - transform: getTransform(image) - }); - - if (isChanged) { - this.output(); - } - }, - - initCropBox: function () { - var options = this.options; - var canvas = this.canvas; - var aspectRatio = options.aspectRatio; - var autoCropArea = num(options.autoCropArea) || 0.8; - var cropBox = { - width: canvas.width, - height: canvas.height - }; - - if (aspectRatio) { - if (canvas.height * aspectRatio > canvas.width) { - cropBox.height = cropBox.width / aspectRatio; - } else { - cropBox.width = cropBox.height * aspectRatio; - } - } - - this.cropBox = cropBox; - this.limitCropBox(true, true); - - // Initialize auto crop area - cropBox.width = min(max(cropBox.width, cropBox.minWidth), cropBox.maxWidth); - cropBox.height = min(max(cropBox.height, cropBox.minHeight), cropBox.maxHeight); - - // The width of auto crop area must large than "minWidth", and the height too. (#164) - cropBox.width = max(cropBox.minWidth, cropBox.width * autoCropArea); - cropBox.height = max(cropBox.minHeight, cropBox.height * autoCropArea); - cropBox.oldLeft = cropBox.left = canvas.left + (canvas.width - cropBox.width) / 2; - cropBox.oldTop = cropBox.top = canvas.top + (canvas.height - cropBox.height) / 2; - - this.initialCropBox = $.extend({}, cropBox); - }, - - limitCropBox: function (isSizeLimited, isPositionLimited) { - var options = this.options; - var aspectRatio = options.aspectRatio; - var container = this.container; - var containerWidth = container.width; - var containerHeight = container.height; - var canvas = this.canvas; - var cropBox = this.cropBox; - var isLimited = this.isLimited; - var minCropBoxWidth; - var minCropBoxHeight; - var maxCropBoxWidth; - var maxCropBoxHeight; - - if (isSizeLimited) { - minCropBoxWidth = num(options.minCropBoxWidth) || 0; - minCropBoxHeight = num(options.minCropBoxHeight) || 0; - - // The min/maxCropBoxWidth/Height must be less than containerWidth/Height - minCropBoxWidth = min(minCropBoxWidth, containerWidth); - minCropBoxHeight = min(minCropBoxHeight, containerHeight); - maxCropBoxWidth = min(containerWidth, isLimited ? canvas.width : containerWidth); - maxCropBoxHeight = min(containerHeight, isLimited ? canvas.height : containerHeight); - - if (aspectRatio) { - if (minCropBoxWidth && minCropBoxHeight) { - if (minCropBoxHeight * aspectRatio > minCropBoxWidth) { - minCropBoxHeight = minCropBoxWidth / aspectRatio; - } else { - minCropBoxWidth = minCropBoxHeight * aspectRatio; - } - } else if (minCropBoxWidth) { - minCropBoxHeight = minCropBoxWidth / aspectRatio; - } else if (minCropBoxHeight) { - minCropBoxWidth = minCropBoxHeight * aspectRatio; - } - - if (maxCropBoxHeight * aspectRatio > maxCropBoxWidth) { - maxCropBoxHeight = maxCropBoxWidth / aspectRatio; - } else { - maxCropBoxWidth = maxCropBoxHeight * aspectRatio; - } - } - - // The minWidth/Height must be less than maxWidth/Height - cropBox.minWidth = min(minCropBoxWidth, maxCropBoxWidth); - cropBox.minHeight = min(minCropBoxHeight, maxCropBoxHeight); - cropBox.maxWidth = maxCropBoxWidth; - cropBox.maxHeight = maxCropBoxHeight; - } - - if (isPositionLimited) { - if (isLimited) { - cropBox.minLeft = max(0, canvas.left); - cropBox.minTop = max(0, canvas.top); - cropBox.maxLeft = min(containerWidth, canvas.left + canvas.width) - cropBox.width; - cropBox.maxTop = min(containerHeight, canvas.top + canvas.height) - cropBox.height; - } else { - cropBox.minLeft = 0; - cropBox.minTop = 0; - cropBox.maxLeft = containerWidth - cropBox.width; - cropBox.maxTop = containerHeight - cropBox.height; - } - } - }, - - renderCropBox: function () { - var options = this.options; - var container = this.container; - var containerWidth = container.width; - var containerHeight = container.height; - var cropBox = this.cropBox; - - if (cropBox.width > cropBox.maxWidth || cropBox.width < cropBox.minWidth) { - cropBox.left = cropBox.oldLeft; - } - - if (cropBox.height > cropBox.maxHeight || cropBox.height < cropBox.minHeight) { - cropBox.top = cropBox.oldTop; - } - - cropBox.width = min(max(cropBox.width, cropBox.minWidth), cropBox.maxWidth); - cropBox.height = min(max(cropBox.height, cropBox.minHeight), cropBox.maxHeight); - - this.limitCropBox(false, true); - - cropBox.oldLeft = cropBox.left = min(max(cropBox.left, cropBox.minLeft), cropBox.maxLeft); - cropBox.oldTop = cropBox.top = min(max(cropBox.top, cropBox.minTop), cropBox.maxTop); - - if (options.movable && options.cropBoxMovable) { - - // Turn to move the canvas when the crop box is equal to the container - this.$face.data(DATA_ACTION, (cropBox.width === containerWidth && cropBox.height === containerHeight) ? ACTION_MOVE : ACTION_ALL); - } - - this.$cropBox.css({ - width: cropBox.width, - height: cropBox.height, - left: cropBox.left, - top: cropBox.top - }); - - if (this.isCropped && this.isLimited) { - this.limitCanvas(true, true); - } - - if (!this.isDisabled) { - this.output(); - } - }, - - output: function () { - this.preview(); - - if (this.isCompleted) { - this.trigger(EVENT_CROP, this.getData()); - } else if (!this.isBuilt) { - - // Only trigger one crop event before complete - this.$element.one(EVENT_BUILT, $.proxy(function () { - this.trigger(EVENT_CROP, this.getData()); - }, this)); - } - }, - - initPreview: function () { - var crossOrigin = getCrossOrigin(this.crossOrigin); - var url = crossOrigin ? this.crossOriginUrl : this.url; - var $clone2; - - this.$preview = $(this.options.preview); - this.$clone2 = $clone2 = $(''); - this.$viewBox.html($clone2); - this.$preview.each(function () { - var $this = $(this); - - // Save the original size for recover - $this.data(DATA_PREVIEW, { - width: $this.width(), - height: $this.height(), - html: $this.html() - }); - - /** - * Override img element styles - * Add `display:block` to avoid margin top issue - * (Occur only when margin-top <= -height) - */ - $this.html( - '' - ); - }); - }, - - resetPreview: function () { - this.$preview.each(function () { - var $this = $(this); - var data = $this.data(DATA_PREVIEW); - - $this.css({ - width: data.width, - height: data.height - }).html(data.html).removeData(DATA_PREVIEW); - }); - }, - - preview: function () { - var image = this.image; - var canvas = this.canvas; - var cropBox = this.cropBox; - var cropBoxWidth = cropBox.width; - var cropBoxHeight = cropBox.height; - var width = image.width; - var height = image.height; - var left = cropBox.left - canvas.left - image.left; - var top = cropBox.top - canvas.top - image.top; - - if (!this.isCropped || this.isDisabled) { - return; - } - - this.$clone2.css({ - width: width, - height: height, - marginLeft: -left, - marginTop: -top, - transform: getTransform(image) - }); - - this.$preview.each(function () { - var $this = $(this); - var data = $this.data(DATA_PREVIEW); - var originalWidth = data.width; - var originalHeight = data.height; - var newWidth = originalWidth; - var newHeight = originalHeight; - var ratio = 1; - - if (cropBoxWidth) { - ratio = originalWidth / cropBoxWidth; - newHeight = cropBoxHeight * ratio; - } - - if (cropBoxHeight && newHeight > originalHeight) { - ratio = originalHeight / cropBoxHeight; - newWidth = cropBoxWidth * ratio; - newHeight = originalHeight; - } - - $this.css({ - width: newWidth, - height: newHeight - }).find('img').css({ - width: width * ratio, - height: height * ratio, - marginLeft: -left * ratio, - marginTop: -top * ratio, - transform: getTransform(image) - }); - }); - }, - - bind: function () { - var options = this.options; - var $this = this.$element; - var $cropper = this.$cropper; - - if ($.isFunction(options.cropstart)) { - $this.on(EVENT_CROP_START, options.cropstart); - } - - if ($.isFunction(options.cropmove)) { - $this.on(EVENT_CROP_MOVE, options.cropmove); - } - - if ($.isFunction(options.cropend)) { - $this.on(EVENT_CROP_END, options.cropend); - } - - if ($.isFunction(options.crop)) { - $this.on(EVENT_CROP, options.crop); - } - - if ($.isFunction(options.zoom)) { - $this.on(EVENT_ZOOM, options.zoom); - } - - $cropper.on(EVENT_MOUSE_DOWN, $.proxy(this.cropStart, this)); - - if (options.zoomable && options.zoomOnWheel) { - $cropper.on(EVENT_WHEEL, $.proxy(this.wheel, this)); - } - - if (options.toggleDragModeOnDblclick) { - $cropper.on(EVENT_DBLCLICK, $.proxy(this.dblclick, this)); - } - - $document. - on(EVENT_MOUSE_MOVE, (this._cropMove = proxy(this.cropMove, this))). - on(EVENT_MOUSE_UP, (this._cropEnd = proxy(this.cropEnd, this))); - - if (options.responsive) { - $window.on(EVENT_RESIZE, (this._resize = proxy(this.resize, this))); - } - }, - - unbind: function () { - var options = this.options; - var $this = this.$element; - var $cropper = this.$cropper; - - if ($.isFunction(options.cropstart)) { - $this.off(EVENT_CROP_START, options.cropstart); - } - - if ($.isFunction(options.cropmove)) { - $this.off(EVENT_CROP_MOVE, options.cropmove); - } - - if ($.isFunction(options.cropend)) { - $this.off(EVENT_CROP_END, options.cropend); - } - - if ($.isFunction(options.crop)) { - $this.off(EVENT_CROP, options.crop); - } - - if ($.isFunction(options.zoom)) { - $this.off(EVENT_ZOOM, options.zoom); - } - - $cropper.off(EVENT_MOUSE_DOWN, this.cropStart); - - if (options.zoomable && options.zoomOnWheel) { - $cropper.off(EVENT_WHEEL, this.wheel); - } - - if (options.toggleDragModeOnDblclick) { - $cropper.off(EVENT_DBLCLICK, this.dblclick); - } - - $document. - off(EVENT_MOUSE_MOVE, this._cropMove). - off(EVENT_MOUSE_UP, this._cropEnd); - - if (options.responsive) { - $window.off(EVENT_RESIZE, this._resize); - } - }, - - resize: function () { - var restore = this.options.restore; - var $container = this.$container; - var container = this.container; - var canvasData; - var cropBoxData; - var ratio; - - // Check `container` is necessary for IE8 - if (this.isDisabled || !container) { - return; - } - - ratio = $container.width() / container.width; - - // Resize when width changed or height changed - if (ratio !== 1 || $container.height() !== container.height) { - if (restore) { - canvasData = this.getCanvasData(); - cropBoxData = this.getCropBoxData(); - } - - this.render(); - - if (restore) { - this.setCanvasData($.each(canvasData, function (i, n) { - canvasData[i] = n * ratio; - })); - this.setCropBoxData($.each(cropBoxData, function (i, n) { - cropBoxData[i] = n * ratio; - })); - } - } - }, - - dblclick: function () { - if (this.isDisabled) { - return; - } - - if (this.$dragBox.hasClass(CLASS_CROP)) { - this.setDragMode(ACTION_MOVE); - } else { - this.setDragMode(ACTION_CROP); - } - }, - - wheel: function (event) { - var e = event.originalEvent || event; - var ratio = num(this.options.wheelZoomRatio) || 0.1; - var delta = 1; - - if (this.isDisabled) { - return; - } - - event.preventDefault(); - - // Limit wheel speed to prevent zoom too fast - if (this.wheeling) { - return; - } - - this.wheeling = true; - - setTimeout($.proxy(function () { - this.wheeling = false; - }, this), 50); - - if (e.deltaY) { - delta = e.deltaY > 0 ? 1 : -1; - } else if (e.wheelDelta) { - delta = -e.wheelDelta / 120; - } else if (e.detail) { - delta = e.detail > 0 ? 1 : -1; - } - - this.zoom(-delta * ratio, event); - }, - - cropStart: function (event) { - var options = this.options; - var originalEvent = event.originalEvent; - var touches = originalEvent && originalEvent.touches; - var e = event; - var touchesLength; - var action; - - if (this.isDisabled) { - return; - } - - if (touches) { - touchesLength = touches.length; - - if (touchesLength > 1) { - if (options.zoomable && options.zoomOnTouch && touchesLength === 2) { - e = touches[1]; - this.startX2 = e.pageX; - this.startY2 = e.pageY; - action = ACTION_ZOOM; - } else { - return; - } - } - - e = touches[0]; - } - - action = action || $(e.target).data(DATA_ACTION); - - if (REGEXP_ACTIONS.test(action)) { - if (this.trigger(EVENT_CROP_START, { - originalEvent: originalEvent, - action: action - }).isDefaultPrevented()) { - return; - } - - event.preventDefault(); - - this.action = action; - this.cropping = false; - - // IE8 has `event.pageX/Y`, but not `event.originalEvent.pageX/Y` - // IE10 has `event.originalEvent.pageX/Y`, but not `event.pageX/Y` - this.startX = e.pageX || originalEvent && originalEvent.pageX; - this.startY = e.pageY || originalEvent && originalEvent.pageY; - - if (action === ACTION_CROP) { - this.cropping = true; - this.$dragBox.addClass(CLASS_MODAL); - } - } - }, - - cropMove: function (event) { - var options = this.options; - var originalEvent = event.originalEvent; - var touches = originalEvent && originalEvent.touches; - var e = event; - var action = this.action; - var touchesLength; - - if (this.isDisabled) { - return; - } - - if (touches) { - touchesLength = touches.length; - - if (touchesLength > 1) { - if (options.zoomable && options.zoomOnTouch && touchesLength === 2) { - e = touches[1]; - this.endX2 = e.pageX; - this.endY2 = e.pageY; - } else { - return; - } - } - - e = touches[0]; - } - - if (action) { - if (this.trigger(EVENT_CROP_MOVE, { - originalEvent: originalEvent, - action: action - }).isDefaultPrevented()) { - return; - } - - event.preventDefault(); - - this.endX = e.pageX || originalEvent && originalEvent.pageX; - this.endY = e.pageY || originalEvent && originalEvent.pageY; - - this.change(e.shiftKey, action === ACTION_ZOOM ? event : null); - } - }, - - cropEnd: function (event) { - var originalEvent = event.originalEvent; - var action = this.action; - - if (this.isDisabled) { - return; - } - - if (action) { - event.preventDefault(); - - if (this.cropping) { - this.cropping = false; - this.$dragBox.toggleClass(CLASS_MODAL, this.isCropped && this.options.modal); - } - - this.action = ''; - - this.trigger(EVENT_CROP_END, { - originalEvent: originalEvent, - action: action - }); - } - }, - - change: function (shiftKey, event) { - var options = this.options; - var aspectRatio = options.aspectRatio; - var action = this.action; - var container = this.container; - var canvas = this.canvas; - var cropBox = this.cropBox; - var width = cropBox.width; - var height = cropBox.height; - var left = cropBox.left; - var top = cropBox.top; - var right = left + width; - var bottom = top + height; - var minLeft = 0; - var minTop = 0; - var maxWidth = container.width; - var maxHeight = container.height; - var renderable = true; - var offset; - var range; - - // Locking aspect ratio in "free mode" by holding shift key (#259) - if (!aspectRatio && shiftKey) { - aspectRatio = width && height ? width / height : 1; - } - - if (this.limited) { - minLeft = cropBox.minLeft; - minTop = cropBox.minTop; - maxWidth = minLeft + min(container.width, canvas.left + canvas.width); - maxHeight = minTop + min(container.height, canvas.top + canvas.height); - } - - range = { - x: this.endX - this.startX, - y: this.endY - this.startY - }; - - if (aspectRatio) { - range.X = range.y * aspectRatio; - range.Y = range.x / aspectRatio; - } - - switch (action) { - // Move crop box - case ACTION_ALL: - left += range.x; - top += range.y; - break; - - // Resize crop box - case ACTION_EAST: - if (range.x >= 0 && (right >= maxWidth || aspectRatio && - (top <= minTop || bottom >= maxHeight))) { - - renderable = false; - break; - } - - width += range.x; - - if (aspectRatio) { - height = width / aspectRatio; - top -= range.Y / 2; - } - - if (width < 0) { - action = ACTION_WEST; - width = 0; - } - - break; - - case ACTION_NORTH: - if (range.y <= 0 && (top <= minTop || aspectRatio && - (left <= minLeft || right >= maxWidth))) { - - renderable = false; - break; - } - - height -= range.y; - top += range.y; - - if (aspectRatio) { - width = height * aspectRatio; - left += range.X / 2; - } - - if (height < 0) { - action = ACTION_SOUTH; - height = 0; - } - - break; - - case ACTION_WEST: - if (range.x <= 0 && (left <= minLeft || aspectRatio && - (top <= minTop || bottom >= maxHeight))) { - - renderable = false; - break; - } - - width -= range.x; - left += range.x; - - if (aspectRatio) { - height = width / aspectRatio; - top += range.Y / 2; - } - - if (width < 0) { - action = ACTION_EAST; - width = 0; - } - - break; - - case ACTION_SOUTH: - if (range.y >= 0 && (bottom >= maxHeight || aspectRatio && - (left <= minLeft || right >= maxWidth))) { - - renderable = false; - break; - } - - height += range.y; - - if (aspectRatio) { - width = height * aspectRatio; - left -= range.X / 2; - } - - if (height < 0) { - action = ACTION_NORTH; - height = 0; - } - - break; - - case ACTION_NORTH_EAST: - if (aspectRatio) { - if (range.y <= 0 && (top <= minTop || right >= maxWidth)) { - renderable = false; - break; - } - - height -= range.y; - top += range.y; - width = height * aspectRatio; - } else { - if (range.x >= 0) { - if (right < maxWidth) { - width += range.x; - } else if (range.y <= 0 && top <= minTop) { - renderable = false; - } - } else { - width += range.x; - } - - if (range.y <= 0) { - if (top > minTop) { - height -= range.y; - top += range.y; - } - } else { - height -= range.y; - top += range.y; - } - } - - if (width < 0 && height < 0) { - action = ACTION_SOUTH_WEST; - height = 0; - width = 0; - } else if (width < 0) { - action = ACTION_NORTH_WEST; - width = 0; - } else if (height < 0) { - action = ACTION_SOUTH_EAST; - height = 0; - } - - break; - - case ACTION_NORTH_WEST: - if (aspectRatio) { - if (range.y <= 0 && (top <= minTop || left <= minLeft)) { - renderable = false; - break; - } - - height -= range.y; - top += range.y; - width = height * aspectRatio; - left += range.X; - } else { - if (range.x <= 0) { - if (left > minLeft) { - width -= range.x; - left += range.x; - } else if (range.y <= 0 && top <= minTop) { - renderable = false; - } - } else { - width -= range.x; - left += range.x; - } - - if (range.y <= 0) { - if (top > minTop) { - height -= range.y; - top += range.y; - } - } else { - height -= range.y; - top += range.y; - } - } - - if (width < 0 && height < 0) { - action = ACTION_SOUTH_EAST; - height = 0; - width = 0; - } else if (width < 0) { - action = ACTION_NORTH_EAST; - width = 0; - } else if (height < 0) { - action = ACTION_SOUTH_WEST; - height = 0; - } - - break; - - case ACTION_SOUTH_WEST: - if (aspectRatio) { - if (range.x <= 0 && (left <= minLeft || bottom >= maxHeight)) { - renderable = false; - break; - } - - width -= range.x; - left += range.x; - height = width / aspectRatio; - } else { - if (range.x <= 0) { - if (left > minLeft) { - width -= range.x; - left += range.x; - } else if (range.y >= 0 && bottom >= maxHeight) { - renderable = false; - } - } else { - width -= range.x; - left += range.x; - } - - if (range.y >= 0) { - if (bottom < maxHeight) { - height += range.y; - } - } else { - height += range.y; - } - } - - if (width < 0 && height < 0) { - action = ACTION_NORTH_EAST; - height = 0; - width = 0; - } else if (width < 0) { - action = ACTION_SOUTH_EAST; - width = 0; - } else if (height < 0) { - action = ACTION_NORTH_WEST; - height = 0; - } - - break; - - case ACTION_SOUTH_EAST: - if (aspectRatio) { - if (range.x >= 0 && (right >= maxWidth || bottom >= maxHeight)) { - renderable = false; - break; - } - - width += range.x; - height = width / aspectRatio; - } else { - if (range.x >= 0) { - if (right < maxWidth) { - width += range.x; - } else if (range.y >= 0 && bottom >= maxHeight) { - renderable = false; - } - } else { - width += range.x; - } - - if (range.y >= 0) { - if (bottom < maxHeight) { - height += range.y; - } - } else { - height += range.y; - } - } - - if (width < 0 && height < 0) { - action = ACTION_NORTH_WEST; - height = 0; - width = 0; - } else if (width < 0) { - action = ACTION_SOUTH_WEST; - width = 0; - } else if (height < 0) { - action = ACTION_NORTH_EAST; - height = 0; - } - - break; - - // Move canvas - case ACTION_MOVE: - this.move(range.x, range.y); - renderable = false; - break; - - // Zoom canvas - case ACTION_ZOOM: - this.zoom((function (x1, y1, x2, y2) { - var z1 = sqrt(x1 * x1 + y1 * y1); - var z2 = sqrt(x2 * x2 + y2 * y2); - - return (z2 - z1) / z1; - })( - abs(this.startX - this.startX2), - abs(this.startY - this.startY2), - abs(this.endX - this.endX2), - abs(this.endY - this.endY2) - ), event); - this.startX2 = this.endX2; - this.startY2 = this.endY2; - renderable = false; - break; - - // Create crop box - case ACTION_CROP: - if (!range.x || !range.y) { - renderable = false; - break; - } - - offset = this.$cropper.offset(); - left = this.startX - offset.left; - top = this.startY - offset.top; - width = cropBox.minWidth; - height = cropBox.minHeight; - - if (range.x > 0) { - action = range.y > 0 ? ACTION_SOUTH_EAST : ACTION_NORTH_EAST; - } else if (range.x < 0) { - left -= width; - action = range.y > 0 ? ACTION_SOUTH_WEST : ACTION_NORTH_WEST; - } - - if (range.y < 0) { - top -= height; - } - - // Show the crop box if is hidden - if (!this.isCropped) { - this.$cropBox.removeClass(CLASS_HIDDEN); - this.isCropped = true; - - if (this.limited) { - this.limitCropBox(true, true); - } - } - - break; - - // No default - } - - if (renderable) { - cropBox.width = width; - cropBox.height = height; - cropBox.left = left; - cropBox.top = top; - this.action = action; - - this.renderCropBox(); - } - - // Override - this.startX = this.endX; - this.startY = this.endY; - }, - - // Show the crop box manually - crop: function () { - if (!this.isBuilt || this.isDisabled) { - return; - } - - if (!this.isCropped) { - this.isCropped = true; - this.limitCropBox(true, true); - - if (this.options.modal) { - this.$dragBox.addClass(CLASS_MODAL); - } - - this.$cropBox.removeClass(CLASS_HIDDEN); - } - - this.setCropBoxData(this.initialCropBox); - }, - - // Reset the image and crop box to their initial states - reset: function () { - if (!this.isBuilt || this.isDisabled) { - return; - } - - this.image = $.extend({}, this.initialImage); - this.canvas = $.extend({}, this.initialCanvas); - this.cropBox = $.extend({}, this.initialCropBox); - - this.renderCanvas(); - - if (this.isCropped) { - this.renderCropBox(); - } - }, - - // Clear the crop box - clear: function () { - if (!this.isCropped || this.isDisabled) { - return; - } - - $.extend(this.cropBox, { - left: 0, - top: 0, - width: 0, - height: 0 - }); - - this.isCropped = false; - this.renderCropBox(); - - this.limitCanvas(true, true); - - // Render canvas after crop box rendered - this.renderCanvas(); - - this.$dragBox.removeClass(CLASS_MODAL); - this.$cropBox.addClass(CLASS_HIDDEN); - }, - - /** - * Replace the image's src and rebuild the cropper - * - * @param {String} url - * @param {Boolean} onlyColorChanged (optional) - */ - replace: function (url, onlyColorChanged) { - if (!this.isDisabled && url) { - if (this.isImg) { - this.$element.attr('src', url); - } - - if (onlyColorChanged) { - this.url = url; - this.$clone.attr('src', url); - - if (this.isBuilt) { - this.$preview.find('img').add(this.$clone2).attr('src', url); - } - } else { - if (this.isImg) { - this.isReplaced = true; - } - - // Clear previous data - this.options.data = null; - this.load(url); - } - } - }, - - // Enable (unfreeze) the cropper - enable: function () { - if (this.isBuilt) { - this.isDisabled = false; - this.$cropper.removeClass(CLASS_DISABLED); - } - }, - - // Disable (freeze) the cropper - disable: function () { - if (this.isBuilt) { - this.isDisabled = true; - this.$cropper.addClass(CLASS_DISABLED); - } - }, - - // Destroy the cropper and remove the instance from the image - destroy: function () { - var $this = this.$element; - - if (this.isLoaded) { - if (this.isImg && this.isReplaced) { - $this.attr('src', this.originalUrl); - } - - this.unbuild(); - $this.removeClass(CLASS_HIDDEN); - } else { - if (this.isImg) { - $this.off(EVENT_LOAD, this.start); - } else if (this.$clone) { - this.$clone.remove(); - } - } - - $this.removeData(NAMESPACE); - }, - - /** - * Move the canvas with relative offsets - * - * @param {Number} offsetX - * @param {Number} offsetY (optional) - */ - move: function (offsetX, offsetY) { - var canvas = this.canvas; - - this.moveTo( - isUndefined(offsetX) ? offsetX : canvas.left + num(offsetX), - isUndefined(offsetY) ? offsetY : canvas.top + num(offsetY) - ); - }, - - /** - * Move the canvas to an absolute point - * - * @param {Number} x - * @param {Number} y (optional) - */ - moveTo: function (x, y) { - var canvas = this.canvas; - var isChanged = false; - - // If "y" is not present, its default value is "x" - if (isUndefined(y)) { - y = x; - } - - x = num(x); - y = num(y); - - if (this.isBuilt && !this.isDisabled && this.options.movable) { - if (isNumber(x)) { - canvas.left = x; - isChanged = true; - } - - if (isNumber(y)) { - canvas.top = y; - isChanged = true; - } - - if (isChanged) { - this.renderCanvas(true); - } - } - }, - - /** - * Zoom the canvas with a relative ratio - * - * @param {Number} ratio - * @param {jQuery Event} _event (private) - */ - zoom: function (ratio, _event) { - var canvas = this.canvas; - - ratio = num(ratio); - - if (ratio < 0) { - ratio = 1 / (1 - ratio); - } else { - ratio = 1 + ratio; - } - - this.zoomTo(canvas.width * ratio / canvas.naturalWidth, _event); - }, - - /** - * Zoom the canvas to an absolute ratio - * - * @param {Number} ratio - * @param {jQuery Event} _event (private) - */ - zoomTo: function (ratio, _event) { - var options = this.options; - var canvas = this.canvas; - var width = canvas.width; - var height = canvas.height; - var naturalWidth = canvas.naturalWidth; - var naturalHeight = canvas.naturalHeight; - var originalEvent; - var newWidth; - var newHeight; - var offset; - var center; - - ratio = num(ratio); - - if (ratio >= 0 && this.isBuilt && !this.isDisabled && options.zoomable) { - newWidth = naturalWidth * ratio; - newHeight = naturalHeight * ratio; - - if (_event) { - originalEvent = _event.originalEvent; - } - - if (this.trigger(EVENT_ZOOM, { - originalEvent: originalEvent, - oldRatio: width / naturalWidth, - ratio: newWidth / naturalWidth - }).isDefaultPrevented()) { - return; - } - - if (originalEvent) { - offset = this.$cropper.offset(); - center = originalEvent.touches ? getTouchesCenter(originalEvent.touches) : { - pageX: _event.pageX || originalEvent.pageX || 0, - pageY: _event.pageY || originalEvent.pageY || 0 - }; - - // Zoom from the triggering point of the event - canvas.left -= (newWidth - width) * ( - ((center.pageX - offset.left) - canvas.left) / width - ); - canvas.top -= (newHeight - height) * ( - ((center.pageY - offset.top) - canvas.top) / height - ); - } else { - - // Zoom from the center of the canvas - canvas.left -= (newWidth - width) / 2; - canvas.top -= (newHeight - height) / 2; - } - - canvas.width = newWidth; - canvas.height = newHeight; - this.renderCanvas(true); - } - }, - - /** - * Rotate the canvas with a relative degree - * - * @param {Number} degree - */ - rotate: function (degree) { - this.rotateTo((this.image.rotate || 0) + num(degree)); - }, - - /** - * Rotate the canvas to an absolute degree - * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function#rotate() - * - * @param {Number} degree - */ - rotateTo: function (degree) { - degree = num(degree); - - if (isNumber(degree) && this.isBuilt && !this.isDisabled && this.options.rotatable) { - this.image.rotate = degree % 360; - this.isRotated = true; - this.renderCanvas(true); - } - }, - - /** - * Scale the image - * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function#scale() - * - * @param {Number} scaleX - * @param {Number} scaleY (optional) - */ - scale: function (scaleX, scaleY) { - var image = this.image; - var isChanged = false; - - // If "scaleY" is not present, its default value is "scaleX" - if (isUndefined(scaleY)) { - scaleY = scaleX; - } - - scaleX = num(scaleX); - scaleY = num(scaleY); - - if (this.isBuilt && !this.isDisabled && this.options.scalable) { - if (isNumber(scaleX)) { - image.scaleX = scaleX; - isChanged = true; - } - - if (isNumber(scaleY)) { - image.scaleY = scaleY; - isChanged = true; - } - - if (isChanged) { - this.renderImage(true); - } - } - }, - - /** - * Scale the abscissa of the image - * - * @param {Number} scaleX - */ - scaleX: function (scaleX) { - var scaleY = this.image.scaleY; - - this.scale(scaleX, isNumber(scaleY) ? scaleY : 1); - }, - - /** - * Scale the ordinate of the image - * - * @param {Number} scaleY - */ - scaleY: function (scaleY) { - var scaleX = this.image.scaleX; - - this.scale(isNumber(scaleX) ? scaleX : 1, scaleY); - }, - - /** - * Get the cropped area position and size data (base on the original image) - * - * @param {Boolean} isRounded (optional) - * @return {Object} data - */ - getData: function (isRounded) { - var options = this.options; - var image = this.image; - var canvas = this.canvas; - var cropBox = this.cropBox; - var ratio; - var data; - - if (this.isBuilt && this.isCropped) { - data = { - x: cropBox.left - canvas.left, - y: cropBox.top - canvas.top, - width: cropBox.width, - height: cropBox.height - }; - - ratio = image.width / image.naturalWidth; - - $.each(data, function (i, n) { - n = n / ratio; - data[i] = isRounded ? round(n) : n; - }); - - } else { - data = { - x: 0, - y: 0, - width: 0, - height: 0 - }; - } - - if (options.rotatable) { - data.rotate = image.rotate || 0; - } - - if (options.scalable) { - data.scaleX = image.scaleX || 1; - data.scaleY = image.scaleY || 1; - } - - return data; - }, - - /** - * Set the cropped area position and size with new data - * - * @param {Object} data - */ - setData: function (data) { - var options = this.options; - var image = this.image; - var canvas = this.canvas; - var cropBoxData = {}; - var isRotated; - var isScaled; - var ratio; - - if ($.isFunction(data)) { - data = data.call(this.element); - } - - if (this.isBuilt && !this.isDisabled && $.isPlainObject(data)) { - if (options.rotatable) { - if (isNumber(data.rotate) && data.rotate !== image.rotate) { - image.rotate = data.rotate; - this.isRotated = isRotated = true; - } - } - - if (options.scalable) { - if (isNumber(data.scaleX) && data.scaleX !== image.scaleX) { - image.scaleX = data.scaleX; - isScaled = true; - } - - if (isNumber(data.scaleY) && data.scaleY !== image.scaleY) { - image.scaleY = data.scaleY; - isScaled = true; - } - } - - if (isRotated) { - this.renderCanvas(); - } else if (isScaled) { - this.renderImage(); - } - - ratio = image.width / image.naturalWidth; - - if (isNumber(data.x)) { - cropBoxData.left = data.x * ratio + canvas.left; - } - - if (isNumber(data.y)) { - cropBoxData.top = data.y * ratio + canvas.top; - } - - if (isNumber(data.width)) { - cropBoxData.width = data.width * ratio; - } - - if (isNumber(data.height)) { - cropBoxData.height = data.height * ratio; - } - - this.setCropBoxData(cropBoxData); - } - }, - - /** - * Get the container size data - * - * @return {Object} data - */ - getContainerData: function () { - return this.isBuilt ? this.container : {}; - }, - - /** - * Get the image position and size data - * - * @return {Object} data - */ - getImageData: function () { - return this.isLoaded ? this.image : {}; - }, - - /** - * Get the canvas position and size data - * - * @return {Object} data - */ - getCanvasData: function () { - var canvas = this.canvas; - var data = {}; - - if (this.isBuilt) { - $.each([ - 'left', - 'top', - 'width', - 'height', - 'naturalWidth', - 'naturalHeight' - ], function (i, n) { - data[n] = canvas[n]; - }); - } - - return data; - }, - - /** - * Set the canvas position and size with new data - * - * @param {Object} data - */ - setCanvasData: function (data) { - var canvas = this.canvas; - var aspectRatio = canvas.aspectRatio; - - if ($.isFunction(data)) { - data = data.call(this.$element); - } - - if (this.isBuilt && !this.isDisabled && $.isPlainObject(data)) { - if (isNumber(data.left)) { - canvas.left = data.left; - } - - if (isNumber(data.top)) { - canvas.top = data.top; - } - - if (isNumber(data.width)) { - canvas.width = data.width; - canvas.height = data.width / aspectRatio; - } else if (isNumber(data.height)) { - canvas.height = data.height; - canvas.width = data.height * aspectRatio; - } - - this.renderCanvas(true); - } - }, - - /** - * Get the crop box position and size data - * - * @return {Object} data - */ - getCropBoxData: function () { - var cropBox = this.cropBox; - var data; - - if (this.isBuilt && this.isCropped) { - data = { - left: cropBox.left, - top: cropBox.top, - width: cropBox.width, - height: cropBox.height - }; - } - - return data || {}; - }, - - /** - * Set the crop box position and size with new data - * - * @param {Object} data - */ - setCropBoxData: function (data) { - var cropBox = this.cropBox; - var aspectRatio = this.options.aspectRatio; - var isWidthChanged; - var isHeightChanged; - - if ($.isFunction(data)) { - data = data.call(this.$element); - } - - if (this.isBuilt && this.isCropped && !this.isDisabled && $.isPlainObject(data)) { - - if (isNumber(data.left)) { - cropBox.left = data.left; - } - - if (isNumber(data.top)) { - cropBox.top = data.top; - } - - if (isNumber(data.width)) { - isWidthChanged = true; - cropBox.width = data.width; - } - - if (isNumber(data.height)) { - isHeightChanged = true; - cropBox.height = data.height; - } - - if (aspectRatio) { - if (isWidthChanged) { - cropBox.height = cropBox.width / aspectRatio; - } else if (isHeightChanged) { - cropBox.width = cropBox.height * aspectRatio; - } - } - - this.renderCropBox(); - } - }, - - /** - * Get a canvas drawn the cropped image - * - * @param {Object} options (optional) - * @return {HTMLCanvasElement} canvas - */ - getCroppedCanvas: function (options) { - var originalWidth; - var originalHeight; - var canvasWidth; - var canvasHeight; - var scaledWidth; - var scaledHeight; - var scaledRatio; - var aspectRatio; - var canvas; - var context; - var data; - - if (!this.isBuilt || !this.isCropped || !SUPPORT_CANVAS) { - return; - } - - if (!$.isPlainObject(options)) { - options = {}; - } - - data = this.getData(); - originalWidth = data.width; - originalHeight = data.height; - aspectRatio = originalWidth / originalHeight; - - if ($.isPlainObject(options)) { - scaledWidth = options.width; - scaledHeight = options.height; - - if (scaledWidth) { - scaledHeight = scaledWidth / aspectRatio; - scaledRatio = scaledWidth / originalWidth; - } else if (scaledHeight) { - scaledWidth = scaledHeight * aspectRatio; - scaledRatio = scaledHeight / originalHeight; - } - } - - // The canvas element will use `Math.floor` on a float number, so floor first - canvasWidth = floor(scaledWidth || originalWidth); - canvasHeight = floor(scaledHeight || originalHeight); - - canvas = $('')[0]; - canvas.width = canvasWidth; - canvas.height = canvasHeight; - context = canvas.getContext('2d'); - - if (options.fillColor) { - context.fillStyle = options.fillColor; - context.fillRect(0, 0, canvasWidth, canvasHeight); - } - - // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.drawImage - context.drawImage.apply(context, (function () { - var source = getSourceCanvas(this.$clone[0], this.image); - var sourceWidth = source.width; - var sourceHeight = source.height; - var canvas = this.canvas; - var params = [source]; - - // Source canvas - var srcX = data.x + canvas.naturalWidth * (abs(data.scaleX || 1) - 1) / 2; - var srcY = data.y + canvas.naturalHeight * (abs(data.scaleY || 1) - 1) / 2; - var srcWidth; - var srcHeight; - - // Destination canvas - var dstX; - var dstY; - var dstWidth; - var dstHeight; - - if (srcX <= -originalWidth || srcX > sourceWidth) { - srcX = srcWidth = dstX = dstWidth = 0; - } else if (srcX <= 0) { - dstX = -srcX; - srcX = 0; - srcWidth = dstWidth = min(sourceWidth, originalWidth + srcX); - } else if (srcX <= sourceWidth) { - dstX = 0; - srcWidth = dstWidth = min(originalWidth, sourceWidth - srcX); - } - - if (srcWidth <= 0 || srcY <= -originalHeight || srcY > sourceHeight) { - srcY = srcHeight = dstY = dstHeight = 0; - } else if (srcY <= 0) { - dstY = -srcY; - srcY = 0; - srcHeight = dstHeight = min(sourceHeight, originalHeight + srcY); - } else if (srcY <= sourceHeight) { - dstY = 0; - srcHeight = dstHeight = min(originalHeight, sourceHeight - srcY); - } - - // All the numerical parameters should be integer for `drawImage` (#476) - params.push(floor(srcX), floor(srcY), floor(srcWidth), floor(srcHeight)); - - // Scale destination sizes - if (scaledRatio) { - dstX *= scaledRatio; - dstY *= scaledRatio; - dstWidth *= scaledRatio; - dstHeight *= scaledRatio; - } - - // Avoid "IndexSizeError" in IE and Firefox - if (dstWidth > 0 && dstHeight > 0) { - params.push(floor(dstX), floor(dstY), floor(dstWidth), floor(dstHeight)); - } - - return params; - }).call(this)); - - return canvas; - }, - - /** - * Change the aspect ratio of the crop box - * - * @param {Number} aspectRatio - */ - setAspectRatio: function (aspectRatio) { - var options = this.options; - - if (!this.isDisabled && !isUndefined(aspectRatio)) { - - // 0 -> NaN - options.aspectRatio = max(0, aspectRatio) || NaN; - - if (this.isBuilt) { - this.initCropBox(); - - if (this.isCropped) { - this.renderCropBox(); - } - } - } - }, - - /** - * Change the drag mode - * - * @param {String} mode (optional) - */ - setDragMode: function (mode) { - var options = this.options; - var croppable; - var movable; - - if (this.isLoaded && !this.isDisabled) { - croppable = mode === ACTION_CROP; - movable = options.movable && mode === ACTION_MOVE; - mode = (croppable || movable) ? mode : ACTION_NONE; - - this.$dragBox. - data(DATA_ACTION, mode). - toggleClass(CLASS_CROP, croppable). - toggleClass(CLASS_MOVE, movable); - - if (!options.cropBoxMovable) { - - // Sync drag mode to crop box when it is not movable(#300) - this.$face. - data(DATA_ACTION, mode). - toggleClass(CLASS_CROP, croppable). - toggleClass(CLASS_MOVE, movable); - } - } - } - }; - - Cropper.DEFAULTS = { - - // Define the view mode of the cropper - viewMode: 0, // 0, 1, 2, 3 - - // Define the dragging mode of the cropper - dragMode: 'crop', // 'crop', 'move' or 'none' - - // Define the aspect ratio of the crop box - aspectRatio: NaN, - - // An object with the previous cropping result data - data: null, - - // A jQuery selector for adding extra containers to preview - preview: '', - - // Re-render the cropper when resize the window - responsive: true, - - // Restore the cropped area after resize the window - restore: true, - - // Check if the current image is a cross-origin image - checkCrossOrigin: true, - - // Check the current image's Exif Orientation information - checkOrientation: true, - - // Show the black modal - modal: true, - - // Show the dashed lines for guiding - guides: true, - - // Show the center indicator for guiding - center: true, - - // Show the white modal to highlight the crop box - highlight: true, - - // Show the grid background - background: true, - - // Enable to crop the image automatically when initialize - autoCrop: true, - - // Define the percentage of automatic cropping area when initializes - autoCropArea: 0.8, - - // Enable to move the image - movable: true, - - // Enable to rotate the image - rotatable: true, - - // Enable to scale the image - scalable: true, - - // Enable to zoom the image - zoomable: true, - - // Enable to zoom the image by dragging touch - zoomOnTouch: true, - - // Enable to zoom the image by wheeling mouse - zoomOnWheel: true, - - // Define zoom ratio when zoom the image by wheeling mouse - wheelZoomRatio: 0.1, - - // Enable to move the crop box - cropBoxMovable: true, - - // Enable to resize the crop box - cropBoxResizable: true, - - // Toggle drag mode between "crop" and "move" when click twice on the cropper - toggleDragModeOnDblclick: true, - - // Size limitation - minCanvasWidth: 0, - minCanvasHeight: 0, - minCropBoxWidth: 0, - minCropBoxHeight: 0, - minContainerWidth: 200, - minContainerHeight: 100, - - // Shortcuts of events - build: null, - built: null, - cropstart: null, - cropmove: null, - cropend: null, - crop: null, - zoom: null - }; - - Cropper.setDefaults = function (options) { - $.extend(Cropper.DEFAULTS, options); - }; - - Cropper.TEMPLATE = ( - '
' + - '
' + - '
' + - '
' + - '
' + - '
' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '
' + - '
' - ); - - // Save the other cropper - Cropper.other = $.fn.cropper; - - // Register as jQuery plugin - $.fn.cropper = function (option) { - var args = toArray(arguments, 1); - var result; - - this.each(function () { - var $this = $(this); - var data = $this.data(NAMESPACE); - var options; - var fn; - - if (!data) { - if (/destroy/.test(option)) { - return; - } - - options = $.extend({}, $this.data(), $.isPlainObject(option) && option); - $this.data(NAMESPACE, (data = new Cropper(this, options))); - } - - if (typeof option === 'string' && $.isFunction(fn = data[option])) { - result = fn.apply(data, args); - } - }); - - return isUndefined(result) ? this : result; - }; - - $.fn.cropper.Constructor = Cropper; - $.fn.cropper.setDefaults = Cropper.setDefaults; - - // No conflict - $.fn.cropper.noConflict = function () { - $.fn.cropper = Cropper.other; - return this; - }; - -}); -- cgit v1.2.3 From d93527805569e9462b5f142d807b14eaaf179876 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 7 Aug 2017 07:47:29 +0000 Subject: Fix issues with pdf-js dependencies --- vendor/assets/javascripts/pdf.js | 9365 +++++++++++++++++++ vendor/assets/javascripts/pdf.min.js | 6 + vendor/assets/javascripts/pdf.worker.js | 305 +- vendor/assets/javascripts/pdf.worker.min.js | 19 + vendor/assets/javascripts/pdflab.js | 12484 -------------------------- 5 files changed, 9392 insertions(+), 12787 deletions(-) create mode 100755 vendor/assets/javascripts/pdf.js create mode 100755 vendor/assets/javascripts/pdf.min.js mode change 100644 => 100755 vendor/assets/javascripts/pdf.worker.js create mode 100755 vendor/assets/javascripts/pdf.worker.min.js delete mode 100644 vendor/assets/javascripts/pdflab.js (limited to 'vendor') diff --git a/vendor/assets/javascripts/pdf.js b/vendor/assets/javascripts/pdf.js new file mode 100755 index 00000000000..91c43b12716 --- /dev/null +++ b/vendor/assets/javascripts/pdf.js @@ -0,0 +1,9365 @@ +/* Copyright 2017 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define("pdfjs-dist/build/pdf", [], factory); + else if(typeof exports === 'object') + exports["pdfjs-dist/build/pdf"] = factory(); + else + root["pdfjs-dist/build/pdf"] = root.pdfjsDistBuildPdf = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __w_pdfjs_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __w_pdfjs_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __w_pdfjs_require__.c = installedModules; +/******/ +/******/ // identity function for calling harmony imports with the correct context +/******/ __w_pdfjs_require__.i = function(value) { return value; }; +/******/ +/******/ // define getter function for harmony exports +/******/ __w_pdfjs_require__.d = function(exports, name, getter) { +/******/ if(!__w_pdfjs_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __w_pdfjs_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __w_pdfjs_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __w_pdfjs_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 13); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +var compatibility = __w_pdfjs_require__(14); +var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined; +var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; +var TextRenderingMode = { + FILL: 0, + STROKE: 1, + FILL_STROKE: 2, + INVISIBLE: 3, + FILL_ADD_TO_PATH: 4, + STROKE_ADD_TO_PATH: 5, + FILL_STROKE_ADD_TO_PATH: 6, + ADD_TO_PATH: 7, + FILL_STROKE_MASK: 3, + ADD_TO_PATH_FLAG: 4 +}; +var ImageKind = { + GRAYSCALE_1BPP: 1, + RGB_24BPP: 2, + RGBA_32BPP: 3 +}; +var AnnotationType = { + TEXT: 1, + LINK: 2, + FREETEXT: 3, + LINE: 4, + SQUARE: 5, + CIRCLE: 6, + POLYGON: 7, + POLYLINE: 8, + HIGHLIGHT: 9, + UNDERLINE: 10, + SQUIGGLY: 11, + STRIKEOUT: 12, + STAMP: 13, + CARET: 14, + INK: 15, + POPUP: 16, + FILEATTACHMENT: 17, + SOUND: 18, + MOVIE: 19, + WIDGET: 20, + SCREEN: 21, + PRINTERMARK: 22, + TRAPNET: 23, + WATERMARK: 24, + THREED: 25, + REDACT: 26 +}; +var AnnotationFlag = { + INVISIBLE: 0x01, + HIDDEN: 0x02, + PRINT: 0x04, + NOZOOM: 0x08, + NOROTATE: 0x10, + NOVIEW: 0x20, + READONLY: 0x40, + LOCKED: 0x80, + TOGGLENOVIEW: 0x100, + LOCKEDCONTENTS: 0x200 +}; +var AnnotationFieldFlag = { + READONLY: 0x0000001, + REQUIRED: 0x0000002, + NOEXPORT: 0x0000004, + MULTILINE: 0x0001000, + PASSWORD: 0x0002000, + NOTOGGLETOOFF: 0x0004000, + RADIO: 0x0008000, + PUSHBUTTON: 0x0010000, + COMBO: 0x0020000, + EDIT: 0x0040000, + SORT: 0x0080000, + FILESELECT: 0x0100000, + MULTISELECT: 0x0200000, + DONOTSPELLCHECK: 0x0400000, + DONOTSCROLL: 0x0800000, + COMB: 0x1000000, + RICHTEXT: 0x2000000, + RADIOSINUNISON: 0x2000000, + COMMITONSELCHANGE: 0x4000000 +}; +var AnnotationBorderStyleType = { + SOLID: 1, + DASHED: 2, + BEVELED: 3, + INSET: 4, + UNDERLINE: 5 +}; +var StreamType = { + UNKNOWN: 0, + FLATE: 1, + LZW: 2, + DCT: 3, + JPX: 4, + JBIG: 5, + A85: 6, + AHX: 7, + CCF: 8, + RL: 9 +}; +var FontType = { + UNKNOWN: 0, + TYPE1: 1, + TYPE1C: 2, + CIDFONTTYPE0: 3, + CIDFONTTYPE0C: 4, + TRUETYPE: 5, + CIDFONTTYPE2: 6, + TYPE3: 7, + OPENTYPE: 8, + TYPE0: 9, + MMTYPE1: 10 +}; +var VERBOSITY_LEVELS = { + errors: 0, + warnings: 1, + infos: 5 +}; +var CMapCompressionType = { + NONE: 0, + BINARY: 1, + STREAM: 2 +}; +var OPS = { + dependency: 1, + setLineWidth: 2, + setLineCap: 3, + setLineJoin: 4, + setMiterLimit: 5, + setDash: 6, + setRenderingIntent: 7, + setFlatness: 8, + setGState: 9, + save: 10, + restore: 11, + transform: 12, + moveTo: 13, + lineTo: 14, + curveTo: 15, + curveTo2: 16, + curveTo3: 17, + closePath: 18, + rectangle: 19, + stroke: 20, + closeStroke: 21, + fill: 22, + eoFill: 23, + fillStroke: 24, + eoFillStroke: 25, + closeFillStroke: 26, + closeEOFillStroke: 27, + endPath: 28, + clip: 29, + eoClip: 30, + beginText: 31, + endText: 32, + setCharSpacing: 33, + setWordSpacing: 34, + setHScale: 35, + setLeading: 36, + setFont: 37, + setTextRenderingMode: 38, + setTextRise: 39, + moveText: 40, + setLeadingMoveText: 41, + setTextMatrix: 42, + nextLine: 43, + showText: 44, + showSpacedText: 45, + nextLineShowText: 46, + nextLineSetSpacingShowText: 47, + setCharWidth: 48, + setCharWidthAndBounds: 49, + setStrokeColorSpace: 50, + setFillColorSpace: 51, + setStrokeColor: 52, + setStrokeColorN: 53, + setFillColor: 54, + setFillColorN: 55, + setStrokeGray: 56, + setFillGray: 57, + setStrokeRGBColor: 58, + setFillRGBColor: 59, + setStrokeCMYKColor: 60, + setFillCMYKColor: 61, + shadingFill: 62, + beginInlineImage: 63, + beginImageData: 64, + endInlineImage: 65, + paintXObject: 66, + markPoint: 67, + markPointProps: 68, + beginMarkedContent: 69, + beginMarkedContentProps: 70, + endMarkedContent: 71, + beginCompat: 72, + endCompat: 73, + paintFormXObjectBegin: 74, + paintFormXObjectEnd: 75, + beginGroup: 76, + endGroup: 77, + beginAnnotations: 78, + endAnnotations: 79, + beginAnnotation: 80, + endAnnotation: 81, + paintJpegXObject: 82, + paintImageMaskXObject: 83, + paintImageMaskXObjectGroup: 84, + paintImageXObject: 85, + paintInlineImageXObject: 86, + paintInlineImageXObjectGroup: 87, + paintImageXObjectRepeat: 88, + paintImageMaskXObjectRepeat: 89, + paintSolidColorImageMask: 90, + constructPath: 91 +}; +var verbosity = VERBOSITY_LEVELS.warnings; +function setVerbosityLevel(level) { + verbosity = level; +} +function getVerbosityLevel() { + return verbosity; +} +function info(msg) { + if (verbosity >= VERBOSITY_LEVELS.infos) { + console.log('Info: ' + msg); + } +} +function warn(msg) { + if (verbosity >= VERBOSITY_LEVELS.warnings) { + console.log('Warning: ' + msg); + } +} +function deprecated(details) { + console.log('Deprecated API usage: ' + details); +} +function error(msg) { + if (verbosity >= VERBOSITY_LEVELS.errors) { + console.log('Error: ' + msg); + console.log(backtrace()); + } + throw new Error(msg); +} +function backtrace() { + try { + throw new Error(); + } catch (e) { + return e.stack ? e.stack.split('\n').slice(2).join('\n') : ''; + } +} +function assert(cond, msg) { + if (!cond) { + error(msg); + } +} +var UNSUPPORTED_FEATURES = { + unknown: 'unknown', + forms: 'forms', + javaScript: 'javaScript', + smask: 'smask', + shadingPattern: 'shadingPattern', + font: 'font' +}; +function isSameOrigin(baseUrl, otherUrl) { + try { + var base = new URL(baseUrl); + if (!base.origin || base.origin === 'null') { + return false; + } + } catch (e) { + return false; + } + var other = new URL(otherUrl, base); + return base.origin === other.origin; +} +function isValidProtocol(url) { + if (!url) { + return false; + } + switch (url.protocol) { + case 'http:': + case 'https:': + case 'ftp:': + case 'mailto:': + case 'tel:': + return true; + default: + return false; + } +} +function createValidAbsoluteUrl(url, baseUrl) { + if (!url) { + return null; + } + try { + var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url); + if (isValidProtocol(absoluteUrl)) { + return absoluteUrl; + } + } catch (ex) {} + return null; +} +function shadow(obj, prop, value) { + Object.defineProperty(obj, prop, { + value: value, + enumerable: true, + configurable: true, + writable: false + }); + return value; +} +function getLookupTableFactory(initializer) { + var lookup; + return function () { + if (initializer) { + lookup = Object.create(null); + initializer(lookup); + initializer = null; + } + return lookup; + }; +} +var PasswordResponses = { + NEED_PASSWORD: 1, + INCORRECT_PASSWORD: 2 +}; +var PasswordException = function PasswordExceptionClosure() { + function PasswordException(msg, code) { + this.name = 'PasswordException'; + this.message = msg; + this.code = code; + } + PasswordException.prototype = new Error(); + PasswordException.constructor = PasswordException; + return PasswordException; +}(); +var UnknownErrorException = function UnknownErrorExceptionClosure() { + function UnknownErrorException(msg, details) { + this.name = 'UnknownErrorException'; + this.message = msg; + this.details = details; + } + UnknownErrorException.prototype = new Error(); + UnknownErrorException.constructor = UnknownErrorException; + return UnknownErrorException; +}(); +var InvalidPDFException = function InvalidPDFExceptionClosure() { + function InvalidPDFException(msg) { + this.name = 'InvalidPDFException'; + this.message = msg; + } + InvalidPDFException.prototype = new Error(); + InvalidPDFException.constructor = InvalidPDFException; + return InvalidPDFException; +}(); +var MissingPDFException = function MissingPDFExceptionClosure() { + function MissingPDFException(msg) { + this.name = 'MissingPDFException'; + this.message = msg; + } + MissingPDFException.prototype = new Error(); + MissingPDFException.constructor = MissingPDFException; + return MissingPDFException; +}(); +var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() { + function UnexpectedResponseException(msg, status) { + this.name = 'UnexpectedResponseException'; + this.message = msg; + this.status = status; + } + UnexpectedResponseException.prototype = new Error(); + UnexpectedResponseException.constructor = UnexpectedResponseException; + return UnexpectedResponseException; +}(); +var NotImplementedException = function NotImplementedExceptionClosure() { + function NotImplementedException(msg) { + this.message = msg; + } + NotImplementedException.prototype = new Error(); + NotImplementedException.prototype.name = 'NotImplementedException'; + NotImplementedException.constructor = NotImplementedException; + return NotImplementedException; +}(); +var MissingDataException = function MissingDataExceptionClosure() { + function MissingDataException(begin, end) { + this.begin = begin; + this.end = end; + this.message = 'Missing data [' + begin + ', ' + end + ')'; + } + MissingDataException.prototype = new Error(); + MissingDataException.prototype.name = 'MissingDataException'; + MissingDataException.constructor = MissingDataException; + return MissingDataException; +}(); +var XRefParseException = function XRefParseExceptionClosure() { + function XRefParseException(msg) { + this.message = msg; + } + XRefParseException.prototype = new Error(); + XRefParseException.prototype.name = 'XRefParseException'; + XRefParseException.constructor = XRefParseException; + return XRefParseException; +}(); +var NullCharactersRegExp = /\x00/g; +function removeNullCharacters(str) { + if (typeof str !== 'string') { + warn('The argument for removeNullCharacters must be a string.'); + return str; + } + return str.replace(NullCharactersRegExp, ''); +} +function bytesToString(bytes) { + assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString'); + var length = bytes.length; + var MAX_ARGUMENT_COUNT = 8192; + if (length < MAX_ARGUMENT_COUNT) { + return String.fromCharCode.apply(null, bytes); + } + var strBuf = []; + for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) { + var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length); + var chunk = bytes.subarray(i, chunkEnd); + strBuf.push(String.fromCharCode.apply(null, chunk)); + } + return strBuf.join(''); +} +function stringToBytes(str) { + assert(typeof str === 'string', 'Invalid argument for stringToBytes'); + var length = str.length; + var bytes = new Uint8Array(length); + for (var i = 0; i < length; ++i) { + bytes[i] = str.charCodeAt(i) & 0xFF; + } + return bytes; +} +function arrayByteLength(arr) { + if (arr.length !== undefined) { + return arr.length; + } + assert(arr.byteLength !== undefined); + return arr.byteLength; +} +function arraysToBytes(arr) { + if (arr.length === 1 && arr[0] instanceof Uint8Array) { + return arr[0]; + } + var resultLength = 0; + var i, + ii = arr.length; + var item, itemLength; + for (i = 0; i < ii; i++) { + item = arr[i]; + itemLength = arrayByteLength(item); + resultLength += itemLength; + } + var pos = 0; + var data = new Uint8Array(resultLength); + for (i = 0; i < ii; i++) { + item = arr[i]; + if (!(item instanceof Uint8Array)) { + if (typeof item === 'string') { + item = stringToBytes(item); + } else { + item = new Uint8Array(item); + } + } + itemLength = item.byteLength; + data.set(item, pos); + pos += itemLength; + } + return data; +} +function string32(value) { + return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff); +} +function log2(x) { + var n = 1, + i = 0; + while (x > n) { + n <<= 1; + i++; + } + return i; +} +function readInt8(data, start) { + return data[start] << 24 >> 24; +} +function readUint16(data, offset) { + return data[offset] << 8 | data[offset + 1]; +} +function readUint32(data, offset) { + return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0; +} +function isLittleEndian() { + var buffer8 = new Uint8Array(2); + buffer8[0] = 1; + var buffer16 = new Uint16Array(buffer8.buffer); + return buffer16[0] === 1; +} +function isEvalSupported() { + try { + new Function(''); + return true; + } catch (e) { + return false; + } +} +var Uint32ArrayView = function Uint32ArrayViewClosure() { + function Uint32ArrayView(buffer, length) { + this.buffer = buffer; + this.byteLength = buffer.length; + this.length = length === undefined ? this.byteLength >> 2 : length; + ensureUint32ArrayViewProps(this.length); + } + Uint32ArrayView.prototype = Object.create(null); + var uint32ArrayViewSetters = 0; + function createUint32ArrayProp(index) { + return { + get: function () { + var buffer = this.buffer, + offset = index << 2; + return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0; + }, + set: function (value) { + var buffer = this.buffer, + offset = index << 2; + buffer[offset] = value & 255; + buffer[offset + 1] = value >> 8 & 255; + buffer[offset + 2] = value >> 16 & 255; + buffer[offset + 3] = value >>> 24 & 255; + } + }; + } + function ensureUint32ArrayViewProps(length) { + while (uint32ArrayViewSetters < length) { + Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters)); + uint32ArrayViewSetters++; + } + } + return Uint32ArrayView; +}(); +exports.Uint32ArrayView = Uint32ArrayView; +var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; +var Util = function UtilClosure() { + function Util() {} + var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')']; + Util.makeCssRgb = function Util_makeCssRgb(r, g, b) { + rgbBuf[1] = r; + rgbBuf[3] = g; + rgbBuf[5] = b; + return rgbBuf.join(''); + }; + Util.transform = function Util_transform(m1, m2) { + 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]]; + }; + Util.applyTransform = function Util_applyTransform(p, m) { + var xt = p[0] * m[0] + p[1] * m[2] + m[4]; + var yt = p[0] * m[1] + p[1] * m[3] + m[5]; + return [xt, yt]; + }; + Util.applyInverseTransform = function Util_applyInverseTransform(p, m) { + var d = m[0] * m[3] - m[1] * m[2]; + var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d; + var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d; + return [xt, yt]; + }; + Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) { + var p1 = Util.applyTransform(r, m); + var p2 = Util.applyTransform(r.slice(2, 4), m); + var p3 = Util.applyTransform([r[0], r[3]], m); + var p4 = Util.applyTransform([r[2], r[1]], m); + 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])]; + }; + Util.inverseTransform = function Util_inverseTransform(m) { + var d = m[0] * m[3] - m[1] * m[2]; + 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]; + }; + Util.apply3dTransform = function Util_apply3dTransform(m, v) { + 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]]; + }; + Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) { + var transpose = [m[0], m[2], m[1], m[3]]; + var a = m[0] * transpose[0] + m[1] * transpose[2]; + var b = m[0] * transpose[1] + m[1] * transpose[3]; + var c = m[2] * transpose[0] + m[3] * transpose[2]; + var d = m[2] * transpose[1] + m[3] * transpose[3]; + var first = (a + d) / 2; + var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2; + var sx = first + second || 1; + var sy = first - second || 1; + return [Math.sqrt(sx), Math.sqrt(sy)]; + }; + Util.normalizeRect = function Util_normalizeRect(rect) { + var r = rect.slice(0); + if (rect[0] > rect[2]) { + r[0] = rect[2]; + r[2] = rect[0]; + } + if (rect[1] > rect[3]) { + r[1] = rect[3]; + r[3] = rect[1]; + } + return r; + }; + Util.intersect = function Util_intersect(rect1, rect2) { + function compare(a, b) { + return a - b; + } + var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare), + orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare), + result = []; + rect1 = Util.normalizeRect(rect1); + rect2 = Util.normalizeRect(rect2); + if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) { + result[0] = orderedX[1]; + result[2] = orderedX[2]; + } else { + return false; + } + if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) { + result[1] = orderedY[1]; + result[3] = orderedY[2]; + } else { + return false; + } + return result; + }; + Util.sign = function Util_sign(num) { + return num < 0 ? -1 : 1; + }; + 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']; + Util.toRoman = function Util_toRoman(number, lowerCase) { + assert(isInt(number) && number > 0, 'The number should be a positive integer.'); + var pos, + romanBuf = []; + while (number >= 1000) { + number -= 1000; + romanBuf.push('M'); + } + pos = number / 100 | 0; + number %= 100; + romanBuf.push(ROMAN_NUMBER_MAP[pos]); + pos = number / 10 | 0; + number %= 10; + romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]); + romanBuf.push(ROMAN_NUMBER_MAP[20 + number]); + var romanStr = romanBuf.join(''); + return lowerCase ? romanStr.toLowerCase() : romanStr; + }; + Util.appendToArray = function Util_appendToArray(arr1, arr2) { + Array.prototype.push.apply(arr1, arr2); + }; + Util.prependToArray = function Util_prependToArray(arr1, arr2) { + Array.prototype.unshift.apply(arr1, arr2); + }; + Util.extendObj = function extendObj(obj1, obj2) { + for (var key in obj2) { + obj1[key] = obj2[key]; + } + }; + Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) { + while (dict && !dict.has(name)) { + dict = dict.get('Parent'); + } + if (!dict) { + return null; + } + return getArray ? dict.getArray(name) : dict.get(name); + }; + Util.inherit = function Util_inherit(sub, base, prototype) { + sub.prototype = Object.create(base.prototype); + sub.prototype.constructor = sub; + for (var prop in prototype) { + sub.prototype[prop] = prototype[prop]; + } + }; + Util.loadScript = function Util_loadScript(src, callback) { + var script = document.createElement('script'); + var loaded = false; + script.setAttribute('src', src); + if (callback) { + script.onload = function () { + if (!loaded) { + callback(); + } + loaded = true; + }; + } + document.getElementsByTagName('head')[0].appendChild(script); + }; + return Util; +}(); +var PageViewport = function PageViewportClosure() { + function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) { + this.viewBox = viewBox; + this.scale = scale; + this.rotation = rotation; + this.offsetX = offsetX; + this.offsetY = offsetY; + var centerX = (viewBox[2] + viewBox[0]) / 2; + var centerY = (viewBox[3] + viewBox[1]) / 2; + var rotateA, rotateB, rotateC, rotateD; + rotation = rotation % 360; + rotation = rotation < 0 ? rotation + 360 : rotation; + switch (rotation) { + case 180: + rotateA = -1; + rotateB = 0; + rotateC = 0; + rotateD = 1; + break; + case 90: + rotateA = 0; + rotateB = 1; + rotateC = 1; + rotateD = 0; + break; + case 270: + rotateA = 0; + rotateB = -1; + rotateC = -1; + rotateD = 0; + break; + default: + rotateA = 1; + rotateB = 0; + rotateC = 0; + rotateD = -1; + break; + } + if (dontFlip) { + rotateC = -rotateC; + rotateD = -rotateD; + } + var offsetCanvasX, offsetCanvasY; + var width, height; + if (rotateA === 0) { + offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX; + offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY; + width = Math.abs(viewBox[3] - viewBox[1]) * scale; + height = Math.abs(viewBox[2] - viewBox[0]) * scale; + } else { + offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX; + offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY; + width = Math.abs(viewBox[2] - viewBox[0]) * scale; + height = Math.abs(viewBox[3] - viewBox[1]) * scale; + } + this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY]; + this.width = width; + this.height = height; + this.fontScale = scale; + } + PageViewport.prototype = { + clone: function PageViewPort_clone(args) { + args = args || {}; + var scale = 'scale' in args ? args.scale : this.scale; + var rotation = 'rotation' in args ? args.rotation : this.rotation; + return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip); + }, + convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) { + return Util.applyTransform([x, y], this.transform); + }, + convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) { + var tl = Util.applyTransform([rect[0], rect[1]], this.transform); + var br = Util.applyTransform([rect[2], rect[3]], this.transform); + return [tl[0], tl[1], br[0], br[1]]; + }, + convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) { + return Util.applyInverseTransform([x, y], this.transform); + } + }; + return PageViewport; +}(); +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]; +function stringToPDFString(str) { + var i, + n = str.length, + strBuf = []; + if (str[0] === '\xFE' && str[1] === '\xFF') { + for (i = 2; i < n; i += 2) { + strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1))); + } + } else { + for (i = 0; i < n; ++i) { + var code = PDFStringTranslateTable[str.charCodeAt(i)]; + strBuf.push(code ? String.fromCharCode(code) : str.charAt(i)); + } + } + return strBuf.join(''); +} +function stringToUTF8String(str) { + return decodeURIComponent(escape(str)); +} +function utf8StringToString(str) { + return unescape(encodeURIComponent(str)); +} +function isEmptyObj(obj) { + for (var key in obj) { + return false; + } + return true; +} +function isBool(v) { + return typeof v === 'boolean'; +} +function isInt(v) { + return typeof v === 'number' && (v | 0) === v; +} +function isNum(v) { + return typeof v === 'number'; +} +function isString(v) { + return typeof v === 'string'; +} +function isArray(v) { + return v instanceof Array; +} +function isArrayBuffer(v) { + return typeof v === 'object' && v !== null && v.byteLength !== undefined; +} +function isSpace(ch) { + return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A; +} +function isNodeJS() { + if (typeof __pdfjsdev_webpack__ === 'undefined') { + return typeof process === 'object' && process + '' === '[object process]'; + } + return false; +} +function createPromiseCapability() { + var capability = {}; + capability.promise = new Promise(function (resolve, reject) { + capability.resolve = resolve; + capability.reject = reject; + }); + return capability; +} +var StatTimer = function StatTimerClosure() { + function rpad(str, pad, length) { + while (str.length < length) { + str += pad; + } + return str; + } + function StatTimer() { + this.started = Object.create(null); + this.times = []; + this.enabled = true; + } + StatTimer.prototype = { + time: function StatTimer_time(name) { + if (!this.enabled) { + return; + } + if (name in this.started) { + warn('Timer is already running for ' + name); + } + this.started[name] = Date.now(); + }, + timeEnd: function StatTimer_timeEnd(name) { + if (!this.enabled) { + return; + } + if (!(name in this.started)) { + warn('Timer has not been started for ' + name); + } + this.times.push({ + 'name': name, + 'start': this.started[name], + 'end': Date.now() + }); + delete this.started[name]; + }, + toString: function StatTimer_toString() { + var i, ii; + var times = this.times; + var out = ''; + var longest = 0; + for (i = 0, ii = times.length; i < ii; ++i) { + var name = times[i]['name']; + if (name.length > longest) { + longest = name.length; + } + } + for (i = 0, ii = times.length; i < ii; ++i) { + var span = times[i]; + var duration = span.end - span.start; + out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n'; + } + return out; + } + }; + return StatTimer; +}(); +var createBlob = function createBlob(data, contentType) { + if (typeof Blob !== 'undefined') { + return new Blob([data], { type: contentType }); + } + warn('The "Blob" constructor is not supported.'); +}; +var createObjectURL = function createObjectURLClosure() { + var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + return function createObjectURL(data, contentType, forceDataSchema) { + if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) { + var blob = createBlob(data, contentType); + return URL.createObjectURL(blob); + } + var buffer = 'data:' + contentType + ';base64,'; + for (var i = 0, ii = data.length; i < ii; i += 3) { + var b1 = data[i] & 0xFF; + var b2 = data[i + 1] & 0xFF; + var b3 = data[i + 2] & 0xFF; + var d1 = b1 >> 2, + d2 = (b1 & 3) << 4 | b2 >> 4; + var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64; + var d4 = i + 2 < ii ? b3 & 0x3F : 64; + buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4]; + } + return buffer; + }; +}(); +function MessageHandler(sourceName, targetName, comObj) { + this.sourceName = sourceName; + this.targetName = targetName; + this.comObj = comObj; + this.callbackIndex = 1; + this.postMessageTransfers = true; + var callbacksCapabilities = this.callbacksCapabilities = Object.create(null); + var ah = this.actionHandler = Object.create(null); + this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) { + var data = event.data; + if (data.targetName !== this.sourceName) { + return; + } + if (data.isReply) { + var callbackId = data.callbackId; + if (data.callbackId in callbacksCapabilities) { + var callback = callbacksCapabilities[callbackId]; + delete callbacksCapabilities[callbackId]; + if ('error' in data) { + callback.reject(data.error); + } else { + callback.resolve(data.data); + } + } else { + error('Cannot resolve callback ' + callbackId); + } + } else if (data.action in ah) { + var action = ah[data.action]; + if (data.callbackId) { + var sourceName = this.sourceName; + var targetName = data.sourceName; + Promise.resolve().then(function () { + return action[0].call(action[1], data.data); + }).then(function (result) { + comObj.postMessage({ + sourceName: sourceName, + targetName: targetName, + isReply: true, + callbackId: data.callbackId, + data: result + }); + }, function (reason) { + if (reason instanceof Error) { + reason = reason + ''; + } + comObj.postMessage({ + sourceName: sourceName, + targetName: targetName, + isReply: true, + callbackId: data.callbackId, + error: reason + }); + }); + } else { + action[0].call(action[1], data.data); + } + } else { + error('Unknown action from worker: ' + data.action); + } + }.bind(this); + comObj.addEventListener('message', this._onComObjOnMessage); +} +MessageHandler.prototype = { + on: function messageHandlerOn(actionName, handler, scope) { + var ah = this.actionHandler; + if (ah[actionName]) { + error('There is already an actionName called "' + actionName + '"'); + } + ah[actionName] = [handler, scope]; + }, + send: function messageHandlerSend(actionName, data, transfers) { + var message = { + sourceName: this.sourceName, + targetName: this.targetName, + action: actionName, + data: data + }; + this.postMessage(message, transfers); + }, + sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) { + var callbackId = this.callbackIndex++; + var message = { + sourceName: this.sourceName, + targetName: this.targetName, + action: actionName, + data: data, + callbackId: callbackId + }; + var capability = createPromiseCapability(); + this.callbacksCapabilities[callbackId] = capability; + try { + this.postMessage(message, transfers); + } catch (e) { + capability.reject(e); + } + return capability.promise; + }, + postMessage: function (message, transfers) { + if (transfers && this.postMessageTransfers) { + this.comObj.postMessage(message, transfers); + } else { + this.comObj.postMessage(message); + } + }, + destroy: function () { + this.comObj.removeEventListener('message', this._onComObjOnMessage); + } +}; +function loadJpegStream(id, imageUrl, objs) { + var img = new Image(); + img.onload = function loadJpegStream_onloadClosure() { + objs.resolve(id, img); + }; + img.onerror = function loadJpegStream_onerrorClosure() { + objs.resolve(id, null); + warn('Error during JPEG image loading'); + }; + img.src = imageUrl; +} +exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX; +exports.IDENTITY_MATRIX = IDENTITY_MATRIX; +exports.OPS = OPS; +exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS; +exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES; +exports.AnnotationBorderStyleType = AnnotationBorderStyleType; +exports.AnnotationFieldFlag = AnnotationFieldFlag; +exports.AnnotationFlag = AnnotationFlag; +exports.AnnotationType = AnnotationType; +exports.FontType = FontType; +exports.ImageKind = ImageKind; +exports.CMapCompressionType = CMapCompressionType; +exports.InvalidPDFException = InvalidPDFException; +exports.MessageHandler = MessageHandler; +exports.MissingDataException = MissingDataException; +exports.MissingPDFException = MissingPDFException; +exports.NotImplementedException = NotImplementedException; +exports.PageViewport = PageViewport; +exports.PasswordException = PasswordException; +exports.PasswordResponses = PasswordResponses; +exports.StatTimer = StatTimer; +exports.StreamType = StreamType; +exports.TextRenderingMode = TextRenderingMode; +exports.UnexpectedResponseException = UnexpectedResponseException; +exports.UnknownErrorException = UnknownErrorException; +exports.Util = Util; +exports.XRefParseException = XRefParseException; +exports.arrayByteLength = arrayByteLength; +exports.arraysToBytes = arraysToBytes; +exports.assert = assert; +exports.bytesToString = bytesToString; +exports.createBlob = createBlob; +exports.createPromiseCapability = createPromiseCapability; +exports.createObjectURL = createObjectURL; +exports.deprecated = deprecated; +exports.error = error; +exports.getLookupTableFactory = getLookupTableFactory; +exports.getVerbosityLevel = getVerbosityLevel; +exports.globalScope = globalScope; +exports.info = info; +exports.isArray = isArray; +exports.isArrayBuffer = isArrayBuffer; +exports.isBool = isBool; +exports.isEmptyObj = isEmptyObj; +exports.isInt = isInt; +exports.isNum = isNum; +exports.isString = isString; +exports.isSpace = isSpace; +exports.isNodeJS = isNodeJS; +exports.isSameOrigin = isSameOrigin; +exports.createValidAbsoluteUrl = createValidAbsoluteUrl; +exports.isLittleEndian = isLittleEndian; +exports.isEvalSupported = isEvalSupported; +exports.loadJpegStream = loadJpegStream; +exports.log2 = log2; +exports.readInt8 = readInt8; +exports.readUint16 = readUint16; +exports.readUint32 = readUint32; +exports.removeNullCharacters = removeNullCharacters; +exports.setVerbosityLevel = setVerbosityLevel; +exports.shadow = shadow; +exports.string32 = string32; +exports.stringToBytes = stringToBytes; +exports.stringToPDFString = stringToPDFString; +exports.stringToUTF8String = stringToUTF8String; +exports.utf8StringToString = utf8StringToString; +exports.warn = warn; +/* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(6))) + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var assert = sharedUtil.assert; +var removeNullCharacters = sharedUtil.removeNullCharacters; +var warn = sharedUtil.warn; +var deprecated = sharedUtil.deprecated; +var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl; +var stringToBytes = sharedUtil.stringToBytes; +var CMapCompressionType = sharedUtil.CMapCompressionType; +var DEFAULT_LINK_REL = 'noopener noreferrer nofollow'; +function DOMCanvasFactory() {} +DOMCanvasFactory.prototype = { + create: function DOMCanvasFactory_create(width, height) { + assert(width > 0 && height > 0, 'invalid canvas size'); + var canvas = document.createElement('canvas'); + var context = canvas.getContext('2d'); + canvas.width = width; + canvas.height = height; + return { + canvas: canvas, + context: context + }; + }, + reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) { + assert(canvasAndContextPair.canvas, 'canvas is not specified'); + assert(width > 0 && height > 0, 'invalid canvas size'); + canvasAndContextPair.canvas.width = width; + canvasAndContextPair.canvas.height = height; + }, + destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) { + assert(canvasAndContextPair.canvas, 'canvas is not specified'); + canvasAndContextPair.canvas.width = 0; + canvasAndContextPair.canvas.height = 0; + canvasAndContextPair.canvas = null; + canvasAndContextPair.context = null; + } +}; +var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() { + function DOMCMapReaderFactory(params) { + this.baseUrl = params.baseUrl || null; + this.isCompressed = params.isCompressed || false; + } + DOMCMapReaderFactory.prototype = { + fetch: function (params) { + var name = params.name; + if (!name) { + return Promise.reject(new Error('CMap name must be specified.')); + } + return new Promise(function (resolve, reject) { + var url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : ''); + var request = new XMLHttpRequest(); + request.open('GET', url, true); + if (this.isCompressed) { + request.responseType = 'arraybuffer'; + } + request.onreadystatechange = function () { + if (request.readyState !== XMLHttpRequest.DONE) { + return; + } + if (request.status === 200 || request.status === 0) { + var data; + if (this.isCompressed && request.response) { + data = new Uint8Array(request.response); + } else if (!this.isCompressed && request.responseText) { + data = stringToBytes(request.responseText); + } + if (data) { + resolve({ + cMapData: data, + compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE + }); + return; + } + } + reject(new Error('Unable to load ' + (this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url)); + }.bind(this); + request.send(null); + }.bind(this)); + } + }; + return DOMCMapReaderFactory; +}(); +var CustomStyle = function CustomStyleClosure() { + var prefixes = ['ms', 'Moz', 'Webkit', 'O']; + var _cache = Object.create(null); + function CustomStyle() {} + CustomStyle.getProp = function get(propName, element) { + if (arguments.length === 1 && typeof _cache[propName] === 'string') { + return _cache[propName]; + } + element = element || document.documentElement; + var style = element.style, + prefixed, + uPropName; + if (typeof style[propName] === 'string') { + return _cache[propName] = propName; + } + uPropName = propName.charAt(0).toUpperCase() + propName.slice(1); + for (var i = 0, l = prefixes.length; i < l; i++) { + prefixed = prefixes[i] + uPropName; + if (typeof style[prefixed] === 'string') { + return _cache[propName] = prefixed; + } + } + return _cache[propName] = 'undefined'; + }; + CustomStyle.setProp = function set(propName, element, str) { + var prop = this.getProp(propName); + if (prop !== 'undefined') { + element.style[prop] = str; + } + }; + return CustomStyle; +}(); +var RenderingCancelledException = function RenderingCancelledException() { + function RenderingCancelledException(msg, type) { + this.message = msg; + this.type = type; + } + RenderingCancelledException.prototype = new Error(); + RenderingCancelledException.prototype.name = 'RenderingCancelledException'; + RenderingCancelledException.constructor = RenderingCancelledException; + return RenderingCancelledException; +}(); +var hasCanvasTypedArrays; +hasCanvasTypedArrays = function hasCanvasTypedArrays() { + var canvas = document.createElement('canvas'); + canvas.width = canvas.height = 1; + var ctx = canvas.getContext('2d'); + var imageData = ctx.createImageData(1, 1); + return typeof imageData.data.buffer !== 'undefined'; +}; +var LinkTarget = { + NONE: 0, + SELF: 1, + BLANK: 2, + PARENT: 3, + TOP: 4 +}; +var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top']; +function addLinkAttributes(link, params) { + var url = params && params.url; + link.href = link.title = url ? removeNullCharacters(url) : ''; + if (url) { + var target = params.target; + if (typeof target === 'undefined') { + target = getDefaultSetting('externalLinkTarget'); + } + link.target = LinkTargetStringMap[target]; + var rel = params.rel; + if (typeof rel === 'undefined') { + rel = getDefaultSetting('externalLinkRel'); + } + link.rel = rel; + } +} +function getFilenameFromUrl(url) { + var anchor = url.indexOf('#'); + var query = url.indexOf('?'); + var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length); + return url.substring(url.lastIndexOf('/', end) + 1, end); +} +function getDefaultSetting(id) { + var globalSettings = sharedUtil.globalScope.PDFJS; + switch (id) { + case 'pdfBug': + return globalSettings ? globalSettings.pdfBug : false; + case 'disableAutoFetch': + return globalSettings ? globalSettings.disableAutoFetch : false; + case 'disableStream': + return globalSettings ? globalSettings.disableStream : false; + case 'disableRange': + return globalSettings ? globalSettings.disableRange : false; + case 'disableFontFace': + return globalSettings ? globalSettings.disableFontFace : false; + case 'disableCreateObjectURL': + return globalSettings ? globalSettings.disableCreateObjectURL : false; + case 'disableWebGL': + return globalSettings ? globalSettings.disableWebGL : true; + case 'cMapUrl': + return globalSettings ? globalSettings.cMapUrl : null; + case 'cMapPacked': + return globalSettings ? globalSettings.cMapPacked : false; + case 'postMessageTransfers': + return globalSettings ? globalSettings.postMessageTransfers : true; + case 'workerPort': + return globalSettings ? globalSettings.workerPort : null; + case 'workerSrc': + return globalSettings ? globalSettings.workerSrc : null; + case 'disableWorker': + return globalSettings ? globalSettings.disableWorker : false; + case 'maxImageSize': + return globalSettings ? globalSettings.maxImageSize : -1; + case 'imageResourcesPath': + return globalSettings ? globalSettings.imageResourcesPath : ''; + case 'isEvalSupported': + return globalSettings ? globalSettings.isEvalSupported : true; + case 'externalLinkTarget': + if (!globalSettings) { + return LinkTarget.NONE; + } + switch (globalSettings.externalLinkTarget) { + case LinkTarget.NONE: + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return globalSettings.externalLinkTarget; + } + warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget); + globalSettings.externalLinkTarget = LinkTarget.NONE; + return LinkTarget.NONE; + case 'externalLinkRel': + return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL; + case 'enableStats': + return !!(globalSettings && globalSettings.enableStats); + case 'pdfjsNext': + return !!(globalSettings && globalSettings.pdfjsNext); + default: + throw new Error('Unknown default setting: ' + id); + } +} +function isExternalLinkTargetSet() { + var externalLinkTarget = getDefaultSetting('externalLinkTarget'); + switch (externalLinkTarget) { + case LinkTarget.NONE: + return false; + case LinkTarget.SELF: + case LinkTarget.BLANK: + case LinkTarget.PARENT: + case LinkTarget.TOP: + return true; + } +} +function isValidUrl(url, allowRelative) { + deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.'); + var baseUrl = allowRelative ? 'http://example.com' : null; + return createValidAbsoluteUrl(url, baseUrl) !== null; +} +exports.CustomStyle = CustomStyle; +exports.addLinkAttributes = addLinkAttributes; +exports.isExternalLinkTargetSet = isExternalLinkTargetSet; +exports.isValidUrl = isValidUrl; +exports.getFilenameFromUrl = getFilenameFromUrl; +exports.LinkTarget = LinkTarget; +exports.RenderingCancelledException = RenderingCancelledException; +exports.hasCanvasTypedArrays = hasCanvasTypedArrays; +exports.getDefaultSetting = getDefaultSetting; +exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL; +exports.DOMCanvasFactory = DOMCanvasFactory; +exports.DOMCMapReaderFactory = DOMCMapReaderFactory; + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayDOMUtils = __w_pdfjs_require__(1); +var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType; +var AnnotationType = sharedUtil.AnnotationType; +var stringToPDFString = sharedUtil.stringToPDFString; +var Util = sharedUtil.Util; +var addLinkAttributes = displayDOMUtils.addLinkAttributes; +var LinkTarget = displayDOMUtils.LinkTarget; +var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; +var warn = sharedUtil.warn; +var CustomStyle = displayDOMUtils.CustomStyle; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; +function AnnotationElementFactory() {} +AnnotationElementFactory.prototype = { + create: function AnnotationElementFactory_create(parameters) { + var subtype = parameters.data.annotationType; + switch (subtype) { + case AnnotationType.LINK: + return new LinkAnnotationElement(parameters); + case AnnotationType.TEXT: + return new TextAnnotationElement(parameters); + case AnnotationType.WIDGET: + var fieldType = parameters.data.fieldType; + switch (fieldType) { + case 'Tx': + return new TextWidgetAnnotationElement(parameters); + case 'Btn': + if (parameters.data.radioButton) { + return new RadioButtonWidgetAnnotationElement(parameters); + } else if (parameters.data.checkBox) { + return new CheckboxWidgetAnnotationElement(parameters); + } + warn('Unimplemented button widget annotation: pushbutton'); + break; + case 'Ch': + return new ChoiceWidgetAnnotationElement(parameters); + } + return new WidgetAnnotationElement(parameters); + case AnnotationType.POPUP: + return new PopupAnnotationElement(parameters); + case AnnotationType.HIGHLIGHT: + return new HighlightAnnotationElement(parameters); + case AnnotationType.UNDERLINE: + return new UnderlineAnnotationElement(parameters); + case AnnotationType.SQUIGGLY: + return new SquigglyAnnotationElement(parameters); + case AnnotationType.STRIKEOUT: + return new StrikeOutAnnotationElement(parameters); + case AnnotationType.FILEATTACHMENT: + return new FileAttachmentAnnotationElement(parameters); + default: + return new AnnotationElement(parameters); + } + } +}; +var AnnotationElement = function AnnotationElementClosure() { + function AnnotationElement(parameters, isRenderable) { + this.isRenderable = isRenderable || false; + this.data = parameters.data; + this.layer = parameters.layer; + this.page = parameters.page; + this.viewport = parameters.viewport; + this.linkService = parameters.linkService; + this.downloadManager = parameters.downloadManager; + this.imageResourcesPath = parameters.imageResourcesPath; + this.renderInteractiveForms = parameters.renderInteractiveForms; + if (isRenderable) { + this.container = this._createContainer(); + } + } + AnnotationElement.prototype = { + _createContainer: function AnnotationElement_createContainer() { + var data = this.data, + page = this.page, + viewport = this.viewport; + var container = document.createElement('section'); + var width = data.rect[2] - data.rect[0]; + var height = data.rect[3] - data.rect[1]; + container.setAttribute('data-annotation-id', data.id); + var rect = 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]]); + CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')'); + CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px'); + if (data.borderStyle.width > 0) { + container.style.borderWidth = data.borderStyle.width + 'px'; + if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) { + width = width - 2 * data.borderStyle.width; + height = height - 2 * data.borderStyle.width; + } + var horizontalRadius = data.borderStyle.horizontalCornerRadius; + var verticalRadius = data.borderStyle.verticalCornerRadius; + if (horizontalRadius > 0 || verticalRadius > 0) { + var radius = horizontalRadius + 'px / ' + verticalRadius + 'px'; + CustomStyle.setProp('borderRadius', container, radius); + } + switch (data.borderStyle.style) { + case AnnotationBorderStyleType.SOLID: + container.style.borderStyle = 'solid'; + break; + case AnnotationBorderStyleType.DASHED: + container.style.borderStyle = 'dashed'; + break; + case AnnotationBorderStyleType.BEVELED: + warn('Unimplemented border style: beveled'); + break; + case AnnotationBorderStyleType.INSET: + warn('Unimplemented border style: inset'); + break; + case AnnotationBorderStyleType.UNDERLINE: + container.style.borderBottomStyle = 'solid'; + break; + default: + break; + } + if (data.color) { + container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0); + } else { + container.style.borderWidth = 0; + } + } + container.style.left = rect[0] + 'px'; + container.style.top = rect[1] + 'px'; + container.style.width = width + 'px'; + container.style.height = height + 'px'; + return container; + }, + _createPopup: function AnnotationElement_createPopup(container, trigger, data) { + if (!trigger) { + trigger = document.createElement('div'); + trigger.style.height = container.style.height; + trigger.style.width = container.style.width; + container.appendChild(trigger); + } + var popupElement = new PopupElement({ + container: container, + trigger: trigger, + color: data.color, + title: data.title, + contents: data.contents, + hideWrapper: true + }); + var popup = popupElement.render(); + popup.style.left = container.style.width; + container.appendChild(popup); + }, + render: function AnnotationElement_render() { + throw new Error('Abstract method AnnotationElement.render called'); + } + }; + return AnnotationElement; +}(); +var LinkAnnotationElement = function LinkAnnotationElementClosure() { + function LinkAnnotationElement(parameters) { + AnnotationElement.call(this, parameters, true); + } + Util.inherit(LinkAnnotationElement, AnnotationElement, { + render: function LinkAnnotationElement_render() { + this.container.className = 'linkAnnotation'; + var link = document.createElement('a'); + addLinkAttributes(link, { + url: this.data.url, + target: this.data.newWindow ? LinkTarget.BLANK : undefined + }); + if (!this.data.url) { + if (this.data.action) { + this._bindNamedAction(link, this.data.action); + } else { + this._bindLink(link, this.data.dest); + } + } + this.container.appendChild(link); + return this.container; + }, + _bindLink: function LinkAnnotationElement_bindLink(link, destination) { + var self = this; + link.href = this.linkService.getDestinationHash(destination); + link.onclick = function () { + if (destination) { + self.linkService.navigateTo(destination); + } + return false; + }; + if (destination) { + link.className = 'internalLink'; + } + }, + _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) { + var self = this; + link.href = this.linkService.getAnchorUrl(''); + link.onclick = function () { + self.linkService.executeNamedAction(action); + return false; + }; + link.className = 'internalLink'; + } + }); + return LinkAnnotationElement; +}(); +var TextAnnotationElement = function TextAnnotationElementClosure() { + function TextAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(TextAnnotationElement, AnnotationElement, { + render: function TextAnnotationElement_render() { + this.container.className = 'textAnnotation'; + var image = document.createElement('img'); + image.style.height = this.container.style.height; + image.style.width = this.container.style.width; + image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg'; + image.alt = '[{{type}} Annotation]'; + image.dataset.l10nId = 'text_annotation_type'; + image.dataset.l10nArgs = JSON.stringify({ type: this.data.name }); + if (!this.data.hasPopup) { + this._createPopup(this.container, image, this.data); + } + this.container.appendChild(image); + return this.container; + } + }); + return TextAnnotationElement; +}(); +var WidgetAnnotationElement = function WidgetAnnotationElementClosure() { + function WidgetAnnotationElement(parameters, isRenderable) { + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(WidgetAnnotationElement, AnnotationElement, { + render: function WidgetAnnotationElement_render() { + return this.container; + } + }); + return WidgetAnnotationElement; +}(); +var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() { + var TEXT_ALIGNMENT = ['left', 'center', 'right']; + function TextWidgetAnnotationElement(parameters) { + var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue; + WidgetAnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, { + render: function TextWidgetAnnotationElement_render() { + this.container.className = 'textWidgetAnnotation'; + var element = null; + if (this.renderInteractiveForms) { + if (this.data.multiLine) { + element = document.createElement('textarea'); + element.textContent = this.data.fieldValue; + } else { + element = document.createElement('input'); + element.type = 'text'; + element.setAttribute('value', this.data.fieldValue); + } + element.disabled = this.data.readOnly; + if (this.data.maxLen !== null) { + element.maxLength = this.data.maxLen; + } + if (this.data.comb) { + var fieldWidth = this.data.rect[2] - this.data.rect[0]; + var combWidth = fieldWidth / this.data.maxLen; + element.classList.add('comb'); + element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)'; + } + } else { + element = document.createElement('div'); + element.textContent = this.data.fieldValue; + element.style.verticalAlign = 'middle'; + element.style.display = 'table-cell'; + var font = null; + if (this.data.fontRefName) { + font = this.page.commonObjs.getData(this.data.fontRefName); + } + this._setTextStyle(element, font); + } + if (this.data.textAlignment !== null) { + element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment]; + } + this.container.appendChild(element); + return this.container; + }, + _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) { + var style = element.style; + style.fontSize = this.data.fontSize + 'px'; + style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr'; + if (!font) { + return; + } + style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal'; + style.fontStyle = font.italic ? 'italic' : 'normal'; + var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : ''; + var fallbackName = font.fallbackName || 'Helvetica, sans-serif'; + style.fontFamily = fontFamily + fallbackName; + } + }); + return TextWidgetAnnotationElement; +}(); +var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() { + function CheckboxWidgetAnnotationElement(parameters) { + WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); + } + Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, { + render: function CheckboxWidgetAnnotationElement_render() { + this.container.className = 'buttonWidgetAnnotation checkBox'; + var element = document.createElement('input'); + element.disabled = this.data.readOnly; + element.type = 'checkbox'; + if (this.data.fieldValue && this.data.fieldValue !== 'Off') { + element.setAttribute('checked', true); + } + this.container.appendChild(element); + return this.container; + } + }); + return CheckboxWidgetAnnotationElement; +}(); +var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() { + function RadioButtonWidgetAnnotationElement(parameters) { + WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); + } + Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, { + render: function RadioButtonWidgetAnnotationElement_render() { + this.container.className = 'buttonWidgetAnnotation radioButton'; + var element = document.createElement('input'); + element.disabled = this.data.readOnly; + element.type = 'radio'; + element.name = this.data.fieldName; + if (this.data.fieldValue === this.data.buttonValue) { + element.setAttribute('checked', true); + } + this.container.appendChild(element); + return this.container; + } + }); + return RadioButtonWidgetAnnotationElement; +}(); +var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() { + function ChoiceWidgetAnnotationElement(parameters) { + WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); + } + Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, { + render: function ChoiceWidgetAnnotationElement_render() { + this.container.className = 'choiceWidgetAnnotation'; + var selectElement = document.createElement('select'); + selectElement.disabled = this.data.readOnly; + if (!this.data.combo) { + selectElement.size = this.data.options.length; + if (this.data.multiSelect) { + selectElement.multiple = true; + } + } + for (var i = 0, ii = this.data.options.length; i < ii; i++) { + var option = this.data.options[i]; + var optionElement = document.createElement('option'); + optionElement.textContent = option.displayValue; + optionElement.value = option.exportValue; + if (this.data.fieldValue.indexOf(option.displayValue) >= 0) { + optionElement.setAttribute('selected', true); + } + selectElement.appendChild(optionElement); + } + this.container.appendChild(selectElement); + return this.container; + } + }); + return ChoiceWidgetAnnotationElement; +}(); +var PopupAnnotationElement = function PopupAnnotationElementClosure() { + function PopupAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(PopupAnnotationElement, AnnotationElement, { + render: function PopupAnnotationElement_render() { + this.container.className = 'popupAnnotation'; + var selector = '[data-annotation-id="' + this.data.parentId + '"]'; + var parentElement = this.layer.querySelector(selector); + if (!parentElement) { + return this.container; + } + var popup = new PopupElement({ + container: this.container, + trigger: parentElement, + color: this.data.color, + title: this.data.title, + contents: this.data.contents + }); + var parentLeft = parseFloat(parentElement.style.left); + var parentWidth = parseFloat(parentElement.style.width); + CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top); + this.container.style.left = parentLeft + parentWidth + 'px'; + this.container.appendChild(popup.render()); + return this.container; + } + }); + return PopupAnnotationElement; +}(); +var PopupElement = function PopupElementClosure() { + var BACKGROUND_ENLIGHT = 0.7; + function PopupElement(parameters) { + this.container = parameters.container; + this.trigger = parameters.trigger; + this.color = parameters.color; + this.title = parameters.title; + this.contents = parameters.contents; + this.hideWrapper = parameters.hideWrapper || false; + this.pinned = false; + } + PopupElement.prototype = { + render: function PopupElement_render() { + var wrapper = document.createElement('div'); + wrapper.className = 'popupWrapper'; + this.hideElement = this.hideWrapper ? wrapper : this.container; + this.hideElement.setAttribute('hidden', true); + var popup = document.createElement('div'); + popup.className = 'popup'; + var color = this.color; + if (color) { + var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0]; + var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1]; + var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2]; + popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0); + } + var contents = this._formatContents(this.contents); + var title = document.createElement('h1'); + title.textContent = this.title; + this.trigger.addEventListener('click', this._toggle.bind(this)); + this.trigger.addEventListener('mouseover', this._show.bind(this, false)); + this.trigger.addEventListener('mouseout', this._hide.bind(this, false)); + popup.addEventListener('click', this._hide.bind(this, true)); + popup.appendChild(title); + popup.appendChild(contents); + wrapper.appendChild(popup); + return wrapper; + }, + _formatContents: function PopupElement_formatContents(contents) { + var p = document.createElement('p'); + var lines = contents.split(/(?:\r\n?|\n)/); + for (var i = 0, ii = lines.length; i < ii; ++i) { + var line = lines[i]; + p.appendChild(document.createTextNode(line)); + if (i < ii - 1) { + p.appendChild(document.createElement('br')); + } + } + return p; + }, + _toggle: function PopupElement_toggle() { + if (this.pinned) { + this._hide(true); + } else { + this._show(true); + } + }, + _show: function PopupElement_show(pin) { + if (pin) { + this.pinned = true; + } + if (this.hideElement.hasAttribute('hidden')) { + this.hideElement.removeAttribute('hidden'); + this.container.style.zIndex += 1; + } + }, + _hide: function PopupElement_hide(unpin) { + if (unpin) { + this.pinned = false; + } + if (!this.hideElement.hasAttribute('hidden') && !this.pinned) { + this.hideElement.setAttribute('hidden', true); + this.container.style.zIndex -= 1; + } + } + }; + return PopupElement; +}(); +var HighlightAnnotationElement = function HighlightAnnotationElementClosure() { + function HighlightAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(HighlightAnnotationElement, AnnotationElement, { + render: function HighlightAnnotationElement_render() { + this.container.className = 'highlightAnnotation'; + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + return this.container; + } + }); + return HighlightAnnotationElement; +}(); +var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() { + function UnderlineAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(UnderlineAnnotationElement, AnnotationElement, { + render: function UnderlineAnnotationElement_render() { + this.container.className = 'underlineAnnotation'; + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + return this.container; + } + }); + return UnderlineAnnotationElement; +}(); +var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() { + function SquigglyAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(SquigglyAnnotationElement, AnnotationElement, { + render: function SquigglyAnnotationElement_render() { + this.container.className = 'squigglyAnnotation'; + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + return this.container; + } + }); + return SquigglyAnnotationElement; +}(); +var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() { + function StrikeOutAnnotationElement(parameters) { + var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); + AnnotationElement.call(this, parameters, isRenderable); + } + Util.inherit(StrikeOutAnnotationElement, AnnotationElement, { + render: function StrikeOutAnnotationElement_render() { + this.container.className = 'strikeoutAnnotation'; + if (!this.data.hasPopup) { + this._createPopup(this.container, null, this.data); + } + return this.container; + } + }); + return StrikeOutAnnotationElement; +}(); +var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() { + function FileAttachmentAnnotationElement(parameters) { + AnnotationElement.call(this, parameters, true); + var file = this.data.file; + this.filename = getFilenameFromUrl(file.filename); + this.content = file.content; + this.linkService.onFileAttachmentAnnotation({ + id: stringToPDFString(file.filename), + filename: file.filename, + content: file.content + }); + } + Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, { + render: function FileAttachmentAnnotationElement_render() { + this.container.className = 'fileAttachmentAnnotation'; + var trigger = document.createElement('div'); + trigger.style.height = this.container.style.height; + trigger.style.width = this.container.style.width; + trigger.addEventListener('dblclick', this._download.bind(this)); + if (!this.data.hasPopup && (this.data.title || this.data.contents)) { + this._createPopup(this.container, trigger, this.data); + } + this.container.appendChild(trigger); + return this.container; + }, + _download: function FileAttachmentAnnotationElement_download() { + if (!this.downloadManager) { + warn('Download cannot be started due to unavailable download manager'); + return; + } + this.downloadManager.downloadData(this.content, this.filename, ''); + } + }); + return FileAttachmentAnnotationElement; +}(); +var AnnotationLayer = function AnnotationLayerClosure() { + return { + render: function AnnotationLayer_render(parameters) { + var annotationElementFactory = new AnnotationElementFactory(); + for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { + var data = parameters.annotations[i]; + if (!data) { + continue; + } + var element = annotationElementFactory.create({ + data: data, + layer: parameters.div, + page: parameters.page, + viewport: parameters.viewport, + linkService: parameters.linkService, + downloadManager: parameters.downloadManager, + imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'), + renderInteractiveForms: parameters.renderInteractiveForms || false + }); + if (element.isRenderable) { + parameters.div.appendChild(element.render()); + } + } + }, + update: function AnnotationLayer_update(parameters) { + for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { + var data = parameters.annotations[i]; + var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]'); + if (element) { + CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')'); + } + } + parameters.div.removeAttribute('hidden'); + } + }; +}(); +exports.AnnotationLayer = AnnotationLayer; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayFontLoader = __w_pdfjs_require__(11); +var displayCanvas = __w_pdfjs_require__(10); +var displayMetadata = __w_pdfjs_require__(7); +var displayDOMUtils = __w_pdfjs_require__(1); +var amdRequire; +var InvalidPDFException = sharedUtil.InvalidPDFException; +var MessageHandler = sharedUtil.MessageHandler; +var MissingPDFException = sharedUtil.MissingPDFException; +var PageViewport = sharedUtil.PageViewport; +var PasswordException = sharedUtil.PasswordException; +var StatTimer = sharedUtil.StatTimer; +var UnexpectedResponseException = sharedUtil.UnexpectedResponseException; +var UnknownErrorException = sharedUtil.UnknownErrorException; +var Util = sharedUtil.Util; +var createPromiseCapability = sharedUtil.createPromiseCapability; +var error = sharedUtil.error; +var deprecated = sharedUtil.deprecated; +var getVerbosityLevel = sharedUtil.getVerbosityLevel; +var info = sharedUtil.info; +var isInt = sharedUtil.isInt; +var isArray = sharedUtil.isArray; +var isArrayBuffer = sharedUtil.isArrayBuffer; +var isSameOrigin = sharedUtil.isSameOrigin; +var loadJpegStream = sharedUtil.loadJpegStream; +var stringToBytes = sharedUtil.stringToBytes; +var globalScope = sharedUtil.globalScope; +var warn = sharedUtil.warn; +var FontFaceObject = displayFontLoader.FontFaceObject; +var FontLoader = displayFontLoader.FontLoader; +var CanvasGraphics = displayCanvas.CanvasGraphics; +var Metadata = displayMetadata.Metadata; +var RenderingCancelledException = displayDOMUtils.RenderingCancelledException; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; +var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory; +var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory; +var DEFAULT_RANGE_CHUNK_SIZE = 65536; +var isWorkerDisabled = false; +var workerSrc; +var isPostMessageTransfersDisabled = false; +var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; +var fakeWorkerFilesLoader = null; +var useRequireEnsure = false; +if (typeof __pdfjsdev_webpack__ === 'undefined') { + if (typeof window === 'undefined') { + isWorkerDisabled = true; + if (typeof require.ensure === 'undefined') { + require.ensure = require('node-ensure'); + } + useRequireEnsure = true; + } else if (typeof require !== 'undefined' && typeof require.ensure === 'function') { + useRequireEnsure = true; + } + if (typeof requirejs !== 'undefined' && requirejs.toUrl) { + workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js'); + } + var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load; + fakeWorkerFilesLoader = useRequireEnsure ? function (callback) { + require.ensure([], function () { + var worker = require('./pdf.worker.js'); + callback(worker.WorkerMessageHandler); + }); + } : dynamicLoaderSupported ? function (callback) { + requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) { + callback(worker.WorkerMessageHandler); + }); + } : null; +} +function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) { + var task = new PDFDocumentLoadingTask(); + if (arguments.length > 1) { + deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument'); + } + if (pdfDataRangeTransport) { + if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) { + pdfDataRangeTransport = Object.create(pdfDataRangeTransport); + pdfDataRangeTransport.length = src.length; + pdfDataRangeTransport.initialData = src.initialData; + if (!pdfDataRangeTransport.abort) { + pdfDataRangeTransport.abort = function () {}; + } + } + src = Object.create(src); + src.range = pdfDataRangeTransport; + } + task.onPassword = passwordCallback || null; + task.onProgress = progressCallback || null; + var source; + if (typeof src === 'string') { + source = { url: src }; + } else if (isArrayBuffer(src)) { + source = { data: src }; + } else if (src instanceof PDFDataRangeTransport) { + source = { range: src }; + } else { + if (typeof src !== 'object') { + error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object'); + } + if (!src.url && !src.data && !src.range) { + error('Invalid parameter object: need either .data, .range or .url'); + } + source = src; + } + var params = {}; + var rangeTransport = null; + var worker = null; + for (var key in source) { + if (key === 'url' && typeof window !== 'undefined') { + params[key] = new URL(source[key], window.location).href; + continue; + } else if (key === 'range') { + rangeTransport = source[key]; + continue; + } else if (key === 'worker') { + worker = source[key]; + continue; + } else if (key === 'data' && !(source[key] instanceof Uint8Array)) { + var pdfBytes = source[key]; + if (typeof pdfBytes === 'string') { + params[key] = stringToBytes(pdfBytes); + } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) { + params[key] = new Uint8Array(pdfBytes); + } else if (isArrayBuffer(pdfBytes)) { + params[key] = new Uint8Array(pdfBytes); + } else { + error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.'); + } + continue; + } + params[key] = source[key]; + } + params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; + params.disableNativeImageDecoder = params.disableNativeImageDecoder === true; + var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory; + if (!worker) { + var workerPort = getDefaultSetting('workerPort'); + worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker(); + task._worker = worker; + } + var docId = task.docId; + worker.promise.then(function () { + if (task.destroyed) { + throw new Error('Loading aborted'); + } + return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) { + if (task.destroyed) { + throw new Error('Loading aborted'); + } + var messageHandler = new MessageHandler(docId, workerId, worker.port); + var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory); + task._transport = transport; + messageHandler.send('Ready', null); + }); + }).catch(task._capability.reject); + return task; +} +function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { + if (worker.destroyed) { + return Promise.reject(new Error('Worker was destroyed')); + } + source.disableAutoFetch = getDefaultSetting('disableAutoFetch'); + source.disableStream = getDefaultSetting('disableStream'); + source.chunkedViewerLoading = !!pdfDataRangeTransport; + if (pdfDataRangeTransport) { + source.length = pdfDataRangeTransport.length; + source.initialData = pdfDataRangeTransport.initialData; + } + return worker.messageHandler.sendWithPromise('GetDocRequest', { + docId: docId, + source: source, + disableRange: getDefaultSetting('disableRange'), + maxImageSize: getDefaultSetting('maxImageSize'), + disableFontFace: getDefaultSetting('disableFontFace'), + disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'), + postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled, + docBaseUrl: source.docBaseUrl, + disableNativeImageDecoder: source.disableNativeImageDecoder + }).then(function (workerId) { + if (worker.destroyed) { + throw new Error('Worker was destroyed'); + } + return workerId; + }); +} +var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() { + var nextDocumentId = 0; + function PDFDocumentLoadingTask() { + this._capability = createPromiseCapability(); + this._transport = null; + this._worker = null; + this.docId = 'd' + nextDocumentId++; + this.destroyed = false; + this.onPassword = null; + this.onProgress = null; + this.onUnsupportedFeature = null; + } + PDFDocumentLoadingTask.prototype = { + get promise() { + return this._capability.promise; + }, + destroy: function () { + this.destroyed = true; + var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy(); + return transportDestroyed.then(function () { + this._transport = null; + if (this._worker) { + this._worker.destroy(); + this._worker = null; + } + }.bind(this)); + }, + then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) { + return this.promise.then.apply(this.promise, arguments); + } + }; + return PDFDocumentLoadingTask; +}(); +var PDFDataRangeTransport = function pdfDataRangeTransportClosure() { + function PDFDataRangeTransport(length, initialData) { + this.length = length; + this.initialData = initialData; + this._rangeListeners = []; + this._progressListeners = []; + this._progressiveReadListeners = []; + this._readyCapability = createPromiseCapability(); + } + PDFDataRangeTransport.prototype = { + addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) { + this._rangeListeners.push(listener); + }, + addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) { + this._progressListeners.push(listener); + }, + addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) { + this._progressiveReadListeners.push(listener); + }, + onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) { + var listeners = this._rangeListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](begin, chunk); + } + }, + onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) { + this._readyCapability.promise.then(function () { + var listeners = this._progressListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](loaded); + } + }.bind(this)); + }, + onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) { + this._readyCapability.promise.then(function () { + var listeners = this._progressiveReadListeners; + for (var i = 0, n = listeners.length; i < n; ++i) { + listeners[i](chunk); + } + }.bind(this)); + }, + transportReady: function PDFDataRangeTransport_transportReady() { + this._readyCapability.resolve(); + }, + requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) { + throw new Error('Abstract method PDFDataRangeTransport.requestDataRange'); + }, + abort: function PDFDataRangeTransport_abort() {} + }; + return PDFDataRangeTransport; +}(); +var PDFDocumentProxy = function PDFDocumentProxyClosure() { + function PDFDocumentProxy(pdfInfo, transport, loadingTask) { + this.pdfInfo = pdfInfo; + this.transport = transport; + this.loadingTask = loadingTask; + } + PDFDocumentProxy.prototype = { + get numPages() { + return this.pdfInfo.numPages; + }, + get fingerprint() { + return this.pdfInfo.fingerprint; + }, + getPage: function PDFDocumentProxy_getPage(pageNumber) { + return this.transport.getPage(pageNumber); + }, + getPageIndex: function PDFDocumentProxy_getPageIndex(ref) { + return this.transport.getPageIndex(ref); + }, + getDestinations: function PDFDocumentProxy_getDestinations() { + return this.transport.getDestinations(); + }, + getDestination: function PDFDocumentProxy_getDestination(id) { + return this.transport.getDestination(id); + }, + getPageLabels: function PDFDocumentProxy_getPageLabels() { + return this.transport.getPageLabels(); + }, + getAttachments: function PDFDocumentProxy_getAttachments() { + return this.transport.getAttachments(); + }, + getJavaScript: function PDFDocumentProxy_getJavaScript() { + return this.transport.getJavaScript(); + }, + getOutline: function PDFDocumentProxy_getOutline() { + return this.transport.getOutline(); + }, + getMetadata: function PDFDocumentProxy_getMetadata() { + return this.transport.getMetadata(); + }, + getData: function PDFDocumentProxy_getData() { + return this.transport.getData(); + }, + getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() { + return this.transport.downloadInfoCapability.promise; + }, + getStats: function PDFDocumentProxy_getStats() { + return this.transport.getStats(); + }, + cleanup: function PDFDocumentProxy_cleanup() { + this.transport.startCleanup(); + }, + destroy: function PDFDocumentProxy_destroy() { + return this.loadingTask.destroy(); + } + }; + return PDFDocumentProxy; +}(); +var PDFPageProxy = function PDFPageProxyClosure() { + function PDFPageProxy(pageIndex, pageInfo, transport) { + this.pageIndex = pageIndex; + this.pageInfo = pageInfo; + this.transport = transport; + this.stats = new StatTimer(); + this.stats.enabled = getDefaultSetting('enableStats'); + this.commonObjs = transport.commonObjs; + this.objs = new PDFObjects(); + this.cleanupAfterRender = false; + this.pendingCleanup = false; + this.intentStates = Object.create(null); + this.destroyed = false; + } + PDFPageProxy.prototype = { + get pageNumber() { + return this.pageIndex + 1; + }, + get rotate() { + return this.pageInfo.rotate; + }, + get ref() { + return this.pageInfo.ref; + }, + get userUnit() { + return this.pageInfo.userUnit; + }, + get view() { + return this.pageInfo.view; + }, + getViewport: function PDFPageProxy_getViewport(scale, rotate) { + if (arguments.length < 2) { + rotate = this.rotate; + } + return new PageViewport(this.view, scale, rotate, 0, 0); + }, + getAnnotations: function PDFPageProxy_getAnnotations(params) { + var intent = params && params.intent || null; + if (!this.annotationsPromise || this.annotationsIntent !== intent) { + this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent); + this.annotationsIntent = intent; + } + return this.annotationsPromise; + }, + render: function PDFPageProxy_render(params) { + var stats = this.stats; + stats.time('Overall'); + this.pendingCleanup = false; + var renderingIntent = params.intent === 'print' ? 'print' : 'display'; + var renderInteractiveForms = params.renderInteractiveForms === true ? true : false; + var canvasFactory = params.canvasFactory || new DOMCanvasFactory(); + if (!this.intentStates[renderingIntent]) { + this.intentStates[renderingIntent] = Object.create(null); + } + var intentState = this.intentStates[renderingIntent]; + if (!intentState.displayReadyCapability) { + intentState.receivingOperatorList = true; + intentState.displayReadyCapability = createPromiseCapability(); + intentState.operatorList = { + fnArray: [], + argsArray: [], + lastChunk: false + }; + this.stats.time('Page Request'); + this.transport.messageHandler.send('RenderPageRequest', { + pageIndex: this.pageNumber - 1, + intent: renderingIntent, + renderInteractiveForms: renderInteractiveForms + }); + } + var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory); + internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print'; + if (!intentState.renderTasks) { + intentState.renderTasks = []; + } + intentState.renderTasks.push(internalRenderTask); + var renderTask = internalRenderTask.task; + if (params.continueCallback) { + deprecated('render is used with continueCallback parameter'); + renderTask.onContinue = params.continueCallback; + } + var self = this; + intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) { + if (self.pendingCleanup) { + complete(); + return; + } + stats.time('Rendering'); + internalRenderTask.initializeGraphics(transparency); + internalRenderTask.operatorListChanged(); + }, function pageDisplayReadPromiseError(reason) { + complete(reason); + }); + function complete(error) { + var i = intentState.renderTasks.indexOf(internalRenderTask); + if (i >= 0) { + intentState.renderTasks.splice(i, 1); + } + if (self.cleanupAfterRender) { + self.pendingCleanup = true; + } + self._tryCleanup(); + if (error) { + internalRenderTask.capability.reject(error); + } else { + internalRenderTask.capability.resolve(); + } + stats.timeEnd('Rendering'); + stats.timeEnd('Overall'); + } + return renderTask; + }, + getOperatorList: function PDFPageProxy_getOperatorList() { + function operatorListChanged() { + if (intentState.operatorList.lastChunk) { + intentState.opListReadCapability.resolve(intentState.operatorList); + var i = intentState.renderTasks.indexOf(opListTask); + if (i >= 0) { + intentState.renderTasks.splice(i, 1); + } + } + } + var renderingIntent = 'oplist'; + if (!this.intentStates[renderingIntent]) { + this.intentStates[renderingIntent] = Object.create(null); + } + var intentState = this.intentStates[renderingIntent]; + var opListTask; + if (!intentState.opListReadCapability) { + opListTask = {}; + opListTask.operatorListChanged = operatorListChanged; + intentState.receivingOperatorList = true; + intentState.opListReadCapability = createPromiseCapability(); + intentState.renderTasks = []; + intentState.renderTasks.push(opListTask); + intentState.operatorList = { + fnArray: [], + argsArray: [], + lastChunk: false + }; + this.transport.messageHandler.send('RenderPageRequest', { + pageIndex: this.pageIndex, + intent: renderingIntent + }); + } + return intentState.opListReadCapability.promise; + }, + getTextContent: function PDFPageProxy_getTextContent(params) { + return this.transport.messageHandler.sendWithPromise('GetTextContent', { + pageIndex: this.pageNumber - 1, + normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false, + combineTextItems: params && params.disableCombineTextItems === true ? false : true + }); + }, + _destroy: function PDFPageProxy_destroy() { + this.destroyed = true; + this.transport.pageCache[this.pageIndex] = null; + var waitOn = []; + Object.keys(this.intentStates).forEach(function (intent) { + if (intent === 'oplist') { + return; + } + var intentState = this.intentStates[intent]; + intentState.renderTasks.forEach(function (renderTask) { + var renderCompleted = renderTask.capability.promise.catch(function () {}); + waitOn.push(renderCompleted); + renderTask.cancel(); + }); + }, this); + this.objs.clear(); + this.annotationsPromise = null; + this.pendingCleanup = false; + return Promise.all(waitOn); + }, + destroy: function () { + deprecated('page destroy method, use cleanup() instead'); + this.cleanup(); + }, + cleanup: function PDFPageProxy_cleanup() { + this.pendingCleanup = true; + this._tryCleanup(); + }, + _tryCleanup: function PDFPageProxy_tryCleanup() { + if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) { + var intentState = this.intentStates[intent]; + return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList; + }, this)) { + return; + } + Object.keys(this.intentStates).forEach(function (intent) { + delete this.intentStates[intent]; + }, this); + this.objs.clear(); + this.annotationsPromise = null; + this.pendingCleanup = false; + }, + _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) { + var intentState = this.intentStates[intent]; + if (intentState.displayReadyCapability) { + intentState.displayReadyCapability.resolve(transparency); + } + }, + _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) { + var intentState = this.intentStates[intent]; + var i, ii; + for (i = 0, ii = operatorListChunk.length; i < ii; i++) { + intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]); + intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]); + } + intentState.operatorList.lastChunk = operatorListChunk.lastChunk; + for (i = 0; i < intentState.renderTasks.length; i++) { + intentState.renderTasks[i].operatorListChanged(); + } + if (operatorListChunk.lastChunk) { + intentState.receivingOperatorList = false; + this._tryCleanup(); + } + } + }; + return PDFPageProxy; +}(); +var PDFWorker = function PDFWorkerClosure() { + var nextFakeWorkerId = 0; + function getWorkerSrc() { + if (typeof workerSrc !== 'undefined') { + return workerSrc; + } + if (getDefaultSetting('workerSrc')) { + return getDefaultSetting('workerSrc'); + } + if (pdfjsFilePath) { + return pdfjsFilePath.replace(/\.js$/i, '.worker.js'); + } + error('No PDFJS.workerSrc specified'); + } + var fakeWorkerFilesLoadedCapability; + function setupFakeWorkerGlobal() { + var WorkerMessageHandler; + if (fakeWorkerFilesLoadedCapability) { + return fakeWorkerFilesLoadedCapability.promise; + } + fakeWorkerFilesLoadedCapability = createPromiseCapability(); + var loader = fakeWorkerFilesLoader || function (callback) { + Util.loadScript(getWorkerSrc(), function () { + callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler); + }); + }; + loader(fakeWorkerFilesLoadedCapability.resolve); + return fakeWorkerFilesLoadedCapability.promise; + } + function FakeWorkerPort(defer) { + this._listeners = []; + this._defer = defer; + this._deferred = Promise.resolve(undefined); + } + FakeWorkerPort.prototype = { + postMessage: function (obj, transfers) { + function cloneValue(value) { + if (typeof value !== 'object' || value === null) { + return value; + } + if (cloned.has(value)) { + return cloned.get(value); + } + var result; + var buffer; + if ((buffer = value.buffer) && isArrayBuffer(buffer)) { + var transferable = transfers && transfers.indexOf(buffer) >= 0; + if (value === buffer) { + result = value; + } else if (transferable) { + result = new value.constructor(buffer, value.byteOffset, value.byteLength); + } else { + result = new value.constructor(value); + } + cloned.set(value, result); + return result; + } + result = isArray(value) ? [] : {}; + cloned.set(value, result); + for (var i in value) { + var desc, + p = value; + while (!(desc = Object.getOwnPropertyDescriptor(p, i))) { + p = Object.getPrototypeOf(p); + } + if (typeof desc.value === 'undefined' || typeof desc.value === 'function') { + continue; + } + result[i] = cloneValue(desc.value); + } + return result; + } + if (!this._defer) { + this._listeners.forEach(function (listener) { + listener.call(this, { data: obj }); + }, this); + return; + } + var cloned = new WeakMap(); + var e = { data: cloneValue(obj) }; + this._deferred.then(function () { + this._listeners.forEach(function (listener) { + listener.call(this, e); + }, this); + }.bind(this)); + }, + addEventListener: function (name, listener) { + this._listeners.push(listener); + }, + removeEventListener: function (name, listener) { + var i = this._listeners.indexOf(listener); + this._listeners.splice(i, 1); + }, + terminate: function () { + this._listeners = []; + } + }; + function createCDNWrapper(url) { + var wrapper = 'importScripts(\'' + url + '\');'; + return URL.createObjectURL(new Blob([wrapper])); + } + function PDFWorker(name, port) { + this.name = name; + this.destroyed = false; + this._readyCapability = createPromiseCapability(); + this._port = null; + this._webWorker = null; + this._messageHandler = null; + if (port) { + this._initializeFromPort(port); + return; + } + this._initialize(); + } + PDFWorker.prototype = { + get promise() { + return this._readyCapability.promise; + }, + get port() { + return this._port; + }, + get messageHandler() { + return this._messageHandler; + }, + _initializeFromPort: function PDFWorker_initializeFromPort(port) { + this._port = port; + this._messageHandler = new MessageHandler('main', 'worker', port); + this._messageHandler.on('ready', function () {}); + this._readyCapability.resolve(); + }, + _initialize: function PDFWorker_initialize() { + if (!isWorkerDisabled && !getDefaultSetting('disableWorker') && typeof Worker !== 'undefined') { + var workerSrc = getWorkerSrc(); + try { + if (!isSameOrigin(window.location.href, workerSrc)) { + workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href); + } + var worker = new Worker(workerSrc); + var messageHandler = new MessageHandler('main', 'worker', worker); + var terminateEarly = function () { + worker.removeEventListener('error', onWorkerError); + messageHandler.destroy(); + worker.terminate(); + if (this.destroyed) { + this._readyCapability.reject(new Error('Worker was destroyed')); + } else { + this._setupFakeWorker(); + } + }.bind(this); + var onWorkerError = function (event) { + if (!this._webWorker) { + terminateEarly(); + } + }.bind(this); + worker.addEventListener('error', onWorkerError); + messageHandler.on('test', function PDFWorker_test(data) { + worker.removeEventListener('error', onWorkerError); + if (this.destroyed) { + terminateEarly(); + return; + } + var supportTypedArray = data && data.supportTypedArray; + if (supportTypedArray) { + this._messageHandler = messageHandler; + this._port = worker; + this._webWorker = worker; + if (!data.supportTransfers) { + isPostMessageTransfersDisabled = true; + } + this._readyCapability.resolve(); + messageHandler.send('configure', { verbosity: getVerbosityLevel() }); + } else { + this._setupFakeWorker(); + messageHandler.destroy(); + worker.terminate(); + } + }.bind(this)); + messageHandler.on('console_log', function (data) { + console.log.apply(console, data); + }); + messageHandler.on('console_error', function (data) { + console.error.apply(console, data); + }); + messageHandler.on('ready', function (data) { + worker.removeEventListener('error', onWorkerError); + if (this.destroyed) { + terminateEarly(); + return; + } + try { + sendTest(); + } catch (e) { + this._setupFakeWorker(); + } + }.bind(this)); + var sendTest = function () { + var postMessageTransfers = getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled; + var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]); + try { + messageHandler.send('test', testObj, [testObj.buffer]); + } catch (ex) { + info('Cannot use postMessage transfers'); + testObj[0] = 0; + messageHandler.send('test', testObj); + } + }; + sendTest(); + return; + } catch (e) { + info('The worker has been disabled.'); + } + } + this._setupFakeWorker(); + }, + _setupFakeWorker: function PDFWorker_setupFakeWorker() { + if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) { + warn('Setting up fake worker.'); + isWorkerDisabled = true; + } + setupFakeWorkerGlobal().then(function (WorkerMessageHandler) { + if (this.destroyed) { + this._readyCapability.reject(new Error('Worker was destroyed')); + return; + } + var isTypedArraysPresent = Uint8Array !== Float32Array; + var port = new FakeWorkerPort(isTypedArraysPresent); + this._port = port; + var id = 'fake' + nextFakeWorkerId++; + var workerHandler = new MessageHandler(id + '_worker', id, port); + WorkerMessageHandler.setup(workerHandler, port); + var messageHandler = new MessageHandler(id, id + '_worker', port); + this._messageHandler = messageHandler; + this._readyCapability.resolve(); + }.bind(this)); + }, + destroy: function PDFWorker_destroy() { + this.destroyed = true; + if (this._webWorker) { + this._webWorker.terminate(); + this._webWorker = null; + } + this._port = null; + if (this._messageHandler) { + this._messageHandler.destroy(); + this._messageHandler = null; + } + } + }; + return PDFWorker; +}(); +var WorkerTransport = function WorkerTransportClosure() { + function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) { + this.messageHandler = messageHandler; + this.loadingTask = loadingTask; + this.pdfDataRangeTransport = pdfDataRangeTransport; + this.commonObjs = new PDFObjects(); + this.fontLoader = new FontLoader(loadingTask.docId); + this.CMapReaderFactory = new CMapReaderFactory({ + baseUrl: getDefaultSetting('cMapUrl'), + isCompressed: getDefaultSetting('cMapPacked') + }); + this.destroyed = false; + this.destroyCapability = null; + this._passwordCapability = null; + this.pageCache = []; + this.pagePromises = []; + this.downloadInfoCapability = createPromiseCapability(); + this.setupMessageHandler(); + } + WorkerTransport.prototype = { + destroy: function WorkerTransport_destroy() { + if (this.destroyCapability) { + return this.destroyCapability.promise; + } + this.destroyed = true; + this.destroyCapability = createPromiseCapability(); + if (this._passwordCapability) { + this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback')); + } + var waitOn = []; + this.pageCache.forEach(function (page) { + if (page) { + waitOn.push(page._destroy()); + } + }); + this.pageCache = []; + this.pagePromises = []; + var self = this; + var terminated = this.messageHandler.sendWithPromise('Terminate', null); + waitOn.push(terminated); + Promise.all(waitOn).then(function () { + self.fontLoader.clear(); + if (self.pdfDataRangeTransport) { + self.pdfDataRangeTransport.abort(); + self.pdfDataRangeTransport = null; + } + if (self.messageHandler) { + self.messageHandler.destroy(); + self.messageHandler = null; + } + self.destroyCapability.resolve(); + }, this.destroyCapability.reject); + return this.destroyCapability.promise; + }, + setupMessageHandler: function WorkerTransport_setupMessageHandler() { + var messageHandler = this.messageHandler; + var loadingTask = this.loadingTask; + var pdfDataRangeTransport = this.pdfDataRangeTransport; + if (pdfDataRangeTransport) { + pdfDataRangeTransport.addRangeListener(function (begin, chunk) { + messageHandler.send('OnDataRange', { + begin: begin, + chunk: chunk + }); + }); + pdfDataRangeTransport.addProgressListener(function (loaded) { + messageHandler.send('OnDataProgress', { loaded: loaded }); + }); + pdfDataRangeTransport.addProgressiveReadListener(function (chunk) { + messageHandler.send('OnDataRange', { chunk: chunk }); + }); + messageHandler.on('RequestDataRange', function transportDataRange(data) { + pdfDataRangeTransport.requestDataRange(data.begin, data.end); + }, this); + } + messageHandler.on('GetDoc', function transportDoc(data) { + var pdfInfo = data.pdfInfo; + this.numPages = data.pdfInfo.numPages; + var loadingTask = this.loadingTask; + var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask); + this.pdfDocument = pdfDocument; + loadingTask._capability.resolve(pdfDocument); + }, this); + messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) { + this._passwordCapability = createPromiseCapability(); + if (loadingTask.onPassword) { + var updatePassword = function (password) { + this._passwordCapability.resolve({ password: password }); + }.bind(this); + loadingTask.onPassword(updatePassword, exception.code); + } else { + this._passwordCapability.reject(new PasswordException(exception.message, exception.code)); + } + return this._passwordCapability.promise; + }, this); + messageHandler.on('PasswordException', function transportPasswordException(exception) { + loadingTask._capability.reject(new PasswordException(exception.message, exception.code)); + }, this); + messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) { + this.loadingTask._capability.reject(new InvalidPDFException(exception.message)); + }, this); + messageHandler.on('MissingPDF', function transportMissingPDF(exception) { + this.loadingTask._capability.reject(new MissingPDFException(exception.message)); + }, this); + messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) { + this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status)); + }, this); + messageHandler.on('UnknownError', function transportUnknownError(exception) { + this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details)); + }, this); + messageHandler.on('DataLoaded', function transportPage(data) { + this.downloadInfoCapability.resolve(data); + }, this); + messageHandler.on('PDFManagerReady', function transportPage(data) { + if (this.pdfDataRangeTransport) { + this.pdfDataRangeTransport.transportReady(); + } + }, this); + messageHandler.on('StartRenderPage', function transportRender(data) { + if (this.destroyed) { + return; + } + var page = this.pageCache[data.pageIndex]; + page.stats.timeEnd('Page Request'); + page._startRenderPage(data.transparency, data.intent); + }, this); + messageHandler.on('RenderPageChunk', function transportRender(data) { + if (this.destroyed) { + return; + } + var page = this.pageCache[data.pageIndex]; + page._renderPageChunk(data.operatorList, data.intent); + }, this); + messageHandler.on('commonobj', function transportObj(data) { + if (this.destroyed) { + return; + } + var id = data[0]; + var type = data[1]; + if (this.commonObjs.hasData(id)) { + return; + } + switch (type) { + case 'Font': + var exportedData = data[2]; + if ('error' in exportedData) { + var exportedError = exportedData.error; + warn('Error during font loading: ' + exportedError); + this.commonObjs.resolve(id, exportedError); + break; + } + var fontRegistry = null; + if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) { + fontRegistry = { + registerFont: function (font, url) { + globalScope['FontInspector'].fontAdded(font, url); + } + }; + } + var font = new FontFaceObject(exportedData, { + isEvalSuported: getDefaultSetting('isEvalSupported'), + disableFontFace: getDefaultSetting('disableFontFace'), + fontRegistry: fontRegistry + }); + this.fontLoader.bind([font], function fontReady(fontObjs) { + this.commonObjs.resolve(id, font); + }.bind(this)); + break; + case 'FontPath': + this.commonObjs.resolve(id, data[2]); + break; + default: + error('Got unknown common object type ' + type); + } + }, this); + messageHandler.on('obj', function transportObj(data) { + if (this.destroyed) { + return; + } + var id = data[0]; + var pageIndex = data[1]; + var type = data[2]; + var pageProxy = this.pageCache[pageIndex]; + var imageData; + if (pageProxy.objs.hasData(id)) { + return; + } + switch (type) { + case 'JpegStream': + imageData = data[3]; + loadJpegStream(id, imageData, pageProxy.objs); + break; + case 'Image': + imageData = data[3]; + pageProxy.objs.resolve(id, imageData); + var MAX_IMAGE_SIZE_TO_STORE = 8000000; + if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) { + pageProxy.cleanupAfterRender = true; + } + break; + default: + error('Got unknown object type ' + type); + } + }, this); + messageHandler.on('DocProgress', function transportDocProgress(data) { + if (this.destroyed) { + return; + } + var loadingTask = this.loadingTask; + if (loadingTask.onProgress) { + loadingTask.onProgress({ + loaded: data.loaded, + total: data.total + }); + } + }, this); + messageHandler.on('PageError', function transportError(data) { + if (this.destroyed) { + return; + } + var page = this.pageCache[data.pageNum - 1]; + var intentState = page.intentStates[data.intent]; + if (intentState.displayReadyCapability) { + intentState.displayReadyCapability.reject(data.error); + } else { + error(data.error); + } + if (intentState.operatorList) { + intentState.operatorList.lastChunk = true; + for (var i = 0; i < intentState.renderTasks.length; i++) { + intentState.renderTasks[i].operatorListChanged(); + } + } + }, this); + messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) { + if (this.destroyed) { + return; + } + var featureId = data.featureId; + var loadingTask = this.loadingTask; + if (loadingTask.onUnsupportedFeature) { + loadingTask.onUnsupportedFeature(featureId); + } + _UnsupportedManager.notify(featureId); + }, this); + messageHandler.on('JpegDecode', function (data) { + if (this.destroyed) { + return Promise.reject(new Error('Worker was destroyed')); + } + if (typeof document === 'undefined') { + return Promise.reject(new Error('"document" is not defined.')); + } + var imageUrl = data[0]; + var components = data[1]; + if (components !== 3 && components !== 1) { + return Promise.reject(new Error('Only 3 components or 1 component can be returned')); + } + return new Promise(function (resolve, reject) { + var img = new Image(); + img.onload = function () { + var width = img.width; + var height = img.height; + var size = width * height; + var rgbaLength = size * 4; + var buf = new Uint8Array(size * components); + var tmpCanvas = document.createElement('canvas'); + tmpCanvas.width = width; + tmpCanvas.height = height; + var tmpCtx = tmpCanvas.getContext('2d'); + tmpCtx.drawImage(img, 0, 0); + var data = tmpCtx.getImageData(0, 0, width, height).data; + var i, j; + if (components === 3) { + for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) { + buf[j] = data[i]; + buf[j + 1] = data[i + 1]; + buf[j + 2] = data[i + 2]; + } + } else if (components === 1) { + for (i = 0, j = 0; i < rgbaLength; i += 4, j++) { + buf[j] = data[i]; + } + } + resolve({ + data: buf, + width: width, + height: height + }); + }; + img.onerror = function () { + reject(new Error('JpegDecode failed to load image')); + }; + img.src = imageUrl; + }); + }, this); + messageHandler.on('FetchBuiltInCMap', function (data) { + if (this.destroyed) { + return Promise.reject(new Error('Worker was destroyed')); + } + return this.CMapReaderFactory.fetch({ name: data.name }); + }, this); + }, + getData: function WorkerTransport_getData() { + return this.messageHandler.sendWithPromise('GetData', null); + }, + getPage: function WorkerTransport_getPage(pageNumber, capability) { + if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) { + return Promise.reject(new Error('Invalid page request')); + } + var pageIndex = pageNumber - 1; + if (pageIndex in this.pagePromises) { + return this.pagePromises[pageIndex]; + } + var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) { + if (this.destroyed) { + throw new Error('Transport destroyed'); + } + var page = new PDFPageProxy(pageIndex, pageInfo, this); + this.pageCache[pageIndex] = page; + return page; + }.bind(this)); + this.pagePromises[pageIndex] = promise; + return promise; + }, + getPageIndex: function WorkerTransport_getPageIndexByRef(ref) { + return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) { + return Promise.reject(new Error(reason)); + }); + }, + getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) { + return this.messageHandler.sendWithPromise('GetAnnotations', { + pageIndex: pageIndex, + intent: intent + }); + }, + getDestinations: function WorkerTransport_getDestinations() { + return this.messageHandler.sendWithPromise('GetDestinations', null); + }, + getDestination: function WorkerTransport_getDestination(id) { + return this.messageHandler.sendWithPromise('GetDestination', { id: id }); + }, + getPageLabels: function WorkerTransport_getPageLabels() { + return this.messageHandler.sendWithPromise('GetPageLabels', null); + }, + getAttachments: function WorkerTransport_getAttachments() { + return this.messageHandler.sendWithPromise('GetAttachments', null); + }, + getJavaScript: function WorkerTransport_getJavaScript() { + return this.messageHandler.sendWithPromise('GetJavaScript', null); + }, + getOutline: function WorkerTransport_getOutline() { + return this.messageHandler.sendWithPromise('GetOutline', null); + }, + getMetadata: function WorkerTransport_getMetadata() { + return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) { + return { + info: results[0], + metadata: results[1] ? new Metadata(results[1]) : null + }; + }); + }, + getStats: function WorkerTransport_getStats() { + return this.messageHandler.sendWithPromise('GetStats', null); + }, + startCleanup: function WorkerTransport_startCleanup() { + this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() { + for (var i = 0, ii = this.pageCache.length; i < ii; i++) { + var page = this.pageCache[i]; + if (page) { + page.cleanup(); + } + } + this.commonObjs.clear(); + this.fontLoader.clear(); + }.bind(this)); + } + }; + return WorkerTransport; +}(); +var PDFObjects = function PDFObjectsClosure() { + function PDFObjects() { + this.objs = Object.create(null); + } + PDFObjects.prototype = { + ensureObj: function PDFObjects_ensureObj(objId) { + if (this.objs[objId]) { + return this.objs[objId]; + } + var obj = { + capability: createPromiseCapability(), + data: null, + resolved: false + }; + this.objs[objId] = obj; + return obj; + }, + get: function PDFObjects_get(objId, callback) { + if (callback) { + this.ensureObj(objId).capability.promise.then(callback); + return null; + } + var obj = this.objs[objId]; + if (!obj || !obj.resolved) { + error('Requesting object that isn\'t resolved yet ' + objId); + } + return obj.data; + }, + resolve: function PDFObjects_resolve(objId, data) { + var obj = this.ensureObj(objId); + obj.resolved = true; + obj.data = data; + obj.capability.resolve(data); + }, + isResolved: function PDFObjects_isResolved(objId) { + var objs = this.objs; + if (!objs[objId]) { + return false; + } + return objs[objId].resolved; + }, + hasData: function PDFObjects_hasData(objId) { + return this.isResolved(objId); + }, + getData: function PDFObjects_getData(objId) { + var objs = this.objs; + if (!objs[objId] || !objs[objId].resolved) { + return null; + } + return objs[objId].data; + }, + clear: function PDFObjects_clear() { + this.objs = Object.create(null); + } + }; + return PDFObjects; +}(); +var RenderTask = function RenderTaskClosure() { + function RenderTask(internalRenderTask) { + this._internalRenderTask = internalRenderTask; + this.onContinue = null; + } + RenderTask.prototype = { + get promise() { + return this._internalRenderTask.capability.promise; + }, + cancel: function RenderTask_cancel() { + this._internalRenderTask.cancel(); + }, + then: function RenderTask_then(onFulfilled, onRejected) { + return this.promise.then.apply(this.promise, arguments); + } + }; + return RenderTask; +}(); +var InternalRenderTask = function InternalRenderTaskClosure() { + function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) { + this.callback = callback; + this.params = params; + this.objs = objs; + this.commonObjs = commonObjs; + this.operatorListIdx = null; + this.operatorList = operatorList; + this.pageNumber = pageNumber; + this.canvasFactory = canvasFactory; + this.running = false; + this.graphicsReadyCallback = null; + this.graphicsReady = false; + this.useRequestAnimationFrame = false; + this.cancelled = false; + this.capability = createPromiseCapability(); + this.task = new RenderTask(this); + this._continueBound = this._continue.bind(this); + this._scheduleNextBound = this._scheduleNext.bind(this); + this._nextBound = this._next.bind(this); + } + InternalRenderTask.prototype = { + initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) { + if (this.cancelled) { + return; + } + if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) { + this.stepper = globalScope.StepperManager.create(this.pageNumber - 1); + this.stepper.init(this.operatorList); + this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint(); + } + var params = this.params; + this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer); + this.gfx.beginDrawing(params.transform, params.viewport, transparency); + this.operatorListIdx = 0; + this.graphicsReady = true; + if (this.graphicsReadyCallback) { + this.graphicsReadyCallback(); + } + }, + cancel: function InternalRenderTask_cancel() { + this.running = false; + this.cancelled = true; + if (getDefaultSetting('pdfjsNext')) { + this.callback(new RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas')); + } else { + this.callback('cancelled'); + } + }, + operatorListChanged: function InternalRenderTask_operatorListChanged() { + if (!this.graphicsReady) { + if (!this.graphicsReadyCallback) { + this.graphicsReadyCallback = this._continueBound; + } + return; + } + if (this.stepper) { + this.stepper.updateOperatorList(this.operatorList); + } + if (this.running) { + return; + } + this._continue(); + }, + _continue: function InternalRenderTask__continue() { + this.running = true; + if (this.cancelled) { + return; + } + if (this.task.onContinue) { + this.task.onContinue(this._scheduleNextBound); + } else { + this._scheduleNext(); + } + }, + _scheduleNext: function InternalRenderTask__scheduleNext() { + if (this.useRequestAnimationFrame && typeof window !== 'undefined') { + window.requestAnimationFrame(this._nextBound); + } else { + Promise.resolve(undefined).then(this._nextBound); + } + }, + _next: function InternalRenderTask__next() { + if (this.cancelled) { + return; + } + this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper); + if (this.operatorListIdx === this.operatorList.argsArray.length) { + this.running = false; + if (this.operatorList.lastChunk) { + this.gfx.endDrawing(); + this.callback(); + } + } + } + }; + return InternalRenderTask; +}(); +var _UnsupportedManager = function UnsupportedManagerClosure() { + var listeners = []; + return { + listen: function (cb) { + deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead'); + listeners.push(cb); + }, + notify: function (featureId) { + for (var i = 0, ii = listeners.length; i < ii; i++) { + listeners[i](featureId); + } + } + }; +}(); +exports.version = '1.8.172'; +exports.build = '8ff1fbe7'; +exports.getDocument = getDocument; +exports.PDFDataRangeTransport = PDFDataRangeTransport; +exports.PDFWorker = PDFWorker; +exports.PDFDocumentProxy = PDFDocumentProxy; +exports.PDFPageProxy = PDFPageProxy; +exports._UnsupportedManager = _UnsupportedManager; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; +var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX; +var ImageKind = sharedUtil.ImageKind; +var OPS = sharedUtil.OPS; +var Util = sharedUtil.Util; +var isNum = sharedUtil.isNum; +var isArray = sharedUtil.isArray; +var warn = sharedUtil.warn; +var createObjectURL = sharedUtil.createObjectURL; +var SVG_DEFAULTS = { + fontStyle: 'normal', + fontWeight: 'normal', + fillColor: '#000000' +}; +var convertImgDataToPng = function convertImgDataToPngClosure() { + var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); + var CHUNK_WRAPPER_SIZE = 12; + var crcTable = new Int32Array(256); + for (var i = 0; i < 256; i++) { + var c = i; + for (var h = 0; h < 8; h++) { + if (c & 1) { + c = 0xedB88320 ^ c >> 1 & 0x7fffffff; + } else { + c = c >> 1 & 0x7fffffff; + } + } + crcTable[i] = c; + } + function crc32(data, start, end) { + var crc = -1; + for (var i = start; i < end; i++) { + var a = (crc ^ data[i]) & 0xff; + var b = crcTable[a]; + crc = crc >>> 8 ^ b; + } + return crc ^ -1; + } + function writePngChunk(type, body, data, offset) { + var p = offset; + var len = body.length; + data[p] = len >> 24 & 0xff; + data[p + 1] = len >> 16 & 0xff; + data[p + 2] = len >> 8 & 0xff; + data[p + 3] = len & 0xff; + p += 4; + data[p] = type.charCodeAt(0) & 0xff; + data[p + 1] = type.charCodeAt(1) & 0xff; + data[p + 2] = type.charCodeAt(2) & 0xff; + data[p + 3] = type.charCodeAt(3) & 0xff; + p += 4; + data.set(body, p); + p += body.length; + var crc = crc32(data, offset + 4, p); + data[p] = crc >> 24 & 0xff; + data[p + 1] = crc >> 16 & 0xff; + data[p + 2] = crc >> 8 & 0xff; + data[p + 3] = crc & 0xff; + } + function adler32(data, start, end) { + var a = 1; + var b = 0; + for (var i = start; i < end; ++i) { + a = (a + (data[i] & 0xff)) % 65521; + b = (b + a) % 65521; + } + return b << 16 | a; + } + function encode(imgData, kind, forceDataSchema) { + var width = imgData.width; + var height = imgData.height; + var bitDepth, colorType, lineSize; + var bytes = imgData.data; + switch (kind) { + case ImageKind.GRAYSCALE_1BPP: + colorType = 0; + bitDepth = 1; + lineSize = width + 7 >> 3; + break; + case ImageKind.RGB_24BPP: + colorType = 2; + bitDepth = 8; + lineSize = width * 3; + break; + case ImageKind.RGBA_32BPP: + colorType = 6; + bitDepth = 8; + lineSize = width * 4; + break; + default: + throw new Error('invalid format'); + } + var literals = new Uint8Array((1 + lineSize) * height); + var offsetLiterals = 0, + offsetBytes = 0; + var y, i; + for (y = 0; y < height; ++y) { + literals[offsetLiterals++] = 0; + literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals); + offsetBytes += lineSize; + offsetLiterals += lineSize; + } + if (kind === ImageKind.GRAYSCALE_1BPP) { + offsetLiterals = 0; + for (y = 0; y < height; y++) { + offsetLiterals++; + for (i = 0; i < lineSize; i++) { + literals[offsetLiterals++] ^= 0xFF; + } + } + } + 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]); + var len = literals.length; + var maxBlockLength = 0xFFFF; + var deflateBlocks = Math.ceil(len / maxBlockLength); + var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4); + var pi = 0; + idat[pi++] = 0x78; + idat[pi++] = 0x9c; + var pos = 0; + while (len > maxBlockLength) { + idat[pi++] = 0x00; + idat[pi++] = 0xff; + idat[pi++] = 0xff; + idat[pi++] = 0x00; + idat[pi++] = 0x00; + idat.set(literals.subarray(pos, pos + maxBlockLength), pi); + pi += maxBlockLength; + pos += maxBlockLength; + len -= maxBlockLength; + } + idat[pi++] = 0x01; + idat[pi++] = len & 0xff; + idat[pi++] = len >> 8 & 0xff; + idat[pi++] = ~len & 0xffff & 0xff; + idat[pi++] = (~len & 0xffff) >> 8 & 0xff; + idat.set(literals.subarray(pos), pi); + pi += literals.length - pos; + var adler = adler32(literals, 0, literals.length); + idat[pi++] = adler >> 24 & 0xff; + idat[pi++] = adler >> 16 & 0xff; + idat[pi++] = adler >> 8 & 0xff; + idat[pi++] = adler & 0xff; + var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; + var data = new Uint8Array(pngLength); + var offset = 0; + data.set(PNG_HEADER, offset); + offset += PNG_HEADER.length; + writePngChunk('IHDR', ihdr, data, offset); + offset += CHUNK_WRAPPER_SIZE + ihdr.length; + writePngChunk('IDATA', idat, data, offset); + offset += CHUNK_WRAPPER_SIZE + idat.length; + writePngChunk('IEND', new Uint8Array(0), data, offset); + return createObjectURL(data, 'image/png', forceDataSchema); + } + return function convertImgDataToPng(imgData, forceDataSchema) { + var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind; + return encode(imgData, kind, forceDataSchema); + }; +}(); +var SVGExtraState = function SVGExtraStateClosure() { + function SVGExtraState() { + this.fontSizeScale = 1; + this.fontWeight = SVG_DEFAULTS.fontWeight; + this.fontSize = 0; + this.textMatrix = IDENTITY_MATRIX; + this.fontMatrix = FONT_IDENTITY_MATRIX; + this.leading = 0; + this.x = 0; + this.y = 0; + this.lineX = 0; + this.lineY = 0; + this.charSpacing = 0; + this.wordSpacing = 0; + this.textHScale = 1; + this.textRise = 0; + this.fillColor = SVG_DEFAULTS.fillColor; + this.strokeColor = '#000000'; + this.fillAlpha = 1; + this.strokeAlpha = 1; + this.lineWidth = 1; + this.lineJoin = ''; + this.lineCap = ''; + this.miterLimit = 0; + this.dashArray = []; + this.dashPhase = 0; + this.dependencies = []; + this.activeClipUrl = null; + this.clipGroup = null; + this.maskId = ''; + } + SVGExtraState.prototype = { + clone: function SVGExtraState_clone() { + return Object.create(this); + }, + setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) { + this.x = x; + this.y = y; + } + }; + return SVGExtraState; +}(); +var SVGGraphics = function SVGGraphicsClosure() { + function opListToTree(opList) { + var opTree = []; + var tmp = []; + var opListLen = opList.length; + for (var x = 0; x < opListLen; x++) { + if (opList[x].fn === 'save') { + opTree.push({ + 'fnId': 92, + 'fn': 'group', + 'items': [] + }); + tmp.push(opTree); + opTree = opTree[opTree.length - 1].items; + continue; + } + if (opList[x].fn === 'restore') { + opTree = tmp.pop(); + } else { + opTree.push(opList[x]); + } + } + return opTree; + } + function pf(value) { + if (value === (value | 0)) { + return value.toString(); + } + var s = value.toFixed(10); + var i = s.length - 1; + if (s[i] !== '0') { + return s; + } + do { + i--; + } while (s[i] === '0'); + return s.substr(0, s[i] === '.' ? i : i + 1); + } + function pm(m) { + if (m[4] === 0 && m[5] === 0) { + if (m[1] === 0 && m[2] === 0) { + if (m[0] === 1 && m[3] === 1) { + return ''; + } + return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')'; + } + if (m[0] === m[3] && m[1] === -m[2]) { + var a = Math.acos(m[0]) * 180 / Math.PI; + return 'rotate(' + pf(a) + ')'; + } + } else { + if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) { + return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')'; + } + } + return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')'; + } + function SVGGraphics(commonObjs, objs, forceDataSchema) { + this.current = new SVGExtraState(); + this.transformMatrix = IDENTITY_MATRIX; + this.transformStack = []; + this.extraStack = []; + this.commonObjs = commonObjs; + this.objs = objs; + this.pendingEOFill = false; + this.embedFonts = false; + this.embeddedFonts = Object.create(null); + this.cssStyle = null; + this.forceDataSchema = !!forceDataSchema; + } + var NS = 'http://www.w3.org/2000/svg'; + var XML_NS = 'http://www.w3.org/XML/1998/namespace'; + var XLINK_NS = 'http://www.w3.org/1999/xlink'; + var LINE_CAP_STYLES = ['butt', 'round', 'square']; + var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; + var clipCount = 0; + var maskCount = 0; + SVGGraphics.prototype = { + save: function SVGGraphics_save() { + this.transformStack.push(this.transformMatrix); + var old = this.current; + this.extraStack.push(old); + this.current = old.clone(); + }, + restore: function SVGGraphics_restore() { + this.transformMatrix = this.transformStack.pop(); + this.current = this.extraStack.pop(); + this.tgrp = null; + }, + group: function SVGGraphics_group(items) { + this.save(); + this.executeOpTree(items); + this.restore(); + }, + loadDependencies: function SVGGraphics_loadDependencies(operatorList) { + var fnArray = operatorList.fnArray; + var fnArrayLen = fnArray.length; + var argsArray = operatorList.argsArray; + var self = this; + for (var i = 0; i < fnArrayLen; i++) { + if (OPS.dependency === fnArray[i]) { + var deps = argsArray[i]; + for (var n = 0, nn = deps.length; n < nn; n++) { + var obj = deps[n]; + var common = obj.substring(0, 2) === 'g_'; + var promise; + if (common) { + promise = new Promise(function (resolve) { + self.commonObjs.get(obj, resolve); + }); + } else { + promise = new Promise(function (resolve) { + self.objs.get(obj, resolve); + }); + } + this.current.dependencies.push(promise); + } + } + } + return Promise.all(this.current.dependencies); + }, + transform: function SVGGraphics_transform(a, b, c, d, e, f) { + var transformMatrix = [a, b, c, d, e, f]; + this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix); + this.tgrp = null; + }, + getSVG: function SVGGraphics_getSVG(operatorList, viewport) { + this.viewport = viewport; + var svgElement = this._initialize(viewport); + return this.loadDependencies(operatorList).then(function () { + this.transformMatrix = IDENTITY_MATRIX; + var opTree = this.convertOpList(operatorList); + this.executeOpTree(opTree); + return svgElement; + }.bind(this)); + }, + convertOpList: function SVGGraphics_convertOpList(operatorList) { + var argsArray = operatorList.argsArray; + var fnArray = operatorList.fnArray; + var fnArrayLen = fnArray.length; + var REVOPS = []; + var opList = []; + for (var op in OPS) { + REVOPS[OPS[op]] = op; + } + for (var x = 0; x < fnArrayLen; x++) { + var fnId = fnArray[x]; + opList.push({ + 'fnId': fnId, + 'fn': REVOPS[fnId], + 'args': argsArray[x] + }); + } + return opListToTree(opList); + }, + executeOpTree: function SVGGraphics_executeOpTree(opTree) { + var opTreeLen = opTree.length; + for (var x = 0; x < opTreeLen; x++) { + var fn = opTree[x].fn; + var fnId = opTree[x].fnId; + var args = opTree[x].args; + switch (fnId | 0) { + case OPS.beginText: + this.beginText(); + break; + case OPS.setLeading: + this.setLeading(args); + break; + case OPS.setLeadingMoveText: + this.setLeadingMoveText(args[0], args[1]); + break; + case OPS.setFont: + this.setFont(args); + break; + case OPS.showText: + this.showText(args[0]); + break; + case OPS.showSpacedText: + this.showText(args[0]); + break; + case OPS.endText: + this.endText(); + break; + case OPS.moveText: + this.moveText(args[0], args[1]); + break; + case OPS.setCharSpacing: + this.setCharSpacing(args[0]); + break; + case OPS.setWordSpacing: + this.setWordSpacing(args[0]); + break; + case OPS.setHScale: + this.setHScale(args[0]); + break; + case OPS.setTextMatrix: + this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); + break; + case OPS.setLineWidth: + this.setLineWidth(args[0]); + break; + case OPS.setLineJoin: + this.setLineJoin(args[0]); + break; + case OPS.setLineCap: + this.setLineCap(args[0]); + break; + case OPS.setMiterLimit: + this.setMiterLimit(args[0]); + break; + case OPS.setFillRGBColor: + this.setFillRGBColor(args[0], args[1], args[2]); + break; + case OPS.setStrokeRGBColor: + this.setStrokeRGBColor(args[0], args[1], args[2]); + break; + case OPS.setDash: + this.setDash(args[0], args[1]); + break; + case OPS.setGState: + this.setGState(args[0]); + break; + case OPS.fill: + this.fill(); + break; + case OPS.eoFill: + this.eoFill(); + break; + case OPS.stroke: + this.stroke(); + break; + case OPS.fillStroke: + this.fillStroke(); + break; + case OPS.eoFillStroke: + this.eoFillStroke(); + break; + case OPS.clip: + this.clip('nonzero'); + break; + case OPS.eoClip: + this.clip('evenodd'); + break; + case OPS.paintSolidColorImageMask: + this.paintSolidColorImageMask(); + break; + case OPS.paintJpegXObject: + this.paintJpegXObject(args[0], args[1], args[2]); + break; + case OPS.paintImageXObject: + this.paintImageXObject(args[0]); + break; + case OPS.paintInlineImageXObject: + this.paintInlineImageXObject(args[0]); + break; + case OPS.paintImageMaskXObject: + this.paintImageMaskXObject(args[0]); + break; + case OPS.paintFormXObjectBegin: + this.paintFormXObjectBegin(args[0], args[1]); + break; + case OPS.paintFormXObjectEnd: + this.paintFormXObjectEnd(); + break; + case OPS.closePath: + this.closePath(); + break; + case OPS.closeStroke: + this.closeStroke(); + break; + case OPS.closeFillStroke: + this.closeFillStroke(); + break; + case OPS.nextLine: + this.nextLine(); + break; + case OPS.transform: + this.transform(args[0], args[1], args[2], args[3], args[4], args[5]); + break; + case OPS.constructPath: + this.constructPath(args[0], args[1]); + break; + case OPS.endPath: + this.endPath(); + break; + case 92: + this.group(opTree[x].items); + break; + default: + warn('Unimplemented operator ' + fn); + break; + } + } + }, + setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) { + this.current.wordSpacing = wordSpacing; + }, + setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) { + this.current.charSpacing = charSpacing; + }, + nextLine: function SVGGraphics_nextLine() { + this.moveText(0, this.current.leading); + }, + setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) { + var current = this.current; + this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f]; + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + current.xcoords = []; + current.tspan = document.createElementNS(NS, 'svg:tspan'); + current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); + current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + current.txtElement = document.createElementNS(NS, 'svg:text'); + current.txtElement.appendChild(current.tspan); + }, + beginText: function SVGGraphics_beginText() { + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + this.current.textMatrix = IDENTITY_MATRIX; + this.current.lineMatrix = IDENTITY_MATRIX; + this.current.tspan = document.createElementNS(NS, 'svg:tspan'); + this.current.txtElement = document.createElementNS(NS, 'svg:text'); + this.current.txtgrp = document.createElementNS(NS, 'svg:g'); + this.current.xcoords = []; + }, + moveText: function SVGGraphics_moveText(x, y) { + var current = this.current; + this.current.x = this.current.lineX += x; + this.current.y = this.current.lineY += y; + current.xcoords = []; + current.tspan = document.createElementNS(NS, 'svg:tspan'); + current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); + current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + }, + showText: function SVGGraphics_showText(glyphs) { + var current = this.current; + var font = current.font; + var fontSize = current.fontSize; + if (fontSize === 0) { + return; + } + var charSpacing = current.charSpacing; + var wordSpacing = current.wordSpacing; + var fontDirection = current.fontDirection; + var textHScale = current.textHScale * fontDirection; + var glyphsLength = glyphs.length; + var vertical = font.vertical; + var widthAdvanceScale = fontSize * current.fontMatrix[0]; + var x = 0, + i; + for (i = 0; i < glyphsLength; ++i) { + var glyph = glyphs[i]; + if (glyph === null) { + x += fontDirection * wordSpacing; + continue; + } else if (isNum(glyph)) { + x += -glyph * fontSize * 0.001; + continue; + } + current.xcoords.push(current.x + x * textHScale); + var width = glyph.width; + var character = glyph.fontChar; + var charWidth = width * widthAdvanceScale + charSpacing * fontDirection; + x += charWidth; + current.tspan.textContent += character; + } + if (vertical) { + current.y -= x * textHScale; + } else { + current.x += x * textHScale; + } + current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' ')); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); + current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); + if (current.fontStyle !== SVG_DEFAULTS.fontStyle) { + current.tspan.setAttributeNS(null, 'font-style', current.fontStyle); + } + if (current.fontWeight !== SVG_DEFAULTS.fontWeight) { + current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight); + } + if (current.fillColor !== SVG_DEFAULTS.fillColor) { + current.tspan.setAttributeNS(null, 'fill', current.fillColor); + } + current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)'); + current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve'); + current.txtElement.appendChild(current.tspan); + current.txtgrp.appendChild(current.txtElement); + this._ensureTransformGroup().appendChild(current.txtElement); + }, + setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) { + this.setLeading(-y); + this.moveText(x, y); + }, + addFontStyle: function SVGGraphics_addFontStyle(fontObj) { + if (!this.cssStyle) { + this.cssStyle = document.createElementNS(NS, 'svg:style'); + this.cssStyle.setAttributeNS(null, 'type', 'text/css'); + this.defs.appendChild(this.cssStyle); + } + var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema); + this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n'; + }, + setFont: function SVGGraphics_setFont(details) { + var current = this.current; + var fontObj = this.commonObjs.get(details[0]); + var size = details[1]; + this.current.font = fontObj; + if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) { + this.addFontStyle(fontObj); + this.embeddedFonts[fontObj.loadedName] = fontObj; + } + current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX; + var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal'; + var italic = fontObj.italic ? 'italic' : 'normal'; + if (size < 0) { + size = -size; + current.fontDirection = -1; + } else { + current.fontDirection = 1; + } + current.fontSize = size; + current.fontFamily = fontObj.loadedName; + current.fontWeight = bold; + current.fontStyle = italic; + current.tspan = document.createElementNS(NS, 'svg:tspan'); + current.tspan.setAttributeNS(null, 'y', pf(-current.y)); + current.xcoords = []; + }, + endText: function SVGGraphics_endText() {}, + setLineWidth: function SVGGraphics_setLineWidth(width) { + this.current.lineWidth = width; + }, + setLineCap: function SVGGraphics_setLineCap(style) { + this.current.lineCap = LINE_CAP_STYLES[style]; + }, + setLineJoin: function SVGGraphics_setLineJoin(style) { + this.current.lineJoin = LINE_JOIN_STYLES[style]; + }, + setMiterLimit: function SVGGraphics_setMiterLimit(limit) { + this.current.miterLimit = limit; + }, + setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.current.strokeColor = color; + }, + setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.current.fillColor = color; + this.current.tspan = document.createElementNS(NS, 'svg:tspan'); + this.current.xcoords = []; + }, + setDash: function SVGGraphics_setDash(dashArray, dashPhase) { + this.current.dashArray = dashArray; + this.current.dashPhase = dashPhase; + }, + constructPath: function SVGGraphics_constructPath(ops, args) { + var current = this.current; + var x = current.x, + y = current.y; + current.path = document.createElementNS(NS, 'svg:path'); + var d = []; + var opLength = ops.length; + for (var i = 0, j = 0; i < opLength; i++) { + switch (ops[i] | 0) { + case OPS.rectangle: + x = args[j++]; + y = args[j++]; + var width = args[j++]; + var height = args[j++]; + var xw = x + width; + var yh = y + height; + d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z'); + break; + case OPS.moveTo: + x = args[j++]; + y = args[j++]; + d.push('M', pf(x), pf(y)); + break; + case OPS.lineTo: + x = args[j++]; + y = args[j++]; + d.push('L', pf(x), pf(y)); + break; + case OPS.curveTo: + x = args[j + 4]; + y = args[j + 5]; + d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y)); + j += 6; + break; + case OPS.curveTo2: + x = args[j + 2]; + y = args[j + 3]; + d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3])); + j += 4; + break; + case OPS.curveTo3: + x = args[j + 2]; + y = args[j + 3]; + d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y)); + j += 4; + break; + case OPS.closePath: + d.push('Z'); + break; + } + } + current.path.setAttributeNS(null, 'd', d.join(' ')); + current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit)); + current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap); + current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); + current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px'); + current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' ')); + current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px'); + current.path.setAttributeNS(null, 'fill', 'none'); + this._ensureTransformGroup().appendChild(current.path); + current.element = current.path; + current.setCurrentPoint(x, y); + }, + endPath: function SVGGraphics_endPath() {}, + clip: function SVGGraphics_clip(type) { + var current = this.current; + var clipId = 'clippath' + clipCount; + clipCount++; + var clipPath = document.createElementNS(NS, 'svg:clipPath'); + clipPath.setAttributeNS(null, 'id', clipId); + clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + var clipElement = current.element.cloneNode(); + if (type === 'evenodd') { + clipElement.setAttributeNS(null, 'clip-rule', 'evenodd'); + } else { + clipElement.setAttributeNS(null, 'clip-rule', 'nonzero'); + } + clipPath.appendChild(clipElement); + this.defs.appendChild(clipPath); + if (current.activeClipUrl) { + current.clipGroup = null; + this.extraStack.forEach(function (prev) { + prev.clipGroup = null; + }); + } + current.activeClipUrl = 'url(#' + clipId + ')'; + this.tgrp = null; + }, + closePath: function SVGGraphics_closePath() { + var current = this.current; + var d = current.path.getAttributeNS(null, 'd'); + d += 'Z'; + current.path.setAttributeNS(null, 'd', d); + }, + setLeading: function SVGGraphics_setLeading(leading) { + this.current.leading = -leading; + }, + setTextRise: function SVGGraphics_setTextRise(textRise) { + this.current.textRise = textRise; + }, + setHScale: function SVGGraphics_setHScale(scale) { + this.current.textHScale = scale / 100; + }, + setGState: function SVGGraphics_setGState(states) { + for (var i = 0, ii = states.length; i < ii; i++) { + var state = states[i]; + var key = state[0]; + var value = state[1]; + switch (key) { + case 'LW': + this.setLineWidth(value); + break; + case 'LC': + this.setLineCap(value); + break; + case 'LJ': + this.setLineJoin(value); + break; + case 'ML': + this.setMiterLimit(value); + break; + case 'D': + this.setDash(value[0], value[1]); + break; + case 'Font': + this.setFont(value); + break; + default: + warn('Unimplemented graphic state ' + key); + break; + } + } + }, + fill: function SVGGraphics_fill() { + var current = this.current; + current.element.setAttributeNS(null, 'fill', current.fillColor); + }, + stroke: function SVGGraphics_stroke() { + var current = this.current; + current.element.setAttributeNS(null, 'stroke', current.strokeColor); + current.element.setAttributeNS(null, 'fill', 'none'); + }, + eoFill: function SVGGraphics_eoFill() { + var current = this.current; + current.element.setAttributeNS(null, 'fill', current.fillColor); + current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); + }, + fillStroke: function SVGGraphics_fillStroke() { + this.stroke(); + this.fill(); + }, + eoFillStroke: function SVGGraphics_eoFillStroke() { + this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); + this.fillStroke(); + }, + closeStroke: function SVGGraphics_closeStroke() { + this.closePath(); + this.stroke(); + }, + closeFillStroke: function SVGGraphics_closeFillStroke() { + this.closePath(); + this.fillStroke(); + }, + paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() { + var current = this.current; + var rect = document.createElementNS(NS, 'svg:rect'); + rect.setAttributeNS(null, 'x', '0'); + rect.setAttributeNS(null, 'y', '0'); + rect.setAttributeNS(null, 'width', '1px'); + rect.setAttributeNS(null, 'height', '1px'); + rect.setAttributeNS(null, 'fill', current.fillColor); + this._ensureTransformGroup().appendChild(rect); + }, + paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) { + var imgObj = this.objs.get(objId); + var imgEl = document.createElementNS(NS, 'svg:image'); + imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src); + imgEl.setAttributeNS(null, 'width', imgObj.width + 'px'); + imgEl.setAttributeNS(null, 'height', imgObj.height + 'px'); + imgEl.setAttributeNS(null, 'x', '0'); + imgEl.setAttributeNS(null, 'y', pf(-h)); + imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')'); + this._ensureTransformGroup().appendChild(imgEl); + }, + paintImageXObject: function SVGGraphics_paintImageXObject(objId) { + var imgData = this.objs.get(objId); + if (!imgData) { + warn('Dependent image isn\'t ready yet'); + return; + } + this.paintInlineImageXObject(imgData); + }, + paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) { + var width = imgData.width; + var height = imgData.height; + var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema); + var cliprect = document.createElementNS(NS, 'svg:rect'); + cliprect.setAttributeNS(null, 'x', '0'); + cliprect.setAttributeNS(null, 'y', '0'); + cliprect.setAttributeNS(null, 'width', pf(width)); + cliprect.setAttributeNS(null, 'height', pf(height)); + this.current.element = cliprect; + this.clip('nonzero'); + var imgEl = document.createElementNS(NS, 'svg:image'); + imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc); + imgEl.setAttributeNS(null, 'x', '0'); + imgEl.setAttributeNS(null, 'y', pf(-height)); + imgEl.setAttributeNS(null, 'width', pf(width) + 'px'); + imgEl.setAttributeNS(null, 'height', pf(height) + 'px'); + imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')'); + if (mask) { + mask.appendChild(imgEl); + } else { + this._ensureTransformGroup().appendChild(imgEl); + } + }, + paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) { + var current = this.current; + var width = imgData.width; + var height = imgData.height; + var fillColor = current.fillColor; + current.maskId = 'mask' + maskCount++; + var mask = document.createElementNS(NS, 'svg:mask'); + mask.setAttributeNS(null, 'id', current.maskId); + var rect = document.createElementNS(NS, 'svg:rect'); + rect.setAttributeNS(null, 'x', '0'); + rect.setAttributeNS(null, 'y', '0'); + rect.setAttributeNS(null, 'width', pf(width)); + rect.setAttributeNS(null, 'height', pf(height)); + rect.setAttributeNS(null, 'fill', fillColor); + rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')'); + this.defs.appendChild(mask); + this._ensureTransformGroup().appendChild(rect); + this.paintInlineImageXObject(imgData, mask); + }, + paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) { + if (isArray(matrix) && matrix.length === 6) { + this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + } + if (isArray(bbox) && bbox.length === 4) { + var width = bbox[2] - bbox[0]; + var height = bbox[3] - bbox[1]; + var cliprect = document.createElementNS(NS, 'svg:rect'); + cliprect.setAttributeNS(null, 'x', bbox[0]); + cliprect.setAttributeNS(null, 'y', bbox[1]); + cliprect.setAttributeNS(null, 'width', pf(width)); + cliprect.setAttributeNS(null, 'height', pf(height)); + this.current.element = cliprect; + this.clip('nonzero'); + this.endPath(); + } + }, + paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {}, + _initialize: function SVGGraphics_initialize(viewport) { + var svg = document.createElementNS(NS, 'svg:svg'); + svg.setAttributeNS(null, 'version', '1.1'); + svg.setAttributeNS(null, 'width', viewport.width + 'px'); + svg.setAttributeNS(null, 'height', viewport.height + 'px'); + svg.setAttributeNS(null, 'preserveAspectRatio', 'none'); + svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height); + var definitions = document.createElementNS(NS, 'svg:defs'); + svg.appendChild(definitions); + this.defs = definitions; + var rootGroup = document.createElementNS(NS, 'svg:g'); + rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform)); + svg.appendChild(rootGroup); + this.svg = rootGroup; + return svg; + }, + _ensureClipGroup: function SVGGraphics_ensureClipGroup() { + if (!this.current.clipGroup) { + var clipGroup = document.createElementNS(NS, 'svg:g'); + clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl); + this.svg.appendChild(clipGroup); + this.current.clipGroup = clipGroup; + } + return this.current.clipGroup; + }, + _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() { + if (!this.tgrp) { + this.tgrp = document.createElementNS(NS, 'svg:g'); + this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); + if (this.current.activeClipUrl) { + this._ensureClipGroup().appendChild(this.tgrp); + } else { + this.svg.appendChild(this.tgrp); + } + } + return this.tgrp; + } + }; + return SVGGraphics; +}(); +exports.SVGGraphics = SVGGraphics; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayDOMUtils = __w_pdfjs_require__(1); +var Util = sharedUtil.Util; +var createPromiseCapability = sharedUtil.createPromiseCapability; +var CustomStyle = displayDOMUtils.CustomStyle; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; +var renderTextLayer = function renderTextLayerClosure() { + var MAX_TEXT_DIVS_TO_RENDER = 100000; + var NonWhitespaceRegexp = /\S/; + function isAllWhitespace(str) { + return !NonWhitespaceRegexp.test(str); + } + var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';']; + function appendText(task, geom, styles) { + var textDiv = document.createElement('div'); + var textDivProperties = { + style: null, + angle: 0, + canvasWidth: 0, + isWhitespace: false, + originalTransform: null, + paddingBottom: 0, + paddingLeft: 0, + paddingRight: 0, + paddingTop: 0, + scale: 1 + }; + task._textDivs.push(textDiv); + if (isAllWhitespace(geom.str)) { + textDivProperties.isWhitespace = true; + task._textDivProperties.set(textDiv, textDivProperties); + return; + } + var tx = Util.transform(task._viewport.transform, geom.transform); + var angle = Math.atan2(tx[1], tx[0]); + var style = styles[geom.fontName]; + if (style.vertical) { + angle += Math.PI / 2; + } + var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]); + var fontAscent = fontHeight; + if (style.ascent) { + fontAscent = style.ascent * fontAscent; + } else if (style.descent) { + fontAscent = (1 + style.descent) * fontAscent; + } + var left; + var top; + if (angle === 0) { + left = tx[4]; + top = tx[5] - fontAscent; + } else { + left = tx[4] + fontAscent * Math.sin(angle); + top = tx[5] - fontAscent * Math.cos(angle); + } + styleBuf[1] = left; + styleBuf[3] = top; + styleBuf[5] = fontHeight; + styleBuf[7] = style.fontFamily; + textDivProperties.style = styleBuf.join(''); + textDiv.setAttribute('style', textDivProperties.style); + textDiv.textContent = geom.str; + if (getDefaultSetting('pdfBug')) { + textDiv.dataset.fontName = geom.fontName; + } + if (angle !== 0) { + textDivProperties.angle = angle * (180 / Math.PI); + } + if (geom.str.length > 1) { + if (style.vertical) { + textDivProperties.canvasWidth = geom.height * task._viewport.scale; + } else { + textDivProperties.canvasWidth = geom.width * task._viewport.scale; + } + } + task._textDivProperties.set(textDiv, textDivProperties); + if (task._enhanceTextSelection) { + var angleCos = 1, + angleSin = 0; + if (angle !== 0) { + angleCos = Math.cos(angle); + angleSin = Math.sin(angle); + } + var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale; + var divHeight = fontHeight; + var m, b; + if (angle !== 0) { + m = [angleCos, angleSin, -angleSin, angleCos, left, top]; + b = Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m); + } else { + b = [left, top, left + divWidth, top + divHeight]; + } + task._bounds.push({ + left: b[0], + top: b[1], + right: b[2], + bottom: b[3], + div: textDiv, + size: [divWidth, divHeight], + m: m + }); + } + } + function render(task) { + if (task._canceled) { + return; + } + var textLayerFrag = task._container; + var textDivs = task._textDivs; + var capability = task._capability; + var textDivsLength = textDivs.length; + if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { + task._renderingDone = true; + capability.resolve(); + return; + } + var canvas = document.createElement('canvas'); + canvas.mozOpaque = true; + var ctx = canvas.getContext('2d', { alpha: false }); + var lastFontSize; + var lastFontFamily; + for (var i = 0; i < textDivsLength; i++) { + var textDiv = textDivs[i]; + var textDivProperties = task._textDivProperties.get(textDiv); + if (textDivProperties.isWhitespace) { + continue; + } + var fontSize = textDiv.style.fontSize; + var fontFamily = textDiv.style.fontFamily; + if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) { + ctx.font = fontSize + ' ' + fontFamily; + lastFontSize = fontSize; + lastFontFamily = fontFamily; + } + var width = ctx.measureText(textDiv.textContent).width; + textLayerFrag.appendChild(textDiv); + var transform = ''; + if (textDivProperties.canvasWidth !== 0 && width > 0) { + textDivProperties.scale = textDivProperties.canvasWidth / width; + transform = 'scaleX(' + textDivProperties.scale + ')'; + } + if (textDivProperties.angle !== 0) { + transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform; + } + if (transform !== '') { + textDivProperties.originalTransform = transform; + CustomStyle.setProp('transform', textDiv, transform); + } + task._textDivProperties.set(textDiv, textDivProperties); + } + task._renderingDone = true; + capability.resolve(); + } + function expand(task) { + var bounds = task._bounds; + var viewport = task._viewport; + var expanded = expandBounds(viewport.width, viewport.height, bounds); + for (var i = 0; i < expanded.length; i++) { + var div = bounds[i].div; + var divProperties = task._textDivProperties.get(div); + if (divProperties.angle === 0) { + divProperties.paddingLeft = bounds[i].left - expanded[i].left; + divProperties.paddingTop = bounds[i].top - expanded[i].top; + divProperties.paddingRight = expanded[i].right - bounds[i].right; + divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom; + task._textDivProperties.set(div, divProperties); + continue; + } + var e = expanded[i], + b = bounds[i]; + var m = b.m, + c = m[0], + s = m[1]; + var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size]; + var ts = new Float64Array(64); + points.forEach(function (p, i) { + var t = Util.applyTransform(p, m); + ts[i + 0] = c && (e.left - t[0]) / c; + ts[i + 4] = s && (e.top - t[1]) / s; + ts[i + 8] = c && (e.right - t[0]) / c; + ts[i + 12] = s && (e.bottom - t[1]) / s; + ts[i + 16] = s && (e.left - t[0]) / -s; + ts[i + 20] = c && (e.top - t[1]) / c; + ts[i + 24] = s && (e.right - t[0]) / -s; + ts[i + 28] = c && (e.bottom - t[1]) / c; + ts[i + 32] = c && (e.left - t[0]) / -c; + ts[i + 36] = s && (e.top - t[1]) / -s; + ts[i + 40] = c && (e.right - t[0]) / -c; + ts[i + 44] = s && (e.bottom - t[1]) / -s; + ts[i + 48] = s && (e.left - t[0]) / s; + ts[i + 52] = c && (e.top - t[1]) / -c; + ts[i + 56] = s && (e.right - t[0]) / s; + ts[i + 60] = c && (e.bottom - t[1]) / -c; + }); + var findPositiveMin = function (ts, offset, count) { + var result = 0; + for (var i = 0; i < count; i++) { + var t = ts[offset++]; + if (t > 0) { + result = result ? Math.min(t, result) : t; + } + } + return result; + }; + var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s)); + divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale; + divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale; + divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale; + divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale; + task._textDivProperties.set(div, divProperties); + } + } + function expandBounds(width, height, boxes) { + var bounds = boxes.map(function (box, i) { + return { + x1: box.left, + y1: box.top, + x2: box.right, + y2: box.bottom, + index: i, + x1New: undefined, + x2New: undefined + }; + }); + expandBoundsLTR(width, bounds); + var expanded = new Array(boxes.length); + bounds.forEach(function (b) { + var i = b.index; + expanded[i] = { + left: b.x1New, + top: 0, + right: b.x2New, + bottom: 0 + }; + }); + boxes.map(function (box, i) { + var e = expanded[i], + b = bounds[i]; + b.x1 = box.top; + b.y1 = width - e.right; + b.x2 = box.bottom; + b.y2 = width - e.left; + b.index = i; + b.x1New = undefined; + b.x2New = undefined; + }); + expandBoundsLTR(height, bounds); + bounds.forEach(function (b) { + var i = b.index; + expanded[i].top = b.x1New; + expanded[i].bottom = b.x2New; + }); + return expanded; + } + function expandBoundsLTR(width, bounds) { + bounds.sort(function (a, b) { + return a.x1 - b.x1 || a.index - b.index; + }); + var fakeBoundary = { + x1: -Infinity, + y1: -Infinity, + x2: 0, + y2: Infinity, + index: -1, + x1New: 0, + x2New: 0 + }; + var horizon = [{ + start: -Infinity, + end: Infinity, + boundary: fakeBoundary + }]; + bounds.forEach(function (boundary) { + var i = 0; + while (i < horizon.length && horizon[i].end <= boundary.y1) { + i++; + } + var j = horizon.length - 1; + while (j >= 0 && horizon[j].start >= boundary.y2) { + j--; + } + var horizonPart, affectedBoundary; + var q, + k, + maxXNew = -Infinity; + for (q = i; q <= j; q++) { + horizonPart = horizon[q]; + affectedBoundary = horizonPart.boundary; + var xNew; + if (affectedBoundary.x2 > boundary.x1) { + xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1; + } else if (affectedBoundary.x2New === undefined) { + xNew = (affectedBoundary.x2 + boundary.x1) / 2; + } else { + xNew = affectedBoundary.x2New; + } + if (xNew > maxXNew) { + maxXNew = xNew; + } + } + boundary.x1New = maxXNew; + for (q = i; q <= j; q++) { + horizonPart = horizon[q]; + affectedBoundary = horizonPart.boundary; + if (affectedBoundary.x2New === undefined) { + if (affectedBoundary.x2 > boundary.x1) { + if (affectedBoundary.index > boundary.index) { + affectedBoundary.x2New = affectedBoundary.x2; + } + } else { + affectedBoundary.x2New = maxXNew; + } + } else if (affectedBoundary.x2New > maxXNew) { + affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2); + } + } + var changedHorizon = [], + lastBoundary = null; + for (q = i; q <= j; q++) { + horizonPart = horizon[q]; + affectedBoundary = horizonPart.boundary; + var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary; + if (lastBoundary === useBoundary) { + changedHorizon[changedHorizon.length - 1].end = horizonPart.end; + } else { + changedHorizon.push({ + start: horizonPart.start, + end: horizonPart.end, + boundary: useBoundary + }); + lastBoundary = useBoundary; + } + } + if (horizon[i].start < boundary.y1) { + changedHorizon[0].start = boundary.y1; + changedHorizon.unshift({ + start: horizon[i].start, + end: boundary.y1, + boundary: horizon[i].boundary + }); + } + if (boundary.y2 < horizon[j].end) { + changedHorizon[changedHorizon.length - 1].end = boundary.y2; + changedHorizon.push({ + start: boundary.y2, + end: horizon[j].end, + boundary: horizon[j].boundary + }); + } + for (q = i; q <= j; q++) { + horizonPart = horizon[q]; + affectedBoundary = horizonPart.boundary; + if (affectedBoundary.x2New !== undefined) { + continue; + } + var used = false; + for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) { + used = horizon[k].boundary === affectedBoundary; + } + for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) { + used = horizon[k].boundary === affectedBoundary; + } + for (k = 0; !used && k < changedHorizon.length; k++) { + used = changedHorizon[k].boundary === affectedBoundary; + } + if (!used) { + affectedBoundary.x2New = maxXNew; + } + } + Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon)); + }); + horizon.forEach(function (horizonPart) { + var affectedBoundary = horizonPart.boundary; + if (affectedBoundary.x2New === undefined) { + affectedBoundary.x2New = Math.max(width, affectedBoundary.x2); + } + }); + } + function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) { + this._textContent = textContent; + this._container = container; + this._viewport = viewport; + this._textDivs = textDivs || []; + this._textDivProperties = new WeakMap(); + this._renderingDone = false; + this._canceled = false; + this._capability = createPromiseCapability(); + this._renderTimer = null; + this._bounds = []; + this._enhanceTextSelection = !!enhanceTextSelection; + } + TextLayerRenderTask.prototype = { + get promise() { + return this._capability.promise; + }, + cancel: function TextLayer_cancel() { + this._canceled = true; + if (this._renderTimer !== null) { + clearTimeout(this._renderTimer); + this._renderTimer = null; + } + this._capability.reject('canceled'); + }, + _render: function TextLayer_render(timeout) { + var textItems = this._textContent.items; + var textStyles = this._textContent.styles; + for (var i = 0, len = textItems.length; i < len; i++) { + appendText(this, textItems[i], textStyles); + } + if (!timeout) { + render(this); + } else { + var self = this; + this._renderTimer = setTimeout(function () { + render(self); + self._renderTimer = null; + }, timeout); + } + }, + expandTextDivs: function TextLayer_expandTextDivs(expandDivs) { + if (!this._enhanceTextSelection || !this._renderingDone) { + return; + } + if (this._bounds !== null) { + expand(this); + this._bounds = null; + } + for (var i = 0, ii = this._textDivs.length; i < ii; i++) { + var div = this._textDivs[i]; + var divProperties = this._textDivProperties.get(div); + if (divProperties.isWhitespace) { + continue; + } + if (expandDivs) { + var transform = '', + padding = ''; + if (divProperties.scale !== 1) { + transform = 'scaleX(' + divProperties.scale + ')'; + } + if (divProperties.angle !== 0) { + transform = 'rotate(' + divProperties.angle + 'deg) ' + transform; + } + if (divProperties.paddingLeft !== 0) { + padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;'; + transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)'; + } + if (divProperties.paddingTop !== 0) { + padding += ' padding-top: ' + divProperties.paddingTop + 'px;'; + transform += ' translateY(' + -divProperties.paddingTop + 'px)'; + } + if (divProperties.paddingRight !== 0) { + padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;'; + } + if (divProperties.paddingBottom !== 0) { + padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;'; + } + if (padding !== '') { + div.setAttribute('style', divProperties.style + padding); + } + if (transform !== '') { + CustomStyle.setProp('transform', div, transform); + } + } else { + div.style.padding = 0; + CustomStyle.setProp('transform', div, divProperties.originalTransform || ''); + } + } + } + }; + function renderTextLayer(renderParameters) { + var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection); + task._render(renderParameters.timeout); + return task; + } + return renderTextLayer; +}(); +exports.renderTextLayer = renderTextLayer; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var g; +g = function () { + return this; +}(); +try { + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + if (typeof window === "object") g = window; +} +module.exports = g; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var error = sharedUtil.error; +function fixMetadata(meta) { + return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) { + var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) { + return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1); + }); + var chars = ''; + for (var i = 0; i < bytes.length; i += 2) { + var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1); + chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';'; + } + return '>' + chars; + }); +} +function Metadata(meta) { + if (typeof meta === 'string') { + meta = fixMetadata(meta); + var parser = new DOMParser(); + meta = parser.parseFromString(meta, 'application/xml'); + } else if (!(meta instanceof Document)) { + error('Metadata: Invalid metadata object'); + } + this.metaDocument = meta; + this.metadata = Object.create(null); + this.parse(); +} +Metadata.prototype = { + parse: function Metadata_parse() { + var doc = this.metaDocument; + var rdf = doc.documentElement; + if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { + rdf = rdf.firstChild; + while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') { + rdf = rdf.nextSibling; + } + } + var nodeName = rdf ? rdf.nodeName.toLowerCase() : null; + if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) { + return; + } + var children = rdf.childNodes, + desc, + entry, + name, + i, + ii, + length, + iLength; + for (i = 0, length = children.length; i < length; i++) { + desc = children[i]; + if (desc.nodeName.toLowerCase() !== 'rdf:description') { + continue; + } + for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) { + if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') { + entry = desc.childNodes[ii]; + name = entry.nodeName.toLowerCase(); + this.metadata[name] = entry.textContent.trim(); + } + } + } + }, + get: function Metadata_get(name) { + return this.metadata[name] || null; + }, + has: function Metadata_has(name) { + return typeof this.metadata[name] !== 'undefined'; + } +}; +exports.Metadata = Metadata; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayDOMUtils = __w_pdfjs_require__(1); +var shadow = sharedUtil.shadow; +var getDefaultSetting = displayDOMUtils.getDefaultSetting; +var WebGLUtils = function WebGLUtilsClosure() { + function loadShader(gl, code, shaderType) { + var shader = gl.createShader(shaderType); + gl.shaderSource(shader, code); + gl.compileShader(shader); + var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); + if (!compiled) { + var errorMsg = gl.getShaderInfoLog(shader); + throw new Error('Error during shader compilation: ' + errorMsg); + } + return shader; + } + function createVertexShader(gl, code) { + return loadShader(gl, code, gl.VERTEX_SHADER); + } + function createFragmentShader(gl, code) { + return loadShader(gl, code, gl.FRAGMENT_SHADER); + } + function createProgram(gl, shaders) { + var program = gl.createProgram(); + for (var i = 0, ii = shaders.length; i < ii; ++i) { + gl.attachShader(program, shaders[i]); + } + gl.linkProgram(program); + var linked = gl.getProgramParameter(program, gl.LINK_STATUS); + if (!linked) { + var errorMsg = gl.getProgramInfoLog(program); + throw new Error('Error during program linking: ' + errorMsg); + } + return program; + } + function createTexture(gl, image, textureId) { + gl.activeTexture(textureId); + var texture = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); + return texture; + } + var currentGL, currentCanvas; + function generateGL() { + if (currentGL) { + return; + } + currentCanvas = document.createElement('canvas'); + currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false }); + } + var smaskVertexShaderCode = '\ + attribute vec2 a_position; \ + attribute vec2 a_texCoord; \ + \ + uniform vec2 u_resolution; \ + \ + varying vec2 v_texCoord; \ + \ + void main() { \ + vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \ + gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ + \ + v_texCoord = a_texCoord; \ + } '; + var smaskFragmentShaderCode = '\ + precision mediump float; \ + \ + uniform vec4 u_backdrop; \ + uniform int u_subtype; \ + uniform sampler2D u_image; \ + uniform sampler2D u_mask; \ + \ + varying vec2 v_texCoord; \ + \ + void main() { \ + vec4 imageColor = texture2D(u_image, v_texCoord); \ + vec4 maskColor = texture2D(u_mask, v_texCoord); \ + if (u_backdrop.a > 0.0) { \ + maskColor.rgb = maskColor.rgb * maskColor.a + \ + u_backdrop.rgb * (1.0 - maskColor.a); \ + } \ + float lum; \ + if (u_subtype == 0) { \ + lum = maskColor.a; \ + } else { \ + lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \ + maskColor.b * 0.11; \ + } \ + imageColor.a *= lum; \ + imageColor.rgb *= imageColor.a; \ + gl_FragColor = imageColor; \ + } '; + var smaskCache = null; + function initSmaskGL() { + var canvas, gl; + generateGL(); + canvas = currentCanvas; + currentCanvas = null; + gl = currentGL; + currentGL = null; + var vertexShader = createVertexShader(gl, smaskVertexShaderCode); + var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode); + var program = createProgram(gl, [vertexShader, fragmentShader]); + gl.useProgram(program); + var cache = {}; + cache.gl = gl; + cache.canvas = canvas; + cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); + cache.positionLocation = gl.getAttribLocation(program, 'a_position'); + cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop'); + cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype'); + var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord'); + var texLayerLocation = gl.getUniformLocation(program, 'u_image'); + var texMaskLocation = gl.getUniformLocation(program, 'u_mask'); + var texCoordBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer); + 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); + gl.enableVertexAttribArray(texCoordLocation); + gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0); + gl.uniform1i(texLayerLocation, 0); + gl.uniform1i(texMaskLocation, 1); + smaskCache = cache; + } + function composeSMask(layer, mask, properties) { + var width = layer.width, + height = layer.height; + if (!smaskCache) { + initSmaskGL(); + } + var cache = smaskCache, + canvas = cache.canvas, + gl = cache.gl; + canvas.width = width; + canvas.height = height; + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + gl.uniform2f(cache.resolutionLocation, width, height); + if (properties.backdrop) { + gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1); + } else { + gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0); + } + gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0); + var texture = createTexture(gl, layer, gl.TEXTURE0); + var maskTexture = createTexture(gl, mask, gl.TEXTURE1); + var buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.positionLocation); + gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); + gl.clearColor(0, 0, 0, 0); + gl.enable(gl.BLEND); + gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + gl.clear(gl.COLOR_BUFFER_BIT); + gl.drawArrays(gl.TRIANGLES, 0, 6); + gl.flush(); + gl.deleteTexture(texture); + gl.deleteTexture(maskTexture); + gl.deleteBuffer(buffer); + return canvas; + } + var figuresVertexShaderCode = '\ + attribute vec2 a_position; \ + attribute vec3 a_color; \ + \ + uniform vec2 u_resolution; \ + uniform vec2 u_scale; \ + uniform vec2 u_offset; \ + \ + varying vec4 v_color; \ + \ + void main() { \ + vec2 position = (a_position + u_offset) * u_scale; \ + vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \ + gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ + \ + v_color = vec4(a_color / 255.0, 1.0); \ + } '; + var figuresFragmentShaderCode = '\ + precision mediump float; \ + \ + varying vec4 v_color; \ + \ + void main() { \ + gl_FragColor = v_color; \ + } '; + var figuresCache = null; + function initFiguresGL() { + var canvas, gl; + generateGL(); + canvas = currentCanvas; + currentCanvas = null; + gl = currentGL; + currentGL = null; + var vertexShader = createVertexShader(gl, figuresVertexShaderCode); + var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode); + var program = createProgram(gl, [vertexShader, fragmentShader]); + gl.useProgram(program); + var cache = {}; + cache.gl = gl; + cache.canvas = canvas; + cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); + cache.scaleLocation = gl.getUniformLocation(program, 'u_scale'); + cache.offsetLocation = gl.getUniformLocation(program, 'u_offset'); + cache.positionLocation = gl.getAttribLocation(program, 'a_position'); + cache.colorLocation = gl.getAttribLocation(program, 'a_color'); + figuresCache = cache; + } + function drawFigures(width, height, backgroundColor, figures, context) { + if (!figuresCache) { + initFiguresGL(); + } + var cache = figuresCache, + canvas = cache.canvas, + gl = cache.gl; + canvas.width = width; + canvas.height = height; + gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); + gl.uniform2f(cache.resolutionLocation, width, height); + var count = 0; + var i, ii, rows; + for (i = 0, ii = figures.length; i < ii; i++) { + switch (figures[i].type) { + case 'lattice': + rows = figures[i].coords.length / figures[i].verticesPerRow | 0; + count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; + break; + case 'triangles': + count += figures[i].coords.length; + break; + } + } + var coords = new Float32Array(count * 2); + var colors = new Uint8Array(count * 3); + var coordsMap = context.coords, + colorsMap = context.colors; + var pIndex = 0, + cIndex = 0; + for (i = 0, ii = figures.length; i < ii; i++) { + var figure = figures[i], + ps = figure.coords, + cs = figure.colors; + switch (figure.type) { + case 'lattice': + var cols = figure.verticesPerRow; + rows = ps.length / cols | 0; + for (var row = 1; row < rows; row++) { + var offset = row * cols + 1; + for (var col = 1; col < cols; col++, offset++) { + coords[pIndex] = coordsMap[ps[offset - cols - 1]]; + coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1]; + coords[pIndex + 2] = coordsMap[ps[offset - cols]]; + coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1]; + coords[pIndex + 4] = coordsMap[ps[offset - 1]]; + coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1]; + colors[cIndex] = colorsMap[cs[offset - cols - 1]]; + colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1]; + colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2]; + colors[cIndex + 3] = colorsMap[cs[offset - cols]]; + colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1]; + colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2]; + colors[cIndex + 6] = colorsMap[cs[offset - 1]]; + colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1]; + colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2]; + coords[pIndex + 6] = coords[pIndex + 2]; + coords[pIndex + 7] = coords[pIndex + 3]; + coords[pIndex + 8] = coords[pIndex + 4]; + coords[pIndex + 9] = coords[pIndex + 5]; + coords[pIndex + 10] = coordsMap[ps[offset]]; + coords[pIndex + 11] = coordsMap[ps[offset] + 1]; + colors[cIndex + 9] = colors[cIndex + 3]; + colors[cIndex + 10] = colors[cIndex + 4]; + colors[cIndex + 11] = colors[cIndex + 5]; + colors[cIndex + 12] = colors[cIndex + 6]; + colors[cIndex + 13] = colors[cIndex + 7]; + colors[cIndex + 14] = colors[cIndex + 8]; + colors[cIndex + 15] = colorsMap[cs[offset]]; + colors[cIndex + 16] = colorsMap[cs[offset] + 1]; + colors[cIndex + 17] = colorsMap[cs[offset] + 2]; + pIndex += 12; + cIndex += 18; + } + } + break; + case 'triangles': + for (var j = 0, jj = ps.length; j < jj; j++) { + coords[pIndex] = coordsMap[ps[j]]; + coords[pIndex + 1] = coordsMap[ps[j] + 1]; + colors[cIndex] = colorsMap[cs[j]]; + colors[cIndex + 1] = colorsMap[cs[j] + 1]; + colors[cIndex + 2] = colorsMap[cs[j] + 2]; + pIndex += 2; + cIndex += 3; + } + break; + } + } + if (backgroundColor) { + gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0); + } else { + gl.clearColor(0, 0, 0, 0); + } + gl.clear(gl.COLOR_BUFFER_BIT); + var coordsBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer); + gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.positionLocation); + gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); + var colorsBuffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer); + gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); + gl.enableVertexAttribArray(cache.colorLocation); + gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0); + gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY); + gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY); + gl.drawArrays(gl.TRIANGLES, 0, count); + gl.flush(); + gl.deleteBuffer(coordsBuffer); + gl.deleteBuffer(colorsBuffer); + return canvas; + } + function cleanup() { + if (smaskCache && smaskCache.canvas) { + smaskCache.canvas.width = 0; + smaskCache.canvas.height = 0; + } + if (figuresCache && figuresCache.canvas) { + figuresCache.canvas.width = 0; + figuresCache.canvas.height = 0; + } + smaskCache = null; + figuresCache = null; + } + return { + get isEnabled() { + if (getDefaultSetting('disableWebGL')) { + return false; + } + var enabled = false; + try { + generateGL(); + enabled = !!currentGL; + } catch (e) {} + return shadow(this, 'isEnabled', enabled); + }, + composeSMask: composeSMask, + drawFigures: drawFigures, + clear: cleanup + }; +}(); +exports.WebGLUtils = WebGLUtils; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayDOMUtils = __w_pdfjs_require__(1); +var displayAPI = __w_pdfjs_require__(3); +var displayAnnotationLayer = __w_pdfjs_require__(2); +var displayTextLayer = __w_pdfjs_require__(5); +var displayMetadata = __w_pdfjs_require__(7); +var displaySVG = __w_pdfjs_require__(4); +var globalScope = sharedUtil.globalScope; +var deprecated = sharedUtil.deprecated; +var warn = sharedUtil.warn; +var LinkTarget = displayDOMUtils.LinkTarget; +var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL; +var isWorker = typeof window === 'undefined'; +if (!globalScope.PDFJS) { + globalScope.PDFJS = {}; +} +var PDFJS = globalScope.PDFJS; +PDFJS.version = '1.8.172'; +PDFJS.build = '8ff1fbe7'; +PDFJS.pdfBug = false; +if (PDFJS.verbosity !== undefined) { + sharedUtil.setVerbosityLevel(PDFJS.verbosity); +} +delete PDFJS.verbosity; +Object.defineProperty(PDFJS, 'verbosity', { + get: function () { + return sharedUtil.getVerbosityLevel(); + }, + set: function (level) { + sharedUtil.setVerbosityLevel(level); + }, + enumerable: true, + configurable: true +}); +PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS; +PDFJS.OPS = sharedUtil.OPS; +PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES; +PDFJS.isValidUrl = displayDOMUtils.isValidUrl; +PDFJS.shadow = sharedUtil.shadow; +PDFJS.createBlob = sharedUtil.createBlob; +PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) { + return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL); +}; +Object.defineProperty(PDFJS, 'isLittleEndian', { + configurable: true, + get: function PDFJS_isLittleEndian() { + var value = sharedUtil.isLittleEndian(); + return sharedUtil.shadow(PDFJS, 'isLittleEndian', value); + } +}); +PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters; +PDFJS.PasswordResponses = sharedUtil.PasswordResponses; +PDFJS.PasswordException = sharedUtil.PasswordException; +PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException; +PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException; +PDFJS.MissingPDFException = sharedUtil.MissingPDFException; +PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException; +PDFJS.Util = sharedUtil.Util; +PDFJS.PageViewport = sharedUtil.PageViewport; +PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability; +PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize; +PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl; +PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked; +PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace; +PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath; +PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker; +PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc; +PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort; +PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange; +PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream; +PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch; +PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug; +PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers; +PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL; +PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL; +PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget; +PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel; +PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported; +PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext; +var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow; +delete PDFJS.openExternalLinksInNewWindow; +Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', { + get: function () { + return PDFJS.externalLinkTarget === LinkTarget.BLANK; + }, + set: function (value) { + if (value) { + deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.'); + } + if (PDFJS.externalLinkTarget !== LinkTarget.NONE) { + warn('PDFJS.externalLinkTarget is already initialized'); + return; + } + PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE; + }, + enumerable: true, + configurable: true +}); +if (savedOpenExternalLinksInNewWindow) { + PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow; +} +PDFJS.getDocument = displayAPI.getDocument; +PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; +PDFJS.PDFWorker = displayAPI.PDFWorker; +Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', { + configurable: true, + get: function PDFJS_hasCanvasTypedArrays() { + var value = displayDOMUtils.hasCanvasTypedArrays(); + return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value); + } +}); +PDFJS.CustomStyle = displayDOMUtils.CustomStyle; +PDFJS.LinkTarget = LinkTarget; +PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes; +PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; +PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet; +PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer; +PDFJS.renderTextLayer = displayTextLayer.renderTextLayer; +PDFJS.Metadata = displayMetadata.Metadata; +PDFJS.SVGGraphics = displaySVG.SVGGraphics; +PDFJS.UnsupportedManager = displayAPI._UnsupportedManager; +exports.globalScope = globalScope; +exports.isWorker = isWorker; +exports.PDFJS = globalScope.PDFJS; + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayDOMUtils = __w_pdfjs_require__(1); +var displayPatternHelper = __w_pdfjs_require__(12); +var displayWebGL = __w_pdfjs_require__(8); +var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; +var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX; +var ImageKind = sharedUtil.ImageKind; +var OPS = sharedUtil.OPS; +var TextRenderingMode = sharedUtil.TextRenderingMode; +var Uint32ArrayView = sharedUtil.Uint32ArrayView; +var Util = sharedUtil.Util; +var assert = sharedUtil.assert; +var info = sharedUtil.info; +var isNum = sharedUtil.isNum; +var isArray = sharedUtil.isArray; +var isLittleEndian = sharedUtil.isLittleEndian; +var error = sharedUtil.error; +var shadow = sharedUtil.shadow; +var warn = sharedUtil.warn; +var TilingPattern = displayPatternHelper.TilingPattern; +var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR; +var WebGLUtils = displayWebGL.WebGLUtils; +var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays; +var MIN_FONT_SIZE = 16; +var MAX_FONT_SIZE = 100; +var MAX_GROUP_SIZE = 4096; +var MIN_WIDTH_FACTOR = 0.65; +var COMPILE_TYPE3_GLYPHS = true; +var MAX_SIZE_TO_COMPILE = 1000; +var FULL_CHUNK_HEIGHT = 16; +var HasCanvasTypedArraysCached = { + get value() { + return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays()); + } +}; +var IsLittleEndianCached = { + get value() { + return shadow(IsLittleEndianCached, 'value', isLittleEndian()); + } +}; +function addContextCurrentTransform(ctx) { + if (!ctx.mozCurrentTransform) { + ctx._originalSave = ctx.save; + ctx._originalRestore = ctx.restore; + ctx._originalRotate = ctx.rotate; + ctx._originalScale = ctx.scale; + ctx._originalTranslate = ctx.translate; + ctx._originalTransform = ctx.transform; + ctx._originalSetTransform = ctx.setTransform; + ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0]; + ctx._transformStack = []; + Object.defineProperty(ctx, 'mozCurrentTransform', { + get: function getCurrentTransform() { + return this._transformMatrix; + } + }); + Object.defineProperty(ctx, 'mozCurrentTransformInverse', { + get: function getCurrentTransformInverse() { + var m = this._transformMatrix; + var a = m[0], + b = m[1], + c = m[2], + d = m[3], + e = m[4], + f = m[5]; + var ad_bc = a * d - b * c; + var bc_ad = b * c - a * d; + 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]; + } + }); + ctx.save = function ctxSave() { + var old = this._transformMatrix; + this._transformStack.push(old); + this._transformMatrix = old.slice(0, 6); + this._originalSave(); + }; + ctx.restore = function ctxRestore() { + var prev = this._transformStack.pop(); + if (prev) { + this._transformMatrix = prev; + this._originalRestore(); + } + }; + ctx.translate = function ctxTranslate(x, y) { + var m = this._transformMatrix; + m[4] = m[0] * x + m[2] * y + m[4]; + m[5] = m[1] * x + m[3] * y + m[5]; + this._originalTranslate(x, y); + }; + ctx.scale = function ctxScale(x, y) { + var m = this._transformMatrix; + m[0] = m[0] * x; + m[1] = m[1] * x; + m[2] = m[2] * y; + m[3] = m[3] * y; + this._originalScale(x, y); + }; + ctx.transform = function ctxTransform(a, b, c, d, e, f) { + var m = this._transformMatrix; + 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]]; + ctx._originalTransform(a, b, c, d, e, f); + }; + ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) { + this._transformMatrix = [a, b, c, d, e, f]; + ctx._originalSetTransform(a, b, c, d, e, f); + }; + ctx.rotate = function ctxRotate(angle) { + var cosValue = Math.cos(angle); + var sinValue = Math.sin(angle); + var m = this._transformMatrix; + 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]]; + this._originalRotate(angle); + }; + } +} +var CachedCanvases = function CachedCanvasesClosure() { + function CachedCanvases(canvasFactory) { + this.canvasFactory = canvasFactory; + this.cache = Object.create(null); + } + CachedCanvases.prototype = { + getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) { + var canvasEntry; + if (this.cache[id] !== undefined) { + canvasEntry = this.cache[id]; + this.canvasFactory.reset(canvasEntry, width, height); + canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0); + } else { + canvasEntry = this.canvasFactory.create(width, height); + this.cache[id] = canvasEntry; + } + if (trackTransform) { + addContextCurrentTransform(canvasEntry.context); + } + return canvasEntry; + }, + clear: function () { + for (var id in this.cache) { + var canvasEntry = this.cache[id]; + this.canvasFactory.destroy(canvasEntry); + delete this.cache[id]; + } + } + }; + return CachedCanvases; +}(); +function compileType3Glyph(imgData) { + var POINT_TO_PROCESS_LIMIT = 1000; + var width = imgData.width, + height = imgData.height; + var i, + j, + j0, + width1 = width + 1; + var points = new Uint8Array(width1 * (height + 1)); + var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]); + var lineSize = width + 7 & ~7, + data0 = imgData.data; + var data = new Uint8Array(lineSize * height), + pos = 0, + ii; + for (i = 0, ii = data0.length; i < ii; i++) { + var mask = 128, + elem = data0[i]; + while (mask > 0) { + data[pos++] = elem & mask ? 0 : 255; + mask >>= 1; + } + } + var count = 0; + pos = 0; + if (data[pos] !== 0) { + points[0] = 1; + ++count; + } + for (j = 1; j < width; j++) { + if (data[pos] !== data[pos + 1]) { + points[j] = data[pos] ? 2 : 1; + ++count; + } + pos++; + } + if (data[pos] !== 0) { + points[j] = 2; + ++count; + } + for (i = 1; i < height; i++) { + pos = i * lineSize; + j0 = i * width1; + if (data[pos - lineSize] !== data[pos]) { + points[j0] = data[pos] ? 1 : 8; + ++count; + } + var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0); + for (j = 1; j < width; j++) { + sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0); + if (POINT_TYPES[sum]) { + points[j0 + j] = POINT_TYPES[sum]; + ++count; + } + pos++; + } + if (data[pos - lineSize] !== data[pos]) { + points[j0 + j] = data[pos] ? 2 : 4; + ++count; + } + if (count > POINT_TO_PROCESS_LIMIT) { + return null; + } + } + pos = lineSize * (height - 1); + j0 = i * width1; + if (data[pos] !== 0) { + points[j0] = 8; + ++count; + } + for (j = 1; j < width; j++) { + if (data[pos] !== data[pos + 1]) { + points[j0 + j] = data[pos] ? 4 : 8; + ++count; + } + pos++; + } + if (data[pos] !== 0) { + points[j0 + j] = 4; + ++count; + } + if (count > POINT_TO_PROCESS_LIMIT) { + return null; + } + var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]); + var outlines = []; + for (i = 0; count && i <= height; i++) { + var p = i * width1; + var end = p + width; + while (p < end && !points[p]) { + p++; + } + if (p === end) { + continue; + } + var coords = [p % width1, i]; + var type = points[p], + p0 = p, + pp; + do { + var step = steps[type]; + do { + p += step; + } while (!points[p]); + pp = points[p]; + if (pp !== 5 && pp !== 10) { + type = pp; + points[p] = 0; + } else { + type = pp & 0x33 * type >> 4; + points[p] &= type >> 2 | type << 2; + } + coords.push(p % width1); + coords.push(p / width1 | 0); + --count; + } while (p0 !== p); + outlines.push(coords); + --i; + } + var drawOutline = function (c) { + c.save(); + c.scale(1 / width, -1 / height); + c.translate(0, -height); + c.beginPath(); + for (var i = 0, ii = outlines.length; i < ii; i++) { + var o = outlines[i]; + c.moveTo(o[0], o[1]); + for (var j = 2, jj = o.length; j < jj; j += 2) { + c.lineTo(o[j], o[j + 1]); + } + } + c.fill(); + c.beginPath(); + c.restore(); + }; + return drawOutline; +} +var CanvasExtraState = function CanvasExtraStateClosure() { + function CanvasExtraState(old) { + this.alphaIsShape = false; + this.fontSize = 0; + this.fontSizeScale = 1; + this.textMatrix = IDENTITY_MATRIX; + this.textMatrixScale = 1; + this.fontMatrix = FONT_IDENTITY_MATRIX; + this.leading = 0; + this.x = 0; + this.y = 0; + this.lineX = 0; + this.lineY = 0; + this.charSpacing = 0; + this.wordSpacing = 0; + this.textHScale = 1; + this.textRenderingMode = TextRenderingMode.FILL; + this.textRise = 0; + this.fillColor = '#000000'; + this.strokeColor = '#000000'; + this.patternFill = false; + this.fillAlpha = 1; + this.strokeAlpha = 1; + this.lineWidth = 1; + this.activeSMask = null; + this.resumeSMaskCtx = null; + this.old = old; + } + CanvasExtraState.prototype = { + clone: function CanvasExtraState_clone() { + return Object.create(this); + }, + setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) { + this.x = x; + this.y = y; + } + }; + return CanvasExtraState; +}(); +var CanvasGraphics = function CanvasGraphicsClosure() { + var EXECUTION_TIME = 15; + var EXECUTION_STEPS = 10; + function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) { + this.ctx = canvasCtx; + this.current = new CanvasExtraState(); + this.stateStack = []; + this.pendingClip = null; + this.pendingEOFill = false; + this.res = null; + this.xobjs = null; + this.commonObjs = commonObjs; + this.objs = objs; + this.canvasFactory = canvasFactory; + this.imageLayer = imageLayer; + this.groupStack = []; + this.processingType3 = null; + this.baseTransform = null; + this.baseTransformStack = []; + this.groupLevel = 0; + this.smaskStack = []; + this.smaskCounter = 0; + this.tempSMask = null; + this.cachedCanvases = new CachedCanvases(this.canvasFactory); + if (canvasCtx) { + addContextCurrentTransform(canvasCtx); + } + this.cachedGetSinglePixelWidth = null; + } + function putBinaryImageData(ctx, imgData) { + if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) { + ctx.putImageData(imgData, 0, 0); + return; + } + var height = imgData.height, + width = imgData.width; + var partialChunkHeight = height % FULL_CHUNK_HEIGHT; + var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; + var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; + var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); + var srcPos = 0, + destPos; + var src = imgData.data; + var dest = chunkImgData.data; + var i, j, thisChunkHeight, elemsInThisChunk; + if (imgData.kind === ImageKind.GRAYSCALE_1BPP) { + var srcLength = src.byteLength; + var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest); + var dest32DataLength = dest32.length; + var fullSrcDiff = width + 7 >> 3; + var white = 0xFFFFFFFF; + var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF; + for (i = 0; i < totalChunks; i++) { + thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight; + destPos = 0; + for (j = 0; j < thisChunkHeight; j++) { + var srcDiff = srcLength - srcPos; + var k = 0; + var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7; + var kEndUnrolled = kEnd & ~7; + var mask = 0; + var srcByte = 0; + for (; k < kEndUnrolled; k += 8) { + srcByte = src[srcPos++]; + dest32[destPos++] = srcByte & 128 ? white : black; + dest32[destPos++] = srcByte & 64 ? white : black; + dest32[destPos++] = srcByte & 32 ? white : black; + dest32[destPos++] = srcByte & 16 ? white : black; + dest32[destPos++] = srcByte & 8 ? white : black; + dest32[destPos++] = srcByte & 4 ? white : black; + dest32[destPos++] = srcByte & 2 ? white : black; + dest32[destPos++] = srcByte & 1 ? white : black; + } + for (; k < kEnd; k++) { + if (mask === 0) { + srcByte = src[srcPos++]; + mask = 128; + } + dest32[destPos++] = srcByte & mask ? white : black; + mask >>= 1; + } + } + while (destPos < dest32DataLength) { + dest32[destPos++] = 0; + } + ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); + } + } else if (imgData.kind === ImageKind.RGBA_32BPP) { + j = 0; + elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4; + for (i = 0; i < fullChunks; i++) { + dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); + srcPos += elemsInThisChunk; + ctx.putImageData(chunkImgData, 0, j); + j += FULL_CHUNK_HEIGHT; + } + if (i < totalChunks) { + elemsInThisChunk = width * partialChunkHeight * 4; + dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); + ctx.putImageData(chunkImgData, 0, j); + } + } else if (imgData.kind === ImageKind.RGB_24BPP) { + thisChunkHeight = FULL_CHUNK_HEIGHT; + elemsInThisChunk = width * thisChunkHeight; + for (i = 0; i < totalChunks; i++) { + if (i >= fullChunks) { + thisChunkHeight = partialChunkHeight; + elemsInThisChunk = width * thisChunkHeight; + } + destPos = 0; + for (j = elemsInThisChunk; j--;) { + dest[destPos++] = src[srcPos++]; + dest[destPos++] = src[srcPos++]; + dest[destPos++] = src[srcPos++]; + dest[destPos++] = 255; + } + ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); + } + } else { + error('bad image kind: ' + imgData.kind); + } + } + function putBinaryImageMask(ctx, imgData) { + var height = imgData.height, + width = imgData.width; + var partialChunkHeight = height % FULL_CHUNK_HEIGHT; + var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; + var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; + var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); + var srcPos = 0; + var src = imgData.data; + var dest = chunkImgData.data; + for (var i = 0; i < totalChunks; i++) { + var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight; + var destPos = 3; + for (var j = 0; j < thisChunkHeight; j++) { + var mask = 0; + for (var k = 0; k < width; k++) { + if (!mask) { + var elem = src[srcPos++]; + mask = 128; + } + dest[destPos] = elem & mask ? 0 : 255; + destPos += 4; + mask >>= 1; + } + } + ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); + } + } + function copyCtxState(sourceCtx, destCtx) { + var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font']; + for (var i = 0, ii = properties.length; i < ii; i++) { + var property = properties[i]; + if (sourceCtx[property] !== undefined) { + destCtx[property] = sourceCtx[property]; + } + } + if (sourceCtx.setLineDash !== undefined) { + destCtx.setLineDash(sourceCtx.getLineDash()); + destCtx.lineDashOffset = sourceCtx.lineDashOffset; + } + } + function composeSMaskBackdrop(bytes, r0, g0, b0) { + var length = bytes.length; + for (var i = 3; i < length; i += 4) { + var alpha = bytes[i]; + if (alpha === 0) { + bytes[i - 3] = r0; + bytes[i - 2] = g0; + bytes[i - 1] = b0; + } else if (alpha < 255) { + var alpha_ = 255 - alpha; + bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8; + bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8; + bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8; + } + } + } + function composeSMaskAlpha(maskData, layerData, transferMap) { + var length = maskData.length; + var scale = 1 / 255; + for (var i = 3; i < length; i += 4) { + var alpha = transferMap ? transferMap[maskData[i]] : maskData[i]; + layerData[i] = layerData[i] * alpha * scale | 0; + } + } + function composeSMaskLuminosity(maskData, layerData, transferMap) { + var length = maskData.length; + for (var i = 3; i < length; i += 4) { + var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28; + layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16; + } + } + function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) { + var hasBackdrop = !!backdrop; + var r0 = hasBackdrop ? backdrop[0] : 0; + var g0 = hasBackdrop ? backdrop[1] : 0; + var b0 = hasBackdrop ? backdrop[2] : 0; + var composeFn; + if (subtype === 'Luminosity') { + composeFn = composeSMaskLuminosity; + } else { + composeFn = composeSMaskAlpha; + } + var PIXELS_TO_PROCESS = 1048576; + var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width)); + for (var row = 0; row < height; row += chunkSize) { + var chunkHeight = Math.min(chunkSize, height - row); + var maskData = maskCtx.getImageData(0, row, width, chunkHeight); + var layerData = layerCtx.getImageData(0, row, width, chunkHeight); + if (hasBackdrop) { + composeSMaskBackdrop(maskData.data, r0, g0, b0); + } + composeFn(maskData.data, layerData.data, transferMap); + maskCtx.putImageData(layerData, 0, row); + } + } + function composeSMask(ctx, smask, layerCtx) { + var mask = smask.canvas; + var maskCtx = smask.context; + ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY); + var backdrop = smask.backdrop || null; + if (!smask.transferMap && WebGLUtils.isEnabled) { + var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, { + subtype: smask.subtype, + backdrop: backdrop + }); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.drawImage(composed, smask.offsetX, smask.offsetY); + return; + } + genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap); + ctx.drawImage(mask, 0, 0); + } + var LINE_CAP_STYLES = ['butt', 'round', 'square']; + var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; + var NORMAL_CLIP = {}; + var EO_CLIP = {}; + CanvasGraphics.prototype = { + beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) { + var width = this.ctx.canvas.width; + var height = this.ctx.canvas.height; + this.ctx.save(); + this.ctx.fillStyle = 'rgb(255, 255, 255)'; + this.ctx.fillRect(0, 0, width, height); + this.ctx.restore(); + if (transparency) { + var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true); + this.compositeCtx = this.ctx; + this.transparentCanvas = transparentCanvas.canvas; + this.ctx = transparentCanvas.context; + this.ctx.save(); + this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform); + } + this.ctx.save(); + if (transform) { + this.ctx.transform.apply(this.ctx, transform); + } + this.ctx.transform.apply(this.ctx, viewport.transform); + this.baseTransform = this.ctx.mozCurrentTransform.slice(); + if (this.imageLayer) { + this.imageLayer.beginLayout(); + } + }, + executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) { + var argsArray = operatorList.argsArray; + var fnArray = operatorList.fnArray; + var i = executionStartIdx || 0; + var argsArrayLen = argsArray.length; + if (argsArrayLen === i) { + return i; + } + var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function'; + var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0; + var steps = 0; + var commonObjs = this.commonObjs; + var objs = this.objs; + var fnId; + while (true) { + if (stepper !== undefined && i === stepper.nextBreakPoint) { + stepper.breakIt(i, continueCallback); + return i; + } + fnId = fnArray[i]; + if (fnId !== OPS.dependency) { + this[fnId].apply(this, argsArray[i]); + } else { + var deps = argsArray[i]; + for (var n = 0, nn = deps.length; n < nn; n++) { + var depObjId = deps[n]; + var common = depObjId[0] === 'g' && depObjId[1] === '_'; + var objsPool = common ? commonObjs : objs; + if (!objsPool.isResolved(depObjId)) { + objsPool.get(depObjId, continueCallback); + return i; + } + } + } + i++; + if (i === argsArrayLen) { + return i; + } + if (chunkOperations && ++steps > EXECUTION_STEPS) { + if (Date.now() > endTime) { + continueCallback(); + return i; + } + steps = 0; + } + } + }, + endDrawing: function CanvasGraphics_endDrawing() { + if (this.current.activeSMask !== null) { + this.endSMaskGroup(); + } + this.ctx.restore(); + if (this.transparentCanvas) { + this.ctx = this.compositeCtx; + this.ctx.save(); + this.ctx.setTransform(1, 0, 0, 1, 0, 0); + this.ctx.drawImage(this.transparentCanvas, 0, 0); + this.ctx.restore(); + this.transparentCanvas = null; + } + this.cachedCanvases.clear(); + WebGLUtils.clear(); + if (this.imageLayer) { + this.imageLayer.endLayout(); + } + }, + setLineWidth: function CanvasGraphics_setLineWidth(width) { + this.current.lineWidth = width; + this.ctx.lineWidth = width; + }, + setLineCap: function CanvasGraphics_setLineCap(style) { + this.ctx.lineCap = LINE_CAP_STYLES[style]; + }, + setLineJoin: function CanvasGraphics_setLineJoin(style) { + this.ctx.lineJoin = LINE_JOIN_STYLES[style]; + }, + setMiterLimit: function CanvasGraphics_setMiterLimit(limit) { + this.ctx.miterLimit = limit; + }, + setDash: function CanvasGraphics_setDash(dashArray, dashPhase) { + var ctx = this.ctx; + if (ctx.setLineDash !== undefined) { + ctx.setLineDash(dashArray); + ctx.lineDashOffset = dashPhase; + } + }, + setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {}, + setFlatness: function CanvasGraphics_setFlatness(flatness) {}, + setGState: function CanvasGraphics_setGState(states) { + for (var i = 0, ii = states.length; i < ii; i++) { + var state = states[i]; + var key = state[0]; + var value = state[1]; + switch (key) { + case 'LW': + this.setLineWidth(value); + break; + case 'LC': + this.setLineCap(value); + break; + case 'LJ': + this.setLineJoin(value); + break; + case 'ML': + this.setMiterLimit(value); + break; + case 'D': + this.setDash(value[0], value[1]); + break; + case 'RI': + this.setRenderingIntent(value); + break; + case 'FL': + this.setFlatness(value); + break; + case 'Font': + this.setFont(value[0], value[1]); + break; + case 'CA': + this.current.strokeAlpha = state[1]; + break; + case 'ca': + this.current.fillAlpha = state[1]; + this.ctx.globalAlpha = state[1]; + break; + case 'BM': + if (value && value.name && value.name !== 'Normal') { + var mode = value.name.replace(/([A-Z])/g, function (c) { + return '-' + c.toLowerCase(); + }).substring(1); + this.ctx.globalCompositeOperation = mode; + if (this.ctx.globalCompositeOperation !== mode) { + warn('globalCompositeOperation "' + mode + '" is not supported'); + } + } else { + this.ctx.globalCompositeOperation = 'source-over'; + } + break; + case 'SMask': + if (this.current.activeSMask) { + if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) { + this.suspendSMaskGroup(); + } else { + this.endSMaskGroup(); + } + } + this.current.activeSMask = value ? this.tempSMask : null; + if (this.current.activeSMask) { + this.beginSMaskGroup(); + } + this.tempSMask = null; + break; + } + } + }, + beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() { + var activeSMask = this.current.activeSMask; + var drawnWidth = activeSMask.canvas.width; + var drawnHeight = activeSMask.canvas.height; + var cacheId = 'smaskGroupAt' + this.groupLevel; + var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true); + var currentCtx = this.ctx; + var currentTransform = currentCtx.mozCurrentTransform; + this.ctx.save(); + var groupCtx = scratchCanvas.context; + groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY); + groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY); + groupCtx.transform.apply(groupCtx, currentTransform); + activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse; + copyCtxState(currentCtx, groupCtx); + this.ctx = groupCtx; + this.setGState([['BM', 'Normal'], ['ca', 1], ['CA', 1]]); + this.groupStack.push(currentCtx); + this.groupLevel++; + }, + suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() { + var groupCtx = this.ctx; + this.groupLevel--; + this.ctx = this.groupStack.pop(); + composeSMask(this.ctx, this.current.activeSMask, groupCtx); + this.ctx.restore(); + this.ctx.save(); + copyCtxState(groupCtx, this.ctx); + this.current.resumeSMaskCtx = groupCtx; + var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform); + this.ctx.transform.apply(this.ctx, deltaTransform); + groupCtx.save(); + groupCtx.setTransform(1, 0, 0, 1, 0, 0); + groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height); + groupCtx.restore(); + }, + resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() { + var groupCtx = this.current.resumeSMaskCtx; + var currentCtx = this.ctx; + this.ctx = groupCtx; + this.groupStack.push(currentCtx); + this.groupLevel++; + }, + endSMaskGroup: function CanvasGraphics_endSMaskGroup() { + var groupCtx = this.ctx; + this.groupLevel--; + this.ctx = this.groupStack.pop(); + composeSMask(this.ctx, this.current.activeSMask, groupCtx); + this.ctx.restore(); + copyCtxState(groupCtx, this.ctx); + var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform); + this.ctx.transform.apply(this.ctx, deltaTransform); + }, + save: function CanvasGraphics_save() { + this.ctx.save(); + var old = this.current; + this.stateStack.push(old); + this.current = old.clone(); + this.current.resumeSMaskCtx = null; + }, + restore: function CanvasGraphics_restore() { + if (this.current.resumeSMaskCtx) { + this.resumeSMaskGroup(); + } + if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) { + this.endSMaskGroup(); + } + if (this.stateStack.length !== 0) { + this.current = this.stateStack.pop(); + this.ctx.restore(); + this.pendingClip = null; + this.cachedGetSinglePixelWidth = null; + } + }, + transform: function CanvasGraphics_transform(a, b, c, d, e, f) { + this.ctx.transform(a, b, c, d, e, f); + this.cachedGetSinglePixelWidth = null; + }, + constructPath: function CanvasGraphics_constructPath(ops, args) { + var ctx = this.ctx; + var current = this.current; + var x = current.x, + y = current.y; + for (var i = 0, j = 0, ii = ops.length; i < ii; i++) { + switch (ops[i] | 0) { + case OPS.rectangle: + x = args[j++]; + y = args[j++]; + var width = args[j++]; + var height = args[j++]; + if (width === 0) { + width = this.getSinglePixelWidth(); + } + if (height === 0) { + height = this.getSinglePixelWidth(); + } + var xw = x + width; + var yh = y + height; + this.ctx.moveTo(x, y); + this.ctx.lineTo(xw, y); + this.ctx.lineTo(xw, yh); + this.ctx.lineTo(x, yh); + this.ctx.lineTo(x, y); + this.ctx.closePath(); + break; + case OPS.moveTo: + x = args[j++]; + y = args[j++]; + ctx.moveTo(x, y); + break; + case OPS.lineTo: + x = args[j++]; + y = args[j++]; + ctx.lineTo(x, y); + break; + case OPS.curveTo: + x = args[j + 4]; + y = args[j + 5]; + ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y); + j += 6; + break; + case OPS.curveTo2: + ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]); + x = args[j + 2]; + y = args[j + 3]; + j += 4; + break; + case OPS.curveTo3: + x = args[j + 2]; + y = args[j + 3]; + ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y); + j += 4; + break; + case OPS.closePath: + ctx.closePath(); + break; + } + } + current.setCurrentPoint(x, y); + }, + closePath: function CanvasGraphics_closePath() { + this.ctx.closePath(); + }, + stroke: function CanvasGraphics_stroke(consumePath) { + consumePath = typeof consumePath !== 'undefined' ? consumePath : true; + var ctx = this.ctx; + var strokeColor = this.current.strokeColor; + ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth); + ctx.globalAlpha = this.current.strokeAlpha; + if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') { + ctx.save(); + ctx.strokeStyle = strokeColor.getPattern(ctx, this); + ctx.stroke(); + ctx.restore(); + } else { + ctx.stroke(); + } + if (consumePath) { + this.consumePath(); + } + ctx.globalAlpha = this.current.fillAlpha; + }, + closeStroke: function CanvasGraphics_closeStroke() { + this.closePath(); + this.stroke(); + }, + fill: function CanvasGraphics_fill(consumePath) { + consumePath = typeof consumePath !== 'undefined' ? consumePath : true; + var ctx = this.ctx; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + var needRestore = false; + if (isPatternFill) { + ctx.save(); + if (this.baseTransform) { + ctx.setTransform.apply(ctx, this.baseTransform); + } + ctx.fillStyle = fillColor.getPattern(ctx, this); + needRestore = true; + } + if (this.pendingEOFill) { + ctx.fill('evenodd'); + this.pendingEOFill = false; + } else { + ctx.fill(); + } + if (needRestore) { + ctx.restore(); + } + if (consumePath) { + this.consumePath(); + } + }, + eoFill: function CanvasGraphics_eoFill() { + this.pendingEOFill = true; + this.fill(); + }, + fillStroke: function CanvasGraphics_fillStroke() { + this.fill(false); + this.stroke(false); + this.consumePath(); + }, + eoFillStroke: function CanvasGraphics_eoFillStroke() { + this.pendingEOFill = true; + this.fillStroke(); + }, + closeFillStroke: function CanvasGraphics_closeFillStroke() { + this.closePath(); + this.fillStroke(); + }, + closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() { + this.pendingEOFill = true; + this.closePath(); + this.fillStroke(); + }, + endPath: function CanvasGraphics_endPath() { + this.consumePath(); + }, + clip: function CanvasGraphics_clip() { + this.pendingClip = NORMAL_CLIP; + }, + eoClip: function CanvasGraphics_eoClip() { + this.pendingClip = EO_CLIP; + }, + beginText: function CanvasGraphics_beginText() { + this.current.textMatrix = IDENTITY_MATRIX; + this.current.textMatrixScale = 1; + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + }, + endText: function CanvasGraphics_endText() { + var paths = this.pendingTextPaths; + var ctx = this.ctx; + if (paths === undefined) { + ctx.beginPath(); + return; + } + ctx.save(); + ctx.beginPath(); + for (var i = 0; i < paths.length; i++) { + var path = paths[i]; + ctx.setTransform.apply(ctx, path.transform); + ctx.translate(path.x, path.y); + path.addToPath(ctx, path.fontSize); + } + ctx.restore(); + ctx.clip(); + ctx.beginPath(); + delete this.pendingTextPaths; + }, + setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) { + this.current.charSpacing = spacing; + }, + setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) { + this.current.wordSpacing = spacing; + }, + setHScale: function CanvasGraphics_setHScale(scale) { + this.current.textHScale = scale / 100; + }, + setLeading: function CanvasGraphics_setLeading(leading) { + this.current.leading = -leading; + }, + setFont: function CanvasGraphics_setFont(fontRefName, size) { + var fontObj = this.commonObjs.get(fontRefName); + var current = this.current; + if (!fontObj) { + error('Can\'t find font for ' + fontRefName); + } + current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX; + if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) { + warn('Invalid font matrix for font ' + fontRefName); + } + if (size < 0) { + size = -size; + current.fontDirection = -1; + } else { + current.fontDirection = 1; + } + this.current.font = fontObj; + this.current.fontSize = size; + if (fontObj.isType3Font) { + return; + } + var name = fontObj.loadedName || 'sans-serif'; + var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal'; + var italic = fontObj.italic ? 'italic' : 'normal'; + var typeface = '"' + name + '", ' + fontObj.fallbackName; + var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size; + this.current.fontSizeScale = size / browserFontSize; + var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; + this.ctx.font = rule; + }, + setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) { + this.current.textRenderingMode = mode; + }, + setTextRise: function CanvasGraphics_setTextRise(rise) { + this.current.textRise = rise; + }, + moveText: function CanvasGraphics_moveText(x, y) { + this.current.x = this.current.lineX += x; + this.current.y = this.current.lineY += y; + }, + setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) { + this.setLeading(-y); + this.moveText(x, y); + }, + setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) { + this.current.textMatrix = [a, b, c, d, e, f]; + this.current.textMatrixScale = Math.sqrt(a * a + b * b); + this.current.x = this.current.lineX = 0; + this.current.y = this.current.lineY = 0; + }, + nextLine: function CanvasGraphics_nextLine() { + this.moveText(0, this.current.leading); + }, + paintChar: function CanvasGraphics_paintChar(character, x, y) { + var ctx = this.ctx; + var current = this.current; + var font = current.font; + var textRenderingMode = current.textRenderingMode; + var fontSize = current.fontSize / current.fontSizeScale; + var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK; + var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG); + var addToPath; + if (font.disableFontFace || isAddToPathSet) { + addToPath = font.getPathGenerator(this.commonObjs, character); + } + if (font.disableFontFace) { + ctx.save(); + ctx.translate(x, y); + ctx.beginPath(); + addToPath(ctx, fontSize); + if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.fill(); + } + if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.stroke(); + } + ctx.restore(); + } else { + if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.fillText(character, x, y); + } + if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) { + ctx.strokeText(character, x, y); + } + } + if (isAddToPathSet) { + var paths = this.pendingTextPaths || (this.pendingTextPaths = []); + paths.push({ + transform: ctx.mozCurrentTransform, + x: x, + y: y, + fontSize: fontSize, + addToPath: addToPath + }); + } + }, + get isFontSubpixelAAEnabled() { + var ctx = this.canvasFactory.create(10, 10).context; + ctx.scale(1.5, 1); + ctx.fillText('I', 0, 10); + var data = ctx.getImageData(0, 0, 10, 10).data; + var enabled = false; + for (var i = 3; i < data.length; i += 4) { + if (data[i] > 0 && data[i] < 255) { + enabled = true; + break; + } + } + return shadow(this, 'isFontSubpixelAAEnabled', enabled); + }, + showText: function CanvasGraphics_showText(glyphs) { + var current = this.current; + var font = current.font; + if (font.isType3Font) { + return this.showType3Text(glyphs); + } + var fontSize = current.fontSize; + if (fontSize === 0) { + return; + } + var ctx = this.ctx; + var fontSizeScale = current.fontSizeScale; + var charSpacing = current.charSpacing; + var wordSpacing = current.wordSpacing; + var fontDirection = current.fontDirection; + var textHScale = current.textHScale * fontDirection; + var glyphsLength = glyphs.length; + var vertical = font.vertical; + var spacingDir = vertical ? 1 : -1; + var defaultVMetrics = font.defaultVMetrics; + var widthAdvanceScale = fontSize * current.fontMatrix[0]; + var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace; + ctx.save(); + ctx.transform.apply(ctx, current.textMatrix); + ctx.translate(current.x, current.y + current.textRise); + if (current.patternFill) { + ctx.fillStyle = current.fillColor.getPattern(ctx, this); + } + if (fontDirection > 0) { + ctx.scale(textHScale, -1); + } else { + ctx.scale(textHScale, 1); + } + var lineWidth = current.lineWidth; + var scale = current.textMatrixScale; + if (scale === 0 || lineWidth === 0) { + var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK; + if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) { + this.cachedGetSinglePixelWidth = null; + lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR; + } + } else { + lineWidth /= scale; + } + if (fontSizeScale !== 1.0) { + ctx.scale(fontSizeScale, fontSizeScale); + lineWidth /= fontSizeScale; + } + ctx.lineWidth = lineWidth; + var x = 0, + i; + for (i = 0; i < glyphsLength; ++i) { + var glyph = glyphs[i]; + if (isNum(glyph)) { + x += spacingDir * glyph * fontSize / 1000; + continue; + } + var restoreNeeded = false; + var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; + var character = glyph.fontChar; + var accent = glyph.accent; + var scaledX, scaledY, scaledAccentX, scaledAccentY; + var width = glyph.width; + if (vertical) { + var vmetric, vx, vy; + vmetric = glyph.vmetric || defaultVMetrics; + vx = glyph.vmetric ? vmetric[1] : width * 0.5; + vx = -vx * widthAdvanceScale; + vy = vmetric[2] * widthAdvanceScale; + width = vmetric ? -vmetric[0] : width; + scaledX = vx / fontSizeScale; + scaledY = (x + vy) / fontSizeScale; + } else { + scaledX = x / fontSizeScale; + scaledY = 0; + } + if (font.remeasure && width > 0) { + var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale; + if (width < measuredWidth && this.isFontSubpixelAAEnabled) { + var characterScaleX = width / measuredWidth; + restoreNeeded = true; + ctx.save(); + ctx.scale(characterScaleX, 1); + scaledX /= characterScaleX; + } else if (width !== measuredWidth) { + scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale; + } + } + if (glyph.isInFont || font.missingFile) { + if (simpleFillText && !accent) { + ctx.fillText(character, scaledX, scaledY); + } else { + this.paintChar(character, scaledX, scaledY); + if (accent) { + scaledAccentX = scaledX + accent.offset.x / fontSizeScale; + scaledAccentY = scaledY - accent.offset.y / fontSizeScale; + this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY); + } + } + } + var charWidth = width * widthAdvanceScale + spacing * fontDirection; + x += charWidth; + if (restoreNeeded) { + ctx.restore(); + } + } + if (vertical) { + current.y -= x * textHScale; + } else { + current.x += x * textHScale; + } + ctx.restore(); + }, + showType3Text: function CanvasGraphics_showType3Text(glyphs) { + var ctx = this.ctx; + var current = this.current; + var font = current.font; + var fontSize = current.fontSize; + var fontDirection = current.fontDirection; + var spacingDir = font.vertical ? 1 : -1; + var charSpacing = current.charSpacing; + var wordSpacing = current.wordSpacing; + var textHScale = current.textHScale * fontDirection; + var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX; + var glyphsLength = glyphs.length; + var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE; + var i, glyph, width, spacingLength; + if (isTextInvisible || fontSize === 0) { + return; + } + this.cachedGetSinglePixelWidth = null; + ctx.save(); + ctx.transform.apply(ctx, current.textMatrix); + ctx.translate(current.x, current.y); + ctx.scale(textHScale, fontDirection); + for (i = 0; i < glyphsLength; ++i) { + glyph = glyphs[i]; + if (isNum(glyph)) { + spacingLength = spacingDir * glyph * fontSize / 1000; + this.ctx.translate(spacingLength, 0); + current.x += spacingLength * textHScale; + continue; + } + var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; + var operatorList = font.charProcOperatorList[glyph.operatorListId]; + if (!operatorList) { + warn('Type3 character \"' + glyph.operatorListId + '\" is not available'); + continue; + } + this.processingType3 = glyph; + this.save(); + ctx.scale(fontSize, fontSize); + ctx.transform.apply(ctx, fontMatrix); + this.executeOperatorList(operatorList); + this.restore(); + var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); + width = transformed[0] * fontSize + spacing; + ctx.translate(width, 0); + current.x += width * textHScale; + } + ctx.restore(); + this.processingType3 = null; + }, + setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {}, + setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) { + this.ctx.rect(llx, lly, urx - llx, ury - lly); + this.clip(); + this.endPath(); + }, + getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) { + var pattern; + if (IR[0] === 'TilingPattern') { + var color = IR[1]; + var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice(); + var self = this; + var canvasGraphicsFactory = { + createCanvasGraphics: function (ctx) { + return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory); + } + }; + pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform); + } else { + pattern = getShadingPatternFromIR(IR); + } + return pattern; + }, + setStrokeColorN: function CanvasGraphics_setStrokeColorN() { + this.current.strokeColor = this.getColorN_Pattern(arguments); + }, + setFillColorN: function CanvasGraphics_setFillColorN() { + this.current.fillColor = this.getColorN_Pattern(arguments); + this.current.patternFill = true; + }, + setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.ctx.strokeStyle = color; + this.current.strokeColor = color; + }, + setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { + var color = Util.makeCssRgb(r, g, b); + this.ctx.fillStyle = color; + this.current.fillColor = color; + this.current.patternFill = false; + }, + shadingFill: function CanvasGraphics_shadingFill(patternIR) { + var ctx = this.ctx; + this.save(); + var pattern = getShadingPatternFromIR(patternIR); + ctx.fillStyle = pattern.getPattern(ctx, this, true); + var inv = ctx.mozCurrentTransformInverse; + if (inv) { + var canvas = ctx.canvas; + var width = canvas.width; + var height = canvas.height; + var bl = Util.applyTransform([0, 0], inv); + var br = Util.applyTransform([0, height], inv); + var ul = Util.applyTransform([width, 0], inv); + var ur = Util.applyTransform([width, height], inv); + var x0 = Math.min(bl[0], br[0], ul[0], ur[0]); + var y0 = Math.min(bl[1], br[1], ul[1], ur[1]); + var x1 = Math.max(bl[0], br[0], ul[0], ur[0]); + var y1 = Math.max(bl[1], br[1], ul[1], ur[1]); + this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0); + } else { + this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10); + } + this.restore(); + }, + beginInlineImage: function CanvasGraphics_beginInlineImage() { + error('Should not call beginInlineImage'); + }, + beginImageData: function CanvasGraphics_beginImageData() { + error('Should not call beginImageData'); + }, + paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) { + this.save(); + this.baseTransformStack.push(this.baseTransform); + if (isArray(matrix) && matrix.length === 6) { + this.transform.apply(this, matrix); + } + this.baseTransform = this.ctx.mozCurrentTransform; + if (isArray(bbox) && bbox.length === 4) { + var width = bbox[2] - bbox[0]; + var height = bbox[3] - bbox[1]; + this.ctx.rect(bbox[0], bbox[1], width, height); + this.clip(); + this.endPath(); + } + }, + paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() { + this.restore(); + this.baseTransform = this.baseTransformStack.pop(); + }, + beginGroup: function CanvasGraphics_beginGroup(group) { + this.save(); + var currentCtx = this.ctx; + if (!group.isolated) { + info('TODO: Support non-isolated groups.'); + } + if (group.knockout) { + warn('Knockout groups not supported.'); + } + var currentTransform = currentCtx.mozCurrentTransform; + if (group.matrix) { + currentCtx.transform.apply(currentCtx, group.matrix); + } + assert(group.bbox, 'Bounding box is required.'); + var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform); + var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height]; + bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0]; + var offsetX = Math.floor(bounds[0]); + var offsetY = Math.floor(bounds[1]); + var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1); + var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1); + var scaleX = 1, + scaleY = 1; + if (drawnWidth > MAX_GROUP_SIZE) { + scaleX = drawnWidth / MAX_GROUP_SIZE; + drawnWidth = MAX_GROUP_SIZE; + } + if (drawnHeight > MAX_GROUP_SIZE) { + scaleY = drawnHeight / MAX_GROUP_SIZE; + drawnHeight = MAX_GROUP_SIZE; + } + var cacheId = 'groupAt' + this.groupLevel; + if (group.smask) { + cacheId += '_smask_' + this.smaskCounter++ % 2; + } + var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true); + var groupCtx = scratchCanvas.context; + groupCtx.scale(1 / scaleX, 1 / scaleY); + groupCtx.translate(-offsetX, -offsetY); + groupCtx.transform.apply(groupCtx, currentTransform); + if (group.smask) { + this.smaskStack.push({ + canvas: scratchCanvas.canvas, + context: groupCtx, + offsetX: offsetX, + offsetY: offsetY, + scaleX: scaleX, + scaleY: scaleY, + subtype: group.smask.subtype, + backdrop: group.smask.backdrop, + transferMap: group.smask.transferMap || null, + startTransformInverse: null + }); + } else { + currentCtx.setTransform(1, 0, 0, 1, 0, 0); + currentCtx.translate(offsetX, offsetY); + currentCtx.scale(scaleX, scaleY); + } + copyCtxState(currentCtx, groupCtx); + this.ctx = groupCtx; + this.setGState([['BM', 'Normal'], ['ca', 1], ['CA', 1]]); + this.groupStack.push(currentCtx); + this.groupLevel++; + this.current.activeSMask = null; + }, + endGroup: function CanvasGraphics_endGroup(group) { + this.groupLevel--; + var groupCtx = this.ctx; + this.ctx = this.groupStack.pop(); + if (this.ctx.imageSmoothingEnabled !== undefined) { + this.ctx.imageSmoothingEnabled = false; + } else { + this.ctx.mozImageSmoothingEnabled = false; + } + if (group.smask) { + this.tempSMask = this.smaskStack.pop(); + } else { + this.ctx.drawImage(groupCtx.canvas, 0, 0); + } + this.restore(); + }, + beginAnnotations: function CanvasGraphics_beginAnnotations() { + this.save(); + this.current = new CanvasExtraState(); + if (this.baseTransform) { + this.ctx.setTransform.apply(this.ctx, this.baseTransform); + } + }, + endAnnotations: function CanvasGraphics_endAnnotations() { + this.restore(); + }, + beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) { + this.save(); + if (isArray(rect) && rect.length === 4) { + var width = rect[2] - rect[0]; + var height = rect[3] - rect[1]; + this.ctx.rect(rect[0], rect[1], width, height); + this.clip(); + this.endPath(); + } + this.transform.apply(this, transform); + this.transform.apply(this, matrix); + }, + endAnnotation: function CanvasGraphics_endAnnotation() { + this.restore(); + }, + paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) { + var domImage = this.objs.get(objId); + if (!domImage) { + warn('Dependent image isn\'t ready yet'); + return; + } + this.save(); + var ctx = this.ctx; + ctx.scale(1 / w, -1 / h); + ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h); + if (this.imageLayer) { + var currentTransform = ctx.mozCurrentTransformInverse; + var position = this.getCanvasPosition(0, 0); + this.imageLayer.appendImage({ + objId: objId, + left: position[0], + top: position[1], + width: w / currentTransform[0], + height: h / currentTransform[3] + }); + } + this.restore(); + }, + paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) { + var ctx = this.ctx; + var width = img.width, + height = img.height; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + var glyph = this.processingType3; + if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) { + if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) { + glyph.compiled = compileType3Glyph({ + data: img.data, + width: width, + height: height + }); + } else { + glyph.compiled = null; + } + } + if (glyph && glyph.compiled) { + glyph.compiled(ctx); + return; + } + var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); + var maskCtx = maskCanvas.context; + maskCtx.save(); + putBinaryImageMask(maskCtx, img); + maskCtx.globalCompositeOperation = 'source-in'; + maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; + maskCtx.fillRect(0, 0, width, height); + maskCtx.restore(); + this.paintInlineImageXObject(maskCanvas.canvas); + }, + paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) { + var width = imgData.width; + var height = imgData.height; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); + var maskCtx = maskCanvas.context; + maskCtx.save(); + putBinaryImageMask(maskCtx, imgData); + maskCtx.globalCompositeOperation = 'source-in'; + maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; + maskCtx.fillRect(0, 0, width, height); + maskCtx.restore(); + var ctx = this.ctx; + for (var i = 0, ii = positions.length; i < ii; i += 2) { + ctx.save(); + ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]); + ctx.scale(1, -1); + ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1); + ctx.restore(); + } + }, + paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) { + var ctx = this.ctx; + var fillColor = this.current.fillColor; + var isPatternFill = this.current.patternFill; + for (var i = 0, ii = images.length; i < ii; i++) { + var image = images[i]; + var width = image.width, + height = image.height; + var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); + var maskCtx = maskCanvas.context; + maskCtx.save(); + putBinaryImageMask(maskCtx, image); + maskCtx.globalCompositeOperation = 'source-in'; + maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; + maskCtx.fillRect(0, 0, width, height); + maskCtx.restore(); + ctx.save(); + ctx.transform.apply(ctx, image.transform); + ctx.scale(1, -1); + ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1); + ctx.restore(); + } + }, + paintImageXObject: function CanvasGraphics_paintImageXObject(objId) { + var imgData = this.objs.get(objId); + if (!imgData) { + warn('Dependent image isn\'t ready yet'); + return; + } + this.paintInlineImageXObject(imgData); + }, + paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) { + var imgData = this.objs.get(objId); + if (!imgData) { + warn('Dependent image isn\'t ready yet'); + return; + } + var width = imgData.width; + var height = imgData.height; + var map = []; + for (var i = 0, ii = positions.length; i < ii; i += 2) { + map.push({ + transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]], + x: 0, + y: 0, + w: width, + h: height + }); + } + this.paintInlineImageXObjectGroup(imgData, map); + }, + paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) { + var width = imgData.width; + var height = imgData.height; + var ctx = this.ctx; + this.save(); + ctx.scale(1 / width, -1 / height); + var currentTransform = ctx.mozCurrentTransformInverse; + var a = currentTransform[0], + b = currentTransform[1]; + var widthScale = Math.max(Math.sqrt(a * a + b * b), 1); + var c = currentTransform[2], + d = currentTransform[3]; + var heightScale = Math.max(Math.sqrt(c * c + d * d), 1); + var imgToPaint, tmpCanvas; + if (imgData instanceof HTMLElement || !imgData.data) { + imgToPaint = imgData; + } else { + tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height); + var tmpCtx = tmpCanvas.context; + putBinaryImageData(tmpCtx, imgData); + imgToPaint = tmpCanvas.canvas; + } + var paintWidth = width, + paintHeight = height; + var tmpCanvasId = 'prescale1'; + while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) { + var newWidth = paintWidth, + newHeight = paintHeight; + if (widthScale > 2 && paintWidth > 1) { + newWidth = Math.ceil(paintWidth / 2); + widthScale /= paintWidth / newWidth; + } + if (heightScale > 2 && paintHeight > 1) { + newHeight = Math.ceil(paintHeight / 2); + heightScale /= paintHeight / newHeight; + } + tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight); + tmpCtx = tmpCanvas.context; + tmpCtx.clearRect(0, 0, newWidth, newHeight); + tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight); + imgToPaint = tmpCanvas.canvas; + paintWidth = newWidth; + paintHeight = newHeight; + tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1'; + } + ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height); + if (this.imageLayer) { + var position = this.getCanvasPosition(0, -height); + this.imageLayer.appendImage({ + imgData: imgData, + left: position[0], + top: position[1], + width: width / currentTransform[0], + height: height / currentTransform[3] + }); + } + this.restore(); + }, + paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) { + var ctx = this.ctx; + var w = imgData.width; + var h = imgData.height; + var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h); + var tmpCtx = tmpCanvas.context; + putBinaryImageData(tmpCtx, imgData); + for (var i = 0, ii = map.length; i < ii; i++) { + var entry = map[i]; + ctx.save(); + ctx.transform.apply(ctx, entry.transform); + ctx.scale(1, -1); + ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1); + if (this.imageLayer) { + var position = this.getCanvasPosition(entry.x, entry.y); + this.imageLayer.appendImage({ + imgData: imgData, + left: position[0], + top: position[1], + width: w, + height: h + }); + } + ctx.restore(); + } + }, + paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() { + this.ctx.fillRect(0, 0, 1, 1); + }, + paintXObject: function CanvasGraphics_paintXObject() { + warn('Unsupported \'paintXObject\' command.'); + }, + markPoint: function CanvasGraphics_markPoint(tag) {}, + markPointProps: function CanvasGraphics_markPointProps(tag, properties) {}, + beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {}, + beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {}, + endMarkedContent: function CanvasGraphics_endMarkedContent() {}, + beginCompat: function CanvasGraphics_beginCompat() {}, + endCompat: function CanvasGraphics_endCompat() {}, + consumePath: function CanvasGraphics_consumePath() { + var ctx = this.ctx; + if (this.pendingClip) { + if (this.pendingClip === EO_CLIP) { + ctx.clip('evenodd'); + } else { + ctx.clip(); + } + this.pendingClip = null; + } + ctx.beginPath(); + }, + getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { + if (this.cachedGetSinglePixelWidth === null) { + this.ctx.save(); + var inverse = this.ctx.mozCurrentTransformInverse; + this.ctx.restore(); + this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3])); + } + return this.cachedGetSinglePixelWidth; + }, + getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { + var transform = this.ctx.mozCurrentTransform; + return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]]; + } + }; + for (var op in OPS) { + CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op]; + } + return CanvasGraphics; +}(); +exports.CanvasGraphics = CanvasGraphics; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var assert = sharedUtil.assert; +var bytesToString = sharedUtil.bytesToString; +var string32 = sharedUtil.string32; +var shadow = sharedUtil.shadow; +var warn = sharedUtil.warn; +function FontLoader(docId) { + this.docId = docId; + this.styleElement = null; + this.nativeFontFaces = []; + this.loadTestFontId = 0; + this.loadingContext = { + requests: [], + nextRequestId: 0 + }; +} +FontLoader.prototype = { + insertRule: function fontLoaderInsertRule(rule) { + var styleElement = this.styleElement; + if (!styleElement) { + styleElement = this.styleElement = document.createElement('style'); + styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId; + document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement); + } + var styleSheet = styleElement.sheet; + styleSheet.insertRule(rule, styleSheet.cssRules.length); + }, + clear: function fontLoaderClear() { + if (this.styleElement) { + this.styleElement.remove(); + this.styleElement = null; + } + this.nativeFontFaces.forEach(function (nativeFontFace) { + document.fonts.delete(nativeFontFace); + }); + this.nativeFontFaces.length = 0; + } +}; +var getLoadTestFont = function () { + return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA=='); +}; +Object.defineProperty(FontLoader.prototype, 'loadTestFont', { + get: function () { + return shadow(this, 'loadTestFont', getLoadTestFont()); + }, + configurable: true +}); +FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) { + this.nativeFontFaces.push(nativeFontFace); + document.fonts.add(nativeFontFace); +}; +FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) { + var rules = []; + var fontsToLoad = []; + var fontLoadPromises = []; + var getNativeFontPromise = function (nativeFontFace) { + return nativeFontFace.loaded.catch(function (e) { + warn('Failed to load font "' + nativeFontFace.family + '": ' + e); + }); + }; + var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported; + for (var i = 0, ii = fonts.length; i < ii; i++) { + var font = fonts[i]; + if (font.attached || font.loading === false) { + continue; + } + font.attached = true; + if (isFontLoadingAPISupported) { + var nativeFontFace = font.createNativeFontFace(); + if (nativeFontFace) { + this.addNativeFontFace(nativeFontFace); + fontLoadPromises.push(getNativeFontPromise(nativeFontFace)); + } + } else { + var rule = font.createFontFaceRule(); + if (rule) { + this.insertRule(rule); + rules.push(rule); + fontsToLoad.push(font); + } + } + } + var request = this.queueLoadingCallback(callback); + if (isFontLoadingAPISupported) { + Promise.all(fontLoadPromises).then(function () { + request.complete(); + }); + } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) { + this.prepareFontLoadEvent(rules, fontsToLoad, request); + } else { + request.complete(); + } +}; +FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) { + function LoadLoader_completeRequest() { + assert(!request.end, 'completeRequest() cannot be called twice'); + request.end = Date.now(); + while (context.requests.length > 0 && context.requests[0].end) { + var otherRequest = context.requests.shift(); + setTimeout(otherRequest.callback, 0); + } + } + var context = this.loadingContext; + var requestId = 'pdfjs-font-loading-' + context.nextRequestId++; + var request = { + id: requestId, + complete: LoadLoader_completeRequest, + callback: callback, + started: Date.now() + }; + context.requests.push(request); + return request; +}; +FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) { + function int32(data, offset) { + return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff; + } + function spliceString(s, offset, remove, insert) { + var chunk1 = s.substr(0, offset); + var chunk2 = s.substr(offset + remove); + return chunk1 + insert + chunk2; + } + var i, ii; + var canvas = document.createElement('canvas'); + canvas.width = 1; + canvas.height = 1; + var ctx = canvas.getContext('2d'); + var called = 0; + function isFontReady(name, callback) { + called++; + if (called > 30) { + warn('Load test font never loaded.'); + callback(); + return; + } + ctx.font = '30px ' + name; + ctx.fillText('.', 0, 20); + var imageData = ctx.getImageData(0, 0, 1, 1); + if (imageData.data[3] > 0) { + callback(); + return; + } + setTimeout(isFontReady.bind(null, name, callback)); + } + var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++; + var data = this.loadTestFont; + var COMMENT_OFFSET = 976; + data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId); + var CFF_CHECKSUM_OFFSET = 16; + var XXXX_VALUE = 0x58585858; + var checksum = int32(data, CFF_CHECKSUM_OFFSET); + for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) { + checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0; + } + if (i < loadTestFontId.length) { + checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0; + } + data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum)); + var url = 'url(data:font/opentype;base64,' + btoa(data) + ');'; + var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}'; + this.insertRule(rule); + var names = []; + for (i = 0, ii = fonts.length; i < ii; i++) { + names.push(fonts[i].loadedName); + } + names.push(loadTestFontId); + var div = document.createElement('div'); + div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;'); + for (i = 0, ii = names.length; i < ii; ++i) { + var span = document.createElement('span'); + span.textContent = 'Hi'; + span.style.fontFamily = names[i]; + div.appendChild(span); + } + document.body.appendChild(div); + isFontReady(loadTestFontId, function () { + document.body.removeChild(div); + request.complete(); + }); +}; +FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts; +var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() { + if (typeof navigator === 'undefined') { + return true; + } + var supported = false; + var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent); + if (m && m[1] >= 14) { + supported = true; + } + return supported; +}; +Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', { + get: function () { + return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported()); + }, + enumerable: true, + configurable: true +}); +var IsEvalSupportedCached = { + get value() { + return shadow(this, 'value', sharedUtil.isEvalSupported()); + } +}; +var FontFaceObject = function FontFaceObjectClosure() { + function FontFaceObject(translatedData, options) { + this.compiledGlyphs = Object.create(null); + for (var i in translatedData) { + this[i] = translatedData[i]; + } + this.options = options; + } + FontFaceObject.prototype = { + createNativeFontFace: function FontFaceObject_createNativeFontFace() { + if (!this.data) { + return null; + } + if (this.options.disableFontFace) { + this.disableFontFace = true; + return null; + } + var nativeFontFace = new FontFace(this.loadedName, this.data, {}); + if (this.options.fontRegistry) { + this.options.fontRegistry.registerFont(this); + } + return nativeFontFace; + }, + createFontFaceRule: function FontFaceObject_createFontFaceRule() { + if (!this.data) { + return null; + } + if (this.options.disableFontFace) { + this.disableFontFace = true; + return null; + } + var data = bytesToString(new Uint8Array(this.data)); + var fontName = this.loadedName; + var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');'; + var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}'; + if (this.options.fontRegistry) { + this.options.fontRegistry.registerFont(this, url); + } + return rule; + }, + getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) { + if (!(character in this.compiledGlyphs)) { + var cmds = objs.get(this.loadedName + '_path_' + character); + var current, i, len; + if (this.options.isEvalSupported && IsEvalSupportedCached.value) { + var args, + js = ''; + for (i = 0, len = cmds.length; i < len; i++) { + current = cmds[i]; + if (current.args !== undefined) { + args = current.args.join(','); + } else { + args = ''; + } + js += 'c.' + current.cmd + '(' + args + ');\n'; + } + this.compiledGlyphs[character] = new Function('c', 'size', js); + } else { + this.compiledGlyphs[character] = function (c, size) { + for (i = 0, len = cmds.length; i < len; i++) { + current = cmds[i]; + if (current.cmd === 'scale') { + current.args = [size, -size]; + } + c[current.cmd].apply(c, current.args); + } + }; + } + } + return this.compiledGlyphs[character]; + } + }; + return FontFaceObject; +}(); +exports.FontFaceObject = FontFaceObject; +exports.FontLoader = FontLoader; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var sharedUtil = __w_pdfjs_require__(0); +var displayWebGL = __w_pdfjs_require__(8); +var Util = sharedUtil.Util; +var info = sharedUtil.info; +var isArray = sharedUtil.isArray; +var error = sharedUtil.error; +var WebGLUtils = displayWebGL.WebGLUtils; +var ShadingIRs = {}; +ShadingIRs.RadialAxial = { + fromIR: function RadialAxial_fromIR(raw) { + var type = raw[1]; + var colorStops = raw[2]; + var p0 = raw[3]; + var p1 = raw[4]; + var r0 = raw[5]; + var r1 = raw[6]; + return { + type: 'Pattern', + getPattern: function RadialAxial_getPattern(ctx) { + var grad; + if (type === 'axial') { + grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]); + } else if (type === 'radial') { + grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1); + } + for (var i = 0, ii = colorStops.length; i < ii; ++i) { + var c = colorStops[i]; + grad.addColorStop(c[0], c[1]); + } + return grad; + } + }; + } +}; +var createMeshCanvas = function createMeshCanvasClosure() { + function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) { + var coords = context.coords, + colors = context.colors; + var bytes = data.data, + rowSize = data.width * 4; + var tmp; + if (coords[p1 + 1] > coords[p2 + 1]) { + tmp = p1; + p1 = p2; + p2 = tmp; + tmp = c1; + c1 = c2; + c2 = tmp; + } + if (coords[p2 + 1] > coords[p3 + 1]) { + tmp = p2; + p2 = p3; + p3 = tmp; + tmp = c2; + c2 = c3; + c3 = tmp; + } + if (coords[p1 + 1] > coords[p2 + 1]) { + tmp = p1; + p1 = p2; + p2 = tmp; + tmp = c1; + c1 = c2; + c2 = tmp; + } + var x1 = (coords[p1] + context.offsetX) * context.scaleX; + var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY; + var x2 = (coords[p2] + context.offsetX) * context.scaleX; + var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY; + var x3 = (coords[p3] + context.offsetX) * context.scaleX; + var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY; + if (y1 >= y3) { + return; + } + var c1r = colors[c1], + c1g = colors[c1 + 1], + c1b = colors[c1 + 2]; + var c2r = colors[c2], + c2g = colors[c2 + 1], + c2b = colors[c2 + 2]; + var c3r = colors[c3], + c3g = colors[c3 + 1], + c3b = colors[c3 + 2]; + var minY = Math.round(y1), + maxY = Math.round(y3); + var xa, car, cag, cab; + var xb, cbr, cbg, cbb; + var k; + for (var y = minY; y <= maxY; y++) { + if (y < y2) { + k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2); + xa = x1 - (x1 - x2) * k; + car = c1r - (c1r - c2r) * k; + cag = c1g - (c1g - c2g) * k; + cab = c1b - (c1b - c2b) * k; + } else { + k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3); + xa = x2 - (x2 - x3) * k; + car = c2r - (c2r - c3r) * k; + cag = c2g - (c2g - c3g) * k; + cab = c2b - (c2b - c3b) * k; + } + k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3); + xb = x1 - (x1 - x3) * k; + cbr = c1r - (c1r - c3r) * k; + cbg = c1g - (c1g - c3g) * k; + cbb = c1b - (c1b - c3b) * k; + var x1_ = Math.round(Math.min(xa, xb)); + var x2_ = Math.round(Math.max(xa, xb)); + var j = rowSize * y + x1_ * 4; + for (var x = x1_; x <= x2_; x++) { + k = (xa - x) / (xa - xb); + k = k < 0 ? 0 : k > 1 ? 1 : k; + bytes[j++] = car - (car - cbr) * k | 0; + bytes[j++] = cag - (cag - cbg) * k | 0; + bytes[j++] = cab - (cab - cbb) * k | 0; + bytes[j++] = 255; + } + } + } + function drawFigure(data, figure, context) { + var ps = figure.coords; + var cs = figure.colors; + var i, ii; + switch (figure.type) { + case 'lattice': + var verticesPerRow = figure.verticesPerRow; + var rows = Math.floor(ps.length / verticesPerRow) - 1; + var cols = verticesPerRow - 1; + for (i = 0; i < rows; i++) { + var q = i * verticesPerRow; + for (var j = 0; j < cols; j++, q++) { + drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]); + drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]); + } + } + break; + case 'triangles': + for (i = 0, ii = ps.length; i < ii; i += 3) { + drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]); + } + break; + default: + error('illigal figure'); + break; + } + } + function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) { + var EXPECTED_SCALE = 1.1; + var MAX_PATTERN_SIZE = 3000; + var BORDER_SIZE = 2; + var offsetX = Math.floor(bounds[0]); + var offsetY = Math.floor(bounds[1]); + var boundsWidth = Math.ceil(bounds[2]) - offsetX; + var boundsHeight = Math.ceil(bounds[3]) - offsetY; + var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE); + var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE); + var scaleX = boundsWidth / width; + var scaleY = boundsHeight / height; + var context = { + coords: coords, + colors: colors, + offsetX: -offsetX, + offsetY: -offsetY, + scaleX: 1 / scaleX, + scaleY: 1 / scaleY + }; + var paddedWidth = width + BORDER_SIZE * 2; + var paddedHeight = height + BORDER_SIZE * 2; + var canvas, tmpCanvas, i, ii; + if (WebGLUtils.isEnabled) { + canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context); + tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false); + tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE); + canvas = tmpCanvas.canvas; + } else { + tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false); + var tmpCtx = tmpCanvas.context; + var data = tmpCtx.createImageData(width, height); + if (backgroundColor) { + var bytes = data.data; + for (i = 0, ii = bytes.length; i < ii; i += 4) { + bytes[i] = backgroundColor[0]; + bytes[i + 1] = backgroundColor[1]; + bytes[i + 2] = backgroundColor[2]; + bytes[i + 3] = 255; + } + } + for (i = 0; i < figures.length; i++) { + drawFigure(data, figures[i], context); + } + tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE); + canvas = tmpCanvas.canvas; + } + return { + canvas: canvas, + offsetX: offsetX - BORDER_SIZE * scaleX, + offsetY: offsetY - BORDER_SIZE * scaleY, + scaleX: scaleX, + scaleY: scaleY + }; + } + return createMeshCanvas; +}(); +ShadingIRs.Mesh = { + fromIR: function Mesh_fromIR(raw) { + var coords = raw[2]; + var colors = raw[3]; + var figures = raw[4]; + var bounds = raw[5]; + var matrix = raw[6]; + var background = raw[8]; + return { + type: 'Pattern', + getPattern: function Mesh_getPattern(ctx, owner, shadingFill) { + var scale; + if (shadingFill) { + scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform); + } else { + scale = Util.singularValueDecompose2dScale(owner.baseTransform); + if (matrix) { + var matrixScale = Util.singularValueDecompose2dScale(matrix); + scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]]; + } + } + var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases); + if (!shadingFill) { + ctx.setTransform.apply(ctx, owner.baseTransform); + if (matrix) { + ctx.transform.apply(ctx, matrix); + } + } + ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY); + ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY); + return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat'); + } + }; + } +}; +ShadingIRs.Dummy = { + fromIR: function Dummy_fromIR() { + return { + type: 'Pattern', + getPattern: function Dummy_fromIR_getPattern() { + return 'hotpink'; + } + }; + } +}; +function getShadingPatternFromIR(raw) { + var shadingIR = ShadingIRs[raw[0]]; + if (!shadingIR) { + error('Unknown IR type: ' + raw[0]); + } + return shadingIR.fromIR(raw); +} +var TilingPattern = function TilingPatternClosure() { + var PaintType = { + COLORED: 1, + UNCOLORED: 2 + }; + var MAX_PATTERN_SIZE = 3000; + function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) { + this.operatorList = IR[2]; + this.matrix = IR[3] || [1, 0, 0, 1, 0, 0]; + this.bbox = Util.normalizeRect(IR[4]); + this.xstep = IR[5]; + this.ystep = IR[6]; + this.paintType = IR[7]; + this.tilingType = IR[8]; + this.color = color; + this.canvasGraphicsFactory = canvasGraphicsFactory; + this.baseTransform = baseTransform; + this.type = 'Pattern'; + this.ctx = ctx; + } + TilingPattern.prototype = { + createPatternCanvas: function TilinPattern_createPatternCanvas(owner) { + var operatorList = this.operatorList; + var bbox = this.bbox; + var xstep = this.xstep; + var ystep = this.ystep; + var paintType = this.paintType; + var tilingType = this.tilingType; + var color = this.color; + var canvasGraphicsFactory = this.canvasGraphicsFactory; + info('TilingType: ' + tilingType); + var x0 = bbox[0], + y0 = bbox[1], + x1 = bbox[2], + y1 = bbox[3]; + var topLeft = [x0, y0]; + var botRight = [x0 + xstep, y0 + ystep]; + var width = botRight[0] - topLeft[0]; + var height = botRight[1] - topLeft[1]; + var matrixScale = Util.singularValueDecompose2dScale(this.matrix); + var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform); + var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]]; + width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE); + height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE); + var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true); + var tmpCtx = tmpCanvas.context; + var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx); + graphics.groupLevel = owner.groupLevel; + this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color); + this.setScale(width, height, xstep, ystep); + this.transformToScale(graphics); + var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]]; + graphics.transform.apply(graphics, tmpTranslate); + this.clipBbox(graphics, bbox, x0, y0, x1, y1); + graphics.executeOperatorList(operatorList); + return tmpCanvas.canvas; + }, + setScale: function TilingPattern_setScale(width, height, xstep, ystep) { + this.scale = [width / xstep, height / ystep]; + }, + transformToScale: function TilingPattern_transformToScale(graphics) { + var scale = this.scale; + var tmpScale = [scale[0], 0, 0, scale[1], 0, 0]; + graphics.transform.apply(graphics, tmpScale); + }, + scaleToContext: function TilingPattern_scaleToContext() { + var scale = this.scale; + this.ctx.scale(1 / scale[0], 1 / scale[1]); + }, + clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) { + if (isArray(bbox) && bbox.length === 4) { + var bboxWidth = x1 - x0; + var bboxHeight = y1 - y0; + graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight); + graphics.clip(); + graphics.endPath(); + } + }, + setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) { + switch (paintType) { + case PaintType.COLORED: + var ctx = this.ctx; + context.fillStyle = ctx.fillStyle; + context.strokeStyle = ctx.strokeStyle; + break; + case PaintType.UNCOLORED: + var cssColor = Util.makeCssRgb(color[0], color[1], color[2]); + context.fillStyle = cssColor; + context.strokeStyle = cssColor; + break; + default: + error('Unsupported paint type: ' + paintType); + } + }, + getPattern: function TilingPattern_getPattern(ctx, owner) { + var temporaryPatternCanvas = this.createPatternCanvas(owner); + ctx = this.ctx; + ctx.setTransform.apply(ctx, this.baseTransform); + ctx.transform.apply(ctx, this.matrix); + this.scaleToContext(); + return ctx.createPattern(temporaryPatternCanvas, 'repeat'); + } + }; + return TilingPattern; +}(); +exports.getShadingPatternFromIR = getShadingPatternFromIR; +exports.TilingPattern = TilingPattern; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; + + +var pdfjsVersion = '1.8.172'; +var pdfjsBuild = '8ff1fbe7'; +var pdfjsSharedUtil = __w_pdfjs_require__(0); +var pdfjsDisplayGlobal = __w_pdfjs_require__(9); +var pdfjsDisplayAPI = __w_pdfjs_require__(3); +var pdfjsDisplayTextLayer = __w_pdfjs_require__(5); +var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(2); +var pdfjsDisplayDOMUtils = __w_pdfjs_require__(1); +var pdfjsDisplaySVG = __w_pdfjs_require__(4); +exports.PDFJS = pdfjsDisplayGlobal.PDFJS; +exports.build = pdfjsDisplayAPI.build; +exports.version = pdfjsDisplayAPI.version; +exports.getDocument = pdfjsDisplayAPI.getDocument; +exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport; +exports.PDFWorker = pdfjsDisplayAPI.PDFWorker; +exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer; +exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer; +exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle; +exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability; +exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses; +exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException; +exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException; +exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics; +exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException; +exports.OPS = pdfjsSharedUtil.OPS; +exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES; +exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl; +exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl; +exports.createObjectURL = pdfjsSharedUtil.createObjectURL; +exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters; +exports.shadow = pdfjsSharedUtil.shadow; +exports.createBlob = pdfjsSharedUtil.createBlob; +exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException; +exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl; +exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __w_pdfjs_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) { + +if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) { + var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined; + var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || ''; + var isAndroid = /Android/.test(userAgent); + var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent); + var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent); + var isChrome = userAgent.indexOf('Chrom') >= 0; + var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent); + var isIOSChrome = userAgent.indexOf('CriOS') >= 0; + var isIE = userAgent.indexOf('Trident') >= 0; + var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent); + var isOpera = userAgent.indexOf('Opera') >= 0; + var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent); + var hasDOM = typeof window === 'object' && typeof document === 'object'; + if (typeof PDFJS === 'undefined') { + globalScope.PDFJS = {}; + } + PDFJS.compatibilityChecked = true; + (function checkTypedArrayCompatibility() { + if (typeof Uint8Array !== 'undefined') { + if (typeof Uint8Array.prototype.subarray === 'undefined') { + Uint8Array.prototype.subarray = function subarray(start, end) { + return new Uint8Array(this.slice(start, end)); + }; + Float32Array.prototype.subarray = function subarray(start, end) { + return new Float32Array(this.slice(start, end)); + }; + } + if (typeof Float64Array === 'undefined') { + globalScope.Float64Array = Float32Array; + } + return; + } + function subarray(start, end) { + return new TypedArray(this.slice(start, end)); + } + function setArrayOffset(array, offset) { + if (arguments.length < 2) { + offset = 0; + } + for (var i = 0, n = array.length; i < n; ++i, ++offset) { + this[offset] = array[i] & 0xFF; + } + } + function TypedArray(arg1) { + var result, i, n; + if (typeof arg1 === 'number') { + result = []; + for (i = 0; i < arg1; ++i) { + result[i] = 0; + } + } else if ('slice' in arg1) { + result = arg1.slice(0); + } else { + result = []; + for (i = 0, n = arg1.length; i < n; ++i) { + result[i] = arg1[i]; + } + } + result.subarray = subarray; + result.buffer = result; + result.byteLength = result.length; + result.set = setArrayOffset; + if (typeof arg1 === 'object' && arg1.buffer) { + result.buffer = arg1.buffer; + } + return result; + } + globalScope.Uint8Array = TypedArray; + globalScope.Int8Array = TypedArray; + globalScope.Uint32Array = TypedArray; + globalScope.Int32Array = TypedArray; + globalScope.Uint16Array = TypedArray; + globalScope.Float32Array = TypedArray; + globalScope.Float64Array = TypedArray; + })(); + (function normalizeURLObject() { + if (!globalScope.URL) { + globalScope.URL = globalScope.webkitURL; + } + })(); + (function checkObjectDefinePropertyCompatibility() { + if (typeof Object.defineProperty !== 'undefined') { + var definePropertyPossible = true; + try { + if (hasDOM) { + Object.defineProperty(new Image(), 'id', { value: 'test' }); + } + var Test = function Test() {}; + Test.prototype = { + get id() {} + }; + Object.defineProperty(new Test(), 'id', { + value: '', + configurable: true, + enumerable: true, + writable: false + }); + } catch (e) { + definePropertyPossible = false; + } + if (definePropertyPossible) { + return; + } + } + Object.defineProperty = function objectDefineProperty(obj, name, def) { + delete obj[name]; + if ('get' in def) { + obj.__defineGetter__(name, def['get']); + } + if ('set' in def) { + obj.__defineSetter__(name, def['set']); + } + if ('value' in def) { + obj.__defineSetter__(name, function objectDefinePropertySetter(value) { + this.__defineGetter__(name, function objectDefinePropertyGetter() { + return value; + }); + return value; + }); + obj[name] = def.value; + } + }; + })(); + (function checkXMLHttpRequestResponseCompatibility() { + if (typeof XMLHttpRequest === 'undefined') { + return; + } + var xhrPrototype = XMLHttpRequest.prototype; + var xhr = new XMLHttpRequest(); + if (!('overrideMimeType' in xhr)) { + Object.defineProperty(xhrPrototype, 'overrideMimeType', { + value: function xmlHttpRequestOverrideMimeType(mimeType) {} + }); + } + if ('responseType' in xhr) { + return; + } + Object.defineProperty(xhrPrototype, 'responseType', { + get: function xmlHttpRequestGetResponseType() { + return this._responseType || 'text'; + }, + set: function xmlHttpRequestSetResponseType(value) { + if (value === 'text' || value === 'arraybuffer') { + this._responseType = value; + if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') { + this.overrideMimeType('text/plain; charset=x-user-defined'); + } + } + } + }); + if (typeof VBArray !== 'undefined') { + Object.defineProperty(xhrPrototype, 'response', { + get: function xmlHttpRequestResponseGet() { + if (this.responseType === 'arraybuffer') { + return new Uint8Array(new VBArray(this.responseBody).toArray()); + } + return this.responseText; + } + }); + return; + } + Object.defineProperty(xhrPrototype, 'response', { + get: function xmlHttpRequestResponseGet() { + if (this.responseType !== 'arraybuffer') { + return this.responseText; + } + var text = this.responseText; + var i, + n = text.length; + var result = new Uint8Array(n); + for (i = 0; i < n; ++i) { + result[i] = text.charCodeAt(i) & 0xFF; + } + return result.buffer; + } + }); + })(); + (function checkWindowBtoaCompatibility() { + if ('btoa' in globalScope) { + return; + } + var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + globalScope.btoa = function (chars) { + var buffer = ''; + var i, n; + for (i = 0, n = chars.length; i < n; i += 3) { + var b1 = chars.charCodeAt(i) & 0xFF; + var b2 = chars.charCodeAt(i + 1) & 0xFF; + var b3 = chars.charCodeAt(i + 2) & 0xFF; + var d1 = b1 >> 2, + d2 = (b1 & 3) << 4 | b2 >> 4; + var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64; + var d4 = i + 2 < n ? b3 & 0x3F : 64; + buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4); + } + return buffer; + }; + })(); + (function checkWindowAtobCompatibility() { + if ('atob' in globalScope) { + return; + } + var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; + globalScope.atob = function (input) { + input = input.replace(/=+$/, ''); + if (input.length % 4 === 1) { + throw new Error('bad atob input'); + } + for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) { + buffer = digits.indexOf(buffer); + } + return output; + }; + })(); + (function checkFunctionPrototypeBindCompatibility() { + if (typeof Function.prototype.bind !== 'undefined') { + return; + } + Function.prototype.bind = function functionPrototypeBind(obj) { + var fn = this, + headArgs = Array.prototype.slice.call(arguments, 1); + var bound = function functionPrototypeBindBound() { + var args = headArgs.concat(Array.prototype.slice.call(arguments)); + return fn.apply(obj, args); + }; + return bound; + }; + })(); + (function checkDatasetProperty() { + if (!hasDOM) { + return; + } + var div = document.createElement('div'); + if ('dataset' in div) { + return; + } + Object.defineProperty(HTMLElement.prototype, 'dataset', { + get: function () { + if (this._dataset) { + return this._dataset; + } + var dataset = {}; + for (var j = 0, jj = this.attributes.length; j < jj; j++) { + var attribute = this.attributes[j]; + if (attribute.name.substring(0, 5) !== 'data-') { + continue; + } + var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) { + return ch.toUpperCase(); + }); + dataset[key] = attribute.value; + } + Object.defineProperty(this, '_dataset', { + value: dataset, + writable: false, + enumerable: false + }); + return dataset; + }, + enumerable: true + }); + })(); + (function checkClassListProperty() { + function changeList(element, itemName, add, remove) { + var s = element.className || ''; + var list = s.split(/\s+/g); + if (list[0] === '') { + list.shift(); + } + var index = list.indexOf(itemName); + if (index < 0 && add) { + list.push(itemName); + } + if (index >= 0 && remove) { + list.splice(index, 1); + } + element.className = list.join(' '); + return index >= 0; + } + if (!hasDOM) { + return; + } + var div = document.createElement('div'); + if ('classList' in div) { + return; + } + var classListPrototype = { + add: function (name) { + changeList(this.element, name, true, false); + }, + contains: function (name) { + return changeList(this.element, name, false, false); + }, + remove: function (name) { + changeList(this.element, name, false, true); + }, + toggle: function (name) { + changeList(this.element, name, true, true); + } + }; + Object.defineProperty(HTMLElement.prototype, 'classList', { + get: function () { + if (this._classList) { + return this._classList; + } + var classList = Object.create(classListPrototype, { + element: { + value: this, + writable: false, + enumerable: true + } + }); + Object.defineProperty(this, '_classList', { + value: classList, + writable: false, + enumerable: false + }); + return classList; + }, + enumerable: true + }); + })(); + (function checkWorkerConsoleCompatibility() { + if (typeof importScripts === 'undefined' || 'console' in globalScope) { + return; + } + var consoleTimer = {}; + var workerConsole = { + log: function log() { + var args = Array.prototype.slice.call(arguments); + globalScope.postMessage({ + targetName: 'main', + action: 'console_log', + data: args + }); + }, + error: function error() { + var args = Array.prototype.slice.call(arguments); + globalScope.postMessage({ + targetName: 'main', + action: 'console_error', + data: args + }); + }, + time: function time(name) { + consoleTimer[name] = Date.now(); + }, + timeEnd: function timeEnd(name) { + var time = consoleTimer[name]; + if (!time) { + throw new Error('Unknown timer name ' + name); + } + this.log('Timer:', name, Date.now() - time); + } + }; + globalScope.console = workerConsole; + })(); + (function checkConsoleCompatibility() { + if (!hasDOM) { + return; + } + if (!('console' in window)) { + window.console = { + log: function () {}, + error: function () {}, + warn: function () {} + }; + return; + } + if (!('bind' in console.log)) { + console.log = function (fn) { + return function (msg) { + return fn(msg); + }; + }(console.log); + console.error = function (fn) { + return function (msg) { + return fn(msg); + }; + }(console.error); + console.warn = function (fn) { + return function (msg) { + return fn(msg); + }; + }(console.warn); + return; + } + })(); + (function checkOnClickCompatibility() { + function ignoreIfTargetDisabled(event) { + if (isDisabled(event.target)) { + event.stopPropagation(); + } + } + function isDisabled(node) { + return node.disabled || node.parentNode && isDisabled(node.parentNode); + } + if (isOpera) { + document.addEventListener('click', ignoreIfTargetDisabled, true); + } + })(); + (function checkOnBlobSupport() { + if (isIE || isIOSChrome) { + PDFJS.disableCreateObjectURL = true; + } + })(); + (function checkNavigatorLanguage() { + if (typeof navigator === 'undefined') { + return; + } + if ('language' in navigator) { + return; + } + PDFJS.locale = navigator.userLanguage || 'en-US'; + })(); + (function checkRangeRequests() { + if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) { + PDFJS.disableRange = true; + PDFJS.disableStream = true; + } + })(); + (function checkHistoryManipulation() { + if (!hasDOM) { + return; + } + if (!history.pushState || isAndroidPre3) { + PDFJS.disableHistory = true; + } + })(); + (function checkSetPresenceInImageData() { + if (!hasDOM) { + return; + } + if (window.CanvasPixelArray) { + if (typeof window.CanvasPixelArray.prototype.set !== 'function') { + window.CanvasPixelArray.prototype.set = function (arr) { + for (var i = 0, ii = this.length; i < ii; i++) { + this[i] = arr[i]; + } + }; + } + } else { + var polyfill = false, + versionMatch; + if (isChrome) { + versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); + polyfill = versionMatch && parseInt(versionMatch[2]) < 21; + } else if (isAndroid) { + polyfill = isAndroidPre5; + } else if (isSafari) { + versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//); + polyfill = versionMatch && parseInt(versionMatch[1]) < 6; + } + if (polyfill) { + var contextPrototype = window.CanvasRenderingContext2D.prototype; + var createImageData = contextPrototype.createImageData; + contextPrototype.createImageData = function (w, h) { + var imageData = createImageData.call(this, w, h); + imageData.data.set = function (arr) { + for (var i = 0, ii = this.length; i < ii; i++) { + this[i] = arr[i]; + } + }; + return imageData; + }; + contextPrototype = null; + } + } + })(); + (function checkRequestAnimationFrame() { + function installFakeAnimationFrameFunctions() { + window.requestAnimationFrame = function (callback) { + return window.setTimeout(callback, 20); + }; + window.cancelAnimationFrame = function (timeoutID) { + window.clearTimeout(timeoutID); + }; + } + if (!hasDOM) { + return; + } + if (isIOS) { + installFakeAnimationFrameFunctions(); + return; + } + if ('requestAnimationFrame' in window) { + return; + } + window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame; + if (!('requestAnimationFrame' in window)) { + installFakeAnimationFrameFunctions(); + } + })(); + (function checkCanvasSizeLimitation() { + if (isIOS || isAndroid) { + PDFJS.maxCanvasPixels = 5242880; + } + })(); + (function checkFullscreenSupport() { + if (!hasDOM) { + return; + } + if (isIE && window.parent !== window) { + PDFJS.disableFullscreen = true; + } + })(); + (function checkCurrentScript() { + if (!hasDOM) { + return; + } + if ('currentScript' in document) { + return; + } + Object.defineProperty(document, 'currentScript', { + get: function () { + var scripts = document.getElementsByTagName('script'); + return scripts[scripts.length - 1]; + }, + enumerable: true, + configurable: true + }); + })(); + (function checkInputTypeNumberAssign() { + if (!hasDOM) { + return; + } + var el = document.createElement('input'); + try { + el.type = 'number'; + } catch (ex) { + var inputProto = el.constructor.prototype; + var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type'); + Object.defineProperty(inputProto, 'type', { + get: function () { + return typeProperty.get.call(this); + }, + set: function (value) { + typeProperty.set.call(this, value === 'number' ? 'text' : value); + }, + enumerable: true, + configurable: true + }); + } + })(); + (function checkDocumentReadyState() { + if (!hasDOM) { + return; + } + if (!document.attachEvent) { + return; + } + var documentProto = document.constructor.prototype; + var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState'); + Object.defineProperty(documentProto, 'readyState', { + get: function () { + var value = readyStateProto.get.call(this); + return value === 'interactive' ? 'loading' : value; + }, + set: function (value) { + readyStateProto.set.call(this, value); + }, + enumerable: true, + configurable: true + }); + })(); + (function checkChildNodeRemove() { + if (!hasDOM) { + return; + } + if (typeof Element.prototype.remove !== 'undefined') { + return; + } + Element.prototype.remove = function () { + if (this.parentNode) { + this.parentNode.removeChild(this); + } + }; + })(); + (function checkPromise() { + if (globalScope.Promise) { + if (typeof globalScope.Promise.all !== 'function') { + globalScope.Promise.all = function (iterable) { + var count = 0, + results = [], + resolve, + reject; + var promise = new globalScope.Promise(function (resolve_, reject_) { + resolve = resolve_; + reject = reject_; + }); + iterable.forEach(function (p, i) { + count++; + p.then(function (result) { + results[i] = result; + count--; + if (count === 0) { + resolve(results); + } + }, reject); + }); + if (count === 0) { + resolve(results); + } + return promise; + }; + } + if (typeof globalScope.Promise.resolve !== 'function') { + globalScope.Promise.resolve = function (value) { + return new globalScope.Promise(function (resolve) { + resolve(value); + }); + }; + } + if (typeof globalScope.Promise.reject !== 'function') { + globalScope.Promise.reject = function (reason) { + return new globalScope.Promise(function (resolve, reject) { + reject(reason); + }); + }; + } + if (typeof globalScope.Promise.prototype.catch !== 'function') { + globalScope.Promise.prototype.catch = function (onReject) { + return globalScope.Promise.prototype.then(undefined, onReject); + }; + } + return; + } + var STATUS_PENDING = 0; + var STATUS_RESOLVED = 1; + var STATUS_REJECTED = 2; + var REJECTION_TIMEOUT = 500; + var HandlerManager = { + handlers: [], + running: false, + unhandledRejections: [], + pendingRejectionCheck: false, + scheduleHandlers: function scheduleHandlers(promise) { + if (promise._status === STATUS_PENDING) { + return; + } + this.handlers = this.handlers.concat(promise._handlers); + promise._handlers = []; + if (this.running) { + return; + } + this.running = true; + setTimeout(this.runHandlers.bind(this), 0); + }, + runHandlers: function runHandlers() { + var RUN_TIMEOUT = 1; + var timeoutAt = Date.now() + RUN_TIMEOUT; + while (this.handlers.length > 0) { + var handler = this.handlers.shift(); + var nextStatus = handler.thisPromise._status; + var nextValue = handler.thisPromise._value; + try { + if (nextStatus === STATUS_RESOLVED) { + if (typeof handler.onResolve === 'function') { + nextValue = handler.onResolve(nextValue); + } + } else if (typeof handler.onReject === 'function') { + nextValue = handler.onReject(nextValue); + nextStatus = STATUS_RESOLVED; + if (handler.thisPromise._unhandledRejection) { + this.removeUnhandeledRejection(handler.thisPromise); + } + } + } catch (ex) { + nextStatus = STATUS_REJECTED; + nextValue = ex; + } + handler.nextPromise._updateStatus(nextStatus, nextValue); + if (Date.now() >= timeoutAt) { + break; + } + } + if (this.handlers.length > 0) { + setTimeout(this.runHandlers.bind(this), 0); + return; + } + this.running = false; + }, + addUnhandledRejection: function addUnhandledRejection(promise) { + this.unhandledRejections.push({ + promise: promise, + time: Date.now() + }); + this.scheduleRejectionCheck(); + }, + removeUnhandeledRejection: function removeUnhandeledRejection(promise) { + promise._unhandledRejection = false; + for (var i = 0; i < this.unhandledRejections.length; i++) { + if (this.unhandledRejections[i].promise === promise) { + this.unhandledRejections.splice(i); + i--; + } + } + }, + scheduleRejectionCheck: function scheduleRejectionCheck() { + if (this.pendingRejectionCheck) { + return; + } + this.pendingRejectionCheck = true; + setTimeout(function rejectionCheck() { + this.pendingRejectionCheck = false; + var now = Date.now(); + for (var i = 0; i < this.unhandledRejections.length; i++) { + if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) { + var unhandled = this.unhandledRejections[i].promise._value; + var msg = 'Unhandled rejection: ' + unhandled; + if (unhandled.stack) { + msg += '\n' + unhandled.stack; + } + try { + throw new Error(msg); + } catch (_) { + console.warn(msg); + } + this.unhandledRejections.splice(i); + i--; + } + } + if (this.unhandledRejections.length) { + this.scheduleRejectionCheck(); + } + }.bind(this), REJECTION_TIMEOUT); + } + }; + var Promise = function Promise(resolver) { + this._status = STATUS_PENDING; + this._handlers = []; + try { + resolver.call(this, this._resolve.bind(this), this._reject.bind(this)); + } catch (e) { + this._reject(e); + } + }; + Promise.all = function Promise_all(promises) { + var resolveAll, rejectAll; + var deferred = new Promise(function (resolve, reject) { + resolveAll = resolve; + rejectAll = reject; + }); + var unresolved = promises.length; + var results = []; + if (unresolved === 0) { + resolveAll(results); + return deferred; + } + function reject(reason) { + if (deferred._status === STATUS_REJECTED) { + return; + } + results = []; + rejectAll(reason); + } + for (var i = 0, ii = promises.length; i < ii; ++i) { + var promise = promises[i]; + var resolve = function (i) { + return function (value) { + if (deferred._status === STATUS_REJECTED) { + return; + } + results[i] = value; + unresolved--; + if (unresolved === 0) { + resolveAll(results); + } + }; + }(i); + if (Promise.isPromise(promise)) { + promise.then(resolve, reject); + } else { + resolve(promise); + } + } + return deferred; + }; + Promise.isPromise = function Promise_isPromise(value) { + return value && typeof value.then === 'function'; + }; + Promise.resolve = function Promise_resolve(value) { + return new Promise(function (resolve) { + resolve(value); + }); + }; + Promise.reject = function Promise_reject(reason) { + return new Promise(function (resolve, reject) { + reject(reason); + }); + }; + Promise.prototype = { + _status: null, + _value: null, + _handlers: null, + _unhandledRejection: null, + _updateStatus: function Promise__updateStatus(status, value) { + if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) { + return; + } + if (status === STATUS_RESOLVED && Promise.isPromise(value)) { + value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED)); + return; + } + this._status = status; + this._value = value; + if (status === STATUS_REJECTED && this._handlers.length === 0) { + this._unhandledRejection = true; + HandlerManager.addUnhandledRejection(this); + } + HandlerManager.scheduleHandlers(this); + }, + _resolve: function Promise_resolve(value) { + this._updateStatus(STATUS_RESOLVED, value); + }, + _reject: function Promise_reject(reason) { + this._updateStatus(STATUS_REJECTED, reason); + }, + then: function Promise_then(onResolve, onReject) { + var nextPromise = new Promise(function (resolve, reject) { + this.resolve = resolve; + this.reject = reject; + }); + this._handlers.push({ + thisPromise: this, + onResolve: onResolve, + onReject: onReject, + nextPromise: nextPromise + }); + HandlerManager.scheduleHandlers(this); + return nextPromise; + }, + catch: function Promise_catch(onReject) { + return this.then(undefined, onReject); + } + }; + globalScope.Promise = Promise; + })(); + (function checkWeakMap() { + if (globalScope.WeakMap) { + return; + } + var id = 0; + function WeakMap() { + this.id = '$weakmap' + id++; + } + WeakMap.prototype = { + has: function (obj) { + return !!Object.getOwnPropertyDescriptor(obj, this.id); + }, + get: function (obj, defaultValue) { + return this.has(obj) ? obj[this.id] : defaultValue; + }, + set: function (obj, value) { + Object.defineProperty(obj, this.id, { + value: value, + enumerable: false, + configurable: true + }); + }, + delete: function (obj) { + delete obj[this.id]; + } + }; + globalScope.WeakMap = WeakMap; + })(); + (function checkURLConstructor() { + var hasWorkingUrl = false; + try { + if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) { + var u = new URL('b', 'http://a'); + u.pathname = 'c%20d'; + hasWorkingUrl = u.href === 'http://a/c%20d'; + } + } catch (e) {} + if (hasWorkingUrl) { + return; + } + var relative = Object.create(null); + relative['ftp'] = 21; + relative['file'] = 0; + relative['gopher'] = 70; + relative['http'] = 80; + relative['https'] = 443; + relative['ws'] = 80; + relative['wss'] = 443; + var relativePathDotMapping = Object.create(null); + relativePathDotMapping['%2e'] = '.'; + relativePathDotMapping['.%2e'] = '..'; + relativePathDotMapping['%2e.'] = '..'; + relativePathDotMapping['%2e%2e'] = '..'; + function isRelativeScheme(scheme) { + return relative[scheme] !== undefined; + } + function invalid() { + clear.call(this); + this._isInvalid = true; + } + function IDNAToASCII(h) { + if (h === '') { + invalid.call(this); + } + return h.toLowerCase(); + } + function percentEscape(c) { + var unicode = c.charCodeAt(0); + if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) { + return c; + } + return encodeURIComponent(c); + } + function percentEscapeQuery(c) { + var unicode = c.charCodeAt(0); + if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) { + return c; + } + return encodeURIComponent(c); + } + var EOF, + ALPHA = /[a-zA-Z]/, + ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; + function parse(input, stateOverride, base) { + function err(message) { + errors.push(message); + } + var state = stateOverride || 'scheme start', + cursor = 0, + buffer = '', + seenAt = false, + seenBracket = false, + errors = []; + loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) { + var c = input[cursor]; + switch (state) { + case 'scheme start': + if (c && ALPHA.test(c)) { + buffer += c.toLowerCase(); + state = 'scheme'; + } else if (!stateOverride) { + buffer = ''; + state = 'no scheme'; + continue; + } else { + err('Invalid scheme.'); + break loop; + } + break; + case 'scheme': + if (c && ALPHANUMERIC.test(c)) { + buffer += c.toLowerCase(); + } else if (c === ':') { + this._scheme = buffer; + buffer = ''; + if (stateOverride) { + break loop; + } + if (isRelativeScheme(this._scheme)) { + this._isRelative = true; + } + if (this._scheme === 'file') { + state = 'relative'; + } else if (this._isRelative && base && base._scheme === this._scheme) { + state = 'relative or authority'; + } else if (this._isRelative) { + state = 'authority first slash'; + } else { + state = 'scheme data'; + } + } else if (!stateOverride) { + buffer = ''; + cursor = 0; + state = 'no scheme'; + continue; + } else if (c === EOF) { + break loop; + } else { + err('Code point not allowed in scheme: ' + c); + break loop; + } + break; + case 'scheme data': + if (c === '?') { + this._query = '?'; + state = 'query'; + } else if (c === '#') { + this._fragment = '#'; + state = 'fragment'; + } else { + if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { + this._schemeData += percentEscape(c); + } + } + break; + case 'no scheme': + if (!base || !isRelativeScheme(base._scheme)) { + err('Missing scheme.'); + invalid.call(this); + } else { + state = 'relative'; + continue; + } + break; + case 'relative or authority': + if (c === '/' && input[cursor + 1] === '/') { + state = 'authority ignore slashes'; + } else { + err('Expected /, got: ' + c); + state = 'relative'; + continue; + } + break; + case 'relative': + this._isRelative = true; + if (this._scheme !== 'file') { + this._scheme = base._scheme; + } + if (c === EOF) { + this._host = base._host; + this._port = base._port; + this._path = base._path.slice(); + this._query = base._query; + this._username = base._username; + this._password = base._password; + break loop; + } else if (c === '/' || c === '\\') { + if (c === '\\') { + err('\\ is an invalid code point.'); + } + state = 'relative slash'; + } else if (c === '?') { + this._host = base._host; + this._port = base._port; + this._path = base._path.slice(); + this._query = '?'; + this._username = base._username; + this._password = base._password; + state = 'query'; + } else if (c === '#') { + this._host = base._host; + this._port = base._port; + this._path = base._path.slice(); + this._query = base._query; + this._fragment = '#'; + this._username = base._username; + this._password = base._password; + state = 'fragment'; + } else { + var nextC = input[cursor + 1]; + var nextNextC = input[cursor + 2]; + if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') { + this._host = base._host; + this._port = base._port; + this._username = base._username; + this._password = base._password; + this._path = base._path.slice(); + this._path.pop(); + } + state = 'relative path'; + continue; + } + break; + case 'relative slash': + if (c === '/' || c === '\\') { + if (c === '\\') { + err('\\ is an invalid code point.'); + } + if (this._scheme === 'file') { + state = 'file host'; + } else { + state = 'authority ignore slashes'; + } + } else { + if (this._scheme !== 'file') { + this._host = base._host; + this._port = base._port; + this._username = base._username; + this._password = base._password; + } + state = 'relative path'; + continue; + } + break; + case 'authority first slash': + if (c === '/') { + state = 'authority second slash'; + } else { + err('Expected \'/\', got: ' + c); + state = 'authority ignore slashes'; + continue; + } + break; + case 'authority second slash': + state = 'authority ignore slashes'; + if (c !== '/') { + err('Expected \'/\', got: ' + c); + continue; + } + break; + case 'authority ignore slashes': + if (c !== '/' && c !== '\\') { + state = 'authority'; + continue; + } else { + err('Expected authority, got: ' + c); + } + break; + case 'authority': + if (c === '@') { + if (seenAt) { + err('@ already seen.'); + buffer += '%40'; + } + seenAt = true; + for (var i = 0; i < buffer.length; i++) { + var cp = buffer[i]; + if (cp === '\t' || cp === '\n' || cp === '\r') { + err('Invalid whitespace in authority.'); + continue; + } + if (cp === ':' && this._password === null) { + this._password = ''; + continue; + } + var tempC = percentEscape(cp); + if (this._password !== null) { + this._password += tempC; + } else { + this._username += tempC; + } + } + buffer = ''; + } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { + cursor -= buffer.length; + buffer = ''; + state = 'host'; + continue; + } else { + buffer += c; + } + break; + case 'file host': + if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { + if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) { + state = 'relative path'; + } else if (buffer.length === 0) { + state = 'relative path start'; + } else { + this._host = IDNAToASCII.call(this, buffer); + buffer = ''; + state = 'relative path start'; + } + continue; + } else if (c === '\t' || c === '\n' || c === '\r') { + err('Invalid whitespace in file host.'); + } else { + buffer += c; + } + break; + case 'host': + case 'hostname': + if (c === ':' && !seenBracket) { + this._host = IDNAToASCII.call(this, buffer); + buffer = ''; + state = 'port'; + if (stateOverride === 'hostname') { + break loop; + } + } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { + this._host = IDNAToASCII.call(this, buffer); + buffer = ''; + state = 'relative path start'; + if (stateOverride) { + break loop; + } + continue; + } else if (c !== '\t' && c !== '\n' && c !== '\r') { + if (c === '[') { + seenBracket = true; + } else if (c === ']') { + seenBracket = false; + } + buffer += c; + } else { + err('Invalid code point in host/hostname: ' + c); + } + break; + case 'port': + if (/[0-9]/.test(c)) { + buffer += c; + } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) { + if (buffer !== '') { + var temp = parseInt(buffer, 10); + if (temp !== relative[this._scheme]) { + this._port = temp + ''; + } + buffer = ''; + } + if (stateOverride) { + break loop; + } + state = 'relative path start'; + continue; + } else if (c === '\t' || c === '\n' || c === '\r') { + err('Invalid code point in port: ' + c); + } else { + invalid.call(this); + } + break; + case 'relative path start': + if (c === '\\') { + err('\'\\\' not allowed in path.'); + } + state = 'relative path'; + if (c !== '/' && c !== '\\') { + continue; + } + break; + case 'relative path': + if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) { + if (c === '\\') { + err('\\ not allowed in relative path.'); + } + var tmp; + if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { + buffer = tmp; + } + if (buffer === '..') { + this._path.pop(); + if (c !== '/' && c !== '\\') { + this._path.push(''); + } + } else if (buffer === '.' && c !== '/' && c !== '\\') { + this._path.push(''); + } else if (buffer !== '.') { + if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') { + buffer = buffer[0] + ':'; + } + this._path.push(buffer); + } + buffer = ''; + if (c === '?') { + this._query = '?'; + state = 'query'; + } else if (c === '#') { + this._fragment = '#'; + state = 'fragment'; + } + } else if (c !== '\t' && c !== '\n' && c !== '\r') { + buffer += percentEscape(c); + } + break; + case 'query': + if (!stateOverride && c === '#') { + this._fragment = '#'; + state = 'fragment'; + } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { + this._query += percentEscapeQuery(c); + } + break; + case 'fragment': + if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { + this._fragment += c; + } + break; + } + cursor++; + } + } + function clear() { + this._scheme = ''; + this._schemeData = ''; + this._username = ''; + this._password = null; + this._host = ''; + this._port = ''; + this._path = []; + this._query = ''; + this._fragment = ''; + this._isInvalid = false; + this._isRelative = false; + } + function JURL(url, base) { + if (base !== undefined && !(base instanceof JURL)) { + base = new JURL(String(base)); + } + this._url = url; + clear.call(this); + var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); + parse.call(this, input, null, base); + } + JURL.prototype = { + toString: function () { + return this.href; + }, + get href() { + if (this._isInvalid) { + return this._url; + } + var authority = ''; + if (this._username !== '' || this._password !== null) { + authority = this._username + (this._password !== null ? ':' + this._password : '') + '@'; + } + return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment; + }, + set href(href) { + clear.call(this); + parse.call(this, href); + }, + get protocol() { + return this._scheme + ':'; + }, + set protocol(protocol) { + if (this._isInvalid) { + return; + } + parse.call(this, protocol + ':', 'scheme start'); + }, + get host() { + return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host; + }, + set host(host) { + if (this._isInvalid || !this._isRelative) { + return; + } + parse.call(this, host, 'host'); + }, + get hostname() { + return this._host; + }, + set hostname(hostname) { + if (this._isInvalid || !this._isRelative) { + return; + } + parse.call(this, hostname, 'hostname'); + }, + get port() { + return this._port; + }, + set port(port) { + if (this._isInvalid || !this._isRelative) { + return; + } + parse.call(this, port, 'port'); + }, + get pathname() { + return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData; + }, + set pathname(pathname) { + if (this._isInvalid || !this._isRelative) { + return; + } + this._path = []; + parse.call(this, pathname, 'relative path start'); + }, + get search() { + return this._isInvalid || !this._query || this._query === '?' ? '' : this._query; + }, + set search(search) { + if (this._isInvalid || !this._isRelative) { + return; + } + this._query = '?'; + if (search[0] === '?') { + search = search.slice(1); + } + parse.call(this, search, 'query'); + }, + get hash() { + return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment; + }, + set hash(hash) { + if (this._isInvalid) { + return; + } + this._fragment = '#'; + if (hash[0] === '#') { + hash = hash.slice(1); + } + parse.call(this, hash, 'fragment'); + }, + get origin() { + var host; + if (this._isInvalid || !this._scheme) { + return ''; + } + switch (this._scheme) { + case 'data': + case 'file': + case 'javascript': + case 'mailto': + return 'null'; + } + host = this.host; + if (!host) { + return ''; + } + return this._scheme + '://' + host; + } + }; + var OriginalURL = globalScope.URL; + if (OriginalURL) { + JURL.createObjectURL = function (blob) { + return OriginalURL.createObjectURL.apply(OriginalURL, arguments); + }; + JURL.revokeObjectURL = function (url) { + OriginalURL.revokeObjectURL(url); + }; + } + globalScope.URL = JURL; + })(); +} +/* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(6))) + +/***/ }) +/******/ ]); +}); \ No newline at end of file diff --git a/vendor/assets/javascripts/pdf.min.js b/vendor/assets/javascripts/pdf.min.js new file mode 100755 index 00000000000..271a471fd49 --- /dev/null +++ b/vendor/assets/javascripts/pdf.min.js @@ -0,0 +1,6 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],e):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=e():t["pdfjs-dist/build/pdf"]=t.pdfjsDistBuildPdf=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=13)}([function(t,e,n){"use strict";(function(t){function r(t){nt=t}function i(){return nt}function a(t){nt>=$.infos&&console.log("Info: "+t)}function s(t){nt>=$.warnings&&console.log("Warning: "+t)}function o(t){console.log("Deprecated API usage: "+t)}function c(t){throw nt>=$.errors&&(console.log("Error: "+t),console.log(l())),new Error(t)}function l(){try{throw new Error}catch(t){return t.stack?t.stack.split("\n").slice(2).join("\n"):""}}function h(t,e){t||c(e)}function u(t,e){try{var n=new URL(t);if(!n.origin||"null"===n.origin)return!1}catch(t){return!1}var r=new URL(e,n);return n.origin===r.origin}function d(t){if(!t)return!1;switch(t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function f(t,e){if(!t)return null;try{var n=e?new URL(t,e):new URL(t);if(d(n))return n}catch(t){}return null}function p(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}function g(t){var e;return function(){return t&&(e=Object.create(null),t(e),t=null),e}}function m(t){return"string"!=typeof t?(s("The argument for removeNullCharacters must be a string."),t):t.replace(ft,"")}function A(t){h(null!==t&&"object"==typeof t&&void 0!==t.length,"Invalid argument for bytesToString");var e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);for(var n=[],r=0;r>24&255,t>>16&255,t>>8&255,255&t)}function S(t){for(var e=1,n=0;t>e;)e<<=1,n++;return n}function w(t,e){return t[e]<<24>>24}function k(t,e){return t[e]<<8|t[e+1]}function C(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function _(){var t=new Uint8Array(2);return t[0]=1,1===new Uint16Array(t.buffer)[0]}function T(){try{return new Function(""),!0}catch(t){return!1}}function P(t){var e,n=t.length,r=[];if("þ"===t[0]&&"ÿ"===t[1])for(e=2;e>2:e,n(this.length)}function e(t){return{get:function(){var e=this.buffer,n=t<<2;return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0},set:function(e){var n=this.buffer,r=t<<2;n[r]=255&e,n[r+1]=e>>8&255,n[r+2]=e>>16&255,n[r+3]=e>>>24&255}}}function n(n){for(;rt[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e},t.intersect=function(e,n){function r(t,e){return t-e}var i=[e[0],e[2],n[0],n[2]].sort(r),a=[e[1],e[3],n[1],n[3]].sort(r),s=[];return e=t.normalizeRect(e),n=t.normalizeRect(n),(i[0]===e[0]&&i[1]===n[0]||i[0]===n[0]&&i[1]===e[0])&&(s[0]=i[1],s[2]=i[2],(a[0]===e[1]&&a[1]===n[1]||a[0]===n[1]&&a[1]===e[1])&&(s[1]=a[1],s[3]=a[2],s))},t.sign=function(t){return t<0?-1:1};var n=["","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"];return t.toRoman=function(t,e){h(F(t)&&t>0,"The number should be a positive integer.");for(var r,i=[];t>=1e3;)t-=1e3,i.push("M");r=t/100|0,t%=100,i.push(n[r]),r=t/10|0,t%=10,i.push(n[10+r]),i.push(n[20+t]);var a=i.join("");return e?a.toLowerCase():a},t.appendToArray=function(t,e){Array.prototype.push.apply(t,e)},t.prependToArray=function(t,e){Array.prototype.unshift.apply(t,e)},t.extendObj=function(t,e){for(var n in e)t[n]=e[n]},t.getInheritableProperty=function(t,e,n){for(;t&&!t.has(e);)t=t.get("Parent");return t?n?t.getArray(e):t.get(e):null},t.inherit=function(t,e,n){t.prototype=Object.create(e.prototype),t.prototype.constructor=t;for(var r in n)t.prototype[r]=n[r]},t.loadScript=function(t,e){var n=document.createElement("script"),r=!1;n.setAttribute("src",t),e&&(n.onload=function(){r||e(),r=!0}),document.getElementsByTagName("head")[0].appendChild(n)},t}(),At=function(){function t(t,e,n,r,i,a){this.viewBox=t,this.scale=e,this.rotation=n,this.offsetX=r,this.offsetY=i;var s,o,c,l,h=(t[2]+t[0])/2,u=(t[3]+t[1])/2;switch(n%=360,n=n<0?n+360:n){case 180:s=-1,o=0,c=0,l=1;break;case 90:s=0,o=1,c=1,l=0;break;case 270:s=0,o=-1,c=-1,l=0;break;default:s=1,o=0,c=0,l=-1}a&&(c=-c,l=-l);var d,f,p,g;0===s?(d=Math.abs(u-t[1])*e+r,f=Math.abs(h-t[0])*e+i,p=Math.abs(t[3]-t[1])*e,g=Math.abs(t[2]-t[0])*e):(d=Math.abs(h-t[0])*e+r,f=Math.abs(u-t[1])*e+i,p=Math.abs(t[2]-t[0])*e,g=Math.abs(t[3]-t[1])*e),this.transform=[s*e,o*e,c*e,l*e,d-s*e*h-c*e*u,f-o*e*h-l*e*u],this.width=p,this.height=g,this.fontScale=e}return t.prototype={clone:function(e){e=e||{};var n="scale"in e?e.scale:this.scale,r="rotation"in e?e.rotation:this.rotation;return new t(this.viewBox.slice(),n,r,this.offsetX,this.offsetY,e.dontFlip)},convertToViewportPoint:function(t,e){return mt.applyTransform([t,e],this.transform)},convertToViewportRectangle:function(t){var e=mt.applyTransform([t[0],t[1]],this.transform),n=mt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]},convertToPdfPoint:function(t,e){return mt.applyInverseTransform([t,e],this.transform)}},t}(),vt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,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,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364],bt=function(){function t(t,e,n){for(;t.lengtha&&(a=s.length)}for(e=0,n=r.length;e>2,d=(3&c)<<4|l>>4,f=s+1>6:64,p=s+20?e:t.length,n>0?n:t.length);return t.substring(t.lastIndexOf("/",r)+1,r)}function s(t){var e=l.globalScope.PDFJS;switch(t){case"pdfBug":return!!e&&e.pdfBug;case"disableAutoFetch":return!!e&&e.disableAutoFetch;case"disableStream":return!!e&&e.disableStream;case"disableRange":return!!e&&e.disableRange;case"disableFontFace":return!!e&&e.disableFontFace;case"disableCreateObjectURL":return!!e&&e.disableCreateObjectURL;case"disableWebGL":return!e||e.disableWebGL;case"cMapUrl":return e?e.cMapUrl:null;case"cMapPacked":return!!e&&e.cMapPacked;case"postMessageTransfers":return!e||e.postMessageTransfers;case"workerPort":return e?e.workerPort:null;case"workerSrc":return e?e.workerSrc:null;case"disableWorker":return!!e&&e.disableWorker;case"maxImageSize":return e?e.maxImageSize:-1;case"imageResourcesPath":return e?e.imageResourcesPath:"";case"isEvalSupported":return!e||e.isEvalSupported;case"externalLinkTarget":if(!e)return S.NONE;switch(e.externalLinkTarget){case S.NONE:case S.SELF:case S.BLANK:case S.PARENT:case S.TOP:return e.externalLinkTarget}return d("PDFJS.externalLinkTarget is invalid: "+e.externalLinkTarget),e.externalLinkTarget=S.NONE,S.NONE;case"externalLinkRel":return e?e.externalLinkRel:A;case"enableStats":return!(!e||!e.enableStats);case"pdfjsNext":return!(!e||!e.pdfjsNext);default:throw new Error("Unknown default setting: "+t)}}function o(){switch(s("externalLinkTarget")){case S.NONE:return!1;case S.SELF:case S.BLANK:case S.PARENT:case S.TOP:return!0}}function c(t,e){return f("isValidUrl(), please use createValidAbsoluteUrl() instead."),null!==p(t,e?"http://example.com":null)}var l=n(0),h=l.assert,u=l.removeNullCharacters,d=l.warn,f=l.deprecated,p=l.createValidAbsoluteUrl,g=l.stringToBytes,m=l.CMapCompressionType,A="noopener noreferrer nofollow";r.prototype={create:function(t,e){h(t>0&&e>0,"invalid canvas size");var n=document.createElement("canvas"),r=n.getContext("2d");return n.width=t,n.height=e,{canvas:n,context:r}},reset:function(t,e,n){h(t.canvas,"canvas is not specified"),h(e>0&&n>0,"invalid canvas size"),t.canvas.width=e,t.canvas.height=n},destroy:function(t){h(t.canvas,"canvas is not specified"),t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}};var v,b=function(){function t(t){this.baseUrl=t.baseUrl||null,this.isCompressed=t.isCompressed||!1}return t.prototype={fetch:function(t){var e=t.name;return e?new Promise(function(t,n){var r=this.baseUrl+e+(this.isCompressed?".bcmap":""),i=new XMLHttpRequest;i.open("GET",r,!0),this.isCompressed&&(i.responseType="arraybuffer"),i.onreadystatechange=function(){if(i.readyState===XMLHttpRequest.DONE){if(200===i.status||0===i.status){var e;if(this.isCompressed&&i.response?e=new Uint8Array(i.response):!this.isCompressed&&i.responseText&&(e=g(i.responseText)),e)return void t({cMapData:e,compressionType:this.isCompressed?m.BINARY:m.NONE})}n(new Error("Unable to load "+(this.isCompressed?"binary ":"")+"CMap at: "+r))}}.bind(this),i.send(null)}.bind(this)):Promise.reject(new Error("CMap name must be specified."))}},t}(),y=function(){function t(){}var e=["ms","Moz","Webkit","O"],n=Object.create(null);return t.getProp=function(t,r){if(1===arguments.length&&"string"==typeof n[t])return n[t];r=r||document.documentElement;var i,a,s=r.style;if("string"==typeof s[t])return n[t]=t;a=t.charAt(0).toUpperCase()+t.slice(1);for(var o=0,c=e.length;o0){r.style.borderWidth=t.borderStyle.width+"px",t.borderStyle.style!==s.UNDERLINE&&(i-=2*t.borderStyle.width,a-=2*t.borderStyle.width);var c=t.borderStyle.horizontalCornerRadius,h=t.borderStyle.verticalCornerRadius;if(c>0||h>0){var u=c+"px / "+h+"px";p.setProp("borderRadius",r,u)}switch(t.borderStyle.style){case s.SOLID:r.style.borderStyle="solid";break;case s.DASHED:r.style.borderStyle="dashed";break;case s.BEVELED:f("Unimplemented border style: beveled");break;case s.INSET:f("Unimplemented border style: inset");break;case s.UNDERLINE:r.style.borderBottomStyle="solid"}t.color?r.style.borderColor=l.makeCssRgb(0|t.color[0],0|t.color[1],0|t.color[2]):r.style.borderWidth=0}return r.style.left=o[0]+"px",r.style.top=o[1]+"px",r.style.width=i+"px",r.style.height=a+"px",r},_createPopup:function(t,e,n){e||(e=document.createElement("div"),e.style.height=t.style.height,e.style.width=t.style.width,t.appendChild(e));var r=new C({container:t,trigger:e,color:n.color,title:n.title,contents:n.contents,hideWrapper:!0}),i=r.render();i.style.left=t.style.width,t.appendChild(i)},render:function(){throw new Error("Abstract method AnnotationElement.render called")}},t}(),A=function(){function t(t){m.call(this,t,!0)}return l.inherit(t,m,{render:function(){this.container.className="linkAnnotation";var t=document.createElement("a");return h(t,{url:this.data.url,target:this.data.newWindow?u.BLANK:void 0}),this.data.url||(this.data.action?this._bindNamedAction(t,this.data.action):this._bindLink(t,this.data.dest)),this.container.appendChild(t),this.container},_bindLink:function(t,e){var n=this;t.href=this.linkService.getDestinationHash(e),t.onclick=function(){return e&&n.linkService.navigateTo(e),!1},e&&(t.className="internalLink")},_bindNamedAction:function(t,e){var n=this;t.href=this.linkService.getAnchorUrl(""),t.onclick=function(){return n.linkService.executeNamedAction(e),!1},t.className="internalLink"}}),t}(),v=function(){function t(t){var e=!!(t.data.hasPopup||t.data.title||t.data.contents);m.call(this,t,e)}return l.inherit(t,m,{render:function(){this.container.className="textAnnotation";var t=document.createElement("img");return t.style.height=this.container.style.height,t.style.width=this.container.style.width,t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.alt="[{{type}} Annotation]",t.dataset.l10nId="text_annotation_type",t.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(this.container,t,this.data),this.container.appendChild(t),this.container}}),t}(),b=function(){function t(t,e){m.call(this,t,e)}return l.inherit(t,m,{render:function(){return this.container}}),t}(),y=function(){function t(t){var e=t.renderInteractiveForms||!t.data.hasAppearance&&!!t.data.fieldValue;b.call(this,t,e)}var e=["left","center","right"];return l.inherit(t,b,{render:function(){this.container.className="textWidgetAnnotation";var t=null;if(this.renderInteractiveForms){if(this.data.multiLine?(t=document.createElement("textarea"),t.textContent=this.data.fieldValue):(t=document.createElement("input"),t.type="text",t.setAttribute("value",this.data.fieldValue)),t.disabled=this.data.readOnly,null!==this.data.maxLen&&(t.maxLength=this.data.maxLen),this.data.comb){var n=this.data.rect[2]-this.data.rect[0],r=n/this.data.maxLen;t.classList.add("comb"),t.style.letterSpacing="calc("+r+"px - 1ch)"}}else{t=document.createElement("div"),t.textContent=this.data.fieldValue,t.style.verticalAlign="middle",t.style.display="table-cell";var i=null;this.data.fontRefName&&(i=this.page.commonObjs.getData(this.data.fontRefName)),this._setTextStyle(t,i)}return null!==this.data.textAlignment&&(t.style.textAlign=e[this.data.textAlignment]),this.container.appendChild(t),this.container},_setTextStyle:function(t,e){var n=t.style;if(n.fontSize=this.data.fontSize+"px",n.direction=this.data.fontDirection<0?"rtl":"ltr",e){n.fontWeight=e.black?e.bold?"900":"bold":e.bold?"bold":"normal",n.fontStyle=e.italic?"italic":"normal";var r=e.loadedName?'"'+e.loadedName+'", ':"",i=e.fallbackName||"Helvetica, sans-serif";n.fontFamily=r+i}}}),t}(),x=function(){function t(t){b.call(this,t,t.renderInteractiveForms)}return l.inherit(t,b,{render:function(){this.container.className="buttonWidgetAnnotation checkBox";var t=document.createElement("input");return t.disabled=this.data.readOnly,t.type="checkbox",this.data.fieldValue&&"Off"!==this.data.fieldValue&&t.setAttribute("checked",!0),this.container.appendChild(t),this.container}}),t}(),S=function(){function t(t){b.call(this,t,t.renderInteractiveForms)}return l.inherit(t,b,{render:function(){this.container.className="buttonWidgetAnnotation radioButton";var t=document.createElement("input");return t.disabled=this.data.readOnly,t.type="radio",t.name=this.data.fieldName,this.data.fieldValue===this.data.buttonValue&&t.setAttribute("checked",!0),this.container.appendChild(t),this.container}}),t}(),w=function(){function t(t){b.call(this,t,t.renderInteractiveForms)}return l.inherit(t,b,{render:function(){this.container.className="choiceWidgetAnnotation";var t=document.createElement("select");t.disabled=this.data.readOnly,this.data.combo||(t.size=this.data.options.length,this.data.multiSelect&&(t.multiple=!0));for(var e=0,n=this.data.options.length;e=0&&i.setAttribute("selected",!0),t.appendChild(i)}return this.container.appendChild(t),this.container}}),t}(),k=function(){function t(t){var e=!(!t.data.title&&!t.data.contents);m.call(this,t,e)}return l.inherit(t,m,{render:function(){this.container.className="popupAnnotation";var t='[data-annotation-id="'+this.data.parentId+'"]',e=this.layer.querySelector(t);if(!e)return this.container;var n=new C({container:this.container,trigger:e,color:this.data.color,title:this.data.title,contents:this.data.contents}),r=parseFloat(e.style.left),i=parseFloat(e.style.width);return p.setProp("transformOrigin",this.container,-(r+i)+"px -"+e.style.top),this.container.style.left=r+i+"px",this.container.appendChild(n.render()),this.container}}),t}(),C=function(){function t(t){this.container=t.container,this.trigger=t.trigger,this.color=t.color,this.title=t.title,this.contents=t.contents,this.hideWrapper=t.hideWrapper||!1,this.pinned=!1}return t.prototype={render:function(){var t=document.createElement("div");t.className="popupWrapper",this.hideElement=this.hideWrapper?t:this.container,this.hideElement.setAttribute("hidden",!0);var e=document.createElement("div");e.className="popup";var n=this.color;if(n){var r=.7*(255-n[0])+n[0],i=.7*(255-n[1])+n[1],a=.7*(255-n[2])+n[2];e.style.backgroundColor=l.makeCssRgb(0|r,0|i,0|a)}var s=this._formatContents(this.contents),o=document.createElement("h1");return o.textContent=this.title,this.trigger.addEventListener("click",this._toggle.bind(this)),this.trigger.addEventListener("mouseover",this._show.bind(this,!1)),this.trigger.addEventListener("mouseout",this._hide.bind(this,!1)),e.addEventListener("click",this._hide.bind(this,!0)),e.appendChild(o),e.appendChild(s),t.appendChild(e),t},_formatContents:function(t){for(var e=document.createElement("p"),n=t.split(/(?:\r\n?|\n)/),r=0,i=n.length;r1&&S("getDocument is called with pdfDataRangeTransport, passwordCallback or progressCallback argument"),e&&(e instanceof J||(e=Object.create(e),e.length=t.length,e.initialData=t.initialData,e.abort||(e.abort=function(){})),t=Object.create(t),t.range=e),a.onPassword=n||null,a.onProgress=r||null;var s;"string"==typeof t?s={url:t}:T(t)?s={data:t}:t instanceof J?s={range:t}:("object"!=typeof t&&x("Invalid parameter in getDocument, need either Uint8Array, string or a parameter object"),t.url||t.data||t.range||x("Invalid parameter object: need either .data, .range or .url"),s=t);var o={},c=null,l=null;for(var h in s)if("url"!==h||"undefined"==typeof window)if("range"!==h)if("worker"!==h)if("data"!==h||s[h]instanceof Uint8Array)o[h]=s[h];else{var u=s[h];"string"==typeof u?o[h]=E(u):"object"!=typeof u||null===u||isNaN(u.length)?T(u)?o[h]=new Uint8Array(u):x("Invalid PDF binary data: either typed array, string or array-like object is expected in the data property."):o[h]=new Uint8Array(u)}else l=s[h];else c=s[h];else o[h]=new URL(s[h],window.location).href;o.rangeChunkSize=o.rangeChunkSize||W,o.disableNativeImageDecoder=!0===o.disableNativeImageDecoder;var f=o.CMapReaderFactory||B;if(!l){var p=j("workerPort");l=p?new Z(null,p):new Z,a._worker=l}var g=a.docId;return l.promise.then(function(){if(a.destroyed)throw new Error("Loading aborted");return i(l,o,c,g).then(function(t){if(a.destroyed)throw new Error("Loading aborted");var e=new d(g,t,l.port),n=new $(e,a,c,f);a._transport=n,e.send("Ready",null)})}).catch(a._capability.reject),a}function i(t,e,n,r){return t.destroyed?Promise.reject(new Error("Worker was destroyed")):(e.disableAutoFetch=j("disableAutoFetch"),e.disableStream=j("disableStream"),e.chunkedViewerLoading=!!n,n&&(e.length=n.length,e.initialData=n.initialData),t.messageHandler.sendWithPromise("GetDocRequest",{docId:r,source:e,disableRange:j("disableRange"),maxImageSize:j("maxImageSize"),disableFontFace:j("disableFontFace"),disableCreateObjectURL:j("disableCreateObjectURL"),postMessageTransfers:j("postMessageTransfers")&&!X,docBaseUrl:e.docBaseUrl,disableNativeImageDecoder:e.disableNativeImageDecoder}).then(function(e){if(t.destroyed)throw new Error("Worker was destroyed");return e}))}var a,s=n(0),o=n(11),c=n(10),l=n(7),h=n(1),u=s.InvalidPDFException,d=s.MessageHandler,f=s.MissingPDFException,p=s.PageViewport,g=s.PasswordException,m=s.StatTimer,A=s.UnexpectedResponseException,v=s.UnknownErrorException,b=s.Util,y=s.createPromiseCapability,x=s.error,S=s.deprecated,w=s.getVerbosityLevel,k=s.info,C=s.isInt,_=s.isArray,T=s.isArrayBuffer,P=s.isSameOrigin,L=s.loadJpegStream,E=s.stringToBytes,R=s.globalScope,I=s.warn,F=o.FontFaceObject,O=o.FontLoader,M=c.CanvasGraphics,D=l.Metadata,N=h.RenderingCancelledException,j=h.getDefaultSetting,U=h.DOMCanvasFactory,B=h.DOMCMapReaderFactory,W=65536,G=!1,X=!1,H="undefined"!=typeof document&&document.currentScript?document.currentScript.src:null,z=null,Y=!1;if("undefined"==typeof __pdfjsdev_webpack__){"undefined"==typeof window?(G=!0,void 0===require.ensure&&(require.ensure=require("node-ensure")),Y=!0):"undefined"!=typeof require&&"function"==typeof require.ensure&&(Y=!0),"undefined"!=typeof requirejs&&requirejs.toUrl&&(a=requirejs.toUrl("pdfjs-dist/build/pdf.worker.js"));var q="undefined"!=typeof requirejs&&requirejs.load;z=Y?function(t){require.ensure([],function(){var e=require("./pdf.worker.js");t(e.WorkerMessageHandler)})}:q?function(t){requirejs(["pdfjs-dist/build/pdf.worker"],function(e){t(e.WorkerMessageHandler)})}:null}var V=function(){function t(){this._capability=y(),this._transport=null,this._worker=null,this.docId="d"+e++,this.destroyed=!1,this.onPassword=null,this.onProgress=null,this.onUnsupportedFeature=null}var e=0;return t.prototype={get promise(){return this._capability.promise},destroy:function(){return this.destroyed=!0,(this._transport?this._transport.destroy():Promise.resolve()).then(function(){this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}.bind(this))},then:function(t,e){return this.promise.then.apply(this.promise,arguments)}},t}(),J=function(){function t(t,e){this.length=t,this.initialData=e,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._readyCapability=y()}return t.prototype={addRangeListener:function(t){this._rangeListeners.push(t)},addProgressListener:function(t){this._progressListeners.push(t)},addProgressiveReadListener:function(t){this._progressiveReadListeners.push(t)},onDataRange:function(t,e){for(var n=this._rangeListeners,r=0,i=n.length;r=0&&s.renderTasks.splice(e,1),l.cleanupAfterRender&&(l.pendingCleanup=!0),l._tryCleanup(),t?o.capability.reject(t):o.capability.resolve(),n.timeEnd("Rendering"),n.timeEnd("Overall")}var n=this.stats;n.time("Overall"),this.pendingCleanup=!1;var r="print"===t.intent?"print":"display",i=!0===t.renderInteractiveForms,a=t.canvasFactory||new U;this.intentStates[r]||(this.intentStates[r]=Object.create(null));var s=this.intentStates[r];s.displayReadyCapability||(s.receivingOperatorList=!0,s.displayReadyCapability=y(),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this.stats.time("Page Request"),this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageNumber-1,intent:r,renderInteractiveForms:i}));var o=new nt(e,t,this.objs,this.commonObjs,s.operatorList,this.pageNumber,a);o.useRequestAnimationFrame="print"!==r,s.renderTasks||(s.renderTasks=[]),s.renderTasks.push(o);var c=o.task;t.continueCallback&&(S("render is used with continueCallback parameter"),c.onContinue=t.continueCallback);var l=this;return s.displayReadyCapability.promise.then(function(t){if(l.pendingCleanup)return void e();n.time("Rendering"),o.initializeGraphics(t),o.operatorListChanged()},function(t){e(t)}),c},getOperatorList:function(){function t(){if(n.operatorList.lastChunk){n.opListReadCapability.resolve(n.operatorList);var t=n.renderTasks.indexOf(e);t>=0&&n.renderTasks.splice(t,1)}}this.intentStates.oplist||(this.intentStates.oplist=Object.create(null));var e,n=this.intentStates.oplist;return n.opListReadCapability||(e={},e.operatorListChanged=t,n.receivingOperatorList=!0,n.opListReadCapability=y(),n.renderTasks=[],n.renderTasks.push(e),n.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageIndex,intent:"oplist"})),n.opListReadCapability.promise},getTextContent:function(t){return this.transport.messageHandler.sendWithPromise("GetTextContent",{pageIndex:this.pageNumber-1,normalizeWhitespace:!(!t||!0!==t.normalizeWhitespace),combineTextItems:!t||!0!==t.disableCombineTextItems})},_destroy:function(){this.destroyed=!0,this.transport.pageCache[this.pageIndex]=null;var t=[];return Object.keys(this.intentStates).forEach(function(e){if("oplist"!==e){this.intentStates[e].renderTasks.forEach(function(e){var n=e.capability.promise.catch(function(){});t.push(n),e.cancel()})}},this),this.objs.clear(),this.annotationsPromise=null,this.pendingCleanup=!1,Promise.all(t)},destroy:function(){S("page destroy method, use cleanup() instead"),this.cleanup()},cleanup:function(){this.pendingCleanup=!0,this._tryCleanup()},_tryCleanup:function(){this.pendingCleanup&&!Object.keys(this.intentStates).some(function(t){var e=this.intentStates[t];return 0!==e.renderTasks.length||e.receivingOperatorList},this)&&(Object.keys(this.intentStates).forEach(function(t){delete this.intentStates[t]},this),this.objs.clear(),this.annotationsPromise=null,this.pendingCleanup=!1)},_startRenderPage:function(t,e){var n=this.intentStates[e];n.displayReadyCapability&&n.displayReadyCapability.resolve(t)},_renderPageChunk:function(t,e){var n,r,i=this.intentStates[e];for(n=0,r=t.length;n=0;return i=t===a?t:s?new t.constructor(a,t.byteOffset,t.byteLength):new t.constructor(t),r.set(t,i),i}i=_(t)?[]:{},r.set(t,i);for(var o in t){for(var c,l=t;!(c=Object.getOwnPropertyDescriptor(l,o));)l=Object.getPrototypeOf(l);void 0!==c.value&&"function"!=typeof c.value&&(i[o]=n(c.value))}return i}if(!this._defer)return void this._listeners.forEach(function(e){e.call(this,{data:t})},this);var r=new WeakMap,i={data:n(t)};this._deferred.then(function(){this._listeners.forEach(function(t){t.call(this,i)},this)}.bind(this))},addEventListener:function(t,e){this._listeners.push(e)},removeEventListener:function(t,e){var n=this._listeners.indexOf(e);this._listeners.splice(n,1)},terminate:function(){this._listeners=[]}},i.prototype={get promise(){return this._readyCapability.promise},get port(){return this._port},get messageHandler(){return this._messageHandler},_initializeFromPort:function(t){this._port=t,this._messageHandler=new d("main","worker",t),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve()},_initialize:function(){if(!G&&!j("disableWorker")&&"undefined"!=typeof Worker){var e=t();try{P(window.location.href,e)||(e=r(new URL(e,window.location).href));var n=new Worker(e),i=new d("main","worker",n),a=function(){n.removeEventListener("error",s),i.destroy(),n.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()}.bind(this),s=function(t){this._webWorker||a()}.bind(this);n.addEventListener("error",s),i.on("test",function(t){if(n.removeEventListener("error",s),this.destroyed)return void a();t&&t.supportTypedArray?(this._messageHandler=i,this._port=n,this._webWorker=n,t.supportTransfers||(X=!0),this._readyCapability.resolve(),i.send("configure",{verbosity:w()})):(this._setupFakeWorker(),i.destroy(),n.terminate())}.bind(this)),i.on("console_log",function(t){console.log.apply(console,t)}),i.on("console_error",function(t){console.error.apply(console,t)}),i.on("ready",function(t){if(n.removeEventListener("error",s),this.destroyed)return void a();try{o()}catch(t){this._setupFakeWorker()}}.bind(this));var o=function(){var t=j("postMessageTransfers")&&!X,e=new Uint8Array([t?255:0]);try{i.send("test",e,[e.buffer])}catch(t){k("Cannot use postMessage transfers"),e[0]=0,i.send("test",e)}};return void o()}catch(t){k("The worker has been disabled.")}}this._setupFakeWorker()},_setupFakeWorker:function(){G||j("disableWorker")||(I("Setting up fake worker."),G=!0),e().then(function(t){if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));var e=Uint8Array!==Float32Array,r=new n(e);this._port=r;var i="fake"+o++,a=new d(i+"_worker",i,r);t.setup(a,r);var s=new d(i,i+"_worker",r);this._messageHandler=s,this._readyCapability.resolve()}.bind(this))},destroy:function(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}},i}(),$=function(){function t(t,e,n,r){this.messageHandler=t,this.loadingTask=e,this.pdfDataRangeTransport=n,this.commonObjs=new tt,this.fontLoader=new O(e.docId),this.CMapReaderFactory=new r({baseUrl:j("cMapUrl"),isCompressed:j("cMapPacked")}),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this.pageCache=[],this.pagePromises=[],this.downloadInfoCapability=y(),this.setupMessageHandler()}return t.prototype={destroy:function(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=y(),this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));var t=[];this.pageCache.forEach(function(e){e&&t.push(e._destroy())}),this.pageCache=[],this.pagePromises=[];var e=this,n=this.messageHandler.sendWithPromise("Terminate",null);return t.push(n),Promise.all(t).then(function(){e.fontLoader.clear(),e.pdfDataRangeTransport&&(e.pdfDataRangeTransport.abort(),e.pdfDataRangeTransport=null),e.messageHandler&&(e.messageHandler.destroy(),e.messageHandler=null),e.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise},setupMessageHandler:function(){var t=this.messageHandler,e=this.loadingTask,n=this.pdfDataRangeTransport;n&&(n.addRangeListener(function(e,n){t.send("OnDataRange",{begin:e,chunk:n})}),n.addProgressListener(function(e){t.send("OnDataProgress",{loaded:e})}),n.addProgressiveReadListener(function(e){t.send("OnDataRange",{chunk:e})}),t.on("RequestDataRange",function(t){n.requestDataRange(t.begin,t.end)},this)),t.on("GetDoc",function(t){var e=t.pdfInfo;this.numPages=t.pdfInfo.numPages;var n=this.loadingTask,r=new Q(e,this,n);this.pdfDocument=r,n._capability.resolve(r)},this),t.on("PasswordRequest",function(t){if(this._passwordCapability=y(),e.onPassword){var n=function(t){this._passwordCapability.resolve({password:t})}.bind(this);e.onPassword(n,t.code)}else this._passwordCapability.reject(new g(t.message,t.code));return this._passwordCapability.promise},this),t.on("PasswordException",function(t){e._capability.reject(new g(t.message,t.code))},this),t.on("InvalidPDF",function(t){this.loadingTask._capability.reject(new u(t.message))},this),t.on("MissingPDF",function(t){this.loadingTask._capability.reject(new f(t.message))},this),t.on("UnexpectedResponse",function(t){this.loadingTask._capability.reject(new A(t.message,t.status))},this),t.on("UnknownError",function(t){this.loadingTask._capability.reject(new v(t.message,t.details))},this),t.on("DataLoaded",function(t){this.downloadInfoCapability.resolve(t)},this),t.on("PDFManagerReady",function(t){this.pdfDataRangeTransport&&this.pdfDataRangeTransport.transportReady()},this),t.on("StartRenderPage",function(t){if(!this.destroyed){var e=this.pageCache[t.pageIndex];e.stats.timeEnd("Page Request"),e._startRenderPage(t.transparency,t.intent)}},this),t.on("RenderPageChunk",function(t){if(!this.destroyed){this.pageCache[t.pageIndex]._renderPageChunk(t.operatorList,t.intent)}},this),t.on("commonobj",function(t){if(!this.destroyed){var e=t[0],n=t[1];if(!this.commonObjs.hasData(e))switch(n){case"Font":var r=t[2];if("error"in r){var i=r.error;I("Error during font loading: "+i),this.commonObjs.resolve(e,i);break}var a=null;j("pdfBug")&&R.FontInspector&&R.FontInspector.enabled&&(a={registerFont:function(t,e){R.FontInspector.fontAdded(t,e)}});var s=new F(r,{isEvalSuported:j("isEvalSupported"),disableFontFace:j("disableFontFace"),fontRegistry:a});this.fontLoader.bind([s],function(t){this.commonObjs.resolve(e,s)}.bind(this));break;case"FontPath":this.commonObjs.resolve(e,t[2]);break;default:x("Got unknown common object type "+n)}}},this),t.on("obj",function(t){if(!this.destroyed){var e,n=t[0],r=t[1],i=t[2],a=this.pageCache[r];if(!a.objs.hasData(n))switch(i){case"JpegStream":e=t[3],L(n,e,a.objs);break;case"Image":e=t[3],a.objs.resolve(n,e);e&&"data"in e&&e.data.length>8e6&&(a.cleanupAfterRender=!0);break;default:x("Got unknown object type "+i)}}},this),t.on("DocProgress",function(t){if(!this.destroyed){var e=this.loadingTask;e.onProgress&&e.onProgress({loaded:t.loaded,total:t.total})}},this),t.on("PageError",function(t){if(!this.destroyed){var e=this.pageCache[t.pageNum-1],n=e.intentStates[t.intent];if(n.displayReadyCapability?n.displayReadyCapability.reject(t.error):x(t.error),n.operatorList){n.operatorList.lastChunk=!0;for(var r=0;rthis.numPages)return Promise.reject(new Error("Invalid page request"));var n=t-1;if(n in this.pagePromises)return this.pagePromises[n];var r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(function(t){if(this.destroyed)throw new Error("Transport destroyed");var e=new K(n,t,this);return this.pageCache[n]=e,e}.bind(this));return this.pagePromises[n]=r,r},getPageIndex:function(t){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:t}).catch(function(t){return Promise.reject(new Error(t))})},getAnnotations:function(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})},getDestinations:function(){return this.messageHandler.sendWithPromise("GetDestinations",null)},getDestination:function(t){return this.messageHandler.sendWithPromise("GetDestination",{id:t})},getPageLabels:function(){return this.messageHandler.sendWithPromise("GetPageLabels",null)},getAttachments:function(){return this.messageHandler.sendWithPromise("GetAttachments",null)},getJavaScript:function(){return this.messageHandler.sendWithPromise("GetJavaScript",null)},getOutline:function(){return this.messageHandler.sendWithPromise("GetOutline",null)},getMetadata:function(){return this.messageHandler.sendWithPromise("GetMetadata",null).then(function(t){return{info:t[0],metadata:t[1]?new D(t[1]):null}})},getStats:function(){return this.messageHandler.sendWithPromise("GetStats",null)},startCleanup:function(){this.messageHandler.sendWithPromise("Cleanup",null).then(function(){for(var t=0,e=this.pageCache.length;t>>8^o[a]}return-1^r}function e(e,n,r,i){var a=i,s=n.length;r[a]=s>>24&255,r[a+1]=s>>16&255,r[a+2]=s>>8&255,r[a+3]=255&s,a+=4,r[a]=255&e.charCodeAt(0),r[a+1]=255&e.charCodeAt(1),r[a+2]=255&e.charCodeAt(2),r[a+3]=255&e.charCodeAt(3),a+=4,r.set(n,a),a+=n.length;var o=t(r,i+4,a);r[a]=o>>24&255,r[a+1]=o>>16&255,r[a+2]=o>>8&255,r[a+3]=255&o}function n(t,e,n){for(var r=1,i=0,a=e;a>3;break;case s.RGB_24BPP:l=2,c=8,h=3*u;break;case s.RGBA_32BPP:l=6,c=8,h=4*u;break;default:throw new Error("invalid format")}var g,m,A=new Uint8Array((1+h)*f),v=0,b=0;for(g=0;g>24&255,u>>16&255,u>>8&255,255&u,f>>24&255,f>>16&255,f>>8&255,255&f,c,l,0,0,0]),x=A.length,S=Math.ceil(x/65535),w=new Uint8Array(2+x+5*S+4),k=0;w[k++]=120,w[k++]=156;for(var C=0;x>65535;)w[k++]=0,w[k++]=255,w[k++]=255,w[k++]=0,w[k++]=0,w.set(A.subarray(C,C+65535),k),k+=65535,C+=65535,x-=65535;w[k++]=1,w[k++]=255&x,w[k++]=x>>8&255,w[k++]=255&~x,w[k++]=(65535&~x)>>8&255,w.set(A.subarray(C),k),k+=A.length-C;var _=n(A,0,A.length);w[k++]=_>>24&255,w[k++]=_>>16&255,w[k++]=_>>8&255,w[k++]=255&_;var T=i.length+3*a+y.length+w.length,P=new Uint8Array(T),L=0;return P.set(i,L),L+=i.length,e("IHDR",y,P,L),L+=a+y.length,e("IDATA",w,P,L),L+=a+w.length,e("IEND",new Uint8Array(0),P,L),d(P,"image/png",o)}for(var i=new Uint8Array([137,80,78,71,13,10,26,10]),a=12,o=new Int32Array(256),c=0;c<256;c++){for(var l=c,h=0;h<8;h++)l=1&l?3988292384^l>>1&2147483647:l>>1&2147483647;o[c]=l}return function(t,e){return r(t,void 0===t.kind?s.GRAYSCALE_1BPP:t.kind,e)}}(),g=function(){function t(){this.fontSizeScale=1,this.fontWeight=f.fontWeight,this.fontSize=0,this.textMatrix=a,this.fontMatrix=i,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=f.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}return t.prototype={clone:function(){return Object.create(this)},setCurrentPoint:function(t,e){this.x=t,this.y=e}},t}(),m=function(){function t(t){for(var e=[],n=[],r=t.length,i=0;i1&&(h.vertical?s.canvasWidth=n.height*e._viewport.scale:s.canvasWidth=n.width*e._viewport.scale),e._textDivProperties.set(i,s),e._enhanceTextSelection){var m=1,A=0;0!==l&&(m=Math.cos(l),A=Math.sin(l));var v,b,y=(h.vertical?n.height:n.width)*e._viewport.scale,x=u;0!==l?(v=[m,A,-A,m,f,g],b=a.getAxialAlignedBoundingBox([0,0,y,x],v)):b=[f,g,f+y,g+x],e._bounds.push({left:b[0],top:b[1],right:b[2],bottom:b[3],div:i,size:[y,x],m:v})}}function n(t){if(!t._canceled){var e=t._container,n=t._textDivs,r=t._capability,i=n.length;if(i>d)return t._renderingDone=!0,void r.resolve();var a=document.createElement("canvas");a.mozOpaque=!0;for(var s,c,l=a.getContext("2d",{alpha:!1}),h=0;h0&&(f.scale=f.canvasWidth/m,A="scaleX("+f.scale+")"),0!==f.angle&&(A="rotate("+f.angle+"deg) "+A),""!==A&&(f.originalTransform=A,o.setProp("transform",u,A)),t._textDivProperties.set(u,f)}}t._renderingDone=!0,r.resolve()}}function r(t){for(var e=t._bounds,n=t._viewport,r=i(n.width,n.height,e),s=0;s0&&(r=r?Math.min(a,r):a)}return r},A=1+Math.min(Math.abs(d),Math.abs(f));c.paddingLeft=m(g,32,16)/A,c.paddingTop=m(g,48,16)/A,c.paddingRight=m(g,0,16)/A,c.paddingBottom=m(g,16,16)/A,t._textDivProperties.set(o,c)}else c.paddingLeft=e[s].left-r[s].left,c.paddingTop=e[s].top-r[s].top,c.paddingRight=r[s].right-e[s].right,c.paddingBottom=r[s].bottom-e[s].bottom,t._textDivProperties.set(o,c)}}function i(t,e,n){var r=n.map(function(t,e){return{x1:t.left,y1:t.top,x2:t.right,y2:t.bottom,index:e,x1New:void 0,x2New:void 0}});l(t,r);var i=new Array(n.length);return r.forEach(function(t){var e=t.index;i[e]={left:t.x1New,top:0,right:t.x2New,bottom:0}}),n.map(function(e,n){var a=i[n],s=r[n];s.x1=e.top,s.y1=t-a.right,s.x2=e.bottom,s.y2=t-a.left,s.index=n,s.x1New=void 0,s.x2New=void 0}),l(e,r),r.forEach(function(t){var e=t.index;i[e].top=t.x1New,i[e].bottom=t.x2New}),i}function l(t,e){e.sort(function(t,e){return t.x1-e.x1||t.index-e.index});var n={x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0},r=[{start:-1/0,end:1/0,boundary:n}];e.forEach(function(t){for(var e=0;e=0&&r[n].start>=t.y2;)n--;var i,a,s,o,c=-1/0;for(s=e;s<=n;s++){i=r[s],a=i.boundary;var l;l=a.x2>t.x1?a.index>t.index?a.x1New:t.x1:void 0===a.x2New?(a.x2+t.x1)/2:a.x2New,l>c&&(c=l)}for(t.x1New=c,s=e;s<=n;s++)i=r[s],a=i.boundary,void 0===a.x2New?a.x2>t.x1?a.index>t.index&&(a.x2New=a.x2):a.x2New=c:a.x2New>c&&(a.x2New=Math.max(c,a.x2));var h=[],u=null;for(s=e;s<=n;s++){i=r[s],a=i.boundary;var d=a.x2>t.x2?a:t;u===d?h[h.length-1].end=i.end:(h.push({start:i.start,end:i.end,boundary:d}),u=d)}for(r[e].start=0&&r[o].start>=a.y1;o--)f=r[o].boundary===a;for(o=n+1;!f&&o\\376\\377([^<]+)/g,function(t,e){for(var n=e.replace(/\\([0-3])([0-7])([0-7])/g,function(t,e,n,r){return String.fromCharCode(64*e+8*n+1*r)}),r="",i=0;i=32&&a<127&&60!==a&&62!==a&&38!==a?String.fromCharCode(a):"&#x"+(65536+a).toString(16).substring(1)+";"}return">"+r})}function i(t){if("string"==typeof t){t=r(t);t=(new DOMParser).parseFromString(t,"application/xml")}else t instanceof Document||s("Metadata: Invalid metadata object");this.metaDocument=t,this.metadata=Object.create(null),this.parse()}var a=n(0),s=a.error;i.prototype={parse:function(){var t=this.metaDocument,e=t.documentElement;if("rdf:rdf"!==e.nodeName.toLowerCase())for(e=e.firstChild;e&&"rdf:rdf"!==e.nodeName.toLowerCase();)e=e.nextSibling;var n=e?e.nodeName.toLowerCase():null;if(e&&"rdf:rdf"===n&&e.hasChildNodes()){var r,i,a,s,o,c,l,h=e.childNodes;for(s=0,c=h.length;s0;)d[f++]=g&p?0:255,p>>=1;var m=0;for(f=0,0!==d[f]&&(c[0]=1,++m),n=1;n>2)+(d[f+1]?4:0)+(d[f-h+1]?8:0),l[A]&&(c[r+n]=l[A],++m),f++;if(d[f-h]!==d[f]&&(c[r+n]=d[f]?2:4,++m),m>1e3)return null}for(f=h*(s-1),r=e*o,0!==d[f]&&(c[r]=8,++m),n=1;n1e3)return null;var v=new Int32Array([0,o,-1,0,-o,0,0,0,1]),b=[];for(e=0;m&&e<=s;e++){for(var y=e*o,x=y+a;y>4,c[y]&=k>>2|k<<2),w.push(y%o),w.push(y/o|0),--m}while(C!==y);b.push(w),--e}}return function(t){t.save(),t.scale(1/a,-1/s),t.translate(0,-s),t.beginPath();for(var e=0,n=b.length;e>3,w=4294967295,k=E.value||!L.value?4278190080:255;for(r=0;rS?c:8*C-7,R=-8&T,I=0,F=0;_>=1}for(;n=h&&(a=l,s=c*a),n=0,i=s;i--;)A[n++]=m[g++],A[n++]=m[g++],A[n++]=m[g++],A[n++]=255;t.putImageData(f,0,r*P)}else x("bad image kind: "+e.kind)}function n(t,e){for(var n=e.height,r=e.width,i=n%P,a=(n-i)/P,s=0===i?a:a+1,o=t.createImageData(r,P),c=0,l=e.data,h=o.data,u=0;u>=1}t.putImageData(o,0,u*P)}}function a(t,e){for(var n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"],r=0,i=n.length;r>8,t[a-2]=t[a-2]*s+n*o>>8,t[a-1]=t[a-1]*s+r*o>>8}}}function o(t,e,n){for(var r=t.length,i=3;i>8]>>8:e[i]*a>>16}}function y(t,e,n,r,i,a,l){var h,u=!!a,d=u?a[0]:0,f=u?a[1]:0,p=u?a[2]:0;h="Luminosity"===i?c:o;for(var g=Math.min(r,Math.ceil(1048576/n)),m=0;m10&&"function"==typeof n,h=l?Date.now()+15:0,u=0,f=this.commonObjs,p=this.objs;;){if(void 0!==r&&s===r.nextBreakPoint)return r.breakIt(s,n),s;if((c=a[s])!==d.dependency)this[c].apply(this,i[s]);else for(var g=i[s],m=0,A=g.length;m10){if(Date.now()>h)return n(),s;u=0}}},endDrawing:function(){null!==this.current.activeSMask&&this.endSMaskGroup(),this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null),this.cachedCanvases.clear(),_.clear(),this.imageLayer&&this.imageLayer.endLayout()},setLineWidth:function(t){this.current.lineWidth=t,this.ctx.lineWidth=t},setLineCap:function(t){this.ctx.lineCap=F[t]},setLineJoin:function(t){this.ctx.lineJoin=O[t]},setMiterLimit:function(t){this.ctx.miterLimit=t},setDash:function(t,e){var n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(t),n.lineDashOffset=e)},setRenderingIntent:function(t){},setFlatness:function(t){},setGState:function(t){for(var e=0,n=t.length;e0&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask?this.suspendSMaskGroup():this.endSMaskGroup()),this.current.activeSMask=a?this.tempSMask:null,this.current.activeSMask&&this.beginSMaskGroup(),this.tempSMask=null}}},beginSMaskGroup:function(){var t=this.current.activeSMask,e=t.canvas.width,n=t.canvas.height,r="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(r,e,n,!0),s=this.ctx,o=s.mozCurrentTransform;this.ctx.save();var c=i.context;c.scale(1/t.scaleX,1/t.scaleY),c.translate(-t.offsetX,-t.offsetY),c.transform.apply(c,o),t.startTransformInverse=c.mozCurrentTransformInverse,a(s,c),this.ctx=c,this.setGState([["BM","Normal"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++},suspendSMaskGroup:function(){var t=this.ctx;this.groupLevel--,this.ctx=this.groupStack.pop(),T(this.ctx,this.current.activeSMask,t),this.ctx.restore(),this.ctx.save(),a(t,this.ctx),this.current.resumeSMaskCtx=t;var e=g.transform(this.current.activeSMask.startTransformInverse,t.mozCurrentTransform);this.ctx.transform.apply(this.ctx,e),t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.restore()},resumeSMaskGroup:function(){var t=this.current.resumeSMaskCtx,e=this.ctx;this.ctx=t,this.groupStack.push(e),this.groupLevel++},endSMaskGroup:function(){var t=this.ctx;this.groupLevel--,this.ctx=this.groupStack.pop(),T(this.ctx,this.current.activeSMask,t),this.ctx.restore(),a(t,this.ctx);var e=g.transform(this.current.activeSMask.startTransformInverse,t.mozCurrentTransform);this.ctx.transform.apply(this.ctx,e)},save:function(){this.ctx.save();var t=this.current;this.stateStack.push(t),this.current=t.clone(),this.current.resumeSMaskCtx=null},restore:function(){this.current.resumeSMaskCtx&&this.resumeSMaskGroup(),null===this.current.activeSMask||0!==this.stateStack.length&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask||this.endSMaskGroup(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.ctx.restore(),this.pendingClip=null,this.cachedGetSinglePixelWidth=null)},transform:function(t,e,n,r,i,a){this.ctx.transform(t,e,n,r,i,a),this.cachedGetSinglePixelWidth=null},constructPath:function(t,e){for(var n=this.ctx,r=this.current,i=r.x,a=r.y,s=0,o=0,c=t.length;s100?100:e;this.current.fontSizeScale=e/c;var h=s+" "+a+" "+c+"px "+o;this.ctx.font=h}},setTextRenderingMode:function(t){this.current.textRenderingMode=t},setTextRise:function(t){this.current.textRise=t},moveText:function(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e},setLeadingMoveText:function(t,e){this.setLeading(-e),this.moveText(t,e)},setTextMatrix:function(t,e,n,r,i,a){this.current.textMatrix=[t,e,n,r,i,a],this.current.textMatrixScale=Math.sqrt(t*t+e*e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0},nextLine:function(){this.moveText(0,this.current.leading)},paintChar:function(t,e,n){var r,i=this.ctx,a=this.current,s=a.font,o=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,l=o&f.FILL_STROKE_MASK,h=!!(o&f.ADD_TO_PATH_FLAG);if((s.disableFontFace||h)&&(r=s.getPathGenerator(this.commonObjs,t)),s.disableFontFace?(i.save(),i.translate(e,n),i.beginPath(),r(i,c),l!==f.FILL&&l!==f.FILL_STROKE||i.fill(),l!==f.STROKE&&l!==f.FILL_STROKE||i.stroke(),i.restore()):(l!==f.FILL&&l!==f.FILL_STROKE||i.fillText(t,e,n),l!==f.STROKE&&l!==f.FILL_STROKE||i.strokeText(t,e,n)),h){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:i.mozCurrentTransform,x:e,y:n,fontSize:c,addToPath:r})}},get isFontSubpixelAAEnabled(){var t=this.canvasFactory.create(10,10).context;t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,n=!1,r=3;r0&&e[r]<255){n=!0;break}return S(this,"isFontSubpixelAAEnabled",n)},showText:function(t){var e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);var r=e.fontSize;if(0!==r){var i=this.ctx,a=e.fontSizeScale,s=e.charSpacing,o=e.wordSpacing,c=e.fontDirection,l=e.textHScale*c,h=t.length,u=n.vertical,d=u?1:-1,p=n.defaultVMetrics,g=r*e.fontMatrix[0],m=e.textRenderingMode===f.FILL&&!n.disableFontFace;i.save(),i.transform.apply(i,e.textMatrix),i.translate(e.x,e.y+e.textRise),e.patternFill&&(i.fillStyle=e.fillColor.getPattern(i,this)),c>0?i.scale(l,-1):i.scale(l,1);var A=e.lineWidth,b=e.textMatrixScale;if(0===b||0===A){var y=e.textRenderingMode&f.FILL_STROKE_MASK;y!==f.STROKE&&y!==f.FILL_STROKE||(this.cachedGetSinglePixelWidth=null,A=.65*this.getSinglePixelWidth())}else A/=b;1!==a&&(i.scale(a,a),A/=a),i.lineWidth=A;var x,S=0;for(x=0;x0){var D=1e3*i.measureText(E).width/r*a;if(I4096&&(h=c/4096,c=4096),l>4096&&(u=l/4096,l=4096);var d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);var f=this.cachedCanvases.getCanvas(d,c,l,!0),p=f.context;p.scale(1/h,1/u),p.translate(-s,-o),p.transform.apply(p,n),t.smask?this.smaskStack.push({canvas:f.canvas,context:p,offsetX:s,offsetY:o,scaleX:h,scaleY:u,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(s,o),e.scale(h,u)),a(e,p),this.ctx=p,this.setGState([["BM","Normal"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++,this.current.activeSMask=null},endGroup:function(t){this.groupLevel--;var e=this.ctx;this.ctx=this.groupStack.pop(),void 0!==this.ctx.imageSmoothingEnabled?this.ctx.imageSmoothingEnabled=!1:this.ctx.mozImageSmoothingEnabled=!1,t.smask?this.tempSMask=this.smaskStack.pop():this.ctx.drawImage(e.canvas,0,0),this.restore()},beginAnnotations:function(){this.save(),this.current=new I,this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)},endAnnotations:function(){this.restore()},beginAnnotation:function(t,e,n){if(this.save(),b(t)&&4===t.length){var r=t[2]-t[0],i=t[3]-t[1];this.ctx.rect(t[0],t[1],r,i),this.clip(),this.endPath()}this.transform.apply(this,e),this.transform.apply(this,n)},endAnnotation:function(){this.restore()},paintJpegXObject:function(t,e,n){var r=this.objs.get(t);if(!r)return void w("Dependent image isn't ready yet");this.save();var i=this.ctx;if(i.scale(1/e,-1/n),i.drawImage(r,0,0,r.width,r.height,0,-n,e,n),this.imageLayer){var a=i.mozCurrentTransformInverse,s=this.getCanvasPosition(0,0);this.imageLayer.appendImage({objId:t,left:s[0],top:s[1],width:e/a[0],height:n/a[3]})}this.restore()},paintImageMaskXObject:function(t){var e=this.ctx,r=t.width,a=t.height,s=this.current.fillColor,o=this.current.patternFill,c=this.processingType3;if(c&&void 0===c.compiled&&(c.compiled=r<=1e3&&a<=1e3?i({data:t.data,width:r,height:a}):null),c&&c.compiled)return void c.compiled(e);var l=this.cachedCanvases.getCanvas("maskCanvas",r,a),h=l.context;h.save(),n(h,t),h.globalCompositeOperation="source-in",h.fillStyle=o?s.getPattern(h,this):s,h.fillRect(0,0,r,a),h.restore(),this.paintInlineImageXObject(l.canvas)},paintImageMaskXObjectRepeat:function(t,e,r,i){var a=t.width,s=t.height,o=this.current.fillColor,c=this.current.patternFill,l=this.cachedCanvases.getCanvas("maskCanvas",a,s),h=l.context;h.save(),n(h,t),h.globalCompositeOperation="source-in",h.fillStyle=c?o.getPattern(h,this):o,h.fillRect(0,0,a,s),h.restore();for(var u=this.ctx,d=0,f=i.length;d2&&g>1||f>2&&m>1;){var v=g,b=m;h>2&&g>1&&(v=Math.ceil(g/2),h/=g/v),f>2&&m>1&&(b=Math.ceil(m/2),f/=m/b),s=this.cachedCanvases.getCanvas(A,v,b),p=s.context,p.clearRect(0,0,v,b),p.drawImage(a,0,0,g,m,0,0,v,b),a=s.canvas,g=v,m=b,A="prescale1"===A?"prescale2":"prescale1"}if(i.drawImage(a,0,0,g,m,0,-r,n,r),this.imageLayer){var y=this.getCanvasPosition(0,-r);this.imageLayer.appendImage({imgData:t,left:y[0],top:y[1],width:n/o[0],height:r/o[3]})}this.restore()},paintInlineImageXObjectGroup:function(t,n){var r=this.ctx,i=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",i,a);e(s.context,t);for(var o=0,c=n.length;o0&&!r.isSyncFontLoadingSupported?this.prepareFontLoadEvent(n,i,f):f.complete()},r.prototype.queueLoadingCallback=function(t){function e(){for(a(!i.end,"completeRequest() cannot be called twice"),i.end=Date.now();n.requests.length>0&&n.requests[0].end;){var t=n.requests.shift();setTimeout(t.callback,0)}}var n=this.loadingContext,r="pdfjs-font-loading-"+n.nextRequestId++,i={id:r,complete:e,callback:t,started:Date.now()};return n.requests.push(i),i},r.prototype.prepareFontLoadEvent=function(t,e,n){function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function i(t,e,n,r){return t.substr(0,e)+r+t.substr(e+n)}function a(t,e){return++d>30?(l("Load test font never loaded."),void e()):(u.font="30px "+t,u.fillText(".",0,20),u.getImageData(0,0,1,1).data[3]>0?void e():void setTimeout(a.bind(null,t,e)))}var s,c,h=document.createElement("canvas");h.width=1,h.height=1;var u=h.getContext("2d"),d=0,f="lt"+Date.now()+this.loadTestFontId++,p=this.loadTestFont;p=i(p,976,f.length,f);var g=r(p,16);for(s=0,c=f.length-3;s=14&&(t=!0),t};Object.defineProperty(r,"isSyncFontLoadingSupported",{get:function(){return c(r,"isSyncFontLoadingSupported",u())},enumerable:!0,configurable:!0});var d={get value(){return c(this,"value",i.isEvalSupported())}},f=function(){function t(t,e){this.compiledGlyphs=Object.create(null);for(var n in t)this[n]=t[n];this.options=e}return t.prototype={createNativeFontFace:function(){if(!this.data)return null;if(this.options.disableFontFace)return this.disableFontFace=!0,null;var t=new FontFace(this.loadedName,this.data,{});return this.options.fontRegistry&&this.options.fontRegistry.registerFont(this),t},createFontFaceRule:function(){if(!this.data)return null;if(this.options.disableFontFace)return this.disableFontFace=!0,null;var t=s(new Uint8Array(this.data)),e=this.loadedName,n="url(data:"+this.mimetype+";base64,"+btoa(t)+");",r='@font-face { font-family:"'+e+'";src:'+n+"}";return this.options.fontRegistry&&this.options.fontRegistry.registerFont(this,n),r},getPathGenerator:function(t,e){if(!(e in this.compiledGlyphs)){var n,r,i,a=t.get(this.loadedName+"_path_"+e);if(this.options.isEvalSupported&&d.value){var s,o="";for(r=0,i=a.length;rl[r+1]&&(c=n,n=r,r=c,c=a,a=s,s=c),l[r+1]>l[i+1]&&(c=r,r=i,i=c,c=s,s=o,o=c),l[n+1]>l[r+1]&&(c=n,n=r,r=c,c=a,a=s,s=c);var f=(l[n]+e.offsetX)*e.scaleX,p=(l[n+1]+e.offsetY)*e.scaleY,g=(l[r]+e.offsetX)*e.scaleX,m=(l[r+1]+e.offsetY)*e.scaleY,A=(l[i]+e.offsetX)*e.scaleX,v=(l[i+1]+e.offsetY)*e.scaleY;if(!(p>=v))for(var b,y,x,S,w,k,C,_,T,P=h[a],L=h[a+1],E=h[a+2],R=h[s],I=h[s+1],F=h[s+2],O=h[o],M=h[o+1],D=h[o+2],N=Math.round(p),j=Math.round(v),U=N;U<=j;U++){Uv?1:m===v?0:(m-U)/(m-v),b=g-(g-A)*T,y=R-(R-O)*T,x=I-(I-M)*T,S=F-(F-D)*T),T=Uv?1:(p-U)/(p-v),w=f-(f-A)*T,k=P-(P-O)*T,C=L-(L-M)*T,_=E-(E-D)*T;for(var B=Math.round(Math.min(b,w)),W=Math.round(Math.max(b,w)),G=d*U+4*B,X=B;X<=W;X++)T=(b-X)/(b-w),T=T<0?0:T>1?1:T,u[G++]=y-(y-k)*T|0,u[G++]=x-(x-C)*T|0,u[G++]=S-(S-_)*T|0,u[G++]=255}}function e(e,n,r){var i,a,s=n.coords,o=n.colors;switch(n.type){case"lattice":var c=n.verticesPerRow,h=Math.floor(s.length/c)-1,u=c-1;for(i=0;i=0,o=/Chrome\/(39|40)\./.test(n),c=n.indexOf("CriOS")>=0,l=n.indexOf("Trident")>=0,h=/\b(iPad|iPhone|iPod)(?=;)/.test(n),u=n.indexOf("Opera")>=0,d=/Safari\//.test(n)&&!/(Chrome\/|Android\s)/.test(n),f="object"==typeof window&&"object"==typeof document;"undefined"==typeof PDFJS&&(e.PDFJS={}),PDFJS.compatibilityChecked=!0,function(){function t(t,e){return new r(this.slice(t,e))}function n(t,e){arguments.length<2&&(e=0);for(var n=0,r=t.length;n>2,l=(3&a)<<4|s>>4,h=n+1>6:64,u=n+2>(-2*r&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a}}}(),function(){void 0===Function.prototype.bind&&(Function.prototype.bind=function(t){var e=this,n=Array.prototype.slice.call(arguments,1);return function(){var r=n.concat(Array.prototype.slice.call(arguments));return e.apply(t,r)}})}(),function(){if(f){"dataset"in document.createElement("div")||Object.defineProperty(HTMLElement.prototype,"dataset",{get:function(){if(this._dataset)return this._dataset;for(var t={},e=0,n=this.attributes.length;e=0&&r&&a.splice(s,1),t.className=a.join(" "),s>=0}if(f){if(!("classList"in document.createElement("div"))){var e={add:function(e){t(this.element,e,!0,!1)},contains:function(e){return t(this.element,e,!1,!1)},remove:function(e){t(this.element,e,!1,!0)},toggle:function(e){t(this.element,e,!0,!0)}};Object.defineProperty(HTMLElement.prototype,"classList",{get:function(){if(this._classList)return this._classList;var t=Object.create(e,{element:{value:this,writable:!1,enumerable:!0}});return Object.defineProperty(this,"_classList",{value:t,writable:!1,enumerable:!1}),t},enumerable:!0})}}}(),function(){if(!("undefined"==typeof importScripts||"console"in e)){var t={},n={log:function(){var t=Array.prototype.slice.call(arguments);e.postMessage({targetName:"main",action:"console_log",data:t})},error:function(){var t=Array.prototype.slice.call(arguments);e.postMessage({targetName:"main",action:"console_error",data:t})},time:function(e){t[e]=Date.now()},timeEnd:function(e){var n=t[e];if(!n)throw new Error("Unknown timer name "+e);this.log("Timer:",e,Date.now()-n)}};e.console=n}}(),function(){if(f)"console"in window?"bind"in console.log||(console.log=function(t){return function(e){return t(e)}}(console.log),console.error=function(t){return function(e){return t(e)}}(console.error),console.warn=function(t){return function(e){return t(e)}}(console.warn)):window.console={log:function(){},error:function(){},warn:function(){}}}(),function(){function t(t){e(t.target)&&t.stopPropagation()}function e(t){return t.disabled||t.parentNode&&e(t.parentNode)}u&&document.addEventListener("click",t,!0)}(),function(){(l||c)&&(PDFJS.disableCreateObjectURL=!0)}(),function(){"undefined"!=typeof navigator&&("language"in navigator||(PDFJS.locale=navigator.userLanguage||"en-US"))}(),function(){(d||i||o||h)&&(PDFJS.disableRange=!0,PDFJS.disableStream=!0)}(),function(){f&&(history.pushState&&!i||(PDFJS.disableHistory=!0))}(),function(){if(f)if(window.CanvasPixelArray)"function"!=typeof window.CanvasPixelArray.prototype.set&&(window.CanvasPixelArray.prototype.set=function(t){for(var e=0,n=this.length;e0;){var n=this.handlers.shift(),r=n.thisPromise._status,i=n.thisPromise._value;try{1===r?"function"==typeof n.onResolve&&(i=n.onResolve(i)):"function"==typeof n.onReject&&(i=n.onReject(i),r=1,n.thisPromise._unhandledRejection&&this.removeUnhandeledRejection(n.thisPromise))}catch(e){r=t,i=e}if(n.nextPromise._updateStatus(r,i),Date.now()>=e)break}if(this.handlers.length>0)return void setTimeout(this.runHandlers.bind(this),0);this.running=!1},addUnhandledRejection:function(t){this.unhandledRejections.push({promise:t,time:Date.now()}),this.scheduleRejectionCheck()},removeUnhandeledRejection:function(t){t._unhandledRejection=!1;for(var e=0;e500){var n=this.unhandledRejections[e].promise._value,r="Unhandled rejection: "+n;n.stack&&(r+="\n"+n.stack);try{throw new Error(r)}catch(t){console.warn(r)}this.unhandledRejections.splice(e),e--}this.unhandledRejections.length&&this.scheduleRejectionCheck()}.bind(this),500))}},r=function(t){this._status=0,this._handlers=[];try{t.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(t){this._reject(t)}};r.all=function(e){function n(e){s._status!==t&&(c=[],a(e))}var i,a,s=new r(function(t,e){i=t,a=e}),o=e.length,c=[];if(0===o)return i(c),s;for(var l=0,h=e.length;l32&&e<127&&-1===[34,35,60,62,63,96].indexOf(e)?t:encodeURIComponent(t)}function a(t){var e=t.charCodeAt(0);return e>32&&e<127&&-1===[34,35,60,62,96].indexOf(e)?t:encodeURIComponent(t)}function s(e,s,o){function c(t){b.push(t)}var l=s||"scheme start",h=0,m="",A=!1,v=!1,b=[];t:for(;(e[h-1]!==f||0===h)&&!this._isInvalid;){var y=e[h];switch(l){case"scheme start":if(!y||!p.test(y)){if(s){c("Invalid scheme.");break t}m="",l="no scheme";continue}m+=y.toLowerCase(),l="scheme";break;case"scheme":if(y&&g.test(y))m+=y.toLowerCase();else{if(":"!==y){if(s){if(y===f)break t;c("Code point not allowed in scheme: "+y);break t}m="",h=0,l="no scheme";continue}if(this._scheme=m,m="",s)break t;t(this._scheme)&&(this._isRelative=!0),l="file"===this._scheme?"relative":this._isRelative&&o&&o._scheme===this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":"?"===y?(this._query="?",l="query"):"#"===y?(this._fragment="#",l="fragment"):y!==f&&"\t"!==y&&"\n"!==y&&"\r"!==y&&(this._schemeData+=i(y));break;case"no scheme":if(o&&t(o._scheme)){l="relative";continue}c("Missing scheme."),n.call(this);break;case"relative or authority":if("/"!==y||"/"!==e[h+1]){c("Expected /, got: "+y),l="relative";continue}l="authority ignore slashes";break;case"relative":if(this._isRelative=!0,"file"!==this._scheme&&(this._scheme=o._scheme),y===f){this._host=o._host,this._port=o._port,this._path=o._path.slice(),this._query=o._query,this._username=o._username,this._password=o._password;break t}if("/"===y||"\\"===y)"\\"===y&&c("\\ is an invalid code point."),l="relative slash";else if("?"===y)this._host=o._host,this._port=o._port,this._path=o._path.slice(),this._query="?",this._username=o._username,this._password=o._password,l="query";else{if("#"!==y){var x=e[h+1],S=e[h+2];("file"!==this._scheme||!p.test(y)||":"!==x&&"|"!==x||S!==f&&"/"!==S&&"\\"!==S&&"?"!==S&&"#"!==S)&&(this._host=o._host,this._port=o._port,this._username=o._username,this._password=o._password,this._path=o._path.slice(),this._path.pop()),l="relative path";continue}this._host=o._host,this._port=o._port,this._path=o._path.slice(),this._query=o._query,this._fragment="#",this._username=o._username,this._password=o._password,l="fragment"}break;case"relative slash":if("/"!==y&&"\\"!==y){"file"!==this._scheme&&(this._host=o._host,this._port=o._port,this._username=o._username,this._password=o._password),l="relative path";continue}"\\"===y&&c("\\ is an invalid code point."),l="file"===this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!==y){c("Expected '/', got: "+y),l="authority ignore slashes";continue}l="authority second slash";break;case"authority second slash":if(l="authority ignore slashes","/"!==y){c("Expected '/', got: "+y);continue}break;case"authority ignore slashes":if("/"!==y&&"\\"!==y){l="authority";continue}c("Expected authority, got: "+y);break;case"authority":if("@"===y){A&&(c("@ already seen."),m+="%40"),A=!0;for(var w=0;w 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - - -/***/ }), - -/***/ 1: -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/* Copyright 2017 Mozilla Foundation +/* Copyright 2017 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -284,7 +14,7 @@ process.umask = function() { return 0; }; */ (function webpackUniversalModuleDefinition(root, factory) { - if(true) + if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("pdfjs-dist/build/pdf.worker", [], factory); @@ -38605,35 +38335,4 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) { /***/ }) /******/ ]); -}); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) - -/***/ }), - -/***/ 24: -/***/ (function(module, exports, __webpack_require__) { - -/* Copyright 2016 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* eslint-disable strict */ - -(typeof window !== 'undefined' ? window : {}).pdfjsDistBuildPdfWorker = - __webpack_require__(1); - - -/***/ }) - -/******/ }); }); \ No newline at end of file diff --git a/vendor/assets/javascripts/pdf.worker.min.js b/vendor/assets/javascripts/pdf.worker.min.js new file mode 100755 index 00000000000..3503a8f46ca --- /dev/null +++ b/vendor/assets/javascripts/pdf.worker.min.js @@ -0,0 +1,19 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf.worker",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf.worker"]=t():e["pdfjs-dist/build/pdf.worker"]=e.pdfjsDistBuildPdfWorker=t()}(this,function(){return function(e){function t(r){if(a[r])return a[r].exports;var i=a[r]={i:r,l:!1,exports:{}};e[r].call(i.exports,i,i.exports,t);i.l=!0;return i.exports}var a={};t.m=e;t.c=a;t.i=function(e){return e};t.d=function(e,a,r){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:r})};t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};t.d(a,"a",a);return a};t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};t.p="";return t(t.s=36)}([function(e,t,a){"use strict";(function(e){function r(e){ae=e}function i(){return ae}function n(e){ae>=$.infos&&console.log("Info: "+e)}function s(e){ae>=$.warnings&&console.log("Warning: "+e)}function o(e){console.log("Deprecated API usage: "+e)}function c(e){if(ae>=$.errors){console.log("Error: "+e);console.log(l())}throw new Error(e)}function l(){try{throw new Error}catch(e){return e.stack?e.stack.split("\n").slice(2).join("\n"):""}}function h(e,t){e||c(t)}function u(e,t){try{var a=new URL(e);if(!a.origin||"null"===a.origin)return!1}catch(e){return!1}var r=new URL(t,a);return a.origin===r.origin}function f(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function d(e,t){if(!e)return null;try{var a=t?new URL(e,t):new URL(e);if(f(a))return a}catch(e){}return null}function g(e,t,a){Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!1});return a}function p(e){var t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}}function m(e){if("string"!=typeof e){s("The argument for removeNullCharacters must be a string.");return e}return e.replace(de,"")}function b(e){h(null!==e&&"object"==typeof e&&void 0!==e.length,"Invalid argument for bytesToString");var t=e.length;if(t<8192)return String.fromCharCode.apply(null,e);for(var a=[],r=0;r>24&255,e>>16&255,e>>8&255,255&e)}function C(e){for(var t=1,a=0;e>t;){t<<=1;a++}return a}function x(e,t){return e[t]<<24>>24}function S(e,t){return e[t]<<8|e[t+1]}function A(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function I(){var e=new Uint8Array(2);e[0]=1;return 1===new Uint16Array(e.buffer)[0]}function B(){try{new Function("");return!0}catch(e){return!1}}function R(e){var t,a=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(t=2;t>2:t;a(this.length)}function t(e){return{get:function(){var t=this.buffer,a=e<<2;return(t[a]|t[a+1]<<8|t[a+2]<<16|t[a+3]<<24)>>>0},set:function(t){var a=this.buffer,r=e<<2;a[r]=255&t;a[r+1]=t>>8&255;a[r+2]=t>>16&255;a[r+3]=t>>>24&255}}}function a(a){for(;re[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t};e.intersect=function(t,a){function r(e,t){return e-t}var i=[t[0],t[2],a[0],a[2]].sort(r),n=[t[1],t[3],a[1],a[3]].sort(r),s=[];t=e.normalizeRect(t);a=e.normalizeRect(a);if(!(i[0]===t[0]&&i[1]===a[0]||i[0]===a[0]&&i[1]===t[0]))return!1;s[0]=i[1];s[2]=i[2];if(!(n[0]===t[1]&&n[1]===a[1]||n[0]===a[1]&&n[1]===t[1]))return!1;s[1]=n[1];s[3]=n[2];return s};e.sign=function(e){return e<0?-1:1};var a=["","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"];e.toRoman=function(e,t){h(E(e)&&e>0,"The number should be a positive integer.");for(var r,i=[];e>=1e3;){e-=1e3;i.push("M")}r=e/100|0;e%=100;i.push(a[r]);r=e/10|0;e%=10;i.push(a[10+r]);i.push(a[20+e]);var n=i.join("");return t?n.toLowerCase():n};e.appendToArray=function(e,t){Array.prototype.push.apply(e,t)};e.prependToArray=function(e,t){Array.prototype.unshift.apply(e,t)};e.extendObj=function(e,t){for(var a in t)e[a]=t[a]};e.getInheritableProperty=function(e,t,a){for(;e&&!e.has(t);)e=e.get("Parent");return e?a?e.getArray(t):e.get(t):null};e.inherit=function(e,t,a){e.prototype=Object.create(t.prototype);e.prototype.constructor=e;for(var r in a)e.prototype[r]=a[r]};e.loadScript=function(e,t){var a=document.createElement("script"),r=!1;a.setAttribute("src",e);t&&(a.onload=function(){r||t();r=!0});document.getElementsByTagName("head")[0].appendChild(a)};return e}(),be=function(){function e(e,t,a,r,i,n){this.viewBox=e;this.scale=t;this.rotation=a;this.offsetX=r;this.offsetY=i;var s,o,c,l,h=(e[2]+e[0])/2,u=(e[3]+e[1])/2;a%=360;a=a<0?a+360:a;switch(a){case 180:s=-1;o=0;c=0;l=1;break;case 90:s=0;o=1;c=1;l=0;break;case 270:s=0;o=-1;c=-1;l=0;break;default:s=1;o=0;c=0;l=-1}if(n){c=-c;l=-l}var f,d,g,p;if(0===s){f=Math.abs(u-e[1])*t+r;d=Math.abs(h-e[0])*t+i;g=Math.abs(e[3]-e[1])*t;p=Math.abs(e[2]-e[0])*t}else{f=Math.abs(h-e[0])*t+r;d=Math.abs(u-e[1])*t+i;g=Math.abs(e[2]-e[0])*t;p=Math.abs(e[3]-e[1])*t}this.transform=[s*t,o*t,c*t,l*t,f-s*t*h-c*t*u,d-o*t*h-l*t*u];this.width=g;this.height=p;this.fontScale=t}e.prototype={clone:function(t){t=t||{};var a="scale"in t?t.scale:this.scale,r="rotation"in t?t.rotation:this.rotation;return new e(this.viewBox.slice(),a,r,this.offsetX,this.offsetY,t.dontFlip)},convertToViewportPoint:function(e,t){return me.applyTransform([e,t],this.transform)},convertToViewportRectangle:function(e){var t=me.applyTransform([e[0],e[1]],this.transform),a=me.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],a[0],a[1]]},convertToPdfPoint:function(e,t){return me.applyInverseTransform([e,t],this.transform)}};return e}(),ve=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,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,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364],ye=function(){function e(e,t,a){for(;e.lengthn&&(n=s.length)}for(t=0,a=r.length;t>2,f=(3&c)<<4|l>>4,d=s+1>6:64,g=s+2=this.end?-1:this.bytes[this.pos++]},getUint16:function(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()},getBytes:function(e){var t=this.bytes,a=this.pos,r=this.end;if(!e)return t.subarray(a,r);var i=a+e;i>r&&(i=r);this.pos=i;return t.subarray(a,i)},peekByte:function(){var e=this.getByte();this.pos--;return e},peekBytes:function(e){var t=this.getBytes(e);this.pos-=t.length;return t},skip:function(e){e||(e=1);this.pos+=e},reset:function(){this.pos=this.start},moveStart:function(){this.start=this.pos},makeSubStream:function(t,a,r){return new e(this.bytes.buffer,t,a,r)}};return e}(),x=function(){function e(e){for(var t=e.length,a=new Uint8Array(t),r=0;rr&&(t=r)}else{for(;!this.eof;)this.readBlock();t=this.bufferLength}this.pos=t;return this.buffer.subarray(a,t)},peekByte:function(){var e=this.getByte();this.pos--;return e},peekBytes:function(e){var t=this.getBytes(e);this.pos-=t.length;return t},makeSubStream:function(e,t,a){for(var r=e+t;this.bufferLength<=r&&!this.eof;)this.readBlock();return new C(this.buffer,e,t,a)},skip:function(e){e||(e=1);this.pos+=e},reset:function(){this.pos=0},getBaseStreams:function(){return this.str&&this.str.getBaseStreams?this.str.getBaseStreams():[]}};return e}(),A=function(){function e(e){this.streams=e;S.call(this,null)}e.prototype=Object.create(S.prototype);e.prototype.readBlock=function(){var e=this.streams;if(0!==e.length){var t=e.shift(),a=t.getBytes(),r=this.bufferLength,i=r+a.length;this.ensureBuffer(i).set(a,r);this.bufferLength=i}else this.eof=!0};e.prototype.getBaseStreams=function(){for(var e=[],t=0,a=this.streams.length;t>e;this.codeSize=r-=e;return t};e.prototype.getCode=function(e){for(var t,a=this.str,r=e[0],i=e[1],n=this.codeSize,s=this.codeBuf;n>16,h=65535&o;(c<1||n>c;this.codeSize=n-c;return h};e.prototype.generateHuffmanTable=function(e){var t,a=e.length,r=0;for(t=0;tr&&(r=e[t]);for(var i=1<>=1}for(t=h;t>=1;if(0!==c){var h,u;if(1===c){h=i;u=n}else if(2===c){var f,d=this.getBits(5)+257,g=this.getBits(5)+1,p=this.getBits(4)+4,m=new Uint8Array(t.length);for(f=0;f0;)C[f++]=k}h=this.generateHuffmanTable(C.subarray(0,d));u=this.generateHuffmanTable(C.subarray(d,w))}else l("Unknown block type in flate stream");e=this.buffer;for(var A=e?e.length:0,I=this.bufferLength;;){var B=this.getCode(h);if(B<256){if(I+1>=A){e=this.ensureBuffer(I+1);A=e.length}e[I++]=B}else{if(256===B){this.bufferLength=I;return}B-=257;B=a[B];var R=B>>16;R>0&&(R=this.getBits(R));s=(65535&B)+R;B=this.getCode(u);B=r[B];R=B>>16;R>0&&(R=this.getBits(R));var T=(65535&B)+R;if(I+s>=A){e=this.ensureBuffer(I+s);A=e.length}for(var O=0;O15)&&l("Unsupported predictor: "+r);this.readBlock=2===r?this.readBlockTiff:this.readBlockPng;this.str=e;this.dict=e.dict;var i=this.colors=a.get("Colors")||1,n=this.bits=a.get("BitsPerComponent")||8,s=this.columns=a.get("Columns")||1;this.pixBytes=i*n+7>>3;this.rowBytes=s*i*n+7>>3;S.call(this,t);return this}e.prototype=Object.create(S.prototype) +;e.prototype.readBlockTiff=function(){var e=this.rowBytes,t=this.bufferLength,a=this.ensureBuffer(t+e),r=this.bits,i=this.colors,n=this.str.getBytes(e);this.eof=!n.length;if(!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===r&&1===i)for(s=0;s>1;f^=f>>2;f^=f>>4;o=(1&f)<<7;a[u++]=f}else if(8===r){for(s=0;s>l-r)&g;l-=r;c=c<=8){a[m++]=c>>h-8&255;h-=8}}h>0&&(a[m++]=(c<<8-h)+(o&(1<<8-h)-1))}this.bufferLength+=e}};e.prototype.readBlockPng=function(){var e=this.rowBytes,t=this.pixBytes,a=this.str.getByte(),r=this.str.getBytes(e);this.eof=!r.length;if(!this.eof){var i=this.bufferLength,n=this.ensureBuffer(i+e),s=n.subarray(i-e,i);0===s.length&&(s=new Uint8Array(e));var o,c,h,u=i;switch(a){case 0:for(o=0;o>1)+r[o];for(;o>1)+r[o]&255;u++}break;case 4:for(o=0;o0;e=(0,this.decrypt)(e,!t);var a,r=this.bufferLength,i=e.length,n=this.ensureBuffer(r+i);for(a=0;a=0;--r){a[i+r]=255&s;s>>=8}}}else this.eof=!0};return e}(),E=function(){function e(e,t){this.str=e;this.dict=e.dict;this.firstDigit=-1;t&&(t*=.5);S.call(this,t)}e.prototype=Object.create(S.prototype);e.prototype.readBlock=function(){var e=this.str.getBytes(8e3);if(e.length){for(var t=e.length+1>>1,a=this.ensureBuffer(this.bufferLength+t),r=this.bufferLength,i=this.firstDigit,n=0,s=e.length;n=48&&c<=57)o=15&c;else{if(!(c>=65&&c<=70||c>=97&&c<=102)){if(62===c){this.eof=!0;break}continue}o=9+(15&c)}if(i<0)i=o;else{a[r++]=i<<4|o;i=-1}}if(i>=0&&this.eof){a[r++]=i<<4;i=-1}this.firstDigit=i;this.bufferLength=r}else this.eof=!0};return e}(),L=function(){function e(e,t){this.str=e;this.dict=e.dict;S.call(this,t)}e.prototype=Object.create(S.prototype);e.prototype.readBlock=function(){var e=this.str.getBytes(2);if(!e||e.length<2||128===e[0])this.eof=!0;else{var t,a=this.bufferLength,r=e[0];if(r<128){t=this.ensureBuffer(a+r+1);t[a++]=e[1];if(r>0){var i=this.str.getBytes(r);t.set(i,a);a+=r}}else{r=257-r;var n=e[1];t=this.ensureBuffer(a+r+1);for(var s=0;s0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}S.call(this,t)}var t=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],a=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],r=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],i=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],n=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],s=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];e.prototype=Object.create(S.prototype);e.prototype.readBlock=function(){for(;!this.eof;){var e=this.lookChar();this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=e}};e.prototype.addPixels=function(e,t){var a=this.codingLine,r=this.codingPos;if(e>a[r]){if(e>this.columns){h("row is wrong length");this.err=!0;e=this.columns}1&r^t&&++r;a[r]=e}this.codingPos=r};e.prototype.addPixelsNeg=function(e,t){var a=this.codingLine,r=this.codingPos;if(e>a[r]){if(e>this.columns){h("row is wrong length");this.err=!0;e=this.columns}1&r^t&&++r;a[r]=e}else if(e0&&e=64);do{c+=l=this.getWhiteCode()}while(l>=64)}else{do{o+=l=this.getWhiteCode()}while(l>=64);do{c+=l=this.getBlackCode()}while(l>=64)}this.addPixels(n[this.codingPos]+o,t);n[this.codingPos]0?--e:++e;for(;i[e]<=n[this.codingPos]&&i[e]0?--e:++e;for(;i[e]<=n[this.codingPos]&&i[e]0?--e:++e;for(;i[e]<=n[this.codingPos]&&i[e]=64);else do{o+=l=this.getWhiteCode()}while(l>=64);this.addPixels(n[this.codingPos]+o,t);t^=1}}var u=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){o=this.lookBits(12);if(this.eoline)for(;-1!==o&&1!==o;){this.eatBits(1);o=this.lookBits(12)}else for(;0===o;){this.eatBits(1);o=this.lookBits(12)}if(1===o){this.eatBits(12);u=!0}else-1===o&&(this.eof=!0)}else this.eof=!0;if(!this.eof&&this.encoding>0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}if(this.eoblock&&u&&this.byteAlign){o=this.lookBits(12);if(1===o){this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}if(this.encoding>=0)for(r=0;r<4;++r){o=this.lookBits(12);1!==o&&h("bad rtc code: "+o);this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){o=this.lookBits(13);if(-1===o){this.eof=!0;return null}if(o>>1==1)break;this.eatBits(1)}this.eatBits(12);if(this.encoding>0){this.eatBits(1);this.nextLine2D=!(1&o)}}n[0]>0?this.outputBits=n[this.codingPos=0]:this.outputBits=n[this.codingPos=1];this.row++}var f;if(this.outputBits>=8){f=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&n[this.codingPos]a){f<<=a;1&this.codingPos||(f|=255>>8-a);this.outputBits-=a;a=0}else{f<<=this.outputBits;1&this.codingPos||(f|=255>>8-this.outputBits);a-=this.outputBits;this.outputBits=0;if(n[this.codingPos]0){f<<=a;a=0}}}while(a)}this.black&&(f^=255);return f};e.prototype.findTableCode=function(e,t,a,r){for(var i=r||0,n=e;n<=t;++n){var s=this.lookBits(n);if(-1===s)return[!0,1,!1];n=i){var o=a[s-i];if(o[0]===n){this.eatBits(n);return[!0,o[1],!0]}}}return[!1,0,!1]};e.prototype.getTwoDimCode=function(){var e,a=0;if(this.eoblock){a=this.lookBits(7);e=t[a];if(e&&e[0]>0){this.eatBits(e[0]);return e[1]}}else{var r=this.findTableCode(1,7,t);if(r[0]&&r[2])return r[1]}h("Bad two dim code");return-1};e.prototype.getWhiteCode=function(){var e,t=0;if(this.eoblock){t=this.lookBits(12);if(-1===t)return 1;e=t>>5==0?a[t]:r[t>>3];if(e[0]>0){this.eatBits(e[0]);return e[1]}}else{var i=this.findTableCode(1,9,r);if(i[0])return i[1];i=this.findTableCode(11,12,a);if(i[0])return i[1]}h("bad white code");this.eatBits(1);return 1};e.prototype.getBlackCode=function(){var e,t;if(this.eoblock){e=this.lookBits(13);if(-1===e)return 1;t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?n[(e>>1)-64]:s[e>>7];if(t[0]>0){this.eatBits(t[0]);return t[1]}}else{var a=this.findTableCode(2,6,s);if(a[0])return a[1];a=this.findTableCode(7,12,n,64);if(a[0])return a[1];a=this.findTableCode(10,13,i);if(a[0])return a[1]}h("bad black code");this.eatBits(1);return 1};e.prototype.lookBits=function(e){for(var t;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t;this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e};e.prototype.eatBits=function(e){(this.inputBits-=e)<0&&(this.inputBits=0)};return e}(),F=function(){function e(e,t,a){this.str=e;this.dict=e.dict;this.cachedData=0;this.bitsCached=0;for(var r={earlyChange:a,codeLength:9,nextCode:258,dictionaryValues:new Uint8Array(4096),dictionaryLengths:new Uint16Array(4096),dictionaryPrevCodes:new Uint16Array(4096),currentSequence:new Uint8Array(4096),currentSequenceLength:0},i=0;i<256;++i){r.dictionaryValues[i]=i;r.dictionaryLengths[i]=1}this.lzwState=r;S.call(this,t)}e.prototype=Object.create(S.prototype);e.prototype.readBits=function(e){for(var t=this.bitsCached,a=this.cachedData;t>>t&(1<0;if(b<256){f[0]=b;d=1}else{if(!(b>=258)){if(256===b){h=9;s=258;d=0;continue}this.eof=!0;delete this.lzwState;break}if(b=0;t--){f[t]=o[a];a=l[a]}}else f[d++]=f[0]}if(v){l[s]=u;c[s]=c[u]+1;o[s]=f[0];s++;h=s+n&s+n-1?h:0|Math.min(Math.log(s+n)/.6931471805599453+1,12)}u=b;g+=d;if(rg&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){var m,b=o<=8?new Uint8Array(g):new Uint16Array(g);for(h=0;h255?255:i;a[r]=a[r+1]=a[r+2]=i},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=255/((1<255?255:i;a[r+1]=n<0?0:n>255?255:n;a[r+2]=s<0?0:s>255?255:s},getRgbBuffer:function(e,t,a,r,i,n,s){if(8!==n||0!==s)for(var o=255/((1<255?255:l<0?0:l;r[i+1]=h>255?255:h<0?0:h;r[i+2]=u>255?255:u<0?0:u}function t(){this.name="DeviceCMYK";this.numComps=4;this.defaultColor=new Float32Array(this.numComps);this.defaultColor[3]=1}t.prototype={getRgb:m.prototype.getRgb,getRgbItem:function(t,a,r,i){e(t,a,1,r,i)},getRgbBuffer:function(t,a,r,i,n,s,o){for(var c=1/((1<8?Math.pow((e+16)/116,3):e*w}function l(e,t,a){if(0!==e[0]||0!==e[1]||0!==e[2]){var r=c(0),i=r,n=c(e[0]),s=r,o=c(e[1]),l=r,h=c(e[2]),u=(1-i)/(1-n),f=1-u,d=(1-s)/(1-o),g=1-d,p=(1-l)/(1-h),m=1-p;a[0]=t[0]*u+f;a[1]=t[1]*d+g;a[2]=t[2]*p+m}else{a[0]=t[0];a[1]=t[1];a[2]=t[2]}}function h(e,r,i){if(1!==e[0]||1!==e[2]){var n=i;t(d,r,n);var s=v;a(e,n,s);t(g,s,i)}else{i[0]=r[0];i[1]=r[1];i[2]=r[2]}}function u(e,a,i){var n=i;t(d,a,n);var s=v;r(e,n,s);t(g,s,i)}function f(e,a,r,s,o,c){var f=n(0,1,a[r]*c),d=n(0,1,a[r+1]*c),g=n(0,1,a[r+2]*c),m=Math.pow(f,e.GR),v=Math.pow(d,e.GG),w=Math.pow(g,e.GB),C=e.MXA*m+e.MXB*v+e.MXC*w,x=e.MYA*m+e.MYB*v+e.MYC*w,S=e.MZA*m+e.MZB*v+e.MZC*w,A=y;A[0]=C;A[1]=x;A[2]=S;var I=k;h(e.whitePoint,A,I);var B=y;l(e.blackPoint,I,B);var R=k;u(b,B,R);var T=y;t(p,R,T);var O=i(T[0]),P=i(T[1]),M=i(T[2]);s[o]=Math.round(255*O);s[o+1]=Math.round(255*P);s[o+2]=Math.round(255*M)}var d=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),g=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),p=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]),b=new Float32Array([1,1,1]),v=new Float32Array(3),y=new Float32Array(3),k=new Float32Array(3),w=Math.pow(24/116,3)/8;e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);this.getRgbItem(e,t,a,0);return a},getRgbItem:function(e,t,a,r){f(this,e,t,a,r,1)},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=1/((1<this.amax||this.bmin>this.bmax){o("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}function t(e){var t;t=e>=6/29?e*e*e:108/841*(e-4/29);return t}function a(e,t,a,r){return a+e*(r-a)/t}function r(e,r,i,n,s,o){var c=r[i],l=r[i+1],h=r[i+2];if(!1!==n){c=a(c,n,0,100);l=a(l,n,e.amin,e.amax);h=a(h,n,e.bmin,e.bmax)}l=l>e.amax?e.amax:le.bmax?e.bmax:h=1?255:255*Math.sqrt(u)|0;s[o+1]=f<=0?0:f>=1?255:255*Math.sqrt(f)|0;s[o+2]=d<=0?0:d>=1?255:255*Math.sqrt(d)|0}e.prototype={getRgb:m.prototype.getRgb,getRgbItem:function(e,t,a,i){r(this,e,t,!1,a,i)},getRgbBuffer:function(e,t,a,i,n,s,o){for(var c=(1<>")&&!w(this.buf1);)if(S(this.buf1)){var i=this.buf1.name;this.shift();if(w(this.buf1))break;r.set(i,this.getObj(e))}else{h("Malformed dictionary: key must be a name object");this.shift()}if(w(this.buf1)){this.recoveryMode||l("End of file inside dictionary");return r}if(C(this.buf2,"stream"))return this.allowStreams?this.makeStream(r,e):r;this.shift();return r;default:return t}if(f(t)){var n=t;if(f(this.buf1)&&C(this.buf2,"R")){var s=new k(n,this.buf1);this.shift();this.shift();return s}return n}if(g(t)){var o=t;e&&(o=e.decryptString(o));return o}return t},findDefaultInlineStreamEnd:function(e){for(var t,a,r,i,n=e.pos,s=0;-1!==(t=e.getByte());)if(0===s)s=69===t?1:0;else if(1===s)s=73===t?2:0;else{c(2===s);if(32===t||10===t||13===t){r=5;i=e.peekBytes(r);for(a=0;a127)){s=0;break}}if(2===s)break}else s=0}return e.pos-4-n},findDCTDecodeInlineStreamEnd:function(e){for(var t,a,r,i=e.pos,n=!1;-1!==(t=e.getByte());)if(255===t){switch(e.getByte()){case 0:break;case 255:e.skip(-1);break;case 217:n=!0;break;case 192:case 193:case 194:case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:a=e.getUint16();a>2?e.skip(a-2):e.skip(-2)}if(n)break}r=e.pos-i;if(-1===t){p("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead.");e.skip(-r);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return r},findASCII85DecodeInlineStreamEnd:function(e){for(var t,a,r=e.pos;-1!==(t=e.getByte());)if(126===t&&62===e.peekByte()){e.skip();break}a=e.pos-r;if(-1===t){p("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a},findASCIIHexDecodeInlineStreamEnd:function(e){for(var t,a,r=e.pos;-1!==(t=e.getByte())&&62!==t;);a=e.pos-r;if(-1===t){p("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a},inlineStreamSkipEI:function(e){for(var t,a=0;-1!==(t=e.getByte());)if(0===a)a=69===t?1:0;else if(1===a)a=73===t?2:0;else if(2===a)break},makeInlineImage:function(e){for(var t=this.lexer,a=t.stream,r=new v(this.xref);!C(this.buf1,"ID")&&!w(this.buf1);){S(this.buf1)||l("Dictionary key must be a name object");var i=this.buf1.name;this.shift();if(w(this.buf1))break;r.set(i,this.getObj(e))}var n,s=r.get("Filter","F");if(S(s))n=s.name;else if(u(s)){var o=this.xref.fetchIfRef(s[0]);S(o)&&(n=o.name)}var c,h,f,d=a.pos;c="DCTDecode"===n||"DCT"===n?this.findDCTDecodeInlineStreamEnd(a):"ASCII85Decide"===n||"A85"===n?this.findASCII85DecodeInlineStreamEnd(a):"ASCIIHexDecode"===n||"AHx"===n?this.findASCIIHexDecodeInlineStreamEnd(a):this.findDefaultInlineStreamEnd(a);var g,p=a.makeSubStream(d,c,r);if(c<1e3){var m=p.getBytes();p.reset();var y=1,k=0;for(h=0,f=m.length;h=9){d=!0;break}s++}if(d){u+=s;r.pos+=s;break}u+=p;r.pos+=p}d||l("Missing endstream");n=u;a.nextChar();this.shift();this.shift()}this.shift();r=r.makeSubStream(i,n,e);t&&(r=t.createStream(r,n));r=this.filter(r,e,n);r.dict=e;return r},filter:function(e,t,a){var r=t.get("Filter","F"),i=t.get("DecodeParms","DP");if(S(r)){u(i)&&(i=this.xref.fetchIfRef(i[0]));return this.makeFilter(e,r.name,a,i)}var n=a;if(u(r))for(var s=r,o=i,c=0,h=s.length;c=48&&e<=57?15&e:e>=65&&e<=70||e>=97&&e<=102?9+(15&e):-1}var a=[1,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,2,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,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,2,0,2,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,2,0,2,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,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];e.prototype={nextChar:function(){return this.currentChar=this.stream.getByte()},peekChar:function(){return this.stream.peekByte()},getNumber:function(){var e=this.currentChar,t=!1,a=0,r=1;if(45===e){r=-1;e=this.nextChar();45===e&&(e=this.nextChar())}else 43===e&&(e=this.nextChar());if(46===e){a=10;e=this.nextChar()}if(e<48||e>57){l("Invalid number: "+String.fromCharCode(e));return 0}for(var i=e-48,n=0,s=1;(e=this.nextChar())>=0;)if(48<=e&&e<=57){var o=e-48;if(t)n=10*n+o;else{0!==a&&(a*=10);i=10*i+o}}else if(46===e){if(0!==a)break;a=1}else if(45===e)p("Badly formatted number");else{if(69!==e&&101!==e)break;e=this.peekChar();if(43===e||45===e){s=45===e?-1:1;this.nextChar()}else if(e<48||e>57)break;t=!0}0!==a&&(i/=a);t&&(i*=Math.pow(10,s*n));return r*i},getString:function(){var e=1,t=!1,a=this.strBuf;a.length=0;for(var r=this.nextChar();;){var i=!1;switch(0|r){case-1:p("Unterminated string");t=!0;break;case 40:++e;a.push("(");break;case 41:if(0==--e){this.nextChar();t=!0}else a.push(")");break;case 92:r=this.nextChar();switch(r){case-1:p("Unterminated string");t=!0;break;case 110:a.push("\n");break;case 114:a.push("\r");break;case 116:a.push("\t");break;case 98:a.push("\b");break;case 102:a.push("\f");break;case 92:case 40:case 41:a.push(String.fromCharCode(r));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:var n=15&r;r=this.nextChar();i=!0;if(r>=48&&r<=55){n=(n<<3)+(15&r);r=this.nextChar();if(r>=48&&r<=55){i=!1;n=(n<<3)+(15&r)}}a.push(String.fromCharCode(n));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:a.push(String.fromCharCode(r))}break;default:a.push(String.fromCharCode(r))}if(t)break;i||(r=this.nextChar())}return a.join("")},getName:function(){var e,r,i=this.strBuf;i.length=0;for(;(e=this.nextChar())>=0&&!a[e];)if(35===e){e=this.nextChar();if(a[e]){p("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number.");i.push("#");break}var n=t(e);if(-1!==n){r=e;e=this.nextChar();var s=t(e);if(-1===s){p("Lexer_getName: Illegal digit ("+String.fromCharCode(e)+") in hexadecimal number.");i.push("#",String.fromCharCode(r));if(a[e])break;i.push(String.fromCharCode(e));continue}i.push(String.fromCharCode(n<<4|s))}else i.push("#",String.fromCharCode(e))}else i.push(String.fromCharCode(e));i.length>127&&p("name token is longer than allowed by the spec: "+i.length);return y.get(i.join(""))},getHexString:function(){var e=this.strBuf;e.length=0;for(var r,i,n=this.currentChar,s=!0;;){if(n<0){p("Unterminated hex string");break}if(62===n){this.nextChar();break}if(1!==a[n]){if(s){r=t(n);if(-1===r){p('Ignoring invalid character "'+n+'" in hex string');n=this.nextChar();continue}}else{i=t(n);if(-1===i){p('Ignoring invalid character "'+n+'" in hex string');n=this.nextChar();continue}e.push(String.fromCharCode(r<<4|i))}s=!s;n=this.nextChar()}else n=this.nextChar()}return e.join("")},getObj:function(){for(var e=!1,t=this.currentChar;;){if(t<0)return m;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(1!==a[t])break;t=this.nextChar()}switch(0|t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:this.nextChar();return b.get("[");case 93:this.nextChar();return b.get("]");case 60:t=this.nextChar();if(60===t){this.nextChar();return b.get("<<")}return this.getHexString();case 62:t=this.nextChar();if(62===t){this.nextChar();return b.get(">>")} +return b.get(">");case 123:this.nextChar();return b.get("{");case 125:this.nextChar();return b.get("}");case 41:this.nextChar();l("Illegal character: "+t)}for(var r=String.fromCharCode(t),i=this.knownCommands,n=i&&void 0!==i[r];(t=this.nextChar())>=0&&!a[t];){var s=r+String.fromCharCode(t);if(n&&void 0===i[s])break;128===r.length&&l("Command token too long: "+r.length);r=s;n=i&&void 0!==i[r]}return"true"===r||"false"!==r&&("null"===r?null:b.get(r))},skipToNextLine:function(){for(var e=this.currentChar;e>=0;){if(13===e){e=this.nextChar();10===e&&this.nextChar();break}if(10===e){this.nextChar();break}e=this.nextChar()}}};return e}(),U={create:function(e){function t(e,t){var a=c.get(e);if(f(a)&&(t?a>=0:a>0))return a;throw new Error('The "'+e+'" parameter in the linearization dictionary is invalid.')}var a,r,i=new F(new q(e),!1,null),n=i.getObj(),s=i.getObj(),o=i.getObj(),c=i.getObj();if(!(f(n)&&f(s)&&C(o,"obj")&&x(c)&&d(a=c.get("Linearized"))&&a>0))return null;if((r=t("L"))!==e.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:r,hints:function(){var e,t,a=c.get("H");if(u(a)&&(2===(e=a.length)||4===e)){for(var r=0;r0))throw new Error("Hint ("+r+") in the linearization dictionary is invalid.");return a}throw new Error("Hint array in the linearization dictionary is invalid.")}(),objectNumberFirst:t("O"),endFirst:t("E"),numPages:t("N"),mainXRefEntriesOffset:t("T"),pageFirst:c.has("P")?t("P",!0):0}}};t.Lexer=q;t.Linearization=U;t.Parser=F},function(e,t,a){"use strict";function r(e){var t;if("object"!=typeof e)return!1;if(u(e))t=e;else{if(!f(e))return!1;t=e.dict}return t.has("FunctionType")}var i=a(0),n=a(1),s=a(34),o=i.error,c=i.info,l=i.isArray,h=i.isBool,u=n.isDict,f=n.isStream,d=s.PostScriptLexer,g=s.PostScriptParser,p=function(){return{getSampleArray:function(e,t,a,r){var i,n,s=1;for(i=0,n=e.length;i>c)*h;l&=(1<a?e=a:e0&&(f=a[h-1]);var d=t[1];h>1,s=t.length>>1,o=new b(r),l=Object.create(null),h=8192,u=new Float32Array(s);return function(e,t,r,i){var c,f,d="",g=u;for(c=0;cy&&(f=y)}m[c]=f}if(h>0){h--;l[d]=m}r.set(m,i)}else r.set(p,i)}}}}(),m=function(){function e(e){this.stack=e?Array.prototype.slice.call(e,0):[]}e.prototype={push:function(e){this.stack.length>=100&&o("PostScript function stack overflow.");this.stack.push(e)},pop:function(){this.stack.length<=0&&o("PostScript function stack underflow.");return this.stack.pop()},copy:function(e){this.stack.length+e>=100&&o("PostScript function stack overflow.");for(var t=this.stack,a=t.length-e,r=e-1;r>=0;r--,a++)t.push(t[a])},index:function(e){this.push(this.stack[this.stack.length-e-1])},roll:function(e,t){var a,r,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(a=s,r=o;a0?i.push(a<>r);break;case"ceiling":a=i.pop();i.push(Math.ceil(a));break;case"copy":a=i.pop();i.copy(a);break;case"cos":a=i.pop();i.push(Math.cos(a));break;case"cvi":a=0|i.pop();i.push(a);break;case"cvr":break;case"div":r=i.pop();a=i.pop();i.push(a/r);break;case"dup":i.copy(1);break;case"eq":r=i.pop();a=i.pop();i.push(a===r);break;case"exch":i.roll(2,1);break;case"exp":r=i.pop();a=i.pop();i.push(Math.pow(a,r));break;case"false":i.push(!1);break;case"floor":a=i.pop();i.push(Math.floor(a));break;case"ge":r=i.pop();a=i.pop();i.push(a>=r);break;case"gt":r=i.pop();a=i.pop();i.push(a>r);break;case"idiv":r=i.pop();a=i.pop();i.push(a/r|0);break;case"index":a=i.pop();i.index(a);break;case"le":r=i.pop();a=i.pop();i.push(a<=r);break;case"ln":a=i.pop();i.push(Math.log(a));break;case"log":a=i.pop();i.push(Math.log(a)/Math.LN10);break;case"lt":r=i.pop();a=i.pop();i.push(a=t?new a(t):e.max<=t?e:new i(e,t)}function f(){}e.prototype.visit=function(e){throw new Error("abstract method")};t.prototype=Object.create(e.prototype);t.prototype.visit=function(e){e.visitArgument(this)};a.prototype=Object.create(e.prototype);a.prototype.visit=function(e){e.visitLiteral(this)};r.prototype=Object.create(e.prototype);r.prototype.visit=function(e){e.visitBinaryOperation(this)};i.prototype=Object.create(e.prototype);i.prototype.visit=function(e){e.visitMin(this)};n.prototype=Object.create(e.prototype);n.prototype.visit=function(e){e.visitVariable(this)};s.prototype=Object.create(e.prototype);s.prototype.visit=function(e){e.visitVariableDefinition(this)};o.prototype={visitArgument:function(e){this.parts.push("Math.max(",e.min,", Math.min(",e.max,", src[srcOffset + ",e.index,"]))")},visitVariable:function(e){this.parts.push("v",e.index)},visitLiteral:function(e){this.parts.push(e.number)},visitBinaryOperation:function(e){this.parts.push("(");e.arg1.visit(this);this.parts.push(" ",e.op," ");e.arg2.visit(this);this.parts.push(")")},visitVariableDefinition:function(e){this.parts.push("var ");e.variable.visit(this);this.parts.push(" = ");e.arg.visit(this);this.parts.push(";")},visitMin:function(e){this.parts.push("Math.min(");e.arg.visit(this);this.parts.push(", ",e.max,")")},toString:function(){return this.parts.join("")}};f.prototype={compile:function(e,r,i){var f,d,g,p,m,b,v,y,k,w,C=[],x=[],S=r.length>>1,A=i.length>>1,I=0;for(f=0;fe.min){s.unshift("Math.max(",r,", ");s.push(")")}if(n0&&this._queuedChunks.push(a);this._msgHandler=t;this._isRangeSupported=!e.disableRange;this._isStreamingSupported=!e.disableStream;this._contentLength=e.length;this._fullRequestReader=null;this._rangeReaders=[];t.on("OnDataRange",this._onReceiveData.bind(this));t.on("OnDataProgress",this._onProgress.bind(this))}function t(e,t){this._stream=e;this._done=!1;this._queuedChunks=t||[];this._requests=[];this._headersReady=Promise.resolve();e._fullRequestReader=this;this.onProgress=null}function a(e,t,a){this._stream=e;this._begin=t;this._end=a;this._queuedChunk=null;this._requests=[];this._done=!1;this.onProgress=null}e.prototype={_onReceiveData:function(e){if(void 0===e.begin)this._fullRequestReader?this._fullRequestReader._enqueue(e.chunk):this._queuedChunks.push(e.chunk);else{var t=this._rangeReaders.some(function(t){if(t._begin!==e.begin)return!1;t._enqueue(e.chunk);return!0});v(t)}},_onProgress:function(e){if(this._rangeReaders.length>0){var t=this._rangeReaders[0];t.onProgress&&t.onProgress({loaded:e.loaded})}},_removeRangeReader:function(e){var t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)},getFullReader:function(){v(!this._fullRequestReader);var e=this._queuedChunks;this._queuedChunks=null;return new t(this,e)},getRangeReader:function(e,t){var r=new a(this,e,t);this._msgHandler.send("RequestDataRange",{begin:e,end:t});this._rangeReaders.push(r);return r},cancelAllRequests:function(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeReaders.slice(0).forEach(function(t){t.cancel(e)})}};t.prototype={_enqueue:function(e){if(!this._done)if(this._requests.length>0){var t=this._requests.shift();t.resolve({value:e,done:!1})}else this._queuedChunks.push(e)},get headersReady(){return this._headersReady},get isRangeSupported(){return this._stream._isRangeSupported},get isStreamingSupported(){return this._stream._isStreamingSupported},get contentLength(){return this._stream._contentLength},read:function(){if(this._queuedChunks.length>0){var e=this._queuedChunks.shift();return Promise.resolve({value:e,done:!1})}if(this._done)return Promise.resolve({value:void 0,done:!0});var t=y();this._requests.push(t);return t.promise},cancel:function(e){this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[]}};a.prototype={_enqueue:function(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[]}this._done=!0;this._stream._removeRangeReader(this)}},get isStreamingSupported(){return!1},read:function(){if(this._queuedChunk)return Promise.resolve({value:this._queuedChunk,done:!1});if(this._done)return Promise.resolve({value:void 0,done:!0});var e=y();this._requests.push(e);return e.promise},cancel:function(e){this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._stream._removeRangeReader(this)}};return e}(),T={setup:function(e,t){var a=!1;e.on("test",function(t){if(!a){a=!0;if(t instanceof Uint8Array){var r=255===t[0];e.postMessageTransfers=r;var i=new XMLHttpRequest,n="response"in i;try{i.responseType}catch(e){n=!1}n?e.send("test",{supportTypedArray:!0,supportTransfers:r}):e.send("test",!1)}else e.send("test","main",!1)}});e.on("configure",function(e){C(e.verbosity)});e.on("GetDocRequest",function(e){return T.createDocumentHandler(e,t)})},createDocumentHandler:function(e,t){function a(){if(T)throw new Error("Worker was terminated")}function r(e){P.push(e)}function n(e){e.finish();var t=P.indexOf(e);P.splice(t,1)}function s(e){var t=y(),a=function(){var e=x.ensureDoc("numPages"),a=x.ensureDoc("fingerprint"),i=x.ensureXRef("encrypt");Promise.all([e,a,i]).then(function(e){var a={numPages:e[0],fingerprint:e[1],encrypted:!!e[2]};t.resolve(a)},r)},r=function(e){t.reject(e)};x.ensureDoc("checkHeader",[]).then(function(){x.ensureDoc("parseStartXRef",[]).then(function(){x.ensureDoc("parse",[e]).then(a,r)},r)},r);return t.promise}function o(e,t){var r,n=y(),s=e.source;if(s.data){try{r=new A(M,s.data,s.password,t,E);n.resolve(r)}catch(e){n.reject(e)}return n.promise}var o;try{if(s.chunkedViewerLoading)o=new R(s,D);else{v(i,"pdfjs/core/network module is not loaded");o=new i(e)}}catch(e){n.reject(e);return n.promise}var c=o.getFullReader();c.headersReady.then(function(){c.isStreamingSupported&&c.isRangeSupported||(c.onProgress=function(e){D.send("DocProgress",{loaded:e.loaded,total:e.total})});if(c.isRangeSupported){var e=s.disableAutoFetch||c.isStreamingSupported;r=new I(M,o,{msgHandler:D,url:s.url,password:s.password,length:c.contentLength,disableAutoFetch:e,rangeChunkSize:s.rangeChunkSize},t,E);n.resolve(r);O=null}}).catch(function(e){n.reject(e);O=null});var l=[],h=0,u=function(){var e=b(l);s.length&&e.length!==s.length&&w("reported HTTP length is different from actual");try{r=new A(M,e,s.password,t,E);n.resolve(r)}catch(e){n.reject(e)}l=[]};new Promise(function(e,t){var i=function(e){try{a();if(e.done){r||u();O=null;return}var n=e.value;h+=m(n);c.isStreamingSupported||D.send("DocProgress",{loaded:h,total:Math.max(h,c.contentLength||0)});r?r.sendProgressiveData(n):l.push(n);c.read().then(i,t)}catch(e){t(e)}};c.read().then(i,t)}).catch(function(e){n.reject(e);O=null});O=function(){o.cancelAllRequests("abort")};return n.promise}function C(e){function t(e){a();D.send("GetDoc",{pdfInfo:e})}function i(e){if(e instanceof d){var t=new B("PasswordException: response "+e.code);r(t);D.sendWithPromise("PasswordRequest",e).then(function(e){n(t);x.updatePassword(e.password);c()}).catch(function(e){n(t);D.send("PasswordException",e)}.bind(null,e))}else e instanceof l?D.send("InvalidPDF",e):e instanceof u?D.send("MissingPDF",e):e instanceof f?D.send("UnexpectedResponse",e):D.send("UnknownError",new g(e.message,e.toString()))}function c(){a();s(!1).then(t,function(e){a();if(e instanceof p){x.requestLoadedStream();x.onLoadedStream().then(function(){a();s(!0).then(t,i)})}else i(e)},i)}a();o(e,{forceDataSchema:e.disableCreateObjectURL,maxImageSize:void 0===e.maxImageSize?-1:e.maxImageSize,disableFontFace:e.disableFontFace,disableNativeImageDecoder:e.disableNativeImageDecoder}).then(function(e){if(T){e.terminate();throw new Error("Worker was terminated")}x=e;D.send("PDFManagerReady",null);x.onLoadedStream().then(function(e){D.send("DataLoaded",{length:e.bytes.byteLength})})}).then(c,i)}var x,T=!1,O=null,P=[],M=e.docId,E=e.docBaseUrl,L=e.docId+"_worker",D=new h(L,M,t);D.postMessageTransfers=e.postMessageTransfers;D.on("GetPage",function(e){return x.getPage(e.pageIndex).then(function(e){var t=x.ensure(e,"rotate"),a=x.ensure(e,"ref"),r=x.ensure(e,"userUnit"),i=x.ensure(e,"view");return Promise.all([t,a,r,i]).then(function(e){return{rotate:e[0],ref:e[1],userUnit:e[2],view:e[3]}})})});D.on("GetPageIndex",function(e){var t=new S(e.ref.num,e.ref.gen);return x.pdfDocument.catalog.getPageIndex(t)});D.on("GetDestinations",function(e){return x.ensureCatalog("destinations")});D.on("GetDestination",function(e){return x.ensureCatalog("getDestination",[e.id])});D.on("GetPageLabels",function(e){return x.ensureCatalog("pageLabels")});D.on("GetAttachments",function(e){return x.ensureCatalog("attachments")});D.on("GetJavaScript",function(e){return x.ensureCatalog("javaScript")});D.on("GetOutline",function(e){return x.ensureCatalog("documentOutline")});D.on("GetMetadata",function(e){return Promise.all([x.ensureDoc("documentInfo"),x.ensureCatalog("metadata")])});D.on("GetData",function(e){x.requestLoadedStream();return x.onLoadedStream().then(function(e){return e.bytes})});D.on("GetStats",function(e){return x.pdfDocument.xref.stats});D.on("GetAnnotations",function(e){return x.getPage(e.pageIndex).then(function(t){return x.ensure(t,"getAnnotationsData",[e.intent])})});D.on("RenderPageRequest",function(e){var t=e.pageIndex;x.getPage(t).then(function(a){var i=new B("RenderPageRequest: page "+t);r(i);var s=t+1,o=Date.now();a.getOperatorList(D,i,e.intent,e.renderInteractiveForms).then(function(e){n(i);k("page="+s+" - getOperatorList: time="+(Date.now()-o)+"ms, len="+e.totalLength)},function(t){n(i);if(!i.terminated){D.send("UnsupportedFeature",{featureId:c.unknown});var a,r="worker.js: while trying to getPage() and getOperatorList()";a="string"==typeof t?{message:t,stack:r}:"object"==typeof t?{message:t.message||t.toString(),stack:t.stack||r}:{message:"Unknown exception type: "+typeof t,stack:r};D.send("PageError",{pageNum:s,error:a,intent:e.intent})}})})},this);D.on("GetTextContent",function(e){var t=e.pageIndex,a=e.normalizeWhitespace,i=e.combineTextItems;return x.getPage(t).then(function(e){var s=new B("GetTextContent: page "+t);r(s);var o=t+1,c=Date.now();return e.extractTextContent(D,s,a,i).then(function(e){n(s);k("text indexing: page="+o+" - time="+(Date.now()-c)+"ms");return e},function(e){n(s);if(!s.terminated)throw e})})});D.on("Cleanup",function(e){return x.cleanup()});D.on("Terminate",function(e){T=!0;if(x){x.terminate();x=null}O&&O();var t=[];P.forEach(function(e){t.push(e.finished);e.terminate()});return Promise.all(t).then(function(){D.destroy();D=null})});D.on("Ready",function(t){C(e);e=null});return L}};"undefined"!=typeof window||x()||function(){var e=new h("worker","main",self);T.setup(e,self);e.send("ready",null)}();t.setPDFNetworkStreamClass=r;t.WorkerTask=B;t.WorkerMessageHandler=T},function(e,t,a){"use strict";var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,a){"use strict";var r=function(){function e(e,t,a){this.data=e;this.bp=t;this.dataEnd=a;this.chigh=e[t];this.clow=0;this.byteIn();this.chigh=this.chigh<<7&65535|this.clow>>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}var t=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];e.prototype={byteIn:function(){var e=this.data,t=this.bp;if(255===e[t]){if(e[t+1]>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}}else{t++;this.clow+=t65535){this.chigh+=this.clow>>16;this.clow&=65535}},readBit:function(e,a){var r,i=e[a]>>1,n=1&e[a],s=t[i],o=s.qe,c=this.a-o;if(this.chigh>15&1;this.clow=this.clow<<1&65535;this.ct--}while(0==(32768&c));this.a=c;e[a]=i<<1|n;return r}};return e}();t.ArithmeticDecoder=r},function(e,t,a){"use strict";var r=a(0),i=a(22),n=a(4),s=r.error,o=r.info,c=r.bytesToString,l=r.warn,h=r.isArray,u=r.Util,f=r.stringToBytes,d=r.assert,g=i.ISOAdobeCharset,p=i.ExpertCharset,m=i.ExpertSubsetCharset,b=n.StandardEncoding,v=n.ExpertEncoding,y=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],k=function(){function e(e,t,a){this.bytes=e.getBytes();this.properties=t;this.seacAnalysisEnabled=!!a}var t=[null,{id:"hstem",min:2,stackClearing:!0,stem:!0},null,{id:"vstem",min:2,stackClearing:!0,stem:!0},{id:"vmoveto",min:1,stackClearing:!0},{id:"rlineto",min:2,resetStack:!0},{id:"hlineto",min:1,resetStack:!0},{id:"vlineto",min:1,resetStack:!0},{id:"rrcurveto",min:6,resetStack:!0},null,{id:"callsubr",min:1,undefStack:!0},{id:"return",min:0,undefStack:!0},null,null,{id:"endchar",min:0,stackClearing:!0},null,null,null,{id:"hstemhm",min:2,stackClearing:!0,stem:!0},{id:"hintmask",min:0,stackClearing:!0},{id:"cntrmask",min:0,stackClearing:!0},{id:"rmoveto",min:2,stackClearing:!0},{id:"hmoveto",min:1,stackClearing:!0},{id:"vstemhm",min:2,stackClearing:!0,stem:!0},{id:"rcurveline",min:8,resetStack:!0},{id:"rlinecurve",min:8,resetStack:!0},{id:"vvcurveto",min:4,resetStack:!0},{id:"hhcurveto",min:4,resetStack:!0},null,{id:"callgsubr",min:1,undefStack:!0},{id:"vhcurveto",min:4,resetStack:!0},{id:"hvcurveto",min:4,resetStack:!0}],a=[null,null,null,{id:"and",min:2,stackDelta:-1},{id:"or",min:2,stackDelta:-1},{id:"not",min:1,stackDelta:0},null,null,null,{id:"abs",min:1,stackDelta:0},{id:"add",min:2,stackDelta:-1,stackFn:function(e,t){e[t-2]=e[t-2]+e[t-1]}},{id:"sub",min:2,stackDelta:-1,stackFn:function(e,t){e[t-2]=e[t-2]-e[t-1]}},{id:"div",min:2,stackDelta:-1,stackFn:function(e,t){e[t-2]=e[t-2]/e[t-1]}},null,{id:"neg",min:1,stackDelta:0,stackFn:function(e,t){e[t-1]=-e[t-1]}},{id:"eq",min:2,stackDelta:-1},null,null,{id:"drop",min:1,stackDelta:-1},null,{id:"put",min:2,stackDelta:-2},{id:"get",min:1,stackDelta:0},{id:"ifelse",min:4,stackDelta:-3},{id:"random",min:0,stackDelta:1},{id:"mul",min:2,stackDelta:-1,stackFn:function(e,t){e[t-2]=e[t-2]*e[t-1]}},null,{id:"sqrt",min:1,stackDelta:0},{id:"dup",min:1,stackDelta:1},{id:"exch",min:2,stackDelta:0},{id:"index",min:2,stackDelta:0},{id:"roll",min:3,stackDelta:-2},null,null,null,{id:"hflex",min:7,resetStack:!0},{id:"flex",min:13,resetStack:!0},{id:"hflex1",min:9,resetStack:!0},{id:"flex1",min:11,resetStack:!0}];e.prototype={parse:function(){var e=this.properties,t=new w;this.cff=t;var a=this.parseHeader(),r=this.parseIndex(a.endPos),i=this.parseIndex(r.endPos),n=this.parseIndex(i.endPos),s=this.parseIndex(n.endPos),o=this.parseDict(i.obj.get(0)),c=this.createDict(I,o,t.strings);t.header=a.obj;t.names=this.parseNameIndex(r.obj);t.strings=this.parseStringIndex(n.obj);t.topDict=c;t.globalSubrIndex=s.obj;this.parsePrivateDict(t.topDict);t.isCIDFont=c.hasName("ROS");var l=c.getByName("CharStrings"),h=this.parseIndex(l).obj,u=c.getByName("FontMatrix");u&&(e.fontMatrix=u);var f=c.getByName("FontBBox");if(f){e.ascent=Math.max(f[3],f[1]);e.descent=Math.min(f[1],f[3]);e.ascentScaled=!0}var d,g;if(t.isCIDFont){for(var p=this.parseIndex(c.getByName("FDArray")).obj,m=0,b=p.count;m=t)s("Invalid CFF header");else if(0!==a){o("cff data is shifted");e=e.subarray(a);this.bytes=e}var r=e[0],i=e[1],n=e[2],c=e[3];return{obj:new C(r,i,n,c),endPos:n}},parseDict:function(e){function t(){for(var t="",r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"],i=e.length;a>4,o=15&n;if(15===s)break;t+=r[s];if(15===o)break;t+=r[o]}return parseFloat(t)}var a=0,r=[],i=[];a=0;for(var n=e.length;a>16;return r}if(29===r){r=e[a++];r=r<<8|e[a++];r=r<<8|e[a++];r=r<<8|e[a++];return r}if(r>=32&&r<=246)return r-139;if(r>=247&&r<=250)return 256*(r-247)+e[a++]+108;if(r>=251&&r<=254)return-256*(r-251)-e[a++]-108;l('CFFParser_parseDict: "'+r+'" is a reserved command.');return NaN}())}return i},parseIndex:function(e){var t,a,r=new S,i=this.bytes,n=i[e++]<<8|i[e++],s=[],o=e;if(0!==n){var c=i[e++],l=e+(n+1)*c-1;for(t=0,a=n+1;t126||91===l||93===l||40===l||41===l||123===l||125===l||60===l||62===l||47===l||37===l||35===l?95:l:s[o]=l}t.push(c(s))}return t},parseStringIndex:function(e){for(var t=new x,a=0,r=e.count;a10)return!1;for(var s=e.stackSize,o=e.stack,c=r.length,h=0;h>16;h+=2;s++}else if(14===u){if(s>=4){s-=4;if(this.seacAnalysisEnabled){e.seac=o.slice(s,s+4);return!1}}f=t[u]}else if(u>=32&&u<=246){o[s]=u-139;s++}else if(u>=247&&u<=254){o[s]=u<251?(u-247<<8)+r[h]+108:-(u-251<<8)-r[h]-108;h++;s++}else if(255===u){o[s]=(r[h]<<24|r[h+1]<<16|r[h+2]<<8|r[h+3])/65536;h+=4;s++}else if(19===u||20===u){e.hints+=s>>1;h+=e.hints+7>>3;s%=2;f=t[u]}else{if(10===u||29===u){var g;g=10===u?i:n;if(!g){f=t[u];l("Missing subrsIndex for "+f.id);return!1}var p=32768;g.count<1240?p=107:g.count<33900&&(p=1131);var m=o[--s]+p;if(m<0||m>=g.count||isNaN(m)){f=t[u];l("Out of bounds subrIndex for "+f.id);return!1}e.stackSize=s;e.callDepth++;var b=this.parseCharString(e,g.get(m),i,n);if(!b)return!1;e.callDepth--;s=e.stackSize;continue}if(11===u){e.stackSize=s;return!0}f=t[u]}if(f){f.stem&&(e.hints+=s>>1);if("min"in f&&!e.undefStack&&s=2&&f.stem?s%=2:s>1&&l("Found too many parameters for stack-clearing command");s>0&&o[s-1]>=0&&(e.width=o[s-1])}if("stackDelta"in f){"stackFn"in f&&f.stackFn(o,s);s+=f.stackDelta}else if(f.stackClearing)s=0;else if(f.resetStack){s=0;e.undefStack=!1}else if(f.undefStack){s=0;e.undefStack=!0;e.firstStackClearing=!1}}}e.stackSize=s;return!0},parseCharStrings:function(e,t,a,r,i){for(var n=[],s=[],o=e.count,c=0;c=i.length){l("Invalid fd index for glyph index.");f=!1}f&&(d=i[g].privateDict.subrsIndex)}else t&&(d=t);f&&(f=this.parseCharString(u,h,d,a));null!==u.width&&(s[c]=u.width);null!==u.seac&&(n[c]=u.seac);f||e.set(c,new Uint8Array([14]))}return{charStrings:e,seacs:n,widths:s}},emptyPrivateDictionary:function(e){var t=this.createDict(B,[],e.strings);e.setByKey(18,[0,0]);e.privateDict=t},parsePrivateDict:function(e){if(e.hasName("Private")){var t=e.getByName("Private");if(h(t)&&2===t.length){var a=t[0],r=t[1];if(0===a||r>=this.bytes.length)this.emptyPrivateDictionary(e);else{var i=r+a,n=this.bytes.subarray(r,i),s=this.parseDict(n),o=this.createDict(B,s,e.strings);e.privateDict=o;if(o.getByName("Subrs")){var c=o.getByName("Subrs"),l=r+c;if(0===c||l>=this.bytes.length)this.emptyPrivateDictionary(e);else{var u=this.parseIndex(l);o.subrsIndex=u.obj}}}}else e.removeByName("Private")}else this.emptyPrivateDictionary(e)},parseCharsets:function(e,t,a,r){if(0===e)return new T(!0,R.ISO_ADOBE,g);if(1===e)return new T(!0,R.EXPERT,p);if(2===e)return new T(!0,R.EXPERT_SUBSET,m);var i,n,o,c=this.bytes,l=e,h=c[e++],u=[".notdef"];t-=1;switch(h){case 0:for(o=0;o=0&&e<=390?y[e]:e-391<=this.strings.length?this.strings[e-391]:y[0]},add:function(e){this.strings.push(e)},get count(){return this.strings.length}};return e}(),S=function(){function e(){this.objects=[];this.length=0}e.prototype={add:function(e){this.length+=e.length;this.objects.push(e)},set:function(e,t){this.length+=t.length-this.objects[e].length;this.objects[e]=t},get:function(e){return this.objects[e]},get count(){return this.objects.length}};return e}(),A=function(){function e(e,t){this.keyToNameMap=e.keyToNameMap;this.nameToKeyMap=e.nameToKeyMap;this.defaults=e.defaults;this.types=e.types;this.opcodes=e.opcodes;this.order=e.order;this.strings=t;this.values=Object.create(null)}e.prototype={setByKey:function(e,t){if(!(e in this.keyToNameMap))return!1;var a=t.length;if(0===a)return!0;for(var r=0;r=this.fdSelect.length?-1:this.fdSelect[e]}};return e}(),M=function(){function e(){this.offsets=Object.create(null)}e.prototype={isTracking:function(e){return e in this.offsets},track:function(e,t){e in this.offsets&&s("Already tracking location of "+e);this.offsets[e]=t},offset:function(e){for(var t in this.offsets)this.offsets[t]+=e},setEntryLocation:function(e,t,a){e in this.offsets||s("Not tracking location of "+e);for(var r=a.data,i=this.offsets[e],n=0,o=t.length;n>24&255;r[h]=d>>16&255;r[u]=d>>8&255;r[f]=255&d}}};return e}(),E=function(){function e(e){this.cff=e}e.prototype={compile:function(){var e=this.cff,t={data:[],length:0,add:function(e){this.data=this.data.concat(e);this.length=this.data.length}},a=this.compileHeader(e.header);t.add(a);var r=this.compileNameIndex(e.names);t.add(r);if(e.isCIDFont&&e.topDict.hasName("FontMatrix")){var i=e.topDict.getByName("FontMatrix");e.topDict.removeByName("FontMatrix");for(var n=0,s=e.fdArray.length;n=-107&&e<=107)t=[e+139];else if(e>=108&&e<=1131){e-=108;t=[247+(e>>8),255&e]}else if(e>=-1131&&e<=-108){e=-e-108;t=[251+(e>>8),255&e]}else t=e>=-32768&&e<=32767?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e];return t},compileHeader:function(e){return[e.major,e.minor,e.hdrSize,e.offSize]},compileNameIndex:function(e){for(var t=new S,a=0,r=e.length;a>8&255,255&r],s=1;for(i=0;i>8&255,255&c):3===o?n.push(c>>16&255,c>>8&255,255&c):n.push(c>>>24&255,c>>16&255,c>>8&255,255&c);a[i]&&(c+=a[i].length)}for(i=0;i=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(r=a;r=t||t<=this.progressiveDataLength))for(var a=this.chunkSize,r=Math.floor(e/a),n=Math.floor((t-1)/a)+1,s=r;s=this.end)return-1;this.ensureByte(e);return this.bytes[this.pos++]},getUint16:function(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()},getBytes:function(e){var t=this.bytes,a=this.pos,r=this.end;if(!e){this.ensureRange(a,r);return t.subarray(a,r)}var i=a+e;i>r&&(i=r);this.ensureRange(a,i);this.pos=i;return t.subarray(a,i)},peekByte:function(){var e=this.getByte();this.pos--;return e},peekBytes:function(e){var t=this.getBytes(e);this.pos-=t.length;return t},getByteRange:function(e,t){this.ensureRange(e,t);return this.bytes.subarray(e,t)},skip:function(e){e||(e=1);this.pos+=e},reset:function(){this.pos=this.start},moveStart:function(){this.start=this.pos},makeSubStream:function(e,t,a){function r(){}this.ensureRange(e,e+t);r.prototype=Object.create(this);r.prototype.getMissingChunks=function(){for(var e=this.chunkSize,t=Math.floor(this.start/e),a=Math.floor((this.end-1)/e)+1,r=[],i=t;i=0&&r+1!==n){t.push({beginChunk:a,endChunk:r+1});a=n}i+1===e.length&&t.push({beginChunk:a,endChunk:n+1});r=n}return t},onProgress:function(e){var t=this.stream.numChunksLoaded*this.chunkSize+e.loaded;this.msgHandler.send("DocProgress",{loaded:t,total:this.length})},onReceiveData:function(e){var t=e.chunk,a=void 0===e.begin,r=a?this.progressiveDataLength:e.begin,i=r+t.byteLength,n=Math.floor(r/this.chunkSize),s=i>5&255;d[n++]=i>>13&255;d[n++]=i>>21&255;d[n++]=i>>>29&255;d[n++]=0;d[n++]=0;d[n++]=0;var g=new Int32Array(16);for(n=0;n>>32-x)|0;b=w}c=c+b|0;l=l+v|0;h=h+y|0;u=u+k|0}return new Uint8Array([255&c,c>>8&255,c>>16&255,c>>>24&255,255&l,l>>8&255,l>>16&255,l>>>24&255,255&h,h>>8&255,h>>16&255,h>>>24&255,255&u,u>>8&255,u>>16&255,u>>>24&255])}var t=new Uint8Array([7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21]),a=new Int32Array([-680876936,-389564586,606105819,-1044525330,-176418897,1200080426,-1473231341,-45705983,1770035416,-1958414417,-42063,-1990404162,1804603682,-40341101,-1502002290,1236535329,-165796510,-1069501632,643717713,-373897302,-701558691,38016083,-660478335,-405537848,568446438,-1019803690,-187363961,1163531501,-1444681467,-51403784,1735328473,-1926607734,-378558,-2022574463,1839030562,-35309556,-1530992060,1272893353,-155497632,-1094730640,681279174,-358537222,-722521979,76029189,-640364487,-421815835,530742520,-995338651,-198630844,1126891415,-1416354905,-57434055,1700485571,-1894986606,-1051523,-2054922799,1873313359,-30611744,-1560198380,1309151649,-145523070,-1120210379,718787259,-343485551]);return e}(),w=function(){function e(e,t){this.high=0|e;this.low=0|t}e.prototype={and:function(e){this.high&=e.high;this.low&=e.low},xor:function(e){this.high^=e.high;this.low^=e.low},or:function(e){this.high|=e.high;this.low|=e.low},shiftRight:function(e){if(e>=32){this.low=this.high>>>e-32|0;this.high=0}else{this.low=this.low>>>e|this.high<<32-e;this.high=this.high>>>e|0}},shiftLeft:function(e){if(e>=32){this.high=this.low<>>32-e;this.low=this.low<>>e|a<<32-e;this.high=a>>>e|t<<32-e},not:function(){this.high=~this.high;this.low=~this.low},add:function(e){var t=(this.low>>>0)+(e.low>>>0),a=(this.high>>>0)+(e.high>>>0);t>4294967295&&(a+=1);this.low=0|t;this.high=0|a},copyTo:function(e,t){e[t]=this.high>>>24&255;e[t+1]=this.high>>16&255;e[t+2]=this.high>>8&255;e[t+3]=255&this.high;e[t+4]=this.low>>>24&255;e[t+5]=this.low>>16&255;e[t+6]=this.low>>8&255;e[t+7]=255&this.low},assign:function(e){this.high=e.high;this.low=e.low}};return e}(),C=function(){function e(e,t){return e>>>t|e<<32-t}function t(e,t,a){return e&t^~e&a}function a(e,t,a){return e&t^e&a^t&a}function r(t){return e(t,2)^e(t,13)^e(t,22)}function i(t){return e(t,6)^e(t,11)^e(t,25)}function n(t){return e(t,7)^e(t,18)^t>>>3}function s(t){return e(t,17)^e(t,19)^t>>>10}function o(e,o,l){var h,u,f,d=1779033703,g=3144134277,p=1013904242,m=2773480762,b=1359893119,v=2600822924,y=528734635,k=1541459225,w=64*Math.ceil((l+9)/64),C=new Uint8Array(w);for(h=0;h>>29&255;C[h++]=l>>21&255;C[h++]=l>>13&255;C[h++]=l>>5&255;C[h++]=l<<3&255;var x=new Uint32Array(64);for(h=0;h>24&255,d>>16&255,d>>8&255,255&d,g>>24&255,g>>16&255,g>>8&255,255&g,p>>24&255,p>>16&255,p>>8&255,255&p,m>>24&255,m>>16&255,m>>8&255,255&m,b>>24&255,b>>16&255,b>>8&255,255&b,v>>24&255,v>>16&255,v>>8&255,255&v,y>>24&255,y>>16&255,y>>8&255,255&y,k>>24&255,k>>16&255,k>>8&255,255&k])}var c=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];return o}(),x=function(){function e(e,t,a,r,i){e.assign(t);e.and(a);i.assign(t);i.not();i.and(r);e.xor(i)}function t(e,t,a,r,i){e.assign(t);e.and(a);i.assign(t);i.and(r);e.xor(i);i.assign(a);i.and(r);e.xor(i)}function a(e,t,a){e.assign(t);e.rotateRight(28);a.assign(t);a.rotateRight(34);e.xor(a);a.assign(t);a.rotateRight(39);e.xor(a)}function r(e,t,a){e.assign(t);e.rotateRight(14);a.assign(t);a.rotateRight(18);e.xor(a);a.assign(t);a.rotateRight(41);e.xor(a)}function i(e,t,a){e.assign(t);e.rotateRight(1);a.assign(t);a.rotateRight(8);e.xor(a);a.assign(t);a.shiftRight(7);e.xor(a)}function n(e,t,a){e.assign(t);e.rotateRight(19);a.assign(t);a.rotateRight(61);e.xor(a);a.assign(t);a.shiftRight(6);e.xor(a)}function s(s,c,l,h){h=!!h;var u,f,d,g,p,m,b,v;if(h){u=new w(3418070365,3238371032);f=new w(1654270250,914150663);d=new w(2438529370,812702999);g=new w(355462360,4144912697);p=new w(1731405415,4290775857);m=new w(2394180231,1750603025);b=new w(3675008525,1694076839);v=new w(1203062813,3204075428)}else{u=new w(1779033703,4089235720);f=new w(3144134277,2227873595);d=new w(1013904242,4271175723);g=new w(2773480762,1595750129);p=new w(1359893119,2917565137);m=new w(2600822924,725511199);b=new w(528734635,4215389547);v=new w(1541459225,327033209)}var y,k,C,x=128*Math.ceil((l+17)/128),S=new Uint8Array(x);for(y=0;y>>29&255;S[y++]=l>>21&255;S[y++]=l>>13&255;S[y++]=l>>5&255;S[y++]=l<<3&255;var A=new Array(80);for(y=0;y<80;y++)A[y]=new w(0,0);var I,B=new w(0,0),R=new w(0,0),T=new w(0,0),O=new w(0,0),P=new w(0,0),M=new w(0,0),E=new w(0,0),L=new w(0,0),D=new w(0,0),F=new w(0,0),q=new w(0,0),U=new w(0,0);for(y=0;y=1;--r){s=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=s;s=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=s;a[2]=c;s=a[15];c=a[11];l=a[7];a[15]=a[3];a[11]=s;a[7]=c;a[3]=l;for(i=0;i<16;++i)a[i]=o[a[i]];for(i=0,n=16*r;i<16;++i,++n)a[i]^=t[n];for(i=0;i<16;i+=4){var u=h[a[i]],f=h[a[i+1]],d=h[a[i+2]],g=h[a[i+3]];s=u^f>>>8^f<<24^d>>>16^d<<16^g>>>24^g<<8;a[i]=s>>>24&255;a[i+1]=s>>16&255;a[i+2]=s>>8&255;a[i+3]=255&s}}s=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=s;s=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=s;a[2]=c;s=a[15];c=a[11];l=a[7];a[15]=a[3];a[11]=s;a[7]=c;a[3]=l;for(i=0;i<16;++i){a[i]=o[a[i]];a[i]^=t[i]}return a}function a(e,t){var a,r,i,n,o=new Uint8Array(16);o.set(e);for(h=0;h<16;++h)o[h]^=t[h];for(l=1;l<10;l++){for(h=0;h<16;++h)o[h]=s[o[h]];i=o[1];o[1]=o[5];o[5]=o[9];o[9]=o[13];o[13]=i;i=o[2];r=o[6];o[2]=o[10];o[6]=o[14];o[10]=i;o[14]=r;i=o[3];r=o[7];a=o[11];o[3]=o[15];o[7]=i;o[11]=r;o[15]=a;for(var h=0;h<16;h+=4){var u=o[h+0],f=o[h+1],d=o[h+2],g=o[h+3];a=u^f^d^g;o[h+0]^=a^c[u^f];o[h+1]^=a^c[f^d];o[h+2]^=a^c[d^g];o[h+3]^=a^c[g^u]}for(h=0,n=16*l;h<16;++h,++n)o[h]^=t[n]}for(h=0;h<16;++h)o[h]=s[o[h]];i=o[1];o[1]=o[5];o[5]=o[9];o[9]=o[13];o[13]=i;i=o[2];r=o[6];o[2]=o[10];o[6]=o[14];o[10]=i;o[14]=r;i=o[3];r=o[7];a=o[11];o[3]=o[15];o[7]=i;o[11]=r;o[15]=a;for(h=0,n=160;h<16;++h,++n)o[h]^=t[n];return o}function r(t){this.key=e(t);this.buffer=new Uint8Array(16);this.bufferPosition=0}function i(e,a){var r,i,n,s=e.length,o=this.buffer,c=this.bufferPosition,l=[],h=this.iv;for(r=0;r=n;--r)if(d[r]!==g){g=0;break}f-=g;l[l.length-1]=d.subarray(0,16-g)}}var p=new Uint8Array(f);for(r=0,i=0,n=l.length;r=256&&(a=255&(27^a))}for(var h=0;h<4;++h){t[r]=s^=t[r-32];r++;t[r]=o^=t[r-32];r++;t[r]=c^=t[r-32];r++;t[r]=l^=t[r-32];r++}}return t}function t(e,t){var a=new Uint8Array(16);a.set(e);var r,i,n,o,c,h;for(i=0,n=224;i<16;++i,++n)a[i]^=t[n];for(r=13;r>=1;--r){o=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=o;o=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=o;a[2]=c;o=a[15];c=a[11];h=a[7];a[15]=a[3];a[11]=o;a[7]=c;a[3]=h;for(i=0;i<16;++i)a[i]=s[a[i]];for(i=0,n=16*r;i<16;++i,++n)a[i]^=t[n];for(i=0;i<16;i+=4){var u=l[a[i]],f=l[a[i+1]],d=l[a[i+2]],g=l[a[i+3]];o=u^f>>>8^f<<24^d>>>16^d<<16^g>>>24^g<<8;a[i]=o>>>24&255;a[i+1]=o>>16&255;a[i+2]=o>>8&255;a[i+3]=255&o}}o=a[13];a[13]=a[9];a[9]=a[5];a[5]=a[1];a[1]=o;o=a[14];c=a[10];a[14]=a[6];a[10]=a[2];a[6]=o;a[2]=c;o=a[15];c=a[11];h=a[7];a[15]=a[3];a[11]=o;a[7]=c;a[3]=h;for(i=0;i<16;++i){a[i]=s[a[i]];a[i]^=t[i]}return a}function a(e,t){var a,r,i,s,l=new Uint8Array(16);l.set(e);for(h=0;h<16;++h)l[h]^=t[h];for(c=1;c<14;c++){for(h=0;h<16;++h)l[h]=n[l[h]];i=l[1];l[1]=l[5];l[5]=l[9];l[9]=l[13];l[13]=i;i=l[2];r=l[6];l[2]=l[10];l[6]=l[14];l[10]=i;l[14]=r;i=l[3];r=l[7];a=l[11];l[3]=l[15];l[7]=i;l[11]=r;l[15]=a;for(var h=0;h<16;h+=4){var u=l[h+0],f=l[h+1],d=l[h+2],g=l[h+3];a=u^f^d^g;l[h+0]^=a^o[u^f];l[h+1]^=a^o[f^d];l[h+2]^=a^o[d^g];l[h+3]^=a^o[g^u]}for(h=0,s=16*c;h<16;++h,++s)l[h]^=t[s]}for(h=0;h<16;++h)l[h]=n[l[h]];i=l[1];l[1]=l[5];l[5]=l[9];l[9]=l[13];l[13]=i;i=l[2];r=l[6];l[2]=l[10];l[6]=l[14];l[10]=i;l[14]=r;i=l[3];r=l[7];a=l[11];l[3]=l[15];l[7]=i;l[11]=r;l[15]=a;for(h=0,s=224;h<16;++h,++s)l[h]^=t[s];return l}function r(t){this.key=e(t);this.buffer=new Uint8Array(16);this.bufferPosition=0}function i(e,a){var r,i,n,s=e.length,o=this.buffer,c=this.bufferPosition,l=[],h=this.iv;for(r=0;r=n;--r)if(d[r]!==g){g=0;break}f-=g;l[l.length-1]=d.subarray(0,16-g)}}var p=new Uint8Array(f);for(r=0,i=0,n=l.length;rs-32;){var o=t.length+i.length+r.length,c=new Uint8Array(64*o),l=e(t,i);l=e(l,r);for(var h=0,u=0;h<64;h++,u+=o)c.set(l,u);n=new I(i.subarray(0,16)).encrypt(c,i.subarray(16,32));for(var f=0,d=0;d<16;d++){f*=1;f%=3;f+=(n[d]>>>0)%3;f%=3}0===f?i=C(n,0,n.length):1===f?i=S(n,0,n.length):2===f&&(i=x(n,0,n.length));s++}return i.subarray(0,32)}function a(){}function r(e,t){if(e.length!==t.length)return!1;for(var a=0;a>8&255;f[d++]=i>>16&255;f[d++]=i>>>24&255;for(l=0,h=e.length;l=4&&!o){f[d++]=255;f[d++]=255;f[d++]=255;f[d++]=255}var g=k(f,0,d),p=s>>3;if(n>=3)for(l=0;l<50;++l)g=k(g,0,p);var m,b,v=g.subarray(0,p);if(n>=3){for(d=0;d<32;++d)f[d]=c[d];for(l=0,h=e.length;l>3;if(a>=3)for(i=0;i<50;++i)l=k(l,0,l.length);var u,f;if(a>=3){f=t;var d,g=new Uint8Array(h);for(i=19;i>=0;i--){for(d=0;d=4){var O=r.get("CF");b(O)&&(O.suppressEncryption=!0);this.cf=O;this.stmf=r.get("StmF")||v;this.strf=r.get("StrF")||v;this.eff=r.get("EFF")||this.stmf}}function i(e,t,a,r){var i,n,s=new Uint8Array(a.length+9);for(i=0,n=a.length;i>8&255;s[i++]=e>>16&255;s[i++]=255&t;s[i++]=t>>8&255;if(r){s[i++]=115;s[i++]=65;s[i++]=108;s[i++]=84}return k(s,0,i).subarray(0,Math.min(a.length+5,16))}function n(e,t,a,r,n){u(m(t),"Invalid crypt filter name.");var s,o=e.get(t.name);null!==o&&void 0!==o&&(s=o.get("CFM"));if(!s||"None"===s.name)return function(){return new A};if("V2"===s.name)return function(){return new y(i(a,r,n,!1))};if("AESV2"===s.name)return function(){return new I(i(a,r,n,!0))};if("AESV3"===s.name)return function(){return new B(n)};h("Unknown crypto method")}var c=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]),v=p.get("Identity");r.prototype={createCipherTransform:function(e,t){if(4===this.algorithm||5===this.algorithm)return new O(n(this.cf,this.stmf,e,t,this.encryptionKey),n(this.cf,this.strf,e,t,this.encryptionKey));var a=i(e,t,this.encryptionKey,!1),r=function(){return new y(a)};return new O(r,r)}};return r}();t.AES128Cipher=I;t.AES256Cipher=B;t.ARCFourCipher=y;t.CipherTransformFactory=P;t.PDF17=R;t.PDF20=T;t.calculateMD5=k;t.calculateSHA256=C;t.calculateSHA384=S;t.calculateSHA512=x},function(e,t,a){"use strict";var r=a(0),i=a(1),n=a(2),s=a(5),o=a(27),c=a(3),l=a(31),h=a(26),u=a(6),f=a(32),d=a(23),g=a(30),p=a(21),m=a(4),b=a(17),v=a(18),y=a(7),k=r.FONT_IDENTITY_MATRIX,w=r.IDENTITY_MATRIX,C=r.UNSUPPORTED_FEATURES,x=r.ImageKind,S=r.OPS,A=r.TextRenderingMode,I=r.CMapCompressionType,B=r.Util,R=r.assert,T=r.createPromiseCapability,O=r.error,P=r.info,M=r.isArray,E=r.isNum,L=r.isString,D=r.getLookupTableFactory,F=r.warn,q=i.Dict,U=i.Name,N=i.isEOF,j=i.isCmd,_=i.isDict,z=i.isName,H=i.isRef,G=i.isStream,X=n.DecodeStream,V=n.JpegStream,W=n.Stream,K=s.Lexer,Y=s.Parser,J=o.PDFImage,Z=c.ColorSpace,Q=l.MurmurHash3_64,$=h.ErrorFont,ee=h.FontFlags,te=h.Font,ae=h.IdentityToUnicodeMap,re=h.ToUnicodeMap,ie=h.getFontType,ne=u.isPDFFunction,se=u.PDFFunction,oe=f.Pattern,ce=f.getTilingPatternIR,le=d.CMapFactory,he=d.IdentityCMap,ue=g.getMetrics,fe=p.bidi,de=m.WinAnsiEncoding,ge=m.StandardEncoding,pe=m.MacRomanEncoding,me=m.SymbolSetEncoding,be=m.ZapfDingbatsEncoding,ve=m.getEncoding,ye=b.getStdFontMap,ke=b.getSerifFonts,we=b.getSymbolsFonts,Ce=v.getNormalizedUnicodes,xe=v.reverseIfRtl,Se=v.getUnicodeForGlyph,Ae=y.getGlyphsUnicode,Ie=function(){function e(e,t,a,r){this.xref=e;this.resources=t;this.handler=a;this.forceDataSchema=r}function t(e,t,a,i,n,s,o,c){this.pdfManager=e;this.xref=t;this.handler=a;this.pageIndex=i;this.idFactory=n;this.fontCache=s;this.builtInCMapCache=o;this.options=c||r;this.fetchBuiltInCMap=function(e){var t=o[e];return t?Promise.resolve(t):a.sendWithPromise("FetchBuiltInCMap",{name:e}).then(function(t){t.compressionType!==I.NONE&&(o[e]=t);return t})}}function a(){this.reset()}var r={forceDataSchema:!1,maxImageSize:-1,disableFontFace:!1,disableNativeImageDecoder:!1};e.prototype={canDecode:function(t){return t instanceof V&&e.isDecodable(t,this.xref,this.resources)},decode:function(e){var t=e.dict,a=t.get("ColorSpace","CS");a=Z.parse(a,this.xref,this.resources);var r=a.numComps;return this.handler.sendWithPromise("JpegDecode",[e.getIR(this.forceDataSchema),r]).then(function(t){var a=t.data;return new W(a,0,a.length,e.dict)})}};e.isSupported=function(e,t,a){var r=e.dict;if(r.has("DecodeParms")||r.has("DP"))return!1;var i=Z.parse(r.get("ColorSpace","CS"),t,a);return("DeviceGray"===i.name||"DeviceRGB"===i.name)&&i.isDefaultDecode(r.getArray("Decode","D"))};e.isDecodable=function(e,t,a){var r=e.dict;if(r.has("DecodeParms")||r.has("DP"))return!1;var i=Z.parse(r.get("ColorSpace","CS"),t,a);return(1===i.numComps||3===i.numComps)&&i.isDefaultDecode(r.getArray("Decode","D"))};a.prototype={check:function(){if(++this.checked<100)return!1;this.checked=0;return this.endTime<=Date.now()},reset:function(){this.endTime=Date.now()+20;this.checked=0}};var i=Promise.resolve();t.prototype={hasBlendModes:function(e){if(!_(e))return!1;var t=Object.create(null);e.objId&&(t[e.objId]=!0);for(var a=[e],r=this.xref;a.length;){var i,n,s,o=a.shift(),c=o.get("ExtGState");if(_(c)){var l=c.getKeys();for(n=0,s=l.length;nu)F("Image exceeded maximum allowed size and was removed.");else{var f,d,g=c.get("ImageMask","IM")||!1;if(g){var p=c.get("Width","W"),m=c.get("Height","H"),b=p+7>>3,v=a.getBytes(b*m),y=c.getArray("Decode","D"),k=!!y&&y[0]>0;f=J.createMask(v,p,m,a instanceof X,k);f.cached=!0;d=[f];i.addOp(S.paintImageMaskXObject,d);n&&(s[n]={fn:S.paintImageMaskXObject,args:d})}else{var w=c.get("SMask","SM")||!1,C=c.get("Mask")||!1;if(!r||w||C||a instanceof V||!(l+h<200)){var x=!this.options.disableNativeImageDecoder,A="img_"+this.idFactory.createObjId();i.addDependency(A);d=[A,l,h];if(x&&!w&&!C&&a instanceof V&&e.isSupported(a,this.xref,t)){i.addOp(S.paintJpegXObject,d);this.handler.send("obj",[A,this.pageIndex,"JpegStream",a.getIR(this.options.forceDataSchema)])}else{var I=null;x&&(a instanceof V||C instanceof V||w instanceof V)&&(I=new e(o.xref,t,o.handler,o.options.forceDataSchema));J.buildImage(o.handler,o.xref,t,a,r,I).then(function(e){var t=e.createImageData(!1);o.handler.send("obj",[A,o.pageIndex,"Image",t],[t.data.buffer])}).then(void 0,function(e){F("Unable to decode image: "+e);o.handler.send("obj",[A,o.pageIndex,"Image",null])});i.addOp(S.paintImageXObject,d);n&&(s[n]={fn:S.paintImageXObject,args:d})}}else{f=new J(this.xref,t,a,r,null,null).createImageData(!0);i.addOp(S.paintInlineImageXObject,[f])}}}}else F("Image dimensions are missing, or not numbers.")},handleSMask:function(e,t,a,r,i){var n=e.get("G"),s={subtype:e.get("S").name,backdrop:e.get("BC")},o=e.get("TR");if(ne(o)){for(var c=se.parse(this.xref,o),l=new Uint8Array(256),h=new Float32Array(1),u=0;u<256;u++){h[0]=u/255;c(h,0,h,0);l[u]=255*h[0]|0}s.transferMap=l}return this.buildFormXObject(t,n,s,a,r,i.state.clone())},handleTilingType:function(e,t,a,r,i,n,s){var o=new Re,c=[i.get("Resources"),a],l=q.merge(this.xref,c);return this.getOperatorList(r,s,l,o).then(function(){n.addDependencies(o.dependencies);n.addOp(e,ce({fnArray:o.fnArray,argsArray:o.argsArray},i,t))})},handleSetFont:function(e,t,a,r,i,n){var s;if(t){t=t.slice();s=t[0].name}var o=this;return this.loadFont(s,a,e).then(function(t){return t.font.isType3Font?t.loadType3Data(o,e,r,i).then(function(){return t},function(e){o.handler.send("UnsupportedFeature",{featureId:C.font});return new Be("g_font_error",new $("Type3 font load error: "+e),t.font)}):t}).then(function(e){n.font=e.font;e.send(o.handler);return e.loadedName})},handleText:function(e,t){var a=t.font,r=a.charsToGlyphs(e),i=!!(t.textRenderingMode&A.ADD_TO_PATH_FLAG);if(a.data&&(i||this.options.disableFontFace))for(var n=function(e){if(!a.renderer.hasBuiltPath(e)){var t=a.renderer.getPathJs(e);this.handler.send("commonobj",[a.loadedName+"_path_"+e,"FontPath",t])}}.bind(this),s=0,o=r.length;s0&&a.addOp(S.setGState,[n])})},loadFont:function(e,t,a){function r(){return Promise.resolve(new Be("g_font_error",new $("Font "+e+" is not available"),t))}var i,n=this.xref;if(t){R(H(t));i=t}else{var s=a.get("Font");if(!s){F("fontRes not available");return r()}i=s.getRaw(e)}if(!i){F("fontRef not available");return r()}if(this.fontCache.has(i))return this.fontCache.get(i);t=n.fetchIfRef(i);if(!_(t))return r();if(t.translated)return t.translated;var o,c=T(),l=this.preEvaluateFont(t),h=l.descriptor,u=H(i);u&&(o=i.toString());if(_(h)){h.fontAliases||(h.fontAliases=Object.create(null));var f=h.fontAliases,d=l.hash;if(f[d]){var g=f[d].aliasRef;if(u&&g&&this.fontCache.has(g)){this.fontCache.putAlias(i,g);return this.fontCache.get(i)}}else f[d]={fontID:te.getFontID()};u&&(f[d].aliasRef=i);o=f[d].fontID}if(u)this.fontCache.put(i,c.promise);else{o||(o=this.idFactory.createObjId());this.fontCache.put("id_"+o,c.promise)}R(o,'The "fontID" must be defined.');t.loadedName="g_"+this.pdfManager.docId+"_f"+o;t.translated=c.promise;var p;try{p=this.translateFont(l)}catch(e){p=Promise.reject(e)}var m=this;p.then(function(e){if(void 0!==e.fontType){n.stats.fontTypes[e.fontType]=!0}c.resolve(new Be(t.loadedName,e,t))},function(e){m.handler.send("UnsupportedFeature",{featureId:C.font});try{var a=l.descriptor,r=a&&a.get("FontFile3"),i=r&&r.get("Subtype"),s=ie(l.type,i&&i.name);n.stats.fontTypes[s]=!0}catch(e){}c.resolve(new Be(t.loadedName,new $(e instanceof Error?e.message:e),t))});return c.promise},buildPath:function(e,t,a){var r=e.length-1;a||(a=[]);if(r<0||e.fnArray[r]!==S.constructPath)e.addOp(S.constructPath,[[t],a]);else{var i=e.argsArray[r];i[0].push(t);Array.prototype.push.apply(i[1],a)}},handleColorN:function(e,t,a,r,i,n,s){var o,c=a[a.length-1];if(z(c)&&(o=i.get(c.name))){var l=G(o)?o.dict:o,h=l.get("PatternType");if(1===h){var u=r.base?r.base.getRgb(a,0):null;return this.handleTilingType(t,u,n,o,l,e,s)}if(2===h){var f=l.get("Shading"),d=l.getArray("Matrix");o=oe.parseShading(f,d,this.xref,n,this.handler);e.addOp(t,o.getIR());return Promise.resolve()}return Promise.reject("Unknown PatternType: "+h)}e.addOp(t,a);return Promise.resolve()},getOperatorList:function(e,t,r,n,s){var o=this,c=this.xref,l=Object.create(null);R(n);r=r||q.empty;var h=r.get("XObject")||q.empty,u=r.get("Pattern")||q.empty,f=new Te(s||new Pe),d=new Me(e,c,f),g=new a;return new Promise(function e(a,s){var p=function(t){t.then(function(){try{e(a,s)}catch(e){s(e)}},s)};t.ensureNotTerminated();g.reset();for(var m,b,v,y,k={};!(m=g.check());){k.args=null;if(!d.read(k))break;var w=k.args,C=k.fn;switch(0|C){case S.paintXObject:if(w[0].code)break;var x=w[0].name;if(!x){F("XObject must be referred to by name.");continue}if(void 0!==l[x]){n.addOp(l[x].fn,l[x].args);w=null;continue}var A=h.get(x);if(A){R(G(A),"XObject should be a stream");var I=A.dict.get("Subtype");R(z(I),"XObject should have a Name subtype");if("Form"===I.name){f.save();p(o.buildFormXObject(r,A,null,n,t,f.state.clone()).then(function(){f.restore()}));return}if("Image"===I.name){o.buildPaintImageXObject(r,A,!1,n,x,l);w=null;continue}if("PS"===I.name){P("Ignored XObject subtype PS");continue}O("Unhandled XObject subtype "+I.name)}break;case S.setFont:var B=w[1];p(o.handleSetFont(r,w,null,n,t,f.state).then(function(e){n.addDependency(e);n.addOp(S.setFont,[e,B])}));return;case S.endInlineImage: +var T=w[0].cacheKey;if(T){var M=l[T];if(void 0!==M){n.addOp(M.fn,M.args);w=null;continue}}o.buildPaintImageXObject(r,w[0],!0,n,T,l);w=null;continue;case S.showText:w[0]=o.handleText(w[0],f.state);break;case S.showSpacedText:var D=w[0],U=[],N=D.length,j=f.state;for(b=0;b0){a*=I.fontMatrix[3];t[3]*=a}}var r=B.transform(I.ctm,B.transform(I.textMatrix,t));b.transform=r;if(e.vertical){b.width=Math.sqrt(r[0]*r[0]+r[1]*r[1]);b.height=0;b.vertical=!0}else{b.width=0;b.height=Math.sqrt(r[2]*r[2]+r[3]*r[3]);b.vertical=!1}var i=I.textLineMatrix[0],n=I.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=I.ctm[0];n=I.ctm[1];var o=Math.sqrt(i*i+n*n);b.textAdvanceScale=o*s;b.lastAdvanceWidth=0;b.lastAdvanceHeight=0;var c=e.spaceWidth/1e3*I.fontSize;if(c){b.spaceWidth=c;b.fakeSpaceMin=c*v;b.fakeMultiSpaceMin=c*y;b.fakeMultiSpaceMax=c*C;b.textRunBreakAllowed=!e.isMonospace}else{b.spaceWidth=0;b.fakeSpaceMin=1/0;b.fakeMultiSpaceMin=1/0;b.fakeMultiSpaceMax=0;b.textRunBreakAllowed=!1}b.initialized=!0;return b}function l(e){for(var t,a=0,r=e.length;a=32&&t<=127;)a++;return a0&&d(g,a.str)}var p=0,m=0;if(t.vertical){m=l*I.fontMatrix[0]*I.fontSize+f;i+=m}else{p=(l*I.fontMatrix[0]*I.fontSize+f)*I.textHScale;r+=p}I.translateTextMatrix(p,m);a.str.push(h)}if(t.vertical){a.lastAdvanceHeight=i;a.height+=Math.abs(i)}else{a.lastAdvanceWidth=r;a.width+=r}return a}function d(e,t){if(!(e0;)t.push(" ")}function g(){if(b.initialized){b.width*=b.textAdvanceScale;b.height*=b.textAdvanceScale;m.items.push(h(b));b.initialized=!1;b.str.length=0}}n=n||new Te(new Oe);var p=/\s/g,m={items:[],styles:Object.create(null)},b={initialized:!1,str:[],width:0,height:0,vertical:!1,lastAdvanceWidth:0,lastAdvanceHeight:0,textAdvanceScale:0,spaceWidth:0,fakeSpaceMin:1/0,fakeMultiSpaceMin:1/0,fakeMultiSpaceMax:-0,textRunBreakAllowed:!1,transform:null,fontName:null},v=.3,y=1.5,C=4,x=this,A=this.xref;r=A.fetchIfRef(r)||q.empty;var I,T=null,O=Object.create(null),P=new Me(e,A,n),L=new a;return new Promise(function e(a,l){var h=function(t){t.then(function(){try{e(a,l)}catch(e){l(e)}},l)};t.ensureNotTerminated();L.reset();for(var p,v={},y=[];!(p=L.check());){y.length=0;v.args=y;if(!P.read(v))break;I=n.state;var k=v.fn;y=v.args;var C,A;switch(0|k){case S.setFont:var D=y[0].name,F=y[1];if(I.font&&D===I.fontName&&F===I.fontSize)break;g();I.fontName=D;I.fontSize=F;h(u(D,null));return;case S.setTextRise:g();I.textRise=y[0];break;case S.setHScale:g();I.textHScale=y[0]/100;break;case S.setLeading:g();I.leading=y[0];break;case S.moveText:var U=!!I.font&&0===(I.font.vertical?y[0]:y[1]);C=y[0]-y[1];if(o&&U&&b.initialized&&C>0&&C<=b.fakeMultiSpaceMax){I.translateTextLineMatrix(y[0],y[1]);b.width+=y[0]-b.lastAdvanceWidth;b.height+=y[1]-b.lastAdvanceHeight;A=y[0]-b.lastAdvanceWidth-(y[1]-b.lastAdvanceHeight);d(A,b.str);break}g();I.translateTextLineMatrix(y[0],y[1]);I.textMatrix=I.textLineMatrix.slice();break;case S.setLeadingMoveText:g();I.leading=-y[1];I.translateTextLineMatrix(y[0],y[1]);I.textMatrix=I.textLineMatrix.slice();break;case S.nextLine:g();I.carriageReturn();break;case S.setTextMatrix:C=I.calcTextLineMatrixAdvance(y[0],y[1],y[2],y[3],y[4],y[5]);if(o&&null!==C&&b.initialized&&C.value>0&&C.value<=b.fakeMultiSpaceMax){I.translateTextLineMatrix(C.width,C.height);b.width+=C.width-b.lastAdvanceWidth;b.height+=C.height-b.lastAdvanceHeight;A=C.width-b.lastAdvanceWidth-(C.height-b.lastAdvanceHeight);d(A,b.str);break}g();I.setTextMatrix(y[0],y[1],y[2],y[3],y[4],y[5]);I.setTextLineMatrix(y[0],y[1],y[2],y[3],y[4],y[5]);break;case S.setCharSpacing:I.charSpacing=y[0];break;case S.setWordSpacing:I.wordSpacing=y[0];break;case S.beginText:g();I.textMatrix=w.slice();I.textLineMatrix=w.slice();break;case S.showSpacedText:for(var N,j=y[0],H=0,X=j.length;Hb.fakeMultiSpaceMax;V||(b.height+=N)}else{C=-C;N=C*I.textHScale;I.translateTextMatrix(N,0);V=b.textRunBreakAllowed&&C>b.fakeMultiSpaceMax;V||(b.width+=N)}V?g():C>0&&d(C,b.str)}break;case S.showText:f(y[0]);break;case S.nextLineShowText:g();I.carriageReturn();f(y[0]);break;case S.nextLineSetSpacingShowText:g();I.wordSpacing=y[0];I.charSpacing=y[1];I.carriageReturn();f(y[2]);break;case S.paintXObject:g();if(y[0].code)break;T||(T=r.get("XObject")||q.empty);var W=y[0].name;if(O.key===W){if(O.texts){B.appendToArray(m.items,O.texts.items);B.extendObj(m.styles,O.texts.styles)}break}var K=T.get(W);if(!K)break;R(G(K),"XObject should be a stream");var Y=K.dict.get("Subtype");R(z(Y),"XObject should have a Name subtype");if("Form"!==Y.name){O.key=W;O.texts=null;break}n.save();var J=K.dict.getArray("Matrix");M(J)&&6===J.length&&n.transform(J);h(x.getTextContent(K,t,K.dict.get("Resources")||r,n,s,o).then(function(e){B.appendToArray(m.items,e.items);B.extendObj(m.styles,e.styles);n.restore();O.key=W;O.texts=e}));return;case S.setGState:g();var Z=y[0],Q=r.get("ExtGState");if(!_(Q)||!z(Z))break;var $=Q.get(Z.name);if(!_($))break;var ee=$.get("Font");if(ee){I.fontName=null;I.fontSize=ee[1];h(u(null,ee[0]));return}}}if(p)h(i);else{g();a(m)}})},extractDataStructures:function(e,t,a){var r=this.xref,i=e.get("ToUnicode")||t.get("ToUnicode"),n=i?this.readToUnicode(i):Promise.resolve(void 0);if(a.composite){var s=e.get("CIDSystemInfo");_(s)&&(a.cidSystemInfo={registry:s.get("Registry"),ordering:s.get("Ordering"),supplement:s.get("Supplement")});var o=e.get("CIDToGIDMap");G(o)&&(a.cidToGidMap=this.readCidToGidMap(o))}var c,l=[],h=null;if(e.has("Encoding")){c=e.get("Encoding");if(_(c)){h=c.get("BaseEncoding");h=z(h)?h.name:null;if(c.has("Differences"))for(var u=c.get("Differences"),f=0,d=0,g=u.length;d0;a.dict=e;return n.then(function(e){a.toUnicode=e;return this.buildToUnicode(a)}.bind(this)).then(function(e){a.toUnicode=e;return a})},buildToUnicode:function(e){e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0;if(e.hasIncludedToUnicodeMap)return Promise.resolve(e.toUnicode);var t,a,r;if(!e.composite){t=[];var i=e.defaultEncoding.slice(),n=e.baseEncodingName,s=e.differences;for(a in s){r=s[a];".notdef"!==r&&(i[a]=r)}var o=Ae();for(a in i){r=i[a];if(""!==r)if(void 0!==o[r])t[a]=String.fromCharCode(o[r]);else{var c=0;switch(r[0]){case"G":3===r.length&&(c=parseInt(r.substr(1),16));break;case"g":5===r.length&&(c=parseInt(r.substr(1),16));break;case"C":case"c":r.length>=3&&(c=+r.substr(1));break;default:var l=Se(r,o);-1!==l&&(c=l)}if(c){if(n&&c===+a){var h=ve(n);if(h&&(r=h[a])){t[a]=String.fromCharCode(o[r]);continue}}t[a]=String.fromCharCode(c)}}}return Promise.resolve(new re(t))}if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof he)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){var u=e.cidSystemInfo.registry,f=e.cidSystemInfo.ordering,d=U.get(u+"-"+f+"-UCS2");return le.create({encoding:d,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then(function(a){var r=e.cMap;t=[];r.forEach(function(e,r){R(r<=65535,"Max size of CID is 65,535");var i=a.lookup(r);i&&(t[e]=String.fromCharCode((i.charCodeAt(0)<<8)+i.charCodeAt(1)))});return new re(t)})}return Promise.resolve(new ae(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return z(t)?le.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then(function(e){return e instanceof he?new ae(0,65535):new re(e.getMap())}):G(t)?le.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then(function(e){if(e instanceof he)return new ae(0,65535);var t=new Array(e.length);e.forEach(function(e,a){for(var r=[],i=0;i>1]=n}}return a},extractWidths:function(e,t,a){var r,i,n,s,o,c,l,h,u=this.xref,f=[],d=0,g=[];if(a.composite){d=e.get("DW")||1e3;h=e.get("W");if(h)for(i=0,n=h.length;i=1e3?this.flush():this.fnArray.length>=995&&(e===S.restore||e===S.endText)&&this.flush())},addDependency:function(e){if(!(e in this.dependencies)){this.dependencies[e]=!0;this.addOp(S.dependency,[e])}},addDependencies:function(e){for(var t in e)this.addDependency(t)},addOpList:function(e){B.extendObj(this.dependencies,e.dependencies);for(var t=0,a=e.length;ts&&P("Command "+n+": expected [0,"+s+"] args, but received "+o+" args.");else{if(o!==s){for(var c=this.nonProcessedArgs;o>s;){c.push(t.shift());o--}for(;o1e3){u=Math.max(u,g);p+=d+2;g=0;d=0}f.push({transform:m,x:g,y:p,w:b.width,h:b.height});g+=b.width+2;d=Math.max(d,b.height)}var v=Math.max(u,g)+1,y=p+d+1,k=new Uint8Array(v*y*4),w=v<<2;for(h=0;h=0;){C[B-4]=C[B];C[B-3]=C[B+1];C[B-2]=C[B+2];C[B-1]=C[B+3];C[B+A]=C[B+A-4];C[B+A+1]=C[B+A-3];C[B+A+2]=C[B+A-2];C[B+A+3]=C[B+A-1];B-=w}}t.splice(i,4*l,S.paintInlineImageXObjectGroup);a.splice(i,4*l,[{width:v,height:y,kind:x.RGBA_32BPP,data:k},f]);return i+1});e(r,[S.save,S.transform,S.paintImageMaskXObject,S.restore],function(e){for(var a=e.fnArray,r=e.argsArray,i=e.iCurr,n=i-3,s=i-2,o=i-1,c=n+4,l=a.length;c+3=4&&t[i-4]===t[n]&&t[i-3]===t[s]&&t[i-2]===t[o]&&t[i-1]===t[c]&&a[i-4][0]===l&&a[i-4][1]===h){d++;g-=5}for(var p=g+4,m=1;m0?Math.min(r.xcb,i.PPx-1):Math.min(r.xcb,i.PPx);i.ycb_=a>0?Math.min(r.ycb,i.PPy-1):Math.min(r.ycb,i.PPy);return i}function i(e,t,a){var r=1<t.trx0?Math.ceil(t.trx1/r)-Math.floor(t.trx0/r):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,h=c*l;t.precinctParameters={ +precinctWidth:r,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function f(e,t,a){var r,i,n,s,o=a.xcb_,c=a.ycb_,l=1<>o,f=t.tby0>>c,d=t.tbx1+l-1>>o,g=t.tby1+h-1>>c,p=t.resolution.precinctParameters,m=[],b=[];for(i=f;ik.cbxMax&&(k.cbxMax=r);ik.cbyMax&&(k.cbyMax=i)}else b[s]=k={cbxMin:r,cbyMin:i,cbxMax:r,cbyMax:i};n.precinct=k}}t.codeblockParameters={codeblockWidth:o,codeblockHeight:c,numcodeblockwide:d-u+1,numcodeblockhigh:g-f+1};t.codeblocks=m;t.precincts=b}function d(e,t,a){for(var r=[],i=e.subbands,n=0,s=i.length;ne.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[h],a=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],a=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){var n=e.resolutions[a],s=n.precinctParameters.numprecincts;if(!(i>=s)){for(;t=0;--m){var b=c.resolutions[m],v=p*b.precinctParameters.precinctWidth,y=p*b.precinctParameters.precinctHeight;u=Math.min(u,v);f=Math.min(f,y);d=Math.max(d,b.precinctParameters.numprecinctswide);g=Math.max(g,b.precinctParameters.numprecinctshigh);h[m]={width:v,height:y};p<<=1}a=Math.min(a,u);r=Math.min(r,f);i=Math.max(i,d);n=Math.max(n,g);s[o]={resolutions:h,minWidth:u,minHeight:f,maxNumWide:d,maxNumHigh:g}}return{components:s,minWidth:a,minHeight:r,maxNumWide:i,maxNumHigh:n}}function w(e){for(var t=e.SIZ,a=e.currentTile.index,n=e.tiles[a],s=t.Csiz,c=0;c>>u&(1<0;){var j=w.shift();y=j.codeblock;void 0===y.data&&(y.data=[]);y.data.push({data:t,start:a+h,end:a+h+j.dataLength,codingpasses:j.codingpasses});h+=j.dataLength}}}return h}function x(e,t,a,r,i,n,s,o){for(var c=r.tbx0,l=r.tby0,h=r.tbx1-r.tbx0,f=r.codeblocks,d="H"===r.type.charAt(0)?1:0,g="H"===r.type.charAt(1)?t:0,p=0,m=f.length;p=n?L:L*(1<0?1-m:0)}var I=b.subbands[w],R=B[I.type];x(k,v,y,I,f?1:Math.pow(2,u+R-A)*(1+S/2048),l+A-1,f,h)}g.push({width:v,height:y,items:k})}var T=d.calculate(g,r.tcx0,r.tcy0);return{left:r.tcx0,top:r.tcy0,width:T.width,height:T.height,items:T.items}}function A(e){for(var t=e.SIZ,a=e.components,r=t.Csiz,i=[],n=0,s=e.tiles.length;n>2);k=w+y;C=w+v;B[T++]=k<=0?0:k>=f?255:k>>h;B[T++]=w<=0?0:w>=f?255:w>>h;B[T++]=C<=0?0:C>=f?255:C>>h}else for(p=0;p=f?255:k>>h;B[T++]=w<=0?0:w>=f?255:w>>h;B[T++]=C<=0?0:C>=f?255:C>>h}if(O)for(p=0,T=3;p=g?255:x+u>>h}}else for(o=0;o=f?255:A+u>>h;T+=r}}i.push(R)}return i}function I(e,t){for(var a=e.SIZ,r=a.Csiz,i=e.tiles[t],n=0;n>24&255,c>>16&255,c>>8&255,255&c);s("Unsupported header type "+c+" ("+p+")")}f&&(t+=u)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function(e){for(var t=e.getByte();t>=0;){var a=t;t=e.getByte();if(65361===(a<<8|t)){e.skip(4);var r=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0,s=e.getInt32()>>>0;e.skip(16);var c=e.getUint16();this.width=r-n;this.height=i-s;this.componentsCount=c;this.bitsPerComponent=8;return}}o("JPX Error: No size marker found in JPX stream")},parseCodestream:function(e,r,i){var n={},c=!1;try{for(var u=r;u+1>5;p=[];for(;d>3;O.mu=0}else{O.epsilon=e[d]>>3;O.mu=(7&e[d])<<8|e[d+1];d+=2}p.push(O)}T.SPqcds=p;if(n.mainHeader)n.QCD=T;else{n.currentTile.QCD=T;n.currentTile.QCC=[]}break;case 65373:y=l(e,u);var P={};d=u+2;var M;if(n.SIZ.Csiz<257)M=e[d++];else{M=l(e,d);d+=2}g=e[d++];switch(31&g){case 0:m=8;b=!0;break;case 1:m=16;b=!1;break;case 2:m=16;b=!0;break;default:throw new Error("Invalid SQcd value "+g)}P.noQuantization=8===m;P.scalarExpounded=b;P.guardBits=g>>5;p=[];for(;d>3;O.mu=0}else{O.epsilon=e[d]>>3;O.mu=(7&e[d])<<8|e[d+1];d+=2}p.push(O)}P.SPqcds=p;n.mainHeader?n.QCC[M]=P:n.currentTile.QCC[M]=P;break;case 65362:y=l(e,u);var E={};d=u+2;var L=e[d++];E.entropyCoderWithCustomPrecincts=!!(1&L);E.sopMarkerUsed=!!(2&L);E.ephMarkerUsed=!!(4&L);E.progressionOrder=e[d++];E.layersCount=l(e,d);d+=2;E.multipleComponentTransform=e[d++];E.decompositionLevelsCount=e[d++];E.xcb=2+(15&e[d++]);E.ycb=2+(15&e[d++]);var D=e[d++];E.selectiveArithmeticCodingBypass=!!(1&D);E.resetContextProbabilities=!!(2&D);E.terminationOnEachCodingPass=!!(4&D);E.verticalyStripe=!!(8&D);E.predictableTermination=!!(16&D);E.segmentationSymbolUsed=!!(32&D);E.reversibleTransformation=e[d++];if(E.entropyCoderWithCustomPrecincts){for(var F=[];d>4})}E.precinctsSizes=F}var U=[];E.selectiveArithmeticCodingBypass&&U.push("selectiveArithmeticCodingBypass");E.resetContextProbabilities&&U.push("resetContextProbabilities");E.terminationOnEachCodingPass&&U.push("terminationOnEachCodingPass");E.verticalyStripe&&U.push("verticalyStripe");E.predictableTermination&&U.push("predictableTermination");if(U.length>0){c=!0;throw new Error("Unsupported COD options ("+U.join(", ")+")")}if(n.mainHeader)n.COD=E;else{n.currentTile.COD=E;n.currentTile.COC=[]}break;case 65424:y=l(e,u);v={};v.index=l(e,u+2);v.length=h(e,u+4);v.dataEnd=v.length+u-2;v.partIndex=e[u+8];v.partsCount=e[u+9];n.mainHeader=!1;if(0===v.partIndex){v.COD=n.COD;v.COC=n.COC.slice(0);v.QCD=n.QCD;v.QCC=n.QCC.slice(0)}n.currentTile=v;break;case 65427:v=n.currentTile;if(0===v.partIndex){I(n,v.index);w(n)}y=v.dataEnd-u;C(n,e,u,y);break;case 65365:case 65367:case 65368:case 65380:y=l(e,u);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+f.toString(16))}u+=y}}catch(e){c||this.failOnCorruptedImage?o("JPX Error: "+e.message):s("JPX: Trying to recover from: "+e.message)}this.tiles=A(n);this.width=n.SIZ.Xsiz-n.SIZ.XOsiz;this.height=n.SIZ.Ysiz-n.SIZ.YOsiz;this.componentsCount=n.SIZ.Csiz}};var R=function(){function e(e,t){var a=c(Math.max(e,t))+1;this.levels=[];for(var r=0;r>=1;t>>=1;r++}r--;a=this.levels[r];a.items[a.index]=i;this.currentLevel=r;delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];e--;if(e<0){this.value=a;return!1}this.currentLevel=e;t=this.levels[e];t.items[t.index]=a;return!0}};return e}(),T=function(){function e(e,t,a){var r=c(Math.max(e,t))+1;this.levels=[];for(var i=0;ia){this.currentLevel=r;this.propagateValues();return!1}e>>=1;t>>=1;r++}this.currentLevel=r-1;return!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1;this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];--e>=0;){t=this.levels[e];t.items[t.index]=a}},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];t.items[t.index]=255;e--;if(e<0)return!1;this.currentLevel=e;t=this.levels[e];t.items[t.index]=a;return!0}};return e}(),O=function(){function e(e,i,n,s,o){this.width=e;this.height=i;this.contextLabelTable="HH"===n?r:"HL"===n?a:t;var c=e*i;this.neighborsSignificance=new Uint8Array(c);this.coefficentsSign=new Uint8Array(c);this.coefficentsMagnitude=o>14?new Uint32Array(c):o>6?new Uint16Array(c):new Uint8Array(c);this.processingFlags=new Uint8Array(c);var l=new Uint8Array(c);if(0!==s)for(var h=0;h0,c=t+10){r=a-n;o&&(i[r-1]+=16);c&&(i[r+1]+=16);i[r]+=4}if(e+1=a)break;s[f]&=-2;if(!r[f]&&n[f]){var p=c[n[f]],m=e.readBit(o,p);if(m){var b=this.decodeSignBit(g,u,f);i[f]=b;r[f]=1;this.setNeighborsSignificance(g,u,f);s[f]|=2}l[f]++;s[f]|=1}}},decodeSignBit:function(e,t,a){var r,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,f=this.coefficentsSign;s=t>0&&0!==u[a-1];if(t+10&&0!==u[a-l];if(e+1=0){o=9+r;c=this.decoder.readBit(this.contexts,o)}else{o=9-r;c=1^this.decoder.readBit(this.contexts,o)}return c},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,a=this.width,r=this.height,i=this.coefficentsMagnitude,n=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=a*r,h=4*a,u=0;u>1;t|=0;var i,n,s,o,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,u=.443506852043971,f=1.230174104914001;i=t-3;for(n=r+4;n--;i+=2)e[i]*=1/f;i=t-2;s=u*e[i-1];for(n=r+3;n--;i+=2){o=u*e[i+1];e[i]=f*e[i]-s-o;if(!n--)break;i+=2;s=u*e[i+1];e[i]=f*e[i]-s-o}i=t-1;s=h*e[i-1];for(n=r+2;n--;i+=2){o=h*e[i+1];e[i]-=s+o;if(!n--)break;i+=2;s=h*e[i+1];e[i]-=s+o}i=t;s=l*e[i-1];for(n=r+1;n--;i+=2){o=l*e[i+1];e[i]-=s+o;if(!n--)break;i+=2;s=l*e[i+1];e[i]-=s+o}if(0!==r){i=t+1;s=c*e[i-1];for(n=r;n--;i+=2){o=c*e[i+1];e[i]-=s+o;if(!n--)break;i+=2;s=c*e[i+1];e[i]-=s+o}}};return e}(),E=function(){function e(){P.call(this)}e.prototype=Object.create(P.prototype);e.prototype.filter=function(e,t,a){var r=a>>1;t|=0;var i,n;for(i=t,n=r+1;n--;i+=2)e[i]-=e[i-1]+e[i+1]+2>>2;for(i=t+1,n=r;n--;i+=2)e[i]+=e[i-1]+e[i+1]>>1};return e}();return e}();t.JpxImage=f},function(e,t,a){"use strict";var r=a(0),i=a(1),n=a(13),s=a(5),o=a(12),c=a(3),l=r.InvalidPDFException,h=r.MissingDataException,u=r.XRefParseException,f=r.assert,d=r.bytesToString,g=r.createPromiseCapability,p=r.error,m=r.info,b=r.isArray,v=r.isBool,y=r.isInt,k=r.isString,w=r.shadow,C=r.stringToPDFString,x=r.stringToUTF8String,S=r.warn,A=r.createValidAbsoluteUrl,I=r.Util,B=i.Dict,R=i.Ref,T=i.RefSet,O=i.RefSetCache,P=i.isName,M=i.isCmd,E=i.isDict,L=i.isRef,D=i.isRefsEqual,F=i.isStream,q=n.CipherTransformFactory,U=s.Lexer,N=s.Parser,j=o.ChunkedStream,_=c.ColorSpace,z=function(){function e(e,t,a){this.pdfManager=e;this.xref=t;this.catDict=t.getCatalogObj();f(E(this.catDict),"catalog object is not a dictionary");this.fontCache=new O;this.builtInCMapCache=Object.create(null);this.pageKidsCountCache=new O;this.pageFactory=a;this.pagePromises=[]}e.prototype={get metadata(){var e=this.catDict.getRaw("Metadata");if(!L(e))return w(this,"metadata",null);var t,a=!!this.xref.encrypt&&this.xref.encrypt.encryptMetadata,r=this.xref.fetch(e,!a);if(r&&E(r.dict)){var i=r.dict.get("Type"),n=r.dict.get("Subtype");if(P(i,"Metadata")&&P(n,"XML"))try{t=x(d(r.getBytes()))}catch(e){if(e instanceof h)throw e;m("Skipping invalid metadata.")}}return w(this,"metadata",t)},get toplevelPagesDict(){var e=this.catDict.get("Pages");f(E(e),"invalid top-level pages dictionary");return w(this,"toplevelPagesDict",e)},get documentOutline(){var e=null;try{e=this.readDocumentOutline()}catch(e){if(e instanceof h)throw e;S("Unable to read document outline")}return w(this,"documentOutline",e)},readDocumentOutline:function(){var t=this.catDict.get("Outlines");if(!E(t))return null;t=t.getRaw("First");if(!L(t))return null;var a={items:[]},r=[{obj:t,parent:a}],i=new T;i.put(t);for(var n=this.xref,s=new Uint8Array(3);r.length>0;){var o=r.shift(),c=n.fetchIfRef(o.obj);if(null!==c){f(c.has("Title"),"Invalid outline item");var l={url:null,dest:null};e.parseDestDictionary({destDict:c,resultObj:l,docBaseUrl:this.pdfManager.docBaseUrl});var h=c.get("Title"),u=c.get("F")||0,d=c.getArray("C"),g=s;!b(d)||3!==d.length||0===d[0]&&0===d[1]&&0===d[2]||(g=_.singletons.rgb.getRgb(d,0));var p={dest:l.dest,url:l.url,unsafeUrl:l.unsafeUrl,newWindow:l.newWindow,title:C(h),color:g,count:c.get("Count"),bold:!!(2&u),italic:!!(1&u),items:[]};o.parent.items.push(p);t=c.getRaw("First");if(L(t)&&!i.has(t)){r.push({obj:t,parent:p});i.put(t)}t=c.getRaw("Next");if(L(t)&&!i.has(t)){r.push({obj:t,parent:o.parent});i.put(t)}}}return a.items.length>0?a.items:null},get numPages(){var e=this.toplevelPagesDict.get("Count");f(y(e),"page count in top level pages object is not an integer");return w(this,"num",e)},get destinations(){function e(e){return E(e)?e.get("D"):e}var t,a,r=this.xref,i={},n=this.catDict.get("Names");n&&n.has("Dests")?t=n.getRaw("Dests"):this.catDict.has("Dests")&&(a=this.catDict.get("Dests"));if(a){n=a;n.forEach(function(t,a){a&&(i[t]=e(a))})}if(t){var s=new X(t,r),o=s.getAll();for(var c in o)i[c]=e(o[c])}return w(this,"destinations",i)},getDestination:function(e){function t(e){return E(e)?e.get("D"):e}var a,r,i=this.xref,n=null,s=this.catDict.get("Names");s&&s.has("Dests")?a=s.getRaw("Dests"):this.catDict.has("Dests")&&(r=this.catDict.get("Dests"));if(r){var o=r.get(e);o&&(n=t(o))}if(a){n=t(new X(a,i).get(e))}return n},get pageLabels(){var e=null;try{e=this.readPageLabels()}catch(e){if(e instanceof h)throw e;S("Unable to read page labels.")}return w(this,"pageLabels",e)},readPageLabels:function(){var e=this.catDict.getRaw("PageLabels");if(!e)return null;for(var t=new Array(this.numPages),a=null,r="",i=new V(e,this.xref),n=i.getAll(),s="",o=1,c=0,l=this.numPages;c=1,"Invalid start in PageLabel dictionary.");o=p||1}switch(a){case"D":s=o;break;case"R":case"r":s=I.toRoman(o,"r"===a);break;case"A":case"a":for(var m="a"===a?97:65,b=o-1,v=String.fromCharCode(m+b%26),w=[],x=0,S=b/26|0;x<=S;x++)w.push(v);s=w.join("");break;default:f(!a,'Invalid style "'+a+'" in PageLabel dictionary.')}t[c]=r+s;s="";o++}return t},get attachments(){var e,t=this.xref,a=null,r=this.catDict.get("Names");r&&(e=r.getRaw("EmbeddedFiles"));if(e){var i=new X(e,t),n=i.getAll();for(var s in n){var o=new W(n[s],t);a||(a=Object.create(null));a[C(s)]=o.serializable}}return w(this,"attachments",a)},get javaScript(){function e(e){var t=e.get("S");if(P(t,"JavaScript")){var a=e.get("JS");if(F(a))a=d(a.getBytes());else if(!k(a))return;r.push(C(a))}}var t=this.xref,a=this.catDict.get("Names"),r=[];if(a&&a.has("JavaScript")){var i=new X(a.getRaw("JavaScript"),t),n=i.getAll();for(var s in n){var o=n[s];E(o)&&e(o)}}var c=this.catDict.get("OpenAction");if(E(c,"Action")){var l=c.get("S");if(P(l,"Named")){var h=c.get("N");P(h,"Print")&&r.push("print({});")}else e(c)}return w(this,"javaScript",r)},cleanup:function(){this.pageKidsCountCache.clear();var e=[];this.fontCache.forEach(function(t){e.push(t)});return Promise.all(e).then(function(e){for(var t=0,a=e.length;t0&&n+a=0;u--)i.push(h[u])}}r.reject("Page index "+e+" not found.")}var a,r=g(),i=[this.catDict.getRaw("Pages")],n=0,s=this.xref,o=this.pageKidsCountCache;t();return r.promise},getPageIndex:function(e){function t(t){var a,i=0;return r.fetchAsync(t).then(function(r){if(D(t,e)&&!E(r,"Page")&&(!E(r)||r.has("Type")||!r.has("Contents")))throw new Error("The reference does not point to a /Page Dict.");if(!r)return null;f(E(r),"node must be a Dict.");a=r.getRaw("Parent");return r.getAsync("Parent")}).then(function(e){if(!e)return null;f(E(e),"parent must be a Dict.");return e.getAsync("Kids")}).then(function(e){if(!e)return null;for(var n=[],s=!1,o=0;o0;){var l=c[0],h=c[1];y(l)&&y(h)||p("Invalid XRef range fields: "+l+", "+h);y(n)&&y(s)&&y(o)||p("Invalid XRef entry fields length: "+l+", "+h);for(t=r.entryNum;t=r)break;t++;n++}return n}var t=10,a=13,r=60,i=/^(\d+)\s+(\d+)\s+obj\b/,n=new Uint8Array([116,114,97,105,108,101,114]),s=new Uint8Array([115,116,97,114,116,120,114,101,102]),o=new Uint8Array([101,110,100,111,98,106]),c=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var h=this.stream;h.pos=0;for(var u=h.getBytes(),f=h.start,d=u.length,g=[],p=[];f=e.length);){n+=String.fromCharCode(s);s=e[i]}return n}(u,f);if(0!==v.indexOf("xref")||4!==v.length&&!/\s/.test(v[4]))if(b=i.exec(v)){void 0===this.entries[b[1]]&&(this.entries[b[1]]={offset:f-h.start,gen:0|b[2],uncompressed:!0});var y=e(u,f,o)+7,k=u.subarray(f,f+y),w=e(k,0,c);if(w=d)break;m=u[f]}while(m!==t&&m!==a);else++f}var C,x;for(C=0,x=p.length;C0;){var i,n,s=t.fetchIfRef(r.shift());if(E(s))if(s.has("Kids")){var o=s.get("Kids");for(i=0,n=o.length;i10){S('Search depth limit reached for "'+this._type+'" tree.');return null}var o=n.get("Kids");if(!b(o))return null;t=0;a=o.length-1;for(;t<=a;){r=t+a>>1;var c=i.fetchIfRef(o[r]),l=c.get("Limits");if(ei.fetchIfRef(l[1]))){n=i.fetchIfRef(o[r]);break}t=r+1}}if(t>a)return null}var h=n.get(this._type);if(b(h)){t=0;a=h.length-2;for(;t<=a;){r=t+a&-2;var u=i.fetchIfRef(h[r]);if(eu))return i.fetchIfRef(h[r+1]);t=r+2}}}return null}};return e}(),X=function(){function e(e,t){this.root=e;this.xref=t;this._type="Names"}I.inherit(e,G,{});return e}(),V=function(){function e(e,t){this.root=e;this.xref=t;this._type="Nums"}I.inherit(e,G,{});return e}(),W=function(){function e(e,t){if(e&&E(e)){this.xref=t;this.root=e;e.has("FS")&&(this.fs=e.get("FS"));this.description=e.has("Desc")?C(e.get("Desc")):"";e.has("RF")&&S("Related file specifications are not supported");this.contentAvailable=!0;if(!e.has("EF")){this.contentAvailable=!1;S("Non-embedded file specifications are not supported")}}}function t(e){return e.has("UF")?e.get("UF"):e.has("F")?e.get("F"):e.has("Unix")?e.get("Unix"):e.has("Mac")?e.get("Mac"):e.has("DOS")?e.get("DOS"):null}e.prototype={get filename(){if(!this._filename&&this.root){var e=t(this.root)||"unnamed";this._filename=C(e).replace(/\\\\/g,"\\").replace(/\\\//g,"/").replace(/\\/g,"/")}return this._filename},get content(){if(!this.contentAvailable)return null;!this.contentRef&&this.root&&(this.contentRef=t(this.root.get("EF")));var e=null;if(this.contentRef){var a=this.xref,r=a.fetchIfRef(this.contentRef);r&&F(r)?e=r.getBytes():S("Embedded file specification points to non-existing/invalid content")}else S("Embedded file specification does not have a content");return e},get serializable(){return{filename:this.filename,content:this.content}}};return e}(),K=function(){function e(e){return L(e)||E(e)||b(e)||F(e)}function t(t,a){var r;if(E(t)||F(t)){var i;i=E(t)?t.map:t.dict.map;for(var n in i){r=i[n];e(r)&&a.push(r)}}else if(b(t))for(var s=0,o=t.length;s=65520&&e<=65535?0:e>=62976&&e<=63743?h()[e]||e:e}function i(e,t){var a=t[e];if(void 0!==a)return a;if(!e)return-1;if("u"===e[0]){var r,i=e.length;if(7===i&&"n"===e[1]&&"i"===e[2])r=e.substr(3);else{if(!(i>=5&&i<=7))return-1;r=e.substr(1)}if(r===r.toUpperCase()){a=parseInt(r,16);if(a>=0)return a}}return-1}function n(e){for(var t=0,a=u.length;t=r.begin&&e=t.begin&&e=t.begin&&e=0;r--)a+=e[r];return a}var c=a(0),l=c.getLookupTableFactory,h=l(function(e){e[63721]=169;e[63193]=169;e[63720]=174;e[63194]=174;e[63722]=8482;e[63195]=8482;e[63729]=9127;e[63730]=9128;e[63731]=9129;e[63740]=9131;e[63741]=9132;e[63742]=9133;e[63726]=9121;e[63727]=9122;e[63728]=9123;e[63737]=9124;e[63738]=9125;e[63739]=9126;e[63723]=9115;e[63724]=9116;e[63725]=9117;e[63734]=9118;e[63735]=9119;e[63736]=9120}),u=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}],f=l(function(e){e["¨"]=" ̈";e["¯"]=" ̄";e["´"]=" ́";e["µ"]="μ";e["¸"]=" ̧";e["IJ"]="IJ";e["ij"]="ij";e["Ŀ"]="L·";e["ŀ"]="l·";e["ʼn"]="ʼn";e["ſ"]="s";e["DŽ"]="DŽ";e["Dž"]="Dž";e["dž"]="dž";e["LJ"]="LJ";e["Lj"]="Lj";e["lj"]="lj";e["NJ"]="NJ";e["Nj"]="Nj";e["nj"]="nj";e["DZ"]="DZ";e["Dz"]="Dz";e["dz"]="dz";e["˘"]=" ̆";e["˙"]=" ̇";e["˚"]=" ̊";e["˛"]=" ̨";e["˜"]=" ̃";e["˝"]=" ̋";e["ͺ"]=" ͅ";e["΄"]=" ́";e["ϐ"]="β";e["ϑ"]="θ";e["ϒ"]="Υ";e["ϕ"]="φ";e["ϖ"]="π";e["ϰ"]="κ";e["ϱ"]="ρ";e["ϲ"]="ς";e["ϴ"]="Θ";e["ϵ"]="ε";e["Ϲ"]="Σ";e["և"]="եւ";e["ٵ"]="اٴ";e["ٶ"]="وٴ";e["ٷ"]="ۇٴ";e["ٸ"]="يٴ";e["ำ"]="ํา";e["ຳ"]="ໍາ";e["ໜ"]="ຫນ";e["ໝ"]="ຫມ";e["ཷ"]="ྲཱྀ";e["ཹ"]="ླཱྀ";e["ẚ"]="aʾ";e["᾽"]=" ̓";e["᾿"]=" ̓";e["῀"]=" ͂";e["῾"]=" ̔";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e[" "]=" ";e["‗"]=" ̳";e["․"]=".";e["‥"]="..";e["…"]="...";e["″"]="′′";e["‴"]="′′′";e["‶"]="‵‵";e["‷"]="‵‵‵";e["‼"]="!!";e["‾"]=" ̅";e["⁇"]="??";e["⁈"]="?!";e["⁉"]="!?";e["⁗"]="′′′′";e[" "]=" ";e["₨"]="Rs";e["℀"]="a/c";e["℁"]="a/s";e["℃"]="°C";e["℅"]="c/o";e["℆"]="c/u";e["ℇ"]="Ɛ";e["℉"]="°F";e["№"]="No";e["℡"]="TEL";e["ℵ"]="א";e["ℶ"]="ב";e["ℷ"]="ג";e["ℸ"]="ד";e["℻"]="FAX";e["Ⅰ"]="I";e["Ⅱ"]="II";e["Ⅲ"]="III";e["Ⅳ"]="IV";e["Ⅴ"]="V";e["Ⅵ"]="VI";e["Ⅶ"]="VII";e["Ⅷ"]="VIII";e["Ⅸ"]="IX";e["Ⅹ"]="X";e["Ⅺ"]="XI";e["Ⅻ"]="XII";e["Ⅼ"]="L";e["Ⅽ"]="C";e["Ⅾ"]="D";e["Ⅿ"]="M";e["ⅰ"]="i";e["ⅱ"]="ii";e["ⅲ"]="iii";e["ⅳ"]="iv";e["ⅴ"]="v";e["ⅵ"]="vi";e["ⅶ"]="vii";e["ⅷ"]="viii";e["ⅸ"]="ix";e["ⅹ"]="x";e["ⅺ"]="xi";e["ⅻ"]="xii";e["ⅼ"]="l";e["ⅽ"]="c";e["ⅾ"]="d";e["ⅿ"]="m";e["∬"]="∫∫";e["∭"]="∫∫∫";e["∯"]="∮∮";e["∰"]="∮∮∮";e["⑴"]="(1)";e["⑵"]="(2)";e["⑶"]="(3)";e["⑷"]="(4)";e["⑸"]="(5)";e["⑹"]="(6)";e["⑺"]="(7)";e["⑻"]="(8)";e["⑼"]="(9)";e["⑽"]="(10)";e["⑾"]="(11)";e["⑿"]="(12)";e["⒀"]="(13)";e["⒁"]="(14)";e["⒂"]="(15)";e["⒃"]="(16)";e["⒄"]="(17)";e["⒅"]="(18)";e["⒆"]="(19)";e["⒇"]="(20)";e["⒈"]="1.";e["⒉"]="2.";e["⒊"]="3.";e["⒋"]="4.";e["⒌"]="5.";e["⒍"]="6.";e["⒎"]="7.";e["⒏"]="8.";e["⒐"]="9.";e["⒑"]="10.";e["⒒"]="11.";e["⒓"]="12.";e["⒔"]="13.";e["⒕"]="14.";e["⒖"]="15.";e["⒗"]="16.";e["⒘"]="17.";e["⒙"]="18.";e["⒚"]="19.";e["⒛"]="20.";e["⒜"]="(a)";e["⒝"]="(b)";e["⒞"]="(c)";e["⒟"]="(d)";e["⒠"]="(e)";e["⒡"]="(f)";e["⒢"]="(g)";e["⒣"]="(h)";e["⒤"]="(i)";e["⒥"]="(j)";e["⒦"]="(k)";e["⒧"]="(l)";e["⒨"]="(m)";e["⒩"]="(n)";e["⒪"]="(o)";e["⒫"]="(p)";e["⒬"]="(q)";e["⒭"]="(r)";e["⒮"]="(s)";e["⒯"]="(t)";e["⒰"]="(u)";e["⒱"]="(v)";e["⒲"]="(w)";e["⒳"]="(x)";e["⒴"]="(y)";e["⒵"]="(z)";e["⨌"]="∫∫∫∫";e["⩴"]="::=";e["⩵"]="==";e["⩶"]="===";e["⺟"]="母";e["⻳"]="龟";e["⼀"]="一";e["⼁"]="丨";e["⼂"]="丶";e["⼃"]="丿";e["⼄"]="乙";e["⼅"]="亅";e["⼆"]="二";e["⼇"]="亠";e["⼈"]="人";e["⼉"]="儿";e["⼊"]="入";e["⼋"]="八";e["⼌"]="冂";e["⼍"]="冖";e["⼎"]="冫";e["⼏"]="几";e["⼐"]="凵";e["⼑"]="刀";e["⼒"]="力";e["⼓"]="勹";e["⼔"]="匕";e["⼕"]="匚";e["⼖"]="匸";e["⼗"]="十";e["⼘"]="卜";e["⼙"]="卩";e["⼚"]="厂";e["⼛"]="厶";e["⼜"]="又";e["⼝"]="口";e["⼞"]="囗";e["⼟"]="土";e["⼠"]="士";e["⼡"]="夂";e["⼢"]="夊";e["⼣"]="夕";e["⼤"]="大";e["⼥"]="女";e["⼦"]="子";e["⼧"]="宀";e["⼨"]="寸";e["⼩"]="小";e["⼪"]="尢";e["⼫"]="尸";e["⼬"]="屮";e["⼭"]="山";e["⼮"]="巛";e["⼯"]="工";e["⼰"]="己";e["⼱"]="巾";e["⼲"]="干";e["⼳"]="幺";e["⼴"]="广";e["⼵"]="廴";e["⼶"]="廾";e["⼷"]="弋";e["⼸"]="弓";e["⼹"]="彐";e["⼺"]="彡";e["⼻"]="彳";e["⼼"]="心";e["⼽"]="戈";e["⼾"]="戶";e["⼿"]="手";e["⽀"]="支";e["⽁"]="攴";e["⽂"]="文";e["⽃"]="斗";e["⽄"]="斤";e["⽅"]="方";e["⽆"]="无";e["⽇"]="日";e["⽈"]="曰";e["⽉"]="月";e["⽊"]="木";e["⽋"]="欠";e["⽌"]="止";e["⽍"]="歹";e["⽎"]="殳";e["⽏"]="毋";e["⽐"]="比";e["⽑"]="毛";e["⽒"]="氏";e["⽓"]="气";e["⽔"]="水";e["⽕"]="火";e["⽖"]="爪";e["⽗"]="父";e["⽘"]="爻";e["⽙"]="爿";e["⽚"]="片";e["⽛"]="牙";e["⽜"]="牛";e["⽝"]="犬";e["⽞"]="玄";e["⽟"]="玉";e["⽠"]="瓜";e["⽡"]="瓦";e["⽢"]="甘";e["⽣"]="生";e["⽤"]="用";e["⽥"]="田";e["⽦"]="疋";e["⽧"]="疒";e["⽨"]="癶";e["⽩"]="白";e["⽪"]="皮";e["⽫"]="皿";e["⽬"]="目";e["⽭"]="矛";e["⽮"]="矢";e["⽯"]="石";e["⽰"]="示";e["⽱"]="禸";e["⽲"]="禾";e["⽳"]="穴";e["⽴"]="立";e["⽵"]="竹";e["⽶"]="米";e["⽷"]="糸";e["⽸"]="缶";e["⽹"]="网";e["⽺"]="羊";e["⽻"]="羽";e["⽼"]="老";e["⽽"]="而";e["⽾"]="耒";e["⽿"]="耳";e["⾀"]="聿";e["⾁"]="肉";e["⾂"]="臣";e["⾃"]="自";e["⾄"]="至";e["⾅"]="臼";e["⾆"]="舌";e["⾇"]="舛";e["⾈"]="舟";e["⾉"]="艮";e["⾊"]="色";e["⾋"]="艸";e["⾌"]="虍";e["⾍"]="虫";e["⾎"]="血";e["⾏"]="行";e["⾐"]="衣";e["⾑"]="襾";e["⾒"]="見";e["⾓"]="角";e["⾔"]="言";e["⾕"]="谷";e["⾖"]="豆";e["⾗"]="豕";e["⾘"]="豸";e["⾙"]="貝";e["⾚"]="赤";e["⾛"]="走";e["⾜"]="足";e["⾝"]="身";e["⾞"]="車";e["⾟"]="辛";e["⾠"]="辰";e["⾡"]="辵";e["⾢"]="邑";e["⾣"]="酉";e["⾤"]="釆";e["⾥"]="里";e["⾦"]="金";e["⾧"]="長";e["⾨"]="門";e["⾩"]="阜";e["⾪"]="隶";e["⾫"]="隹";e["⾬"]="雨";e["⾭"]="靑";e["⾮"]="非";e["⾯"]="面";e["⾰"]="革";e["⾱"]="韋";e["⾲"]="韭";e["⾳"]="音";e["⾴"]="頁";e["⾵"]="風";e["⾶"]="飛";e["⾷"]="食";e["⾸"]="首";e["⾹"]="香";e["⾺"]="馬";e["⾻"]="骨";e["⾼"]="高";e["⾽"]="髟";e["⾾"]="鬥";e["⾿"]="鬯";e["⿀"]="鬲";e["⿁"]="鬼";e["⿂"]="魚";e["⿃"]="鳥";e["⿄"]="鹵";e["⿅"]="鹿";e["⿆"]="麥";e["⿇"]="麻";e["⿈"]="黃";e["⿉"]="黍";e["⿊"]="黑";e["⿋"]="黹";e["⿌"]="黽";e["⿍"]="鼎";e["⿎"]="鼓";e["⿏"]="鼠";e["⿐"]="鼻";e["⿑"]="齊";e["⿒"]="齒";e["⿓"]="龍";e["⿔"]="龜";e["⿕"]="龠";e["〶"]="〒";e["〸"]="十";e["〹"]="卄";e["〺"]="卅";e["゛"]=" ゙";e["゜"]=" ゚";e["ㄱ"]="ᄀ";e["ㄲ"]="ᄁ";e["ㄳ"]="ᆪ";e["ㄴ"]="ᄂ";e["ㄵ"]="ᆬ";e["ㄶ"]="ᆭ";e["ㄷ"]="ᄃ";e["ㄸ"]="ᄄ";e["ㄹ"]="ᄅ";e["ㄺ"]="ᆰ";e["ㄻ"]="ᆱ";e["ㄼ"]="ᆲ";e["ㄽ"]="ᆳ";e["ㄾ"]="ᆴ";e["ㄿ"]="ᆵ";e["ㅀ"]="ᄚ";e["ㅁ"]="ᄆ";e["ㅂ"]="ᄇ";e["ㅃ"]="ᄈ";e["ㅄ"]="ᄡ";e["ㅅ"]="ᄉ";e["ㅆ"]="ᄊ";e["ㅇ"]="ᄋ";e["ㅈ"]="ᄌ";e["ㅉ"]="ᄍ";e["ㅊ"]="ᄎ";e["ㅋ"]="ᄏ";e["ㅌ"]="ᄐ";e["ㅍ"]="ᄑ";e["ㅎ"]="ᄒ";e["ㅏ"]="ᅡ";e["ㅐ"]="ᅢ";e["ㅑ"]="ᅣ";e["ㅒ"]="ᅤ";e["ㅓ"]="ᅥ";e["ㅔ"]="ᅦ";e["ㅕ"]="ᅧ";e["ㅖ"]="ᅨ";e["ㅗ"]="ᅩ";e["ㅘ"]="ᅪ";e["ㅙ"]="ᅫ";e["ㅚ"]="ᅬ";e["ㅛ"]="ᅭ";e["ㅜ"]="ᅮ";e["ㅝ"]="ᅯ";e["ㅞ"]="ᅰ";e["ㅟ"]="ᅱ";e["ㅠ"]="ᅲ";e["ㅡ"]="ᅳ";e["ㅢ"]="ᅴ";e["ㅣ"]="ᅵ";e["ㅤ"]="ᅠ";e["ㅥ"]="ᄔ";e["ㅦ"]="ᄕ";e["ㅧ"]="ᇇ";e["ㅨ"]="ᇈ";e["ㅩ"]="ᇌ";e["ㅪ"]="ᇎ";e["ㅫ"]="ᇓ";e["ㅬ"]="ᇗ";e["ㅭ"]="ᇙ";e["ㅮ"]="ᄜ";e["ㅯ"]="ᇝ";e["ㅰ"]="ᇟ";e["ㅱ"]="ᄝ";e["ㅲ"]="ᄞ";e["ㅳ"]="ᄠ";e["ㅴ"]="ᄢ";e["ㅵ"]="ᄣ";e["ㅶ"]="ᄧ";e["ㅷ"]="ᄩ";e["ㅸ"]="ᄫ";e["ㅹ"]="ᄬ";e["ㅺ"]="ᄭ";e["ㅻ"]="ᄮ";e["ㅼ"]="ᄯ";e["ㅽ"]="ᄲ";e["ㅾ"]="ᄶ";e["ㅿ"]="ᅀ";e["ㆀ"]="ᅇ";e["ㆁ"]="ᅌ";e["ㆂ"]="ᇱ";e["ㆃ"]="ᇲ";e["ㆄ"]="ᅗ";e["ㆅ"]="ᅘ";e["ㆆ"]="ᅙ";e["ㆇ"]="ᆄ";e["ㆈ"]="ᆅ";e["ㆉ"]="ᆈ";e["ㆊ"]="ᆑ";e["ㆋ"]="ᆒ";e["ㆌ"]="ᆔ";e["ㆍ"]="ᆞ";e["ㆎ"]="ᆡ";e["㈀"]="(ᄀ)";e["㈁"]="(ᄂ)";e["㈂"]="(ᄃ)";e["㈃"]="(ᄅ)";e["㈄"]="(ᄆ)";e["㈅"]="(ᄇ)";e["㈆"]="(ᄉ)";e["㈇"]="(ᄋ)";e["㈈"]="(ᄌ)";e["㈉"]="(ᄎ)";e["㈊"]="(ᄏ)";e["㈋"]="(ᄐ)";e["㈌"]="(ᄑ)";e["㈍"]="(ᄒ)";e["㈎"]="(가)";e["㈏"]="(나)";e["㈐"]="(다)";e["㈑"]="(라)";e["㈒"]="(마)";e["㈓"]="(바)";e["㈔"]="(사)";e["㈕"]="(아)";e["㈖"]="(자)";e["㈗"]="(차)";e["㈘"]="(카)" +;e["㈙"]="(타)";e["㈚"]="(파)";e["㈛"]="(하)";e["㈜"]="(주)";e["㈝"]="(오전)";e["㈞"]="(오후)";e["㈠"]="(一)";e["㈡"]="(二)";e["㈢"]="(三)";e["㈣"]="(四)";e["㈤"]="(五)";e["㈥"]="(六)";e["㈦"]="(七)";e["㈧"]="(八)";e["㈨"]="(九)";e["㈩"]="(十)";e["㈪"]="(月)";e["㈫"]="(火)";e["㈬"]="(水)";e["㈭"]="(木)";e["㈮"]="(金)";e["㈯"]="(土)";e["㈰"]="(日)";e["㈱"]="(株)";e["㈲"]="(有)";e["㈳"]="(社)";e["㈴"]="(名)";e["㈵"]="(特)";e["㈶"]="(財)";e["㈷"]="(祝)";e["㈸"]="(労)";e["㈹"]="(代)";e["㈺"]="(呼)";e["㈻"]="(学)";e["㈼"]="(監)";e["㈽"]="(企)";e["㈾"]="(資)";e["㈿"]="(協)";e["㉀"]="(祭)";e["㉁"]="(休)";e["㉂"]="(自)";e["㉃"]="(至)";e["㋀"]="1月";e["㋁"]="2月";e["㋂"]="3月";e["㋃"]="4月";e["㋄"]="5月";e["㋅"]="6月";e["㋆"]="7月";e["㋇"]="8月";e["㋈"]="9月";e["㋉"]="10月";e["㋊"]="11月";e["㋋"]="12月";e["㍘"]="0点";e["㍙"]="1点";e["㍚"]="2点";e["㍛"]="3点";e["㍜"]="4点";e["㍝"]="5点";e["㍞"]="6点";e["㍟"]="7点";e["㍠"]="8点";e["㍡"]="9点";e["㍢"]="10点";e["㍣"]="11点";e["㍤"]="12点";e["㍥"]="13点";e["㍦"]="14点";e["㍧"]="15点";e["㍨"]="16点";e["㍩"]="17点";e["㍪"]="18点";e["㍫"]="19点";e["㍬"]="20点";e["㍭"]="21点";e["㍮"]="22点";e["㍯"]="23点";e["㍰"]="24点";e["㏠"]="1日";e["㏡"]="2日";e["㏢"]="3日";e["㏣"]="4日";e["㏤"]="5日";e["㏥"]="6日";e["㏦"]="7日";e["㏧"]="8日";e["㏨"]="9日";e["㏩"]="10日";e["㏪"]="11日";e["㏫"]="12日";e["㏬"]="13日";e["㏭"]="14日";e["㏮"]="15日";e["㏯"]="16日";e["㏰"]="17日";e["㏱"]="18日";e["㏲"]="19日";e["㏳"]="20日";e["㏴"]="21日";e["㏵"]="22日";e["㏶"]="23日";e["㏷"]="24日";e["㏸"]="25日";e["㏹"]="26日";e["㏺"]="27日";e["㏻"]="28日";e["㏼"]="29日";e["㏽"]="30日";e["㏾"]="31日";e["ff"]="ff";e["fi"]="fi";e["fl"]="fl";e["ffi"]="ffi";e["ffl"]="ffl";e["ſt"]="ſt";e["st"]="st";e["ﬓ"]="մն";e["ﬔ"]="մե";e["ﬕ"]="մի";e["ﬖ"]="վն";e["ﬗ"]="մխ";e["ﭏ"]="אל";e["ﭐ"]="ٱ";e["ﭑ"]="ٱ";e["ﭒ"]="ٻ";e["ﭓ"]="ٻ";e["ﭔ"]="ٻ";e["ﭕ"]="ٻ";e["ﭖ"]="پ";e["ﭗ"]="پ";e["ﭘ"]="پ";e["ﭙ"]="پ";e["ﭚ"]="ڀ";e["ﭛ"]="ڀ";e["ﭜ"]="ڀ";e["ﭝ"]="ڀ";e["ﭞ"]="ٺ";e["ﭟ"]="ٺ";e["ﭠ"]="ٺ";e["ﭡ"]="ٺ";e["ﭢ"]="ٿ";e["ﭣ"]="ٿ";e["ﭤ"]="ٿ";e["ﭥ"]="ٿ";e["ﭦ"]="ٹ";e["ﭧ"]="ٹ";e["ﭨ"]="ٹ";e["ﭩ"]="ٹ";e["ﭪ"]="ڤ";e["ﭫ"]="ڤ";e["ﭬ"]="ڤ";e["ﭭ"]="ڤ";e["ﭮ"]="ڦ";e["ﭯ"]="ڦ";e["ﭰ"]="ڦ";e["ﭱ"]="ڦ";e["ﭲ"]="ڄ";e["ﭳ"]="ڄ";e["ﭴ"]="ڄ";e["ﭵ"]="ڄ";e["ﭶ"]="ڃ";e["ﭷ"]="ڃ";e["ﭸ"]="ڃ";e["ﭹ"]="ڃ";e["ﭺ"]="چ";e["ﭻ"]="چ";e["ﭼ"]="چ";e["ﭽ"]="چ";e["ﭾ"]="ڇ";e["ﭿ"]="ڇ";e["ﮀ"]="ڇ";e["ﮁ"]="ڇ";e["ﮂ"]="ڍ";e["ﮃ"]="ڍ";e["ﮄ"]="ڌ";e["ﮅ"]="ڌ";e["ﮆ"]="ڎ";e["ﮇ"]="ڎ";e["ﮈ"]="ڈ";e["ﮉ"]="ڈ";e["ﮊ"]="ژ";e["ﮋ"]="ژ";e["ﮌ"]="ڑ";e["ﮍ"]="ڑ";e["ﮎ"]="ک";e["ﮏ"]="ک";e["ﮐ"]="ک";e["ﮑ"]="ک";e["ﮒ"]="گ";e["ﮓ"]="گ";e["ﮔ"]="گ";e["ﮕ"]="گ";e["ﮖ"]="ڳ";e["ﮗ"]="ڳ";e["ﮘ"]="ڳ";e["ﮙ"]="ڳ";e["ﮚ"]="ڱ";e["ﮛ"]="ڱ";e["ﮜ"]="ڱ";e["ﮝ"]="ڱ";e["ﮞ"]="ں";e["ﮟ"]="ں";e["ﮠ"]="ڻ";e["ﮡ"]="ڻ";e["ﮢ"]="ڻ";e["ﮣ"]="ڻ";e["ﮤ"]="ۀ";e["ﮥ"]="ۀ";e["ﮦ"]="ہ";e["ﮧ"]="ہ";e["ﮨ"]="ہ";e["ﮩ"]="ہ";e["ﮪ"]="ھ";e["ﮫ"]="ھ";e["ﮬ"]="ھ";e["ﮭ"]="ھ";e["ﮮ"]="ے";e["ﮯ"]="ے";e["ﮰ"]="ۓ";e["ﮱ"]="ۓ";e["ﯓ"]="ڭ";e["ﯔ"]="ڭ";e["ﯕ"]="ڭ";e["ﯖ"]="ڭ";e["ﯗ"]="ۇ";e["ﯘ"]="ۇ";e["ﯙ"]="ۆ";e["ﯚ"]="ۆ";e["ﯛ"]="ۈ";e["ﯜ"]="ۈ";e["ﯝ"]="ٷ";e["ﯞ"]="ۋ";e["ﯟ"]="ۋ";e["ﯠ"]="ۅ";e["ﯡ"]="ۅ";e["ﯢ"]="ۉ";e["ﯣ"]="ۉ";e["ﯤ"]="ې";e["ﯥ"]="ې";e["ﯦ"]="ې";e["ﯧ"]="ې";e["ﯨ"]="ى";e["ﯩ"]="ى";e["ﯪ"]="ئا";e["ﯫ"]="ئا";e["ﯬ"]="ئە";e["ﯭ"]="ئە";e["ﯮ"]="ئو";e["ﯯ"]="ئو";e["ﯰ"]="ئۇ";e["ﯱ"]="ئۇ";e["ﯲ"]="ئۆ";e["ﯳ"]="ئۆ";e["ﯴ"]="ئۈ";e["ﯵ"]="ئۈ";e["ﯶ"]="ئې";e["ﯷ"]="ئې";e["ﯸ"]="ئې";e["ﯹ"]="ئى";e["ﯺ"]="ئى";e["ﯻ"]="ئى";e["ﯼ"]="ی";e["ﯽ"]="ی";e["ﯾ"]="ی";e["ﯿ"]="ی";e["ﰀ"]="ئج";e["ﰁ"]="ئح";e["ﰂ"]="ئم";e["ﰃ"]="ئى";e["ﰄ"]="ئي";e["ﰅ"]="بج";e["ﰆ"]="بح";e["ﰇ"]="بخ";e["ﰈ"]="بم";e["ﰉ"]="بى";e["ﰊ"]="بي";e["ﰋ"]="تج";e["ﰌ"]="تح";e["ﰍ"]="تخ";e["ﰎ"]="تم";e["ﰏ"]="تى";e["ﰐ"]="تي";e["ﰑ"]="ثج";e["ﰒ"]="ثم";e["ﰓ"]="ثى";e["ﰔ"]="ثي";e["ﰕ"]="جح";e["ﰖ"]="جم";e["ﰗ"]="حج";e["ﰘ"]="حم";e["ﰙ"]="خج";e["ﰚ"]="خح";e["ﰛ"]="خم";e["ﰜ"]="سج";e["ﰝ"]="سح";e["ﰞ"]="سخ";e["ﰟ"]="سم";e["ﰠ"]="صح";e["ﰡ"]="صم";e["ﰢ"]="ضج";e["ﰣ"]="ضح";e["ﰤ"]="ضخ";e["ﰥ"]="ضم";e["ﰦ"]="طح";e["ﰧ"]="طم";e["ﰨ"]="ظم";e["ﰩ"]="عج";e["ﰪ"]="عم";e["ﰫ"]="غج";e["ﰬ"]="غم";e["ﰭ"]="فج";e["ﰮ"]="فح";e["ﰯ"]="فخ";e["ﰰ"]="فم";e["ﰱ"]="فى";e["ﰲ"]="في";e["ﰳ"]="قح";e["ﰴ"]="قم";e["ﰵ"]="قى";e["ﰶ"]="قي";e["ﰷ"]="كا";e["ﰸ"]="كج";e["ﰹ"]="كح";e["ﰺ"]="كخ";e["ﰻ"]="كل";e["ﰼ"]="كم";e["ﰽ"]="كى";e["ﰾ"]="كي";e["ﰿ"]="لج";e["ﱀ"]="لح";e["ﱁ"]="لخ";e["ﱂ"]="لم";e["ﱃ"]="لى";e["ﱄ"]="لي";e["ﱅ"]="مج";e["ﱆ"]="مح";e["ﱇ"]="مخ";e["ﱈ"]="مم";e["ﱉ"]="مى";e["ﱊ"]="مي";e["ﱋ"]="نج";e["ﱌ"]="نح";e["ﱍ"]="نخ";e["ﱎ"]="نم";e["ﱏ"]="نى";e["ﱐ"]="ني";e["ﱑ"]="هج";e["ﱒ"]="هم";e["ﱓ"]="هى";e["ﱔ"]="هي";e["ﱕ"]="يج";e["ﱖ"]="يح";e["ﱗ"]="يخ";e["ﱘ"]="يم";e["ﱙ"]="يى";e["ﱚ"]="يي";e["ﱛ"]="ذٰ";e["ﱜ"]="رٰ";e["ﱝ"]="ىٰ";e["ﱞ"]=" ٌّ";e["ﱟ"]=" ٍّ";e["ﱠ"]=" َّ";e["ﱡ"]=" ُّ";e["ﱢ"]=" ِّ";e["ﱣ"]=" ّٰ";e["ﱤ"]="ئر";e["ﱥ"]="ئز";e["ﱦ"]="ئم";e["ﱧ"]="ئن";e["ﱨ"]="ئى";e["ﱩ"]="ئي";e["ﱪ"]="بر";e["ﱫ"]="بز";e["ﱬ"]="بم";e["ﱭ"]="بن";e["ﱮ"]="بى";e["ﱯ"]="بي";e["ﱰ"]="تر";e["ﱱ"]="تز";e["ﱲ"]="تم";e["ﱳ"]="تن";e["ﱴ"]="تى";e["ﱵ"]="تي";e["ﱶ"]="ثر";e["ﱷ"]="ثز";e["ﱸ"]="ثم";e["ﱹ"]="ثن";e["ﱺ"]="ثى";e["ﱻ"]="ثي";e["ﱼ"]="فى";e["ﱽ"]="في";e["ﱾ"]="قى";e["ﱿ"]="قي";e["ﲀ"]="كا";e["ﲁ"]="كل";e["ﲂ"]="كم";e["ﲃ"]="كى";e["ﲄ"]="كي";e["ﲅ"]="لم";e["ﲆ"]="لى";e["ﲇ"]="لي";e["ﲈ"]="ما";e["ﲉ"]="مم";e["ﲊ"]="نر";e["ﲋ"]="نز";e["ﲌ"]="نم";e["ﲍ"]="نن";e["ﲎ"]="نى";e["ﲏ"]="ني";e["ﲐ"]="ىٰ";e["ﲑ"]="ير";e["ﲒ"]="يز";e["ﲓ"]="يم";e["ﲔ"]="ين";e["ﲕ"]="يى";e["ﲖ"]="يي";e["ﲗ"]="ئج";e["ﲘ"]="ئح";e["ﲙ"]="ئخ";e["ﲚ"]="ئم";e["ﲛ"]="ئه";e["ﲜ"]="بج";e["ﲝ"]="بح";e["ﲞ"]="بخ";e["ﲟ"]="بم";e["ﲠ"]="به";e["ﲡ"]="تج";e["ﲢ"]="تح";e["ﲣ"]="تخ";e["ﲤ"]="تم";e["ﲥ"]="ته";e["ﲦ"]="ثم";e["ﲧ"]="جح";e["ﲨ"]="جم";e["ﲩ"]="حج";e["ﲪ"]="حم";e["ﲫ"]="خج";e["ﲬ"]="خم";e["ﲭ"]="سج";e["ﲮ"]="سح";e["ﲯ"]="سخ";e["ﲰ"]="سم";e["ﲱ"]="صح";e["ﲲ"]="صخ";e["ﲳ"]="صم";e["ﲴ"]="ضج";e["ﲵ"]="ضح";e["ﲶ"]="ضخ";e["ﲷ"]="ضم";e["ﲸ"]="طح";e["ﲹ"]="ظم";e["ﲺ"]="عج";e["ﲻ"]="عم";e["ﲼ"]="غج";e["ﲽ"]="غم";e["ﲾ"]="فج";e["ﲿ"]="فح";e["ﳀ"]="فخ";e["ﳁ"]="فم";e["ﳂ"]="قح";e["ﳃ"]="قم";e["ﳄ"]="كج";e["ﳅ"]="كح";e["ﳆ"]="كخ";e["ﳇ"]="كل";e["ﳈ"]="كم";e["ﳉ"]="لج";e["ﳊ"]="لح";e["ﳋ"]="لخ";e["ﳌ"]="لم";e["ﳍ"]="له";e["ﳎ"]="مج";e["ﳏ"]="مح";e["ﳐ"]="مخ";e["ﳑ"]="مم";e["ﳒ"]="نج";e["ﳓ"]="نح";e["ﳔ"]="نخ";e["ﳕ"]="نم";e["ﳖ"]="نه";e["ﳗ"]="هج";e["ﳘ"]="هم";e["ﳙ"]="هٰ";e["ﳚ"]="يج";e["ﳛ"]="يح";e["ﳜ"]="يخ";e["ﳝ"]="يم";e["ﳞ"]="يه";e["ﳟ"]="ئم";e["ﳠ"]="ئه";e["ﳡ"]="بم";e["ﳢ"]="به";e["ﳣ"]="تم";e["ﳤ"]="ته";e["ﳥ"]="ثم";e["ﳦ"]="ثه";e["ﳧ"]="سم";e["ﳨ"]="سه";e["ﳩ"]="شم";e["ﳪ"]="شه";e["ﳫ"]="كل";e["ﳬ"]="كم";e["ﳭ"]="لم";e["ﳮ"]="نم";e["ﳯ"]="نه";e["ﳰ"]="يم";e["ﳱ"]="يه";e["ﳲ"]="ـَّ";e["ﳳ"]="ـُّ";e["ﳴ"]="ـِّ";e["ﳵ"]="طى";e["ﳶ"]="طي";e["ﳷ"]="عى";e["ﳸ"]="عي";e["ﳹ"]="غى";e["ﳺ"]="غي";e["ﳻ"]="سى";e["ﳼ"]="سي";e["ﳽ"]="شى";e["ﳾ"]="شي";e["ﳿ"]="حى";e["ﴀ"]="حي";e["ﴁ"]="جى";e["ﴂ"]="جي";e["ﴃ"]="خى";e["ﴄ"]="خي";e["ﴅ"]="صى";e["ﴆ"]="صي";e["ﴇ"]="ضى";e["ﴈ"]="ضي";e["ﴉ"]="شج";e["ﴊ"]="شح";e["ﴋ"]="شخ";e["ﴌ"]="شم";e["ﴍ"]="شر";e["ﴎ"]="سر";e["ﴏ"]="صر";e["ﴐ"]="ضر";e["ﴑ"]="طى";e["ﴒ"]="طي";e["ﴓ"]="عى";e["ﴔ"]="عي";e["ﴕ"]="غى";e["ﴖ"]="غي";e["ﴗ"]="سى";e["ﴘ"]="سي";e["ﴙ"]="شى";e["ﴚ"]="شي";e["ﴛ"]="حى";e["ﴜ"]="حي";e["ﴝ"]="جى";e["ﴞ"]="جي";e["ﴟ"]="خى";e["ﴠ"]="خي";e["ﴡ"]="صى";e["ﴢ"]="صي";e["ﴣ"]="ضى";e["ﴤ"]="ضي";e["ﴥ"]="شج";e["ﴦ"]="شح";e["ﴧ"]="شخ";e["ﴨ"]="شم";e["ﴩ"]="شر";e["ﴪ"]="سر";e["ﴫ"]="صر";e["ﴬ"]="ضر";e["ﴭ"]="شج";e["ﴮ"]="شح";e["ﴯ"]="شخ";e["ﴰ"]="شم";e["ﴱ"]="سه";e["ﴲ"]="شه";e["ﴳ"]="طم";e["ﴴ"]="سج";e["ﴵ"]="سح";e["ﴶ"]="سخ";e["ﴷ"]="شج";e["ﴸ"]="شح";e["ﴹ"]="شخ";e["ﴺ"]="طم";e["ﴻ"]="ظم";e["ﴼ"]="اً";e["ﴽ"]="اً";e["ﵐ"]="تجم";e["ﵑ"]="تحج";e["ﵒ"]="تحج";e["ﵓ"]="تحم";e["ﵔ"]="تخم";e["ﵕ"]="تمج";e["ﵖ"]="تمح";e["ﵗ"]="تمخ";e["ﵘ"]="جمح";e["ﵙ"]="جمح";e["ﵚ"]="حمي";e["ﵛ"]="حمى";e["ﵜ"]="سحج";e["ﵝ"]="سجح";e["ﵞ"]="سجى";e["ﵟ"]="سمح";e["ﵠ"]="سمح";e["ﵡ"]="سمج";e["ﵢ"]="سمم";e["ﵣ"]="سمم";e["ﵤ"]="صحح";e["ﵥ"]="صحح";e["ﵦ"]="صمم";e["ﵧ"]="شحم";e["ﵨ"]="شحم";e["ﵩ"]="شجي";e["ﵪ"]="شمخ";e["ﵫ"]="شمخ";e["ﵬ"]="شمم";e["ﵭ"]="شمم";e["ﵮ"]="ضحى";e["ﵯ"]="ضخم";e["ﵰ"]="ضخم";e["ﵱ"]="طمح";e["ﵲ"]="طمح";e["ﵳ"]="طمم";e["ﵴ"]="طمي";e["ﵵ"]="عجم";e["ﵶ"]="عمم";e["ﵷ"]="عمم";e["ﵸ"]="عمى";e["ﵹ"]="غمم";e["ﵺ"]="غمي";e["ﵻ"]="غمى";e["ﵼ"]="فخم";e["ﵽ"]="فخم";e["ﵾ"]="قمح";e["ﵿ"]="قمم";e["ﶀ"]="لحم";e["ﶁ"]="لحي";e["ﶂ"]="لحى";e["ﶃ"]="لجج";e["ﶄ"]="لجج";e["ﶅ"]="لخم";e["ﶆ"]="لخم";e["ﶇ"]="لمح";e["ﶈ"]="لمح";e["ﶉ"]="محج";e["ﶊ"]="محم";e["ﶋ"]="محي";e["ﶌ"]="مجح";e["ﶍ"]="مجم";e["ﶎ"]="مخج";e["ﶏ"]="مخم";e["ﶒ"]="مجخ";e["ﶓ"]="همج";e["ﶔ"]="همم";e["ﶕ"]="نحم";e["ﶖ"]="نحى";e["ﶗ"]="نجم";e["ﶘ"]="نجم";e["ﶙ"]="نجى";e["ﶚ"]="نمي";e["ﶛ"]="نمى";e["ﶜ"]="يمم";e["ﶝ"]="يمم";e["ﶞ"]="بخي";e["ﶟ"]="تجي";e["ﶠ"]="تجى";e["ﶡ"]="تخي";e["ﶢ"]="تخى";e["ﶣ"]="تمي";e["ﶤ"]="تمى";e["ﶥ"]="جمي";e["ﶦ"]="جحى";e["ﶧ"]="جمى";e["ﶨ"]="سخى";e["ﶩ"]="صحي";e["ﶪ"]="شحي";e["ﶫ"]="ضحي";e["ﶬ"]="لجي";e["ﶭ"]="لمي";e["ﶮ"]="يحي";e["ﶯ"]="يجي";e["ﶰ"]="يمي";e["ﶱ"]="ممي";e["ﶲ"]="قمي";e["ﶳ"]="نحي";e["ﶴ"]="قمح";e["ﶵ"]="لحم";e["ﶶ"]="عمي";e["ﶷ"]="كمي";e["ﶸ"]="نجح";e["ﶹ"]="مخي";e["ﶺ"]="لجم";e["ﶻ"]="كمم";e["ﶼ"]="لجم";e["ﶽ"]="نجح";e["ﶾ"]="جحي";e["ﶿ"]="حجي";e["ﷀ"]="مجي";e["ﷁ"]="فمي";e["ﷂ"]="بحي";e["ﷃ"]="كمم";e["ﷄ"]="عجم";e["ﷅ"]="صمم";e["ﷆ"]="سخي";e["ﷇ"]="نجي";e["﹉"]="‾";e["﹊"]="‾";e["﹋"]="‾";e["﹌"]="‾";e["﹍"]="_";e["﹎"]="_";e["﹏"]="_";e["ﺀ"]="ء";e["ﺁ"]="آ";e["ﺂ"]="آ";e["ﺃ"]="أ";e["ﺄ"]="أ";e["ﺅ"]="ؤ";e["ﺆ"]="ؤ";e["ﺇ"]="إ";e["ﺈ"]="إ";e["ﺉ"]="ئ";e["ﺊ"]="ئ";e["ﺋ"]="ئ";e["ﺌ"]="ئ";e["ﺍ"]="ا";e["ﺎ"]="ا";e["ﺏ"]="ب";e["ﺐ"]="ب";e["ﺑ"]="ب";e["ﺒ"]="ب";e["ﺓ"]="ة";e["ﺔ"]="ة";e["ﺕ"]="ت";e["ﺖ"]="ت";e["ﺗ"]="ت";e["ﺘ"]="ت";e["ﺙ"]="ث";e["ﺚ"]="ث";e["ﺛ"]="ث";e["ﺜ"]="ث";e["ﺝ"]="ج";e["ﺞ"]="ج";e["ﺟ"]="ج";e["ﺠ"]="ج";e["ﺡ"]="ح";e["ﺢ"]="ح";e["ﺣ"]="ح";e["ﺤ"]="ح";e["ﺥ"]="خ";e["ﺦ"]="خ";e["ﺧ"]="خ";e["ﺨ"]="خ";e["ﺩ"]="د";e["ﺪ"]="د";e["ﺫ"]="ذ";e["ﺬ"]="ذ";e["ﺭ"]="ر";e["ﺮ"]="ر";e["ﺯ"]="ز";e["ﺰ"]="ز";e["ﺱ"]="س";e["ﺲ"]="س";e["ﺳ"]="س";e["ﺴ"]="س";e["ﺵ"]="ش";e["ﺶ"]="ش";e["ﺷ"]="ش";e["ﺸ"]="ش";e["ﺹ"]="ص";e["ﺺ"]="ص";e["ﺻ"]="ص";e["ﺼ"]="ص";e["ﺽ"]="ض";e["ﺾ"]="ض";e["ﺿ"]="ض";e["ﻀ"]="ض";e["ﻁ"]="ط";e["ﻂ"]="ط";e["ﻃ"]="ط";e["ﻄ"]="ط";e["ﻅ"]="ظ";e["ﻆ"]="ظ";e["ﻇ"]="ظ";e["ﻈ"]="ظ";e["ﻉ"]="ع";e["ﻊ"]="ع";e["ﻋ"]="ع";e["ﻌ"]="ع";e["ﻍ"]="غ";e["ﻎ"]="غ";e["ﻏ"]="غ";e["ﻐ"]="غ";e["ﻑ"]="ف";e["ﻒ"]="ف";e["ﻓ"]="ف";e["ﻔ"]="ف";e["ﻕ"]="ق";e["ﻖ"]="ق";e["ﻗ"]="ق";e["ﻘ"]="ق";e["ﻙ"]="ك";e["ﻚ"]="ك";e["ﻛ"]="ك";e["ﻜ"]="ك";e["ﻝ"]="ل";e["ﻞ"]="ل";e["ﻟ"]="ل";e["ﻠ"]="ل";e["ﻡ"]="م";e["ﻢ"]="م";e["ﻣ"]="م";e["ﻤ"]="م";e["ﻥ"]="ن";e["ﻦ"]="ن";e["ﻧ"]="ن";e["ﻨ"]="ن";e["ﻩ"]="ه";e["ﻪ"]="ه";e["ﻫ"]="ه";e["ﻬ"]="ه";e["ﻭ"]="و";e["ﻮ"]="و";e["ﻯ"]="ى";e["ﻰ"]="ى";e["ﻱ"]="ي";e["ﻲ"]="ي";e["ﻳ"]="ي";e["ﻴ"]="ي";e["ﻵ"]="لآ";e["ﻶ"]="لآ";e["ﻷ"]="لأ";e["ﻸ"]="لأ";e["ﻹ"]="لإ";e["ﻺ"]="لإ";e["ﻻ"]="لا";e["ﻼ"]="لا"});t.mapSpecialUnicodeValues=r;t.reverseIfRtl=o;t.getUnicodeRangeFor=n;t.getNormalizedUnicodes=f;t.getUnicodeForGlyph=i},function(e,t,a){"use strict";function r(e,t){this.url=e;t=t||{};this.isHttp=/^https?:/i.test(e);this.httpHeaders=this.isHttp&&t.httpHeaders||{};this.withCredentials=t.withCredentials||!1;this.getXhr=t.getXhr||function(){return new XMLHttpRequest};this.currXhrId=0;this.pendingRequests=Object.create(null);this.loadedRequests=Object.create(null)}function i(e){var t=e.response;if("string"!=typeof t)return t;for(var a=t.length,r=new Uint8Array(a),i=0;i=2&&a.onHeadersReceived){a.onHeadersReceived();delete a.onHeadersReceived}if(4===r.readyState&&e in this.pendingRequests){delete this.pendingRequests[e];if(0===r.status&&this.isHttp)a.onError&&a.onError(r.status);else{var n=r.status||200;if(200===n&&206===a.expectedStatus||n===a.expectedStatus){this.loadedRequests[e]=!0;var s=i(r);if(206===n){var o=r.getResponseHeader("Content-Range"),c=/bytes (\d+)-(\d+)\/(\d+)/.exec(o),l=parseInt(c[1],10);a.onDone({begin:l,chunk:s})}else a.onProgressiveData?a.onDone(null):s?a.onDone({begin:0,chunk:s}):a.onError&&a.onError(r.status)}else a.onError&&a.onError(r.status)}}}},hasPendingRequests:function(){for(var e in this.pendingRequests)return!0;return!1},getRequestXhr:function(e){return this.pendingRequests[e].xhr},isStreamingRequest:function(e){return!!this.pendingRequests[e].onProgressiveData},isPendingRequest:function(e){return e in this.pendingRequests},isLoadedRequest:function(e){return e in this.loadedRequests},abortAllRequests:function(){for(var e in this.pendingRequests)this.abortRequest(0|e)},abortRequest:function(e){var t=this.pendingRequests[e].xhr;delete this.pendingRequests[e];t.abort()}};var f=c.assert,d=c.createPromiseCapability,g=c.isInt,p=c.MissingPDFException,m=c.UnexpectedResponseException;n.prototype={_onRangeRequestReaderClosed:function(e){var t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)},getFullReader:function(){f(!this._fullRequestReader);this._fullRequestReader=new s(this._manager,this._options);return this._fullRequestReader},getRangeReader:function(e,t){var a=new o(this._manager,e,t);a.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(a);return a},cancelAllRequests:function(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeRequestReaders.slice(0).forEach(function(t){t.cancel(e)})}};s.prototype={_validateRangeRequestCapabilities:function(){if(this._disableRange)return!1;var e=this._manager;if(!e.isHttp)return!1;var t=this._fullRequestId,a=e.getRequestXhr(t);if("bytes"!==a.getResponseHeader("Accept-Ranges"))return!1;if("identity"!==(a.getResponseHeader("Content-Encoding")||"identity"))return!1;var r=a.getResponseHeader("Content-Length");r=parseInt(r,10);if(!g(r))return!1;this._contentLength=r;return!(r<=2*this._rangeChunkSize)},_onHeadersReceived:function(){this._validateRangeRequestCapabilities()&&(this._isRangeSupported=!0);var e=this._manager,t=this._fullRequestId;e.isStreamingRequest(t)?this._isStreamingSupported=!0:this._isRangeSupported&&e.abortRequest(t);this._headersReceivedCapability.resolve()},_onProgressiveData:function(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._cachedChunks.push(e)},_onDone:function(e){e&&this._onProgressiveData(e.chunk);this._done=!0;if(!(this._cachedChunks.length>0)){this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[]}},_onError:function(e){var t,a=this._url;t=404===e||0===e&&/^file:/.test(a)?new p('Missing PDF "'+a+'".'):new m("Unexpected server response ("+e+') while retrieving PDF "'+a+'".',e);this._storedError=t;this._headersReceivedCapability.reject(t);this._requests.forEach(function(e){e.reject(t)});this._requests=[];this._cachedChunks=[]},_onProgress:function(e){this.onProgress&&this.onProgress({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})},get isRangeSupported(){return this._isRangeSupported},get isStreamingSupported(){return this._isStreamingSupported},get contentLength(){return this._contentLength},get headersReady(){return this._headersReceivedCapability.promise},read:function(){if(this._storedError)return Promise.reject(this._storedError);if(this._cachedChunks.length>0){var e=this._cachedChunks.shift();return Promise.resolve(e)}if(this._done)return Promise.resolve({value:void 0,done:!0});var t=d();this._requests.push(t);return t.promise},cancel:function(e){this._done=!0;this._headersReceivedCapability.reject(e);this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId);this._fullRequestReader=null}};o.prototype={_close:function(){this.onClosed&&this.onClosed(this)},_onDone:function(e){var t=e.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._close()},_onProgress:function(e){!this.isStreamingSupported&&this.onProgress&&this.onProgress({loaded:e.loaded})},get isStreamingSupported(){return!1},read:function(){if(null!==this._queuedChunk){var e=this._queuedChunk;this._queuedChunk=null;return Promise.resolve({value:e,done:!1})}if(this._done)return Promise.resolve({value:void 0,done:!0});var t=d();this._requests.push(t);return t.promise},cancel:function(e){this._done=!0;this._requests.forEach(function(e){e.resolve({value:void 0,done:!0})});this._requests=[];this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId);this._close()}};l.setPDFNetworkStreamClass(n);t.PDFNetworkStream=n;t.NetworkManager=r},function(e,t,a){"use strict";function r(){}var i=a(0),n=a(1),s=a(2),o=a(3),c=a(16),l=a(14),h=i.AnnotationBorderStyleType,u=i.AnnotationFieldFlag,f=i.AnnotationFlag,d=i.AnnotationType,g=i.OPS,p=i.Util,m=i.isArray,b=i.isInt,v=i.stringToBytes,y=i.stringToPDFString,k=i.warn,w=n.Dict,C=n.isDict,x=n.isName,S=n.isRef,A=n.isStream,I=s.Stream,B=o.ColorSpace,R=c.Catalog,T=c.ObjectLoader,O=c.FileSpec,P=l.OperatorList;r.prototype={create:function(e,t,a,r){var i=e.fetchIfRef(t);if(C(i)){var n=S(t)?t.toString():"annot_"+r.createObjId(),s=i.get("Subtype");s=x(s)?s.name:null;var o={xref:e,dict:i,ref:S(t)?t:null,subtype:s,id:n,pdfManager:a};switch(s){case"Link":return new N(o);case"Text":return new U(o);case"Widget":var c=p.getInheritableProperty(i,"FT");c=x(c)?c.name:null;switch(c){case"Tx":return new D(o);case"Btn":return new F(o);case"Ch":return new q(o)}k('Unimplemented widget field type "'+c+'", falling back to base field type.');return new L(o);case"Popup":return new j(o);case"Highlight":return new _(o);case"Underline":return new z(o);case"Squiggly":return new H(o);case"StrikeOut":return new G(o);case"FileAttachment":return new X(o);default:k(s?'Unimplemented annotation type "'+s+'", falling back to base annotation.':"Annotation is missing the required /Subtype.");return new M(o)}}}};var M=function(){function e(e,t,a){var r=p.getAxialAlignedBoundingBox(t,a),i=r[0],n=r[1],s=r[2],o=r[3];if(i===s||n===o)return[1,0,0,1,e[0],e[1]];var c=(e[2]-e[0])/(s-i),l=(e[3]-e[1])/(o-n);return[c,0,0,l,e[0]-i*c,e[1]-n*l]}function t(e){var t=e.dict;this.setFlags(t.get("F"));this.setRectangle(t.getArray("Rect"));this.setColor(t.getArray("C"));this.setBorderStyle(t);this.setAppearance(t);this.data={};this.data.id=e.id;this.data.subtype=e.subtype;this.data.annotationFlags=this.flags;this.data.rect=this.rectangle;this.data.color=this.color;this.data.borderStyle=this.borderStyle;this.data.hasAppearance=!!this.appearance}t.prototype={_hasFlag:function(e,t){return!!(e&t)},_isViewable:function(e){return!this._hasFlag(e,f.INVISIBLE)&&!this._hasFlag(e,f.HIDDEN)&&!this._hasFlag(e,f.NOVIEW)},_isPrintable:function(e){return this._hasFlag(e,f.PRINT)&&!this._hasFlag(e,f.INVISIBLE)&&!this._hasFlag(e,f.HIDDEN)},get viewable(){return 0===this.flags||this._isViewable(this.flags)},get printable(){return 0!==this.flags&&this._isPrintable(this.flags)},setFlags:function(e){this.flags=b(e)&&e>0?e:0},hasFlag:function(e){return this._hasFlag(this.flags,e)},setRectangle:function(e){m(e)&&4===e.length?this.rectangle=p.normalizeRect(e):this.rectangle=[0,0,0,0]},setColor:function(e){var t=new Uint8Array(3);if(m(e))switch(e.length){case 0:this.color=null;break;case 1:B.singletons.gray.getRgbItem(e,0,t,0);this.color=t;break;case 3:B.singletons.rgb.getRgbItem(e,0,t,0);this.color=t;break;case 4:B.singletons.cmyk.getRgbItem(e,0,t,0);this.color=t;break;default:this.color=t}else this.color=t},setBorderStyle:function(e){this.borderStyle=new E;if(C(e))if(e.has("BS")){var t=e.get("BS"),a=t.get("Type");if(!a||x(a,"Border")){this.borderStyle.setWidth(t.get("W"));this.borderStyle.setStyle(t.get("S"));this.borderStyle.setDashArray(t.getArray("D"))}}else if(e.has("Border")){var r=e.getArray("Border");if(m(r)&&r.length>=3){this.borderStyle.setHorizontalCornerRadius(r[0]);this.borderStyle.setVerticalCornerRadius(r[1]);this.borderStyle.setWidth(r[2]);4===r.length&&this.borderStyle.setDashArray(r[3])}}else this.borderStyle.setWidth(0)},setAppearance:function(e){this.appearance=null;var t=e.get("AP");if(C(t)){var a=t.get("N");if(A(a))this.appearance=a;else if(C(a)){var r=e.get("AS");x(r)&&a.has(r.name)&&(this.appearance=a.get(r.name))}}},_preparePopup:function(e){e.has("C")||(this.data.color=null);this.data.hasPopup=e.has("Popup");this.data.title=y(e.get("T")||"");this.data.contents=y(e.get("Contents")||"")},loadResources:function(e){return new Promise(function(t,a){this.appearance.dict.getAsync("Resources").then(function(r){if(r){new T(r.map,e,r.xref).load().then(function(){t(r)},a)}else t()},a)}.bind(this))},getOperatorList:function(t,a,r){if(!this.appearance)return Promise.resolve(new P);var i=this.data,n=this.appearance.dict,s=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),o=n.getArray("BBox")||[0,0,1,1],c=n.getArray("Matrix")||[1,0,0,1,0,0],l=e(i.rect,o,c),h=this;return s.then(function(e){var r=new P;r.addOp(g.beginAnnotation,[i.rect,l,c]);return t.getOperatorList(h.appearance,a,e,r).then(function(){r.addOp(g.endAnnotation,[]);h.appearance.reset();return r})})}};return t}(),E=function(){function e(){this.width=1;this.style=h.SOLID;this.dashArray=[3];this.horizontalCornerRadius=0;this.verticalCornerRadius=0}e.prototype={setWidth:function(e){e===(0|e)&&(this.width=e)},setStyle:function(e){if(e)switch(e.name){case"S":this.style=h.SOLID;break;case"D":this.style=h.DASHED;break;case"B":this.style=h.BEVELED;break;case"I":this.style=h.INSET;break;case"U":this.style=h.UNDERLINE}},setDashArray:function(e){if(m(e)&&e.length>0){for(var t=!0,a=!0,r=0,i=e.length;r=0)){t=!1;break}n>0&&(a=!1)}t&&!a?this.dashArray=e:this.width=0}else e&&(this.width=0)},setHorizontalCornerRadius:function(e){e===(0|e)&&(this.horizontalCornerRadius=e)},setVerticalCornerRadius:function(e){e===(0|e)&&(this.verticalCornerRadius=e)}};return e}(),L=function(){function e(e){M.call(this,e);var t=e.dict,a=this.data;a.annotationType=d.WIDGET;a.fieldName=this._constructFieldName(t);a.fieldValue=p.getInheritableProperty(t,"V",!0);a.alternativeText=y(t.get("TU")||"");a.defaultAppearance=p.getInheritableProperty(t,"DA")||"";var r=p.getInheritableProperty(t,"FT");a.fieldType=x(r)?r.name:null;this.fieldResources=p.getInheritableProperty(t,"DR")||w.empty;a.fieldFlags=p.getInheritableProperty(t,"Ff");(!b(a.fieldFlags)||a.fieldFlags<0)&&(a.fieldFlags=0);a.readOnly=this.hasFieldFlag(u.READONLY);"Sig"===a.fieldType&&this.setFlags(f.HIDDEN)}p.inherit(e,M,{_constructFieldName:function(e){if(!e.has("T")&&!e.has("Parent")){k("Unknown field name, falling back to empty field name.");return""}if(!e.has("Parent"))return y(e.get("T"));var t=[];e.has("T")&&t.unshift(y(e.get("T")));for(var a=e;a.has("Parent");){a=a.get("Parent");if(!C(a))break;a.has("T")&&t.unshift(y(a.get("T")))}return t.join(".")},hasFieldFlag:function(e){return!!(this.data.fieldFlags&e)}});return e}(),D=function(){function e(e){L.call(this,e);this.data.fieldValue=y(this.data.fieldValue||"");var t=p.getInheritableProperty(e.dict,"Q");(!b(t)||t<0||t>2)&&(t=null);this.data.textAlignment=t;var a=p.getInheritableProperty(e.dict,"MaxLen");(!b(a)||a<0)&&(a=null);this.data.maxLen=a;this.data.multiLine=this.hasFieldFlag(u.MULTILINE);this.data.comb=this.hasFieldFlag(u.COMB)&&!this.hasFieldFlag(u.MULTILINE)&&!this.hasFieldFlag(u.PASSWORD)&&!this.hasFieldFlag(u.FILESELECT)&&null!==this.data.maxLen}p.inherit(e,L,{getOperatorList:function(e,t,a){var r=new P;if(a)return Promise.resolve(r);if(this.appearance)return M.prototype.getOperatorList.call(this,e,t,a);if(!this.data.defaultAppearance)return Promise.resolve(r);var i=new I(v(this.data.defaultAppearance));return e.getOperatorList(i,t,this.fieldResources,r).then(function(){return r})}});return e}(),F=function(){function e(e){L.call(this,e);this.data.checkBox=!this.hasFieldFlag(u.RADIO)&&!this.hasFieldFlag(u.PUSHBUTTON);if(this.data.checkBox){if(!x(this.data.fieldValue))return;this.data.fieldValue=this.data.fieldValue.name}this.data.radioButton=this.hasFieldFlag(u.RADIO)&&!this.hasFieldFlag(u.PUSHBUTTON);if(this.data.radioButton){this.data.fieldValue=this.data.buttonValue=null;var t=e.dict.get("Parent");if(C(t)&&t.has("V")){var a=t.get("V");x(a)&&(this.data.fieldValue=a.name)}var r=e.dict.get("AP");if(!C(r))return;var i=r.get("N");if(!C(i))return;for(var n=i.getKeys(),s=0,o=n.length;s=0&&"ET"===p[B];--B)p[B]="EN";for(B=m+1;B0&&(T=p[m-1]);var O=S;R+1P&&r(P)&&(E=P)}for(P=M;P>=E;--P){var L=-1;for(m=0,b=w.length;m=0){o(g,L,m);L=-1}}else L<0&&(L=m);L>=0&&o(g,L,w.length)}for(m=0,b=g.length;m"!==D||(g[m]="")}return c(g.join(""),l)} +var h=a(0),u=h.warn,f=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],d=["AN","AN","AN","AN","AN","AN","ON","ON","AL","ET","ET","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL"],g=[],p=[];t.bidi=l},function(e,t,a){"use strict";var r=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],i=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],n=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];t.ISOAdobeCharset=r;t.ExpertCharset=i;t.ExpertSubsetCharset=n},function(e,t,a){"use strict";var r=a(0),i=a(1),n=a(2),s=a(5),o=r.Util,c=r.assert,l=r.warn,h=r.error,u=r.isInt,f=r.isString,d=r.MissingDataException,g=r.CMapCompressionType,p=i.isEOF,m=i.isName,b=i.isCmd,v=i.isStream,y=n.Stream,k=s.Lexer,w=["Adobe-GB1-UCS2","Adobe-CNS1-UCS2","Adobe-Japan1-UCS2","Adobe-Korea1-UCS2","78-EUC-H","78-EUC-V","78-H","78-RKSJ-H","78-RKSJ-V","78-V","78ms-RKSJ-H","78ms-RKSJ-V","83pv-RKSJ-H","90ms-RKSJ-H","90ms-RKSJ-V","90msp-RKSJ-H","90msp-RKSJ-V","90pv-RKSJ-H","90pv-RKSJ-V","Add-H","Add-RKSJ-H","Add-RKSJ-V","Add-V","Adobe-CNS1-0","Adobe-CNS1-1","Adobe-CNS1-2","Adobe-CNS1-3","Adobe-CNS1-4","Adobe-CNS1-5","Adobe-CNS1-6","Adobe-GB1-0","Adobe-GB1-1","Adobe-GB1-2","Adobe-GB1-3","Adobe-GB1-4","Adobe-GB1-5","Adobe-Japan1-0","Adobe-Japan1-1","Adobe-Japan1-2","Adobe-Japan1-3","Adobe-Japan1-4","Adobe-Japan1-5","Adobe-Japan1-6","Adobe-Korea1-0","Adobe-Korea1-1","Adobe-Korea1-2","B5-H","B5-V","B5pc-H","B5pc-V","CNS-EUC-H","CNS-EUC-V","CNS1-H","CNS1-V","CNS2-H","CNS2-V","ETHK-B5-H","ETHK-B5-V","ETen-B5-H","ETen-B5-V","ETenms-B5-H","ETenms-B5-V","EUC-H","EUC-V","Ext-H","Ext-RKSJ-H","Ext-RKSJ-V","Ext-V","GB-EUC-H","GB-EUC-V","GB-H","GB-V","GBK-EUC-H","GBK-EUC-V","GBK2K-H","GBK2K-V","GBKp-EUC-H","GBKp-EUC-V","GBT-EUC-H","GBT-EUC-V","GBT-H","GBT-V","GBTpc-EUC-H","GBTpc-EUC-V","GBpc-EUC-H","GBpc-EUC-V","H","HKdla-B5-H","HKdla-B5-V","HKdlb-B5-H","HKdlb-B5-V","HKgccs-B5-H","HKgccs-B5-V","HKm314-B5-H","HKm314-B5-V","HKm471-B5-H","HKm471-B5-V","HKscs-B5-H","HKscs-B5-V","Hankaku","Hiragana","KSC-EUC-H","KSC-EUC-V","KSC-H","KSC-Johab-H","KSC-Johab-V","KSC-V","KSCms-UHC-H","KSCms-UHC-HW-H","KSCms-UHC-HW-V","KSCms-UHC-V","KSCpc-EUC-H","KSCpc-EUC-V","Katakana","NWP-H","NWP-V","RKSJ-H","RKSJ-V","Roman","UniCNS-UCS2-H","UniCNS-UCS2-V","UniCNS-UTF16-H","UniCNS-UTF16-V","UniCNS-UTF32-H","UniCNS-UTF32-V","UniCNS-UTF8-H","UniCNS-UTF8-V","UniGB-UCS2-H","UniGB-UCS2-V","UniGB-UTF16-H","UniGB-UTF16-V","UniGB-UTF32-H","UniGB-UTF32-V","UniGB-UTF8-H","UniGB-UTF8-V","UniJIS-UCS2-H","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V","UniJIS-UCS2-V","UniJIS-UTF16-H","UniJIS-UTF16-V","UniJIS-UTF32-H","UniJIS-UTF32-V","UniJIS-UTF8-H","UniJIS-UTF8-V","UniJIS2004-UTF16-H","UniJIS2004-UTF16-V","UniJIS2004-UTF32-H","UniJIS2004-UTF32-V","UniJIS2004-UTF8-H","UniJIS2004-UTF8-V","UniJISPro-UCS2-HW-V","UniJISPro-UCS2-V","UniJISPro-UTF8-V","UniJISX0213-UTF32-H","UniJISX0213-UTF32-V","UniJISX02132004-UTF32-H","UniJISX02132004-UTF32-V","UniKS-UCS2-H","UniKS-UCS2-V","UniKS-UTF16-H","UniKS-UTF16-V","UniKS-UTF32-H","UniKS-UTF32-V","UniKS-UTF8-H","UniKS-UTF8-V","V","WP-Symbol"],C=function(){function e(e){this.codespaceRanges=[[],[],[],[]];this.numCodespaceRanges=0;this._map=[];this.name="";this.vertical=!1;this.useCMap=null;this.builtInCMap=e}e.prototype={addCodespaceRange:function(e,t,a){this.codespaceRanges[e-1].push(t,a);this.numCodespaceRanges++},mapCidRange:function(e,t,a){for(;e<=t;)this._map[e++]=a++},mapBfRange:function(e,t,a){for(var r=a.length-1;e<=t;){this._map[e++]=a;a=a.substr(0,r)+String.fromCharCode(a.charCodeAt(r)+1)}},mapBfRangeToArray:function(e,t,a){for(var r=0,i=a.length;e<=t&&r>>0;for(var o=i[s],c=0,l=o.length;c=h&&r<=u){a.charcode=r;a.length=s+1;return}}}a.charcode=0;a.length=1},get length(){return this._map.length},get isIdentityCMap(){if("Identity-H"!==this.name&&"Identity-V"!==this.name)return!1;if(65536!==this._map.length)return!1;for(var e=0;e<65536;e++)if(this._map[e]!==e)return!1;return!0}};return e}(),x=function(){function e(e,t){C.call(this);this.vertical=e;this.addCodespaceRange(t,0,65535)}o.inherit(e,C,{});e.prototype={addCodespaceRange:C.prototype.addCodespaceRange,mapCidRange:function(e,t,a){h("should not call mapCidRange")},mapBfRange:function(e,t,a){h("should not call mapBfRange")},mapBfRangeToArray:function(e,t,a){h("should not call mapBfRangeToArray")},mapOne:function(e,t){h("should not call mapCidOne")},lookup:function(e){return u(e)&&e<=65535?e:void 0},contains:function(e){return u(e)&&e<=65535},forEach:function(e){for(var t=0;t<=65535;t++)e(t,t)},charCodeOf:function(e){return u(e)&&e<=65535?e:-1},getMap:function(){for(var e=new Array(65536),t=0;t<=65535;t++)e[t]=t;return e},readCharCode:C.prototype.readCharCode,get length(){return 65536},get isIdentityCMap(){h("should not access .isIdentityCMap")}};return e}(),S=function(){function e(e,t){for(var a=0,r=0;r<=t;r++)a=a<<8|e[r];return a>>>0}function t(e,t){return 1===t?String.fromCharCode(e[0],e[1]):3===t?String.fromCharCode(e[0],e[1],e[2],e[3]):String.fromCharCode.apply(null,e.subarray(0,t+1))}function a(e,t,a){for(var r=0,i=a;i>=0;i--){r+=e[i]+t[i];e[i]=255&r;r>>=8}}function r(e,t){for(var a=1,r=t;r>=0&&a>0;r--){a+=e[r];e[r]=255&a;a>>=8}}function i(e){this.buffer=e;this.pos=0;this.end=e.length;this.tmpBuf=new Uint8Array(l)}function n(n,s,l){return new Promise(function(h,u){var f=new i(n),d=f.readByte();s.vertical=!!(1&d);for(var g,p,m=null,b=new Uint8Array(o),v=new Uint8Array(o),y=new Uint8Array(o),k=new Uint8Array(o),w=new Uint8Array(o);(p=f.readByte())>=0;){var C=p>>5;if(7!==C){var x=!!(16&p),S=15&p;c(S+1<=o);var A,I=f.readNumber();switch(C){case 0:f.readHex(b,S);f.readHexNumber(v,S);a(v,b,S);s.addCodespaceRange(S+1,e(b,S),e(v,S));for(A=1;A=this.end?-1:this.buffer[this.pos++]},readNumber:function(){var e,t=0;do{var a=this.readByte();a<0&&h("unexpected EOF in bcmap");e=!(128&a);t=t<<7|127&a}while(!e);return t},readSigned:function(){var e=this.readNumber();return 1&e?~(e>>>1):e>>>1},readHex:function(e,t){e.set(this.buffer.subarray(this.pos,this.pos+t+1));this.pos+=t+1},readHexNumber:function(e,t){var a,r=this.tmpBuf,i=0;do{var n=this.readByte();n<0&&h("unexpected EOF in bcmap");a=!(128&n);r[i++]=127&n}while(!a);for(var s=t,o=0,c=0;s>=0;){for(;c<8&&r.length>0;){o=r[--i]<>=8;c-=8}},readHexSigned:function(e,t){this.readHexNumber(e,t);for(var a=1&e[t]?255:0,r=0,i=0;i<=t;i++){r=(1&r)<<8|e[i];e[i]=r>>1^a}},readString:function(){for(var e=this.readNumber(),t="",a=0;a>>0}function t(e){f(e)||h("Malformed CMap: expected string.")}function a(e){u(e)||h("Malformed CMap: expected int.")}function r(a,r){for(;;){var i=r.getObj();if(p(i))break;if(b(i,"endbfchar"))return;t(i);var n=e(i);i=r.getObj();t(i);var s=i;a.mapOne(n,s)}}function i(a,r){for(;;){var i=r.getObj();if(p(i))break;if(b(i,"endbfrange"))return;t(i);var n=e(i);i=r.getObj();t(i);var s=e(i);i=r.getObj();if(u(i)||f(i)){var o=u(i)?String.fromCharCode(i):i;a.mapBfRange(n,s,o)}else{if(!b(i,"["))break;i=r.getObj();for(var c=[];!b(i,"]")&&!p(i);){c.push(i);i=r.getObj()}a.mapBfRangeToArray(n,s,c)}}h("Invalid bf range.")}function n(r,i){for(;;){var n=i.getObj();if(p(n))break;if(b(n,"endcidchar"))return;t(n);var s=e(n);n=i.getObj();a(n);var o=n;r.mapOne(s,o)}}function s(r,i){for(;;){var n=i.getObj();if(p(n))break;if(b(n,"endcidrange"))return;t(n);var s=e(n);n=i.getObj();t(n);var o=e(n);n=i.getObj();a(n);var c=n;r.mapCidRange(s,o,c)}}function o(t,a){for(;;){var r=a.getObj();if(p(r))break;if(b(r,"endcodespacerange"))return;if(!f(r))break;var i=e(r);r=a.getObj();if(!f(r))break;var n=e(r);t.addCodespaceRange(r.length,i,n)}h("Invalid codespace range.")}function A(e,t){var a=t.getObj();u(a)&&(e.vertical=!!a)}function I(e,t){var a=t.getObj();m(a)&&f(a.name)&&(e.name=a.name)}function B(e,t,a,c){var h,u;e:for(;;)try{var f=t.getObj();if(p(f))break;if(m(f)){"WMode"===f.name?A(e,t):"CMapName"===f.name&&I(e,t);h=f}else if(b(f))switch(f.cmd){case"endcmap":break e;case"usecmap":m(h)&&(u=h.name);break;case"begincodespacerange":o(e,t);break;case"beginbfchar":r(e,t);break;case"begincidchar":n(e,t);break;case"beginbfrange":i(e,t);break;case"begincidrange":s(e,t)}}catch(e){if(e instanceof d)throw e;l("Invalid cMap data: "+e);continue}!c&&u&&(c=u);return c?R(e,a,c):Promise.resolve(e)}function R(e,t,a){return T(a,t).then(function(t){e.useCMap=t;if(0===e.numCodespaceRanges){for(var a=e.useCMap.codespaceRanges,r=0;r100){S("getInheritedPageProp: maximum loop count exceeded for "+e);return r?r[0]:void 0}a=a.get("Parent")}if(r)return 1!==r.length&&B(r[0])?I.merge(this.xref,r):r[0]},get content(){return this.getPageProp("Contents")},get resources(){return w(this,"resources",this.getInheritedPageProp("Resources")||I.empty)},get mediaBox(){var e=this.getInheritedPageProp("MediaBox",!0);return b(e)&&4===e.length?w(this,"mediaBox",e):w(this,"mediaBox",a)},get cropBox(){var e=this.getInheritedPageProp("CropBox",!0);return b(e)&&4===e.length?w(this,"cropBox",e):w(this,"cropBox",this.mediaBox)},get userUnit(){var e=this.getPageProp("UserUnit");(!y(e)||e<=0)&&(e=1);return w(this,"userUnit",e)},get view(){var e=this.mediaBox,t=this.cropBox;if(e===t)return w(this,"view",e);var a=d.intersect(t,e);return w(this,"view",a||e)},get rotate(){var e=this.getInheritedPageProp("Rotate")||0;e%90!=0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360);return w(this,"rotate",e)},getContentStream:function(){var e,t=this.content;if(b(t)){var a,r=this.xref,i=t.length,n=[];for(a=0;a0,"stream must have data");this.pdfManager=e;this.stream=a;this.xref=new D(a,e)}function t(e,t,a,r){var i=e.pos,n=e.end,s=[];i+a>n&&(a=n-i);for(var o=0;o0;){i-=1024-"startxref".length;i<0&&(i=0);e.pos=i;r=t(e,"startxref",1024,!0)}if(r){e.skip(9);var n;do{n=e.getByte()}while(A(n));for(var s="";n>=32&&n<=57;){s+=String.fromCharCode(n);n=e.getByte()}a=parseInt(s,10);isNaN(a)&&(a=0)}}return w(this,"startXRef",a)},get mainXRefEntriesOffset(){var e=0,t=this.linearization;t&&(e=t.mainXRefEntriesOffset);return w(this,"mainXRefEntriesOffset",e)},checkHeader:function(){var e=this.stream;e.reset();if(t(e,"%PDF-",1024)){e.moveStart();for(var a,r="";(a=e.getByte())>32&&!(r.length>=12);)r+=String.fromCharCode(a);this.pdfFormatVersion||(this.pdfFormatVersion=r.substring(5))}else;},parseStartXRef:function(){var e=this.startXRef;this.xref.setStartXRef(e)},setup:function(e){this.xref.parse(e);var t=this,a={createPage:function(e,a,r,i,n){return new _(t.pdfManager,t.xref,e,a,r,i,n)}};this.catalog=new E(this.pdfManager,this.xref,a)},get numPages(){var e=this.linearization,t=e?e.numPages:this.catalog.numPages;return w(this,"numPages",t)},get documentInfo(){var e,t={PDFFormatVersion:this.pdfFormatVersion,IsAcroFormPresent:!!this.acroForm,IsXFAPresent:!!this.xfa};try{e=this.xref.trailer.get("Info")}catch(e){if(e instanceof f)throw e;m("The document information dictionary is invalid.")}if(e){var r=a.entries;for(var i in r)if(e.has(i)){var n=e.get(i);r[i](n)?t[i]="string"!=typeof n?n:x(n):m('Bad value in document info for "'+i+'"')}}return w(this,"documentInfo",t)},get fingerprint(){var e,t=this.xref,a="",r=t.trailer.get("ID");if(r&&b(r)&&r[0]&&k(r[0])&&"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"!==r[0])e=C(r[0]);else{this.stream.ensureRange&&this.stream.ensureRange(0,Math.min(1024,this.stream.end));e=q(this.stream.bytes.subarray(0,1024),0,1024)}for(var i=0,n=e.length;i>1;s=r+c+14;n=[];for(o=0;o>1;a>16,c=0,l=0;n+=10;if(o<0)do{i=e[n]<<8|e[n+1];var h=e[n+2]<<8|e[n+3];n+=4;var u,f;if(1&i){u=(e[n]<<24|e[n+1]<<16)>>16;f=(e[n+2]<<24|e[n+3]<<16)>>16;n+=4}else{u=e[n++];f=e[n++]}if(2&i){c=u;l=f}else{c=0;l=0}var d=1,g=1,p=0,m=0;if(8&i){d=g=(e[n]<<24|e[n+1]<<16)/1073741824;n+=2}else if(64&i){d=(e[n]<<24|e[n+1]<<16)/1073741824;g=(e[n+2]<<24|e[n+3]<<16)/1073741824;n+=4}else if(128&i){d=(e[n]<<24|e[n+1]<<16)/1073741824;p=(e[n+2]<<24|e[n+3]<<16)/1073741824;m=(e[n+4]<<24|e[n+5]<<16)/1073741824;g=(e[n+6]<<24|e[n+7]<<16)/1073741824;n+=8}var b=a.glyphs[h];if(b){t.push({cmd:"save"});t.push({cmd:"transform",args:[d,p,m,g,c,l]});s(b,t,a);t.push({cmd:"restore"})}}while(32&i);else{var v,y,k=[];for(v=0;v0;)C.push({flags:i})}for(v=0;v>16;n+=2;break;case 2:c-=e[n++];break;case 18:c+=e[n++]}C[v].x=c}for(v=0;v>16;n+=2;break;case 4:l-=e[n++];break;case 36:l+=e[n++]}C[v].y=l}var S=0;for(n=0;n>1;A=!0;break;case 4:f+=l.pop();r(u,f);A=!0;break;case 5:for(;l.length>0;){u+=l.shift();f+=l.shift();i(u,f)}break;case 6:for(;l.length>0;){u+=l.shift();i(u,f);if(0===l.length)break;f+=l.shift();i(u,f)}break;case 7:for(;l.length>0;){f+=l.shift();i(u,f);if(0===l.length)break;u+=l.shift();i(u,f)}break;case 8:for(;l.length>0;){m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+l.shift();s(m,v,b,y,u,f)}break;case 10:x=l.pop()+a.subrsBias;S=a.subrs[x];S&&c(S);break;case 11:return;case 12:I=e[p++];switch(I){case 34:m=u+l.shift();b=m+l.shift();k=f+l.shift();u=b+l.shift();s(m,f,b,k,u,k);m=u+l.shift();b=m+l.shift();u=b+l.shift();s(m,k,b,f,u,f);break;case 35:m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+l.shift();s(m,v,b,y,u,f);m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+l.shift();s(m,v,b,y,u,f);l.pop();break;case 36:m=u+l.shift();k=f+l.shift();b=m+l.shift();w=k+l.shift();u=b+l.shift();s(m,k,b,w,u,w);m=u+l.shift();b=m+l.shift();C=w+l.shift();u=b+l.shift();s(m,w,b,C,u,f);break;case 37:var B=u,R=f;m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+l.shift();s(m,v,b,y,u,f);m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b;f=y;Math.abs(u-B)>Math.abs(f-R)?u+=l.shift():f+=l.shift();s(m,v,b,y,u,f);break;default:h("unknown operator: 12 "+I)}break;case 14:if(l.length>=4){var T=l.pop(),O=l.pop();f=l.pop();u=l.pop();t.push({cmd:"save"});t.push({cmd:"translate",args:[u,f]});var P=n(a.cmap,String.fromCharCode(a.glyphNameMap[d[T]]));o(a.glyphs[P.glyphId],t,a);t.push({cmd:"restore"});P=n(a.cmap,String.fromCharCode(a.glyphNameMap[d[O]]));o(a.glyphs[P.glyphId],t,a)}return;case 18:g+=l.length>>1;A=!0;break;case 19:case 20:g+=l.length>>1;p+=g+7>>3;A=!0;break;case 21:f+=l.pop();u+=l.pop();r(u,f);A=!0;break;case 22:u+=l.pop() +;r(u,f);A=!0;break;case 23:g+=l.length>>1;A=!0;break;case 24:for(;l.length>2;){m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+l.shift();s(m,v,b,y,u,f)}u+=l.shift();f+=l.shift();i(u,f);break;case 25:for(;l.length>6;){u+=l.shift();f+=l.shift();i(u,f)}m=u+l.shift();v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+l.shift();s(m,v,b,y,u,f);break;case 26:l.length%2&&(u+=l.shift());for(;l.length>0;){m=u;v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b;f=y+l.shift();s(m,v,b,y,u,f)}break;case 27:l.length%2&&(f+=l.shift());for(;l.length>0;){m=u+l.shift();v=f;b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y;s(m,v,b,y,u,f)}break;case 28:l.push((e[p]<<24|e[p+1]<<16)>>16);p+=2;break;case 29:x=l.pop()+a.gsubrsBias;S=a.gsubrs[x];S&&c(S);break;case 30:for(;l.length>0;){m=u;v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+(1===l.length?l.shift():0);s(m,v,b,y,u,f);if(0===l.length)break;m=u+l.shift();v=f;b=m+l.shift();y=v+l.shift();f=y+l.shift();u=b+(1===l.length?l.shift():0);s(m,v,b,y,u,f)}break;case 31:for(;l.length>0;){m=u+l.shift();v=f;b=m+l.shift();y=v+l.shift();f=y+l.shift();u=b+(1===l.length?l.shift():0);s(m,v,b,y,u,f);if(0===l.length)break;m=u;v=f+l.shift();b=m+l.shift();y=v+l.shift();u=b+l.shift();f=y+(1===l.length?l.shift():0);s(m,v,b,y,u,f)}break;default:I<32&&h("unknown operator: "+I);if(I<247)l.push(I-139);else if(I<251)l.push(256*(I-247)+e[p++]+108);else if(I<255)l.push(256*-(I-251)-e[p++]-108);else{l.push((e[p]<<24|e[p+1]<<16|e[p+2]<<8|e[p+3])/65536);p+=4}}A&&(l.length=0)}}var l=[],u=0,f=0,g=0;c(e)}function p(e){this.compiledGlyphs=Object.create(null);this.compiledCharCodeToGlyphId=Object.create(null);this.fontMatrix=e}function m(e,t,a){a=a||[488e-6,0,0,488e-6,0,0];p.call(this,a);this.glyphs=e;this.cmap=t}function b(e,t,a,r){a=a||[.001,0,0,.001,0,0];p.call(this,a);this.glyphs=e.glyphs;this.gsubrs=e.gsubrs||[];this.subrs=e.subrs||[];this.cmap=t;this.glyphNameMap=r||f();this.gsubrsBias=this.gsubrs.length<1240?107:this.gsubrs.length<33900?1131:32768;this.subrsBias=this.subrs.length<1240?107:this.subrs.length<33900?1131:32768}p.prototype={getPathJs:function(e){var t=n(this.cmap,e),a=this.compiledGlyphs[t.glyphId];if(!a){a=this.compileGlyph(this.glyphs[t.glyphId]);this.compiledGlyphs[t.glyphId]=a}void 0===this.compiledCharCodeToGlyphId[t.charCode]&&(this.compiledCharCodeToGlyphId[t.charCode]=t.glyphId);return a},compileGlyph:function(e){if(!e||0===e.length||14===e[0])return"";var t=[];t.push({cmd:"save"});t.push({cmd:"transform",args:this.fontMatrix.slice()});t.push({cmd:"scale",args:["size","-size"]});this.compileGlyphImpl(e,t);t.push({cmd:"restore"});return t},compileGlyphImpl:function(){h("Children classes should implement this.")},hasBuiltPath:function(e){var t=n(this.cmap,e);return void 0!==this.compiledGlyphs[t.glyphId]&&void 0!==this.compiledCharCodeToGlyphId[t.charCode]}};c.inherit(m,p,{compileGlyphImpl:function(e,t){s(e,t,this)}});c.inherit(b,p,{compileGlyphImpl:function(e,t){o(e,t,this)}});return{create:function(n,s){for(var o,c,h,u,f,d,g=new Uint8Array(n.data),p=t(g,4),v=0,y=12;v=0?r:0}}else if(c)for(i in t)o[i]=t[i];else{n=F;for(i=0;i=0?r:0}}var l,h=e.differences;if(h)for(i in h){var u=h[i];r=a.indexOf(u);if(-1===r){l||(l=E());var f=s(u,l);f!==u&&(r=a.indexOf(f))}o[i]=r>=0?r:0}return o}var c=a(0),l=(a(1),a(2)),h=a(7),u=a(25),f=a(4),d=a(17),g=a(18),p=a(35),m=a(11),b=c.FONT_IDENTITY_MATRIX,v=c.FontType,y=c.assert,k=c.bytesToString,w=c.error,C=c.info,x=c.isArray,S=c.isInt,A=c.isNum,I=c.readUint32,B=c.shadow,R=c.string32,T=c.warn,O=c.MissingDataException,P=c.isSpace,M=l.Stream,E=h.getGlyphsUnicode,L=h.getDingbatsGlyphsUnicode,D=u.FontRendererFactory,F=f.StandardEncoding,q=f.MacRomanEncoding,U=f.SymbolSetEncoding,N=f.ZapfDingbatsEncoding,j=f.getEncoding,_=d.getStdFontMap,z=d.getNonStdFontMap,H=d.getGlyphMapForStandardFonts,G=d.getSupplementalGlyphMapForArialBlack,X=g.getUnicodeRangeFor,V=g.mapSpecialUnicodeValues,W=g.getUnicodeForGlyph,K=p.Type1Parser,Y=m.CFFStandardStrings,J=m.CFFParser,Z=m.CFFCompiler,Q=m.CFF,$=m.CFFHeader,ee=m.CFFTopDict,te=m.CFFPrivateDict,ae=m.CFFStrings,re=m.CFFIndex,ie=m.CFFCharset,ne=57344,se=63743,oe=!1,ce=1e3,le=!1,he={FixedPitch:1,Serif:2,Symbolic:4,Script:8,Nonsymbolic:32,Italic:64,AllCap:65536,SmallCap:131072,ForceBold:262144},ue=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"],fe=function(){function e(e,t,a,r,i,n,s,o){this.fontChar=e;this.unicode=t;this.accent=a;this.width=r;this.vmetric=i;this.operatorListId=n;this.isSpace=s;this.isInFont=o}e.prototype.matchesForCache=function(e,t,a,r,i,n,s,o){return this.fontChar===e&&this.unicode===t&&this.accent===a&&this.width===r&&this.vmetric===i&&this.operatorListId===n&&this.isSpace===s&&this.isInFont===o};return e}(),de=function(){function e(e){this._map=e}e.prototype={get length(){return this._map.length},forEach:function(e){for(var t in this._map)e(t,this._map[t].charCodeAt(0))},has:function(e){return void 0!==this._map[e]},get:function(e){return this._map[e]},charCodeOf:function(e){return this._map.indexOf(e)},amend:function(e){for(var t in e)this._map[t]=e[t]}};return e}(),ge=function(){function e(e,t){this.firstChar=e;this.lastChar=t}e.prototype={get length(){return this.lastChar+1-this.firstChar},forEach:function(e){for(var t=this.firstChar,a=this.lastChar;t<=a;t++)e(t,t)},has:function(e){return this.firstChar<=e&&e<=this.lastChar},get:function(e){if(this.firstChar<=e&&e<=this.lastChar)return String.fromCharCode(e)},charCodeOf:function(e){return S(e)&&e>=this.firstChar&&e<=this.lastChar?e:-1},amend:function(e){w("Should not call amend()")}};return e}(),pe=function(){function e(e,t,a){e[t]=a>>8&255;e[t+1]=255&a}function t(e,t,a){e[t]=a>>24&255;e[t+1]=a>>16&255;e[t+2]=a>>8&255;e[t+3]=255&a}function a(e,t,a){var r,i;if(a instanceof Uint8Array)e.set(a,t);else if("string"==typeof a)for(r=0,i=a.length;ra;){a<<=1;r++}var i=a*t;return{range:i,entry:r,rangeShift:t*e-i}};r.prototype={toArray:function(){var i=this.sfnt,n=this.tables,s=Object.keys(n);s.sort();var o,c,l,h,u,f=s.length,d=12+16*f,g=[d];for(o=0;o>>0;g.push(d)}var p=new Uint8Array(d);for(o=0;o>>0}t(p,d+4,b);t(p,d+8,g[o]);t(p,d+12,n[u].length);d+=16}return p},addTable:function(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}};return r}(),me=new Int32Array([0,32,127,161,173,174,1536,1920,2208,4256,6016,6144,7168,7248,8192,8208,8209,8210,8232,8240,8287,8304,9676,9677,12288,12289,43616,43648,65520,65536]),be=function(){function e(e,t,a){var i,s,o;this.name=e;this.loadedName=a.loadedName;this.isType3Font=a.isType3Font;this.sizes=[];this.missingFile=!1;this.glyphCache=Object.create(null);this.isSerifFont=!!(a.flags&he.Serif);this.isSymbolicFont=!!(a.flags&he.Symbolic);this.isMonospace=!!(a.flags&he.FixedPitch);var c=a.type,l=a.subtype;this.type=c;this.fallbackName=this.isMonospace?"monospace":this.isSerifFont?"serif":"sans-serif";this.differences=a.differences;this.widths=a.widths;this.defaultWidth=a.defaultWidth;this.composite=a.composite;this.wideChars=a.wideChars;this.cMap=a.cMap;this.ascent=a.ascent/ce;this.descent=a.descent/ce;this.fontMatrix=a.fontMatrix;this.bbox=a.bbox;this.toUnicode=a.toUnicode;this.toFontChar=[];if("Type3"!==a.type){this.cidEncoding=a.cidEncoding;this.vertical=a.vertical;if(this.vertical){this.vmetrics=a.vmetrics;this.defaultVMetrics=a.defaultVMetrics}var g;if(t&&!t.isEmpty){"Type1C"===l&&("Type1"!==c&&"MMType1"!==c?h(t)?l="TrueType":c="Type1":u(t)&&(c=l="OpenType"));"CIDFontType0C"===l&&"CIDFontType0"!==c&&(c="CIDFontType0");"OpenType"===l&&(c="OpenType");"CIDFontType0"===c&&(f(t)?l="CIDFontType0":u(t)?c=l="OpenType":l="CIDFontType0C");var p;switch(c){case"MMType1":C("MMType1 font ("+e+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var m="Type1C"===l||"CIDFontType0C"===l?new ke(t,a):new ye(e,t,a);r(a);p=this.convert(e,m,a);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype";p=this.checkAndRepair(e,t,a);if(this.isOpenType){r(a);c="OpenType"}break;default:w("Font "+c+" is not supported")}this.data=p;this.fontType=n(c,l);this.fontMatrix=a.fontMatrix;this.widths=a.widths;this.defaultWidth=a.defaultWidth;this.toUnicode=a.toUnicode;this.encoding=a.baseEncoding;this.seacMap=a.seacMap;this.loading=!0}else{t&&T('Font file is empty in "'+e+'" ('+this.loadedName+")");this.missingFile=!0;var b=e.replace(/[,_]/g,"-"),y=_(),k=z(),x=!!y[b]||!(!k[b]||!y[k[b]]);b=y[b]||k[b]||b;this.bold=-1!==b.search(/bold/gi);this.italic=-1!==b.search(/oblique/gi)||-1!==b.search(/italic/gi);this.black=-1!==e.search(/Black/g);this.remeasure=Object.keys(this.widths).length>0;if(x&&"CIDFontType2"===c&&0===a.cidEncoding.indexOf("Identity-")){var S=H(),A=[];for(i in S)A[+i]=S[i];if(/Arial-?Black/i.test(e)){var I=G();for(i in I)A[+i]=I[i]}this.toUnicode instanceof ge||this.toUnicode.forEach(function(e,t){A[+e]=t});this.toFontChar=A;this.toUnicode=new de(A)}else if(/Symbol/i.test(b))this.toFontChar=d(U,E(),a.differences);else if(/Dingbats/i.test(b)){/Wingdings/i.test(e)&&T("Non-embedded Wingdings font, falling back to ZapfDingbats.");this.toFontChar=d(N,L(),a.differences)}else if(x)this.toFontChar=d(a.defaultEncoding,E(),a.differences);else{g=E();this.toUnicode.forEach(function(e,t){if(!this.composite){s=a.differences[e]||a.defaultEncoding[e];o=W(s,g);-1!==o&&(t=o)}this.toFontChar[e]=t}.bind(this))}this.loadedName=b.split("-")[0];this.loading=!1;this.fontType=n(c,l)}}else{for(i=0;i<256;i++)this.toFontChar[i]=this.differences[i]||a.defaultEncoding[i];this.fontType=v.TYPE3}}function t(e,t){return(e<<8)+t}function a(e,t){var a=(e<<8)+t;return 32768&a?a-65536:a}function o(e,t,a,r){return(e<<24)+(t<<16)+(a<<8)+r}function c(e){return String.fromCharCode(e>>8&255,255&e)}function l(e){e=e>32767?32767:e<-32768?-32768:e;return String.fromCharCode(e>>8&255,255&e)}function h(e){var t=e.peekBytes(4);return 65536===I(t,0)}function u(e){var t=e.peekBytes(4);return"OTTO"===k(t)}function f(e){var t=e.peekBytes(2);return 37===t[0]&&33===t[1]||128===t[0]&&1===t[1]}function d(e,t,a){for(var r,i=[],n=0,s=e.length;n>1;e=t||a.push({fontCharCode:0|r,glyphId:e[r]});a.sort(function(e,t){return e.fontCharCode-t.fontCharCode});for(var i=[],n=a.length,s=0;s65535?2:1,l="\0\0"+c(o)+"\0\0"+R(4+8*o);for(a=s.length-1;a>=0&&!(s[a][0]<=65535);--a);var h=a+1;s[a][0]<65535&&65535===s[a][1]&&(s[a][1]=65534);var u,f,d,g,p=s[a][1]<65535?1:0,b=h+p,v=pe.getSearchParams(b,2),y="",k="",w="",C="",x="",S=0;for(a=0,r=h;a0){k+="ÿÿ";y+="ÿÿ";w+="\0";C+="\0\0"}var B="\0\0"+c(2*b)+c(v.range)+c(v.entry)+c(v.rangeShift)+k+"\0\0"+y+w+C+x,T="",O="";if(o>1){l+="\0\0\n"+R(4+8*o+4+B.length);T="";for(a=0,r=s.length;at.getUint16())return!1;t.getBytes(6);if(0===t.getUint16())return!1;e.data[8]=e.data[9]=0;return!0}function O(e,t,a){a=a||{unitsPerEm:0,yMax:0,yMin:0,ascent:0,descent:0};var r=0,i=0,n=0,s=0,o=null,l=0;if(t)for(var h in t){h|=0;(o>h||!o)&&(o=h);l 123 are reserved for internal usage")}else{o=0;l=255}var f=e.bbox||[0,0,0,0],d=a.unitsPerEm||1/(e.fontMatrix||b)[0],g=e.ascentScaled?1:d/ce,p=a.ascent||Math.round(g*(e.ascent||f[3])),m=a.descent||Math.round(g*(e.descent||f[1]));m>0&&e.descent>0&&f[1]<0&&(m=-m);var v=a.yMax||p,y=-a.yMin||-m;return"\0$ô\0\0\0Š»\0\0\0ŒŠ»\0\0ß\x001\0\0\0\0"+String.fromCharCode(e.fixedPitch?9:0)+"\0\0\0\0\0\0"+R(r)+R(i)+R(n)+R(s)+"*21*"+c(e.italicAngle?1:0)+c(o||e.firstChar)+c(l||e.lastChar)+c(p)+c(m)+"\0d"+c(v)+c(y)+"\0\0\0\0\0\0\0\0"+c(e.xHeight)+c(e.capHeight)+c(0)+c(o||e.firstChar)+"\0"}function P(e){var t=Math.floor(e.italicAngle*Math.pow(2,16));return"\0\0\0"+R(t)+"\0\0\0\0"+R(e.fixedPitch)+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}function K(e,t){t||(t=[[],[]]);var a,r,i,n,s,o=[t[0][0]||"Original licence",t[0][1]||e,t[0][2]||"Unknown",t[0][3]||"uniqueID",t[0][4]||e,t[0][5]||"Version 0.11",t[0][6]||"",t[0][7]||"Unknown",t[0][8]||"Unknown",t[0][9]||"Unknown"],l=[];for(a=0,r=o.length;as.length)return 0;if(!n&&f>0){r.set(s.subarray(0,u),i);r.set([0,0],i+u);r.set(s.subarray(d,v),i+u+2);v-=f;s.length-v>3&&(v=v+3&-4);return v}if(s.length-v>3){v=v+3&-4;r.set(s.subarray(0,v),i);return v}r.set(s,i);return s.length}function l(e,t){for(var a,r,i,n,s,o=e.data,c=0,l=0,h=0,f=[],g=[],p=[],m=t.tooComplexToFollowFunctions,b=!1,v=0,y=0,k=o.length;c0&&(c+=C-1)}}else{if(b||y){T("TT: nested FDEFs not allowed");m=!0}b=!0;h=c;n=f.pop();t.functionsDefined[n]={data:o,i:c}}else if(!b&&!y){n=f[f.length-1];t.functionsUsed[n]=!0;if(n in t.functionsStackDeltas)f.length+=t.functionsStackDeltas[n];else if(n in t.functionsDefined&&p.indexOf(n)<0){g.push({data:o,i:c,stackTop:f.length-1});p.push(n);s=t.functionsDefined[n];if(!s){T("TT: CALL non-existent function");t.hintsValid=!1;return}o=s.data;c=s.i}}if(!b&&!y){var x=w<=142?d[w]:w>=192&&w<=223?-1:w>=224?-2:0;if(w>=113&&w<=117){r=f.pop();isNaN(r)||(x=2*-r)}for(;x<0&&f.length>0;){f.pop();x++}for(;x>0;){f.push(NaN);x--}}}t.tooComplexToFollowFunctions=m;var S=[o];c>o.length&&S.push(new Uint8Array(c-o.length));if(h>l){T("TT: complementing a missing function tail");S.push(new Uint8Array([34,45]))}u(e,S)}function h(e,t){if(!e.tooComplexToFollowFunctions)if(e.functionsDefined.length>t){T("TT: more functions defined than expected");e.hintsValid=!1}else for(var a=0,r=e.functionsUsed.length;at){T("TT: invalid function id: "+a);e.hintsValid=!1;return}if(e.functionsUsed[a]&&!e.functionsDefined[a]){T("TT: undefined function: "+a);e.hintsValid=!1;return}}}function u(e,t){if(t.length>1){var a,r,i=0;for(a=0,r=t.length;a=0&&Q.has(t))||!!($&&a>=0&&A($[a])))}var d=[0,0,0,0,0,0,0,0,-2,-2,-2,-2,0,0,-2,-5,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-1,0,-1,-1,-1,-1,1,-1,-999,0,1,0,-1,-2,0,-1,-2,-1,-1,0,-1,-1,0,0,-999,-999,-1,-1,-1,-1,-2,-999,-2,-2,-999,0,-2,-2,0,0,-2,0,-2,0,0,0,-2,-1,-1,1,1,0,0,-1,-1,-1,-1,-1,-1,-1,0,0,-1,0,-1,-1,0,-999,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,-2,-999,-999,-999,-999,-999,-1,-1,-2,-2,0,0,0,0,-1,-1,-999,-2,-2,0,0,-1,-2,-2,0,0,0,-1,-1,-1,-2];i=new M(new Uint8Array(i.getBytes()));var g,m,b=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "],v=function(e){return{version:k(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}(i),I=v.numTables,B=Object.create(null);B["OS/2"]=null;B.cmap=null;B.head=null;B.hhea=null;B.hmtx=null;B.maxp=null;B.name=null;B.post=null;for(var R,L=0;L>>0,r=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.pos;e.pos=e.start?e.start:0;e.skip(r);var s=e.getBytes(i);e.pos=n;if("head"===t){s[8]=s[9]=s[10]=s[11]=0;s[17]|=32}return{tag:t,checksum:a,length:i,offset:r,data:s}}(i);b.indexOf(R.tag)<0||0!==R.length&&(B[R.tag]=R)}var D=!B["CFF "];if(D){B.loca||w('Required "loca" table is not found');if(!B.glyf){T('Required "glyf" table is not found -- trying to recover.');B.glyf={tag:"glyf",data:new Uint8Array(0)}}this.isOpenType=!1}else{if("OTTO"===v.version&&!n.composite||!B.head||!B.hhea||!B.maxp||!B.post){m=new M(B["CFF "].data);g=new ke(m,n);r(n);return this.convert(e,g,n)}delete B.glyf;delete B.loca;delete B.fpgm;delete B.prep;delete B["cvt "];this.isOpenType=!0}B.maxp||w('Required "maxp" table is not found');i.pos=(i.start||0)+B.maxp.offset;var U=i.getInt32(),N=i.getUint16(),_=0;if(U>=65536&&B.maxp.length>=22){i.pos+=8;if(i.getUint16()>2){B.maxp.data[14]=0;B.maxp.data[15]=2}i.pos+=4;_=i.getUint16()}var z=!1;if("CIDFontType2"===n.type&&n.toUnicode&&n.toUnicode.get(0)>"\0"){z=!0;N++;B.maxp.data[4]=N>>8;B.maxp.data[5]=255&N}var H=function(e,t,a,r){var i={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};e&&l(e,i);t&&l(t,i);e&&h(i,r);if(a&&1&a.length){var n=new Uint8Array(a.length+1);n.set(a.data);a.data=n}return i.hintsValid}(B.fpgm,B.prep,B["cvt "],_);if(!H){delete B.fpgm;delete B.prep;delete B["cvt "]}!function(e,t,a,r){if(t){e.pos=(e.start?e.start:0)+t.offset;e.pos+=t.length-2;var i=e.getUint16();if(i>r){C("The numOfMetrics ("+i+") should not be greater than the numGlyphs ("+r+")");i=r;t.data[34]=(65280&i)>>8;t.data[35]=255&i}var n=r-i,s=n-(a.length-4*i>>1);if(s>0){var o=new Uint8Array(a.length+2*s);o.set(a.data);a.data=o}}else a&&(a.data=null)}(i,B.hhea,B.hmtx,N);B.head||w('Required "head" table is not found');!function(e,a,r){var i=e.data,n=o(i[0],i[1],i[2],i[3]);if(n>>16!=1){C("Attempting to fix invalid version in head table: "+n);i[0]=0;i[1]=1;i[2]=0;i[3]=0}var s=t(i[50],i[51]);if(s<0||s>1){C("Attempting to fix invalid indexToLocFormat in head table: "+s);var c=a+1;if(r===c<<1){i[50]=0;i[51]=0}else if(r===c<<2){i[50]=0;i[51]=1}else T("Could not fix indexToLocFormat: "+s)}}(B.head,N,D?B.loca.length:0);var G=Object.create(null);if(D){var X=t(B.head.data[50],B.head.data[51]);G=function(e,t,a,r,i,n){var s,o,l;if(r){s=4;o=function(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]};l=function(e,t,a){e[t]=a>>>24&255;e[t+1]=a>>16&255;e[t+2]=a>>8&255;e[t+3]=255&a}}else{s=2;o=function(e,t){return e[t]<<9|e[t+1]<<1};l=function(e,t,a){e[t]=a>>9&255;e[t+1]=a>>1&255}}var h=e.data,u=s*(1+a);if(h.length!==u){h=new Uint8Array(u);h.set(e.data.subarray(0,u));e.data=h}var f=t.data,d=f.length,g=new Uint8Array(d),p=o(h,0),m=0,b=Object.create(null);l(h,0,m);var v,y;for(v=0,y=s;vd&&(d+3&-4)===k&&(k=d);if(k>d){l(h,y,m);p=k}else{p===k&&(b[v]=!0);m+=c(f,p,k,g,m,i);l(h,y,m);p=k}}if(0===m){var w=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(v=0,y=s;vC+m)t.data=g.subarray(0,C+m);else{t.data=new Uint8Array(C+m);t.data.set(g.subarray(0,m))}t.data.set(g.subarray(0,C),m);l(e.data,h.length-s,m+C)}else t.data=g.subarray(0,m);return b}(B.loca,B.glyf,N,X,H,z)}B.hhea||w('Required "hhea" table is not found');if(0===B.hhea.data[10]&&0===B.hhea.data[11]){B.hhea.data[10]=255;B.hhea.data[11]=255}var V={unitsPerEm:t(B.head.data[18],B.head.data[19]),yMax:t(B.head.data[42],B.head.data[43]),yMin:a(B.head.data[38],B.head.data[39]),ascent:t(B.hhea.data[4],B.hhea.data[5]),descent:a(B.hhea.data[6],B.hhea.data[7])};this.ascent=V.ascent/V.unitsPerEm;this.descent=V.descent/V.unitsPerEm;if(B.post){(function(e,t,a){var r=(i.start?i.start:0)+e.offset;i.pos=r;var n=e.length,s=r+n,o=i.getInt32();i.getBytes(28);var c,l,h=!0;switch(o){case 65536:c=ue;break;case 131072:var u=i.getUint16();if(u!==a){h=!1;break}var f=[];for(l=0;l=32768){h=!1;break}f.push(d)}if(!h)break;for(var g=[],p=[];i.pos=0&&a>>0,d=!1;if(0===h&&0===u)d=!0;else if(1===h&&0===u)d=!0;else if(3!==h||1!==u||!r&&s){if(a&&3===h&&0===u){d=!0;c=!0}}else{d=!0;a||(c=!0)}d&&(s={platformId:h,encodingId:u,offset:f});if(c)break}s&&(t.pos=n+s.offset);if(!s||-1===t.peekByte()){T("Could not find a preferred cmap table.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var g=t.getUint16();t.getUint16();t.getUint16();var p,m,b=!1,v=[];if(0===g){for(p=0;p<256;p++){var y=t.getByte();y&&v.push({charCode:p,glyphId:y})}b=!0}else if(4===g){var k=t.getUint16()>>1;t.getBytes(6);var w,C=[];for(w=0;w>1)-(k-w);i.offsetIndex=A;x=Math.max(x,A+i.end-i.start+1)}else i.offsetIndex=-1}var I=[];for(p=0;p0&&f(we,-1,-1)){Y[W]=we;ve=!0}}ve||(Y[W]=0)}}}else if(0===ie&&0===ne)for(L=0;Ln)){i.pos=d;var g=f.name;if(f.encoding){for(var p="",m=0,b=f.length;m=n){o+=r;for(;o=0&&(n[s]=t)}}return o(e,n,r)},getSeacs:function(e){var t,a,r=[];for(t=0,a=e.length;t>8&255,255&f)}n.charset=new ie(!1,0,[],u);var d=new re;d.add([139,14]);for(c=0;c0;y--)v[y]-=v[y-1];p.setByName(b,v)}}n.topDict.privateDict=p;var k=new re;for(c=0,l=r.length;cr?r:e}function a(e,t,a,r,i,n){var s,o,c,l,h=i*n,u=t<=8?new Uint8Array(h):t<=16?new Uint16Array(h):new Uint32Array(h),f=a/i,d=r/n,g=0,p=new Uint16Array(i),m=a;for(s=0;s>3)*a,c=e.byteLength,l=o===c;if(!r||i&&!l)if(i){n=new Uint8Array(o);n.set(e);for(s=c;s>7&1;l[f+1]=r>>6&1;l[f+2]=r>>5&1;l[f+3]=r>>4&1;l[f+4]=r>>3&1;l[f+5]=r>>2&1;l[f+6]=r>>1&1;l[f+7]=1&r;f+=8}if(f>=1}}}else{var b=0;r=0;for(f=0,a=o;f>v;l[f]=y<0?0:y>u?u:y;r&=(1<m[w+1]){v=255;break}}o[u]=v}}else h("Unknown mask format.");if(o)for(u=0,g=3,d=t*n;u=255?255:0|i;e[f+1]=n<=0?0:n>=255?255:0|n;e[f+2]=s<=0?0:s>=255?255:0|s}else{e[f]=255;e[f+1]=255;e[f+2]=255}}},createImageData:function(e){var t,a=this.drawWidth,r=this.drawHeight,i={width:a,height:r},n=this.numComps,s=this.width,o=this.height,h=this.bpc,u=s*n*h+7>>3;if(!e){var f;"DeviceGray"===this.colorSpace.name&&1===h?f=c.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==h||this.needsDecode||(f=c.RGB_24BPP);if(f&&!this.smask&&!this.mask&&a===s&&r===o){i.kind=f;t=this.getImageBytes(o*u);if(this.image instanceof b)i.data=t;else{var d=new Uint8Array(t.length);d.set(t);i.data=d}if(this.needsDecode){l(f===c.GRAYSCALE_1BPP);for(var g=i.data,p=0,m=g.length;p>3,c=this.getImageBytes(n*o),l=this.getComponents(c);if(1!==s){this.needsDecode&&this.decodeBuffer(l);r=i*n;var u=255/((1<>>0}var i=e.getContexts(t),n=1,s=r(1),o=r(1)?r(1)?r(1)?r(1)?r(1)?r(32)+4436:r(12)+340:r(8)+84:r(6)+20:r(4)+4:r(2);return 0===s?o:o>0?-o:null}function r(e,t,a){for(var r=e.getContexts("IAID"),i=1,n=0;n=E&&R=L){z=z<<1&v;for(d=0;d=0&&O=0){P=U[T][O];P&&(z|=P<=e?E<<=1:E=E<<1|C[P][M]}for(u=0;u=k||M<0||M>=y?E<<=1:E=E<<1|r[P][M]}var L=x.readBit(S,E);T[O]=L}}return C}function g(e,t,i,o,c,l,h,u,g,m,b){e&&n("JBIG2 error: huffman is not supported");for(var v=[],y=0,k=s(i.length+o),w=b.decoder,C=b.contextCache;v.length1)A=p(e,t,x,y,0,I,1,i.concat(v),k,0,0,1,0,l,g,m,b);else{var B=r(C,w,k),R=a(C,"IARDX",w),T=a(C,"IARDY",w);A=d(x,y,g,B>1)+N,(U>>1)+j,!1,y,k)}var _,z,H,G=P-(1&p?0:F),X=T-(2&p?D:0);if(f){for(_=0;_>5&7,u=[31&o],f=t+6;if(7===o){h=536870911&l(e,f-1);f+=3;var d=h+7>>3;u[0]=e[f++];for(;--d>0;)u.push(e[f++])}else 5!==o&&6!==o||n("JBIG2 error: invalid referred-to flags");a.retainBits=u;var g,p,m=a.number<=256?1:a.number<=65536?2:4,b=[];for(g=0;g>>24&255;x[3]=k.height>>16&255;x[4]=k.height>>8&255;x[5]=255&k.height;for(g=f,p=e.length;g>2&3;g.huffmanDWSelector=p>>4&3;g.bitmapSizeSelector=p>>6&1;g.aggregationInstancesSelector=p>>7&1;g.bitmapCodingContextUsed=!!(256&p);g.bitmapCodingContextRetained=!!(512&p);g.template=p>>10&3;g.refinementTemplate=p>>12&1;f+=2;if(!g.huffman){s=0===g.template?4:1;r=[];for(i=0;i>2&3);m.referenceCorner=b>>4&3;m.transposed=!!(64&b);m.combinationOperator=b>>7&3;m.defaultPixelValue=b>>9&1;m.dsOffset=b<<17>>27;m.refinementTemplate=b>>15&1;if(m.huffman){var y=c(u,f);f+=2;m.huffmanFS=3&y;m.huffmanDS=y>>2&3;m.huffmanDT=y>>4&3;m.huffmanRefinementDW=y>>6&3;m.huffmanRefinementDH=y>>8&3;m.huffmanRefinementDX=y>>10&3;m.huffmanRefinementDY=y>>12&3;m.huffmanRefinementSizeSelector=!!(14&y)}if(m.refinement&&!m.refinementTemplate){r=[];for(i=0;i<2;i++){r.push({x:o(u,f),y:o(u,f+1)});f+=2}m.refinementAt=r}m.numberOfSymbolInstances=l(u,f);f+=4;m.huffman&&n("JBIG2 error: huffman is not supported");a=[m,h.referredTo,u,f,d];break;case 38:case 39:var k={};k.info=v(u,f);f+=T;var w=u[f++];k.mmr=!!(1&w);k.template=w>>1&3;k.prediction=!!(8&w);if(!k.mmr){s=0===k.template?4:1;r=[];for(i=0;i>2&1;C.combinationOperator=x>>3&3;C.requiresBuffer=!!(32&x);C.combinationOperatorOverride=!!(64&x);a=[C];break;case 49:case 50:case 51:case 62:break;default:n("JBIG2 error: segment type "+h.typeName+"("+h.type+") is not implemented")}var S="on"+h.typeName;S in t&&t[S].apply(t,a)}function k(e,t){for(var a=0,r=e.length;a>3,a=new Uint8Array(t*e.height);if(e.defaultPixelValue)for(var r=0,i=a.length;r>3,u=o.combinationOperatorOverride?e.combinationOperator:o.combinationOperator,f=this.buffer,d=128>>(7&e.x),g=e.y*h+(e.x>>3);switch(u){case 0:for(a=0;a>=1;if(!i){i=128;s++}}g+=h}break;case 2:for(a=0;a>=1;if(!i){i=128;s++}}g+=h}break;default:n("JBIG2 error: operator "+u+" is not supported")}},onImmediateGenericRegion:function(e,a,r,i){var n=e.info,s=new t(a,r,i),o=f(e.mmr,n.width,n.height,e.template,e.prediction,null,e.at,s);this.drawBitmap(n,o)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,a,r,i,s,o){e.huffman&&n("JBIG2 error: huffman is not supported");var c=this.symbols;c||(this.symbols=c={});for(var l=[],h=0,u=r.length;h0&&!e[s-1];)s--;n.push({children:[],index:0});var o,c=n[0];for(a=0;a0;)c=n.pop();c.index++;n.push(c);for(;n.length<=a;){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}i++}if(a+10){L--;return E>>L&1}E=e[t++];if(255===E){var a=e[t++];a&&n("JPEG error: unexpected marker "+(E<<8|a).toString(16))}L=7;return E>>>7}function p(e){for(var t=e;;){t=t[g()];if("number"==typeof t)return t;"object"!=typeof t&&n("JPEG error: invalid huffman sequence")}}function m(e){for(var t=0;e>0;){t=t<<1|g();e--}return t}function b(e){if(1===e)return 1===g()?1:-1;var t=m(e);return t>=1<>4;if(0!==s){i+=o;var c=h[i];e.blockData[t+c]=b(s);i++}else{if(o<15)break;i+=16}}}function y(e,t){var a=p(e.huffmanTableDC),r=0===a?0:b(a)<0)D--;else for(var a=c,r=u;a<=r;){var i=p(e.huffmanTableAC),n=15&i,s=i>>4;if(0!==n){a+=s;var o=h[a];e.blockData[t+o]=b(n)*(1<>4;if(0===a)if(o<15){D=m(o)+(1<=65488&&G<=65495))break;t+=2}U=l(e,t);if(U&&U.invalid){i("decodeScan - unexpected Scan data, next marker is: "+U.invalid);t=U.offset}return t-M}function s(e,t,a){var r,i,s,o,c,l,h,y,k,w,C,x,S,A,I,B,R,T=e.quantizationTable,O=e.blockData;T||n("JPEG error: missing required Quantization Table.");for(var P=0;P<64;P+=8){k=O[t+P];w=O[t+P+1];C=O[t+P+2];x=O[t+P+3];S=O[t+P+4];A=O[t+P+5];I=O[t+P+6];B=O[t+P+7];k*=T[P];if(0!=(w|C|x|S|A|I|B)){w*=T[P+1];C*=T[P+2];x*=T[P+3];S*=T[P+4];A*=T[P+5];I*=T[P+6];B*=T[P+7];r=b*k+128>>8;i=b*S+128>>8;s=C;o=I;c=v*(w-B)+128>>8;y=v*(w+B)+128>>8;l=x<<4;h=A<<4;r=r+i+1>>1;i=r-i;R=s*m+o*p+128>>8;s=s*p-o*m+128>>8;o=R;c=c+h+1>>1;h=c-h;y=y+l+1>>1;l=y-l;r=r+o+1>>1;o=r-o;i=i+s+1>>1;s=i-s;R=c*g+y*d+2048>>12;c=c*d-y*g+2048>>12;y=R;R=l*f+h*u+2048>>12;l=l*u-h*f+2048>>12;h=R;a[P]=r+y;a[P+7]=r-y;a[P+1]=i+h;a[P+6]=i-h;a[P+2]=s+l;a[P+5]=s-l;a[P+3]=o+c;a[P+4]=o-c}else{R=b*k+512>>10;a[P]=R;a[P+1]=R;a[P+2]=R;a[P+3]=R;a[P+4]=R;a[P+5]=R;a[P+6]=R;a[P+7]=R}}for(var M=0;M<8;++M){k=a[M];w=a[M+8];C=a[M+16];x=a[M+24];S=a[M+32];A=a[M+40];I=a[M+48];B=a[M+56];if(0!=(w|C|x|S|A|I|B)){r=b*k+2048>>12;i=b*S+2048>>12;s=C;o=I;c=v*(w-B)+2048>>12;y=v*(w+B)+2048>>12;l=x;h=A;r=4112+(r+i+1>>1);i=r-i;R=s*m+o*p+2048>>12;s=s*p-o*m+2048>>12;o=R;c=c+h+1>>1;h=c-h;y=y+l+1>>1;l=y-l;r=r+o+1>>1;o=r-o;i=i+s+1>>1;s=i-s;R=c*g+y*d+2048>>12;c=c*d-y*g+2048>>12;y=R;R=l*f+h*u+2048>>12;l=l*u-h*f+2048>>12;h=R;k=r+y;B=r-y;w=i+h;I=i-h;C=s+l;A=s-l;x=o+c;S=o-c;k=k<16?0:k>=4080?255:k>>4;w=w<16?0:w>=4080?255:w>>4;C=C<16?0:C>=4080?255:C>>4;x=x<16?0:x>=4080?255:x>>4;S=S<16?0:S>=4080?255:S>>4;A=A<16?0:A>=4080?255:A>>4;I=I<16?0:I>=4080?255:I>>4;B=B<16?0:B>=4080?255:B>>4;O[t+M]=k;O[t+M+8]=w;O[t+M+16]=C;O[t+M+24]=x;O[t+M+32]=S;O[t+M+40]=A;O[t+M+48]=I;O[t+M+56]=B}else{R=b*k+8192>>14;R=R<-2040?0:R>=2024?255:R+2056>>4;O[t+M]=R;O[t+M+8]=R;O[t+M+16]=R;O[t+M+24]=R;O[t+M+32]=R;O[t+M+40]=R;O[t+M+48]=R;O[t+M+56]=R}}}function o(e,t){for(var r=t.blocksPerLine,i=t.blocksPerColumn,n=new Int16Array(64),o=0;o=255?255:e}function l(e,t,a){function r(t){return e[t]<<8|e[t+1]}var i=e.length-1,n=a=i)return null;var s=r(t);if(s>=65472&&s<=65534)return{invalid:null,marker:s,offset:t};for(var o=r(n);!(o>=65472&&o<=65534);){if(++n>=i)return null;o=r(n)}return{invalid:s.toString(16),marker:o,offset:n}}var h=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),u=4017,f=799,d=3406,g=2276,p=1567,m=3784,b=5793,v=2896;e.prototype={parse:function(e){function a(){var t=e[u]<<8|e[u+1];u+=2;return t}var s,c,u=0,f=null,d=null,g=[],p=[],m=[],b=a();65496!==b&&n("JPEG error: SOI not found");b=a();for(;65497!==b;){var v,y,k;switch(b){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514: +case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var w=function(){var t=a(),r=u+t-2,n=l(e,r,u);if(n&&n.invalid){i("readDataBlock - incorrect length, next marker is: "+n.invalid);r=n.offset}var s=e.subarray(u,r);u+=s.length;return s}();65504===b&&74===w[0]&&70===w[1]&&73===w[2]&&70===w[3]&&0===w[4]&&(f={version:{major:w[5],minor:w[6]},densityUnits:w[7],xDensity:w[8]<<8|w[9],yDensity:w[10]<<8|w[11],thumbWidth:w[12],thumbHeight:w[13],thumbData:w.subarray(14,14+3*w[12]*w[13])});65518===b&&65===w[0]&&100===w[1]&&111===w[2]&&98===w[3]&&101===w[4]&&(d={version:w[5]<<8|w[6],flags0:w[7]<<8|w[8],flags1:w[9]<<8|w[10],transformCode:w[11]});break;case 65499:for(var C,x=a(),S=x+u-2;u>4==0)for(y=0;y<64;y++){C=h[y];I[C]=e[u++]}else if(A>>4==1)for(y=0;y<64;y++){C=h[y];I[C]=a()}else n("JPEG error: DQT - invalid table spec");g[15&A]=I}break;case 65472:case 65473:case 65474:s&&n("JPEG error: Only single frame JPEGs supported");a();s={};s.extended=65473===b;s.progressive=65474===b;s.precision=e[u++];s.scanLines=a();s.samplesPerLine=a();s.components=[];s.componentIds={};var B,R=e[u++],T=0,O=0;for(v=0;v>4,M=15&e[u+1];T>4==0?m:p)[15&D]=t(F,U)}break;case 65501:a();c=a();break;case 65498:a();var N,j=e[u++],_=[];for(v=0;v>4];N.huffmanTableAC=p[15&H];_.push(N)}var G=e[u++],X=e[u++],V=e[u++],W=r(e,u,s,_,c,G,X,V>>4,15&V);u+=W;break;case 65535:255!==e[u]&&u--;break;default:if(255===e[u-3]&&e[u-2]>=192&&e[u-2]<=254){u-=3;break}n("JPEG error: unknown marker "+b.toString(16))}b=a()}this.width=s.samplesPerLine;this.height=s.scanLines;this.jfif=f;this.adobe=d;this.components=[];for(v=0;v>8)+k[h+1];return v},_isColorConversionNeeded:function(){return!(!this.adobe||!this.adobe.transformCode)||(3===this.numComponents?!(!this.adobe&&0===this.colorTransform):!this.adobe&&1===this.colorTransform)},_convertYccToRgb:function(e){for(var t,a,r,i=0,n=e.length;i=0?255:l<=s?0:255+l*(1/255/255)|0;e[n++]=h>=0?255:h<=s?0:255+h*(1/255/255)|0;e[n++]=u>=0?255:u<=s?0:255+u*(1/255/255)|0}return e},getData:function(e,t,a){this.numComponents>4&&n("JPEG error: Unsupported color mode");var r=this._getLinearizedBlockData(e,t);if(1===this.numComponents&&a){for(var i=r.length,s=new Uint8Array(3*i),o=0,c=0;c>>8;n[s++]=255&o}}}else if(e instanceof Uint8Array){n=e;s=n.length}else{if(!("object"==typeof e&&"length"in e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");n=e;s=n.length;r=!0}var c=s>>2,l=s-4*c,h=r?new i(n,c):new Uint32Array(n.buffer,0,c),u=0,f=0,d=this.h1,g=this.h2,p=3432918353,m=461845907;for(t=0;t>>17;u=u*m&4294901760|13715*u&65535;d^=u;d=d<<13|d>>>19;d=5*d+3864292196}else{f=h[t];f=f*p&4294901760|11601*f&65535;f=f<<15|f>>>17;f=f*m&4294901760|13715*f&65535;g^=f;g=g<<13|g>>>19;g=5*g+3864292196}u=0;switch(l){case 3:u^=n[4*c+2]<<16;case 2:u^=n[4*c+1]<<8;case 1:u^=n[4*c];u=u*p&4294901760|11601*u&65535;u=u<<15|u>>>17;u=u*m&4294901760|13715*u&65535;1&c?d^=u:g^=u}this.h1=d;this.h2=g;return this},hexdigest:function(){var e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&4294901760|36045*e&65535;t=4283543511*t&4294901760|(2950163797*(t<<16|e>>>16)&4294901760)>>>16;e^=t>>>1;e=444984403*e&4294901760|60499*e&65535;t=3301882366*t&4294901760|(3120437893*(t<<16|e>>>16)&4294901760)>>>16;e^=t>>>1;for(var a=0,r=[e,t],i="";a>>0).toString(16);n.length<8;)n="0"+n;i+=n}return i}};return t}();t.MurmurHash3_64=n},function(e,t,a){"use strict";function r(e,t,a){return["TilingPattern",a,e,t.getArray("Matrix"),t.getArray("BBox"),t.get("XStep"),t.get("YStep"),t.get("PaintType"),t.get("TilingType")]}var i=a(0),n=a(1),s=a(6),o=a(3),c=i.UNSUPPORTED_FEATURES,l=i.MissingDataException,h=i.Util,u=i.assert,f=i.error,d=i.info,g=i.warn,p=n.isStream,m=s.PDFFunction,b=o.ColorSpace,v={FUNCTION_BASED:1,AXIAL:2,RADIAL:3,FREE_FORM_MESH:4,LATTICE_FORM_MESH:5,COONS_PATCH_MESH:6,TENSOR_PATCH_MESH:7},y=function(){function e(){f("should not call Pattern constructor")}e.prototype={getPattern:function(e){f("Should not call Pattern.getStyle: "+e)}};e.parseShading=function(e,t,a,r,i){var n=p(e)?e.dict:e,s=n.get("ShadingType");try{switch(s){case v.AXIAL:case v.RADIAL:return new k.RadialAxial(n,t,a,r);case v.FREE_FORM_MESH:case v.LATTICE_FORM_MESH:case v.COONS_PATCH_MESH:case v.TENSOR_PATCH_MESH:return new k.Mesh(e,t,a,r);default:throw new Error("Unsupported ShadingType: "+s)}}catch(e){if(e instanceof l)throw e;i.send("UnsupportedFeature",{featureId:c.shadingPattern});g(e);return new k.Dummy}};return e}(),k={};k.SMALL_NUMBER=1e-6;k.RadialAxial=function(){function e(e,t,a,r){this.matrix=t;this.coordsArr=e.getArray("Coords");this.shadingType=e.get("ShadingType");this.type="Pattern";var i=e.get("ColorSpace","CS");i=b.parse(i,a,r);this.cs=i;var n=0,s=1;if(e.has("Domain")){var o=e.getArray("Domain");n=o[0];s=o[1]}var c=!1,l=!1;if(e.has("Extend")){var u=e.getArray("Extend");c=u[0];l=u[1]}if(!(this.shadingType!==v.RADIAL||c&&l)){var f=this.coordsArr[0],p=this.coordsArr[1],y=this.coordsArr[2],w=this.coordsArr[3],C=this.coordsArr[4],x=this.coordsArr[5],S=Math.sqrt((f-w)*(f-w)+(p-C)*(p-C));y<=x+S&&x<=y+S&&g("Unsupported radial gradient.")}this.extendStart=c;this.extendEnd=l;var A=e.get("Function"),I=m.parseArray(a,A),B=s-n,R=B/10,T=this.colorStops=[];if(n>=s||R<=0)d("Bad shading domain.");else{for(var O,P=new Float32Array(i.numComps),M=new Float32Array(1),E=n;E<=s;E+=R){M[0]=E;I(M,0,P,0);O=i.getRgb(P,0);var L=h.makeCssRgb(O[0],O[1],O[2]);T.push([(E-n)/B,L])}var D="transparent";if(e.has("Background")){O=i.getRgb(e.get("Background"),0);D=h.makeCssRgb(O[0],O[1],O[2])}if(!c){T.unshift([0,D]);T[1][0]+=k.SMALL_NUMBER}if(!l){T[T.length-1][0]-=k.SMALL_NUMBER;T.push([1,D])}this.colorStops=T}}e.prototype={getIR:function(){var e,t,a,r,i,n=this.coordsArr,s=this.shadingType;if(s===v.AXIAL){t=[n[0],n[1]];a=[n[2],n[3]];r=null;i=null;e="axial"}else if(s===v.RADIAL){t=[n[0],n[1]];a=[n[3],n[4]];r=n[2];i=n[5];e="radial"}else f("getPattern type unknown: "+s);var o=this.matrix;if(o){t=h.applyTransform(t,o);a=h.applyTransform(a,o);if(s===v.RADIAL){var c=h.singularValueDecompose2dScale(o);r*=c[0];i*=c[1]}}return["RadialAxial",e,this.colorStops,t,a,r,i]}};return e}();k.Mesh=function(){function e(e,t){this.stream=e;this.context=t;this.buffer=0;this.bufferLength=0;var a=t.numComps;this.tmpCompsBuf=new Float32Array(a);var r=t.colorSpace.numComps;this.tmpCsCompsBuf=t.colorFn?new Float32Array(r):this.tmpCompsBuf}function t(e,t){for(var a=e.coords,r=e.colors,i=[],n=[],s=0;t.hasData;){var o=t.readFlag(),c=t.readCoordinate(),l=t.readComponents();if(0===s){u(0<=o&&o<=2,"Unknown type4 flag");switch(o){case 0:s=3;break;case 1:n.push(n[n.length-2],n[n.length-1]);s=1;break;case 2:n.push(n[n.length-3],n[n.length-1]);s=1}i.push(o)}n.push(a.length);a.push(c);r.push(l);s--;t.align()}e.figures.push({type:"triangles",coords:new Int32Array(n),colors:new Int32Array(n)})}function a(e,t,a){for(var r=e.coords,i=e.colors,n=[];t.hasData;){var s=t.readCoordinate(),o=t.readComponents();n.push(r.length);r.push(s);i.push(o)}e.figures.push({type:"lattice",coords:new Int32Array(n),colors:new Int32Array(n),verticesPerRow:a})}function r(e,t){var a=e.figures[t];u("patch"===a.type,"Unexpected patch mesh figure");var r=e.coords,i=e.colors,n=a.coords,s=a.colors,o=Math.min(r[n[0]][0],r[n[3]][0],r[n[12]][0],r[n[15]][0]),c=Math.min(r[n[0]][1],r[n[3]][1],r[n[12]][1],r[n[15]][1]),f=Math.max(r[n[0]][0],r[n[3]][0],r[n[12]][0],r[n[15]][0]),p=Math.max(r[n[0]][1],r[n[3]][1],r[n[12]][1],r[n[15]][1]),m=Math.ceil((f-o)*d/(e.bounds[2]-e.bounds[0]));m=Math.max(l,Math.min(h,m));var b=Math.ceil((p-c)*d/(e.bounds[3]-e.bounds[1]));b=Math.max(l,Math.min(h,b));for(var v=m+1,y=new Int32Array((b+1)*v),k=new Int32Array((b+1)*v),w=0,C=new Uint8Array(3),x=new Uint8Array(3),S=i[s[0]],A=i[s[1]],I=i[s[2]],B=i[s[3]],R=g(b),T=g(m),O=0;O<=b;O++){C[0]=(S[0]*(b-O)+I[0]*O)/b|0;C[1]=(S[1]*(b-O)+I[1]*O)/b|0;C[2]=(S[2]*(b-O)+I[2]*O)/b|0;x[0]=(A[0]*(b-O)+B[0]*O)/b|0;x[1]=(A[1]*(b-O)+B[1]*O)/b|0;x[2]=(A[2]*(b-O)+B[2]*O)/b|0;for(var P=0;P<=m;P++,w++)if(0!==O&&O!==b||0!==P&&P!==m){for(var M=0,E=0,L=0,D=0;D<=3;D++)for(var F=0;F<=3;F++,L++){var q=R[O][D]*T[P][F];M+=r[n[L]][0]*q;E+=r[n[L]][1]*q}y[w]=r.length;r.push([M,E]);k[w]=i.length;var U=new Uint8Array(3);U[0]=(C[0]*(m-P)+x[0]*P)/m|0;U[1]=(C[1]*(m-P)+x[1]*P)/m|0;U[2]=(C[2]*(m-P)+x[2]*P)/m|0;i.push(U)}}y[0]=n[0];k[0]=s[0];y[m]=n[3];k[m]=s[1];y[v*b]=n[12];k[v*b]=s[2];y[v*b+m]=n[15];k[v*b+m]=s[3];e.figures[t]={type:"lattice",coords:y,colors:k,verticesPerRow:v}}function i(e,t){for(var a=e.coords,r=e.colors,i=new Int32Array(16),n=new Int32Array(4);t.hasData;){var s=t.readFlag();u(0<=s&&s<=3,"Unknown type6 flag");var o,c,l=a.length;for(o=0,c=0!==s?8:12;oo?o:t;a=a>c?c:a;r=r=2,"Invalid VerticesPerRow");a(this,x,A);break;case v.COONS_PATCH_MESH:i(this,x);S=!0;break;case v.TENSOR_PATCH_MESH:n(this,x);S=!0;break;default:f("Unsupported mesh type.")}if(S){s(this);for(var I=0,B=this.figures.length;I0)return!0;var e=this.stream.getByte();if(e<0)return!1;this.buffer=e;this.bufferLength=8;return!0},readBits:function(e){var t=this.buffer,a=this.bufferLength;if(32===e){if(0===a)return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0;t=t<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();var r=this.stream.getByte();this.buffer=r&(1<>a)>>>0}if(8===e&&0===a)return this.stream.getByte();for(;a>a},align:function(){this.buffer=0;this.bufferLength=0},readFlag:function(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function(){var e=this.context.bitsPerCoordinate,t=this.readBits(e),a=this.readBits(e),r=this.context.decode,i=e<32?1/((1<=0&&(t>=65&&t<=90||t>=97&&t<=122);)a.push(String.fromCharCode(t));var r=a.join("");switch(r.toLowerCase()){case"if":return h.IF;case"ifelse":return h.IFELSE;default:return h.getOperator(r)}},getNumber:function(){var e=this.currentChar,t=this.strBuf;t.length=0;t[0]=String.fromCharCode(e);for(;(e=this.nextChar())>=0&&(e>=48&&e<=57||45===e||46===e);)t.push(String.fromCharCode(e));var a=parseFloat(t.join(""));isNaN(a)&&n("Invalid floating point number: "+a);return a}};return e}();t.PostScriptLexer=u;t.PostScriptParser=c},function(e,t,a){"use strict";var r=a(0),i=a(2),n=a(4),s=r.warn,o=r.isSpace,c=i.Stream,l=n.getEncoding,h=function(){function e(){this.width=0;this.lsb=0;this.flexing=!1;this.output=[];this.stack=[]}var t={hstem:[1],vstem:[3],vmoveto:[4],rlineto:[5],hlineto:[6],vlineto:[7],rrcurveto:[8],callsubr:[10],flex:[12,35],drop:[12,18],endchar:[14],rmoveto:[21],hmoveto:[22],vhcurveto:[30],hvcurveto:[31]};e.prototype={convert:function(e,a,r){for(var i,n,o,c=e.length,l=!1,h=0;hr)return!0;for(var i=r-e,n=i;n>8&255,255&s);else{s=65536*s|0;this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s)}}this.output.push.apply(this.output,t);a?this.stack.splice(i,e):this.stack.length=0;return!1}};return e}(),u=function(){function e(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function t(e,t,a){if(a>=e.length)return new Uint8Array(0);var r,i,n=0|t;for(r=0;r>8;n=52845*(c+n)+22719&65535}return o}function a(t,a,r){var i,n,s=0|a,o=t.length,c=o>>>1,l=new Uint8Array(c);for(i=0,n=0;i>8;s=52845*(f+s)+22719&65535}}}return Array.prototype.slice.call(l,r,n)}function r(e){return 47===e||91===e||93===e||123===e||125===e||40===e||41===e}function i(r,i,s){if(i){var o=r.getBytes(),l=!(e(o[0])&&e(o[1])&&e(o[2])&&e(o[3]));r=new c(l?t(o,n,4):a(o,n,4))}this.seacAnalysisEnabled=!!s;this.stream=r;this.nextChar()}var n=55665;i.prototype={readNumberArray:function(){this.getToken();for(var e=[];;){var t=this.getToken();if(null===t||"]"===t||"}"===t)break;e.push(parseFloat(t||0))}return e},readNumber:function(){var e=this.getToken();return parseFloat(e||0)},readInt:function(){var e=this.getToken();return 0|parseInt(e||0,10)},readBoolean:function(){return"true"===this.getToken()?1:0},nextChar:function(){return this.currentChar=this.stream.getByte()},getToken:function(){for(var e=!1,t=this.currentChar;;){if(-1===t)return null;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(!o(t))break;t=this.nextChar()}if(r(t)){this.nextChar();return String.fromCharCode(t)}var a="";do{a+=String.fromCharCode(t);t=this.nextChar()}while(t>=0&&!o(t)&&!r(t));return a},extractFontProgram:function(){var e=this.stream,a=[],r=[],i=Object.create(null);i.lenIV=4;for(var n,s,o,c,l,u={subrs:[],charstrings:[],properties:{privateData:i}};null!==(n=this.getToken());)if("/"===n){n=this.getToken();switch(n){case"CharStrings":this.getToken();this.getToken();this.getToken();this.getToken();for(;;){n=this.getToken();if(null===n||"end"===n)break;if("/"===n){var f=this.getToken();s=this.readInt();this.getToken();o=e.makeSubStream(e.pos,s);c=u.properties.privateData.lenIV;l=t(o.getBytes(),4330,c);e.skip(s);this.nextChar();n=this.getToken();"noaccess"===n&&this.getToken();r.push({glyph:f,encoded:l})}}break;case"Subrs":this.readInt();this.getToken();for(;"dup"===(n=this.getToken());){var d=this.readInt();s=this.readInt();this.getToken();o=e.makeSubStream(e.pos,s);c=u.properties.privateData.lenIV;l=t(o.getBytes(),4330,c);e.skip(s);this.nextChar();n=this.getToken();"noaccess"===n&&this.getToken();a[d]=l}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var g=this.readNumberArray();(g.length>0&&g.length,1)||(u.properties.privateData[n]=g);break;case"StemSnapH":case"StemSnapV":u.properties.privateData[n]=this.readNumberArray();break;case"StdHW":case"StdVW":u.properties.privateData[n]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":case"ExpansionFactor":u.properties.privateData[n]=this.readNumber();break;case"ForceBold":u.properties.privateData[n]=this.readBoolean()}}for(var p=0;p=0,o=/Chrome\/(39|40)\./.test(a),c=a.indexOf("CriOS")>=0,l=a.indexOf("Trident")>=0,h=/\b(iPad|iPhone|iPod)(?=;)/.test(a),u=a.indexOf("Opera")>=0,f=/Safari\//.test(a)&&!/(Chrome\/|Android\s)/.test(a),d="object"==typeof window&&"object"==typeof document;"undefined"==typeof PDFJS&&(t.PDFJS={});PDFJS.compatibilityChecked=!0;!function(){function e(e,t){return new r(this.slice(e,t))}function a(e,t){arguments.length<2&&(t=0);for(var a=0,r=e.length;a>2,l=(3&n)<<4|s>>4,h=a+1>6:64,u=a+2>(-2*r&6)):0)a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);return n}}}();!function(){void 0===Function.prototype.bind&&(Function.prototype.bind=function(e){var t=this,a=Array.prototype.slice.call(arguments,1);return function(){var r=a.concat(Array.prototype.slice.call(arguments));return t.apply(e,r)}})}();!function(){if(d){"dataset"in document.createElement("div")||Object.defineProperty(HTMLElement.prototype,"dataset",{get:function(){if(this._dataset)return this._dataset;for(var e={},t=0,a=this.attributes.length;t=0&&r&&n.splice(s,1);e.className=n.join(" ");return s>=0}if(d){if(!("classList"in document.createElement("div"))){var t={add:function(t){e(this.element,t,!0,!1)},contains:function(t){return e(this.element,t,!1,!1)},remove:function(t){e(this.element,t,!1,!0)},toggle:function(t){e(this.element,t,!0,!0)}};Object.defineProperty(HTMLElement.prototype,"classList",{get:function(){if(this._classList)return this._classList;var e=Object.create(t,{element:{value:this,writable:!1,enumerable:!0}});Object.defineProperty(this,"_classList",{value:e,writable:!1,enumerable:!1});return e},enumerable:!0})}}}();!function(){if(!("undefined"==typeof importScripts||"console"in t)){var e={},a={log:function(){var e=Array.prototype.slice.call(arguments);t.postMessage({targetName:"main",action:"console_log",data:e})},error:function(){var e=Array.prototype.slice.call(arguments);t.postMessage({targetName:"main",action:"console_error",data:e})},time:function(t){e[t]=Date.now()},timeEnd:function(t){var a=e[t];if(!a)throw new Error("Unknown timer name "+t);this.log("Timer:",t,Date.now()-a)}};t.console=a}}();!function(){if(d)if("console"in window)if("bind"in console.log);else{console.log=function(e){return function(t){return e(t)}}(console.log);console.error=function(e){return function(t){return e(t)}}(console.error);console.warn=function(e){return function(t){return e(t)}}(console.warn)}else window.console={log:function(){},error:function(){},warn:function(){}}}();!function(){function e(e){t(e.target)&&e.stopPropagation()}function t(e){return e.disabled||e.parentNode&&t(e.parentNode)}u&&document.addEventListener("click",e,!0)}();!function(){(l||c)&&(PDFJS.disableCreateObjectURL=!0)}();!function(){"undefined"!=typeof navigator&&("language"in navigator||(PDFJS.locale=navigator.userLanguage||"en-US"))}();!function(){if(f||i||o||h){PDFJS.disableRange=!0;PDFJS.disableStream=!0}}();!function(){d&&(history.pushState&&!i||(PDFJS.disableHistory=!0))}();!function(){if(d)if(window.CanvasPixelArray)"function"!=typeof window.CanvasPixelArray.prototype.set&&(window.CanvasPixelArray.prototype.set=function(e){for(var t=0,a=this.length;t0;){var a=this.handlers.shift(),r=a.thisPromise._status,i=a.thisPromise._value;try{if(1===r)"function"==typeof a.onResolve&&(i=a.onResolve(i));else if("function"==typeof a.onReject){i=a.onReject(i);r=1;a.thisPromise._unhandledRejection&&this.removeUnhandeledRejection(a.thisPromise)}}catch(t){r=e;i=t}a.nextPromise._updateStatus(r,i);if(Date.now()>=t)break}this.handlers.length>0?setTimeout(this.runHandlers.bind(this),0):this.running=!1},addUnhandledRejection:function(e){this.unhandledRejections.push({promise:e,time:Date.now()});this.scheduleRejectionCheck()},removeUnhandeledRejection:function(e){e._unhandledRejection=!1;for(var t=0;t500){var a=this.unhandledRejections[t].promise._value,r="Unhandled rejection: "+a;a.stack&&(r+="\n"+a.stack);try{throw new Error(r)}catch(e){console.warn(r)}this.unhandledRejections.splice(t);t--}this.unhandledRejections.length&&this.scheduleRejectionCheck()}.bind(this),500)}}},r=function(e){this._status=0;this._handlers=[];try{e.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(e){this._reject(e)}};r.all=function(t){function a(t){if(s._status!==e){c=[];n(t)}}var i,n,s=new r(function(e,t){i=e;n=t}),o=t.length,c=[];if(0===o){i(c);return s}for(var l=0,h=t.length;l32&&t<127&&-1===[34,35,60,62,63,96].indexOf(t)?e:encodeURIComponent(e)}function n(e){var t=e.charCodeAt(0);return t>32&&t<127&&-1===[34,35,60,62,96].indexOf(t)?e:encodeURIComponent(e)}function s(t,s,o){function c(e){y.push(e)}var l=s||"scheme start",h=0,m="",b=!1,v=!1,y=[];e:for(;(t[h-1]!==d||0===h)&&!this._isInvalid;){var k=t[h];switch(l){case"scheme start":if(!k||!g.test(k)){if(s){c("Invalid scheme.");break e}m="";l="no scheme";continue}m+=k.toLowerCase();l="scheme";break;case"scheme":if(k&&p.test(k))m+=k.toLowerCase();else{if(":"!==k){if(s){if(k===d)break e;c("Code point not allowed in scheme: "+k);break e}m="";h=0;l="no scheme";continue}this._scheme=m;m="";if(s)break e;e(this._scheme)&&(this._isRelative=!0);l="file"===this._scheme?"relative":this._isRelative&&o&&o._scheme===this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":if("?"===k){this._query="?";l="query"}else if("#"===k){this._fragment="#";l="fragment"}else k!==d&&"\t"!==k&&"\n"!==k&&"\r"!==k&&(this._schemeData+=i(k));break;case"no scheme":if(o&&e(o._scheme)){l="relative";continue}c("Missing scheme.");a.call(this);break;case"relative or authority":if("/"!==k||"/"!==t[h+1]){c("Expected /, got: "+k);l="relative";continue}l="authority ignore slashes";break;case"relative":this._isRelative=!0;"file"!==this._scheme&&(this._scheme=o._scheme);if(k===d){this._host=o._host;this._port=o._port;this._path=o._path.slice();this._query=o._query;this._username=o._username;this._password=o._password;break e}if("/"===k||"\\"===k){"\\"===k&&c("\\ is an invalid code point.");l="relative slash"}else if("?"===k){this._host=o._host;this._port=o._port;this._path=o._path.slice();this._query="?";this._username=o._username;this._password=o._password;l="query"}else{if("#"!==k){var w=t[h+1],C=t[h+2];if("file"!==this._scheme||!g.test(k)||":"!==w&&"|"!==w||C!==d&&"/"!==C&&"\\"!==C&&"?"!==C&&"#"!==C){this._host=o._host;this._port=o._port;this._username=o._username;this._password=o._password;this._path=o._path.slice();this._path.pop()}l="relative path";continue}this._host=o._host;this._port=o._port;this._path=o._path.slice();this._query=o._query;this._fragment="#";this._username=o._username;this._password=o._password;l="fragment"}break;case"relative slash":if("/"!==k&&"\\"!==k){if("file"!==this._scheme){this._host=o._host;this._port=o._port;this._username=o._username;this._password=o._password}l="relative path";continue}"\\"===k&&c("\\ is an invalid code point.");l="file"===this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!==k){c("Expected '/', got: "+k);l="authority ignore slashes";continue}l="authority second slash";break;case"authority second slash":l="authority ignore slashes";if("/"!==k){c("Expected '/', got: "+k);continue}break;case"authority ignore slashes":if("/"!==k&&"\\"!==k){l="authority";continue}c("Expected authority, got: "+k);break;case"authority":if("@"===k){if(b){c("@ already seen.");m+="%40"}b=!0;for(var x=0;x 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - - -/***/ }), -/* 1 */, -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/* Copyright 2017 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -(function webpackUniversalModuleDefinition(root, factory) { - if(true) - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define("pdfjs-dist/build/pdf", [], factory); - else if(typeof exports === 'object') - exports["pdfjs-dist/build/pdf"] = factory(); - else - root["pdfjs-dist/build/pdf"] = root.pdfjsDistBuildPdf = factory(); -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __w_pdfjs_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; -/******/ -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __w_pdfjs_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __w_pdfjs_require__.c = installedModules; -/******/ -/******/ // identity function for calling harmony imports with the correct context -/******/ __w_pdfjs_require__.i = function(value) { return value; }; -/******/ -/******/ // define getter function for harmony exports -/******/ __w_pdfjs_require__.d = function(exports, name, getter) { -/******/ if(!__w_pdfjs_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { -/******/ configurable: false, -/******/ enumerable: true, -/******/ get: getter -/******/ }); -/******/ } -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __w_pdfjs_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __w_pdfjs_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __w_pdfjs_require__.p = ""; -/******/ -/******/ // Load entry module and return exports -/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 13); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(global) { - -var compatibility = __w_pdfjs_require__(14); -var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined; -var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; -var TextRenderingMode = { - FILL: 0, - STROKE: 1, - FILL_STROKE: 2, - INVISIBLE: 3, - FILL_ADD_TO_PATH: 4, - STROKE_ADD_TO_PATH: 5, - FILL_STROKE_ADD_TO_PATH: 6, - ADD_TO_PATH: 7, - FILL_STROKE_MASK: 3, - ADD_TO_PATH_FLAG: 4 -}; -var ImageKind = { - GRAYSCALE_1BPP: 1, - RGB_24BPP: 2, - RGBA_32BPP: 3 -}; -var AnnotationType = { - TEXT: 1, - LINK: 2, - FREETEXT: 3, - LINE: 4, - SQUARE: 5, - CIRCLE: 6, - POLYGON: 7, - POLYLINE: 8, - HIGHLIGHT: 9, - UNDERLINE: 10, - SQUIGGLY: 11, - STRIKEOUT: 12, - STAMP: 13, - CARET: 14, - INK: 15, - POPUP: 16, - FILEATTACHMENT: 17, - SOUND: 18, - MOVIE: 19, - WIDGET: 20, - SCREEN: 21, - PRINTERMARK: 22, - TRAPNET: 23, - WATERMARK: 24, - THREED: 25, - REDACT: 26 -}; -var AnnotationFlag = { - INVISIBLE: 0x01, - HIDDEN: 0x02, - PRINT: 0x04, - NOZOOM: 0x08, - NOROTATE: 0x10, - NOVIEW: 0x20, - READONLY: 0x40, - LOCKED: 0x80, - TOGGLENOVIEW: 0x100, - LOCKEDCONTENTS: 0x200 -}; -var AnnotationFieldFlag = { - READONLY: 0x0000001, - REQUIRED: 0x0000002, - NOEXPORT: 0x0000004, - MULTILINE: 0x0001000, - PASSWORD: 0x0002000, - NOTOGGLETOOFF: 0x0004000, - RADIO: 0x0008000, - PUSHBUTTON: 0x0010000, - COMBO: 0x0020000, - EDIT: 0x0040000, - SORT: 0x0080000, - FILESELECT: 0x0100000, - MULTISELECT: 0x0200000, - DONOTSPELLCHECK: 0x0400000, - DONOTSCROLL: 0x0800000, - COMB: 0x1000000, - RICHTEXT: 0x2000000, - RADIOSINUNISON: 0x2000000, - COMMITONSELCHANGE: 0x4000000 -}; -var AnnotationBorderStyleType = { - SOLID: 1, - DASHED: 2, - BEVELED: 3, - INSET: 4, - UNDERLINE: 5 -}; -var StreamType = { - UNKNOWN: 0, - FLATE: 1, - LZW: 2, - DCT: 3, - JPX: 4, - JBIG: 5, - A85: 6, - AHX: 7, - CCF: 8, - RL: 9 -}; -var FontType = { - UNKNOWN: 0, - TYPE1: 1, - TYPE1C: 2, - CIDFONTTYPE0: 3, - CIDFONTTYPE0C: 4, - TRUETYPE: 5, - CIDFONTTYPE2: 6, - TYPE3: 7, - OPENTYPE: 8, - TYPE0: 9, - MMTYPE1: 10 -}; -var VERBOSITY_LEVELS = { - errors: 0, - warnings: 1, - infos: 5 -}; -var CMapCompressionType = { - NONE: 0, - BINARY: 1, - STREAM: 2 -}; -var OPS = { - dependency: 1, - setLineWidth: 2, - setLineCap: 3, - setLineJoin: 4, - setMiterLimit: 5, - setDash: 6, - setRenderingIntent: 7, - setFlatness: 8, - setGState: 9, - save: 10, - restore: 11, - transform: 12, - moveTo: 13, - lineTo: 14, - curveTo: 15, - curveTo2: 16, - curveTo3: 17, - closePath: 18, - rectangle: 19, - stroke: 20, - closeStroke: 21, - fill: 22, - eoFill: 23, - fillStroke: 24, - eoFillStroke: 25, - closeFillStroke: 26, - closeEOFillStroke: 27, - endPath: 28, - clip: 29, - eoClip: 30, - beginText: 31, - endText: 32, - setCharSpacing: 33, - setWordSpacing: 34, - setHScale: 35, - setLeading: 36, - setFont: 37, - setTextRenderingMode: 38, - setTextRise: 39, - moveText: 40, - setLeadingMoveText: 41, - setTextMatrix: 42, - nextLine: 43, - showText: 44, - showSpacedText: 45, - nextLineShowText: 46, - nextLineSetSpacingShowText: 47, - setCharWidth: 48, - setCharWidthAndBounds: 49, - setStrokeColorSpace: 50, - setFillColorSpace: 51, - setStrokeColor: 52, - setStrokeColorN: 53, - setFillColor: 54, - setFillColorN: 55, - setStrokeGray: 56, - setFillGray: 57, - setStrokeRGBColor: 58, - setFillRGBColor: 59, - setStrokeCMYKColor: 60, - setFillCMYKColor: 61, - shadingFill: 62, - beginInlineImage: 63, - beginImageData: 64, - endInlineImage: 65, - paintXObject: 66, - markPoint: 67, - markPointProps: 68, - beginMarkedContent: 69, - beginMarkedContentProps: 70, - endMarkedContent: 71, - beginCompat: 72, - endCompat: 73, - paintFormXObjectBegin: 74, - paintFormXObjectEnd: 75, - beginGroup: 76, - endGroup: 77, - beginAnnotations: 78, - endAnnotations: 79, - beginAnnotation: 80, - endAnnotation: 81, - paintJpegXObject: 82, - paintImageMaskXObject: 83, - paintImageMaskXObjectGroup: 84, - paintImageXObject: 85, - paintInlineImageXObject: 86, - paintInlineImageXObjectGroup: 87, - paintImageXObjectRepeat: 88, - paintImageMaskXObjectRepeat: 89, - paintSolidColorImageMask: 90, - constructPath: 91 -}; -var verbosity = VERBOSITY_LEVELS.warnings; -function setVerbosityLevel(level) { - verbosity = level; -} -function getVerbosityLevel() { - return verbosity; -} -function info(msg) { - if (verbosity >= VERBOSITY_LEVELS.infos) { - console.log('Info: ' + msg); - } -} -function warn(msg) { - if (verbosity >= VERBOSITY_LEVELS.warnings) { - console.log('Warning: ' + msg); - } -} -function deprecated(details) { - console.log('Deprecated API usage: ' + details); -} -function error(msg) { - if (verbosity >= VERBOSITY_LEVELS.errors) { - console.log('Error: ' + msg); - console.log(backtrace()); - } - throw new Error(msg); -} -function backtrace() { - try { - throw new Error(); - } catch (e) { - return e.stack ? e.stack.split('\n').slice(2).join('\n') : ''; - } -} -function assert(cond, msg) { - if (!cond) { - error(msg); - } -} -var UNSUPPORTED_FEATURES = { - unknown: 'unknown', - forms: 'forms', - javaScript: 'javaScript', - smask: 'smask', - shadingPattern: 'shadingPattern', - font: 'font' -}; -function isSameOrigin(baseUrl, otherUrl) { - try { - var base = new URL(baseUrl); - if (!base.origin || base.origin === 'null') { - return false; - } - } catch (e) { - return false; - } - var other = new URL(otherUrl, base); - return base.origin === other.origin; -} -function isValidProtocol(url) { - if (!url) { - return false; - } - switch (url.protocol) { - case 'http:': - case 'https:': - case 'ftp:': - case 'mailto:': - case 'tel:': - return true; - default: - return false; - } -} -function createValidAbsoluteUrl(url, baseUrl) { - if (!url) { - return null; - } - try { - var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url); - if (isValidProtocol(absoluteUrl)) { - return absoluteUrl; - } - } catch (ex) {} - return null; -} -function shadow(obj, prop, value) { - Object.defineProperty(obj, prop, { - value: value, - enumerable: true, - configurable: true, - writable: false - }); - return value; -} -function getLookupTableFactory(initializer) { - var lookup; - return function () { - if (initializer) { - lookup = Object.create(null); - initializer(lookup); - initializer = null; - } - return lookup; - }; -} -var PasswordResponses = { - NEED_PASSWORD: 1, - INCORRECT_PASSWORD: 2 -}; -var PasswordException = function PasswordExceptionClosure() { - function PasswordException(msg, code) { - this.name = 'PasswordException'; - this.message = msg; - this.code = code; - } - PasswordException.prototype = new Error(); - PasswordException.constructor = PasswordException; - return PasswordException; -}(); -var UnknownErrorException = function UnknownErrorExceptionClosure() { - function UnknownErrorException(msg, details) { - this.name = 'UnknownErrorException'; - this.message = msg; - this.details = details; - } - UnknownErrorException.prototype = new Error(); - UnknownErrorException.constructor = UnknownErrorException; - return UnknownErrorException; -}(); -var InvalidPDFException = function InvalidPDFExceptionClosure() { - function InvalidPDFException(msg) { - this.name = 'InvalidPDFException'; - this.message = msg; - } - InvalidPDFException.prototype = new Error(); - InvalidPDFException.constructor = InvalidPDFException; - return InvalidPDFException; -}(); -var MissingPDFException = function MissingPDFExceptionClosure() { - function MissingPDFException(msg) { - this.name = 'MissingPDFException'; - this.message = msg; - } - MissingPDFException.prototype = new Error(); - MissingPDFException.constructor = MissingPDFException; - return MissingPDFException; -}(); -var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() { - function UnexpectedResponseException(msg, status) { - this.name = 'UnexpectedResponseException'; - this.message = msg; - this.status = status; - } - UnexpectedResponseException.prototype = new Error(); - UnexpectedResponseException.constructor = UnexpectedResponseException; - return UnexpectedResponseException; -}(); -var NotImplementedException = function NotImplementedExceptionClosure() { - function NotImplementedException(msg) { - this.message = msg; - } - NotImplementedException.prototype = new Error(); - NotImplementedException.prototype.name = 'NotImplementedException'; - NotImplementedException.constructor = NotImplementedException; - return NotImplementedException; -}(); -var MissingDataException = function MissingDataExceptionClosure() { - function MissingDataException(begin, end) { - this.begin = begin; - this.end = end; - this.message = 'Missing data [' + begin + ', ' + end + ')'; - } - MissingDataException.prototype = new Error(); - MissingDataException.prototype.name = 'MissingDataException'; - MissingDataException.constructor = MissingDataException; - return MissingDataException; -}(); -var XRefParseException = function XRefParseExceptionClosure() { - function XRefParseException(msg) { - this.message = msg; - } - XRefParseException.prototype = new Error(); - XRefParseException.prototype.name = 'XRefParseException'; - XRefParseException.constructor = XRefParseException; - return XRefParseException; -}(); -var NullCharactersRegExp = /\x00/g; -function removeNullCharacters(str) { - if (typeof str !== 'string') { - warn('The argument for removeNullCharacters must be a string.'); - return str; - } - return str.replace(NullCharactersRegExp, ''); -} -function bytesToString(bytes) { - assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString'); - var length = bytes.length; - var MAX_ARGUMENT_COUNT = 8192; - if (length < MAX_ARGUMENT_COUNT) { - return String.fromCharCode.apply(null, bytes); - } - var strBuf = []; - for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) { - var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length); - var chunk = bytes.subarray(i, chunkEnd); - strBuf.push(String.fromCharCode.apply(null, chunk)); - } - return strBuf.join(''); -} -function stringToBytes(str) { - assert(typeof str === 'string', 'Invalid argument for stringToBytes'); - var length = str.length; - var bytes = new Uint8Array(length); - for (var i = 0; i < length; ++i) { - bytes[i] = str.charCodeAt(i) & 0xFF; - } - return bytes; -} -function arrayByteLength(arr) { - if (arr.length !== undefined) { - return arr.length; - } - assert(arr.byteLength !== undefined); - return arr.byteLength; -} -function arraysToBytes(arr) { - if (arr.length === 1 && arr[0] instanceof Uint8Array) { - return arr[0]; - } - var resultLength = 0; - var i, - ii = arr.length; - var item, itemLength; - for (i = 0; i < ii; i++) { - item = arr[i]; - itemLength = arrayByteLength(item); - resultLength += itemLength; - } - var pos = 0; - var data = new Uint8Array(resultLength); - for (i = 0; i < ii; i++) { - item = arr[i]; - if (!(item instanceof Uint8Array)) { - if (typeof item === 'string') { - item = stringToBytes(item); - } else { - item = new Uint8Array(item); - } - } - itemLength = item.byteLength; - data.set(item, pos); - pos += itemLength; - } - return data; -} -function string32(value) { - return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff); -} -function log2(x) { - var n = 1, - i = 0; - while (x > n) { - n <<= 1; - i++; - } - return i; -} -function readInt8(data, start) { - return data[start] << 24 >> 24; -} -function readUint16(data, offset) { - return data[offset] << 8 | data[offset + 1]; -} -function readUint32(data, offset) { - return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0; -} -function isLittleEndian() { - var buffer8 = new Uint8Array(2); - buffer8[0] = 1; - var buffer16 = new Uint16Array(buffer8.buffer); - return buffer16[0] === 1; -} -function isEvalSupported() { - try { - new Function(''); - return true; - } catch (e) { - return false; - } -} -var Uint32ArrayView = function Uint32ArrayViewClosure() { - function Uint32ArrayView(buffer, length) { - this.buffer = buffer; - this.byteLength = buffer.length; - this.length = length === undefined ? this.byteLength >> 2 : length; - ensureUint32ArrayViewProps(this.length); - } - Uint32ArrayView.prototype = Object.create(null); - var uint32ArrayViewSetters = 0; - function createUint32ArrayProp(index) { - return { - get: function () { - var buffer = this.buffer, - offset = index << 2; - return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0; - }, - set: function (value) { - var buffer = this.buffer, - offset = index << 2; - buffer[offset] = value & 255; - buffer[offset + 1] = value >> 8 & 255; - buffer[offset + 2] = value >> 16 & 255; - buffer[offset + 3] = value >>> 24 & 255; - } - }; - } - function ensureUint32ArrayViewProps(length) { - while (uint32ArrayViewSetters < length) { - Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters)); - uint32ArrayViewSetters++; - } - } - return Uint32ArrayView; -}(); -exports.Uint32ArrayView = Uint32ArrayView; -var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; -var Util = function UtilClosure() { - function Util() {} - var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')']; - Util.makeCssRgb = function Util_makeCssRgb(r, g, b) { - rgbBuf[1] = r; - rgbBuf[3] = g; - rgbBuf[5] = b; - return rgbBuf.join(''); - }; - Util.transform = function Util_transform(m1, m2) { - 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]]; - }; - Util.applyTransform = function Util_applyTransform(p, m) { - var xt = p[0] * m[0] + p[1] * m[2] + m[4]; - var yt = p[0] * m[1] + p[1] * m[3] + m[5]; - return [xt, yt]; - }; - Util.applyInverseTransform = function Util_applyInverseTransform(p, m) { - var d = m[0] * m[3] - m[1] * m[2]; - var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d; - var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d; - return [xt, yt]; - }; - Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) { - var p1 = Util.applyTransform(r, m); - var p2 = Util.applyTransform(r.slice(2, 4), m); - var p3 = Util.applyTransform([r[0], r[3]], m); - var p4 = Util.applyTransform([r[2], r[1]], m); - 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])]; - }; - Util.inverseTransform = function Util_inverseTransform(m) { - var d = m[0] * m[3] - m[1] * m[2]; - 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]; - }; - Util.apply3dTransform = function Util_apply3dTransform(m, v) { - 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]]; - }; - Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) { - var transpose = [m[0], m[2], m[1], m[3]]; - var a = m[0] * transpose[0] + m[1] * transpose[2]; - var b = m[0] * transpose[1] + m[1] * transpose[3]; - var c = m[2] * transpose[0] + m[3] * transpose[2]; - var d = m[2] * transpose[1] + m[3] * transpose[3]; - var first = (a + d) / 2; - var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2; - var sx = first + second || 1; - var sy = first - second || 1; - return [Math.sqrt(sx), Math.sqrt(sy)]; - }; - Util.normalizeRect = function Util_normalizeRect(rect) { - var r = rect.slice(0); - if (rect[0] > rect[2]) { - r[0] = rect[2]; - r[2] = rect[0]; - } - if (rect[1] > rect[3]) { - r[1] = rect[3]; - r[3] = rect[1]; - } - return r; - }; - Util.intersect = function Util_intersect(rect1, rect2) { - function compare(a, b) { - return a - b; - } - var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare), - orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare), - result = []; - rect1 = Util.normalizeRect(rect1); - rect2 = Util.normalizeRect(rect2); - if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) { - result[0] = orderedX[1]; - result[2] = orderedX[2]; - } else { - return false; - } - if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) { - result[1] = orderedY[1]; - result[3] = orderedY[2]; - } else { - return false; - } - return result; - }; - Util.sign = function Util_sign(num) { - return num < 0 ? -1 : 1; - }; - 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']; - Util.toRoman = function Util_toRoman(number, lowerCase) { - assert(isInt(number) && number > 0, 'The number should be a positive integer.'); - var pos, - romanBuf = []; - while (number >= 1000) { - number -= 1000; - romanBuf.push('M'); - } - pos = number / 100 | 0; - number %= 100; - romanBuf.push(ROMAN_NUMBER_MAP[pos]); - pos = number / 10 | 0; - number %= 10; - romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]); - romanBuf.push(ROMAN_NUMBER_MAP[20 + number]); - var romanStr = romanBuf.join(''); - return lowerCase ? romanStr.toLowerCase() : romanStr; - }; - Util.appendToArray = function Util_appendToArray(arr1, arr2) { - Array.prototype.push.apply(arr1, arr2); - }; - Util.prependToArray = function Util_prependToArray(arr1, arr2) { - Array.prototype.unshift.apply(arr1, arr2); - }; - Util.extendObj = function extendObj(obj1, obj2) { - for (var key in obj2) { - obj1[key] = obj2[key]; - } - }; - Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) { - while (dict && !dict.has(name)) { - dict = dict.get('Parent'); - } - if (!dict) { - return null; - } - return getArray ? dict.getArray(name) : dict.get(name); - }; - Util.inherit = function Util_inherit(sub, base, prototype) { - sub.prototype = Object.create(base.prototype); - sub.prototype.constructor = sub; - for (var prop in prototype) { - sub.prototype[prop] = prototype[prop]; - } - }; - Util.loadScript = function Util_loadScript(src, callback) { - var script = document.createElement('script'); - var loaded = false; - script.setAttribute('src', src); - if (callback) { - script.onload = function () { - if (!loaded) { - callback(); - } - loaded = true; - }; - } - document.getElementsByTagName('head')[0].appendChild(script); - }; - return Util; -}(); -var PageViewport = function PageViewportClosure() { - function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) { - this.viewBox = viewBox; - this.scale = scale; - this.rotation = rotation; - this.offsetX = offsetX; - this.offsetY = offsetY; - var centerX = (viewBox[2] + viewBox[0]) / 2; - var centerY = (viewBox[3] + viewBox[1]) / 2; - var rotateA, rotateB, rotateC, rotateD; - rotation = rotation % 360; - rotation = rotation < 0 ? rotation + 360 : rotation; - switch (rotation) { - case 180: - rotateA = -1; - rotateB = 0; - rotateC = 0; - rotateD = 1; - break; - case 90: - rotateA = 0; - rotateB = 1; - rotateC = 1; - rotateD = 0; - break; - case 270: - rotateA = 0; - rotateB = -1; - rotateC = -1; - rotateD = 0; - break; - default: - rotateA = 1; - rotateB = 0; - rotateC = 0; - rotateD = -1; - break; - } - if (dontFlip) { - rotateC = -rotateC; - rotateD = -rotateD; - } - var offsetCanvasX, offsetCanvasY; - var width, height; - if (rotateA === 0) { - offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX; - offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY; - width = Math.abs(viewBox[3] - viewBox[1]) * scale; - height = Math.abs(viewBox[2] - viewBox[0]) * scale; - } else { - offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX; - offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY; - width = Math.abs(viewBox[2] - viewBox[0]) * scale; - height = Math.abs(viewBox[3] - viewBox[1]) * scale; - } - this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY]; - this.width = width; - this.height = height; - this.fontScale = scale; - } - PageViewport.prototype = { - clone: function PageViewPort_clone(args) { - args = args || {}; - var scale = 'scale' in args ? args.scale : this.scale; - var rotation = 'rotation' in args ? args.rotation : this.rotation; - return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip); - }, - convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) { - return Util.applyTransform([x, y], this.transform); - }, - convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) { - var tl = Util.applyTransform([rect[0], rect[1]], this.transform); - var br = Util.applyTransform([rect[2], rect[3]], this.transform); - return [tl[0], tl[1], br[0], br[1]]; - }, - convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) { - return Util.applyInverseTransform([x, y], this.transform); - } - }; - return PageViewport; -}(); -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]; -function stringToPDFString(str) { - var i, - n = str.length, - strBuf = []; - if (str[0] === '\xFE' && str[1] === '\xFF') { - for (i = 2; i < n; i += 2) { - strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1))); - } - } else { - for (i = 0; i < n; ++i) { - var code = PDFStringTranslateTable[str.charCodeAt(i)]; - strBuf.push(code ? String.fromCharCode(code) : str.charAt(i)); - } - } - return strBuf.join(''); -} -function stringToUTF8String(str) { - return decodeURIComponent(escape(str)); -} -function utf8StringToString(str) { - return unescape(encodeURIComponent(str)); -} -function isEmptyObj(obj) { - for (var key in obj) { - return false; - } - return true; -} -function isBool(v) { - return typeof v === 'boolean'; -} -function isInt(v) { - return typeof v === 'number' && (v | 0) === v; -} -function isNum(v) { - return typeof v === 'number'; -} -function isString(v) { - return typeof v === 'string'; -} -function isArray(v) { - return v instanceof Array; -} -function isArrayBuffer(v) { - return typeof v === 'object' && v !== null && v.byteLength !== undefined; -} -function isSpace(ch) { - return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A; -} -function isNodeJS() { - if (typeof __pdfjsdev_webpack__ === 'undefined') { - return typeof process === 'object' && process + '' === '[object process]'; - } - return false; -} -function createPromiseCapability() { - var capability = {}; - capability.promise = new Promise(function (resolve, reject) { - capability.resolve = resolve; - capability.reject = reject; - }); - return capability; -} -var StatTimer = function StatTimerClosure() { - function rpad(str, pad, length) { - while (str.length < length) { - str += pad; - } - return str; - } - function StatTimer() { - this.started = Object.create(null); - this.times = []; - this.enabled = true; - } - StatTimer.prototype = { - time: function StatTimer_time(name) { - if (!this.enabled) { - return; - } - if (name in this.started) { - warn('Timer is already running for ' + name); - } - this.started[name] = Date.now(); - }, - timeEnd: function StatTimer_timeEnd(name) { - if (!this.enabled) { - return; - } - if (!(name in this.started)) { - warn('Timer has not been started for ' + name); - } - this.times.push({ - 'name': name, - 'start': this.started[name], - 'end': Date.now() - }); - delete this.started[name]; - }, - toString: function StatTimer_toString() { - var i, ii; - var times = this.times; - var out = ''; - var longest = 0; - for (i = 0, ii = times.length; i < ii; ++i) { - var name = times[i]['name']; - if (name.length > longest) { - longest = name.length; - } - } - for (i = 0, ii = times.length; i < ii; ++i) { - var span = times[i]; - var duration = span.end - span.start; - out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n'; - } - return out; - } - }; - return StatTimer; -}(); -var createBlob = function createBlob(data, contentType) { - if (typeof Blob !== 'undefined') { - return new Blob([data], { type: contentType }); - } - warn('The "Blob" constructor is not supported.'); -}; -var createObjectURL = function createObjectURLClosure() { - var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - return function createObjectURL(data, contentType, forceDataSchema) { - if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) { - var blob = createBlob(data, contentType); - return URL.createObjectURL(blob); - } - var buffer = 'data:' + contentType + ';base64,'; - for (var i = 0, ii = data.length; i < ii; i += 3) { - var b1 = data[i] & 0xFF; - var b2 = data[i + 1] & 0xFF; - var b3 = data[i + 2] & 0xFF; - var d1 = b1 >> 2, - d2 = (b1 & 3) << 4 | b2 >> 4; - var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64; - var d4 = i + 2 < ii ? b3 & 0x3F : 64; - buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4]; - } - return buffer; - }; -}(); -function MessageHandler(sourceName, targetName, comObj) { - this.sourceName = sourceName; - this.targetName = targetName; - this.comObj = comObj; - this.callbackIndex = 1; - this.postMessageTransfers = true; - var callbacksCapabilities = this.callbacksCapabilities = Object.create(null); - var ah = this.actionHandler = Object.create(null); - this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) { - var data = event.data; - if (data.targetName !== this.sourceName) { - return; - } - if (data.isReply) { - var callbackId = data.callbackId; - if (data.callbackId in callbacksCapabilities) { - var callback = callbacksCapabilities[callbackId]; - delete callbacksCapabilities[callbackId]; - if ('error' in data) { - callback.reject(data.error); - } else { - callback.resolve(data.data); - } - } else { - error('Cannot resolve callback ' + callbackId); - } - } else if (data.action in ah) { - var action = ah[data.action]; - if (data.callbackId) { - var sourceName = this.sourceName; - var targetName = data.sourceName; - Promise.resolve().then(function () { - return action[0].call(action[1], data.data); - }).then(function (result) { - comObj.postMessage({ - sourceName: sourceName, - targetName: targetName, - isReply: true, - callbackId: data.callbackId, - data: result - }); - }, function (reason) { - if (reason instanceof Error) { - reason = reason + ''; - } - comObj.postMessage({ - sourceName: sourceName, - targetName: targetName, - isReply: true, - callbackId: data.callbackId, - error: reason - }); - }); - } else { - action[0].call(action[1], data.data); - } - } else { - error('Unknown action from worker: ' + data.action); - } - }.bind(this); - comObj.addEventListener('message', this._onComObjOnMessage); -} -MessageHandler.prototype = { - on: function messageHandlerOn(actionName, handler, scope) { - var ah = this.actionHandler; - if (ah[actionName]) { - error('There is already an actionName called "' + actionName + '"'); - } - ah[actionName] = [handler, scope]; - }, - send: function messageHandlerSend(actionName, data, transfers) { - var message = { - sourceName: this.sourceName, - targetName: this.targetName, - action: actionName, - data: data - }; - this.postMessage(message, transfers); - }, - sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) { - var callbackId = this.callbackIndex++; - var message = { - sourceName: this.sourceName, - targetName: this.targetName, - action: actionName, - data: data, - callbackId: callbackId - }; - var capability = createPromiseCapability(); - this.callbacksCapabilities[callbackId] = capability; - try { - this.postMessage(message, transfers); - } catch (e) { - capability.reject(e); - } - return capability.promise; - }, - postMessage: function (message, transfers) { - if (transfers && this.postMessageTransfers) { - this.comObj.postMessage(message, transfers); - } else { - this.comObj.postMessage(message); - } - }, - destroy: function () { - this.comObj.removeEventListener('message', this._onComObjOnMessage); - } -}; -function loadJpegStream(id, imageUrl, objs) { - var img = new Image(); - img.onload = function loadJpegStream_onloadClosure() { - objs.resolve(id, img); - }; - img.onerror = function loadJpegStream_onerrorClosure() { - objs.resolve(id, null); - warn('Error during JPEG image loading'); - }; - img.src = imageUrl; -} -exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX; -exports.IDENTITY_MATRIX = IDENTITY_MATRIX; -exports.OPS = OPS; -exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS; -exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES; -exports.AnnotationBorderStyleType = AnnotationBorderStyleType; -exports.AnnotationFieldFlag = AnnotationFieldFlag; -exports.AnnotationFlag = AnnotationFlag; -exports.AnnotationType = AnnotationType; -exports.FontType = FontType; -exports.ImageKind = ImageKind; -exports.CMapCompressionType = CMapCompressionType; -exports.InvalidPDFException = InvalidPDFException; -exports.MessageHandler = MessageHandler; -exports.MissingDataException = MissingDataException; -exports.MissingPDFException = MissingPDFException; -exports.NotImplementedException = NotImplementedException; -exports.PageViewport = PageViewport; -exports.PasswordException = PasswordException; -exports.PasswordResponses = PasswordResponses; -exports.StatTimer = StatTimer; -exports.StreamType = StreamType; -exports.TextRenderingMode = TextRenderingMode; -exports.UnexpectedResponseException = UnexpectedResponseException; -exports.UnknownErrorException = UnknownErrorException; -exports.Util = Util; -exports.XRefParseException = XRefParseException; -exports.arrayByteLength = arrayByteLength; -exports.arraysToBytes = arraysToBytes; -exports.assert = assert; -exports.bytesToString = bytesToString; -exports.createBlob = createBlob; -exports.createPromiseCapability = createPromiseCapability; -exports.createObjectURL = createObjectURL; -exports.deprecated = deprecated; -exports.error = error; -exports.getLookupTableFactory = getLookupTableFactory; -exports.getVerbosityLevel = getVerbosityLevel; -exports.globalScope = globalScope; -exports.info = info; -exports.isArray = isArray; -exports.isArrayBuffer = isArrayBuffer; -exports.isBool = isBool; -exports.isEmptyObj = isEmptyObj; -exports.isInt = isInt; -exports.isNum = isNum; -exports.isString = isString; -exports.isSpace = isSpace; -exports.isNodeJS = isNodeJS; -exports.isSameOrigin = isSameOrigin; -exports.createValidAbsoluteUrl = createValidAbsoluteUrl; -exports.isLittleEndian = isLittleEndian; -exports.isEvalSupported = isEvalSupported; -exports.loadJpegStream = loadJpegStream; -exports.log2 = log2; -exports.readInt8 = readInt8; -exports.readUint16 = readUint16; -exports.readUint32 = readUint32; -exports.removeNullCharacters = removeNullCharacters; -exports.setVerbosityLevel = setVerbosityLevel; -exports.shadow = shadow; -exports.string32 = string32; -exports.stringToBytes = stringToBytes; -exports.stringToPDFString = stringToPDFString; -exports.stringToUTF8String = stringToUTF8String; -exports.utf8StringToString = utf8StringToString; -exports.warn = warn; -/* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(6))) - -/***/ }), -/* 1 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var assert = sharedUtil.assert; -var removeNullCharacters = sharedUtil.removeNullCharacters; -var warn = sharedUtil.warn; -var deprecated = sharedUtil.deprecated; -var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl; -var stringToBytes = sharedUtil.stringToBytes; -var CMapCompressionType = sharedUtil.CMapCompressionType; -var DEFAULT_LINK_REL = 'noopener noreferrer nofollow'; -function DOMCanvasFactory() {} -DOMCanvasFactory.prototype = { - create: function DOMCanvasFactory_create(width, height) { - assert(width > 0 && height > 0, 'invalid canvas size'); - var canvas = document.createElement('canvas'); - var context = canvas.getContext('2d'); - canvas.width = width; - canvas.height = height; - return { - canvas: canvas, - context: context - }; - }, - reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) { - assert(canvasAndContextPair.canvas, 'canvas is not specified'); - assert(width > 0 && height > 0, 'invalid canvas size'); - canvasAndContextPair.canvas.width = width; - canvasAndContextPair.canvas.height = height; - }, - destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) { - assert(canvasAndContextPair.canvas, 'canvas is not specified'); - canvasAndContextPair.canvas.width = 0; - canvasAndContextPair.canvas.height = 0; - canvasAndContextPair.canvas = null; - canvasAndContextPair.context = null; - } -}; -var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() { - function DOMCMapReaderFactory(params) { - this.baseUrl = params.baseUrl || null; - this.isCompressed = params.isCompressed || false; - } - DOMCMapReaderFactory.prototype = { - fetch: function (params) { - var name = params.name; - if (!name) { - return Promise.reject(new Error('CMap name must be specified.')); - } - return new Promise(function (resolve, reject) { - var url = this.baseUrl + name + (this.isCompressed ? '.bcmap' : ''); - var request = new XMLHttpRequest(); - request.open('GET', url, true); - if (this.isCompressed) { - request.responseType = 'arraybuffer'; - } - request.onreadystatechange = function () { - if (request.readyState !== XMLHttpRequest.DONE) { - return; - } - if (request.status === 200 || request.status === 0) { - var data; - if (this.isCompressed && request.response) { - data = new Uint8Array(request.response); - } else if (!this.isCompressed && request.responseText) { - data = stringToBytes(request.responseText); - } - if (data) { - resolve({ - cMapData: data, - compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE - }); - return; - } - } - reject(new Error('Unable to load ' + (this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url)); - }.bind(this); - request.send(null); - }.bind(this)); - } - }; - return DOMCMapReaderFactory; -}(); -var CustomStyle = function CustomStyleClosure() { - var prefixes = ['ms', 'Moz', 'Webkit', 'O']; - var _cache = Object.create(null); - function CustomStyle() {} - CustomStyle.getProp = function get(propName, element) { - if (arguments.length === 1 && typeof _cache[propName] === 'string') { - return _cache[propName]; - } - element = element || document.documentElement; - var style = element.style, - prefixed, - uPropName; - if (typeof style[propName] === 'string') { - return _cache[propName] = propName; - } - uPropName = propName.charAt(0).toUpperCase() + propName.slice(1); - for (var i = 0, l = prefixes.length; i < l; i++) { - prefixed = prefixes[i] + uPropName; - if (typeof style[prefixed] === 'string') { - return _cache[propName] = prefixed; - } - } - return _cache[propName] = 'undefined'; - }; - CustomStyle.setProp = function set(propName, element, str) { - var prop = this.getProp(propName); - if (prop !== 'undefined') { - element.style[prop] = str; - } - }; - return CustomStyle; -}(); -var RenderingCancelledException = function RenderingCancelledException() { - function RenderingCancelledException(msg, type) { - this.message = msg; - this.type = type; - } - RenderingCancelledException.prototype = new Error(); - RenderingCancelledException.prototype.name = 'RenderingCancelledException'; - RenderingCancelledException.constructor = RenderingCancelledException; - return RenderingCancelledException; -}(); -var hasCanvasTypedArrays; -hasCanvasTypedArrays = function hasCanvasTypedArrays() { - var canvas = document.createElement('canvas'); - canvas.width = canvas.height = 1; - var ctx = canvas.getContext('2d'); - var imageData = ctx.createImageData(1, 1); - return typeof imageData.data.buffer !== 'undefined'; -}; -var LinkTarget = { - NONE: 0, - SELF: 1, - BLANK: 2, - PARENT: 3, - TOP: 4 -}; -var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top']; -function addLinkAttributes(link, params) { - var url = params && params.url; - link.href = link.title = url ? removeNullCharacters(url) : ''; - if (url) { - var target = params.target; - if (typeof target === 'undefined') { - target = getDefaultSetting('externalLinkTarget'); - } - link.target = LinkTargetStringMap[target]; - var rel = params.rel; - if (typeof rel === 'undefined') { - rel = getDefaultSetting('externalLinkRel'); - } - link.rel = rel; - } -} -function getFilenameFromUrl(url) { - var anchor = url.indexOf('#'); - var query = url.indexOf('?'); - var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length); - return url.substring(url.lastIndexOf('/', end) + 1, end); -} -function getDefaultSetting(id) { - var globalSettings = sharedUtil.globalScope.PDFJS; - switch (id) { - case 'pdfBug': - return globalSettings ? globalSettings.pdfBug : false; - case 'disableAutoFetch': - return globalSettings ? globalSettings.disableAutoFetch : false; - case 'disableStream': - return globalSettings ? globalSettings.disableStream : false; - case 'disableRange': - return globalSettings ? globalSettings.disableRange : false; - case 'disableFontFace': - return globalSettings ? globalSettings.disableFontFace : false; - case 'disableCreateObjectURL': - return globalSettings ? globalSettings.disableCreateObjectURL : false; - case 'disableWebGL': - return globalSettings ? globalSettings.disableWebGL : true; - case 'cMapUrl': - return globalSettings ? globalSettings.cMapUrl : null; - case 'cMapPacked': - return globalSettings ? globalSettings.cMapPacked : false; - case 'postMessageTransfers': - return globalSettings ? globalSettings.postMessageTransfers : true; - case 'workerPort': - return globalSettings ? globalSettings.workerPort : null; - case 'workerSrc': - return globalSettings ? globalSettings.workerSrc : null; - case 'disableWorker': - return globalSettings ? globalSettings.disableWorker : false; - case 'maxImageSize': - return globalSettings ? globalSettings.maxImageSize : -1; - case 'imageResourcesPath': - return globalSettings ? globalSettings.imageResourcesPath : ''; - case 'isEvalSupported': - return globalSettings ? globalSettings.isEvalSupported : true; - case 'externalLinkTarget': - if (!globalSettings) { - return LinkTarget.NONE; - } - switch (globalSettings.externalLinkTarget) { - case LinkTarget.NONE: - case LinkTarget.SELF: - case LinkTarget.BLANK: - case LinkTarget.PARENT: - case LinkTarget.TOP: - return globalSettings.externalLinkTarget; - } - warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget); - globalSettings.externalLinkTarget = LinkTarget.NONE; - return LinkTarget.NONE; - case 'externalLinkRel': - return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL; - case 'enableStats': - return !!(globalSettings && globalSettings.enableStats); - case 'pdfjsNext': - return !!(globalSettings && globalSettings.pdfjsNext); - default: - throw new Error('Unknown default setting: ' + id); - } -} -function isExternalLinkTargetSet() { - var externalLinkTarget = getDefaultSetting('externalLinkTarget'); - switch (externalLinkTarget) { - case LinkTarget.NONE: - return false; - case LinkTarget.SELF: - case LinkTarget.BLANK: - case LinkTarget.PARENT: - case LinkTarget.TOP: - return true; - } -} -function isValidUrl(url, allowRelative) { - deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.'); - var baseUrl = allowRelative ? 'http://example.com' : null; - return createValidAbsoluteUrl(url, baseUrl) !== null; -} -exports.CustomStyle = CustomStyle; -exports.addLinkAttributes = addLinkAttributes; -exports.isExternalLinkTargetSet = isExternalLinkTargetSet; -exports.isValidUrl = isValidUrl; -exports.getFilenameFromUrl = getFilenameFromUrl; -exports.LinkTarget = LinkTarget; -exports.RenderingCancelledException = RenderingCancelledException; -exports.hasCanvasTypedArrays = hasCanvasTypedArrays; -exports.getDefaultSetting = getDefaultSetting; -exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL; -exports.DOMCanvasFactory = DOMCanvasFactory; -exports.DOMCMapReaderFactory = DOMCMapReaderFactory; - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayDOMUtils = __w_pdfjs_require__(1); -var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType; -var AnnotationType = sharedUtil.AnnotationType; -var stringToPDFString = sharedUtil.stringToPDFString; -var Util = sharedUtil.Util; -var addLinkAttributes = displayDOMUtils.addLinkAttributes; -var LinkTarget = displayDOMUtils.LinkTarget; -var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; -var warn = sharedUtil.warn; -var CustomStyle = displayDOMUtils.CustomStyle; -var getDefaultSetting = displayDOMUtils.getDefaultSetting; -function AnnotationElementFactory() {} -AnnotationElementFactory.prototype = { - create: function AnnotationElementFactory_create(parameters) { - var subtype = parameters.data.annotationType; - switch (subtype) { - case AnnotationType.LINK: - return new LinkAnnotationElement(parameters); - case AnnotationType.TEXT: - return new TextAnnotationElement(parameters); - case AnnotationType.WIDGET: - var fieldType = parameters.data.fieldType; - switch (fieldType) { - case 'Tx': - return new TextWidgetAnnotationElement(parameters); - case 'Btn': - if (parameters.data.radioButton) { - return new RadioButtonWidgetAnnotationElement(parameters); - } else if (parameters.data.checkBox) { - return new CheckboxWidgetAnnotationElement(parameters); - } - warn('Unimplemented button widget annotation: pushbutton'); - break; - case 'Ch': - return new ChoiceWidgetAnnotationElement(parameters); - } - return new WidgetAnnotationElement(parameters); - case AnnotationType.POPUP: - return new PopupAnnotationElement(parameters); - case AnnotationType.HIGHLIGHT: - return new HighlightAnnotationElement(parameters); - case AnnotationType.UNDERLINE: - return new UnderlineAnnotationElement(parameters); - case AnnotationType.SQUIGGLY: - return new SquigglyAnnotationElement(parameters); - case AnnotationType.STRIKEOUT: - return new StrikeOutAnnotationElement(parameters); - case AnnotationType.FILEATTACHMENT: - return new FileAttachmentAnnotationElement(parameters); - default: - return new AnnotationElement(parameters); - } - } -}; -var AnnotationElement = function AnnotationElementClosure() { - function AnnotationElement(parameters, isRenderable) { - this.isRenderable = isRenderable || false; - this.data = parameters.data; - this.layer = parameters.layer; - this.page = parameters.page; - this.viewport = parameters.viewport; - this.linkService = parameters.linkService; - this.downloadManager = parameters.downloadManager; - this.imageResourcesPath = parameters.imageResourcesPath; - this.renderInteractiveForms = parameters.renderInteractiveForms; - if (isRenderable) { - this.container = this._createContainer(); - } - } - AnnotationElement.prototype = { - _createContainer: function AnnotationElement_createContainer() { - var data = this.data, - page = this.page, - viewport = this.viewport; - var container = document.createElement('section'); - var width = data.rect[2] - data.rect[0]; - var height = data.rect[3] - data.rect[1]; - container.setAttribute('data-annotation-id', data.id); - var rect = 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]]); - CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')'); - CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px'); - if (data.borderStyle.width > 0) { - container.style.borderWidth = data.borderStyle.width + 'px'; - if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) { - width = width - 2 * data.borderStyle.width; - height = height - 2 * data.borderStyle.width; - } - var horizontalRadius = data.borderStyle.horizontalCornerRadius; - var verticalRadius = data.borderStyle.verticalCornerRadius; - if (horizontalRadius > 0 || verticalRadius > 0) { - var radius = horizontalRadius + 'px / ' + verticalRadius + 'px'; - CustomStyle.setProp('borderRadius', container, radius); - } - switch (data.borderStyle.style) { - case AnnotationBorderStyleType.SOLID: - container.style.borderStyle = 'solid'; - break; - case AnnotationBorderStyleType.DASHED: - container.style.borderStyle = 'dashed'; - break; - case AnnotationBorderStyleType.BEVELED: - warn('Unimplemented border style: beveled'); - break; - case AnnotationBorderStyleType.INSET: - warn('Unimplemented border style: inset'); - break; - case AnnotationBorderStyleType.UNDERLINE: - container.style.borderBottomStyle = 'solid'; - break; - default: - break; - } - if (data.color) { - container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0); - } else { - container.style.borderWidth = 0; - } - } - container.style.left = rect[0] + 'px'; - container.style.top = rect[1] + 'px'; - container.style.width = width + 'px'; - container.style.height = height + 'px'; - return container; - }, - _createPopup: function AnnotationElement_createPopup(container, trigger, data) { - if (!trigger) { - trigger = document.createElement('div'); - trigger.style.height = container.style.height; - trigger.style.width = container.style.width; - container.appendChild(trigger); - } - var popupElement = new PopupElement({ - container: container, - trigger: trigger, - color: data.color, - title: data.title, - contents: data.contents, - hideWrapper: true - }); - var popup = popupElement.render(); - popup.style.left = container.style.width; - container.appendChild(popup); - }, - render: function AnnotationElement_render() { - throw new Error('Abstract method AnnotationElement.render called'); - } - }; - return AnnotationElement; -}(); -var LinkAnnotationElement = function LinkAnnotationElementClosure() { - function LinkAnnotationElement(parameters) { - AnnotationElement.call(this, parameters, true); - } - Util.inherit(LinkAnnotationElement, AnnotationElement, { - render: function LinkAnnotationElement_render() { - this.container.className = 'linkAnnotation'; - var link = document.createElement('a'); - addLinkAttributes(link, { - url: this.data.url, - target: this.data.newWindow ? LinkTarget.BLANK : undefined - }); - if (!this.data.url) { - if (this.data.action) { - this._bindNamedAction(link, this.data.action); - } else { - this._bindLink(link, this.data.dest); - } - } - this.container.appendChild(link); - return this.container; - }, - _bindLink: function LinkAnnotationElement_bindLink(link, destination) { - var self = this; - link.href = this.linkService.getDestinationHash(destination); - link.onclick = function () { - if (destination) { - self.linkService.navigateTo(destination); - } - return false; - }; - if (destination) { - link.className = 'internalLink'; - } - }, - _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) { - var self = this; - link.href = this.linkService.getAnchorUrl(''); - link.onclick = function () { - self.linkService.executeNamedAction(action); - return false; - }; - link.className = 'internalLink'; - } - }); - return LinkAnnotationElement; -}(); -var TextAnnotationElement = function TextAnnotationElementClosure() { - function TextAnnotationElement(parameters) { - var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(TextAnnotationElement, AnnotationElement, { - render: function TextAnnotationElement_render() { - this.container.className = 'textAnnotation'; - var image = document.createElement('img'); - image.style.height = this.container.style.height; - image.style.width = this.container.style.width; - image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg'; - image.alt = '[{{type}} Annotation]'; - image.dataset.l10nId = 'text_annotation_type'; - image.dataset.l10nArgs = JSON.stringify({ type: this.data.name }); - if (!this.data.hasPopup) { - this._createPopup(this.container, image, this.data); - } - this.container.appendChild(image); - return this.container; - } - }); - return TextAnnotationElement; -}(); -var WidgetAnnotationElement = function WidgetAnnotationElementClosure() { - function WidgetAnnotationElement(parameters, isRenderable) { - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(WidgetAnnotationElement, AnnotationElement, { - render: function WidgetAnnotationElement_render() { - return this.container; - } - }); - return WidgetAnnotationElement; -}(); -var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() { - var TEXT_ALIGNMENT = ['left', 'center', 'right']; - function TextWidgetAnnotationElement(parameters) { - var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue; - WidgetAnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, { - render: function TextWidgetAnnotationElement_render() { - this.container.className = 'textWidgetAnnotation'; - var element = null; - if (this.renderInteractiveForms) { - if (this.data.multiLine) { - element = document.createElement('textarea'); - element.textContent = this.data.fieldValue; - } else { - element = document.createElement('input'); - element.type = 'text'; - element.setAttribute('value', this.data.fieldValue); - } - element.disabled = this.data.readOnly; - if (this.data.maxLen !== null) { - element.maxLength = this.data.maxLen; - } - if (this.data.comb) { - var fieldWidth = this.data.rect[2] - this.data.rect[0]; - var combWidth = fieldWidth / this.data.maxLen; - element.classList.add('comb'); - element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)'; - } - } else { - element = document.createElement('div'); - element.textContent = this.data.fieldValue; - element.style.verticalAlign = 'middle'; - element.style.display = 'table-cell'; - var font = null; - if (this.data.fontRefName) { - font = this.page.commonObjs.getData(this.data.fontRefName); - } - this._setTextStyle(element, font); - } - if (this.data.textAlignment !== null) { - element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment]; - } - this.container.appendChild(element); - return this.container; - }, - _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) { - var style = element.style; - style.fontSize = this.data.fontSize + 'px'; - style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr'; - if (!font) { - return; - } - style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal'; - style.fontStyle = font.italic ? 'italic' : 'normal'; - var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : ''; - var fallbackName = font.fallbackName || 'Helvetica, sans-serif'; - style.fontFamily = fontFamily + fallbackName; - } - }); - return TextWidgetAnnotationElement; -}(); -var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() { - function CheckboxWidgetAnnotationElement(parameters) { - WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); - } - Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, { - render: function CheckboxWidgetAnnotationElement_render() { - this.container.className = 'buttonWidgetAnnotation checkBox'; - var element = document.createElement('input'); - element.disabled = this.data.readOnly; - element.type = 'checkbox'; - if (this.data.fieldValue && this.data.fieldValue !== 'Off') { - element.setAttribute('checked', true); - } - this.container.appendChild(element); - return this.container; - } - }); - return CheckboxWidgetAnnotationElement; -}(); -var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() { - function RadioButtonWidgetAnnotationElement(parameters) { - WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); - } - Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, { - render: function RadioButtonWidgetAnnotationElement_render() { - this.container.className = 'buttonWidgetAnnotation radioButton'; - var element = document.createElement('input'); - element.disabled = this.data.readOnly; - element.type = 'radio'; - element.name = this.data.fieldName; - if (this.data.fieldValue === this.data.buttonValue) { - element.setAttribute('checked', true); - } - this.container.appendChild(element); - return this.container; - } - }); - return RadioButtonWidgetAnnotationElement; -}(); -var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() { - function ChoiceWidgetAnnotationElement(parameters) { - WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); - } - Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, { - render: function ChoiceWidgetAnnotationElement_render() { - this.container.className = 'choiceWidgetAnnotation'; - var selectElement = document.createElement('select'); - selectElement.disabled = this.data.readOnly; - if (!this.data.combo) { - selectElement.size = this.data.options.length; - if (this.data.multiSelect) { - selectElement.multiple = true; - } - } - for (var i = 0, ii = this.data.options.length; i < ii; i++) { - var option = this.data.options[i]; - var optionElement = document.createElement('option'); - optionElement.textContent = option.displayValue; - optionElement.value = option.exportValue; - if (this.data.fieldValue.indexOf(option.displayValue) >= 0) { - optionElement.setAttribute('selected', true); - } - selectElement.appendChild(optionElement); - } - this.container.appendChild(selectElement); - return this.container; - } - }); - return ChoiceWidgetAnnotationElement; -}(); -var PopupAnnotationElement = function PopupAnnotationElementClosure() { - function PopupAnnotationElement(parameters) { - var isRenderable = !!(parameters.data.title || parameters.data.contents); - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(PopupAnnotationElement, AnnotationElement, { - render: function PopupAnnotationElement_render() { - this.container.className = 'popupAnnotation'; - var selector = '[data-annotation-id="' + this.data.parentId + '"]'; - var parentElement = this.layer.querySelector(selector); - if (!parentElement) { - return this.container; - } - var popup = new PopupElement({ - container: this.container, - trigger: parentElement, - color: this.data.color, - title: this.data.title, - contents: this.data.contents - }); - var parentLeft = parseFloat(parentElement.style.left); - var parentWidth = parseFloat(parentElement.style.width); - CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top); - this.container.style.left = parentLeft + parentWidth + 'px'; - this.container.appendChild(popup.render()); - return this.container; - } - }); - return PopupAnnotationElement; -}(); -var PopupElement = function PopupElementClosure() { - var BACKGROUND_ENLIGHT = 0.7; - function PopupElement(parameters) { - this.container = parameters.container; - this.trigger = parameters.trigger; - this.color = parameters.color; - this.title = parameters.title; - this.contents = parameters.contents; - this.hideWrapper = parameters.hideWrapper || false; - this.pinned = false; - } - PopupElement.prototype = { - render: function PopupElement_render() { - var wrapper = document.createElement('div'); - wrapper.className = 'popupWrapper'; - this.hideElement = this.hideWrapper ? wrapper : this.container; - this.hideElement.setAttribute('hidden', true); - var popup = document.createElement('div'); - popup.className = 'popup'; - var color = this.color; - if (color) { - var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0]; - var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1]; - var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2]; - popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0); - } - var contents = this._formatContents(this.contents); - var title = document.createElement('h1'); - title.textContent = this.title; - this.trigger.addEventListener('click', this._toggle.bind(this)); - this.trigger.addEventListener('mouseover', this._show.bind(this, false)); - this.trigger.addEventListener('mouseout', this._hide.bind(this, false)); - popup.addEventListener('click', this._hide.bind(this, true)); - popup.appendChild(title); - popup.appendChild(contents); - wrapper.appendChild(popup); - return wrapper; - }, - _formatContents: function PopupElement_formatContents(contents) { - var p = document.createElement('p'); - var lines = contents.split(/(?:\r\n?|\n)/); - for (var i = 0, ii = lines.length; i < ii; ++i) { - var line = lines[i]; - p.appendChild(document.createTextNode(line)); - if (i < ii - 1) { - p.appendChild(document.createElement('br')); - } - } - return p; - }, - _toggle: function PopupElement_toggle() { - if (this.pinned) { - this._hide(true); - } else { - this._show(true); - } - }, - _show: function PopupElement_show(pin) { - if (pin) { - this.pinned = true; - } - if (this.hideElement.hasAttribute('hidden')) { - this.hideElement.removeAttribute('hidden'); - this.container.style.zIndex += 1; - } - }, - _hide: function PopupElement_hide(unpin) { - if (unpin) { - this.pinned = false; - } - if (!this.hideElement.hasAttribute('hidden') && !this.pinned) { - this.hideElement.setAttribute('hidden', true); - this.container.style.zIndex -= 1; - } - } - }; - return PopupElement; -}(); -var HighlightAnnotationElement = function HighlightAnnotationElementClosure() { - function HighlightAnnotationElement(parameters) { - var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(HighlightAnnotationElement, AnnotationElement, { - render: function HighlightAnnotationElement_render() { - this.container.className = 'highlightAnnotation'; - if (!this.data.hasPopup) { - this._createPopup(this.container, null, this.data); - } - return this.container; - } - }); - return HighlightAnnotationElement; -}(); -var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() { - function UnderlineAnnotationElement(parameters) { - var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(UnderlineAnnotationElement, AnnotationElement, { - render: function UnderlineAnnotationElement_render() { - this.container.className = 'underlineAnnotation'; - if (!this.data.hasPopup) { - this._createPopup(this.container, null, this.data); - } - return this.container; - } - }); - return UnderlineAnnotationElement; -}(); -var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() { - function SquigglyAnnotationElement(parameters) { - var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(SquigglyAnnotationElement, AnnotationElement, { - render: function SquigglyAnnotationElement_render() { - this.container.className = 'squigglyAnnotation'; - if (!this.data.hasPopup) { - this._createPopup(this.container, null, this.data); - } - return this.container; - } - }); - return SquigglyAnnotationElement; -}(); -var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() { - function StrikeOutAnnotationElement(parameters) { - var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); - AnnotationElement.call(this, parameters, isRenderable); - } - Util.inherit(StrikeOutAnnotationElement, AnnotationElement, { - render: function StrikeOutAnnotationElement_render() { - this.container.className = 'strikeoutAnnotation'; - if (!this.data.hasPopup) { - this._createPopup(this.container, null, this.data); - } - return this.container; - } - }); - return StrikeOutAnnotationElement; -}(); -var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() { - function FileAttachmentAnnotationElement(parameters) { - AnnotationElement.call(this, parameters, true); - var file = this.data.file; - this.filename = getFilenameFromUrl(file.filename); - this.content = file.content; - this.linkService.onFileAttachmentAnnotation({ - id: stringToPDFString(file.filename), - filename: file.filename, - content: file.content - }); - } - Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, { - render: function FileAttachmentAnnotationElement_render() { - this.container.className = 'fileAttachmentAnnotation'; - var trigger = document.createElement('div'); - trigger.style.height = this.container.style.height; - trigger.style.width = this.container.style.width; - trigger.addEventListener('dblclick', this._download.bind(this)); - if (!this.data.hasPopup && (this.data.title || this.data.contents)) { - this._createPopup(this.container, trigger, this.data); - } - this.container.appendChild(trigger); - return this.container; - }, - _download: function FileAttachmentAnnotationElement_download() { - if (!this.downloadManager) { - warn('Download cannot be started due to unavailable download manager'); - return; - } - this.downloadManager.downloadData(this.content, this.filename, ''); - } - }); - return FileAttachmentAnnotationElement; -}(); -var AnnotationLayer = function AnnotationLayerClosure() { - return { - render: function AnnotationLayer_render(parameters) { - var annotationElementFactory = new AnnotationElementFactory(); - for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { - var data = parameters.annotations[i]; - if (!data) { - continue; - } - var element = annotationElementFactory.create({ - data: data, - layer: parameters.div, - page: parameters.page, - viewport: parameters.viewport, - linkService: parameters.linkService, - downloadManager: parameters.downloadManager, - imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'), - renderInteractiveForms: parameters.renderInteractiveForms || false - }); - if (element.isRenderable) { - parameters.div.appendChild(element.render()); - } - } - }, - update: function AnnotationLayer_update(parameters) { - for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { - var data = parameters.annotations[i]; - var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]'); - if (element) { - CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')'); - } - } - parameters.div.removeAttribute('hidden'); - } - }; -}(); -exports.AnnotationLayer = AnnotationLayer; - -/***/ }), -/* 3 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayFontLoader = __w_pdfjs_require__(11); -var displayCanvas = __w_pdfjs_require__(10); -var displayMetadata = __w_pdfjs_require__(7); -var displayDOMUtils = __w_pdfjs_require__(1); -var amdRequire; -var InvalidPDFException = sharedUtil.InvalidPDFException; -var MessageHandler = sharedUtil.MessageHandler; -var MissingPDFException = sharedUtil.MissingPDFException; -var PageViewport = sharedUtil.PageViewport; -var PasswordException = sharedUtil.PasswordException; -var StatTimer = sharedUtil.StatTimer; -var UnexpectedResponseException = sharedUtil.UnexpectedResponseException; -var UnknownErrorException = sharedUtil.UnknownErrorException; -var Util = sharedUtil.Util; -var createPromiseCapability = sharedUtil.createPromiseCapability; -var error = sharedUtil.error; -var deprecated = sharedUtil.deprecated; -var getVerbosityLevel = sharedUtil.getVerbosityLevel; -var info = sharedUtil.info; -var isInt = sharedUtil.isInt; -var isArray = sharedUtil.isArray; -var isArrayBuffer = sharedUtil.isArrayBuffer; -var isSameOrigin = sharedUtil.isSameOrigin; -var loadJpegStream = sharedUtil.loadJpegStream; -var stringToBytes = sharedUtil.stringToBytes; -var globalScope = sharedUtil.globalScope; -var warn = sharedUtil.warn; -var FontFaceObject = displayFontLoader.FontFaceObject; -var FontLoader = displayFontLoader.FontLoader; -var CanvasGraphics = displayCanvas.CanvasGraphics; -var Metadata = displayMetadata.Metadata; -var RenderingCancelledException = displayDOMUtils.RenderingCancelledException; -var getDefaultSetting = displayDOMUtils.getDefaultSetting; -var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory; -var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory; -var DEFAULT_RANGE_CHUNK_SIZE = 65536; -var isWorkerDisabled = false; -var workerSrc; -var isPostMessageTransfersDisabled = false; -var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; -var fakeWorkerFilesLoader = null; -var useRequireEnsure = false; -if (typeof __pdfjsdev_webpack__ === 'undefined') { - if (typeof window === 'undefined') { - isWorkerDisabled = true; - if (false) { - require.ensure = require('node-ensure'); - } - useRequireEnsure = true; - } else if (true) { - useRequireEnsure = true; - } - if (typeof requirejs !== 'undefined' && requirejs.toUrl) { - workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js'); - } - var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load; - fakeWorkerFilesLoader = useRequireEnsure ? function (callback) { - __webpack_require__.e/* require.ensure */(0).then((function () { - var worker = __webpack_require__(1); - callback(worker.WorkerMessageHandler); - }).bind(null, __webpack_require__)).catch(__webpack_require__.oe); - } : dynamicLoaderSupported ? function (callback) { - requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) { - callback(worker.WorkerMessageHandler); - }); - } : null; -} -function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) { - var task = new PDFDocumentLoadingTask(); - if (arguments.length > 1) { - deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument'); - } - if (pdfDataRangeTransport) { - if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) { - pdfDataRangeTransport = Object.create(pdfDataRangeTransport); - pdfDataRangeTransport.length = src.length; - pdfDataRangeTransport.initialData = src.initialData; - if (!pdfDataRangeTransport.abort) { - pdfDataRangeTransport.abort = function () {}; - } - } - src = Object.create(src); - src.range = pdfDataRangeTransport; - } - task.onPassword = passwordCallback || null; - task.onProgress = progressCallback || null; - var source; - if (typeof src === 'string') { - source = { url: src }; - } else if (isArrayBuffer(src)) { - source = { data: src }; - } else if (src instanceof PDFDataRangeTransport) { - source = { range: src }; - } else { - if (typeof src !== 'object') { - error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object'); - } - if (!src.url && !src.data && !src.range) { - error('Invalid parameter object: need either .data, .range or .url'); - } - source = src; - } - var params = {}; - var rangeTransport = null; - var worker = null; - for (var key in source) { - if (key === 'url' && typeof window !== 'undefined') { - params[key] = new URL(source[key], window.location).href; - continue; - } else if (key === 'range') { - rangeTransport = source[key]; - continue; - } else if (key === 'worker') { - worker = source[key]; - continue; - } else if (key === 'data' && !(source[key] instanceof Uint8Array)) { - var pdfBytes = source[key]; - if (typeof pdfBytes === 'string') { - params[key] = stringToBytes(pdfBytes); - } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) { - params[key] = new Uint8Array(pdfBytes); - } else if (isArrayBuffer(pdfBytes)) { - params[key] = new Uint8Array(pdfBytes); - } else { - error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.'); - } - continue; - } - params[key] = source[key]; - } - params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; - params.disableNativeImageDecoder = params.disableNativeImageDecoder === true; - var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory; - if (!worker) { - var workerPort = getDefaultSetting('workerPort'); - worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker(); - task._worker = worker; - } - var docId = task.docId; - worker.promise.then(function () { - if (task.destroyed) { - throw new Error('Loading aborted'); - } - return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) { - if (task.destroyed) { - throw new Error('Loading aborted'); - } - var messageHandler = new MessageHandler(docId, workerId, worker.port); - var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory); - task._transport = transport; - messageHandler.send('Ready', null); - }); - }).catch(task._capability.reject); - return task; -} -function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { - if (worker.destroyed) { - return Promise.reject(new Error('Worker was destroyed')); - } - source.disableAutoFetch = getDefaultSetting('disableAutoFetch'); - source.disableStream = getDefaultSetting('disableStream'); - source.chunkedViewerLoading = !!pdfDataRangeTransport; - if (pdfDataRangeTransport) { - source.length = pdfDataRangeTransport.length; - source.initialData = pdfDataRangeTransport.initialData; - } - return worker.messageHandler.sendWithPromise('GetDocRequest', { - docId: docId, - source: source, - disableRange: getDefaultSetting('disableRange'), - maxImageSize: getDefaultSetting('maxImageSize'), - disableFontFace: getDefaultSetting('disableFontFace'), - disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'), - postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled, - docBaseUrl: source.docBaseUrl, - disableNativeImageDecoder: source.disableNativeImageDecoder - }).then(function (workerId) { - if (worker.destroyed) { - throw new Error('Worker was destroyed'); - } - return workerId; - }); -} -var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() { - var nextDocumentId = 0; - function PDFDocumentLoadingTask() { - this._capability = createPromiseCapability(); - this._transport = null; - this._worker = null; - this.docId = 'd' + nextDocumentId++; - this.destroyed = false; - this.onPassword = null; - this.onProgress = null; - this.onUnsupportedFeature = null; - } - PDFDocumentLoadingTask.prototype = { - get promise() { - return this._capability.promise; - }, - destroy: function () { - this.destroyed = true; - var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy(); - return transportDestroyed.then(function () { - this._transport = null; - if (this._worker) { - this._worker.destroy(); - this._worker = null; - } - }.bind(this)); - }, - then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) { - return this.promise.then.apply(this.promise, arguments); - } - }; - return PDFDocumentLoadingTask; -}(); -var PDFDataRangeTransport = function pdfDataRangeTransportClosure() { - function PDFDataRangeTransport(length, initialData) { - this.length = length; - this.initialData = initialData; - this._rangeListeners = []; - this._progressListeners = []; - this._progressiveReadListeners = []; - this._readyCapability = createPromiseCapability(); - } - PDFDataRangeTransport.prototype = { - addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) { - this._rangeListeners.push(listener); - }, - addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) { - this._progressListeners.push(listener); - }, - addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) { - this._progressiveReadListeners.push(listener); - }, - onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) { - var listeners = this._rangeListeners; - for (var i = 0, n = listeners.length; i < n; ++i) { - listeners[i](begin, chunk); - } - }, - onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) { - this._readyCapability.promise.then(function () { - var listeners = this._progressListeners; - for (var i = 0, n = listeners.length; i < n; ++i) { - listeners[i](loaded); - } - }.bind(this)); - }, - onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) { - this._readyCapability.promise.then(function () { - var listeners = this._progressiveReadListeners; - for (var i = 0, n = listeners.length; i < n; ++i) { - listeners[i](chunk); - } - }.bind(this)); - }, - transportReady: function PDFDataRangeTransport_transportReady() { - this._readyCapability.resolve(); - }, - requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) { - throw new Error('Abstract method PDFDataRangeTransport.requestDataRange'); - }, - abort: function PDFDataRangeTransport_abort() {} - }; - return PDFDataRangeTransport; -}(); -var PDFDocumentProxy = function PDFDocumentProxyClosure() { - function PDFDocumentProxy(pdfInfo, transport, loadingTask) { - this.pdfInfo = pdfInfo; - this.transport = transport; - this.loadingTask = loadingTask; - } - PDFDocumentProxy.prototype = { - get numPages() { - return this.pdfInfo.numPages; - }, - get fingerprint() { - return this.pdfInfo.fingerprint; - }, - getPage: function PDFDocumentProxy_getPage(pageNumber) { - return this.transport.getPage(pageNumber); - }, - getPageIndex: function PDFDocumentProxy_getPageIndex(ref) { - return this.transport.getPageIndex(ref); - }, - getDestinations: function PDFDocumentProxy_getDestinations() { - return this.transport.getDestinations(); - }, - getDestination: function PDFDocumentProxy_getDestination(id) { - return this.transport.getDestination(id); - }, - getPageLabels: function PDFDocumentProxy_getPageLabels() { - return this.transport.getPageLabels(); - }, - getAttachments: function PDFDocumentProxy_getAttachments() { - return this.transport.getAttachments(); - }, - getJavaScript: function PDFDocumentProxy_getJavaScript() { - return this.transport.getJavaScript(); - }, - getOutline: function PDFDocumentProxy_getOutline() { - return this.transport.getOutline(); - }, - getMetadata: function PDFDocumentProxy_getMetadata() { - return this.transport.getMetadata(); - }, - getData: function PDFDocumentProxy_getData() { - return this.transport.getData(); - }, - getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() { - return this.transport.downloadInfoCapability.promise; - }, - getStats: function PDFDocumentProxy_getStats() { - return this.transport.getStats(); - }, - cleanup: function PDFDocumentProxy_cleanup() { - this.transport.startCleanup(); - }, - destroy: function PDFDocumentProxy_destroy() { - return this.loadingTask.destroy(); - } - }; - return PDFDocumentProxy; -}(); -var PDFPageProxy = function PDFPageProxyClosure() { - function PDFPageProxy(pageIndex, pageInfo, transport) { - this.pageIndex = pageIndex; - this.pageInfo = pageInfo; - this.transport = transport; - this.stats = new StatTimer(); - this.stats.enabled = getDefaultSetting('enableStats'); - this.commonObjs = transport.commonObjs; - this.objs = new PDFObjects(); - this.cleanupAfterRender = false; - this.pendingCleanup = false; - this.intentStates = Object.create(null); - this.destroyed = false; - } - PDFPageProxy.prototype = { - get pageNumber() { - return this.pageIndex + 1; - }, - get rotate() { - return this.pageInfo.rotate; - }, - get ref() { - return this.pageInfo.ref; - }, - get userUnit() { - return this.pageInfo.userUnit; - }, - get view() { - return this.pageInfo.view; - }, - getViewport: function PDFPageProxy_getViewport(scale, rotate) { - if (arguments.length < 2) { - rotate = this.rotate; - } - return new PageViewport(this.view, scale, rotate, 0, 0); - }, - getAnnotations: function PDFPageProxy_getAnnotations(params) { - var intent = params && params.intent || null; - if (!this.annotationsPromise || this.annotationsIntent !== intent) { - this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent); - this.annotationsIntent = intent; - } - return this.annotationsPromise; - }, - render: function PDFPageProxy_render(params) { - var stats = this.stats; - stats.time('Overall'); - this.pendingCleanup = false; - var renderingIntent = params.intent === 'print' ? 'print' : 'display'; - var renderInteractiveForms = params.renderInteractiveForms === true ? true : false; - var canvasFactory = params.canvasFactory || new DOMCanvasFactory(); - if (!this.intentStates[renderingIntent]) { - this.intentStates[renderingIntent] = Object.create(null); - } - var intentState = this.intentStates[renderingIntent]; - if (!intentState.displayReadyCapability) { - intentState.receivingOperatorList = true; - intentState.displayReadyCapability = createPromiseCapability(); - intentState.operatorList = { - fnArray: [], - argsArray: [], - lastChunk: false - }; - this.stats.time('Page Request'); - this.transport.messageHandler.send('RenderPageRequest', { - pageIndex: this.pageNumber - 1, - intent: renderingIntent, - renderInteractiveForms: renderInteractiveForms - }); - } - var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory); - internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print'; - if (!intentState.renderTasks) { - intentState.renderTasks = []; - } - intentState.renderTasks.push(internalRenderTask); - var renderTask = internalRenderTask.task; - if (params.continueCallback) { - deprecated('render is used with continueCallback parameter'); - renderTask.onContinue = params.continueCallback; - } - var self = this; - intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) { - if (self.pendingCleanup) { - complete(); - return; - } - stats.time('Rendering'); - internalRenderTask.initializeGraphics(transparency); - internalRenderTask.operatorListChanged(); - }, function pageDisplayReadPromiseError(reason) { - complete(reason); - }); - function complete(error) { - var i = intentState.renderTasks.indexOf(internalRenderTask); - if (i >= 0) { - intentState.renderTasks.splice(i, 1); - } - if (self.cleanupAfterRender) { - self.pendingCleanup = true; - } - self._tryCleanup(); - if (error) { - internalRenderTask.capability.reject(error); - } else { - internalRenderTask.capability.resolve(); - } - stats.timeEnd('Rendering'); - stats.timeEnd('Overall'); - } - return renderTask; - }, - getOperatorList: function PDFPageProxy_getOperatorList() { - function operatorListChanged() { - if (intentState.operatorList.lastChunk) { - intentState.opListReadCapability.resolve(intentState.operatorList); - var i = intentState.renderTasks.indexOf(opListTask); - if (i >= 0) { - intentState.renderTasks.splice(i, 1); - } - } - } - var renderingIntent = 'oplist'; - if (!this.intentStates[renderingIntent]) { - this.intentStates[renderingIntent] = Object.create(null); - } - var intentState = this.intentStates[renderingIntent]; - var opListTask; - if (!intentState.opListReadCapability) { - opListTask = {}; - opListTask.operatorListChanged = operatorListChanged; - intentState.receivingOperatorList = true; - intentState.opListReadCapability = createPromiseCapability(); - intentState.renderTasks = []; - intentState.renderTasks.push(opListTask); - intentState.operatorList = { - fnArray: [], - argsArray: [], - lastChunk: false - }; - this.transport.messageHandler.send('RenderPageRequest', { - pageIndex: this.pageIndex, - intent: renderingIntent - }); - } - return intentState.opListReadCapability.promise; - }, - getTextContent: function PDFPageProxy_getTextContent(params) { - return this.transport.messageHandler.sendWithPromise('GetTextContent', { - pageIndex: this.pageNumber - 1, - normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false, - combineTextItems: params && params.disableCombineTextItems === true ? false : true - }); - }, - _destroy: function PDFPageProxy_destroy() { - this.destroyed = true; - this.transport.pageCache[this.pageIndex] = null; - var waitOn = []; - Object.keys(this.intentStates).forEach(function (intent) { - if (intent === 'oplist') { - return; - } - var intentState = this.intentStates[intent]; - intentState.renderTasks.forEach(function (renderTask) { - var renderCompleted = renderTask.capability.promise.catch(function () {}); - waitOn.push(renderCompleted); - renderTask.cancel(); - }); - }, this); - this.objs.clear(); - this.annotationsPromise = null; - this.pendingCleanup = false; - return Promise.all(waitOn); - }, - destroy: function () { - deprecated('page destroy method, use cleanup() instead'); - this.cleanup(); - }, - cleanup: function PDFPageProxy_cleanup() { - this.pendingCleanup = true; - this._tryCleanup(); - }, - _tryCleanup: function PDFPageProxy_tryCleanup() { - if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) { - var intentState = this.intentStates[intent]; - return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList; - }, this)) { - return; - } - Object.keys(this.intentStates).forEach(function (intent) { - delete this.intentStates[intent]; - }, this); - this.objs.clear(); - this.annotationsPromise = null; - this.pendingCleanup = false; - }, - _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) { - var intentState = this.intentStates[intent]; - if (intentState.displayReadyCapability) { - intentState.displayReadyCapability.resolve(transparency); - } - }, - _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) { - var intentState = this.intentStates[intent]; - var i, ii; - for (i = 0, ii = operatorListChunk.length; i < ii; i++) { - intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]); - intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]); - } - intentState.operatorList.lastChunk = operatorListChunk.lastChunk; - for (i = 0; i < intentState.renderTasks.length; i++) { - intentState.renderTasks[i].operatorListChanged(); - } - if (operatorListChunk.lastChunk) { - intentState.receivingOperatorList = false; - this._tryCleanup(); - } - } - }; - return PDFPageProxy; -}(); -var PDFWorker = function PDFWorkerClosure() { - var nextFakeWorkerId = 0; - function getWorkerSrc() { - if (typeof workerSrc !== 'undefined') { - return workerSrc; - } - if (getDefaultSetting('workerSrc')) { - return getDefaultSetting('workerSrc'); - } - if (pdfjsFilePath) { - return pdfjsFilePath.replace(/\.js$/i, '.worker.js'); - } - error('No PDFJS.workerSrc specified'); - } - var fakeWorkerFilesLoadedCapability; - function setupFakeWorkerGlobal() { - var WorkerMessageHandler; - if (fakeWorkerFilesLoadedCapability) { - return fakeWorkerFilesLoadedCapability.promise; - } - fakeWorkerFilesLoadedCapability = createPromiseCapability(); - var loader = fakeWorkerFilesLoader || function (callback) { - Util.loadScript(getWorkerSrc(), function () { - callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler); - }); - }; - loader(fakeWorkerFilesLoadedCapability.resolve); - return fakeWorkerFilesLoadedCapability.promise; - } - function FakeWorkerPort(defer) { - this._listeners = []; - this._defer = defer; - this._deferred = Promise.resolve(undefined); - } - FakeWorkerPort.prototype = { - postMessage: function (obj, transfers) { - function cloneValue(value) { - if (typeof value !== 'object' || value === null) { - return value; - } - if (cloned.has(value)) { - return cloned.get(value); - } - var result; - var buffer; - if ((buffer = value.buffer) && isArrayBuffer(buffer)) { - var transferable = transfers && transfers.indexOf(buffer) >= 0; - if (value === buffer) { - result = value; - } else if (transferable) { - result = new value.constructor(buffer, value.byteOffset, value.byteLength); - } else { - result = new value.constructor(value); - } - cloned.set(value, result); - return result; - } - result = isArray(value) ? [] : {}; - cloned.set(value, result); - for (var i in value) { - var desc, - p = value; - while (!(desc = Object.getOwnPropertyDescriptor(p, i))) { - p = Object.getPrototypeOf(p); - } - if (typeof desc.value === 'undefined' || typeof desc.value === 'function') { - continue; - } - result[i] = cloneValue(desc.value); - } - return result; - } - if (!this._defer) { - this._listeners.forEach(function (listener) { - listener.call(this, { data: obj }); - }, this); - return; - } - var cloned = new WeakMap(); - var e = { data: cloneValue(obj) }; - this._deferred.then(function () { - this._listeners.forEach(function (listener) { - listener.call(this, e); - }, this); - }.bind(this)); - }, - addEventListener: function (name, listener) { - this._listeners.push(listener); - }, - removeEventListener: function (name, listener) { - var i = this._listeners.indexOf(listener); - this._listeners.splice(i, 1); - }, - terminate: function () { - this._listeners = []; - } - }; - function createCDNWrapper(url) { - var wrapper = 'importScripts(\'' + url + '\');'; - return URL.createObjectURL(new Blob([wrapper])); - } - function PDFWorker(name, port) { - this.name = name; - this.destroyed = false; - this._readyCapability = createPromiseCapability(); - this._port = null; - this._webWorker = null; - this._messageHandler = null; - if (port) { - this._initializeFromPort(port); - return; - } - this._initialize(); - } - PDFWorker.prototype = { - get promise() { - return this._readyCapability.promise; - }, - get port() { - return this._port; - }, - get messageHandler() { - return this._messageHandler; - }, - _initializeFromPort: function PDFWorker_initializeFromPort(port) { - this._port = port; - this._messageHandler = new MessageHandler('main', 'worker', port); - this._messageHandler.on('ready', function () {}); - this._readyCapability.resolve(); - }, - _initialize: function PDFWorker_initialize() { - if (!isWorkerDisabled && !getDefaultSetting('disableWorker') && typeof Worker !== 'undefined') { - var workerSrc = getWorkerSrc(); - try { - if (!isSameOrigin(window.location.href, workerSrc)) { - workerSrc = createCDNWrapper(new URL(workerSrc, window.location).href); - } - var worker = new Worker(workerSrc); - var messageHandler = new MessageHandler('main', 'worker', worker); - var terminateEarly = function () { - worker.removeEventListener('error', onWorkerError); - messageHandler.destroy(); - worker.terminate(); - if (this.destroyed) { - this._readyCapability.reject(new Error('Worker was destroyed')); - } else { - this._setupFakeWorker(); - } - }.bind(this); - var onWorkerError = function (event) { - if (!this._webWorker) { - terminateEarly(); - } - }.bind(this); - worker.addEventListener('error', onWorkerError); - messageHandler.on('test', function PDFWorker_test(data) { - worker.removeEventListener('error', onWorkerError); - if (this.destroyed) { - terminateEarly(); - return; - } - var supportTypedArray = data && data.supportTypedArray; - if (supportTypedArray) { - this._messageHandler = messageHandler; - this._port = worker; - this._webWorker = worker; - if (!data.supportTransfers) { - isPostMessageTransfersDisabled = true; - } - this._readyCapability.resolve(); - messageHandler.send('configure', { verbosity: getVerbosityLevel() }); - } else { - this._setupFakeWorker(); - messageHandler.destroy(); - worker.terminate(); - } - }.bind(this)); - messageHandler.on('console_log', function (data) { - console.log.apply(console, data); - }); - messageHandler.on('console_error', function (data) { - console.error.apply(console, data); - }); - messageHandler.on('ready', function (data) { - worker.removeEventListener('error', onWorkerError); - if (this.destroyed) { - terminateEarly(); - return; - } - try { - sendTest(); - } catch (e) { - this._setupFakeWorker(); - } - }.bind(this)); - var sendTest = function () { - var postMessageTransfers = getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled; - var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]); - try { - messageHandler.send('test', testObj, [testObj.buffer]); - } catch (ex) { - info('Cannot use postMessage transfers'); - testObj[0] = 0; - messageHandler.send('test', testObj); - } - }; - sendTest(); - return; - } catch (e) { - info('The worker has been disabled.'); - } - } - this._setupFakeWorker(); - }, - _setupFakeWorker: function PDFWorker_setupFakeWorker() { - if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) { - warn('Setting up fake worker.'); - isWorkerDisabled = true; - } - setupFakeWorkerGlobal().then(function (WorkerMessageHandler) { - if (this.destroyed) { - this._readyCapability.reject(new Error('Worker was destroyed')); - return; - } - var isTypedArraysPresent = Uint8Array !== Float32Array; - var port = new FakeWorkerPort(isTypedArraysPresent); - this._port = port; - var id = 'fake' + nextFakeWorkerId++; - var workerHandler = new MessageHandler(id + '_worker', id, port); - WorkerMessageHandler.setup(workerHandler, port); - var messageHandler = new MessageHandler(id, id + '_worker', port); - this._messageHandler = messageHandler; - this._readyCapability.resolve(); - }.bind(this)); - }, - destroy: function PDFWorker_destroy() { - this.destroyed = true; - if (this._webWorker) { - this._webWorker.terminate(); - this._webWorker = null; - } - this._port = null; - if (this._messageHandler) { - this._messageHandler.destroy(); - this._messageHandler = null; - } - } - }; - return PDFWorker; -}(); -var WorkerTransport = function WorkerTransportClosure() { - function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) { - this.messageHandler = messageHandler; - this.loadingTask = loadingTask; - this.pdfDataRangeTransport = pdfDataRangeTransport; - this.commonObjs = new PDFObjects(); - this.fontLoader = new FontLoader(loadingTask.docId); - this.CMapReaderFactory = new CMapReaderFactory({ - baseUrl: getDefaultSetting('cMapUrl'), - isCompressed: getDefaultSetting('cMapPacked') - }); - this.destroyed = false; - this.destroyCapability = null; - this._passwordCapability = null; - this.pageCache = []; - this.pagePromises = []; - this.downloadInfoCapability = createPromiseCapability(); - this.setupMessageHandler(); - } - WorkerTransport.prototype = { - destroy: function WorkerTransport_destroy() { - if (this.destroyCapability) { - return this.destroyCapability.promise; - } - this.destroyed = true; - this.destroyCapability = createPromiseCapability(); - if (this._passwordCapability) { - this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback')); - } - var waitOn = []; - this.pageCache.forEach(function (page) { - if (page) { - waitOn.push(page._destroy()); - } - }); - this.pageCache = []; - this.pagePromises = []; - var self = this; - var terminated = this.messageHandler.sendWithPromise('Terminate', null); - waitOn.push(terminated); - Promise.all(waitOn).then(function () { - self.fontLoader.clear(); - if (self.pdfDataRangeTransport) { - self.pdfDataRangeTransport.abort(); - self.pdfDataRangeTransport = null; - } - if (self.messageHandler) { - self.messageHandler.destroy(); - self.messageHandler = null; - } - self.destroyCapability.resolve(); - }, this.destroyCapability.reject); - return this.destroyCapability.promise; - }, - setupMessageHandler: function WorkerTransport_setupMessageHandler() { - var messageHandler = this.messageHandler; - var loadingTask = this.loadingTask; - var pdfDataRangeTransport = this.pdfDataRangeTransport; - if (pdfDataRangeTransport) { - pdfDataRangeTransport.addRangeListener(function (begin, chunk) { - messageHandler.send('OnDataRange', { - begin: begin, - chunk: chunk - }); - }); - pdfDataRangeTransport.addProgressListener(function (loaded) { - messageHandler.send('OnDataProgress', { loaded: loaded }); - }); - pdfDataRangeTransport.addProgressiveReadListener(function (chunk) { - messageHandler.send('OnDataRange', { chunk: chunk }); - }); - messageHandler.on('RequestDataRange', function transportDataRange(data) { - pdfDataRangeTransport.requestDataRange(data.begin, data.end); - }, this); - } - messageHandler.on('GetDoc', function transportDoc(data) { - var pdfInfo = data.pdfInfo; - this.numPages = data.pdfInfo.numPages; - var loadingTask = this.loadingTask; - var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask); - this.pdfDocument = pdfDocument; - loadingTask._capability.resolve(pdfDocument); - }, this); - messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) { - this._passwordCapability = createPromiseCapability(); - if (loadingTask.onPassword) { - var updatePassword = function (password) { - this._passwordCapability.resolve({ password: password }); - }.bind(this); - loadingTask.onPassword(updatePassword, exception.code); - } else { - this._passwordCapability.reject(new PasswordException(exception.message, exception.code)); - } - return this._passwordCapability.promise; - }, this); - messageHandler.on('PasswordException', function transportPasswordException(exception) { - loadingTask._capability.reject(new PasswordException(exception.message, exception.code)); - }, this); - messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) { - this.loadingTask._capability.reject(new InvalidPDFException(exception.message)); - }, this); - messageHandler.on('MissingPDF', function transportMissingPDF(exception) { - this.loadingTask._capability.reject(new MissingPDFException(exception.message)); - }, this); - messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) { - this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status)); - }, this); - messageHandler.on('UnknownError', function transportUnknownError(exception) { - this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details)); - }, this); - messageHandler.on('DataLoaded', function transportPage(data) { - this.downloadInfoCapability.resolve(data); - }, this); - messageHandler.on('PDFManagerReady', function transportPage(data) { - if (this.pdfDataRangeTransport) { - this.pdfDataRangeTransport.transportReady(); - } - }, this); - messageHandler.on('StartRenderPage', function transportRender(data) { - if (this.destroyed) { - return; - } - var page = this.pageCache[data.pageIndex]; - page.stats.timeEnd('Page Request'); - page._startRenderPage(data.transparency, data.intent); - }, this); - messageHandler.on('RenderPageChunk', function transportRender(data) { - if (this.destroyed) { - return; - } - var page = this.pageCache[data.pageIndex]; - page._renderPageChunk(data.operatorList, data.intent); - }, this); - messageHandler.on('commonobj', function transportObj(data) { - if (this.destroyed) { - return; - } - var id = data[0]; - var type = data[1]; - if (this.commonObjs.hasData(id)) { - return; - } - switch (type) { - case 'Font': - var exportedData = data[2]; - if ('error' in exportedData) { - var exportedError = exportedData.error; - warn('Error during font loading: ' + exportedError); - this.commonObjs.resolve(id, exportedError); - break; - } - var fontRegistry = null; - if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) { - fontRegistry = { - registerFont: function (font, url) { - globalScope['FontInspector'].fontAdded(font, url); - } - }; - } - var font = new FontFaceObject(exportedData, { - isEvalSuported: getDefaultSetting('isEvalSupported'), - disableFontFace: getDefaultSetting('disableFontFace'), - fontRegistry: fontRegistry - }); - this.fontLoader.bind([font], function fontReady(fontObjs) { - this.commonObjs.resolve(id, font); - }.bind(this)); - break; - case 'FontPath': - this.commonObjs.resolve(id, data[2]); - break; - default: - error('Got unknown common object type ' + type); - } - }, this); - messageHandler.on('obj', function transportObj(data) { - if (this.destroyed) { - return; - } - var id = data[0]; - var pageIndex = data[1]; - var type = data[2]; - var pageProxy = this.pageCache[pageIndex]; - var imageData; - if (pageProxy.objs.hasData(id)) { - return; - } - switch (type) { - case 'JpegStream': - imageData = data[3]; - loadJpegStream(id, imageData, pageProxy.objs); - break; - case 'Image': - imageData = data[3]; - pageProxy.objs.resolve(id, imageData); - var MAX_IMAGE_SIZE_TO_STORE = 8000000; - if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) { - pageProxy.cleanupAfterRender = true; - } - break; - default: - error('Got unknown object type ' + type); - } - }, this); - messageHandler.on('DocProgress', function transportDocProgress(data) { - if (this.destroyed) { - return; - } - var loadingTask = this.loadingTask; - if (loadingTask.onProgress) { - loadingTask.onProgress({ - loaded: data.loaded, - total: data.total - }); - } - }, this); - messageHandler.on('PageError', function transportError(data) { - if (this.destroyed) { - return; - } - var page = this.pageCache[data.pageNum - 1]; - var intentState = page.intentStates[data.intent]; - if (intentState.displayReadyCapability) { - intentState.displayReadyCapability.reject(data.error); - } else { - error(data.error); - } - if (intentState.operatorList) { - intentState.operatorList.lastChunk = true; - for (var i = 0; i < intentState.renderTasks.length; i++) { - intentState.renderTasks[i].operatorListChanged(); - } - } - }, this); - messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) { - if (this.destroyed) { - return; - } - var featureId = data.featureId; - var loadingTask = this.loadingTask; - if (loadingTask.onUnsupportedFeature) { - loadingTask.onUnsupportedFeature(featureId); - } - _UnsupportedManager.notify(featureId); - }, this); - messageHandler.on('JpegDecode', function (data) { - if (this.destroyed) { - return Promise.reject(new Error('Worker was destroyed')); - } - if (typeof document === 'undefined') { - return Promise.reject(new Error('"document" is not defined.')); - } - var imageUrl = data[0]; - var components = data[1]; - if (components !== 3 && components !== 1) { - return Promise.reject(new Error('Only 3 components or 1 component can be returned')); - } - return new Promise(function (resolve, reject) { - var img = new Image(); - img.onload = function () { - var width = img.width; - var height = img.height; - var size = width * height; - var rgbaLength = size * 4; - var buf = new Uint8Array(size * components); - var tmpCanvas = document.createElement('canvas'); - tmpCanvas.width = width; - tmpCanvas.height = height; - var tmpCtx = tmpCanvas.getContext('2d'); - tmpCtx.drawImage(img, 0, 0); - var data = tmpCtx.getImageData(0, 0, width, height).data; - var i, j; - if (components === 3) { - for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) { - buf[j] = data[i]; - buf[j + 1] = data[i + 1]; - buf[j + 2] = data[i + 2]; - } - } else if (components === 1) { - for (i = 0, j = 0; i < rgbaLength; i += 4, j++) { - buf[j] = data[i]; - } - } - resolve({ - data: buf, - width: width, - height: height - }); - }; - img.onerror = function () { - reject(new Error('JpegDecode failed to load image')); - }; - img.src = imageUrl; - }); - }, this); - messageHandler.on('FetchBuiltInCMap', function (data) { - if (this.destroyed) { - return Promise.reject(new Error('Worker was destroyed')); - } - return this.CMapReaderFactory.fetch({ name: data.name }); - }, this); - }, - getData: function WorkerTransport_getData() { - return this.messageHandler.sendWithPromise('GetData', null); - }, - getPage: function WorkerTransport_getPage(pageNumber, capability) { - if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) { - return Promise.reject(new Error('Invalid page request')); - } - var pageIndex = pageNumber - 1; - if (pageIndex in this.pagePromises) { - return this.pagePromises[pageIndex]; - } - var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) { - if (this.destroyed) { - throw new Error('Transport destroyed'); - } - var page = new PDFPageProxy(pageIndex, pageInfo, this); - this.pageCache[pageIndex] = page; - return page; - }.bind(this)); - this.pagePromises[pageIndex] = promise; - return promise; - }, - getPageIndex: function WorkerTransport_getPageIndexByRef(ref) { - return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) { - return Promise.reject(new Error(reason)); - }); - }, - getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) { - return this.messageHandler.sendWithPromise('GetAnnotations', { - pageIndex: pageIndex, - intent: intent - }); - }, - getDestinations: function WorkerTransport_getDestinations() { - return this.messageHandler.sendWithPromise('GetDestinations', null); - }, - getDestination: function WorkerTransport_getDestination(id) { - return this.messageHandler.sendWithPromise('GetDestination', { id: id }); - }, - getPageLabels: function WorkerTransport_getPageLabels() { - return this.messageHandler.sendWithPromise('GetPageLabels', null); - }, - getAttachments: function WorkerTransport_getAttachments() { - return this.messageHandler.sendWithPromise('GetAttachments', null); - }, - getJavaScript: function WorkerTransport_getJavaScript() { - return this.messageHandler.sendWithPromise('GetJavaScript', null); - }, - getOutline: function WorkerTransport_getOutline() { - return this.messageHandler.sendWithPromise('GetOutline', null); - }, - getMetadata: function WorkerTransport_getMetadata() { - return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) { - return { - info: results[0], - metadata: results[1] ? new Metadata(results[1]) : null - }; - }); - }, - getStats: function WorkerTransport_getStats() { - return this.messageHandler.sendWithPromise('GetStats', null); - }, - startCleanup: function WorkerTransport_startCleanup() { - this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() { - for (var i = 0, ii = this.pageCache.length; i < ii; i++) { - var page = this.pageCache[i]; - if (page) { - page.cleanup(); - } - } - this.commonObjs.clear(); - this.fontLoader.clear(); - }.bind(this)); - } - }; - return WorkerTransport; -}(); -var PDFObjects = function PDFObjectsClosure() { - function PDFObjects() { - this.objs = Object.create(null); - } - PDFObjects.prototype = { - ensureObj: function PDFObjects_ensureObj(objId) { - if (this.objs[objId]) { - return this.objs[objId]; - } - var obj = { - capability: createPromiseCapability(), - data: null, - resolved: false - }; - this.objs[objId] = obj; - return obj; - }, - get: function PDFObjects_get(objId, callback) { - if (callback) { - this.ensureObj(objId).capability.promise.then(callback); - return null; - } - var obj = this.objs[objId]; - if (!obj || !obj.resolved) { - error('Requesting object that isn\'t resolved yet ' + objId); - } - return obj.data; - }, - resolve: function PDFObjects_resolve(objId, data) { - var obj = this.ensureObj(objId); - obj.resolved = true; - obj.data = data; - obj.capability.resolve(data); - }, - isResolved: function PDFObjects_isResolved(objId) { - var objs = this.objs; - if (!objs[objId]) { - return false; - } - return objs[objId].resolved; - }, - hasData: function PDFObjects_hasData(objId) { - return this.isResolved(objId); - }, - getData: function PDFObjects_getData(objId) { - var objs = this.objs; - if (!objs[objId] || !objs[objId].resolved) { - return null; - } - return objs[objId].data; - }, - clear: function PDFObjects_clear() { - this.objs = Object.create(null); - } - }; - return PDFObjects; -}(); -var RenderTask = function RenderTaskClosure() { - function RenderTask(internalRenderTask) { - this._internalRenderTask = internalRenderTask; - this.onContinue = null; - } - RenderTask.prototype = { - get promise() { - return this._internalRenderTask.capability.promise; - }, - cancel: function RenderTask_cancel() { - this._internalRenderTask.cancel(); - }, - then: function RenderTask_then(onFulfilled, onRejected) { - return this.promise.then.apply(this.promise, arguments); - } - }; - return RenderTask; -}(); -var InternalRenderTask = function InternalRenderTaskClosure() { - function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) { - this.callback = callback; - this.params = params; - this.objs = objs; - this.commonObjs = commonObjs; - this.operatorListIdx = null; - this.operatorList = operatorList; - this.pageNumber = pageNumber; - this.canvasFactory = canvasFactory; - this.running = false; - this.graphicsReadyCallback = null; - this.graphicsReady = false; - this.useRequestAnimationFrame = false; - this.cancelled = false; - this.capability = createPromiseCapability(); - this.task = new RenderTask(this); - this._continueBound = this._continue.bind(this); - this._scheduleNextBound = this._scheduleNext.bind(this); - this._nextBound = this._next.bind(this); - } - InternalRenderTask.prototype = { - initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) { - if (this.cancelled) { - return; - } - if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) { - this.stepper = globalScope.StepperManager.create(this.pageNumber - 1); - this.stepper.init(this.operatorList); - this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint(); - } - var params = this.params; - this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer); - this.gfx.beginDrawing(params.transform, params.viewport, transparency); - this.operatorListIdx = 0; - this.graphicsReady = true; - if (this.graphicsReadyCallback) { - this.graphicsReadyCallback(); - } - }, - cancel: function InternalRenderTask_cancel() { - this.running = false; - this.cancelled = true; - if (getDefaultSetting('pdfjsNext')) { - this.callback(new RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas')); - } else { - this.callback('cancelled'); - } - }, - operatorListChanged: function InternalRenderTask_operatorListChanged() { - if (!this.graphicsReady) { - if (!this.graphicsReadyCallback) { - this.graphicsReadyCallback = this._continueBound; - } - return; - } - if (this.stepper) { - this.stepper.updateOperatorList(this.operatorList); - } - if (this.running) { - return; - } - this._continue(); - }, - _continue: function InternalRenderTask__continue() { - this.running = true; - if (this.cancelled) { - return; - } - if (this.task.onContinue) { - this.task.onContinue(this._scheduleNextBound); - } else { - this._scheduleNext(); - } - }, - _scheduleNext: function InternalRenderTask__scheduleNext() { - if (this.useRequestAnimationFrame && typeof window !== 'undefined') { - window.requestAnimationFrame(this._nextBound); - } else { - Promise.resolve(undefined).then(this._nextBound); - } - }, - _next: function InternalRenderTask__next() { - if (this.cancelled) { - return; - } - this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper); - if (this.operatorListIdx === this.operatorList.argsArray.length) { - this.running = false; - if (this.operatorList.lastChunk) { - this.gfx.endDrawing(); - this.callback(); - } - } - } - }; - return InternalRenderTask; -}(); -var _UnsupportedManager = function UnsupportedManagerClosure() { - var listeners = []; - return { - listen: function (cb) { - deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead'); - listeners.push(cb); - }, - notify: function (featureId) { - for (var i = 0, ii = listeners.length; i < ii; i++) { - listeners[i](featureId); - } - } - }; -}(); -exports.version = '1.8.172'; -exports.build = '8ff1fbe7'; -exports.getDocument = getDocument; -exports.PDFDataRangeTransport = PDFDataRangeTransport; -exports.PDFWorker = PDFWorker; -exports.PDFDocumentProxy = PDFDocumentProxy; -exports.PDFPageProxy = PDFPageProxy; -exports._UnsupportedManager = _UnsupportedManager; - -/***/ }), -/* 4 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; -var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX; -var ImageKind = sharedUtil.ImageKind; -var OPS = sharedUtil.OPS; -var Util = sharedUtil.Util; -var isNum = sharedUtil.isNum; -var isArray = sharedUtil.isArray; -var warn = sharedUtil.warn; -var createObjectURL = sharedUtil.createObjectURL; -var SVG_DEFAULTS = { - fontStyle: 'normal', - fontWeight: 'normal', - fillColor: '#000000' -}; -var convertImgDataToPng = function convertImgDataToPngClosure() { - var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); - var CHUNK_WRAPPER_SIZE = 12; - var crcTable = new Int32Array(256); - for (var i = 0; i < 256; i++) { - var c = i; - for (var h = 0; h < 8; h++) { - if (c & 1) { - c = 0xedB88320 ^ c >> 1 & 0x7fffffff; - } else { - c = c >> 1 & 0x7fffffff; - } - } - crcTable[i] = c; - } - function crc32(data, start, end) { - var crc = -1; - for (var i = start; i < end; i++) { - var a = (crc ^ data[i]) & 0xff; - var b = crcTable[a]; - crc = crc >>> 8 ^ b; - } - return crc ^ -1; - } - function writePngChunk(type, body, data, offset) { - var p = offset; - var len = body.length; - data[p] = len >> 24 & 0xff; - data[p + 1] = len >> 16 & 0xff; - data[p + 2] = len >> 8 & 0xff; - data[p + 3] = len & 0xff; - p += 4; - data[p] = type.charCodeAt(0) & 0xff; - data[p + 1] = type.charCodeAt(1) & 0xff; - data[p + 2] = type.charCodeAt(2) & 0xff; - data[p + 3] = type.charCodeAt(3) & 0xff; - p += 4; - data.set(body, p); - p += body.length; - var crc = crc32(data, offset + 4, p); - data[p] = crc >> 24 & 0xff; - data[p + 1] = crc >> 16 & 0xff; - data[p + 2] = crc >> 8 & 0xff; - data[p + 3] = crc & 0xff; - } - function adler32(data, start, end) { - var a = 1; - var b = 0; - for (var i = start; i < end; ++i) { - a = (a + (data[i] & 0xff)) % 65521; - b = (b + a) % 65521; - } - return b << 16 | a; - } - function encode(imgData, kind, forceDataSchema) { - var width = imgData.width; - var height = imgData.height; - var bitDepth, colorType, lineSize; - var bytes = imgData.data; - switch (kind) { - case ImageKind.GRAYSCALE_1BPP: - colorType = 0; - bitDepth = 1; - lineSize = width + 7 >> 3; - break; - case ImageKind.RGB_24BPP: - colorType = 2; - bitDepth = 8; - lineSize = width * 3; - break; - case ImageKind.RGBA_32BPP: - colorType = 6; - bitDepth = 8; - lineSize = width * 4; - break; - default: - throw new Error('invalid format'); - } - var literals = new Uint8Array((1 + lineSize) * height); - var offsetLiterals = 0, - offsetBytes = 0; - var y, i; - for (y = 0; y < height; ++y) { - literals[offsetLiterals++] = 0; - literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals); - offsetBytes += lineSize; - offsetLiterals += lineSize; - } - if (kind === ImageKind.GRAYSCALE_1BPP) { - offsetLiterals = 0; - for (y = 0; y < height; y++) { - offsetLiterals++; - for (i = 0; i < lineSize; i++) { - literals[offsetLiterals++] ^= 0xFF; - } - } - } - 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]); - var len = literals.length; - var maxBlockLength = 0xFFFF; - var deflateBlocks = Math.ceil(len / maxBlockLength); - var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4); - var pi = 0; - idat[pi++] = 0x78; - idat[pi++] = 0x9c; - var pos = 0; - while (len > maxBlockLength) { - idat[pi++] = 0x00; - idat[pi++] = 0xff; - idat[pi++] = 0xff; - idat[pi++] = 0x00; - idat[pi++] = 0x00; - idat.set(literals.subarray(pos, pos + maxBlockLength), pi); - pi += maxBlockLength; - pos += maxBlockLength; - len -= maxBlockLength; - } - idat[pi++] = 0x01; - idat[pi++] = len & 0xff; - idat[pi++] = len >> 8 & 0xff; - idat[pi++] = ~len & 0xffff & 0xff; - idat[pi++] = (~len & 0xffff) >> 8 & 0xff; - idat.set(literals.subarray(pos), pi); - pi += literals.length - pos; - var adler = adler32(literals, 0, literals.length); - idat[pi++] = adler >> 24 & 0xff; - idat[pi++] = adler >> 16 & 0xff; - idat[pi++] = adler >> 8 & 0xff; - idat[pi++] = adler & 0xff; - var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; - var data = new Uint8Array(pngLength); - var offset = 0; - data.set(PNG_HEADER, offset); - offset += PNG_HEADER.length; - writePngChunk('IHDR', ihdr, data, offset); - offset += CHUNK_WRAPPER_SIZE + ihdr.length; - writePngChunk('IDATA', idat, data, offset); - offset += CHUNK_WRAPPER_SIZE + idat.length; - writePngChunk('IEND', new Uint8Array(0), data, offset); - return createObjectURL(data, 'image/png', forceDataSchema); - } - return function convertImgDataToPng(imgData, forceDataSchema) { - var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind; - return encode(imgData, kind, forceDataSchema); - }; -}(); -var SVGExtraState = function SVGExtraStateClosure() { - function SVGExtraState() { - this.fontSizeScale = 1; - this.fontWeight = SVG_DEFAULTS.fontWeight; - this.fontSize = 0; - this.textMatrix = IDENTITY_MATRIX; - this.fontMatrix = FONT_IDENTITY_MATRIX; - this.leading = 0; - this.x = 0; - this.y = 0; - this.lineX = 0; - this.lineY = 0; - this.charSpacing = 0; - this.wordSpacing = 0; - this.textHScale = 1; - this.textRise = 0; - this.fillColor = SVG_DEFAULTS.fillColor; - this.strokeColor = '#000000'; - this.fillAlpha = 1; - this.strokeAlpha = 1; - this.lineWidth = 1; - this.lineJoin = ''; - this.lineCap = ''; - this.miterLimit = 0; - this.dashArray = []; - this.dashPhase = 0; - this.dependencies = []; - this.activeClipUrl = null; - this.clipGroup = null; - this.maskId = ''; - } - SVGExtraState.prototype = { - clone: function SVGExtraState_clone() { - return Object.create(this); - }, - setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) { - this.x = x; - this.y = y; - } - }; - return SVGExtraState; -}(); -var SVGGraphics = function SVGGraphicsClosure() { - function opListToTree(opList) { - var opTree = []; - var tmp = []; - var opListLen = opList.length; - for (var x = 0; x < opListLen; x++) { - if (opList[x].fn === 'save') { - opTree.push({ - 'fnId': 92, - 'fn': 'group', - 'items': [] - }); - tmp.push(opTree); - opTree = opTree[opTree.length - 1].items; - continue; - } - if (opList[x].fn === 'restore') { - opTree = tmp.pop(); - } else { - opTree.push(opList[x]); - } - } - return opTree; - } - function pf(value) { - if (value === (value | 0)) { - return value.toString(); - } - var s = value.toFixed(10); - var i = s.length - 1; - if (s[i] !== '0') { - return s; - } - do { - i--; - } while (s[i] === '0'); - return s.substr(0, s[i] === '.' ? i : i + 1); - } - function pm(m) { - if (m[4] === 0 && m[5] === 0) { - if (m[1] === 0 && m[2] === 0) { - if (m[0] === 1 && m[3] === 1) { - return ''; - } - return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')'; - } - if (m[0] === m[3] && m[1] === -m[2]) { - var a = Math.acos(m[0]) * 180 / Math.PI; - return 'rotate(' + pf(a) + ')'; - } - } else { - if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) { - return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')'; - } - } - return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')'; - } - function SVGGraphics(commonObjs, objs, forceDataSchema) { - this.current = new SVGExtraState(); - this.transformMatrix = IDENTITY_MATRIX; - this.transformStack = []; - this.extraStack = []; - this.commonObjs = commonObjs; - this.objs = objs; - this.pendingEOFill = false; - this.embedFonts = false; - this.embeddedFonts = Object.create(null); - this.cssStyle = null; - this.forceDataSchema = !!forceDataSchema; - } - var NS = 'http://www.w3.org/2000/svg'; - var XML_NS = 'http://www.w3.org/XML/1998/namespace'; - var XLINK_NS = 'http://www.w3.org/1999/xlink'; - var LINE_CAP_STYLES = ['butt', 'round', 'square']; - var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; - var clipCount = 0; - var maskCount = 0; - SVGGraphics.prototype = { - save: function SVGGraphics_save() { - this.transformStack.push(this.transformMatrix); - var old = this.current; - this.extraStack.push(old); - this.current = old.clone(); - }, - restore: function SVGGraphics_restore() { - this.transformMatrix = this.transformStack.pop(); - this.current = this.extraStack.pop(); - this.tgrp = null; - }, - group: function SVGGraphics_group(items) { - this.save(); - this.executeOpTree(items); - this.restore(); - }, - loadDependencies: function SVGGraphics_loadDependencies(operatorList) { - var fnArray = operatorList.fnArray; - var fnArrayLen = fnArray.length; - var argsArray = operatorList.argsArray; - var self = this; - for (var i = 0; i < fnArrayLen; i++) { - if (OPS.dependency === fnArray[i]) { - var deps = argsArray[i]; - for (var n = 0, nn = deps.length; n < nn; n++) { - var obj = deps[n]; - var common = obj.substring(0, 2) === 'g_'; - var promise; - if (common) { - promise = new Promise(function (resolve) { - self.commonObjs.get(obj, resolve); - }); - } else { - promise = new Promise(function (resolve) { - self.objs.get(obj, resolve); - }); - } - this.current.dependencies.push(promise); - } - } - } - return Promise.all(this.current.dependencies); - }, - transform: function SVGGraphics_transform(a, b, c, d, e, f) { - var transformMatrix = [a, b, c, d, e, f]; - this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix); - this.tgrp = null; - }, - getSVG: function SVGGraphics_getSVG(operatorList, viewport) { - this.viewport = viewport; - var svgElement = this._initialize(viewport); - return this.loadDependencies(operatorList).then(function () { - this.transformMatrix = IDENTITY_MATRIX; - var opTree = this.convertOpList(operatorList); - this.executeOpTree(opTree); - return svgElement; - }.bind(this)); - }, - convertOpList: function SVGGraphics_convertOpList(operatorList) { - var argsArray = operatorList.argsArray; - var fnArray = operatorList.fnArray; - var fnArrayLen = fnArray.length; - var REVOPS = []; - var opList = []; - for (var op in OPS) { - REVOPS[OPS[op]] = op; - } - for (var x = 0; x < fnArrayLen; x++) { - var fnId = fnArray[x]; - opList.push({ - 'fnId': fnId, - 'fn': REVOPS[fnId], - 'args': argsArray[x] - }); - } - return opListToTree(opList); - }, - executeOpTree: function SVGGraphics_executeOpTree(opTree) { - var opTreeLen = opTree.length; - for (var x = 0; x < opTreeLen; x++) { - var fn = opTree[x].fn; - var fnId = opTree[x].fnId; - var args = opTree[x].args; - switch (fnId | 0) { - case OPS.beginText: - this.beginText(); - break; - case OPS.setLeading: - this.setLeading(args); - break; - case OPS.setLeadingMoveText: - this.setLeadingMoveText(args[0], args[1]); - break; - case OPS.setFont: - this.setFont(args); - break; - case OPS.showText: - this.showText(args[0]); - break; - case OPS.showSpacedText: - this.showText(args[0]); - break; - case OPS.endText: - this.endText(); - break; - case OPS.moveText: - this.moveText(args[0], args[1]); - break; - case OPS.setCharSpacing: - this.setCharSpacing(args[0]); - break; - case OPS.setWordSpacing: - this.setWordSpacing(args[0]); - break; - case OPS.setHScale: - this.setHScale(args[0]); - break; - case OPS.setTextMatrix: - this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); - break; - case OPS.setLineWidth: - this.setLineWidth(args[0]); - break; - case OPS.setLineJoin: - this.setLineJoin(args[0]); - break; - case OPS.setLineCap: - this.setLineCap(args[0]); - break; - case OPS.setMiterLimit: - this.setMiterLimit(args[0]); - break; - case OPS.setFillRGBColor: - this.setFillRGBColor(args[0], args[1], args[2]); - break; - case OPS.setStrokeRGBColor: - this.setStrokeRGBColor(args[0], args[1], args[2]); - break; - case OPS.setDash: - this.setDash(args[0], args[1]); - break; - case OPS.setGState: - this.setGState(args[0]); - break; - case OPS.fill: - this.fill(); - break; - case OPS.eoFill: - this.eoFill(); - break; - case OPS.stroke: - this.stroke(); - break; - case OPS.fillStroke: - this.fillStroke(); - break; - case OPS.eoFillStroke: - this.eoFillStroke(); - break; - case OPS.clip: - this.clip('nonzero'); - break; - case OPS.eoClip: - this.clip('evenodd'); - break; - case OPS.paintSolidColorImageMask: - this.paintSolidColorImageMask(); - break; - case OPS.paintJpegXObject: - this.paintJpegXObject(args[0], args[1], args[2]); - break; - case OPS.paintImageXObject: - this.paintImageXObject(args[0]); - break; - case OPS.paintInlineImageXObject: - this.paintInlineImageXObject(args[0]); - break; - case OPS.paintImageMaskXObject: - this.paintImageMaskXObject(args[0]); - break; - case OPS.paintFormXObjectBegin: - this.paintFormXObjectBegin(args[0], args[1]); - break; - case OPS.paintFormXObjectEnd: - this.paintFormXObjectEnd(); - break; - case OPS.closePath: - this.closePath(); - break; - case OPS.closeStroke: - this.closeStroke(); - break; - case OPS.closeFillStroke: - this.closeFillStroke(); - break; - case OPS.nextLine: - this.nextLine(); - break; - case OPS.transform: - this.transform(args[0], args[1], args[2], args[3], args[4], args[5]); - break; - case OPS.constructPath: - this.constructPath(args[0], args[1]); - break; - case OPS.endPath: - this.endPath(); - break; - case 92: - this.group(opTree[x].items); - break; - default: - warn('Unimplemented operator ' + fn); - break; - } - } - }, - setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) { - this.current.wordSpacing = wordSpacing; - }, - setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) { - this.current.charSpacing = charSpacing; - }, - nextLine: function SVGGraphics_nextLine() { - this.moveText(0, this.current.leading); - }, - setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) { - var current = this.current; - this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f]; - this.current.x = this.current.lineX = 0; - this.current.y = this.current.lineY = 0; - current.xcoords = []; - current.tspan = document.createElementNS(NS, 'svg:tspan'); - current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); - current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); - current.tspan.setAttributeNS(null, 'y', pf(-current.y)); - current.txtElement = document.createElementNS(NS, 'svg:text'); - current.txtElement.appendChild(current.tspan); - }, - beginText: function SVGGraphics_beginText() { - this.current.x = this.current.lineX = 0; - this.current.y = this.current.lineY = 0; - this.current.textMatrix = IDENTITY_MATRIX; - this.current.lineMatrix = IDENTITY_MATRIX; - this.current.tspan = document.createElementNS(NS, 'svg:tspan'); - this.current.txtElement = document.createElementNS(NS, 'svg:text'); - this.current.txtgrp = document.createElementNS(NS, 'svg:g'); - this.current.xcoords = []; - }, - moveText: function SVGGraphics_moveText(x, y) { - var current = this.current; - this.current.x = this.current.lineX += x; - this.current.y = this.current.lineY += y; - current.xcoords = []; - current.tspan = document.createElementNS(NS, 'svg:tspan'); - current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); - current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); - current.tspan.setAttributeNS(null, 'y', pf(-current.y)); - }, - showText: function SVGGraphics_showText(glyphs) { - var current = this.current; - var font = current.font; - var fontSize = current.fontSize; - if (fontSize === 0) { - return; - } - var charSpacing = current.charSpacing; - var wordSpacing = current.wordSpacing; - var fontDirection = current.fontDirection; - var textHScale = current.textHScale * fontDirection; - var glyphsLength = glyphs.length; - var vertical = font.vertical; - var widthAdvanceScale = fontSize * current.fontMatrix[0]; - var x = 0, - i; - for (i = 0; i < glyphsLength; ++i) { - var glyph = glyphs[i]; - if (glyph === null) { - x += fontDirection * wordSpacing; - continue; - } else if (isNum(glyph)) { - x += -glyph * fontSize * 0.001; - continue; - } - current.xcoords.push(current.x + x * textHScale); - var width = glyph.width; - var character = glyph.fontChar; - var charWidth = width * widthAdvanceScale + charSpacing * fontDirection; - x += charWidth; - current.tspan.textContent += character; - } - if (vertical) { - current.y -= x * textHScale; - } else { - current.x += x * textHScale; - } - current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' ')); - current.tspan.setAttributeNS(null, 'y', pf(-current.y)); - current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); - current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); - if (current.fontStyle !== SVG_DEFAULTS.fontStyle) { - current.tspan.setAttributeNS(null, 'font-style', current.fontStyle); - } - if (current.fontWeight !== SVG_DEFAULTS.fontWeight) { - current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight); - } - if (current.fillColor !== SVG_DEFAULTS.fillColor) { - current.tspan.setAttributeNS(null, 'fill', current.fillColor); - } - current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)'); - current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve'); - current.txtElement.appendChild(current.tspan); - current.txtgrp.appendChild(current.txtElement); - this._ensureTransformGroup().appendChild(current.txtElement); - }, - setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) { - this.setLeading(-y); - this.moveText(x, y); - }, - addFontStyle: function SVGGraphics_addFontStyle(fontObj) { - if (!this.cssStyle) { - this.cssStyle = document.createElementNS(NS, 'svg:style'); - this.cssStyle.setAttributeNS(null, 'type', 'text/css'); - this.defs.appendChild(this.cssStyle); - } - var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema); - this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n'; - }, - setFont: function SVGGraphics_setFont(details) { - var current = this.current; - var fontObj = this.commonObjs.get(details[0]); - var size = details[1]; - this.current.font = fontObj; - if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) { - this.addFontStyle(fontObj); - this.embeddedFonts[fontObj.loadedName] = fontObj; - } - current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX; - var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal'; - var italic = fontObj.italic ? 'italic' : 'normal'; - if (size < 0) { - size = -size; - current.fontDirection = -1; - } else { - current.fontDirection = 1; - } - current.fontSize = size; - current.fontFamily = fontObj.loadedName; - current.fontWeight = bold; - current.fontStyle = italic; - current.tspan = document.createElementNS(NS, 'svg:tspan'); - current.tspan.setAttributeNS(null, 'y', pf(-current.y)); - current.xcoords = []; - }, - endText: function SVGGraphics_endText() {}, - setLineWidth: function SVGGraphics_setLineWidth(width) { - this.current.lineWidth = width; - }, - setLineCap: function SVGGraphics_setLineCap(style) { - this.current.lineCap = LINE_CAP_STYLES[style]; - }, - setLineJoin: function SVGGraphics_setLineJoin(style) { - this.current.lineJoin = LINE_JOIN_STYLES[style]; - }, - setMiterLimit: function SVGGraphics_setMiterLimit(limit) { - this.current.miterLimit = limit; - }, - setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { - var color = Util.makeCssRgb(r, g, b); - this.current.strokeColor = color; - }, - setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) { - var color = Util.makeCssRgb(r, g, b); - this.current.fillColor = color; - this.current.tspan = document.createElementNS(NS, 'svg:tspan'); - this.current.xcoords = []; - }, - setDash: function SVGGraphics_setDash(dashArray, dashPhase) { - this.current.dashArray = dashArray; - this.current.dashPhase = dashPhase; - }, - constructPath: function SVGGraphics_constructPath(ops, args) { - var current = this.current; - var x = current.x, - y = current.y; - current.path = document.createElementNS(NS, 'svg:path'); - var d = []; - var opLength = ops.length; - for (var i = 0, j = 0; i < opLength; i++) { - switch (ops[i] | 0) { - case OPS.rectangle: - x = args[j++]; - y = args[j++]; - var width = args[j++]; - var height = args[j++]; - var xw = x + width; - var yh = y + height; - d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z'); - break; - case OPS.moveTo: - x = args[j++]; - y = args[j++]; - d.push('M', pf(x), pf(y)); - break; - case OPS.lineTo: - x = args[j++]; - y = args[j++]; - d.push('L', pf(x), pf(y)); - break; - case OPS.curveTo: - x = args[j + 4]; - y = args[j + 5]; - d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y)); - j += 6; - break; - case OPS.curveTo2: - x = args[j + 2]; - y = args[j + 3]; - d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3])); - j += 4; - break; - case OPS.curveTo3: - x = args[j + 2]; - y = args[j + 3]; - d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y)); - j += 4; - break; - case OPS.closePath: - d.push('Z'); - break; - } - } - current.path.setAttributeNS(null, 'd', d.join(' ')); - current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit)); - current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap); - current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); - current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px'); - current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' ')); - current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px'); - current.path.setAttributeNS(null, 'fill', 'none'); - this._ensureTransformGroup().appendChild(current.path); - current.element = current.path; - current.setCurrentPoint(x, y); - }, - endPath: function SVGGraphics_endPath() {}, - clip: function SVGGraphics_clip(type) { - var current = this.current; - var clipId = 'clippath' + clipCount; - clipCount++; - var clipPath = document.createElementNS(NS, 'svg:clipPath'); - clipPath.setAttributeNS(null, 'id', clipId); - clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix)); - var clipElement = current.element.cloneNode(); - if (type === 'evenodd') { - clipElement.setAttributeNS(null, 'clip-rule', 'evenodd'); - } else { - clipElement.setAttributeNS(null, 'clip-rule', 'nonzero'); - } - clipPath.appendChild(clipElement); - this.defs.appendChild(clipPath); - if (current.activeClipUrl) { - current.clipGroup = null; - this.extraStack.forEach(function (prev) { - prev.clipGroup = null; - }); - } - current.activeClipUrl = 'url(#' + clipId + ')'; - this.tgrp = null; - }, - closePath: function SVGGraphics_closePath() { - var current = this.current; - var d = current.path.getAttributeNS(null, 'd'); - d += 'Z'; - current.path.setAttributeNS(null, 'd', d); - }, - setLeading: function SVGGraphics_setLeading(leading) { - this.current.leading = -leading; - }, - setTextRise: function SVGGraphics_setTextRise(textRise) { - this.current.textRise = textRise; - }, - setHScale: function SVGGraphics_setHScale(scale) { - this.current.textHScale = scale / 100; - }, - setGState: function SVGGraphics_setGState(states) { - for (var i = 0, ii = states.length; i < ii; i++) { - var state = states[i]; - var key = state[0]; - var value = state[1]; - switch (key) { - case 'LW': - this.setLineWidth(value); - break; - case 'LC': - this.setLineCap(value); - break; - case 'LJ': - this.setLineJoin(value); - break; - case 'ML': - this.setMiterLimit(value); - break; - case 'D': - this.setDash(value[0], value[1]); - break; - case 'Font': - this.setFont(value); - break; - default: - warn('Unimplemented graphic state ' + key); - break; - } - } - }, - fill: function SVGGraphics_fill() { - var current = this.current; - current.element.setAttributeNS(null, 'fill', current.fillColor); - }, - stroke: function SVGGraphics_stroke() { - var current = this.current; - current.element.setAttributeNS(null, 'stroke', current.strokeColor); - current.element.setAttributeNS(null, 'fill', 'none'); - }, - eoFill: function SVGGraphics_eoFill() { - var current = this.current; - current.element.setAttributeNS(null, 'fill', current.fillColor); - current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); - }, - fillStroke: function SVGGraphics_fillStroke() { - this.stroke(); - this.fill(); - }, - eoFillStroke: function SVGGraphics_eoFillStroke() { - this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); - this.fillStroke(); - }, - closeStroke: function SVGGraphics_closeStroke() { - this.closePath(); - this.stroke(); - }, - closeFillStroke: function SVGGraphics_closeFillStroke() { - this.closePath(); - this.fillStroke(); - }, - paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() { - var current = this.current; - var rect = document.createElementNS(NS, 'svg:rect'); - rect.setAttributeNS(null, 'x', '0'); - rect.setAttributeNS(null, 'y', '0'); - rect.setAttributeNS(null, 'width', '1px'); - rect.setAttributeNS(null, 'height', '1px'); - rect.setAttributeNS(null, 'fill', current.fillColor); - this._ensureTransformGroup().appendChild(rect); - }, - paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) { - var imgObj = this.objs.get(objId); - var imgEl = document.createElementNS(NS, 'svg:image'); - imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src); - imgEl.setAttributeNS(null, 'width', imgObj.width + 'px'); - imgEl.setAttributeNS(null, 'height', imgObj.height + 'px'); - imgEl.setAttributeNS(null, 'x', '0'); - imgEl.setAttributeNS(null, 'y', pf(-h)); - imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')'); - this._ensureTransformGroup().appendChild(imgEl); - }, - paintImageXObject: function SVGGraphics_paintImageXObject(objId) { - var imgData = this.objs.get(objId); - if (!imgData) { - warn('Dependent image isn\'t ready yet'); - return; - } - this.paintInlineImageXObject(imgData); - }, - paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) { - var width = imgData.width; - var height = imgData.height; - var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema); - var cliprect = document.createElementNS(NS, 'svg:rect'); - cliprect.setAttributeNS(null, 'x', '0'); - cliprect.setAttributeNS(null, 'y', '0'); - cliprect.setAttributeNS(null, 'width', pf(width)); - cliprect.setAttributeNS(null, 'height', pf(height)); - this.current.element = cliprect; - this.clip('nonzero'); - var imgEl = document.createElementNS(NS, 'svg:image'); - imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc); - imgEl.setAttributeNS(null, 'x', '0'); - imgEl.setAttributeNS(null, 'y', pf(-height)); - imgEl.setAttributeNS(null, 'width', pf(width) + 'px'); - imgEl.setAttributeNS(null, 'height', pf(height) + 'px'); - imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')'); - if (mask) { - mask.appendChild(imgEl); - } else { - this._ensureTransformGroup().appendChild(imgEl); - } - }, - paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) { - var current = this.current; - var width = imgData.width; - var height = imgData.height; - var fillColor = current.fillColor; - current.maskId = 'mask' + maskCount++; - var mask = document.createElementNS(NS, 'svg:mask'); - mask.setAttributeNS(null, 'id', current.maskId); - var rect = document.createElementNS(NS, 'svg:rect'); - rect.setAttributeNS(null, 'x', '0'); - rect.setAttributeNS(null, 'y', '0'); - rect.setAttributeNS(null, 'width', pf(width)); - rect.setAttributeNS(null, 'height', pf(height)); - rect.setAttributeNS(null, 'fill', fillColor); - rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')'); - this.defs.appendChild(mask); - this._ensureTransformGroup().appendChild(rect); - this.paintInlineImageXObject(imgData, mask); - }, - paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) { - if (isArray(matrix) && matrix.length === 6) { - this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - if (isArray(bbox) && bbox.length === 4) { - var width = bbox[2] - bbox[0]; - var height = bbox[3] - bbox[1]; - var cliprect = document.createElementNS(NS, 'svg:rect'); - cliprect.setAttributeNS(null, 'x', bbox[0]); - cliprect.setAttributeNS(null, 'y', bbox[1]); - cliprect.setAttributeNS(null, 'width', pf(width)); - cliprect.setAttributeNS(null, 'height', pf(height)); - this.current.element = cliprect; - this.clip('nonzero'); - this.endPath(); - } - }, - paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {}, - _initialize: function SVGGraphics_initialize(viewport) { - var svg = document.createElementNS(NS, 'svg:svg'); - svg.setAttributeNS(null, 'version', '1.1'); - svg.setAttributeNS(null, 'width', viewport.width + 'px'); - svg.setAttributeNS(null, 'height', viewport.height + 'px'); - svg.setAttributeNS(null, 'preserveAspectRatio', 'none'); - svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height); - var definitions = document.createElementNS(NS, 'svg:defs'); - svg.appendChild(definitions); - this.defs = definitions; - var rootGroup = document.createElementNS(NS, 'svg:g'); - rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform)); - svg.appendChild(rootGroup); - this.svg = rootGroup; - return svg; - }, - _ensureClipGroup: function SVGGraphics_ensureClipGroup() { - if (!this.current.clipGroup) { - var clipGroup = document.createElementNS(NS, 'svg:g'); - clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl); - this.svg.appendChild(clipGroup); - this.current.clipGroup = clipGroup; - } - return this.current.clipGroup; - }, - _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() { - if (!this.tgrp) { - this.tgrp = document.createElementNS(NS, 'svg:g'); - this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); - if (this.current.activeClipUrl) { - this._ensureClipGroup().appendChild(this.tgrp); - } else { - this.svg.appendChild(this.tgrp); - } - } - return this.tgrp; - } - }; - return SVGGraphics; -}(); -exports.SVGGraphics = SVGGraphics; - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayDOMUtils = __w_pdfjs_require__(1); -var Util = sharedUtil.Util; -var createPromiseCapability = sharedUtil.createPromiseCapability; -var CustomStyle = displayDOMUtils.CustomStyle; -var getDefaultSetting = displayDOMUtils.getDefaultSetting; -var renderTextLayer = function renderTextLayerClosure() { - var MAX_TEXT_DIVS_TO_RENDER = 100000; - var NonWhitespaceRegexp = /\S/; - function isAllWhitespace(str) { - return !NonWhitespaceRegexp.test(str); - } - var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';']; - function appendText(task, geom, styles) { - var textDiv = document.createElement('div'); - var textDivProperties = { - style: null, - angle: 0, - canvasWidth: 0, - isWhitespace: false, - originalTransform: null, - paddingBottom: 0, - paddingLeft: 0, - paddingRight: 0, - paddingTop: 0, - scale: 1 - }; - task._textDivs.push(textDiv); - if (isAllWhitespace(geom.str)) { - textDivProperties.isWhitespace = true; - task._textDivProperties.set(textDiv, textDivProperties); - return; - } - var tx = Util.transform(task._viewport.transform, geom.transform); - var angle = Math.atan2(tx[1], tx[0]); - var style = styles[geom.fontName]; - if (style.vertical) { - angle += Math.PI / 2; - } - var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]); - var fontAscent = fontHeight; - if (style.ascent) { - fontAscent = style.ascent * fontAscent; - } else if (style.descent) { - fontAscent = (1 + style.descent) * fontAscent; - } - var left; - var top; - if (angle === 0) { - left = tx[4]; - top = tx[5] - fontAscent; - } else { - left = tx[4] + fontAscent * Math.sin(angle); - top = tx[5] - fontAscent * Math.cos(angle); - } - styleBuf[1] = left; - styleBuf[3] = top; - styleBuf[5] = fontHeight; - styleBuf[7] = style.fontFamily; - textDivProperties.style = styleBuf.join(''); - textDiv.setAttribute('style', textDivProperties.style); - textDiv.textContent = geom.str; - if (getDefaultSetting('pdfBug')) { - textDiv.dataset.fontName = geom.fontName; - } - if (angle !== 0) { - textDivProperties.angle = angle * (180 / Math.PI); - } - if (geom.str.length > 1) { - if (style.vertical) { - textDivProperties.canvasWidth = geom.height * task._viewport.scale; - } else { - textDivProperties.canvasWidth = geom.width * task._viewport.scale; - } - } - task._textDivProperties.set(textDiv, textDivProperties); - if (task._enhanceTextSelection) { - var angleCos = 1, - angleSin = 0; - if (angle !== 0) { - angleCos = Math.cos(angle); - angleSin = Math.sin(angle); - } - var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale; - var divHeight = fontHeight; - var m, b; - if (angle !== 0) { - m = [angleCos, angleSin, -angleSin, angleCos, left, top]; - b = Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m); - } else { - b = [left, top, left + divWidth, top + divHeight]; - } - task._bounds.push({ - left: b[0], - top: b[1], - right: b[2], - bottom: b[3], - div: textDiv, - size: [divWidth, divHeight], - m: m - }); - } - } - function render(task) { - if (task._canceled) { - return; - } - var textLayerFrag = task._container; - var textDivs = task._textDivs; - var capability = task._capability; - var textDivsLength = textDivs.length; - if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { - task._renderingDone = true; - capability.resolve(); - return; - } - var canvas = document.createElement('canvas'); - canvas.mozOpaque = true; - var ctx = canvas.getContext('2d', { alpha: false }); - var lastFontSize; - var lastFontFamily; - for (var i = 0; i < textDivsLength; i++) { - var textDiv = textDivs[i]; - var textDivProperties = task._textDivProperties.get(textDiv); - if (textDivProperties.isWhitespace) { - continue; - } - var fontSize = textDiv.style.fontSize; - var fontFamily = textDiv.style.fontFamily; - if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) { - ctx.font = fontSize + ' ' + fontFamily; - lastFontSize = fontSize; - lastFontFamily = fontFamily; - } - var width = ctx.measureText(textDiv.textContent).width; - textLayerFrag.appendChild(textDiv); - var transform = ''; - if (textDivProperties.canvasWidth !== 0 && width > 0) { - textDivProperties.scale = textDivProperties.canvasWidth / width; - transform = 'scaleX(' + textDivProperties.scale + ')'; - } - if (textDivProperties.angle !== 0) { - transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform; - } - if (transform !== '') { - textDivProperties.originalTransform = transform; - CustomStyle.setProp('transform', textDiv, transform); - } - task._textDivProperties.set(textDiv, textDivProperties); - } - task._renderingDone = true; - capability.resolve(); - } - function expand(task) { - var bounds = task._bounds; - var viewport = task._viewport; - var expanded = expandBounds(viewport.width, viewport.height, bounds); - for (var i = 0; i < expanded.length; i++) { - var div = bounds[i].div; - var divProperties = task._textDivProperties.get(div); - if (divProperties.angle === 0) { - divProperties.paddingLeft = bounds[i].left - expanded[i].left; - divProperties.paddingTop = bounds[i].top - expanded[i].top; - divProperties.paddingRight = expanded[i].right - bounds[i].right; - divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom; - task._textDivProperties.set(div, divProperties); - continue; - } - var e = expanded[i], - b = bounds[i]; - var m = b.m, - c = m[0], - s = m[1]; - var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size]; - var ts = new Float64Array(64); - points.forEach(function (p, i) { - var t = Util.applyTransform(p, m); - ts[i + 0] = c && (e.left - t[0]) / c; - ts[i + 4] = s && (e.top - t[1]) / s; - ts[i + 8] = c && (e.right - t[0]) / c; - ts[i + 12] = s && (e.bottom - t[1]) / s; - ts[i + 16] = s && (e.left - t[0]) / -s; - ts[i + 20] = c && (e.top - t[1]) / c; - ts[i + 24] = s && (e.right - t[0]) / -s; - ts[i + 28] = c && (e.bottom - t[1]) / c; - ts[i + 32] = c && (e.left - t[0]) / -c; - ts[i + 36] = s && (e.top - t[1]) / -s; - ts[i + 40] = c && (e.right - t[0]) / -c; - ts[i + 44] = s && (e.bottom - t[1]) / -s; - ts[i + 48] = s && (e.left - t[0]) / s; - ts[i + 52] = c && (e.top - t[1]) / -c; - ts[i + 56] = s && (e.right - t[0]) / s; - ts[i + 60] = c && (e.bottom - t[1]) / -c; - }); - var findPositiveMin = function (ts, offset, count) { - var result = 0; - for (var i = 0; i < count; i++) { - var t = ts[offset++]; - if (t > 0) { - result = result ? Math.min(t, result) : t; - } - } - return result; - }; - var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s)); - divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale; - divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale; - divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale; - divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale; - task._textDivProperties.set(div, divProperties); - } - } - function expandBounds(width, height, boxes) { - var bounds = boxes.map(function (box, i) { - return { - x1: box.left, - y1: box.top, - x2: box.right, - y2: box.bottom, - index: i, - x1New: undefined, - x2New: undefined - }; - }); - expandBoundsLTR(width, bounds); - var expanded = new Array(boxes.length); - bounds.forEach(function (b) { - var i = b.index; - expanded[i] = { - left: b.x1New, - top: 0, - right: b.x2New, - bottom: 0 - }; - }); - boxes.map(function (box, i) { - var e = expanded[i], - b = bounds[i]; - b.x1 = box.top; - b.y1 = width - e.right; - b.x2 = box.bottom; - b.y2 = width - e.left; - b.index = i; - b.x1New = undefined; - b.x2New = undefined; - }); - expandBoundsLTR(height, bounds); - bounds.forEach(function (b) { - var i = b.index; - expanded[i].top = b.x1New; - expanded[i].bottom = b.x2New; - }); - return expanded; - } - function expandBoundsLTR(width, bounds) { - bounds.sort(function (a, b) { - return a.x1 - b.x1 || a.index - b.index; - }); - var fakeBoundary = { - x1: -Infinity, - y1: -Infinity, - x2: 0, - y2: Infinity, - index: -1, - x1New: 0, - x2New: 0 - }; - var horizon = [{ - start: -Infinity, - end: Infinity, - boundary: fakeBoundary - }]; - bounds.forEach(function (boundary) { - var i = 0; - while (i < horizon.length && horizon[i].end <= boundary.y1) { - i++; - } - var j = horizon.length - 1; - while (j >= 0 && horizon[j].start >= boundary.y2) { - j--; - } - var horizonPart, affectedBoundary; - var q, - k, - maxXNew = -Infinity; - for (q = i; q <= j; q++) { - horizonPart = horizon[q]; - affectedBoundary = horizonPart.boundary; - var xNew; - if (affectedBoundary.x2 > boundary.x1) { - xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1; - } else if (affectedBoundary.x2New === undefined) { - xNew = (affectedBoundary.x2 + boundary.x1) / 2; - } else { - xNew = affectedBoundary.x2New; - } - if (xNew > maxXNew) { - maxXNew = xNew; - } - } - boundary.x1New = maxXNew; - for (q = i; q <= j; q++) { - horizonPart = horizon[q]; - affectedBoundary = horizonPart.boundary; - if (affectedBoundary.x2New === undefined) { - if (affectedBoundary.x2 > boundary.x1) { - if (affectedBoundary.index > boundary.index) { - affectedBoundary.x2New = affectedBoundary.x2; - } - } else { - affectedBoundary.x2New = maxXNew; - } - } else if (affectedBoundary.x2New > maxXNew) { - affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2); - } - } - var changedHorizon = [], - lastBoundary = null; - for (q = i; q <= j; q++) { - horizonPart = horizon[q]; - affectedBoundary = horizonPart.boundary; - var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary; - if (lastBoundary === useBoundary) { - changedHorizon[changedHorizon.length - 1].end = horizonPart.end; - } else { - changedHorizon.push({ - start: horizonPart.start, - end: horizonPart.end, - boundary: useBoundary - }); - lastBoundary = useBoundary; - } - } - if (horizon[i].start < boundary.y1) { - changedHorizon[0].start = boundary.y1; - changedHorizon.unshift({ - start: horizon[i].start, - end: boundary.y1, - boundary: horizon[i].boundary - }); - } - if (boundary.y2 < horizon[j].end) { - changedHorizon[changedHorizon.length - 1].end = boundary.y2; - changedHorizon.push({ - start: boundary.y2, - end: horizon[j].end, - boundary: horizon[j].boundary - }); - } - for (q = i; q <= j; q++) { - horizonPart = horizon[q]; - affectedBoundary = horizonPart.boundary; - if (affectedBoundary.x2New !== undefined) { - continue; - } - var used = false; - for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) { - used = horizon[k].boundary === affectedBoundary; - } - for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) { - used = horizon[k].boundary === affectedBoundary; - } - for (k = 0; !used && k < changedHorizon.length; k++) { - used = changedHorizon[k].boundary === affectedBoundary; - } - if (!used) { - affectedBoundary.x2New = maxXNew; - } - } - Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon)); - }); - horizon.forEach(function (horizonPart) { - var affectedBoundary = horizonPart.boundary; - if (affectedBoundary.x2New === undefined) { - affectedBoundary.x2New = Math.max(width, affectedBoundary.x2); - } - }); - } - function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) { - this._textContent = textContent; - this._container = container; - this._viewport = viewport; - this._textDivs = textDivs || []; - this._textDivProperties = new WeakMap(); - this._renderingDone = false; - this._canceled = false; - this._capability = createPromiseCapability(); - this._renderTimer = null; - this._bounds = []; - this._enhanceTextSelection = !!enhanceTextSelection; - } - TextLayerRenderTask.prototype = { - get promise() { - return this._capability.promise; - }, - cancel: function TextLayer_cancel() { - this._canceled = true; - if (this._renderTimer !== null) { - clearTimeout(this._renderTimer); - this._renderTimer = null; - } - this._capability.reject('canceled'); - }, - _render: function TextLayer_render(timeout) { - var textItems = this._textContent.items; - var textStyles = this._textContent.styles; - for (var i = 0, len = textItems.length; i < len; i++) { - appendText(this, textItems[i], textStyles); - } - if (!timeout) { - render(this); - } else { - var self = this; - this._renderTimer = setTimeout(function () { - render(self); - self._renderTimer = null; - }, timeout); - } - }, - expandTextDivs: function TextLayer_expandTextDivs(expandDivs) { - if (!this._enhanceTextSelection || !this._renderingDone) { - return; - } - if (this._bounds !== null) { - expand(this); - this._bounds = null; - } - for (var i = 0, ii = this._textDivs.length; i < ii; i++) { - var div = this._textDivs[i]; - var divProperties = this._textDivProperties.get(div); - if (divProperties.isWhitespace) { - continue; - } - if (expandDivs) { - var transform = '', - padding = ''; - if (divProperties.scale !== 1) { - transform = 'scaleX(' + divProperties.scale + ')'; - } - if (divProperties.angle !== 0) { - transform = 'rotate(' + divProperties.angle + 'deg) ' + transform; - } - if (divProperties.paddingLeft !== 0) { - padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;'; - transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)'; - } - if (divProperties.paddingTop !== 0) { - padding += ' padding-top: ' + divProperties.paddingTop + 'px;'; - transform += ' translateY(' + -divProperties.paddingTop + 'px)'; - } - if (divProperties.paddingRight !== 0) { - padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;'; - } - if (divProperties.paddingBottom !== 0) { - padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;'; - } - if (padding !== '') { - div.setAttribute('style', divProperties.style + padding); - } - if (transform !== '') { - CustomStyle.setProp('transform', div, transform); - } - } else { - div.style.padding = 0; - CustomStyle.setProp('transform', div, divProperties.originalTransform || ''); - } - } - } - }; - function renderTextLayer(renderParameters) { - var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection); - task._render(renderParameters.timeout); - return task; - } - return renderTextLayer; -}(); -exports.renderTextLayer = renderTextLayer; - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var g; -g = function () { - return this; -}(); -try { - g = g || Function("return this")() || (1, eval)("this"); -} catch (e) { - if (typeof window === "object") g = window; -} -module.exports = g; - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var error = sharedUtil.error; -function fixMetadata(meta) { - return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) { - var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) { - return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1); - }); - var chars = ''; - for (var i = 0; i < bytes.length; i += 2) { - var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1); - chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';'; - } - return '>' + chars; - }); -} -function Metadata(meta) { - if (typeof meta === 'string') { - meta = fixMetadata(meta); - var parser = new DOMParser(); - meta = parser.parseFromString(meta, 'application/xml'); - } else if (!(meta instanceof Document)) { - error('Metadata: Invalid metadata object'); - } - this.metaDocument = meta; - this.metadata = Object.create(null); - this.parse(); -} -Metadata.prototype = { - parse: function Metadata_parse() { - var doc = this.metaDocument; - var rdf = doc.documentElement; - if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { - rdf = rdf.firstChild; - while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') { - rdf = rdf.nextSibling; - } - } - var nodeName = rdf ? rdf.nodeName.toLowerCase() : null; - if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) { - return; - } - var children = rdf.childNodes, - desc, - entry, - name, - i, - ii, - length, - iLength; - for (i = 0, length = children.length; i < length; i++) { - desc = children[i]; - if (desc.nodeName.toLowerCase() !== 'rdf:description') { - continue; - } - for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) { - if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') { - entry = desc.childNodes[ii]; - name = entry.nodeName.toLowerCase(); - this.metadata[name] = entry.textContent.trim(); - } - } - } - }, - get: function Metadata_get(name) { - return this.metadata[name] || null; - }, - has: function Metadata_has(name) { - return typeof this.metadata[name] !== 'undefined'; - } -}; -exports.Metadata = Metadata; - -/***/ }), -/* 8 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayDOMUtils = __w_pdfjs_require__(1); -var shadow = sharedUtil.shadow; -var getDefaultSetting = displayDOMUtils.getDefaultSetting; -var WebGLUtils = function WebGLUtilsClosure() { - function loadShader(gl, code, shaderType) { - var shader = gl.createShader(shaderType); - gl.shaderSource(shader, code); - gl.compileShader(shader); - var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); - if (!compiled) { - var errorMsg = gl.getShaderInfoLog(shader); - throw new Error('Error during shader compilation: ' + errorMsg); - } - return shader; - } - function createVertexShader(gl, code) { - return loadShader(gl, code, gl.VERTEX_SHADER); - } - function createFragmentShader(gl, code) { - return loadShader(gl, code, gl.FRAGMENT_SHADER); - } - function createProgram(gl, shaders) { - var program = gl.createProgram(); - for (var i = 0, ii = shaders.length; i < ii; ++i) { - gl.attachShader(program, shaders[i]); - } - gl.linkProgram(program); - var linked = gl.getProgramParameter(program, gl.LINK_STATUS); - if (!linked) { - var errorMsg = gl.getProgramInfoLog(program); - throw new Error('Error during program linking: ' + errorMsg); - } - return program; - } - function createTexture(gl, image, textureId) { - gl.activeTexture(textureId); - var texture = gl.createTexture(); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); - return texture; - } - var currentGL, currentCanvas; - function generateGL() { - if (currentGL) { - return; - } - currentCanvas = document.createElement('canvas'); - currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false }); - } - var smaskVertexShaderCode = '\ - attribute vec2 a_position; \ - attribute vec2 a_texCoord; \ - \ - uniform vec2 u_resolution; \ - \ - varying vec2 v_texCoord; \ - \ - void main() { \ - vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \ - gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ - \ - v_texCoord = a_texCoord; \ - } '; - var smaskFragmentShaderCode = '\ - precision mediump float; \ - \ - uniform vec4 u_backdrop; \ - uniform int u_subtype; \ - uniform sampler2D u_image; \ - uniform sampler2D u_mask; \ - \ - varying vec2 v_texCoord; \ - \ - void main() { \ - vec4 imageColor = texture2D(u_image, v_texCoord); \ - vec4 maskColor = texture2D(u_mask, v_texCoord); \ - if (u_backdrop.a > 0.0) { \ - maskColor.rgb = maskColor.rgb * maskColor.a + \ - u_backdrop.rgb * (1.0 - maskColor.a); \ - } \ - float lum; \ - if (u_subtype == 0) { \ - lum = maskColor.a; \ - } else { \ - lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \ - maskColor.b * 0.11; \ - } \ - imageColor.a *= lum; \ - imageColor.rgb *= imageColor.a; \ - gl_FragColor = imageColor; \ - } '; - var smaskCache = null; - function initSmaskGL() { - var canvas, gl; - generateGL(); - canvas = currentCanvas; - currentCanvas = null; - gl = currentGL; - currentGL = null; - var vertexShader = createVertexShader(gl, smaskVertexShaderCode); - var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode); - var program = createProgram(gl, [vertexShader, fragmentShader]); - gl.useProgram(program); - var cache = {}; - cache.gl = gl; - cache.canvas = canvas; - cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); - cache.positionLocation = gl.getAttribLocation(program, 'a_position'); - cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop'); - cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype'); - var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord'); - var texLayerLocation = gl.getUniformLocation(program, 'u_image'); - var texMaskLocation = gl.getUniformLocation(program, 'u_mask'); - var texCoordBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer); - 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); - gl.enableVertexAttribArray(texCoordLocation); - gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0); - gl.uniform1i(texLayerLocation, 0); - gl.uniform1i(texMaskLocation, 1); - smaskCache = cache; - } - function composeSMask(layer, mask, properties) { - var width = layer.width, - height = layer.height; - if (!smaskCache) { - initSmaskGL(); - } - var cache = smaskCache, - canvas = cache.canvas, - gl = cache.gl; - canvas.width = width; - canvas.height = height; - gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); - gl.uniform2f(cache.resolutionLocation, width, height); - if (properties.backdrop) { - gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1); - } else { - gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0); - } - gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0); - var texture = createTexture(gl, layer, gl.TEXTURE0); - var maskTexture = createTexture(gl, mask, gl.TEXTURE1); - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW); - gl.enableVertexAttribArray(cache.positionLocation); - gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); - gl.clearColor(0, 0, 0, 0); - gl.enable(gl.BLEND); - gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - gl.clear(gl.COLOR_BUFFER_BIT); - gl.drawArrays(gl.TRIANGLES, 0, 6); - gl.flush(); - gl.deleteTexture(texture); - gl.deleteTexture(maskTexture); - gl.deleteBuffer(buffer); - return canvas; - } - var figuresVertexShaderCode = '\ - attribute vec2 a_position; \ - attribute vec3 a_color; \ - \ - uniform vec2 u_resolution; \ - uniform vec2 u_scale; \ - uniform vec2 u_offset; \ - \ - varying vec4 v_color; \ - \ - void main() { \ - vec2 position = (a_position + u_offset) * u_scale; \ - vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \ - gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ - \ - v_color = vec4(a_color / 255.0, 1.0); \ - } '; - var figuresFragmentShaderCode = '\ - precision mediump float; \ - \ - varying vec4 v_color; \ - \ - void main() { \ - gl_FragColor = v_color; \ - } '; - var figuresCache = null; - function initFiguresGL() { - var canvas, gl; - generateGL(); - canvas = currentCanvas; - currentCanvas = null; - gl = currentGL; - currentGL = null; - var vertexShader = createVertexShader(gl, figuresVertexShaderCode); - var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode); - var program = createProgram(gl, [vertexShader, fragmentShader]); - gl.useProgram(program); - var cache = {}; - cache.gl = gl; - cache.canvas = canvas; - cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); - cache.scaleLocation = gl.getUniformLocation(program, 'u_scale'); - cache.offsetLocation = gl.getUniformLocation(program, 'u_offset'); - cache.positionLocation = gl.getAttribLocation(program, 'a_position'); - cache.colorLocation = gl.getAttribLocation(program, 'a_color'); - figuresCache = cache; - } - function drawFigures(width, height, backgroundColor, figures, context) { - if (!figuresCache) { - initFiguresGL(); - } - var cache = figuresCache, - canvas = cache.canvas, - gl = cache.gl; - canvas.width = width; - canvas.height = height; - gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); - gl.uniform2f(cache.resolutionLocation, width, height); - var count = 0; - var i, ii, rows; - for (i = 0, ii = figures.length; i < ii; i++) { - switch (figures[i].type) { - case 'lattice': - rows = figures[i].coords.length / figures[i].verticesPerRow | 0; - count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; - break; - case 'triangles': - count += figures[i].coords.length; - break; - } - } - var coords = new Float32Array(count * 2); - var colors = new Uint8Array(count * 3); - var coordsMap = context.coords, - colorsMap = context.colors; - var pIndex = 0, - cIndex = 0; - for (i = 0, ii = figures.length; i < ii; i++) { - var figure = figures[i], - ps = figure.coords, - cs = figure.colors; - switch (figure.type) { - case 'lattice': - var cols = figure.verticesPerRow; - rows = ps.length / cols | 0; - for (var row = 1; row < rows; row++) { - var offset = row * cols + 1; - for (var col = 1; col < cols; col++, offset++) { - coords[pIndex] = coordsMap[ps[offset - cols - 1]]; - coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1]; - coords[pIndex + 2] = coordsMap[ps[offset - cols]]; - coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1]; - coords[pIndex + 4] = coordsMap[ps[offset - 1]]; - coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1]; - colors[cIndex] = colorsMap[cs[offset - cols - 1]]; - colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1]; - colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2]; - colors[cIndex + 3] = colorsMap[cs[offset - cols]]; - colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1]; - colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2]; - colors[cIndex + 6] = colorsMap[cs[offset - 1]]; - colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1]; - colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2]; - coords[pIndex + 6] = coords[pIndex + 2]; - coords[pIndex + 7] = coords[pIndex + 3]; - coords[pIndex + 8] = coords[pIndex + 4]; - coords[pIndex + 9] = coords[pIndex + 5]; - coords[pIndex + 10] = coordsMap[ps[offset]]; - coords[pIndex + 11] = coordsMap[ps[offset] + 1]; - colors[cIndex + 9] = colors[cIndex + 3]; - colors[cIndex + 10] = colors[cIndex + 4]; - colors[cIndex + 11] = colors[cIndex + 5]; - colors[cIndex + 12] = colors[cIndex + 6]; - colors[cIndex + 13] = colors[cIndex + 7]; - colors[cIndex + 14] = colors[cIndex + 8]; - colors[cIndex + 15] = colorsMap[cs[offset]]; - colors[cIndex + 16] = colorsMap[cs[offset] + 1]; - colors[cIndex + 17] = colorsMap[cs[offset] + 2]; - pIndex += 12; - cIndex += 18; - } - } - break; - case 'triangles': - for (var j = 0, jj = ps.length; j < jj; j++) { - coords[pIndex] = coordsMap[ps[j]]; - coords[pIndex + 1] = coordsMap[ps[j] + 1]; - colors[cIndex] = colorsMap[cs[j]]; - colors[cIndex + 1] = colorsMap[cs[j] + 1]; - colors[cIndex + 2] = colorsMap[cs[j] + 2]; - pIndex += 2; - cIndex += 3; - } - break; - } - } - if (backgroundColor) { - gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0); - } else { - gl.clearColor(0, 0, 0, 0); - } - gl.clear(gl.COLOR_BUFFER_BIT); - var coordsBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer); - gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW); - gl.enableVertexAttribArray(cache.positionLocation); - gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); - var colorsBuffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer); - gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); - gl.enableVertexAttribArray(cache.colorLocation); - gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0); - gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY); - gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY); - gl.drawArrays(gl.TRIANGLES, 0, count); - gl.flush(); - gl.deleteBuffer(coordsBuffer); - gl.deleteBuffer(colorsBuffer); - return canvas; - } - function cleanup() { - if (smaskCache && smaskCache.canvas) { - smaskCache.canvas.width = 0; - smaskCache.canvas.height = 0; - } - if (figuresCache && figuresCache.canvas) { - figuresCache.canvas.width = 0; - figuresCache.canvas.height = 0; - } - smaskCache = null; - figuresCache = null; - } - return { - get isEnabled() { - if (getDefaultSetting('disableWebGL')) { - return false; - } - var enabled = false; - try { - generateGL(); - enabled = !!currentGL; - } catch (e) {} - return shadow(this, 'isEnabled', enabled); - }, - composeSMask: composeSMask, - drawFigures: drawFigures, - clear: cleanup - }; -}(); -exports.WebGLUtils = WebGLUtils; - -/***/ }), -/* 9 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayDOMUtils = __w_pdfjs_require__(1); -var displayAPI = __w_pdfjs_require__(3); -var displayAnnotationLayer = __w_pdfjs_require__(2); -var displayTextLayer = __w_pdfjs_require__(5); -var displayMetadata = __w_pdfjs_require__(7); -var displaySVG = __w_pdfjs_require__(4); -var globalScope = sharedUtil.globalScope; -var deprecated = sharedUtil.deprecated; -var warn = sharedUtil.warn; -var LinkTarget = displayDOMUtils.LinkTarget; -var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL; -var isWorker = typeof window === 'undefined'; -if (!globalScope.PDFJS) { - globalScope.PDFJS = {}; -} -var PDFJS = globalScope.PDFJS; -PDFJS.version = '1.8.172'; -PDFJS.build = '8ff1fbe7'; -PDFJS.pdfBug = false; -if (PDFJS.verbosity !== undefined) { - sharedUtil.setVerbosityLevel(PDFJS.verbosity); -} -delete PDFJS.verbosity; -Object.defineProperty(PDFJS, 'verbosity', { - get: function () { - return sharedUtil.getVerbosityLevel(); - }, - set: function (level) { - sharedUtil.setVerbosityLevel(level); - }, - enumerable: true, - configurable: true -}); -PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS; -PDFJS.OPS = sharedUtil.OPS; -PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES; -PDFJS.isValidUrl = displayDOMUtils.isValidUrl; -PDFJS.shadow = sharedUtil.shadow; -PDFJS.createBlob = sharedUtil.createBlob; -PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) { - return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL); -}; -Object.defineProperty(PDFJS, 'isLittleEndian', { - configurable: true, - get: function PDFJS_isLittleEndian() { - var value = sharedUtil.isLittleEndian(); - return sharedUtil.shadow(PDFJS, 'isLittleEndian', value); - } -}); -PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters; -PDFJS.PasswordResponses = sharedUtil.PasswordResponses; -PDFJS.PasswordException = sharedUtil.PasswordException; -PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException; -PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException; -PDFJS.MissingPDFException = sharedUtil.MissingPDFException; -PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException; -PDFJS.Util = sharedUtil.Util; -PDFJS.PageViewport = sharedUtil.PageViewport; -PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability; -PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize; -PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl; -PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked; -PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace; -PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath; -PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker; -PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc; -PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort; -PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange; -PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream; -PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch; -PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug; -PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers; -PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL; -PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL; -PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget; -PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel; -PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported; -PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext; -var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow; -delete PDFJS.openExternalLinksInNewWindow; -Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', { - get: function () { - return PDFJS.externalLinkTarget === LinkTarget.BLANK; - }, - set: function (value) { - if (value) { - deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.'); - } - if (PDFJS.externalLinkTarget !== LinkTarget.NONE) { - warn('PDFJS.externalLinkTarget is already initialized'); - return; - } - PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE; - }, - enumerable: true, - configurable: true -}); -if (savedOpenExternalLinksInNewWindow) { - PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow; -} -PDFJS.getDocument = displayAPI.getDocument; -PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; -PDFJS.PDFWorker = displayAPI.PDFWorker; -Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', { - configurable: true, - get: function PDFJS_hasCanvasTypedArrays() { - var value = displayDOMUtils.hasCanvasTypedArrays(); - return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value); - } -}); -PDFJS.CustomStyle = displayDOMUtils.CustomStyle; -PDFJS.LinkTarget = LinkTarget; -PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes; -PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl; -PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet; -PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer; -PDFJS.renderTextLayer = displayTextLayer.renderTextLayer; -PDFJS.Metadata = displayMetadata.Metadata; -PDFJS.SVGGraphics = displaySVG.SVGGraphics; -PDFJS.UnsupportedManager = displayAPI._UnsupportedManager; -exports.globalScope = globalScope; -exports.isWorker = isWorker; -exports.PDFJS = globalScope.PDFJS; - -/***/ }), -/* 10 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayDOMUtils = __w_pdfjs_require__(1); -var displayPatternHelper = __w_pdfjs_require__(12); -var displayWebGL = __w_pdfjs_require__(8); -var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX; -var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX; -var ImageKind = sharedUtil.ImageKind; -var OPS = sharedUtil.OPS; -var TextRenderingMode = sharedUtil.TextRenderingMode; -var Uint32ArrayView = sharedUtil.Uint32ArrayView; -var Util = sharedUtil.Util; -var assert = sharedUtil.assert; -var info = sharedUtil.info; -var isNum = sharedUtil.isNum; -var isArray = sharedUtil.isArray; -var isLittleEndian = sharedUtil.isLittleEndian; -var error = sharedUtil.error; -var shadow = sharedUtil.shadow; -var warn = sharedUtil.warn; -var TilingPattern = displayPatternHelper.TilingPattern; -var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR; -var WebGLUtils = displayWebGL.WebGLUtils; -var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays; -var MIN_FONT_SIZE = 16; -var MAX_FONT_SIZE = 100; -var MAX_GROUP_SIZE = 4096; -var MIN_WIDTH_FACTOR = 0.65; -var COMPILE_TYPE3_GLYPHS = true; -var MAX_SIZE_TO_COMPILE = 1000; -var FULL_CHUNK_HEIGHT = 16; -var HasCanvasTypedArraysCached = { - get value() { - return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays()); - } -}; -var IsLittleEndianCached = { - get value() { - return shadow(IsLittleEndianCached, 'value', isLittleEndian()); - } -}; -function addContextCurrentTransform(ctx) { - if (!ctx.mozCurrentTransform) { - ctx._originalSave = ctx.save; - ctx._originalRestore = ctx.restore; - ctx._originalRotate = ctx.rotate; - ctx._originalScale = ctx.scale; - ctx._originalTranslate = ctx.translate; - ctx._originalTransform = ctx.transform; - ctx._originalSetTransform = ctx.setTransform; - ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0]; - ctx._transformStack = []; - Object.defineProperty(ctx, 'mozCurrentTransform', { - get: function getCurrentTransform() { - return this._transformMatrix; - } - }); - Object.defineProperty(ctx, 'mozCurrentTransformInverse', { - get: function getCurrentTransformInverse() { - var m = this._transformMatrix; - var a = m[0], - b = m[1], - c = m[2], - d = m[3], - e = m[4], - f = m[5]; - var ad_bc = a * d - b * c; - var bc_ad = b * c - a * d; - 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]; - } - }); - ctx.save = function ctxSave() { - var old = this._transformMatrix; - this._transformStack.push(old); - this._transformMatrix = old.slice(0, 6); - this._originalSave(); - }; - ctx.restore = function ctxRestore() { - var prev = this._transformStack.pop(); - if (prev) { - this._transformMatrix = prev; - this._originalRestore(); - } - }; - ctx.translate = function ctxTranslate(x, y) { - var m = this._transformMatrix; - m[4] = m[0] * x + m[2] * y + m[4]; - m[5] = m[1] * x + m[3] * y + m[5]; - this._originalTranslate(x, y); - }; - ctx.scale = function ctxScale(x, y) { - var m = this._transformMatrix; - m[0] = m[0] * x; - m[1] = m[1] * x; - m[2] = m[2] * y; - m[3] = m[3] * y; - this._originalScale(x, y); - }; - ctx.transform = function ctxTransform(a, b, c, d, e, f) { - var m = this._transformMatrix; - 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]]; - ctx._originalTransform(a, b, c, d, e, f); - }; - ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) { - this._transformMatrix = [a, b, c, d, e, f]; - ctx._originalSetTransform(a, b, c, d, e, f); - }; - ctx.rotate = function ctxRotate(angle) { - var cosValue = Math.cos(angle); - var sinValue = Math.sin(angle); - var m = this._transformMatrix; - 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]]; - this._originalRotate(angle); - }; - } -} -var CachedCanvases = function CachedCanvasesClosure() { - function CachedCanvases(canvasFactory) { - this.canvasFactory = canvasFactory; - this.cache = Object.create(null); - } - CachedCanvases.prototype = { - getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) { - var canvasEntry; - if (this.cache[id] !== undefined) { - canvasEntry = this.cache[id]; - this.canvasFactory.reset(canvasEntry, width, height); - canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0); - } else { - canvasEntry = this.canvasFactory.create(width, height); - this.cache[id] = canvasEntry; - } - if (trackTransform) { - addContextCurrentTransform(canvasEntry.context); - } - return canvasEntry; - }, - clear: function () { - for (var id in this.cache) { - var canvasEntry = this.cache[id]; - this.canvasFactory.destroy(canvasEntry); - delete this.cache[id]; - } - } - }; - return CachedCanvases; -}(); -function compileType3Glyph(imgData) { - var POINT_TO_PROCESS_LIMIT = 1000; - var width = imgData.width, - height = imgData.height; - var i, - j, - j0, - width1 = width + 1; - var points = new Uint8Array(width1 * (height + 1)); - var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]); - var lineSize = width + 7 & ~7, - data0 = imgData.data; - var data = new Uint8Array(lineSize * height), - pos = 0, - ii; - for (i = 0, ii = data0.length; i < ii; i++) { - var mask = 128, - elem = data0[i]; - while (mask > 0) { - data[pos++] = elem & mask ? 0 : 255; - mask >>= 1; - } - } - var count = 0; - pos = 0; - if (data[pos] !== 0) { - points[0] = 1; - ++count; - } - for (j = 1; j < width; j++) { - if (data[pos] !== data[pos + 1]) { - points[j] = data[pos] ? 2 : 1; - ++count; - } - pos++; - } - if (data[pos] !== 0) { - points[j] = 2; - ++count; - } - for (i = 1; i < height; i++) { - pos = i * lineSize; - j0 = i * width1; - if (data[pos - lineSize] !== data[pos]) { - points[j0] = data[pos] ? 1 : 8; - ++count; - } - var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0); - for (j = 1; j < width; j++) { - sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0); - if (POINT_TYPES[sum]) { - points[j0 + j] = POINT_TYPES[sum]; - ++count; - } - pos++; - } - if (data[pos - lineSize] !== data[pos]) { - points[j0 + j] = data[pos] ? 2 : 4; - ++count; - } - if (count > POINT_TO_PROCESS_LIMIT) { - return null; - } - } - pos = lineSize * (height - 1); - j0 = i * width1; - if (data[pos] !== 0) { - points[j0] = 8; - ++count; - } - for (j = 1; j < width; j++) { - if (data[pos] !== data[pos + 1]) { - points[j0 + j] = data[pos] ? 4 : 8; - ++count; - } - pos++; - } - if (data[pos] !== 0) { - points[j0 + j] = 4; - ++count; - } - if (count > POINT_TO_PROCESS_LIMIT) { - return null; - } - var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]); - var outlines = []; - for (i = 0; count && i <= height; i++) { - var p = i * width1; - var end = p + width; - while (p < end && !points[p]) { - p++; - } - if (p === end) { - continue; - } - var coords = [p % width1, i]; - var type = points[p], - p0 = p, - pp; - do { - var step = steps[type]; - do { - p += step; - } while (!points[p]); - pp = points[p]; - if (pp !== 5 && pp !== 10) { - type = pp; - points[p] = 0; - } else { - type = pp & 0x33 * type >> 4; - points[p] &= type >> 2 | type << 2; - } - coords.push(p % width1); - coords.push(p / width1 | 0); - --count; - } while (p0 !== p); - outlines.push(coords); - --i; - } - var drawOutline = function (c) { - c.save(); - c.scale(1 / width, -1 / height); - c.translate(0, -height); - c.beginPath(); - for (var i = 0, ii = outlines.length; i < ii; i++) { - var o = outlines[i]; - c.moveTo(o[0], o[1]); - for (var j = 2, jj = o.length; j < jj; j += 2) { - c.lineTo(o[j], o[j + 1]); - } - } - c.fill(); - c.beginPath(); - c.restore(); - }; - return drawOutline; -} -var CanvasExtraState = function CanvasExtraStateClosure() { - function CanvasExtraState(old) { - this.alphaIsShape = false; - this.fontSize = 0; - this.fontSizeScale = 1; - this.textMatrix = IDENTITY_MATRIX; - this.textMatrixScale = 1; - this.fontMatrix = FONT_IDENTITY_MATRIX; - this.leading = 0; - this.x = 0; - this.y = 0; - this.lineX = 0; - this.lineY = 0; - this.charSpacing = 0; - this.wordSpacing = 0; - this.textHScale = 1; - this.textRenderingMode = TextRenderingMode.FILL; - this.textRise = 0; - this.fillColor = '#000000'; - this.strokeColor = '#000000'; - this.patternFill = false; - this.fillAlpha = 1; - this.strokeAlpha = 1; - this.lineWidth = 1; - this.activeSMask = null; - this.resumeSMaskCtx = null; - this.old = old; - } - CanvasExtraState.prototype = { - clone: function CanvasExtraState_clone() { - return Object.create(this); - }, - setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) { - this.x = x; - this.y = y; - } - }; - return CanvasExtraState; -}(); -var CanvasGraphics = function CanvasGraphicsClosure() { - var EXECUTION_TIME = 15; - var EXECUTION_STEPS = 10; - function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) { - this.ctx = canvasCtx; - this.current = new CanvasExtraState(); - this.stateStack = []; - this.pendingClip = null; - this.pendingEOFill = false; - this.res = null; - this.xobjs = null; - this.commonObjs = commonObjs; - this.objs = objs; - this.canvasFactory = canvasFactory; - this.imageLayer = imageLayer; - this.groupStack = []; - this.processingType3 = null; - this.baseTransform = null; - this.baseTransformStack = []; - this.groupLevel = 0; - this.smaskStack = []; - this.smaskCounter = 0; - this.tempSMask = null; - this.cachedCanvases = new CachedCanvases(this.canvasFactory); - if (canvasCtx) { - addContextCurrentTransform(canvasCtx); - } - this.cachedGetSinglePixelWidth = null; - } - function putBinaryImageData(ctx, imgData) { - if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) { - ctx.putImageData(imgData, 0, 0); - return; - } - var height = imgData.height, - width = imgData.width; - var partialChunkHeight = height % FULL_CHUNK_HEIGHT; - var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; - var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; - var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); - var srcPos = 0, - destPos; - var src = imgData.data; - var dest = chunkImgData.data; - var i, j, thisChunkHeight, elemsInThisChunk; - if (imgData.kind === ImageKind.GRAYSCALE_1BPP) { - var srcLength = src.byteLength; - var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest); - var dest32DataLength = dest32.length; - var fullSrcDiff = width + 7 >> 3; - var white = 0xFFFFFFFF; - var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF; - for (i = 0; i < totalChunks; i++) { - thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight; - destPos = 0; - for (j = 0; j < thisChunkHeight; j++) { - var srcDiff = srcLength - srcPos; - var k = 0; - var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7; - var kEndUnrolled = kEnd & ~7; - var mask = 0; - var srcByte = 0; - for (; k < kEndUnrolled; k += 8) { - srcByte = src[srcPos++]; - dest32[destPos++] = srcByte & 128 ? white : black; - dest32[destPos++] = srcByte & 64 ? white : black; - dest32[destPos++] = srcByte & 32 ? white : black; - dest32[destPos++] = srcByte & 16 ? white : black; - dest32[destPos++] = srcByte & 8 ? white : black; - dest32[destPos++] = srcByte & 4 ? white : black; - dest32[destPos++] = srcByte & 2 ? white : black; - dest32[destPos++] = srcByte & 1 ? white : black; - } - for (; k < kEnd; k++) { - if (mask === 0) { - srcByte = src[srcPos++]; - mask = 128; - } - dest32[destPos++] = srcByte & mask ? white : black; - mask >>= 1; - } - } - while (destPos < dest32DataLength) { - dest32[destPos++] = 0; - } - ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); - } - } else if (imgData.kind === ImageKind.RGBA_32BPP) { - j = 0; - elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4; - for (i = 0; i < fullChunks; i++) { - dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); - srcPos += elemsInThisChunk; - ctx.putImageData(chunkImgData, 0, j); - j += FULL_CHUNK_HEIGHT; - } - if (i < totalChunks) { - elemsInThisChunk = width * partialChunkHeight * 4; - dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); - ctx.putImageData(chunkImgData, 0, j); - } - } else if (imgData.kind === ImageKind.RGB_24BPP) { - thisChunkHeight = FULL_CHUNK_HEIGHT; - elemsInThisChunk = width * thisChunkHeight; - for (i = 0; i < totalChunks; i++) { - if (i >= fullChunks) { - thisChunkHeight = partialChunkHeight; - elemsInThisChunk = width * thisChunkHeight; - } - destPos = 0; - for (j = elemsInThisChunk; j--;) { - dest[destPos++] = src[srcPos++]; - dest[destPos++] = src[srcPos++]; - dest[destPos++] = src[srcPos++]; - dest[destPos++] = 255; - } - ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); - } - } else { - error('bad image kind: ' + imgData.kind); - } - } - function putBinaryImageMask(ctx, imgData) { - var height = imgData.height, - width = imgData.width; - var partialChunkHeight = height % FULL_CHUNK_HEIGHT; - var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; - var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; - var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); - var srcPos = 0; - var src = imgData.data; - var dest = chunkImgData.data; - for (var i = 0; i < totalChunks; i++) { - var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight; - var destPos = 3; - for (var j = 0; j < thisChunkHeight; j++) { - var mask = 0; - for (var k = 0; k < width; k++) { - if (!mask) { - var elem = src[srcPos++]; - mask = 128; - } - dest[destPos] = elem & mask ? 0 : 255; - destPos += 4; - mask >>= 1; - } - } - ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); - } - } - function copyCtxState(sourceCtx, destCtx) { - var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font']; - for (var i = 0, ii = properties.length; i < ii; i++) { - var property = properties[i]; - if (sourceCtx[property] !== undefined) { - destCtx[property] = sourceCtx[property]; - } - } - if (sourceCtx.setLineDash !== undefined) { - destCtx.setLineDash(sourceCtx.getLineDash()); - destCtx.lineDashOffset = sourceCtx.lineDashOffset; - } - } - function composeSMaskBackdrop(bytes, r0, g0, b0) { - var length = bytes.length; - for (var i = 3; i < length; i += 4) { - var alpha = bytes[i]; - if (alpha === 0) { - bytes[i - 3] = r0; - bytes[i - 2] = g0; - bytes[i - 1] = b0; - } else if (alpha < 255) { - var alpha_ = 255 - alpha; - bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8; - bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8; - bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8; - } - } - } - function composeSMaskAlpha(maskData, layerData, transferMap) { - var length = maskData.length; - var scale = 1 / 255; - for (var i = 3; i < length; i += 4) { - var alpha = transferMap ? transferMap[maskData[i]] : maskData[i]; - layerData[i] = layerData[i] * alpha * scale | 0; - } - } - function composeSMaskLuminosity(maskData, layerData, transferMap) { - var length = maskData.length; - for (var i = 3; i < length; i += 4) { - var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28; - layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16; - } - } - function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) { - var hasBackdrop = !!backdrop; - var r0 = hasBackdrop ? backdrop[0] : 0; - var g0 = hasBackdrop ? backdrop[1] : 0; - var b0 = hasBackdrop ? backdrop[2] : 0; - var composeFn; - if (subtype === 'Luminosity') { - composeFn = composeSMaskLuminosity; - } else { - composeFn = composeSMaskAlpha; - } - var PIXELS_TO_PROCESS = 1048576; - var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width)); - for (var row = 0; row < height; row += chunkSize) { - var chunkHeight = Math.min(chunkSize, height - row); - var maskData = maskCtx.getImageData(0, row, width, chunkHeight); - var layerData = layerCtx.getImageData(0, row, width, chunkHeight); - if (hasBackdrop) { - composeSMaskBackdrop(maskData.data, r0, g0, b0); - } - composeFn(maskData.data, layerData.data, transferMap); - maskCtx.putImageData(layerData, 0, row); - } - } - function composeSMask(ctx, smask, layerCtx) { - var mask = smask.canvas; - var maskCtx = smask.context; - ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY); - var backdrop = smask.backdrop || null; - if (!smask.transferMap && WebGLUtils.isEnabled) { - var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, { - subtype: smask.subtype, - backdrop: backdrop - }); - ctx.setTransform(1, 0, 0, 1, 0, 0); - ctx.drawImage(composed, smask.offsetX, smask.offsetY); - return; - } - genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap); - ctx.drawImage(mask, 0, 0); - } - var LINE_CAP_STYLES = ['butt', 'round', 'square']; - var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; - var NORMAL_CLIP = {}; - var EO_CLIP = {}; - CanvasGraphics.prototype = { - beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) { - var width = this.ctx.canvas.width; - var height = this.ctx.canvas.height; - this.ctx.save(); - this.ctx.fillStyle = 'rgb(255, 255, 255)'; - this.ctx.fillRect(0, 0, width, height); - this.ctx.restore(); - if (transparency) { - var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true); - this.compositeCtx = this.ctx; - this.transparentCanvas = transparentCanvas.canvas; - this.ctx = transparentCanvas.context; - this.ctx.save(); - this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform); - } - this.ctx.save(); - if (transform) { - this.ctx.transform.apply(this.ctx, transform); - } - this.ctx.transform.apply(this.ctx, viewport.transform); - this.baseTransform = this.ctx.mozCurrentTransform.slice(); - if (this.imageLayer) { - this.imageLayer.beginLayout(); - } - }, - executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) { - var argsArray = operatorList.argsArray; - var fnArray = operatorList.fnArray; - var i = executionStartIdx || 0; - var argsArrayLen = argsArray.length; - if (argsArrayLen === i) { - return i; - } - var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function'; - var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0; - var steps = 0; - var commonObjs = this.commonObjs; - var objs = this.objs; - var fnId; - while (true) { - if (stepper !== undefined && i === stepper.nextBreakPoint) { - stepper.breakIt(i, continueCallback); - return i; - } - fnId = fnArray[i]; - if (fnId !== OPS.dependency) { - this[fnId].apply(this, argsArray[i]); - } else { - var deps = argsArray[i]; - for (var n = 0, nn = deps.length; n < nn; n++) { - var depObjId = deps[n]; - var common = depObjId[0] === 'g' && depObjId[1] === '_'; - var objsPool = common ? commonObjs : objs; - if (!objsPool.isResolved(depObjId)) { - objsPool.get(depObjId, continueCallback); - return i; - } - } - } - i++; - if (i === argsArrayLen) { - return i; - } - if (chunkOperations && ++steps > EXECUTION_STEPS) { - if (Date.now() > endTime) { - continueCallback(); - return i; - } - steps = 0; - } - } - }, - endDrawing: function CanvasGraphics_endDrawing() { - if (this.current.activeSMask !== null) { - this.endSMaskGroup(); - } - this.ctx.restore(); - if (this.transparentCanvas) { - this.ctx = this.compositeCtx; - this.ctx.save(); - this.ctx.setTransform(1, 0, 0, 1, 0, 0); - this.ctx.drawImage(this.transparentCanvas, 0, 0); - this.ctx.restore(); - this.transparentCanvas = null; - } - this.cachedCanvases.clear(); - WebGLUtils.clear(); - if (this.imageLayer) { - this.imageLayer.endLayout(); - } - }, - setLineWidth: function CanvasGraphics_setLineWidth(width) { - this.current.lineWidth = width; - this.ctx.lineWidth = width; - }, - setLineCap: function CanvasGraphics_setLineCap(style) { - this.ctx.lineCap = LINE_CAP_STYLES[style]; - }, - setLineJoin: function CanvasGraphics_setLineJoin(style) { - this.ctx.lineJoin = LINE_JOIN_STYLES[style]; - }, - setMiterLimit: function CanvasGraphics_setMiterLimit(limit) { - this.ctx.miterLimit = limit; - }, - setDash: function CanvasGraphics_setDash(dashArray, dashPhase) { - var ctx = this.ctx; - if (ctx.setLineDash !== undefined) { - ctx.setLineDash(dashArray); - ctx.lineDashOffset = dashPhase; - } - }, - setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {}, - setFlatness: function CanvasGraphics_setFlatness(flatness) {}, - setGState: function CanvasGraphics_setGState(states) { - for (var i = 0, ii = states.length; i < ii; i++) { - var state = states[i]; - var key = state[0]; - var value = state[1]; - switch (key) { - case 'LW': - this.setLineWidth(value); - break; - case 'LC': - this.setLineCap(value); - break; - case 'LJ': - this.setLineJoin(value); - break; - case 'ML': - this.setMiterLimit(value); - break; - case 'D': - this.setDash(value[0], value[1]); - break; - case 'RI': - this.setRenderingIntent(value); - break; - case 'FL': - this.setFlatness(value); - break; - case 'Font': - this.setFont(value[0], value[1]); - break; - case 'CA': - this.current.strokeAlpha = state[1]; - break; - case 'ca': - this.current.fillAlpha = state[1]; - this.ctx.globalAlpha = state[1]; - break; - case 'BM': - if (value && value.name && value.name !== 'Normal') { - var mode = value.name.replace(/([A-Z])/g, function (c) { - return '-' + c.toLowerCase(); - }).substring(1); - this.ctx.globalCompositeOperation = mode; - if (this.ctx.globalCompositeOperation !== mode) { - warn('globalCompositeOperation "' + mode + '" is not supported'); - } - } else { - this.ctx.globalCompositeOperation = 'source-over'; - } - break; - case 'SMask': - if (this.current.activeSMask) { - if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) { - this.suspendSMaskGroup(); - } else { - this.endSMaskGroup(); - } - } - this.current.activeSMask = value ? this.tempSMask : null; - if (this.current.activeSMask) { - this.beginSMaskGroup(); - } - this.tempSMask = null; - break; - } - } - }, - beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() { - var activeSMask = this.current.activeSMask; - var drawnWidth = activeSMask.canvas.width; - var drawnHeight = activeSMask.canvas.height; - var cacheId = 'smaskGroupAt' + this.groupLevel; - var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true); - var currentCtx = this.ctx; - var currentTransform = currentCtx.mozCurrentTransform; - this.ctx.save(); - var groupCtx = scratchCanvas.context; - groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY); - groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY); - groupCtx.transform.apply(groupCtx, currentTransform); - activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse; - copyCtxState(currentCtx, groupCtx); - this.ctx = groupCtx; - this.setGState([['BM', 'Normal'], ['ca', 1], ['CA', 1]]); - this.groupStack.push(currentCtx); - this.groupLevel++; - }, - suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() { - var groupCtx = this.ctx; - this.groupLevel--; - this.ctx = this.groupStack.pop(); - composeSMask(this.ctx, this.current.activeSMask, groupCtx); - this.ctx.restore(); - this.ctx.save(); - copyCtxState(groupCtx, this.ctx); - this.current.resumeSMaskCtx = groupCtx; - var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform); - this.ctx.transform.apply(this.ctx, deltaTransform); - groupCtx.save(); - groupCtx.setTransform(1, 0, 0, 1, 0, 0); - groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height); - groupCtx.restore(); - }, - resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() { - var groupCtx = this.current.resumeSMaskCtx; - var currentCtx = this.ctx; - this.ctx = groupCtx; - this.groupStack.push(currentCtx); - this.groupLevel++; - }, - endSMaskGroup: function CanvasGraphics_endSMaskGroup() { - var groupCtx = this.ctx; - this.groupLevel--; - this.ctx = this.groupStack.pop(); - composeSMask(this.ctx, this.current.activeSMask, groupCtx); - this.ctx.restore(); - copyCtxState(groupCtx, this.ctx); - var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform); - this.ctx.transform.apply(this.ctx, deltaTransform); - }, - save: function CanvasGraphics_save() { - this.ctx.save(); - var old = this.current; - this.stateStack.push(old); - this.current = old.clone(); - this.current.resumeSMaskCtx = null; - }, - restore: function CanvasGraphics_restore() { - if (this.current.resumeSMaskCtx) { - this.resumeSMaskGroup(); - } - if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) { - this.endSMaskGroup(); - } - if (this.stateStack.length !== 0) { - this.current = this.stateStack.pop(); - this.ctx.restore(); - this.pendingClip = null; - this.cachedGetSinglePixelWidth = null; - } - }, - transform: function CanvasGraphics_transform(a, b, c, d, e, f) { - this.ctx.transform(a, b, c, d, e, f); - this.cachedGetSinglePixelWidth = null; - }, - constructPath: function CanvasGraphics_constructPath(ops, args) { - var ctx = this.ctx; - var current = this.current; - var x = current.x, - y = current.y; - for (var i = 0, j = 0, ii = ops.length; i < ii; i++) { - switch (ops[i] | 0) { - case OPS.rectangle: - x = args[j++]; - y = args[j++]; - var width = args[j++]; - var height = args[j++]; - if (width === 0) { - width = this.getSinglePixelWidth(); - } - if (height === 0) { - height = this.getSinglePixelWidth(); - } - var xw = x + width; - var yh = y + height; - this.ctx.moveTo(x, y); - this.ctx.lineTo(xw, y); - this.ctx.lineTo(xw, yh); - this.ctx.lineTo(x, yh); - this.ctx.lineTo(x, y); - this.ctx.closePath(); - break; - case OPS.moveTo: - x = args[j++]; - y = args[j++]; - ctx.moveTo(x, y); - break; - case OPS.lineTo: - x = args[j++]; - y = args[j++]; - ctx.lineTo(x, y); - break; - case OPS.curveTo: - x = args[j + 4]; - y = args[j + 5]; - ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y); - j += 6; - break; - case OPS.curveTo2: - ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]); - x = args[j + 2]; - y = args[j + 3]; - j += 4; - break; - case OPS.curveTo3: - x = args[j + 2]; - y = args[j + 3]; - ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y); - j += 4; - break; - case OPS.closePath: - ctx.closePath(); - break; - } - } - current.setCurrentPoint(x, y); - }, - closePath: function CanvasGraphics_closePath() { - this.ctx.closePath(); - }, - stroke: function CanvasGraphics_stroke(consumePath) { - consumePath = typeof consumePath !== 'undefined' ? consumePath : true; - var ctx = this.ctx; - var strokeColor = this.current.strokeColor; - ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth); - ctx.globalAlpha = this.current.strokeAlpha; - if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') { - ctx.save(); - ctx.strokeStyle = strokeColor.getPattern(ctx, this); - ctx.stroke(); - ctx.restore(); - } else { - ctx.stroke(); - } - if (consumePath) { - this.consumePath(); - } - ctx.globalAlpha = this.current.fillAlpha; - }, - closeStroke: function CanvasGraphics_closeStroke() { - this.closePath(); - this.stroke(); - }, - fill: function CanvasGraphics_fill(consumePath) { - consumePath = typeof consumePath !== 'undefined' ? consumePath : true; - var ctx = this.ctx; - var fillColor = this.current.fillColor; - var isPatternFill = this.current.patternFill; - var needRestore = false; - if (isPatternFill) { - ctx.save(); - if (this.baseTransform) { - ctx.setTransform.apply(ctx, this.baseTransform); - } - ctx.fillStyle = fillColor.getPattern(ctx, this); - needRestore = true; - } - if (this.pendingEOFill) { - ctx.fill('evenodd'); - this.pendingEOFill = false; - } else { - ctx.fill(); - } - if (needRestore) { - ctx.restore(); - } - if (consumePath) { - this.consumePath(); - } - }, - eoFill: function CanvasGraphics_eoFill() { - this.pendingEOFill = true; - this.fill(); - }, - fillStroke: function CanvasGraphics_fillStroke() { - this.fill(false); - this.stroke(false); - this.consumePath(); - }, - eoFillStroke: function CanvasGraphics_eoFillStroke() { - this.pendingEOFill = true; - this.fillStroke(); - }, - closeFillStroke: function CanvasGraphics_closeFillStroke() { - this.closePath(); - this.fillStroke(); - }, - closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() { - this.pendingEOFill = true; - this.closePath(); - this.fillStroke(); - }, - endPath: function CanvasGraphics_endPath() { - this.consumePath(); - }, - clip: function CanvasGraphics_clip() { - this.pendingClip = NORMAL_CLIP; - }, - eoClip: function CanvasGraphics_eoClip() { - this.pendingClip = EO_CLIP; - }, - beginText: function CanvasGraphics_beginText() { - this.current.textMatrix = IDENTITY_MATRIX; - this.current.textMatrixScale = 1; - this.current.x = this.current.lineX = 0; - this.current.y = this.current.lineY = 0; - }, - endText: function CanvasGraphics_endText() { - var paths = this.pendingTextPaths; - var ctx = this.ctx; - if (paths === undefined) { - ctx.beginPath(); - return; - } - ctx.save(); - ctx.beginPath(); - for (var i = 0; i < paths.length; i++) { - var path = paths[i]; - ctx.setTransform.apply(ctx, path.transform); - ctx.translate(path.x, path.y); - path.addToPath(ctx, path.fontSize); - } - ctx.restore(); - ctx.clip(); - ctx.beginPath(); - delete this.pendingTextPaths; - }, - setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) { - this.current.charSpacing = spacing; - }, - setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) { - this.current.wordSpacing = spacing; - }, - setHScale: function CanvasGraphics_setHScale(scale) { - this.current.textHScale = scale / 100; - }, - setLeading: function CanvasGraphics_setLeading(leading) { - this.current.leading = -leading; - }, - setFont: function CanvasGraphics_setFont(fontRefName, size) { - var fontObj = this.commonObjs.get(fontRefName); - var current = this.current; - if (!fontObj) { - error('Can\'t find font for ' + fontRefName); - } - current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX; - if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) { - warn('Invalid font matrix for font ' + fontRefName); - } - if (size < 0) { - size = -size; - current.fontDirection = -1; - } else { - current.fontDirection = 1; - } - this.current.font = fontObj; - this.current.fontSize = size; - if (fontObj.isType3Font) { - return; - } - var name = fontObj.loadedName || 'sans-serif'; - var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal'; - var italic = fontObj.italic ? 'italic' : 'normal'; - var typeface = '"' + name + '", ' + fontObj.fallbackName; - var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size; - this.current.fontSizeScale = size / browserFontSize; - var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; - this.ctx.font = rule; - }, - setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) { - this.current.textRenderingMode = mode; - }, - setTextRise: function CanvasGraphics_setTextRise(rise) { - this.current.textRise = rise; - }, - moveText: function CanvasGraphics_moveText(x, y) { - this.current.x = this.current.lineX += x; - this.current.y = this.current.lineY += y; - }, - setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) { - this.setLeading(-y); - this.moveText(x, y); - }, - setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) { - this.current.textMatrix = [a, b, c, d, e, f]; - this.current.textMatrixScale = Math.sqrt(a * a + b * b); - this.current.x = this.current.lineX = 0; - this.current.y = this.current.lineY = 0; - }, - nextLine: function CanvasGraphics_nextLine() { - this.moveText(0, this.current.leading); - }, - paintChar: function CanvasGraphics_paintChar(character, x, y) { - var ctx = this.ctx; - var current = this.current; - var font = current.font; - var textRenderingMode = current.textRenderingMode; - var fontSize = current.fontSize / current.fontSizeScale; - var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK; - var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG); - var addToPath; - if (font.disableFontFace || isAddToPathSet) { - addToPath = font.getPathGenerator(this.commonObjs, character); - } - if (font.disableFontFace) { - ctx.save(); - ctx.translate(x, y); - ctx.beginPath(); - addToPath(ctx, fontSize); - if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) { - ctx.fill(); - } - if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) { - ctx.stroke(); - } - ctx.restore(); - } else { - if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) { - ctx.fillText(character, x, y); - } - if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) { - ctx.strokeText(character, x, y); - } - } - if (isAddToPathSet) { - var paths = this.pendingTextPaths || (this.pendingTextPaths = []); - paths.push({ - transform: ctx.mozCurrentTransform, - x: x, - y: y, - fontSize: fontSize, - addToPath: addToPath - }); - } - }, - get isFontSubpixelAAEnabled() { - var ctx = this.canvasFactory.create(10, 10).context; - ctx.scale(1.5, 1); - ctx.fillText('I', 0, 10); - var data = ctx.getImageData(0, 0, 10, 10).data; - var enabled = false; - for (var i = 3; i < data.length; i += 4) { - if (data[i] > 0 && data[i] < 255) { - enabled = true; - break; - } - } - return shadow(this, 'isFontSubpixelAAEnabled', enabled); - }, - showText: function CanvasGraphics_showText(glyphs) { - var current = this.current; - var font = current.font; - if (font.isType3Font) { - return this.showType3Text(glyphs); - } - var fontSize = current.fontSize; - if (fontSize === 0) { - return; - } - var ctx = this.ctx; - var fontSizeScale = current.fontSizeScale; - var charSpacing = current.charSpacing; - var wordSpacing = current.wordSpacing; - var fontDirection = current.fontDirection; - var textHScale = current.textHScale * fontDirection; - var glyphsLength = glyphs.length; - var vertical = font.vertical; - var spacingDir = vertical ? 1 : -1; - var defaultVMetrics = font.defaultVMetrics; - var widthAdvanceScale = fontSize * current.fontMatrix[0]; - var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace; - ctx.save(); - ctx.transform.apply(ctx, current.textMatrix); - ctx.translate(current.x, current.y + current.textRise); - if (current.patternFill) { - ctx.fillStyle = current.fillColor.getPattern(ctx, this); - } - if (fontDirection > 0) { - ctx.scale(textHScale, -1); - } else { - ctx.scale(textHScale, 1); - } - var lineWidth = current.lineWidth; - var scale = current.textMatrixScale; - if (scale === 0 || lineWidth === 0) { - var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK; - if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) { - this.cachedGetSinglePixelWidth = null; - lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR; - } - } else { - lineWidth /= scale; - } - if (fontSizeScale !== 1.0) { - ctx.scale(fontSizeScale, fontSizeScale); - lineWidth /= fontSizeScale; - } - ctx.lineWidth = lineWidth; - var x = 0, - i; - for (i = 0; i < glyphsLength; ++i) { - var glyph = glyphs[i]; - if (isNum(glyph)) { - x += spacingDir * glyph * fontSize / 1000; - continue; - } - var restoreNeeded = false; - var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; - var character = glyph.fontChar; - var accent = glyph.accent; - var scaledX, scaledY, scaledAccentX, scaledAccentY; - var width = glyph.width; - if (vertical) { - var vmetric, vx, vy; - vmetric = glyph.vmetric || defaultVMetrics; - vx = glyph.vmetric ? vmetric[1] : width * 0.5; - vx = -vx * widthAdvanceScale; - vy = vmetric[2] * widthAdvanceScale; - width = vmetric ? -vmetric[0] : width; - scaledX = vx / fontSizeScale; - scaledY = (x + vy) / fontSizeScale; - } else { - scaledX = x / fontSizeScale; - scaledY = 0; - } - if (font.remeasure && width > 0) { - var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale; - if (width < measuredWidth && this.isFontSubpixelAAEnabled) { - var characterScaleX = width / measuredWidth; - restoreNeeded = true; - ctx.save(); - ctx.scale(characterScaleX, 1); - scaledX /= characterScaleX; - } else if (width !== measuredWidth) { - scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale; - } - } - if (glyph.isInFont || font.missingFile) { - if (simpleFillText && !accent) { - ctx.fillText(character, scaledX, scaledY); - } else { - this.paintChar(character, scaledX, scaledY); - if (accent) { - scaledAccentX = scaledX + accent.offset.x / fontSizeScale; - scaledAccentY = scaledY - accent.offset.y / fontSizeScale; - this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY); - } - } - } - var charWidth = width * widthAdvanceScale + spacing * fontDirection; - x += charWidth; - if (restoreNeeded) { - ctx.restore(); - } - } - if (vertical) { - current.y -= x * textHScale; - } else { - current.x += x * textHScale; - } - ctx.restore(); - }, - showType3Text: function CanvasGraphics_showType3Text(glyphs) { - var ctx = this.ctx; - var current = this.current; - var font = current.font; - var fontSize = current.fontSize; - var fontDirection = current.fontDirection; - var spacingDir = font.vertical ? 1 : -1; - var charSpacing = current.charSpacing; - var wordSpacing = current.wordSpacing; - var textHScale = current.textHScale * fontDirection; - var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX; - var glyphsLength = glyphs.length; - var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE; - var i, glyph, width, spacingLength; - if (isTextInvisible || fontSize === 0) { - return; - } - this.cachedGetSinglePixelWidth = null; - ctx.save(); - ctx.transform.apply(ctx, current.textMatrix); - ctx.translate(current.x, current.y); - ctx.scale(textHScale, fontDirection); - for (i = 0; i < glyphsLength; ++i) { - glyph = glyphs[i]; - if (isNum(glyph)) { - spacingLength = spacingDir * glyph * fontSize / 1000; - this.ctx.translate(spacingLength, 0); - current.x += spacingLength * textHScale; - continue; - } - var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; - var operatorList = font.charProcOperatorList[glyph.operatorListId]; - if (!operatorList) { - warn('Type3 character \"' + glyph.operatorListId + '\" is not available'); - continue; - } - this.processingType3 = glyph; - this.save(); - ctx.scale(fontSize, fontSize); - ctx.transform.apply(ctx, fontMatrix); - this.executeOperatorList(operatorList); - this.restore(); - var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); - width = transformed[0] * fontSize + spacing; - ctx.translate(width, 0); - current.x += width * textHScale; - } - ctx.restore(); - this.processingType3 = null; - }, - setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {}, - setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) { - this.ctx.rect(llx, lly, urx - llx, ury - lly); - this.clip(); - this.endPath(); - }, - getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) { - var pattern; - if (IR[0] === 'TilingPattern') { - var color = IR[1]; - var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice(); - var self = this; - var canvasGraphicsFactory = { - createCanvasGraphics: function (ctx) { - return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory); - } - }; - pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform); - } else { - pattern = getShadingPatternFromIR(IR); - } - return pattern; - }, - setStrokeColorN: function CanvasGraphics_setStrokeColorN() { - this.current.strokeColor = this.getColorN_Pattern(arguments); - }, - setFillColorN: function CanvasGraphics_setFillColorN() { - this.current.fillColor = this.getColorN_Pattern(arguments); - this.current.patternFill = true; - }, - setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { - var color = Util.makeCssRgb(r, g, b); - this.ctx.strokeStyle = color; - this.current.strokeColor = color; - }, - setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { - var color = Util.makeCssRgb(r, g, b); - this.ctx.fillStyle = color; - this.current.fillColor = color; - this.current.patternFill = false; - }, - shadingFill: function CanvasGraphics_shadingFill(patternIR) { - var ctx = this.ctx; - this.save(); - var pattern = getShadingPatternFromIR(patternIR); - ctx.fillStyle = pattern.getPattern(ctx, this, true); - var inv = ctx.mozCurrentTransformInverse; - if (inv) { - var canvas = ctx.canvas; - var width = canvas.width; - var height = canvas.height; - var bl = Util.applyTransform([0, 0], inv); - var br = Util.applyTransform([0, height], inv); - var ul = Util.applyTransform([width, 0], inv); - var ur = Util.applyTransform([width, height], inv); - var x0 = Math.min(bl[0], br[0], ul[0], ur[0]); - var y0 = Math.min(bl[1], br[1], ul[1], ur[1]); - var x1 = Math.max(bl[0], br[0], ul[0], ur[0]); - var y1 = Math.max(bl[1], br[1], ul[1], ur[1]); - this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0); - } else { - this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10); - } - this.restore(); - }, - beginInlineImage: function CanvasGraphics_beginInlineImage() { - error('Should not call beginInlineImage'); - }, - beginImageData: function CanvasGraphics_beginImageData() { - error('Should not call beginImageData'); - }, - paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) { - this.save(); - this.baseTransformStack.push(this.baseTransform); - if (isArray(matrix) && matrix.length === 6) { - this.transform.apply(this, matrix); - } - this.baseTransform = this.ctx.mozCurrentTransform; - if (isArray(bbox) && bbox.length === 4) { - var width = bbox[2] - bbox[0]; - var height = bbox[3] - bbox[1]; - this.ctx.rect(bbox[0], bbox[1], width, height); - this.clip(); - this.endPath(); - } - }, - paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() { - this.restore(); - this.baseTransform = this.baseTransformStack.pop(); - }, - beginGroup: function CanvasGraphics_beginGroup(group) { - this.save(); - var currentCtx = this.ctx; - if (!group.isolated) { - info('TODO: Support non-isolated groups.'); - } - if (group.knockout) { - warn('Knockout groups not supported.'); - } - var currentTransform = currentCtx.mozCurrentTransform; - if (group.matrix) { - currentCtx.transform.apply(currentCtx, group.matrix); - } - assert(group.bbox, 'Bounding box is required.'); - var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform); - var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height]; - bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0]; - var offsetX = Math.floor(bounds[0]); - var offsetY = Math.floor(bounds[1]); - var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1); - var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1); - var scaleX = 1, - scaleY = 1; - if (drawnWidth > MAX_GROUP_SIZE) { - scaleX = drawnWidth / MAX_GROUP_SIZE; - drawnWidth = MAX_GROUP_SIZE; - } - if (drawnHeight > MAX_GROUP_SIZE) { - scaleY = drawnHeight / MAX_GROUP_SIZE; - drawnHeight = MAX_GROUP_SIZE; - } - var cacheId = 'groupAt' + this.groupLevel; - if (group.smask) { - cacheId += '_smask_' + this.smaskCounter++ % 2; - } - var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true); - var groupCtx = scratchCanvas.context; - groupCtx.scale(1 / scaleX, 1 / scaleY); - groupCtx.translate(-offsetX, -offsetY); - groupCtx.transform.apply(groupCtx, currentTransform); - if (group.smask) { - this.smaskStack.push({ - canvas: scratchCanvas.canvas, - context: groupCtx, - offsetX: offsetX, - offsetY: offsetY, - scaleX: scaleX, - scaleY: scaleY, - subtype: group.smask.subtype, - backdrop: group.smask.backdrop, - transferMap: group.smask.transferMap || null, - startTransformInverse: null - }); - } else { - currentCtx.setTransform(1, 0, 0, 1, 0, 0); - currentCtx.translate(offsetX, offsetY); - currentCtx.scale(scaleX, scaleY); - } - copyCtxState(currentCtx, groupCtx); - this.ctx = groupCtx; - this.setGState([['BM', 'Normal'], ['ca', 1], ['CA', 1]]); - this.groupStack.push(currentCtx); - this.groupLevel++; - this.current.activeSMask = null; - }, - endGroup: function CanvasGraphics_endGroup(group) { - this.groupLevel--; - var groupCtx = this.ctx; - this.ctx = this.groupStack.pop(); - if (this.ctx.imageSmoothingEnabled !== undefined) { - this.ctx.imageSmoothingEnabled = false; - } else { - this.ctx.mozImageSmoothingEnabled = false; - } - if (group.smask) { - this.tempSMask = this.smaskStack.pop(); - } else { - this.ctx.drawImage(groupCtx.canvas, 0, 0); - } - this.restore(); - }, - beginAnnotations: function CanvasGraphics_beginAnnotations() { - this.save(); - this.current = new CanvasExtraState(); - if (this.baseTransform) { - this.ctx.setTransform.apply(this.ctx, this.baseTransform); - } - }, - endAnnotations: function CanvasGraphics_endAnnotations() { - this.restore(); - }, - beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) { - this.save(); - if (isArray(rect) && rect.length === 4) { - var width = rect[2] - rect[0]; - var height = rect[3] - rect[1]; - this.ctx.rect(rect[0], rect[1], width, height); - this.clip(); - this.endPath(); - } - this.transform.apply(this, transform); - this.transform.apply(this, matrix); - }, - endAnnotation: function CanvasGraphics_endAnnotation() { - this.restore(); - }, - paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) { - var domImage = this.objs.get(objId); - if (!domImage) { - warn('Dependent image isn\'t ready yet'); - return; - } - this.save(); - var ctx = this.ctx; - ctx.scale(1 / w, -1 / h); - ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h); - if (this.imageLayer) { - var currentTransform = ctx.mozCurrentTransformInverse; - var position = this.getCanvasPosition(0, 0); - this.imageLayer.appendImage({ - objId: objId, - left: position[0], - top: position[1], - width: w / currentTransform[0], - height: h / currentTransform[3] - }); - } - this.restore(); - }, - paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) { - var ctx = this.ctx; - var width = img.width, - height = img.height; - var fillColor = this.current.fillColor; - var isPatternFill = this.current.patternFill; - var glyph = this.processingType3; - if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) { - if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) { - glyph.compiled = compileType3Glyph({ - data: img.data, - width: width, - height: height - }); - } else { - glyph.compiled = null; - } - } - if (glyph && glyph.compiled) { - glyph.compiled(ctx); - return; - } - var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); - var maskCtx = maskCanvas.context; - maskCtx.save(); - putBinaryImageMask(maskCtx, img); - maskCtx.globalCompositeOperation = 'source-in'; - maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; - maskCtx.fillRect(0, 0, width, height); - maskCtx.restore(); - this.paintInlineImageXObject(maskCanvas.canvas); - }, - paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) { - var width = imgData.width; - var height = imgData.height; - var fillColor = this.current.fillColor; - var isPatternFill = this.current.patternFill; - var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); - var maskCtx = maskCanvas.context; - maskCtx.save(); - putBinaryImageMask(maskCtx, imgData); - maskCtx.globalCompositeOperation = 'source-in'; - maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; - maskCtx.fillRect(0, 0, width, height); - maskCtx.restore(); - var ctx = this.ctx; - for (var i = 0, ii = positions.length; i < ii; i += 2) { - ctx.save(); - ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]); - ctx.scale(1, -1); - ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1); - ctx.restore(); - } - }, - paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) { - var ctx = this.ctx; - var fillColor = this.current.fillColor; - var isPatternFill = this.current.patternFill; - for (var i = 0, ii = images.length; i < ii; i++) { - var image = images[i]; - var width = image.width, - height = image.height; - var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); - var maskCtx = maskCanvas.context; - maskCtx.save(); - putBinaryImageMask(maskCtx, image); - maskCtx.globalCompositeOperation = 'source-in'; - maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; - maskCtx.fillRect(0, 0, width, height); - maskCtx.restore(); - ctx.save(); - ctx.transform.apply(ctx, image.transform); - ctx.scale(1, -1); - ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1); - ctx.restore(); - } - }, - paintImageXObject: function CanvasGraphics_paintImageXObject(objId) { - var imgData = this.objs.get(objId); - if (!imgData) { - warn('Dependent image isn\'t ready yet'); - return; - } - this.paintInlineImageXObject(imgData); - }, - paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) { - var imgData = this.objs.get(objId); - if (!imgData) { - warn('Dependent image isn\'t ready yet'); - return; - } - var width = imgData.width; - var height = imgData.height; - var map = []; - for (var i = 0, ii = positions.length; i < ii; i += 2) { - map.push({ - transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]], - x: 0, - y: 0, - w: width, - h: height - }); - } - this.paintInlineImageXObjectGroup(imgData, map); - }, - paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) { - var width = imgData.width; - var height = imgData.height; - var ctx = this.ctx; - this.save(); - ctx.scale(1 / width, -1 / height); - var currentTransform = ctx.mozCurrentTransformInverse; - var a = currentTransform[0], - b = currentTransform[1]; - var widthScale = Math.max(Math.sqrt(a * a + b * b), 1); - var c = currentTransform[2], - d = currentTransform[3]; - var heightScale = Math.max(Math.sqrt(c * c + d * d), 1); - var imgToPaint, tmpCanvas; - if (imgData instanceof HTMLElement || !imgData.data) { - imgToPaint = imgData; - } else { - tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height); - var tmpCtx = tmpCanvas.context; - putBinaryImageData(tmpCtx, imgData); - imgToPaint = tmpCanvas.canvas; - } - var paintWidth = width, - paintHeight = height; - var tmpCanvasId = 'prescale1'; - while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) { - var newWidth = paintWidth, - newHeight = paintHeight; - if (widthScale > 2 && paintWidth > 1) { - newWidth = Math.ceil(paintWidth / 2); - widthScale /= paintWidth / newWidth; - } - if (heightScale > 2 && paintHeight > 1) { - newHeight = Math.ceil(paintHeight / 2); - heightScale /= paintHeight / newHeight; - } - tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight); - tmpCtx = tmpCanvas.context; - tmpCtx.clearRect(0, 0, newWidth, newHeight); - tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight); - imgToPaint = tmpCanvas.canvas; - paintWidth = newWidth; - paintHeight = newHeight; - tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1'; - } - ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height); - if (this.imageLayer) { - var position = this.getCanvasPosition(0, -height); - this.imageLayer.appendImage({ - imgData: imgData, - left: position[0], - top: position[1], - width: width / currentTransform[0], - height: height / currentTransform[3] - }); - } - this.restore(); - }, - paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) { - var ctx = this.ctx; - var w = imgData.width; - var h = imgData.height; - var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h); - var tmpCtx = tmpCanvas.context; - putBinaryImageData(tmpCtx, imgData); - for (var i = 0, ii = map.length; i < ii; i++) { - var entry = map[i]; - ctx.save(); - ctx.transform.apply(ctx, entry.transform); - ctx.scale(1, -1); - ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1); - if (this.imageLayer) { - var position = this.getCanvasPosition(entry.x, entry.y); - this.imageLayer.appendImage({ - imgData: imgData, - left: position[0], - top: position[1], - width: w, - height: h - }); - } - ctx.restore(); - } - }, - paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() { - this.ctx.fillRect(0, 0, 1, 1); - }, - paintXObject: function CanvasGraphics_paintXObject() { - warn('Unsupported \'paintXObject\' command.'); - }, - markPoint: function CanvasGraphics_markPoint(tag) {}, - markPointProps: function CanvasGraphics_markPointProps(tag, properties) {}, - beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {}, - beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {}, - endMarkedContent: function CanvasGraphics_endMarkedContent() {}, - beginCompat: function CanvasGraphics_beginCompat() {}, - endCompat: function CanvasGraphics_endCompat() {}, - consumePath: function CanvasGraphics_consumePath() { - var ctx = this.ctx; - if (this.pendingClip) { - if (this.pendingClip === EO_CLIP) { - ctx.clip('evenodd'); - } else { - ctx.clip(); - } - this.pendingClip = null; - } - ctx.beginPath(); - }, - getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) { - if (this.cachedGetSinglePixelWidth === null) { - this.ctx.save(); - var inverse = this.ctx.mozCurrentTransformInverse; - this.ctx.restore(); - this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3])); - } - return this.cachedGetSinglePixelWidth; - }, - getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { - var transform = this.ctx.mozCurrentTransform; - return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]]; - } - }; - for (var op in OPS) { - CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op]; - } - return CanvasGraphics; -}(); -exports.CanvasGraphics = CanvasGraphics; - -/***/ }), -/* 11 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var assert = sharedUtil.assert; -var bytesToString = sharedUtil.bytesToString; -var string32 = sharedUtil.string32; -var shadow = sharedUtil.shadow; -var warn = sharedUtil.warn; -function FontLoader(docId) { - this.docId = docId; - this.styleElement = null; - this.nativeFontFaces = []; - this.loadTestFontId = 0; - this.loadingContext = { - requests: [], - nextRequestId: 0 - }; -} -FontLoader.prototype = { - insertRule: function fontLoaderInsertRule(rule) { - var styleElement = this.styleElement; - if (!styleElement) { - styleElement = this.styleElement = document.createElement('style'); - styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId; - document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement); - } - var styleSheet = styleElement.sheet; - styleSheet.insertRule(rule, styleSheet.cssRules.length); - }, - clear: function fontLoaderClear() { - if (this.styleElement) { - this.styleElement.remove(); - this.styleElement = null; - } - this.nativeFontFaces.forEach(function (nativeFontFace) { - document.fonts.delete(nativeFontFace); - }); - this.nativeFontFaces.length = 0; - } -}; -var getLoadTestFont = function () { - return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA=='); -}; -Object.defineProperty(FontLoader.prototype, 'loadTestFont', { - get: function () { - return shadow(this, 'loadTestFont', getLoadTestFont()); - }, - configurable: true -}); -FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) { - this.nativeFontFaces.push(nativeFontFace); - document.fonts.add(nativeFontFace); -}; -FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) { - var rules = []; - var fontsToLoad = []; - var fontLoadPromises = []; - var getNativeFontPromise = function (nativeFontFace) { - return nativeFontFace.loaded.catch(function (e) { - warn('Failed to load font "' + nativeFontFace.family + '": ' + e); - }); - }; - var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported; - for (var i = 0, ii = fonts.length; i < ii; i++) { - var font = fonts[i]; - if (font.attached || font.loading === false) { - continue; - } - font.attached = true; - if (isFontLoadingAPISupported) { - var nativeFontFace = font.createNativeFontFace(); - if (nativeFontFace) { - this.addNativeFontFace(nativeFontFace); - fontLoadPromises.push(getNativeFontPromise(nativeFontFace)); - } - } else { - var rule = font.createFontFaceRule(); - if (rule) { - this.insertRule(rule); - rules.push(rule); - fontsToLoad.push(font); - } - } - } - var request = this.queueLoadingCallback(callback); - if (isFontLoadingAPISupported) { - Promise.all(fontLoadPromises).then(function () { - request.complete(); - }); - } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) { - this.prepareFontLoadEvent(rules, fontsToLoad, request); - } else { - request.complete(); - } -}; -FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) { - function LoadLoader_completeRequest() { - assert(!request.end, 'completeRequest() cannot be called twice'); - request.end = Date.now(); - while (context.requests.length > 0 && context.requests[0].end) { - var otherRequest = context.requests.shift(); - setTimeout(otherRequest.callback, 0); - } - } - var context = this.loadingContext; - var requestId = 'pdfjs-font-loading-' + context.nextRequestId++; - var request = { - id: requestId, - complete: LoadLoader_completeRequest, - callback: callback, - started: Date.now() - }; - context.requests.push(request); - return request; -}; -FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) { - function int32(data, offset) { - return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff; - } - function spliceString(s, offset, remove, insert) { - var chunk1 = s.substr(0, offset); - var chunk2 = s.substr(offset + remove); - return chunk1 + insert + chunk2; - } - var i, ii; - var canvas = document.createElement('canvas'); - canvas.width = 1; - canvas.height = 1; - var ctx = canvas.getContext('2d'); - var called = 0; - function isFontReady(name, callback) { - called++; - if (called > 30) { - warn('Load test font never loaded.'); - callback(); - return; - } - ctx.font = '30px ' + name; - ctx.fillText('.', 0, 20); - var imageData = ctx.getImageData(0, 0, 1, 1); - if (imageData.data[3] > 0) { - callback(); - return; - } - setTimeout(isFontReady.bind(null, name, callback)); - } - var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++; - var data = this.loadTestFont; - var COMMENT_OFFSET = 976; - data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId); - var CFF_CHECKSUM_OFFSET = 16; - var XXXX_VALUE = 0x58585858; - var checksum = int32(data, CFF_CHECKSUM_OFFSET); - for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) { - checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0; - } - if (i < loadTestFontId.length) { - checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0; - } - data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum)); - var url = 'url(data:font/opentype;base64,' + btoa(data) + ');'; - var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}'; - this.insertRule(rule); - var names = []; - for (i = 0, ii = fonts.length; i < ii; i++) { - names.push(fonts[i].loadedName); - } - names.push(loadTestFontId); - var div = document.createElement('div'); - div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;'); - for (i = 0, ii = names.length; i < ii; ++i) { - var span = document.createElement('span'); - span.textContent = 'Hi'; - span.style.fontFamily = names[i]; - div.appendChild(span); - } - document.body.appendChild(div); - isFontReady(loadTestFontId, function () { - document.body.removeChild(div); - request.complete(); - }); -}; -FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts; -var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() { - if (typeof navigator === 'undefined') { - return true; - } - var supported = false; - var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent); - if (m && m[1] >= 14) { - supported = true; - } - return supported; -}; -Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', { - get: function () { - return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported()); - }, - enumerable: true, - configurable: true -}); -var IsEvalSupportedCached = { - get value() { - return shadow(this, 'value', sharedUtil.isEvalSupported()); - } -}; -var FontFaceObject = function FontFaceObjectClosure() { - function FontFaceObject(translatedData, options) { - this.compiledGlyphs = Object.create(null); - for (var i in translatedData) { - this[i] = translatedData[i]; - } - this.options = options; - } - FontFaceObject.prototype = { - createNativeFontFace: function FontFaceObject_createNativeFontFace() { - if (!this.data) { - return null; - } - if (this.options.disableFontFace) { - this.disableFontFace = true; - return null; - } - var nativeFontFace = new FontFace(this.loadedName, this.data, {}); - if (this.options.fontRegistry) { - this.options.fontRegistry.registerFont(this); - } - return nativeFontFace; - }, - createFontFaceRule: function FontFaceObject_createFontFaceRule() { - if (!this.data) { - return null; - } - if (this.options.disableFontFace) { - this.disableFontFace = true; - return null; - } - var data = bytesToString(new Uint8Array(this.data)); - var fontName = this.loadedName; - var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');'; - var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}'; - if (this.options.fontRegistry) { - this.options.fontRegistry.registerFont(this, url); - } - return rule; - }, - getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) { - if (!(character in this.compiledGlyphs)) { - var cmds = objs.get(this.loadedName + '_path_' + character); - var current, i, len; - if (this.options.isEvalSupported && IsEvalSupportedCached.value) { - var args, - js = ''; - for (i = 0, len = cmds.length; i < len; i++) { - current = cmds[i]; - if (current.args !== undefined) { - args = current.args.join(','); - } else { - args = ''; - } - js += 'c.' + current.cmd + '(' + args + ');\n'; - } - this.compiledGlyphs[character] = new Function('c', 'size', js); - } else { - this.compiledGlyphs[character] = function (c, size) { - for (i = 0, len = cmds.length; i < len; i++) { - current = cmds[i]; - if (current.cmd === 'scale') { - current.args = [size, -size]; - } - c[current.cmd].apply(c, current.args); - } - }; - } - } - return this.compiledGlyphs[character]; - } - }; - return FontFaceObject; -}(); -exports.FontFaceObject = FontFaceObject; -exports.FontLoader = FontLoader; - -/***/ }), -/* 12 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var sharedUtil = __w_pdfjs_require__(0); -var displayWebGL = __w_pdfjs_require__(8); -var Util = sharedUtil.Util; -var info = sharedUtil.info; -var isArray = sharedUtil.isArray; -var error = sharedUtil.error; -var WebGLUtils = displayWebGL.WebGLUtils; -var ShadingIRs = {}; -ShadingIRs.RadialAxial = { - fromIR: function RadialAxial_fromIR(raw) { - var type = raw[1]; - var colorStops = raw[2]; - var p0 = raw[3]; - var p1 = raw[4]; - var r0 = raw[5]; - var r1 = raw[6]; - return { - type: 'Pattern', - getPattern: function RadialAxial_getPattern(ctx) { - var grad; - if (type === 'axial') { - grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]); - } else if (type === 'radial') { - grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1); - } - for (var i = 0, ii = colorStops.length; i < ii; ++i) { - var c = colorStops[i]; - grad.addColorStop(c[0], c[1]); - } - return grad; - } - }; - } -}; -var createMeshCanvas = function createMeshCanvasClosure() { - function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) { - var coords = context.coords, - colors = context.colors; - var bytes = data.data, - rowSize = data.width * 4; - var tmp; - if (coords[p1 + 1] > coords[p2 + 1]) { - tmp = p1; - p1 = p2; - p2 = tmp; - tmp = c1; - c1 = c2; - c2 = tmp; - } - if (coords[p2 + 1] > coords[p3 + 1]) { - tmp = p2; - p2 = p3; - p3 = tmp; - tmp = c2; - c2 = c3; - c3 = tmp; - } - if (coords[p1 + 1] > coords[p2 + 1]) { - tmp = p1; - p1 = p2; - p2 = tmp; - tmp = c1; - c1 = c2; - c2 = tmp; - } - var x1 = (coords[p1] + context.offsetX) * context.scaleX; - var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY; - var x2 = (coords[p2] + context.offsetX) * context.scaleX; - var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY; - var x3 = (coords[p3] + context.offsetX) * context.scaleX; - var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY; - if (y1 >= y3) { - return; - } - var c1r = colors[c1], - c1g = colors[c1 + 1], - c1b = colors[c1 + 2]; - var c2r = colors[c2], - c2g = colors[c2 + 1], - c2b = colors[c2 + 2]; - var c3r = colors[c3], - c3g = colors[c3 + 1], - c3b = colors[c3 + 2]; - var minY = Math.round(y1), - maxY = Math.round(y3); - var xa, car, cag, cab; - var xb, cbr, cbg, cbb; - var k; - for (var y = minY; y <= maxY; y++) { - if (y < y2) { - k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2); - xa = x1 - (x1 - x2) * k; - car = c1r - (c1r - c2r) * k; - cag = c1g - (c1g - c2g) * k; - cab = c1b - (c1b - c2b) * k; - } else { - k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3); - xa = x2 - (x2 - x3) * k; - car = c2r - (c2r - c3r) * k; - cag = c2g - (c2g - c3g) * k; - cab = c2b - (c2b - c3b) * k; - } - k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3); - xb = x1 - (x1 - x3) * k; - cbr = c1r - (c1r - c3r) * k; - cbg = c1g - (c1g - c3g) * k; - cbb = c1b - (c1b - c3b) * k; - var x1_ = Math.round(Math.min(xa, xb)); - var x2_ = Math.round(Math.max(xa, xb)); - var j = rowSize * y + x1_ * 4; - for (var x = x1_; x <= x2_; x++) { - k = (xa - x) / (xa - xb); - k = k < 0 ? 0 : k > 1 ? 1 : k; - bytes[j++] = car - (car - cbr) * k | 0; - bytes[j++] = cag - (cag - cbg) * k | 0; - bytes[j++] = cab - (cab - cbb) * k | 0; - bytes[j++] = 255; - } - } - } - function drawFigure(data, figure, context) { - var ps = figure.coords; - var cs = figure.colors; - var i, ii; - switch (figure.type) { - case 'lattice': - var verticesPerRow = figure.verticesPerRow; - var rows = Math.floor(ps.length / verticesPerRow) - 1; - var cols = verticesPerRow - 1; - for (i = 0; i < rows; i++) { - var q = i * verticesPerRow; - for (var j = 0; j < cols; j++, q++) { - drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]); - drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]); - } - } - break; - case 'triangles': - for (i = 0, ii = ps.length; i < ii; i += 3) { - drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]); - } - break; - default: - error('illigal figure'); - break; - } - } - function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) { - var EXPECTED_SCALE = 1.1; - var MAX_PATTERN_SIZE = 3000; - var BORDER_SIZE = 2; - var offsetX = Math.floor(bounds[0]); - var offsetY = Math.floor(bounds[1]); - var boundsWidth = Math.ceil(bounds[2]) - offsetX; - var boundsHeight = Math.ceil(bounds[3]) - offsetY; - var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE); - var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE); - var scaleX = boundsWidth / width; - var scaleY = boundsHeight / height; - var context = { - coords: coords, - colors: colors, - offsetX: -offsetX, - offsetY: -offsetY, - scaleX: 1 / scaleX, - scaleY: 1 / scaleY - }; - var paddedWidth = width + BORDER_SIZE * 2; - var paddedHeight = height + BORDER_SIZE * 2; - var canvas, tmpCanvas, i, ii; - if (WebGLUtils.isEnabled) { - canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context); - tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false); - tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE); - canvas = tmpCanvas.canvas; - } else { - tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false); - var tmpCtx = tmpCanvas.context; - var data = tmpCtx.createImageData(width, height); - if (backgroundColor) { - var bytes = data.data; - for (i = 0, ii = bytes.length; i < ii; i += 4) { - bytes[i] = backgroundColor[0]; - bytes[i + 1] = backgroundColor[1]; - bytes[i + 2] = backgroundColor[2]; - bytes[i + 3] = 255; - } - } - for (i = 0; i < figures.length; i++) { - drawFigure(data, figures[i], context); - } - tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE); - canvas = tmpCanvas.canvas; - } - return { - canvas: canvas, - offsetX: offsetX - BORDER_SIZE * scaleX, - offsetY: offsetY - BORDER_SIZE * scaleY, - scaleX: scaleX, - scaleY: scaleY - }; - } - return createMeshCanvas; -}(); -ShadingIRs.Mesh = { - fromIR: function Mesh_fromIR(raw) { - var coords = raw[2]; - var colors = raw[3]; - var figures = raw[4]; - var bounds = raw[5]; - var matrix = raw[6]; - var background = raw[8]; - return { - type: 'Pattern', - getPattern: function Mesh_getPattern(ctx, owner, shadingFill) { - var scale; - if (shadingFill) { - scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform); - } else { - scale = Util.singularValueDecompose2dScale(owner.baseTransform); - if (matrix) { - var matrixScale = Util.singularValueDecompose2dScale(matrix); - scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]]; - } - } - var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases); - if (!shadingFill) { - ctx.setTransform.apply(ctx, owner.baseTransform); - if (matrix) { - ctx.transform.apply(ctx, matrix); - } - } - ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY); - ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY); - return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat'); - } - }; - } -}; -ShadingIRs.Dummy = { - fromIR: function Dummy_fromIR() { - return { - type: 'Pattern', - getPattern: function Dummy_fromIR_getPattern() { - return 'hotpink'; - } - }; - } -}; -function getShadingPatternFromIR(raw) { - var shadingIR = ShadingIRs[raw[0]]; - if (!shadingIR) { - error('Unknown IR type: ' + raw[0]); - } - return shadingIR.fromIR(raw); -} -var TilingPattern = function TilingPatternClosure() { - var PaintType = { - COLORED: 1, - UNCOLORED: 2 - }; - var MAX_PATTERN_SIZE = 3000; - function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) { - this.operatorList = IR[2]; - this.matrix = IR[3] || [1, 0, 0, 1, 0, 0]; - this.bbox = Util.normalizeRect(IR[4]); - this.xstep = IR[5]; - this.ystep = IR[6]; - this.paintType = IR[7]; - this.tilingType = IR[8]; - this.color = color; - this.canvasGraphicsFactory = canvasGraphicsFactory; - this.baseTransform = baseTransform; - this.type = 'Pattern'; - this.ctx = ctx; - } - TilingPattern.prototype = { - createPatternCanvas: function TilinPattern_createPatternCanvas(owner) { - var operatorList = this.operatorList; - var bbox = this.bbox; - var xstep = this.xstep; - var ystep = this.ystep; - var paintType = this.paintType; - var tilingType = this.tilingType; - var color = this.color; - var canvasGraphicsFactory = this.canvasGraphicsFactory; - info('TilingType: ' + tilingType); - var x0 = bbox[0], - y0 = bbox[1], - x1 = bbox[2], - y1 = bbox[3]; - var topLeft = [x0, y0]; - var botRight = [x0 + xstep, y0 + ystep]; - var width = botRight[0] - topLeft[0]; - var height = botRight[1] - topLeft[1]; - var matrixScale = Util.singularValueDecompose2dScale(this.matrix); - var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform); - var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]]; - width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE); - height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE); - var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true); - var tmpCtx = tmpCanvas.context; - var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx); - graphics.groupLevel = owner.groupLevel; - this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color); - this.setScale(width, height, xstep, ystep); - this.transformToScale(graphics); - var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]]; - graphics.transform.apply(graphics, tmpTranslate); - this.clipBbox(graphics, bbox, x0, y0, x1, y1); - graphics.executeOperatorList(operatorList); - return tmpCanvas.canvas; - }, - setScale: function TilingPattern_setScale(width, height, xstep, ystep) { - this.scale = [width / xstep, height / ystep]; - }, - transformToScale: function TilingPattern_transformToScale(graphics) { - var scale = this.scale; - var tmpScale = [scale[0], 0, 0, scale[1], 0, 0]; - graphics.transform.apply(graphics, tmpScale); - }, - scaleToContext: function TilingPattern_scaleToContext() { - var scale = this.scale; - this.ctx.scale(1 / scale[0], 1 / scale[1]); - }, - clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) { - if (isArray(bbox) && bbox.length === 4) { - var bboxWidth = x1 - x0; - var bboxHeight = y1 - y0; - graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight); - graphics.clip(); - graphics.endPath(); - } - }, - setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) { - switch (paintType) { - case PaintType.COLORED: - var ctx = this.ctx; - context.fillStyle = ctx.fillStyle; - context.strokeStyle = ctx.strokeStyle; - break; - case PaintType.UNCOLORED: - var cssColor = Util.makeCssRgb(color[0], color[1], color[2]); - context.fillStyle = cssColor; - context.strokeStyle = cssColor; - break; - default: - error('Unsupported paint type: ' + paintType); - } - }, - getPattern: function TilingPattern_getPattern(ctx, owner) { - var temporaryPatternCanvas = this.createPatternCanvas(owner); - ctx = this.ctx; - ctx.setTransform.apply(ctx, this.baseTransform); - ctx.transform.apply(ctx, this.matrix); - this.scaleToContext(); - return ctx.createPattern(temporaryPatternCanvas, 'repeat'); - } - }; - return TilingPattern; -}(); -exports.getShadingPatternFromIR = getShadingPatternFromIR; -exports.TilingPattern = TilingPattern; - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; - - -var pdfjsVersion = '1.8.172'; -var pdfjsBuild = '8ff1fbe7'; -var pdfjsSharedUtil = __w_pdfjs_require__(0); -var pdfjsDisplayGlobal = __w_pdfjs_require__(9); -var pdfjsDisplayAPI = __w_pdfjs_require__(3); -var pdfjsDisplayTextLayer = __w_pdfjs_require__(5); -var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(2); -var pdfjsDisplayDOMUtils = __w_pdfjs_require__(1); -var pdfjsDisplaySVG = __w_pdfjs_require__(4); -exports.PDFJS = pdfjsDisplayGlobal.PDFJS; -exports.build = pdfjsDisplayAPI.build; -exports.version = pdfjsDisplayAPI.version; -exports.getDocument = pdfjsDisplayAPI.getDocument; -exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport; -exports.PDFWorker = pdfjsDisplayAPI.PDFWorker; -exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer; -exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer; -exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle; -exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability; -exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses; -exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException; -exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException; -exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics; -exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException; -exports.OPS = pdfjsSharedUtil.OPS; -exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES; -exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl; -exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl; -exports.createObjectURL = pdfjsSharedUtil.createObjectURL; -exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters; -exports.shadow = pdfjsSharedUtil.shadow; -exports.createBlob = pdfjsSharedUtil.createBlob; -exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException; -exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl; -exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes; - -/***/ }), -/* 14 */ -/***/ (function(module, exports, __w_pdfjs_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function(global) { - -if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) { - var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : undefined; - var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || ''; - var isAndroid = /Android/.test(userAgent); - var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent); - var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent); - var isChrome = userAgent.indexOf('Chrom') >= 0; - var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent); - var isIOSChrome = userAgent.indexOf('CriOS') >= 0; - var isIE = userAgent.indexOf('Trident') >= 0; - var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent); - var isOpera = userAgent.indexOf('Opera') >= 0; - var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent); - var hasDOM = typeof window === 'object' && typeof document === 'object'; - if (typeof PDFJS === 'undefined') { - globalScope.PDFJS = {}; - } - PDFJS.compatibilityChecked = true; - (function checkTypedArrayCompatibility() { - if (typeof Uint8Array !== 'undefined') { - if (typeof Uint8Array.prototype.subarray === 'undefined') { - Uint8Array.prototype.subarray = function subarray(start, end) { - return new Uint8Array(this.slice(start, end)); - }; - Float32Array.prototype.subarray = function subarray(start, end) { - return new Float32Array(this.slice(start, end)); - }; - } - if (typeof Float64Array === 'undefined') { - globalScope.Float64Array = Float32Array; - } - return; - } - function subarray(start, end) { - return new TypedArray(this.slice(start, end)); - } - function setArrayOffset(array, offset) { - if (arguments.length < 2) { - offset = 0; - } - for (var i = 0, n = array.length; i < n; ++i, ++offset) { - this[offset] = array[i] & 0xFF; - } - } - function TypedArray(arg1) { - var result, i, n; - if (typeof arg1 === 'number') { - result = []; - for (i = 0; i < arg1; ++i) { - result[i] = 0; - } - } else if ('slice' in arg1) { - result = arg1.slice(0); - } else { - result = []; - for (i = 0, n = arg1.length; i < n; ++i) { - result[i] = arg1[i]; - } - } - result.subarray = subarray; - result.buffer = result; - result.byteLength = result.length; - result.set = setArrayOffset; - if (typeof arg1 === 'object' && arg1.buffer) { - result.buffer = arg1.buffer; - } - return result; - } - globalScope.Uint8Array = TypedArray; - globalScope.Int8Array = TypedArray; - globalScope.Uint32Array = TypedArray; - globalScope.Int32Array = TypedArray; - globalScope.Uint16Array = TypedArray; - globalScope.Float32Array = TypedArray; - globalScope.Float64Array = TypedArray; - })(); - (function normalizeURLObject() { - if (!globalScope.URL) { - globalScope.URL = globalScope.webkitURL; - } - })(); - (function checkObjectDefinePropertyCompatibility() { - if (typeof Object.defineProperty !== 'undefined') { - var definePropertyPossible = true; - try { - if (hasDOM) { - Object.defineProperty(new Image(), 'id', { value: 'test' }); - } - var Test = function Test() {}; - Test.prototype = { - get id() {} - }; - Object.defineProperty(new Test(), 'id', { - value: '', - configurable: true, - enumerable: true, - writable: false - }); - } catch (e) { - definePropertyPossible = false; - } - if (definePropertyPossible) { - return; - } - } - Object.defineProperty = function objectDefineProperty(obj, name, def) { - delete obj[name]; - if ('get' in def) { - obj.__defineGetter__(name, def['get']); - } - if ('set' in def) { - obj.__defineSetter__(name, def['set']); - } - if ('value' in def) { - obj.__defineSetter__(name, function objectDefinePropertySetter(value) { - this.__defineGetter__(name, function objectDefinePropertyGetter() { - return value; - }); - return value; - }); - obj[name] = def.value; - } - }; - })(); - (function checkXMLHttpRequestResponseCompatibility() { - if (typeof XMLHttpRequest === 'undefined') { - return; - } - var xhrPrototype = XMLHttpRequest.prototype; - var xhr = new XMLHttpRequest(); - if (!('overrideMimeType' in xhr)) { - Object.defineProperty(xhrPrototype, 'overrideMimeType', { - value: function xmlHttpRequestOverrideMimeType(mimeType) {} - }); - } - if ('responseType' in xhr) { - return; - } - Object.defineProperty(xhrPrototype, 'responseType', { - get: function xmlHttpRequestGetResponseType() { - return this._responseType || 'text'; - }, - set: function xmlHttpRequestSetResponseType(value) { - if (value === 'text' || value === 'arraybuffer') { - this._responseType = value; - if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') { - this.overrideMimeType('text/plain; charset=x-user-defined'); - } - } - } - }); - if (typeof VBArray !== 'undefined') { - Object.defineProperty(xhrPrototype, 'response', { - get: function xmlHttpRequestResponseGet() { - if (this.responseType === 'arraybuffer') { - return new Uint8Array(new VBArray(this.responseBody).toArray()); - } - return this.responseText; - } - }); - return; - } - Object.defineProperty(xhrPrototype, 'response', { - get: function xmlHttpRequestResponseGet() { - if (this.responseType !== 'arraybuffer') { - return this.responseText; - } - var text = this.responseText; - var i, - n = text.length; - var result = new Uint8Array(n); - for (i = 0; i < n; ++i) { - result[i] = text.charCodeAt(i) & 0xFF; - } - return result.buffer; - } - }); - })(); - (function checkWindowBtoaCompatibility() { - if ('btoa' in globalScope) { - return; - } - var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - globalScope.btoa = function (chars) { - var buffer = ''; - var i, n; - for (i = 0, n = chars.length; i < n; i += 3) { - var b1 = chars.charCodeAt(i) & 0xFF; - var b2 = chars.charCodeAt(i + 1) & 0xFF; - var b3 = chars.charCodeAt(i + 2) & 0xFF; - var d1 = b1 >> 2, - d2 = (b1 & 3) << 4 | b2 >> 4; - var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64; - var d4 = i + 2 < n ? b3 & 0x3F : 64; - buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4); - } - return buffer; - }; - })(); - (function checkWindowAtobCompatibility() { - if ('atob' in globalScope) { - return; - } - var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - globalScope.atob = function (input) { - input = input.replace(/=+$/, ''); - if (input.length % 4 === 1) { - throw new Error('bad atob input'); - } - for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) { - buffer = digits.indexOf(buffer); - } - return output; - }; - })(); - (function checkFunctionPrototypeBindCompatibility() { - if (typeof Function.prototype.bind !== 'undefined') { - return; - } - Function.prototype.bind = function functionPrototypeBind(obj) { - var fn = this, - headArgs = Array.prototype.slice.call(arguments, 1); - var bound = function functionPrototypeBindBound() { - var args = headArgs.concat(Array.prototype.slice.call(arguments)); - return fn.apply(obj, args); - }; - return bound; - }; - })(); - (function checkDatasetProperty() { - if (!hasDOM) { - return; - } - var div = document.createElement('div'); - if ('dataset' in div) { - return; - } - Object.defineProperty(HTMLElement.prototype, 'dataset', { - get: function () { - if (this._dataset) { - return this._dataset; - } - var dataset = {}; - for (var j = 0, jj = this.attributes.length; j < jj; j++) { - var attribute = this.attributes[j]; - if (attribute.name.substring(0, 5) !== 'data-') { - continue; - } - var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) { - return ch.toUpperCase(); - }); - dataset[key] = attribute.value; - } - Object.defineProperty(this, '_dataset', { - value: dataset, - writable: false, - enumerable: false - }); - return dataset; - }, - enumerable: true - }); - })(); - (function checkClassListProperty() { - function changeList(element, itemName, add, remove) { - var s = element.className || ''; - var list = s.split(/\s+/g); - if (list[0] === '') { - list.shift(); - } - var index = list.indexOf(itemName); - if (index < 0 && add) { - list.push(itemName); - } - if (index >= 0 && remove) { - list.splice(index, 1); - } - element.className = list.join(' '); - return index >= 0; - } - if (!hasDOM) { - return; - } - var div = document.createElement('div'); - if ('classList' in div) { - return; - } - var classListPrototype = { - add: function (name) { - changeList(this.element, name, true, false); - }, - contains: function (name) { - return changeList(this.element, name, false, false); - }, - remove: function (name) { - changeList(this.element, name, false, true); - }, - toggle: function (name) { - changeList(this.element, name, true, true); - } - }; - Object.defineProperty(HTMLElement.prototype, 'classList', { - get: function () { - if (this._classList) { - return this._classList; - } - var classList = Object.create(classListPrototype, { - element: { - value: this, - writable: false, - enumerable: true - } - }); - Object.defineProperty(this, '_classList', { - value: classList, - writable: false, - enumerable: false - }); - return classList; - }, - enumerable: true - }); - })(); - (function checkWorkerConsoleCompatibility() { - if (typeof importScripts === 'undefined' || 'console' in globalScope) { - return; - } - var consoleTimer = {}; - var workerConsole = { - log: function log() { - var args = Array.prototype.slice.call(arguments); - globalScope.postMessage({ - targetName: 'main', - action: 'console_log', - data: args - }); - }, - error: function error() { - var args = Array.prototype.slice.call(arguments); - globalScope.postMessage({ - targetName: 'main', - action: 'console_error', - data: args - }); - }, - time: function time(name) { - consoleTimer[name] = Date.now(); - }, - timeEnd: function timeEnd(name) { - var time = consoleTimer[name]; - if (!time) { - throw new Error('Unknown timer name ' + name); - } - this.log('Timer:', name, Date.now() - time); - } - }; - globalScope.console = workerConsole; - })(); - (function checkConsoleCompatibility() { - if (!hasDOM) { - return; - } - if (!('console' in window)) { - window.console = { - log: function () {}, - error: function () {}, - warn: function () {} - }; - return; - } - if (!('bind' in console.log)) { - console.log = function (fn) { - return function (msg) { - return fn(msg); - }; - }(console.log); - console.error = function (fn) { - return function (msg) { - return fn(msg); - }; - }(console.error); - console.warn = function (fn) { - return function (msg) { - return fn(msg); - }; - }(console.warn); - return; - } - })(); - (function checkOnClickCompatibility() { - function ignoreIfTargetDisabled(event) { - if (isDisabled(event.target)) { - event.stopPropagation(); - } - } - function isDisabled(node) { - return node.disabled || node.parentNode && isDisabled(node.parentNode); - } - if (isOpera) { - document.addEventListener('click', ignoreIfTargetDisabled, true); - } - })(); - (function checkOnBlobSupport() { - if (isIE || isIOSChrome) { - PDFJS.disableCreateObjectURL = true; - } - })(); - (function checkNavigatorLanguage() { - if (typeof navigator === 'undefined') { - return; - } - if ('language' in navigator) { - return; - } - PDFJS.locale = navigator.userLanguage || 'en-US'; - })(); - (function checkRangeRequests() { - if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) { - PDFJS.disableRange = true; - PDFJS.disableStream = true; - } - })(); - (function checkHistoryManipulation() { - if (!hasDOM) { - return; - } - if (!history.pushState || isAndroidPre3) { - PDFJS.disableHistory = true; - } - })(); - (function checkSetPresenceInImageData() { - if (!hasDOM) { - return; - } - if (window.CanvasPixelArray) { - if (typeof window.CanvasPixelArray.prototype.set !== 'function') { - window.CanvasPixelArray.prototype.set = function (arr) { - for (var i = 0, ii = this.length; i < ii; i++) { - this[i] = arr[i]; - } - }; - } - } else { - var polyfill = false, - versionMatch; - if (isChrome) { - versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); - polyfill = versionMatch && parseInt(versionMatch[2]) < 21; - } else if (isAndroid) { - polyfill = isAndroidPre5; - } else if (isSafari) { - versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//); - polyfill = versionMatch && parseInt(versionMatch[1]) < 6; - } - if (polyfill) { - var contextPrototype = window.CanvasRenderingContext2D.prototype; - var createImageData = contextPrototype.createImageData; - contextPrototype.createImageData = function (w, h) { - var imageData = createImageData.call(this, w, h); - imageData.data.set = function (arr) { - for (var i = 0, ii = this.length; i < ii; i++) { - this[i] = arr[i]; - } - }; - return imageData; - }; - contextPrototype = null; - } - } - })(); - (function checkRequestAnimationFrame() { - function installFakeAnimationFrameFunctions() { - window.requestAnimationFrame = function (callback) { - return window.setTimeout(callback, 20); - }; - window.cancelAnimationFrame = function (timeoutID) { - window.clearTimeout(timeoutID); - }; - } - if (!hasDOM) { - return; - } - if (isIOS) { - installFakeAnimationFrameFunctions(); - return; - } - if ('requestAnimationFrame' in window) { - return; - } - window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame; - if (!('requestAnimationFrame' in window)) { - installFakeAnimationFrameFunctions(); - } - })(); - (function checkCanvasSizeLimitation() { - if (isIOS || isAndroid) { - PDFJS.maxCanvasPixels = 5242880; - } - })(); - (function checkFullscreenSupport() { - if (!hasDOM) { - return; - } - if (isIE && window.parent !== window) { - PDFJS.disableFullscreen = true; - } - })(); - (function checkCurrentScript() { - if (!hasDOM) { - return; - } - if ('currentScript' in document) { - return; - } - Object.defineProperty(document, 'currentScript', { - get: function () { - var scripts = document.getElementsByTagName('script'); - return scripts[scripts.length - 1]; - }, - enumerable: true, - configurable: true - }); - })(); - (function checkInputTypeNumberAssign() { - if (!hasDOM) { - return; - } - var el = document.createElement('input'); - try { - el.type = 'number'; - } catch (ex) { - var inputProto = el.constructor.prototype; - var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type'); - Object.defineProperty(inputProto, 'type', { - get: function () { - return typeProperty.get.call(this); - }, - set: function (value) { - typeProperty.set.call(this, value === 'number' ? 'text' : value); - }, - enumerable: true, - configurable: true - }); - } - })(); - (function checkDocumentReadyState() { - if (!hasDOM) { - return; - } - if (!document.attachEvent) { - return; - } - var documentProto = document.constructor.prototype; - var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState'); - Object.defineProperty(documentProto, 'readyState', { - get: function () { - var value = readyStateProto.get.call(this); - return value === 'interactive' ? 'loading' : value; - }, - set: function (value) { - readyStateProto.set.call(this, value); - }, - enumerable: true, - configurable: true - }); - })(); - (function checkChildNodeRemove() { - if (!hasDOM) { - return; - } - if (typeof Element.prototype.remove !== 'undefined') { - return; - } - Element.prototype.remove = function () { - if (this.parentNode) { - this.parentNode.removeChild(this); - } - }; - })(); - (function checkPromise() { - if (globalScope.Promise) { - if (typeof globalScope.Promise.all !== 'function') { - globalScope.Promise.all = function (iterable) { - var count = 0, - results = [], - resolve, - reject; - var promise = new globalScope.Promise(function (resolve_, reject_) { - resolve = resolve_; - reject = reject_; - }); - iterable.forEach(function (p, i) { - count++; - p.then(function (result) { - results[i] = result; - count--; - if (count === 0) { - resolve(results); - } - }, reject); - }); - if (count === 0) { - resolve(results); - } - return promise; - }; - } - if (typeof globalScope.Promise.resolve !== 'function') { - globalScope.Promise.resolve = function (value) { - return new globalScope.Promise(function (resolve) { - resolve(value); - }); - }; - } - if (typeof globalScope.Promise.reject !== 'function') { - globalScope.Promise.reject = function (reason) { - return new globalScope.Promise(function (resolve, reject) { - reject(reason); - }); - }; - } - if (typeof globalScope.Promise.prototype.catch !== 'function') { - globalScope.Promise.prototype.catch = function (onReject) { - return globalScope.Promise.prototype.then(undefined, onReject); - }; - } - return; - } - var STATUS_PENDING = 0; - var STATUS_RESOLVED = 1; - var STATUS_REJECTED = 2; - var REJECTION_TIMEOUT = 500; - var HandlerManager = { - handlers: [], - running: false, - unhandledRejections: [], - pendingRejectionCheck: false, - scheduleHandlers: function scheduleHandlers(promise) { - if (promise._status === STATUS_PENDING) { - return; - } - this.handlers = this.handlers.concat(promise._handlers); - promise._handlers = []; - if (this.running) { - return; - } - this.running = true; - setTimeout(this.runHandlers.bind(this), 0); - }, - runHandlers: function runHandlers() { - var RUN_TIMEOUT = 1; - var timeoutAt = Date.now() + RUN_TIMEOUT; - while (this.handlers.length > 0) { - var handler = this.handlers.shift(); - var nextStatus = handler.thisPromise._status; - var nextValue = handler.thisPromise._value; - try { - if (nextStatus === STATUS_RESOLVED) { - if (typeof handler.onResolve === 'function') { - nextValue = handler.onResolve(nextValue); - } - } else if (typeof handler.onReject === 'function') { - nextValue = handler.onReject(nextValue); - nextStatus = STATUS_RESOLVED; - if (handler.thisPromise._unhandledRejection) { - this.removeUnhandeledRejection(handler.thisPromise); - } - } - } catch (ex) { - nextStatus = STATUS_REJECTED; - nextValue = ex; - } - handler.nextPromise._updateStatus(nextStatus, nextValue); - if (Date.now() >= timeoutAt) { - break; - } - } - if (this.handlers.length > 0) { - setTimeout(this.runHandlers.bind(this), 0); - return; - } - this.running = false; - }, - addUnhandledRejection: function addUnhandledRejection(promise) { - this.unhandledRejections.push({ - promise: promise, - time: Date.now() - }); - this.scheduleRejectionCheck(); - }, - removeUnhandeledRejection: function removeUnhandeledRejection(promise) { - promise._unhandledRejection = false; - for (var i = 0; i < this.unhandledRejections.length; i++) { - if (this.unhandledRejections[i].promise === promise) { - this.unhandledRejections.splice(i); - i--; - } - } - }, - scheduleRejectionCheck: function scheduleRejectionCheck() { - if (this.pendingRejectionCheck) { - return; - } - this.pendingRejectionCheck = true; - setTimeout(function rejectionCheck() { - this.pendingRejectionCheck = false; - var now = Date.now(); - for (var i = 0; i < this.unhandledRejections.length; i++) { - if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) { - var unhandled = this.unhandledRejections[i].promise._value; - var msg = 'Unhandled rejection: ' + unhandled; - if (unhandled.stack) { - msg += '\n' + unhandled.stack; - } - try { - throw new Error(msg); - } catch (_) { - console.warn(msg); - } - this.unhandledRejections.splice(i); - i--; - } - } - if (this.unhandledRejections.length) { - this.scheduleRejectionCheck(); - } - }.bind(this), REJECTION_TIMEOUT); - } - }; - var Promise = function Promise(resolver) { - this._status = STATUS_PENDING; - this._handlers = []; - try { - resolver.call(this, this._resolve.bind(this), this._reject.bind(this)); - } catch (e) { - this._reject(e); - } - }; - Promise.all = function Promise_all(promises) { - var resolveAll, rejectAll; - var deferred = new Promise(function (resolve, reject) { - resolveAll = resolve; - rejectAll = reject; - }); - var unresolved = promises.length; - var results = []; - if (unresolved === 0) { - resolveAll(results); - return deferred; - } - function reject(reason) { - if (deferred._status === STATUS_REJECTED) { - return; - } - results = []; - rejectAll(reason); - } - for (var i = 0, ii = promises.length; i < ii; ++i) { - var promise = promises[i]; - var resolve = function (i) { - return function (value) { - if (deferred._status === STATUS_REJECTED) { - return; - } - results[i] = value; - unresolved--; - if (unresolved === 0) { - resolveAll(results); - } - }; - }(i); - if (Promise.isPromise(promise)) { - promise.then(resolve, reject); - } else { - resolve(promise); - } - } - return deferred; - }; - Promise.isPromise = function Promise_isPromise(value) { - return value && typeof value.then === 'function'; - }; - Promise.resolve = function Promise_resolve(value) { - return new Promise(function (resolve) { - resolve(value); - }); - }; - Promise.reject = function Promise_reject(reason) { - return new Promise(function (resolve, reject) { - reject(reason); - }); - }; - Promise.prototype = { - _status: null, - _value: null, - _handlers: null, - _unhandledRejection: null, - _updateStatus: function Promise__updateStatus(status, value) { - if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) { - return; - } - if (status === STATUS_RESOLVED && Promise.isPromise(value)) { - value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED)); - return; - } - this._status = status; - this._value = value; - if (status === STATUS_REJECTED && this._handlers.length === 0) { - this._unhandledRejection = true; - HandlerManager.addUnhandledRejection(this); - } - HandlerManager.scheduleHandlers(this); - }, - _resolve: function Promise_resolve(value) { - this._updateStatus(STATUS_RESOLVED, value); - }, - _reject: function Promise_reject(reason) { - this._updateStatus(STATUS_REJECTED, reason); - }, - then: function Promise_then(onResolve, onReject) { - var nextPromise = new Promise(function (resolve, reject) { - this.resolve = resolve; - this.reject = reject; - }); - this._handlers.push({ - thisPromise: this, - onResolve: onResolve, - onReject: onReject, - nextPromise: nextPromise - }); - HandlerManager.scheduleHandlers(this); - return nextPromise; - }, - catch: function Promise_catch(onReject) { - return this.then(undefined, onReject); - } - }; - globalScope.Promise = Promise; - })(); - (function checkWeakMap() { - if (globalScope.WeakMap) { - return; - } - var id = 0; - function WeakMap() { - this.id = '$weakmap' + id++; - } - WeakMap.prototype = { - has: function (obj) { - return !!Object.getOwnPropertyDescriptor(obj, this.id); - }, - get: function (obj, defaultValue) { - return this.has(obj) ? obj[this.id] : defaultValue; - }, - set: function (obj, value) { - Object.defineProperty(obj, this.id, { - value: value, - enumerable: false, - configurable: true - }); - }, - delete: function (obj) { - delete obj[this.id]; - } - }; - globalScope.WeakMap = WeakMap; - })(); - (function checkURLConstructor() { - var hasWorkingUrl = false; - try { - if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) { - var u = new URL('b', 'http://a'); - u.pathname = 'c%20d'; - hasWorkingUrl = u.href === 'http://a/c%20d'; - } - } catch (e) {} - if (hasWorkingUrl) { - return; - } - var relative = Object.create(null); - relative['ftp'] = 21; - relative['file'] = 0; - relative['gopher'] = 70; - relative['http'] = 80; - relative['https'] = 443; - relative['ws'] = 80; - relative['wss'] = 443; - var relativePathDotMapping = Object.create(null); - relativePathDotMapping['%2e'] = '.'; - relativePathDotMapping['.%2e'] = '..'; - relativePathDotMapping['%2e.'] = '..'; - relativePathDotMapping['%2e%2e'] = '..'; - function isRelativeScheme(scheme) { - return relative[scheme] !== undefined; - } - function invalid() { - clear.call(this); - this._isInvalid = true; - } - function IDNAToASCII(h) { - if (h === '') { - invalid.call(this); - } - return h.toLowerCase(); - } - function percentEscape(c) { - var unicode = c.charCodeAt(0); - if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) { - return c; - } - return encodeURIComponent(c); - } - function percentEscapeQuery(c) { - var unicode = c.charCodeAt(0); - if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) { - return c; - } - return encodeURIComponent(c); - } - var EOF, - ALPHA = /[a-zA-Z]/, - ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; - function parse(input, stateOverride, base) { - function err(message) { - errors.push(message); - } - var state = stateOverride || 'scheme start', - cursor = 0, - buffer = '', - seenAt = false, - seenBracket = false, - errors = []; - loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) { - var c = input[cursor]; - switch (state) { - case 'scheme start': - if (c && ALPHA.test(c)) { - buffer += c.toLowerCase(); - state = 'scheme'; - } else if (!stateOverride) { - buffer = ''; - state = 'no scheme'; - continue; - } else { - err('Invalid scheme.'); - break loop; - } - break; - case 'scheme': - if (c && ALPHANUMERIC.test(c)) { - buffer += c.toLowerCase(); - } else if (c === ':') { - this._scheme = buffer; - buffer = ''; - if (stateOverride) { - break loop; - } - if (isRelativeScheme(this._scheme)) { - this._isRelative = true; - } - if (this._scheme === 'file') { - state = 'relative'; - } else if (this._isRelative && base && base._scheme === this._scheme) { - state = 'relative or authority'; - } else if (this._isRelative) { - state = 'authority first slash'; - } else { - state = 'scheme data'; - } - } else if (!stateOverride) { - buffer = ''; - cursor = 0; - state = 'no scheme'; - continue; - } else if (c === EOF) { - break loop; - } else { - err('Code point not allowed in scheme: ' + c); - break loop; - } - break; - case 'scheme data': - if (c === '?') { - this._query = '?'; - state = 'query'; - } else if (c === '#') { - this._fragment = '#'; - state = 'fragment'; - } else { - if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { - this._schemeData += percentEscape(c); - } - } - break; - case 'no scheme': - if (!base || !isRelativeScheme(base._scheme)) { - err('Missing scheme.'); - invalid.call(this); - } else { - state = 'relative'; - continue; - } - break; - case 'relative or authority': - if (c === '/' && input[cursor + 1] === '/') { - state = 'authority ignore slashes'; - } else { - err('Expected /, got: ' + c); - state = 'relative'; - continue; - } - break; - case 'relative': - this._isRelative = true; - if (this._scheme !== 'file') { - this._scheme = base._scheme; - } - if (c === EOF) { - this._host = base._host; - this._port = base._port; - this._path = base._path.slice(); - this._query = base._query; - this._username = base._username; - this._password = base._password; - break loop; - } else if (c === '/' || c === '\\') { - if (c === '\\') { - err('\\ is an invalid code point.'); - } - state = 'relative slash'; - } else if (c === '?') { - this._host = base._host; - this._port = base._port; - this._path = base._path.slice(); - this._query = '?'; - this._username = base._username; - this._password = base._password; - state = 'query'; - } else if (c === '#') { - this._host = base._host; - this._port = base._port; - this._path = base._path.slice(); - this._query = base._query; - this._fragment = '#'; - this._username = base._username; - this._password = base._password; - state = 'fragment'; - } else { - var nextC = input[cursor + 1]; - var nextNextC = input[cursor + 2]; - if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') { - this._host = base._host; - this._port = base._port; - this._username = base._username; - this._password = base._password; - this._path = base._path.slice(); - this._path.pop(); - } - state = 'relative path'; - continue; - } - break; - case 'relative slash': - if (c === '/' || c === '\\') { - if (c === '\\') { - err('\\ is an invalid code point.'); - } - if (this._scheme === 'file') { - state = 'file host'; - } else { - state = 'authority ignore slashes'; - } - } else { - if (this._scheme !== 'file') { - this._host = base._host; - this._port = base._port; - this._username = base._username; - this._password = base._password; - } - state = 'relative path'; - continue; - } - break; - case 'authority first slash': - if (c === '/') { - state = 'authority second slash'; - } else { - err('Expected \'/\', got: ' + c); - state = 'authority ignore slashes'; - continue; - } - break; - case 'authority second slash': - state = 'authority ignore slashes'; - if (c !== '/') { - err('Expected \'/\', got: ' + c); - continue; - } - break; - case 'authority ignore slashes': - if (c !== '/' && c !== '\\') { - state = 'authority'; - continue; - } else { - err('Expected authority, got: ' + c); - } - break; - case 'authority': - if (c === '@') { - if (seenAt) { - err('@ already seen.'); - buffer += '%40'; - } - seenAt = true; - for (var i = 0; i < buffer.length; i++) { - var cp = buffer[i]; - if (cp === '\t' || cp === '\n' || cp === '\r') { - err('Invalid whitespace in authority.'); - continue; - } - if (cp === ':' && this._password === null) { - this._password = ''; - continue; - } - var tempC = percentEscape(cp); - if (this._password !== null) { - this._password += tempC; - } else { - this._username += tempC; - } - } - buffer = ''; - } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { - cursor -= buffer.length; - buffer = ''; - state = 'host'; - continue; - } else { - buffer += c; - } - break; - case 'file host': - if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { - if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) { - state = 'relative path'; - } else if (buffer.length === 0) { - state = 'relative path start'; - } else { - this._host = IDNAToASCII.call(this, buffer); - buffer = ''; - state = 'relative path start'; - } - continue; - } else if (c === '\t' || c === '\n' || c === '\r') { - err('Invalid whitespace in file host.'); - } else { - buffer += c; - } - break; - case 'host': - case 'hostname': - if (c === ':' && !seenBracket) { - this._host = IDNAToASCII.call(this, buffer); - buffer = ''; - state = 'port'; - if (stateOverride === 'hostname') { - break loop; - } - } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { - this._host = IDNAToASCII.call(this, buffer); - buffer = ''; - state = 'relative path start'; - if (stateOverride) { - break loop; - } - continue; - } else if (c !== '\t' && c !== '\n' && c !== '\r') { - if (c === '[') { - seenBracket = true; - } else if (c === ']') { - seenBracket = false; - } - buffer += c; - } else { - err('Invalid code point in host/hostname: ' + c); - } - break; - case 'port': - if (/[0-9]/.test(c)) { - buffer += c; - } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) { - if (buffer !== '') { - var temp = parseInt(buffer, 10); - if (temp !== relative[this._scheme]) { - this._port = temp + ''; - } - buffer = ''; - } - if (stateOverride) { - break loop; - } - state = 'relative path start'; - continue; - } else if (c === '\t' || c === '\n' || c === '\r') { - err('Invalid code point in port: ' + c); - } else { - invalid.call(this); - } - break; - case 'relative path start': - if (c === '\\') { - err('\'\\\' not allowed in path.'); - } - state = 'relative path'; - if (c !== '/' && c !== '\\') { - continue; - } - break; - case 'relative path': - if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) { - if (c === '\\') { - err('\\ not allowed in relative path.'); - } - var tmp; - if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { - buffer = tmp; - } - if (buffer === '..') { - this._path.pop(); - if (c !== '/' && c !== '\\') { - this._path.push(''); - } - } else if (buffer === '.' && c !== '/' && c !== '\\') { - this._path.push(''); - } else if (buffer !== '.') { - if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') { - buffer = buffer[0] + ':'; - } - this._path.push(buffer); - } - buffer = ''; - if (c === '?') { - this._query = '?'; - state = 'query'; - } else if (c === '#') { - this._fragment = '#'; - state = 'fragment'; - } - } else if (c !== '\t' && c !== '\n' && c !== '\r') { - buffer += percentEscape(c); - } - break; - case 'query': - if (!stateOverride && c === '#') { - this._fragment = '#'; - state = 'fragment'; - } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { - this._query += percentEscapeQuery(c); - } - break; - case 'fragment': - if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { - this._fragment += c; - } - break; - } - cursor++; - } - } - function clear() { - this._scheme = ''; - this._schemeData = ''; - this._username = ''; - this._password = null; - this._host = ''; - this._port = ''; - this._path = []; - this._query = ''; - this._fragment = ''; - this._isInvalid = false; - this._isRelative = false; - } - function JURL(url, base) { - if (base !== undefined && !(base instanceof JURL)) { - base = new JURL(String(base)); - } - this._url = url; - clear.call(this); - var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); - parse.call(this, input, null, base); - } - JURL.prototype = { - toString: function () { - return this.href; - }, - get href() { - if (this._isInvalid) { - return this._url; - } - var authority = ''; - if (this._username !== '' || this._password !== null) { - authority = this._username + (this._password !== null ? ':' + this._password : '') + '@'; - } - return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment; - }, - set href(href) { - clear.call(this); - parse.call(this, href); - }, - get protocol() { - return this._scheme + ':'; - }, - set protocol(protocol) { - if (this._isInvalid) { - return; - } - parse.call(this, protocol + ':', 'scheme start'); - }, - get host() { - return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host; - }, - set host(host) { - if (this._isInvalid || !this._isRelative) { - return; - } - parse.call(this, host, 'host'); - }, - get hostname() { - return this._host; - }, - set hostname(hostname) { - if (this._isInvalid || !this._isRelative) { - return; - } - parse.call(this, hostname, 'hostname'); - }, - get port() { - return this._port; - }, - set port(port) { - if (this._isInvalid || !this._isRelative) { - return; - } - parse.call(this, port, 'port'); - }, - get pathname() { - return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData; - }, - set pathname(pathname) { - if (this._isInvalid || !this._isRelative) { - return; - } - this._path = []; - parse.call(this, pathname, 'relative path start'); - }, - get search() { - return this._isInvalid || !this._query || this._query === '?' ? '' : this._query; - }, - set search(search) { - if (this._isInvalid || !this._isRelative) { - return; - } - this._query = '?'; - if (search[0] === '?') { - search = search.slice(1); - } - parse.call(this, search, 'query'); - }, - get hash() { - return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment; - }, - set hash(hash) { - if (this._isInvalid) { - return; - } - this._fragment = '#'; - if (hash[0] === '#') { - hash = hash.slice(1); - } - parse.call(this, hash, 'fragment'); - }, - get origin() { - var host; - if (this._isInvalid || !this._scheme) { - return ''; - } - switch (this._scheme) { - case 'data': - case 'file': - case 'javascript': - case 'mailto': - return 'null'; - } - host = this.host; - if (!host) { - return ''; - } - return this._scheme + '://' + host; - } - }; - var OriginalURL = globalScope.URL; - if (OriginalURL) { - JURL.createObjectURL = function (blob) { - return OriginalURL.createObjectURL.apply(OriginalURL, arguments); - }; - JURL.revokeObjectURL = function (url) { - OriginalURL.revokeObjectURL(url); - }; - } - globalScope.URL = JURL; - })(); -} -/* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(6))) - -/***/ }) -/******/ ]); -}); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) - -/***/ }), -/* 3 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(Buffer) {/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -// css base code, injected by the css-loader -module.exports = function(useSourceMap) { - var list = []; - - // return the list of modules as css string - list.toString = function toString() { - return this.map(function (item) { - var content = cssWithMappingToString(item, useSourceMap); - if(item[2]) { - return "@media " + item[2] + "{" + content + "}"; - } else { - return content; - } - }).join(""); - }; - - // import a list of modules into the list - list.i = function(modules, mediaQuery) { - if(typeof modules === "string") - modules = [[null, modules, ""]]; - var alreadyImportedModules = {}; - for(var i = 0; i < this.length; i++) { - var id = this[i][0]; - if(typeof id === "number") - alreadyImportedModules[id] = true; - } - for(i = 0; i < modules.length; i++) { - var item = modules[i]; - // skip already imported module - // this implementation is not 100% perfect for weird media query combinations - // when a module is imported multiple times with different media queries. - // I hope this will never occur (Hey this way we have smaller bundles) - if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { - if(mediaQuery && !item[2]) { - item[2] = mediaQuery; - } else if(mediaQuery) { - item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; - } - list.push(item); - } - } - }; - return list; -}; - -function cssWithMappingToString(item, useSourceMap) { - var content = item[1] || ''; - var cssMapping = item[3]; - if (!cssMapping) { - return content; - } - - if (useSourceMap) { - var sourceMapping = toComment(cssMapping); - var sourceURLs = cssMapping.sources.map(function (source) { - return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' - }); - - return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); - } - - return [content].join('\n'); -} - -// Adapted from convert-source-map (MIT) -function toComment(sourceMap) { - var base64 = new Buffer(JSON.stringify(sourceMap)).toString('base64'); - var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; - - return '/*# ' + data + ' */'; -} - -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10).Buffer)) - -/***/ }), -/* 4 */ -/***/ (function(module, exports) { - -// this module is a runtime utility for cleaner component module output and will -// be included in the final webpack user bundle - -module.exports = function normalizeComponent ( - rawScriptExports, - compiledTemplate, - scopeId, - cssModules -) { - var esModule - var scriptExports = rawScriptExports = rawScriptExports || {} - - // ES6 modules interop - var type = typeof rawScriptExports.default - if (type === 'object' || type === 'function') { - esModule = rawScriptExports - scriptExports = rawScriptExports.default - } - - // Vue.extend constructor export interop - var options = typeof scriptExports === 'function' - ? scriptExports.options - : scriptExports - - // render functions - if (compiledTemplate) { - options.render = compiledTemplate.render - options.staticRenderFns = compiledTemplate.staticRenderFns - } - - // scopedId - if (scopeId) { - options._scopeId = scopeId - } - - // inject cssModules - if (cssModules) { - var computed = Object.create(options.computed || null) - Object.keys(cssModules).forEach(function (key) { - var module = cssModules[key] - computed[key] = function () { return module } - }) - options.computed = computed - } - - return { - esModule: esModule, - exports: scriptExports, - options: options - } -} - - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { - -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra - Modified by Evan You @yyx990803 -*/ - -var hasDocument = typeof document !== 'undefined' - -if (typeof DEBUG !== 'undefined' && DEBUG) { - if (!hasDocument) { - throw new Error( - 'vue-style-loader cannot be used in a non-browser environment. ' + - "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment." - ) } -} - -var listToStyles = __webpack_require__(21) - -/* -type StyleObject = { - id: number; - parts: Array -} - -type StyleObjectPart = { - css: string; - media: string; - sourceMap: ?string -} -*/ - -var stylesInDom = {/* - [id: number]: { - id: number, - refs: number, - parts: Array<(obj?: StyleObjectPart) => void> - } -*/} - -var head = hasDocument && (document.head || document.getElementsByTagName('head')[0]) -var singletonElement = null -var singletonCounter = 0 -var isProduction = false -var noop = function () {} - -// Force single-tag solution on IE6-9, which has a hard limit on the # of