roundcubemail-plugins-kolab/plugins/pdfviewer/viewer/viewer.js

93 lines
45 KiB
JavaScript

var DEFAULT_URL=null,DEFAULT_SCALE="auto",DEFAULT_SCALE_DELTA=1.1,UNKNOWN_SCALE=0,CACHE_SIZE=20,CSS_UNITS=96/72,SCROLLBAR_PADDING=40,VERTICAL_PADDING=5,MIN_SCALE=0.25,MAX_SCALE=4,IMAGE_DIR="./images/",SETTINGS_MEMORY=20,ANNOT_MIN_SIZE=10,RenderingStates={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},FindStates={FIND_FOUND:0,FIND_NOTFOUND:1,FIND_WRAPPED:2,FIND_PENDING:3};PDFJS.workerSrc="pdf.js";var mozL10n=document.mozL10n||document.webL10n;
function getFileName(a){var b=a.indexOf("#"),c=a.indexOf("?"),b=Math.min(0<b?b:a.length,0<c?c:a.length);return a.substring(a.lastIndexOf("/",b)+1,b)}function scrollIntoView(a,b){for(var c=a.offsetParent,d=a.offsetTop;c.clientHeight==c.scrollHeight;)if(d+=c.offsetTop,c=c.offsetParent,!c)return;b&&(d+=b.top);c.scrollTop=d}
var Cache=function(a){var b=[];this.push=function(c){var d=b.indexOf(c);0<=d&&b.splice(d);b.push(c);b.length>a&&b.shift().destroy()}},ProgressBar=function(){function a(a,c){this.div=document.querySelector(a+" .progress");this.height=c.height||100;this.width=c.width||100;this.units=c.units||"%";this.div.style.height=this.height+this.units}a.prototype={updateBar:function(){if(this._indeterminate)this.div.classList.add("indeterminate");else{var a=this.width*this._percent/100;95<this._percent?this.div.classList.add("full"):
this.div.classList.remove("full");this.div.classList.remove("indeterminate");this.div.style.width=a+this.units}},get percent(){return this._percent},set percent(a){this._indeterminate=isNaN(a);this._percent=Math.min(Math.max(a,0),100);this.updateBar()}};return a}(),Settings=function(){function a(a){this.fingerprint=a;this.initializedPromise=new PDFJS.Promise;a=function(a){this.initialize(a||"{}");this.initializedPromise.resolve()}.bind(this);b&&a(localStorage.getItem("database"))}var b;try{b="localStorage"in
window&&null!==window.localStorage&&localStorage}catch(c){b=!1}a.prototype={initialize:function(a){a=JSON.parse(a);"files"in a||(a.files=[]);a.files.length>=SETTINGS_MEMORY&&a.files.shift();for(var b,c=0,f=a.files.length;c<f;c++)if(a.files[c].fingerprint==this.fingerprint){b=c;break}"number"!=typeof b&&(b=a.files.push({fingerprint:this.fingerprint})-1);this.file=a.files[b];this.database=a},set:function(a,c){if(this.initializedPromise.isResolved){this.file[a]=c;var j=JSON.stringify(this.database);
b&&localStorage.setItem("database",j)}},get:function(a,b){return!this.initializedPromise.isResolved?b:this.file[a]||b}};return a}(),cache=new Cache(CACHE_SIZE),currentPageNumber=1,PDFFindController={startedTextExtraction:!1,extractTextPromises:[],active:!1,pageContents:[],pageMatches:[],selected:{pageIdx:-1,matchIdx:-1},offset:{pageIdx:null,matchIdx:null},resumePageIdx:null,resumeCallback:null,state:null,dirtyMatch:!1,findTimeout:null,initialize:function(){var a=["find","findagain","findhighlightallchange",
"findcasesensitivitychange"];this.handleEvent=this.handleEvent.bind(this);for(var b=0;b<a.length;b++)window.addEventListener(a[b],this.handleEvent)},calcFindMatch:function(a){var b=this.pageContents[a],c=this.state.query,d=this.state.caseSensitive,e=c.length;if(0!==e){d||(b=b.toLowerCase(),c=c.toLowerCase());for(var d=[],j=-e;;){j=b.indexOf(c,j+e);if(-1===j)break;d.push(j)}this.pageMatches[a]=d;this.updatePage(a);this.resumePageIdx===a&&(a=this.resumeCallback,this.resumeCallback=this.resumePageIdx=
null,a())}},extractText:function(){function a(b){PDFView.pages[b].getTextContent().then(function(c){c=c.bidiTexts;for(var f="",h=0;h<c.length;h++)f+=c[h].str;d.pageContents.push(f);d.extractTextPromises[b].resolve(b);b+1<PDFView.pages.length&&a(b+1)})}if(!this.startedTextExtraction){this.startedTextExtraction=!0;this.pageContents=[];for(var b=0,c=PDFView.pdfDocument.numPages;b<c;b++)this.extractTextPromises.push(new PDFJS.Promise);var d=this;a(0);return this.extractTextPromise}},handleEvent:function(a){if(null===
this.state||"findagain"!==a.type)this.dirtyMatch=!0;this.state=a.detail;this.updateUIState(FindStates.FIND_PENDING);this.extractText();clearTimeout(this.findTimeout);"find"===a.type?this.findTimeout=setTimeout(this.nextMatch.bind(this),250):this.nextMatch()},updatePage:function(a){var b=PDFView.pages[a];this.selected.pageIdx===a&&b.scrollIntoView();b.textLayer&&b.textLayer.updateMatches()},nextMatch:function(){var a=this.state.findPrevious,b=PDFView.pages.length;this.active=!0;if(this.dirtyMatch){this.dirtyMatch=
!1;this.selected.pageIdx=this.selected.matchIdx=-1;this.offset.pageIdx=a?b-1:0;this.offset.matchIdx=null;this.hadMatch=!1;this.resumePageIdx=this.resumeCallback=null;this.pageMatches=[];for(var c=this,d=0;d<b;d++)this.updatePage(d),this.extractTextPromises[d].onData(function(a){setTimeout(function(){c.calcFindMatch(a)})})}if(""===this.state.query)this.updateUIState(FindStates.FIND_FOUND);else if(!this.resumeCallback){b=this.offset;if(null!==b.matchIdx){d=this.pageMatches[b.pageIdx].length;if(!a&&
b.matchIdx+1<d||a&&0<b.matchIdx){this.hadMatch=!0;b.matchIdx=a?b.matchIdx-1:b.matchIdx+1;this.updateMatch(!0);return}this.advanceOffsetPage(a)}this.nextPageMatch()}},nextPageMatch:function(){null!==this.resumePageIdx&&console.error("There can only be one pending page.");var a=function(a){var b=this.offset;a=a.length;var c=this.state.findPrevious;if(a)this.hadMatch=!0,b.matchIdx=c?a-1:0,this.updateMatch(!0);else{this.advanceOffsetPage(c);if(b.wrapped&&(b.matchIdx=null,!this.hadMatch)){this.updateMatch(!1);
return}this.nextPageMatch()}}.bind(this),b=this.offset.pageIdx,c=this.pageMatches;c[b]?a(c[b]):(this.resumeCallback=function(){a(c[b])},this.resumePageIdx=b)},advanceOffsetPage:function(a){var b=this.offset,c=this.extractTextPromises.length;b.pageIdx=a?b.pageIdx-1:b.pageIdx+1;b.matchIdx=null;if(b.pageIdx>=c||0>b.pageIdx)b.pageIdx=a?c-1:0,b.wrapped=!0},updateMatch:function(a){var b=FindStates.FIND_NOTFOUND,c=this.offset.wrapped;this.offset.wrapped=!1;a&&(a=this.selected.pageIdx,this.selected.pageIdx=
this.offset.pageIdx,this.selected.matchIdx=this.offset.matchIdx,b=c?FindStates.FIND_WRAPPED:FindStates.FIND_FOUND,-1!==a&&a!==this.selected.pageIdx&&this.updatePage(a));this.updateUIState(b,this.state.findPrevious);-1!==this.selected.pageIdx&&this.updatePage(this.selected.pageIdx,!0)},updateUIState:function(a,b){PDFView.supportsIntegratedFind?FirefoxCom.request("updateFindControlState",{result:a,findPrevious:b}):PDFFindBar.updateUIState(a,b)}},PDFFindBar={opened:!1,initialize:function(){this.bar=
document.getElementById("findbar");this.toggleButton=document.getElementById("viewFind");this.findField=document.getElementById("findInput");this.highlightAll=document.getElementById("findHighlightAll");this.caseSensitive=document.getElementById("findMatchCase");this.findMsg=document.getElementById("findMsg");this.findStatusIcon=document.getElementById("findStatusIcon");var a=this;this.toggleButton.addEventListener("click",function(){a.toggle()});this.findField.addEventListener("input",function(){a.dispatchEvent("")});
this.bar.addEventListener("keydown",function(b){switch(b.keyCode){case 13:b.target===a.findField&&a.dispatchEvent("again",b.shiftKey);break;case 27:a.close()}});document.getElementById("findPrevious").addEventListener("click",function(){a.dispatchEvent("again",!0)});document.getElementById("findNext").addEventListener("click",function(){a.dispatchEvent("again",!1)});this.highlightAll.addEventListener("click",function(){a.dispatchEvent("highlightallchange")});this.caseSensitive.addEventListener("click",
function(){a.dispatchEvent("casesensitivitychange")})},dispatchEvent:function(a,b){var c=document.createEvent("CustomEvent");c.initCustomEvent("find"+a,!0,!0,{query:this.findField.value,caseSensitive:this.caseSensitive.checked,highlightAll:this.highlightAll.checked,findPrevious:b});return window.dispatchEvent(c)},updateUIState:function(a,b){var c=!1,d="",e="";switch(a){case FindStates.FIND_PENDING:e="pending";break;case FindStates.FIND_NOTFOUND:d=mozL10n.get("find_not_found",null,"Phrase not found");
c=!0;break;case FindStates.FIND_WRAPPED:d=b?mozL10n.get("find_reached_top",null,"Reached top of document, continued from bottom"):mozL10n.get("find_reached_bottom",null,"Reached end of document, continued from top")}c?this.findField.classList.add("notFound"):this.findField.classList.remove("notFound");this.findField.setAttribute("data-status",e);this.findMsg.textContent=d},open:function(){this.opened||(this.opened=!0,this.toggleButton.classList.add("toggled"),this.bar.classList.remove("hidden"),this.findField.select(),
this.findField.focus())},close:function(){this.opened&&(this.opened=!1,this.toggleButton.classList.remove("toggled"),this.bar.classList.add("hidden"),PDFFindController.active=!1)},toggle:function(){this.opened?this.close():this.open()}},PDFView={pages:[],thumbnails:[],currentScale:UNKNOWN_SCALE,currentScaleValue:null,initialBookmark:document.location.hash.substring(1),startedTextExtraction:!1,pageText:[],container:null,thumbnailContainer:null,initialized:!1,fellback:!1,pdfDocument:null,sidebarOpen:!1,
pageViewScroll:null,thumbnailViewScroll:null,isFullscreen:!1,previousScale:null,pageRotation:0,mouseScrollTimeStamp:0,mouseScrollDelta:0,lastScroll:0,previousPageNumber:1,initialize:function(){var a=this,b=this.container=document.getElementById("viewerContainer");this.pageViewScroll={};this.watchScroll(b,this.pageViewScroll,updateViewarea);var c=this.thumbnailContainer=document.getElementById("thumbnailView");this.thumbnailViewScroll={};this.watchScroll(c,this.thumbnailViewScroll,this.renderHighestPriority.bind(this));
PDFFindBar.initialize();PDFFindController.initialize();this.initialized=!0;b.addEventListener("scroll",function(){a.lastScroll=Date.now()},!1)},watchScroll:function(a,b,c){b.down=!0;b.lastY=a.scrollTop;a.addEventListener("scroll",function(){var d=a.scrollTop,e=b.lastY;d>e?b.down=!0:d<e&&(b.down=!1);b.lastY=d;c()},!0)},setScale:function(a,b,c){if(a!=this.currentScale){for(var d=this.pages,e=0;e<d.length;e++)d[e].update(a*CSS_UNITS);!c&&this.currentScale!=a&&this.pages[this.page-1].scrollIntoView();
this.currentScale=a;c=document.createEvent("UIEvents");c.initUIEvent("scalechange",!1,!1,window,0);c.scale=a;c.resetAutoSettings=b;window.dispatchEvent(c)}},parseScale:function(a,b,c){if("custom"!=a){var d=parseFloat(a);this.currentScaleValue=a;if(d)this.setScale(d,!0,c);else{var e=this.container,j=this.pages[this.page-1];if(j){var f=(e.clientWidth-SCROLLBAR_PADDING)/j.width*j.scale/CSS_UNITS,e=(e.clientHeight-VERTICAL_PADDING)/j.height*j.scale/CSS_UNITS;switch(a){case "page-actual":d=1;break;case "page-width":d=
f;break;case "page-height":d=e;break;case "page-fit":d=Math.min(f,e);break;case "auto":d=Math.min(1,f)}this.setScale(d,b,c);selectScaleOption(a)}}}},zoomIn:function(){var a=(this.currentScale*DEFAULT_SCALE_DELTA).toFixed(2),a=Math.min(MAX_SCALE,a);this.parseScale(a,!0)},zoomOut:function(){var a=(this.currentScale/DEFAULT_SCALE_DELTA).toFixed(2),a=Math.max(MIN_SCALE,a);this.parseScale(a,!0)},set page(a){var b=this.pages;document.getElementById("pageNumber");var c=document.createEvent("UIEvents");c.initUIEvent("pagechange",
!1,!1,window,0);0<a&&a<=b.length?(b[a-1].updateStats(),this.previousPageNumber=currentPageNumber,currentPageNumber=a,c.pageNumber=a,window.dispatchEvent(c),updateViewarea.inProgress||this.loading&&1==a||b[a-1].scrollIntoView()):(this.previousPageNumber=a,c.pageNumber=this.page,window.dispatchEvent(c))},get page(){return currentPageNumber},get supportsPrinting(){var a="mozPrintCallback"in document.createElement("canvas");Object.defineProperty(this,"supportsPrinting",{value:a,enumerable:!0,configurable:!0,
writable:!1});return a},get supportsFullscreen(){var a=document.documentElement,a=a.requestFullscreen||a.mozRequestFullScreen||a.webkitRequestFullScreen;window.frameElement&&(a=!1);Object.defineProperty(this,"supportsFullScreen",{value:a,enumerable:!0,configurable:!0,writable:!1});return a},get supportsIntegratedFind(){Object.defineProperty(this,"supportsIntegratedFind",{value:!1,enumerable:!0,configurable:!0,writable:!1});return!1},get supportsDocumentFonts(){Object.defineProperty(this,"supportsDocumentFonts",
{value:!0,enumerable:!0,configurable:!0,writable:!1});return!0},get isHorizontalScrollbarEnabled(){var a=document.getElementById("viewerContainer");return a.scrollWidth>a.clientWidth},initPassiveLoading:function(){PDFView.loadingBar||(PDFView.loadingBar=new ProgressBar("#loadingBar",{}));window.addEventListener("message",function(a){var b=a.data;if("object"===typeof b&&"pdfjsLoadAction"in b)switch(b.pdfjsLoadAction){case "progress":PDFView.progress(b.loaded/b.total);break;case "complete":if(!b.data){PDFView.error(mozL10n.get("loading_error",
null,"An error occurred while loading the PDF."),a);break}PDFView.open(b.data,0)}});FirefoxCom.requestSync("initPassiveLoading",null)},setTitleUsingUrl:function(a){this.url=a;try{this.setTitle(decodeURIComponent(getFileName(a))||a)}catch(b){this.setTitle(a)}},setTitle:function(a){document.title=a},open:function(a,b,c){var d={password:c};"string"===typeof a?(this.setTitleUsingUrl(a),d.url=a):a&&"byteLength"in a&&(d.data=a);PDFView.loadingBar||(PDFView.loadingBar=new ProgressBar("#loadingBar",{}));
this.pdfDocument=null;var e=this;e.loading=!0;PDFJS.getDocument(d).then(function(a){e.load(a,b);e.loading=!1},function(d,f){if(f&&"PasswordException"===f.name&&"needpassword"===f.code){var h=mozL10n.get("request_password",null,"PDF is protected by a password:");if((c=prompt(h))&&0<c.length)return PDFView.open(a,b,c)}h=mozL10n.get("loading_error",null,"An error occurred while loading the PDF.");f&&"InvalidPDFException"===f.name&&(h=mozL10n.get("invalid_file_error",null,"Invalid or corrupted PDF file."));
document.getElementById("loading").textContent=mozL10n.get("loading_error_indicator",null,"Error");e.error(h,{message:d});e.loading=!1},function(a){e.progress(a.loaded/a.total)})},download:function(){var a=this.url.split("#")[0];window.open(a+"#pdfjs.action=download","_parent")},fallback:function(){},navigateTo:function(a){"string"===typeof a&&(a=this.destinations[a]);if(a instanceof Array){var b=a[0],b=b instanceof Object?this.pagesRefMap[b.num+" "+b.gen+" R"]:b+1;b>this.pages.length&&(b=this.pages.length);
b&&(this.page=b,this.pages[b-1].scrollIntoView(a))}},getDestinationHash:function(a){if("string"===typeof a)return PDFView.getAnchorUrl("#"+escape(a));if(a instanceof Array){var b=a[0];if(b=b instanceof Object?this.pagesRefMap[b.num+" "+b.gen+" R"]:b+1){var b=PDFView.getAnchorUrl("#page="+b),c=a[1];if("object"===typeof c&&("name"in c&&"XYZ"==c.name)&&(b+="&zoom="+100*(a[4]||this.currentScale),a[2]||a[3]))b+=","+(a[2]||0)+","+(a[3]||0);return b}}return""},getAnchorUrl:function(a){return a},getOutputScale:function(){var a=
"devicePixelRatio"in window?window.devicePixelRatio:1;return{sx:a,sy:a,scaled:1!=a}},error:function(a,b){var c=mozL10n.get("error_version_info",{version:PDFJS.version||"?",build:PDFJS.build||"?"},"PDF.js v{{version}} (build: {{build}})")+"\n";b&&(c+=mozL10n.get("error_message",{message:b.message},"Message: {{message}}"),b.stack?c+="\n"+mozL10n.get("error_stack",{stack:b.stack},"Stack: {{stack}}"):(b.filename&&(c+="\n"+mozL10n.get("error_file",{file:b.filename},"File: {{file}}")),b.lineNumber&&(c+=
"\n"+mozL10n.get("error_line",{line:b.lineNumber},"Line: {{line}}"))));document.getElementById("loadingBox").setAttribute("hidden","true");var d=document.getElementById("errorWrapper");d.removeAttribute("hidden");document.getElementById("errorMessage").textContent=a;document.getElementById("errorClose").onclick=function(){d.setAttribute("hidden","true")};var e=document.getElementById("errorMoreInfo"),j=document.getElementById("errorShowMore"),f=document.getElementById("errorShowLess");j.onclick=function(){e.removeAttribute("hidden");
j.setAttribute("hidden","true");f.removeAttribute("hidden")};f.onclick=function(){e.setAttribute("hidden","true");j.removeAttribute("hidden");f.setAttribute("hidden","true")};j.removeAttribute("hidden");f.setAttribute("hidden","true");e.value=c;e.rows=c.split("\n").length-1},progress:function(a){a=Math.round(100*a);PDFView.loadingBar.percent=a},load:function(a,b){function c(a,b){a.onAfterDraw=function(){b.setImage(a.canvas)}}this.pdfDocument=a;document.getElementById("errorWrapper").setAttribute("hidden",
"true");document.getElementById("loadingBox").setAttribute("hidden","true");document.getElementById("loading").textContent="";var d=document.getElementById("thumbnailView");for(d.parentNode.scrollTop=0;d.hasChildNodes();)d.removeChild(d.lastChild);"_loadingInterval"in d&&clearInterval(d._loadingInterval);for(var e=document.getElementById("viewer");e.hasChildNodes();)e.removeChild(e.lastChild);var j=a.numPages,f=a.fingerprint;document.getElementById("numPages").textContent=mozL10n.get("page_of",{pageCount:j},
"of {{pageCount}}");document.getElementById("pageNumber").max=j;PDFView.documentFingerprint=f;var h=PDFView.store=new Settings(f),f=h.initializedPromise;this.pageRotation=0;var g=this.pages=[];this.pageText=[];this.startedTextExtraction=!1;for(var m={},k=this.thumbnails=[],l=[],n=1;n<=j;n++)l.push(a.getPage(n));var p=this,l=PDFJS.Promise.all(l);l.then(function(a){for(var f=1;f<=j;f++){var h=a[f-1],l=new PageView(e,h,f,b,h.stats,p.navigateTo.bind(p)),n=new ThumbnailView(d,h,f);c(l,n);g.push(l);k.push(n);
h=h.ref;m[h.num+" "+h.gen+" R"]=f}p.pagesRefMap=m});n=a.getDestinations();n.then(function(a){p.destinations=a});PDFJS.Promise.all([l,n,f]).then(function(){a.getOutline().then(function(a){p.outline=new DocumentOutlineView(a)});var c=null;if(h.get("exists",!1))var c=h.get("page","1"),d=h.get("zoom",PDFView.currentScale),e=h.get("scrollLeft","0"),f=h.get("scrollTop","0"),c="page="+c+"&zoom="+d+","+e+","+f;p.setInitialView(c,b)});a.getMetadata().then(function(b){var c=b.info;b=b.metadata;p.documentInfo=
c;p.metadata=b;console.log("PDF "+a.fingerprint+" ["+c.PDFFormatVersion+" "+(c.Producer||"-")+" / "+(c.Creator||"-")+"]"+(PDFJS.version?" (PDF.js: "+PDFJS.version+")":""));var d;b&&b.has("dc:title")&&(d=b.get("dc:title"));!d&&(c&&c.Title)&&(d=c.Title);d&&p.setTitle(d+" - "+document.title)})},setInitialView:function(a,b){this.currentScale=0;this.currentScaleValue=null;this.initialBookmark?(this.setHash(this.initialBookmark),this.initialBookmark=null):a?this.setHash(a):b&&(this.parseScale(b,!0),this.page=
1);PDFView.currentScale===UNKNOWN_SCALE&&this.parseScale(DEFAULT_SCALE,!0)},renderHighestPriority:function(){var a=this.getVisiblePages();(a=this.getHighestPriority(a,this.pages,this.pageViewScroll.down))?this.renderView(a,"page"):this.sidebarOpen&&(a=this.getVisibleThumbs(),(a=this.getHighestPriority(a,this.thumbnails,this.thumbnailViewScroll.down))&&this.renderView(a,"thumbnail"))},getHighestPriority:function(a,b,c){var d=a.views,e=d.length;if(0===e)return!1;for(var j=0;j<e;++j){var f=d[j].view;
if(!this.isViewFinished(f))return f}a=c?a.last.id:a.first.id-2;return b[a]&&!this.isViewFinished(b[a])?b[a]:!1},isViewFinished:function(a){return a.renderingState===RenderingStates.FINISHED},renderView:function(a,b){switch(a.renderingState){case RenderingStates.FINISHED:return!1;case RenderingStates.PAUSED:PDFView.highestPriorityPage=b+a.id;a.resume();break;case RenderingStates.RUNNING:PDFView.highestPriorityPage=b+a.id;break;case RenderingStates.INITIAL:PDFView.highestPriorityPage=b+a.id,a.draw(this.renderHighestPriority.bind(this))}return!0},
setHash:function(a){if(a)if(0<=a.indexOf("=")){var b=PDFView.parseQueryString(a);if("nameddest"in b)PDFView.navigateTo(b.nameddest);else if("page"in b)if(a=b.page|0||1,"zoom"in b){var b=b.zoom.split(","),c=b[0],d=parseFloat(c);d&&(c=d/100);this.pages[a-1].scrollIntoView([null,{name:"XYZ"},b[1]|0,b[2]|0,c])}else this.page=a}else/^\d+$/.test(a)?this.page=a:PDFView.navigateTo(unescape(a))},switchSidebarView:function(a){var b=document.getElementById("thumbnailView"),c=document.getElementById("outlineView"),
d=document.getElementById("viewThumbnail"),e=document.getElementById("viewOutline");switch(a){case "thumbs":a=b.classList.contains("hidden");d.classList.add("toggled");e.classList.remove("toggled");b.classList.remove("hidden");c.classList.add("hidden");PDFView.renderHighestPriority();a&&scrollIntoView(document.getElementById("thumbnailContainer"+this.page));break;case "outline":d.classList.remove("toggled"),e.classList.add("toggled"),b.classList.add("hidden"),c.classList.remove("hidden"),e.getAttribute("disabled")}},
getVisiblePages:function(){return this.getVisibleElements(this.container,this.pages,!0)},getVisibleThumbs:function(){return this.getVisibleElements(this.thumbnailContainer,this.thumbnails)},getVisibleElements:function(a,b,c){for(var d=0,e,j=a.scrollTop,f=1,h=b.length;f<=h;++f){e=b[f-1];d=e.el.offsetTop;if(d+e.el.clientHeight>j)break;d+=e.el.clientHeight}var g=[];if(this.isFullscreen)return c=this.pages[this.page-1],g.push({id:c.id,view:c}),{first:c,last:c,views:g};a=j+a.clientHeight;for(var m,k,l;f<=
h&&d<a;++f)e=b[f-1],l=e.el.clientHeight,d=e.el.offsetTop,m=d+l,k=Math.max(0,j-d)+Math.max(0,m-a),k=Math.floor(100*(l-k)/l),g.push({id:e.id,y:d,view:e,percent:k}),d=m;b=g[0];d=g[g.length-1];c&&g.sort(function(a,b){var c=a.percent-b.percent;return 0.0010<Math.abs(c)?-c:a.id-b.id});return{first:b,last:d,views:g}},parseQueryString:function(a){a=a.split("&");for(var b={},c=0;c<a.length;++c){var d=a[c].split("="),e=1<d.length?d[1]:null;b[unescape(d[0])]=unescape(e)}return b},beforePrint:function(){if(this.supportsPrinting){document.querySelector("body").setAttribute("data-mozPrintCallback",
!0);for(var a=0,b=this.pages.length;a<b;++a)this.pages[a].beforePrint()}else a=mozL10n.get("printing_not_supported",null,"Warning: Printing is not fully supported by this browser."),this.error(a)},afterPrint:function(){for(var a=document.getElementById("printContainer");a.hasChildNodes();)a.removeChild(a.lastChild)},fullscreen:function(){if(document.fullscreenElement||document.mozFullScreen||document.webkitIsFullScreen)return!1;var a=document.getElementById("viewerContainer");if(document.documentElement.requestFullscreen)a.requestFullscreen();
else if(document.documentElement.mozRequestFullScreen)a.mozRequestFullScreen();else if(document.documentElement.webkitRequestFullScreen)a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);else return!1;this.isFullscreen=!0;var b=this.pages[this.page-1];this.previousScale=this.currentScaleValue;this.parseScale("page-fit",!0);setTimeout(function(){b.scrollIntoView()},0);this.showPresentationControls();return!0},exitFullscreen:function(){this.isFullscreen=!1;this.parseScale(this.previousScale);this.page=
this.page;this.clearMouseScrollState();this.hidePresentationControls()},showPresentationControls:function(){var a=document.getElementById("viewerContainer");this.presentationControlsTimeout?clearTimeout(this.presentationControlsTimeout):a.classList.add("presentationControls");this.presentationControlsTimeout=setTimeout(function(){a.classList.remove("presentationControls");delete PDFView.presentationControlsTimeout},3E3)},hidePresentationControls:function(){this.presentationControlsTimeout&&(clearTimeout(this.presentationControlsTimeout),
delete this.presentationControlsTimeout,document.getElementById("viewerContainer").classList.remove("presentationControls"))},rotatePages:function(a){this.pageRotation=(this.pageRotation+360+a)%360;a=0;for(var b=this.pages.length;a<b;a++){var c=this.pages[a];c.update(c.scale,this.pageRotation)}a=0;for(b=this.thumbnails.length;a<b;a++)this.thumbnails[a].updateRotation(this.pageRotation);var d=this.pages[this.page-1];this.parseScale(this.currentScaleValue,!0);this.renderHighestPriority();setTimeout(function(){d.scrollIntoView()},
0)},mouseScroll:function(a){var b=(new Date).getTime(),c=this.mouseScrollTimeStamp;b>c&&50>b-c||((0<this.mouseScrollDelta&&0>a||0>this.mouseScrollDelta&&0<a)&&this.clearMouseScrollState(),this.mouseScrollDelta+=a,120<=Math.abs(this.mouseScrollDelta)&&(a=0<this.mouseScrollDelta?-1:1,this.clearMouseScrollState(),c=this.page,1==c&&-1==a||c==this.pages.length&&1==a||(this.page+=a,this.mouseScrollTimeStamp=b)))},clearMouseScrollState:function(){this.mouseScrollDelta=this.mouseScrollTimeStamp=0}},PageView=
function(a,b,c,d){this.id=c;this.pdfPage=b;this.rotation=0;this.scale=d||1;this.viewport=this.pdfPage.getViewport(this.scale,this.pdfPage.rotate);this.renderingState=RenderingStates.INITIAL;this.textLayer=this.textContent=this.resume=null;c=document.createElement("a");c.name=""+this.id;var e=this.el=document.createElement("div");e.id="pageContainer"+this.id;e.className="page";e.style.width=Math.floor(this.viewport.width)+"px";e.style.height=Math.floor(this.viewport.height)+"px";a.appendChild(c);a.appendChild(e);
this.destroy=function(){this.update();this.pdfPage.destroy()};this.update=function(a,b){this.renderingState=RenderingStates.INITIAL;this.resume=null;"undefined"!==typeof b&&(this.rotation=b);this.scale=a||this.scale;var c=this.pdfPage.getViewport(this.scale,(this.rotation+this.pdfPage.rotate)%360);this.viewport=c;e.style.width=Math.floor(c.width)+"px";for(e.style.height=Math.floor(c.height)+"px";e.hasChildNodes();)e.removeChild(e.lastChild);e.removeAttribute("data-loaded");delete this.canvas;this.loadingIconDiv=
document.createElement("div");this.loadingIconDiv.className="loadingIcon";e.appendChild(this.loadingIconDiv)};Object.defineProperty(this,"width",{get:function(){return this.viewport.width},enumerable:!0});Object.defineProperty(this,"height",{get:function(){return this.viewport.height},enumerable:!0});this.getPagePoint=function(a,b){return this.viewport.convertToPdfPoint(a,b)};this.scrollIntoView=function(a){if(a){var b=0,c=0,d=0,m=0,k;k=0;switch(a[1].name){case "XYZ":b=a[2];c=a[3];k=a[4];break;case "Fit":case "FitB":k=
"page-fit";break;case "FitH":case "FitBH":c=a[2];k="page-width";break;case "FitV":case "FitBV":b=a[2];k="page-height";break;case "FitR":b=a[2];c=a[3];d=a[4]-b;m=a[5]-c;a=(this.container.clientWidth-SCROLLBAR_PADDING)/d/CSS_UNITS;k=(this.container.clientHeight-SCROLLBAR_PADDING)/m/CSS_UNITS;k=Math.min(a,k);break;default:return}k&&k!==PDFView.currentScale?PDFView.parseScale(k,!0,!0):PDFView.currentScale===UNKNOWN_SCALE&&PDFView.parseScale(DEFAULT_SCALE,!0,!0);var l=[this.viewport.convertToViewportPoint(b,
c),this.viewport.convertToViewportPoint(b+d,c+m)];setTimeout(function(){var a=Math.min(l[0][0],l[1][0]),b=Math.min(l[0][1],l[1][1]),c=Math.abs(l[0][0]-l[1][0]),d=Math.abs(l[0][1]-l[1][1]);scrollIntoView(e,{left:a,top:b,width:c,height:d})},0)}else scrollIntoView(e)};this.getTextContent=function(){this.textContent||(this.textContent=this.pdfPage.getTextContent());return this.textContent};this.draw=function(a){function c(d){n.renderingState=RenderingStates.FINISHED;n.loadingIconDiv&&(e.removeChild(n.loadingIconDiv),
delete n.loadingIconDiv);d&&PDFView.error(mozL10n.get("rendering_error",null,"An error occurred while rendering the page."),d);n.stats=b.stats;n.updateStats();if(n.onAfterDraw)n.onAfterDraw();cache.push(n);a()}this.renderingState!==RenderingStates.INITIAL&&error("Must be in new state before drawing");this.renderingState=RenderingStates.RUNNING;var d=document.createElement("canvas");d.id="page"+this.id;d.mozOpaque=!0;e.appendChild(d);this.canvas=d;var g=null;PDFJS.disableTextLayer||(g=document.createElement("div"),
g.className="textLayer",e.appendChild(g));var m=this.textLayer=g?new TextLayerBuilder(g,this.id-1):null,k=this.viewport,l=PDFView.getOutputScale();d.width=Math.floor(k.width)*l.sx;d.height=Math.floor(k.height)*l.sy;l.scaled&&(k="scale("+1/l.sx+", "+1/l.sy+")",CustomStyle.setProp("transform",d,k),CustomStyle.setProp("transformOrigin",d,"0% 0%"),g&&(CustomStyle.setProp("transform",g,k),CustomStyle.setProp("transformOrigin",g,"0% 0%")));g=d.getContext("2d");g.save();g.fillStyle="rgb(255, 255, 255)";
g.fillRect(0,0,d.width,d.height);g.restore();l.scaled&&g.scale(l.sx,l.sy);var n=this;this.pdfPage.render({canvasContext:g,viewport:this.viewport,textLayer:m,continueCallback:function(a){PDFView.highestPriorityPage!=="page"+n.id?(n.renderingState=RenderingStates.PAUSED,n.resume=function(){n.renderingState=RenderingStates.RUNNING;a()}):a()}}).then(function(){c(null)},function(a){c(a)});m&&this.getTextContent().then(function(a){m.setTextContent(a)});var p=this.viewport,q=function(a,b){a.href=PDFView.getDestinationHash(b);
a.onclick=function(){b&&PDFView.navigateTo(b);return!1}},r=function(a,b,c){c||(c=p.convertToViewportRectangle(b.rect),c=PDFJS.Util.normalizeRect(c));a=document.createElement(a);a.style.left=Math.floor(c[0])+"px";a.style.top=Math.floor(c[1])+"px";a.style.width=Math.ceil(c[2]-c[0])+"px";a.style.height=Math.ceil(c[3]-c[1])+"px";return a},s=function(a){var b=document.createElement("section");b.className="annotText";var c=p.convertToViewportRectangle(a.rect),c=PDFJS.Util.normalizeRect(c);c[3]-c[1]<ANNOT_MIN_SIZE&&
(c[3]=c[1]+ANNOT_MIN_SIZE);c[2]-c[0]<ANNOT_MIN_SIZE&&(c[2]=c[0]+(c[3]-c[1]));var d=r("img",a,c),e=a.name;d.src=IMAGE_DIR+"annotation-"+e.toLowerCase()+".svg";d.alt=mozL10n.get("text_annotation_type",{type:e},"[{{type}} Annotation]");var f=document.createElement("div");f.setAttribute("hidden",!0);var e=document.createElement("h1"),j=document.createElement("p");f.style.left=Math.floor(c[2])+"px";f.style.top=Math.floor(c[1])+"px";e.textContent=a.title;if(!a.content&&!a.title)f.setAttribute("hidden",
!0);else{c=document.createElement("span");a=a.content.split(/(?:\r\n?|\n)/);for(var h=0,g=a.length;h<g;++h)c.appendChild(document.createTextNode(a[h])),h<g-1&&c.appendChild(document.createElement("br"));j.appendChild(c);d.addEventListener("mouseover",function(){f.removeAttribute("hidden")},!1);d.addEventListener("mouseout",function(){f.setAttribute("hidden",!0)},!1)}f.appendChild(e);f.appendChild(j);b.appendChild(d);b.appendChild(f);return b};this.pdfPage.getAnnotations().then(function(a){for(var b=
0;b<a.length;b++){var c=a[b];switch(c.type){case "Link":var d=r("a",c);d.href=c.url||"";c.url||q(d,"dest"in c?c.dest:null);e.appendChild(d);break;case "Text":(c=s(c))&&e.appendChild(c);break;case "Widget":PDFView.fallback()}}});e.setAttribute("data-loaded",!0)};this.beforePrint=function(){var a=this.pdfPage,b=a.getViewport(1),c=this.canvas=document.createElement("canvas");c.width=2*Math.floor(b.width);c.height=2*Math.floor(b.height);c.style.width=2*b.width+"pt";c.style.height=2*b.height+"pt";CustomStyle.setProp("transform",
c,"scale(0.5, 0.5)");CustomStyle.setProp("transformOrigin",c,"0% 0%");document.getElementById("printContainer").appendChild(c);var d=this;c.mozPrintCallback=function(e){var k=e.context;k.save();k.fillStyle="rgb(255, 255, 255)";k.fillRect(0,0,c.width,c.height);k.restore();k.scale(2,2);a.render({canvasContext:k,viewport:b}).then(function(){e.done();d.pdfPage.destroy()},function(a){console.error(a);"abort"in object?e.abort():e.done();d.pdfPage.destroy()})}};this.updateStats=function(){PDFJS.pdfBug&&
Stats.enabled&&Stats.add(this.id,this.stats)}},ThumbnailView=function(a,b,c){function d(){var a=document.createElement("canvas");a.id="thumbnail"+c;a.mozOpaque=!0;a.width=k;a.height=l;a.className="thumbnailImage";a.setAttribute("aria-label",mozL10n.get("thumb_page_canvas",{page:c},"Thumbnail of Page {{page}}"));p.setAttribute("data-loaded",!0);q.appendChild(a);a=a.getContext("2d");a.save();a.fillStyle="rgb(255, 255, 255)";a.fillRect(0,0,k,l);a.restore();return a}var e=document.createElement("a");
e.href=PDFView.getAnchorUrl("#page="+c);e.title=mozL10n.get("thumb_page_title",{page:c},"Page {{page}}");e.onclick=function(){PDFView.page=c;return!1};var j=0,f=(j+b.rotate)%360,h=b.getViewport(1,f),g=this.width=h.width,m=this.height=h.height;this.id=c;var k=98,l=k/this.width*this.height,n=this.scaleX=k/g;this.scaleY=l/m;var p=this.el=document.createElement("div");p.id="thumbnailContainer"+c;p.className="thumbnail";1===c&&p.classList.add("selected");var q=document.createElement("div");q.className=
"thumbnailSelectionRing";q.style.width=k+"px";q.style.height=l+"px";p.appendChild(q);e.appendChild(p);a.appendChild(e);this.hasImage=!1;this.renderingState=RenderingStates.INITIAL;this.updateRotation=function(a){j=a;f=(j+b.rotate)%360;h=b.getViewport(1,f);g=this.width=h.width;m=this.height=h.height;l=k/this.width*this.height;n=this.scaleX=k/g;this.scaleY=l/m;p.removeAttribute("data-loaded");q.textContent="";q.style.width=k+"px";q.style.height=l+"px";this.hasImage=!1;this.renderingState=RenderingStates.INITIAL;
this.resume=null};this.drawingRequired=function(){return!this.hasImage};this.draw=function(a){this.renderingState!==RenderingStates.INITIAL&&error("Must be in new state before drawing");this.renderingState=RenderingStates.RUNNING;if(this.hasImage)a();else{var c=this,e=d(),j=b.getViewport(n,f);b.render({canvasContext:e,viewport:j,continueCallback:function(a){PDFView.highestPriorityPage!=="thumbnail"+c.id?(c.renderingState=RenderingStates.PAUSED,c.resume=function(){c.renderingState=RenderingStates.RUNNING;
a()}):a()}}).then(function(){c.renderingState=RenderingStates.FINISHED;a()},function(){c.renderingState=RenderingStates.FINISHED;a()});this.hasImage=!0}};this.setImage=function(a){if(!this.hasImage&&a){this.renderingState=RenderingStates.FINISHED;var b=d();b.drawImage(a,0,0,a.width,a.height,0,0,b.canvas.width,b.canvas.height);this.hasImage=!0}}},DocumentOutlineView=function(a){function b(a,b){a.href=PDFView.getDestinationHash(b.dest);a.onclick=function(){PDFView.navigateTo(b.dest);return!1}}for(var c=
document.getElementById("outlineView");c.firstChild;)c.removeChild(c.firstChild);if(a)for(c=[{parent:c,items:a}];0<c.length;){a=c.shift();var d,e=a.items.length;for(d=0;d<e;d++){var j=a.items[d],f=document.createElement("div");f.className="outlineItem";var h=document.createElement("a");b(h,j);h.textContent=j.title;f.appendChild(h);0<j.items.length&&(h=document.createElement("div"),h.className="outlineItems",f.appendChild(h),c.push({parent:h,items:j.items}));a.parent.appendChild(f)}}else a=document.createElement("div"),
a.classList.add("noOutline"),a.textContent=mozL10n.get("no_outline",null,"No Outline Available"),c.appendChild(a)},CustomStyle=function(){function a(){}var b=["ms","Moz","Webkit","O"],c={};a.getProp=function(a,e){if(1==arguments.length&&"string"==typeof c[a])return c[a];e=e||document.documentElement;var j=e.style,f,h;if("string"==typeof j[a])return c[a]=a;h=a.charAt(0).toUpperCase()+a.slice(1);for(var g=0,m=b.length;g<m;g++)if(f=b[g]+h,"string"==typeof j[f])return c[a]=f;return c[a]="undefined"};
a.setProp=function(a,b,c){a=this.getProp(a);"undefined"!=a&&(b.style[a]=c)};return a}(),TextLayerBuilder=function(a,b){var c=document.createDocumentFragment();this.textLayerDiv=a;this.divContentDone=this.layoutDone=!1;this.pageIdx=b;this.matches=[];this.beginLayout=function(){this.textDivs=[];this.textLayerQueue=[];this.renderingDone=!1};this.endLayout=function(){this.layoutDone=!0;this.insertDivContent()};this.renderLayer=function(){var a=this.textDivs,b=this.textLayerDiv,j=document.createElement("canvas").getContext("2d");
if(!(1E5<a.length)){for(var f=0,h=a.length;f<h;f++){var g=a[f];c.appendChild(g);j.font=g.style.fontSize+" "+g.style.fontFamily;var m=j.measureText(g.textContent).width;0<m&&(CustomStyle.setProp("transform",g,"scale("+g.dataset.canvasWidth/m+", 1)"),CustomStyle.setProp("transformOrigin",g,"0% 0%"),b.appendChild(g))}this.renderingDone=!0;this.updateMatches();b.appendChild(c)}};this.setupRenderLayoutTimer=function(){var a=this;200<Date.now()-PDFView.lastScroll?this.renderLayer():(this.renderTimer&&clearTimeout(this.renderTimer),
this.renderTimer=setTimeout(function(){a.setupRenderLayoutTimer()},200))};this.appendText=function(a){var b=document.createElement("div"),c=a.fontSize*a.vScale;b.dataset.canvasWidth=a.canvasWidth*a.hScale;b.dataset.fontName=a.fontName;b.style.fontSize=c+"px";b.style.fontFamily=a.fontFamily;b.style.left=a.x+"px";b.style.top=a.y-c+"px";this.textDivs.push(b)};this.insertDivContent=function(){if(this.layoutDone&&!this.divContentDone&&this.textContent){this.divContentDone=!0;for(var a=this.textDivs,b=
this.textContent.bidiTexts,c=0;c<b.length;c++){var f=b[c],h=a[c];h.textContent=f.str;h.dir=f.ltr?"ltr":"rtl"}this.setupRenderLayoutTimer()}};this.setTextContent=function(a){this.textContent=a;this.insertDivContent()};this.convertMatches=function(a){for(var b=0,c=0,f=this.textContent.bidiTexts,h=f.length-1,g=PDFFindController.state.query.length,m=[],k=0;k<a.length;k++){for(var l=a[k];b!==h&&l>=c+f[b].str.length;)c+=f[b].str.length,b++;b==f.length&&console.error("Could not find matching mapping");for(var n=
{begin:{divIdx:b,offset:l-c}},l=l+g;b!==h&&l>c+f[b].str.length;)c+=f[b].str.length,b++;n.end={divIdx:b,offset:l-c};m.push(n)}return m};this.renderMatches=function(a){function b(a,c){var d=a.divIdx,e=h[d];e.textContent="";var g=f[d].str.substring(0,a.offset),g=document.createTextNode(g);if(c){var d=m&&d===k,j=document.createElement("span");j.className=c+(d?" selected":"");j.appendChild(g);e.appendChild(j)}else e.appendChild(g)}function c(a,b,d){var e=a.divIdx,g=h[e];a=f[e].str.substring(a.offset,b.offset);
a=document.createTextNode(a);d?(b=document.createElement("span"),b.className=d,b.appendChild(a),g.appendChild(b)):g.appendChild(a)}if(0!==a.length){var f=this.textContent.bidiTexts,h=this.textDivs,g=null,m=this.pageIdx===PDFFindController.selected.pageIdx,k=PDFFindController.selected.matchIdx,l={divIdx:-1,offset:void 0},n=k,p=n+1;if(PDFFindController.state.highlightAll)n=0,p=a.length;else if(!m)return;for(;n<p;n++){var q=a[n],r=q.begin,q=q.end,s=m&&n===k,t=s?" selected":"";s&&scrollIntoView(h[r.divIdx],
{top:-50});!g||r.divIdx!==g.divIdx?(null!==g&&c(g,l),b(r)):c(g,r);if(r.divIdx===q.divIdx)c(r,q,"highlight"+t);else{c(r,l,"highlight begin"+t);for(g=r.divIdx+1;g<q.divIdx;g++)h[g].className="highlight middle"+t;b(q,"highlight end"+t)}g=q}g&&c(g,l)}};this.updateMatches=function(){if(this.renderingDone){for(var a=this.matches,b=this.textDivs,c=this.textContent.bidiTexts,f=-1,h=0;h<a.length;h++){for(var g=a[h],f=Math.max(f,g.begin.divIdx);f<=g.end.divIdx;f++){var m=b[f];m.textContent=c[f].str;m.className=
""}f=g.end.divIdx+1}PDFFindController.active&&(this.matches=this.convertMatches(PDFFindController.pageMatches[this.pageIdx]||[]),this.renderMatches(this.matches))}}};
document.addEventListener("DOMContentLoaded",function(){PDFView.initialize();var a=PDFView.parseQueryString(document.location.search.substring(1)).file||DEFAULT_URL;window.File&&(window.FileReader&&window.FileList&&window.Blob)&&(document.getElementById("fileInput").value=null);var b=document.location.hash.substring(1),b=PDFView.parseQueryString(b);"disableWorker"in b&&(PDFJS.disableWorker="true"===b.disableWorker);var c=navigator.language;"locale"in b&&(c=b.locale);mozL10n.setLanguage(c);if("textLayer"in
b)switch(b.textLayer){case "off":PDFJS.disableTextLayer=!0;break;case "visible":case "shadow":case "hover":document.getElementById("viewer").classList.add("textLayer-"+b.textLayer)}"pdfBug"in b&&(PDFJS.pdfBug=!0,b=b.pdfBug.split(","),PDFBug.enable(b),PDFBug.init());PDFView.supportsPrinting||document.getElementById("print").classList.add("hidden");PDFView.supportsFullscreen||document.getElementById("fullscreen").classList.add("hidden");PDFView.supportsIntegratedFind&&document.querySelector("#viewFind").classList.add("hidden");
PDFJS.LogManager.addLogger({warn:function(){PDFView.fallback()}});var d=document.getElementById("mainContainer"),e=document.getElementById("outerContainer");d.addEventListener("transitionend",function(a){a.target==d&&(a=document.createEvent("UIEvents"),a.initUIEvent("resize",!1,!1,window,0),window.dispatchEvent(a),e.classList.remove("sidebarMoving"))},!0);document.getElementById("sidebarToggle").addEventListener("click",function(){this.classList.toggle("toggled");e.classList.add("sidebarMoving");
e.classList.toggle("sidebarOpen");PDFView.sidebarOpen=e.classList.contains("sidebarOpen");PDFView.renderHighestPriority()});document.getElementById("viewThumbnail").addEventListener("click",function(){PDFView.switchSidebarView("thumbs")});document.getElementById("viewOutline").addEventListener("click",function(){PDFView.switchSidebarView("outline")});document.getElementById("previous").addEventListener("click",function(){PDFView.page--});document.getElementById("next").addEventListener("click",function(){PDFView.page++});
document.querySelector(".zoomIn").addEventListener("click",function(){PDFView.zoomIn()});document.querySelector(".zoomOut").addEventListener("click",function(){PDFView.zoomOut()});document.getElementById("fullscreen").addEventListener("click",function(){PDFView.fullscreen()});document.getElementById("print").addEventListener("click",function(){window.print()});document.getElementById("pageNumber").addEventListener("change",function(){PDFView.page=this.value});document.getElementById("scaleSelect").addEventListener("change",
function(){PDFView.parseScale(this.value)});document.getElementById("first_page").addEventListener("click",function(){PDFView.page=1});document.getElementById("last_page").addEventListener("click",function(){PDFView.page=PDFView.pdfDocument.numPages});document.getElementById("page_rotate_ccw").addEventListener("click",function(){PDFView.rotatePages(-90)});document.getElementById("page_rotate_cw").addEventListener("click",function(){PDFView.rotatePages(90)});PDFView.open(a,0)},!0);
function updateViewarea(){if(PDFView.initialized){var a=PDFView.getVisiblePages(),b=a.views;if(0!==b.length){PDFView.renderHighestPriority();for(var c=PDFView.page,a=a.first,d=0,e=b.length,j=!1;d<e;++d){var f=b[d];if(100>f.percent)break;if(f.id===PDFView.page){j=!0;break}}j||(c=b[0].id);PDFView.isFullscreen||(updateViewarea.inProgress=!0,PDFView.page=c,updateViewarea.inProgress=!1);var b=PDFView.currentScale,c=PDFView.currentScaleValue,h=c==b?100*b:c,g=a.id,b="#page="+g+("&zoom="+h),m=PDFView.pages[g-
1].getPagePoint(PDFView.container.scrollLeft,PDFView.container.scrollTop-a.y),b=b+(","+Math.round(m[0])+","+Math.round(m[1])),k=PDFView.store;k.initializedPromise.then(function(){k.set("exists",!0);k.set("page",g);k.set("zoom",h);k.set("scrollLeft",Math.round(m[0]));k.set("scrollTop",Math.round(m[1]))});PDFView.getAnchorUrl(b)}}}
window.addEventListener("resize",function(){PDFView.initialized&&(document.getElementById("pageWidthOption").selected||document.getElementById("pageFitOption").selected||document.getElementById("pageAutoOption").selected)&&PDFView.parseScale(document.getElementById("scaleSelect").value);updateViewarea()});window.addEventListener("hashchange",function(){PDFView.setHash(document.location.hash.substring(1))});
window.addEventListener("change",function(a){var b=a.target.files;b&&0!=b.length&&(a=new FileReader,a.onload=function(a){a=new Uint8Array(a.target.result);PDFView.open(a,0)},b=b[0],a.readAsArrayBuffer(b),PDFView.setTitleUsingUrl(b.name))},!0);function selectScaleOption(a){for(var b=document.getElementById("scaleSelect").options,c=!1,d=0;d<b.length;d++){var e=b[d];e.value!=a?e.selected=!1:c=e.selected=!0}return c}
window.addEventListener("localized",function(){document.getElementsByTagName("html")[0].dir=mozL10n.getDirection()},!0);
window.addEventListener("scalechange",function(a){var b=document.getElementById("customScaleOption");b.selected=!1;if((a.resetAutoSettings||!document.getElementById("pageWidthOption").selected&&!document.getElementById("pageFitOption").selected&&!document.getElementById("pageAutoOption").selected)&&!selectScaleOption(""+a.scale))b.textContent=Math.round(1E4*a.scale)/100+"%",b.selected=!0;updateViewarea()},!0);
window.addEventListener("pagechange",function(a){a=a.pageNumber;if(PDFView.previousPageNumber!==a){document.getElementById("pageNumber").value=a;var b=document.querySelector(".thumbnail.selected");b&&b.classList.remove("selected");b=document.getElementById("thumbnailContainer"+a);b.classList.add("selected");var c=PDFView.getVisibleThumbs(),d=c.views.length;if(0<d){var e=c.first.id,c=1<d?c.last.id:e;(a<=e||a>=c)&&scrollIntoView(b)}}document.getElementById("previous").disabled=1>=a;document.getElementById("next").disabled=
a>=PDFView.pages.length},!0);window.addEventListener("DOMMouseScroll",function(a){if(a.ctrlKey){a.preventDefault();var b=a.detail;a=0<b?"zoomOut":"zoomIn";for(var c=0,b=Math.abs(b);c<b;c++)PDFView[a]()}else PDFView.isFullscreen&&PDFView.mouseScroll(-40*a.detail)},!1);window.addEventListener("mousemove",function(){PDFView.isFullscreen&&PDFView.showPresentationControls()},!1);window.addEventListener("mousedown",function(a){PDFView.isFullscreen&&0===a.button&&(a.preventDefault(),PDFView.page++)},!1);
window.addEventListener("keydown",function(a){var b=!1,c=(a.ctrlKey?1:0)|(a.altKey?2:0)|(a.shiftKey?4:0)|(a.metaKey?8:0);if(1==c||8==c)switch(a.keyCode){case 70:PDFView.supportsIntegratedFind||(PDFFindBar.toggle(),b=!0);break;case 61:case 107:case 187:case 171:PDFView.zoomIn();b=!0;break;case 173:case 109:case 189:PDFView.zoomOut();b=!0;break;case 48:case 96:PDFView.parseScale(DEFAULT_SCALE,!0),b=!0}if(1==c||8==c||5==c||12==c)switch(a.keyCode){case 71:PDFView.supportsIntegratedFind||(PDFFindBar.dispatchEvent("again",
5==c||12==c),b=!0)}if(b)a.preventDefault();else{var d=document.activeElement;if(!d||!("INPUT"==d.tagName||"SELECT"==d.tagName)){for(var e=document.getElementById("toolbar");d;){if(d===e&&!PDFView.isFullscreen)return;d=d.parentNode}if(0==c)switch(a.keyCode){case 38:case 33:case 8:if(!PDFView.isFullscreen&&"page-fit"!==PDFView.currentScaleValue)break;case 37:if(PDFView.isHorizontalScrollbarEnabled)break;case 75:case 80:PDFView.page--;b=!0;break;case 40:case 34:case 32:if(!PDFView.isFullscreen&&"page-fit"!==
PDFView.currentScaleValue)break;case 39:if(PDFView.isHorizontalScrollbarEnabled)break;case 74:case 78:PDFView.page++;b=!0;break;case 36:PDFView.isFullscreen&&(PDFView.page=1,b=!0);break;case 35:PDFView.isFullscreen&&(PDFView.page=PDFView.pdfDocument.numPages,b=!0);break;case 82:PDFView.rotatePages(90)}if(4==c)switch(a.keyCode){case 82:PDFView.rotatePages(-90)}b&&(a.preventDefault(),PDFView.clearMouseScrollState())}}});window.addEventListener("beforeprint",function(){PDFView.beforePrint()});
window.addEventListener("afterprint",function(){PDFView.afterPrint()});(function(){function a(){!document.fullscreenElement&&(!document.mozFullScreen&&!document.webkitIsFullScreen)&&PDFView.exitFullscreen()}window.addEventListener("fullscreenchange",a,!1);window.addEventListener("mozfullscreenchange",a,!1);window.addEventListener("webkitfullscreenchange",a,!1)})();