diff --git a/bower.json b/bower.json index 9bfb14262..0ead12b21 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.7.254", + "version": "1.7.256", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 9788f880d..1485a0414 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -23,8 +23,8 @@ } }(this, function (exports) { 'use strict'; - var pdfjsVersion = '1.7.254'; - var pdfjsBuild = 'ec26a7e5'; + var pdfjsVersion = '1.7.256'; + var pdfjsBuild = 'd3ae5b38'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; var pdfjsLibs = {}; (function pdfjsWrapper() { @@ -50155,6 +50155,7 @@ params[key] = source[key]; } params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; + params.disableNativeImageDecoder = params.disableNativeImageDecoder === true; if (!worker) { worker = new PDFWorker(); task._worker = worker; @@ -50197,7 +50198,8 @@ disableFontFace: getDefaultSetting('disableFontFace'), disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'), postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled, - docBaseUrl: source.docBaseUrl + docBaseUrl: source.docBaseUrl, + disableNativeImageDecoder: source.disableNativeImageDecoder }).then(function (workerId) { if (worker.destroyed) { throw new Error('Worker was destroyed'); @@ -51359,7 +51361,8 @@ cMapOptions: { url: null, packed: false - } + }, + disableNativeImageDecoder: false }; function NativeImageDecoder(xref, resources, handler, forceDataSchema) { this.xref = xref; @@ -51570,6 +51573,7 @@ operatorList.addOp(OPS.paintInlineImageXObject, [imgData]); return; } + var useNativeImageDecoder = !this.options.disableNativeImageDecoder; var objId = 'img_' + this.idFactory.createObjId(); operatorList.addDependency(objId); args = [ @@ -51577,7 +51581,7 @@ w, h ]; - if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) { + if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) { operatorList.addOp(OPS.paintJpegXObject, args); this.handler.send('obj', [ objId, @@ -51588,7 +51592,7 @@ return; } var nativeImageDecoder = null; - if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) { + if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) { nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema); } PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) { @@ -56199,7 +56203,8 @@ forceDataSchema: data.disableCreateObjectURL, maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize, disableFontFace: data.disableFontFace, - cMapOptions: cMapOptions + cMapOptions: cMapOptions, + disableNativeImageDecoder: data.disableNativeImageDecoder }; getPdfManager(data, evaluatorOptions).then(function (newPdfManager) { if (terminated) { diff --git a/build/pdf.js b/build/pdf.js index 6de24ed73..10df94f54 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -23,8 +23,8 @@ } }(this, function (exports) { 'use strict'; - var pdfjsVersion = '1.7.254'; - var pdfjsBuild = 'ec26a7e5'; + var pdfjsVersion = '1.7.256'; + var pdfjsBuild = 'd3ae5b38'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; var pdfjsLibs = {}; (function pdfjsWrapper() { @@ -7701,6 +7701,7 @@ params[key] = source[key]; } params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; + params.disableNativeImageDecoder = params.disableNativeImageDecoder === true; if (!worker) { worker = new PDFWorker(); task._worker = worker; @@ -7743,7 +7744,8 @@ disableFontFace: getDefaultSetting('disableFontFace'), disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'), postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled, - docBaseUrl: source.docBaseUrl + docBaseUrl: source.docBaseUrl, + disableNativeImageDecoder: source.disableNativeImageDecoder }).then(function (workerId) { if (worker.destroyed) { throw new Error('Worker was destroyed'); diff --git a/build/pdf.min.js b/build/pdf.min.js index 1b75ec9c8..4b4f8cf63 100644 --- a/build/pdf.min.js +++ b/build/pdf.min.js @@ -1,5 +1,5 @@ -!function(t,e){"use strict";"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",["exports"],e):e("undefined"!=typeof exports?exports:t.pdfjsDistBuildPdf={})}(this,function(t){"use strict";var e="1.7.254",n="ec26a7e5",i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:null,r={};(function(){!function(t,e){e(t.pdfjsSharedUtil={})}(this,function(t){function e(t){Z=t}function n(){return Z}function i(t){Z>=Q.infos&&console.log("Info: "+t)}function r(t){Z>=Q.warnings&&console.log("Warning: "+t)}function a(t){console.log("Deprecated API usage: "+t)}function s(t){throw Z>=Q.errors&&(console.log("Error: "+t),console.log(o())),new Error(t)}function o(){try{throw new Error}catch(t){return t.stack?t.stack.split("\n").slice(2).join("\n"):""}}function c(t,e){t||s(e)}function l(t,e){try{var n=new URL(t);if(!n.origin||"null"===n.origin)return!1}catch(t){return!1}var i=new URL(e,n);return n.origin===i.origin}function h(t){if(!t)return!1;switch(t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function u(t,e){if(!t)return null;try{var n=e?new URL(t,e):new URL(t);if(h(n))return n}catch(t){}return null}function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}function f(t){var e;return function(){return t&&(e=Object.create(null),t(e),t=null),e}}function p(t){return"string"!=typeof t?(r("The argument for removeNullCharacters must be a string."),t):t.replace(lt,"")}function g(t){c(null!==t&&"object"==typeof t&&void 0!==t.length,"Invalid argument for bytesToString");var e=t.length,n=8192;if(e>24&255,t>>16&255,t>>8&255,255&t)}function y(t){for(var e=1,n=0;t>e;)e<<=1,n++;return n}function x(t,e){return t[e]<<24>>24}function S(t,e){return t[e]<<8|t[e+1]}function k(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function _(){var t=new Uint8Array(2);t[0]=1;var e=new Uint16Array(t.buffer);return 1===e[0]}function C(){try{return new Function(""),!0}catch(t){return!1}}function w(t){var e,n=t.length,i=[];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,i=t<<2;n[i]=255&e,n[i+1]=e>>8&255,n[i+2]=e>>16&255,n[i+3]=e>>>24&255}}}function n(n){for(;it[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 i(t,e){return t-e}var r=[e[0],e[2],n[0],n[2]].sort(i),a=[e[1],e[3],n[1],n[3]].sort(i),s=[];return e=t.normalizeRect(e),n=t.normalizeRect(n),(r[0]===e[0]&&r[1]===n[0]||r[0]===n[0]&&r[1]===e[0])&&(s[0]=r[1],s[2]=r[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){c(R(t)&&t>0,"The number should be a positive integer.");for(var i,r=[];t>=1e3;)t-=1e3,r.push("M");i=t/100|0,t%=100,r.push(n[i]),i=t/10|0,t%=10,r.push(n[10+i]),r.push(n[20+t]);var a=r.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 i in n)t.prototype[i]=n[i]},t.loadScript=function(t,e){var n=document.createElement("script"),i=!1;n.setAttribute("src",t),e&&(n.onload=function(){i||e(),i=!0}),document.getElementsByTagName("head")[0].appendChild(n)},t}(),ft=function(){function t(t,e,n,i,r,a){this.viewBox=t,this.scale=e,this.rotation=n,this.offsetX=i,this.offsetY=r;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+i,f=Math.abs(h-t[0])*e+r,p=Math.abs(t[3]-t[1])*e,g=Math.abs(t[2]-t[0])*e):(d=Math.abs(h-t[0])*e+i,f=Math.abs(u-t[1])*e+r,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,i="rotation"in e?e.rotation:this.rotation;return new t(this.viewBox.slice(),n,i,this.offsetX,this.offsetY,e.dontFlip)},convertToViewportPoint:function(t,e){return dt.applyTransform([t,e],this.transform)},convertToViewportRectangle:function(t){var e=dt.applyTransform([t[0],t[1]],this.transform),n=dt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]},convertToPdfPoint:function(t,e){return dt.applyInverseTransform([t,e],this.transform)}},t}(),pt=[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];!function(){if(B.Promise)return"function"!=typeof B.Promise.all&&(B.Promise.all=function(t){var e,n,i=0,r=[],a=new B.Promise(function(t,i){e=t,n=i});return t.forEach(function(t,a){i++,t.then(function(t){r[a]=t,i--,0===i&&e(r)},n)}),0===i&&e(r),a}),"function"!=typeof B.Promise.resolve&&(B.Promise.resolve=function(t){return new B.Promise(function(e){e(t)})}),"function"!=typeof B.Promise.reject&&(B.Promise.reject=function(t){return new B.Promise(function(e,n){n(t)})}),void("function"!=typeof B.Promise.prototype.catch&&(B.Promise.prototype.catch=function(t){return B.Promise.prototype.then(void 0,t)}));var t=0,e=1,n=2,i=500,a={handlers:[],running:!1,unhandledRejections:[],pendingRejectionCheck:!1,scheduleHandlers:function(e){e._status!==t&&(this.handlers=this.handlers.concat(e._handlers),e._handlers=[],this.running||(this.running=!0,setTimeout(this.runHandlers.bind(this),0)))},runHandlers:function(){for(var t=1,i=Date.now()+t;this.handlers.length>0;){var r=this.handlers.shift(),a=r.thisPromise._status,s=r.thisPromise._value;try{a===e?"function"==typeof r.onResolve&&(s=r.onResolve(s)):"function"==typeof r.onReject&&(s=r.onReject(s),a=e,r.thisPromise._unhandledRejection&&this.removeUnhandeledRejection(r.thisPromise))}catch(t){a=n,s=t}if(r.nextPromise._updateStatus(a,s),Date.now()>=i)break}return this.handlers.length>0?void setTimeout(this.runHandlers.bind(this),0):void(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;ei){var n=this.unhandledRejections[e].promise._value,a="Unhandled rejection: "+n;n.stack&&(a+="\n"+n.stack),r(a),this.unhandledRejections.splice(e),e--}this.unhandledRejections.length&&this.scheduleRejectionCheck()}.bind(this),i))}},s=function(e){this._status=t,this._handlers=[];try{e.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(t){this._reject(t)}};s.all=function(t){function e(t){a._status!==n&&(c=[],r(t))}var i,r,a=new s(function(t,e){i=t,r=e}),o=t.length,c=[];if(0===o)return i(c),a;for(var l=0,h=t.length;la&&(a=s.length)}for(e=0,n=i.length;e>2,d=(3&c)<<4|l>>4,f=s+1>6:64,p=s+232&&e<127&&[34,35,60,62,63,96].indexOf(e)===-1?t:encodeURIComponent(t)}function a(t){var e=t.charCodeAt(0);return e>32&&e<127&&[34,35,60,62,96].indexOf(e)===-1?t:encodeURIComponent(t)}function s(t,s,o){function c(t){b.push(t)}var l=s||"scheme start",h=0,m="",A=!1,v=!1,b=[];t:for(;(t[h-1]!==f||0===h)&&!this._isInvalid;){var y=t[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(f===y)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;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":"?"===y?(this._query="?",l="query"):"#"===y?(this._fragment="#",l="fragment"):f!==y&&"\t"!==y&&"\n"!==y&&"\r"!==y&&(this._schemeData+=r(y));break;case"no scheme":if(o&&e(o._scheme)){l="relative";continue}c("Missing scheme."),n.call(this);break;case"relative or authority":if("/"!==y||"/"!==t[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),f===y){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=t[h+1],S=t[h+2];("file"!==this._scheme||!p.test(y)||":"!==x&&"|"!==x||f!==S&&"/"!==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 k=0;k0?e:t.length,n>0?n:t.length);return t.substring(t.lastIndexOf("/",i)+1,i)}function a(t){var n=e.globalScope.PDFJS;switch(t){case"pdfBug":return!!n&&n.pdfBug;case"disableAutoFetch":return!!n&&n.disableAutoFetch;case"disableStream":return!!n&&n.disableStream;case"disableRange":return!!n&&n.disableRange;case"disableFontFace":return!!n&&n.disableFontFace;case"disableCreateObjectURL":return!!n&&n.disableCreateObjectURL;case"disableWebGL":return!n||n.disableWebGL;case"cMapUrl":return n?n.cMapUrl:null;case"cMapPacked":return!!n&&n.cMapPacked;case"postMessageTransfers":return!n||n.postMessageTransfers;case"workerSrc":return n?n.workerSrc:null;case"disableWorker":return!!n&&n.disableWorker;case"maxImageSize":return n?n.maxImageSize:-1;case"imageResourcesPath":return n?n.imageResourcesPath:"";case"isEvalSupported":return!n||n.isEvalSupported;case"externalLinkTarget":if(!n)return m.NONE;switch(n.externalLinkTarget){case m.NONE:case m.SELF:case m.BLANK:case m.PARENT:case m.TOP:return n.externalLinkTarget}return h("PDFJS.externalLinkTarget is invalid: "+n.externalLinkTarget),n.externalLinkTarget=m.NONE,m.NONE;case"externalLinkRel":return n?n.externalLinkRel:f;case"enableStats":return!(!n||!n.enableStats);default:throw new Error("Unknown default setting: "+t)}}function s(){var t=a("externalLinkTarget");switch(t){case m.NONE:return!1;case m.SELF:case m.BLANK:case m.PARENT:case m.TOP:return!0}}function o(t,e){u("isValidUrl(), please use createValidAbsoluteUrl() instead.");var n=e?"http://example.com":null;return null!==d(t,n)}var c=e.assert,l=e.removeNullCharacters,h=e.warn,u=e.deprecated,d=e.createValidAbsoluteUrl,f="noopener noreferrer nofollow";n.prototype={create:function(t,e){c(t>0&&e>0,"invalid canvas size");var n=document.createElement("canvas");return n.width=t,n.height=e,n},reset:function(t,e,n){c(t,"canvas is not specified"),c(e>0&&n>0,"invalid canvas size"),t.width=e,t.height=n},destroy:function(t){c(t,"canvas is not specified"),t.width=0,t.height=0}};var p,g=function(){function t(){}var e=["ms","Moz","Webkit","O"],n=Object.create(null);return t.getProp=function(t,i){if(1===arguments.length&&"string"==typeof n[t])return n[t];i=i||document.documentElement;var r,a,s=i.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;o=Q.infos&&console.log("Info: "+t)}function r(t){Z>=Q.warnings&&console.log("Warning: "+t)}function a(t){console.log("Deprecated API usage: "+t)}function s(t){throw Z>=Q.errors&&(console.log("Error: "+t),console.log(o())),new Error(t)}function o(){try{throw new Error}catch(t){return t.stack?t.stack.split("\n").slice(2).join("\n"):""}}function c(t,e){t||s(e)}function l(t,e){try{var n=new URL(t);if(!n.origin||"null"===n.origin)return!1}catch(t){return!1}var i=new URL(e,n);return n.origin===i.origin}function h(t){if(!t)return!1;switch(t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function u(t,e){if(!t)return null;try{var n=e?new URL(t,e):new URL(t);if(h(n))return n}catch(t){}return null}function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}function f(t){var e;return function(){return t&&(e=Object.create(null),t(e),t=null),e}}function p(t){return"string"!=typeof t?(r("The argument for removeNullCharacters must be a string."),t):t.replace(lt,"")}function g(t){c(null!==t&&"object"==typeof t&&void 0!==t.length,"Invalid argument for bytesToString");var e=t.length,n=8192;if(e>24&255,t>>16&255,t>>8&255,255&t)}function y(t){for(var e=1,n=0;t>e;)e<<=1,n++;return n}function x(t,e){return t[e]<<24>>24}function S(t,e){return t[e]<<8|t[e+1]}function k(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}function _(){var t=new Uint8Array(2);t[0]=1;var e=new Uint16Array(t.buffer);return 1===e[0]}function C(){try{return new Function(""),!0}catch(t){return!1}}function w(t){var e,n=t.length,i=[];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,i=t<<2;n[i]=255&e,n[i+1]=e>>8&255,n[i+2]=e>>16&255,n[i+3]=e>>>24&255}}}function n(n){for(;it[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 i(t,e){return t-e}var r=[e[0],e[2],n[0],n[2]].sort(i),a=[e[1],e[3],n[1],n[3]].sort(i),s=[];return e=t.normalizeRect(e),n=t.normalizeRect(n),(r[0]===e[0]&&r[1]===n[0]||r[0]===n[0]&&r[1]===e[0])&&(s[0]=r[1],s[2]=r[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){c(R(t)&&t>0,"The number should be a positive integer.");for(var i,r=[];t>=1e3;)t-=1e3,r.push("M");i=t/100|0,t%=100,r.push(n[i]),i=t/10|0,t%=10,r.push(n[10+i]),r.push(n[20+t]);var a=r.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 i in n)t.prototype[i]=n[i]},t.loadScript=function(t,e){var n=document.createElement("script"),i=!1;n.setAttribute("src",t),e&&(n.onload=function(){i||e(),i=!0}),document.getElementsByTagName("head")[0].appendChild(n)},t}(),ft=function(){function t(t,e,n,i,r,a){this.viewBox=t,this.scale=e,this.rotation=n,this.offsetX=i,this.offsetY=r;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+i,f=Math.abs(h-t[0])*e+r,p=Math.abs(t[3]-t[1])*e,g=Math.abs(t[2]-t[0])*e):(d=Math.abs(h-t[0])*e+i,f=Math.abs(u-t[1])*e+r,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,i="rotation"in e?e.rotation:this.rotation;return new t(this.viewBox.slice(),n,i,this.offsetX,this.offsetY,e.dontFlip)},convertToViewportPoint:function(t,e){return dt.applyTransform([t,e],this.transform)},convertToViewportRectangle:function(t){var e=dt.applyTransform([t[0],t[1]],this.transform),n=dt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],n[0],n[1]]},convertToPdfPoint:function(t,e){return dt.applyInverseTransform([t,e],this.transform)}},t}(),pt=[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];!function(){if(B.Promise)return"function"!=typeof B.Promise.all&&(B.Promise.all=function(t){var e,n,i=0,r=[],a=new B.Promise(function(t,i){e=t,n=i});return t.forEach(function(t,a){i++,t.then(function(t){r[a]=t,i--,0===i&&e(r)},n)}),0===i&&e(r),a}),"function"!=typeof B.Promise.resolve&&(B.Promise.resolve=function(t){return new B.Promise(function(e){e(t)})}),"function"!=typeof B.Promise.reject&&(B.Promise.reject=function(t){return new B.Promise(function(e,n){n(t)})}),void("function"!=typeof B.Promise.prototype.catch&&(B.Promise.prototype.catch=function(t){return B.Promise.prototype.then(void 0,t)}));var t=0,e=1,n=2,i=500,a={handlers:[],running:!1,unhandledRejections:[],pendingRejectionCheck:!1,scheduleHandlers:function(e){e._status!==t&&(this.handlers=this.handlers.concat(e._handlers),e._handlers=[],this.running||(this.running=!0,setTimeout(this.runHandlers.bind(this),0)))},runHandlers:function(){for(var t=1,i=Date.now()+t;this.handlers.length>0;){var r=this.handlers.shift(),a=r.thisPromise._status,s=r.thisPromise._value;try{a===e?"function"==typeof r.onResolve&&(s=r.onResolve(s)):"function"==typeof r.onReject&&(s=r.onReject(s),a=e,r.thisPromise._unhandledRejection&&this.removeUnhandeledRejection(r.thisPromise))}catch(t){a=n,s=t}if(r.nextPromise._updateStatus(a,s),Date.now()>=i)break}return this.handlers.length>0?void setTimeout(this.runHandlers.bind(this),0):void(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;ei){var n=this.unhandledRejections[e].promise._value,a="Unhandled rejection: "+n;n.stack&&(a+="\n"+n.stack),r(a),this.unhandledRejections.splice(e),e--}this.unhandledRejections.length&&this.scheduleRejectionCheck()}.bind(this),i))}},s=function(e){this._status=t,this._handlers=[];try{e.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(t){this._reject(t)}};s.all=function(t){function e(t){a._status!==n&&(c=[],r(t))}var i,r,a=new s(function(t,e){i=t,r=e}),o=t.length,c=[];if(0===o)return i(c),a;for(var l=0,h=t.length;la&&(a=s.length)}for(e=0,n=i.length;e>2,d=(3&c)<<4|l>>4,f=s+1>6:64,p=s+232&&e<127&&[34,35,60,62,63,96].indexOf(e)===-1?t:encodeURIComponent(t)}function a(t){var e=t.charCodeAt(0);return e>32&&e<127&&[34,35,60,62,96].indexOf(e)===-1?t:encodeURIComponent(t)}function s(t,s,o){function c(t){b.push(t)}var l=s||"scheme start",h=0,m="",A=!1,v=!1,b=[];t:for(;(t[h-1]!==f||0===h)&&!this._isInvalid;){var y=t[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(f===y)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;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":"?"===y?(this._query="?",l="query"):"#"===y?(this._fragment="#",l="fragment"):f!==y&&"\t"!==y&&"\n"!==y&&"\r"!==y&&(this._schemeData+=r(y));break;case"no scheme":if(o&&e(o._scheme)){l="relative";continue}c("Missing scheme."),n.call(this);break;case"relative or authority":if("/"!==y||"/"!==t[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),f===y){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=t[h+1],S=t[h+2];("file"!==this._scheme||!p.test(y)||":"!==x&&"|"!==x||f!==S&&"/"!==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 k=0;k0?e:t.length,n>0?n:t.length);return t.substring(t.lastIndexOf("/",i)+1,i)}function a(t){var n=e.globalScope.PDFJS;switch(t){case"pdfBug":return!!n&&n.pdfBug;case"disableAutoFetch":return!!n&&n.disableAutoFetch;case"disableStream":return!!n&&n.disableStream;case"disableRange":return!!n&&n.disableRange;case"disableFontFace":return!!n&&n.disableFontFace;case"disableCreateObjectURL":return!!n&&n.disableCreateObjectURL;case"disableWebGL":return!n||n.disableWebGL;case"cMapUrl":return n?n.cMapUrl:null;case"cMapPacked":return!!n&&n.cMapPacked;case"postMessageTransfers":return!n||n.postMessageTransfers;case"workerSrc":return n?n.workerSrc:null;case"disableWorker":return!!n&&n.disableWorker;case"maxImageSize":return n?n.maxImageSize:-1;case"imageResourcesPath":return n?n.imageResourcesPath:"";case"isEvalSupported":return!n||n.isEvalSupported;case"externalLinkTarget":if(!n)return m.NONE;switch(n.externalLinkTarget){case m.NONE:case m.SELF:case m.BLANK:case m.PARENT:case m.TOP:return n.externalLinkTarget}return h("PDFJS.externalLinkTarget is invalid: "+n.externalLinkTarget),n.externalLinkTarget=m.NONE,m.NONE;case"externalLinkRel":return n?n.externalLinkRel:f;case"enableStats":return!(!n||!n.enableStats);default:throw new Error("Unknown default setting: "+t)}}function s(){var t=a("externalLinkTarget");switch(t){case m.NONE:return!1;case m.SELF:case m.BLANK:case m.PARENT:case m.TOP:return!0}}function o(t,e){u("isValidUrl(), please use createValidAbsoluteUrl() instead.");var n=e?"http://example.com":null;return null!==d(t,n)}var c=e.assert,l=e.removeNullCharacters,h=e.warn,u=e.deprecated,d=e.createValidAbsoluteUrl,f="noopener noreferrer nofollow";n.prototype={create:function(t,e){c(t>0&&e>0,"invalid canvas size");var n=document.createElement("canvas");return n.width=t,n.height=e,n},reset:function(t,e,n){c(t,"canvas is not specified"),c(e>0&&n>0,"invalid canvas size"),t.width=e,t.height=n},destroy:function(t){c(t,"canvas is not specified"),t.width=0,t.height=0}};var p,g=function(){function t(){}var e=["ms","Moz","Webkit","O"],n=Object.create(null);return t.getProp=function(t,i){if(1===arguments.length&&"string"==typeof n[t])return n[t];i=i||document.documentElement;var r,a,s=i.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&&!n.isSyncFontLoadingSupported?this.prepareFontLoadEvent(i,r,p):p.complete()},n.prototype.queueLoadingCallback=function(t){function e(){for(i(!a.end,"completeRequest() cannot be called twice"),a.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++,a={id:r,complete:e,callback:t,started:Date.now()};return n.requests.push(a),a},n.prototype.prepareFontLoadEvent=function(t,e,n){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function r(t,e,n,i){var r=t.substr(0,e),a=t.substr(e+n);return r+i+a}function s(t,e){if(d++,d>30)return o("Load test font never loaded."),void e();u.font="30px "+t,u.fillText(".",0,20);var n=u.getImageData(0,0,1,1);return n.data[3]>0?void e():void setTimeout(s.bind(null,t,e))}var c,l,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,g=976;p=r(p,g,f.length,f);var m=16,A=1482184792,v=i(p,m);for(c=0,l=f.length-3;c=14&&(t=!0),t};Object.defineProperty(n,"isSyncFontLoadingSupported",{get:function(){return s(n,"isSyncFontLoadingSupported",l())},enumerable:!0,configurable:!0});var h={get value(){return s(this,"value",e.isEvalSupported())}},u=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=r(new Uint8Array(this.data)),e=this.loadedName,n="url(data:"+this.mimetype+";base64,"+btoa(t)+");",i='@font-face { font-family:"'+e+'";src:'+n+"}";return this.options.fontRegistry&&this.options.fontRegistry.registerFont(this,n),i},getPathGenerator:function(t,e){if(!(e in this.compiledGlyphs)){var n,i,r,a=t.get(this.loadedName+"_path_"+e);if(this.options.isEvalSupported&&h.value){var s,o="";for(i=0,r=a.length;i\\376\\377([^<]+)/g,function(t,e){for(var n=e.replace(/\\([0-3])([0-7])([0-7])/g,function(t,e,n,i){return String.fromCharCode(64*e+8*n+1*i)}),i="",r=0;r=32&&a<127&&60!==a&&62!==a&&38!==a?String.fromCharCode(a):"&#x"+(65536+a).toString(16).substring(1)+";"}return">"+i})}function i(t){if("string"==typeof t){t=n(t);var e=new DOMParser;t=e.parseFromString(t,"application/xml")}else t instanceof Document||r("Metadata: Invalid metadata object");this.metaDocument=t,this.metadata=Object.create(null),this.parse()}var r=e.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 i,r,a,s,o,c,l,h=e.childNodes;for(s=0,c=h.length;s>>8^s}return i^-1}function e(e,n,i,r){var a=r,s=n.length;i[a]=s>>24&255,i[a+1]=s>>16&255,i[a+2]=s>>8&255,i[a+3]=255&s,a+=4,i[a]=255&e.charCodeAt(0),i[a+1]=255&e.charCodeAt(1),i[a+2]=255&e.charCodeAt(2),i[a+3]=255&e.charCodeAt(3),a+=4,i.set(n,a),a+=n.length;var o=t(i,r+4,a);i[a]=o>>24&255,i[a+1]=o>>16&255,i[a+2]=o>>8&255,i[a+3]=255&o}function n(t,e,n){for(var i=1,r=0,a=e;a>3;break;case r.RGB_24BPP:l=2,c=8,u=3*d;break;case r.RGBA_32BPP:l=6,c=8,u=4*d;break;default:throw new Error("invalid format")}var g,m,A=new Uint8Array((1+u)*f),v=0,b=0;for(g=0;g>24&255,d>>16&255,d>>8&255,255&d,f>>24&255,f>>16&255,f>>8&255,255&f,c,l,0,0,0]),x=A.length,S=65535,k=Math.ceil(x/S),_=new Uint8Array(2+x+5*k+4),C=0;_[C++]=120,_[C++]=156;for(var w=0;x>S;)_[C++]=0,_[C++]=255,_[C++]=255,_[C++]=0,_[C++]=0,_.set(A.subarray(w,w+S),C),C+=S,w+=S,x-=S;_[C++]=1,_[C++]=255&x,_[C++]=x>>8&255,_[C++]=65535&~x&255,_[C++]=(65535&~x)>>8&255,_.set(A.subarray(w),C),C+=A.length-w;var T=n(A,0,A.length);_[C++]=T>>24&255,_[C++]=T>>16&255,_[C++]=T>>8&255,_[C++]=255&T;var L=a.length+3*s+y.length+_.length,P=new Uint8Array(L),E=0;return P.set(a,E),E+=a.length,e("IHDR",y,P,E),E+=s+y.length,e("IDATA",_,P,E),E+=s+_.length,e("IEND",new Uint8Array(0),P,E),h(P,"image/png",o)}for(var a=new Uint8Array([137,80,78,71,13,10,26,10]),s=12,o=new Int32Array(256),c=0;c<256;c++){for(var l=c,u=0;u<8;u++)l=1&l?3988292384^l>>1&2147483647:l>>1&2147483647;o[c]=l}return function(t,e){var n=void 0===t.kind?r.GRAYSCALE_1BPP:t.kind;return i(t,n,e)}}(),f=function(){function t(){this.fontSizeScale=1,this.fontWeight=u.fontWeight,this.fontSize=0,this.textMatrix=i,this.fontMatrix=n,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=u.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}(),p=function(){function t(t){for(var e=[],n=[],i=t.length,r=0;r0){i.style.borderWidth=t.borderStyle.width+"px",t.borderStyle.style!==r.UNDERLINE&&(a-=2*t.borderStyle.width,s-=2*t.borderStyle.width);var l=t.borderStyle.horizontalCornerRadius,h=t.borderStyle.verticalCornerRadius;if(l>0||h>0){var f=l+"px / "+h+"px";d.setProp("borderRadius",i,f)}switch(t.borderStyle.style){case r.SOLID:i.style.borderStyle="solid";break;case r.DASHED:i.style.borderStyle="dashed";break;case r.BEVELED:u("Unimplemented border style: beveled");break;case r.INSET:u("Unimplemented border style: inset");break;case r.UNDERLINE:i.style.borderBottomStyle="solid"}t.color?i.style.borderColor=o.makeCssRgb(0|t.color[0],0|t.color[1],0|t.color[2]):i.style.borderWidth=0}return i.style.left=c[0]+"px",i.style.top=c[1]+"px",i.style.width=a+"px",i.style.height=s+"px",i},_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 i=new k({container:t,trigger:e,color:n.color,title:n.title,contents:n.contents,hideWrapper:!0}),r=i.render();r.style.left=t.style.width,t.appendChild(r)},render:function(){throw new Error("Abstract method AnnotationElement.render called")}},t}(),g=function(){function t(t){p.call(this,t,!0)}return o.inherit(t,p,{render:function(){this.container.className="linkAnnotation";var t=document.createElement("a");return c(t,{url:this.data.url,target:this.data.newWindow?l.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}(),m=function(){function t(t){var e=!!(t.data.hasPopup||t.data.title||t.data.contents);p.call(this,t,e)}return o.inherit(t,p,{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}(),A=function(){function t(t,e){p.call(this,t,e)}return o.inherit(t,p,{render:function(){return this.container}}),t}(),v=function(){function t(t){var e=t.renderInteractiveForms||!t.data.hasAppearance&&!!t.data.fieldValue;A.call(this,t,e)}var e=["left","center","right"];return o.inherit(t,A,{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],i=n/this.data.maxLen;t.classList.add("comb"),t.style.letterSpacing="calc("+i+"px - 1ch)"}}else{t=document.createElement("div"),t.textContent=this.data.fieldValue,t.style.verticalAlign="middle",t.style.display="table-cell";var r=null;this.data.fontRefName&&(r=this.page.commonObjs.getData(this.data.fontRefName)),this._setTextStyle(t,r)}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 i=e.loadedName?'"'+e.loadedName+'", ':"",r=e.fallbackName||"Helvetica, sans-serif"; n.fontFamily=i+r}}}),t}(),b=function(){function t(t){A.call(this,t,t.renderInteractiveForms)}return o.inherit(t,A,{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}(),y=function(){function t(t){A.call(this,t,t.renderInteractiveForms)}return o.inherit(t,A,{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}(),x=function(){function t(t){A.call(this,t,t.renderInteractiveForms)}return o.inherit(t,A,{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&&r.setAttribute("selected",!0),t.appendChild(r)}return this.container.appendChild(t),this.container}}),t}(),S=function(){function t(t){var e=!(!t.data.title&&!t.data.contents);p.call(this,t,e)}return o.inherit(t,p,{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 k({container:this.container,trigger:e,color:this.data.color,title:this.data.title,contents:this.data.contents}),i=parseFloat(e.style.left),r=parseFloat(e.style.width);return d.setProp("transformOrigin",this.container,-(i+r)+"px -"+e.style.top),this.container.style.left=i+r+"px",this.container.appendChild(n.render()),this.container}}),t}(),k=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}var e=.7;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 n=document.createElement("div");n.className="popup";var i=this.color;if(i){var r=e*(255-i[0])+i[0],a=e*(255-i[1])+i[1],s=e*(255-i[2])+i[2];n.style.backgroundColor=o.makeCssRgb(0|r,0|a,0|s)}var c=this._formatContents(this.contents),l=document.createElement("h1");return l.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)),n.addEventListener("click",this._hide.bind(this,!0)),n.appendChild(l),n.appendChild(c),t.appendChild(n),t},_formatContents:function(t){for(var e=document.createElement("p"),n=t.split(/(?:\r\n?|\n)/),i=0,r=n.length;i1&&(h.vertical?o.canvasWidth=n.height*e._viewport.scale:o.canvasWidth=n.width*e._viewport.scale),e._textDivProperties.set(a,o),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=i.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:a,size:[y,x],m:v})}}function n(t){if(!t._canceled){var e=t._container,n=t._textDivs,i=t._capability,r=n.length;if(r>d)return t._renderingDone=!0,void i.resolve();var s=document.createElement("canvas");s.mozOpaque=!0;for(var o,c,l=s.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,a.setProp("transform",u,A)),t._textDivProperties.set(u,f)}}t._renderingDone=!0,i.resolve()}}function o(t){for(var e=t._bounds,n=t._viewport,r=c(n.width,n.height,e),a=0;a0&&(i=i?Math.min(a,i):a)}return i},A=1+Math.min(Math.abs(d),Math.abs(f));o.paddingLeft=m(g,32,16)/A,o.paddingTop=m(g,48,16)/A,o.paddingRight=m(g,0,16)/A,o.paddingBottom=m(g,16,16)/A,t._textDivProperties.set(s,o)}else o.paddingLeft=e[a].left-r[a].left,o.paddingTop=e[a].top-r[a].top,o.paddingRight=r[a].right-e[a].right,o.paddingBottom=r[a].bottom-e[a].bottom,t._textDivProperties.set(s,o)}}function c(t,e,n){var i=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,i);var r=new Array(n.length);return i.forEach(function(t){var e=t.index;r[e]={left:t.x1New,top:0,right:t.x2New,bottom:0}}),n.map(function(e,n){var a=r[n],s=i[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,i),i.forEach(function(t){var e=t.index;r[e].top=t.x1New,r[e].bottom=t.x2New}),r}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},i=[{start:-(1/0),end:1/0,boundary:n}];e.forEach(function(t){for(var e=0;e=0&&i[n].start>=t.y2;)n--;var r,a,s,o,c=-(1/0);for(s=e;s<=n;s++){r=i[s],a=r.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++)r=i[s],a=r.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++){r=i[s],a=r.boundary;var d=a.x2>t.x2?a:t;u===d?h[h.length-1].end=r.end:(h.push({start:r.start,end:r.end,boundary:d}),u=d)}for(i[e].start=0&&i[o].start>=a.y1;o--)f=i[o].boundary===a;for(o=n+1;!f&&ol[i+1]&&(c=n,n=i,i=c,c=a,a=s,s=c),l[i+1]>l[r+1]&&(c=i,i=r,r=c,c=s,s=o,o=c),l[n+1]>l[i+1]&&(c=n,n=i,i=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[i]+e.offsetX)*e.scaleX,m=(l[i+1]+e.offsetY)*e.scaleY,A=(l[r]+e.offsetX)*e.scaleX,v=(l[r+1]+e.offsetY)*e.scaleY;if(!(p>=v))for(var b,y,x,S,k,_,C,w,T,L=h[a],P=h[a+1],E=h[a+2],R=h[s],I=h[s+1],D=h[s+2],j=h[o],O=h[o+1],F=h[o+2],M=Math.round(p),N=Math.round(v),U=M;U<=N;U++){Uv?1:m===v?0:(m-U)/(m-v),b=g-(g-A)*T,y=R-(R-j)*T,x=I-(I-O)*T,S=D-(D-F)*T),T=Uv?1:(p-U)/(p-v),k=f-(f-A)*T,_=L-(L-j)*T,C=P-(P-O)*T,w=E-(E-F)*T;for(var B=Math.round(Math.min(b,k)),W=Math.round(Math.max(b,k)),G=d*U+4*B,X=B;X<=W;X++)T=(b-X)/(b-k),T=T<0?0:T>1?1:T,u[G++]=y-(y-_)*T|0,u[G++]=x-(x-C)*T|0,u[G++]=S-(S-w)*T|0,u[G++]=255}}function e(e,n,i){var r,a,s=n.coords,c=n.colors;switch(n.type){case"lattice":var l=n.verticesPerRow,h=Math.floor(s.length/l)-1,u=l-1;for(r=0;r0;)f[p++]=m&g?0:255,g>>=1;var A=0;for(p=0,0!==f[p]&&(l[0]=1,++A),n=1;n>2)+(f[p+1]?4:0)+(f[p-u+1]?8:0),h[v]&&(l[i+n]=h[v],++A),p++;if(f[p-u]!==f[p]&&(l[i+n]=f[p]?2:4,++A),A>a)return null}for(p=u*(o-1),i=e*c,0!==f[p]&&(l[i]=8,++A),n=1;na)return null;var b=new Int32Array([0,c,-1,0,-c,0,0,0,1]),y=[];for(e=0;A&&e<=o;e++){for(var x=e*c,S=x+s;x>4,l[x]&=C>>2|C<<2),_.push(x%c),_.push(x/c|0),--A}while(w!==x);y.push(_),--e}}var L=function(t){t.save(),t.scale(1/s,-1/o),t.translate(0,-o),t.beginPath();for(var e=0,n=y.length;e>3,k=4294967295,_=j.value||!D.value?4278190080:255;for(i=0;iS?c:8*C-7,L=T&-8,P=0,E=0;w>=1}for(;n=u&&(a=h,s=c*a),n=0,r=s;r--;)A[n++]=m[g++],A[n++]=m[g++],A[n++]=m[g++],A[n++]=255;t.putImageData(p,0,i*I)}else b("bad image kind: "+e.kind)}function n(t,e){for(var n=e.height,i=e.width,r=n%I,a=(n-r)/I,s=0===r?a:a+1,o=t.createImageData(i,I),c=0,l=e.data,h=o.data,u=0;u>=1}t.putImageData(o,0,u*I)}}function i(t,e){for(var n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"],i=0,r=n.length;i>8,t[a-2]=t[a-2]*s+n*o>>8,t[a-1]=t[a-1]*s+i*o>>8}}}function v(t,e,n){for(var i=t.length,r=1/255,a=3;a>8]>>8:e[r]*a>>16}}function M(t,e,n,i,a,s,o){var c,l=!!s,h=l?s[0]:0,u=l?s[1]:0,d=l?s[2]:0;c="Luminosity"===a?C:v;for(var f=1048576,p=Math.min(i,Math.ceil(f/n)),g=0;gB&&"function"==typeof n,u=l?Date.now()+U:0,d=0,f=this.commonObjs,p=this.objs;;){if(void 0!==i&&s===i.nextBreakPoint)return i.breakIt(s,n),s;if(c=a[s],c!==h.dependency)this[c].apply(this,r[s]);else for(var g=r[s],m=0,A=g.length;mB){if(Date.now()>u)return n(),s;d=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=W[t]},setLineJoin:function(t){this.ctx.lineJoin=G[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,a=this.cachedCanvases.getCanvas(r,e,n,!0),s=this.ctx,o=s.mozCurrentTransform;this.ctx.save();var c=a.context;c.scale(1/t.scaleX,1/t.scaleY),c.translate(-t.offsetX,-t.offsetY),c.transform.apply(c,o),t.startTransformInverse=c.mozCurrentTransformInverse,i(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(),N(this.ctx,this.current.activeSMask,t),this.ctx.restore(),this.ctx.save(),i(t,this.ctx),this.current.resumeSMaskCtx=t;var e=f.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(),N(this.ctx,this.current.activeSMask,t),this.ctx.restore(),i(t,this.ctx);var e=f.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,i,r,a){this.ctx.transform(t,e,n,i,r,a),this.cachedGetSinglePixelWidth=null},constructPath:function(t,e){for(var n=this.ctx,i=this.current,r=i.x,a=i.y,s=0,o=0,c=t.length;sT?T:e;this.current.fontSizeScale=e/l;var h=s+" "+a+" "+l+"px "+c;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,i,r,a){this.current.textMatrix=[t,e,n,i,r,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 i,r=this.ctx,a=this.current,s=a.font,o=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,l=o&u.FILL_STROKE_MASK,h=!!(o&u.ADD_TO_PATH_FLAG);if((s.disableFontFace||h)&&(i=s.getPathGenerator(this.commonObjs,t)),s.disableFontFace?(r.save(),r.translate(e,n),r.beginPath(),i(r,c),l!==u.FILL&&l!==u.FILL_STROKE||r.fill(),l!==u.STROKE&&l!==u.FILL_STROKE||r.stroke(),r.restore()):(l!==u.FILL&&l!==u.FILL_STROKE||r.fillText(t,e,n),l!==u.STROKE&&l!==u.FILL_STROKE||r.strokeText(t,e,n)),h){var d=this.pendingTextPaths||(this.pendingTextPaths=[]);d.push({transform:r.mozCurrentTransform,x:e,y:n,fontSize:c,addToPath:i})}},get isFontSubpixelAAEnabled(){var t=this.canvasFactory.create(10,10).getContext("2d");t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,n=!1,i=3;i0&&e[i]<255){n=!0;break}return y(this,"isFontSubpixelAAEnabled",n)},showText:function(t){var e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);var i=e.fontSize;if(0!==i){var r=this.ctx,a=e.fontSizeScale,s=e.charSpacing,o=e.wordSpacing,c=e.fontDirection,l=e.textHScale*c,h=t.length,d=n.vertical,f=d?1:-1,p=n.defaultVMetrics,g=i*e.fontMatrix[0],A=e.textRenderingMode===u.FILL&&!n.disableFontFace;r.save(),r.transform.apply(r,e.textMatrix),r.translate(e.x,e.y+e.textRise),e.patternFill&&(r.fillStyle=e.fillColor.getPattern(r,this)),c>0?r.scale(l,-1):r.scale(l,1);var v=e.lineWidth,b=e.textMatrixScale;if(0===b||0===v){var y=e.textRenderingMode&u.FILL_STROKE_MASK;y!==u.STROKE&&y!==u.FILL_STROKE||(this.cachedGetSinglePixelWidth=null,v=this.getSinglePixelWidth()*P)}else v/=b;1!==a&&(r.scale(a,a),v/=a),r.lineWidth=v;var x,S=0;for(x=0;x0){var M=1e3*r.measureText(R).width/i*a;if(DL&&(h=c/L,c=L),l>L&&(u=l/L,l=L);var d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);var m=this.cachedCanvases.getCanvas(d,c,l,!0),A=m.context;A.scale(1/h,1/u),A.translate(-s,-o),A.transform.apply(A,n),t.smask?this.smaskStack.push({canvas:m.canvas,context:A,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)),i(e,A),this.ctx=A,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 F,this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)},endAnnotations:function(){this.restore()},beginAnnotation:function(t,e,n){if(this.save(),A(t)&&4===t.length){var i=t[2]-t[0],r=t[3]-t[1];this.ctx.rect(t[0],t[1],i,r),this.clip(),this.endPath()}this.transform.apply(this,e),this.transform.apply(this,n)},endAnnotation:function(){this.restore()},paintJpegXObject:function(t,e,n){var i=this.objs.get(t);if(!i)return void x("Dependent image isn't ready yet");this.save();var r=this.ctx;if(r.scale(1/e,-1/n),r.drawImage(i,0,0,i.width,i.height,0,-n,e,n),this.imageLayer){var a=r.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,i=t.width,r=t.height,a=this.current.fillColor,o=this.current.patternFill,c=this.processingType3;if(E&&c&&void 0===c.compiled&&(i<=R&&r<=R?c.compiled=s({data:t.data,width:i,height:r}):c.compiled=null),c&&c.compiled)return void c.compiled(e);var l=this.cachedCanvases.getCanvas("maskCanvas",i,r),h=l.context;h.save(),n(h,t),h.globalCompositeOperation="source-in",h.fillStyle=o?a.getPattern(h,this):a,h.fillRect(0,0,i,r),h.restore(),this.paintInlineImageXObject(l.canvas)},paintImageMaskXObjectRepeat:function(t,e,i,r){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=r.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(r.drawImage(a,0,0,g,m,0,-i,n,i),this.imageLayer){var y=this.getCanvasPosition(0,-i);this.imageLayer.appendImage({imgData:t,left:y[0],top:y[1],width:n/o[0],height:i/o[3]})}this.restore()},paintInlineImageXObjectGroup:function(t,n){var i=this.ctx,r=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",r,a),o=s.context;e(o,t);for(var c=0,l=n.length;c1&&_("getDocument is called with pdfDataRangeTransport, passwordCallback or progressCallback argument"),e&&(e instanceof q||(e=Object.create(e),e.length=t.length,e.initialData=t.initialData,e.abort||(e.abort=function(){})),t=Object.create(t),t.range=e),r.onPassword=n||null,r.onProgress=i||null;var a;"string"==typeof t?a={url:t}:P(t)?a={data:t}:t instanceof q?a={range:t}:("object"!=typeof t&&k("Invalid parameter in getDocument, need either Uint8Array, string or a parameter object"),t.url||t.data||t.range||k("Invalid parameter object: need either .data, .range or .url"),a=t);var s={},o=null,c=null;for(var l in a)if("url"!==l||"undefined"==typeof window)if("range"!==l)if("worker"!==l)if("data"!==l||a[l]instanceof Uint8Array)s[l]=a[l];else{var h=a[l];"string"==typeof h?s[l]=I(h):"object"!=typeof h||null===h||isNaN(h.length)?P(h)?s[l]=new Uint8Array(h):k("Invalid PDF binary data: either typed array, string or array-like object is expected in the data property."):s[l]=new Uint8Array(h)}else c=a[l];else o=a[l];else s[l]=new URL(a[l],window.location).href;s.rangeChunkSize=s.rangeChunkSize||W,c||(c=new K,r._worker=c);var d=r.docId;return c.promise.then(function(){if(r.destroyed)throw new Error("Loading aborted");return u(c,s,o,d).then(function(t){if(r.destroyed)throw new Error("Loading aborted");var e=new p(d,t,c.port),n=new Z(e,r,o);r._transport=n,e.send("Ready",null)})}).catch(r._capability.reject),r}function u(t,e,n,i){return t.destroyed?Promise.reject(new Error("Worker was destroyed")):(e.disableAutoFetch=U("disableAutoFetch"),e.disableStream=U("disableStream"),e.chunkedViewerLoading=!!n,n&&(e.length=n.length,e.initialData=n.initialData),t.messageHandler.sendWithPromise("GetDocRequest",{docId:i,source:e,disableRange:U("disableRange"),maxImageSize:U("maxImageSize"),cMapUrl:U("cMapUrl"),cMapPacked:U("cMapPacked"),disableFontFace:U("disableFontFace"),disableCreateObjectURL:U("disableCreateObjectURL"),postMessageTransfers:U("postMessageTransfers")&&!X,docBaseUrl:e.docBaseUrl}).then(function(e){if(t.destroyed)throw new Error("Worker was destroyed");return e}))}var d,f=r.InvalidPDFException,p=r.MessageHandler,g=r.MissingPDFException,m=r.PageViewport,A=r.PasswordException,v=r.StatTimer,b=r.UnexpectedResponseException,y=r.UnknownErrorException,x=r.Util,S=r.createPromiseCapability,k=r.error,_=r.deprecated,C=r.getVerbosityLevel,w=r.info,T=r.isInt,L=r.isArray,P=r.isArrayBuffer,E=r.isSameOrigin,R=r.loadJpegStream,I=r.stringToBytes,D=r.globalScope,j=r.warn,O=a.FontFaceObject,F=a.FontLoader,M=s.CanvasGraphics,N=o.Metadata,U=c.getDefaultSetting,B=c.DOMCanvasFactory,W=65536,G=!1,X=!1,H=null,z=!1;"undefined"==typeof window&&(G=!0,"undefined"==typeof require.ensure&&(require.ensure=require("node-ensure")),z=!0),"undefined"!=typeof __webpack_require__&&(z=!0),"undefined"!=typeof requirejs&&requirejs.toUrl&&(d=requirejs.toUrl("pdfjs-dist/build/pdf.worker.js"));var Y="undefined"!=typeof requirejs&&requirejs.load;H=z?function(t){require.ensure([],function(){var e=require("./pdf.worker.js");t(e.WorkerMessageHandler)})}:Y?function(t){requirejs(["pdfjs-dist/build/pdf.worker"],function(e){t(e.WorkerMessageHandler)})}:null;var V=function(){function t(){this._capability=S(),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(){this.destroyed=!0;var t=this._transport?this._transport.destroy():Promise.resolve();return t.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}(),q=function(){function t(t,e){this.length=t,this.initialData=e,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._readyCapability=S()}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,i=0,r=n.length;i=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 i="print"===t.intent?"print":"display",r=t.renderInteractiveForms===!0,a=t.canvasFactory||new B;this.intentStates[i]||(this.intentStates[i]=Object.create(null));var s=this.intentStates[i];s.displayReadyCapability||(s.receivingOperatorList=!0,s.displayReadyCapability=S(),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this.stats.time("Page Request"),this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageNumber-1, -intent:i,renderInteractiveForms:r}));var o=new et(e,t,this.objs,this.commonObjs,s.operatorList,this.pageNumber,a);o.useRequestAnimationFrame="print"!==i,s.renderTasks||(s.renderTasks=[]),s.renderTasks.push(o);var c=o.task;t.continueCallback&&(_("render is used with continueCallback parameter"),c.onContinue=t.continueCallback);var l=this;return s.displayReadyCapability.promise.then(function(t){return l.pendingCleanup?void e():(n.time("Rendering"),o.initializeGraphics(t),void o.operatorListChanged())},function(t){e(t)}),c},getOperatorList:function(){function t(){if(i.operatorList.lastChunk){i.opListReadCapability.resolve(i.operatorList);var t=i.renderTasks.indexOf(n);t>=0&&i.renderTasks.splice(t,1)}}var e="oplist";this.intentStates[e]||(this.intentStates[e]=Object.create(null));var n,i=this.intentStates[e];return i.opListReadCapability||(n={},n.operatorListChanged=t,i.receivingOperatorList=!0,i.opListReadCapability=S(),i.renderTasks=[],i.renderTasks.push(n),i.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageIndex,intent:e})),i.opListReadCapability.promise},getTextContent:function(t){return this.transport.messageHandler.sendWithPromise("GetTextContent",{pageIndex:this.pageNumber-1,normalizeWhitespace:!(!t||t.normalizeWhitespace!==!0),combineTextItems:!t||t.disableCombineTextItems!==!0})},_destroy:function(){this.destroyed=!0,this.transport.pageCache[this.pageIndex]=null;var t=[];return Object.keys(this.intentStates).forEach(function(e){if("oplist"!==e){var n=this.intentStates[e];n.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(){_("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,i,r=this.intentStates[e];for(n=0,i=t.length;n=0;return r=t===a?t:s?new t.constructor(a,t.byteOffset,t.byteLength):new t.constructor(t),i.set(t,r),r}r=L(t)?[]:{},i.set(t,r);for(var o in t){for(var c,l=t;!(c=Object.getOwnPropertyDescriptor(l,o));)l=Object.getPrototypeOf(l);"undefined"!=typeof c.value&&"function"!=typeof c.value&&(r[o]=n(c.value))}return r}if(!this._defer)return void this._listeners.forEach(function(e){e.call(this,{data:t})},this);var i=new WeakMap,r={data:n(t)};this._deferred.then(function(){this._listeners.forEach(function(t){t.call(this,r)},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=[]}},a.prototype={get promise(){return this._readyCapability.promise},get port(){return this._port},get messageHandler(){return this._messageHandler},_initialize:function(){if(!G&&!U("disableWorker")&&"undefined"!=typeof Worker){var e=t();try{E(window.location.href,e)||(e=r(new URL(e,window.location).href));var n=new Worker(e),i=new p("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();var e=t&&t.supportTypedArray;e?(this._messageHandler=i,this._port=n,this._webWorker=n,t.supportTransfers||(X=!0),this._readyCapability.resolve(),i.send("configure",{verbosity:C()})):(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=U("postMessageTransfers")&&!X,e=new Uint8Array([t?255:0]);try{i.send("test",e,[e.buffer])}catch(t){w("Cannot use postMessage transfers"),e[0]=0,i.send("test",e)}};return void o()}catch(t){w("The worker has been disabled.")}}this._setupFakeWorker()},_setupFakeWorker:function(){G||U("disableWorker")||(j("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,i=new n(e);this._port=i;var r="fake"+o++,a=new p(r+"_worker",r,i);t.setup(a,i);var s=new p(r,r+"_worker",i);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)}},a}(),Z=function(){function t(t,e,n){this.messageHandler=t,this.loadingTask=e,this.pdfDataRangeTransport=n,this.commonObjs=new $,this.fontLoader=new F(e.docId),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this.pageCache=[],this.pagePromises=[],this.downloadInfoCapability=S(),this.setupMessageHandler()}return t.prototype={destroy:function(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=S(),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,i=new J(e,this,n);this.pdfDocument=i,n._capability.resolve(i)},this),t.on("PasswordRequest",function(t){if(this._passwordCapability=S(),e.onPassword){var n=function(t){this._passwordCapability.resolve({password:t})}.bind(this);e.onPassword(n,t.code)}else this._passwordCapability.reject(new A(t.message,t.code));return this._passwordCapability.promise},this),t.on("PasswordException",function(t){e._capability.reject(new A(t.message,t.code))},this),t.on("InvalidPDF",function(t){this.loadingTask._capability.reject(new f(t.message))},this),t.on("MissingPDF",function(t){this.loadingTask._capability.reject(new g(t.message))},this),t.on("UnexpectedResponse",function(t){this.loadingTask._capability.reject(new b(t.message,t.status))},this),t.on("UnknownError",function(t){this.loadingTask._capability.reject(new y(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){var e=this.pageCache[t.pageIndex];e._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 i=t[2];if("error"in i){var r=i.error;j("Error during font loading: "+r),this.commonObjs.resolve(e,r);break}var a=null;U("pdfBug")&&D.FontInspector&&D.FontInspector.enabled&&(a={registerFont:function(t,e){D.FontInspector.fontAdded(t,e)}});var s=new O(i,{isEvalSuported:U("isEvalSupported"),disableFontFace:U("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:k("Got unknown common object type "+n)}}},this),t.on("obj",function(t){if(!this.destroyed){var e,n=t[0],i=t[1],r=t[2],a=this.pageCache[i];if(!a.objs.hasData(n))switch(r){case"JpegStream":e=t[3],R(n,e,a.objs);break;case"Image":e=t[3],a.objs.resolve(n,e);var s=8e6;e&&"data"in e&&e.data.length>s&&(a.cleanupAfterRender=!0);break;default:k("Got unknown object type "+r)}}},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):k(t.error),n.operatorList){n.operatorList.lastChunk=!0;for(var i=0;ithis.numPages)return Promise.reject(new Error("Invalid page request"));var n=t-1;if(n in this.pagePromises)return this.pagePromises[n];var i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(function(t){if(this.destroyed)throw new Error("Transport destroyed");var e=new Q(n,t,this);return this.pageCache[n]=e,e}.bind(this));return this.pagePromises[n]=i,i},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 N(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>3,k=4294967295,_=j.value||!D.value?4278190080:255;for(i=0;iS?c:8*C-7,L=T&-8,P=0,E=0;w>=1}for(;n=u&&(a=h,s=c*a),n=0,r=s;r--;)A[n++]=m[g++],A[n++]=m[g++],A[n++]=m[g++],A[n++]=255;t.putImageData(p,0,i*I)}else b("bad image kind: "+e.kind)}function n(t,e){for(var n=e.height,i=e.width,r=n%I,a=(n-r)/I,s=0===r?a:a+1,o=t.createImageData(i,I),c=0,l=e.data,h=o.data,u=0;u>=1}t.putImageData(o,0,u*I)}}function i(t,e){for(var n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"],i=0,r=n.length;i>8,t[a-2]=t[a-2]*s+n*o>>8,t[a-1]=t[a-1]*s+i*o>>8}}}function v(t,e,n){for(var i=t.length,r=1/255,a=3;a>8]>>8:e[r]*a>>16}}function M(t,e,n,i,a,s,o){var c,l=!!s,h=l?s[0]:0,u=l?s[1]:0,d=l?s[2]:0;c="Luminosity"===a?C:v;for(var f=1048576,p=Math.min(i,Math.ceil(f/n)),g=0;gB&&"function"==typeof n,u=l?Date.now()+U:0,d=0,f=this.commonObjs,p=this.objs;;){if(void 0!==i&&s===i.nextBreakPoint)return i.breakIt(s,n),s;if(c=a[s],c!==h.dependency)this[c].apply(this,r[s]);else for(var g=r[s],m=0,A=g.length;mB){if(Date.now()>u)return n(),s;d=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=W[t]},setLineJoin:function(t){this.ctx.lineJoin=G[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,a=this.cachedCanvases.getCanvas(r,e,n,!0),s=this.ctx,o=s.mozCurrentTransform;this.ctx.save();var c=a.context;c.scale(1/t.scaleX,1/t.scaleY),c.translate(-t.offsetX,-t.offsetY),c.transform.apply(c,o),t.startTransformInverse=c.mozCurrentTransformInverse,i(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(),N(this.ctx,this.current.activeSMask,t),this.ctx.restore(),this.ctx.save(),i(t,this.ctx),this.current.resumeSMaskCtx=t;var e=f.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(),N(this.ctx,this.current.activeSMask,t),this.ctx.restore(),i(t,this.ctx);var e=f.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,i,r,a){this.ctx.transform(t,e,n,i,r,a),this.cachedGetSinglePixelWidth=null},constructPath:function(t,e){for(var n=this.ctx,i=this.current,r=i.x,a=i.y,s=0,o=0,c=t.length;sT?T:e;this.current.fontSizeScale=e/l;var h=s+" "+a+" "+l+"px "+c;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,i,r,a){this.current.textMatrix=[t,e,n,i,r,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 i,r=this.ctx,a=this.current,s=a.font,o=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,l=o&u.FILL_STROKE_MASK,h=!!(o&u.ADD_TO_PATH_FLAG);if((s.disableFontFace||h)&&(i=s.getPathGenerator(this.commonObjs,t)),s.disableFontFace?(r.save(),r.translate(e,n),r.beginPath(),i(r,c),l!==u.FILL&&l!==u.FILL_STROKE||r.fill(),l!==u.STROKE&&l!==u.FILL_STROKE||r.stroke(),r.restore()):(l!==u.FILL&&l!==u.FILL_STROKE||r.fillText(t,e,n),l!==u.STROKE&&l!==u.FILL_STROKE||r.strokeText(t,e,n)),h){var d=this.pendingTextPaths||(this.pendingTextPaths=[]);d.push({transform:r.mozCurrentTransform,x:e,y:n,fontSize:c,addToPath:i})}},get isFontSubpixelAAEnabled(){var t=this.canvasFactory.create(10,10).getContext("2d");t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,n=!1,i=3;i0&&e[i]<255){n=!0;break}return y(this,"isFontSubpixelAAEnabled",n)},showText:function(t){var e=this.current,n=e.font;if(n.isType3Font)return this.showType3Text(t);var i=e.fontSize;if(0!==i){var r=this.ctx,a=e.fontSizeScale,s=e.charSpacing,o=e.wordSpacing,c=e.fontDirection,l=e.textHScale*c,h=t.length,d=n.vertical,f=d?1:-1,p=n.defaultVMetrics,g=i*e.fontMatrix[0],A=e.textRenderingMode===u.FILL&&!n.disableFontFace;r.save(),r.transform.apply(r,e.textMatrix),r.translate(e.x,e.y+e.textRise),e.patternFill&&(r.fillStyle=e.fillColor.getPattern(r,this)),c>0?r.scale(l,-1):r.scale(l,1);var v=e.lineWidth,b=e.textMatrixScale;if(0===b||0===v){var y=e.textRenderingMode&u.FILL_STROKE_MASK;y!==u.STROKE&&y!==u.FILL_STROKE||(this.cachedGetSinglePixelWidth=null,v=this.getSinglePixelWidth()*P)}else v/=b;1!==a&&(r.scale(a,a),v/=a),r.lineWidth=v;var x,S=0;for(x=0;x0){var M=1e3*r.measureText(R).width/i*a;if(DL&&(h=c/L,c=L),l>L&&(u=l/L,l=L);var d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);var m=this.cachedCanvases.getCanvas(d,c,l,!0),A=m.context;A.scale(1/h,1/u),A.translate(-s,-o),A.transform.apply(A,n),t.smask?this.smaskStack.push({canvas:m.canvas,context:A,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)),i(e,A),this.ctx=A,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 F,this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)},endAnnotations:function(){this.restore()},beginAnnotation:function(t,e,n){if(this.save(),A(t)&&4===t.length){var i=t[2]-t[0],r=t[3]-t[1];this.ctx.rect(t[0],t[1],i,r),this.clip(),this.endPath()}this.transform.apply(this,e),this.transform.apply(this,n)},endAnnotation:function(){this.restore()},paintJpegXObject:function(t,e,n){var i=this.objs.get(t);if(!i)return void x("Dependent image isn't ready yet");this.save();var r=this.ctx;if(r.scale(1/e,-1/n),r.drawImage(i,0,0,i.width,i.height,0,-n,e,n),this.imageLayer){var a=r.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,i=t.width,r=t.height,a=this.current.fillColor,o=this.current.patternFill,c=this.processingType3;if(E&&c&&void 0===c.compiled&&(i<=R&&r<=R?c.compiled=s({data:t.data,width:i,height:r}):c.compiled=null),c&&c.compiled)return void c.compiled(e);var l=this.cachedCanvases.getCanvas("maskCanvas",i,r),h=l.context;h.save(),n(h,t),h.globalCompositeOperation="source-in",h.fillStyle=o?a.getPattern(h,this):a,h.fillRect(0,0,i,r),h.restore(),this.paintInlineImageXObject(l.canvas)},paintImageMaskXObjectRepeat:function(t,e,i,r){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=r.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(r.drawImage(a,0,0,g,m,0,-i,n,i),this.imageLayer){var y=this.getCanvasPosition(0,-i);this.imageLayer.appendImage({imgData:t,left:y[0],top:y[1],width:n/o[0],height:i/o[3]})}this.restore()},paintInlineImageXObjectGroup:function(t,n){var i=this.ctx,r=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",r,a),o=s.context;e(o,t);for(var c=0,l=n.length;c1&&_("getDocument is called with pdfDataRangeTransport, passwordCallback or progressCallback argument"),e&&(e instanceof q||(e=Object.create(e),e.length=t.length,e.initialData=t.initialData,e.abort||(e.abort=function(){})),t=Object.create(t),t.range=e),r.onPassword=n||null,r.onProgress=i||null;var a;"string"==typeof t?a={url:t}:P(t)?a={data:t}:t instanceof q?a={range:t}:("object"!=typeof t&&k("Invalid parameter in getDocument, need either Uint8Array, string or a parameter object"),t.url||t.data||t.range||k("Invalid parameter object: need either .data, .range or .url"),a=t);var s={},o=null,c=null;for(var l in a)if("url"!==l||"undefined"==typeof window)if("range"!==l)if("worker"!==l)if("data"!==l||a[l]instanceof Uint8Array)s[l]=a[l];else{var h=a[l];"string"==typeof h?s[l]=I(h):"object"!=typeof h||null===h||isNaN(h.length)?P(h)?s[l]=new Uint8Array(h):k("Invalid PDF binary data: either typed array, string or array-like object is expected in the data property."):s[l]=new Uint8Array(h)}else c=a[l];else o=a[l];else s[l]=new URL(a[l],window.location).href;s.rangeChunkSize=s.rangeChunkSize||W,s.disableNativeImageDecoder=s.disableNativeImageDecoder===!0,c||(c=new K,r._worker=c);var d=r.docId;return c.promise.then(function(){if(r.destroyed)throw new Error("Loading aborted");return u(c,s,o,d).then(function(t){if(r.destroyed)throw new Error("Loading aborted");var e=new p(d,t,c.port),n=new Z(e,r,o);r._transport=n,e.send("Ready",null)})}).catch(r._capability.reject),r}function u(t,e,n,i){return t.destroyed?Promise.reject(new Error("Worker was destroyed")):(e.disableAutoFetch=U("disableAutoFetch"),e.disableStream=U("disableStream"),e.chunkedViewerLoading=!!n,n&&(e.length=n.length,e.initialData=n.initialData),t.messageHandler.sendWithPromise("GetDocRequest",{docId:i,source:e,disableRange:U("disableRange"),maxImageSize:U("maxImageSize"),cMapUrl:U("cMapUrl"),cMapPacked:U("cMapPacked"),disableFontFace:U("disableFontFace"),disableCreateObjectURL:U("disableCreateObjectURL"),postMessageTransfers:U("postMessageTransfers")&&!X,docBaseUrl:e.docBaseUrl,disableNativeImageDecoder:e.disableNativeImageDecoder}).then(function(e){if(t.destroyed)throw new Error("Worker was destroyed");return e}))}var d,f=r.InvalidPDFException,p=r.MessageHandler,g=r.MissingPDFException,m=r.PageViewport,A=r.PasswordException,v=r.StatTimer,b=r.UnexpectedResponseException,y=r.UnknownErrorException,x=r.Util,S=r.createPromiseCapability,k=r.error,_=r.deprecated,C=r.getVerbosityLevel,w=r.info,T=r.isInt,L=r.isArray,P=r.isArrayBuffer,E=r.isSameOrigin,R=r.loadJpegStream,I=r.stringToBytes,D=r.globalScope,j=r.warn,O=a.FontFaceObject,F=a.FontLoader,M=s.CanvasGraphics,N=o.Metadata,U=c.getDefaultSetting,B=c.DOMCanvasFactory,W=65536,G=!1,X=!1,H=null,z=!1;"undefined"==typeof window&&(G=!0,"undefined"==typeof require.ensure&&(require.ensure=require("node-ensure")),z=!0),"undefined"!=typeof __webpack_require__&&(z=!0),"undefined"!=typeof requirejs&&requirejs.toUrl&&(d=requirejs.toUrl("pdfjs-dist/build/pdf.worker.js"));var Y="undefined"!=typeof requirejs&&requirejs.load;H=z?function(t){require.ensure([],function(){var e=require("./pdf.worker.js");t(e.WorkerMessageHandler)})}:Y?function(t){requirejs(["pdfjs-dist/build/pdf.worker"],function(e){t(e.WorkerMessageHandler)})}:null;var V=function(){function t(){this._capability=S(),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(){this.destroyed=!0;var t=this._transport?this._transport.destroy():Promise.resolve();return t.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}(),q=function(){function t(t,e){this.length=t,this.initialData=e,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._readyCapability=S()}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,i=0,r=n.length;i=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 i="print"===t.intent?"print":"display",r=t.renderInteractiveForms===!0,a=t.canvasFactory||new B;this.intentStates[i]||(this.intentStates[i]=Object.create(null));var s=this.intentStates[i];s.displayReadyCapability||(s.receivingOperatorList=!0,s.displayReadyCapability=S(),s.operatorList={fnArray:[],argsArray:[], +lastChunk:!1},this.stats.time("Page Request"),this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageNumber-1,intent:i,renderInteractiveForms:r}));var o=new et(e,t,this.objs,this.commonObjs,s.operatorList,this.pageNumber,a);o.useRequestAnimationFrame="print"!==i,s.renderTasks||(s.renderTasks=[]),s.renderTasks.push(o);var c=o.task;t.continueCallback&&(_("render is used with continueCallback parameter"),c.onContinue=t.continueCallback);var l=this;return s.displayReadyCapability.promise.then(function(t){return l.pendingCleanup?void e():(n.time("Rendering"),o.initializeGraphics(t),void o.operatorListChanged())},function(t){e(t)}),c},getOperatorList:function(){function t(){if(i.operatorList.lastChunk){i.opListReadCapability.resolve(i.operatorList);var t=i.renderTasks.indexOf(n);t>=0&&i.renderTasks.splice(t,1)}}var e="oplist";this.intentStates[e]||(this.intentStates[e]=Object.create(null));var n,i=this.intentStates[e];return i.opListReadCapability||(n={},n.operatorListChanged=t,i.receivingOperatorList=!0,i.opListReadCapability=S(),i.renderTasks=[],i.renderTasks.push(n),i.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageIndex,intent:e})),i.opListReadCapability.promise},getTextContent:function(t){return this.transport.messageHandler.sendWithPromise("GetTextContent",{pageIndex:this.pageNumber-1,normalizeWhitespace:!(!t||t.normalizeWhitespace!==!0),combineTextItems:!t||t.disableCombineTextItems!==!0})},_destroy:function(){this.destroyed=!0,this.transport.pageCache[this.pageIndex]=null;var t=[];return Object.keys(this.intentStates).forEach(function(e){if("oplist"!==e){var n=this.intentStates[e];n.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(){_("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,i,r=this.intentStates[e];for(n=0,i=t.length;n=0;return r=t===a?t:s?new t.constructor(a,t.byteOffset,t.byteLength):new t.constructor(t),i.set(t,r),r}r=L(t)?[]:{},i.set(t,r);for(var o in t){for(var c,l=t;!(c=Object.getOwnPropertyDescriptor(l,o));)l=Object.getPrototypeOf(l);"undefined"!=typeof c.value&&"function"!=typeof c.value&&(r[o]=n(c.value))}return r}if(!this._defer)return void this._listeners.forEach(function(e){e.call(this,{data:t})},this);var i=new WeakMap,r={data:n(t)};this._deferred.then(function(){this._listeners.forEach(function(t){t.call(this,r)},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=[]}},a.prototype={get promise(){return this._readyCapability.promise},get port(){return this._port},get messageHandler(){return this._messageHandler},_initialize:function(){if(!G&&!U("disableWorker")&&"undefined"!=typeof Worker){var e=t();try{E(window.location.href,e)||(e=r(new URL(e,window.location).href));var n=new Worker(e),i=new p("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();var e=t&&t.supportTypedArray;e?(this._messageHandler=i,this._port=n,this._webWorker=n,t.supportTransfers||(X=!0),this._readyCapability.resolve(),i.send("configure",{verbosity:C()})):(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=U("postMessageTransfers")&&!X,e=new Uint8Array([t?255:0]);try{i.send("test",e,[e.buffer])}catch(t){w("Cannot use postMessage transfers"),e[0]=0,i.send("test",e)}};return void o()}catch(t){w("The worker has been disabled.")}}this._setupFakeWorker()},_setupFakeWorker:function(){G||U("disableWorker")||(j("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,i=new n(e);this._port=i;var r="fake"+o++,a=new p(r+"_worker",r,i);t.setup(a,i);var s=new p(r,r+"_worker",i);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)}},a}(),Z=function(){function t(t,e,n){this.messageHandler=t,this.loadingTask=e,this.pdfDataRangeTransport=n,this.commonObjs=new $,this.fontLoader=new F(e.docId),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this.pageCache=[],this.pagePromises=[],this.downloadInfoCapability=S(),this.setupMessageHandler()}return t.prototype={destroy:function(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=S(),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,i=new J(e,this,n);this.pdfDocument=i,n._capability.resolve(i)},this),t.on("PasswordRequest",function(t){if(this._passwordCapability=S(),e.onPassword){var n=function(t){this._passwordCapability.resolve({password:t})}.bind(this);e.onPassword(n,t.code)}else this._passwordCapability.reject(new A(t.message,t.code));return this._passwordCapability.promise},this),t.on("PasswordException",function(t){e._capability.reject(new A(t.message,t.code))},this),t.on("InvalidPDF",function(t){this.loadingTask._capability.reject(new f(t.message))},this),t.on("MissingPDF",function(t){this.loadingTask._capability.reject(new g(t.message))},this),t.on("UnexpectedResponse",function(t){this.loadingTask._capability.reject(new b(t.message,t.status))},this),t.on("UnknownError",function(t){this.loadingTask._capability.reject(new y(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){var e=this.pageCache[t.pageIndex];e._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 i=t[2];if("error"in i){var r=i.error;j("Error during font loading: "+r),this.commonObjs.resolve(e,r);break}var a=null;U("pdfBug")&&D.FontInspector&&D.FontInspector.enabled&&(a={registerFont:function(t,e){D.FontInspector.fontAdded(t,e)}});var s=new O(i,{isEvalSuported:U("isEvalSupported"),disableFontFace:U("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:k("Got unknown common object type "+n)}}},this),t.on("obj",function(t){if(!this.destroyed){var e,n=t[0],i=t[1],r=t[2],a=this.pageCache[i];if(!a.objs.hasData(n))switch(r){case"JpegStream":e=t[3],R(n,e,a.objs);break;case"Image":e=t[3],a.objs.resolve(n,e);var s=8e6;e&&"data"in e&&e.data.length>s&&(a.cleanupAfterRender=!0);break;default:k("Got unknown object type "+r)}}},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):k(t.error),n.operatorList){n.operatorList.lastChunk=!0;for(var i=0;ithis.numPages)return Promise.reject(new Error("Invalid page request"));var n=t-1;if(n in this.pagePromises)return this.pagePromises[n];var i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(function(t){if(this.destroyed)throw new Error("Transport destroyed");var e=new Q(n,t,this);return this.pageCache[n]=e,e}.bind(this));return this.pagePromises[n]=i,i},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 N(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=t&&n("PostScript },contains:function(e){return l(e)&&e<=65535},forEach:function(e){for(var t=0;t<=65535;t++)e(t,t)},charCodeOf:function(e){return l(e)&&e<=65535?e:-1},getMap:function(){for(var e=new Array(65536),t=0;t<=65535;t++)e[t]=t;return e},readCharCode:y.prototype.readCharCode,get length(){return 65536},get isIdentityCMap(){c("should not access .isIdentityCMap")}};return e}(),w=function(){function e(e){return new Promise(function(t,a){var r=new XMLHttpRequest;r.open("GET",e,!0);r.responseType="arraybuffer";r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&(!r.response||200!==r.status&&0!==r.status?a(new Error("Unable to get binary cMap at: "+e)):t(new Uint8Array(r.response)))};r.send(null)})}function t(e,t){for(var a=0,r=0;r<=t;r++)a=a<<8|e[r];return a>>>0}function a(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 r(e,t,a){for(var r=0,i=a;i>=0;i--){r+=e[i]+t[i];e[i]=255&r;r>>=8}}function i(e,t){for(var a=1,r=t;r>=0&&a>0;r--){a+=e[r];e[r]=255&a;a>>=8}}function n(e){this.buffer=e;this.pos=0;this.end=e.length;this.tmpBuf=new Uint8Array(u)}function o(o,l,u){return e(o).then(function(e){var o=new n(e),f=o.readByte();l.vertical=!!(1&f);for(var d,g,p=null,m=new Uint8Array(h),b=new Uint8Array(h),v=new Uint8Array(h),y=new Uint8Array(h),k=new Uint8Array(h);(g=o.readByte())>=0;){var w=g>>5;if(7!==w){var C=!!(16&g),x=15&g;s(x+1<=h);var S,A=1,I=o.readNumber();switch(w){case 0:o.readHex(m,x);o.readHexNumber(b,x);r(b,m,x);l.addCodespaceRange(x+1,t(m,x),t(b,x));for(S=1;S=this.end?-1:this.buffer[this.pos++]},readNumber:function(){var e,t=0;do{var a=this.readByte();a<0&&c("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&&c("unexpected EOF in bcmap");a=!(128&n);r[i++]=127&n}while(!a);for(var s=t,o=0,l=0;s>=0;){for(;l<8&&r.length>0;){o=r[--i]<>=8;l-=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){h(e)||c("Malformed CMap: expected string.")}function a(e){l(e)||c("Malformed CMap: expected int.")}function r(a,r){for(;;){var i=r.getObj();if(f(i))break;if(g(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(f(i))break;if(g(i,"endbfrange"))return;t(i);var n=e(i);i=r.getObj();t(i);var s=e(i);i=r.getObj();if(l(i)||h(i)){var o=l(i)?String.fromCharCode(i):i;a.mapBfRange(n,s,o)}else{if(!g(i,"["))break;i=r.getObj();for(var u=[];!g(i,"]")&&!f(i);){u.push(i);i=r.getObj()}a.mapBfRangeToArray(n,s,u)}}c("Invalid bf range.")}function n(r,i){for(;;){var n=i.getObj();if(f(n))break;if(g(n,"endcidchar"))return;t(n);var s=e(n);n=i.getObj();a(n);var o=n;r.mapOne(s,o)}}function C(r,i){for(;;){var n=i.getObj();if(f(n))break;if(g(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 x(t,a){for(;;){var r=a.getObj();if(f(r))break;if(g(r,"endcodespacerange"))return;if(!h(r))break;var i=e(r);r=a.getObj();if(!h(r))break;var n=e(r);t.addCodespaceRange(r.length,i,n)}c("Invalid codespace range.")}function S(e,t){var a=t.getObj();l(a)&&(e.vertical=!!a)}function A(e,t){var a=t.getObj();d(a)&&h(a.name)&&(e.name=a.name)}function I(e,t,a,s){var c,l;e:for(;;)try{var h=t.getObj();if(f(h))break;if(d(h)){"WMode"===h.name?S(e,t):"CMapName"===h.name&&A(e,t);c=h}else if(g(h))switch(h.cmd){case"endcmap":break e;case"usecmap":d(c)&&(l=c.name);break;case"begincodespacerange":x(e,t);break;case"beginbfchar":r(e,t);break;case"begincidchar":n(e,t);break;case"beginbfrange":i(e,t);break;case"begincidrange":C(e,t)}}catch(e){if(e instanceof u)throw e;o("Invalid cMap data: "+e);continue}!s&&l&&(s=l);return s?B(e,a,s):Promise.resolve(e)}function B(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;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:g.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(p,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(p,s,i)}function f(e,a,r,i,n,c){var f=o(0,1,a[r]*c),d=o(0,1,a[r+1]*c),g=o(0,1,a[r+2]*c),p=Math.pow(f,e.GR),v=Math.pow(d,e.GG),w=Math.pow(g,e.GB),C=e.MXA*p+e.MXB*v+e.MXC*w,x=e.MYA*p+e.MYB*v+e.MYC*w,S=e.MZA*p+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(m,R,T);var O=s(T[0]),P=s(T[1]),E=s(T[2]);i[n]=Math.round(255*O);i[n+1]=Math.round(255*P);i[n+2]=Math.round(255*E)}var d=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),p=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),m=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){n("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(n!==!1){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:g.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<=0?s[i]=r:s[i]=0}}else if(o)for(i in t)s[i]=t[i];else{n=D;for(i=0;i=0?s[i]=r:s[i]=0}}var c,l=e.differences;if(l)for(i in l){var h=l[i];r=a.indexOf(h);if(r===-1){c||(c=E());var u=g(h,c);u!==h&&(r=a.indexOf(u))}r>=0?s[i]=r:s[i]=0}return s}var m=t.FONT_IDENTITY_MATRIX,b=t.FontType,v=t.assert,y=t.bytesToString,k=t.error,w=t.info,C=t.isArray,x=t.isInt,S=t.isNum,A=t.readUint32,I=t.shadow,B=t.string32,R=t.warn,T=t.MissingDataException,O=t.isSpace,P=r.Stream,E=i.getGlyphsUnicode,M=i.getDingbatsGlyphsUnicode,L=n.FontRendererFactory,D=s.StandardEncoding,F=s.MacRomanEncoding,U=s.SymbolSetEncoding,j=s.ZapfDingbatsEncoding,q=s.getEncoding,N=o.getStdFontMap,_=o.getNonStdFontMap,z=o.getGlyphMapForStandardFonts,H=o.getSupplementalGlyphMapForArialBlack,G=c.getUnicodeRangeFor,X=c.mapSpecialUnicodeValues,W=c.getUnicodeForGlyph,V=l.Type1Parser,K=h.CFFStandardStrings,Y=h.CFFParser,J=h.CFFCompiler,Z=h.CFF,Q=h.CFFHeader,$=h.CFFTopDict,ee=h.CFFPrivateDict,te=h.CFFStrings,ae=h.CFFIndex,re=h.CFFCharset,ie=57344,ne=63743,se=!1,oe=1e3,ce=!1,le={FixedPitch:1,Serif:2,Symbolic:4,Script:8,Nonsymbolic:32,Italic:64,AllCap:65536,SmallCap:131072,ForceBold:262144},he=[".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"],ue=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}(),fe=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}(),de=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 x(e)&&e>=this.firstChar&&e<=this.lastChar?e:-1},amend:function(e){k("Should not call amend()")}};return e}(),ge=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}};var i=12,n=16;r.prototype={toArray:function(){var s=this.sfnt,o=this.tables,c=Object.keys(o);c.sort();var l,h,u,f,d,g=c.length,p=i+g*n,m=[p];for(l=0;l>>0;p+=b;m.push(p)}var v=new Uint8Array(p);for(l=0;l>>0}t(v,p+4,k);t(v,p+8,m[l]);t(v,p+12,o[d].length);p+=n}return v},addTable:function(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}};return r}(),pe=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]),me=function(){function e(e,t,a){var r,i,n;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&le.Serif);this.isSymbolicFont=!!(a.flags&le.Symbolic);this.isMonospace=!!(a.flags&le.FixedPitch);var h=a.type,f=a.subtype;this.type=h;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/oe;this.descent=a.descent/oe;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"===f&&("Type1"!==h&&"MMType1"!==h?s(t)?f="TrueType":h="Type1":o(t)&&(h=f="OpenType"));"CIDFontType0C"===f&&"CIDFontType0"!==h&&(h="CIDFontType0");"OpenType"===f&&(h="OpenType"); "CIDFontType0"===h&&(c(t)?f="CIDFontType0":o(t)?h=f="OpenType":f="CIDFontType0C");var p;switch(h){case"MMType1":w("MMType1 font ("+e+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var m="Type1C"===f||"CIDFontType0C"===f?new ye(t,a):new ve(e,t,a);u(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){u(a);h="OpenType"}break;default:k("Font "+h+" is not supported")}this.data=p;this.fontType=d(h,f);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&&R('Font file is empty in "'+e+'" ('+this.loadedName+")");this.missingFile=!0;var v=e.replace(/[,_]/g,"-"),y=N(),C=_(),x=!!y[v]||!(!C[v]||!y[C[v]]);v=y[v]||C[v]||v;this.bold=v.search(/bold/gi)!==-1;this.italic=v.search(/oblique/gi)!==-1||v.search(/italic/gi)!==-1;this.black=e.search(/Black/g)!==-1;this.remeasure=Object.keys(this.widths).length>0;if(x&&"CIDFontType2"===h&&0===a.cidEncoding.indexOf("Identity-")){var S=z(),A=[];for(r in S)A[+r]=S[r];if(/Arial-?Black/i.test(e)){var I=H();for(r in I)A[+r]=I[r]}var B=this.toUnicode instanceof de;B||this.toUnicode.forEach(function(e,t){A[+e]=t});this.toFontChar=A;this.toUnicode=new fe(A)}else if(/Symbol/i.test(v))this.toFontChar=l(U,E(),a.differences);else if(/Dingbats/i.test(v)){/Wingdings/i.test(e)&&R("Non-embedded Wingdings font, falling back to ZapfDingbats.");this.toFontChar=l(j,M(),a.differences)}else if(x)this.toFontChar=l(a.defaultEncoding,E(),a.differences);else{g=E();this.toUnicode.forEach(function(e,t){if(!this.composite){i=a.differences[e]||a.defaultEncoding[e];n=W(i,g);n!==-1&&(t=n)}this.toFontChar[e]=t}.bind(this))}this.loadedName=v.split("-")[0];this.loading=!1;this.fontType=d(h,f)}}else{for(r=0;r<256;r++)this.toFontChar[r]=this.differences[r]||a.defaultEncoding[r];this.fontType=b.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 r(e,t,a,r){return(e<<24)+(t<<16)+(a<<8)+r}function i(e){return String.fromCharCode(e>>8&255,255&e)}function n(e){e=e>32767?32767:e<-32768?-32768:e;return String.fromCharCode(e>>8&255,255&e)}function s(e){var t=e.peekBytes(4);return 65536===A(t,0)}function o(e){var t=e.peekBytes(4);return"OTTO"===y(t)}function c(e){var t=e.peekBytes(2);return 37===t[0]&&33===t[1]||128===t[0]&&1===t[1]}function l(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"+i(c)+"\0\0"+B(4+8*c);for(a=o.length-1;a>=0&&!(o[a][0]<=65535);--a);var h=a+1;o[a][0]<65535&&65535===o[a][1]&&(o[a][1]=65534);var u,f,d,g,p=o[a][1]<65535?1:0,m=h+p,b=ge.getSearchParams(m,2),v="",y="",k="",w="",x="",S=0;for(a=0,r=h;a0){y+="ÿÿ";v+="ÿÿ";k+="\0";w+="\0\0"}var T="\0\0"+i(2*m)+i(b.range)+i(b.entry)+i(b.rangeShift)+y+"\0\0"+v+k+w+x,O="",P="";if(c>1){l+="\0\0\n"+B(4+8*c+4+T.length);O="";for(a=0,r=o.length;an)return!1;t.getBytes(6);var s=t.getUint16();if(0===s)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,n=0,s=0,o=0,c=null,l=0;if(t)for(var h in t){h|=0;(c>h||!c)&&(c=h);l 123 are reserved for internal usage")}else{c=0;l=255}var f=e.bbox||[0,0,0,0],d=a.unitsPerEm||1/(e.fontMatrix||m)[0],g=e.ascentScaled?1:d/oe,p=a.ascent||Math.round(g*(e.ascent||f[3])),b=a.descent||Math.round(g*(e.descent||f[1]));b>0&&e.descent>0&&f[1]<0&&(b=-b);var v=a.yMax||p,y=-a.yMin||-b;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"+B(r)+B(n)+B(s)+B(o)+"*21*"+i(e.italicAngle?1:0)+i(c||e.firstChar)+i(l||e.lastChar)+i(p)+i(b)+"\0d"+i(v)+i(y)+"\0\0\0\0\0\0\0\0"+i(e.xHeight)+i(e.capHeight)+i(0)+i(c||e.firstChar)+"\0"}function V(e){var t=Math.floor(e.italicAngle*Math.pow(2,16));return"\0\0\0"+B(t)+"\0\0\0\0"+B(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,n,s,o,c=[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=c.length;a>>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}}function o(e){return{version:y(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}function c(e,t,a,r){if(!e){R("No cmap table available.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var i,n=(t.start?t.start:0)+e.offset;t.pos=n;t.getUint16();for(var s,o=t.getUint16(),c=!1,l=0;l>>0,d=!1;if(0===h&&0===u)d=!0;else if(1===h&&0===u)d=!0;else if(3!==h||1!==u||(a||!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||t.peekByte()===-1){R("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;pr){w("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)}function h(e,t,a,r,i,n){if(a-t<=12)return 0;var s=e.subarray(t,a),o=s[0]<<8|s[1];if(32768&o){r.set(s,i);return s.length}var c,l=10,h=0;for(c=0;cs.length)return 0;if(!n&&d>0){r.set(s.subarray(0,f),i);r.set([0,0],i+f);r.set(s.subarray(g,y),i+f+2);y-=d;s.length-y>3&&(y=y+3&-4);return y}if(s.length-y>3){y=y+3&-4;r.set(s.subarray(0,y),i);return y}r.set(s,i);return s.length}function f(e,a,i){var n=e.data,s=r(n[0],n[1],n[2],n[3]);if(s>>16!==1){w("Attempting to fix invalid version in head table: "+s);n[0]=0;n[1]=1;n[2]=0;n[3]=0}var o=t(n[50],n[51]);if(o<0||o>1){w("Attempting to fix invalid indexToLocFormat in head table: "+o);var c=a+1;if(i===c<<1){n[50]=0;n[51]=0}else if(i===c<<2){n[50]=0;n[51]=1}else R("Could not fix indexToLocFormat: "+o)}}function d(e,t,a,r,i,n){var s,o,c;if(r){s=4;o=function(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]};c=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};c=function(e,t,a){e[t]=a>>9&255;e[t+1]=a>>1&255}}var l=e.data,u=s*(1+a);if(l.length!==u){l=new Uint8Array(u);l.set(e.data.subarray(0,u));e.data=l}var f=t.data,d=f.length,g=new Uint8Array(d),p=o(l,0),m=0,b=Object.create(null);c(l,0,m);var v,y;for(v=0,y=s;vd&&(d+3&-4)===k&&(k=d);if(k>d){c(l,y,m);p=k}else{p===k&&(b[v]=!0);var w=h(f,p,k,g,m,i);m+=w;c(l,y,m);p=k}}if(0===m){var C=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(v=0,y=s;vx+m)t.data=g.subarray(0,x+m);else{t.data=new Uint8Array(x+m);t.data.set(g.subarray(0,m))}t.data.set(g.subarray(0,x),m);c(e.data,l.length-s,m+x)}else t.data=g.subarray(0,m);return b}function m(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=he;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.posn)){i.pos=m;var b=p.name;if(p.encoding){for(var v="",k=0,w=p.length;k0&&(c+=k-1)}}else{if(p||b){R("TT: nested FDEFs not allowed");g=!0}p=!0;h=c;n=u.pop();t.functionsDefined[n]={data:o,i:c}}else if(!p&&!b){n=u[u.length-1];t.functionsUsed[n]=!0;if(n in t.functionsStackDeltas)u.length+=t.functionsStackDeltas[n];else if(n in t.functionsDefined&&d.indexOf(n)<0){f.push({data:o,i:c,stackTop:u.length-1});d.push(n);s=t.functionsDefined[n];if(!s){R("TT: CALL non-existent function");t.hintsValid=!1;return}o=s.data;c=s.i}}if(!p&&!b){var w=y<=142?L[y]:y>=192&&y<=223?-1:y>=224?-2:0;if(y>=113&&y<=117){r=u.pop();isNaN(r)||(w=2*-r)}for(;w<0&&u.length>0;){u.pop();w++}for(;w>0;){u.push(NaN);w--}}}t.tooComplexToFollowFunctions=g;var C=[o];c>o.length&&C.push(new Uint8Array(c-o.length));if(h>l){R("TT: complementing a missing function tail");C.push(new Uint8Array([34,45]))}I(e,C)}function A(e,t){if(!e.tooComplexToFollowFunctions)if(e.functionsDefined.length>t){R("TT: more functions defined than expected");e.hintsValid=!1}else for(var a=0,r=e.functionsUsed.length;at){R("TT: invalid function id: "+a);e.hintsValid=!1;return}if(e.functionsUsed[a]&&!e.functionsDefined[a]){R("TT: undefined function: "+a);e.hintsValid=!1;return}}}function I(e,t){if(t.length>1){var a,r,i=0;for(a=0,r=t.length;a=0&&ue.has(t))||!!(fe&&a>=0&&S(fe[a])))}var L=[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 P(new Uint8Array(i.getBytes()));var U,j,N=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "],_=o(i),z=_.numTables,H=Object.create(null);H["OS/2"]=null;H.cmap=null;H.head=null;H.hhea=null;H.hmtx=null;H.maxp=null;H.name=null;H.post=null;for(var G,X=0;X=65536&&H.maxp.length>=22){i.pos+=8;var ee=i.getUint16();if(ee>2){H.maxp.data[14]=0;H.maxp.data[15]=2}i.pos+=4;$=i.getUint16()}var te=!1;if("CIDFontType2"===n.type&&n.toUnicode&&n.toUnicode.get(0)>"\0"){te=!0;Q++;H.maxp.data[4]=Q>>8;H.maxp.data[5]=255&Q}var ae=B(H.fpgm,H.prep,H["cvt "],$);if(!ae){delete H.fpgm;delete H.prep;delete H["cvt "]}l(i,H.hhea,H.hmtx,Q);H.head||k('Required "head" table is not found');f(H.head,Q,W?H.loca.length:0);var re=Object.create(null);if(W){var ie=t(H.head.data[50],H.head.data[51]);re=d(H.loca,H.glyf,Q,ie,ae,te)}H.hhea||k('Required "hhea" table is not found');if(0===H.hhea.data[10]&&0===H.hhea.data[11]){H.hhea.data[10]=255;H.hhea.data[11]=255}var ne={unitsPerEm:t(H.head.data[18],H.head.data[19]),yMax:t(H.head.data[42],H.head.data[43]),yMin:a(H.head.data[38],H.head.data[39]),ascent:t(H.hhea.data[4],H.hhea.data[5]),descent:a(H.hhea.data[6],H.hhea.data[7])};this.ascent=ne.ascent/ne.unitsPerEm;this.descent=ne.descent/ne.unitsPerEm;if(H.post){var se=m(H.post,n,Q);se||(H.post=null)}var oe,le=[],ue=n.toUnicode,fe=n.widths,pe=ue instanceof de||65536===ue.length;if(n.composite){var me=n.cidToGidMap||[],be=0===me.length;n.cMap.forEach(function(e,t){v(t<=65535,"Max size of CID is 65,535");var a=-1;be?a=t:void 0!==me[t]&&(a=me[t]);a>=0&&a0&&M(Ee,-1,-1)){le[oe]=Ee;Oe=!0}}Oe||(le[oe]=0)}}}else if(0===ke&&0===we)for(X=0;X=n){o+=r;for(;o=0&&(n[s]=t)}}return p(e,n,r)},getSeacs:function(e){var t,a,r=[];for(t=0,a=e.length;t>8&255,255&f)}n.charset=new re(!1,0,[],u);var d=new ae;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 ae;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[f]=v}}else c("Unknown mask format.");if(o)for(f=0,g=3,d=t*n;f=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,c=this.width,l=this.height,h=this.bpc,u=c*n*h+7>>3;if(!e){var f;"DeviceGray"===this.colorSpace.name&&1===h?f=s.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==h||this.needsDecode||(f=s.RGB_24BPP);if(f&&!this.smask&&!this.mask&&a===c&&r===l){i.kind=f;t=this.getImageBytes(l*u);if(this.image instanceof p)i.data=t;else{var d=new Uint8Array(t.length);d.set(t);i.data=d}if(this.needsDecode){o(f===s.GRAYSCALE_1BPP);for(var g=i.data,b=0,v=g.length;b>3,l=this.getImageBytes(n*o),h=this.getComponents(l);if(1!==s){this.needsDecode&&this.decodeBuffer(h);r=i*n;var u=255/((1<0;){var o=r.shift(),c=n.fetchIfRef(o.obj);if(null!==c){h(c.has("Title"),"Invalid outline item");var l={url:null,dest:null};e.parseDestDictionary({destDict:c,resultObj:l,docBaseUrl:this.pdfManager.docBaseUrl});var u=c.get("Title"),f=c.get("F")||0,d=c.getArray("C"),g=s;!p(d)||3!==d.length||0===d[0]&&0===d[1]&&0===d[2]||(g=j.singletons.rgb.getRgb(d,0));var m={dest:l.dest,url:l.url,unsafeUrl:l.unsafeUrl,newWindow:l.newWindow,title:k(u),color:g,count:c.get("Count"),bold:!!(2&f),italic:!!(1&f),items:[]};o.parent.items.push(m);t=c.getRaw("First");if(P(t)&&!i.has(t)){r.push({obj:t,parent:m});i.put(t)}t=c.getRaw("Next");if(P(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");h(b(e),"page count in top level pages object is not an integer");return y(this,"num",e)},get destinations(){function e(e){return O(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 z(t,r),o=s.getAll();for(var c in o)i[c]=e(o[c])}return y(this,"destinations",i)},getDestination:function(e){function t(e){return O(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){var c=new z(a,i);n=t(c.get(e))}return n},get pageLabels(){var e=null;try{e=this.readPageLabels()}catch(e){if(e instanceof c)throw e;C("Unable to read page labels.")}return y(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 H(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=S.toRoman(o,"r"===a);break;case"A":case"a":for(var m=26,y=65,w=97,C="a"===a?w:y,x=o-1,A=String.fromCharCode(C+x%m),I=[],B=0,T=x/m|0;B<=T;B++)I.push(A);s=I.join("");break;default:h(!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 z(e,t),n=i.getAll();for(var s in n){var o=new G(n[s],t);a||(a=Object.create(null));a[k(s)]=o.serializable}}return y(this,"attachments",a)},get javaScript(){function e(e){var t=e.get("S");if(R(t,"JavaScript")){var a=e.get("JS");if(M(a))a=u(a.getBytes());else if(!v(a))return;r.push(k(a))}}var t=this.xref,a=this.catDict.get("Names"),r=[];if(a&&a.has("JavaScript")){var i=new z(a.getRaw("JavaScript"),t),n=i.getAll();for(var s in n){var o=n[s];O(o)&&e(o)}}var c=this.catDict.get("OpenAction");if(O(c,"Action")){var l=c.get("S");if(R(l,"Named")){var h=c.get("N");R(h,"Print")&&r.push("print({});")}else e(c)}return y(this,"javaScript",r)},cleanup:function(){var e=[];this.fontCache.forEach(function(t){e.push(t)});return Promise.all(e).then(function(e){for(var t=0,a=e.length;t=0;u--)r.push(l[u]);else{r=[l[e-i]];i=e}}}a.reject("Page index "+e+" not found.")}var a=f(),r=[this.catDict.getRaw("Pages")],i=0,n=this.xref,s=!1;t();return a.promise},getPageIndex:function(e){function t(t){var a,i=0;return r.fetchAsync(t).then(function(r){if(E(t,e)&&!O(r,"Page")&&(!O(r)||r.has("Type")||!r.has("Contents")))throw new Error("The reference does not point to a /Page Dict.");if(!r)return null;h(O(r),"node must be a Dict.");a=r.getRaw("Parent");return r.getAsync("Parent")}).then(function(e){if(!e)return null;h(O(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];b(l)&&b(h)||d("Invalid XRef range fields: "+l+", "+h);b(n)&&b(s)&&b(o)||d("Invalid XRef entry fields length: "+l+", "+h);for(t=r.entryNum;t=e.length);){a+=String.fromCharCode(n);n=e[t]}return a}function t(e,t,a){for(var r=a.length,i=e.length,n=0;t=r)break;t++;n++}return n}var a=9,r=10,i=13,n=32,s=37,c=60,l=/^(\d+)\s+(\d+)\s+obj\b/,h=new Uint8Array([116,114,97,105,108,101,114]),u=new Uint8Array([115,116,97,114,116,120,114,101,102]),f=new Uint8Array([101,110,100,111,98,106]),d=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var g=this.stream;g.pos=0;for(var p=g.getBytes(),m=g.start,b=p.length,v=[],y=[];m=b)break;k=p[m]}while(k!==r&&k!==i);else++m}var I,B;for(I=0,B=y.length;I0;){var i,n,s=t.fetchIfRef(r.shift());if(O(s))if(s.has("Kids")){var o=s.get("Kids");for(i=0,n=o.length;io){C('Search depth limit reached for "'+this._type+'" tree.');return null}var c=n.get("Kids");if(!p(c))return null;t=0;a=c.length-1;for(;t<=a;){r=t+a>>1;var l=i.fetchIfRef(c[r]),h=l.get("Limits");if(ei.fetchIfRef(h[1]))){n=i.fetchIfRef(c[r]);break}t=r+1}}if(t>a)return null}var u=n.get(this._type);if(p(u)){t=0;a=u.length-2;for(;t<=a;){r=t+a&-2;var f=i.fetchIfRef(u[r]);if(ef))return i.fetchIfRef(u[r+1]);t=r+2}}}return null}};return e}(),z=function(){function e(e,t){this.root=e;this.xref=t;this._type="Names"}S.inherit(e,_,{});return e}(),H=function(){function e(e,t){this.root=e;this.xref=t;this._type="Nums"}S.inherit(e,_,{});return e}(),G=function(){function e(e,t){if(e&&O(e)){this.xref=t;this.root=e;e.has("FS")&&(this.fs=e.get("FS"));this.description=e.has("Desc")?k(e.get("Desc")):"";e.has("RF")&&C("Related file specifications are not supported");this.contentAvailable=!0;if(!e.has("EF")){this.contentAvailable=!1;C("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=k(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&&M(r)?e=r.getBytes():C("Embedded file specification points to non-existing/invalid content")}else C("Embedded file specification does not have a content");return e},get serializable(){return{filename:this.filename,content:this.content}}};return e}(),X=function(){function e(e){return P(e)||O(e)||p(e)||M(e)}function t(t,a){var r;if(O(t)||M(t)){var i;i=O(t)?t.map:t.dict.map;for(var n in i){r=i[n];e(r)&&a.push(r)}}else if(p(t))for(var s=0,o=t.length;s=s||R<=0)u("Bad shading domain.");else{for(var O,P=new Float32Array(i.numComps),E=new Float32Array(1),M=n;M<=s;M+=R){E[0]=M;I(E,0,P,0);O=i.getRgb(P,0);var L=c.makeCssRgb(O[0],O[1],O[2]);T.push([(M-n)/B,L])}var D="transparent";if(e.has("Background")){O=i.getRgb(e.get("Background"),0);D=c.makeCssRgb(O[0],O[1],O[2])}if(!l){T.unshift([0,D]);T[1][0]+=v.SMALL_NUMBER}if(!h){T[T.length-1][0]-=v.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===m.AXIAL){t=[n[0],n[1]];a=[n[2],n[3]];r=null;i=null;e="axial"}else if(s===m.RADIAL){t=[n[0],n[1]];a=[n[3],n[4]];r=n[2];i=n[5];e="radial"}else h("getPattern type unknown: "+s);var o=this.matrix;if(o){t=c.applyTransform(t,o);a=c.applyTransform(a,o);if(s===m.RADIAL){var l=c.singularValueDecompose2dScale(o);r*=l[0];i*=l[1]}}return["RadialAxial",e,this.colorStops,t,a,r,i]}};return e}();v.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(),h=t.readComponents();if(0===s){l(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(h);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];l("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]),h=Math.max(r[n[0]][0],r[n[3]][0],r[n[12]][0],r[n[15]][0]),d=Math.max(r[n[0]][1],r[n[3]][1],r[n[12]][1],r[n[15]][1]),g=Math.ceil((h-o)*b/(e.bounds[2]-e.bounds[0]));g=Math.max(u,Math.min(f,g));var p=Math.ceil((d-c)*b/(e.bounds[3]-e.bounds[1]));p=Math.max(u,Math.min(f,p));for(var m=g+1,y=new Int32Array((p+1)*m),k=new Int32Array((p+1)*m),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=v(p),T=v(g),O=0;O<=p;O++){C[0]=(S[0]*(p-O)+I[0]*O)/p|0;C[1]=(S[1]*(p-O)+I[1]*O)/p|0;C[2]=(S[2]*(p-O)+I[2]*O)/p|0;x[0]=(A[0]*(p-O)+B[0]*O)/p|0;x[1]=(A[1]*(p-O)+B[1]*O)/p|0;x[2]=(A[2]*(p-O)+B[2]*O)/p|0;for(var P=0;P<=g;P++,w++)if(0!==O&&O!==p||0!==P&&P!==g){for(var E=0,M=0,L=0,D=0;D<=3;D++)for(var F=0;F<=3;F++,L++){var U=R[O][D]*T[P][F];E+=r[n[L]][0]*U;M+=r[n[L]][1]*U}y[w]=r.length;r.push([E,M]);k[w]=i.length;var j=new Uint8Array(3);j[0]=(C[0]*(g-P)+x[0]*P)/g|0;j[1]=(C[1]*(g-P)+x[1]*P)/g|0;j[2]=(C[2]*(g-P)+x[2]*P)/g|0;i.push(j)}}y[0]=n[0];k[0]=s[0];y[g]=n[3];k[g]=s[1];y[m*p]=n[12];k[m*p]=s[2];y[m*p+g]=n[15];k[m*p+g]=s[3];e.figures[t]={type:"lattice",coords:y,colors:k,verticesPerRow:m}}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();l(0<=s&&s<=3,"Unknown type6 flag");var o,c,h=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 m.COONS_PATCH_MESH:i(this,x);S=!0;break;case m.TENSOR_PATCH_MESH:n(this,x);S=!0;break;default:h("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<u)M("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=V.createMask(v,p,m,a instanceof z,k);f.cached=!0;d=[f];i.addOp(C.paintImageMaskXObject,d);n&&(s[n]={fn:C.paintImageMaskXObject,args:d})}else{var w=c.get("SMask","SM")||!1,x=c.get("Mask")||!1,S=200;if(!r||w||x||a instanceof H||!(l+h0&&a.addOp(C.setGState,[s])})},loadFont:function(e,t,a,r){function i(){return Promise.resolve(new Se("g_font_error",new J("Font "+e+" is not available"),t))}var n;if(t){A(N(t));n=t}else{var s=r.get("Font");if(!s){M("fontRes not available");return i()}n=s.getRaw(e)}if(!n){M("fontRef not available");return i()}if(this.fontCache.has(n))return this.fontCache.get(n);t=a.fetchIfRef(n);if(!j(t))return i();if(t.translated)return t.translated;var o,c=I(),l=this.preEvaluateFont(t,a),h=l.descriptor,u=N(n);u&&(o=n.toString());if(j(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(n,g);return this.fontCache.get(n)}}else f[d]={fontID:Q.getFontID()};u&&(f[d].aliasRef=n);o=f[d].fontID}if(u)this.fontCache.put(n,c.promise);else{o||(o=this.idFactory.createObjId());this.fontCache.put("id_"+o,c.promise)}A(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,a)}catch(e){p=Promise.reject(e)}var m=this;p.then(function(e){if(void 0!==e.fontType){var r=a.stats.fontTypes;r[e.fontType]=!0}c.resolve(new Se(t.loadedName,e,t))},function(e){m.handler.send("UnsupportedFeature",{featureId:k.font});try{var r=l.descriptor,i=r&&r.get("FontFile3"),n=i&&i.get("Subtype"),s=te(l.type,n&&n.name),o=a.stats.fontTypes;o[s]=!0}catch(e){}c.resolve(new Se(t.loadedName,new J(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]!==C.constructPath)e.addOp(C.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,l){var h,u=a[a.length-1];if(q(u)&&(h=i.get(u.name))){var f=_(h)?h.dict:h,d=f.get("PatternType");if(d===o){var g=r.base?r.base.getRgb(a,0):null;return this.handleTilingType(t,g,n,h,f,e,s)}if(d===c){var p=f.get("Shading"),m=f.getArray("Matrix");h=ie.parseShading(p,m,l,n,this.handler);e.addOp(t,h.getIR());return Promise.resolve()}return Promise.reject("Unknown PatternType: "+d)}e.addOp(t,a);return Promise.resolve()},getOperatorList:function(e,t,r,i,n){var o=this,c=this.xref,l=Object.create(null);A(i);r=r||L.empty;var h=r.get("XObject")||L.empty,u=r.get("Pattern")||L.empty,f=new Ie(n||new Re),d=new Te(e,c,f),g=new a;return new Promise(function e(a,n){var p=function(t){t.then(function(){try{e(a,n)}catch(e){n(e)}},n)};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,x=k.fn;switch(0|x){case C.paintXObject:if(w[0].code)break;var S=w[0].name;if(!S){M("XObject must be referred to by name.");continue}if(void 0!==l[S]){i.addOp(l[S].fn,l[S].args);w=null;continue}var I=h.get(S);if(I){A(_(I),"XObject should be a stream");var T=I.dict.get("Subtype");A(q(T),"XObject should have a Name subtype");if("Form"===T.name){f.save();p(o.buildFormXObject(r,I,null,i,t,f.state.clone()).then(function(){f.restore()}));return}if("Image"===T.name){o.buildPaintImageXObject(r,I,!1,i,S,l);w=null;continue}if("PS"===T.name){R("Ignored XObject subtype PS");continue}B("Unhandled XObject subtype "+T.name)}break;case C.setFont:var E=w[1];p(o.handleSetFont(r,w,null,i,t,f.state).then(function(e){i.addDependency(e);i.addOp(C.setFont,[e,E])}));return;case C.endInlineImage:var D=w[0].cacheKey;if(D){var F=l[D];if(void 0!==F){i.addOp(F.fn,F.args);w=null;continue}}o.buildPaintImageXObject(r,w[0],!0,i,D,l);w=null;continue;case C.showText:w[0]=o.handleText(w[0],f.state);break;case C.showSpacedText:var U=w[0],N=[],z=U.length,H=f.state;for(b=0;b0){a*=R.fontMatrix[3];t[3]*=a}}var r=S.transform(R.ctm,S.transform(R.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=R.textLineMatrix[0],n=R.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=R.ctm[0];n=R.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*R.fontSize;if(c){b.spaceWidth=c;b.fakeSpaceMin=c*k;b.fakeMultiSpaceMin=c*w;b.fakeMultiSpaceMax=c*x;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){var b=l*R.fontMatrix[0];m=b*R.fontSize+f;i+=m}else{var v=l*R.fontMatrix[0];p=(v*R.fontSize+f)*R.textHScale;r+=p}R.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}}i=i||new Ie(new Be);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},k=.3,w=1.5,x=4,I=this,B=this.xref;r=B.fetchIfRef(r)||L.empty;var R,P=null,E=Object.create(null),M=new Te(e,B,i),D=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();D.reset();for(var p,v={},k=[];!(p=D.check());){k.length=0;v.args=k;if(!M.read(v))break;R=i.state;var w=v.fn;k=v.args;var x,B;switch(0|w){case C.setFont:var F=k[0].name,U=k[1];if(R.font&&F===R.fontName&&U===R.fontSize)break;g();R.fontName=F;R.fontSize=U;h(u(F,null));return;case C.setTextRise:g();R.textRise=k[0];break;case C.setHScale:g();R.textHScale=k[0]/100;break;case C.setLeading:g();R.leading=k[0];break;case C.moveText:var N=!!R.font&&0===(R.font.vertical?k[0]:k[1]);x=k[0]-k[1];if(o&&N&&b.initialized&&x>0&&x<=b.fakeMultiSpaceMax){R.translateTextLineMatrix(k[0],k[1]);b.width+=k[0]-b.lastAdvanceWidth;b.height+=k[1]-b.lastAdvanceHeight;B=k[0]-b.lastAdvanceWidth-(k[1]-b.lastAdvanceHeight);d(B,b.str);break}g();R.translateTextLineMatrix(k[0],k[1]);R.textMatrix=R.textLineMatrix.slice();break;case C.setLeadingMoveText:g();R.leading=-k[1];R.translateTextLineMatrix(k[0],k[1]);R.textMatrix=R.textLineMatrix.slice();break;case C.nextLine:g();R.carriageReturn();break;case C.setTextMatrix:x=R.calcTextLineMatrixAdvance(k[0],k[1],k[2],k[3],k[4],k[5]);if(o&&null!==x&&b.initialized&&x.value>0&&x.value<=b.fakeMultiSpaceMax){R.translateTextLineMatrix(x.width,x.height);b.width+=x.width-b.lastAdvanceWidth;b.height+=x.height-b.lastAdvanceHeight;B=x.width-b.lastAdvanceWidth-(x.height-b.lastAdvanceHeight);d(B,b.str);break}g();R.setTextMatrix(k[0],k[1],k[2],k[3],k[4],k[5]);R.setTextLineMatrix(k[0],k[1],k[2],k[3],k[4],k[5]);break;case C.setCharSpacing:R.charSpacing=k[0];break;case C.setWordSpacing:R.wordSpacing=k[0];break;case C.beginText:g();R.textMatrix=y.slice();R.textLineMatrix=y.slice();break;case C.showSpacedText:for(var z,H=k[0],G=0,X=H.length;Gb.fakeMultiSpaceMax;W||(b.height+=z)}else{x=-x;z=x*R.textHScale;R.translateTextMatrix(z,0);W=b.textRunBreakAllowed&&x>b.fakeMultiSpaceMax;W||(b.width+=z)}W?g():x>0&&d(x,b.str)}break;case C.showText:f(k[0]);break;case C.nextLineShowText:g();R.carriageReturn();f(k[0]);break;case C.nextLineSetSpacingShowText:g();R.wordSpacing=k[0];R.charSpacing=k[1];R.carriageReturn();f(k[2]);break;case C.paintXObject:g();if(k[0].code)break;P||(P=r.get("XObject")||L.empty);var V=k[0].name;if(E.key===V){if(E.texts){S.appendToArray(m.items,E.texts.items);S.extendObj(m.styles,E.texts.styles)}break}var K=P.get(V);if(!K)break;A(_(K),"XObject should be a stream");var Y=K.dict.get("Subtype");A(q(Y),"XObject should have a Name subtype");if("Form"!==Y.name){E.key=V;E.texts=null;break}i.save();var J=K.dict.getArray("Matrix");T(J)&&6===J.length&&i.transform(J);h(I.getTextContent(K,t,K.dict.get("Resources")||r,i,n,o).then(function(e){S.appendToArray(m.items,e.items);S.extendObj(m.styles,e.styles);i.restore();E.key=V;E.texts=e}));return;case C.setGState:g();var Z=k[0],Q=r.get("ExtGState");if(!j(Q)||!q(Z))break;var $=Q.get(Z.name);if(!j($))break;var ee=$.get("Font");if(ee){R.fontName=null;R.fontSize=ee[1];h(u(null,ee[0]));return}}}if(p)h(s);else{g();a(m)}})},extractDataStructures:function(e,t,a,r){var i=e.get("ToUnicode")||t.get("ToUnicode"),n=i?this.readToUnicode(i):Promise.resolve(void 0);if(r.composite){var s=e.get("CIDSystemInfo");j(s)&&(r.cidSystemInfo={registry:s.get("Registry"),ordering:s.get("Ordering"),supplement:s.get("Supplement")});var o=e.get("CIDToGIDMap");_(o)&&(r.cidToGidMap=this.readCidToGidMap(o))}var c,l=[],h=null;if(e.has("Encoding")){c=e.get("Encoding");if(j(c)){h=c.get("BaseEncoding");h=q(h)?h.name:null;if(c.has("Differences"))for(var u=c.get("Differences"),f=0,d=0,g=u.length;d0;r.dict=e;return n.then(function(e){r.toUnicode=e;return this.buildToUnicode(r)}.bind(this)).then(function(e){r.toUnicode=e;return r})},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=Ce();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=we(r,o);l!==-1&&(c=l)}if(c){if(n&&c===+a){var h=pe(n);if(h&&(r=h[a])){t[a]=String.fromCharCode(o[r]);continue}}t[a]=String.fromCharCode(c)}}}return Promise.resolve(new ee(t))}if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof oe)||"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=D.get(u+"-"+f+"-UCS2");return se.create(d,this.options.cMapOptions,null).then(function(a){var r=e.cMap;t=[];r.forEach(function(e,r){A(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 ee(t)})}return Promise.resolve(new $(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return q(t)?se.create(t,this.options.cMapOptions,null).then(function(e){return e instanceof oe?new $(0,65535):new ee(e.getMap())}):_(t)?se.create(t,this.options.cMapOptions,null).then(function(e){if(e instanceof oe)return new $(0,65535);var t=new Array(e.length);e.forEach(function(e,a){for(var r=[],i=0;i>1;a[s]=n}}return a},extractWidths:function(e,t,a,r){var i,n,s,o,c,l,h,u,f=[],d=0,g=[];if(r.composite){d=e.get("DW")||1e3;u=e.get("W");if(u)for(n=0,s=u.length;n=a?this.flush():this.fnArray.length>=r&&(e===C.restore||e===C.endText)&&this.flush())},addDependency:function(e){if(!(e in this.dependencies)){this.dependencies[e]=!0;this.addOp(C.dependency,[e])}},addDependencies:function(e){for(var t in e)this.addDependency(t); -},addOpList:function(e){S.extendObj(this.dependencies,e.dependencies);for(var t=0,a=e.length;ts&&R("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(;or){p=Math.max(p,v);y+=b+2*i;v=0;b=0}m.push({transform:k,x:v,y:y,w:x.width,h:x.height});v+=x.width+2*i;b=Math.max(b,x.height)}var S=Math.max(p,v)+i,A=y+b+i,I=new Uint8Array(S*A*4),B=S<<2;for(g=0;g=0;){R[P-4]=R[P];R[P-3]=R[P+1];R[P-2]=R[P+2];R[P-1]=R[P+3];R[P+T]=R[P+T-4];R[P+T+1]=R[P+T-3];R[P+T+2]=R[P+T-2];R[P+T+3]=R[P+T-1];P-=B}}n.splice(c,4*d,C.paintInlineImageXObjectGroup);s.splice(c,4*d,[{width:S,height:A,kind:w.RGBA_32BPP,data:I},m]);return c+1});e(r,[C.save,C.transform,C.paintImageMaskXObject,C.restore],function(e){for(var a=10,r=100,i=1e3,n=e.fnArray,s=e.argsArray,o=e.iCurr,c=o-3,l=o-2,h=o-1,u=c+4,f=n.length;u+3=4&&r[s-4]===r[o]&&r[s-3]===r[c]&&r[s-2]===r[l]&&r[s-1]===r[h]&&i[s-4][0]===u&&i[s-4][1]===f){p++;m-=5}for(var b=m+4,v=1;v0?e:0},hasFlag:function(e){return this._hasFlag(this.flags,e)},setRectangle:function(e){g(e)&&4===e.length?this.rectangle=d.normalizeRect(e):this.rectangle=[0,0,0,0]},setColor:function(e){var t=new Uint8Array(3);if(g(e))switch(e.length){case 0:this.color=null;break;case 1:S.singletons.gray.getRgbItem(e,0,t,0);this.color=t;break;case 3:S.singletons.rgb.getRgbItem(e,0,t,0);this.color=t;break;case 4:S.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 O;if(k(e))if(e.has("BS")){var t=e.get("BS"),a=t.get("Type");if(!a||w(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(g(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)},_preparePopup:function(e){e.has("C")||(this.data.color=null);this.data.hasPopup=e.has("Popup");this.data.title=b(e.get("T")||"");this.data.contents=b(e.get("Contents")||"")},loadResources:function(e){return new Promise(function(t,a){this.appearance.dict.getAsync("Resources").then(function(r){if(r){var i=new I(r.map,e,r.xref);i.load().then(function(){t(r)},a)}else t()},a)}.bind(this))},getOperatorList:function(t,a,r){if(!this.appearance)return Promise.resolve(new R);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 R;r.addOp(f.beginAnnotation,[i.rect,l,c]);return t.getOperatorList(h.appearance,a,e,r).then(function(){r.addOp(f.endAnnotation,[]);h.appearance.reset();return r})})}};a.appendToOperatorList=function(e,t,a,r,i,n){for(var s=[],o=0,c=e.length;o0){for(var t=!0,a=!0,r=0,i=e.length;r=0;if(!s){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}(),P=function(){function e(e){T.call(this,e);var t=e.dict,a=this.data;a.annotationType=u.WIDGET;a.fieldName=this._constructFieldName(t);a.fieldValue=d.getInheritableProperty(t,"V",!0);a.alternativeText=b(t.get("TU")||"");a.defaultAppearance=d.getInheritableProperty(t,"DA")||"";var r=d.getInheritableProperty(t,"FT");a.fieldType=w(r)?r.name:null;this.fieldResources=d.getInheritableProperty(t,"DR")||y.empty;a.fieldFlags=d.getInheritableProperty(t,"Ff");(!p(a.fieldFlags)||a.fieldFlags<0)&&(a.fieldFlags=0);a.readOnly=this.hasFieldFlag(l.READONLY);"Sig"===a.fieldType&&this.setFlags(h.HIDDEN)}d.inherit(e,T,{_constructFieldName:function(e){if(!e.has("T")&&!e.has("Parent")){v("Unknown field name, falling back to empty field name.");return""}if(!e.has("Parent"))return b(e.get("T"));var t=[];e.has("T")&&t.unshift(b(e.get("T")));for(var a=e;a.has("Parent");){a=a.get("Parent");a.has("T")&&t.unshift(b(a.get("T")))}return t.join(".")},hasFieldFlag:function(e){return!!(this.data.fieldFlags&e)}});return e}(),E=function(){function e(e){P.call(this,e);this.data.fieldValue=b(this.data.fieldValue||"");var t=d.getInheritableProperty(e.dict,"Q");(!p(t)||t<0||t>2)&&(t=null);this.data.textAlignment=t;var a=d.getInheritableProperty(e.dict,"MaxLen");(!p(a)||a<0)&&(a=null);this.data.maxLen=a;this.data.multiLine=this.hasFieldFlag(l.MULTILINE);this.data.comb=this.hasFieldFlag(l.COMB)&&!this.hasFieldFlag(l.MULTILINE)&&!this.hasFieldFlag(l.PASSWORD)&&!this.hasFieldFlag(l.FILESELECT)&&null!==this.data.maxLen}d.inherit(e,P,{getOperatorList:function(e,t,a){var r=new R;if(a)return Promise.resolve(r);if(this.appearance)return T.prototype.getOperatorList.call(this,e,t,a);if(!this.data.defaultAppearance)return Promise.resolve(r);var i=new x(m(this.data.defaultAppearance));return e.getOperatorList(i,t,this.fieldResources,r).then(function(){return r})}});return e}(),M=function(){function e(e){P.call(this,e);this.data.checkBox=!this.hasFieldFlag(l.RADIO)&&!this.hasFieldFlag(l.PUSHBUTTON);if(this.data.checkBox){if(!w(this.data.fieldValue))return;this.data.fieldValue=this.data.fieldValue.name}this.data.radioButton=this.hasFieldFlag(l.RADIO)&&!this.hasFieldFlag(l.PUSHBUTTON);if(this.data.radioButton){this.data.fieldValue=this.data.buttonValue=null;var t=e.dict.get("Parent");if(!k(t)||!t.has("V"))return;var a=t.get("V");if(!w(a))return;this.data.fieldValue=a.name;var r=e.dict.get("AP");if(!k(r))return;var i=r.get("N");if(!k(i))return;for(var n=i.getKeys(),s=0,o=n.length;sn){w("Page_getInheritedPageProp: maximum loop count exceeded.");break}a=a.get("Parent")}return r?1===r.length||!S(r[0])||i>n?r[0]:x.merge(this.xref,r):x.empty},get content(){return this.getPageProp("Contents")},get resources(){return v(this,"resources",this.getInheritedPageProp("Resources"))},get mediaBox(){var e=this.getInheritedPageProp("MediaBox",!0);return g(e)&&4===e.length?v(this,"mediaBox",e):v(this,"mediaBox",a)},get cropBox(){var e=this.getInheritedPageProp("CropBox",!0);return g(e)&&4===e.length?v(this,"cropBox",e):v(this,"cropBox",this.mediaBox)},get userUnit(){var e=this.getPageProp("UserUnit");(!m(e)||e<=0)&&(e=t);return v(this,"userUnit",e)},get view(){var e=this.mediaBox,t=this.cropBox;if(e===t)return v(this,"view",e);var a=h.intersect(t,e);return v(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 v(this,"rotate",e)},getContentStream:function(){var e,t=this.content;if(g(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 E(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;){s-=i-"startxref".length;s<0&&(s=0);e.pos=s;n=t(e,"startxref",i,!0)}if(n){e.skip(9);var o;do o=e.getByte();while(C(o));for(var c="";o>=32&&o<=57;){c+=String.fromCharCode(o);o=e.getByte()}a=parseInt(c,10);isNaN(a)&&(a=0)}}return v(this,"startXRef",a)},get mainXRefEntriesOffset(){var e=0,t=this.linearization;t&&(e=t.mainXRefEntriesOffset);return v(this,"mainXRefEntriesOffset",e)},checkHeader:function(){var e=this.stream;e.reset();if(t(e,"%PDF-",1024)){e.moveStart();for(var a,r=12,i="";(a=e.getByte())>32&&!(i.length>=r);)i+=String.fromCharCode(a);this.pdfFormatVersion||(this.pdfFormatVersion=i.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){return new q(t.pdfManager,t.xref,e,a,r,i)}};this.catalog=new O(this.pdfManager,this.xref,a)},get numPages(){var e=this.linearization,t=e?e.numPages:this.catalog.numPages;return v(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){d("The document information dictionary is invalid.")}if(e){var a=i.entries;for(var r in a)if(e.has(r)){var n=e.get(r);a[r](n)?t[r]="string"!=typeof n?n:k(n):d('Bad value in document info for "'+r+'"')}}return v(this,"documentInfo",t)},get fingerprint(){var e,t=this.xref,i="",n=t.trailer.get("ID");if(n&&g(n)&&n[0]&&b(n[0])&&n[0]!==r)e=y(n[0]);else{this.stream.ensureRange&&this.stream.ensureRange(0,Math.min(a,this.stream.end));e=L(this.stream.bytes.subarray(0,a),0,a)}for(var s=0,o=e.length;s0&&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});b(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(){b(!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);var t=this._rangeReaders.slice(0);t.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=v();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{var t=this._requests.shift();t.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=v();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 i(e){e.finish();var t=P.indexOf(e);P.splice(t,1)}function n(e){var t=v(),a=function(){var e=I.ensureDoc("numPages"),a=I.ensureDoc("fingerprint"),i=I.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)};I.ensureDoc("checkHeader",[]).then(function(){I.ensureDoc("parseStartXRef",[]).then(function(){I.ensureDoc("parse",[e]).then(a,r)},r)},r);return t.promise}function y(e,t){var r,i=v(),n=e.source;if(n.data){try{r=new S(E,n.data,n.password,t,M);i.resolve(r)}catch(e){i.reject(e)}return i.promise}var o;try{if(n.chunkedViewerLoading)o=new R(n,D);else{b(s,"pdfjs/core/network module is not loaded");o=new s(e)}}catch(e){i.reject(e);return i.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=n.disableAutoFetch||c.isStreamingSupported;r=new A(E,o,{msgHandler:D,url:n.url,password:n.password,length:c.contentLength,disableAutoFetch:e,rangeChunkSize:n.rangeChunkSize},t,M);i.resolve(r);O=null}}).catch(function(e){i.reject(e);O=null});var l=[],h=0,u=function(){var e=m(l);n.length&&e.length!==n.length&&w("reported HTTP length is different from actual");try{r=new S(E,e,n.password,t,M);i.resolve(r)}catch(e){i.reject(e)}l=[]},f=new Promise(function(e,t){var i=function(e){try{a();if(e.done){r||u();O=null;return}var n=e.value;h+=p(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)});f.catch(function(e){i.reject(e);O=null});O=function(){o.cancelAllRequests("abort")};return i.promise}function C(e){function t(e){a();D.send("GetDoc",{pdfInfo:e})}function s(e){if(e instanceof f){var t=new B("PasswordException: response "+e.code);r(t);D.sendWithPromise("PasswordRequest",e).then(function(e){i(t);I.updatePassword(e.password);o()}).catch(function(e){i(t);D.send("PasswordException",e)}.bind(null,e))}else e instanceof c?D.send("InvalidPDF",e):e instanceof h?D.send("MissingPDF",e):e instanceof u?D.send("UnexpectedResponse",e):D.send("UnknownError",new d(e.message,e.toString()))}function o(){a();n(!1).then(t,function(e){a();if(e instanceof g){I.requestLoadedStream();I.onLoadedStream().then(function(){a();n(!0).then(t,s)})}else s(e)},s)}a();var l={url:void 0===e.cMapUrl?null:e.cMapUrl,packed:e.cMapPacked===!0},p={forceDataSchema:e.disableCreateObjectURL,maxImageSize:void 0===e.maxImageSize?-1:e.maxImageSize,disableFontFace:e.disableFontFace,cMapOptions:l};y(e,p).then(function(e){if(T){e.terminate();throw new Error("Worker was terminated")}I=e;D.send("PDFManagerReady",null);I.onLoadedStream().then(function(e){D.send("DataLoaded",{length:e.bytes.byteLength})})}).then(o,s)}var I,T=!1,O=null,P=[],E=e.docId,M=e.docBaseUrl,L=e.docId+"_worker",D=new l(L,E,t);D.postMessageTransfers=e.postMessageTransfers;D.on("GetPage",function(e){return I.getPage(e.pageIndex).then(function(e){var t=I.ensure(e,"rotate"),a=I.ensure(e,"ref"),r=I.ensure(e,"userUnit"),i=I.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 x(e.ref.num,e.ref.gen),a=I.pdfDocument.catalog;return a.getPageIndex(t)});D.on("GetDestinations",function(e){return I.ensureCatalog("destinations")});D.on("GetDestination",function(e){return I.ensureCatalog("getDestination",[e.id])});D.on("GetPageLabels",function(e){return I.ensureCatalog("pageLabels")});D.on("GetAttachments",function(e){return I.ensureCatalog("attachments")});D.on("GetJavaScript",function(e){return I.ensureCatalog("javaScript")});D.on("GetOutline",function(e){return I.ensureCatalog("documentOutline")});D.on("GetMetadata",function(e){return Promise.all([I.ensureDoc("documentInfo"),I.ensureCatalog("metadata")])});D.on("GetData",function(e){I.requestLoadedStream();return I.onLoadedStream().then(function(e){return e.bytes})});D.on("GetStats",function(e){return I.pdfDocument.xref.stats});D.on("GetAnnotations",function(e){return I.getPage(e.pageIndex).then(function(t){return I.ensure(t,"getAnnotationsData",[e.intent])})});D.on("RenderPageRequest",function(e){var t=e.pageIndex;I.getPage(t).then(function(a){var n=new B("RenderPageRequest: page "+t);r(n);var s=t+1,c=Date.now();a.getOperatorList(D,n,e.intent,e.renderInteractiveForms).then(function(e){i(n);k("page="+s+" - getOperatorList: time="+(Date.now()-c)+"ms, len="+e.totalLength)},function(t){i(n);if(!n.terminated){D.send("UnsupportedFeature",{featureId:o.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,n=e.combineTextItems;return I.getPage(t).then(function(e){var s=new B("GetTextContent: page "+t);r(s);var o=t+1,c=Date.now();return e.extractTextContent(s,a,n).then(function(e){i(s);k("text indexing: page="+o+" - time="+(Date.now()-c)+"ms");return e},function(e){i(s);if(!s.terminated)throw e})})});D.on("Cleanup",function(e){return I.cleanup()});D.on("Terminate",function(e){T=!0;if(I){I.terminate();I=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||"undefined"!=typeof module&&module.require||n();e.setPDFNetworkStreamClass=i;e.WorkerTask=B;e.WorkerMessageHandler=T});!function(e,t){t(e.pdfjsCoreNetwork={},e.pdfjsSharedUtil,e.pdfjsCoreWorker)}(this,function(e,t,a){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||c,s=n===c&&a.expectedStatus===l;if(s||n===a.expectedStatus){this.loadedRequests[e]=!0;var o=i(r);if(n===l){var h=r.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(h),f=parseInt(u[1],10);a.onDone({begin:f,chunk:o})}else a.onProgressiveData?a.onDone(null):o?a.onDone({begin:0,chunk:o}):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 u=t.assert,f=t.createPromiseCapability,d=t.isInt,g=t.MissingPDFException,p=t.UnexpectedResponseException;n.prototype={_onRangeRequestReaderClosed:function(e){var t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)},getFullReader:function(){u(!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);var t=this._rangeRequestReaders.slice(0);t.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;var r=a.getResponseHeader("Content-Encoding")||"identity";if("identity"!==r)return!1;var i=a.getResponseHeader("Content-Length");i=parseInt(i,10);if(!d(i))return!1;this._contentLength=i;return!(i<=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){var t=this._requests.shift();t.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 g('Missing PDF "'+a+'".'):new p("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=f();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){var a=this._requests.shift();a.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=f();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()}};a.setPDFNetworkStreamClass(n);e.PDFNetworkStream=n;e.NetworkManager=r})}).call(t);e.WorkerMessageHandler=t.pdfjsCoreWorker.WorkerMessageHandler}); \ No newline at end of file +if(this.stream.end)return this.stream.pos0)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<u)M("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=V.createMask(v,p,m,a instanceof z,k);f.cached=!0;d=[f];i.addOp(C.paintImageMaskXObject,d);n&&(s[n]={fn:C.paintImageMaskXObject,args:d})}else{var w=c.get("SMask","SM")||!1,x=c.get("Mask")||!1,S=200;if(!r||w||x||a instanceof H||!(l+h0&&a.addOp(C.setGState,[s])})},loadFont:function(e,t,a,r){function i(){return Promise.resolve(new Se("g_font_error",new J("Font "+e+" is not available"),t))}var n;if(t){A(N(t));n=t}else{var s=r.get("Font");if(!s){M("fontRes not available");return i()}n=s.getRaw(e)}if(!n){M("fontRef not available");return i()}if(this.fontCache.has(n))return this.fontCache.get(n);t=a.fetchIfRef(n);if(!j(t))return i();if(t.translated)return t.translated;var o,c=I(),l=this.preEvaluateFont(t,a),h=l.descriptor,u=N(n);u&&(o=n.toString());if(j(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(n,g);return this.fontCache.get(n)}}else f[d]={fontID:Q.getFontID()};u&&(f[d].aliasRef=n);o=f[d].fontID}if(u)this.fontCache.put(n,c.promise);else{o||(o=this.idFactory.createObjId());this.fontCache.put("id_"+o,c.promise)}A(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,a)}catch(e){p=Promise.reject(e)}var m=this;p.then(function(e){if(void 0!==e.fontType){var r=a.stats.fontTypes;r[e.fontType]=!0}c.resolve(new Se(t.loadedName,e,t))},function(e){m.handler.send("UnsupportedFeature",{featureId:k.font});try{var r=l.descriptor,i=r&&r.get("FontFile3"),n=i&&i.get("Subtype"),s=te(l.type,n&&n.name),o=a.stats.fontTypes;o[s]=!0}catch(e){}c.resolve(new Se(t.loadedName,new J(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]!==C.constructPath)e.addOp(C.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,l){var h,u=a[a.length-1];if(q(u)&&(h=i.get(u.name))){var f=_(h)?h.dict:h,d=f.get("PatternType");if(d===o){var g=r.base?r.base.getRgb(a,0):null;return this.handleTilingType(t,g,n,h,f,e,s)}if(d===c){var p=f.get("Shading"),m=f.getArray("Matrix");h=ie.parseShading(p,m,l,n,this.handler);e.addOp(t,h.getIR());return Promise.resolve()}return Promise.reject("Unknown PatternType: "+d)}e.addOp(t,a);return Promise.resolve()},getOperatorList:function(e,t,r,i,n){var o=this,c=this.xref,l=Object.create(null);A(i);r=r||L.empty;var h=r.get("XObject")||L.empty,u=r.get("Pattern")||L.empty,f=new Ie(n||new Re),d=new Te(e,c,f),g=new a;return new Promise(function e(a,n){var p=function(t){t.then(function(){try{e(a,n)}catch(e){n(e)}},n)};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,x=k.fn;switch(0|x){case C.paintXObject:if(w[0].code)break;var S=w[0].name;if(!S){M("XObject must be referred to by name.");continue}if(void 0!==l[S]){i.addOp(l[S].fn,l[S].args);w=null;continue}var I=h.get(S);if(I){A(_(I),"XObject should be a stream");var T=I.dict.get("Subtype");A(q(T),"XObject should have a Name subtype");if("Form"===T.name){f.save();p(o.buildFormXObject(r,I,null,i,t,f.state.clone()).then(function(){f.restore()}));return}if("Image"===T.name){o.buildPaintImageXObject(r,I,!1,i,S,l);w=null;continue}if("PS"===T.name){R("Ignored XObject subtype PS");continue}B("Unhandled XObject subtype "+T.name)}break;case C.setFont:var E=w[1];p(o.handleSetFont(r,w,null,i,t,f.state).then(function(e){i.addDependency(e);i.addOp(C.setFont,[e,E])}));return;case C.endInlineImage:var D=w[0].cacheKey;if(D){var F=l[D];if(void 0!==F){i.addOp(F.fn,F.args);w=null;continue}}o.buildPaintImageXObject(r,w[0],!0,i,D,l);w=null;continue;case C.showText:w[0]=o.handleText(w[0],f.state);break;case C.showSpacedText:var U=w[0],N=[],z=U.length,H=f.state;for(b=0;b0){a*=R.fontMatrix[3];t[3]*=a}}var r=S.transform(R.ctm,S.transform(R.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=R.textLineMatrix[0],n=R.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=R.ctm[0];n=R.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*R.fontSize;if(c){b.spaceWidth=c;b.fakeSpaceMin=c*k;b.fakeMultiSpaceMin=c*w;b.fakeMultiSpaceMax=c*x;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){var b=l*R.fontMatrix[0];m=b*R.fontSize+f;i+=m}else{var v=l*R.fontMatrix[0];p=(v*R.fontSize+f)*R.textHScale;r+=p}R.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}}i=i||new Ie(new Be);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},k=.3,w=1.5,x=4,I=this,B=this.xref;r=B.fetchIfRef(r)||L.empty;var R,P=null,E=Object.create(null),M=new Te(e,B,i),D=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();D.reset();for(var p,v={},k=[];!(p=D.check());){k.length=0;v.args=k;if(!M.read(v))break;R=i.state;var w=v.fn;k=v.args;var x,B;switch(0|w){case C.setFont:var F=k[0].name,U=k[1];if(R.font&&F===R.fontName&&U===R.fontSize)break;g();R.fontName=F;R.fontSize=U;h(u(F,null));return;case C.setTextRise:g();R.textRise=k[0];break;case C.setHScale:g();R.textHScale=k[0]/100;break;case C.setLeading:g();R.leading=k[0];break;case C.moveText:var N=!!R.font&&0===(R.font.vertical?k[0]:k[1]);x=k[0]-k[1];if(o&&N&&b.initialized&&x>0&&x<=b.fakeMultiSpaceMax){R.translateTextLineMatrix(k[0],k[1]);b.width+=k[0]-b.lastAdvanceWidth;b.height+=k[1]-b.lastAdvanceHeight;B=k[0]-b.lastAdvanceWidth-(k[1]-b.lastAdvanceHeight);d(B,b.str);break}g();R.translateTextLineMatrix(k[0],k[1]);R.textMatrix=R.textLineMatrix.slice();break;case C.setLeadingMoveText:g();R.leading=-k[1];R.translateTextLineMatrix(k[0],k[1]);R.textMatrix=R.textLineMatrix.slice();break;case C.nextLine:g();R.carriageReturn();break;case C.setTextMatrix:x=R.calcTextLineMatrixAdvance(k[0],k[1],k[2],k[3],k[4],k[5]);if(o&&null!==x&&b.initialized&&x.value>0&&x.value<=b.fakeMultiSpaceMax){R.translateTextLineMatrix(x.width,x.height);b.width+=x.width-b.lastAdvanceWidth;b.height+=x.height-b.lastAdvanceHeight;B=x.width-b.lastAdvanceWidth-(x.height-b.lastAdvanceHeight);d(B,b.str);break}g();R.setTextMatrix(k[0],k[1],k[2],k[3],k[4],k[5]);R.setTextLineMatrix(k[0],k[1],k[2],k[3],k[4],k[5]);break;case C.setCharSpacing:R.charSpacing=k[0];break;case C.setWordSpacing:R.wordSpacing=k[0];break;case C.beginText:g();R.textMatrix=y.slice();R.textLineMatrix=y.slice();break;case C.showSpacedText:for(var z,H=k[0],G=0,X=H.length;Gb.fakeMultiSpaceMax;W||(b.height+=z)}else{x=-x;z=x*R.textHScale;R.translateTextMatrix(z,0);W=b.textRunBreakAllowed&&x>b.fakeMultiSpaceMax;W||(b.width+=z)}W?g():x>0&&d(x,b.str)}break;case C.showText:f(k[0]);break;case C.nextLineShowText:g();R.carriageReturn();f(k[0]);break;case C.nextLineSetSpacingShowText:g();R.wordSpacing=k[0];R.charSpacing=k[1];R.carriageReturn();f(k[2]);break;case C.paintXObject:g();if(k[0].code)break;P||(P=r.get("XObject")||L.empty);var V=k[0].name;if(E.key===V){if(E.texts){S.appendToArray(m.items,E.texts.items);S.extendObj(m.styles,E.texts.styles)}break}var K=P.get(V);if(!K)break;A(_(K),"XObject should be a stream");var Y=K.dict.get("Subtype");A(q(Y),"XObject should have a Name subtype");if("Form"!==Y.name){E.key=V;E.texts=null;break}i.save();var J=K.dict.getArray("Matrix");T(J)&&6===J.length&&i.transform(J);h(I.getTextContent(K,t,K.dict.get("Resources")||r,i,n,o).then(function(e){S.appendToArray(m.items,e.items);S.extendObj(m.styles,e.styles);i.restore();E.key=V;E.texts=e}));return;case C.setGState:g();var Z=k[0],Q=r.get("ExtGState");if(!j(Q)||!q(Z))break;var $=Q.get(Z.name);if(!j($))break;var ee=$.get("Font");if(ee){R.fontName=null;R.fontSize=ee[1];h(u(null,ee[0]));return}}}if(p)h(s);else{g();a(m)}})},extractDataStructures:function(e,t,a,r){var i=e.get("ToUnicode")||t.get("ToUnicode"),n=i?this.readToUnicode(i):Promise.resolve(void 0);if(r.composite){var s=e.get("CIDSystemInfo");j(s)&&(r.cidSystemInfo={registry:s.get("Registry"),ordering:s.get("Ordering"),supplement:s.get("Supplement")});var o=e.get("CIDToGIDMap");_(o)&&(r.cidToGidMap=this.readCidToGidMap(o))}var c,l=[],h=null;if(e.has("Encoding")){c=e.get("Encoding");if(j(c)){h=c.get("BaseEncoding");h=q(h)?h.name:null;if(c.has("Differences"))for(var u=c.get("Differences"),f=0,d=0,g=u.length;d0;r.dict=e;return n.then(function(e){r.toUnicode=e;return this.buildToUnicode(r)}.bind(this)).then(function(e){r.toUnicode=e;return r})},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=Ce();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=we(r,o);l!==-1&&(c=l)}if(c){if(n&&c===+a){var h=pe(n);if(h&&(r=h[a])){t[a]=String.fromCharCode(o[r]);continue}}t[a]=String.fromCharCode(c)}}}return Promise.resolve(new ee(t))}if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof oe)||"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=D.get(u+"-"+f+"-UCS2");return se.create(d,this.options.cMapOptions,null).then(function(a){var r=e.cMap;t=[];r.forEach(function(e,r){A(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 ee(t)})}return Promise.resolve(new $(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return q(t)?se.create(t,this.options.cMapOptions,null).then(function(e){return e instanceof oe?new $(0,65535):new ee(e.getMap())}):_(t)?se.create(t,this.options.cMapOptions,null).then(function(e){if(e instanceof oe)return new $(0,65535);var t=new Array(e.length);e.forEach(function(e,a){for(var r=[],i=0;i>1;a[s]=n}}return a},extractWidths:function(e,t,a,r){var i,n,s,o,c,l,h,u,f=[],d=0,g=[];if(r.composite){d=e.get("DW")||1e3;u=e.get("W");if(u)for(n=0,s=u.length;n=a?this.flush():this.fnArray.length>=r&&(e===C.restore||e===C.endText)&&this.flush())},addDependency:function(e){if(!(e in this.dependencies)){this.dependencies[e]=!0;this.addOp(C.dependency,[e]); +}},addDependencies:function(e){for(var t in e)this.addDependency(t)},addOpList:function(e){S.extendObj(this.dependencies,e.dependencies);for(var t=0,a=e.length;ts&&R("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(;or){p=Math.max(p,v);y+=b+2*i;v=0;b=0}m.push({transform:k,x:v,y:y,w:x.width,h:x.height});v+=x.width+2*i;b=Math.max(b,x.height)}var S=Math.max(p,v)+i,A=y+b+i,I=new Uint8Array(S*A*4),B=S<<2;for(g=0;g=0;){R[P-4]=R[P];R[P-3]=R[P+1];R[P-2]=R[P+2];R[P-1]=R[P+3];R[P+T]=R[P+T-4];R[P+T+1]=R[P+T-3];R[P+T+2]=R[P+T-2];R[P+T+3]=R[P+T-1];P-=B}}n.splice(c,4*d,C.paintInlineImageXObjectGroup);s.splice(c,4*d,[{width:S,height:A,kind:w.RGBA_32BPP,data:I},m]);return c+1});e(r,[C.save,C.transform,C.paintImageMaskXObject,C.restore],function(e){for(var a=10,r=100,i=1e3,n=e.fnArray,s=e.argsArray,o=e.iCurr,c=o-3,l=o-2,h=o-1,u=c+4,f=n.length;u+3=4&&r[s-4]===r[o]&&r[s-3]===r[c]&&r[s-2]===r[l]&&r[s-1]===r[h]&&i[s-4][0]===u&&i[s-4][1]===f){p++;m-=5}for(var b=m+4,v=1;v0?e:0},hasFlag:function(e){return this._hasFlag(this.flags,e)},setRectangle:function(e){g(e)&&4===e.length?this.rectangle=d.normalizeRect(e):this.rectangle=[0,0,0,0]},setColor:function(e){var t=new Uint8Array(3);if(g(e))switch(e.length){case 0:this.color=null;break;case 1:S.singletons.gray.getRgbItem(e,0,t,0);this.color=t;break;case 3:S.singletons.rgb.getRgbItem(e,0,t,0);this.color=t;break;case 4:S.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 O;if(k(e))if(e.has("BS")){var t=e.get("BS"),a=t.get("Type");if(!a||w(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(g(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)},_preparePopup:function(e){e.has("C")||(this.data.color=null);this.data.hasPopup=e.has("Popup");this.data.title=b(e.get("T")||"");this.data.contents=b(e.get("Contents")||"")},loadResources:function(e){return new Promise(function(t,a){this.appearance.dict.getAsync("Resources").then(function(r){if(r){var i=new I(r.map,e,r.xref);i.load().then(function(){t(r)},a)}else t()},a)}.bind(this))},getOperatorList:function(t,a,r){if(!this.appearance)return Promise.resolve(new R);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 R;r.addOp(f.beginAnnotation,[i.rect,l,c]);return t.getOperatorList(h.appearance,a,e,r).then(function(){r.addOp(f.endAnnotation,[]);h.appearance.reset();return r})})}};a.appendToOperatorList=function(e,t,a,r,i,n){for(var s=[],o=0,c=e.length;o0){for(var t=!0,a=!0,r=0,i=e.length;r=0;if(!s){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}(),P=function(){function e(e){T.call(this,e);var t=e.dict,a=this.data;a.annotationType=u.WIDGET;a.fieldName=this._constructFieldName(t);a.fieldValue=d.getInheritableProperty(t,"V",!0);a.alternativeText=b(t.get("TU")||"");a.defaultAppearance=d.getInheritableProperty(t,"DA")||"";var r=d.getInheritableProperty(t,"FT");a.fieldType=w(r)?r.name:null;this.fieldResources=d.getInheritableProperty(t,"DR")||y.empty;a.fieldFlags=d.getInheritableProperty(t,"Ff");(!p(a.fieldFlags)||a.fieldFlags<0)&&(a.fieldFlags=0);a.readOnly=this.hasFieldFlag(l.READONLY);"Sig"===a.fieldType&&this.setFlags(h.HIDDEN)}d.inherit(e,T,{_constructFieldName:function(e){if(!e.has("T")&&!e.has("Parent")){v("Unknown field name, falling back to empty field name.");return""}if(!e.has("Parent"))return b(e.get("T"));var t=[];e.has("T")&&t.unshift(b(e.get("T")));for(var a=e;a.has("Parent");){a=a.get("Parent");a.has("T")&&t.unshift(b(a.get("T")))}return t.join(".")},hasFieldFlag:function(e){return!!(this.data.fieldFlags&e)}});return e}(),E=function(){function e(e){P.call(this,e);this.data.fieldValue=b(this.data.fieldValue||"");var t=d.getInheritableProperty(e.dict,"Q");(!p(t)||t<0||t>2)&&(t=null);this.data.textAlignment=t;var a=d.getInheritableProperty(e.dict,"MaxLen");(!p(a)||a<0)&&(a=null);this.data.maxLen=a;this.data.multiLine=this.hasFieldFlag(l.MULTILINE);this.data.comb=this.hasFieldFlag(l.COMB)&&!this.hasFieldFlag(l.MULTILINE)&&!this.hasFieldFlag(l.PASSWORD)&&!this.hasFieldFlag(l.FILESELECT)&&null!==this.data.maxLen}d.inherit(e,P,{getOperatorList:function(e,t,a){var r=new R;if(a)return Promise.resolve(r);if(this.appearance)return T.prototype.getOperatorList.call(this,e,t,a);if(!this.data.defaultAppearance)return Promise.resolve(r);var i=new x(m(this.data.defaultAppearance));return e.getOperatorList(i,t,this.fieldResources,r).then(function(){return r})}});return e}(),M=function(){function e(e){P.call(this,e);this.data.checkBox=!this.hasFieldFlag(l.RADIO)&&!this.hasFieldFlag(l.PUSHBUTTON);if(this.data.checkBox){if(!w(this.data.fieldValue))return;this.data.fieldValue=this.data.fieldValue.name}this.data.radioButton=this.hasFieldFlag(l.RADIO)&&!this.hasFieldFlag(l.PUSHBUTTON);if(this.data.radioButton){this.data.fieldValue=this.data.buttonValue=null;var t=e.dict.get("Parent");if(!k(t)||!t.has("V"))return;var a=t.get("V");if(!w(a))return;this.data.fieldValue=a.name;var r=e.dict.get("AP");if(!k(r))return;var i=r.get("N");if(!k(i))return;for(var n=i.getKeys(),s=0,o=n.length;sn){w("Page_getInheritedPageProp: maximum loop count exceeded.");break}a=a.get("Parent")}return r?1===r.length||!S(r[0])||i>n?r[0]:x.merge(this.xref,r):x.empty},get content(){return this.getPageProp("Contents")},get resources(){return v(this,"resources",this.getInheritedPageProp("Resources"))},get mediaBox(){var e=this.getInheritedPageProp("MediaBox",!0);return g(e)&&4===e.length?v(this,"mediaBox",e):v(this,"mediaBox",a)},get cropBox(){var e=this.getInheritedPageProp("CropBox",!0);return g(e)&&4===e.length?v(this,"cropBox",e):v(this,"cropBox",this.mediaBox)},get userUnit(){var e=this.getPageProp("UserUnit");(!m(e)||e<=0)&&(e=t);return v(this,"userUnit",e)},get view(){var e=this.mediaBox,t=this.cropBox;if(e===t)return v(this,"view",e);var a=h.intersect(t,e);return v(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 v(this,"rotate",e)},getContentStream:function(){var e,t=this.content;if(g(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 E(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;){s-=i-"startxref".length;s<0&&(s=0);e.pos=s;n=t(e,"startxref",i,!0)}if(n){e.skip(9);var o;do o=e.getByte();while(C(o));for(var c="";o>=32&&o<=57;){c+=String.fromCharCode(o);o=e.getByte()}a=parseInt(c,10);isNaN(a)&&(a=0)}}return v(this,"startXRef",a)},get mainXRefEntriesOffset(){var e=0,t=this.linearization;t&&(e=t.mainXRefEntriesOffset);return v(this,"mainXRefEntriesOffset",e)},checkHeader:function(){var e=this.stream;e.reset();if(t(e,"%PDF-",1024)){e.moveStart();for(var a,r=12,i="";(a=e.getByte())>32&&!(i.length>=r);)i+=String.fromCharCode(a);this.pdfFormatVersion||(this.pdfFormatVersion=i.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){return new q(t.pdfManager,t.xref,e,a,r,i)}};this.catalog=new O(this.pdfManager,this.xref,a)},get numPages(){var e=this.linearization,t=e?e.numPages:this.catalog.numPages;return v(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){d("The document information dictionary is invalid.")}if(e){var a=i.entries;for(var r in a)if(e.has(r)){var n=e.get(r);a[r](n)?t[r]="string"!=typeof n?n:k(n):d('Bad value in document info for "'+r+'"')}}return v(this,"documentInfo",t)},get fingerprint(){var e,t=this.xref,i="",n=t.trailer.get("ID");if(n&&g(n)&&n[0]&&b(n[0])&&n[0]!==r)e=y(n[0]);else{this.stream.ensureRange&&this.stream.ensureRange(0,Math.min(a,this.stream.end));e=L(this.stream.bytes.subarray(0,a),0,a)}for(var s=0,o=e.length;s0&&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});b(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(){b(!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);var t=this._rangeReaders.slice(0);t.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=v();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{var t=this._requests.shift();t.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=v();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 i(e){e.finish();var t=P.indexOf(e);P.splice(t,1)}function n(e){var t=v(),a=function(){var e=I.ensureDoc("numPages"),a=I.ensureDoc("fingerprint"),i=I.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)};I.ensureDoc("checkHeader",[]).then(function(){I.ensureDoc("parseStartXRef",[]).then(function(){I.ensureDoc("parse",[e]).then(a,r)},r)},r);return t.promise}function y(e,t){var r,i=v(),n=e.source;if(n.data){try{r=new S(E,n.data,n.password,t,M);i.resolve(r)}catch(e){i.reject(e)}return i.promise}var o;try{if(n.chunkedViewerLoading)o=new R(n,D);else{b(s,"pdfjs/core/network module is not loaded");o=new s(e)}}catch(e){i.reject(e);return i.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=n.disableAutoFetch||c.isStreamingSupported;r=new A(E,o,{msgHandler:D,url:n.url,password:n.password,length:c.contentLength,disableAutoFetch:e,rangeChunkSize:n.rangeChunkSize},t,M);i.resolve(r);O=null}}).catch(function(e){i.reject(e);O=null});var l=[],h=0,u=function(){var e=m(l);n.length&&e.length!==n.length&&w("reported HTTP length is different from actual");try{r=new S(E,e,n.password,t,M);i.resolve(r)}catch(e){i.reject(e)}l=[]},f=new Promise(function(e,t){var i=function(e){try{a();if(e.done){r||u();O=null;return}var n=e.value;h+=p(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)});f.catch(function(e){i.reject(e);O=null});O=function(){o.cancelAllRequests("abort")};return i.promise}function C(e){function t(e){a();D.send("GetDoc",{pdfInfo:e})}function s(e){if(e instanceof f){var t=new B("PasswordException: response "+e.code);r(t);D.sendWithPromise("PasswordRequest",e).then(function(e){i(t);I.updatePassword(e.password);o()}).catch(function(e){i(t);D.send("PasswordException",e)}.bind(null,e))}else e instanceof c?D.send("InvalidPDF",e):e instanceof h?D.send("MissingPDF",e):e instanceof u?D.send("UnexpectedResponse",e):D.send("UnknownError",new d(e.message,e.toString()))}function o(){a();n(!1).then(t,function(e){a();if(e instanceof g){I.requestLoadedStream();I.onLoadedStream().then(function(){a();n(!0).then(t,s)})}else s(e)},s)}a();var l={url:void 0===e.cMapUrl?null:e.cMapUrl,packed:e.cMapPacked===!0},p={forceDataSchema:e.disableCreateObjectURL,maxImageSize:void 0===e.maxImageSize?-1:e.maxImageSize,disableFontFace:e.disableFontFace,cMapOptions:l,disableNativeImageDecoder:e.disableNativeImageDecoder};y(e,p).then(function(e){if(T){e.terminate();throw new Error("Worker was terminated")}I=e;D.send("PDFManagerReady",null);I.onLoadedStream().then(function(e){D.send("DataLoaded",{length:e.bytes.byteLength})})}).then(o,s)}var I,T=!1,O=null,P=[],E=e.docId,M=e.docBaseUrl,L=e.docId+"_worker",D=new l(L,E,t);D.postMessageTransfers=e.postMessageTransfers;D.on("GetPage",function(e){return I.getPage(e.pageIndex).then(function(e){var t=I.ensure(e,"rotate"),a=I.ensure(e,"ref"),r=I.ensure(e,"userUnit"),i=I.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 x(e.ref.num,e.ref.gen),a=I.pdfDocument.catalog;return a.getPageIndex(t)});D.on("GetDestinations",function(e){return I.ensureCatalog("destinations")});D.on("GetDestination",function(e){return I.ensureCatalog("getDestination",[e.id])});D.on("GetPageLabels",function(e){return I.ensureCatalog("pageLabels")});D.on("GetAttachments",function(e){return I.ensureCatalog("attachments")});D.on("GetJavaScript",function(e){return I.ensureCatalog("javaScript")});D.on("GetOutline",function(e){return I.ensureCatalog("documentOutline")});D.on("GetMetadata",function(e){return Promise.all([I.ensureDoc("documentInfo"),I.ensureCatalog("metadata")])});D.on("GetData",function(e){I.requestLoadedStream();return I.onLoadedStream().then(function(e){return e.bytes})});D.on("GetStats",function(e){return I.pdfDocument.xref.stats});D.on("GetAnnotations",function(e){return I.getPage(e.pageIndex).then(function(t){return I.ensure(t,"getAnnotationsData",[e.intent])})});D.on("RenderPageRequest",function(e){var t=e.pageIndex;I.getPage(t).then(function(a){var n=new B("RenderPageRequest: page "+t);r(n);var s=t+1,c=Date.now();a.getOperatorList(D,n,e.intent,e.renderInteractiveForms).then(function(e){i(n);k("page="+s+" - getOperatorList: time="+(Date.now()-c)+"ms, len="+e.totalLength)},function(t){i(n);if(!n.terminated){D.send("UnsupportedFeature",{featureId:o.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,n=e.combineTextItems;return I.getPage(t).then(function(e){var s=new B("GetTextContent: page "+t);r(s);var o=t+1,c=Date.now();return e.extractTextContent(s,a,n).then(function(e){i(s);k("text indexing: page="+o+" - time="+(Date.now()-c)+"ms");return e},function(e){i(s);if(!s.terminated)throw e})})});D.on("Cleanup",function(e){return I.cleanup()});D.on("Terminate",function(e){T=!0;if(I){I.terminate();I=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||"undefined"!=typeof module&&module.require||n();e.setPDFNetworkStreamClass=i;e.WorkerTask=B;e.WorkerMessageHandler=T});!function(e,t){t(e.pdfjsCoreNetwork={},e.pdfjsSharedUtil,e.pdfjsCoreWorker)}(this,function(e,t,a){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||c,s=n===c&&a.expectedStatus===l;if(s||n===a.expectedStatus){this.loadedRequests[e]=!0;var o=i(r);if(n===l){var h=r.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(h),f=parseInt(u[1],10);a.onDone({begin:f,chunk:o})}else a.onProgressiveData?a.onDone(null):o?a.onDone({begin:0,chunk:o}):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 u=t.assert,f=t.createPromiseCapability,d=t.isInt,g=t.MissingPDFException,p=t.UnexpectedResponseException;n.prototype={_onRangeRequestReaderClosed:function(e){var t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)},getFullReader:function(){u(!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);var t=this._rangeRequestReaders.slice(0);t.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;var r=a.getResponseHeader("Content-Encoding")||"identity";if("identity"!==r)return!1;var i=a.getResponseHeader("Content-Length");i=parseInt(i,10);if(!d(i))return!1;this._contentLength=i;return!(i<=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){var t=this._requests.shift();t.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 g('Missing PDF "'+a+'".'):new p("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=f();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){var a=this._requests.shift();a.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=f();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()}};a.setPDFNetworkStreamClass(n);e.PDFNetworkStream=n;e.NetworkManager=r})}).call(t);e.WorkerMessageHandler=t.pdfjsCoreWorker.WorkerMessageHandler}); \ No newline at end of file diff --git a/package.json b/package.json index dfeebd8f3..66f87d69e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.7.254", + "version": "1.7.256", "main": "build/pdf.js", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [